mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
[1285]
Author: phpnut Date: 10:09:03 PM, Monday, October 31, 2005 Message: Removed references in the Session class [1283] Author: phpnut Date: 8:47:37 PM, Monday, October 31, 2005 Message: Added fix to the Controller::constructClassess(). The database should have an instance available if a component will use it. [1282] Author: phpnut Date: 8:36:07 PM, Monday, October 31, 2005 Message: Updated the Model association methods to correct and error I introduced when reactoring last week. Added a return from each of the settings in Security::inactiveMins(); This class is not fully implemented. Updated scaffold and dipatcher with changes to the session class. Fixed problem with session not working properly. Added a regenrate id for sessions. When CAKE_SECURITY is set to high this will regenrate a new session key on each request. The old session file will be removed from the file system. This is a added security measure. [1270] Author: phpnut Date: 1:55:28 PM, Sunday, October 30, 2005 Message: Updated Session class to regenrate a new session key on each request when security level set to high. Updated doc comments in some classes [1269] Author: phpnut Date: 9:49:43 AM, Sunday, October 30, 2005 Message: Added a fix for Ticket #105 git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1286 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
30adcf8d0a
commit
67d156ef2b
27 changed files with 348 additions and 248 deletions
|
@ -9,8 +9,7 @@
|
||||||
; * CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
; * CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||||
; * Copyright (c) 2005, CakePHP Authors/Developers
|
; * Copyright (c) 2005, CakePHP Authors/Developers
|
||||||
; *
|
; *
|
||||||
; * Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
|
; * Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
|
||||||
; * Larry E. Masters aka PhpNut <nut@phpnut.com>
|
|
||||||
; * Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
; * Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
||||||
; *
|
; *
|
||||||
; * Licensed under The MIT License
|
; * Licensed under The MIT License
|
||||||
|
|
|
@ -11,8 +11,7 @@
|
||||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||||
* Copyright (c) 2005, CakePHP Authors/Developers
|
* Copyright (c) 2005, CakePHP Authors/Developers
|
||||||
*
|
*
|
||||||
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
|
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
|
||||||
* Larry E. Masters aka PhpNut <nut@phpnut.com>
|
|
||||||
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
||||||
*
|
*
|
||||||
* Licensed under The MIT License
|
* Licensed under The MIT License
|
||||||
|
|
|
@ -194,3 +194,10 @@ a:hover
|
||||||
padding: 0;
|
padding: 0;
|
||||||
border: 0;
|
border: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.message {
|
||||||
|
background-color: #E3FFD1;
|
||||||
|
border:1px solid #060;
|
||||||
|
padding:1em;
|
||||||
|
margin-bottom:1em;
|
||||||
|
}
|
||||||
|
|
|
@ -42,6 +42,19 @@ define('WEEK', 7 * DAY);
|
||||||
define('MONTH', 30 * DAY);
|
define('MONTH', 30 * DAY);
|
||||||
define('YEAR', 365 * DAY);
|
define('YEAR', 365 * DAY);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Patch for PHP < 4.3
|
||||||
|
*/
|
||||||
|
if (!function_exists("ob_get_clean"))
|
||||||
|
{
|
||||||
|
function ob_get_clean()
|
||||||
|
{
|
||||||
|
$ob_contents = ob_get_contents();
|
||||||
|
ob_end_clean();
|
||||||
|
return $ob_contents;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads all models.
|
* Loads all models.
|
||||||
*
|
*
|
||||||
|
@ -98,6 +111,7 @@ function loadControllers ()
|
||||||
*/
|
*/
|
||||||
function loadController ($name)
|
function loadController ($name)
|
||||||
{
|
{
|
||||||
|
$name = Inflector::underscore($name);
|
||||||
if(file_exists(CONTROLLERS.$name.'_controller.php'))
|
if(file_exists(CONTROLLERS.$name.'_controller.php'))
|
||||||
{
|
{
|
||||||
$controller_fn = CONTROLLERS.$name.'_controller.php';
|
$controller_fn = CONTROLLERS.$name.'_controller.php';
|
||||||
|
|
|
@ -189,7 +189,12 @@ define ('PEAR', VENDORS.'Pear'.DS);
|
||||||
/**
|
/**
|
||||||
* Full url prefix
|
* Full url prefix
|
||||||
*/
|
*/
|
||||||
define('FULL_BASE_URL', 'http://'.$_SERVER['HTTP_HOST']);
|
$s = null;
|
||||||
|
if ( (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] =='on' ))
|
||||||
|
{
|
||||||
|
$s ='s';
|
||||||
|
}
|
||||||
|
define('FULL_BASE_URL', 'http'.$s.'://'.$_SERVER['HTTP_HOST']);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Web path to the public images directory.
|
* Web path to the public images directory.
|
||||||
|
|
|
@ -182,9 +182,14 @@ class Dispatcher extends Object
|
||||||
$controller->autoLayout = !$params['bare'];
|
$controller->autoLayout = !$params['bare'];
|
||||||
$controller->autoRender = !$params['render'];
|
$controller->autoRender = !$params['render'];
|
||||||
|
|
||||||
|
if(!defined('AUTO_SESSION') || AUTO_SESSION == true)
|
||||||
|
{
|
||||||
|
array_push($controller->components, 'Session');
|
||||||
|
}
|
||||||
|
|
||||||
if((in_array('scaffold', array_keys($classVars))) && ($missingAction === true))
|
if((in_array('scaffold', array_keys($classVars))) && ($missingAction === true))
|
||||||
{
|
{
|
||||||
$scaffolding =& new Scaffold($controller, $params);
|
$scaffolding = new Scaffold($controller, $params);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,8 +208,11 @@ class Dispatcher extends Object
|
||||||
}
|
}
|
||||||
if(!defined('AUTO_SESSION') || AUTO_SESSION == true)
|
if(!defined('AUTO_SESSION') || AUTO_SESSION == true)
|
||||||
{
|
{
|
||||||
session_write_close();
|
if (function_exists('session_write_close'))
|
||||||
$session =& CakeSession::getInstance($this->base);
|
{
|
||||||
|
session_write_close();
|
||||||
|
}
|
||||||
|
$session = CakeSession::getInstance($this->base);
|
||||||
}
|
}
|
||||||
return $this->_invoke($controller, $params );
|
return $this->_invoke($controller, $params );
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,7 @@
|
||||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||||
* Copyright (c) 2005, CakePHP Authors/Developers
|
* Copyright (c) 2005, CakePHP Authors/Developers
|
||||||
*
|
*
|
||||||
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
|
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
|
||||||
* Larry E. Masters aka PhpNut <nut@phpnut.com>
|
|
||||||
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
|
||||||
*
|
*
|
||||||
* Licensed under The MIT License
|
* Licensed under The MIT License
|
||||||
* Redistributions of files must retain the above copyright notice.
|
* Redistributions of files must retain the above copyright notice.
|
||||||
|
|
|
@ -9,9 +9,7 @@
|
||||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||||
* Copyright (c) 2005, CakePHP Authors/Developers
|
* Copyright (c) 2005, CakePHP Authors/Developers
|
||||||
*
|
*
|
||||||
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
|
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
|
||||||
* Larry E. Masters aka PhpNut <nut@phpnut.com>
|
|
||||||
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
|
||||||
*
|
*
|
||||||
* Licensed under The MIT License
|
* Licensed under The MIT License
|
||||||
* Redistributions of files must retain the above copyright notice.
|
* Redistributions of files must retain the above copyright notice.
|
||||||
|
|
|
@ -109,7 +109,7 @@ class SessionComponent extends Object
|
||||||
*
|
*
|
||||||
* Use like this. $this->Session->error();
|
* Use like this. $this->Session->error();
|
||||||
*
|
*
|
||||||
* @return unknown
|
* @return string Last session error
|
||||||
*/
|
*/
|
||||||
function error()
|
function error()
|
||||||
{
|
{
|
||||||
|
@ -119,10 +119,44 @@ class SessionComponent extends Object
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* Use like this. $this->Session->valid();
|
* Use like this. $this->Session->setError();
|
||||||
*
|
*
|
||||||
* @param unknown_type $name
|
* @return string Last session error
|
||||||
* @return unknown
|
*/
|
||||||
|
function setFlash($flashMessage)
|
||||||
|
{
|
||||||
|
$this->write('Message.flash', $flashMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enter description here...
|
||||||
|
*
|
||||||
|
* Use like this. $this->Session->setError();
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
function flash()
|
||||||
|
{
|
||||||
|
if($this->check('Message.flash'))
|
||||||
|
{
|
||||||
|
echo '<div class="message">'.$this->read('Message.flash').'</div>';
|
||||||
|
$this->del('Message.flash');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enter description here...
|
||||||
|
*
|
||||||
|
* Use like this. $this->Session->valid();
|
||||||
|
* This will return true if session is valid
|
||||||
|
* false if session is invalid
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function valid()
|
function valid()
|
||||||
{
|
{
|
||||||
|
|
|
@ -49,144 +49,136 @@ uses(DS.'controller'.DS.'component',DS.'model'.DS.'model', 'inflector', 'folder'
|
||||||
*/
|
*/
|
||||||
class Controller extends Object
|
class Controller extends Object
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Name of the controller.
|
* Name of the controller.
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $name = null;
|
var $name = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the current URL (for links etc.)
|
* Stores the current URL (for links etc.)
|
||||||
*
|
*
|
||||||
* @var string Current URL
|
* @var string Current URL
|
||||||
*/
|
*/
|
||||||
var $here = null;
|
var $here = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Action to be performed.
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $parent = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Action to be performed.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
var $action = null;
|
var $action = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of names of models the particular controller wants to use.
|
* An array of names of models the particular controller wants to use.
|
||||||
*
|
*
|
||||||
* @var mixed A single name as a string or a list of names as an array.
|
* @var mixed A single name as a string or a list of names as an array.
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
var $uses = false;
|
var $uses = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of names of built-in helpers to include.
|
* An array of names of built-in helpers to include.
|
||||||
*
|
*
|
||||||
* @var mixed A single name as a string or a list of names as an array.
|
* @var mixed A single name as a string or a list of names as an array.
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
var $helpers = array('Html');
|
var $helpers = array('Html');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
*/
|
*/
|
||||||
var $viewPath;
|
var $viewPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Variables for the view
|
* Variables for the view
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $_viewVars = array();
|
var $_viewVars = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Web page title
|
* Web page title
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $pageTitle = false;
|
var $pageTitle = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of model objects.
|
* An array of model objects.
|
||||||
*
|
*
|
||||||
* @var array Array of model objects.
|
* @var array Array of model objects.
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $modelNames = array();
|
var $modelNames = array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $base = null;
|
var $base = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Layout file to use (see /app/views/layouts/default.thtml)
|
* Layout file to use (see /app/views/layouts/default.thtml)
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $layout = 'default';
|
var $layout = 'default';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Automatically render the view (the dispatcher checks for this variable before running render())
|
* Automatically render the view (the dispatcher checks for this variable before running render())
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $autoRender = true;
|
var $autoRender = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $autoLayout = true;
|
var $autoLayout = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database configuration to use (see /config/database.php)
|
* Database configuration to use (see /config/database.php)
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $useDbConfig = 'default';
|
var $useDbConfig = 'default';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $beforeFilter = null;
|
var $beforeFilter = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
*/
|
*/
|
||||||
var $components = array();
|
var $components = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function __construct ()
|
function __construct ()
|
||||||
{
|
{
|
||||||
if($this->name === null)
|
if($this->name === null)
|
||||||
|
@ -205,11 +197,14 @@ class Controller extends Object
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function constructClasses(){
|
function constructClasses()
|
||||||
|
{
|
||||||
|
$dboFactory = DboFactory::getInstance($this->useDbConfig);
|
||||||
|
$this->db =& $dboFactory;
|
||||||
|
|
||||||
if (!empty($this->components))
|
if (!empty($this->components))
|
||||||
{
|
{
|
||||||
|
@ -246,9 +241,6 @@ class Controller extends Object
|
||||||
$id = $this->params['pass'];
|
$id = $this->params['pass'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$dboFactory = DboFactory::getInstance($this->useDbConfig);
|
|
||||||
$this->db =& $dboFactory;
|
|
||||||
|
|
||||||
if (class_exists($this->modelClass) && ($this->uses === false))
|
if (class_exists($this->modelClass) && ($this->uses === false))
|
||||||
{
|
{
|
||||||
$this->{$this->modelClass} =& new $this->modelClass($id);
|
$this->{$this->modelClass} =& new $this->modelClass($id);
|
||||||
|
@ -474,18 +466,6 @@ class Controller extends Object
|
||||||
$this->render('../errors/missingDatabase');
|
$this->render('../errors/missingDatabase');
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
// /**
|
|
||||||
// * Displays an error page to the user. Uses layouts/error.html to render the page.
|
|
||||||
// *
|
|
||||||
// * @param int $code Error code (for instance: 404)
|
|
||||||
// * @param string $name Name of the error (for instance: Not Found)
|
|
||||||
// * @param string $message Error message
|
|
||||||
// */
|
|
||||||
// function error ($code, $name, $message)
|
|
||||||
// {
|
|
||||||
// header ("HTTP/1.0 {$code} {$name}");
|
|
||||||
// print ($this->_render(VIEWS.'layouts/error.thtml', array('code'=>$code,'name'=>$name,'message'=>$message)));
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets data for this view. Will set title if the key "title" is in given $data array.
|
* Sets data for this view. Will set title if the key "title" is in given $data array.
|
||||||
|
@ -801,16 +781,16 @@ class Controller extends Object
|
||||||
{
|
{
|
||||||
list($modelName) = $relation;
|
list($modelName) = $relation;
|
||||||
|
|
||||||
$modelKey = Inflector::underscore($modelName);
|
$modelKeyM = Inflector::underscore($modelName);
|
||||||
$modelObject = new $modelName();
|
$modelObject = new $modelName();
|
||||||
|
|
||||||
if( $doCreateOptions )
|
if( $doCreateOptions )
|
||||||
{
|
{
|
||||||
$otherDisplayField = $modelObject->getDisplayField();
|
$otherDisplayField = $modelObject->getDisplayField();
|
||||||
$fieldNames[$modelKey]['model'] = $modelName;
|
$fieldNames[$modelKeyM]['model'] = $modelName;
|
||||||
$fieldNames[$modelKey]['prompt'] = "Related ".Inflector::humanize(Inflector::pluralize($modelName));
|
$fieldNames[$modelKeyM]['prompt'] = "Related ".Inflector::humanize(Inflector::pluralize($modelName));
|
||||||
$fieldNames[$modelKey]['type'] = "selectMultiple";
|
$fieldNames[$modelKeyM]['type'] = "selectMultiple";
|
||||||
$fieldNames[$modelKey]['tagName'] = $modelKey.'/'.$modelKey;
|
$fieldNames[$modelKeyM]['tagName'] = $modelName.'/'.$modelName;
|
||||||
|
|
||||||
foreach( $modelObject->findAll() as $pass )
|
foreach( $modelObject->findAll() as $pass )
|
||||||
{
|
{
|
||||||
|
@ -818,15 +798,15 @@ class Controller extends Object
|
||||||
{
|
{
|
||||||
if( $key == $modelName && isset( $value['id'] ) && isset( $value[$otherDisplayField] ) )
|
if( $key == $modelName && isset( $value['id'] ) && isset( $value[$otherDisplayField] ) )
|
||||||
{
|
{
|
||||||
$fieldNames[$modelKey]['options'][$value['id']] = $value[$otherDisplayField];
|
$fieldNames[$modelKeyM]['options'][$value['id']] = $value[$otherDisplayField];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( isset( $data[$model] ) )
|
if( isset( $data[$modelName] ) )
|
||||||
{
|
{
|
||||||
foreach( $data[$model] as $row )
|
foreach( $data[$modelName] as $key => $row )
|
||||||
{
|
{
|
||||||
$fieldNames[$modelKey]['selected'][$row['id']] = $row['id'];
|
$fieldNames[$modelKeyM]['selected'][$row['id']] = $row['id'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,7 @@
|
||||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||||
* Copyright (c) 2005, CakePHP Authors/Developers
|
* Copyright (c) 2005, CakePHP Authors/Developers
|
||||||
*
|
*
|
||||||
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
|
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
|
||||||
* Larry E. Masters aka PhpNut <nut@phpnut.com>
|
|
||||||
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
||||||
*
|
*
|
||||||
* Licensed under The MIT License
|
* Licensed under The MIT License
|
||||||
|
@ -210,11 +209,24 @@ class Scaffold extends Object {
|
||||||
|
|
||||||
if ($this->controllerClass->{$this->modelKey}->save($this->controllerClass->params['data']))
|
if ($this->controllerClass->{$this->modelKey}->save($this->controllerClass->params['data']))
|
||||||
{
|
{
|
||||||
|
if(is_object($this->controllerClass->Session))
|
||||||
|
{
|
||||||
|
$this->controllerClass->Session->setFlash('Your '.Inflector::humanize($this->modelKey).' has been saved.');
|
||||||
|
$this->controllerClass->redirect('/'.Inflector::underscore($this->controllerClass->viewPath));
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return $this->controllerClass->flash('Your '.Inflector::humanize($this->modelKey).' has been saved.', '/'.
|
return $this->controllerClass->flash('Your '.Inflector::humanize($this->modelKey).' has been saved.', '/'.
|
||||||
Inflector::underscore($this->controllerClass->viewPath) );
|
Inflector::underscore($this->controllerClass->viewPath) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if(is_object($this->controllerClass->Session))
|
||||||
|
{
|
||||||
|
$this->controllerClass->Session->setFlash('Please correct errors below');
|
||||||
|
}
|
||||||
$this->controllerClass->set('data', $this->controllerClass->params['data']);
|
$this->controllerClass->set('data', $this->controllerClass->params['data']);
|
||||||
$this->controllerClass->validateErrors($this->controllerClass->{$this->modelKey});
|
$this->controllerClass->validateErrors($this->controllerClass->{$this->modelKey});
|
||||||
return $this->controllerClass->render($this->actionView, '', LIBS.'controller'.DS.'templates'.DS.'scaffolds'.DS.'new.thtml');
|
return $this->controllerClass->render($this->actionView, '', LIBS.'controller'.DS.'templates'.DS.'scaffolds'.DS.'new.thtml');
|
||||||
|
@ -240,13 +252,31 @@ class Scaffold extends Object {
|
||||||
|
|
||||||
if ( $this->controllerClass->{$this->modelKey}->save())
|
if ( $this->controllerClass->{$this->modelKey}->save())
|
||||||
{
|
{
|
||||||
|
if(is_object($this->controllerClass->Session))
|
||||||
|
{
|
||||||
|
$this->controllerClass->Session->setFlash('Your '.Inflector::humanize($this->modelKey).' has been saved.', '/');
|
||||||
|
$this->controllerClass->redirect('/'.Inflector::underscore($this->controllerClass->viewPath));
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return $this->controllerClass->flash('The '.Inflector::humanize($this->modelKey).' has been updated.','/'.
|
return $this->controllerClass->flash('The '.Inflector::humanize($this->modelKey).' has been updated.','/'.
|
||||||
Inflector::underscore($this->controllerClass->viewPath));
|
Inflector::underscore($this->controllerClass->viewPath));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if(is_object($this->controllerClass->Session))
|
||||||
|
{
|
||||||
|
$this->controllerClass->Session->setFlash('The '.Inflector::humanize($this->modelKey).' has been updated.','/');
|
||||||
|
$this->controllerClass->redirect('/'.Inflector::underscore($this->controllerClass->viewPath));
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return $this->controllerClass->flash('There was an error updating the '.Inflector::humanize($this->modelKey),'/'.
|
return $this->controllerClass->flash('There was an error updating the '.Inflector::humanize($this->modelKey),'/'.
|
||||||
Inflector::underscore($this->controllerClass->viewPath));
|
Inflector::underscore($this->controllerClass->viewPath));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,13 +292,31 @@ class Scaffold extends Object {
|
||||||
$id = $params['pass'][0];
|
$id = $params['pass'][0];
|
||||||
if ($this->controllerClass->{$this->modelKey}->del($id))
|
if ($this->controllerClass->{$this->modelKey}->del($id))
|
||||||
{
|
{
|
||||||
|
if(is_object($this->controllerClass->Session))
|
||||||
|
{
|
||||||
|
$this->controllerClass->Session->setFlash('The '.Inflector::humanize($this->modelKey).' with id: '.$id.' has been deleted.', '/');
|
||||||
|
$this->controllerClass->redirect('/'.Inflector::underscore($this->controllerClass->viewPath));
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return $this->controllerClass->flash('The '.Inflector::humanize($this->modelKey).' with id: '.
|
return $this->controllerClass->flash('The '.Inflector::humanize($this->modelKey).' with id: '.
|
||||||
$id.' has been deleted.', '/'.Inflector::underscore($this->controllerClass->viewPath));
|
$id.' has been deleted.', '/'.Inflector::underscore($this->controllerClass->viewPath));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return $this->controllerClass->flash('There was an error deleting the '.Inflector::humanize($this->modelKey).' with the id '.
|
if(is_object($this->controllerClass->Session))
|
||||||
|
{
|
||||||
|
$this->controllerClass->Session->setFlash('There was an error deleting the '.Inflector::humanize($this->modelKey).' with the id '.$id, '/');
|
||||||
|
$this->controllerClass->redirect('/'.Inflector::underscore($this->controllerClass->viewPath));
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return $this->controllerClass->flash('There was an error deleting the '.Inflector::humanize($this->modelKey).' with the id '.
|
||||||
$id, '/'.Inflector::underscore($this->controllerClass->viewPath));
|
$id, '/'.Inflector::underscore($this->controllerClass->viewPath));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,8 +347,11 @@ class Scaffold extends Object {
|
||||||
$this->controllerClass->constructClasses();
|
$this->controllerClass->constructClasses();
|
||||||
if(!defined('AUTO_SESSION') || AUTO_SESSION == true)
|
if(!defined('AUTO_SESSION') || AUTO_SESSION == true)
|
||||||
{
|
{
|
||||||
session_write_close();
|
if (function_exists('session_write_close'))
|
||||||
$session =& CakeSession::getInstance();
|
{
|
||||||
|
session_write_close();
|
||||||
|
}
|
||||||
|
$session = CakeSession::getInstance($this->controllerClass->base);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($params['action'] === 'index' || $params['action'] === 'list' ||
|
if($params['action'] === 'index' || $params['action'] === 'list' ||
|
||||||
|
|
|
@ -9,8 +9,7 @@
|
||||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||||
* Copyright (c) 2005, CakePHP Authors/Developers
|
* Copyright (c) 2005, CakePHP Authors/Developers
|
||||||
*
|
*
|
||||||
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
|
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
|
||||||
* Larry E. Masters aka PhpNut <nut@phpnut.com>
|
|
||||||
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
||||||
*
|
*
|
||||||
* Licensed under The MIT License
|
* Licensed under The MIT License
|
||||||
|
@ -48,7 +47,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
echo "<li>".$html->linkTo('Delete '.Inflector::humanize($modelName), '/'.$this->viewPath.'/destroy/'.$data[$modelKey]['id'])."</li>";
|
echo "<li>".$html->linkTo('Delete '.Inflector::humanize($modelName), '/'.$this->viewPath.'/destroy/'.$data[$modelKey]['id'])."</li>";
|
||||||
echo "<li>".$html->linkTo('List '.Inflector::humanize($modelName), '/'.$this->viewPath.'/list')."</li>";
|
echo "<li>".$html->linkTo('List '.Inflector::humanize($modelName), '/'.$this->viewPath.'/index')."</li>";
|
||||||
foreach( $fieldNames as $field => $value ) {
|
foreach( $fieldNames as $field => $value ) {
|
||||||
if( isset( $value['foreignKey'] ) )
|
if( isset( $value['foreignKey'] ) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,8 +9,7 @@
|
||||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||||
* Copyright (c) 2005, CakePHP Authors/Developers
|
* Copyright (c) 2005, CakePHP Authors/Developers
|
||||||
*
|
*
|
||||||
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
|
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
|
||||||
* Larry E. Masters aka PhpNut <nut@phpnut.com>
|
|
||||||
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
||||||
*
|
*
|
||||||
* Licensed under The MIT License
|
* Licensed under The MIT License
|
||||||
|
|
|
@ -9,8 +9,7 @@
|
||||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||||
* Copyright (c) 2005, CakePHP Authors/Developers
|
* Copyright (c) 2005, CakePHP Authors/Developers
|
||||||
*
|
*
|
||||||
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
|
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
|
||||||
* Larry E. Masters aka PhpNut <nut@phpnut.com>
|
|
||||||
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
||||||
*
|
*
|
||||||
* Licensed under The MIT License
|
* Licensed under The MIT License
|
||||||
|
@ -41,7 +40,7 @@
|
||||||
?>
|
?>
|
||||||
<ul class='actions'>
|
<ul class='actions'>
|
||||||
<?php
|
<?php
|
||||||
echo "<li>".$html->linkTo('List '.Inflector::humanize($this->name), '/'.$this->viewPath.'/list')."</li>";
|
echo "<li>".$html->linkTo('List '.Inflector::humanize($this->name), '/'.$this->viewPath.'/index')."</li>";
|
||||||
|
|
||||||
?>
|
?>
|
||||||
</ul>
|
</ul>
|
|
@ -9,8 +9,7 @@
|
||||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||||
* Copyright (c) 2005, CakePHP Authors/Developers
|
* Copyright (c) 2005, CakePHP Authors/Developers
|
||||||
*
|
*
|
||||||
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
|
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
|
||||||
* Larry E. Masters aka PhpNut <nut@phpnut.com>
|
|
||||||
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
||||||
*
|
*
|
||||||
* Licensed under The MIT License
|
* Licensed under The MIT License
|
||||||
|
@ -80,7 +79,7 @@
|
||||||
<?php
|
<?php
|
||||||
echo "<li>".$html->linkTo('Edit '.Inflector::humanize($objModel->name), '/'.$this->viewPath.'/edit/'.$data[$objModel->tableToModel[$objModel->table]]['id'])."</li>";
|
echo "<li>".$html->linkTo('Edit '.Inflector::humanize($objModel->name), '/'.$this->viewPath.'/edit/'.$data[$objModel->tableToModel[$objModel->table]]['id'])."</li>";
|
||||||
echo "<li>".$html->linkTo('Delete '.Inflector::humanize($objModel->name), '/'.$this->viewPath.'/destroy/'.$data[$objModel->tableToModel[$objModel->table]]['id'])."</li>";
|
echo "<li>".$html->linkTo('Delete '.Inflector::humanize($objModel->name), '/'.$this->viewPath.'/destroy/'.$data[$objModel->tableToModel[$objModel->table]]['id'])."</li>";
|
||||||
echo "<li>".$html->linkTo('List '.Inflector::humanize($objModel->name), '/'.$this->viewPath.'/list')."</li>";
|
echo "<li>".$html->linkTo('List '.Inflector::humanize($objModel->name), '/'.$this->viewPath.'/index')."</li>";
|
||||||
echo "<li>".$html->linkTo('New '.Inflector::humanize($objModel->name), '/'.$this->viewPath.'/add')."</li>";
|
echo "<li>".$html->linkTo('New '.Inflector::humanize($objModel->name), '/'.$this->viewPath.'/add')."</li>";
|
||||||
foreach( $fieldNames as $field => $value ) {
|
foreach( $fieldNames as $field => $value ) {
|
||||||
if( isset( $value['foreignKey'] ) )
|
if( isset( $value['foreignKey'] ) )
|
||||||
|
|
|
@ -264,12 +264,11 @@ class DBO_MySQL extends DBO
|
||||||
{
|
{
|
||||||
$resultRow = array();
|
$resultRow = array();
|
||||||
$i =0;
|
$i =0;
|
||||||
|
|
||||||
foreach ($row as $index => $field)
|
foreach ($row as $index => $field)
|
||||||
{
|
{
|
||||||
list($table, $column) = $this->map[$index];
|
list($table, $column) = $this->map[$index];
|
||||||
$resultRow[Inflector::singularize($table)][$column] = $row[$index];
|
$resultRow[$table][$column] = $row[$index];
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
return $resultRow;
|
return $resultRow;
|
||||||
}
|
}
|
||||||
|
@ -278,6 +277,7 @@ class DBO_MySQL extends DBO
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -1111,6 +1111,7 @@ class Model extends Object
|
||||||
$data = $newValue;
|
$data = $newValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1211,9 +1212,9 @@ class Model extends Object
|
||||||
{
|
{
|
||||||
foreach ($value1 as $key2 => $value2)
|
foreach ($value1 as $key2 => $value2)
|
||||||
{
|
{
|
||||||
if($key2 === Inflector::singularize($this->table))
|
if($key2 === $this->name)
|
||||||
{
|
{
|
||||||
if( 0 == strncmp($key2, $this->{$model}->{$this->currentModel.'_foreignkey'}, strlen($key2)) )
|
if( 0 == strncmp($key2, $this->{$model}->{$this->currentModel.'_foreignkey'}, $key2) )
|
||||||
{
|
{
|
||||||
if(!empty ($value2['id']))
|
if(!empty ($value2['id']))
|
||||||
{
|
{
|
||||||
|
@ -1226,28 +1227,29 @@ class Model extends Object
|
||||||
$manyToManyConditions = $this->parseConditions($this->{$model}->{$this->currentModel.'_conditions'});
|
$manyToManyConditions = $this->parseConditions($this->{$model}->{$this->currentModel.'_conditions'});
|
||||||
$manyToManyOrder = $this->{$model}->{$this->currentModel.'_order'};
|
$manyToManyOrder = $this->{$model}->{$this->currentModel.'_order'};
|
||||||
|
|
||||||
$tmpSQL = "SELECT {$this->{$model}->{$this->currentModel.'_fields'}} FROM {$this->{$model}->table}
|
$tmpSQL = "SELECT {$this->{$model}->{$this->currentModel.'_fields'}} FROM {$this->{$model}->table} AS {$this->{$model}->name}
|
||||||
JOIN {$this->{$model}->{$this->currentModel.'_jointable'}}
|
JOIN {$this->{$model}->{$this->currentModel.'_jointable'}}
|
||||||
ON {$this->{$model}->{$this->currentModel.'_jointable'}}.
|
ON {$this->{$model}->{$this->currentModel.'_jointable'}}.
|
||||||
{$this->{$model}->{$this->currentModel.'_foreignkey'}} = '$value2[id]'
|
{$this->{$model}->{$this->currentModel.'_foreignkey'}} = '$value2[id]'
|
||||||
AND {$this->{$model}->{$this->currentModel.'_jointable'}}.
|
AND {$this->{$model}->{$this->currentModel.'_jointable'}}.
|
||||||
{$this->{$model}->{$this->currentModel.'_associationforeignkey'}} = {$this->{$model}->table} .id"
|
{$this->{$model}->{$this->currentModel.'_associationforeignkey'}} = {$this->{$model}->name} .id"
|
||||||
.($manyToManyConditions? " WHERE {$manyToManyConditions}":null)
|
.($manyToManyConditions? " WHERE {$manyToManyConditions}":null)
|
||||||
.($manyToManyOrder? " ORDER BY {$manyToManyOrder}": null);
|
.($manyToManyOrder? " ORDER BY {$manyToManyOrder}": null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$manyToManySelect[$this->{$model}->table] = $this->db->all($tmpSQL);
|
$manyToManySelect[$this->{$model}->name] = $this->db->all($tmpSQL);
|
||||||
}
|
}
|
||||||
if( !empty($manyToManySelect[$this->{$model}->table]) && is_array($manyToManySelect[$this->{$model}->table]))
|
if( !empty($manyToManySelect[$this->{$model}->name]) && is_array($manyToManySelect[$this->{$model}->name]))
|
||||||
{
|
{
|
||||||
$newKey = Inflector::singularize($this->{$model}->table);
|
$newKey = $this->{$model}->name;
|
||||||
foreach ($manyToManySelect[$this->{$model}->table] as $key => $value)
|
foreach ($manyToManySelect[$this->{$model}->name] as $key => $value)
|
||||||
{
|
{
|
||||||
$manyToManySelect1[$newKey][$key] = $value[$newKey];
|
$manyToManySelect1[$newKey][$key] = $value[$newKey];
|
||||||
}
|
}
|
||||||
$merged = array_merge_recursive($data[$count],$manyToManySelect1);
|
$merged = array_merge_recursive($data[$count],$manyToManySelect1);
|
||||||
$newdata[$count] = $merged;
|
$newdata[$count] = $merged;
|
||||||
unset( $manyToManySelect[$this->{$model}->table], $manyToManySelect1 );
|
unset( $manyToManySelect[$this->{$model}->name], $manyToManySelect1 );
|
||||||
}
|
}
|
||||||
if(!empty($newdata[$count]))
|
if(!empty($newdata[$count]))
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,9 +11,7 @@
|
||||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||||
* Copyright (c) 2005, CakePHP Authors/Developers
|
* Copyright (c) 2005, CakePHP Authors/Developers
|
||||||
*
|
*
|
||||||
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
|
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
|
||||||
* Larry E. Masters aka PhpNut <nut@phpnut.com>
|
|
||||||
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
|
||||||
*
|
*
|
||||||
* Licensed under The MIT License
|
* Licensed under The MIT License
|
||||||
* Redistributions of files must retain the above copyright notice.
|
* Redistributions of files must retain the above copyright notice.
|
||||||
|
|
|
@ -11,8 +11,7 @@
|
||||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||||
* Copyright (c) 2005, CakePHP Authors/Developers
|
* Copyright (c) 2005, CakePHP Authors/Developers
|
||||||
*
|
*
|
||||||
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
|
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
|
||||||
* Larry E. Masters aka PhpNut <nut@phpnut.com>
|
|
||||||
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
||||||
*
|
*
|
||||||
* Licensed under The MIT License
|
* Licensed under The MIT License
|
||||||
|
|
|
@ -58,14 +58,14 @@ class Security extends Object
|
||||||
switch (CAKE_SECURITY)
|
switch (CAKE_SECURITY)
|
||||||
{
|
{
|
||||||
case 'high':
|
case 'high':
|
||||||
return 0;
|
return 10;
|
||||||
break;
|
break;
|
||||||
case 'medium':
|
case 'medium':
|
||||||
return ;
|
return 20;
|
||||||
break;
|
break;
|
||||||
case 'low':
|
case 'low':
|
||||||
default :
|
default :
|
||||||
return;
|
return 30;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,10 +91,9 @@ class CakeSession extends Object
|
||||||
function &getInstance($base = null)
|
function &getInstance($base = null)
|
||||||
{
|
{
|
||||||
static $instance = array();
|
static $instance = array();
|
||||||
|
|
||||||
if (!$instance)
|
if (!$instance)
|
||||||
{
|
{
|
||||||
$instance[0] =& new CakeSession;
|
$instance[0] = new CakeSession;
|
||||||
$instance[0]->host = $_SERVER['HTTP_HOST'];
|
$instance[0]->host = $_SERVER['HTTP_HOST'];
|
||||||
if (strpos($instance[0]->host, ':') !== false)
|
if (strpos($instance[0]->host, ':') !== false)
|
||||||
{
|
{
|
||||||
|
@ -110,8 +109,8 @@ class CakeSession extends Object
|
||||||
|
|
||||||
$instance[0]->ip = $_SERVER['REMOTE_ADDR'];
|
$instance[0]->ip = $_SERVER['REMOTE_ADDR'];
|
||||||
$instance[0]->userAgent = !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "";
|
$instance[0]->userAgent = !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "";
|
||||||
|
|
||||||
$instance[0]->_initSession();
|
$instance[0]->_initSession();
|
||||||
|
$instance[0]->_begin();
|
||||||
}
|
}
|
||||||
return $instance[0];
|
return $instance[0];
|
||||||
}
|
}
|
||||||
|
@ -124,7 +123,7 @@ class CakeSession extends Object
|
||||||
*/
|
*/
|
||||||
function checkSessionVar($name)
|
function checkSessionVar($name)
|
||||||
{
|
{
|
||||||
$cakeSession =& CakeSession::getInstance();
|
$cakeSession = CakeSession::getInstance();
|
||||||
$expression = "return isset(".$cakeSession->_sessionVarNames($name).");";
|
$expression = "return isset(".$cakeSession->_sessionVarNames($name).");";
|
||||||
return eval($expression);
|
return eval($expression);
|
||||||
}
|
}
|
||||||
|
@ -137,14 +136,14 @@ class CakeSession extends Object
|
||||||
*/
|
*/
|
||||||
function delSessionVar($name)
|
function delSessionVar($name)
|
||||||
{
|
{
|
||||||
$cakeSession =& CakeSession::getInstance();
|
$cakeSession = CakeSession::getInstance();
|
||||||
if($cakeSession->check($name))
|
if($cakeSession->checkSessionVar($name))
|
||||||
{
|
{
|
||||||
$var = $cakeSession->_sessionVarNames($name);
|
$var = $cakeSession->_sessionVarNames($name);
|
||||||
eval("unset($var);");
|
eval("unset($var);");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$this->_setError(2, "$name doesn't exist");
|
$cakeSession->_setError(2, "$name doesn't exist");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +155,7 @@ class CakeSession extends Object
|
||||||
*/
|
*/
|
||||||
function getError($errorNumber)
|
function getError($errorNumber)
|
||||||
{
|
{
|
||||||
$cakeSession =& CakeSession::getInstance();
|
$cakeSession = CakeSession::getInstance();
|
||||||
if(!is_array($cakeSession->error) || !array_key_exists($errorNumber, $cakeSession->error))
|
if(!is_array($cakeSession->error) || !array_key_exists($errorNumber, $cakeSession->error))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -174,7 +173,7 @@ class CakeSession extends Object
|
||||||
*/
|
*/
|
||||||
function getLastError()
|
function getLastError()
|
||||||
{
|
{
|
||||||
$cakeSession =& CakeSession::getInstance();
|
$cakeSession = CakeSession::getInstance();
|
||||||
if($cakeSession->lastError)
|
if($cakeSession->lastError)
|
||||||
{
|
{
|
||||||
return $cakeSession->getError($cakeSession->lastError);
|
return $cakeSession->getError($cakeSession->lastError);
|
||||||
|
@ -192,7 +191,7 @@ class CakeSession extends Object
|
||||||
*/
|
*/
|
||||||
function isValid()
|
function isValid()
|
||||||
{
|
{
|
||||||
$cakeSession =& CakeSession::getInstance();
|
$cakeSession = CakeSession::getInstance();
|
||||||
return $cakeSession->valid;
|
return $cakeSession->valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,7 +203,7 @@ class CakeSession extends Object
|
||||||
*/
|
*/
|
||||||
function readSessionVar($name)
|
function readSessionVar($name)
|
||||||
{
|
{
|
||||||
$cakeSession =& CakeSession::getInstance();
|
$cakeSession = CakeSession::getInstance();
|
||||||
if($cakeSession->checkSessionVar($name))
|
if($cakeSession->checkSessionVar($name))
|
||||||
{
|
{
|
||||||
$result = eval("return ".$cakeSession->_sessionVarNames($name).";");
|
$result = eval("return ".$cakeSession->_sessionVarNames($name).";");
|
||||||
|
@ -222,7 +221,7 @@ class CakeSession extends Object
|
||||||
*/
|
*/
|
||||||
function writeSessionVar($name, $value)
|
function writeSessionVar($name, $value)
|
||||||
{
|
{
|
||||||
$cakeSession =& CakeSession::getInstance();
|
$cakeSession = CakeSession::getInstance();
|
||||||
$expression = $cakeSession->_sessionVarNames($name);
|
$expression = $cakeSession->_sessionVarNames($name);
|
||||||
$expression .= " = \$value;";
|
$expression .= " = \$value;";
|
||||||
eval($expression);
|
eval($expression);
|
||||||
|
@ -235,20 +234,10 @@ class CakeSession extends Object
|
||||||
*/
|
*/
|
||||||
function _begin()
|
function _begin()
|
||||||
{
|
{
|
||||||
$cakeSession =& CakeSession::getInstance();
|
$cakeSession = CakeSession::getInstance();
|
||||||
session_cache_limiter("must-revalidate");
|
session_cache_limiter("must-revalidate");
|
||||||
session_start();
|
session_start();
|
||||||
header('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"');
|
$cakeSession->_new();
|
||||||
$cakeSession->sessionId = session_id();
|
|
||||||
|
|
||||||
if($cakeSession->_isActiveSession() == false)
|
|
||||||
{
|
|
||||||
$cakeSession->_new();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$cakeSession->_renew();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -297,19 +286,19 @@ class CakeSession extends Object
|
||||||
*/
|
*/
|
||||||
function _initSession()
|
function _initSession()
|
||||||
{
|
{
|
||||||
$cakeSession =& CakeSession::getInstance();
|
$cakeSession = CakeSession::getInstance();
|
||||||
switch (CAKE_SECURITY)
|
switch (CAKE_SECURITY)
|
||||||
{
|
{
|
||||||
case 'high':
|
case 'high':
|
||||||
$cookieLifeTime = 0;
|
$cakeSession->cookieLifeTime = 0;
|
||||||
ini_set('session.referer_check', $cakeSession->host);
|
ini_set('session.referer_check', $cakeSession->host);
|
||||||
break;
|
break;
|
||||||
case 'medium':
|
case 'medium':
|
||||||
$cookieLifeTime = 7 * 86400;
|
$cakeSession->cookieLifeTime = 7 * 86400;
|
||||||
break;
|
break;
|
||||||
case 'low':
|
case 'low':
|
||||||
default :
|
default :
|
||||||
$cookieLifeTime = 788940000;
|
$cakeSession->cookieLifeTime = 788940000;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,7 +310,7 @@ class CakeSession extends Object
|
||||||
ini_set('session.serialize_handler', 'php');
|
ini_set('session.serialize_handler', 'php');
|
||||||
ini_set('session.use_cookies', 1);
|
ini_set('session.use_cookies', 1);
|
||||||
ini_set('session.name', CAKE_SESSION_COOKIE);
|
ini_set('session.name', CAKE_SESSION_COOKIE);
|
||||||
ini_set('session.cookie_lifetime', $cookieLifeTime);
|
ini_set('session.cookie_lifetime', $cakeSession->cookieLifeTime);
|
||||||
ini_set('session.cookie_path', $cakeSession->path);
|
ini_set('session.cookie_path', $cakeSession->path);
|
||||||
ini_set('session.gc_probability', 1);
|
ini_set('session.gc_probability', 1);
|
||||||
ini_set('session.gc_maxlifetime', Security::inactiveMins() * 60);
|
ini_set('session.gc_maxlifetime', Security::inactiveMins() * 60);
|
||||||
|
@ -335,7 +324,7 @@ class CakeSession extends Object
|
||||||
ini_set('session.serialize_handler', 'php');
|
ini_set('session.serialize_handler', 'php');
|
||||||
ini_set('session.use_cookies', 1);
|
ini_set('session.use_cookies', 1);
|
||||||
ini_set('session.name', CAKE_SESSION_COOKIE);
|
ini_set('session.name', CAKE_SESSION_COOKIE);
|
||||||
ini_set('session.cookie_lifetime', $cookieLifeTime);
|
ini_set('session.cookie_lifetime', $cakeSession->cookieLifeTime);
|
||||||
ini_set('session.cookie_path', $cakeSession->path);
|
ini_set('session.cookie_path', $cakeSession->path);
|
||||||
ini_set('session.gc_probability', 1);
|
ini_set('session.gc_probability', 1);
|
||||||
ini_set('session.gc_maxlifetime', Security::inactiveMins() * 60);
|
ini_set('session.gc_maxlifetime', Security::inactiveMins() * 60);
|
||||||
|
@ -349,7 +338,7 @@ class CakeSession extends Object
|
||||||
break;
|
break;
|
||||||
case 'php':
|
case 'php':
|
||||||
ini_set('session.name', CAKE_SESSION_COOKIE);
|
ini_set('session.name', CAKE_SESSION_COOKIE);
|
||||||
ini_set('session.cookie_lifetime', $cookieLifeTime);
|
ini_set('session.cookie_lifetime', $cakeSession->cookieLifeTime);
|
||||||
ini_set('session.cookie_path', $cakeSession->path);
|
ini_set('session.cookie_path', $cakeSession->path);
|
||||||
ini_set('session.gc_maxlifetime', Security::inactiveMins() * 60);
|
ini_set('session.gc_maxlifetime', Security::inactiveMins() * 60);
|
||||||
break;
|
break;
|
||||||
|
@ -362,25 +351,13 @@ class CakeSession extends Object
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ini_set('session.name', CAKE_SESSION_COOKIE);
|
ini_set('session.name', CAKE_SESSION_COOKIE);
|
||||||
ini_set('session.cookie_lifetime', $cookieLifeTime);
|
ini_set('session.cookie_lifetime', $cakeSession->cookieLifeTime);
|
||||||
ini_set('session.cookie_path', $cakeSession->path);
|
ini_set('session.cookie_path', $cakeSession->path);
|
||||||
ini_set('session.gc_maxlifetime', Security::inactiveMins() * 60);
|
ini_set('session.gc_maxlifetime', Security::inactiveMins() * 60);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cakeSession->_begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enter description here...
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
* @return unknown
|
|
||||||
*/
|
|
||||||
function _isActiveSession()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -391,8 +368,7 @@ class CakeSession extends Object
|
||||||
*/
|
*/
|
||||||
function _new()
|
function _new()
|
||||||
{
|
{
|
||||||
$cakeSession =& CakeSession::getInstance();
|
$cakeSession = CakeSession::getInstance();
|
||||||
|
|
||||||
if(!ereg("proxy\.aol\.com$", gethostbyaddr($cakeSession->ip)))
|
if(!ereg("proxy\.aol\.com$", gethostbyaddr($cakeSession->ip)))
|
||||||
{
|
{
|
||||||
if($cakeSession->readSessionVar("Config"))
|
if($cakeSession->readSessionVar("Config"))
|
||||||
|
@ -427,6 +403,12 @@ class CakeSession extends Object
|
||||||
}
|
}
|
||||||
$cakeSession->valid = true;
|
$cakeSession->valid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(CAKE_SECURITY == 'high')
|
||||||
|
{
|
||||||
|
$cakeSession->_regenerateId();
|
||||||
|
}
|
||||||
|
header('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -457,6 +439,38 @@ class CakeSession extends Object
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enter description here...
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function _regenerateId()
|
||||||
|
{
|
||||||
|
$cakeSession = CakeSession::getInstance();
|
||||||
|
$oldSessionId = session_id();
|
||||||
|
session_regenerate_id();
|
||||||
|
$newSessid = session_id();
|
||||||
|
if (function_exists('session_write_close'))
|
||||||
|
{
|
||||||
|
if(CAKE_SECURITY == 'high')
|
||||||
|
{
|
||||||
|
if (isset($_COOKIE[session_name()]))
|
||||||
|
{
|
||||||
|
setcookie(CAKE_SESSION_COOKIE, '', time()-42000, $cakeSession->path);
|
||||||
|
}
|
||||||
|
$file = ini_get('session.save_path')."/sess_$oldSessionId";
|
||||||
|
@unlink($file);
|
||||||
|
}
|
||||||
|
session_write_close();
|
||||||
|
$cakeSession->_initSession();
|
||||||
|
session_id($newSessid);
|
||||||
|
session_start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
|
@ -465,7 +479,7 @@ class CakeSession extends Object
|
||||||
*/
|
*/
|
||||||
function _renew()
|
function _renew()
|
||||||
{
|
{
|
||||||
return true;
|
$cakeSession->_regenerateId();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -477,7 +491,7 @@ class CakeSession extends Object
|
||||||
*/
|
*/
|
||||||
function _sessionVarNames($name)
|
function _sessionVarNames($name)
|
||||||
{
|
{
|
||||||
$cakeSession =& CakeSession::getInstance();
|
$cakeSession = CakeSession::getInstance();
|
||||||
if(is_string($name))
|
if(is_string($name))
|
||||||
{
|
{
|
||||||
if(strpos($name, "."))
|
if(strpos($name, "."))
|
||||||
|
@ -509,7 +523,7 @@ class CakeSession extends Object
|
||||||
*/
|
*/
|
||||||
function _setError($errorNumber, $errorMessage)
|
function _setError($errorNumber, $errorMessage)
|
||||||
{
|
{
|
||||||
$cakeSession =& CakeSession::getInstance();
|
$cakeSession = CakeSession::getInstance();
|
||||||
if($cakeSession->error === false)
|
if($cakeSession->error === false)
|
||||||
{
|
{
|
||||||
$cakeSession->error = array();
|
$cakeSession->error = array();
|
||||||
|
|
|
@ -11,8 +11,7 @@
|
||||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||||
* Copyright (c) 2005, CakePHP Authors/Developers
|
* Copyright (c) 2005, CakePHP Authors/Developers
|
||||||
*
|
*
|
||||||
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
|
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
|
||||||
* Larry E. Masters aka PhpNut <nut@phpnut.com>
|
|
||||||
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
||||||
*
|
*
|
||||||
* Licensed under The MIT License
|
* Licensed under The MIT License
|
||||||
|
|
|
@ -11,8 +11,7 @@
|
||||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||||
* Copyright (c) 2005, CakePHP Authors/Developers
|
* Copyright (c) 2005, CakePHP Authors/Developers
|
||||||
*
|
*
|
||||||
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
|
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
|
||||||
* Larry E. Masters aka PhpNut <nut@phpnut.com>
|
|
||||||
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
||||||
*
|
*
|
||||||
* Licensed under The MIT License
|
* Licensed under The MIT License
|
||||||
|
|
|
@ -11,8 +11,7 @@
|
||||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||||
* Copyright (c) 2005, CakePHP Authors/Developers
|
* Copyright (c) 2005, CakePHP Authors/Developers
|
||||||
*
|
*
|
||||||
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
|
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
|
||||||
* Larry E. Masters aka PhpNut <nut@phpnut.com>
|
|
||||||
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
||||||
*
|
*
|
||||||
* Licensed under The MIT License
|
* Licensed under The MIT License
|
||||||
|
|
|
@ -9,8 +9,7 @@
|
||||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||||
* Copyright (c) 2005, CakePHP Authors/Developers
|
* Copyright (c) 2005, CakePHP Authors/Developers
|
||||||
*
|
*
|
||||||
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
|
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
|
||||||
* Larry E. Masters aka PhpNut <nut@phpnut.com>
|
|
||||||
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
||||||
*
|
*
|
||||||
* Licensed under The MIT License
|
* Licensed under The MIT License
|
||||||
|
|
|
@ -39,7 +39,10 @@
|
||||||
echo $html->link('CakeBin', 'http://cakephp.org/pastes/',array('class'=>''));
|
echo $html->link('CakeBin', 'http://cakephp.org/pastes/',array('class'=>''));
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="content">
|
<div id="content">
|
||||||
|
|
||||||
|
<?php if(is_object($this->controller->Session)){$this->controller->Session->flash();} ?>
|
||||||
<?php echo $content_for_layout?>
|
<?php echo $content_for_layout?>
|
||||||
</div>
|
</div>
|
||||||
<div id="pb-cake">
|
<div id="pb-cake">
|
||||||
|
|
|
@ -10,8 +10,7 @@
|
||||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||||
* Copyright (c) 2005, CakePHP Authors/Developers
|
* Copyright (c) 2005, CakePHP Authors/Developers
|
||||||
*
|
*
|
||||||
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
|
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
|
||||||
* Larry E. Masters aka PhpNut <nut@phpnut.com>
|
|
||||||
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
|
||||||
*
|
*
|
||||||
* Licensed under The MIT License
|
* Licensed under The MIT License
|
||||||
|
|
Loading…
Reference in a new issue