Skip to content
This repository has been archived by the owner on Nov 26, 2017. It is now read-only.

Commit

Permalink
Envieronment, log, mail, plugin,registry, session, updater
Browse files Browse the repository at this point in the history
  • Loading branch information
elinw committed Apr 20, 2011
1 parent 2c03b11 commit aacdb90
Show file tree
Hide file tree
Showing 23 changed files with 194 additions and 165 deletions.
1 change: 1 addition & 0 deletions libraries/joomla/environment/request.php
Expand Up @@ -33,6 +33,7 @@
* @static
* @package Joomla.Platform
* @subpackage Environment
* @deprecated Get the JInput object from the application instead
* @since 11.1
*/
class JRequest
Expand Down
1 change: 1 addition & 0 deletions libraries/joomla/error/error.php
Expand Up @@ -30,6 +30,7 @@
* @package Joomla.Platform
* @subpackage Error
* @since 11.1
* @deprecated
*/
abstract class JError
{
Expand Down
5 changes: 3 additions & 2 deletions libraries/joomla/log/log.php
Expand Up @@ -20,7 +20,7 @@
* Joomla! Log Class
*
* This class hooks into the global log configuration settings to allow for user configured
* logging events to be sent to where the user wishes it to be sent. On high load sites
* logging events to be sent to where the user wishes them to be sent. On high load sites
* SysLog is probably the best (pure PHP function), then the text file based loggers (CSV, W3C
* or plain FormattedText) and finally MySQL offers the most features (e.g. rapid searching)
* but will incur a performance hit due to INSERT being issued.
Expand Down Expand Up @@ -167,7 +167,8 @@ public static function add($entry, $priority = JLog::INFO, $category = '', $date
}

/**
* Method to set the way the JError will handle different error levels. Use this if you want to override the default settings.
* Method to set the way the JError will handle different error levels.
* Use this if you want to override the default settings.
*
* @param array $options The object configuration array.
* @param integer $priorities ...
Expand Down
2 changes: 1 addition & 1 deletion libraries/joomla/log/loggers/formattedtext.php
Expand Up @@ -161,7 +161,7 @@ public function addEntry(JLogEntry $entry)
$entry->date = $entry->date->format('Y-m-d', false);
}

// Decode the entry priority into an english string.
// Decode the entry priority into an English string.
$entry->priority = $this->priorities[$entry->priority];

// Get a list of all the entry keys and make sure they are upper case.
Expand Down
2 changes: 1 addition & 1 deletion libraries/joomla/log/loggers/w3c.php
Expand Up @@ -28,7 +28,7 @@
class JLoggerW3C extends JLoggerFormattedText
{
/**
* @var string The format for which each entry follows in the log file. All fields must be
* @var string The format which each entry follows in the log file. All fields must be
* named in all caps and be within curly brackets eg. {FOOBAR}.
* @since 11.1
*/
Expand Down
10 changes: 5 additions & 5 deletions libraries/joomla/mail/mail.php
Expand Up @@ -155,7 +155,7 @@ public function setBody($content)
*/
public function addRecipient($recipient)
{
// If the recipient is an aray, add each recipient... otherwise just add the one
// If the recipient is an array, add each recipient... otherwise just add the one
if (is_array($recipient)) {
foreach ($recipient as $to)
{
Expand All @@ -181,7 +181,7 @@ public function addRecipient($recipient)
*/
public function addCC($cc)
{
// If the carbon copy recipient is an aray, add each recipient... otherwise just add the one
// If the carbon copy recipient is an array, add each recipient... otherwise just add the one
if (isset ($cc)) {
if (is_array($cc)) {
foreach ($cc as $to)
Expand Down Expand Up @@ -209,7 +209,7 @@ public function addCC($cc)
*/
public function addBCC($bcc)
{
// If the blind carbon copy recipient is an aray, add each recipient... otherwise just add the one
// If the blind carbon copy recipient is an array, add each recipient... otherwise just add the one
if (isset($bcc)) {
if (is_array($bcc)) {
foreach ($bcc as $to)
Expand Down Expand Up @@ -237,7 +237,7 @@ public function addBCC($bcc)
*/
public function addAttachment($attachment)
{
// If the file attachments is an aray, add each file... otherwise just add the one
// If the file attachments is an array, add each file... otherwise just add the one
if (isset($attachment)) {
if (is_array($attachment)) {
foreach ($attachment as $file)
Expand Down Expand Up @@ -314,7 +314,7 @@ public function useSendmail($sendmail = null)
* @param string $host SMTP Host [optional]
* @param string $user SMTP Username [optional]
* @param string $pass SMTP Password [optional]
* @param $secure
* @param string $secure
* @param int $port
*
* @return boolean True on success
Expand Down
2 changes: 1 addition & 1 deletion libraries/joomla/plugin/helper.php
Expand Up @@ -105,7 +105,7 @@ public static function importPlugin($type, $plugin = null, $autocreate = true, $
}
}

// bail out early if we're not using default args
// Bail out early if we're not using default args
if(!$defaults) {
return $results;
}
Expand Down
1 change: 1 addition & 0 deletions libraries/joomla/plugin/plugin.php
Expand Up @@ -87,6 +87,7 @@ public function __construct(&$subject, $config = array())
* @access public
* @param string $extension The extension for which a language file should be loaded
* @param string $basePath The basepath to use
*
* @return boolean True, if the file has successfully loaded.
* @since 11.1
*/
Expand Down
3 changes: 3 additions & 0 deletions libraries/joomla/registry/format/ini.php
Expand Up @@ -63,8 +63,10 @@ public function objectToString($object, $options = array())
*
* @param string INI formatted string to convert.
* @param mixed An array of options used by the formatter, or a boolean setting to process sections.
*
* @return object Data object.
* @since 11.1
*
*/
public function stringToObject($data, $options = array())
{
Expand All @@ -73,6 +75,7 @@ public function stringToObject($data, $options = array())
$sections = (isset($options['processSections'])) ? $options['processSections'] : false;
} else {
// Backward compatibility for 1.5 usage.
@deprecated
$sections = (boolean) $options;
}

Expand Down
62 changes: 35 additions & 27 deletions libraries/joomla/session/session.php
Expand Up @@ -18,7 +18,7 @@
* Provides access to session-state values as well as session-level
* settings and lifetime management methods.
* Based on the standart PHP session handling mechanism it provides
* for you more advanced features such as expire timeouts.
* more advanced features such as expire timeouts.
*
* @package Joomla.Platform
* @subpackage Session
Expand Down Expand Up @@ -165,6 +165,7 @@ public function getExpire()
* it is present, if not it will invalidate the session.
*
* @param boolean If true, force a new token to be created
*
* @return string The session token
*/
public function getToken($forceNew = false)
Expand All @@ -186,6 +187,8 @@ public function getToken($forceNew = false)
*
* @param string Hashed token to be verified
* @param boolean If true, expires the session
*
* @return boolean
* @since 11.1
*/
public function hasToken($tCheck, $forceExpire = true)
Expand All @@ -209,7 +212,6 @@ public function hasToken($tCheck, $forceExpire = true)
*
* @return string Hashed var name
* @since 11.1
* @static
*/
public static function getFormToken($forceNew = false)
{
Expand Down Expand Up @@ -296,6 +298,7 @@ public function isNew()
* @param string Name of a variable
* @param mixed Default value of a variable if not set
* @param string Namespace to use, default to 'default'
*
* @return mixed Value of a variable
*/
public function get($name, $default = null, $namespace = 'default')
Expand All @@ -320,6 +323,7 @@ public function get($name, $default = null, $namespace = 'default')
* @param string Name of a variable.
* @param mixed Value of a variable.
* @param string Namespace to use, default to 'default'.
*
* @return mixed Old value of a variable.
*/
public function set($name, $value = null, $namespace = 'default')
Expand Down Expand Up @@ -370,7 +374,8 @@ public function has($name, $namespace = 'default')
*/
public function clear($name, $namespace = 'default')
{
$namespace = '__'.$namespace; //add prefix to namespace to avoid collisions
// Add prefix to namespace to avoid collisions
$namespace = '__'.$namespace;

if ($this->_state !== 'active') {
// @TODO :: generated error here
Expand All @@ -395,7 +400,7 @@ public function clear($name, $namespace = 'default')
*/
protected function _start()
{
// start session if not startet
// Start session if not started
if ($this->_state == 'restart') {
session_id($this->_createId());
} else {
Expand All @@ -413,7 +418,7 @@ protected function _start()

// Send modified header for IE 6.0 Security Policy
// Joomla! 1.6: Moved to configurable plugin due to security concerns
//header('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"');
// header('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"');

return true;
}
Expand All @@ -425,13 +430,13 @@ protected function _start()
* with the current session in its storage (file or DB). It forces new session to be
* started after this method is called. It does not unset the session cookie.
*
* @return void
* @return boolean true on success
* @see session_unset()
* @see session_destroy()
*/
public function destroy()
{
// session was already destroyed
// Session was already destroyed
if ($this->_state === 'destroyed') {
return true;
}
Expand Down Expand Up @@ -495,23 +500,23 @@ public function fork()
return false;
}

// save values
// Save values
$values = $_SESSION;

// keep session config
// Keep session config
$trans = ini_get('session.use_trans_sid');
if ($trans) {
ini_set('session.use_trans_sid', 0);
}
$cookie = session_get_cookie_params();

// create new session id
// Create new session id
$id = $this->_createId(strlen($this->getId()));

// kill session
// Kill session
session_destroy();

// re-register the session store after a session has been destroyed, to avoid PHP bug
// Re-register the session store after a session has been destroyed, to avoid PHP bug
$this->_store->register();

// restore config
Expand All @@ -529,7 +534,7 @@ public function fork()
* Writes session data and ends session
*
* Session data is usually stored after your script terminated without the need
* to call JSession::close(),but as session data is locked to prevent concurrent
* to call JSession::close(), but as session data is locked to prevent concurrent
* writes only one script may operate on a session at any time. When using
* framesets together with sessions you will experience the frames loading one
* by one due to this locking. You can reduce the time needed to load all the
Expand Down Expand Up @@ -585,6 +590,7 @@ protected function _setCookieParams()
* Create a token-string
*
* @param int length of string
*
* @return string generated token
*/
protected function _createToken($length = 32)
Expand Down Expand Up @@ -636,29 +642,30 @@ protected function _setTimers()
}

/**
* set additional session options
* Set additional session options
*
* @param array list of parameter
*
* @return boolean true on success
*/
protected function _setOptions(&$options)
{
// set name
// Set name
if (isset($options['name'])) {
session_name(md5($options['name']));
}

// set id
// Set id
if (isset($options['id'])) {
session_id($options['id']);
}

// set expire time
// Set expire time
if (isset($options['expire'])) {
$this->_expire = $options['expire'];
}

// get security options
// Get security options
if (isset($options['security'])) {
$this->_security = explode(',', $options['security']);
}
Expand All @@ -667,7 +674,7 @@ protected function _setOptions(&$options)
$this->_force_ssl = (bool) $options['force_ssl'];
}

//sync the session maxlifetime
// Sync the session maxlifetime
ini_set('session.gc_maxlifetime', $this->_expire);

return true;
Expand All @@ -683,39 +690,40 @@ protected function _setOptions(&$options)
* If one check failed, session data has to be cleaned.
*
* @param boolean reactivate session
*
* @return boolean true on success
* @see http://shiflett.org/articles/the-truth-about-sessions
*/
protected function _validate($restart = false)
{
// allow to restart a session
// Allow to restart a session
if ($restart) {
$this->_state = 'active';

$this->set('session.client.address' , null);
$this->set('session.client.address' , null);
$this->set('session.client.forwarded' , null);
$this->set('session.client.browser' , null);
$this->set('session.client.browser' , null);
$this->set('session.token' , null);
}

// check if session has expired
// Check if session has expired
if ($this->_expire) {
$curTime = $this->get('session.timer.now' , 0 );
$maxTime = $this->get('session.timer.last', 0) + $this->_expire;

// empty session variables
// Empty session variables
if ($maxTime < $curTime) {
$this->_state = 'expired';
return false;
}
}

// record proxy forwarded for in the session in case we need it later
// Record proxy forwarded for in the session in case we need it later
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$this->set('session.client.forwarded', $_SERVER['HTTP_X_FORWARDED_FOR']);
}

// check for client adress
// Check for client adress
if (in_array('fix_adress', $this->_security) && isset($_SERVER['REMOTE_ADDR'])) {
$ip = $this->get('session.client.address');

Expand All @@ -727,7 +735,7 @@ protected function _validate($restart = false)
}
}

// check for clients browser
// Check for clients browser
if (in_array('fix_browser', $this->_security) && isset($_SERVER['HTTP_USER_AGENT'])) {
$browser = $this->get('session.client.browser');

Expand Down

0 comments on commit aacdb90

Please sign in to comment.