mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Merging:
Revision: [1729] Fixed loading - added model, cakesession, security. Now loads properly. Revision: [1728] Fixing problems found in the way Cake handles sessions. These updates seem to work properly now. Added gethost() to basics.php to replace using gethostbyaddr which can be very slow. Added session_write_close(); in Controller::redirect(); Revision: [1719] Fix scaffold show.thtml undefined index error git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1730 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
1867e6503a
commit
28cb84e549
5 changed files with 99 additions and 93 deletions
|
@ -482,4 +482,19 @@ function setUri()
|
||||||
}
|
}
|
||||||
return $uri;
|
return $uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function gethost ($ip)
|
||||||
|
{
|
||||||
|
if (stristr(getenv('OS'), 'windows'))
|
||||||
|
{
|
||||||
|
$host = split('Name:',`nslookup $ip`);
|
||||||
|
return ( trim (isset($host[1]) ? str_replace ("\n".'Address: '.$ip, '', $host[1]) : $ip));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$host = `host $ip`;
|
||||||
|
return (($host ? end ( explode (' ', $host)) : $ip));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -299,6 +299,10 @@ class Controller extends Object
|
||||||
{
|
{
|
||||||
$url = '/'.$url;
|
$url = '/'.$url;
|
||||||
}
|
}
|
||||||
|
if (function_exists('session_write_close'))
|
||||||
|
{
|
||||||
|
session_write_close();
|
||||||
|
}
|
||||||
header ('Location: '.$this->base.$url);
|
header ('Location: '.$this->base.$url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,6 @@ class CakeSession extends Object
|
||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
*/
|
*/
|
||||||
var $sessionId = null;
|
var $sessionId = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
|
@ -93,7 +92,6 @@ class CakeSession extends Object
|
||||||
*
|
*
|
||||||
* @return unknown
|
* @return unknown
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function __construct($base = null)
|
function __construct($base = null)
|
||||||
{
|
{
|
||||||
$this->host = $_SERVER['HTTP_HOST'];
|
$this->host = $_SERVER['HTTP_HOST'];
|
||||||
|
@ -191,7 +189,6 @@ class CakeSession extends Object
|
||||||
*/
|
*/
|
||||||
function getLastError()
|
function getLastError()
|
||||||
{
|
{
|
||||||
|
|
||||||
if($this->lastError)
|
if($this->lastError)
|
||||||
{
|
{
|
||||||
return $this->getError($this->lastError);
|
return $this->getError($this->lastError);
|
||||||
|
@ -209,7 +206,6 @@ class CakeSession extends Object
|
||||||
*/
|
*/
|
||||||
function isValid()
|
function isValid()
|
||||||
{
|
{
|
||||||
|
|
||||||
return $this->valid;
|
return $this->valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +239,6 @@ class CakeSession extends Object
|
||||||
*/
|
*/
|
||||||
function returnSessionVars()
|
function returnSessionVars()
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!empty($_SESSION))
|
if(!empty($_SESSION))
|
||||||
{
|
{
|
||||||
$result = eval("return ".$_SESSION.";");
|
$result = eval("return ".$_SESSION.";");
|
||||||
|
@ -261,7 +256,6 @@ class CakeSession extends Object
|
||||||
*/
|
*/
|
||||||
function writeSessionVar($name, $value)
|
function writeSessionVar($name, $value)
|
||||||
{
|
{
|
||||||
|
|
||||||
$expression = $this->_sessionVarNames($name);
|
$expression = $this->_sessionVarNames($name);
|
||||||
$expression .= " = \$value;";
|
$expression .= " = \$value;";
|
||||||
eval($expression);
|
eval($expression);
|
||||||
|
@ -274,12 +268,6 @@ class CakeSession extends Object
|
||||||
*/
|
*/
|
||||||
function _begin()
|
function _begin()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (function_exists('session_write_close'))
|
|
||||||
{
|
|
||||||
session_write_close();
|
|
||||||
}
|
|
||||||
|
|
||||||
session_cache_limiter("must-revalidate");
|
session_cache_limiter("must-revalidate");
|
||||||
session_start();
|
session_start();
|
||||||
$this->_new();
|
$this->_new();
|
||||||
|
@ -331,6 +319,10 @@ class CakeSession extends Object
|
||||||
*/
|
*/
|
||||||
function _initSession()
|
function _initSession()
|
||||||
{
|
{
|
||||||
|
if (function_exists('session_write_close'))
|
||||||
|
{
|
||||||
|
session_write_close();
|
||||||
|
}
|
||||||
|
|
||||||
switch ($this->security)
|
switch ($this->security)
|
||||||
{
|
{
|
||||||
|
@ -404,7 +396,6 @@ class CakeSession extends Object
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -415,8 +406,7 @@ class CakeSession extends Object
|
||||||
*/
|
*/
|
||||||
function _new()
|
function _new()
|
||||||
{
|
{
|
||||||
|
if(!ereg("\.aol\.com$", gethost($this->ip)))
|
||||||
if(!ereg("proxy\.aol\.com$", @gethostbyaddr($this->ip)))
|
|
||||||
{
|
{
|
||||||
if($this->readSessionVar("Config"))
|
if($this->readSessionVar("Config"))
|
||||||
{
|
{
|
||||||
|
@ -486,7 +476,6 @@ class CakeSession extends Object
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
|
@ -496,28 +485,24 @@ class CakeSession extends Object
|
||||||
*/
|
*/
|
||||||
function _regenerateId()
|
function _regenerateId()
|
||||||
{
|
{
|
||||||
|
|
||||||
$oldSessionId = session_id();
|
$oldSessionId = session_id();
|
||||||
session_regenerate_id();
|
$sessionpath = session_save_path();
|
||||||
$newSessid = session_id();
|
if (empty($sessionpath))
|
||||||
if (function_exists('session_write_close'))
|
|
||||||
{
|
|
||||||
if($this->security == 'high')
|
|
||||||
{
|
{
|
||||||
|
$sessionpath = "/tmp";
|
||||||
|
}
|
||||||
if (isset($_COOKIE[session_name()]))
|
if (isset($_COOKIE[session_name()]))
|
||||||
{
|
{
|
||||||
setcookie(CAKE_SESSION_COOKIE, '', time()-42000, $this->path);
|
setcookie(CAKE_SESSION_COOKIE, '', time()-42000, $this->path);
|
||||||
}
|
}
|
||||||
$sessionpath = session_save_path();
|
session_regenerate_id();
|
||||||
$file = $sessionpath."/sess_$oldSessionId";
|
$newSessid = session_id();
|
||||||
|
$file = $sessionpath.DS."sess_$oldSessionId";
|
||||||
@unlink($file);
|
@unlink($file);
|
||||||
}
|
|
||||||
session_write_close();
|
|
||||||
$this->_initSession();
|
$this->_initSession();
|
||||||
session_id($newSessid);
|
session_id($newSessid);
|
||||||
session_start();
|
session_start();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
|
@ -539,7 +524,6 @@ class CakeSession extends Object
|
||||||
*/
|
*/
|
||||||
function _sessionVarNames($name)
|
function _sessionVarNames($name)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(is_string($name))
|
if(is_string($name))
|
||||||
{
|
{
|
||||||
if(strpos($name, "."))
|
if(strpos($name, "."))
|
||||||
|
@ -571,7 +555,6 @@ class CakeSession extends Object
|
||||||
*/
|
*/
|
||||||
function _setError($errorNumber, $errorMessage)
|
function _setError($errorNumber, $errorMessage)
|
||||||
{
|
{
|
||||||
|
|
||||||
if($this->error === false)
|
if($this->error === false)
|
||||||
{
|
{
|
||||||
$this->error = array();
|
$this->error = array();
|
||||||
|
|
|
@ -93,7 +93,7 @@
|
||||||
foreach ($objModel->_oneToOne as $relation)
|
foreach ($objModel->_oneToOne as $relation)
|
||||||
{
|
{
|
||||||
list($association, $model, $value) = $relation;
|
list($association, $model, $value) = $relation;
|
||||||
$otherModelName = $objModel->tableToModel[$model];
|
$otherModelName = $objModel->tableToModel[$objModel->{$model}->table];
|
||||||
$controller = Inflector::pluralize($model);
|
$controller = Inflector::pluralize($model);
|
||||||
|
|
||||||
echo "<div class='related'><H2>Related ".Inflector::humanize($association)."</H2>";
|
echo "<div class='related'><H2>Related ".Inflector::humanize($association)."</H2>";
|
||||||
|
@ -113,7 +113,7 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
echo "</dl>";
|
echo "</dl>";
|
||||||
echo "<ul class='actions'><li>".$html->linkTo('Edit '.Inflector::humanize($association),"/".Inflector::underscore($controller)."/edit/{$data[$association][$otherModelObject->primaryKey]}")."</li></ul></div>";
|
echo "<ul class='actions'><li>".$html->linkTo('Edit '.Inflector::humanize($association),"/".Inflector::underscore($controller)."/edit/{$data[$association][$objModel->{$model}->primaryKey]}")."</li></ul></div>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,10 @@ require_once (CONFIGS.'core.php');
|
||||||
require_once (CONFIGS.'database.php');
|
require_once (CONFIGS.'database.php');
|
||||||
|
|
||||||
uses ('neat_array');
|
uses ('neat_array');
|
||||||
|
uses ('object');
|
||||||
|
uses ('session');
|
||||||
|
uses ('security');
|
||||||
|
uses ('model'.DS.'model');
|
||||||
uses ('model'.DS.'dbo'.DS.'dbo_factory');
|
uses ('model'.DS.'dbo'.DS.'dbo_factory');
|
||||||
uses ('controller'.DS.'controller');
|
uses ('controller'.DS.'controller');
|
||||||
uses ('controller'.DS.'components'.DS.'acl');
|
uses ('controller'.DS.'components'.DS.'acl');
|
||||||
|
|
Loading…
Add table
Reference in a new issue