Beispiel #1
1
 public function index()
 {
     $os = explode(' ', php_uname());
     $mysql_support = function_exists('mysql_close') ? '<font color="green">√</font>' : '<font color="red">×</font>';
     $register_globals = get_cfg_var("register_globals") ? '<font color="green">√</font>' : '<font color="red">×</font>';
     $enable_dl = get_cfg_var("enable_dl") ? '<font color="green">√</font>' : '<font color="red">×</font>';
     $allow_url_fopen = get_cfg_var("allow_url_fopen") ? '<font color="green">√</font>' : '<font color="red">×</font>';
     $display_errors = get_cfg_var("display_errors") ? '<font color="green">√</font>' : '<font color="red">×</font>';
     $session_support = function_exists('session_start') ? '<font color="green">√</font>' : '<font color="red">×</font>';
     $config['server_name'] = $_SERVER['SERVER_NAME'];
     $config['server_ip'] = @gethostbyname($_SERVER['SERVER_NAME']);
     $config['server_time'] = date("Y年n月j日 H:i:s");
     $config['os'] = $os[0];
     $config['os_core'] = $os[2];
     $config['server_root'] = dirname(dirname($_SERVER['SCRIPT_FILENAME']));
     $config['server_engine'] = $_SERVER['SERVER_SOFTWARE'];
     $config['server_port'] = $_SERVER['SERVER_PORT'];
     $config['php_version'] = PHP_VERSION;
     $config['php_run_type'] = strtoupper(php_sapi_name());
     $config['mysql_support'] = $mysql_support;
     $config['register_globals'] = $register_globals;
     $config['allow_url_fopen'] = $allow_url_fopen;
     $config['display_errors'] = $display_errors;
     $config['enable_dl'] = $enable_dl;
     $config['memory_limit'] = get_cfg_var("memory_limit");
     $config['post_max_size'] = get_cfg_var("post_max_size");
     $config['upload_max_filesize'] = get_cfg_var("upload_max_filesize");
     $config['max_execution_time'] = get_cfg_var("max_execution_time");
     $config['session_support'] = $session_support;
     $this->config_arr = $config;
     $this->display();
 }
Beispiel #2
1
 function Create($proto)
 {
     if ($this->debug) {
         e("SAMConnection.Create(proto={$proto})");
     }
     $rc = false;
     /* search the PHP config for a factory to use...    */
     $x = get_cfg_var('sam.factory.' . $proto);
     if ($this->debug) {
         t('SAMConnection.Create() get_cfg_var() "' . $x . '"');
     }
     /* If there is no configuration (php.ini) entry for this protocol, default it.  */
     if (strlen($x) == 0) {
         /* for every protocol other than MQTT assume we will use XMS    */
         if ($proto != 'mqtt') {
             $x = 'xms';
         } else {
             $x = 'mqtt';
         }
     }
     /* Invoke the chosen factory to create a real connection object...   */
     $x = 'sam_factory_' . $x . '.php';
     if ($this->debug) {
         t("SAMConnection.Create() calling factory - {$x}");
     }
     $rc = (include $x);
     if ($this->debug && $rc) {
         t('SAMConnection.Create() rc = ' . get_class($rc));
     }
     if ($this->debug) {
         x('SAMConnection.Create()');
     }
     return $rc;
 }
Beispiel #3
0
function optimizeDB($text)
{
    global $pathToIndex;
    // SETTING BEGIN
    // Run the task every n days
    $scheduleDays = 10;
    // SETTING END
    $loggixDB = $pathToIndex . Loggix_Core::LOGGIX_SQLITE_3;
    $filename = $loggixDB . '.BAK';
    if (!file_exists($filename) || filemtime($filename) + 86400 * $scheduleDays <= time()) {
        if (copy($loggixDB, $filename)) {
            chmod($filename, 0666);
            $backupDB = 'sqlite:' . $filename;
            $bdb = new PDO($backupDB);
            // Garbage Collection (/admin/delete.php)
            $maxLifeTime = get_cfg_var("session.gc_maxlifetime");
            $expirationTime = time() - $maxLifeTime;
            $sql = 'DELETE FROM ' . SESSION_TABLE . ' ' . 'WHERE ' . "sess_date < '" . $expirationTime . "'";
            $bdb->query($sql);
            // Vacuum DB
            $bdb->query('VACUUM');
            if (rename($loggixDB, $loggixDB . '.OLD')) {
                copy($filename, $loggixDB);
                chmod($loggixDB, 0666);
            }
            if (file_exists($loggixDB)) {
                unlink($loggixDB . '.OLD');
            }
        }
    }
    return $text;
}
Beispiel #4
0
 function out_buffer_mode_get()
 {
     if (@function_exists('ob_start')) {
         $mode = 1;
     } else {
         $mode = 0;
     }
     /**
      * If a user sets the output_handler in php.ini to ob_gzhandler, then
      * any right frame file in phpMyAdmin will not be handled properly by the
      * browser. My fix was to check the ini file within the
      * out_buffer_mode_get() function.
      *
      * (Patch by Garth Gillespie, modified by Marc Delisle)
      */
     if (@function_exists('ini_get')) {
         if (@ini_get('output_handler') == 'ob_gzhandler') {
             $mode = 0;
         }
     } else {
         if (@get_cfg_var('output_handler') == 'ob_gzhandler') {
             $mode = 0;
         }
     }
     // End patch
     # Zero (0) is no mode or in other words output buffering is OFF.
     # Follow 2^0, 2^1, 2^2, 2^3 type values for the modes.
     # Usefull if we ever decide to combine modes.  Then a bitmask
     # field of the sum of all modes will be the natural choice.
     //header("X-ob_mode: $mode");
     return $mode;
 }
