Source for file Kernel.php
Documentation is available at Kernel.php
* DotBoost Technologies Inc.
* DotKernel Application Framework
* @copyright Copyright (c) 2009 DotBoost Technologies (http://www.dotboost.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @version $Id: Kernel.php 165 2010-07-02 07:25:12Z teo $
* Bunch of miscelaneous functions, used in all DotKernel Applications
* @author DotKernel Team <team@dotkernel.com>
* Dot Kernel version identification
$this->config = Zend_Registry::get('configuration');
* End the execution of the application, by sending an 404 header and redirecting to home page
header('HTTP/1.0 404 Not Found');
echo '<SCRIPT LANGUAGE=JAVASCRIPT>
window.location.href="'. $this->config->website->params->url. '"
- Unfortunately, Microsoft has added a clever new
- \"feature\" to Internet Explorer. If the text of
- an error\'s message is \"too small\", specifically
- less than 512 bytes, Internet Explorer returns
- its own error message. You can turn that off,
- but it\'s pretty tricky to find switch called
- \"smart error messages\". That means, of course,
- that short error messages are censored by default.
- IIS always returns error messages that are long
- enough to make Internet Explorer happy. The
- workaround is pretty simple: pad the error
- message with a big comment like this to push it
- over the five hundred and twelve bytes minimum.
- Of course, that\'s exactly what you\'re reading
* Return the user Ip , whatever the server are set
if (isSet ($_SERVER['HTTP_X_FORWARDED_FOR']))
$realIp = $_SERVER['HTTP_X_FORWARDED_FOR'];
elseif (isSet ($_SERVER['HTTP_CLIENT_IP']))
$realIp = $_SERVER['HTTP_CLIENT_IP'];
$realIp = $_SERVER['REMOTE_ADDR'];
if (getenv('HTTP_X_FORWARDED_FOR'))
$realIp = getenv('HTTP_X_FORWARDED_FOR');
elseif (getenv('HTTP_CLIENT_IP'))
$realIp = getenv('HTTP_CLIENT_IP');
$realIp = getenv('REMOTE_ADDR');
* Return the name of the browser icon based on User Agent
$browser = $xml->name->type->toArray();
foreach ($browser as $key => $val)
if (stripos($agent,$val['uaBrowser']) !== FALSE)
* Return the name of the OS icon based on User Agent
$os = $xml->type->toArray();
foreach ($major as $osArray)
{//there are minor version
foreach ($osArray['identify'] as $minor)
$uaStringArray = explode('|',$minor['uaString']);
foreach ($uaStringArray as $uaString)
if ((stripos($agent, $uaString) !== false))
$operatingSystem = array('icon'=> strtolower(str_replace(' ', '_', $osArray['os'])), 'major'=> $osArray['os'], 'minor'=> $minor['osName']);
{//no minor version known for this os
if ((stripos($agent, $osArray['os']) !== false))
$operatingSystem = array('icon'=> strtolower(str_replace(' ', '_', $osArray['os'])), 'major'=> $osArray['os'], 'minor'=> '');
return array('major'=> '', 'minor'=> '');
* Return date formatted fancy
* @param string $format - 'short', 'long'
public static function timeFormat($date, $format= 'short')
$settings = Zend_Registry::get('settings');
$times = strftime($settings->timeFormatLong,$times);
$times = strftime($settings->timeFormatShort,$times);
* Process that validate and filter the input/output data.
* Return valid and filtered data
* @param Zend_Validate $validator
$data = $error = array();
$filter = new Zend_Filter();
$filter->addFilter(new Zend_Filter_HtmlEntities());
$filter->addFilter(new Zend_Filter_StringTrim());
foreach ($values as $k=> $v)
if($validator->isValid($values[$k]))
$data[$k] = $filter->filter($values[$k]);
foreach ($validator->getMessages() as $message)
$error[$k] = str_replace($values[$k], $filter->filter($values[$k]), $message);
return array('data'=> $data,'error'=> $error);
|