/** * Making the class non-abstract with a protected constructor does a better * job of preventing instantiation than just marking the class as abstract. * * @see start() */ public function __construct(array $configs) { // Quickly initialize some defaults like usePEAR // by adding the $premature flag $this->_optionsInit(true); $this->setOptions($configs); if ($this->opt('logPhpErrors')) { set_error_handler(array('self', 'phpErrors'), E_ALL); } // Check the PHP configuration if (!defined('SIGHUP')) { trigger_error('PHP is compiled without --enable-pcntl directive', E_USER_ERROR); } // Check for CLI if (php_sapi_name() !== 'cli') { trigger_error('You can only create daemon from the command line (CLI-mode)', E_USER_ERROR); } // Check for POSIX if (!function_exists('posix_getpid')) { trigger_error('PHP is compiled without --enable-posix directive', E_USER_ERROR); } // Enable Garbage Collector (PHP >= 5.3) if (function_exists('gc_enable')) { gc_enable(); } // Initialize & check variables if (false === $this->_optionsInit(false)) { if (is_object($this->_option) && is_array($this->_option->errors)) { foreach ($this->_option->errors as $error) { $this->notice($error); } } trigger_error('Crucial options are not set. Review log:', E_USER_ERROR); } }
public function index() { $os = explode(' ', php_uname()); $mysql_support = function_exists('mysql_close') ? '<font color="green">√</font>' : '<font color="red">×</font>'; $register_globals = get_cfg_var("register_globals") ? '<font color="green">√</font>' : '<font color="red">×</font>'; $enable_dl = get_cfg_var("enable_dl") ? '<font color="green">√</font>' : '<font color="red">×</font>'; $allow_url_fopen = get_cfg_var("allow_url_fopen") ? '<font color="green">√</font>' : '<font color="red">×</font>'; $display_errors = get_cfg_var("display_errors") ? '<font color="green">√</font>' : '<font color="red">×</font>'; $session_support = function_exists('session_start') ? '<font color="green">√</font>' : '<font color="red">×</font>'; $config['server_name'] = $_SERVER['SERVER_NAME']; $config['server_ip'] = @gethostbyname($_SERVER['SERVER_NAME']); $config['server_time'] = date("Y年n月j日 H:i:s"); $config['os'] = $os[0]; $config['os_core'] = $os[2]; $config['server_root'] = dirname(dirname($_SERVER['SCRIPT_FILENAME'])); $config['server_engine'] = $_SERVER['SERVER_SOFTWARE']; $config['server_port'] = $_SERVER['SERVER_PORT']; $config['php_version'] = PHP_VERSION; $config['php_run_type'] = strtoupper(php_sapi_name()); $config['mysql_support'] = $mysql_support; $config['register_globals'] = $register_globals; $config['allow_url_fopen'] = $allow_url_fopen; $config['display_errors'] = $display_errors; $config['enable_dl'] = $enable_dl; $config['memory_limit'] = get_cfg_var("memory_limit"); $config['post_max_size'] = get_cfg_var("post_max_size"); $config['upload_max_filesize'] = get_cfg_var("upload_max_filesize"); $config['max_execution_time'] = get_cfg_var("max_execution_time"); $config['session_support'] = $session_support; $this->config_arr = $config; $this->display(); }
public function upgrade() { if (php_sapi_name() == "cli") { // @todo this may screw up some module installers, but we don't have a better answer at // this time. $_SERVER["HTTP_HOST"] = "example.com"; } else { if (!user::active()->admin && !Session::instance()->get("can_upgrade", false)) { access::forbidden(); } } // Upgrade gallery and user first module::install("gallery"); module::install("user"); // Then upgrade the rest foreach (module::available() as $id => $module) { if ($id == "gallery") { continue; } if ($module->active && $module->code_version != $module->version) { module::install($id); } } if (php_sapi_name() == "cli") { print "Upgrade complete\n"; } else { url::redirect("upgrader?done=1"); } }
public function run() { if (fnmatch('*cli*', php_sapi_name())) { $dir = Config::get('dir.schedules', APPLICATION_PATH . DS . 'schedules'); if (is_dir($dir)) { Timer::start(); Cli::show("Start of execution", 'COMMENT'); $files = glob($dir . DS . '*.php'); foreach ($files as $file) { require_once $file; $object = str_replace('.php', '', Arrays::last(explode(DS, $file))); $class = 'Thin\\' . ucfirst(Inflector::camelize($object . '_schedule')); $instance = lib('app')->make($class); $methods = get_class_methods($instance); Cli::show("Start schedule '{$object}'", 'COMMENT'); foreach ($methods as $method) { $when = $this->getWhen($instance, $method); $isDue = $this->isDue($object, $method, $when); if (true === $isDue) { Cli::show("Execution of {$object}->{$method}", 'INFO'); $instance->{$method}(); } else { Cli::show("No need to execute {$object}->{$method}", 'QUESTION'); } } } Cli::show("Time of execution [" . Timer::get() . " s.]", 'SUCCESS'); Cli::show("end of execution", 'COMMENT'); } } }
function ic_system_info() { $thread_safe = false; $debug_build = false; $cgi_cli = false; $php_ini_path = ''; ob_start(); phpinfo(INFO_GENERAL); $php_info = ob_get_contents(); ob_end_clean(); foreach (split("\n", $php_info) as $line) { if (eregi('command', $line)) { continue; } if (eregi('thread safety.*(enabled|yes)', $line)) { $thread_safe = true; } if (eregi('debug.*(enabled|yes)', $line)) { $debug_build = true; } if (eregi("configuration file.*(</B></td><TD ALIGN=\"left\">| => |v\">)([^ <]*)(.*</td.*)?", $line, $match)) { $php_ini_path = $match[2]; if (!@file_exists($php_ini_path)) { $php_ini_path = ''; } } $cgi_cli = strpos(php_sapi_name(), 'cgi') !== false || strpos(php_sapi_name(), 'cli') !== false; } return array('THREAD_SAFE' => $thread_safe, 'DEBUG_BUILD' => $debug_build, 'PHP_INI' => $php_ini_path, 'CGI_CLI' => $cgi_cli); }
/** * Scan the input for XXE attacks. * * @param string $input * Unsafe input * @param Closure $callback * Callback called to build the dom. * Must be an instance of DomDocument and receives the input as argument * * @return bool|DomDocument False if an XXE attack was discovered, * otherwise the return of the callback */ private static function scanInput($input, Closure $callback) { $isRunningFpm = substr(php_sapi_name(), 0, 3) === 'fpm'; if ($isRunningFpm) { // If running with PHP-FPM and an entity is detected we refuse to parse the feed // @see https://bugs.php.net/bug.php?id=64938 if (strpos($input, '<!ENTITY') !== false) { return false; } } else { $entityLoaderDisabled = libxml_disable_entity_loader(true); } libxml_use_internal_errors(true); $dom = $callback($input); // Scan for potential XEE attacks using ENTITY foreach ($dom->childNodes as $child) { if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) { if ($child->entities->length > 0) { return false; } } } if ($isRunningFpm === false) { libxml_disable_entity_loader($entityLoaderDisabled); } return $dom; }
/** * Automatically registers all service classes in $this->services array * {@inheritdoc} * @param Application|\Apitude\Core\Application $app */ public function register(Application $app) { foreach ($this->services as $key => $class) { if (is_numeric($key)) { $key = $class; } $app[$key] = $app->share(function () use($class, $app) { $result = new $class(); $app->initialize($result); return $result; }); } if (!empty($this->doctrineEventSubscribers)) { $config = $app['config']; foreach ($this->doctrineEventSubscribers as $class) { $config['orm.subscribers'][] = $class; } } if (!empty($this->entityFolders)) { if (!isset($config)) { $config = $app['config']; } foreach ($this->entityFolders as $namespace => $path) { $config['orm.options']['orm.em.options']['mappings'][] = ['type' => 'annotation', 'namespace' => $namespace, 'path' => $path, 'use_simple_annotation_reader' => false]; } } if (isset($config)) { $app['config'] = $config; } if (php_sapi_name() === 'cli' && !empty($this->commands)) { $app['base_commands'] = $app->extend('base_commands', function (array $commands) { return array_merge($commands, $this->commands); }); } }
/** * Dump specified value. * * @param mixed $value * @param int $output * @return null|string */ public function dump($value, $output = self::OUTPUT_ECHO) { if (php_sapi_name() === 'cli' && $output == self::OUTPUT_ECHO) { print_r($value); if (is_scalar($value)) { echo "\n"; } return null; } //Dumping is pretty slow operation, let's record it so we can exclude dump time from application //timeline $benchmark = $this->benchmark('dump'); try { switch ($output) { case self::OUTPUT_ECHO: echo $this->style->mountContainer($this->dumpValue($value, '', 0)); break; case self::OUTPUT_RETURN: return $this->style->mountContainer($this->dumpValue($value, '', 0)); break; case self::OUTPUT_LOG: $this->logger()->debug(print_r($value, true)); break; case self::OUTPUT_LOG_NICE: $this->logger()->debug($this->dump($value, self::OUTPUT_RETURN)); break; } return null; } finally { $this->benchmark($benchmark); } }
/** * 构造函数 * @param mixed $arg 对象参数, 常为 SQL 语句或要导入的文件路径 */ public function __construct($type, $arg) { $this->type = $type; $this->arg = $arg; $this->inCli = php_sapi_name() === 'cli'; $this->init(); }
/** * (non-PHPdoc) * @see \parallely\AbstractTransport::_prepare() */ protected function _prepare() { if (extension_loaded('xcache') !== true or php_sapi_name() === 'cli') { throw new \parallely\Exception(\parallely\Exception::SETUP_ERROR); } return $this; }
public function run() { // Initialize router try { if (php_sapi_name() == 'cli') { // Handle console apps // @todo: finish! $router = new Router($this->getProjectFromArgs()); } else { // Handle web apps $url = UrlFactory::autodetect(); $router = new Router($this->getProjectFromUrl($url)); $router->parseUrl($url); } } catch (RouteNotFoundException $e) { $context = new Context($e->getProject(), $e->getUrl()); if ($this->onRouteNotFound) { // Call the user defined route not found handler call_user_func($this->onRouteNotFound, ['statusCode' => 404, 'context' => $context, 'exceptionMessage' => $e->getMessage()]); } else { // Display a default error page $response = new Phtml($context); $response->setStatusCode(404)->setViewDir(__DIR__ . '/Scripts')->setViewFilename('error.phtml')->setViewParams(['statusCode' => 404, 'exceptionMessage' => $e->getMessage()])->render(); } } }
public function run() { static::$netteDirectory = realpath(__DIR__ . '/../../../../app'); $netteContainer = $this->getNetteContainer(); if (php_sapi_name() !== 'cli') { define('STDIN', fopen('php://stdin', 'r')); echo '<pre>'; } CLI::write('Welcome to the Nette Framework CRUD generator 1.0@beta5.', 0, FALSE); static::$settings = (object) ['netteRoot' => realpath(static::$netteDirectory . '/..'), 'netteConfig' => FALSE, 'netteDatabase' => FALSE, 'source' => \Utils\Constants::SOURCE_MYSQL_DISCOVERED, 'tables' => [], 'table' => FALSE, 'target' => \Utils\Constants::TARGET_NETTE_DATABASE, 'foreignKeys' => \Utils\Constants::FOREIGN_KEYS_TABLE, 'module' => FALSE, 'template' => realpath(__DIR__ . '/Templates/default'), 'php' => '<?php', 'entityManager' => NULL]; $this->showSourceDialog(); CLI::write('Verifying Nette configuration:', 0, TRUE, TRUE, TRUE); static::$settings->netteDatabase = $this->getDatabaseConnectionParameters($netteContainer); static::$settings->netteConfig = \Nette\Neon\Neon::decode(\Bruha\Generator\Utils\File::read(static::$netteDirectory . '/config/config.neon')); if ($this->checkExtensionsConfiguration()) { CLI::write('New extensions were installed.', 0, TRUE, TRUE, TRUE); CLI::write('Application needs to be restarted for loading them.', 1); CLI::write("Write 'php -f index.php' for start with new loaded extensions.", 2); exit; } $this->showTablesDialog($this->processSourceDialog($netteContainer)); $this->showTargetDialog(); $this->showForeignKeysDialog(); $this->showModuleDialog(); $this->chooseTemplatesDialog(); static::$startTime = microtime(TRUE); $this->generate(); }
/** * isConsole * * @return boolean */ public static function isConsole() { if (php_sapi_name() == 'cli') { return true; } return false; }
private function loadSecurity() { if (php_sapi_name() != 'cli') { $this->__security = new \PAJ\Library\Security\SecurityController(); $this->set('loggedin', $this->__security->get('loggedin')); } }
/** * Class constructor * * @param array An optional associative array of configuration settings. * Recognized key values include 'clientId' (this list is not meant to be comprehensive). */ public function __construct($config = array()) { $config['clientId'] = 0; \Event::listen(function ($event) { // This must be done before the session is read, otherwise it will overwrite // the existing session with a guest non-https session prior to redirecting to https // NOTE: we're including a cli check here because the console currently uses the 'site' // application. This should be remedied in the new framework. $app = $event->getArgument('app'); if ($app->getCfg('force_ssl') == 2 && php_sapi_name() != 'cli') { $uri = JURI::getInstance(); if (strtolower($uri->getScheme()) != 'https') { // We also can't use the Application::redirect method here as // it tries to use JFactory::getDocument, which doesn't work // prior to application initialization $uri->setScheme('https'); header('HTTP/1.1 303 See other'); header('Location: ' . (string) $uri); header('Content-Type: text/html;'); $app->close(); } } }, 'application_onBeforeSessionCreate'); parent::__construct($config); }
public function getBestLocale() { if (isset($this->locale)) { return $this->locale; } if (php_sapi_name() === 'cli') { $localeRaw = $this->default; } else { // Get the locale from the request headers $localeRaw = $this->getDI()->getRequest()->getBestLanguage(); $localeRaw = str_replace('-', '_', $localeRaw); } if (strpos($localeRaw, '..') !== false) { throw new Exception('Locale has dangerous characters'); } $localeParts = explode('_', $localeRaw); $language = $localeParts[0]; $country = count($localeParts) > 1 ? '_' . strtoupper($localeParts[1]) : ''; if ($this->isLocaleSupported("{$language}{$country}")) { $locale = "{$language}{$country}"; } else { if (array_key_exists($language, $this->map)) { $locale = $this->map[$language]; } else { $locale = $this->default; } } $this->locale = $locale; return $this->locale; }
/** * Get the URL of assets. * The base URL that contains all published asset files of yii-debug-toolbar. * @return string */ public function getAssetsUrl() { if (null === $this->_assetsUrl && 'cli' !== php_sapi_name()) { $this->_assetsUrl = Yii::app()->getAssetManager()->publish(dirname(__FILE__) . '/assets', false, -1, YII_DEBUG); } return $this->_assetsUrl; }
/** * Verify that we are running PHP through the command line interface. * * This function is useful for making sure that code cannot be run via the web server, * such as a function that needs to write files to which the web server should not have * access to. * * @return * A boolean value that is true when PHP is being run through the command line, * and false if being run through cgi or mod_php. */ function drush_verify_cli() { if (php_sapi_name() == 'cgi') { return is_numeric($_SERVER['argc']) && $_SERVER['argc'] > 0; } return php_sapi_name() == 'cli'; }
/** * Constructor */ public function __construct() { $this->webroot = dirname(ABSPATH); $this->root = dirname($this->webroot); $this->name = WP_ENV; $this->mode = php_sapi_name() === 'cli' ? 'cli' : 'http'; }
public function check() { $report = null; if (php_sapi_name() === 'cli') { // @todo find a way to detect this in CLI. return new common_configuration_Report(common_configuration_Report::VALID, 'The AllowOverride directive cannot be checked in CLI mode.', $this); } $server = (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on" ? 'https' : 'http') . "://" . $_SERVER['SERVER_NAME'] . ($_SERVER["SERVER_PORT"] != "80" ? ":" . $_SERVER["SERVER_PORT"] : ''); $request = $_SERVER["REQUEST_URI"]; $request = substr($request, 0, strpos($request, '?')); $request = substr($request, 0, strrpos($request, '/')); $url = $server . $request . '/checks/testAllowOverride/noneOrAll/'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $output = curl_exec($ch); $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($httpcode == '403') { $report = new common_configuration_Report(common_configuration_Report::VALID, 'The AllowOverride directive is set to All.', $this); } else { $report = new common_configuration_Report(common_configuration_Report::INVALID, 'The AllowOverride directive may not be set to All.', $this); } return $report; }
public function main() { $count = array(); $article = M('article'); $type = M('type'); $link = M('link'); $hd = M('flash'); $ping = M('pl'); $guest = M('guestbook'); $count['article'] = $article->count(); //文章总数 $count['narticle'] = $article->where('status=0')->count(); //未审核文章总数 $count['guestbook'] = $guest->count(); //留言总数 $count['nguestbook'] = $guest->where('status=0')->count(); //未审核留言总数 $count['type'] = $type->count(); //栏目总数 $count['link'] = $link->count(); //链接总数 $count['hd'] = $hd->count(); //幻灯总数 $count['ping'] = $ping->count(); //评论总数 $count['nping'] = $ping->where('status=0')->count(); //未审核评论 $this->assign('count', $count); unset($article, $type, $link, $hd, $ping, $guest); $info = array('操作系统' => PHP_OS, '运行环境' => $_SERVER["SERVER_SOFTWARE"], 'PHP运行方式' => php_sapi_name(), '上传附件限制' => ini_get('upload_max_filesize'), '执行时间限制' => ini_get('max_execution_time') . '秒', '服务器时间' => date("Y年n月j日 H:i:s"), '北京时间' => gmdate("Y年n月j日 H:i:s", time() + 8 * 3600), '服务器域名/IP' => $_SERVER['SERVER_NAME'] . ' [ ' . gethostbyname($_SERVER['SERVER_NAME']) . ' ]', '剩余空间' => round(@disk_free_space(".") / (1024 * 1024), 2) . 'M', 'register_globals' => get_cfg_var("register_globals") == "1" ? "ON" : "OFF", 'magic_quotes_gpc' => 1 === get_magic_quotes_gpc() ? 'YES' : 'NO', 'magic_quotes_runtime' => 1 === get_magic_quotes_runtime() ? 'YES' : 'NO'); $this->assign('info', $info); $this->display('main'); }
/** * Get sort order * * @param string $sort * @param string $page * @param string $ord * @return array */ public function getSortOrder($sort = null, $page = null, $ord = 'ASC') { $field = 'id'; $order = $ord; $sess = null; if (stripos(php_sapi_name(), 'cli') === false || stripos(php_sapi_name(), 'server') !== false) { $sess = \Pop\Session\Session::getInstance(); } if (null !== $sort) { if (null !== $sess && $page != $sess->lastPage) { if ($sort != $sess->lastSortField) { $field = $sort; $order = $ord; } else { $field = $sess->lastSortField; $order = $sess->lastSortOrder; } } else { $field = $sort; if (null !== $sess && isset($sess->lastSortOrder)) { $order = $sess->lastSortOrder == 'ASC' ? 'DESC' : 'ASC'; } else { $order = $ord; } } } if (null !== $sess) { $sess->lastSortField = $field; $sess->lastSortOrder = $order; $sess->lastPage = $page; } return $field . ' ' . $order; }
/** * Fixes CGI only one Status header allowed bug * * @link http://bugs.php.net/bug.php?id=36705 * * @return Mage_Core_Controller_Response_Http */ public function sendHeaders() { if (!$this->canSendHeaders()) { Mage::log('HEADERS ALREADY SENT: ' . mageDebugBacktrace(true, true, true)); return $this; } if (substr(php_sapi_name(), 0, 3) == 'cgi') { $statusSent = false; foreach ($this->_headersRaw as $i => $header) { if (stripos($header, 'status:') === 0) { if ($statusSent) { unset($this->_headersRaw[$i]); } else { $statusSent = true; } } } foreach ($this->_headers as $i => $header) { if (strcasecmp($header['name'], 'status') === 0) { if ($statusSent) { unset($this->_headers[$i]); } else { $statusSent = true; } } } } return parent::sendHeaders(); }
/** * Constructor. * * @param array $options The formatting options. */ public function __construct(array $options = array()) { // The specified formatting options are merged with the default values. $this->options = array_merge(array('type' => php_sapi_name() == 'cli' ? 'cli' : 'text', 'line_ending' => $this->options['type'] == 'html' ? '<br/>' : "\n", 'indentation' => " ", 'remove_comments' => false, 'clause_newline' => true, 'parts_newline' => true, 'indent_parts' => true, 'formats' => array(array('type' => Token::TYPE_KEYWORD, 'flags' => Token::FLAG_KEYWORD_RESERVED, 'html' => 'class="sql-reserved"', 'cli' => "[35m", 'function' => 'strtoupper'), array('type' => Token::TYPE_KEYWORD, 'flags' => 0, 'html' => 'class="sql-keyword"', 'cli' => "[95m", 'function' => 'strtoupper'), array('type' => Token::TYPE_COMMENT, 'flags' => 0, 'html' => 'class="sql-comment"', 'cli' => "[37m", 'function' => ''), array('type' => Token::TYPE_BOOL, 'flags' => 0, 'html' => 'class="sql-atom"', 'cli' => "[36m", 'function' => 'strtoupper'), array('type' => Token::TYPE_NUMBER, 'flags' => 0, 'html' => 'class="sql-number"', 'cli' => "[92m", 'function' => 'strtolower'), array('type' => Token::TYPE_STRING, 'flags' => 0, 'html' => 'class="sql-string"', 'cli' => "[91m", 'function' => ''), array('type' => Token::TYPE_SYMBOL, 'flags' => 0, 'html' => 'class="sql-variable"', 'cli' => "[36m", 'function' => ''))), $options); // `parts_newline` requires `clause_newline` $this->options['parts_newline'] &= $this->options['clause_newline']; }
/** * initializeBag */ private function initializeBag() { $scriptName = ''; $dirname = '/'; $rewriteOn = false; if (php_sapi_name() !== 'cli') { $scriptName = $_SERVER['SCRIPT_NAME']; $rewriteOn = !preg_match("#{$scriptName}#", $this->getUrl()); } $parseUrl = parse_url($this->url); $info = pathinfo($scriptName); $context = !empty($info['basename']) && php_sapi_name() !== 'cli' && false === $rewriteOn ? "/{$info['basename']}" : ''; $scheme = !empty($parseUrl['scheme']) ? "{$parseUrl['scheme']}://" : ''; $host = !empty($parseUrl['host']) ? "{$parseUrl['host']}" : ''; $port = !empty($parseUrl['port']) ? ":{$parseUrl['port']}" : ''; $query = !empty($parseUrl['query']) ? "?{$parseUrl['query']}" : ''; $this->path = !empty($parseUrl['path']) ? "{$parseUrl['path']}{$query}" : ''; /* Normalize windows and *nix directory name by using "/" */ /* Ex: windows directory name can be "\" and *nix directory name is "/" */ /* This changes all "\" to "/" */ if (!empty($info['dirname'])) { $dirname = str_replace("\\", '/', $info['dirname']); } $this->assetPath = $dirname != '/' ? $dirname . '/' : $dirname; $this->basePath = rtrim($this->assetPath, '/') . $context; $this->baseUrl = "{$scheme}{$host}{$port}{$this->basePath}"; }
function getShowSlowBase() { global $showslow_root; $showslow_root = str_replace(DIRECTORY_SEPARATOR, '/', $showslow_root); // Chopping of trailing slash which is not supposed to be there in Apache config // See: http://httpd.apache.org/docs/2.0/mod/core.html#documentroot $docroot = str_replace(DIRECTORY_SEPARATOR, '/', $_SERVER['DOCUMENT_ROOT']); if (substr($docroot, -1) == '/') { $docroot = substr($docroot, 0, -1); } $docrootlength = strlen($docroot); if (array_key_exists('HTTP_HOST', $_SERVER)) { $host = $_SERVER['HTTP_HOST']; } else { $host = php_uname('n'); // if not running from command line, send warning to the log file if (php_sapi_name() !== 'cli') { error_log("[ShowSlow config] Warning: Can't determine site's host name, using {$host}"); } } $protocol = 'http'; if (array_key_exists('HTTPS', $_SERVER) && $_SERVER['HTTPS'] == 'HTTPS') { $protocol = 'https'; } return $protocol . '://' . $host . substr($showslow_root, $docrootlength); }
function dbQuery($sql, $parameters = array()) { global $fullSql, $debug, $sql_debug, $console_color, $database_link; $fullSql = dbMakeQuery($sql, $parameters); if ($debug) { if (php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { if (preg_match('/(INSERT INTO `alert_log`).*(details)/i', $fullSql)) { echo "\nINSERT INTO `alert_log` entry masked due to binary data\n"; } else { print $console_color->convert("\nSQL[%y" . $fullSql . '%n] '); } } else { $sql_debug[] = $fullSql; } } /* if($this->logFile) $time_start = microtime(true); */ $result = mysqli_query($database_link, $fullSql); // sets $this->result /* if($this->logFile) { $time_end = microtime(true); fwrite($this->logFile, date('Y-m-d H:i:s') . "\n" . $fullSql . "\n" . number_format($time_end - $time_start, 8) . " seconds\n\n"); } */ if ($result === false && error_reporting() & 1) { // aye. this gets triggers on duplicate Contact insert // trigger_error('QDB - Error in query: ' . $fullSql . ' : ' . mysql_error(), E_USER_WARNING); } return $result; }
/** * Returns true if the class is being run from the command line, caches result * @since 1.0 * @static * @ignore * @return bool True if the script is being run from a CLI or false if its being run from a webserver */ private static function _is_cli() { if (is_null(self::$is_cli)) { self::$is_cli = php_sapi_name() == 'cli'; } return self::$is_cli; }
/** * Class constructor */ public function __construct() { if (php_sapi_name() == 'cli') { $this->setEnabled(false); } $this->_formatter = new Zend_Log_Formatter_Firebug(); }
/** * @return string */ public function __toString() { if (php_sapi_name() == 'cli') { return (string) $this->exception; } return $this->render(); }