コード例 #1
1
ファイル: yay_parse.php プロジェクト: lastguest/yay
function yay_parse(string $source, Directives $directives = null, BlueContext $blueContext = null) : string
{
    if ($gc = gc_enabled()) {
        gc_disable();
    }
    // important optimization!
    static $globalDirectives = null;
    if (null === $globalDirectives) {
        $globalDirectives = new ArrayObject();
    }
    $directives = $directives ?: new Directives();
    $blueContext = $blueContext ?: new BlueContext();
    $cg = (object) ['ts' => TokenStream::fromSource($source), 'directives' => $directives, 'cycle' => new Cycle($source), 'globalDirectives' => $globalDirectives, 'blueContext' => $blueContext];
    foreach ($cg->globalDirectives as $d) {
        $cg->directives->add($d);
    }
    traverse(midrule(function (TokenStream $ts) use($directives, $blueContext) {
        $token = $ts->current();
        tail_call:
        if (null === $token) {
            return;
        }
        // skip when something looks like a new macro to be parsed
        if ('macro' === (string) $token) {
            return;
        }
        // here we do the 'magic' to match and expand userland macros
        $directives->apply($ts, $token, $blueContext);
        $token = $ts->next();
        goto tail_call;
    }), consume(chain(token(T_STRING, 'macro')->as('declaration'), optional(repeat(rtoken('/^·\\w+$/')))->as('tags'), lookahead(token('{')), commit(chain(braces()->as('pattern'), operator('>>'), braces()->as('expansion')))->as('body'), optional(token(';'))), CONSUME_DO_TRIM)->onCommit(function (Ast $macroAst) use($cg) {
        $scope = Map::fromEmpty();
        $tags = Map::fromValues(array_map('strval', $macroAst->{'tags'}));
        $pattern = new Pattern($macroAst->{'declaration'}->line(), $macroAst->{'body pattern'}, $tags, $scope);
        $expansion = new Expansion($macroAst->{'body expansion'}, $tags, $scope);
        $macro = new Macro($tags, $pattern, $expansion, $cg->cycle);
        $cg->directives->add($macro);
        // allocate the userland macro
        // allocate the userland macro globally if it's declared as global
        if ($macro->tags()->contains('·global')) {
            $cg->globalDirectives[] = $macro;
        }
    }))->parse($cg->ts);
    $expansion = (string) $cg->ts;
    if ($gc) {
        gc_enable();
    }
    return $expansion;
}
コード例 #2
0
 protected function tearDown()
 {
     //Close & unsets
     if (is_object($this->em)) {
         $this->em->getConnection()->close();
         $this->em->close();
     }
     unset($this->em);
     unset($this->container);
     unset($this->kern);
     unset($this->client);
     //Nettoyage des mocks
     //http://kriswallsmith.net/post/18029585104/faster-phpunit
     $refl = new \ReflectionObject($this);
     foreach ($refl->getProperties() as $prop) {
         if (!$prop->isStatic() && 0 !== strpos($prop->getDeclaringClass()->getName(), 'PHPUnit_')) {
             $prop->setAccessible(true);
             $prop->setValue($this, null);
         }
     }
     //Nettoyage du garbage
     if (!gc_enabled()) {
         gc_enable();
     }
     gc_collect_cycles();
     //Parent
     parent::tearDown();
 }
コード例 #3
0
	/**
	 * Remove items that link back to this before destroying this object
	 */
	public function __destruct()
	{
		if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode'))
		{
			unset($this->feed);
		}
	}
コード例 #4
0
ファイル: Daemon.php プロジェクト: Hypnobox/daemon
 protected function iterate($seconds)
 {
     sleep($seconds);
     if (!gc_enabled()) {
         gc_enable();
     }
     gc_collect_cycles();
 }
コード例 #5
0
ファイル: Command.php プロジェクト: shaogx/easyJob
 public function __construct()
 {
     $this->checkPcntl();
     // Enable PHP 5.3 garbage collection
     if (function_exists('gc_enable')) {
         gc_enable();
         $this->gc = gc_enabled();
     }
 }
