* @link http://buildwithcraft.com */ /** * @param $dbHostname * @return string */ function normalizeDbHostname($dbHostname) { // MacOS command line db connections apparently want this in numeric format. if (strcasecmp($dbHostname, 'localhost') == 0) { $dbHostname = '127.0.0.1'; } return $dbHostname; } /** * Returns the correct connection string depending on whether a unixSocket is specific or not in the db config. * * @param $dbConfig * @return string */ function processConnectionString($dbConfig) { if (!empty($dbConfig['unixSocket'])) { return strtolower('mysql:unix_socket=' . $dbConfig['unixSocket'] . ';dbname=' . $dbConfig['database'] . ';'); } else { return strtolower('mysql:host=' . normalizeDbHostname($dbConfig['server']) . ';dbname=' . $dbConfig['database'] . ';port=' . $dbConfig['port'] . ';'); } } $common = (require CRAFT_APP_PATH . 'etc/config/common.php'); return CMap::mergeArray($common, array('basePath' => dirname(__FILE__) . '/../../', 'import' => array('application.*', 'application.migrations.*'), 'componentAliases' => array('app.*', 'app.enums.*', 'app.etc.components.*', 'app.etc.console.*', 'app.etc.console.commands.*', 'app.etc.dates.*', 'app.etc.db.*', 'app.etc.db.schemas.*', 'app.etc.io.*', 'app.etc.logging.*', 'app.etc.updates.*', 'app.helpers.*', 'app.migrations.*', 'app.services.*', 'app.validators.*'), 'components' => array('db' => array('connectionString' => processConnectionString($dbConfig), 'emulatePrepare' => true, 'username' => $dbConfig['user'], 'password' => $dbConfig['password'], 'charset' => $dbConfig['charset'], 'tablePrefix' => $tablePrefix, 'driverMap' => array('mysql' => 'Craft\\MysqlSchema'), 'class' => 'Craft\\DbConnection'), 'migrations' => array('class' => 'Craft\\MigrationsService')), 'commandPath' => Craft\Craft::getPathOfAlias('system.cli.commands.*')));
<script type="text/javascript"> /*<![CDATA[*/ if (typeof(console) == 'object') { console.groupCollapsed("Profiling Summary Report"); console.log("Time: <?php echo sprintf('%0.5f', Craft\Craft::getLogger()->getExecutionTime()); ?> s\n"); console.log("Memory: <?php echo number_format(Craft\Craft::getLogger()->getMemoryUsage() / 1024); ?> Kb\n"); console.log(" count total average min max "); <?php foreach ($data as $index => $entry) { $proc = CJavaScript::quote($entry[0]); $count = sprintf('%5d', $entry[1]); $min = sprintf('%0.5f', $entry[2]); $max = sprintf('%0.5f', $entry[3]); $total = sprintf('%0.5f', $entry[4]); $average = sprintf('%0.5f', $entry[4] / $entry[1]); echo "\tconsole.log(\" {$count} {$total} {$average} {$min} {$max} {$proc}\");\n"; } ?> console.groupEnd(); } /*]]>*/ </script>
defined('CRAFT_CONFIG_PATH') || define('CRAFT_CONFIG_PATH', $frontConfigPath); } else { defined('CRAFT_CONFIG_PATH') || define('CRAFT_CONFIG_PATH', CRAFT_BASE_PATH . 'config/'); } defined('CRAFT_PLUGINS_PATH') || define('CRAFT_PLUGINS_PATH', CRAFT_BASE_PATH . 'plugins/'); defined('CRAFT_STORAGE_PATH') || define('CRAFT_STORAGE_PATH', CRAFT_BASE_PATH . 'storage/'); defined('CRAFT_TEMPLATES_PATH') || define('CRAFT_TEMPLATES_PATH', CRAFT_BASE_PATH . 'templates/'); defined('CRAFT_TRANSLATIONS_PATH') || define('CRAFT_TRANSLATIONS_PATH', CRAFT_BASE_PATH . 'translations/'); defined('CRAFT_ENVIRONMENT') || define('CRAFT_ENVIRONMENT', 'console'); /** * Yii command line script file configured for Craft. */ // fix for fcgi defined('STDIN') or define('STDIN', fopen('php://stdin', 'r')); require_once dirname(__FILE__) . '/../../framework/yii.php'; require_once CRAFT_APP_PATH . 'Craft.php'; require_once CRAFT_APP_PATH . 'Info.php'; // Guzzle makes use of these PHP constants, but they aren't actually defined in some compilations of PHP. // See http://it.blog.adclick.pt/php/fixing-php-notice-use-of-undefined-constant-curlopt_timeout_ms-assumed-curlopt_timeout_ms/ defined('CURLOPT_TIMEOUT_MS') || define('CURLOPT_TIMEOUT_MS', 155); defined('CURLOPT_CONNECTTIMEOUT_MS') || define('CURLOPT_CONNECTTIMEOUT_MS', 156); // Load up Composer's files require CRAFT_APP_PATH . 'vendor/autoload.php'; // Disable the PHP include path Yii::$enableIncludePath = false; require_once dirname(__FILE__) . '/ConsoleApp.php'; Yii::setPathOfAlias('app', CRAFT_APP_PATH); Yii::setPathOfAlias('plugins', CRAFT_PLUGINS_PATH); $app = Yii::createApplication('Craft\\ConsoleApp', $configPath); $app->commandRunner->addCommands(Craft\Craft::getPathOfAlias('application.consolecommands.*')); $app->run();
$timestamp = $environmentData[3]; $forced = isset($environmentData[4]) ? $environmentData[4] : false; $cookiePos = mb_strpos($message, '$_COOKIE'); $serverPos = mb_strpos($message, '$_SERVER'); $sessionPos = mb_strpos($message, '$_SESSION'); $getInfo = mb_substr($message, 0, $cookiePos); $nextPos = !$sessionPos ? $serverPos : $sessionPos; $cookieInfo = mb_substr($message, $cookiePos, $nextPos - $cookiePos); $sessionInfo = false; if ($sessionPos) { $sessionInfo = mb_substr($message, $sessionPos, $serverPos - $sessionPos); } $serverInfo = mb_substr($message, $serverPos); Craft\LoggingHelper::processFireBugLogEntry($level, $timestamp, $category, $getInfo, Craft\Craft::t('GET Info'), $forced); Craft\LoggingHelper::processFireBugLogEntry($level, $timestamp, $category, $cookieInfo, Craft\Craft::t('COOKIE Info'), $forced); if ($sessionInfo) { Craft\LoggingHelper::processFireBugLogEntry($level, $timestamp, $category, $sessionInfo, Craft\Craft::t('SESSION Info'), $forced); } Craft\LoggingHelper::processFireBugLogEntry($level, $timestamp, $category, $serverInfo, Craft\Craft::t('SERVER Info'), $forced); echo "\tconsole.groupCollapsed(\"Logs\");\n"; foreach ($data as $log) { Craft\LoggingHelper::processFireBugLogEntry($log[1], $log[3], $log[2], $log[0], null, isset($log[4]) ? $log[4] : false); } echo "\tconsole.groupEnd();\n"; ?> console.groupEnd(); } /*]]>*/ </script>