コード例 #1
0
 protected function extract($file, $path)
 {
     $processError = null;
     // try to use unzip on *nix
     if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
         $command = 'unzip ' . escapeshellarg($file) . ' -d ' . escapeshellarg($path);
         if (0 === $this->process->execute($command, $ignoredOutput)) {
             return;
         }
         $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
     }
     if (!class_exists('ZipArchive')) {
         // php.ini path is added to the error message to help users find the correct file
         $iniPath = php_ini_loaded_file();
         if ($iniPath) {
             $iniMessage = 'The php.ini used by your command-line PHP is: ' . $iniPath;
         } else {
             $iniMessage = 'A php.ini file does not exist. You will have to create one.';
         }
         $error = "Could not decompress the archive, enable the PHP zip extension or install unzip.\n" . $iniMessage . "\n" . $processError;
         if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
             $error = "Could not decompress the archive, enable the PHP zip extension.\n" . $iniMessage;
         }
         throw new \RuntimeException($error);
     }
     $zipArchive = new ZipArchive();
     if (true !== ($retval = $zipArchive->open($file))) {
         throw new \UnexpectedValueException($this->getErrorMessage($retval, $file));
     }
     if (true !== $zipArchive->extractTo($path)) {
         throw new \RuntimeException("There was an error extracting the ZIP file. Corrupt file?");
     }
     $zipArchive->close();
 }
コード例 #2
0
ファイル: functions.php プロジェクト: pleio/newsletter
/**
 * Start the commandline to send a newsletter
 * This is offloaded because it could take a while and/or resources
 *
 * @param Newsletter $entity Newsletter entity to be processed
 *
 * @return void
 */
function newsletter_start_commandline_sending(Newsletter $entity)
{
    if (!empty($entity) && elgg_instanceof($entity, "object", Newsletter::SUBTYPE)) {
        // prepare commandline settings
        $settings = array("entity_guid" => $entity->getGUID(), "host" => $_SERVER["HTTP_HOST"], "memory_limit" => ini_get("memory_limit"), "secret" => newsletter_generate_commanline_secret($entity->getGUID()));
        if (isset($_SERVER["HTTPS"])) {
            $settings["https"] = $_SERVER["HTTPS"];
        }
        // ini settings
        $ini_param = "";
        $ini_file = php_ini_loaded_file();
        if (!empty($ini_file)) {
            $ini_param = "-c " . $ini_file . " ";
        }
        // which script to run
        $script_location = dirname(dirname(__FILE__)) . "/procedures/cli.php";
        // convert settings to commandline params
        $query_string = http_build_query($settings, "", " ");
        // start the correct commandline
        if (PHP_OS === "WINNT") {
            pclose(popen("start /B php " . $ini_param . $script_location . " " . $query_string, "r"));
        } else {
            exec("php " . $ini_param . $script_location . " " . $query_string . " > /dev/null &");
        }
    }
}
コード例 #3
0
 /**
  * Execute the "show" command
  *
  * @param  InputInterface $input Input object
  * @param  OutputInterface $output Output object
  * @throws \Exception
  * @return null
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $path = $input->getOption('path');
     // if we're not given a path at all, try to figure it out
     if ($path === null) {
         $path = php_ini_loaded_file();
     }
     if (!is_file($path)) {
         throw new \Exception('Path is null or not accessible: "' . $path . '"');
     }
     $ini = parse_ini_file($path, true);
     $output->writeLn('Current PHP.ini settings from ' . $path);
     $output->writeLn('##########');
     foreach ($ini as $section => $data) {
         $output->writeLn('<info>:: ' . $section . '</info>');
         if (empty($data)) {
             $output->writeLn("\t<fg=yellow>No settings</fg=yellow>");
         } else {
             foreach ($data as $path => $value) {
                 $output->writeLn("\t" . $path . ' => ' . var_export($value, true));
             }
         }
         $output->writeLn("-----------------\n");
     }
 }
コード例 #4
0
ファイル: functions.php プロジェクト: coldtrick/newsletter
/**
 * Start the commandline to send a newsletter
 * This is offloaded because it could take a while and/or resources
 *
 * @param Newsletter $entity Newsletter entity to be processed
 *
 * @return void
 */