Beispiel #5
0
 /**
  * @copydoc Form::display
  */
 function display($request = null, $template = null)
 {
     import('lib.pkp.classes.xslt.XSLTransformer');
     $templateMgr = TemplateManager::getManager($request);
     $templateMgr->assign(array('localeOptions' => $this->supportedLocales, 'localesComplete' => $this->localesComplete, 'clientCharsetOptions' => $this->supportedClientCharsets, 'connectionCharsetOptions' => $this->supportedConnectionCharsets, 'databaseCharsetOptions' => $this->supportedDatabaseCharsets, 'allowFileUploads' => get_cfg_var('file_uploads') ? __('common.yes') : __('common.no'), 'maxFileUploadSize' => get_cfg_var('upload_max_filesize'), 'databaseDriverOptions' => $this->checkDBDrivers(), 'supportsMBString' => PKPString::hasMBString() ? __('common.yes') : __('common.no'), 'phpIsSupportedVersion' => version_compare(PHP_REQUIRED_VERSION, PHP_VERSION) != 1, 'xslEnabled' => XSLTransformer::checkSupport(), 'xslRequired' => REQUIRES_XSL, 'phpRequiredVersion' => PHP_REQUIRED_VERSION, 'phpVersion' => PHP_VERSION));
     parent::display();
 }
 function osTicketSession($ttl = 0)
 {
     $this->ttl = $ttl ? $ttl : get_cfg_var('session.gc_maxlifetime');
     if (!$this->ttl) {
         $this->ttl = SESSION_TTL;
     }
     session_name('OSTSESSID');
     if (OsticketConfig::getDBVersion()) {
         return session_start();
     } elseif (defined('DISABLE_SESSION')) {
         return;
     }
     # Cookies
     // Avoid setting a cookie domain without a dot, thanks
     // http://stackoverflow.com/a/1188145
     $domain = null;
     if (isset($_SERVER['HTTP_HOST']) && strpos($_SERVER['HTTP_HOST'], '.') !== false && !Validator::is_ip($_SERVER['HTTP_HOST'])) {
         // Remote port specification, as it will make an invalid domain
         list($domain) = explode(':', $_SERVER['HTTP_HOST']);
     }
     session_set_cookie_params(86400, ROOT_PATH, $domain, osTicket::is_https());
     //Set handlers.
     session_set_save_handler(array(&$this, 'open'), array(&$this, 'close'), array(&$this, 'read'), array(&$this, 'write'), array(&$this, 'destroy'), array(&$this, 'gc'));
     //Forced cleanup.
     register_shutdown_function('session_write_close');
     //Start the session.
     session_start();
 }
/**
 * Gets the php.ini path used by the current PHP interpretor.
 *
 * @return string the php.ini path
 */
