traceEnd() public static method

This method is used to indicate the end of the execution of a function in debug mode.
public static traceEnd ( string $res = '' ) : void
$res string the result of the function
return void
Ejemplo n.º 1
0
 /**
  * Send the request and store the results.
  *
  * @return bool true on success, false on failure.
  */
 protected function sendRequest()
 {
     phpCAS::traceBegin();
     /*********************************************************
      * initialize the CURL session
      *********************************************************/
     $ch = $this->_initAndConfigure();
     /*********************************************************
      * Perform the query
      *********************************************************/
     $buf = curl_exec($ch);
     if ($buf === false) {
         phpCAS::trace('curl_exec() failed');
         $this->storeErrorMessage('CURL error #' . curl_errno($ch) . ': ' . curl_error($ch));
         $res = false;
     } else {
         $this->storeResponseBody($buf);
         phpCAS::trace("Response Body: \n" . $buf . "\n");
         $res = true;
     }
     // close the CURL session
     curl_close($ch);
     phpCAS::traceEnd($res);
     return $res;
 }
Ejemplo n.º 2
0
 /**
  * Send the request and store the results.
  *
  * @return bool true on success, false on failure.
  */
 protected function sendRequest()
 {
     phpCAS::traceBegin();
     /*********************************************************
      * initialize the CURL session
      *********************************************************/
     $ch = $this->_initAndConfigure();
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     phpCAS::log(var_dump($ch) . ' [' . basename($dbg[0]['file']) . ':' . $dbg[0]['line'] . ']');
     /*********************************************************
      * Perform the query
      *********************************************************/
     $buf = curl_exec($ch);
     if ($buf === false) {
         phpCAS::trace('curl_exec() failed');
         $this->storeErrorMessage('CURL error #' . curl_errno($ch) . ': ' . curl_error($ch));
         $res = false;
     } else {
         $this->storeResponseBody($buf);
         phpCAS::trace("Response Body: \n" . $buf . "\n");
         $res = true;
     }
     // close the CURL session
     curl_close($ch);
     phpCAS::traceEnd($res);
     return $res;
 }
Ejemplo n.º 3
0
 /**
  * The constructor of the class, should be called only by inherited classes.
  *
  * @param CAS_Client $cas_parent the CAS _client instance that creates the
  * current object.
  *
  * @return void
  *
  * @protected
  */
 function __construct($cas_parent)
 {
     phpCAS::traceBegin();
     if (!$cas_parent->isProxy()) {
         phpCAS::error('defining PGT storage makes no sense when not using a CAS proxy');
     }
     phpCAS::traceEnd();
 }
Ejemplo n.º 4
0
 public function getSambaProxyTicket()
 {
     phpCAS::traceBegin();
     if ($this->hasGot()) {
         throw new CAS_OutOfSequenceException('Cannot set the URL, request already sent.');
     }
     $this->count = 1;
     $this->initializeProxyTicket();
     phpCAS::traceEnd();
     return $this->getProxyTicket();
 }
Ejemplo n.º 5
0
 /**
  * Set the fixed URL that will be set as the CAS service parameter. When this
  * method is not called, a phpCAS script uses its own URL.
  *
  * @param $url the URL
  */
 function setFixedServiceURL($url)
 {
     global $PHPCAS_CLIENT;
     phpCAS::traceBegin();
     if (!is_object($PHPCAS_CLIENT)) {
         phpCAS::error('this method should only be called after ' . __CLASS__ . '::proxy()');
     }
     if (gettype($url) != 'string') {
         phpCAS::error('type mismatched for parameter $url (should be `string\')');
     }
     $PHPCAS_CLIENT->setURL($url);
     phpCAS::traceEnd();
 }
Ejemplo n.º 6
0
 /**
  * Send the request and store the results.
  *
  * @return boolean TRUE on success, FALSE on failure.
  */
 protected function _sendRequest()
 {
     phpCAS::traceBegin();
     /*********************************************************
      * initialize the CURL session
      *********************************************************/
     $ch = curl_init($this->url);
     if (version_compare(PHP_VERSION, '5.1.3', '>=')) {
         //only avaible in php5
         curl_setopt_array($ch, $this->curlOptions);
     } else {
         foreach ($this->curlOptions as $key => $value) {
             curl_setopt($ch, $key, $value);
         }
     }
     /*********************************************************
      * Set SSL configuration
      *********************************************************/
     if ($this->caCertPath) {
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
         curl_setopt($ch, CURLOPT_CAINFO, $this->caCertPath);
         phpCAS::trace('CURL: Set CURLOPT_CAINFO');
     } else {
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     }
     /*********************************************************
      * Configure curl to capture our output.
      *********************************************************/
     // return the CURL output into a variable
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     // get the HTTP header with a callback
     curl_setopt($ch, CURLOPT_HEADERFUNCTION, array($this, '_curlReadHeaders'));
     /*********************************************************
      * Add cookie headers to our request.
      *********************************************************/
     if (count($this->cookies)) {
         $cookieStrings = array();
         foreach ($this->cookies as $name => $val) {
             $cookieStrings[] = $name . '=' . $val;
         }
         curl_setopt($ch, CURLOPT_COOKIE, implode(';', $cookieStrings));
     }
     /*********************************************************
      * Add any additional headers
      *********************************************************/
     if (count($this->headers)) {
         curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);
     }
     /*********************************************************
      * Flag and Body for POST requests
      *********************************************************/
     if ($this->isPost) {
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $this->postBody);
     }
     /*********************************************************
      * Perform the query
      *********************************************************/
     $buf = curl_exec($ch);
     if ($buf === FALSE) {
         phpCAS::trace('curl_exec() failed');
         $this->storeErrorMessage('CURL error #' . curl_errno($ch) . ': ' . curl_error($ch));
         $res = FALSE;
     } else {
         $this->storeResponseBody($buf);
         phpCAS::trace("Response Body: \n" . $buf . "\n");
         $res = TRUE;
     }
     // close the CURL session
     curl_close($ch);
     phpCAS::traceEnd($res);
     return $res;
 }
Ejemplo n.º 7
0
 /**
  * This method returns the URL of the current request (without any ticket
  * CGI parameter).
  *
  * @return The URL
  */
 private function getURL()
 {
     phpCAS::traceBegin();
     // the URL is built when needed only
     if (empty($this->_url)) {
         $final_uri = '';
         # Forcing base url if specified explicitly
         if ($this->_service_base_url != null) {
             $final_uri .= $this->_service_base_url;
         } else {
             $final_uri = $this->isHttps() ? 'https' : 'http';
             $final_uri .= '://';
             $final_uri .= $this->getServerUrl();
         }
         $request_uri = explode('?', $_SERVER['REQUEST_URI'], 2);
         $final_uri .= $request_uri[0];
         if (isset($request_uri[1]) && $request_uri[1]) {
             $query_string = $this->removeParameterFromQueryString('ticket', $request_uri[1]);
             // If the query string still has anything left, append it to the final URI
             if ($query_string !== '') {
                 $final_uri .= "?{$query_string}";
             }
         }
         phpCAS::trace("Final URI: {$final_uri}");
         $this->setURL($final_uri);
     }
     phpCAS::traceEnd($this->_url);
     return $this->_url;
 }
Ejemplo n.º 8
0
 /**
  * Parse Cookies without PECL
  * From the comments in http://php.net/manual/en/function.http-parse-cookie.php
  * @param array $header 	An array of header lines.
  * @param string $defaultDomain 	The domain to use if none is specified in the cookie.
  * @return array of cookies
  */
 protected function parseCookieHeaders($header, $defaultDomain)
 {
     phpCAS::traceBegin();
     $cookies = array();
     foreach ($header as $line) {
         if (preg_match('/^Set-Cookie2?: /i', $line)) {
             $cookies[] = $this->parseCookieHeader($line, $defaultDomain);
         }
     }
     phpCAS::traceEnd($cookies);
     return $cookies;
 }
Ejemplo n.º 9
0
 /**
  * This method is used to logout from CAS. Halts by redirecting to the CAS server.
  * @param $url a URL that will be transmitted to the CAS server (to come back to when logged out)
  */
 function logout($url = "")
 {
     global $PHPCAS_CLIENT;
     phpCAS::traceBegin();
     if (!is_object($PHPCAS_CLIENT)) {
         phpCAS::error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()');
     }
     $PHPCAS_CLIENT->logout($url);
     // never reached
     phpCAS::traceEnd();
 }
Ejemplo n.º 10
0
 /**
  * The class constructor, called by CASClient::SetPGTStorageDB().
  *
  * @param $cas_parent the CASClient instance that creates the object.
  * @param $user the user to access the data with
  * @param $password the user's password
  * @param $database_type the type of the database hosting the data
  * @param $hostname the server hosting the database
  * @param $port the port the server is listening on
  * @param $database the name of the database
  * @param $table the name of the table storing the data
  *
  * @public
  */
 function PGTStorageDB($cas_parent, $user, $password, $database_type, $hostname, $port, $database, $table)
 {
     phpCAS::traceBegin();
     // call the ancestor's constructor
     $this->PGTStorage($cas_parent);
     if (empty($database_type)) {
         $database_type = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE_TYPE;
     }
     if (empty($hostname)) {
         $hostname = CAS_PGT_STORAGE_DB_DEFAULT_HOSTNAME;
     }
     if ($port == 0) {
         $port = CAS_PGT_STORAGE_DB_DEFAULT_PORT;
     }
     if (empty($database)) {
         $database = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE;
     }
     if (empty($table)) {
         $table = CAS_PGT_STORAGE_DB_DEFAULT_TABLE;
     }
     // build and store the PEAR DB URL
     $this->_url = $database_type . ':' . '//' . $user . ':' . $password . '@' . $server . ':' . $port . '/' . $database;
     // XXX should use setURL and setTable
     phpCAS::traceEnd();
 }
Ejemplo n.º 11
0
 /**
  * Change CURL options.
  * CURL is used to connect through HTTPS to CAS server
  * @param $key the option key
  * @param $value the value to set
  */
 function setExtraCurlOption($key, $value)
 {
     global $PHPCAS_CLIENT;
     phpCAS::traceBegin();
     if (!is_object($PHPCAS_CLIENT)) {
         phpCAS::error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()');
     }
     $PHPCAS_CLIENT->setExtraCurlOption($key, $value);
     phpCAS::traceEnd();
 }
Ejemplo n.º 12
0
 /**
  * This method returns the URL of the current request (without any ticket
  * CGI parameter).
  *
  * @return The URL
  *
  * @private
  */
 function getURL()
 {
     phpCAS::traceBegin();
     // the URL is built when needed only
     if (empty($this->_url)) {
         $final_uri = '';
         // remove the ticket if present in the URL
         $final_uri = $this->isHttps() ? 'https' : 'http';
         $final_uri .= '://';
         /* replaced by Julien Marchal - v0.4.6
          * $this->_url .= $_SERVER['SERVER_NAME'];
          */
         if (empty($_SERVER['HTTP_X_FORWARDED_SERVER'])) {
             /* replaced by teedog - v0.4.12
              * $this->_url .= $_SERVER['SERVER_NAME'];
              */
             if (empty($_SERVER['SERVER_NAME'])) {
                 $server_name = $_SERVER['HTTP_HOST'];
             } else {
                 $server_name = $_SERVER['SERVER_NAME'];
             }
         } else {
             $server_name = $_SERVER['HTTP_X_FORWARDED_SERVER'];
         }
         $final_uri .= $server_name;
         if (!strpos($server_name, ':')) {
             if ($this->isHttps() && $_SERVER['SERVER_PORT'] != 443 || !$this->isHttps() && $_SERVER['SERVER_PORT'] != 80) {
                 $final_uri .= ':';
                 $final_uri .= $_SERVER['SERVER_PORT'];
             }
         }
         $baseurl = explode("?", $_SERVER['REQUEST_URI'], 2);
         $final_uri .= $baseurl[0];
         $query_string = '';
         if ($_GET) {
             $kv = array();
             foreach ($_GET as $key => $value) {
                 if ($key !== "ticket") {
                     $kv[] = urlencode($key) . "=" . urlencode($value);
                 }
             }
             $query_string = join("&", $kv);
         }
         if ($query_string) {
             $final_uri .= "?" . $query_string;
         }
         $this->setURL($final_uri);
     }
     phpCAS::traceEnd($this->_url);
     return $this->_url;
 }
Ejemplo n.º 13
0
 /**
  * This method reads a PGT corresponding to a PGT Iou and deletes the 
  * corresponding file.
  *
  * @param $pgt_iou the PGT iou
  *
  * @return the corresponding PGT, or FALSE on error
  *
  * @public
  */
 function read($pgt_iou)
 {
     phpCAS::traceBegin();
     $pgt = FALSE;
     $fname = $this->getPGTIouFilename($pgt_iou);
     if (file_exists($fname)) {
         if (!($f = fopen($fname, "r"))) {
             phpCAS::trace('could not open `' . $fname . '\'');
         } else {
             if (($pgt = fgets($f)) === FALSE) {
                 phpCAS::trace('could not read PGT from `' . $fname . '\'');
             }
             fclose($f);
         }
         // delete the PGT file
         @unlink($fname);
     } else {
         phpCAS::trace('No such file `' . $fname . '\'');
     }
     phpCAS::traceEnd($pgt);
     return $pgt;
 }
Ejemplo n.º 14
0
 /**
  * Validate the proxies from the proxy ticket validation against the
  * chains that were definded.
  *
  * @param array $list List of proxies from the proxy ticket validation.
  *
  * @return if any chain fully matches the supplied list
  */
 public function contains(array $list)
 {
     phpCAS::traceBegin();
     $count = 0;
     foreach ($this->_chains as $chain) {
         phpCAS::trace("Checking chain " . $count++);
         if ($chain->matches($list)) {
             phpCAS::traceEnd(true);
             return true;
         }
     }
     phpCAS::trace("No proxy chain matches.");
     phpCAS::traceEnd(false);
     return false;
 }
Ejemplo n.º 15
0
 /**
  * This method reads a PGT corresponding to a PGT Iou and deletes the
  * corresponding db entry.
  *
  * @param string $pgt_iou the PGT iou
  *
  * @return the corresponding PGT, or FALSE on error
  */
 public function read($pgt_iou)
 {
     phpCAS::traceBegin();
     $pgt = false;
     // initialize the PDO object for this method
     $pdo = $this->_getPdo();
     $this->_setErrorMode();
     try {
         $pdo->beginTransaction();
         // fetch the pgt for the specified pgt_iou
         $query = $pdo->prepare($this->retrievePgtSql());
         $query->bindValue(':pgt_iou', $pgt_iou, PDO::PARAM_STR);
         $query->execute();
         $pgt = $query->fetchColumn(0);
         $query->closeCursor();
         // delete the specified pgt_iou from the database
         $query = $pdo->prepare($this->deletePgtSql());
         $query->bindValue(':pgt_iou', $pgt_iou, PDO::PARAM_STR);
         $query->execute();
         $query->closeCursor();
         $pdo->commit();
     } catch (PDOException $e) {
         // attempt rolling back the transaction before throwing a phpCAS error
         try {
             $pdo->rollBack();
         } catch (PDOException $e) {
         }
         phpCAS::trace('error reading PGT from database: ' . $e->getMessage());
     }
     // reset the PDO object
     $this->_resetErrorMode();
     phpCAS::traceEnd();
     return $pgt;
 }
Ejemplo n.º 16
0
 /**
  * This method returns the URL of the current request (without any ticket
  * CGI parameter).
  *
  * @return The URL
  *
  * @private
  */
 function getURL()
 {
     phpCAS::traceBegin();
     // the URL is built when needed only
     if (empty($this->_url)) {
         $final_uri = '';
         // remove the ticket if present in the URL
         $final_uri = $this->isHttps() ? 'https' : 'http';
         $final_uri .= '://';
         /* replaced by Julien Marchal - v0.4.6
          * $this->_url .= $_SERVER['SERVER_NAME'];
          */
         if (empty($_SERVER['HTTP_X_FORWARDED_SERVER'])) {
             /* replaced by teedog - v0.4.12
              * $this->_url .= $_SERVER['SERVER_NAME'];
              */
             if (empty($_SERVER['SERVER_NAME'])) {
                 $server_name = $_SERVER['HTTP_HOST'];
             } else {
                 $server_name = $_SERVER['SERVER_NAME'];
             }
         } else {
             $server_name = $_SERVER['HTTP_X_FORWARDED_SERVER'];
         }
         $final_uri .= $server_name;
         if (!strpos($server_name, ':')) {
             if ($this->isHttps() && $_SERVER['SERVER_PORT'] != 443 || !$this->isHttps() && $_SERVER['SERVER_PORT'] != 80) {
                 $final_uri .= ':';
                 $final_uri .= $_SERVER['SERVER_PORT'];
             }
         }
         $request_uri = explode('?', $_SERVER['REQUEST_URI'], 2);
         $final_uri .= $request_uri[0];
         if (isset($request_uri[1]) && $request_uri[1]) {
             $query_string = $this->removeParameterFromQueryString('ticket', $request_uri[1]);
             // If the query string still has anything left, append it to the final URI
             if ($query_string !== '') {
                 $final_uri .= "?{$query_string}";
             }
         }
         phpCAS::trace("Final URI: {$final_uri}");
         $this->setURL($final_uri);
     }
     phpCAS::traceEnd($this->_url);
     return $this->_url;
 }
Ejemplo n.º 17
0
	/**
	 * This method returns the URL of the current request (without any ticket
	 * CGI parameter).
	 *
	 * @return The URL
	 */
	private function getURL()
	{
		phpCAS::traceBegin();
		// the URL is built when needed only
		if ( empty($this->_url) ) {
			$final_uri = '';
			// remove the ticket if present in the URL
			$final_uri = ($this->isHttps()) ? 'https' : 'http';
			$final_uri .= '://';

			$final_uri .= $this->getServerUrl();
			$request_uri	= explode('?', $_SERVER['REQUEST_URI'], 2);
			$final_uri		.= $request_uri[0];
				
			if (isset($request_uri[1]) && $request_uri[1])
			{
				$query_string	= $this->removeParameterFromQueryString('ticket', $request_uri[1]);

				// If the query string still has anything left, append it to the final URI
				if ($query_string !== '')
				$final_uri	.= "?$query_string";

			}
				
			phpCAS::trace("Final URI: $final_uri");
			$this->setURL($final_uri);
		}
		phpCAS::traceEnd($this->_url);
		return $this->_url;
	}
Ejemplo n.º 18
0
 /**
  * Renaming the session
  */
 private function renameSession($ticket)
 {
     phpCAS::traceBegin();
     if ($this->_start_session) {
         if (!empty($this->_user)) {
             $old_session = $_SESSION;
             session_destroy();
             // set up a new session, of name based on the ticket
             $session_id = preg_replace('/[^\\w]/', '', $ticket);
             phpCAS::trace("Session ID: " . $session_id);
             session_id($session_id);
             session_start();
             phpCAS::trace("Restoring old session vars");
             $_SESSION = $old_session;
         } else {
             phpCAS::error('Session should only be renamed after successfull authentication');
         }
     } else {
         phpCAS::trace("Skipping session rename since phpCAS is not handling the session.");
     }
     phpCAS::traceEnd();
 }
Ejemplo n.º 19
0
 /**
  * This method is used to add header parameters when rebroadcasting
  * pgtIou/pgtId or logoutRequest.
  *
  * @param String $header Header to send when rebroadcasting.
  *
  * @return void
  */
 public static function addRebroadcastHeader($header)
 {
     phpCAS::traceBegin();
     phpCAS::_validateClientExists();
     try {
         self::$_PHPCAS_CLIENT->addRebroadcastHeader($header);
     } catch (Exception $e) {
         phpCAS::error(get_class($e) . ': ' . $e->getMessage());
     }
     phpCAS::traceEnd();
 }
Ejemplo n.º 20
0
 /**
  * Perform the request.
  *
  * @return void
  * @throws CAS_OutOfSequenceException If called multiple times.
  * @throws CAS_ProxyTicketException If there is a proxy-ticket failure.
  *		The code of the Exception will be one of:
  *			PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE
  *			PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE
  *			PHPCAS_SERVICE_PT_FAILURE
  * @throws CAS_ProxiedService_Exception If there is a failure sending the
  * request to the target service.
  */
 public function send()
 {
     if ($this->hasBeenSent()) {
         throw new CAS_OutOfSequenceException('Cannot send, request already sent.');
     }
     phpCAS::traceBegin();
     // Get our proxy ticket and append it to our URL.
     $this->initializeProxyTicket();
     $url = $this->getServiceUrl();
     if (strstr($url, '?') === false) {
         $url = $url . '?ticket=' . $this->getProxyTicket();
     } else {
         $url = $url . '&ticket=' . $this->getProxyTicket();
     }
     try {
         $this->makeRequest($url);
     } catch (Exception $e) {
         phpCAS::traceEnd();
         throw $e;
     }
 }
Ejemplo n.º 21
0
Archivo: CAS.php Proyecto: rhertzog/lcs
 /**
  * This method is used to add header parameters when rebroadcasting
  * pgtIou/pgtId or logoutRequest.
  *
  * @param String $header Header to send when rebroadcasting.
  *
  * @return void
  */
 public static function addRebroadcastHeader($header)
 {
     phpCAS::traceBegin();
     if (!is_object(self::$_PHPCAS_CLIENT)) {
         phpCAS::error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()');
     }
     self::$_PHPCAS_CLIENT->addRebroadcastHeader($header);
     phpCAS::traceEnd();
 }
Ejemplo n.º 22
0
 /**
  * Open the IMAP stream (similar to imap_open()).
  *
  * @return resource Returns an IMAP stream on success
  * @throws CAS_OutOfSequenceException If called multiple times.
  * @throws CAS_ProxyTicketException If there is a proxy-ticket failure.
  *		The code of the Exception will be one of:
  *			PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE
  *			PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE
  *			PHPCAS_SERVICE_PT_FAILURE
  * @throws CAS_ProxiedService_Exception If there is a failure sending the request to the target service.	 */
 public function open()
 {
     if ($this->hasBeenOpened()) {
         throw new CAS_OutOfSequenceException('Stream already opened.');
     }
     if (empty($this->_mailbox)) {
         throw new CAS_ProxiedService_Exception('You must specify a mailbox via ' . get_class($this) . '->setMailbox($mailbox)');
     }
     phpCAS::traceBegin();
     // Get our proxy ticket and append it to our URL.
     $this->initializeProxyTicket();
     phpCAS::trace('opening IMAP mailbox `' . $this->_mailbox . '\'...');
     $this->_stream = @imap_open($this->_mailbox, $this->_username, $this->getProxyTicket(), $this->_options);
     if ($this->_stream) {
         phpCAS::trace('ok');
     } else {
         phpCAS::trace('could not open mailbox');
         // @todo add localization integration.
         $message = 'IMAP Error: ' . $url . ' ' . var_export(imap_errors(), true);
         phpCAS::trace($message);
         throw new CAS_ProxiedService_Exception($message);
     }
     phpCAS::traceEnd();
     return $this->_stream;
 }
Ejemplo n.º 23
0
 /**
  * This method rebroadcasts logout/pgtIou requests. Can be LOGOUT,PGTIOU
  *
  * @param int $type type of rebroadcasting.
  *
  * @return void
  */
 private function _rebroadcast($type)
 {
     phpCAS::traceBegin();
     $rebroadcast_curl_options = array(CURLOPT_FAILONERROR => 1, CURLOPT_FOLLOWLOCATION => 1, CURLOPT_RETURNTRANSFER => 1, CURLOPT_CONNECTTIMEOUT => 1, CURLOPT_TIMEOUT => 4);
     // Try to determine the IP address of the server
     if (!empty($_SERVER['SERVER_ADDR'])) {
         $ip = $_SERVER['SERVER_ADDR'];
     } else {
         if (!empty($_SERVER['LOCAL_ADDR'])) {
             // IIS 7
             $ip = $_SERVER['LOCAL_ADDR'];
         }
     }
     // Try to determine the DNS name of the server
     if (!empty($ip)) {
         $dns = gethostbyaddr($ip);
     }
     $multiClassName = 'CAS_Request_CurlMultiRequest';
     $multiRequest = new $multiClassName();
     for ($i = 0; $i < sizeof($this->_rebroadcast_nodes); $i++) {
         if ($this->_getNodeType($this->_rebroadcast_nodes[$i]) == self::HOSTNAME && !empty($dns) && stripos($this->_rebroadcast_nodes[$i], $dns) === false || $this->_getNodeType($this->_rebroadcast_nodes[$i]) == self::IP && !empty($ip) && stripos($this->_rebroadcast_nodes[$i], $ip) === false) {
             phpCAS::trace('Rebroadcast target URL: ' . $this->_rebroadcast_nodes[$i] . $_SERVER['REQUEST_URI']);
             $className = $this->_requestImplementation;
             $request = new $className();
             $url = $this->_rebroadcast_nodes[$i] . $_SERVER['REQUEST_URI'];
             $request->setUrl($url);
             if (count($this->_rebroadcast_headers)) {
                 $request->addHeaders($this->_rebroadcast_headers);
             }
             $request->makePost();
             if ($type == self::LOGOUT) {
                 // Logout request
                 $request->setPostBody('rebroadcast=false&logoutRequest=' . $_POST['logoutRequest']);
             } else {
                 if ($type == self::PGTIOU) {
                     // pgtIou/pgtId rebroadcast
                     $request->setPostBody('rebroadcast=false');
                 }
             }
             $request->setCurlOptions($rebroadcast_curl_options);
             $multiRequest->addRequest($request);
         } else {
             phpCAS::trace('Rebroadcast not sent to self: ' . $this->_rebroadcast_nodes[$i] . ' == ' . (!empty($ip) ? $ip : '') . '/' . (!empty($dns) ? $dns : ''));
         }
     }
     // We need at least 1 request
     if ($multiRequest->getNumRequests() > 0) {
         $multiRequest->send();
     }
     phpCAS::traceEnd();
 }
Ejemplo n.º 24
0
 /**
  * This method returns the URL of the current request (without any ticket
  * CGI parameter).
  *
  * @return The URL
  *
  * @private
  */
 function getURL()
 {
     phpCAS::traceBegin();
     // the URL is built when needed only
     if (empty($this->_url)) {
         $final_uri = '';
         // remove the ticket if present in the URL
         $final_uri = $this->isHttps() ? 'https' : 'http';
         $final_uri .= '://';
         /* replaced by Julien Marchal - v0.4.6
          * $this->_url .= $_SERVER['SERVER_NAME'];
          */
         if (empty($_SERVER['HTTP_X_FORWARDED_SERVER'])) {
             /* replaced by teedog - v0.4.12
              * $this->_url .= $_SERVER['SERVER_NAME'];
              */
             if (empty($_SERVER['SERVER_NAME'])) {
                 $server_name = $_SERVER['HTTP_HOST'];
             } else {
                 $server_name = $_SERVER['SERVER_NAME'];
             }
         } else {
             $server_name = $_SERVER['HTTP_X_FORWARDED_SERVER'];
         }
         $final_uri .= $server_name;
         if (!strpos($server_name, ':')) {
             if ($this->isHttps() && $_SERVER['SERVER_PORT'] != 443 || !$this->isHttps() && $_SERVER['SERVER_PORT'] != 80) {
                 $final_uri .= ':';
                 $final_uri .= $_SERVER['SERVER_PORT'];
             }
         }
         $final_uri .= strtok($_SERVER['REQUEST_URI'], "?");
         $cgi_params = '?' . strtok("?");
         // remove the ticket if present in the CGI parameters
         $cgi_params = preg_replace('/&ticket=[^&]*/', '', $cgi_params);
         $cgi_params = preg_replace('/\\?ticket=[^&;]*/', '?', $cgi_params);
         //Mike DiTore wants to get rid of the ?login flag if present
         $cgi_params = preg_replace('/&login[^&]*/', '', $cgi_params);
         $cgi_params = preg_replace('/\\?login[^&;]*/', '?', $cgi_params);
         //end mike
         $cgi_params = preg_replace('/\\?%26/', '?', $cgi_params);
         $cgi_params = preg_replace('/\\?&/', '?', $cgi_params);
         $cgi_params = preg_replace('/\\?$/', '', $cgi_params);
         $final_uri .= $cgi_params;
         $this->setURL($final_uri);
     }
     phpCAS::traceEnd($this->_url);
     return $this->_url;
 }
Ejemplo n.º 25
0
 /**
  * This method returns the URL of the current request (without any ticket
  * CGI parameter).
  *
  * @return The URL
  *
  * @private
  */
 function getURL()
 {
     phpCAS::traceBegin();
     // the URL is built when needed only
     if (empty($this->_url)) {
         $final_uri = '';
         // remove the ticket if present in the URL
         $final_uri = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';
         $final_uri .= '://';
         /* replaced by Julien Marchal - v0.4.6
          * $this->_url .= $_SERVER['SERVER_NAME'];
          */
         if (empty($_SERVER['HTTP_X_FORWARDED_SERVER'])) {
             /* replaced by teedog - v0.4.12
              * $this->_url .= $_SERVER['SERVER_NAME'];
              */
             if (empty($_SERVER['SERVER_NAME'])) {
                 $final_uri .= $_SERVER['HTTP_HOST'];
             } else {
                 $final_uri .= $_SERVER['SERVER_NAME'];
             }
         } else {
             $final_uri .= $_SERVER['HTTP_X_FORWARDED_SERVER'];
         }
         if ($_SERVER['HTTPS'] == 'on' && $_SERVER['SERVER_PORT'] != 443 || $_SERVER['HTTPS'] != 'on' && $_SERVER['SERVER_PORT'] != 80) {
             $final_uri .= ':';
             $final_uri .= $_SERVER['SERVER_PORT'];
         }
         $final_uri .= strtok($_SERVER['REQUEST_URI'], "?");
         $cgi_params = '?' . strtok("?");
         // remove the ticket if present in the CGI parameters
         $cgi_params = preg_replace('/&ticket=[^&]*/', '', $cgi_params);
         $cgi_params = preg_replace('/\\?ticket=[^&;]*/', '?', $cgi_params);
         $cgi_params = preg_replace('/\\?$/', '', $cgi_params);
         $final_uri .= $cgi_params;
         $this->setURL($final_uri);
     }
     phpCAS::traceEnd($this->_url);
     return $this->_url;
 }
Ejemplo n.º 26
0
 /**
  * This method returns the URL of the current request (without any ticket
  * CGI parameter).
  *
  * @return The URL
  *
  * @private
  */
 function getURL()
 {
     phpCAS::traceBegin();
     // the URL is built when needed only
     if (empty($this->_url)) {
         $final_uri = '';
         // remove the ticket if present in the URL
         $final_uri = $this->isHttps() ? 'https' : 'http';
         $final_uri .= '://';
         /* replaced by Julien Marchal - v0.4.6
          * $this->_url .= $_SERVER['SERVER_NAME'];
          */
         if (empty($_SERVER['HTTP_X_FORWARDED_SERVER'])) {
             /* replaced by teedog - v0.4.12
              * $this->_url .= $_SERVER['SERVER_NAME'];
              */
             if (empty($_SERVER['SERVER_NAME'])) {
                 $server_name = $_SERVER['HTTP_HOST'];
             } else {
                 $server_name = $_SERVER['SERVER_NAME'];
             }
         } else {
             $server_name = $_SERVER['HTTP_X_FORWARDED_SERVER'];
         }
         $final_uri .= $server_name;
         if (!strpos($server_name, ':')) {
             if ($this->isHttps() && $_SERVER['SERVER_PORT'] != 443 || !$this->isHttps() && $_SERVER['SERVER_PORT'] != 80) {
                 $final_uri .= ':';
                 $final_uri .= $_SERVER['SERVER_PORT'];
             }
         }
         $php_is_for_sissies = split("\\?", $_SERVER['REQUEST_URI'], 2);
         $final_uri .= $php_is_for_sissies[0];
         if (sizeof($php_is_for_sissies) > 1) {
             $cgi_params = '?' . $php_is_for_sissies[1];
         } else {
             $cgi_params = '?';
         }
         // remove the ticket if present in the CGI parameters
         $cgi_params = preg_replace('/&ticket=[^&]*/', '', $cgi_params);
         $cgi_params = preg_replace('/\\?ticket=[^&;]*/', '?', $cgi_params);
         $cgi_params = preg_replace('/\\?%26/', '?', $cgi_params);
         $cgi_params = preg_replace('/\\?&/', '?', $cgi_params);
         $cgi_params = preg_replace('/\\?$/', '', $cgi_params);
         $final_uri .= $cgi_params;
         $this->setURL($final_uri);
     }
     phpCAS::traceEnd($this->_url);
     return $this->_url;
 }