X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=fs_selfservice%2Fwordpress%2Ffreeside_selfservice.php;h=852c22e75eafc693406254bfa9f819498c6eb429;hb=b5e8459bb1b5775edb0f55b05a9a7b1021b49621;hp=5fe7aa789580c13153bc251778f50ffb673b2d6a;hpb=6e1fafd27404892ea9b138b880bc2879d9273c9e;p=freeside.git diff --git a/fs_selfservice/wordpress/freeside_selfservice.php b/fs_selfservice/wordpress/freeside_selfservice.php index 5fe7aa789..852c22e75 100644 --- a/fs_selfservice/wordpress/freeside_selfservice.php +++ b/fs_selfservice/wordpress/freeside_selfservice.php @@ -5,7 +5,7 @@ Plugin URI: http://freeside.biz/freeside Description: Call the Freeside signup and self-service APIs from within Wordpress Version: 0.20170417 Author: Freeside Internet Services, Inc. -Author URI: https://freeside.biz/freeside/ +Author URI: http://freeside.biz/freeside/ License URI: https://www.gnu.org/licenses/gpl-3.0.html Text Domain: freeside_selfserivce Domain Path: /languages @@ -46,12 +46,23 @@ function freeside_server_input() { //TODO: remove freeside_server on uninstall function freeside_init() { - //error_log("FINALLY action run ". $FREESIDE_PROCESS_LOGIN); - //error_log($GLOBALS['$FREESIDE_PROCESS_LOGIN']); + if ( $GLOBALS['FREESIDE_PROCESS_LOGOUT'] ) { + $GLOBALS['FREESIDE_PROCESS_LOGOUT'] = false; + + $freeside = new FreesideSelfService(); + $response = $freeside->logout( array( + 'session_id' => $_COOKIE['freeside_session_id'], + ) ); + setcookie('freeside_session_id', '', time() - 3600); + $error = $response['error']; + if ( $error ) { + error_log("Logout error: $error"); + } + return; + } + if ( ! $GLOBALS['FREESIDE_PROCESS_LOGIN'] ) { -error_log("DACOOKIE: ". $_COOKIE['freeside_session_id']); - $GLOBALS['FREESIDE_SESSION_ID'] = $_COOKIE['freeside_session_id']; return; } else { $GLOBALS['FREESIDE_PROCESS_LOGIN'] = false; @@ -77,11 +88,12 @@ error_log("DACOOKIE: ". $_COOKIE['freeside_session_id']); $url .= $_SERVER['SERVER_NAME']; $url .= $_SERVER['REQUEST_URI']; - wp_redirect(dirname($url). '/example_login.php?username='. urlencode($_POST['freeside_username']). - '&domain='. urlencode($_POST['freeside_domain']). - '&email='. urlencode($_POST['freeside_email']). - '&freeside_error='. urlencode($error) - ); + wp_redirect(dirname($url). '/example_login.php?'. + 'username='. urlencode($_POST['freeside_username']). + '&domain='. urlencode($_POST['freeside_domain']). + '&email='. urlencode($_POST['freeside_email']). + '&freeside_error='. urlencode($error) + ); exit; } @@ -90,11 +102,7 @@ error_log("DACOOKIE: ". $_COOKIE['freeside_session_id']); $session_id = $response['session_id']; - error_log("[login] logged into freeside with session_id=$freeside_session_id, setting cookie"); - -// now what? for now, always redirect to the main page (or the select a -// customer diversion). -// eventually, other options? + //error_log("[login] logged into freeside with session_id=$freeside_session_id, setting cookie"); setcookie('freeside_session_id', $session_id); @@ -127,7 +135,7 @@ class FreesideSelfService { public function __call($name, $arguments) { $URL = 'http://'. get_option('freeside_server'). ':8080'; - error_log("[FreesideSelfService] $name called, sending to ". $URL); + //error_log("[FreesideSelfService] $name called, sending to ". $URL); $request = xmlrpc_encode_request("FS.ClientAPI_XMLRPC.$name", freeside_flatten($arguments[0])); $context = stream_context_create( array( 'http' => array( @@ -137,7 +145,7 @@ class FreesideSelfService { ))); $file = file_get_contents($URL, false, $context); $response = xmlrpc_decode($file); - if (xmlrpc_is_fault($response)) { + if (isset($response) && xmlrpc_is_fault($response)) { trigger_error("[FreesideSelfService] XML-RPC communication error: $response[faultString] ($response[faultCode])"); } else { //error_log("[FreesideSelfService] $response");