function get_ini_path()
{
    if ($path = get_cfg_var('cfg_file_path')) {
        return $path;
    }
    return 'WARNING: not using a php.ini file';
}
Beispiel #8
0
 /**
  * Constructor
  *
  * @param   string|RFormatter $format      Output format ID, or formatter instance defaults to 'html'
  */
 public function __construct($format = 'html')
 {
     static $didIni = false;
     if (!$didIni) {
         $didIni = true;
         foreach (array_keys(static::$config) as $key) {
             $iniVal = get_cfg_var('ref.' . $key);
             print_r($iniVal);
             if ($iniVal !== false) {
                 static::$config[$key] = $iniVal;
             }
         }
     }
     if ($format instanceof RFormatter) {
         $this->fmt = $format;
     } else {
         $format = isset(static::$config['formatters'][$format]) ? static::$config['formatters'][$format] : 'R' . ucfirst($format) . 'Formatter';
         if (!class_exists($format, false)) {
             throw new \Exception(sprintf('%s class not found', $format));
         }
         $this->fmt = new $format();
     }
     if (static::$env) {
         return;
     }
     static::$env = array('is54' => version_compare(PHP_VERSION, '5.4') >= 0, 'is546' => version_compare(PHP_VERSION, '5.4.6') >= 0, 'is56' => version_compare(PHP_VERSION, '5.6') >= 0, 'curlActive' => function_exists('curl_version'), 'mbStr' => function_exists('mb_detect_encoding'), 'supportsDate' => strncasecmp(PHP_OS, 'WIN', 3) !== 0 || version_compare(PHP_VERSION, '5.3.10') >= 0);
 }
 public function main()
 {
     $count = array();
     $article = M('article');
     $type = M('type');
     $link = M('link');
     $hd = M('flash');
     $ping = M('pl');
     $guest = M('guestbook');
     $count['article'] = $article->count();
     //文章总数
     $count['narticle'] = $article->where('status=0')->count();
     //未审核文章总数
     $count['guestbook'] = $guest->count();
     //留言总数
     $count['nguestbook'] = $guest->where('status=0')->count();
     //未审核留言总数
     $count['type'] = $type->count();
     //栏目总数
     $count['link'] = $link->count();
     //链接总数
     $count['hd'] = $hd->count();
     //幻灯总数
     $count['ping'] = $ping->count();
     //评论总数
     $count['nping'] = $ping->where('status=0')->count();
     //未审核评论
     $this->assign('count', $count);
     unset($article, $type, $link, $hd, $ping, $guest);
     $info = array('操作系统' => PHP_OS, '运行环境' => $_SERVER["SERVER_SOFTWARE"], 'PHP运行方式' => php_sapi_name(), '上传附件限制' => ini_get('upload_max_filesize'), '执行时间限制' => ini_get('max_execution_time') . '秒', '服务器时间' => date("Y年n月j日 H:i:s"), '北京时间' => gmdate("Y年n月j日 H:i:s", time() + 8 * 3600), '服务器域名/IP' => $_SERVER['SERVER_NAME'] . ' [ ' . gethostbyname($_SERVER['SERVER_NAME']) . ' ]', '剩余空间' => round(@disk_free_space(".") / (1024 * 1024), 2) . 'M', 'register_globals' => get_cfg_var("register_globals") == "1" ? "ON" : "OFF", 'magic_quotes_gpc' => 1 === get_magic_quotes_gpc() ? 'YES' : 'NO', 'magic_quotes_runtime' => 1 === get_magic_quotes_runtime() ? 'YES' : 'NO');
     $this->assign('info', $info);
     $this->display('main');
 }
Beispiel #10
0
 function SessionManager()
 {
     // Read the maxlifetime setting from PHP
     $this->life_time = get_cfg_var("session.gc_maxlifetime");
     // Register this object as the session handler
     session_set_save_handler(array(&$this, "open"), array(&$this, "close"), array(&$this, "read"), array(&$this, "write"), array(&$this, "destroy"), array(&$this, "gc"));
 }
Beispiel #11
0
 public function main()
 {
     $info = array('操作系统' => PHP_OS, '运行环境' => $_SERVER["SERVER_SOFTWARE"], 'PHP运行方式' => php_sapi_name(), 'ThinkPHP版本' => THINK_VERSION . ' [ <a href="http://thinkphp.cn" target="_blank">查看最新版本</a> ]', '上传附件限制' => ini_get('upload_max_filesize'), '执行时间限制' => ini_get('max_execution_time') . '秒', '服务器时间' => date("Y年n月j日 H:i:s"), '北京时间' => gmdate("Y年n月j日 H:i:s", time() + 8 * 3600), '服务器域名/IP' => $_SERVER['SERVER_NAME'] . ' [ ' . gethostbyname($_SERVER['SERVER_NAME']) . ' ]', '剩余空间' => round(@disk_free_space(".") / (1024 * 1024), 2) . 'M', 'register_globals' => get_cfg_var("register_globals") == "1" ? "ON" : "OFF", 'magic_quotes_gpc' => 1 === get_magic_quotes_gpc() ? 'YES' : 'NO', 'magic_quotes_runtime' => 1 === get_magic_quotes_runtime() ? 'YES' : 'NO');
     $this->assign('info1', $info);
     // dump($info);
     $this->display();
 }
