Example #1
12
 /**
  * Sets the time against which the session is measured. This function also
  * sets the cash_session_id internally as a mechanism for tracking analytics
  * against a consistent id, regardless of PHP session id.
  *
  * @return boolean
  */
 protected function startSession()
 {
     // begin PHP session
     if (!defined('STDIN')) {
         // no session for CLI, suckers
         @session_cache_limiter('nocache');
         $session_length = 3600;
         @ini_set("session.gc_maxlifetime", $session_length);
         @session_start();
     }
     $this->cash_session_timeout = ini_get("session.gc_maxlifetime");
     if (!isset($_SESSION['cash_session_id'])) {
         $modifier_array = array('deedee', 'johnny', 'joey', 'tommy', 'marky');
         $_SESSION['cash_session_id'] = $modifier_array[array_rand($modifier_array)] . '_' . rand(1000, 9999) . substr((string) time(), 4);
     }
     if (isset($_SESSION['cash_last_request_time'])) {
         if ($_SESSION['cash_last_request_time'] + $this->cash_session_timeout < time()) {
             $this->resetSession();
         }
     }
     $_SESSION['cash_last_request_time'] = time();
     if (!isset($GLOBALS['cash_script_store'])) {
         $GLOBALS['cash_script_store'] = array();
     }
     return true;
 }
 /**
  * Filters an asset after it has been loaded.
  *
  * @param  \Assetic\Asset\AssetInterface  $asset
  * @return void
  */
 public function filterLoad(AssetInterface $asset)
 {
     $max_nesting_level = ini_get('xdebug.max_nesting_level');
     $memory_limit = ini_get('memory_limit');
     if ($max_nesting_level && $max_nesting_level < 200) {
         ini_set('xdebug.max_nesting_level', 200);
     }
     if ($memory_limit && $memory_limit < 256) {
         ini_set('memory_limit', '256M');
     }
     $root = $asset->getSourceRoot();
     $path = $asset->getSourcePath();
     $dirs = array();
     $lc = new \Less_Parser(array('compress' => true));
     if ($root && $path) {
         $dirs[] = dirname($root . '/' . $path);
     }
     foreach ($this->loadPaths as $loadPath) {
         $dirs[] = $loadPath;
     }
     $lc->SetImportDirs($dirs);
     $url = parse_url($this->getRequest()->getUriForPath(''));
     $absolutePath = str_replace(public_path(), '', $root);
     if (isset($url['path'])) {
         $absolutePath = $url['path'] . $absolutePath;
     }
     $lc->parseFile($root . '/' . $path, $absolutePath);
     $asset->setContent($lc->getCss());
 }
Example #3
3
File: lib.php Project: winiceo/job
function dump($var, $echo = true, $label = null, $strict = true)
{
    $label = $label === null ? '' : rtrim($label) . ' ';
    if (!$strict) {
        if (ini_get('html_errors')) {
            $output = print_r($var, true);
            $output = "<pre>" . $label . htmlspecialchars($output, ENT_QUOTES) . "</pre>";
        } else {
            $output = $label . " : " . print_r($var, true);
        }
    } else {
        ob_start();
        var_dump($var);
        $output = ob_get_clean();
        if (!extension_loaded('xdebug')) {
            $output = preg_replace("/\\]\\=\\>\n(\\s+)/m", "] => ", $output);
            $output = '<pre>' . $label . htmlspecialchars($output, ENT_QUOTES, "GB2312") . '</pre>';
        }
    }
    if ($echo) {
        echo $output;
        return null;
    } else {
        return $output;
    }
}
Example #4
2
 public function dir_name()
 {
     $path = ini_get("xhprof.output_dir");
     $path = empty($path) ? sys_get_temp_dir() : $path;
     return $path;
     // return DATA_DIR."/xhprof/";
 }
