public function info() { echo Configure::version(); die; phpinfo(); die; }
/** * Displays a header for the shell * * @return void */ protected function _welcome() { $this->out(); $this->out(__d('cake_console', '<info>Welcome to CakePHP %s Console</info>', 'v' . Configure::version())); $this->out(__d('cake_console', '<info>Customize by RikkeiSoft Co. Ltd.,</info>')); $this->hr(); }
/** * Displays a header for the shell */ protected function _welcome() { $this->out(); $this->out('<info>Welcome to ' . Configure::read('App.name') . ' ' . Configure::version() . ' Console</info>'); $this->hr(); $this->out('App : ' . APP_DIR); $this->out('Path: ' . APP); $this->hr(); }
function _setPath($type, $path) { if (version_compare(Configure::version(), '1.3') > 0) { App::build(array(Inflector::pluralize($type) => (array) $path)); $this->Interactive->objectPath = dirname($path) . DS; } else { Configure::write(Inflector::singularize($type) . 'Paths', (array) $path); $this->Interactive->objectPath = $path; } }
/** * beforeRender - Get necessary data about environment to pass back to controller * * @return array */ public function beforeRender(Controller $controller) { parent::beforeRender($controller); $return = array(); // PHP Data $phpVer = phpversion(); $return['php'] = array_merge(array('PHP_VERSION' => $phpVer), $_SERVER); unset($return['php']['argv']); // CakePHP Data $return['cake'] = array('APP' => APP, 'APP_DIR' => APP_DIR, 'APPLIBS' => APPLIBS, 'CACHE' => CACHE, 'CAKE' => CAKE, 'CAKE_CORE_INCLUDE_PATH' => CAKE_CORE_INCLUDE_PATH, 'CORE_PATH' => CORE_PATH, 'CAKE_VERSION' => Configure::version(), 'CSS' => CSS, 'CSS_URL' => CSS_URL, 'DS' => DS, 'FULL_BASE_URL' => FULL_BASE_URL, 'IMAGES' => IMAGES, 'IMAGES_URL' => IMAGES_URL, 'JS' => JS, 'JS_URL' => JS_URL, 'LOGS' => LOGS, 'ROOT' => ROOT, 'TESTS' => TESTS, 'TMP' => TMP, 'VENDORS' => VENDORS, 'WEBROOT_DIR' => WEBROOT_DIR, 'WWW_ROOT' => WWW_ROOT); return $return; }
/** * Returns an array of group -> config map * * @return array Array of group to config map * @throws CacheException */ public static function groupConfigs($group = null) { if (version_compare(Configure::version(), '2.4', '>=')) { return parent::groupConfigs($group); } if ($group == null) { return self::$_groups; } if (isset(self::$_groups[$group])) { return array($group => self::$_groups[$group]); } else { throw new CacheException(sprintf('Invalid cache group %s', $group)); } }
/** * generate * Generate .cake array * * @return array $dotcake */ public function generate() { $dotcake = array(); $dotcake['cake_version'] = Configure::version(); $dotcake['cake'] = $this->__cake; $dotcake['build_path'] = array(); $paths = $this->__paths; foreach ($paths as $key => $values) { $formattedKey = strtolower(Inflector::pluralize(preg_replace('/\\A.+\\//', '', $key))); $dotcake['build_path'][$formattedKey] = array(); $dotcake['build_path'][$formattedKey] = array_map(array($this, 'relativePath'), $values); } return $dotcake; }
/** * beforeRender - Get necessary data about environment to pass back to controller * * @return array */ public function beforeRender(Controller $controller) { parent::beforeRender($controller); $return = array(); // PHP Data $phpVer = phpversion(); $return['php'] = array_merge(array('PHP_VERSION' => $phpVer), $_SERVER); unset($return['php']['argv']); // CakePHP Data $return['cake'] = array('APP' => APP, 'APP_DIR' => APP_DIR, 'APPLIBS' => APPLIBS, 'CACHE' => CACHE, 'CAKE' => CAKE, 'CAKE_CORE_INCLUDE_PATH' => CAKE_CORE_INCLUDE_PATH, 'CORE_PATH' => CORE_PATH, 'CAKE_VERSION' => Configure::version(), 'CSS' => CSS, 'CSS_URL' => CSS_URL, 'DS' => DS, 'FULL_BASE_URL' => FULL_BASE_URL, 'IMAGES' => IMAGES, 'IMAGES_URL' => IMAGES_URL, 'JS' => JS, 'JS_URL' => JS_URL, 'LOGS' => LOGS, 'ROOT' => ROOT, 'TESTS' => TESTS, 'TMP' => TMP, 'VENDORS' => VENDORS, 'WEBROOT_DIR' => WEBROOT_DIR, 'WWW_ROOT' => WWW_ROOT); $cakeConstants = array_fill_keys(array('DS', 'ROOT', 'FULL_BASE_URL', 'TIME_START', 'SECOND', 'MINUTE', 'HOUR', 'DAY', 'WEEK', 'MONTH', 'YEAR', 'LOG_ERROR', 'FULL_BASE_URL'), ''); $var = get_defined_constants(true); $return['app'] = array_diff_key($var['user'], $return['cake'], $cakeConstants); return $return; }
/** * get version * * @return string */ function getVersion() { if (method_exists('Configure', 'version')) { return Configure::version(); } else { $handle = fopen(CAKE . DS . 'VERSION.txt', "r"); if ($handle) { while (($line = fgets($handle, 4096)) !== false) { if (preg_match('/\\/\\//', $line)) { continue; } if (preg_match('/([0-9]+\\.[0-9]+\\.[0-9]+)/', $line, $m)) { return $m[1]; } } fclose($handle); } } return null; }
/** * cakeVersion method * * @return void * @access protected */ protected static function cakeVersion() { if (Mi::$cakeVersion) { return Mi::$cakeVersion; } return Mi::$cakeVersion = substr(Configure::version(), 0, 3); }
/** * Returns a reference to the Debugger singleton object instance. * * @return object * @access public * @static */ function &getInstance($class = null) { if (!empty($class)) { if (is_null(self::$instance) || strtolower($class) != strtolower(get_class(self::$instance))) { self::$instance =& new $class(); if (Configure::read() > 0) { Configure::version(); // Make sure the core config is loaded self::$instance->helpPath = Configure::read('Cake.Debugger.HelpPath'); } } } if (is_null(self::$instance)) { self::$instance =& new Debugger(); if (Configure::read() > 0) { Configure::version(); // Make sure the core config is loaded self::$instance->helpPath = Configure::read('Cake.Debugger.HelpPath'); } } return self::$instance; }
/** * Shows console help * * @access public */ function help() { $this->stdout("\nWelcome to CakePHP v" . Configure::version() . " Console"); $this->stdout("---------------------------------------------------------------"); $this->stdout("Current Paths:"); $this->stdout(" -app: " . $this->params['app']); $this->stdout(" -working: " . rtrim($this->params['working'], DS)); $this->stdout(" -root: " . rtrim($this->params['root'], DS)); $this->stdout(" -core: " . rtrim(CORE_PATH, DS)); $this->stdout(""); $this->stdout("Changing Paths:"); $this->stdout("your working path should be the same as your application path"); $this->stdout("to change your path use the '-app' param."); $this->stdout("Example: -app relative/path/to/myapp or -app /absolute/path/to/myapp"); $this->stdout("\nAvailable Shells:"); $_shells = array(); foreach ($this->shellPaths as $path) { if (is_dir($path)) { $shells = Configure::listObjects('file', $path); $path = str_replace(CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS, 'CORE' . DS, $path); $path = str_replace(APP, 'APP' . DS, $path); $path = str_replace(ROOT, 'ROOT', $path); $path = rtrim($path, DS); $this->stdout("\n " . $path . ":"); if (empty($shells)) { $this->stdout("\t - none"); } else { sort($shells); foreach ($shells as $shell) { if ($shell !== 'shell.php') { $this->stdout("\t " . str_replace('.php', '', $shell)); } } } } } $this->stdout("\nTo run a command, type 'cake shell_name [args]'"); $this->stdout("To get help on a specific command, type 'cake shell_name help'"); $this->_stop(); }
/** * Displays a header for the shell * * @access protected */ function _welcome() { $this->Dispatch->clear(); $this->out(); $this->out('Welcome to CakePHP v' . Configure::version() . ' Console'); $this->hr(); $this->out('App : ' . $this->params['app']); $this->out('Path: ' . $this->params['working']); $this->hr(); }
/** * Dispatches a CLI request * * @access public */ function dispatch() { $this->stdout("\nWelcome to CakePHP v" . Configure::version() . " Console"); $this->stdout("---------------------------------------------------------------"); if (isset($this->args[0])) { $this->shell = $this->args[0]; $this->shiftArgs(); $this->shellName = Inflector::camelize($this->shell); $this->shellClass = $this->shellName . 'Shell'; if ($this->shell == 'help') { $this->help(); } else { $loaded = false; foreach ($this->shellPaths as $path) { $this->shellPath = $path . $this->shell . ".php"; if (file_exists($this->shellPath)) { $loaded = true; break; } } if ($loaded) { require CONSOLE_LIBS . 'shell.php'; require $this->shellPath; if (class_exists($this->shellClass)) { $command = null; if (isset($this->args[0])) { $command = $this->args[0]; } $this->shellCommand = Inflector::variable($command); $shell = new $this->shellClass($this); $shell->initialize(); $shell->loadTasks(); foreach ($shell->taskNames as $task) { $shell->{$task}->initialize(); $shell->{$task}->loadTasks(); } $task = Inflector::camelize($command); if (in_array($task, $shell->taskNames)) { $this->shiftArgs(); $shell->{$task}->startup(); if (isset($this->args[0]) && $this->args[0] == 'help') { if (method_exists($shell->{$task}, 'help')) { $shell->{$task}->help(); exit; } else { $this->help(); } } $shell->{$task}->execute(); return; } $classMethods = get_class_methods($shell); $privateMethod = $missingCommand = false; if ((in_array($command, $classMethods) || in_array(strtolower($command), $classMethods)) && strpos($command, '_', 0) === 0) { $privateMethod = true; } if (!in_array($command, $classMethods) && !in_array(strtolower($command), $classMethods)) { $missingCommand = true; } $protectedCommands = array('initialize', 'in', 'out', 'err', 'hr', 'createfile', 'isdir', 'copydir', 'object', 'tostring', 'requestaction', 'log', 'cakeerror', 'shelldispatcher', '__initconstants', '__initenvironment', '__construct', 'dispatch', '__bootstrap', 'getinput', 'stdout', 'stderr', 'parseparams', 'shiftargs'); if (in_array(strtolower($command), $protectedCommands)) { $missingCommand = true; } if ($missingCommand && method_exists($shell, 'main')) { $shell->startup(); $shell->main(); } elseif (!$privateMethod && method_exists($shell, $command)) { $this->shiftArgs(); $shell->startup(); $shell->{$command}(); } else { $this->stderr("Unknown {$this->shellName} command '{$command}'.\nFor usage, try 'cake {$this->shell} help'.\n\n"); } } else { $this->stderr('Class ' . $this->shellClass . ' could not be loaded'); } } else { $this->help(); } } } else { $this->help(); } }
function cakeRender($content, $type, $org_charset = null, $target_charset = null) { if (is_null($target_charset)) { $target_charset = $this->charset_content; } if (!class_exists($this->Controller->view)) { if (!$this->import('View', $this->view)) { return $this->errorGather('Qdmail<->CakePHP View Load Error , the name is \'' . $this->view . '\'', __LINE__); } } $type = strtolower($type); $view = new $this->Controller->view($this->Controller, false); $view->layout = $this->layout; $mess = null; $content = $view->renderElement($this->view_dir . DS . $type . DS . $this->template, array('content' => $content), true); if (1.2 > (double) substr(Configure::version(), 0, 3)) { $view->subDir = $this->layout_dir . DS . $type . DS; } else { $view->layoutPath = $this->layout_dir . DS . $type; } $mess .= $view->renderLayout($content); if (is_null($org_charset)) { $org_charset = $this->qd_detect_encoding($mess); } $mess = $this->qd_convert_encoding($mess, $target_charset, $org_charset); return array($mess, $target_charset, $org_charset); }
/** * Returns a reference to the Debugger singleton object instance. * * @return object * @access public * @static */ function &getInstance($class = null) { static $instance = array(); if (!empty($class)) { if (!$instance || strtolower($class) != strtolower(get_class($instance[0]))) { $instance[0] =& new $class(); if (Configure::read() > 0) { Configure::version(); // Make sure the core config is loaded $instance[0]->helpPath = Configure::read('Cake.Debugger.HelpPath'); } } } if (!$instance) { $instance[0] =& new Debugger(); if (Configure::read() > 0) { Configure::version(); // Make sure the core config is loaded $instance[0]->helpPath = Configure::read('Cake.Debugger.HelpPath'); } } return $instance[0]; }
/** * Checks the versions of PHP, CakePHP and PHPSass * * @throws CakeException If one of the required versions is not available * * @return void */ protected function _checkVersion() { if (PHP_VERSION < self::$_minVersionPHP) { throw new CakeException(__('The SassCompiler plugin requires PHP version %s or higher!', self::$_minVersionPHP)); } if (Configure::version() < self::$_minVersionCakePHP) { throw new CakeException(__('The SassCompiler plugin requires CakePHP version %s or higher!', self::$_minVersionCakePHP)); } $scssc = new SassCompiler(); if ($scssc::$VERSION < self::$_minVersionScssc) { throw new CakeException(__('The SassCompiler plugin requires scssc version %s or higher!', self::$_minVersionLessc)); } unset($scssc); }
*/ if (defined('TEST_EXECUTION')) { return; } /* * Setup caching, check if a cache class is made available i.e. through a * framework. */ $cacheRead = function ($key) { return false; }; $cacheWrite = function ($key, $value) { return false; }; $lithium = class_exists('\\lithium\\storage\\Cache'); $version = is_callable('Configure::version') ? Configure::version() : null; $cakephp20 = $version && version_compare($version, '2.0', '>='); $cakephp13 = $version && version_compare($version, '1.3', '>=') && !$cakephp20; if ($cakephp13 || $cakephp20) { $cacheRead = function ($key) { return Cache::read($key); }; $cacheWrite = function ($key, $value) { return Cache::write($key, $value); }; } elseif ($lithium) { $cacheRead = function ($key) { return \lithium\storage\Cache::read('default', $key); }; $cacheWrite = function ($key, $value) { return \lithium\storage\Cache::write('default', $key, $value);
/** * Shows console help * * @access public */ function help() { $this->clear(); $this->stdout("\nWelcome to CakePHP v" . Configure::version() . " Console"); $this->stdout("---------------------------------------------------------------"); $this->stdout("Current Paths:"); $this->stdout(" -app: " . $this->params['app']); $this->stdout(" -working: " . rtrim($this->params['working'], DS)); $this->stdout(" -root: " . rtrim($this->params['root'], DS)); $this->stdout(" -core: " . rtrim(CORE_PATH, DS)); $this->stdout(""); $this->stdout("Changing Paths:"); $this->stdout("your working path should be the same as your application path"); $this->stdout("to change your path use the '-app' param."); $this->stdout("Example: -app relative/path/to/myapp or -app /absolute/path/to/myapp"); $this->stdout("\nAvailable Shells:"); $shellList = array(); foreach ($this->shellPaths as $path) { if (!is_dir($path)) { continue; } $shells = App::objects('file', $path); if (empty($shells)) { continue; } if (preg_match('@plugins[\\\\/]([^\\\\/]*)@', $path, $matches)) { $type = Inflector::camelize($matches[1]); } elseif (preg_match('@([^\\\\/]*)[\\\\/]vendors[\\\\/]@', $path, $matches)) { $type = $matches[1]; } elseif (strpos($path, CAKE_CORE_INCLUDE_PATH . DS . 'cake') === 0) { $type = 'CORE'; } else { $type = 'app'; } foreach ($shells as $shell) { if ($shell !== 'shell.php') { $shell = str_replace('.php', '', $shell); $shellList[$shell][$type] = $type; } } } if ($shellList) { ksort($shellList); if (DS === '/') { $width = exec('tput cols') - 2; } if (empty($width)) { $width = 80; } $columns = max(1, floor($width / 30)); $rows = ceil(count($shellList) / $columns); foreach ($shellList as $shell => $types) { sort($types); $shellList[$shell] = str_pad($shell . ' [' . implode($types, ', ') . ']', $width / $columns); } $out = array_chunk($shellList, $rows); for ($i = 0; $i < $rows; $i++) { $row = ''; for ($j = 0; $j < $columns; $j++) { if (!isset($out[$j][$i])) { continue; } $row .= $out[$j][$i]; } $this->stdout(" " . $row); } } $this->stdout("\nTo run a command, type 'cake shell_name [args]'"); $this->stdout("To get help on a specific command, type 'cake shell_name help'"); }
/** * Displays a header for the shell * * @access protected */ function _welcome() { $this->out("\nWelcome to CakePHP v" . Configure::version() . " Console"); $this->out("---------------------------------------------------------------"); $this->out('App : ' . $this->params['app']); $this->out('Path: ' . $this->params['working']); $this->hr(); }
/** * Make the actual call to Akismet * * @param object $model Model using this behavior * @param string $path Akismet method to call * @return mixed * @access private */ function __query(&$model, $method) { $request = $model->data; $post = array(); foreach ($this->settings[$model->alias] as $label => $field) { if ($label != 'is_spam') { $alias = $model->alias; if (strpos($field, '.')) { list($alias, $field) = explode('.', $field, 2); } if (!empty($request[$alias][$field])) { $post['comment_' . $label] = $request[$alias][$field]; } } } if (empty($post) || $this->__conn === false) { return false; } if (!$this->__conn) { if (!($auth = Configure::read('Akismet'))) { Configure::load('akismet'); if (!($auth = Configure::read('Akismet'))) { return $this->__conn = false; } } App::import('Core', 'HttpSocket'); $userAgent = 'CakePHP/' . Configure::version(); $userAgent .= ' | AkismetBehavior/' . $this->_version; $request = array('uri' => 'http://' . $auth['key'] . '.rest.akismet.com', 'header' => array('User-Agent' => $userAgent)); $timeout = !empty($auth['timeout']) ? $auth['timeout'] : 3; $this->__conn =& new HttpSocket(compact('request', 'timeout')); if ($this->__conn->post('/1.1/verify-key', $auth) != 'valid') { return $this->__conn = false; } $this->__conn->config['request']['body'] = array('blog' => $auth['blog'], 'user_ip' => env('REMOTE_ADDR'), 'user_agent' => env('HTTP_USER_AGENT'), 'referrer' => env('HTTP_REFERER')); } return $this->__conn->post('/1.1/' . $method, $post); }
public function setUp() { parent::setUp(); // This test case is only valid for 2.3.x series $this->skipIf(version_compare(Configure::version(), '2.3.1', '<')); }
div.code-coverage-results span.result-good { color: #0a0; } div#version { padding-top: 2px; float: right; padding-left: 20px; } </style> <link rel="stylesheet" type="text/css" href="<?php echo $baseDir; ?> css/cake.generic.css"/> </head> <body> <div id="container"> <div id="header"> <div id="version"> PHPUnit: <?php echo class_exists('PHPUnit_Runner_Version') ? PHPUnit_Runner_Version::id() : 'n/a'; ?> </div> <h1>CakePHP: the rapid development php framework</h1> </div> <div id="content"> <h2>CakePHP Test Suite <?php echo Configure::version(); ?> </h2>
/** * Displays a header for the shell * */ protected function _welcome() { $this->clear(); $this->out(); $this->out('<info>Welcome to CakePHP v' . Configure::version() . ' Console</info>'); $this->hr(); $this->out('App : ' . APP_DIR); $this->out('Path: ' . APP_PATH); $this->hr(); }
/** * testVersion method * * @access public * @return void */ function testVersion() { $result = Configure::version(); $this->assertTrue(version_compare($result, '1.2', '>=')); }
/** * Test cake2.4 passwordHasher feature * * @return void */ public function testPasswordHasher() { $this->skipIf((double) Configure::version() < 2.4, 'Needs 2.4 and above'); $this->User->Behaviors->load('Tools.Passwordable', ['formField' => 'pwd', 'formFieldRepeat' => 'pwd_repeat', 'allowSame' => false, 'current' => false, 'passwordHasher' => 'Complex']); $this->User->create(); $data = ['pwd' => 'somepwd', 'pwd_repeat' => 'somepwd']; $this->User->set($data); $result = $this->User->save(); $this->assertTrue((bool) $result); $uid = (string) $this->User->id; $this->User->Behaviors->load('Tools.Passwordable', ['current' => true]); $this->User->create(); $data = ['id' => $uid, 'pwd' => '123456', 'pwd_repeat' => '12345678']; $this->User->set($data); $this->assertTrue($this->User->Behaviors->loaded('Passwordable')); $is = $this->User->save(); $this->assertFalse($is); $this->User->create(); $data = ['id' => $uid, 'pwd_current' => 'somepwdx', 'pwd' => '123456', 'pwd_repeat' => '123456']; $this->User->set($data); $is = $this->User->save(); $this->assertFalse($is); $this->User->create(); $data = ['id' => $uid, 'pwd_current' => 'somepwd', 'pwd' => '123456', 'pwd_repeat' => '123456']; $this->User->set($data); $is = $this->User->save(); $this->assertTrue(!empty($is)); }
/** * [ADMIN] PHPINFOを表示する */ public function admin_info() { $this->pageTitle = '環境情報'; $smartUrl = 'ON'; if (Configure::read('App.baseUrl')) { $smartUrl = 'OFF'; } $datasources = array('csv' => 'CSV', 'sqlite' => 'SQLite', 'mysql' => 'MySQL', 'postgres' => 'PostgreSQL'); $db = ConnectionManager::getDataSource('baser'); list($type, $name) = explode('/', $db->config['datasource'], 2); $datasource = preg_replace('/^bc/', '', strtolower($name)); $this->set('datasource', @$datasources[$datasource]); $this->set('smartUrl', $smartUrl); $this->set('baserVersion', $this->siteConfigs['version']); $this->set('cakeVersion', Configure::version()); $this->subMenuElements = array('site_configs'); }
/** * testAdminRowAction */ public function testAdminRowAction() { $url = array('controller' => 'users', 'action' => 'edit', 1); $expected = array('a' => array('href' => '/users/edit/1', 'class' => 'edit'), 'Edit', '/a'); $result = $this->Croogo->adminRowAction('Edit', $url); $this->assertTags($result, $expected); $options = array('class' => 'test-class'); $message = 'Are you sure?'; $onclick = "return confirm('" . $message . "');"; if (version_compare(Configure::version(), '2.4.0', '>=')) { $onclick = sprintf("if (confirm("%s")) { return true; } return false;", $message); } $expected = array('a' => array('href' => '/users/edit/1', 'class' => 'test-class edit', 'onclick' => $onclick), 'Edit', '/a'); $result = $this->Croogo->adminRowAction('Edit', $url, $options, $message); $this->assertTags($result, $expected); }
/** * Displays a header for the shell * * @return void */ protected function _welcome() { $this->out(); $this->out(__d('cake_console', '<info>Welcome to CakePHP %s Console</info>', 'v' . Configure::version())); $this->hr(); $this->out(__d('cake_console', 'App : %s', APP_DIR)); $this->out(__d('cake_console', 'Path: %s', APP)); $this->hr(); }
/** * Run all upgrade steps one at a time * * @return void */ public function all() { foreach ($this->OptionParser->subcommands() as $command) { $name = $command->name(); if ($name === 'all' || $name === 'group') { continue; } $version = (double) Configure::version(); if ($version < 2.5 && $name === 'cake25' || $version < 3.0 && $name === 'cake30') { $this->out('Skipping command ' . $name); continue; } if (!empty($this->params['interactive'])) { $continue = $this->in('Continue with `' . $name . '`?', array('y', 'n', 'q'), 'y'); if ($continue === 'q') { return $this->error('Aborted'); } if ($continue === 'n') { $this->out('Skipping command ' . $name); continue; } } $this->out(__d('cake_console', 'Running %s', $name)); $this->{$name}(); } }