Models
[
class tree: Models
] [
index: Models
] [
all elements
]
Packages:
Application
Bootstrap
Controllers
Models
Source for file Base.php
Documentation is available at
Base.php
<?php
/**
* Base
*
* Copyright (C) 2009 Mai (Me Artificial Intelligence)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*
@author
Wouter Bulten (wouterbulten@mai-ai.org)
*
@copyright
Copyright (C) 2009 Mai (Me Artificial Intelligence)
*
@license
http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
*
@link
http://www.launchpad.net/mai
*
*
@package
Models
*
@subpackage
Other
*
*/
/**
* The Base class contains some basic functions for Mai.
*
*
@author
Wouter Bulten (wouterbulten@mai-ai.org)
*
@copyright
Copyright (C) 2009 Mai (Me Artificial Intelligence)
*
@license
http://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 (GPLv3)
*
@link
http://www.launchpad.net/mai
*
*
@package
Models
*
@subpackage
Other
*
*/
class
Base
{
/**
* Contains the path of the log files.
*
@var
string
*/
static
private
$_logPath
;
/**
* Contains the name of the default log file.
*
@var
string
*/
static
private
$_logFilename
;
/**
* Contains the logger class
*
@var
object
Zend_Log
*/
static
private
$_logger
;
/**
* Private constructor to prevent creation of this class.
*
@return
void
*/
private
function
__construct
(
)
{
}
/**
* Stores a given message to the log.
*
* Zend_Log::EMERG: Emergency: system is unusable
* Zend_Log::ALERT: Alert: action must be taken immediately
* Zend_Log::CRIT: Critical: critical condition
* Zend_Log::ERR: Error: error conditions
* Zend_Log::WARN: Warning: warning conditions
* Zend_Log::NOTICE: Notice: normal but significant condition
* Zend_Log::INFO: Informational: informational messages
* Zend_Log::DEBUG: Debug: debug messages
*
*
@param
$message
*
@param
$type
Type of the message
*
@return
void
*/
// static public function log($message, $type = Zend_Log::INFO)
// {
// //Logger does not already excist, create
// if(empty(self::$_logger) || !(self::$_logger instanceof Zend_Log))
// {
// //Load log path
// if(empty(self::$_logPath))
// {
// self::$_logPath = Zend_Registry::get('config')->log->path;
// }
//
// //Load default filename
// if(empty(self::$_logFilename))
// {
// self::$_logFilename = Zend_Registry::get('config')->log->name_default_file;
// }
//
// //Start class
// self::$_logger = new Zend_Log(new Zend_Log_Writer_Stream(BASE_PATH . self::$_logPath . '/' . self::$_logFilename));
// }
//
// self::$_logger->log($message, $type);
// }
/**
* Get the ip address of the current user.
*
*
@return
string
*/
public
static
function
getRealIp
(
)
{
if
(
!
empty
(
$_SERVER
[
'HTTP_CLIENT_IP'
]
))
{
$ip
=
$_SERVER
[
'HTTP_CLIENT_IP'
]
;
}
elseif
(
!
empty
(
$_SERVER
[
'HTTP_X_FORWARDED_FOR'
]
))
{
$ip
=
$_SERVER
[
'HTTP_X_FORWARDED_FOR'
]
;
}
else
{
$ip
=
$_SERVER
[
'REMOTE_ADDR'
]
;
}
return
$ip
;
}
}
Documentation generated on Mon, 27 Jul 2009 19:54:28 +0200 by
phpDocumentor 1.4.1