Example #5
2
 function jws_fetchUrl($url)
 {
     //Can we use cURL?
     if (is_callable('curl_init')) {
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_TIMEOUT, 20);
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
         $feedData = curl_exec($ch);
         curl_close($ch);
         //If not then use file_get_contents
     } elseif (ini_get('allow_url_fopen') == 1 || ini_get('allow_url_fopen') === TRUE) {
         $feedData = @file_get_contents($url);
         //Or else use the WP HTTP API
     } else {
         if (!class_exists('WP_Http')) {
             include_once ABSPATH . WPINC . '/class-http.php';
         }
         $request = new WP_Http();
         $result = $request->request($url);
         $feedData = $result['body'];
     }
     /*    echo $feedData;
     		exit;*/
     return $feedData;
 }
 /**
  * Constructor
  *
  * @access	public
  * @param	object		ipsRegistry reference
  * @param	array 		Configuration info for this method
  * @param	array 		Custom configuration info for this method
  * @return	void
  */
 public function __construct(ipsRegistry $registry, $method, $conf = array())
 {
     $this->method_config = $method;
     $this->openid_config = $conf;
     parent::__construct($registry);
     //-----------------------------------------
     // Fix include path for OpenID libs
     //-----------------------------------------
     $path_extra = dirname(__FILE__);
     $path = ini_get('include_path');
     $path = $path_extra . PATH_SEPARATOR . $path;
     ini_set('include_path', $path);
     define('Auth_OpenID_RAND_SOURCE', null);
     //-----------------------------------------
     // OpenID libraries are not STRICT compliant
     //-----------------------------------------
     ob_start();
     /**
      * Turn off strict error reporting for openid
      */
     if (version_compare(PHP_VERSION, '5.2.0', '>=')) {
         error_reporting(E_ERROR | E_WARNING | E_PARSE | E_RECOVERABLE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_USER_WARNING);
     } else {
         error_reporting(E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR | E_USER_ERROR | E_USER_WARNING);
     }
     //-----------------------------------------
     // And grab libs
     //-----------------------------------------
     require_once "Auth/OpenID/Consumer.php";
     require_once "Auth/OpenID/FileStore.php";
     require_once "Auth/OpenID/SReg.php";
     require_once "Auth/OpenID/PAPE.php";
 }
 /**
  * Converts a YAML string to a PHP array.
  *
  * @param string  $value                  A YAML string
  * @param Boolean $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
  * @param Boolean $objectSupport          true if object support is enabled, false otherwise
  *
  * @return array A PHP array representing the YAML string
  */
 public static function parse($value, $exceptionOnInvalidType = false, $objectSupport = false)
 {
     self::$exceptionOnInvalidType = $exceptionOnInvalidType;
     self::$objectSupport = $objectSupport;
     $value = trim($value);
     if (0 == strlen($value)) {
         return '';
     }
     if (function_exists('mb_internal_encoding') && (int) ini_get('mbstring.func_overload') & 2) {
         $mbEncoding = mb_internal_encoding();
         mb_internal_encoding('ASCII');
     }
     $i = 0;
     switch ($value[0]) {
         case '[':
             $result = self::parseSequence($value, $i);
             ++$i;
             break;
         case '{':
             $result = self::parseMapping($value, $i);
             ++$i;
             break;
         default:
             $result = self::parseScalar($value, null, array('"', "'"), $i);
     }
     // some comments are allowed at the end
     if (preg_replace('/\\s+#.*$/A', '', substr($value, $i))) {
         throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)));
     }
     if (isset($mbEncoding)) {
         mb_internal_encoding($mbEncoding);
     }
     return $result;
 }
 function getFieldTypeDetails($webserviceField)
 {
     global $upload_maxsize;
     $typeDetails = array();
     switch ($webserviceField->getFieldDataType()) {
         case 'reference':
             $typeDetails['refersTo'] = $webserviceField->getReferenceList();
             break;
         case 'multipicklist':
         case 'picklist':
             $typeDetails["picklistValues"] = $this->getPicklistDetails($webserviceField);
             $typeDetails['defaultValue'] = $typeDetails["picklistValues"][0]['value'];
             break;
         case 'file':
             $maxUploadSize = 0;
             $maxUploadSize = ini_get('upload_max_filesize');
             $maxUploadSize = strtolower($maxUploadSize);
             $maxUploadSize = explode('m', $maxUploadSize);
             $maxUploadSize = $maxUploadSize[0];
             if (!is_numeric($maxUploadSize)) {
                 $maxUploadSize = 0;
             }
             $maxUploadSize = $maxUploadSize * 1000000;
             if ($upload_maxsize > $maxUploadSize) {
                 $maxUploadSize = $upload_maxsize;
             }
             $typeDetails['maxUploadFileSize'] = $maxUploadSize;
             break;
         case 'date':
             $typeDetails['format'] = $this->user->date_format;
     }
     return $typeDetails;
 }
Example #9
1
 /**
  * Max execution time.
  *
  * @since 150424 Initial release.
  *
  * @param int|null $max Max execution time.
  *
  * @return int Max execution time; in seconds.
  */
 public function max(int $max = null) : int
 {
     if (isset($max) && $max >= 0) {
         @set_time_limit($max);
     }
     return (int) ini_get('max_execution_time');
 }
Example #10
1
 /**
  * @brief Accion que se encarga de manipular el proceso de guardar
  * un archivo en el servidor
  * @param array $allowedExtensions Arreglo de extensiones validas para el archivo
  * @param int $sizeLimit Tamaño maximo permitido del fichero que se sube
  */
 function upload($allowedExtensions, $sizeLimit = 10485760)
 {
     jimport('Amadeus.Util.Uploader');
     $media =& JComponentHelper::getParams('com_media');
     $postSize = $this->toBytes(ini_get('post_max_size'));
     $uploadSize = $this->toBytes(ini_get('upload_max_filesize'));
     $mediaSize = (int) $media->get('upload_maxsize');
     // Se selecciona el minimo tamaño válido para un fichero, de acuerdo
     // a los valores configurados en el php, el joomla y el componente.
     $sizeLimit = min($postSize, $uploadSize, $mediaSize, $sizeLimit);
     // Se alamacena la imagen en la ruta especificada
     $uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
     $result = $uploader->handleUpload(JPATH_SITE . '/tmp/', true);
     if (!isset($result['error'])) {
         jimport('Amadeus.Util.Validation');
         $file = $uploader->getName();
         $result = AmadeusUtilValidation::isValidFile($file, $only_image);
         if (isset($result['error'])) {
             jimport('joomla.filesystem.file');
             if (!JFile::delete($file)) {
                 $result = array('error' => JText::_('DELETEERROR'));
             }
         } else {
             $this->_file = $file;
         }
     }
     return $result;
 }
Example #11
1
function syscheck($items)
{
    foreach ($items as $key => $item) {
        if ($item['list'] == 'php') {
            $items[$key]['current'] = PHP_VERSION;
        } elseif ($item['list'] == 'upload') {
            $items[$key]['current'] = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : 'unknow';
        } elseif ($item['list'] == 'gdversion') {
            $tmp = function_exists('gd_info') ? gd_info() : array();
            $items[$key]['current'] = empty($tmp['GD Version']) ? 'noext' : $tmp['GD Version'];
            unset($tmp);
        } elseif ($item['list'] == 'disk') {
            if (function_exists('disk_free_space')) {
                $items[$key]['current'] = floor(disk_free_space(admin_ROOT) / (1024 * 1024)) . 'M';
            } else {
                $items[$key]['current'] = 'unknow';
            }
        } elseif (isset($item['c'])) {
            $items[$key]['current'] = constant($item['c']);
        }
        $items[$key]['status'] = 1;
        if ($item['r'] != 'notset' && strcmp($items[$key]['current'], $item['r']) < 0) {
            $items[$key]['status'] = 0;
        }
    }
    return $items;
}
Example #12
1
 public static function getVideoData($videoid, $customimage, $customtitle, $customdescription)
 {
     $theTitle = '';
     $Description = '';
     $theImage = '';
     //if($firstvideo=='')
     //$firstvideo=$videoid;
     $XML_SOURCE = '';
     if ($customimage != '') {
         $theImage = $customimage;
     } else {
         if (ini_get('allow_url_fopen')) {
             $XML_SOURCE = YouTubeGalleryMisc::getURLData('http://video.google.com/videofeed?docid=' . $videoid);
             $match = array();
             preg_match("/media:thumbnail url=\"([^\"]\\S*)\"/siU", $XML_SOURCE, $match);
             $theImage = $match[1];
         }
         //if(ini_get('allow_url_fopen'))
     }
     //if($customimage!='')
     $theTitle = 'Google Video';
     if ($customtitle != '') {
         $theTitle = $customtitle;
     }
     if ($customdescription != '') {
         $Description = $customdescription;
     }
     return array('videosource' => 'google', 'videoid' => $videoid, 'imageurl' => $theImage, 'title' => $theTitle, 'description' => $Description);
 }
Example #13
1
 public static function toXml($data, $rootNodeName = 'data', $xml = null)
 {
     // turn off compatibility mode as simple xml throws a wobbly if you don't.
     if (ini_get('zend.ze1_compatibility_mode') == 1) {
         ini_set('zend.ze1_compatibility_mode', 0);
     }
     if ($xml == null) {
         $xml = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><{$rootNodeName} />");
     }
     // loop through the data passed in.
     foreach ($data as $key => $value) {
         // no numeric keys in our xml please!
         if (is_numeric($key)) {
             // make string key...
             $key = "child_" . (string) $key;
         }
         // replace anything not alpha numeric
         $key = preg_replace('/[^a-z]/i', '', $key);
         // if there is another array found recrusively call this function
         if (is_array($value)) {
             $node = $xml->addChild($key);
             // recrusive call.
             ArrayToXML::toXml($value, $rootNodeName, $node);
         } else {
             // add single node.
             $value = htmlentities($value);
             $xml->addChild($key, $value);
         }
     }
     // pass back as string. or simple xml object if you want!
     return $xml->asXML();
 }
Example #14
1
 public function __construct($di, $config = array())
 {
     $this->di = $di;
     $this->repo = new PDOSessionRepository($this->di->get('db'));
     $this->mapper = new PDOSessionDatamapper($this->di->get('db'));
     $this->maxLifetime = isset($config['maxLifetime']) ? $config['maxLifetime'] : ini_get('session.gc_maxlifetime');
 }
 /**
  * testDocRef method
  *
  * @return void
  */
 public function testDocRef()
 {
     ini_set('docref_root', '');
     $this->assertEquals(ini_get('docref_root'), '');
     $debugger = new Debugger();
     $this->assertEquals(ini_get('docref_root'), 'http://php.net/');
 }
 public function __construct()
 {
     $time_limit = ini_get('max_execution_time');
     if (!empty($time_limit)) {
         $this->maxTimeLimit = (int) $time_limit + $this->maxTimeLimit;
     }
 }
Example #17
0
/**
 * Start the commandline to send a newsletter
 * This is offloaded because it could take a while and/or resources
 *
 * @param Newsletter $entity Newsletter entity to be processed
 *
 * @return void
 */
function newsletter_start_commandline_sending(Newsletter $entity)
{
    if (!empty($entity) && elgg_instanceof($entity, "object", Newsletter::SUBTYPE)) {
        // prepare commandline settings
        $settings = array("entity_guid" => $entity->getGUID(), "host" => $_SERVER["HTTP_HOST"], "memory_limit" => ini_get("memory_limit"), "secret" => newsletter_generate_commanline_secret($entity->getGUID()));
        if (isset($_SERVER["HTTPS"])) {
            $settings["https"] = $_SERVER["HTTPS"];
        }
        // ini settings
        $ini_param = "";
        $ini_file = php_ini_loaded_file();
        if (!empty($ini_file)) {
            $ini_param = "-c " . $ini_file . " ";
        }
        // which script to run
        $script_location = dirname(dirname(__FILE__)) . "/procedures/cli.php";
        // convert settings to commandline params
        $query_string = http_build_query($settings, "", " ");
        // start the correct commandline
        if (PHP_OS === "WINNT") {
            pclose(popen("start /B php " . $ini_param . $script_location . " " . $query_string, "r"));
        } else {
            exec("php " . $ini_param . $script_location . " " . $query_string . " > /dev/null &");
        }
    }
}
Example #18
0
 /**
  * Connects to a database.
  * @return void
  * @throws DibiException
  */
 public function connect(array &$config)
 {
     DibiConnection::alias($config, 'username', 'user');
     DibiConnection::alias($config, 'password', 'pass');
     if (isset($config['resource'])) {
         $this->connection = $config['resource'];
     } else {
         // default values
         if (!isset($config['username'])) {
             $config['username'] = ini_get('odbc.default_user');
         }
         if (!isset($config['password'])) {
             $config['password'] = ini_get('odbc.default_pw');
         }
         if (!isset($config['dsn'])) {
             $config['dsn'] = ini_get('odbc.default_db');
         }
         if (empty($config['persistent'])) {
             $this->connection = @odbc_connect($config['dsn'], $config['username'], $config['password']);
             // intentionally @
         } else {
             $this->connection = @odbc_pconnect($config['dsn'], $config['username'], $config['password']);
             // intentionally @
         }
     }
     if (!is_resource($this->connection)) {
         throw new DibiDriverException(odbc_errormsg() . ' ' . odbc_error());
     }
 }
 /**
  * Method for parsing ini files
  *
  * @param		string	$filename Path and name of the ini file to parse
  *
  * @return	array		Array of strings found in the file, the array indices will be the keys. On failure an empty array will be returned
  *
  * @since		2.5
  */
 public static function parseFile($filename)
 {
     jimport('joomla.filesystem.file');
     if (!JFile::exists($filename)) {
         return array();
     }
     // Capture hidden PHP errors from the parsing
     $version = phpversion();
     $php_errormsg = null;
     $track_errors = ini_get('track_errors');
     ini_set('track_errors', true);
     if ($version >= '5.3.1') {
         $contents = file_get_contents($filename);
         $contents = str_replace('_QQ_', '"\\""', $contents);
         $strings = @parse_ini_string($contents);
         if ($strings === false) {
             return array();
         }
     } else {
         $strings = @parse_ini_file($filename);
         if ($strings === false) {
             return array();
         }
         if ($version == '5.3.0' && is_array($strings)) {
             foreach ($strings as $key => $string) {
                 $strings[$key] = str_replace('_QQ_', '"', $string);
             }
         }
     }
     return $strings;
 }
 /**
  * Renders the page by injecting controller data inside a view template
  */
 public function render()
 {
     $viewFile = 'views/' . $this->name . '.php';
     if (!file_exists($viewFile)) {
         throw new Exception("view file [{$viewFile}] is missing");
     }
     // inject data and render template
     $this->buildPageData();
     extract($this->data);
     ob_start();
     if ((bool) ini_get('short_open_tag') === true) {
         include $viewFile;
     } else {
         $templateCode = file_get_contents($viewFile);
         $this->convertShortTags($templateCode);
         // Evaluating PHP mixed with HTML requires closing the PHP markup opened by eval()
         $templateCode = '?>' . $templateCode;
         echo eval($templateCode);
     }
     // get ouput
     $out = ob_get_contents();
     // get rid of buffer
     @ob_end_clean();
     return $out;
 }
Example #21
0
 function downloadPackage($src, $dst)
 {
     if (ini_get('allow_url_fopen')) {
         $file = @file_get_contents($src);
     } else {
         if (function_exists('curl_init')) {
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_URL, $src);
             curl_setopt($ch, CURLOPT_HEADER, 0);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             curl_setopt($ch, CURLOPT_TIMEOUT, 180);
             $safeMode = @ini_get('safe_mode');
             $openBasedir = @ini_get('open_basedir');
             if (empty($safeMode) && empty($openBasedir)) {
                 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
             }
             $file = curl_exec($ch);
             curl_close($ch);
         } else {
             return false;
         }
     }
     file_put_contents($dst, $file);
     return file_exists($dst);
 }
Example #22
0
 /**
  *
  * add filter for Site option defaults
  *
  */
 public static function default_site_options()
 {
     //global
     add_site_option('backwpup_version', '0.0.0');
     //job default
     add_site_option('backwpup_jobs', array());
     //general
     add_site_option('backwpup_cfg_showadminbar', 1);
     add_site_option('backwpup_cfg_showfoldersize', 0);
     add_site_option('backwpup_cfg_protectfolders', 1);
     //job
     $max_execution_time = 0;
     if (strstr(PHP_SAPI, 'cgi')) {
         $max_execution_time = (int) ini_get('max_execution_time');
     }
     add_site_option('backwpup_cfg_jobmaxexecutiontime', $max_execution_time);
     add_site_option('backwpup_cfg_jobziparchivemethod', '');
     add_site_option('backwpup_cfg_jobstepretry', 3);
     add_site_option('backwpup_cfg_jobrunauthkey', substr(md5(BackWPup::get_plugin_data('hash')), 11, 8));
     add_site_option('backwpup_cfg_loglevel', 'normal_translated');
     add_site_option('backwpup_cfg_jobwaittimems', 0);
     add_site_option('backwpup_cfg_jobdooutput', 0);
     //Logs
     add_site_option('backwpup_cfg_maxlogs', 30);
     add_site_option('backwpup_cfg_gzlogs', 0);
     $upload_dir = wp_upload_dir();
     $logs_dir = trailingslashit(str_replace('\\', '/', $upload_dir['basedir'])) . 'backwpup-' . BackWPup::get_plugin_data('hash') . '-logs/';
     $content_path = trailingslashit(str_replace('\\', '/', WP_CONTENT_DIR));
     $logs_dir = str_replace($content_path, '', $logs_dir);
     add_site_option('backwpup_cfg_logfolder', $logs_dir);
     //Network Auth
     add_site_option('backwpup_cfg_httpauthuser', '');
     add_site_option('backwpup_cfg_httpauthpassword', '');
 }
 /**
  * opening of the session - mandatory arguments won't be needed
  *
  * @param string $savePath
  * @param string $sessionName
  * @return bool
  */
 public function open($savePath, $sessionName)
 {
     if (!isset($this->_lifeTime)) {
         $this->_lifeTime = intval(ini_get("session.gc_maxlifetime"));
     }
     if (!isset($this->_refreshTime)) {
         $this->_refreshTime = ceil($this->_lifeTime / 3);
     }
     $this->_initSessionData = null;
     $this->_memcache = new Memcache();
     if (Kwf_Config::getValue('aws.simpleCacheCluster')) {
         $servers = Kwf_Util_Aws_ElastiCache_CacheClusterEndpoints::getCached(Kwf_Config::getValue('aws.simpleCacheCluster'));
     } else {
         if (Kwf_Cache_Simple::$memcacheHost) {
             $servers = array(array('host' => Kwf_Cache_Simple::$memcacheHost, 'port' => Kwf_Cache_Simple::$memcachePort));
         } else {
             throw new Kwf_Exception("no memcache configured");
         }
     }
     foreach ($servers as $s) {
         if (version_compare(phpversion('memcache'), '2.1.0') == -1 || phpversion('memcache') == '2.2.4') {
             // < 2.1.0
             $this->_memcache->addServer($s['host'], $s['port'], true, 1, 1, 1);
         } else {
             if (version_compare(phpversion('memcache'), '3.0.0') == -1) {
                 // < 3.0.0
                 $this->_memcache->addServer($s['host'], $s['port'], true, 1, 1, 1, true, null, 10000);
             } else {
                 $this->_memcache->addServer($s['host'], $s['port'], true, 1, 1, 1);
             }
         }
     }
     return true;
 }
Example #24
0
 /**
  * Constructs a new Log_display object.
  *
  * @param string $name     Ignored.
  * @param string $ident    The identity string.
  * @param array  $conf     The configuration array.
  * @param int    $level    Log messages up to and including this level.
  * @access public
  */
 function Log_display($name = '', $ident = '', $conf = array(), $level = PEAR_LOG_DEBUG)
 {
     if (!class_exists('G')) {
         $realdocuroot = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']);
         $docuroot = explode('/', $realdocuroot);
         array_pop($docuroot);
         $pathhome = implode('/', $docuroot) . '/';
         array_pop($docuroot);
         $pathTrunk = implode('/', $docuroot) . '/';
         require_once $pathTrunk . 'gulliver/system/class.g.php';
     }
     $this->_id = G::encryptOld(microtime());
     $this->_ident = $ident;
     $this->_mask = Log::UPTO($level);
     if (isset($conf['error_prepend'])) {
         $this->_error_prepend = $conf['error_prepend'];
     } else {
         $this->_error_prepend = ini_get('error_prepend_string');
     }
     if (isset($conf['error_append'])) {
         $this->_error_append = $conf['error_append'];
     } else {
         $this->_error_append = ini_get('error_append_string');
     }
     if (isset($conf['linebreak'])) {
         $this->_linebreak = $conf['linebreak'];
     }
 }
function check_php()
{
    $data = array();
    $data['errors'] = array();
    $data['caninstall'] = true;
    $ver = explode('.', PHP_VERSION);
    $ver_num = $ver[0] . $ver[1] . $ver[2];
    if ($ver_num < 500) {
        $data['caninstall'] = false;
        $data['errors'][] = array('level' => 'error', 'code' => 'php_version', 'message' => 'Votre version de PHP est trop vieille. Installez PHP 5.');
    } elseif ($ver_num < 529) {
        $data['errors'][] = array('level' => 'warning', 'code' => 'php_version', 'message' => 'Vous utilisez PHP ' . PHP_VERSION . ' !<br />Il est conseill&eacute; d\'utiliser au moins la version 5.2.9 de PHP.');
    } else {
        $data['errors'][] = array('level' => 'good', 'code' => 'php_version', 'message' => 'Votre version de PHP (' . PHP_VERSION . ') est support&eacute;e par Iconito.');
    }
    if (ini_get('session.auto_start')) {
        $data['caninstall'] = false;
        $data['errors'][] = array('level' => 'error', 'code' => 'session_autostart', 'message' => 'Vous devez d&eacute;sactiver la cr&eacute;ation de session automatique. Pour cela, modifiez la directive "session.auto_start" dans votre php.ini (pour tous vos sites), dans la configuration de votre virtualhost dans la configuration d\'Apache (pour ce site sp&eacute;cifiquement), ou dans le .htaccess d\'Iconito (dans le r&eacute;pertoire "Iconito/www").');
    } else {
        $data['errors'][] = array('level' => 'good', 'code' => 'session_autostart', 'message' => 'La cr&eacute;ation de session automatique est d&eacute;sactiv&eacute;e.');
    }
    $php_extensions = get_loaded_extensions();
    if (!in_array('xml', $php_extensions)) {
        $data['caninstall'] = false;
        $data['errors'][] = array('level' => 'error', 'code' => 'php_ext_xml', 'message' => 'Vous devez activer l\'extension "xml" dans PHP.');
    } else {
        $data['errors'][] = array('level' => 'good', 'code' => 'php_ext_xml', 'message' => 'L\'extension "xml" est activ&eacute;e.');
    }
    if (!in_array('session', $php_extensions)) {
        $data['caninstall'] = false;
        $data['errors'][] = array('level' => 'error', 'code' => 'php_ext_session', 'message' => 'Vous devez activer l\'extension "session" dans PHP.');
    } else {
        $data['errors'][] = array('level' => 'good', 'code' => 'php_ext_session', 'message' => 'L\'extension "session" est activ&eacute;e.');
    }
    if (!in_array('mysql', $php_extensions)) {
        $data['caninstall'] = false;
        $data['errors'][] = array('level' => 'error', 'code' => 'php_ext_mysql', 'message' => 'Vous devez activer l\'extension "mysql" dans PHP.');
    } else {
        $data['errors'][] = array('level' => 'good', 'code' => 'php_ext_mysql', 'message' => 'L\'extension "mysql" est activ&eacute;e.');
    }
    if (!in_array('gd', $php_extensions)) {
        $data['caninstall'] = false;
        $data['errors'][] = array('level' => 'error', 'code' => 'php_ext_gd', 'message' => 'Vous devez activer l\'extension "gd" dans PHP.');
    } else {
        $data['errors'][] = array('level' => 'good', 'code' => 'php_ext_gd', 'message' => 'L\'extension "gd" est activ&eacute;e.');
        if (!(imagetypes() & IMG_GIF)) {
            $data['caninstall'] = true;
            $data['errors'][] = array('level' => 'warning', 'code' => 'php_gd_gif', 'message' => 'Votre version de "gd" ne supporte pas l\'&eacute;criture du format GIF. Il est pr&eacute;f&eacute;rable de mettre &agrave; jour cette extension.');
        } else {
            $data['errors'][] = array('level' => 'good', 'code' => 'php_gd_gif', 'message' => 'Votre version de "gd" supporte le format GIF.');
        }
    }
    if (!in_array('zlib', $php_extensions)) {
        $data['caninstall'] = false;
        $data['errors'][] = array('level' => 'error', 'code' => 'php_ext_zlib', 'message' => 'Vous devez activer l\'extension "zlib" dans PHP.');
    } else {
        $data['errors'][] = array('level' => 'good', 'code' => 'php_ext_zlib', 'message' => 'L\'extension "zlib" est activ&eacute;e.');
    }
    return $data;
}
Example #26
0
 public static function start()
 {
     $OSCOM_Language = Registry::get('Language');
     $OSCOM_MessageStack = Registry::get('MessageStack');
     if (SERVICE_DEBUG_CHECK_LOCALE == '1') {
         $setlocale = setlocale(LC_TIME, explode(',', $OSCOM_Language->getLocale()));
         if ($setlocale === false || $setlocale === null) {
             $OSCOM_MessageStack->add('debug', 'Error: Locale does not exist: ' . $OSCOM_Language->getLocale(), 'error');
         }
     }
     if (SERVICE_DEBUG_CHECK_INSTALLATION_MODULE == '1' && file_exists(OSCOM::BASE_DIRECTORY . 'Core/Site/Setup')) {
         $OSCOM_MessageStack->add('debug', sprintf(OSCOM::getDef('warning_install_directory_exists'), OSCOM::BASE_DIRECTORY . 'Core/Site/Setup'), 'warning');
     }
     if (SERVICE_DEBUG_CHECK_CONFIGURATION == '1' && is_writeable(OSCOM::BASE_DIRECTORY . 'Config/settings.ini')) {
         $OSCOM_MessageStack->add('debug', sprintf(OSCOM::getDef('warning_config_file_writeable'), OSCOM::BASE_DIRECTORY . 'Config//settings.ini'), 'warning');
     }
     if (SERVICE_DEBUG_CHECK_SESSION_DIRECTORY == '1' && OSCOM::getConfig('store_sessions') == '') {
         if (!is_dir(OSCOM_Registry::get('Session')->getSavePath())) {
             $OSCOM_MessageStack->add('debug', sprintf(OSCOM::getDef('warning_session_directory_non_existent'), OSCOM_Registry::get('Session')->getSavePath()), 'warning');
         } elseif (!is_writeable(OSCOM_Registry::get('Session')->getSavePath())) {
             $OSCOM_MessageStack->add('debug', sprintf(OSCOM::getDef('warning_session_directory_not_writeable'), OSCOM_Registry::get('Session')->getSavePath()), 'warning');
         }
     }
     if (SERVICE_DEBUG_CHECK_SESSION_AUTOSTART == '1' && (bool) ini_get('session.auto_start')) {
         $OSCOM_MessageStack->add('debug', OSCOM::getDef('warning_session_auto_start'), 'warning');
     }
     if (SERVICE_DEBUG_CHECK_DOWNLOAD_DIRECTORY == '1' && DOWNLOAD_ENABLED == '1') {
         if (!is_dir(DIR_FS_DOWNLOAD)) {
             $OSCOM_MessageStack->add('debug', sprintf(OSCOM::getDef('warning_download_directory_non_existent'), DIR_FS_DOWNLOAD), 'warning');
         }
     }
     return true;
 }
Example #27
0
/**
 * Initialize session.
 * @param boolean $keepopen keep session open? The default is
 * 			to close the session after $_SESSION has been populated.
 * @uses $_SESSION
 */