Beispiel #12
0
function define_url()
{
    //获取、定义当前运行环境
    $environment = get_cfg_var('environment');
    empty($environment) and $environment = 'local';
    define('ENVIRONMENT', $environment);
    $domain = config('domain');
    $allow_host = $domain['allow_host'];
    $allow_port = $domain['allow_port'];
    list($scheme, $host, $port) = $domain['default'];
    $uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
    if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] === '1' || strtolower($_SERVER['HTTPS']) === 'on') || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) === 'https' || isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] === '443') {
        $scheme = 'https';
    }
    if (isset($_SERVER['HTTP_HOST']) && in_array($_SERVER['HTTP_HOST'], $allow_host)) {
        $host = $_SERVER['HTTP_HOST'];
    }
    if (isset($_SERVER['SERVER_PORT']) && in_array(intval($_SERVER['SERVER_PORT']), $allow_port)) {
        $port = intval($_SERVER['SERVER_PORT']);
    }
    $port = $port === 80 ? '' : ':' . $port;
    define('SITE_DOMAIN', $host);
    define('URL_REQUEST', trim($uri, '/'));
    define('U_R_L', $scheme . '://' . $host . $port . '/');
    define('URL_URI', U_R_L . URL_REQUEST);
}
 public function detail()
 {
     //记录点击量
     session_start();
     $max = get_cfg_var('session.gc_maxlifetime');
     if (isset($_SESSION['update']) && is_numeric($_SESSION['update']) && time() - $_SESSION['update'] > $max) {
         unset($_SESSION['update']);
     }
     if (!isset($_SESSION['update']) || !is_numeric($_SESSION['update']) || time() - $_SESSION['update'] > $max) {
         $_SESSION['id'] = "";
     } else {
         $_SESSION['id'] = 1;
     }
     header("/index.php/home/index/detail?id=1");
     $id = $_GET['id'];
     $art1 = new \Home\Model\ArticleModel();
     $condition["article_id"] = 1;
     $artList1 = $art1->where($condition)->select();
     if ($id == $artList1[0]["article_id"] && !$_SESSION['id']) {
         $sql = "update blog_article set click = click + 1 where article_id={$id}";
         $art1->execute($sql);
     }
     if (!isset($_SESSION['update']) || !is_numeric($_SESSION['update']) || time() - $_SESSION['update'] > $max) {
         $_SESSION['update'] = time();
     }
     $this->assign('artList1', $artList1);
     $this->display('detail');
 }
Beispiel #14
0
 protected static function initAutoloader()
 {
     $vendorPath = static::findParentPath('vendor');
     if (file_exists($vendorPath . '/autoload.php')) {
         $loader = (include $vendorPath . '/autoload.php');
     }
     if (class_exists('Zend\\Loader\\AutoloaderFactory')) {
         return;
     }
     $zf2Path = false;
     if (getenv('ZF2_PATH')) {
         // Support for ZF2_PATH environment variable
         $zf2Path = getenv('ZF2_PATH');
     } elseif (get_cfg_var('zf2_path')) {
         // Support for zf2_path directive value
         $zf2Path = get_cfg_var('zf2_path');
     }
     if ($zf2Path) {
         if (isset($loader)) {
             $loader->add('Zend', $zf2Path);
             $loader->add('ZendXml', $zf2Path);
         } else {
             include $zf2Path . '/Zend/Loader/AutoloaderFactory.php';
             Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true)));
         }
     }
 }
Beispiel #15
0
function get_file_upload_errstring_from_errno($errorLevel)
{
    if (!defined('UPLOAD_ERR_CANT_WRITE')) {
        // Introduced in PHP 5.1.0
        define('UPLOAD_ERR_CANT_WRITE', 5);
    }
    switch ($errorLevel) {
        case UPLOAD_ERR_OK:
            $details = get_lang('No error');
        case UPLOAD_ERR_INI_SIZE:
            $details = get_lang('File too large. Notice : Max file size %size', array('%size' => get_cfg_var('upload_max_filesize')));
            break;
        case UPLOAD_ERR_FORM_SIZE:
            $details = get_lang('File size exceeds');
            break;
        case UPLOAD_ERR_PARTIAL:
            $details = get_lang('File upload incomplete');
            break;
        case UPLOAD_ERR_NO_FILE:
            $details = get_lang('No file uploaded');
            break;
        case UPLOAD_ERR_NO_TMP_DIR:
            $details = get_lang('Temporary folder missing');
            break;
        case UPLOAD_ERR_CANT_WRITE:
            $details = get_lang('Failed to write file to disk');
            break;
        default:
            $details = get_lang('Unknown error code %errCode%', array('%errCode%' => $errorLevel));
            break;
    }
    return $details;
}
Beispiel #16
0
function perform_test($test)
{
    global $_FORM;
    $arr = array();
    $extensions = get_loaded_extensions();
    switch ($test) {
        case "php_mbstring":
            $arr["value"] = defined("MB_OVERLOAD_MAIL") ? "Enabled" : "";
            $arr["value"] or $arr["remedy"] = "Your installation of PHP does not have the mbstring extension.";
            break;
        case "php_version":
            $arr["value"] = phpversion();
            if (!version_compare(phpversion(), "5.4", ">=")) {
                $arr["remedy"] = "Some functionality may not work correctly with your version of PHP. It is recommended that you upgrade.";
            }
            break;
        case "php_memory":
            $arr["value"] = get_cfg_var("memory_limit");
            if (str_replace(array("m", "M"), "", $arr["value"]) < 32) {
                $arr["remedy"] = "Your installation of PHP may not have enough memory enabled. It is recommended to change the memory limit in the PHP config file: " . get_cfg_var("cfg_file_path");
            }
            break;
        case "php_gd":
            if (function_exists("gd_info")) {
                $gd_info = gd_info();
            } else {
                $gd_info = array();
            }
            $arr["value"] = $gd_info["GD Version"];
            if (!in_array("gd", $extensions)) {
                $arr["remedy"] = "Your installation of PHP does not have the GD extension. It is recommended to install GD.";
            }
            break;
        case "php_pdo":
            $arr["value"] = "Enabled";
            if (!extension_loaded('pdo')) {
                $arr["value"] = "";
                $arr["remedy"] = "Your installation of PHP does not have the PDO database extension.";
            }
            break;
        case "mail_exists":
            $arr["value"] = "mail()";
            if (!function_exists("mail")) {
                $arr["remedy"] = "Your installation of PHP does not have the mail() function. allocPSA may not be able to send out emails.";
            }
            break;
        case "attachments_dir":
            $arr["value"] = $_FORM["ATTACHMENTS_DIR"];
            if ($_FORM["ATTACHMENTS_DIR"] == "" || !is_dir($_FORM["ATTACHMENTS_DIR"]) || !is_writeable($_FORM["ATTACHMENTS_DIR"])) {
                $arr["remedy"] = "The directory specified for file uploads is either not defined or not writeable by the webserver process. Run:";
                $arr["remedy"] .= "<br>mkdir " . $_FORM["ATTACHMENTS_DIR"];
                $arr["remedy"] .= "<br>chmod a+w " . $_FORM["ATTACHMENTS_DIR"];
            }
            break;
    }
    $arr["status"] = IMG_TICK;
    $arr["remedy"] and $arr["status"] = IMG_CROSS;
    $arr["remedy"] or $arr["remedy"] = "Ok.";
    return $arr;
}
 public function __construct(Stopwatch $stopwatch = null, $fileLinkFormat = null)
 {
     $this->stopwatch = $stopwatch;
     $this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
     // All clones share these properties by reference:
     $this->rootRefs = array(&$this->data, &$this->dataCount, &$this->isCollected, &$this->clonesCount);
 }
