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; } }
function _testXPath($xpath_expression) { if (!class_exists('DOMDocument') || !class_exists('DOMXPath')) { if (function_exists('domxml_open_mem')) { $dom = domxml_open_mem($this->_response); if (!$dom) { $this->fail('Error parsing doc'); return false; } var_dump($dom); $xpath = $dom->xpath_init(); var_dump($xpath); $ctx = $dom->xpath_new_context(); var_dump($xpath_expression); $result = $ctx->xpath_eval($xpath_expression); var_dump($result); $return = new stdClass(); $return->length = count($result->nodeset); return $return; } $this->fail('No xpath support built in'); return false; } else { if (extension_loaded('domxml')) { $this->fail('Please disable the domxml extension. Only php5 builtin domxml is supported'); return false; } } $dom = new DOMDocument(); $dom->loadHtml($this->_response); $xpath = new DOMXPath($dom); $node = $xpath->query($xpath_expression); return $node; }
/** * Constructor * * @param array $options associative array of options * @throws Zend_Cache_Exception * @return void */ public function __construct(array $options = array()) { if (!extension_loaded('memcache')) { Zend_Cache::throwException('The memcache extension must be loaded for using this backend !'); } parent::__construct($options); if (isset($this->_options['servers'])) { $value = $this->_options['servers']; if (isset($value['host'])) { // in this case, $value seems to be a simple associative array (one server only) $value = array(0 => $value); // let's transform it into a classical array of associative arrays } $this->setOption('servers', $value); } $this->_memcache = new Memcache(); foreach ($this->_options['servers'] as $server) { if (!array_key_exists('persistent', $server)) { $server['persistent'] = Zend_Cache_Backend_Memcached::DEFAULT_PERSISTENT; } if (!array_key_exists('port', $server)) { $server['port'] = Zend_Cache_Backend_Memcached::DEFAULT_PORT; } $this->_memcache->addServer($server['host'], $server['port'], $server['persistent']); } }
public function init() { $this->settings = get_option('ninja_forms_settings'); if (!extension_loaded('curl')) { throw new Exception(sprintf(__('The cURL extension is not loaded. %sPlease ensure its installed and activated.%s', 'ninja-forms-upload'), '<a href="http://php.net/manual/en/curl.installation.php">', '</a>')); } $this->oauth = new Dropbox_OAuth_Consumer_Curl(self::CONSUMER_KEY, self::CONSUMER_SECRET); $this->oauth_state = $this->get_option('dropbox_oauth_state'); $this->request_token = $this->get_token('request'); $this->access_token = $this->get_token('access'); if ($this->oauth_state == 'request') { //If we have not got an access token then we need to grab one try { $this->oauth->setToken($this->request_token); $this->access_token = $this->oauth->getAccessToken(); $this->oauth_state = 'access'; $this->oauth->setToken($this->access_token); $this->save_tokens(); //Supress the error because unlink, then init should be called } catch (Exception $e) { } } elseif ($this->oauth_state == 'access') { $this->oauth->setToken($this->access_token); } else { //If we don't have an acess token then lets setup a new request $this->request_token = $this->oauth->getRequestToken(); $this->oauth->setToken($this->request_token); $this->oauth_state = 'request'; $this->save_tokens(); } $this->dropbox = new Dropbox_API($this->oauth); }
public function refresh($force = false) { if (extension_loaded('curl')) { $data = array(); if ($force) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency WHERE code != '" . $this->db->escape($this->config->get('config_currency')) . "'"); } else { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency WHERE code != '" . $this->db->escape($this->config->get('config_currency')) . "' AND date_modified < '" . $this->db->escape(date('Y-m-d H:i:s', strtotime('-1 day'))) . "'"); } foreach ($query->rows as $result) { $data[] = $this->config->get('config_currency') . $result['code'] . '=X'; } $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'http://download.finance.yahoo.com/d/quotes.csv?s=' . implode(',', $data) . '&f=sl1&e=.csv'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($curl, CURLOPT_TIMEOUT, 30); $content = curl_exec($curl); curl_close($curl); $lines = explode("\n", trim($content)); foreach ($lines as $line) { $currency = utf8_substr($line, 4, 3); $value = utf8_substr($line, 11, 6); if ((double) $value) { $this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '" . (double) $value . "', date_modified = '" . $this->db->escape(date('Y-m-d H:i:s')) . "' WHERE code = '" . $this->db->escape($currency) . "'"); } } $this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '1.00000', date_modified = '" . $this->db->escape(date('Y-m-d H:i:s')) . "' WHERE code = '" . $this->db->escape($this->config->get('config_currency')) . "'"); $this->cache->delete('currency'); } }
/** * Constructor * * @param array $opts * @return void * @throws Zend\Serializer\Exception if wddx extension not found */ public function __construct($opts = array()) { if (!extension_loaded('wddx')) { throw new ExtensionNotLoadedException('PHP extension "wddx" is required for this adapter'); } parent::__construct($opts); }
public function check() { if (phpversion() < '5.0.0') { return Response::json(FAIL, array('您的php版本过低,不能安装本软件,请升级到5.0.0或更高版本再安装,谢谢!')); } if (!extension_loaded('PDO')) { return Response::json(FAIL, array('请加载PHP的PDO模块,谢谢!')); } if (!function_exists('session_start')) { return Response::json(FAIL, array('请开启session,谢谢!')); } if (!is_writable(ROOT_PATH)) { return Response::json(FAIL, array('请保证代码目录有写权限,谢谢!')); } $config = (require CONFIG_PATH . 'mysql.php'); try { $mysql = new PDO('mysql:host=' . $config['master']['host'] . ';port=' . $config['master']['port'], $config['master']['user'], $config['master']['pwd']); } catch (Exception $e) { return Response::json(FAIL, array('请正确输入信息连接mysql,保证启动mysql,谢谢!')); } $mysql->exec('CREATE DATABASE ' . $config['master']['dbname']); $mysql = null; unset($config); return Response::json(SUCC, array('检测通过')); }
/** * @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; }
public function displayList() { global $cookie, $currentIndex; $warnings = array(); if (!file_exists(_PS_ROOT_DIR_ . '/.htaccess')) { $warnings[] = $this->l('In order to enable the PrestaShop Webservice, please generate the .htaccess file via the "Generators" tab (in the "Tools" tab).'); } if (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') === false) { $warnings[] = $this->l('To avoid operating problems, please use an Apache server.'); } if (function_exists('apache_get_modules')) { $apache_modules = apache_get_modules(); if (!in_array('mod_auth_basic', $apache_modules)) { $warnings[] = $this->l('Please activate the Apache module \'mod_auth_basic\' to allow authentication of PrestaShop webservice.'); } if (!in_array('mod_rewrite', $apache_modules)) { $warnings[] = $this->l('Please activate the Apache module \'mod_rewrite\' to allow using the PrestaShop webservice.'); } } else { $warnings[] = $this->l('We could not check if basic authentication and rewrite extensions are activated. Please manually check if they are activated in order to use the PrestaShop webservice.'); } if (!extension_loaded('SimpleXML')) { $warnings[] = $this->l('Please activate the PHP extension \'SimpleXML\' to allow testing of PrestaShop webservice.'); } if (!configuration::get('PS_SSL_ENABLED')) { $warnings[] = $this->l('If possible, it is preferable to use SSL (https) for webservice calls, as it avoids the security issues of type "man in the middle".'); } $this->displayWarning($warnings); foreach ($this->_list as $k => $item) { if ($item['is_module'] && $item['class_name'] && $item['module_name'] && ($instance = Module::getInstanceByName($item['module_name'])) && !$instance->useNormalPermissionBehaviour()) { unset($this->_list[$k]); } } parent::displayList(); }
/** * Apply Spanish normalizing logic to string. * * @param array $words * @return array */ public static function stemWord($string) { if (extension_loaded('stem')) { return stem_spanish($string); } return $string; }
public function setUp() { if (!extension_loaded('openssl')) { $this->markTestSkipped('Tests_HTTP_Functions requires openssl.'); } parent::setUp(); }
private function _processXmlResponse($url, $xml = '') { /* A private utility method used by other public methods to process XML responses. */ if (extension_loaded('curl')) { $ch = curl_init() or die(curl_error()); $timeout = 10; curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); if (!empty($xml)) { curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/xml', 'Content-length: ' . strlen($xml))); } $data = curl_exec($ch); curl_close($ch); if ($data) { return new \SimpleXMLElement($data); } else { return false; } } if (!empty($xml)) { throw new Exception('Set xml, but curl does not installed.'); } return simplexml_load_file($url); }
/** * Verify that we can support the curl extention. * If this is not the case we will throw a BadFunctionCallException. * * @throws BadFunctionCallException * @return bool */ public function verifySupport() { if (!extension_loaded('curl')) { throw new \BadFunctionCallException('The cURL extension is required.'); } return true; }
/** +---------------------------------------------------------- * 架构函数 +---------------------------------------------------------- * @access public +---------------------------------------------------------- * @param array $config 数据库配置数组 +---------------------------------------------------------- */ public function __construct($config = '') { if (!extension_loaded('mysql')) { throw_exception(L('_NOT_SUPPERT_') . ':mysql'); } $this->config = $this->parseConfig($config); }
/** * Class constructor * * @param array|Zend_Config|null $options (Optional) Options to set */ public function __construct($options = null) { if (!extension_loaded('zlib')) { throw new Zend_Filter_Exception('This filter needs the zlib extension'); } parent::__construct($options); }
private function send($url, $headers, $data) { if (!extension_loaded('curl')) { die('Sorry cURL is not installed!'); } $uri = HydnaUtil::parse_uri($url); $curl_handle = curl_init(); $conn = sprintf('%s://%s:%d%s', $uri['scheme'], $uri['host'], $uri['port'], $uri['channel']); if (!empty($uri['token'])) { $conn .= sprintf('?%s', $uri['token']); } curl_setopt($curl_handle, CURLOPT_URL, $conn); curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, Hydna::$TIMEOUT); curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_handle, CURLOPT_HTTPHEADER, $headers); $data = HydnaUtil::clean_payload($data); curl_setopt($curl_handle, CURLOPT_POST, true); curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $data); $result = curl_exec($curl_handle); $code = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE); curl_close($curl_handle); if ($code != 200) { throw new Exception("Error, response code: " . $code); } return true; }
/** * Constructor * * @param array $options associative array of options * @throws Zend_Cache_Exception * @return void */ public function __construct(array $options = array()) { if (!extension_loaded('xcache')) { Zend_Cache::throwException('The xcache extension must be loaded for using this backend !'); } parent::__construct($options); }
public function escape(array $values) { if (extension_loaded("mbstring")) { $toEnc = defined("SDB_MSSQL_ENCODING") ? SDB_MSSQL_ENCODING : "SJIS"; $fromEnc = mb_internal_encoding(); $currentRegexEnc = mb_regex_encoding(); mb_regex_encoding($fromEnc); foreach ($values as $k => &$val) { if (is_bool($val)) { $val = $val ? "1" : "0"; } elseif (is_string($val)) { $val = "'" . mb_convert_encoding(mb_ereg_replace("'", "''", $val), $toEnc, $fromEnc) . "'"; } } mb_regex_encoding($currentRegexEnc); } else { foreach ($values as &$val) { if (is_bool($val)) { $val = $val ? "1" : "0"; } elseif (is_string($val)) { $val = "'" . str_replace("'", "''", $val) . "'"; } } } return $values; }
/** * Check if php GD library is installed or not * @last edit: $arsalanshah * @Reason: Initial; * */ public static function isPhpGd() { if (extension_loaded('gd') && function_exists('gd_info')) { return true; } return false; }
/** * Class constructor */ public function __construct() { if (!extension_loaded('lzf')) { require_once 'Zend/Filter/Exception.php'; throw new Zend_Filter_Exception('This filter needs the lzf extension'); } }
/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @return void */ protected function setUp() { include_once JPATH_PLATFORM . '/joomla/cache/storage.php'; include_once JPATH_PLATFORM . '/joomla/cache/storage/xcache.php'; $this->xcacheAvailable = extension_loaded('xcache'); $this->object = JCacheStorage::getInstance('xcache'); }
/** * Checks if ImageMagick is enabled. * * @throws Gleez_Exception * @return boolean */ public static function check() { if (!extension_loaded('imagick')) { throw new Gleez_Exception('Imagick is not installed, or the extension is not loaded'); } return Image_Imagick::$_checked = TRUE; }
/** * constructor * * @param array $options associative array of cache driver options */ public function __construct($options = array()) { if (!extension_loaded('memcache')) { throw new Doctrine_Cache_Exception('In order to use Memcache driver, the memcache extension must be loaded.'); } parent::__construct($options); if (isset($options['servers'])) { $value = $options['servers']; if (isset($value['host'])) { // in this case, $value seems to be a simple associative array (one server only) $value = array(0 => $value); // let's transform it into a classical array of associative arrays } $this->setOption('servers', $value); } $this->_memcache = new Memcache(); foreach ($this->_options['servers'] as $server) { if (!array_key_exists('persistent', $server)) { $server['persistent'] = true; } if (!array_key_exists('port', $server)) { $server['port'] = 11211; } $this->_memcache->addServer($server['host'], $server['port'], $server['persistent']); } }
/** * 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' ) ); } }
protected function setUp() { if (!extension_loaded('curl')) { $this->markTestSuiteSkipped('Curl extension is not available.'); } echo "\n\n--------------\nExecuting Curl Proxy\n\n"; }
public function getStep2() { $this->layout->step = 2; $data['req']['php_version'] = PHP_VERSION_ID >= 50400; $data['req']['mcrypt'] = extension_loaded('mcrypt'); $data['req']['pdo'] = extension_loaded('pdo_mysql'); if (function_exists('apache_get_modules')) { $data['req']['rewrite'] = in_array('mod_rewrite', apache_get_modules()); } $dirs = array($_SERVER['DOCUMENT_ROOT'] . '/apps/frontend/storage/', $_SERVER['DOCUMENT_ROOT'] . '/apps/backend/storage/', $_SERVER['DOCUMENT_ROOT'] . '/upload/', $_SERVER['DOCUMENT_ROOT'] . '/install/', $_SERVER['DOCUMENT_ROOT'] . '/apps/frontend/config/', $_SERVER['DOCUMENT_ROOT'] . '/apps/backend/config/'); foreach ($dirs as $path) { $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST); foreach ($iterator as $item) { @chmod($item, 0777); } } $data['req']['wr_fr_storage'] = is_writable($_SERVER['DOCUMENT_ROOT'] . '/apps/frontend/storage/'); $data['req']['wr_bk_storage'] = is_writable($_SERVER['DOCUMENT_ROOT'] . '/apps/backend/storage/'); $data['req']['wr_upload'] = is_writable($_SERVER['DOCUMENT_ROOT'] . '/upload/'); $data['req']['wr_install'] = is_writable($_SERVER['DOCUMENT_ROOT'] . '/install/'); $data['req']['wr_fr_db'] = is_writable($_SERVER['DOCUMENT_ROOT'] . '/apps/frontend/config/'); $data['req']['wr_bk_db'] = is_writable($_SERVER['DOCUMENT_ROOT'] . '/apps/backend/config/'); $data['valid_step'] = true; foreach ($data['req'] as $valid) { $data['valid_step'] = $data['valid_step'] && $valid; } Session::put('step2', $data['valid_step']); $this->layout->content = View::make('install::step2', $data); return $this->layout; }
public function updateCurrencies() { if (extension_loaded('curl')) { $data = array(); $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency WHERE code != '" . $this->db->escape($this->config->get('config_currency')) . "' AND date_modified > '" . date(strtotime('-1 day')) . "'"); foreach ($query->rows as $result) { $data[] = $this->config->get('config_currency') . $result['code'] . '=X'; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://download.finance.yahoo.com/d/quotes.csv?s=' . implode(',', $data) . '&f=sl1&e=.csv'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $content = curl_exec($ch); curl_close($ch); $lines = explode("\n", trim($content)); foreach ($lines as $line) { $currency = substr($line, 4, 3); $value = substr($line, 11, 6); if ((double) $value) { $this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '" . (double) $value . "', date_modified = NOW() WHERE code = '" . $this->db->escape($currency) . "'"); } } $this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '1.00000', date_modified = NOW() WHERE code = '" . $this->db->escape($this->config->get('config_currency')) . "'"); $this->cache->delete('currency'); } }
protected function execute(InputInterface $input, OutputInterface $output) { $manifest = $input->getOption('manifest') ?: 'https://platform.sh/cli/manifest.json'; $currentVersion = $input->getOption('current-version') ?: $this->getApplication()->getVersion(); if (extension_loaded('Phar') && !($localPhar = \Phar::running(false))) { $this->stdErr->writeln('This instance of the CLI was not installed as a Phar archive.'); if (file_exists(CLI_ROOT . '/../../autoload.php')) { $this->stdErr->writeln('Update using: <info>composer global update</info>'); } return 1; } $manager = new Manager(Manifest::loadFile($manifest)); if (isset($localPhar)) { $manager->setRunningFile($localPhar); } $onlyMinor = !$input->getOption('major'); $updated = $manager->update($currentVersion, $onlyMinor); if ($updated) { $this->stdErr->writeln("Successfully updated"); $localPhar = $manager->getRunningFile(); passthru('php ' . escapeshellarg($localPhar) . ' --version'); } else { $this->stdErr->writeln("No updates found. The Platform.sh CLI is up-to-date."); } return 0; }
/** * Class constructor * Available options * 'public' => public key * 'private' => private key * 'envelope' => envelope key * 'passphrase' => passphrase * 'compression' => compress value with this compression adapter * 'package' => pack envelope keys into encrypted string, simplifies decryption * * @param string|array $options Options for this adapter */ public function __construct($options = array()) { if (!extension_loaded('openssl')) { require_once 'Zend/Filter/Exception.php'; throw new Zend_Filter_Exception('This filter needs the openssl extension'); } if ($options instanceof Zend_Config) { $options = $options->toArray(); } if (!is_array($options)) { $options = array('public' => $options); } if (array_key_exists('passphrase', $options)) { $this->setPassphrase($options['passphrase']); unset($options['passphrase']); } if (array_key_exists('compression', $options)) { $this->setCompression($options['compression']); unset($options['compress']); } if (array_key_exists('package', $options)) { $this->setPackage($options['package']); unset($options['package']); } $this->_setKeys($options); }
protected function setUp() { if (!extension_loaded('curl')) { $this->markTestSkipped('cURL is not installed, marking all Http Client Curl Adapter tests skipped.'); } parent::setUp(); }