function session_init($keepopen = false)
{
    $settings = new phpVBoxConfigClass();
    // Sessions provided by auth module?
    if (@$settings->auth->capabilities['sessionStart']) {
        call_user_func(array($settings->auth, $settings->auth->capabilities['sessionStart']), $keepopen);
        return;
    }
    // No session support? No login...
    if (@$settings->noAuth || !function_exists('session_start')) {
        global $_SESSION;
        $_SESSION['valid'] = true;
        $_SESSION['authCheckHeartbeat'] = time();
        $_SESSION['admin'] = true;
        return;
    }
    // start session
    session_start();
    // Session is auto-started by PHP?
    if (!ini_get('session.auto_start')) {
        ini_set('session.use_trans_sid', 0);
        ini_set('session.use_only_cookies', 1);
        // Session path
        if (isset($settings->sessionSavePath)) {
            session_save_path($settings->sessionSavePath);
        }
        session_name(isset($settings->session_name) ? $settings->session_name : md5('phpvbx' . $_SERVER['DOCUMENT_ROOT'] . $_SERVER['HTTP_USER_AGENT']));
        session_start();
    }
    if (!$keepopen) {
        session_write_close();
    }
}
Example #28
0
/**
 * Check if compression handler (ob_gzhandler) should be enabled. Note: this should not be used
 * as an indicator of whether output received by a client will be compressed, only whether an
 * output handler is used to compress output.
 * @return bool
 * @access public
 */
function compress_handler_is_enabled() {
	global $g_compress_html;

	// indicates compression should be disabled for a page. Note: php.ini may still enable zlib.output_compression.
	// it may be possible to turn this off through the use of ini_set within that specific page.
	if( defined( 'COMPRESSION_DISABLED' ) ) {
		return false;
	}

	// Dont use config_get here so only dependency is on consant.inc.php in this module
	// We only actively compress html if global configuration compress_html is set.
	if( ON == $g_compress_html ) {
		// both compression handlers require zlib module to be loaded
		if( !extension_loaded( 'zlib' ) ) {
			return false;
		}

		if ( ini_get( 'zlib.output_compression' ) ) {
			/* zlib output compression is already enabled - we can't load the gzip output handler */
			return false;
		}

		// Since php 5.2.10, it's possible to set zlib.output_compression via ini_set.
		// This method is preferred over ob_gzhandler
		if( php_version_at_least( '5.2.10' ) && ini_get( 'output_handler' ) == '' && function_exists( 'ini_set' ) ) {
			ini_set( 'zlib.output_compression', true );
			// do it transparently
			return false;
		}

		// if php.ini does not already use ob_gzhandler by default, return true.
		return ( 'ob_gzhandler' != ini_get( 'output_handler' ) );
	}
}
Example #29
0
 /**
  * @param array  $params
  * @param string $username
  * @param string $password
  * @param array  $driverOptions
  *
  * @throws \Doctrine\DBAL\Driver\Mysqli\MysqliException
  */
 public function __construct(array $params, $username, $password, array $driverOptions = array())
 {
     $port = isset($params['port']) ? $params['port'] : ini_get('mysqli.default_port');
     // Fallback to default MySQL port if not given.
     if (!$port) {
         $port = 3306;
     }
     $socket = isset($params['unix_socket']) ? $params['unix_socket'] : ini_get('mysqli.default_socket');
     $dbname = isset($params['dbname']) ? $params['dbname'] : null;
     $flags = isset($driverOptions[static::OPTION_FLAGS]) ? $driverOptions[static::OPTION_FLAGS] : null;
     $this->_conn = mysqli_init();
     $this->setDriverOptions($driverOptions);
     $previousHandler = set_error_handler(function () {
     });
     if (!$this->_conn->real_connect($params['host'], $username, $password, $dbname, $port, $socket, $flags)) {
         set_error_handler($previousHandler);
         $sqlState = 'HY000';
         if (@$this->_conn->sqlstate) {
             $sqlState = $this->_conn->sqlstate;
         }
         throw new MysqliException($this->_conn->connect_error, $sqlState, $this->_conn->connect_errno);
     }
     set_error_handler($previousHandler);
     if (isset($params['charset'])) {
         $this->_conn->set_charset($params['charset']);
     }
 }
Example #30
0
function eis_file(&$filename)
{
    if (defined('INCLUDE_PATH') && constant('INCLUDE_PATH')) {
        return array('.', INCLUDE_PATH);
    }
    $inc_path_delim = substr(PHP_OS, 0, 3) == 'WIN' ? ';' : ':';
    $path_delim = substr(PHP_OS, 0, 3) == 'WIN' ? "\\" : '/';
    $ipath = explode($inc_path_delim, ini_get('include_path'));
    $file = implode($path_delim, explode("/", $filename));
    //ищем файл
    $flag = false;
    foreach ($ipath as $path) {
        if ($path != ".") {
            $path = implode($path_delim, explode($path_delim, $path));
            //обрезаем последний слэш
            $path = implode($path_delim, explode($path_delim, $path)) . $path_delim . ENGINE_VERSION . $path_delim . ENGINE_TYPE . $path_delim;
        }
        if (is_file($path . $path_delim . $file)) {
            $flag = true;
            break;
        }
    }
    if ($flag) {
        $filename = $path . $path_delim . $file;
    }
    return $flag;
}