function newsletter_start_commandline_sending(Newsletter $entity)
{
    if (!elgg_instanceof($entity, 'object', Newsletter::SUBTYPE)) {
        return;
    }
    // prepare commandline settings
    $settings = ['entity_guid' => $entity->getGUID(), 'host' => $_SERVER['HTTP_HOST'], 'memory_limit' => ini_get('memory_limit'), 'secret' => newsletter_generate_commanline_secret($entity->getGUID())];
    if (isset($_SERVER['HTTPS'])) {
        $settings['https'] = $_SERVER['HTTPS'];
    }
    // ini settings
    $ini_param = '';
    $ini_file = php_ini_loaded_file();
    if (!empty($ini_file)) {
        $ini_param = "-c {$ini_file} ";
    }
    // which script to run
    $script_location = dirname(dirname(__FILE__)) . '/procedures/cli.php';
    // convert settings to commandline params
    $query_string = http_build_query($settings, '', ' ');
    // start the correct commandline
    if (PHP_OS === 'WINNT') {
        pclose(popen('start /B php ' . $ini_param . $script_location . ' ' . $query_string, 'r'));
    } else {
        exec('php ' . $ini_param . $script_location . ' ' . $query_string . ' > /dev/null &');
    }
}
コード例 #5
0
ファイル: ci_depends.php プロジェクト: bruensicke/li3_redis
 /**
  * Install extension by given name.
  *
  * Uses configration retrieved as per `php_ini_loaded_file()`.
  *
  * @see http://php.net/php_ini_loaded_file
  * @param string $name The name of the extension to install.
  * @return void
  */
 public static function install($name)
 {
     if (!isset(static::$_extensions[$name])) {
         return;
     }
     $extension = static::$_extensions[$name];
     echo $name;
     if (isset($extension['require']['php'])) {
         $version = $extension['require']['php'];
         if (!version_compare(PHP_VERSION, $version[1], $version[0])) {
             $message = " => not installed, requires a PHP version %s %s (%s installed)\n";
             printf($message, $version[0], $version[1], PHP_VERSION);
             return;
         }
     }
     static::_system(sprintf('wget %s > /dev/null 2>&1', $extension['url']));
     $file = basename($extension['url']);
     static::_system(sprintf('tar -xzf %s > /dev/null 2>&1', $file));
     $folder = basename($file, '.tgz');
     $folder = basename($folder, '.tar.gz');
     $message = 'sh -c "cd %s && phpize && ./configure %s ';
     $message .= '&& make && sudo make install" > /dev/null 2>&1';
     static::_system(sprintf($message, $folder, implode(' ', $extension['configure'])));
     foreach ($extension['ini'] as $ini) {
         static::_system(sprintf("echo %s >> %s", $ini, php_ini_loaded_file()));
     }
     printf("=> installed (%s)\n", $folder);
 }
コード例 #6
0
 public function __construct()
 {
     parent::__construct();
     //
     // Make sure that bool valued settings are cast to ints.
     //
     $this->_settings = array(self::ALLOW_USER_REGISTRATION => 1, self::EXECUTABLE_TAR => Framework_HostOs::isWindows() ? '' : 'tar', self::EXECUTABLE_GIT => 'git' . (Framework_HostOs::isWindows() ? '.exe' : ''), self::EXECUTABLE_PHP => 'php' . (Framework_HostOs::isWindows() ? '.exe' : '') . (php_ini_loaded_file() ? ' -c ' . htmlentities(str_replace(array('\\', '//'), '/', php_ini_loaded_file())) : ''), self::EXECUTABLE_SVN => 'svn' . (Framework_HostOs::isWindows() ? '.exe' : ''), self::INTERNAL_BUILDER_ACTIVE => CINTIENT_INTERNAL_BUILDER_ACTIVE, self::VERSION => '');
 }
コード例 #7
0
ファイル: HHVM.php プロジェクト: staabm/pickle
 public function getIniPath()
 {
     $ini = php_ini_loaded_file();
     if (!$ini && file_exists('/etc/hhvm/php.ini')) {
         $ini = '/etc/hhvm/php.ini';
     }
     return $ini;
 }
コード例 #8
0
 public function iniCheck($info, $setting, $expected, $required = true, $help = null)
 {
     $current = ini_get($setting);
     $cb = function () use($current, $expected) {
         return is_callable($expected) ? call_user_func($expected, $current) : $current == $expected;
     };
     $message = sprintf('%s in %s is currently set to %s but %s be set to %s.', $setting, php_ini_loaded_file(), var_export($current, true), $required ? 'must' : 'should', var_export($expected, true)) . ' ' . $help;
     $this->check($info, $cb, trim($message), $required);
 }
コード例 #9
0
ファイル: PHPINI.php プロジェクト: siltronicz/webinterface
 /**
  * @param string $section
  */
 public static function setDirective($section, $directive, $value)
 {
     $ini_file = php_ini_loaded_file();
     self::doBackup($ini_file);
     $ini = new INIReaderWriter($ini_file);
     $ini->set($section, $directive, $value);
     $ini->write($ini_file);
     return true;
 }
コード例 #10
0
ファイル: ConfigCommand.php プロジェクト: phpbrew/phpbrew
 public function execute()
 {
     $file = php_ini_loaded_file();
     if (!file_exists($file)) {
         $php = Config::getCurrentPhpName();
         $this->logger->warn("Sorry, I can't find the {$file} file for php {$php}.");
         return;
     }
     Utils::editor($file);
 }
コード例 #11
0
/** @return Tester\Runner\PhpInterpreter */
function createInterpreter()
{
    if (defined('HHVM_VERSION')) {
        return new Tester\Runner\HhvmPhpInterpreter(PHP_BINARY);
    } elseif (defined('PHPDBG_VERSION')) {
        return new Tester\Runner\ZendPhpDbgInterpreter(PHP_BINARY, ' -c ' . Tester\Helpers::escapeArg(php_ini_loaded_file()));
    } else {
        return new Tester\Runner\ZendPhpInterpreter(PHP_BINARY, ' -c ' . Tester\Helpers::escapeArg(php_ini_loaded_file()));
    }
}
コード例 #12
0
ファイル: IniHelper.php プロジェクト: Rudloff/composer
 /**
  * Returns an array of php.ini locations with at least one entry
  *
  * The equivalent of calling php_ini_loaded_file then php_ini_scanned_files.
  * The loaded ini location is the first entry and may be empty.
  * @return array
  */
 public static function getAll()
 {
     if ($env = strval(getenv(self::ENV_ORIGINAL))) {
         return explode(PATH_SEPARATOR, $env);
     }
     $paths = array(strval(php_ini_loaded_file()));
     if ($scanned = php_ini_scanned_files()) {
         $paths = array_merge($paths, array_map('trim', explode(',', $scanned)));
     }
     return $paths;
 }