コード例 #6
0
ファイル: SuluTestCase.php プロジェクト: sulu/sulu
 /**
  * {@inheritdoc}
  */
 public static function setUpBeforeClass()
 {
     // enables garbage collector because symfony/phpunit-bridge disables it. see:
     // see: https://github.com/symfony/symfony/pull/13398/files#diff-81bfee6017752d99d3119f4ddb1a09edR1
     // see: https://github.com/symfony/symfony/pull/13398 (feature list)
     if (!gc_enabled()) {
         gc_enable();
     }
 }
コード例 #7
0
ファイル: Memory.php プロジェクト: xhoogland/Monique
 /**
  * In the constructor we'll simply initialise the earlier two properties,
  * respectivily with an array and the current timestamp.
  */
 public static function Initialize()
 {
     self::$s_pStatistics = new \stdClass();
     self::$s_pStatistics->Memory = 0;
     self::$s_pStatistics->Cycles = 0;
     self::$s_nLastCollect = time();
     if (!gc_enabled()) {
         gc_enable();
     }
 }
コード例 #8
0
 /**
  * Gc
  */
 private function gc()
 {
     if (gc_enabled()) {
         gc_collect_cycles();
     } else {
         gc_enable();
         gc_collect_cycles();
         gc_disable();
     }
 }
コード例 #9
0
 /**
  * @param  WorkerEvent $event
  * @return void
  */
 public function onStopConditionCheck(WorkerEvent $event)
 {
     // @see http://php.net/manual/en/features.gc.collecting-cycles.php
     if (gc_enabled()) {
         gc_collect_cycles();
     }
     $usage = memory_get_usage();
     if ($this->maxMemory && $usage > $this->maxMemory) {
         $event->exitWorkerLoop();
         $this->state = sprintf("memory threshold of %s exceeded (usage: %s)", $this->humanFormat($this->maxMemory), $this->humanFormat($usage));
     } else {
         $this->state = sprintf('%s memory usage', $this->humanFormat($usage));
     }
 }
コード例 #10
0
ファイル: Timer.php プロジェクト: flaviovs/timeit
 protected static function timeExec(callable $code, $rounds)
 {
     $gc_enabled = gc_enabled();
     if ($gc_enabled) {
         gc_disable();
     }
     $start = microtime(TRUE);
     for ($i = 0; $i < $rounds; $i++) {
         $code();
     }
     $end = microtime(TRUE);
     if ($gc_enabled) {
         gc_enable();
     }
     return $end - $start;
 }
コード例 #11
0
 /**
  * 环境检查
  * @throws Exception
  */
 public function check_pcntl()
 {
     // Make sure PHP has support for pcntl
     if (!function_exists('pcntl_signal')) {
         $message = 'PHP does not appear to be compiled with the PCNTL extension.  This is neccesary for daemonization';
         throw new Exception($message);
     }
     //信号处理
     pcntl_signal(SIGTERM, array(&$this, "signal_handler"));
     pcntl_signal(SIGINT, array(&$this, "signal_handler"));
     pcntl_signal(SIGQUIT, array(&$this, "signal_handler"));
     // Enable PHP 5.3 garbage collection
     if (function_exists('gc_enable')) {
         gc_enable();
         $this->gc_enabled = gc_enabled();
     }
 }
コード例 #12
0
 public function __construct($socket_url, $protocol_name, $transport_name = 'Socket')
 {
     if (PHP_SAPI !== 'cli') {
         throw new LogicException("Daemonic Application should be run using CLI SAPI");
     }
     if (version_compare("5.3.0", PHP_VERSION, '>')) {
         throw new LogicException("Daemonic Application requires PHP 5.3.0+");
     }
     // Checking for GarbageCollection patch
     if (false === gc_enabled()) {
         gc_enable();
     }
     $transport_class = 'MFS\\AppServer\\Transport\\' . $transport_name;
     $this->setTransport(new $transport_class($socket_url, array($this, 'onRequest')));
     $protocol_class = 'MFS\\AppServer\\' . $protocol_name . '\\Server';
     $this->setProtocol(new $protocol_class());
     $this->log('Initialized Daemonic Handler');
 }
