Пример #1
1
 function GPC()
 {
     if (!defined('str')) {
         define('str', 2);
     }
     if (!defined('int')) {
         define('int', 1);
     }
     if (!defined('arr_str')) {
         define('arr_str', 5);
     }
     if (!defined('arr_int')) {
         define('arr_int', 4);
     }
     if (!defined('none')) {
         define('none', 0);
     }
     if (!defined('arr_none')) {
         define('arr_none', 3);
     }
     if (!defined('db_esc')) {
         define('db_esc', 6);
     }
     if (!defined('html_enc')) {
         define('html_enc', 7);
     }
     if (!defined('path')) {
         define('path', 8);
     }
     $this->prepare_original = array('"', "'", '<', '>');
     $this->prepare_entity = array('&quot;', '&#039;', '&lt;', '&gt;');
     $this->php523 = version_compare(PHP_VERSION, '5.2.3', '>=');
 }
Пример #2
0
 public function __construct($options)
 {
     // we need at least PHP7
     if (version_compare(PHP_VERSION, '7.0.0') < 0) {
         throw new Exception("Foundation require PHP 7 or newer.");
     }
     // get all errors
     error_reporting(E_ALL);
     set_error_handler([$this, "errorHandler"]);
     // the application root is foundation directory's upper directory
     $this->rootpath = $options["rootpath"] ?? "../";
     $this->setupApplicationRoot();
     // application timezone
     $this->timezone = $options["timezone"] ?? "UTC";
     $this->setupApplicationTimezone();
     // environment
     $this->env = getenv("ENV") ?? "dev";
     // application namespace
     $this->namespace = $options["namespace"] ?? null;
     if (is_null($this->namespace)) {
         throw new Exception("App Namespace not given.");
     }
     // configure
     $this->config = (object) (require $this->rootpath . "/config/" . $this->env . ".php");
     // register autoloader
     $this->registerAutoloader();
 }
Пример #3
0
 protected function getInput()
 {
     JHTML::_('behavior.framework');
     $document =& JFactory::getDocument();
     if (!version_compare(JVERSION, '3.0', 'ge')) {
         $checkJqueryLoaded = false;
         $header = $document->getHeadData();
         foreach ($header['scripts'] as $scriptName => $scriptData) {
             if (substr_count($scriptName, '/jquery')) {
                 $checkJqueryLoaded = true;
             }
         }
         //Add js
         if (!$checkJqueryLoaded) {
             $document->addScript(JURI::root() . $this->element['path'] . 'js/jquery.min.js');
         }
         $document->addScript(JURI::root() . $this->element['path'] . 'js/chosen.jquery.min.js');
         $document->addStyleSheet(JURI::root() . $this->element['path'] . 'css/chosen.css');
     }
     $document->addScript(JURI::root() . $this->element['path'] . 'js/colorpicker/colorpicker.js');
     $document->addScript(JURI::root() . $this->element['path'] . 'js/jquery.lightbox-0.5.min.js');
     $document->addScript(JURI::root() . $this->element['path'] . 'js/btbase64.min.js');
     $document->addScript(JURI::root() . $this->element['path'] . 'js/bt.js');
     $document->addScript(JURI::root() . $this->element['path'] . 'js/script.js');
     //Add css
     $document->addStyleSheet(JURI::root() . $this->element['path'] . 'css/bt.css');
     $document->addStyleSheet(JURI::root() . $this->element['path'] . 'js/colorpicker/colorpicker.css');
     $document->addStyleSheet(JURI::root() . $this->element['path'] . 'css/jquery.lightbox-0.5.css');
     return null;
 }
Пример #4
0
 /**
  * @since	1.6
  */
 function display($tpl = null)
 {
     // Get data from the model
     $this->state = $this->get('State');
     $this->changeSet = $this->get('Items');
     $this->errors = $this->changeSet->check();
     $this->results = $this->changeSet->getStatus();
     $this->schemaVersion = $this->get('SchemaVersion');
     $this->updateVersion = $this->get('UpdateVersion');
     $this->filterParams = $this->get('DefaultTextFilters');
     $this->schemaVersion = $this->schemaVersion ? $this->schemaVersion : JText::_('JNONE');
     $this->updateVersion = $this->updateVersion ? $this->updateVersion : JText::_('JNONE');
     $this->pagination = $this->get('Pagination');
     $this->errorCount = count($this->errors);
     $errors = count($this->errors);
     if ($this->schemaVersion != $this->changeSet->getSchema()) {
         $this->errorCount++;
     }
     if (!$this->filterParams) {
         $this->errorCount++;
     }
     if (version_compare($this->updateVersion, VJOKTE) != 0) {
         $this->errorCount++;
     }
     parent::display($tpl);
 }
Пример #5
0
 public function activate()
 {
     if (!in_array('woocommerce/woocommerce.php', get_option('active_plugins')) || !defined('WC_VERSION') || !version_compare(WC_VERSION, '2.6', '>=')) {
         deactivate_plugins(plugin_basename(__FILE__));
         wp_die(sprintf(__('Для работы плагина eDostavka нужно установить %s! не ниже 2.6 версии'), '<a href="http://wordpress.org/extend/plugins/woocommerce/">WooCommerce</a>'));
     }
 }
Пример #6
0
 function load()
 {
     $this->values = array();
     if (JRequest::getCmd('from_display', false) == false) {
         $this->values[] = JHTML::_('select.option', '', JText::_('HIKA_INHERIT'));
     }
     $this->values[] = JHTML::_('select.optgroup', '-- ' . JText::_('FROM_HIKASHOP') . ' --');
     foreach ($this->default as $d) {
         $this->values[] = JHTML::_('select.option', $d, JText::_(strtoupper($d)));
     }
     if (version_compare(JVERSION, '1.6.0', '>=')) {
         $this->values[] = JHTML::_('select.optgroup', '-- ' . JText::_('FROM_HIKASHOP') . ' --');
     }
     $closeOpt = '';
     $values = $this->getLayout();
     foreach ($values as $value) {
         if (substr($value, 0, 1) == '#') {
             if (version_compare(JVERSION, '1.6.0', '>=') && !empty($closeOpt)) {
                 $this->values[] = JHTML::_('select.optgroup', $closeOpt);
             }
             $value = substr($value, 1);
             $closeOpt = '-- ' . JText::sprintf('FROM_TEMPLATE', basename($value)) . ' --';
             $this->values[] = JHTML::_('select.optgroup', $closeOpt);
         } else {
             $this->values[] = JHTML::_('select.option', $value, $value);
         }
     }
     if (version_compare(JVERSION, '1.6.0', '>=') && !empty($closeOpt)) {
         $this->values[] = JHTML::_('select.optgroup', $closeOpt);
     }
 }
 /**
  * @expectedException \Psy\Exception\FatalErrorException
  * @expectedExceptionMessage Can't use function return value in write context
  */
 public function testEmpty()
 {
     if (version_compare(PHP_VERSION, '5.5', '>=')) {
         $this->markTestSkipped();
     }
     $this->traverser->traverse($this->parse('empty(strtolower("A"))'));
 }
Пример #8
0
 public function testContainer()
 {
     $container = $this->createYamlBundleTestContainer();
     $this->assertInstanceOf('Symfony\\Bridge\\Doctrine\\Logger\\DbalLogger', $container->get('doctrine.dbal.logger'));
     $this->assertInstanceOf('Symfony\\Bridge\\Doctrine\\DataCollector\\DoctrineDataCollector', $container->get('data_collector.doctrine'));
     $this->assertInstanceOf('Doctrine\\DBAL\\Configuration', $container->get('doctrine.dbal.default_connection.configuration'));
     $this->assertInstanceOf('Doctrine\\Common\\EventManager', $container->get('doctrine.dbal.default_connection.event_manager'));
     $this->assertInstanceOf('Doctrine\\DBAL\\Connection', $container->get('doctrine.dbal.default_connection'));
     $this->assertInstanceOf('Doctrine\\Common\\Annotations\\Reader', $container->get('doctrine.orm.metadata.annotation_reader'));
     $this->assertInstanceOf('Doctrine\\ORM\\Configuration', $container->get('doctrine.orm.default_configuration'));
     $this->assertInstanceOf('Doctrine\\ORM\\Mapping\\Driver\\DriverChain', $container->get('doctrine.orm.default_metadata_driver'));
     $this->assertInstanceOf('Doctrine\\Common\\Cache\\ArrayCache', $container->get('doctrine.orm.default_metadata_cache'));
     $this->assertInstanceOf('Doctrine\\Common\\Cache\\ArrayCache', $container->get('doctrine.orm.default_query_cache'));
     $this->assertInstanceOf('Doctrine\\Common\\Cache\\ArrayCache', $container->get('doctrine.orm.default_result_cache'));
     $this->assertInstanceOf('Doctrine\\ORM\\EntityManager', $container->get('doctrine.orm.default_entity_manager'));
     $this->assertInstanceOf('Doctrine\\DBAL\\Connection', $container->get('database_connection'));
     $this->assertInstanceOf('Doctrine\\ORM\\EntityManager', $container->get('doctrine.orm.entity_manager'));
     $this->assertInstanceOf('Doctrine\\Common\\EventManager', $container->get('doctrine.orm.default_entity_manager.event_manager'));
     $this->assertInstanceOf('Doctrine\\Common\\EventManager', $container->get('doctrine.dbal.event_manager'));
     $this->assertInstanceOf('Symfony\\Bridge\\Doctrine\\CacheWarmer\\ProxyCacheWarmer', $container->get('doctrine.orm.proxy_cache_warmer'));
     $this->assertInstanceOf('Doctrine\\Common\\Persistence\\ManagerRegistry', $container->get('doctrine'));
     $this->assertInstanceOf('Symfony\\Bridge\\Doctrine\\Validator\\Constraints\\UniqueEntityValidator', $container->get('doctrine.orm.validator.unique'));
     $this->assertSame($container->get('my.platform'), $container->get('doctrine.dbal.default_connection')->getDatabasePlatform());
     $this->assertTrue(Type::hasType('test'));
     if (version_compare(PHP_VERSION, '5.3.6', '<')) {
         $this->assertInstanceOf('Doctrine\\DBAL\\Event\\Listeners\\MysqlSessionInit', $container->get('doctrine.dbal.default_connection.events.mysqlsessioninit'));
     } else {
         $this->assertFalse($container->has('doctrine.dbal.default_connection.events.mysqlsessioninit'));
     }
 }