コード例 #13
0
ファイル: System.php プロジェクト: KasaiDot/FoolFrame
 public static function getEnvironment(Context $context)
 {
     $environment = [];
     $environment['server'] = ['title' => _i('Server Information'), 'data' => [['title' => _i('Web Server Software'), 'value' => $_SERVER['SERVER_SOFTWARE'], 'alert' => ['type' => 'warning', 'condition' => (bool) preg_match('/nginx/i', $_SERVER['SERVER_SOFTWARE']), 'title' => 'Warning', 'string' => _i('The nginx web server has its own internal file size limit variable for uploads. It is recommended that this value be set at the same value set in the PHP configuration file.')]], ['title' => _i('PHP Version'), 'value' => PHP_VERSION, 'alert' => ['type' => 'important', 'condition' => version_compare(PHP_VERSION, '5.4.0') < 0, 'title' => _i('Please Update Immediately'), 'string' => _i('The minimum requirements to run this software is 5.4.0.')]]]];
     $environment['software'] = ['title' => _i('Software Information'), 'data' => [['title' => _i('FoolFrame Version'), 'value' => $context->getService('config')->get('foolz/foolframe', 'package', 'main.version'), 'alert' => ['type' => 'info', 'condition' => true, 'title' => _i('New Update Available'), 'string' => _i('There is a new version of the software available for download.')]]]];
     $environment['php-configuration'] = ['title' => _i('PHP Configuration'), 'data' => [['title' => _i('Config Location'), 'value' => php_ini_loaded_file(), 'description' => _i('This is the path to the location of the php.ini configuration file.')], ['title' => 'allow_url_fopen', 'value' => ini_get('allow_url_fopen') ? _i('On') : _i('Off'), 'description' => _i('This option enables the URL-aware fopen wrappers that allows access to remote files using the FTP or HTTP protocol.'), 'alert' => ['type' => 'important', 'condition' => (bool) (!ini_get('allow_url_fopen')), 'title' => _i('Critical'), 'string' => _i('The PHP configuration on the server currently has URL-aware fopen wrappers disabled. The software will be operating at limited functionality.')]], ['title' => 'max_execution_time', 'value' => ini_get('max_execution_time'), 'description' => _i('This sets the maximum time in seconds a script is allowed to run before it is terminated by the parser.'), 'alert' => ['type' => 'warning', 'condition' => (bool) (intval(ini_get('max_execution_time')) < 60), 'title' => _i('Warning'), 'string' => _i('Your current value for maximum execution time is below the suggested value.')]], ['title' => 'file_uploads', 'value' => ini_get('file_uploads') ? _i('On') : _i('Off'), 'description' => _i('This sets whether or not to allow HTTP file uploads.'), 'alert' => ['type' => 'important', 'condition' => (bool) (!ini_get('file_uploads')), 'title' => _i('Critical'), 'string' => _i('The PHP configuration on the server currently has file uploads disabled. This option must be enabled for the software to fully function.')]], ['title' => 'post_max_size', 'value' => ini_get('post_max_size'), 'description' => _i('This sets the maximum size of POST data allowed.'), 'alert' => ['type' => 'warning', 'condition' => (bool) (intval(substr(ini_get('post_max_size'), 0, -1)) < 16), 'title' => _i('Warning'), 'string' => _i('Your current value for maximum POST data size is below the suggested value.')]], ['title' => 'upload_max_filesize', 'value' => ini_get('upload_max_filesize'), 'description' => _i('This sets the maximum size allowed to be uploaded.'), 'alert' => ['type' => 'warning', 'condition' => (bool) (intval(substr(ini_get('upload_max_filesize'), 0, -1)) < 16), 'title' => _i('Warning'), 'string' => _i('Your current value for maximum upload file size is below the suggested value.')]], ['title' => 'max_file_uploads', 'value' => ini_get('max_file_uploads'), 'description' => _i('This sets the maximum number of files allowed to be uploaded concurrently.'), 'alert' => ['type' => 'warning', 'condition' => (bool) (intval(ini_get('max_file_uploads')) < 60), 'title' => _i('Warning'), 'string' => _i('Your current value for maximum number of concurrent uploads is below the suggested value.')]]]];
     $environment['php-extensions'] = ['title' => _i('PHP Extensions'), 'data' => [['title' => 'APC', 'value' => extension_loaded('apc') ? _i('Installed') : _i('Unavailable'), 'alert' => ['type' => 'warning', 'condition' => (bool) (!extension_loaded('apc')), 'title' => _i('Warning'), 'string' => _i('Your PHP environment shows that you do not have the "%s" extension installed. This may limit the functionality of the software.', 'APC')]], ['title' => 'cURL', 'value' => extension_loaded('curl') ? _i('Installed') : _i('Unavailable'), 'alert' => ['type' => 'important', 'condition' => (bool) (!extension_loaded('curl')), 'title' => _i('Critical'), 'string' => _i('Your PHP environment shows that you do not have the "%s" extension installed. This may limit the functionality of the software.', 'cURL')]], ['title' => 'FileInfo', 'value' => extension_loaded('fileinfo') ? _i('Installed') : _i('Unavailable'), 'alert' => ['type' => 'important', 'condition' => (bool) (!extension_loaded('fileinfo')), 'title' => _i('Critical'), 'string' => _i('Your PHP environment shows that you do not have the "%s" extension installed. This may limit the functionality of the software.', 'FileInfo')]], ['title' => 'JSON', 'value' => extension_loaded('json') ? _i('Installed') : _i('Unavailable'), 'alert' => ['type' => 'important', 'condition' => (bool) (!extension_loaded('json')), 'title' => _i('Critical'), 'string' => _i('Your PHP environment shows that you do not have the "%s" extension installed. This may limit the functionality of the software.', 'JSON')]], ['title' => 'Multi-byte String', 'value' => extension_loaded('mbstring') ? _i('Installed') : _i('Unavailable'), 'alert' => ['type' => 'important', 'condition' => (bool) (!extension_loaded('mbstring')), 'title' => _i('Critical'), 'string' => _i('Your PHP environment shows that you do not have the "%s" extension installed. This may limit the functionality of the software.', 'Multi-byte String')]], ['title' => 'MySQLi', 'value' => extension_loaded('mysqli') ? _i('Installed') : _i('Unavailable'), 'alert' => ['type' => 'important', 'condition' => (bool) (!extension_loaded('mysqli')), 'title' => _i('Critical'), 'string' => _i('Your PHP environment shows that you do not have the "%s" extension installed. This may limit the functionality of the software.', 'MySQLi')]], ['title' => 'PDO MySQL', 'value' => extension_loaded('pdo_mysql') ? _i('Installed') : _i('Unavailable'), 'alert' => ['type' => 'important', 'condition' => (bool) (!extension_loaded('pdo_mysql')), 'title' => _i('Critical'), 'string' => _i('Your PHP environment shows that you do not have the "%s" extension installed. This may limit the functionality of the software.', 'PDO MySQL')]]]];
     $environment = Hook::forge('Foolz\\FoolFrame\\Model\\System::getEnvironment#var.environment')->setParam('environment', $environment)->execute()->get($environment);
     usort($environment['php-extensions']['data'], array('System', 'sortByTitle'));
     return $environment;
 }
