public static function run() { spl_autoload_register(['Bootstrap', 'autoload']); putenv('LANG=en_US.UTF-8'); setlocale(LC_CTYPE, 'en_US.UTF-8'); date_default_timezone_set(@date_default_timezone_get()); session_start(); $session = new Session($_SESSION); $request = new Request($_REQUEST); $setup = new Setup($request->query_boolean('refresh', false)); $context = new Context($session, $request, $setup); if ($context->is_api_request()) { (new Api($context))->apply(); } else { if ($context->is_info_request()) { $public_href = $setup->get('PUBLIC_HREF'); $x_head_tags = $context->get_x_head_html(); require __DIR__ . '/pages/info.php'; } else { $public_href = $setup->get('PUBLIC_HREF'); $x_head_tags = $context->get_x_head_html(); $fallback_html = (new Fallback($context))->get_html(); require __DIR__ . '/pages/index.php'; } } }
/** * It should automatically switch to the travis logger if the * CONTINUOUS_INTEGRATION environment variable is set. */ public function testTravisLogger() { putenv('CONTINUOUS_INTEGRATION=1'); $container = new Container(['PhpBench\\Extension\\CoreExtension'], ['path' => 'hello', 'config_path' => '/path/to/phpbench.json']); $container->init(); $this->assertEquals('travis', $container->getParameter('progress')); }
function translate($lang, $test = 0) { global $LOCALE_PATH; putenv("LANGUAGE={$lang}"); bindtextdomain("zarafa", "{$LOCALE_PATH}"); if (STORE_SUPPORTS_UNICODE == false) { bind_textdomain_codeset('zarafa', "windows-1252"); } else { bind_textdomain_codeset('zarafa', "utf-8"); } textdomain('zarafa'); setlocale(LC_ALL, $lang); $trans_array["Sent Items"] = _("Sent Items"); $trans_array["Outbox"] = _("Outbox"); $trans_array["Deleted Items"] = _("Deleted Items"); $trans_array["Inbox"] = _("Inbox"); $trans_array["Calendar"] = _("Calendar"); $trans_array["Contacts"] = _("Contacts"); $trans_array["Drafts"] = _("Drafts"); $trans_array["Journal"] = _("Journal"); $trans_array["Notes"] = _("Notes"); $trans_array["Tasks"] = _("Tasks"); $trans_array["Junk E-mail"] = _("Junk E-mail"); return $trans_array; }
function before($route) { $lang_mapping = array('fr' => 'fr_FR'); if (!isset($_SESSION['locale'])) { $locale = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); $_SESSION['locale'] = strtolower(substr(chop($locale[0]), 0, 2)); } $lang = $_SESSION['locale']; // Convert simple language code into full language code if (array_key_exists($lang, $lang_mapping)) { $lang = $lang_mapping[$lang]; } $lang = "{$lang}.utf8"; $textdomain = "localization"; putenv("LANGUAGE={$lang}"); putenv("LANG={$lang}"); putenv("LC_ALL={$lang}"); putenv("LC_MESSAGES={$lang}"); setlocale(LC_ALL, $lang); setlocale(LC_CTYPE, $lang); $locales_dir = dirname(__FILE__) . '/i18n'; bindtextdomain($textdomain, $locales_dir); bind_textdomain_codeset($textdomain, 'UTF-8'); textdomain($textdomain); set('locale', $lang); }
private function setLocaleOnCommand($command) { ob_start(); putenv("LC_CTYPE=en_US.UTF-8"); passthru($command); return ob_get_clean(); }
public static function startMSS() { $n = rand(100000000000.0, 1000000000000000.0); $rand = base_convert($n, 10, 36); $socketfile = "/tmp/php-connector-{$rand}.sock"; putenv("CPANEL_PHPCONNECT_SOCKET={$socketfile}"); self::$socketfile = $socketfile; $dir = dirname(__FILE__); $script = 'startMockSocketServer.php'; $class = 'MockSocketServer.php'; $basedir = realpath("{$dir}/../../.."); $mockserverscript = "{$basedir}/{$script}"; require_once "{$basedir}/{$class}"; if (!file_exists($mockserverscript)) { self::fail("Mock socket server script '{$mockserverscript}' does not exist"); } $cmd = "/usr/bin/php -f {$mockserverscript}"; $arg = "socketfile={$socketfile}"; $full_cmd = "nohup {$cmd} {$arg} > /dev/null 2>&1 & echo \$!"; // > /dev/null $PID = exec($full_cmd); self::$mockSocketServerPID = $PID; $lookup = exec("ps -p {$PID} | grep -v 'PID'"); sleep(1); if (empty($lookup)) { self::fail('Failed to start mock socket server'); } elseif (!file_exists($socketfile)) { self::fail('Socket file does not exist: ' . $socketfile); } }
public function testItReturnsUsefulErrorIfUnknownAndInDevelopment() { putenv('APP_ENV=development'); $exception = new RuntimeException('Some message.'); $handled = ExceptionHandler::handleException($exception); $this->assertEquals(['error' => $exception->getCode(), 'message' => $exception->getMessage(), 'trace' => $exception->getTraceAsString()], $handled); }
/** * Makes it so the content is available in getenv() */ public function toEnv() { $dots = $this->toDots($this->content); foreach ($dots as $dot_k => $dot_v) { putenv(sprintf('%s=%s', $dot_k, $dot_v)); } }
/** * Creates the application. * * @return \Illuminate\Foundation\Application */ public function createApplication() { putenv('DB_DEFAULT=sqlite_testing'); $app = (require __DIR__ . '/../bootstrap/app.php'); $app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap(); return $app; }
/** * Sets the current locale code */ public function setLocale($locale) { //Remove from master until I figure this out /*if (!$this->isLocaleSupported($locale)) { throw new Exceptions\LocaleNotSupportedException( sprintf('Locale %s is not supported', $locale) ); }*/ try { $gettextLocale = $locale . "." . $this->encoding; // All locale functions are updated: LC_COLLATE, LC_CTYPE, // LC_MONETARY, LC_NUMERIC, LC_TIME and LC_MESSAGES putenv("LC_ALL={$gettextLocale}"); putenv("LANGUAGE={$gettextLocale}"); setlocale(LC_ALL, $gettextLocale); // Domain $this->setDomain($this->domain); $this->locale = $locale; $this->session->set($locale); // Laravel built-in locale if ($this->configuration->isSyncLaravel()) { $this->adapter->setLocale($locale); } return $this->getLocale(); } catch (\Exception $e) { $this->locale = $this->configuration->getFallbackLocale(); $exceptionPosition = $e->getFile() . ":" . $e->getLine(); throw new \Exception($exceptionPosition . $e->getMessage()); } }
function viewvc_utils_wrap_utf8_exec($command) { ob_start(); putenv("LC_CTYPE=en_US.UTF-8"); passthru($command); return ob_get_clean(); }
/** * Set app environment variables * * @param string $root * @return void */ public static function setEnvVariables($root = '/') { $configs = null; // Set custom handler to catch errors as exceptions set_error_handler(create_function('$severity, $message, $file, $line', 'throw new \\ErrorException($message, $severity, $severity, $file, $line);')); if (file_exists($root . '/.dev.env') && is_readable($root . '/.dev.env')) { $configs = file_get_contents($root . '/.dev.env'); } else { if (file_exists($root . '/.dist.env') && is_readable($root . '/.dist.env')) { $configs = file_get_contents($root . '/.dist.env'); } else { if (file_exists($root . '/.test.env') && is_readable($root . '/.test.env')) { $configs = file_get_contents($root . '/.test.env'); } else { if (file_exists($root . '/.env') && is_readable($root . '/.env')) { $configs = file_get_contents($root . '/.env'); } else { throw new NotFoundException('No configuration file found.'); } } } } if (false === $configs || null !== error_get_last()) { throw new UnreadableException('Configuration not readable.'); } // Restore original error handler restore_error_handler(); $configs = explode("\n", trim($configs)); array_map(function ($config) { // Remove whitespaces $config = preg_replace('(\\s+)', '', $config); // Add as environment variables putenv($config); }, $configs); }
protected function validateNonNative() { // Check to see if Docker has been exported. if (!$this->envExported()) { $this->stdOut->writeln("<comment>Docker environment information not exported. Attempting from PLATFORM_DOCKER_MACHINE_NAME"); if (getenv('PLATFORM_DOCKER_MACHINE_NAME')) { // Attempt to boot the Docker VM if (!Machine::start(getenv('PLATFORM_DOCKER_MACHINE_NAME'))) { $this->stdOut->writeln("<error>Failed to start Docker machine</error>"); exit(1); } } else { $this->stdOut->writeln("<error>You need to start your Docker machine and export the environment information"); exit(1); } // Export the Docker VM info on behalf of the user $this->dockerParams = Machine::getEnv(getenv('PLATFORM_DOCKER_MACHINE_NAME')); foreach ($this->dockerParams as $key => $value) { putenv("{$key}={$value}"); } } // Give a Docker command a try. if (!Docker::available()) { $this->stdOut->writeln("<error>Unable to reach Docker service - try manually exporting environment variables.</error>"); exit(1); } }
public function loadParamsAndArgs($self = null, $opts = null, $args = null) { parent::loadParamsAndArgs($self, $opts, $args); if (!empty($this->mOptions['wiki_id'])) { putenv("SERVER_ID={$this->mOptions['wiki_id']}"); } }
/** * logDiskUsageData * * Retrives data and logs it to file * * @param string $type type of logging default set to normal but it can be API too. * @return string $string if type is API returns data as string * * */ public function logData($type = false) { $class = __CLASS__; $settings = Logger::$_settings->{$class}; $timestamp = time(); //get process data here $ps_args = '-Ao %cpu,%mem,pid,user,comm,args'; putenv('COLUMNS=1000'); $string = shell_exec("ps {$ps_args}"); //$string = explode("\n", trim ($processData)); //get log location $logdirname = sprintf($this->logdir, date('Y-m-d')); $logpath = LOG_PATH . $logdirname; //echo "LOG_PATH : " . $logpath . " \n"; $filename = sprintf($this->logfile, $logdirname, $timestamp); //echo "FILENAME : " . $filename . " \n"; //great log folder if it doesnt exist if (!file_exists($logpath)) { mkdir($logpath, 0777); } //read me on encoding array to disk instead //https://www.safaribooksonline.com/library/view/php-cookbook/1565926811/ch05s08.html //write out process data to file LoadUtility::safefilerewrite($filename, $string, "w", true); if ($type == "api") { return $string; } else { return true; } }
function smart_spam($code) { @putenv('GDFONTPATH=' . realpath('.')); $font = 'FONT.TTF'; // antispam image height $height = 40; // antispam image width $width = 110; $font_size = $height * 0.6; $image = @imagecreate($width, $height); $background_color = @imagecolorallocate($image, 255, 255, 255); $noise_color = @imagecolorallocate($image, 20, 40, 100); /* add image noise */ for ($i = 0; $i < $width * $height / 4; $i++) { @imageellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color); } /* render text */ $text_color = @imagecolorallocate($image, 20, 40, 100); @imagettftext($image, $font_size, 0, 7, 29, $text_color, $font, $code) or die('Cannot render TTF text.'); //output image to the browser *//* header('Content-Type: image/png'); @imagepng($image) or die('imagepng error!'); @imagedestroy($image); exit; }
private function createLogger($ci = false) { putenv('CONTINUOUS_INTEGRATION' . ($ci ? '=1' : '=0')); $logger = new DotsLogger($this->timeUnit); $logger->setOutput($this->output->reveal()); return $logger; }
/** * @covers Virtphp\Command\DestroyCommand::execute */ public function testExecuteWithActiveVirtphpEnv() { // Create directory for testing $dir = __DIR__ . '/footest'; if (!file_exists($dir) && !mkdir($dir)) { $this->markTestSkipped('Unable to create a directory for testing'); } putenv("VIRTPHP_ENV_PATH={$dir}"); $destroyerMock = null; $command = $this->getMock('Virtphp\\Command\\DestroyCommand', array('getHelperSet', 'getWorker', 'getEnvironments')); $command->expects($this->any())->method('getHelperSet')->will($this->returnCallback(function () { return new HelperSetMock(); })); $command->expects($this->any())->method('getWorker')->will($this->returnCallback(function ($name, $args) use(&$destroyerMock) { $destroyerMock = new DestroyerMock($name, $args); return $destroyerMock; })); $command->expects($this->any())->method('getEnvironments')->will($this->returnValue(array($dir => array('name' => '', 'path' => '')))); $execute = new \ReflectionMethod('Virtphp\\Command\\DestroyCommand', 'execute'); $execute->setAccessible(true); $input = new ArgvInput(array('file.php', $dir), $command->getDefinition()); $output = new TestOutput(); $result = $execute->invoke($command, $input, $output); $this->assertFalse($result); $this->assertCount(1, $output->messages); $this->assertEquals('You must deactivate this virtual environment before destroying it!', $output->messages[0]); // Clean up created directory rmdir($dir); }
public function testEnv() { $this->assertTrue(Env::init()); putenv('FOO=123'); $this->assertSame(123, env('FOO')); $this->assertFalse(Env::init()); }
function ADODB_informix72() { // alternatively, use older method: //putenv("DBDATE=Y4MD-"); // force ISO date format putenv('GL_DATE=%Y-%m-%d'); }
protected function getCmdLine() { putenv("MAGICK_THREAD_LIMIT=1"); $exeCmd = parent::getCmdLine(); KalturaLog::info("command line: [{$exeCmd}]"); return $exeCmd; }
protected function execute(InputInterface $input, OutputInterface $output) { if ($input->getOption('list')) { return $this->listScripts(); } elseif (!$input->getArgument('script')) { throw new \RunTimeException('Missing required argument "script"'); } $script = $input->getArgument('script'); if (!in_array($script, $this->scriptEvents)) { if (defined('Composer\\Script\\ScriptEvents::' . str_replace('-', '_', strtoupper($script)))) { throw new \InvalidArgumentException(sprintf('Script "%s" cannot be run with this command', $script)); } } $composer = $this->getComposer(); $hasListeners = $composer->getEventDispatcher()->hasEventListeners(new CommandEvent($script, $composer, $this->getIO())); if (!$hasListeners) { throw new \InvalidArgumentException(sprintf('Script "%s" is not defined in this package', $script)); } // add the bin dir to the PATH to make local binaries of deps usable in scripts $binDir = $composer->getConfig()->get('bin-dir'); if (is_dir($binDir)) { $_SERVER['PATH'] = realpath($binDir) . PATH_SEPARATOR . getenv('PATH'); putenv('PATH=' . $_SERVER['PATH']); } $args = $input->getArgument('args'); return $composer->getEventDispatcher()->dispatchScript($script, $input->getOption('dev') || !$input->getOption('no-dev'), $args); }
/** * {@inheritdoc} */ public function run() { ob_start(); $input = $this->container->get('input'); $output = $this->container->get('output'); // Create reactor and register custom options $reactor = new Reactor($input, $output, $this->container); $reactor->setLogo($this->loadLogo()); $reactor->registerCustomOption('env', 'Overrides the Mako environment', function (Config $config, $option) { putenv('MAKO_ENV=' . $option); $config->setEnvironment($option); }); $reactor->registerCustomOption('database', 'Overrides the default database connection', function (Config $config, $option) { $config->set('database.default', $option); }); $reactor->registerCustomOption('mute', 'Mutes all output', function (Output $output) { $output->mute(); }); // Register reactor commands foreach ($this->getCommands() as $command => $class) { $reactor->registerCommand($command, $class); } // Run the reactor $reactor->run(); }
function thumbnailThis($ruta, $img, $c_nombr, $c_vig, $c_folio) { // Set the enviroment variable for GD putenv('GDFONTPATH=' . realpath('.')); $cardId = uniqid(); // Genera un ID único para el nombre de archivo while (file_exists($ruta . '/cards/' . $cardId . ".jpg")) { // Si el nombre existe, genera otro $cardId = uniqid(); // unlink( $ruta.$img."_usuario.jpg" ); } // Name the font to be used (note the lack of the .ttf extension) $font = 'varela'; /*Dimensiones*/ $c_width = 1004; $c_height = 1299; $laImagen = $img . ".jpg"; $createdImg = imagecreatefromjpeg($ruta . $laImagen); /*imagejpeg($createdImg,$ruta."hola.jpg",50);*/ $width = imagesx($createdImg); $height = imagesy($createdImg); $previous = imagecreatetruecolor($c_width, $c_height); imagecopyresampled($previous, $createdImg, 0, 0, 0, 0, $c_width, $c_height, $width, $height); /*Color en RGB*/ $text_color = imagecolorallocate($previous, 5, 5, 5); /*imagestring($previous, 5, 5, 5, 'A Simple Text String', $text_color);*/ /*Texto para la imagen Imagen, tamaño, ángulo, posX, posY, color, fuente, texto*/ imagettftext($previous, 20, 0, 130, 767, $text_color, $font, $c_nombr); imagettftext($previous, 20, 0, 750, 767, $text_color, $font, $c_vig); imagettftext($previous, 20, 0, 750, 875, $text_color, $font, $c_folio); imagejpeg($previous, $ruta . '/cards/' . $cardId . ".jpg", 100); return $ruta . '/cards/' . $cardId . ".jpg"; }
protected function setUpEnvironment() { $kernelRootDir = $this->container->getParameter('kernel.root_dir'); putenv(sprintf('COMPOSER_HOME=%s', $this->container->getParameter('oro_distribution.composer_cache_home'))); chdir(realpath($kernelRootDir . '/../')); set_time_limit(0); }
/** * Constructor. * * @param Application $app */ public function __construct(Application $app) { $this->app = $app; // Set composer environment variables putenv('COMPOSER_HOME=' . $this->app['resources']->getPath('cache/composer')); $this->setup(); }
/** * {@inheritDoc} */ public function initialize() { if (static::isLocalUrl($this->url)) { $this->repoDir = str_replace('file://', '', $this->url); } else { $this->repoDir = $this->config->get('home') . '/cache.git/' . preg_replace('{[^a-z0-9.]}i', '-', $this->url) . '/'; // update the repo if it is a valid git repository if (is_dir($this->repoDir) && 0 === $this->process->execute('git remote', $output, $this->repoDir)) { if (0 !== $this->process->execute('git remote update --prune origin', $output, $this->repoDir)) { $this->io->write('<error>Failed to update ' . $this->url . ', package information from this repository may be outdated (' . $this->process->getErrorOutput() . ')</error>'); } } else { // clean up directory and do a fresh clone into it $fs = new Filesystem(); $fs->removeDirectory($this->repoDir); // added in git 1.7.1, prevents prompting the user putenv('GIT_ASKPASS=echo'); $command = sprintf('git clone --mirror %s %s', escapeshellarg($this->url), escapeshellarg($this->repoDir)); if (0 !== $this->process->execute($command, $output)) { $output = $this->process->getErrorOutput(); if (0 !== $this->process->execute('git --version', $ignoredOutput)) { throw new \RuntimeException('Failed to clone ' . $this->url . ', git was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput()); } throw new \RuntimeException('Failed to clone ' . $this->url . ', could not read packages from it' . "\n\n" . $output); } } } $this->getTags(); $this->getBranches(); }
public static function setEnv($env = self::ENV_PRODUCTION) { switch (true) { case getenv('APPLICATION_ENV') !== FALSE: $env = getenv('APPLICATION_ENV'); break; case isset($_SERVER['APPLICATION_ENV']): $env = $_SERVER['APPLICATION_ENV']; break; default: // $env = self::ENV_PRODUCTION; } // set error behavior switch ($env) { case self::ENV_PRODUCTION: error_reporting(0); ini_set('display_errors', 'Off'); break; case self::ENV_STAGING: ini_set('display_errors', 'On'); error_reporting(E_ERROR); break; default: ini_set('display_errors', 'On'); error_reporting(E_ALL); } // save env putenv('APPLICATION_ENV=' . $env); }
/** * Set up the tests. * * @return void */ public function setUp() { putenv('APP_ENV=testing'); $this->configureContainer(); $this->configureEventDispatcher(); $this->configureFakerGenerator(); }
/** * {@inheritDoc} */ protected function setUp() { parent::setUp(); $this->initialWorkingDirectory = getcwd(); // Ensure we have a clean environment. putenv('COMPOSER='); }