Beispiel #18
0
 /**
  * Launch PHP's built-in web server for this specific WordPress installation.
  *
  * Uses `php -S` to launch a web server serving the WordPress webroot.
  * <http://php.net/manual/en/features.commandline.webserver.php>
  *
  * ## OPTIONS
  *
  * [--host=<host>]
  * : The hostname to bind the server to.
  * ---
  * default: localhost
  * ---
  *
  * [--port=<port>]
  * : The port number to bind the server to.
  * ---
  * default: 8080
  * ---
  *
  * [--docroot=<path>]
  * : The path to use as the document root.
  *
  * [--config=<file>]
  * : Configure the server with a specific .ini file.
  *
  * ## EXAMPLES
  *
  *     # Make the instance available on any address (with port 8080)
  *     $ wp server --host=0.0.0.0
  *     PHP 5.6.9 Development Server started at Tue May 24 01:27:11 2016
  *     Listening on http://0.0.0.0:8080
  *     Document root is /
  *     Press Ctrl-C to quit.
  *
  *     # Run on port 80 (for multisite)
  *     $ sudo wp server --host=localhost.localdomain --port=80
  *     PHP 5.6.9 Development Server started at Tue May 24 01:30:06 2016
  *     Listening on http://localhost1.localdomain1:8080
  *     Document root is /
  *     Press Ctrl-C to quit.
  *
  *     # Configure the server with a specific .ini file
  *     $ wp server --config=development.ini
  *     PHP 7.0.9 Development Server started at Mon Aug 22 12:09:04 2016
  *     Listening on http://localhost:8080
  *     Document root is /
  *     Press Ctrl-C to quit.
  *
  * @when before_wp_load
  */
 function __invoke($_, $assoc_args)
 {
     $min_version = '5.4';
     if (version_compare(PHP_VERSION, $min_version, '<')) {
         WP_CLI::error("The `wp server` command requires PHP {$min_version} or newer.");
     }
     $defaults = array('host' => 'localhost', 'port' => 8080, 'docroot' => false, 'config' => get_cfg_var('cfg_file_path'));
     $assoc_args = array_merge($defaults, $assoc_args);
     $docroot = $assoc_args['docroot'];
     if (!$docroot) {
         $config_path = WP_CLI::get_runner()->project_config_path;
         if (!$config_path) {
             $docroot = ABSPATH;
         } else {
             $docroot = dirname($config_path);
         }
     }
     $cmd = \WP_CLI\Utils\esc_cmd('%s -S %s -t %s -c %s %s', PHP_BINARY, $assoc_args['host'] . ':' . $assoc_args['port'], $docroot, $assoc_args['config'], \WP_CLI\Utils\extract_from_phar(WP_CLI_ROOT . '/php/router.php'));
     $descriptors = array(STDIN, STDOUT, STDERR);
     // https://bugs.php.net/bug.php?id=60181
     $options = array();
     if (\WP_CLI\Utils\is_windows()) {
         $options["bypass_shell"] = TRUE;
     }
     exit(proc_close(proc_open($cmd, $descriptors, $pipes, NULL, NULL, $options)));
 }
