diff options
| author | Christopher Burger <burgerc@freeside.biz> | 2018-01-16 12:14:54 -0500 |
|---|---|---|
| committer | Christopher Burger <burgerc@freeside.biz> | 2018-09-11 11:40:59 -0400 |
| commit | 76a893c2187f59e7fdb9bc8282b780efd9dd8504 (patch) | |
| tree | bbdbab4dc1df7ff44fa607162a00f38ab74a1b4e /min_selfservice/freeside.class.php | |
| parent | e55e22e00eba74f2713b52fccbbb380f454531f4 (diff) | |
RT# 39340 - Created minimal selfservice that only allows payments to be made, authorization is based on ip and mac address. This is not done yet need to write routine to get mac address from radius server based on ip address.
Diffstat (limited to 'min_selfservice/freeside.class.php')
| -rw-r--r-- | min_selfservice/freeside.class.php | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/min_selfservice/freeside.class.php b/min_selfservice/freeside.class.php new file mode 100644 index 000000000..ee77ce016 --- /dev/null +++ b/min_selfservice/freeside.class.php @@ -0,0 +1,74 @@ +<?php + +#pre-php 5.4 compatible version? +function flatten($hash) { + if ( !is_array($hash) ) return $hash; + $flat = array(); + + array_walk($hash, function($value, $key, &$to) { + array_push($to, $key, $value); + }, $flat); + + if ( PHP_VERSION_ID >= 50400 ) { + + #php 5.4+ (deb 7+) + foreach ($hash as $key => $value) { + $flat[] = $key; + $flat[] = $value; + } + + } + + return($flat); +} + +#php 5.4+? +#function flatten($hash) { +# if ( !is_array($hash) ) return $hash; +# +# $flat = array(); +# +# foreach ($hash as $key => $value) { +# $flat[] = $key; +# $flat[] = $value; +# } +# +# return($flat); +#} + +class FreesideSelfService { + + //Change this to match the location of your selfservice xmlrpc.cgi or daemon + #var $URL = 'https://localhost/selfservice/xmlrpc.cgi'; + #var $URL = 'http://localhost/selfservice/xmlrpc.cgi'; + var $URL = 'http://localhost:8080/'; + + function FreesideSelfService() { + $this; + } + + public function __call($name, $arguments) { + + error_log("[FreesideSelfService] $name called, sending to ". $this->URL); + + $request = xmlrpc_encode_request("FS.ClientAPI_XMLRPC.$name", flatten($arguments[0])); + $context = stream_context_create( array( 'http' => array( + 'method' => "POST", + 'header' => "Content-Type: text/xml", + 'content' => $request + ))); + $file = file_get_contents($this->URL, false, $context); + $response = xmlrpc_decode($file); + // uncomment to trace everything + //error_log(print_r($response, true)); + if (xmlrpc_is_fault($response)) { + trigger_error("[FreesideSelfService] XML-RPC communication error: $response[faultString] ($response[faultCode])"); + } else { + //error_log("[FreesideSelfService] $response"); + return $response; + } + } + +} + +?> |
