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:
phpnut 2005-11-01 04:20:28 +00:00
parent 30adcf8d0a
commit 67d156ef2b
27 changed files with 348 additions and 248 deletions

View file

@ -9,8 +9,7 @@
; * CakePHP : Rapid Development Framework <http://www.cakephp.org/>
; * Copyright (c) 2005, CakePHP Authors/Developers
; *
; * Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
; * Larry E. Masters aka PhpNut <nut@phpnut.com>
; * Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
; * Kamil Dzielinski aka Brego <brego.dk@gmail.com>
; *
; * Licensed under The MIT License

View file

@ -11,8 +11,7 @@
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
* Larry E. Masters aka PhpNut <nut@phpnut.com>
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License

View file

@ -194,3 +194,10 @@ a:hover
padding: 0;
border: 0;
}
div.message {
background-color: #E3FFD1;
border:1px solid #060;
padding:1em;
margin-bottom:1em;
}

View file

@ -42,6 +42,19 @@ define('WEEK', 7 * DAY);
define('MONTH', 30 * 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.
*
@ -98,6 +111,7 @@ function loadControllers ()
*/
function loadController ($name)
{
$name = Inflector::underscore($name);
if(file_exists(CONTROLLERS.$name.'_controller.php'))
{
$controller_fn = CONTROLLERS.$name.'_controller.php';

View file

@ -189,7 +189,12 @@ define ('PEAR', VENDORS.'Pear'.DS);
/**
* 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.

View file

@ -182,9 +182,14 @@ class Dispatcher extends Object
$controller->autoLayout = !$params['bare'];
$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))
{
$scaffolding =& new Scaffold($controller, $params);
$scaffolding = new Scaffold($controller, $params);
exit;
}
@ -202,9 +207,12 @@ class Dispatcher extends Object
$params['action'] = 'privateAction';
}
if(!defined('AUTO_SESSION') || AUTO_SESSION == true)
{
if (function_exists('session_write_close'))
{
session_write_close();
$session =& CakeSession::getInstance($this->base);
}
$session = CakeSession::getInstance($this->base);
}
return $this->_invoke($controller, $params );
}

View file

@ -11,9 +11,7 @@
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
* Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.

View file

@ -9,9 +9,7 @@
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
* Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.

View file

@ -109,7 +109,7 @@ class SessionComponent extends Object
*
* Use like this. $this->Session->error();
*
* @return unknown
* @return string Last session error
*/
function error()
{
@ -119,10 +119,44 @@ class SessionComponent extends Object
/**
* Enter description here...
*
* Use like this. $this->Session->valid();
* Use like this. $this->Session->setError();
*
* @param unknown_type $name
* @return unknown
* @return string Last session error
*/
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()
{

View file

@ -49,7 +49,7 @@ uses(DS.'controller'.DS.'component',DS.'model'.DS.'model', 'inflector', 'folder'
*/
class Controller extends Object
{
/**
/**
* Name of the controller.
*
* @var unknown_type
@ -57,22 +57,14 @@ class Controller extends Object
*/
var $name = null;
/**
/**
* Stores the current URL (for links etc.)
*
* @var string Current URL
*/
var $here = null;
/**
* Enter description here...
*
* @var unknown_type
* @access public
*/
var $parent = null;
/**
/**
* Action to be performed.
*
* @var string
@ -80,7 +72,7 @@ class Controller extends Object
*/
var $action = null;
/**
/**
* 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.
@ -88,7 +80,7 @@ class Controller extends Object
*/
var $uses = false;
/**
/**
* 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.
@ -96,14 +88,14 @@ class Controller extends Object
*/
var $helpers = array('Html');
/**
/**
* Enter description here...
*
* @var unknown_type
*/
var $viewPath;
/**
/**
* Variables for the view
*
* @var array
@ -111,7 +103,7 @@ class Controller extends Object
*/
var $_viewVars = array();
/**
/**
* Web page title
*
* @var boolean
@ -119,7 +111,7 @@ class Controller extends Object
*/
var $pageTitle = false;
/**
/**
* An array of model objects.
*
* @var array Array of model objects.
@ -128,7 +120,7 @@ class Controller extends Object
var $modelNames = array();
/**
/**
* Enter description here...
*
* @var unknown_type
@ -136,7 +128,7 @@ class Controller extends Object
*/
var $base = null;
/**
/**
* Layout file to use (see /app/views/layouts/default.thtml)
*
* @var string
@ -144,7 +136,7 @@ class Controller extends Object
*/
var $layout = 'default';
/**
/**
* Automatically render the view (the dispatcher checks for this variable before running render())
*
* @var boolean
@ -152,7 +144,7 @@ class Controller extends Object
*/
var $autoRender = true;
/**
/**
* Enter description here...
*
* @var boolean
@ -160,7 +152,7 @@ class Controller extends Object
*/
var $autoLayout = true;
/**
/**
* Database configuration to use (see /config/database.php)
*
* @var string
@ -168,7 +160,7 @@ class Controller extends Object
*/
var $useDbConfig = 'default';
/**
/**
* Enter description here...
*
* @var string
@ -176,14 +168,14 @@ class Controller extends Object
*/
var $beforeFilter = null;
/**
/**
* Enter description here...
*
* @var unknown_type
*/
var $components = array();
/**
/**
* Constructor.
*
*/
@ -205,11 +197,14 @@ class Controller extends Object
parent::__construct();
}
/**
/**
* Enter description here...
*
*/
function constructClasses(){
function constructClasses()
{
$dboFactory = DboFactory::getInstance($this->useDbConfig);
$this->db =& $dboFactory;
if (!empty($this->components))
{
@ -246,9 +241,6 @@ class Controller extends Object
$id = $this->params['pass'];
}
$dboFactory = DboFactory::getInstance($this->useDbConfig);
$this->db =& $dboFactory;
if (class_exists($this->modelClass) && ($this->uses === false))
{
$this->{$this->modelClass} =& new $this->modelClass($id);
@ -474,18 +466,6 @@ class Controller extends Object
$this->render('../errors/missingDatabase');
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.
@ -801,16 +781,16 @@ class Controller extends Object
{
list($modelName) = $relation;
$modelKey = Inflector::underscore($modelName);
$modelKeyM = Inflector::underscore($modelName);
$modelObject = new $modelName();
if( $doCreateOptions )
{
$otherDisplayField = $modelObject->getDisplayField();
$fieldNames[$modelKey]['model'] = $modelName;
$fieldNames[$modelKey]['prompt'] = "Related ".Inflector::humanize(Inflector::pluralize($modelName));
$fieldNames[$modelKey]['type'] = "selectMultiple";
$fieldNames[$modelKey]['tagName'] = $modelKey.'/'.$modelKey;
$fieldNames[$modelKeyM]['model'] = $modelName;
$fieldNames[$modelKeyM]['prompt'] = "Related ".Inflector::humanize(Inflector::pluralize($modelName));
$fieldNames[$modelKeyM]['type'] = "selectMultiple";
$fieldNames[$modelKeyM]['tagName'] = $modelName.'/'.$modelName;
foreach( $modelObject->findAll() as $pass )
{
@ -818,15 +798,15 @@ class Controller extends Object
{
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'];
}
}
}

View file

@ -11,8 +11,7 @@
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
* Larry E. Masters aka PhpNut <nut@phpnut.com>
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License
@ -210,11 +209,24 @@ class Scaffold extends Object {
if ($this->controllerClass->{$this->modelKey}->save($this->controllerClass->params['data']))
{
return $this->controllerClass->flash('Your '.Inflector::humanize($this->modelKey).' has been saved.', '/'.
Inflector::underscore($this->controllerClass->viewPath) );
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.', '/'.
Inflector::underscore($this->controllerClass->viewPath) );
}
}
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->validateErrors($this->controllerClass->{$this->modelKey});
return $this->controllerClass->render($this->actionView, '', LIBS.'controller'.DS.'templates'.DS.'scaffolds'.DS.'new.thtml');
@ -239,16 +251,34 @@ class Scaffold extends Object {
$this->controllerClass->{$this->modelKey}->set($this->controllerClass->params['data']);
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.','/'.
Inflector::underscore($this->controllerClass->viewPath));
}
}
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),'/'.
Inflector::underscore($this->controllerClass->viewPath));
}
}
}
/**
* Performs a delete on given scaffolded Model.
@ -261,16 +291,34 @@ class Scaffold extends Object {
{
$id = $params['pass'][0];
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: '.
$id.' has been deleted.', '/'.Inflector::underscore($this->controllerClass->viewPath));
}
}
else
{
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));
}
}
}
/**
* When methods are now present in a controller
@ -298,9 +346,12 @@ class Scaffold extends Object {
{
$this->controllerClass->constructClasses();
if(!defined('AUTO_SESSION') || AUTO_SESSION == true)
{
if (function_exists('session_write_close'))
{
session_write_close();
$session =& CakeSession::getInstance();
}
$session = CakeSession::getInstance($this->controllerClass->base);
}
if($params['action'] === 'index' || $params['action'] === 'list' ||

View file

@ -9,8 +9,7 @@
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
* Larry E. Masters aka PhpNut <nut@phpnut.com>
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License
@ -48,7 +47,7 @@
<?php
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 ) {
if( isset( $value['foreignKey'] ) )
{

View file

@ -9,8 +9,7 @@
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
* Larry E. Masters aka PhpNut <nut@phpnut.com>
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License

View file

@ -9,8 +9,7 @@
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
* Larry E. Masters aka PhpNut <nut@phpnut.com>
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License
@ -41,7 +40,7 @@
?>
<ul class='actions'>
<?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>

View file

@ -9,8 +9,7 @@
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
* Larry E. Masters aka PhpNut <nut@phpnut.com>
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License
@ -80,7 +79,7 @@
<?php
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('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>";
foreach( $fieldNames as $field => $value ) {
if( isset( $value['foreignKey'] ) )

View file

@ -264,11 +264,10 @@ class DBO_MySQL extends DBO
{
$resultRow = array();
$i =0;
foreach ($row as $index => $field)
{
list($table, $column) = $this->map[$index];
$resultRow[Inflector::singularize($table)][$column] = $row[$index];
$resultRow[$table][$column] = $row[$index];
$i++;
}
return $resultRow;
@ -278,6 +277,7 @@ class DBO_MySQL extends DBO
return false;
}
}
}
?>

View file

@ -1111,6 +1111,7 @@ class Model extends Object
$data = $newValue;
}
}
return $data;
}
@ -1211,9 +1212,9 @@ class Model extends Object
{
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']))
{
@ -1226,28 +1227,29 @@ class Model extends Object
$manyToManyConditions = $this->parseConditions($this->{$model}->{$this->currentModel.'_conditions'});
$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'}}
ON {$this->{$model}->{$this->currentModel.'_jointable'}}.
{$this->{$model}->{$this->currentModel.'_foreignkey'}} = '$value2[id]'
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)
.($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);
foreach ($manyToManySelect[$this->{$model}->table] as $key => $value)
$newKey = $this->{$model}->name;
foreach ($manyToManySelect[$this->{$model}->name] as $key => $value)
{
$manyToManySelect1[$newKey][$key] = $value[$newKey];
}
$merged = array_merge_recursive($data[$count],$manyToManySelect1);
$newdata[$count] = $merged;
unset( $manyToManySelect[$this->{$model}->table], $manyToManySelect1 );
unset( $manyToManySelect[$this->{$model}->name], $manyToManySelect1 );
}
if(!empty($newdata[$count]))
{

View file

@ -11,9 +11,7 @@
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
* Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.

View file

@ -11,8 +11,7 @@
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
* Larry E. Masters aka PhpNut <nut@phpnut.com>
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License

View file

@ -58,14 +58,14 @@ class Security extends Object
switch (CAKE_SECURITY)
{
case 'high':
return 0;
return 10;
break;
case 'medium':
return ;
return 20;
break;
case 'low':
default :
return;
return 30;
break;
}
}

View file

@ -91,10 +91,9 @@ class CakeSession extends Object
function &getInstance($base = null)
{
static $instance = array();
if (!$instance)
{
$instance[0] =& new CakeSession;
$instance[0] = new CakeSession;
$instance[0]->host = $_SERVER['HTTP_HOST'];
if (strpos($instance[0]->host, ':') !== false)
{
@ -110,8 +109,8 @@ class CakeSession extends Object
$instance[0]->ip = $_SERVER['REMOTE_ADDR'];
$instance[0]->userAgent = !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "";
$instance[0]->_initSession();
$instance[0]->_begin();
}
return $instance[0];
}
@ -124,7 +123,7 @@ class CakeSession extends Object
*/
function checkSessionVar($name)
{
$cakeSession =& CakeSession::getInstance();
$cakeSession = CakeSession::getInstance();
$expression = "return isset(".$cakeSession->_sessionVarNames($name).");";
return eval($expression);
}
@ -137,14 +136,14 @@ class CakeSession extends Object
*/
function delSessionVar($name)
{
$cakeSession =& CakeSession::getInstance();
if($cakeSession->check($name))
$cakeSession = CakeSession::getInstance();
if($cakeSession->checkSessionVar($name))
{
$var = $cakeSession->_sessionVarNames($name);
eval("unset($var);");
return true;
}
$this->_setError(2, "$name doesn't exist");
$cakeSession->_setError(2, "$name doesn't exist");
return false;
}
@ -156,7 +155,7 @@ class CakeSession extends Object
*/
function getError($errorNumber)
{
$cakeSession =& CakeSession::getInstance();
$cakeSession = CakeSession::getInstance();
if(!is_array($cakeSession->error) || !array_key_exists($errorNumber, $cakeSession->error))
{
return false;
@ -174,7 +173,7 @@ class CakeSession extends Object
*/
function getLastError()
{
$cakeSession =& CakeSession::getInstance();
$cakeSession = CakeSession::getInstance();
if($cakeSession->lastError)
{
return $cakeSession->getError($cakeSession->lastError);
@ -192,7 +191,7 @@ class CakeSession extends Object
*/
function isValid()
{
$cakeSession =& CakeSession::getInstance();
$cakeSession = CakeSession::getInstance();
return $cakeSession->valid;
}
@ -204,7 +203,7 @@ class CakeSession extends Object
*/
function readSessionVar($name)
{
$cakeSession =& CakeSession::getInstance();
$cakeSession = CakeSession::getInstance();
if($cakeSession->checkSessionVar($name))
{
$result = eval("return ".$cakeSession->_sessionVarNames($name).";");
@ -222,7 +221,7 @@ class CakeSession extends Object
*/
function writeSessionVar($name, $value)
{
$cakeSession =& CakeSession::getInstance();
$cakeSession = CakeSession::getInstance();
$expression = $cakeSession->_sessionVarNames($name);
$expression .= " = \$value;";
eval($expression);
@ -235,21 +234,11 @@ class CakeSession extends Object
*/
function _begin()
{
$cakeSession =& CakeSession::getInstance();
$cakeSession = CakeSession::getInstance();
session_cache_limiter("must-revalidate");
session_start();
header('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"');
$cakeSession->sessionId = session_id();
if($cakeSession->_isActiveSession() == false)
{
$cakeSession->_new();
}
else
{
$cakeSession->_renew();
}
}
/**
* Enter description here...
@ -297,19 +286,19 @@ class CakeSession extends Object
*/
function _initSession()
{
$cakeSession =& CakeSession::getInstance();
$cakeSession = CakeSession::getInstance();
switch (CAKE_SECURITY)
{
case 'high':
$cookieLifeTime = 0;
$cakeSession->cookieLifeTime = 0;
ini_set('session.referer_check', $cakeSession->host);
break;
case 'medium':
$cookieLifeTime = 7 * 86400;
$cakeSession->cookieLifeTime = 7 * 86400;
break;
case 'low':
default :
$cookieLifeTime = 788940000;
$cakeSession->cookieLifeTime = 788940000;
break;
}
@ -321,7 +310,7 @@ class CakeSession extends Object
ini_set('session.serialize_handler', 'php');
ini_set('session.use_cookies', 1);
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.gc_probability', 1);
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.use_cookies', 1);
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.gc_probability', 1);
ini_set('session.gc_maxlifetime', Security::inactiveMins() * 60);
@ -349,7 +338,7 @@ class CakeSession extends Object
break;
case 'php':
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.gc_maxlifetime', Security::inactiveMins() * 60);
break;
@ -362,25 +351,13 @@ class CakeSession extends Object
else
{
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.gc_maxlifetime', Security::inactiveMins() * 60);
}
break;
}
$cakeSession->_begin();
}
/**
* Enter description here...
*
* @access private
* @return unknown
*/
function _isActiveSession()
{
return false;
}
/**
@ -391,8 +368,7 @@ class CakeSession extends Object
*/
function _new()
{
$cakeSession =& CakeSession::getInstance();
$cakeSession = CakeSession::getInstance();
if(!ereg("proxy\.aol\.com$", gethostbyaddr($cakeSession->ip)))
{
if($cakeSession->readSessionVar("Config"))
@ -427,6 +403,12 @@ class CakeSession extends Object
}
$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();
}
/**
* 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...
*
@ -465,7 +479,7 @@ class CakeSession extends Object
*/
function _renew()
{
return true;
$cakeSession->_regenerateId();
}
/**
@ -477,7 +491,7 @@ class CakeSession extends Object
*/
function _sessionVarNames($name)
{
$cakeSession =& CakeSession::getInstance();
$cakeSession = CakeSession::getInstance();
if(is_string($name))
{
if(strpos($name, "."))
@ -509,7 +523,7 @@ class CakeSession extends Object
*/
function _setError($errorNumber, $errorMessage)
{
$cakeSession =& CakeSession::getInstance();
$cakeSession = CakeSession::getInstance();
if($cakeSession->error === false)
{
$cakeSession->error = array();

View file

@ -11,8 +11,7 @@
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
* Larry E. Masters aka PhpNut <nut@phpnut.com>
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License

View file

@ -11,8 +11,7 @@
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
* Larry E. Masters aka PhpNut <nut@phpnut.com>
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License

View file

@ -11,8 +11,7 @@
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
* Larry E. Masters aka PhpNut <nut@phpnut.com>
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License

View file

@ -9,8 +9,7 @@
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
* Larry E. Masters aka PhpNut <nut@phpnut.com>
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License

View file

@ -39,7 +39,10 @@
echo $html->link('CakeBin', 'http://cakephp.org/pastes/',array('class'=>''));
?>
</div>
<div id="content">
<?php if(is_object($this->controller->Session)){$this->controller->Session->flash();} ?>
<?php echo $content_for_layout?>
</div>
<div id="pb-cake">

View file

@ -10,8 +10,7 @@
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
* Larry E. Masters aka PhpNut <nut@phpnut.com>
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License