mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merging fixes to trunk
Revision: [1815] Adding the path.php require back, and removing the code that was in the path.php file. Revision: [1814] More work on Model. Removed all code from app/webroot/index.php that is moved to the bootstrap file. Added CAKE_SESSION_TIMEOUT define in app/config/core.php Revision: [1813] Adding a bootstrap file to remove need to edit index.php anymore git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1816 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
6d17d0d608
commit
9ca1ce91d8
10 changed files with 183 additions and 131 deletions
|
@ -6,4 +6,4 @@
|
|||
// +---------------------------------------------------------------------------------------------------+ //
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
0.10.5.1810 RC 1
|
||||
0.10.6.1816 RC 1
|
|
@ -65,6 +65,17 @@ define('CAKE_SESSION_COOKIE', 'CAKEPHP');
|
|||
*/
|
||||
define('CAKE_SECURITY', 'high');
|
||||
|
||||
/**
|
||||
* Set Cake Session time out.
|
||||
* If CAKE_SECURITY define is set
|
||||
* high: multiplied by 10
|
||||
* medium: is multiplied by 100
|
||||
* low is: multiplied by 300
|
||||
*
|
||||
* Number below is seconds.
|
||||
*/
|
||||
define('CAKE_SESSION_TIMEOUT', '120');
|
||||
|
||||
/**
|
||||
* Set a random string of used in session.
|
||||
*
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
/* SVN FILE: $Id$ */
|
||||
|
||||
/**
|
||||
* The main "loop"
|
||||
* Short description for file.
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
|
@ -34,18 +34,11 @@
|
|||
*/
|
||||
if (!defined('DS'))
|
||||
{
|
||||
/**
|
||||
* Enter description here...
|
||||
*/
|
||||
define('DS', DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
if (!defined('ROOT'))
|
||||
{
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
*/
|
||||
define('ROOT', dirname(dirname(dirname(__FILE__))).DS);
|
||||
}
|
||||
|
||||
|
@ -58,88 +51,5 @@ if (!defined('WEBROOT_DIR'))
|
|||
{
|
||||
define ('WEBROOT_DIR', basename(dirname(__FILE__)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Configuration, directory layout and standard libraries
|
||||
*/
|
||||
require_once ROOT.'cake'.DS.'basics.php';
|
||||
require_once ROOT.APP_DIR.DS.'config'.DS.'core.php';
|
||||
require_once ROOT.'cake'.DS.'config'.DS.'paths.php';
|
||||
require_once LIBS.'object.php';
|
||||
require_once LIBS.'session.php';
|
||||
require_once LIBS.'security.php';
|
||||
require_once LIBS.'neat_array.php';
|
||||
require_once LIBS.'inflector.php';
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
*/
|
||||
|
||||
if (empty($uri) && defined('BASE_URL'))
|
||||
{
|
||||
$uri = setUri();
|
||||
if ($uri === '/' || $uri === '/index.php' || $uri === '/app/')
|
||||
{
|
||||
$_GET['url'] = '/';
|
||||
$url = '/';
|
||||
}
|
||||
else
|
||||
{
|
||||
$elements = explode('/index.php', $uri);
|
||||
if(!empty($elements[1]))
|
||||
{
|
||||
$_GET['url'] = $elements[1];
|
||||
$url = $elements[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
$_GET['url'] = '/';
|
||||
$url = '/';
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$url = empty($_GET['url'])? null: $_GET['url'];
|
||||
}
|
||||
|
||||
|
||||
if (strpos($url, 'ccss/') === 0)
|
||||
{
|
||||
include WWW_ROOT.DS.'css.php';
|
||||
die();
|
||||
}
|
||||
|
||||
|
||||
DEBUG? error_reporting(E_ALL): error_reporting(0);
|
||||
if (DEBUG)
|
||||
{
|
||||
ini_set('display_errors', 1);
|
||||
}
|
||||
|
||||
$TIME_START = getMicrotime();
|
||||
|
||||
require_once CAKE.'dispatcher.php';
|
||||
require_once LIBS.'model'.DS.'connection_manager.php';
|
||||
|
||||
config('database');
|
||||
|
||||
if (class_exists('DATABASE_CONFIG') && !class_exists('AppModel'))
|
||||
{
|
||||
require_once LIBS.'model'.DS.'model.php';
|
||||
loadModels();
|
||||
}
|
||||
|
||||
//RUN THE SCRIPT
|
||||
if(isset($_GET['url']) && $_GET['url'] === 'favicon.ico')
|
||||
{
|
||||
}else{
|
||||
$Dispatcher= new Dispatcher ();
|
||||
$Dispatcher->dispatch($url);
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
echo "<!-- ". round(getMicrotime() - $TIME_START, 2) ."s -->";
|
||||
}
|
||||
require_once ROOT.'cake'.DS.'bootstrap.php';
|
||||
?>
|
128
cake/bootstrap.php
Normal file
128
cake/bootstrap.php
Normal file
|
@ -0,0 +1,128 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
|
||||
/**
|
||||
* Basic Cake functionality.
|
||||
*
|
||||
* Core functions for including other source files, loading models and so forth.
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||
* Copyright (c) 2005, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright (c) 2005, Cake Software Foundation, Inc.
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||
* @package cake
|
||||
* @subpackage cake.cake
|
||||
* @since CakePHP v 0.2.9
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Configuration, directory layout and standard libraries
|
||||
*/
|
||||
require_once ROOT.'cake'.DS.'basics.php';
|
||||
require_once ROOT.APP_DIR.DS.'config'.DS.'core.php';
|
||||
require_once ROOT.'cake'.DS.'config'.DS.'paths.php';
|
||||
require_once LIBS.'object.php';
|
||||
require_once LIBS.'session.php';
|
||||
require_once LIBS.'security.php';
|
||||
require_once LIBS.'neat_array.php';
|
||||
require_once LIBS.'inflector.php';
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
*/
|
||||
if (empty($uri) && defined('BASE_URL'))
|
||||
{
|
||||
$uri = setUri();
|
||||
if ($uri === '/' || $uri === '/index.php' || $uri === '/app/')
|
||||
{
|
||||
$_GET['url'] = '/';
|
||||
$url = '/';
|
||||
}
|
||||
else
|
||||
{
|
||||
$elements = explode('/index.php', $uri);
|
||||
if(!empty($elements[1]))
|
||||
{
|
||||
$_GET['url'] = $elements[1];
|
||||
$url = $elements[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
$_GET['url'] = '/';
|
||||
$url = '/';
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(empty($_GET['url']))
|
||||
{
|
||||
$url = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
$url = $_GET['url'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (strpos($url, 'ccss/') === 0)
|
||||
{
|
||||
include WWW_ROOT.DS.'css.php';
|
||||
die();
|
||||
}
|
||||
|
||||
|
||||
if (DEBUG)
|
||||
{
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
error_reporting(0);
|
||||
}
|
||||
|
||||
$TIME_START = getMicrotime();
|
||||
|
||||
require_once CAKE.'dispatcher.php';
|
||||
require_once LIBS.'model'.DS.'connection_manager.php';
|
||||
|
||||
config('database');
|
||||
|
||||
if (class_exists('DATABASE_CONFIG') && !class_exists('AppModel'))
|
||||
{
|
||||
require_once LIBS.'model'.DS.'model.php';
|
||||
loadModels();
|
||||
}
|
||||
|
||||
if(isset($_GET['url']) && $_GET['url'] === 'favicon.ico')
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
$Dispatcher= new Dispatcher ();
|
||||
$Dispatcher->dispatch($url);
|
||||
}
|
||||
|
||||
if (DEBUG)
|
||||
{
|
||||
echo "<!-- ". round(getMicrotime() - $TIME_START, 2) ."s -->";
|
||||
}
|
||||
?>
|
|
@ -340,8 +340,16 @@ class DataSource extends Object
|
|||
{
|
||||
case '{$__cake_id__$}':
|
||||
$val = null;
|
||||
if (isset($data[$index][$model->name])) {
|
||||
$val = $data[$index][$model->name][$model->primaryKey];
|
||||
if (isset($data[$index][$model->name]))
|
||||
{
|
||||
if(isset($data[$index][$model->name][$model->primaryKey]))
|
||||
{
|
||||
$val = $data[$index][$model->name][$model->primaryKey];
|
||||
}
|
||||
else
|
||||
{
|
||||
$val = '';
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '{$__cake_foreignKey__$}':
|
||||
|
|
|
@ -462,7 +462,7 @@ class DboSource extends DataSource
|
|||
}
|
||||
else
|
||||
{
|
||||
if(isset($this->joinFieldJoin))
|
||||
if(isset($this->joinFieldJoin) && !isset($queryData['fields']))
|
||||
{
|
||||
$joinFields = ', ';
|
||||
$joinFields .= join(', ', $this->joinFieldJoin['fields']);
|
||||
|
@ -714,10 +714,10 @@ class DboSource extends DataSource
|
|||
{
|
||||
$data['conditions'] = ' 1 ';
|
||||
}
|
||||
// if (!isset($data['fields']))
|
||||
// {
|
||||
// $data['fields'] = '*';
|
||||
// }
|
||||
if (!isset($data['fields']))
|
||||
{
|
||||
$data['fields'] = '';
|
||||
}
|
||||
if (!isset($data['joins']))
|
||||
{
|
||||
$data['joins'] = array();
|
||||
|
@ -754,7 +754,6 @@ class DboSource extends DataSource
|
|||
}
|
||||
else
|
||||
{
|
||||
//$fields = array('*');
|
||||
foreach ($model->_tableInfo->value as $field)
|
||||
{
|
||||
$fields[]= $field['name'];
|
||||
|
|
|
@ -621,7 +621,7 @@ class Model extends Object
|
|||
* @param mixed $fields String of single fieldname, or an array of fieldnames.
|
||||
* @return array Array of database fields
|
||||
*/
|
||||
function read ($id = null, $fields = null)
|
||||
function read ($fields = null, $id = null)
|
||||
{
|
||||
$this->validationErrors = null;
|
||||
if ($id != null)
|
||||
|
@ -950,7 +950,7 @@ class Model extends Object
|
|||
*/
|
||||
function find ($conditions = null, $fields = null, $order = null, $recursive = 1)
|
||||
{
|
||||
$data = $this->findAll($conditions, $fields, $order, 1, $recursive);
|
||||
$data = $this->findAll($conditions, $fields, $order, 1, null, $recursive);
|
||||
if (empty($data[0]))
|
||||
{
|
||||
return false;
|
||||
|
@ -1068,9 +1068,9 @@ class Model extends Object
|
|||
* @param string $conditions SQL conditions (WHERE clause conditions)
|
||||
* @return int Number of matching rows
|
||||
*/
|
||||
function findCount ($conditions = null)
|
||||
function findCount ($conditions = null, $recursive = 0)
|
||||
{
|
||||
list($data) = $this->findAll($conditions, 'COUNT(*) AS count', null, null, 1, 0);
|
||||
list($data) = $this->findAll($conditions, 'COUNT(*) AS count', null, null, 1, $recursive);
|
||||
if (isset($data[0]['count']))
|
||||
{
|
||||
return $data[0]['count'];
|
||||
|
|
|
@ -618,7 +618,7 @@ class Model extends Object
|
|||
* @param mixed $fields String of single fieldname, or an array of fieldnames.
|
||||
* @return array Array of database fields
|
||||
*/
|
||||
function read ($id = null, $fields = null)
|
||||
function read ($fields = null, $id = null)
|
||||
{
|
||||
$this->validationErrors = null;
|
||||
if ($id != null)
|
||||
|
@ -947,7 +947,7 @@ class Model extends Object
|
|||
*/
|
||||
function find ($conditions = null, $fields = null, $order = null, $recursive = 1)
|
||||
{
|
||||
$data = $this->findAll($conditions, $fields, $order, 1, $recursive);
|
||||
$data = $this->findAll($conditions, $fields, $order, 1, null, $recursive);
|
||||
if (empty($data[0]))
|
||||
{
|
||||
return false;
|
||||
|
@ -1065,9 +1065,9 @@ class Model extends Object
|
|||
* @param string $conditions SQL conditions (WHERE clause conditions)
|
||||
* @return int Number of matching rows
|
||||
*/
|
||||
function findCount ($conditions = null)
|
||||
function findCount ($conditions = null, $recursive = 0)
|
||||
{
|
||||
list($data) = $this->findAll($conditions, 'COUNT(*) AS count', null, null, 1, 0);
|
||||
list($data) = $this->findAll($conditions, 'COUNT(*) AS count', null, null, 1, $recursive);
|
||||
if (isset($data[0]['count']))
|
||||
{
|
||||
return $data[0]['count'];
|
||||
|
|
|
@ -3,20 +3,20 @@
|
|||
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||
* Copyright (c) 2005, Cake Software Foundation, Inc.
|
||||
* Copyright (c) 2005, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @filesource
|
||||
* @copyright Copyright (c) 2005, Cake Software Foundation, Inc.
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||
* @package cake
|
||||
|
@ -30,7 +30,7 @@
|
|||
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* @package cake
|
||||
|
@ -39,18 +39,18 @@
|
|||
*/
|
||||
class Security extends Object
|
||||
{
|
||||
|
||||
|
||||
function &getInstance()
|
||||
{
|
||||
static $instance = array();
|
||||
|
||||
|
||||
if (!$instance)
|
||||
{
|
||||
$instance[0] =& new Security;
|
||||
}
|
||||
return $instance[0];
|
||||
}
|
||||
|
||||
|
||||
function inactiveMins()
|
||||
{
|
||||
$security =& Security::getInstance();
|
||||
|
@ -60,27 +60,27 @@ class Security extends Object
|
|||
return 10;
|
||||
break;
|
||||
case 'medium':
|
||||
return 20;
|
||||
return 100;
|
||||
break;
|
||||
case 'low':
|
||||
default :
|
||||
return 30;
|
||||
return 300;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function generateAuthKey()
|
||||
{
|
||||
|
||||
|
||||
return $authKey;
|
||||
}
|
||||
|
||||
|
||||
function validateAuthKey($authKey)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function hash($string, $type='sha1')
|
||||
{
|
||||
$type = strtolower($type);
|
||||
|
@ -111,7 +111,7 @@ class Security extends Object
|
|||
return md5($string);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function cipher($text, $key)
|
||||
{
|
||||
if (!defined('CIPHER_SEED'))
|
||||
|
@ -120,7 +120,7 @@ class Security extends Object
|
|||
define('CIPHER_SEED', 'mKEZGy8AB8FErX4t');
|
||||
}
|
||||
srand(CIPHER_SEED);
|
||||
|
||||
|
||||
$out = '';
|
||||
for($i = 0; $i < strlen($text); $i++)
|
||||
{
|
||||
|
@ -128,7 +128,7 @@ class Security extends Object
|
|||
{
|
||||
$toss = rand(0, 255);
|
||||
}
|
||||
|
||||
|
||||
$mask = rand(0, 255);
|
||||
$out .= chr(ord(substr($text, $i, 1)) ^ $mask);
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ class CakeSession extends Object
|
|||
}
|
||||
|
||||
$this->time = time();
|
||||
$this->sessionTime = $this->time + (Security::inactiveMins() * 60);
|
||||
$this->sessionTime = $this->time + (Security::inactiveMins() * CAKE_SESSION_TIMEOUT);
|
||||
$this->security = CAKE_SECURITY;
|
||||
$this->_initSession();
|
||||
$this->_begin();
|
||||
|
@ -370,7 +370,6 @@ class CakeSession extends Object
|
|||
ini_set('session.cookie_lifetime', $this->cookieLifeTime);
|
||||
ini_set('session.cookie_path', $this->path);
|
||||
ini_set('session.gc_probability', 1);
|
||||
ini_set('session.gc_maxlifetime', Security::inactiveMins() * 60);
|
||||
ini_set('session.auto_start', 0);
|
||||
ini_set('session.save_path', TMP.'sessions');
|
||||
break;
|
||||
|
@ -384,7 +383,6 @@ class CakeSession extends Object
|
|||
ini_set('session.cookie_lifetime', $this->cookieLifeTime);
|
||||
ini_set('session.cookie_path', $this->path);
|
||||
ini_set('session.gc_probability', 1);
|
||||
ini_set('session.gc_maxlifetime', Security::inactiveMins() * 60);
|
||||
ini_set('session.auto_start', 0);
|
||||
session_set_save_handler(array('CakeSession', '_open'),
|
||||
array('CakeSession', '_close'),
|
||||
|
@ -398,7 +396,6 @@ class CakeSession extends Object
|
|||
ini_set('session.cookie_lifetime', $this->cookieLifeTime);
|
||||
ini_set('session.cookie_path', $this->path);
|
||||
ini_set('session.gc_probability', 1);
|
||||
ini_set('session.gc_maxlifetime', Security::inactiveMins() * 60);
|
||||
break;
|
||||
default :
|
||||
$config = CONFIGS.CAKE_SESSION_SAVE.'.php';
|
||||
|
@ -412,7 +409,6 @@ class CakeSession extends Object
|
|||
ini_set('session.cookie_lifetime', $this->cookieLifeTime);
|
||||
ini_set('session.cookie_path', $this->path);
|
||||
ini_set('session.gc_probability', 1);
|
||||
ini_set('session.gc_maxlifetime', Security::inactiveMins() * 60);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue