r42 - in phpOpenTracker/trunk/phpOpenTracker: . Database Database/Driver
Sebastian Bergmann at BerliOS <[email protected]> Mon, 21 Mar 2005 09:01:04 +0100
| Newsgroups | gmane.comp.web.phpopentracker.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: s_bergmann Date: 2005-03-21 09:00:39 +0100 (Mon, 21 Mar 2005) New Revision: 42 Added: phpOpenTracker/trunk/phpOpenTracker/Database/ phpOpenTracker/trunk/phpOpenTracker/Database/Driver.php phpOpenTracker/trunk/phpOpenTracker/Database/Driver/ phpOpenTracker/trunk/phpOpenTracker/Database/Driver/MySQL.php phpOpenTracker/trunk/phpOpenTracker/LoggingEngine.php Log: Flush, so I do not have to backup it locally. Added: phpOpenTracker/trunk/phpOpenTracker/Database/Driver/MySQL.php =================================================================== --- phpOpenTracker/trunk/phpOpenTracker/Database/Driver/MySQL.php 2005-03-21 07:58:49 UTC (rev 41) +++ phpOpenTracker/trunk/phpOpenTracker/Database/Driver/MySQL.php 2005-03-21 08:00:39 UTC (rev 42) @@ -0,0 +1,51 @@ +<?php +/* ***** BEGIN LICENSE BLOCK ***** + * Version: Apache License 2.0 + * + * The contents of this file are subject to the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is the phpOpenTracker_Database_Driver_MySQL class. + * + * The Initial Developer of the Original Code is Sebastian Bergmann. + * Portions created by the Initial Developer are Copyright (C) 2000-2005 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * ***** END LICENSE BLOCK ***** */ + +require_once 'phpOpenTracker/Database/Driver.php'; + +/** + * phpOpenTracker Database Driver for MySQL. + * + * @author Sebastian Bergmann <[email protected]> + * @copyright Copyright © 2000-2005 Sebastian Bergmann <[email protected]> + * @license http://www.apache.org/licenses/LICENSE-2.0 The Apache License, Version 2.0 + * @category phpOpenTracker + * @package phpOpenTracker + * @since phpOpenTracker 2.0.0 + */ +class phpOpenTracker_Database_Driver_MySQL extends phpOpenTracker_Database_Driver { + public function storePageImpression($first = FALSE) { + if ($first === TRUE) { + // SET @visitor_id = UUID(); + // INSERT INTO ... VALUES ( ... @visitor_id ... ); + // SELECT @visitor_id AS visitor_id; + } + } +} + +// +// "phpOpenTracker essenya, gul meletya; +// Sebastian carneron PHP." +// +?> Property changes on: phpOpenTracker/trunk/phpOpenTracker/Database/Driver/MySQL.php ___________________________________________________________________ Name: svn:keywords + Id Added: phpOpenTracker/trunk/phpOpenTracker/Database/Driver.php =================================================================== --- phpOpenTracker/trunk/phpOpenTracker/Database/Driver.php 2005-03-21 07:58:49 UTC (rev 41) +++ phpOpenTracker/trunk/phpOpenTracker/Database/Driver.php 2005-03-21 08:00:39 UTC (rev 42) @@ -0,0 +1,42 @@ +<?php +/* ***** BEGIN LICENSE BLOCK ***** + * Version: Apache License 2.0 + * + * The contents of this file are subject to the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is the phpOpenTracker_Database_Driver class. + * + * The Initial Developer of the Original Code is Sebastian Bergmann. + * Portions created by the Initial Developer are Copyright (C) 2000-2005 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * ***** END LICENSE BLOCK ***** */ + +/** + * Abstract Base Class for phpOpenTracker Database Drivers. + * + * @author Sebastian Bergmann <[email protected]> + * @copyright Copyright © 2000-2005 Sebastian Bergmann <[email protected]> + * @license http://www.apache.org/licenses/LICENSE-2.0 The Apache License, Version 2.0 + * @category phpOpenTracker + * @package phpOpenTracker + * @since phpOpenTracker 2.0.0 + */ +abstract class phpOpenTracker_Database_Driver { +} + +// +// "phpOpenTracker essenya, gul meletya; +// Sebastian carneron PHP." +// +?> Property changes on: phpOpenTracker/trunk/phpOpenTracker/Database/Driver.php ___________________________________________________________________ Name: svn:keywords + Id Added: phpOpenTracker/trunk/phpOpenTracker/LoggingEngine.php =================================================================== --- phpOpenTracker/trunk/phpOpenTracker/LoggingEngine.php 2005-03-21 07:58:49 UTC (rev 41) +++ phpOpenTracker/trunk/phpOpenTracker/LoggingEngine.php 2005-03-21 08:00:39 UTC (rev 42) @@ -0,0 +1,186 @@ +<?php +/* ***** BEGIN LICENSE BLOCK ***** + * Version: Apache License 2.0 + * + * The contents of this file are subject to the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is the phpOpenTracker_LoggingEngine class. + * + * The Initial Developer of the Original Code is Sebastian Bergmann. + * Portions created by the Initial Developer are Copyright (C) 2000-2005 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * ***** END LICENSE BLOCK ***** */ + +/** + * phpOpenTracker Logging Engine. + * + * @author Sebastian Bergmann <[email protected]> + * @copyright Copyright © 2000-2005 Sebastian Bergmann <[email protected]> + * @license http://www.apache.org/licenses/LICENSE-2.0 The Apache License, Version 2.0 + * @category phpOpenTracker + * @package phpOpenTracker + * @since phpOpenTracker 1.0.0 + */ +class phpOpenTracker_LoggingEngine { + private function setupSession($parameters) { + // Client ID. + + $parameters['client_id'] = isset($parameters['client_id']) ? $parameters['client_id'] : 1; + $_SESSION['pot_first_request'] = isset($_SESSION['pot_first_request']) ? FALSE : TRUE; + + if ($_SESSION['pot_first_request'] === TRUE) { + $client_id_switched = FALSE; + } + + else if ($_SESSION['pot_client_id'] != $parameters['client_id']) { + $_SESSION['pot_first_request'] = TRUE; + $client_id_switched = TRUE; + } + + $_SESSION['pot_client_id'] = $parameters['client_id']; + + // First request (page impression) of a session (visit). + + if ($_SESSION['pot_first_request'] === TRUE) { + if (!$client_id_switched) { + // Hostname. + + if (!isset($parameters['host']) && + !isset($parameters['ip_address'])) { + if (isset($_SERVER['REMOTE_ADDR'])) { + $_SESSION['pot_ip_address'] = $_SERVER['REMOTE_ADDR']; + + if (isset($_SERVER['REMOTE_HOST'])) { + $_SESSION['pot_host_orig'] = $_SERVER['REMOTE_HOST']; + } else { + if ($config['resolve_hostname']) { + $_SESSION['pot_host_orig'] = gethostbyaddr($_SESSION['pot_ip_address']); + } else { + $_SESSION['pot_host_orig'] = $_SESSION['pot_ip_address']; + } + } + } else { + $_SESSION['pot_host_orig'] = ''; + $_SESSION['pot_ip_address'] = ''; + } + } else { + $_SESSION['pot_host_orig'] = isset($parameters['host']) ? $parameters['host'] : ''; + $_SESSION['pot_ip_address'] = isset($parameters['ip_address']) ? $parameters['ip_address'] : ''; + } + + $_SESSION['pot_host'] = $_SESSION['pot_host_orig']; + + if ($config['group_hostnames']) { + $_SESSION['pot_host'] = phpOpenTracker_Parser::hostname($_SESSION['pot_host']); + } + + // User-Agent. + + if (isset($parameters['user_agent'])) { + $_SESSION['pot_user_agent_orig'] = $parameters['user_agent']; + } else { + $_SESSION['pot_user_agent_orig'] = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; + } + + if ($config['group_user_agents']) { + $session = array_merge( + $session, + phpOpenTracker_Parser::userAgent($_SESSION['pot_user_agent_orig']) + ); + } else { + $_SESSION['pot_operating_system'] = 'Not identified'; + $_SESSION['pot_user_agent'] = $_SESSION['pot_user_agent_orig']; + } + } + + // Referer. + + if (isset($parameters['referer'])) { + $_SESSION['pot_referer_orig'] = $parameters['referer']; + } else { + $_SESSION['pot_referer_orig'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; + } + + $_SESSION['pot_referer_orig'] = urldecode($_SESSION['pot_referer_orig']); + + if ($config['clean_referer_string']) { + $_SESSION['pot_referer'] = preg_replace('/(\?.*)/', '', $_SESSION['pot_referer_orig']); + } else { + $_SESSION['pot_referer'] = $_SESSION['pot_referer_orig']; + } + + if (!empty($_SESSION['pot_referer'])) { + $_SESSION['pot_referer'] = str_replace( + array( + 'http://', + 'https://' + ), + '', + $_SESSION['pot_referer'] + ); + } + } else { + $_SESSION['pot_last_document'] = $_SESSION['pot_document']; + } + + $_SESSION['pot_document_url'] = isset($parameters['document_url']) ? $parameters['document_url'] : urldecode($_SERVER[$config['document_env_var']]); + + if ($config['clean_query_string']) { + $_SESSION['pot_document_url'] = preg_replace( + '/(\?.*)/', + '', + $_SESSION['pot_document_url'] + ); + } else { + if ($config['get_parameter_filter'] != '') { + $filters = explode( + ',', + str_replace( + ' ', + '', + $config['get_parameter_filter'] + ) + ); + } else { + $filters = array(); + } + + $filters[] = session_name(); + + foreach ($filters as $filter) { + $_SESSION['pot_document_url'] = preg_replace( + '#\?' . + $filter . + '=.*$|&' . + $filter . + '=.*$|' . + $filter . + '=.*&#msiU', + '', + $_SESSION['pot_document_url'] + ); + } + } + + $_SESSION['pot_document'] = isset($parameters['document']) ? $parameters['document'] : $_SESSION['pot_document_url']; + $_SESSION['pot_plugin_data'] = isset($parameters['plugin_data']) ? $parameters['plugin_data'] : array(); + $_SESSION['pot_timestamp'] = isset($parameters['timestamp']) ? $parameters['timestamp'] : time(); + } +} + +// +// "phpOpenTracker essenya, gul meletya; +// Sebastian carneron PHP." +// +?> Property changes on: phpOpenTracker/trunk/phpOpenTracker/LoggingEngine.php ___________________________________________________________________ Name: svn:keywords + Id