Beispiel #19
0
 public function __construct($debug = true, $charset = 'UTF-8', $env = 'dev')
 {
     $this->env = $env;
     parent::__construct($debug);
     $this->debug = $debug;
     $this->fileLinkFormat = ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
 }
 /**
  * A function to encapsulate rest based calls using the curl library.
  * 
  * @params $url      - OK to have ?foo=bar
  * @params $method   - GET/PUT/POST/DELETE
  * @params $payload  - data to send in if PUT/POST
  * @return array($response_code=>$data) - the function does NOT format response data.
  */
 public function restCall($endpoint, $method = 'GET', $payload = null, $headers = null)
 {
     if (empty($endpoint)) {
         return array(ResponseCodes::MISSING_PARAM => 'Missing server endpoint. This is the URL you intended to call and it was empty.');
     }
     $verifySSL = get_cfg_var('environment') == 'production' ? true : false;
     $curl = curl_init();
     curl_setopt($curl, CURLOPT_URL, $endpoint);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
     curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $verifySSL);
     /*
      * Set the header to json since we will pass json out for all calls.
      */
     curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
     /*
      * Set any headers we were passed. We support a string or an array of strings.
      */
     if (!empty($headers)) {
         if (is_array($headers)) {
             curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
         } else {
             curl_setopt($curl, CURLOPT_HTTPHEADER, array($headers));
         }
     }
     /*
      * Default method is GET
      */
     $method = empty($method) ? 'GET' : strtoupper($method);
     /*
      * Based on the method passed in, we need to set our data
      */
     if ($method == 'POST') {
         curl_setopt($curl, CURLOPT_POST, TRUE);
         curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
     }
     if ($method == 'PUT') {
         $fh = fopen('php://memory', 'w+');
         fwrite($fh, $payload);
         rewind($fh);
         curl_setopt($curl, CURLOPT_INFILE, $fh);
         curl_setopt($curl, CURLOPT_INFILESIZE, strlen($payload));
         curl_setopt($curl, CURLOPT_PUT, TRUE);
     }
     if ($method == 'DELETE') {
         curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'DELETE');
         if (!empty($payload)) {
             curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
         }
     }
     /*
      * Execute the request
      */
     $data = trim(curl_exec($curl));
     $code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
     @fclose($fh);
     if (preg_match('/^({|\\[)/', $data) && preg_match('/(}|\\])$/m', $data)) {
         $data = json_encode($data, true);
     }
     return array($code => $data);
 }
Beispiel #21
0
 public static function initAutoloader()
 {
     if (file_exists('vendor/autoload.php')) {
         $loader = (include 'vendor/autoload.php');
     }
     if (class_exists('Zend\\Loader\\AutoloaderFactory')) {
         return;
     }
     $zf2Path = false;
     if (is_dir('vendor/ZF2/library')) {
         $zf2Path = 'vendor/ZF2/library';
     } elseif (getenv('ZF2_PATH')) {
         // Support for ZF2_PATH environment variable or git submodule
         $zf2Path = getenv('ZF2_PATH');
     } elseif (get_cfg_var('zf2_path')) {
         // Support for zf2_path directive value
         $zf2Path = get_cfg_var('zf2_path');
     }
     if ($zf2Path) {
         if (isset($loader)) {
             $loader->add('Zend', $zf2Path);
             $loader->add('ZendXml', $zf2Path);
         } else {
             include $zf2Path . '/Zend/Loader/AutoloaderFactory.php';
             Zend\Loader\AutoloaderFactory::factory(array('Zend\\Loader\\StandardAutoloader' => array('autoregister_zf' => true)));
         }
     }
     if (!class_exists('Zend\\Loader\\AutoloaderFactory')) {
         throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.');
     }
 }