コード例 #14
0
function collectConfigurationFiles()
{
    $files = array(php_ini_loaded_file());
    $scannedFiles = php_ini_scanned_files();
    if ($scannedFiles) {
        foreach (explode(',', $scannedFiles) as $file) {
            array_push($files, trim($file));
        }
    }
    return $files;
}
コード例 #15
0
 function vtiger_extensionloader_suggest()
 {
     $PHPVER = sprintf("%s.%s", PHP_MAJOR_VERSION, PHP_MINOR_VERSION);
     $OSHWINFO = str_replace('Darwin', 'Mac', PHP_OS) . '_' . php_uname('m');
     $WIN = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? true : false;
     $EXTFNAME = 'vtigerextn_loader';
     $EXTNFILE = $EXTFNAME . ($WIN ? '.dll' : '.so');
     $DISTFILE = sprintf("%s_%s_%s.so", $EXTFNAME, $PHPVER, $OSHWINFO);
     $DISTFILEZIP = sprintf("%s_%s_%s-yyyymmdd.zip", $EXTFNAME, $PHPVER, $OSHWINFO);
     return array('loader_zip' => $DISTFILEZIP, 'loader_file' => $DISTFILE, 'php_ini' => php_ini_loaded_file(), 'extensions_dir' => ini_get('extension_dir'));
 }
コード例 #16
0
 protected static function getPhpArguments()
 {
     $arguments = array();
     $phpFinder = new PhpExecutableFinder();
     if (method_exists($phpFinder, 'findArguments')) {
         $arguments = $phpFinder->findArguments();
     }
     if (false !== ($ini = php_ini_loaded_file())) {
         $arguments[] = '--php-ini=' . $ini;
     }
     return $arguments;
 }
コード例 #17
0
 /**
  * Assemble the complete stack of System Informations
  *
  * @return array
  */
 private function assembleSystemInfos()
 {
     // get system informations and server variables
     $sysinfos = array();
     // WEBSERVER
     if (is_callable('apache_get_version')) {
         $sysinfos['apache_get_version'] = apache_get_version();
         $sysinfos['apache_modules'] = apache_get_modules();
         asort($sysinfos['apache_modules']);
     }
     // fetch server's IP address and it's name
     $sysinfos['server_ip'] = gethostbyname($_SERVER['SERVER_NAME']);
     $sysinfos['server_name'] = gethostbyaddr($sysinfos['server_ip']);
     // PHP
     // Get Interface Webserver<->PHP (Server-API)
     $sysinfos['php_sapi_name'] = php_sapi_name();
     // Is the SERVER-API an CGI (until PHP 5.3) or CGI_FCGI?
     if (substr($sysinfos['php_sapi_name'], 0, 3) == 'cgi') {
         $sysinfos['php_sapi_cgi'] = true;
     }
     $sysinfos['php_uname'] = php_uname();
     $sysinfos['php_os'] = PHP_OS;
     $sysinfos['php_os_bit'] = PHP_INT_SIZE * 8 . 'Bit';
     $sysinfos['php_sapi'] = PHP_SAPI;
     // @todo check out, if this is the same as php_sapi_name?
     $sysinfos['phpversion'] = phpversion();
     $sysinfos['php_extensions'] = get_loaded_extensions();
     asort($sysinfos['php_extensions']);
     $sysinfos['zendversion'] = zend_version();
     $sysinfos['path_to_phpini'] = php_ini_loaded_file();
     $sysinfos['cfg_include_path'] = get_cfg_var('include_path');
     $sysinfos['cfg_file_path'] = realpath(get_cfg_var("cfg_file_path"));
     $sysinfos['zend_thread_safty'] = (int) function_exists('zend_thread_id');
     $sysinfos['open_basedir'] = (int) ini_get('open_basedir');
     $sysinfos['memory_limit'] = ini_get('memory_limit');
     $sysinfos['allow_url_fopen'] = (int) ini_get('allow_url_fopen');
     $sysinfos['allow_url_include'] = (int) ini_get('allow_url_include');
     $sysinfos['file_uploads'] = ini_get('file_uploads');
     $sysinfos['upload_max_filesize'] = ini_get('upload_max_filesize');
     $sysinfos['post_max_size'] = ini_get('post_max_size');
     $sysinfos['disable_functions'] = (int) ini_get('disable_functions');
     $sysinfos['disable_classes'] = (int) ini_get('disable_classes');
     $sysinfos['enable_dl'] = (int) ini_get('enable_dl');
     $sysinfos['filter_default'] = ini_get('filter.default');
     $sysinfos['zend_ze1_compatibility_mode'] = (int) ini_get('zend.ze1_compatibility_mode');
     $sysinfos['unicode_semantics'] = (int) ini_get('unicode.semantics');
     $sysinfos['mbstring_func_overload'] = ini_get('mbstring.func_overload');
     $sysinfos['max_input_time'] = ini_get('max_input_time');
     $sysinfos['max_execution_time'] = ini_get('max_execution_time');
     return $sysinfos;
 }
コード例 #18
0
ファイル: Sec.php プロジェクト: 42northgroup/42Viral
    /**
     * Creates some pseudo random jibberish to be used as a salt value.
     * @access public
     * @static
     * @return string
     * @author Jason D Snider <*****@*****.**>
     */
    public static function makeSalt()
    {
        $seed = openssl_random_pseudo_bytes(4096);
        $seed .= String::uuid();
        $seed .= mt_rand(1000000000, 2147483647);
        $seed .= Security::hash(php_ini_loaded_file(), 'sha512', true);

        if(is_dir(DS . 'var')){
            $seed .= Security::hash(implode(scandir(DS . 'var')), 'sha512');
        }

        $salt = $hash = Security::hash($seed, 'sha512', true);

        return $salt;
    }
コード例 #19
0
 /**
  * Launch sub process
  *
  * @return array The new sub process and its STDIN, STDOUT, STDERR pipes – or FALSE if an error occurred.
  * @throws \RuntimeException
  */
 protected function launchSubProcess()
 {
     $systemCommand = 'FLOW_ROOTPATH=' . FLOW_PATH_ROOT . ' FLOW_PATH_TEMPORARY_BASE=' . escapeshellarg(FLOW_PATH_TEMPORARY_BASE) . ' FLOW_CONTEXT=' . (string) $this->context . ' ' . PHP_BINDIR . '/php -c ' . php_ini_loaded_file() . ' ' . FLOW_PATH_FLOW . 'Scripts/flow.php' . ' --start-slave';
     $descriptorSpecification = [['pipe', 'r'], ['pipe', 'w'], ['pipe', 'a']];
     $this->subProcess = proc_open($systemCommand, $descriptorSpecification, $this->pipes);
     if (!is_resource($this->subProcess)) {
         throw new \RuntimeException('Could not execute sub process.');
     }
     $read = [$this->pipes[1]];
     $write = null;
     $except = null;
     $readTimeout = 30;
     stream_select($read, $write, $except, $readTimeout);
     $subProcessStatus = proc_get_status($this->subProcess);
     return $subProcessStatus['running'] === true ? [$this->subProcess, $this->pipes] : false;
 }
コード例 #20
0
 /**
  * Launch sub process
  *
  * @return array The new sub process and its STDIN, STDOUT, STDERR pipes – or FALSE if an error occurred.
  * @throws \RuntimeException
  */
 protected function launchSubProcess()
 {
     $systemCommand = 'FLOW_ROOTPATH=' . escapeshellarg(FLOW_PATH_ROOT) . ' FLOW_CONTEXT=' . (string) $this->context . ' ' . PHP_BINDIR . '/php -c ' . escapeshellarg(php_ini_loaded_file()) . ' ' . escapeshellarg(FLOW_PATH_FLOW . 'Scripts/flow.php') . ' --start-slave';
     $descriptorSpecification = array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'a'));
     $this->subProcess = proc_open($systemCommand, $descriptorSpecification, $this->pipes);
     if (!is_resource($this->subProcess)) {
         throw new \RuntimeException('Could not execute sub process.');
     }
     $read = array($this->pipes[1]);
     $write = NULL;
     $except = NULL;
     $readTimeout = 30;
     stream_select($read, $write, $except, $readTimeout);
     $subProcessStatus = proc_get_status($this->subProcess);
     return $subProcessStatus['running'] === TRUE ? array($this->subProcess, $this->pipes) : FALSE;
 }
コード例 #21
0
ファイル: email.test.php プロジェクト: kira8565/ITOP203-ZHCN
/**
 * Helper to check server setting required to send an email
 */
function CheckEmailSetting($oP)
{
    $bRet = true;
    if (function_exists('php_ini_loaded_file')) {
        $sPhpIniFile = php_ini_loaded_file();
    } else {
        $sPhpIniFile = 'php.ini';
    }
    $bIsWindows = array_key_exists('WINDIR', $_SERVER) || array_key_exists('windir', $_SERVER);
    if ($bIsWindows) {
        $sSmtpServer = ini_get('SMTP');
        if (empty($sSmtpServer)) {
            $oP->error("The SMTP server is not defined. Please add the 'SMTP' directive into {$sPhpIniFile}");
            $bRet = false;
        } else {
            if (strcasecmp($sSmtpServer, 'localhost') == 0) {
                $oP->warning("Your SMTP server is configured to 'localhost'. You might want to set or change the 'SMTP' directive into {$sPhpIniFile}");
            } else {
                $oP->info("Your SMTP server: <strong>{$sSmtpServer}</strong>. To change this value, modify the 'SMTP' directive into {$sPhpIniFile}");
            }
        }
        $iSmtpPort = (int) ini_get('smtp_port');
        if (empty($iSmtpPort)) {
            $oP->info("The SMTP port is not defined. Please add the 'smtp_port' directive into {$sPhpIniFile}");
            $bRet = false;
        } else {
            if ($iSmtpPort = 25) {
                $oP->info("Your SMTP port is configured to the default value: 25. You might want to set or change the 'smtp_port' directive into {$sPhpIniFile}");
            } else {
                $oP->info("Your SMTP port is configured to {$iSmtpPort}. You might want to set or change the 'smtp_port' directive into {$sPhpIniFile}");
            }
        }
    } else {
        // Not a windows system
        $sSendMail = ini_get('sendmail_path');
        if (empty($sSendMail)) {
            $oP->error("The command to send mail is not defined. Please add the 'sendmail_path' directive into {$sPhpIniFile}. A recommended setting is <em>sendmail_path=sendmail -t -i</em>");
            $bRet = false;
        } else {
            $oP->info("The command to send mail: <strong>{$sSendMail}</strong>. To change this value, modify the 'sendmail_path' directive into {$sPhpIniFile}");
        }
    }
    if ($bRet) {
        $oP->ok("PHP settings are ok to proceed with a test of the email");
    }
    return $bRet;
}
コード例 #22
0
 private function createExtensionHint()
 {
     $paths = array();
     if (($iniPath = php_ini_loaded_file()) !== false) {
         $paths[] = $iniPath;
     }
     if (!defined('HHVM_VERSION') && ($additionalIniPaths = php_ini_scanned_files())) {
         $paths = array_merge($paths, array_map("trim", explode(",", $additionalIniPaths)));
     }
     if (count($paths) === 0) {
         return '';
     }
     $text = "\n  To enable extensions, verify that they are enabled in those .ini files:\n    - ";
     $text .= implode("\n    - ", $paths);
     $text .= "\n  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.";
     return $text;
 }
コード例 #23
0
    public function execute()
    {
        $kernel = kernel();
        if ($this->options->apache2) {
            $config = $this->generateApache2Config($kernel);
            echo $config->generate();
        } else {
            $serverName = $kernel->config->get('framework', 'Domain');
            $serverAliases = $kernel->config->get('framework', 'DomainAliases') ?: [];
            $documentRoot = $kernel->webroot;
            $etc = dirname(php_ini_loaded_file());
            $fpmConfigFile = $etc . DIRECTORY_SEPARATOR . 'php-fpm.conf';
            if (file_exists($fpmConfigFile)) {
                $fpmConfig = parse_ini_file($fpmConfigFile);
            } else {
                $fpmConfig = [];
            }
            $listen = $this->options->{'fastcgi'} ?: (isset($fpmConfig['listen']) ? $fpmConfig['listen'] : 'localhost:9000');
            echo <<<OUT
# vim:et:sw=2:ts=2:sts=2:
server {
  listen 80;
  server_name {$serverName};
  index index.html index.htm index.php;
  server_name_in_redirect off;
  root {$documentRoot};
  autoindex off;
  location / {
    if (!-e \$request_filename) {
      rewrite ^(.*)\$ /index.php\$1 last;
    }
  }
  location ~ \\.php {
    fastcgi_split_path_info ^(.+\\.php)(/.*)\$;
    fastcgi_param  SCRIPT_FILENAME    \$document_root\$fastcgi_script_name;
    fastcgi_param  SCRIPT_NAME        \$fastcgi_script_name;
    fastcgi_param  PATH_INFO          \$fastcgi_path_info;
    fastcgi_index  index.php;
    fastcgi_pass   {$listen};
    include fastcgi_params;
  }
}
OUT;
        }
    }
