コード例 #1
0
ファイル: NXAuth.php プロジェクト: nitroxy/nxauth
 public static function logout($return_uri = "")
 {
     $options = "";
     /* default value in phpCAS */
     $host = (!empty($_SERVER['HTTPS']) ? "https://" : "http://" . $_SERVER['HTTP_HOST']) . '/';
     if (strpos($return_uri, "http") === 0) {
         $host = "";
     }
     if ($return_uri !== null) {
         $return_uri = trim($return_uri, '/');
         $options = array('service' => "{$host}{$return_uri}");
     }
     phpCAS::logout($options);
     NXAPI::clear_cache();
 }
コード例 #2
0
ファイル: NXAPI.php プロジェクト: nitroxy/nxauth
 public static function __callStatic($func, $arguments)
 {
     if (self::$private_key == null) {
         throw new NXAPIError(NXAPIError::MISSING_CONFIGURATION, "No API key found, can't use API");
     } else {
         if (self::$key_id == null) {
             throw new NXAPIError(NXAPIError::MISSING_CONFIGURATION, "No API key id found, can't use API");
         } else {
             $options = isset($arguments[0]) ? $arguments[0] : array();
             $cache_string = self::cache_string($func, $options);
             if (isset($_SESSION['nxapi_cache'][$cache_string])) {
                 return $_SESSION['nxapi_cache'][$cache_string];
             }
             for ($try = 0; $try < 2; ++$try) {
                 list($data, $body) = NXAPI::request_data(array('function' => $func, 'arguments' => $options));
                 if (!$data) {
                     throw new NXAPIError(NXAPIError::GOT_NULL, "NXAPI: Got null", $body);
                 }
                 if ($data->status == "SEQERR") {
                 } else {
                     break;
                 }
             }
             if ($data->status == "OK") {
                 $_SESSION['nxapi_cache'][$cache_string] = $data->data;
                 return $data->data;
             } else {
                 if ($data->status == "SEQERR") {
                     throw new NXAPIError(NXAPIError::SEQUENCE_ERROR, $data->message, $body);
                 } else {
                     throw new NXAPIError(NXAPIError::SERVER_ERROR, $data->message, $body);
                 }
             }
         }
     }
 }