コード例 #13
0
 public function check_pcntl()
 {
     if (!function_exists('pcntl_signal_dispatch')) {
         // PHP < 5.3 uses ticks to handle signals instead of pcntl_signal_dispatch
         // call sighandler only every 10 ticks
         declare (ticks=1);
     }
     // Make sure PHP has support for pcntl
     if (!function_exists('pcntl_signal')) {
         $message = 'PHP does not appear to be compiled with the PCNTL extension.  This is neccesary for daemonization';
         throw new \Exception($message);
     }
     //信号处理
     \pcntl_signal(SIGTERM, array(__CLASS__, "signal_handler"), false);
     \pcntl_signal(SIGINT, array(__CLASS__, "signal_handler"), false);
     \pcntl_signal(SIGQUIT, array(__CLASS__, "signal_handler"), false);
     // Enable PHP 5.3 garbage collection
     if (\function_exists('gc_enable')) {
         \gc_enable();
         $this->gc_enabled = \gc_enabled();
     }
 }
コード例 #14
0
ファイル: gc_001.php プロジェクト: badlamer/hhvm
<?php

gc_disable();
var_dump(gc_enabled());
gc_enable();
var_dump(gc_enabled());
コード例 #15
0
     echo __('PHP Actual Configuration Memory Limit', 'bulletproof-security') . ': <strong><font color="blue">' . __('The Memory Limit value is not available from your Server.', 'bulletproof-security') . '</font></strong><br>';
 } else {
     switch ($memoryLimit) {
         case $memoryLimit >= '128':
             echo __('PHP Actual Configuration Memory Limit', 'bulletproof-security') . ': <strong><font color="green">' . $memoryLimitM . '</font></strong><br>';
             break;
         case $memoryLimit >= '65' && $memoryLimit < '128':
             echo __('PHP Actual Configuration Memory Limit', 'bulletproof-security') . ': <strong><font color="blue">' . $memoryLimitM . __(' Recommendation: Increase Memory Limit to 128M.', 'bulletproof-security') . '</font></strong><br>';
             break;
         case $memoryLimit > '0' && $memoryLimit <= '64':
             echo __('PHP Actual Configuration Memory Limit', 'bulletproof-security') . ': <strong><font color="red">' . $memoryLimitM . __(' Recommendation: Increase Memory Limit to 128M.', 'bulletproof-security') . '</font></strong><br>';
             break;
     }
 }
 if (function_exists('gc_enabled') && function_exists('gc_collect_cycles')) {
     if (gc_enabled()) {
         $garbage = 'On | Cycles: ' . gc_collect_cycles();
     } else {
         $garbage = 'Off';
     }
     echo __('Garbage Collector', 'bulletproof-security') . ': <strong>' . $garbage . '</strong><br>';
 }
 echo __('PHP Max Upload Size', 'bulletproof-security') . ': ';
 $upload_max = ini_get('upload_max_filesize');
 echo '<strong>' . $upload_max . '</strong><br>';
 echo __('PHP Max Post Size', 'bulletproof-security') . ': ';
 $post_max = ini_get('post_max_size');
 echo '<strong>' . $post_max . '</strong><br>';
 echo __('PHP Safe Mode', 'bulletproof-security') . ': ';
 if (ini_get('safe_mode') == 1) {
     $text = '<font color="red"><strong>' . __('On', 'bulletproof-security') . '</strong></font>';
コード例 #16
0
ファイル: Daemon.php プロジェクト: nfx/AsyncBundle
 public function __construct()
 {
     if (!gc_enabled()) {
         gc_enable();
     }
 }
コード例 #17
0
<?php

use Doctrine\Common\Annotations\AnnotationRegistry;
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler;
// Detect if we're loaded by an actual run of phpunit
if (!defined('PHPUNIT_COMPOSER_INSTALL') && !class_exists('PHPUnit_TextUI_Command', false)) {
    return;
}
if (PHP_VERSION_ID >= 50400 && gc_enabled()) {
    // Disabling Zend Garbage Collection to prevent segfaults with PHP5.4+
    // https://bugs.php.net/bug.php?id=53976
    gc_disable();
}
if (class_exists('Doctrine\\Common\\Annotations\\AnnotationRegistry')) {
    AnnotationRegistry::registerLoader('class_exists');
}
DeprecationErrorHandler::register(getenv('SYMFONY_DEPRECATIONS_HELPER'));
コード例 #18
0
<?php

include 'ProcessControl.php';
set_time_limit(0);
if (false == gc_enabled()) {
    gc_enable();
}
$options = getopt('dhP:u:');
if (isset($options['h'])) {
    echo <<<'HELP'
-d            run as a daemon
-h            print this help and exit
-u <username> assume identity of <username> (only when run as root)

HELP;
    exit(0);
}
try {
    $manager = new Fork\Manager(function () {
        $children = new Fork\Children();
        $gearman = new Fork\Worker\PeclGearman(function () {
            return include 'GearmanWorker.php';
        });
        // Run 5 gearmans each restarting after an hour
        $children->createProcesses(new Fork\Worker\ExitAfterDuration($gearman, 3600), 5);
        return $children;
    });
    // Daemonize?
    if (isset($options['d'])) {
        $daemon = new ProcessControl\Daemon();
        if (isset($options['u'])) {
コード例 #19
0
ファイル: main.php プロジェクト: BurakDev/BloonPHP
<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);
if (!gc_enabled()) {
    gc_enable();
}
if (!extension_loaded("pthreads")) {
    die("Please install pthreads extension !");
}
if (file_exists('vendor/autoload.php')) {
    require 'vendor/autoload.php';
} else {
    die("Please install composer and run 'composer install' !" . PHP_EOL);
}
use Emulator\Emulator;
Emulator::start();
コード例 #20
0
ファイル: Watcher.php プロジェクト: beingsane/patternlab-php
 /**
  * Watch the source/ directory for any changes to existing files. Will run forever if given the chance.
  * @param  {Boolean}       decide if the reload server should be turned on
  * @param  {Boolean}       decide if static files like CSS and JS should be moved
  */
 public function watch($reload = false, $moveStatic = true, $noCacheBuster = false)
 {
     // automatically start the auto-refresh tool
     if ($reload) {
         $path = str_replace("lib" . DIRECTORY_SEPARATOR . "PatternLab", "autoReloadServer.php", __DIR__);
         $fp = popen("php " . $path . " -s", "r");
         print "starting page auto-reload...\n";
     }
     $this->noCacheBuster = $noCacheBuster;
     $c = false;
     // track that one loop through the pattern file listing has completed
     $o = new \stdClass();
     // create an object to hold the properties
     $cp = new \stdClass();
     // create an object to hold a clone of $o
     $o->patterns = new \stdClass();
     print "watching your site for changes...\n";
     // run forever
     while (true) {
         // clone the patterns so they can be checked in case something gets deleted
         $cp = clone $o->patterns;
         // iterate over the patterns & related data and regenerate the entire site if they've changed
         $patternObjects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->sd . "/_patterns/"), \RecursiveIteratorIterator::SELF_FIRST);
         // make sure dots are skipped
         $patternObjects->setFlags(\FilesystemIterator::SKIP_DOTS);
         foreach ($patternObjects as $name => $object) {
             // clean-up the file name and make sure it's not one of the pattern lab files or to be ignored
             $fileName = str_replace($this->sd . "/_patterns" . DIRECTORY_SEPARATOR, "", $name);
             $fileNameClean = str_replace(DIRECTORY_SEPARATOR . "_", DIRECTORY_SEPARATOR, $fileName);
             if ($object->isFile() && ($object->getExtension() == "mustache" || $object->getExtension() == "json")) {
                 // make sure this isn't a hidden pattern
                 $patternParts = explode(DIRECTORY_SEPARATOR, $fileName);
                 $pattern = isset($patternParts[2]) ? $patternParts[2] : $patternParts[1];
                 // make sure the pattern still exists in source just in case it's been deleted during the iteration
                 if (file_exists($name)) {
                     $mt = $object->getMTime();
                     if (isset($o->patterns->{$fileName}) && $o->patterns->{$fileName} != $mt) {
                         $o->patterns->{$fileName} = $mt;
                         $this->updateSite($fileName, "changed");
                     } else {
                         if (!isset($o->patterns->{$fileName}) && $c) {
                             $o->patterns->{$fileName} = $mt;
                             $this->updateSite($fileName, "added");
                             if ($object->getExtension() == "mustache") {
                                 $patternSrcPath = str_replace(".mustache", "", $fileName);
                                 $patternDestPath = str_replace("/", "-", $patternSrcPath);
                                 $render = $pattern[0] != "_" ? true : false;
                                 $this->patternPaths[$patternParts[0]][$pattern] = array("patternSrcPath" => $patternSrcPath, "patternDestPath" => $patternDestPath, "render" => $render);
                             }
                         } else {
                             if (!isset($o->patterns->{$fileName})) {
                                 $o->patterns->{$fileName} = $mt;
                             }
                         }
                     }
                     if ($c && isset($o->patterns->{$fileName})) {
                         unset($cp->{$fileName});
                     }
                 } else {
                     // the file was removed during the iteration so remove references to the item
                     unset($o->patterns->{$fileName});
                     unset($cp->{$fileName});
                     unset($this->patternPaths[$patternParts[0]][$pattern]);
                     $this->updateSite($fileName, "removed");
                 }
             }
         }
         // make sure old entries are deleted
         // will throw "pattern not found" errors if an entire directory is removed at once but that shouldn't be a big deal
         if ($c) {
             foreach ($cp as $fileName => $mt) {
                 unset($o->patterns->{$fileName});
                 $patternParts = explode(DIRECTORY_SEPARATOR, $fileName);
                 $pattern = isset($patternParts[2]) ? $patternParts[2] : $patternParts[1];
                 unset($this->patternPaths[$patternParts[0]][$pattern]);
                 $this->updateSite($fileName, "removed");
             }
         }
         // iterate over the data files and regenerate the entire site if they've changed
         $objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->sd . "/_data/"), \RecursiveIteratorIterator::SELF_FIRST);
         // make sure dots are skipped
         $objects->setFlags(\FilesystemIterator::SKIP_DOTS);
         foreach ($objects as $name => $object) {
             $fileName = str_replace($this->sd . "/_data" . DIRECTORY_SEPARATOR, "", $name);
             $mt = $object->getMTime();
             if (!isset($o->{$fileName})) {
                 $o->{$fileName} = $mt;
                 if ($fileName[0] != "_" && $object->isFile()) {
                     $this->moveStaticFile("_data/" . $fileName, "", "_data", "data");
                 }
             } else {
                 if ($o->{$fileName} != $mt) {
                     $o->{$fileName} = $mt;
                     $this->updateSite($fileName, "changed");
                     if ($fileName[0] != "_" && $object->isFile()) {
                         $this->moveStaticFile("_data/" . $fileName, "", "_data", "data");
                     }
                 }
             }
         }
         // iterate over all of the other files in the source directory and move them if their modified time has changed
         if ($moveStatic) {
             $objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->sd . "/"), \RecursiveIteratorIterator::SELF_FIRST);
             // make sure dots are skipped
             $objects->setFlags(\FilesystemIterator::SKIP_DOTS);
             foreach ($objects as $name => $object) {
                 // clean-up the file name and make sure it's not one of the pattern lab files or to be ignored
                 $fileName = str_replace($this->sd . DIRECTORY_SEPARATOR, "", $name);
                 if ($fileName[0] != "_" && !in_array($object->getExtension(), $this->ie) && !in_array($object->getFilename(), $this->id)) {
                     // catch directories that have the ignored dir in their path
                     $ignoreDir = $this->ignoreDir($fileName);
                     // check to see if it's a new directory
                     if (!$ignoreDir && $object->isDir() && !isset($o->{$fileName}) && !is_dir($this->pd . "/" . $fileName)) {
                         mkdir($this->pd . "/" . $fileName);
                         $o->{$fileName} = "dir created";
                         // placeholder
                         print $fileName . "/ directory was created...\n";
                     }
                     // check to see if it's a new file or a file that has changed
                     if (file_exists($name)) {
                         $mt = $object->getMTime();
                         if (!$ignoreDir && $object->isFile() && !isset($o->{$fileName}) && !file_exists($this->pd . "/" . $fileName)) {
                             $o->{$fileName} = $mt;
                             $this->moveStaticFile($fileName, "added");
                             if ($object->getExtension() == "css") {
                                 $this->updateSite($fileName, "changed", 0);
                                 // make sure the site is updated for MQ reasons
                             }
                         } else {
                             if (!$ignoreDir && $object->isFile() && isset($o->{$fileName}) && $o->{$fileName} != $mt) {
                                 $o->{$fileName} = $mt;
                                 $this->moveStaticFile($fileName, "changed");
                                 if ($object->getExtension() == "css") {
                                     $this->updateSite($fileName, "changed", 0);
                                     // make sure the site is updated for MQ reasons
                                 }
                             } else {
                                 if (!isset($o->fileName)) {
                                     $o->{$fileName} = $mt;
                                 }
                             }
                         }
                     } else {
                         unset($o->{$fileName});
                     }
                 }
             }
         }
         $c = true;
         // taking out the garbage. basically killing mustache after each run.
         unset($this->mpl);
         unset($this->msf);
         unset($this->mv);
         if (gc_enabled()) {
             gc_collect_cycles();
         }
         // output anything the reload server might send our way
         if ($reload) {
             $output = fgets($fp, 100);
             if ($output != "\n") {
                 print $output;
             }
         }
         // pause for .05 seconds to give the CPU a rest
         usleep(50000);
     }
     // close the auto-reload process, this shouldn't do anything
     fclose($fp);
 }
