Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
whmcs-coza-epp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gunter Grodotzki
whmcs-coza-epp
Commits
00436127
Commit
00436127
authored
12 years ago
by
Nigel Kukard
Browse files
Options
Downloads
Patches
Plain Diff
Added much better error handling for widget
parent
301795dc
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/widgets/cozaepp_balance.php
+15
-12
15 additions, 12 deletions
modules/widgets/cozaepp_balance.php
with
15 additions
and
12 deletions
modules/widgets/cozaepp_balance.php
+
15
−
12
View file @
00436127
...
...
@@ -36,27 +36,32 @@
# http://allworldit.com
## VERSION: 0.1.0 ##
# Function to implement the cozaepp balance widget
function
widget_cozaepp_balance
(
$vars
)
{
# Setup include dir
$include_path
=
ROOTDIR
.
'/modules/registrars/cozaepp'
;
set_include_path
(
get_
include_path
()
.
PATH_SEPARATOR
.
$
include_path
);
set_include_path
(
$
include_path
.
PATH_SEPARATOR
.
get_
include_path
()
);
# Include EPP stuff we need
require_once
'cozaepp.php'
;
# Include registrar functions aswell
require
ROOTDIR
.
'/includes/registrarfunctions.php'
;
require_once
ROOTDIR
.
'/includes/registrarfunctions.php'
;
# We need pear for the error handling
require_once
"PEAR.php"
;
# Grab module parameters
$params
=
getregistrarconfigoptions
(
'cozaepp'
);
$title
=
"COZA Balance"
;
# Set widget contents
$title
=
"COZA EPP Balance"
;
$template
=
'<p align = "center" class="textblack"><strong>%s</strong></p>'
;
# Request balance from registrar
$client
=
_cozaepp_Client
();
if
(
PEAR
::
isError
(
$client
=
_cozaepp_Client
()))
{
return
array
(
'title'
=>
$title
,
'content'
=>
sprintf
(
$template
,
"ERROR: "
.
$client
->
getMessage
()));
}
$output
=
$client
->
request
(
'
<epp:epp xmlns:epp="urn:ietf:params:xml:ns:epp-1.0" xmlns:contact="urn:ietf:params:xml:ns:contact-1.0"
xmlns:cozacontact="http://co.za/epp/extensions/cozacontact-1-0">
...
...
@@ -80,14 +85,12 @@ function widget_cozaepp_balance($vars) {
$doc
->
loadXML
(
$output
);
$coderes
=
$doc
->
getElementsByTagName
(
'result'
)
->
item
(
0
)
->
getAttribute
(
'code'
);
if
(
$coderes
==
'1000'
)
{
$balance
=
$doc
->
getElementsByTagName
(
'balance'
)
->
item
(
0
)
->
nodeValue
;
$balance
str
=
"Current registrar balance is R "
.
$doc
->
getElementsByTagName
(
'balance'
)
->
item
(
0
)
->
nodeValue
;
}
else
{
$balance
=
'
-
ERROR
-
'
;
$balance
str
=
'ERROR
: Parsing
'
;
}
$content
=
'<p align = "center" class="textblack"><strong>Current registrar balance is R '
.
$balance
.
'</strong></p>'
;
return
array
(
'title'
=>
$title
,
'content'
=>
$content
);
return
array
(
'title'
=>
$title
,
'content'
=>
sprintf
(
$template
,
$balancestr
));
}
add_hook
(
"AdminHomeWidgets"
,
1
,
"widget_cozaepp_balance"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment