public static function log($str)
{
$indent_str = ".";
if (!empty(self::$_PHPCAS_DEBUG['filename'])) {
// Check if file exists and modifiy file permissions to be only
// readable by the webserver
if (!file_exists(self::$_PHPCAS_DEBUG['filename'])) {
touch(self::$_PHPCAS_DEBUG['filename']);
// Chmod will fail on windows
@chmod(self::$_PHPCAS_DEBUG['filename'], 0600);
}
for ($i = 0; $i < self::$_PHPCAS_DEBUG['indent']; $i++) {
$indent_str .= '| ';
}
// allow for multiline output with proper identing. Usefull for
// dumping cas answers etc.
$str2 = str_replace("\n", "\n" . self::$_PHPCAS_DEBUG['unique_id'] . ' ' . $indent_str, $str);
error_log(self::$_PHPCAS_DEBUG['unique_id'] . ' ' . $indent_str . $str2 . "\n", 3, self::$_PHPCAS_DEBUG['filename']);
}
}
/** * 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; }