| verzia 1.40, 2002/09/04 02:28:14 |
verzia 1.41, 2002/09/05 01:27:31 |
|
|
| * cleared by clearAllProperties(), but IDs wasn't |
* cleared by clearAllProperties(), but IDs wasn't |
| * - little method reorganization around manipulation with props |
* - little method reorganization around manipulation with props |
| * - code cleanup |
* - code cleanup |
| |
* 05/09/2002 - remoteLog() method used for remote logging via HTTP POST |
| |
* request method implemented |
| |
* - remote-log.php script added into utils/ subdirectory |
| |
* - method setValues() splited into setStaticValues() |
| |
* and setDynamicValues() |
| */ |
*/ |
| |
|
| define('WEB_LOG_VALUE_SUBSTR_LENGTH', 255); |
define('WEB_LOG_VALUE_SUBSTR_LENGTH', 255); |
| Riadok 597 class Web_Log { |
|
| Riadok 602 class Web_Log { |
|
| if (! $this->_props[$prop_name]['enabled']) |
if (! $this->_props[$prop_name]['enabled']) |
| return false; |
return false; |
| |
|
| return $this->_props[$prop_name]['value']; |
return isset($this->_props[$prop_name]['value']) |
| |
? $this->_props[$prop_name]['value'] |
| |
: false; |
| } |
} |
| |
|
| return false; |
return false; |
| Riadok 639 class Web_Log { |
|
| Riadok 646 class Web_Log { |
|
| 1. setAllPropertyIDs() for setting up IDs |
1. setAllPropertyIDs() for setting up IDs |
| 2. setAllProperties() for setting up values and than IDs |
2. setAllProperties() for setting up values and than IDs |
| */ |
*/ |
| |
$this->setStaticValues(); |
| return $this->setValues(); |
return $this->setDynamicValues(); |
| } /* }}} */ |
} /* }}} */ |
| |
|
| function clearAllPropertyValues() /* {{{ */ |
function clearAllPropertyValues() /* {{{ */ |
| Riadok 674 class Web_Log { |
|
| Riadok 681 class Web_Log { |
|
| function setAllProperties() /* {{{ */ |
function setAllProperties() /* {{{ */ |
| { |
{ |
| /* TODO: see comment above */ |
/* TODO: see comment above */ |
| return $this->setValues(); |
$this->setStaticValues(); |
| |
return $this->setDynamicValues(); |
| } /* }}} */ |
} /* }}} */ |
| |
|
| function clearAllProperties() /* {{{ */ |
function clearAllProperties() /* {{{ */ |
| Riadok 726 class Web_Log { |
|
| Riadok 734 class Web_Log { |
|
| if (isset($this->_db)) { |
if (isset($this->_db)) { |
| if (DB::isError($this->_db)) |
if (DB::isError($this->_db)) |
| return false; |
return false; |
| } |
} else { |
| else { |
|
| $this->_db = DB::connect($this->_dsn); |
$this->_db = DB::connect($this->_dsn); |
| |
|
| if (DB::isError($this->_db)) |
if (DB::isError($this->_db)) |
| Riadok 739 class Web_Log { |
|
| Riadok 746 class Web_Log { |
|
| return true; |
return true; |
| } /* }}} */ |
} /* }}} */ |
| |
|
| |
/** |
| |
* Reconnects to database. |
| |
* |
| |
* @return mixed true on success, PEAR_Error on error |
| |
* @access public |
| |
*/ |
| |
function reconnect() /* {{{ */ |
| |
{ |
| |
unset($this->_db); |
| |
if ($this->_checkDB() == false) { |
| |
return $this->_db; |
| |
} |
| |
return true; |
| |
} /* }}} */ |
| |
|
| /* |
/* |
| * _resolveIP() |
* _resolveIP() |
| * |
* |
| Riadok 1046 class Web_Log { |
|
| Riadok 1068 class Web_Log { |
|
| |
|
| |
|
| /* |
/* |
| * setValues() |
* setStaticValues() |
| * |
* |
| * Set all enabled properties values. |
* Set all enabled properties values. |
| */ |
*/ |
| |
|
| function setValues($value = 0) /* {{{ */ |
function setStaticValues($value = 0) /* {{{ */ |
| { |
{ |
| if ($this->_checkDB() == false) |
// Set basic values |
| return $this->_db; |
|
| |
|
| /* Set basic values */ |
|
| $this->_setBasicValues(); |
$this->_setBasicValues(); |
| |
// Setting basic host values such as remote_host, remote_addr, |
| /* Setting basic host values such as remote_host, remote_addr, |
// proxy_host, proxy_addr |
| proxy_host, proxy_addr */ |
|
| $this->_setHostValues(); |
$this->_setHostValues(); |
| |
// Setting ident protocol values: ident_username, ident_ostype |
| /* Setting ident protocol values: ident_username, ident_ostype */ |
|
| $this->_setIdentValues(); |
$this->_setIdentValues(); |
| |
// Value property |
| /* Value property */ |
|
| $this->_setValueValue($value); |
$this->_setValueValue($value); |
| |
} /* }}} */ |
| |
|
| /* If raw log is enabled, set appropriate IDs according to values */ |
/* |
| if (! $this->_raw_log) { |
* setDynamicValues() |
| $this->_setIDs(); |
* |
| } |
* Set all enabled properties values. |
| |
*/ |
| /* Session property. It is counted according to other IDs, |
|
| so it must be after others IDs counting loop above. */ |
|
| $this->_setSessionIDValue(); |
|
| |
|
| /* Datetime property. It doesn't contain real value, |
function setDynamicValues() /* {{{ */ |
| but SQL clausule for getting datetime. */ |
{ |
| $this->_setDatetimeValue(); |
if ($this->_checkDB() == false) |
| |
return $this->_db; |
| |
// If raw log is enabled, set appropriate IDs according to values |
| |
if (! $this->_raw_log) { |
| |
$this->_setIDs(); |
| |
} |
| |
// Session property. It is counted according to other IDs, |
| |
// so it must be after others IDs counting loop above. |
| |
$this->_setSessionIDValue(); |
| |
// Datetime property. It doesn't contain real value, |
| |
// but SQL clausule for getting datetime. |
| |
$this->_setDatetimeValue(); |
| |
|
| return true; |
return true; |
| } /* }}} */ |
} /* }}} */ |
| |
|
| /* |
/* |
| * registerAccess() |
* registerAccess() |
| Riadok 1096 class Web_Log { |
|
| Riadok 1121 class Web_Log { |
|
| /* NOTES: containing variable parts |
/* NOTES: containing variable parts |
| query_string, request_uri, http_referer |
query_string, request_uri, http_referer |
| */ |
*/ |
| |
$this->setStaticValues(); |
| /* |
$ret = $this->setDynamicValues($value); |
| * Setting values |
|
| */ |
|
| $ret = $this->setValues($value); |
|
| if ($ret != true) |
if ($ret != true) |
| return $ret; |
return $ret; |
| |
|
| Riadok 1175 class Web_Log { |
|
| Riadok 1197 class Web_Log { |
|
| return true; |
return true; |
| } /* }}} */ |
} /* }}} */ |
| |
|
| |
/** |
| |
* Performs remote log via HTTP protocol. Remote script shoud returns |
| |
* text/plain content type and print 1 on success and 0 on error followed |
| |
* by error message on next line(s). |
| |
* |
| |
* @param string $url URL where to log; data will be passed using |
| |
* HTTP POST request method |
| |
* @param string $value value to log |
| |
* @return mixed true on success, PEAR_Error on failure |
| |
* @access public |
| |
*/ |
| |
|
| |
function remoteLog($url, $value = 0) /* {{{ */ |
| |
{ |
| |
$this->setStaticValues($value); |
| |
$data = 'data='.rawurlencode(serialize($this)); |
| |
$host = parse_url($url); |
| |
$port = isset($host['port']) ? $host['port'] : 80; |
| |
$host = $host['host']; |
| |
$response = false; |
| |
$request = "POST $url HTTP/1.0\r\n" |
| |
."Host: $host\r\n" |
| |
."Accept: text/plain\r\n" |
| |
."Accept-Language: en\r\n" |
| |
."User-Agent: phpWebLogAnalyzer::remoteLog()\r\n" |
| |
."Content-type: application/x-www-form-urlencoded\r\n" |
| |
."Content-length: ".strlen($data)."\r\n\r\n".$data; |
| |
$fp = fsockopen($host, $port); |
| |
|
| |
if ($fp) { |
| |
fputs($fp, $request); |
| |
if (strpos(fgets($fp, 1024), '200 ')) { |
| |
do { |
| |
$line = fgets($fp, 1024); |
| |
} while ($line != "\r\n"); |
| |
|
| |
$response = array(); |
| |
while ($line = fgets($fp, 1024)) { |
| |
$response[] = $line; |
| |
} |
| |
fclose($fp); |
| |
} |
| |
} |
| |
if ($response == false || count($response) <= 0) { |
| |
return new PEAR_Error('Connection error ('.$url.')'); // ) |
| |
} |
| |
$error_code = intval($response[0]); |
| |
if ($error_code != 0) { |
| |
return true; |
| |
} |
| |
unset($response[0]); |
| |
$error_message = count($response) > 0 |
| |
? join("\n", $response) : 'Unknown remote log error'; |
| |
return new PEAR_Error($error_message); |
| |
} /* }}} */ |
| |
|
| /* |
/* |
| * _getID() |
* _getID() |
| * |
* |
| Riadok 1668 class Web_Log { |
|
| Riadok 1746 class Web_Log { |
|
| } /* }}} */ |
} /* }}} */ |
| } |
} |
| |
|
| /* vim600: fdm=marker fdl=0 fdc=3 |
/* vim: set expandtab tabstop=4 shiftwidth=4: |
| |
* vim600: fdm=marker fdl=0 fdc=3 |
| */ |
*/ |
| |
|
| ?> |
?> |