コード例 #21
0
require __DIR__ . '/TaxCalculation.php';
require __DIR__ . '/Category.php';
require __DIR__ . '/CsvWriter.php';
require __DIR__ . '/LanguageMapper.php';
$options = getopt(null, ["language:"]);
if (empty($options)) {
    // fallback
    $options["language"] = "de";
}
$skippedProducts = 0;
$mapper = new LanguageMapper($options["language"]);
$feedFilename = sprintf("%s/Mey_%s_%s.csv", "/opt/productexport", $mapper->getLabel(), date("Y-m-d_H-m-s"));
$start = microtime(true);
$data = [];
$brokenProducts = [];
$gc = gc_enabled();
Mage::app()->setCurrentStore(Mage::getModel('core/store')->load($mapper->getStoreId()));
$taxCalc = new TaxCalculation(Mage);
$open = count($products);
$dataWritten = false;
$writer = new CsvWriter($feedFilename);
$productIds = Mage::getModel('catalog/product')->getCollection()->addAttributeToFilter('type_id', array('eq' => 'configurable'))->addAttributeToFilter('status', array('eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED))->getAllIds();
$open = count($productIds);
foreach ($productIds as $id) {
    $product = Mage::getModel('catalog/product')->load($id);
    $websites = $product->getWebsiteIds();
    if (!inMainStore($websites)) {
        $websites = implode(",", $websites);
        echo "[wrong website] skip {$id}, websites: {$websites}\n";
        $skippedProducts++;
        continue;
コード例 #22
0
ファイル: store_test.php プロジェクト: dg711/moodle
 /**
  * Disable the garbage collector if it's enabled to ensure we don't adjust memory statistics.
  */
 private function disable_gc()
 {
     if (gc_enabled()) {
         $this->wedisabledgc = true;
         gc_disable();
     }
 }
コード例 #23
0
 public function enableGC()
 {
     if (!gc_enabled()) {
         gc_enable();
     }
 }
コード例 #24
0
ファイル: gc-1.php プロジェクト: jestintab/zendphp
<?php
gc_enable(); // Enable Garbage Collector
var_dump(gc_enabled()); // true
echo "<br/>";
var_dump(gc_collect_cycles()); // # of elements cleaned up
gc_disable(); // Disable Garbage Collector
echo "<br/>\n";
var_dump(gc_enabled()); // true
echo "<br/>\n";
?>
コード例 #25
0
ファイル: bootstrap.php プロジェクト: freyr/envelope
<?php

/*
 * This file is part of the PhotoUploader package.
 * (c) Michal Giergielewicz <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
if (version_compare(PHP_VERSION, '5.4', '>=') && gc_enabled()) {
    // Disabling Zend Garbage Collection to prevent segfaults with PHP5.4+
    // https://bugs.php.net/bug.php?id=53976
    gc_disable();
}
require_once __DIR__ . '/../vendor/autoload.php';
set_error_handler('\\Freyr\\Envelope\\ErrorHandler::exception_error_handler');
コード例 #26
0
 private static function _renderSystem()
 {
     $i = true;
     $php = array();
     $php[] = array("row" => 1 + (0 + ($i = !$i)), "name" => "PHP версия:", "value" => phpversion());
     $php[] = array("row" => 1 + (0 + ($i = !$i)), "name" => "PHP идентификатор процесса:", "value" => zend_version());
     $php[] = array("row" => 1 + (0 + ($i = !$i)), "name" => "PHP ZEND версия:", "value" => getmypid());
     $php[] = array("row" => 1 + (0 + ($i = !$i)), "name" => "Владелец скрипта:", "value" => get_current_user());
     $php[] = array("row" => 1 + (0 + ($i = !$i)), "name" => "Владелец скрипта [UID]:", "value" => getmyuid());
     $php[] = array("row" => 1 + (0 + ($i = !$i)), "name" => "Владелец скрипта [GID]:", "value" => getmygid());
     $php[] = array("row" => 1 + (0 + ($i = !$i)), "name" => "Владелец скрипта [inode]:", "value" => getmyinode());
     $php[] = array("row" => 1 + (0 + ($i = !$i)), "name" => "Макс. время выполнения скрипта:", "value" => ini_get("max_execution_time"));
     $php[] = array("row" => 1 + (0 + ($i = !$i)), "name" => "Макс. размер загружаемого файла:", "value" => ini_get("upload_max_filesize"));
     $php[] = array("row" => 1 + (0 + ($i = !$i)), "name" => "Макс. размер POST-данных:", "value" => ini_get("post_max_size"));
     $php[] = array("row" => 1 + (0 + ($i = !$i)), "name" => "Макс. объем памяти скрипта:", "value" => ini_get("memory_limit"));
     $php[] = array("row" => 1 + (0 + ($i = !$i)), "name" => "Папка загружаемых файлов:", "value" => ini_get("upload_tmp_dir"));
     $php[] = array("row" => 1 + (0 + ($i = !$i)), "name" => "Папка хранения сессий:", "value" => ini_get("session.save_path"));
     $php[] = array("row" => 1 + (0 + ($i = !$i)), "name" => "Путь включения скриптов:", "value" => get_include_path());
     $php[] = array("row" => 1 + (0 + ($i = !$i)), "name" => "Cборщик циклических ссылок:", "value" => @function_exists("gc_enabled") ? gc_enabled() ? "On" : "Off" : "N/A(?)");
     $php[] = array("row" => 1 + (0 + ($i = !$i)), "name" => "MAGIC_QUOTES_GPC:", "value" => self::mquotes_gpc() ? "On" : "Off");
     $php[] = array("row" => 1 + (0 + ($i = !$i)), "name" => "MAGIC_QUOTES_RUNTIME:", "value" => self::mquotes_runtime() ? "On" : "Off");
     $i = true;
     $mysql = array();
     $mysql[] = array("row" => 1 + (0 + ($i = !$i)), "name" => "Версия сервера:", "value" => mysql_get_server_info());
     $mysql[] = array("row" => 1 + (0 + ($i = !$i)), "name" => "Имя сервера:", "value" => db::coninfo("host"));
     $mysql[] = array("row" => 1 + (0 + ($i = !$i)), "name" => "Имя БД:", "value" => db::coninfo("name"));
     $mysql[] = array("row" => 1 + (0 + ($i = !$i)), "name" => "Имя пользователя:", "value" => db::coninfo("user"));
     $mysql[] = array("row" => 1 + (0 + ($i = !$i)), "name" => "Пароль:", "value" => db::coninfo("pass"));
     $mysql[] = array("row" => 1 + (0 + ($i = !$i)), "name" => "Используемое расширение:", "value" => mysql);
     $t = tpl::get(self::$class, self::$section["name"]);
     $t->setArrayCycle("php", $php);
     $t->setArrayCycle("mysql", $mysql);
     $t->_render();
 }
コード例 #27
0
 /**
  * Remove items that link back to this before destroying this object
  */
 public function __destruct()
 {
     if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode')) {
         if (!empty($this->data['items'])) {
             foreach ($this->data['items'] as $item) {
                 $item->__destruct();
             }
             unset($item, $this->data['items']);
         }
         if (!empty($this->data['ordered_items'])) {
             foreach ($this->data['ordered_items'] as $item) {
                 $item->__destruct();
             }
             unset($item, $this->data['ordered_items']);
         }
     }
 }
コード例 #28
0
 public function watchStarterKit()
 {
     // default vars
     $starterKitPath = $this->starterKitPathPrompt();
     $sourceDir = Config::getOption("sourceDir");
     $fs = new Filesystem();
     $c = false;
     // track that one loop through the pattern file listing has completed
     $o = new \stdClass();
     // create an object to hold the properties
     $cp = new \stdClass();
     // create an object to hold a clone of $o
     $o->patterns = new \stdClass();
     Console::writeLine("watching your starterkit for changes...");
     // run forever
     while (true) {
         // clone the patterns so they can be checked in case something gets deleted
         $cp = clone $o->patterns;
         $objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($starterKitPath), \RecursiveIteratorIterator::SELF_FIRST);
         // make sure dots are skipped
         $objects->setFlags(\FilesystemIterator::SKIP_DOTS);
         foreach ($objects as $name => $object) {
             // clean-up the file name and make sure it's not one of the pattern lab files or to be ignored
             $fileName = str_replace($starterKitPath . DIRECTORY_SEPARATOR, "", $name);
             // check to see if it's a new directory
             if ($object->isDir() && !isset($o->{$fileName}) && !is_dir($starterKitPath . "/" . $fileName)) {
                 mkdir($sourceDir . "/" . $fileName);
                 $o->{$fileName} = "dir created";
                 // placeholder
                 Console::writeLine($fileName . "/ directory was created...");
             }
             // check to see if it's a new file or a file that has changed
             if (file_exists($name)) {
                 $mt = $object->getMTime();
                 if ($object->isFile() && !isset($o->{$fileName}) && !file_exists($sourceDir . DIRECTORY_SEPARATOR . $fileName)) {
                     $o->{$fileName} = $mt;
                     $fs->copy($starterKitPath . DIRECTORY_SEPARATOR . $fileName, $sourceDir . DIRECTORY_SEPARATOR . $fileName);
                     Console::writeInfo($fileName . " added...");
                 } else {
                     if ($object->isFile() && isset($o->{$fileName}) && $o->{$fileName} != $mt) {
                         $o->{$fileName} = $mt;
                         $fs->copy($starterKitPath . DIRECTORY_SEPARATOR . $fileName, $sourceDir . DIRECTORY_SEPARATOR . $fileName);
                         Console::writeInfo($fileName . " changed...");
                     } else {
                         if (!isset($o->fileName)) {
                             $o->{$fileName} = $mt;
                         }
                     }
                 }
             } else {
                 unset($o->{$fileName});
             }
         }
         $c = true;
         // taking out the garbage. basically killing mustache after each run.
         if (gc_enabled()) {
             gc_collect_cycles();
         }
         // pause for .05 seconds to give the CPU a rest
         usleep(50000);
     }
 }
コード例 #29
0
ファイル: server.php プロジェクト: photon/photon
 /**
  * Must be started when already running as daemon.
  */
 public function start()
 {
     $this->registerSignals();
     // For SIGTERM handling
     $poll = new \ZMQPoll();
     foreach ($this->connections as $connection) {
         $connection->connect();
         $poll->add($connection->pull_socket, \ZMQ::POLL_IN);
     }
     // We are using polling to not block indefinitely and be able
     // to process the SIGTERM signal. The poll timeout is .5 second.
     $timeout = 500;
     $to_read = $to_write = array();
     $gc = gc_enabled();
     $i = 0;
     while (true) {
         $events = 0;
         try {
             $events = $poll->poll($to_read, $to_write, $timeout);
             $errors = $poll->getLastErrors();
             if (count($errors) > 0) {
                 foreach ($errors as $error) {
                     Log::error('Error polling object: ' . $error);
                 }
             }
         } catch (\ZMQPollException $e) {
             Log::fatal('Poll failed: ' . $e->getMessage());
             return 1;
         }
         if ($events > 0) {
             foreach ($to_read as $r) {
                 foreach ($this->connections as $connection) {
                     if ($connection->pull_socket === $r) {
                         $this->processRequest($connection);
                         break;
                     }
                 }
                 $i++;
             }
         }
         pcntl_signal_dispatch();
         if ($gc && 500 < $i) {
             $collected = gc_collect_cycles();
             Log::debug(array('photon.server.start', 'collected_cycles', $collected));
             $i = 0;
         }
     }
 }
コード例 #30
0
ファイル: Profiles.php プロジェクト: mdouchin/jelix
 /**
  * clear the loaded profiles to force to reload the profiles file.
  * WARNING: it destroy all objects stored in the pool!
  */
 public static function clear()
 {
     self::$_profiles = null;
     self::$_objectPool = array();
     if (gc_enabled()) {
         gc_collect_cycles();
     }
 }