コード例 #24
0
ファイル: ZipDownloader.php プロジェクト: neon64/composer
 /**
  * {@inheritDoc}
  */
 public function download(PackageInterface $package, $path)
 {
     if (null === self::$hasSystemUnzip) {
         $finder = new ExecutableFinder();
         self::$hasSystemUnzip = (bool) $finder->find('unzip');
     }
     if (!class_exists('ZipArchive') && !self::$hasSystemUnzip) {
         // php.ini path is added to the error message to help users find the correct file
         $iniPath = php_ini_loaded_file();
         if ($iniPath) {
             $iniMessage = 'The php.ini used by your command-line PHP is: ' . $iniPath;
         } else {
             $iniMessage = 'A php.ini file does not exist. You will have to create one.';
         }
         $error = "The zip extension and unzip command are both missing, skipping.\n" . $iniMessage;
         throw new \RuntimeException($error);
     }
     return parent::download($package, $path);
 }
コード例 #25
0
 /**
  * @test
  */
 public function subProcessCommandEvaluatesIniFileUsageSettingCorrectly()
 {
     $settings = array('core' => array('context' => 'Testing', 'phpBinaryPathAndFilename' => '/foo/var/php'));
     $message = 'The command must contain the current ini because it is not explicitly set in settings.';
     $actual = $this->scriptsMock->_call('buildSubprocessCommand', 'flow:foo:identifier', $settings);
     $this->assertContains(sprintf(' -c %s ', escapeshellarg(php_ini_loaded_file())), $actual, $message);
     $settings['core']['subRequestPhpIniPathAndFilename'] = NULL;
     $message = 'The command must contain the current ini because it is explicitly set, but NULL, in settings.';
     $actual = $this->scriptsMock->_call('buildSubprocessCommand', 'flow:foo:identifier', $settings);
     $this->assertContains(sprintf(' -c %s ', escapeshellarg(php_ini_loaded_file())), $actual, $message);
     $settings['core']['subRequestPhpIniPathAndFilename'] = '/foo/ini/path';
     $message = 'The command must contain a specified ini file path because it is set in settings.';
     $actual = $this->scriptsMock->_call('buildSubprocessCommand', 'flow:foo:identifier', $settings);
     $this->assertContains(sprintf(' -c %s ', escapeshellarg('/foo/ini/path')), $actual, $message);
     $settings['core']['subRequestPhpIniPathAndFilename'] = FALSE;
     $message = 'The command must not contain an ini file path because it is set to FALSE in settings.';
     $actual = $this->scriptsMock->_call('buildSubprocessCommand', 'flow:foo:identifier', $settings);
     $this->assertNotContains(' -c ', $actual, $message);
 }
コード例 #26
0
ファイル: Zip.php プロジェクト: pixelpolishers/resolver
 private function ensureZipArchivePresent()
 {
     if (class_exists('ZipArchive')) {
         return;
     }
     // php.ini path is added to the error message to help users find the correct file
     $iniPath = php_ini_loaded_file();
     if ($iniPath) {
         $iniMessage = 'The php.ini used by your command-line PHP is: ' . $iniPath;
     } else {
         $iniMessage = 'A php.ini file does not exist. You will have to create one.';
     }
     if (defined('PHP_WINDOWS_VERSION_BUILD')) {
         $error = "Could not decompress the archive, enable the PHP zip extension or install unzip.\n";
     } else {
         $error = "Could not decompress the archive, enable the PHP zip extension.\n" . $iniMessage;
     }
     $error .= $iniMessage . "\n";
     throw new RuntimeException($error);
 }
コード例 #27
0
 public static function phpInfos()
 {
     $php = array();
     $php['version'] = phpversion();
     $iniVars = ini_get_all();
     $loadedExtensions = get_loaded_extensions();
     // $ext = new ReflectionExtension('mysqli');
     // $ext->info();
     $memoryPeak = memory_get_peak_usage();
     $memoryUsage = memory_get_usage();
     $iniLoaded = php_ini_loaded_file();
     $iniScanned = php_ini_scanned_files();
     $symfony = new Symfony();
     $symfony->initRequirements();
     $symfony->initOptionalRequirements();
     $majesteel = new MajesTeel();
     $majesteel->initRequirements();
     $majesteel->initOptionalRequirements();
     Flight::render('templates/phpInfos.tpl', array('php' => $php, 'iniVars' => $iniVars, 'loadedExtensions' => $loadedExtensions, 'memoryPeak' => $memoryPeak, 'memoryUsage' => $memoryUsage, 'iniLoaded' => $iniLoaded, 'iniScanned' => $iniScanned, 'symfony' => $symfony, 'majesteel' => $majesteel));
 }
コード例 #28
0
 public function getIndex()
 {
     if (!$this->checkAccessRead()) {
         return;
     }
     /*
      * Check if Laravel is compiled to one single file
      */
     $filename = app('path.base') . '/bootstrap/cache/compiled.php';
     if (File::exists($filename)) {
         $optimized = '1 - ' . trans('app.compiled') . ': ' . Carbon::createFromTimeStamp(filemtime($filename));
     } else {
         $optimized = 0;
     }
     /*
      * Count disabled modules
      */
     $moduleBase = app()['modules'];
     $disabled = sizeof($moduleBase->disabled());
     /*
      * Create array with names and values
      */
     $placeholder = Config::get('app.key') == '01234567890123456789012345678912';
     $appClass = get_class(app());
     $opcacheExists = (int) function_exists('opcache_get_status');
     $opcacheEnabled = $opcacheExists and opcache_get_status()['opcache_enabled'] ? 1 : 0;
     $settings = ['PHP.version' => phpversion(), 'PHP.os' => PHP_OS, 'PHP.ini' => php_ini_loaded_file(), 'PHP.memory_limit' => ini_get('memory_limit'), 'PHP.max_execution_time' => ini_get('max_execution_time'), 'PHP.post_max_size' => ini_get('post_max_size'), 'PHP.upload_max_filesize' => ini_get('upload_max_filesize'), 'Laravel.version' => $appClass::VERSION, 'Artisan optimized' => $optimized, 'App.environment' => App::environment(), 'App.url' => Config::get('app.url'), 'App.debug' => (int) Config::get('app.debug'), 'App.key' => $placeholder ? '<em>' . trans('app.placeholder') . '</em>' : trans('app.valid'), 'Cache.default' => Config::get('cache.default'), 'Modules.disabled' => $disabled, 'Mail.pretend' => (int) Config::get('mail.pretend'), 'OPcache.installed' => $opcacheExists, 'OPcache.enabled' => $opcacheEnabled, 'Xdebug.enabled' => extension_loaded('xdebug') ? 1 : 0];
     /*
      * If we use MySQL as database, add values of some MySQL variables.
      */
     if (Config::get('database.default') == 'mysql') {
         $fetchMethod = Config::get('database.fetch');
         DB::connection()->setFetchMode(PDO::FETCH_ASSOC);
         // We need to get the result as array of arrays
         $sqlVars = DB::select('SHOW VARIABLES');
         DB::connection()->setFetchMode($fetchMethod);
         $settings['MySQL.max_connections'] = $this->getSqlVar($sqlVars, 'max_connections');
         $settings['MySQL.max_user_connections'] = $this->getSqlVar($sqlVars, 'max_user_connections');
     }
     $this->pageView('diag::admin_index', compact('settings'));
 }
コード例 #29
0
ファイル: RarDownloader.php プロジェクト: neon64/composer
 protected function extract($file, $path)
 {
     $processError = null;
     // Try to use unrar on *nix
     if (!Platform::isWindows()) {
         $command = 'unrar x ' . ProcessExecutor::escape($file) . ' ' . ProcessExecutor::escape($path) . ' && chmod -R u+w ' . ProcessExecutor::escape($path);
         if (0 === $this->process->execute($command, $ignoredOutput)) {
             return;
         }
         $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
     }
     if (!class_exists('RarArchive')) {
         // php.ini path is added to the error message to help users find the correct file
         $iniPath = php_ini_loaded_file();
         if ($iniPath) {
             $iniMessage = 'The php.ini used by your command-line PHP is: ' . $iniPath;
         } else {
             $iniMessage = 'A php.ini file does not exist. You will have to create one.';
         }
         $error = "Could not decompress the archive, enable the PHP rar extension or install unrar.\n" . $iniMessage . "\n" . $processError;
         if (!Platform::isWindows()) {
             $error = "Could not decompress the archive, enable the PHP rar extension.\n" . $iniMessage;
         }
         throw new \RuntimeException($error);
     }
     $rarArchive = RarArchive::open($file);
     if (false === $rarArchive) {
         throw new \UnexpectedValueException('Could not open RAR archive: ' . $file);
     }
     $entries = $rarArchive->getEntries();
     if (false === $entries) {
         throw new \RuntimeException('Could not retrieve RAR archive entries');
     }
     foreach ($entries as $entry) {
         if (false === $entry->extract($path)) {
             throw new \RuntimeException('Could not extract entry');
         }
     }
     $rarArchive->close();
 }
コード例 #30
0
 protected function extract($file, $path)
 {
     $processError = null;
     if (self::$hasSystemUnzip) {
         $command = 'unzip ' . ProcessExecutor::escape($file) . ' -d ' . ProcessExecutor::escape($path);
         if (!Platform::isWindows()) {
             $command .= ' && chmod -R u+w ' . ProcessExecutor::escape($path);
         }
         try {
             if (0 === $this->process->execute($command, $ignoredOutput)) {
                 return;
             }
             $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
         } catch (\Exception $e) {
             $processError = 'Failed to execute ' . $command . "\n\n" . $e->getMessage();
         }
     }
     if (!class_exists('ZipArchive')) {
         // php.ini path is added to the error message to help users find the correct file
         $iniPath = php_ini_loaded_file();
         if ($iniPath) {
             $iniMessage = 'The php.ini used by your command-line PHP is: ' . $iniPath;
         } else {
             $iniMessage = 'A php.ini file does not exist. You will have to create one.';
         }
         $error = "Could not decompress the archive, enable the PHP zip extension or install unzip.\n" . $iniMessage . ($processError ? "\n" . $processError : '');
         throw new \RuntimeException($error);
     }
     $zipArchive = new ZipArchive();
     if (true !== ($retval = $zipArchive->open($file))) {
         throw new \UnexpectedValueException(rtrim($this->getErrorMessage($retval, $file) . "\n" . $processError), $retval);
     }
     if (true !== $zipArchive->extractTo($path)) {
         $this->io->writeError("<warn>As there is no 'unzip' command installed zip files are being unpacked using the PHP zip extension.</warn>");
         $this->io->writeError("<warn>This may cause invalid reports of corrupted archives. Installing 'unzip' may remediate them.</warn>");
         throw new \RuntimeException("There was an error extracting the ZIP file, it is either corrupted or using an invalid format");
     }
     $zipArchive->close();
 }