Exemplo n.º 1
0
 function index()
 {
     echo Configure::version();
     header("X-XSS-Protection: 0");
     $words = array('a' => 'apple');
     $param = $_GET["param"];
     $this->set('data', $words[$param]);
 }
 /**
  * @return void
  */
 public function testPatchOptionalNotNull()
 {
     $this->skipIf(version_compare(Configure::version(), '3.3.7') <= 0);
     $data = ['string_optional_notnull' => '', 'active_optional_notnull' => ''];
     $entity = $this->Table->newEntity($data);
     $expected = ['string_optional_notnull' => '', 'active_optional_notnull' => false];
     $this->assertSame($expected, $entity->toArray());
 }
 public function testCompositeConstraintsSnapshot()
 {
     $this->skipIf(version_compare(Configure::version(), '3.0.8', '<'), 'Cannot run "testCompositeConstraintsSnapshot" because CakePHP Core feature' . 'is not implemented in this version');
     $this->loadFixtures('Orders');
     $this->Task->params['require-table'] = false;
     $this->Task->params['connection'] = 'test';
     $result = $this->Task->bake('CompositeConstraintsSnapshot');
     $this->assertSameAsFile(__FUNCTION__ . '.php', $result);
 }
Exemplo n.º 4
0
 /**
  * Constructor.
  *
  * @param string $package Package name as string. e.g. `vendor-name/package-name`
  * @param string $path Full path to package's root directory
  * @param string $version Package version number
  */
 public function __construct($package, $path, $version = null)
 {
     $this->_packageName = $package;
     list($this->_vendor, $this->_name) = packageSplit($this->_packageName);
     $this->_version = $version;
     $this->_path = $path;
     if (strtolower($this->_packageName) === 'cakephp/cakephp') {
         $this->_version = Configure::version();
     } elseif (strtolower($this->_packageName) === 'quickapps/cms') {
         $this->_version = quickapps('version');
     }
 }
Exemplo n.º 5
0
 /**
  * Get necessary data about environment to pass back to controller
  *
  * @param \Cake\Controller\Controller $controller The controller.
  * @return array
  */
 protected function _prepare(Controller $controller)
 {
     $return = [];
     // PHP Data
     $phpVer = phpversion();
     $return['php'] = array_merge(['PHP_VERSION' => $phpVer], $_SERVER);
     unset($return['php']['argv']);
     // CakePHP Data
     $return['cake'] = ['APP' => APP, 'APP_DIR' => APP_DIR, 'CACHE' => CACHE, 'CAKE' => CAKE, 'CAKE_CORE_INCLUDE_PATH' => CAKE_CORE_INCLUDE_PATH, 'CORE_PATH' => CORE_PATH, 'CAKE_VERSION' => Configure::version(), 'DS' => DS, 'LOGS' => LOGS, 'ROOT' => ROOT, 'TESTS' => TESTS, 'TMP' => TMP, 'WWW_ROOT' => WWW_ROOT];
     $cakeConstants = array_fill_keys(['DS', 'ROOT', 'TIME_START', 'SECOND', 'MINUTE', 'HOUR', 'DAY', 'WEEK', 'MONTH', 'YEAR'], '');
     $var = get_defined_constants(true);
     $return['app'] = array_diff_key($var['user'], $return['cake'], $cakeConstants);
     if (isset($var['hidef'])) {
         $return['hidef'] = $var['hidef'];
     }
     return $return;
 }
Exemplo n.º 6
0
 /**
  * Main function Prints out the list of shells.
  *
  * @return void
  */
 public function main()
 {
     if (!$this->param('xml') && !$this->param('version')) {
         $this->out("<info>Current Paths:</info>", 2);
         $this->out("* app:  " . APP_DIR);
         $this->out("* root: " . rtrim(ROOT, DIRECTORY_SEPARATOR));
         $this->out("* core: " . rtrim(CORE_PATH, DIRECTORY_SEPARATOR));
         $this->out("");
         $this->out("<info>Available Shells:</info>", 2);
     }
     if ($this->param('version')) {
         $this->out(Configure::version());
         return;
     }
     $shellList = $this->Command->getShellList();
     if (!$shellList) {
         return;
     }
     if (!$this->param('xml')) {
         $this->_asText($shellList);
     } else {
         $this->_asXml($shellList);
     }
 }
 /**
  * Test cake2.4 passwordHasher feature
  *
  * @return void
  */
 public function testPasswordHasher()
 {
     $this->skipIf((double) Configure::version() < 2.4, 'Needs 2.4 and above');
     $this->Users->addBehavior('Tools.Passwordable', ['formField' => 'pwd', 'formFieldRepeat' => 'pwd_repeat', 'allowSame' => false, 'current' => false, 'passwordHasher' => 'Complex']);
     $user = $this->Users->newEntity();
     $data = ['pwd' => 'somepwd', 'pwd_repeat' => 'somepwd'];
     $this->Users->patchEntity($user, $data);
     $result = $this->Users->save($user);
     $this->assertTrue((bool) $result);
     $uid = (string) $user->id;
     $this->Users->removeBehavior('Passwordable');
     $this->Users->addBehavior('Tools.Passwordable', ['current' => true]);
     $user = $this->Users->newEntity();
     $data = ['id' => $uid, 'pwd' => '123456', 'pwd_repeat' => '12345678'];
     $this->Users->patchEntity($user, $data);
     $this->assertTrue($this->Users->behaviors()->has('Passwordable'));
     $is = $this->Users->save($user);
     $this->assertFalse($is);
     $user = $this->Users->newEntity();
     $data = ['id' => $uid, 'pwd_current' => 'somepwdx', 'pwd' => '123456', 'pwd_repeat' => '123456'];
     $this->Users->patchEntity($user, $data);
     $is = $this->Users->save($user);
     $this->assertFalse($is);
     $user = $this->Users->newEntity();
     $data = ['id' => $uid, 'pwd_current' => 'somepwd', 'pwd' => '123456', 'pwd_repeat' => '123456'];
     $this->Users->patchEntity($user, $data);
     $is = $this->Users->save($user);
     $this->assertTrue(!empty($is));
 }
Exemplo n.º 8
0
 /**
  * testVersion method
  *
  * @return void
  */
 public function testVersion()
 {
     $result = Configure::version();
     $this->assertTrue(version_compare($result, '1.2', '>='));
 }
Exemplo n.º 9
0
 /**
  * test that main prints the cakephp's version.
  *
  * @return void
  */
 public function testMainVersion()
 {
     $this->Shell->params['version'] = true;
     $this->Shell->main();
     $output = $this->out->messages();
     $output = implode("\n", $output);
     $expected = Configure::version();
     $this->assertEquals($expected, $output);
 }
Exemplo n.º 10
0
 /**
  * Displays a header for the shell
  *
  * @return void
  */
 protected function _welcome()
 {
     $this->out();
     $this->out(sprintf('<info>Welcome to CakePHP %s Console</info>', 'v' . Configure::version()));
     $this->hr();
     $this->out(sprintf('App : %s', APP_DIR));
     $this->out(sprintf('Path: %s', APP));
     $this->out(sprintf('DocumentRoot: %s', $this->_documentRoot));
     if (!empty($this->_iniFile)) {
         $this->out(sprintf('php.ini FilePath: %s', $this->_iniFile));
     }
     $this->hr();
 }
Exemplo n.º 11
0
 /**
  * System checkup
  * @return void
  * @uses MeCms\Core\Plugin::all()
  * @uses MeCms\Core\Plugin::path()
  * @uses MeTools\Utility\Apache::module()
  * @uses MeTools\Utility\Apache::version()
  */
 public function checkup()
 {
     $checkup['apache'] = ['expires' => Apache::module('mod_expires'), 'rewrite' => Apache::module('mod_rewrite'), 'version' => Apache::version()];
     $checkup['backups'] = ['path' => rtr(Configure::read('MysqlBackup.target') . DS), 'writeable' => folderIsWriteable(Configure::read('MysqlBackup.target'))];
     $checkup['cache'] = Cache::enabled();
     //Checks for PHP's extensions
     foreach (['exif', 'imagick', 'mcrypt', 'zip'] as $extension) {
         $checkup['phpExtensions'][$extension] = extension_loaded($extension);
     }
     $checkup['plugins'] = ['cakephp' => Configure::version(), 'mecms' => trim(file_get_contents(Plugin::path(MECMS, 'version')))];
     //Gets plugins versions
     foreach (Plugin::all(['exclude' => MECMS]) as $plugin) {
         $file = Plugin::path($plugin, 'version', true);
         if ($file) {
             $checkup['plugins']['plugins'][$plugin] = trim(file_get_contents($file));
         } else {
             $checkup['plugins']['plugins'][$plugin] = __d('me_cms', 'n.a.');
         }
     }
     //Checks for temporary directories
     foreach ([LOGS, TMP, Configure::read('Assets.target'), CACHE, LOGIN_LOGS, Configure::read('Thumbs.target')] as $path) {
         $checkup['temporary'][] = ['path' => rtr($path), 'writeable' => folderIsWriteable($path)];
     }
     //Checks for webroot directories
     foreach ([BANNERS, PHOTOS, WWW_ROOT . 'files', WWW_ROOT . 'fonts'] as $path) {
         $checkup['webroot'][] = ['path' => rtr($path), 'writeable' => folderIsWriteable($path)];
     }
     array_walk($checkup, function ($value, $key) {
         $this->set($key, $value);
     });
 }
Exemplo n.º 12
0
 /**
  * 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->out(__d('cake_console', 'DocumentRoot: %s', $this->_documentRoot));
     $this->hr();
 }
Exemplo n.º 13
0
 /**
  * Override Cake\Console\Shell method to return different welcome screen.
  *
  * @return void
  */
 protected function _welcome()
 {
     $this->hr();
     $this->out(sprintf('<info>CakePHP %s Console</info>', 'v' . Configure::version()));
     $this->hr();
 }
Exemplo n.º 14
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);
 }
Exemplo n.º 15
0
 /**
  * Show custom welcome.
  *
  * @return void
  */
 public function startup()
 {
     $this->hr();
     $this->out(sprintf('<info>CakePHP %s Console</info>', 'v' . Configure::version()));
     $this->hr();
 }
Exemplo n.º 16
0
 public function rorderHome()
 {
     echo Configure::version();
     return;
 }
Exemplo n.º 17
0
 /**
  * Displays a header for the shell
  *
  * @return void
  */
 protected function _welcome()
 {
     $this->out();
     $this->out(sprintf('<info>Welcome to CakePHP %s Console</info>', 'v' . Configure::version()));
     $this->hr();
     $this->out(sprintf('App : %s', APP_DIR));
     $this->out(sprintf('Path: %s', APP));
     $this->out(sprintf('PHP : %s', phpversion()));
     $this->hr();
 }
Exemplo n.º 18
0
 /**
  * Asserts the expected CakePHP version.
  *
  * @param string $ver Expected version.
  * @param string $operator Comparison to run, defaults to greater or equal.
  * @
  */
 public function expectedCakePHPVersion($ver, $operator = 'ge')
 {
     $this->assertTrue(version_compare($ver, Configure::version(), $operator));
 }