Beispiel #22
0
 /**
  * This function be used eventually to support more modes.  It is needed
  * because both header and footer functions must know what each other is
  * doing.
  *
  * @return  integer  the output buffer mode
  */
 function out_buffer_mode_get()
 {
     if (PHP_INT_VERSION >= 40000 && @function_exists('ob_start')) {
         $mode = 1;
     } else {
         $mode = 0;
     }
     // If a user sets the output_handler in php.ini to ob_gzhandler, then
     // any right frame file in phpMyAdmin will not be handled properly by
     // the browser. My fix was to check the ini file within the
     // out_buffer_mode_get() function.
     //
     // (Patch by Garth Gillespie, modified by Marc Delisle)
     if (PHP_INT_VERSION >= 40000 && @ini_get('output_handler')) {
         if (@ini_get('output_handler') == 'ob_gzhandler') {
             $mode = 0;
         }
     } else {
         if (PHP_INT_VERSION >= 40000) {
             if (@get_cfg_var('output_handler') == 'ob_gzhandler') {
                 $mode = 0;
             }
         }
     }
     // End patch
     // Zero (0) is no mode or in other words output buffering is OFF.
     // Follow 2^0, 2^1, 2^2, 2^3 type values for the modes.
     // Usefull if we ever decide to combine modes.  Then a bitmask field of
     // the sum of all modes will be the natural choice.
     header('X-ob_mode: ' . $mode);
     return $mode;
 }
Beispiel #23
0
 public function main()
 {
     $this->assign('username', $_SESSION['username']);
     $phpsys = array('php_system' => C('SYS_NAME') . ' ' . C('SYS_VERSIONS'), 'php_uname' => php_uname(), 'php_version' => PHP_VERSION, 'php_port' => $_SERVER['SERVER_PORT'], 'php_software' => $_SERVER['SERVER_SOFTWARE'], 'php_max_time' => get_cfg_var('max_execution_time') . 's', 'php_sapi_name' => php_sapi_name());
     $this->assign('phpsys', $phpsys);
     $this->display();
 }
 public function testGetPhpAndOSInfo()
 {
     $this->assertEquals(PHP_VERSION, $this->config->get('php_version'));
     $this->assertEquals(get_cfg_var('cfg_file_path'), $this->config->get('php_ini'));
     $this->assertEquals(PHP_BINARY, $this->config->get('php'));
     $this->assertEquals(php_uname('v'), $this->config->get('os_version'));
 }
Beispiel #25
0
    /**
     * constructor
     *
     */
    function __construct()
    {
    	//check if the session folder read and writable
    		$dir = new file();
	        if(!file_exists(CONFIG_SYS_DIR_SESSION_PATH))
	        {
	           if(!$dir->mkdir(CONFIG_SYS_DIR_SESSION_PATH))
	           {
	              die('Unable to create session folder.');
	           }
	        }
    		if(!$dir->isReadable(CONFIG_SYS_DIR_SESSION_PATH))
    		{
    			die('Permission denied: ' . CONFIG_SYS_DIR_SESSION_PATH . " is not readable.");
    		}    		
    		if(!$dir->isWritable(CONFIG_SYS_DIR_SESSION_PATH))
    		{
    			die('Permission denied: ' . CONFIG_SYS_DIR_SESSION_PATH . " is not writable.");
    		}
    	$this->dir = backslashToSlash(addTrailingSlash(CONFIG_SYS_DIR_SESSION_PATH));
        $this->lifeTime = get_cfg_var("session.gc_maxlifetime");  
        $this->gcCounterFile = $this->dir . $this->gcCounterFileName; 
        $this->gcLogFile = $this->dir  . $this->gcLogFileName;
       	$this->sessionDir = backslashToSlash($this->dir.session_id().DIRECTORY_SEPARATOR);
        $this->init();    	
    }