Пример #9
0
 public function addGroup($user_id, $group_id, $only = NULL)
 {
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         // Joomla! 1.6+ code here
         $user = JFactory::getUser($user_id);
         //$user		= JUser::getInstance($user_id);
         //if you want the user to in ONLY  the group you are adding  set only to true
         if ($only) {
             foreach ($user->groups as $group) {
                 unset($user->groups[$group]);
             }
         }
         $user->groups[] = $group_id;
         // Bind the data.
         $user->bind($user->groups);
         $user->save();
     } else {
         // Joomla! 1.5 code here
         $user = new JUser();
         //$user = JFactory::getUser();
         $user->load($order->user_id);
         $user->gid = $core_user_new_gid;
         $user->save();
     }
 }
Пример #10
0
 /**
  * PRNG generator based on security principles 
  * at http://phpsecurity.readthedocs.org/en/latest/Insufficient-Entropy-For-Random-Values.html 
  * 
  * @param mixed $length 
  * @param mixed $strong 
  * @access public
  * @return void
  */
 public function getBytes($length, $strong = false)
 {
     $bytes = '';
     if (function_exists('openssl_random_pseudo_bytes')
         && (version_compare(PHP_VERSION, '5.3.4') >= 0
         || strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')
     ) {
         $bytes = openssl_random_pseudo_bytes($length, $usable);
         if (true === $usable) {
             return $bytes;
         }
     }
     if (function_exists('mcrypt_create_iv')
         && (version_compare(PHP_VERSION, '5.3.7') >= 0
         || strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN')
     ) {
         $bytes = mcrypt_create_iv($length, MCRYPT_DEV_URANDOM);
         if ($bytes !== false && strlen($bytes) === $length) {
             return $bytes;
         }
     }
     $checkAlternatives = (file_exists('/dev/urandom') && is_readable('/dev/urandom'))
         || class_exists('\\COM', false);
     if (true === $strong && false === $checkAlternatives) {
         throw new \Exception(
             'Unable to generate sufficiently strong random bytes due to a lack ',
             'of sources with sufficient entropy'
         );
     }
     $generator = $this->getAlternativeGenerator();
     return $generator->generate($length);
 }
Пример #11
0
 public function installStore()
 {
     $pkg = Package::getByHandle('vivid_store');
     if (version_compare($pkg->getPackageVersion(), '2.1', '<')) {
         Installer::renameDatabaseTables($pkg);
     }
     if (version_compare(APP_VERSION, '5.7.4', '<')) {
         Installer::refreshDatabase($pkg);
     }
     Installer::installSinglePages($pkg);
     Installer::installProductParentPage($pkg);
     Installer::installStoreProductPageType($pkg);
     Installer::updateConfigStorage($pkg);
     Installer::setDefaultConfigValues($pkg);
     Installer::installPaymentMethods($pkg);
     Installer::installShippingMethods($pkg);
     Installer::installBlocks($pkg);
     Installer::setPageTypeDefaults($pkg);
     Installer::installCustomerGroups($pkg);
     Installer::installUserAttributes($pkg);
     Installer::installOrderAttributes($pkg);
     Installer::installProductAttributes($pkg);
     Installer::createDDFileset($pkg);
     Installer::installOrderStatuses($pkg);
     Installer::installDefaultTaxClass($pkg);
     if (version_compare($pkg->getPackageVersion(), '3.0', '<')) {
         Installer::migrateOldShippingMethod($pkg);
         Installer::migrateOldTaxRates($pkg);
     }
 }
Пример #12
0
 /**
  * Loads assets from the supplied node.
  *
  * @param \Twig_Node $node
  *
  * @return array An array of asset formulae indexed by name
  */
 private function loadNode(\Twig_Node $node)
 {
     $formulae = array();
     if ($node instanceof AsseticNode) {
         $formulae[$node->getAttribute('name')] = array($node->getAttribute('inputs'), $node->getAttribute('filters'), array('output' => $node->getAttribute('asset')->getTargetPath(), 'name' => $node->getAttribute('name'), 'debug' => $node->getAttribute('debug'), 'combine' => $node->getAttribute('combine'), 'vars' => $node->getAttribute('vars')));
     } elseif ($node instanceof \Twig_Node_Expression_Function) {
         $name = version_compare(\Twig_Environment::VERSION, '1.2.0-DEV', '<') ? $node->getNode('name')->getAttribute('name') : $node->getAttribute('name');
         if ($this->twig->getFunction($name) instanceof AsseticFilterFunction) {
             $arguments = array();
             foreach ($node->getNode('arguments') as $argument) {
                 $arguments[] = eval('return ' . $this->twig->compile($argument) . ';');
             }
             $invoker = $this->twig->getExtension('assetic')->getFilterInvoker($name);
             $inputs = isset($arguments[0]) ? (array) $arguments[0] : array();
             $filters = $invoker->getFilters();
             $options = array_replace($invoker->getOptions(), isset($arguments[1]) ? $arguments[1] : array());
             if (!isset($options['name'])) {
                 $options['name'] = $invoker->getFactory()->generateAssetName($inputs, $filters, $options);
             }
             $formulae[$options['name']] = array($inputs, $filters, $options);
         }
     }
     foreach ($node as $child) {
         if ($child instanceof \Twig_Node) {
             $formulae += $this->loadNode($child);
         }
     }
     if ($node->hasAttribute('embedded_templates')) {
         foreach ($node->getAttribute('embedded_templates') as $child) {
             $formulae += $this->loadNode($child);
         }
     }
     return $formulae;
 }
Пример #13
0
 /**
  * 连接数据库方法
  * @access public
  */
 public function connect($config = '', $linkNum = 0, $autoConnection = false)
 {
     if (!isset($this->linkID[$linkNum])) {
         if (empty($config)) {
             $config = $this->config;
         }
         try {
             if (empty($config['dsn'])) {
                 $config['dsn'] = $this->parseDsn($config);
             }
             if (version_compare(PHP_VERSION, '5.3.6', '<=')) {
                 // 禁用模拟预处理语句
                 $this->options[PDO::ATTR_EMULATE_PREPARES] = false;
             }
             $this->linkID[$linkNum] = new PDO($config['dsn'], $config['username'], $config['password'], $this->options);
         } catch (\PDOException $e) {
             if ($autoConnection) {
                 trace($e->getMessage(), '', 'ERR');
                 return $this->connect($autoConnection, $linkNum);
             } elseif ($config['debug']) {
                 E($e->getMessage());
             }
         }
     }
     return $this->linkID[$linkNum];
 }
Пример #14
0
/**
 * This function calibrefx_update_check is to ...
 */
function calibrefx_update_check()
{
    global $wp_version;
    /** Get time of last update check */
    $calibrefx_update = get_transient('calibrefx-update');
    /** If it has expired, do an update check */
    if (!$calibrefx_update) {
        $url = 'http://api.calibrefx.com/themes-update/';
        $options = apply_filters('calibrefx_update_remote_post_options', array('body' => array('theme_name' => 'calibrefx', 'theme_version' => FRAMEWORK_VERSION, 'url' => home_url(), 'wp_version' => $wp_version, 'php_version' => phpversion(), 'user-agent' => "WordPress/{$wp_version};")));
        $response = wp_remote_post($url, $options);
        $calibrefx_update = wp_remote_retrieve_body($response);
        /** If an error occurred, return FALSE, store for 48 hour */
        if ('error' == $calibrefx_update || is_wp_error($calibrefx_update) || !is_serialized($calibrefx_update)) {
            set_transient('calibrefx-update', array('new_version' => FRAMEWORK_VERSION), 60 * 60 * 48);
            return false;
        }
        /** Else, unserialize */
        $calibrefx_update = maybe_unserialize($calibrefx_update);
        /** And store in transient for 48 hours */
        set_transient('calibrefx-update', $calibrefx_update, 60 * 60 * 48);
    }
    /** If we're already using the latest version, return false */
    if (version_compare(FRAMEWORK_VERSION, $calibrefx_update['new_version'], '>=')) {
        return false;
    }
    return $calibrefx_update;
}
Пример #15
0
 public function run()
 {
     // The only supported upgrade for this is 7.6.0.0RC4 to 7.6.0.0
     if (version_compare($this->from_version, '7.6.0.0RC4', '==') && version_compare($this->to_version, '7.6.0.0', '==')) {
         // Fill in any missing settings
         $defaults = get_sugar_config_defaults();
         foreach ($defaults as $key => $default) {
             if (!array_key_exists($key, $this->upgrader->config)) {
                 $this->log("Setting {$key} does not exist. Setting the default value.");
                 $this->upgrader->config[$key] = $default;
             }
         }
         // Get the known PMSE settings from the database
         $current = $this->getCurrentSettings();
         // Get the new default values
         $pmse = $this->getDefaultSettings();
         // If there is no current entry in sugar_config for PMSE settings...
         if (!isset($this->upgrader->config['pmse_settings_default'])) {
             // ... loop over current settings in the database, replacing default
             // settings with custom ones if they exist
             foreach ($current as $key => $val) {
                 $pmse[$key] = $val;
             }
             $this->upgrader->config['pmse_settings_default'] = $pmse;
         }
         // delete PMSESettings.php
         $this->fileToDelete('modules/pmse_Inbox/engine/PMSESettings.php');
     }
 }
Пример #16
0
 public static function getEmails($list_id = 0)
 {
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     //get Acymailing subscribers email
     $query->select('s.email')->from('#__acymailing_subscriber AS s')->join('LEFT', '#__acymailing_listsub AS l ON s.subid = l.subid')->where('l.listid = ' . (int) $list_id)->where('l.status = 1')->where('s.enabled = 1')->where('s.accept = 1');
     $db->setQuery($query);
     try {
         $emails = $db->loadColumn();
     } catch (RuntimeException $e) {
         if (PWEBCONTACT_DEBUG) {
             modPwebcontactHelper::setLog('Acymailing query error: ' . $e->getMessage());
         }
         return false;
     }
     if (version_compare(JVERSION, '3.0.0') == -1 and $error = $db->getErrorMsg()) {
         if (PWEBCONTACT_DEBUG) {
             modPwebcontactHelper::setLog('Acymailing query error: ' . $error);
         }
         return false;
     }
     if (is_array($emails) and count($emails)) {
         return $emails;
     }
     return false;
 }
 /**
  * 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;
 }
 public function setUp()
 {
     if (version_compare('3.6.0', PHPUnit_Runner_Version::id()) == 1) {
         $this->markTestSkipped('The tested class is not compatible with current version of PHPUnit.');
     }
     $this->constraint = new Phake_PHPUnit_VerifierResultConstraintV3d6();
 }
 public static function check_update($plugin_path, $plugin_slug, $plugin_url, $offering, $key, $version, $option)
 {
     $version_info = function_exists('get_site_transient') ? get_site_transient("gforms_userregistration_version") : get_transient("gforms_userregistration_version");
     //making the remote request for version information
     if (!$version_info) {
         //Getting version number
         $version_info = self::get_version_info($offering, $key, $version);
         self::set_version_info($version_info);
     }
     if ($version_info == -1) {
         return $option;
     }
     if (empty($option->response[$plugin_path])) {
         $option->response[$plugin_path] = new stdClass();
     }
     //Empty response means that the key is invalid. Do not queue for upgrade
     if (!$version_info["is_valid_key"] || version_compare($version, $version_info["version"], '>=')) {
         unset($option->response[$plugin_path]);
     } else {
         $option->response[$plugin_path]->url = $plugin_url;
         $option->response[$plugin_path]->slug = $plugin_slug;
         $option->response[$plugin_path]->package = str_replace("{KEY}", $key, $version_info["url"]);
         $option->response[$plugin_path]->new_version = $version_info["version"];
         $option->response[$plugin_path]->id = "0";
     }
     return $option;
 }
 /**
  * Class constructor
  *
  * @param	object	&$db	Database object
  * @return	void
  */
 public function __construct(&$db)
 {
     parent::__construct($db);
     if (version_compare($this->db->version(), '3.3', '<')) {
         $this->_create_table_if = FALSE;
     }
 }
Пример #21
0
 protected function getEnvironment()
 {
     if (version_compare(phpversion(), '5.3.0', '>=')) {
         return include 'PHP53/TestInclude.php';
     }
     return parent::getEnvironment();
 }
Пример #22
0
 /**
  * Construct the Google Client.
  *
  * @param $config Google_Config or string for the ini file to load
  */
 public function __construct($config = null)
 {
     if (is_string($config) && strlen($config)) {
         $config = new Google_Config($config);
     } else {
         if (!$config instanceof Google_Config) {
             $config = new Google_Config();
             if ($this->isAppEngine()) {
                 // Automatically use Memcache if we're in AppEngine.
                 $config->setCacheClass('Google_Cache_Memcache');
             }
             if (version_compare(phpversion(), "5.3.4", "<=") || $this->isAppEngine()) {
                 // Automatically disable compress.zlib, as currently unsupported.
                 $config->setClassConfig('Google_Http_Request', 'disable_gzip', true);
             }
         }
     }
     if ($config->getIoClass() == Google_Config::USE_AUTO_IO_SELECTION) {
         if (function_exists('curl_version') && function_exists('curl_exec') && !$this->isAppEngine()) {
             $config->setIoClass("Google_IO_Curl");
         } else {
             $config->setIoClass("Google_IO_Stream");
         }
     }
     $this->config = $config;
 }
Пример #23
0
 public function test_login()
 {
     global $phpbb_root_path, $phpEx;
     $db = $this->new_dbal();
     $config = new \phpbb\config\config(array('ip_login_limit_max' => 0, 'ip_login_limit_use_forwarded' => 0, 'max_login_attempts' => 0));
     $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
     $lang = new \phpbb\language\language($lang_loader);
     $request = $this->getMock('\\phpbb\\request\\request');
     $user = new \phpbb\user($lang, '\\phpbb\\datetime');
     $driver_helper = new \phpbb\passwords\driver\helper($config);
     $passwords_drivers = array('passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($config, $driver_helper), 'passwords.driver.bcrypt' => new \phpbb\passwords\driver\bcrypt($config, $driver_helper), 'passwords.driver.salted_md5' => new \phpbb\passwords\driver\salted_md5($config, $driver_helper), 'passwords.driver.phpass' => new \phpbb\passwords\driver\phpass($config, $driver_helper));
     $passwords_helper = new \phpbb\passwords\helper();
     // Set up passwords manager
     $passwords_manager = new \phpbb\passwords\manager($config, $passwords_drivers, $passwords_helper, array_keys($passwords_drivers));
     $phpbb_container = new phpbb_mock_container_builder();
     $provider = new \phpbb\auth\provider\db($db, $config, $passwords_manager, $request, $user, $phpbb_container, $phpbb_root_path, $phpEx);
     if (version_compare(PHP_VERSION, '5.3.7', '<')) {
         $password_hash = '$2a$10$e01Syh9PbJjUkio66eFuUu4FhCE2nRgG7QPc1JACalsPXcIuG2bbi';
     } else {
         $password_hash = '$2y$10$4RmpyVu2y8Yf/lP3.yQBquKvE54TCUuEDEBJYY6FDDFN3LcbCGz9i';
     }
     $expected = array('status' => LOGIN_SUCCESS, 'error_msg' => false, 'user_row' => array('user_id' => '1', 'username' => 'foobar', 'user_password' => $password_hash, 'user_passchg' => '0', 'user_email' => '*****@*****.**', 'user_type' => '0', 'user_login_attempts' => '0'));
     $login_return = $provider->login('foobar', 'example');
     $this->assertEquals($expected['status'], $login_return['status']);
     $this->assertEquals($expected['error_msg'], $login_return['error_msg']);
     foreach ($expected['user_row'] as $key => $value) {
         $this->assertEquals($value, $login_return['user_row'][$key]);
     }
     // Check if convert works
     $login_return = $provider->login('foobar2', 'example');
     $password_start = version_compare(PHP_VERSION, '5.3.7', '<') ? '$2a$10$' : '$2y$10$';
     $this->assertStringStartsWith($password_start, $login_return['user_row']['user_password']);
 }
Пример #24
0
 /**
  * Connect to server
  */
 function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
 {
     $this->persistency = $persistency;
     $this->user = $sqluser;
     $this->server = $sqlserver;
     $this->dbname = $database;
     $port = !$port ? NULL : $port;
     // Persistant connections not supported by the mysqli extension?
     $this->db_connect_id = @mysqli_connect($this->server, $this->user, $sqlpassword, $this->dbname, $port);
     if ($this->db_connect_id && $this->dbname != '') {
         @mysqli_query($this->db_connect_id, "SET NAMES 'utf8'");
         // enforce strict mode on databases that support it
         if (version_compare($this->sql_server_info(true), '5.0.2', '>=')) {
             $result = @mysqli_query($this->db_connect_id, 'SELECT @@session.sql_mode AS sql_mode');
             $row = @mysqli_fetch_assoc($result);
             @mysqli_free_result($result);
             $modes = array_map('trim', explode(',', $row['sql_mode']));
             // TRADITIONAL includes STRICT_ALL_TABLES and STRICT_TRANS_TABLES
             if (!in_array('TRADITIONAL', $modes)) {
                 if (!in_array('STRICT_ALL_TABLES', $modes)) {
                     $modes[] = 'STRICT_ALL_TABLES';
                 }
                 if (!in_array('STRICT_TRANS_TABLES', $modes)) {
                     $modes[] = 'STRICT_TRANS_TABLES';
                 }
             }
             $mode = implode(',', $modes);
             @mysqli_query($this->db_connect_id, "SET SESSION sql_mode='{$mode}'");
         }
         return $this->db_connect_id;
     }
     return $this->sql_error('');
 }
Пример #25
0
/**
 * Check if installation environment meets minimum PB requirements.
 * Can be shared by other plugins that depend on Pressbooks. Example usage:
 *
 *     if ( ! @include_once( WP_PLUGIN_DIR . '/pressbooks/compatibility.php' ) ) {
 *         add_action( 'admin_notices', function () {
 *             echo '<div id="message" class="error fade"><p>' . __( 'Cannot find Pressbooks install.', 'pressbooks' ) . '</p></div>';
 *         } );
 *         return;
 *     }
 *     elseif ( ! pb_meets_minimum_requirements() ) {
 *         return;
 *     }
 *
 *
 * @return bool
 */
function pb_meets_minimum_requirements()
{
    $is_compatible = true;
    // ---------------------------------------------------------------------------------------------------------------
    // PHP Version
    // ---------------------------------------------------------------------------------------------------------------
    // Override PHP version at your own risk!
    global $pb_minimum_php;
    if (empty($pb_minimum_php)) {
        $pb_minimum_php = '5.6.0';
    }
    if (!version_compare(PHP_VERSION, $pb_minimum_php, '>=')) {
        add_action('admin_notices', '_pb_minimum_php');
        $is_compatible = false;
    }
    // ---------------------------------------------------------------------------------------------------------------
    // WordPress Version
    // ---------------------------------------------------------------------------------------------------------------
    // Override WP version at your own risk!
    global $pb_minimum_wp;
    if (empty($pb_minimum_wp)) {
        $pb_minimum_wp = '4.4';
    }
    if (!is_multisite() || !version_compare(get_bloginfo('version'), $pb_minimum_wp, '>=')) {
        add_action('admin_notices', '_pb_minimum_wp');
        $is_compatible = false;
    }
    return $is_compatible;
}
Пример #26
0
 function wp_json_encode($data, $options = 0, $depth = 512)
 {
     /*
      * json_encode() has had extra params added over the years.
      * $options was added in 5.3, and $depth in 5.5.
      * We need to make sure we call it with the correct arguments.
      */
     if (version_compare(PHP_VERSION, '5.5', '>=')) {
         $args = array($data, $options, $depth);
     } elseif (version_compare(PHP_VERSION, '5.3', '>=')) {
         $args = array($data, $options);
     } else {
         $args = array($data);
     }
     $json = call_user_func_array('json_encode', $args);
     // If json_encode() was successful, no need to do more sanity checking.
     // ... unless we're in an old version of PHP, and json_encode() returned
     // a string containing 'null'. Then we need to do more sanity checking.
     if (false !== $json && (version_compare(PHP_VERSION, '5.5', '>=') || false === strpos($json, 'null'))) {
         return $json;
     }
     try {
         $args[0] = _wp_json_sanity_check($data, $depth);
     } catch (Exception $e) {
         return false;
     }
     return call_user_func_array('json_encode', $args);
 }
Пример #27
0
 function _Set_Timeout(&$res, $s, $m = 0)
 {
     if (version_compare(phpversion(), '4.3.0', '<')) {
         return socket_set_timeout($res, $s, $m);
     }
     return stream_set_timeout($res, $s, $m);
 }
Пример #28
0
 /**
  * @param string xml content
  * @return true|PEAR_Error
  */
 function parse($data)
 {
     if (!extension_loaded('xml')) {
         include_once 'PEAR.php';
         return PEAR::raiseError("XML Extension not found", 1);
     }
     $this->_dataStack = $this->_valStack = array();
     $this->_depth = 0;
     if (strpos($data, 'encoding="UTF-8"') || strpos($data, 'encoding="utf-8"') || strpos($data, "encoding='UTF-8'") || strpos($data, "encoding='utf-8'")) {
         $this->encoding = 'UTF-8';
     }
     if (version_compare(phpversion(), '5.0.0', 'lt') && $this->encoding == 'UTF-8') {
         $data = utf8_decode($data);
         $this->encoding = 'ISO-8859-1';
     }
     $xp = xml_parser_create($this->encoding);
     xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, 0);
     xml_set_object($xp, $this);
     xml_set_element_handler($xp, 'startHandler', 'endHandler');
     xml_set_character_data_handler($xp, 'cdataHandler');
     if (!xml_parse($xp, $data)) {
         $msg = xml_error_string(xml_get_error_code($xp));
         $line = xml_get_current_line_number($xp);
         xml_parser_free($xp);
         include_once 'PEAR.php';
         return PEAR::raiseError("XML Error: '{$msg}' on line '{$line}'", 2);
     }
     xml_parser_free($xp);
     return true;
 }
Пример #29
0
 function display($map, $values, $type = 'discount')
 {
     $id = $type . '_' . $map;
     $js = 'window.hikashop.ready( function(){ updateSubscription(\'' . $id . '\'); });';
     if (!HIKASHOP_PHP5) {
         $doc =& JFactory::getDocument();
     } else {
         $doc = JFactory::getDocument();
     }
     $doc->addScriptDeclaration($js);
     if (empty($values)) {
         $values = 'none';
     }
     $choiceValue = $values == 'none' ? $values : 'special';
     $return = JHTML::_('hikaselect.radiolist', $this->choice, "choice_" . $id, 'onchange="updateSubscription(\'' . $id . '\');"', 'value', 'text', $choiceValue);
     $return .= '<input type="hidden" name="data[' . $type . '][' . $map . ']" id="hidden_' . $id . '" value="' . $values . '"/>';
     $valuesArray = explode(',', $values);
     $listAccess = '<div style="display:none" id="div_' . $id . '"><table>';
     foreach ($this->groups as $oneGroup) {
         $listAccess .= '<tr><td>';
         if (version_compare(JVERSION, '1.6.0', '>=') || !in_array($oneGroup->value, array(29, 30))) {
             $listAccess .= '<input type="radio" onchange="updateSubscription(\'' . $id . '\');" value="' . $oneGroup->value . '" ' . (in_array($oneGroup->value, $valuesArray) ? 'checked' : '') . ' name="special_' . $id . '" id="special_' . $id . '_' . $oneGroup->value . '"/>';
         }
         $listAccess .= '</td><td><label for="special_' . $id . '_' . $oneGroup->value . '">' . $oneGroup->text . '</label></td></tr>';
     }
     $listAccess .= '</table></div>';
     $return .= $listAccess;
     return $return;
 }
Пример #30
0
 /**
  * ALTER TABLE
  *
  * @param    string $alter_type ALTER type
  * @param    string $table Table name
  * @param    mixed $field Column definition
  * @return    string|string[]
  */
 protected function _alter_table($alter_type, $table, $field)
 {
     if (in_array($alter_type, array('DROP', 'ADD'), TRUE)) {
         return parent::_alter_table($alter_type, $table, $field);
     }
     $sql = 'ALTER TABLE ' . $this->db->escape_identifiers($table);
     $sqls = array();
     for ($i = 0, $c = count($field); $i < $c; $i++) {
         if ($field[$i]['_literal'] !== FALSE) {
             return FALSE;
         }
         if (version_compare($this->db->version(), '8', '>=') && isset($field[$i]['type'])) {
             $sqls[] = $sql . ' ALTER COLUMN ' . $this->db->escape_identifiers($field[$i]['name']) . ' TYPE ' . $field[$i]['type'] . $field[$i]['length'];
         }
         if (!empty($field[$i]['default'])) {
             $sqls[] = $sql . ' ALTER COLUMN ' . $this->db->escape_identifiers($field[$i]['name']) . ' SET DEFAULT ' . $field[$i]['default'];
         }
         if (isset($field[$i]['null'])) {
             $sqls[] = $sql . ' ALTER COLUMN ' . $this->db->escape_identifiers($field[$i]['name']) . ($field[$i]['null'] === TRUE ? ' DROP NOT NULL' : ' SET NOT NULL');
         }
         if (!empty($field[$i]['new_name'])) {
             $sqls[] = $sql . ' RENAME COLUMN ' . $this->db->escape_identifiers($field[$i]['name']) . ' TO ' . $this->db->escape_identifiers($field[$i]['new_name']);
         }
     }
     return $sqls;
 }