Beispiel #26
0
function template_outputfilter_gzip($tpl_source, &$template_object)
{
    static $_tpl_saved = '';
    $gzipped = 0;
    if ($template_object->enable_gzip) {
        if (extension_loaded("zlib") && !get_cfg_var('zlib.output_compression') && !$template_object->cache && (strstr($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip") || $template_object->force_compression)) {
            $_tpl_saved .= $tpl_source . "\n<!-- zlib compression level " . $template_object->compression_level . " -->\n\n";
            $tpl_source = "";
            if ($template_object->send_now == 1) {
                $gzipped = 1;
                $tpl_source = gzencode($_tpl_saved, $template_object->compression_level);
                $_tpl_saved = "";
            }
        }
    } else {
        if (!$template_object->caching && !get_cfg_var('zlib.output_compression')) {
            $_tpl_saved .= $tpl_source . "\n<!-- normal saved output -->\n\n";
            $tpl_source = "";
            if ($template_object->send_now == 1) {
                $tpl_source = $_tpl_saved;
                $_tpl_saved = "";
            }
        }
    }
    if ($template_object->send_now == 1 && $template_object->enable_gzip == 1) {
        if ($gzipped == 1) {
            header("Content-Encoding: gzip");
            header("Content-Length: " . strlen($tpl_source));
        }
    }
    return $tpl_source;
}
Beispiel #27
0
	public static function start(){
		//PHP
		self::$params["safe_mode"] = (int) ini_get("safe_mode");
		self::$params["safe_mode_gid"] = (int) ini_get("safe_mode_gid");
		self::$params["upload_max_size"] = ini_get("upload_max_filesize");
    	self::$params["post_max_size"] = ini_get("post_max_size");
		self::$params["memory_limit"] = ((ini_get("memory_limit")!="")?ini_get("memory_limit"):get_cfg_var("memory_limit"));
		self::$params["max_execution_time"] = ini_get("max_execution_time");
		
		$uploadTmpDir = ini_get("upload_tmp_dir");
		$uploadTmpDir = $uploadTmpDir ? $uploadTmpDir : realpath(sys_get_temp_dir()); 
		self::$params["upload_tmp_dir"] = $uploadTmpDir;		
		self::$params["upload_tmp_dir_writable"] =  @is_writable($uploadTmpDir);
		self::$params["output_buffering"] = (int)  !! ini_get('output_buffering');
		
		//ZLIB
		self::$params["zlib"] = (int) function_exists('gzopen');
		
		
		//For future or commercial versions
		self::$params["xml_parser_create"] = (int) function_exists("xml_parser_create");
		//GD
		self::$params['gd'] = (int) (function_exists("gd_info") && function_exists("imagecopyresized") && function_exists("imagecopyresampled")) ;
			
		
		self::liveTests();
	}
Beispiel #28
0
 public static function main()
 {
     $accessLog = get_cfg_var('codecept.access_log');
     $userRouter = get_cfg_var('codecept.user_router');
     $directoryIndex = get_cfg_var('codecept.directory_index') ?: 'index.php';
     $documentRoot = $_SERVER['DOCUMENT_ROOT'];
     $requestUri = $_SERVER['REQUEST_URI'];
     $filePath = $documentRoot . '/' . ltrim($requestUri, '/');
     if ($accessLog) {
         $logEntry = sprintf('%s %s "%s %s %s" %s %s' . PHP_EOL, $_SERVER['REMOTE_ADDR'], date('c'), $_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI'], $_SERVER['SERVER_PROTOCOL'], isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '-', isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '-');
         file_put_contents($accessLog, $logEntry, FILE_APPEND);
     }
     if (file_exists($filePath) && is_file($filePath)) {
         return false;
         // serve the requested resource as-is.
     } elseif ($userRouter) {
         return include $userRouter;
     } else {
         if (is_dir($filePath) && file_exists($filePath . '/' . $directoryIndex)) {
             return include $filePath . '/' . $directoryIndex;
         } else {
             return false;
             // serve the requested resource as-is.
         }
     }
 }
Beispiel #29
0
 public function main()
 {
     //$upyun_img = $this->createImgUpYun();
     $info = array('操作系统' => PHP_OS, '运行环境' => $_SERVER["SERVER_SOFTWARE"], 'PHP运行方式' => php_sapi_name(), '上传附件限制' => ini_get('upload_max_filesize'), '执行时间限制' => ini_get('max_execution_time') . '秒', '服务器时间' => date("Y年n月j日 H:i:s"), '北京时间' => gmdate("Y年n月j日 H:i:s", time() + 8 * 3600), '服务器域名/IP' => $_SERVER['SERVER_NAME'] . ' [ ' . gethostbyname($_SERVER['SERVER_NAME']) . ' ]', '服务器剩余空间' => round(disk_free_space(".") / (1024 * 1024), 2) . 'M', 'register_globals' => get_cfg_var("register_globals") == "1" ? "ON" : "OFF", 'magic_quotes_gpc' => 1 === get_magic_quotes_gpc() ? 'YES' : 'NO', 'magic_quotes_runtime' => 1 === get_magic_quotes_runtime() ? 'YES' : 'NO');
     $this->assign('info', $info);
     $this->display();
 }
function phpAds_sendMail($email, $readable, $subject, $contents)
{
    global $phpAds_config, $phpAds_CharSet;
    // Build To header
    if (!get_cfg_var('SMTP')) {
        $param_to = '"' . $readable . '" <' . $email . '>';
    } else {
        $param_to = $email;
    }
    // Build additional headers
    $param_headers = "Content-Transfer-Encoding: 8bit\r\n";
    if (isset($phpAds_CharSet)) {
        $param_headers .= "Content-Type: text/plain; charset=" . $phpAds_CharSet . "\r\n";
    }
    if (get_cfg_var('SMTP')) {
        $param_headers .= 'To: "' . $readable . '" <' . $email . ">\r\n";
    }
    $param_headers .= 'From: "' . $phpAds_config['admin_fullname'] . '" <' . $phpAds_config['admin_email'] . '>' . "\r\n";
    if ($phpAds_config['admin_email_headers'] != '') {
        $param_headers .= "\r\n" . $phpAds_config['admin_email_headers'];
    }
    // Use only \n as header separator when qmail is used
    if ($phpAds_config['qmail_patch']) {
        $param_headers = str_replace("\r", '', $param_headers);
    }
    // Add \r to linebreaks in the contents for MS Exchange compatibility
    $contents = str_replace("\n", "\r\n", $contents);
    return @mail($param_to, $subject, $contents, $param_headers);
}