Changeset 159


Ignore:
Timestamp:
Jun 11, 2006 5:41:23 AM (18 years ago)
Author:
scdev
Message:

${1}

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/module_maker/skel/admin.php

    r154 r159  
    300300
    301301    // Create version.
    302     $version = Version::getInstance($GLOBALS['auth']);
     302    $version = Version::getInstance($auth);
    303303    $version->create('%DB_TBL%', '%PRIMARY_KEY%', $last_insert_id, $frm['__///__']);
    304304
     
    310310function updateRecord($frm)
    311311{
    312     global $auth, $lock;
     312    global $auth;
     313    global $lock;
    313314    global $cache;
    314315    $app =& App::getInstance();
     
    325326
    326327    // Create version.
    327     $version = Version::getInstance($GLOBALS['auth']);
     328    $version = Version::getInstance($auth);
    328329    $version->create('%DB_TBL%', '%PRIMARY_KEY%', $frm['%PRIMARY_KEY%'], $frm['__///__']);
    329330
  • trunk/lib/App.inc.php

    r154 r159  
    830830    * @param    mixed   $carry_args     Additional arguments to carry in the URL automatically (see $app->oHREF()).
    831831    * @param    string  $default_url    A default URL if there is not a valid specified boomerang URL.
     832    * @param    bool    $queryless_referrer_comparison   Exclude the URL query from the refererIsMe() comparison.
    832833    * @return   bool                    False if the session is not running. No return otherwise.
    833834    * @author   Quinn Comendant <quinn@strangecode.com>
    834835    * @since    31 Mar 2006 19:17:00
    835836    */
    836     function dieBoomerangURL($id=null, $carry_args=null, $default_url=null)
     837    function dieBoomerangURL($id=null, $carry_args=null, $default_url=null, $queryless_referrer_comparison=false)
    837838    {
    838839        if (!$this->running) {
     
    854855        } else if (isset($default_url)) {
    855856            $url = $default_url;
    856         } else if (!refererIsMe()) {
     857        } else if (!refererIsMe(true === $queryless_referrer_comparison)) {
    857858            // Ensure that the redirecting page is not also the referrer.
    858859            $url = getenv('HTTP_REFERER');
     
    888889        if ('' != $url && is_string($url)) {
    889890            // Delete any boomerang request keys in the query string.
    890             $url = preg_replace('/boomerang=[\w]+/', '', $url);
     891            $url = preg_replace('/[&?]?boomerang=[\w]+/', '', $url);
    891892
    892893            if (isset($_SESSION['_app'][$this->_ns]['boomerang']['url']) && is_array($_SESSION['_app'][$this->_ns]['boomerang']['url']) && !empty($_SESSION['_app'][$this->_ns]['boomerang']['url'])) {
     
    9991000        }
    10001001        if ($boomerang_time >= (time() - 2)) {
    1001             // Last boomerang direction was more than 2 seconds ago.
    1002             $this->logMsg(sprintf('validBoomerangURL(%s) not valid, boomerang_time too short: %s', $id, time() - $boomerang_time), LOG_DEBUG, __FILE__, __LINE__);
     1002            // Last boomerang direction was less than 2 seconds ago.
     1003            $this->logMsg(sprintf('validBoomerangURL(%s) not valid, boomerang_time too short: %s seconds', $id, time() - $boomerang_time), LOG_DEBUG, __FILE__, __LINE__);
    10031004            return false;
    10041005        }
  • trunk/lib/Auth_SQL.inc.php

    r158 r159  
    444444
    445445            // Update the login counter table with this login access. Convert IP to binary.
     446            // TODO: after MySQL 5.0.23 is released this query could benefit from INSERT DELAYED.
    446447            $db->query("
    447448                INSERT INTO " . $this->_params['db_login_table'] . " (
  • trunk/lib/Prefs.inc.php

    r158 r159  
    180180        }
    181181       
     182        // Set a persistent perference if...
     183        // - there isn't a default.
     184        // - the new value is different than the default
     185        // - there is a previously existing pesistent key.
    182186        if (!isset($_SESSION['_prefs'][$this->_ns]['defaults'][$key]) || $_SESSION['_prefs'][$this->_ns]['defaults'][$key] != $val || isset($_SESSION['_prefs'][$this->_ns]['persistent'][$key])) {
    183187            $_SESSION['_prefs'][$this->_ns]['persistent'][$key] = $val;           
     188            $app->logMsg(sprintf('Setting preference %s to %s', $key, $val), LOG_DEBUG, __FILE__, __LINE__);
     189        } else {
     190            $app->logMsg(sprintf('not setting %s to %s', $key, $val), LOG_DEBUG, __FILE__, __LINE__);
    184191        }
    185192    }
     
    347354        $this->initDB();
    348355
    349         if (isset($_SESSION['_prefs'][$this->_ns]['persistent']) && is_array($_SESSION['_prefs'][$this->_ns]['persistent'])) {
     356        if (isset($_SESSION['_prefs'][$this->_ns]['persistent']) && is_array($_SESSION['_prefs'][$this->_ns]['persistent']) && !empty($_SESSION['_prefs'][$this->_ns]['persistent'])) {
    350357            // Delete old prefs from database.
    351358            $db->query("
     
    365372                );
    366373            }
     374            // TODO: after MySQL 5.0.23 is released this query could benefit from INSERT DELAYED.
    367375            $db->query("
    368                 INSERT LOW_PRIORITY INTO " . $db->escapeString($this->getParam('db_table')) . "
     376                INSERT INTO " . $db->escapeString($this->getParam('db_table')) . "
    369377                (user_id, pref_namespace, pref_key, pref_value)
    370378                VALUES " . join(', ', $insert_values) . "
  • trunk/lib/Utilities.inc.php

    r154 r159  
    595595 * @access  public
    596596 * @param   string  $val    The string to sign.
    597  * @param   string  $seed_key   (Optional) A text key to use for computing the signature.
     597 * @param   string  $salt   (Optional) A text key to use for computing the signature.
    598598 * @return  string  The original value with a signature appended.
    599599 */
    600 function addSignature($val, $seed_key=null)
    601 {
    602     $app =& App::getInstance();
    603    
    604     if ('' == $val) {
    605         $app->logMsg(sprintf('Adding signature to empty string.', null), LOG_NOTICE, __FILE__, __LINE__);
    606     }
    607 
    608     if (!isset($seed_key)) {
    609         $seed_key = $app->getParam('signing_key');
    610     }
    611 
    612     return $val . '-' . substr(md5($val . $seed_key), 0, 18);
     600function addSignature($val, $salt=null)
     601{
     602    $app =& App::getInstance();
     603   
     604    if ('' == trim($val)) {
     605        $app->logMsg(sprintf('Cannot add signature to an empty string.', null), LOG_DEBUG, __FILE__, __LINE__);
     606        return '';
     607    }
     608
     609    if (!isset($salt)) {
     610        $salt = $app->getParam('signing_key');
     611    }
     612
     613    return $val . '-' . substr(md5($salt . md5($val . $salt)), 0, 18);
    613614}
    614615
     
    631632 * @access  public
    632633 * @param   string  $signed_val A value with appended signature.
    633  * @param   string  $seed_key       (Optional) A text key to use for computing the signature.
     634 * @param   string  $salt       (Optional) A text key to use for computing the signature.
    634635 * @return  bool    True if the signature matches the var.
    635636 */
    636 function verifySignature($signed_val, $seed_key=null)
     637function verifySignature($signed_val, $salt=null)
    637638{
    638639    // Strip the value from the signed value.
    639640    $val = removeSignature($signed_val);
    640641    // If the signed value matches the original signed value we consider the value safe.
    641     if ($signed_val == addSignature($val, $seed_key)) {
     642    if ($signed_val == addSignature($val, $salt)) {
    642643        // Signature verified.
    643644        return true;
     
    716717        return false;
    717718    }
    718 }
    719 
    720 /**
    721  * If the given $url is on the same web site, return true. This can be used to
    722  * prevent from sending sensitive info in a get query (like the SID) to another
    723  * domain.
    724  *
    725  * @param  string $url    the URI to test.
    726  * @return bool True if given $url is this domain or has no domain (is a relative url), false if it's another.
    727  */
    728 function isMyDomain($url)
    729 {
    730     static $urls = array();
    731 
    732     if (!isset($urls[$url])) {
    733         if (!preg_match('|\w{1,}\.\w{2,5}/|', $url)) {
    734             // If we can't find a domain we assume the URL is relative.
    735             $urls[$url] = true;
    736         } else {
    737             $urls[$url] = preg_match('/' . preg_quote(getenv('HTTP_HOST')) . '/', $url);
    738         }
    739     }
    740     return $urls[$url];
    741 }
    742 
    743 /**
    744  * Takes a URL and returns it without the query or anchor portion
    745  *
    746  * @param  string $url   any kind of URI
    747  * @return string        the URI with ? or # and everything after removed
    748  */
    749 function stripQuery($url)
    750 {
    751     return preg_replace('![?#].*!', '', $url);
    752719}
    753720
     
    810777
    811778/**
     779 * If the given $url is on the same web site, return true. This can be used to
     780 * prevent from sending sensitive info in a get query (like the SID) to another
     781 * domain.
     782 *
     783 * @param  string $url    the URI to test.
     784 * @return bool True if given $url is our domain or has no domain (is a relative url), false if it's another.
     785 */
     786function isMyDomain($url)
     787{
     788    static $urls = array();
     789
     790    if (!isset($urls[$url])) {
     791        if (!preg_match('|https?://[\w.]+/|', $url)) {
     792            // If we can't find a domain we assume the URL is local (i.e. "/my/url/path/" or "../img/file.jpg").
     793            $urls[$url] = true;
     794        } else {
     795            $urls[$url] = preg_match('|https?://[\w.]*' . preg_quote(getenv('HTTP_HOST'), '|') . '|i', $url);
     796        }
     797    }
     798    return $urls[$url];
     799}
     800
     801/**
     802 * Takes a URL and returns it without the query or anchor portion
     803 *
     804 * @param  string $url   any kind of URI
     805 * @return string        the URI with ? or # and everything after removed
     806 */
     807function stripQuery($url)
     808{
     809    return preg_replace('![?#].*!', '', $url);
     810}
     811
     812/**
    812813 * Returns a fully qualified URL to the current script, including the query.
    813814 *
     
    823824 * Compares the current url with the referring url.
    824825 *
    825  * @param  string  $compary_query  Include the query string in the comparison.
    826  * @return bool    true if the current script (or specified valid_referer)
    827  *                 is the referrer. false otherwise.
     826 * @param  bool $exclude_query  Remove the query string first before comparing.
     827 * @return bool                 True if the current URL is the same as the refering URL, false otherwise.
    828828 */
    829829function refererIsMe($exclude_query=false)
  • trunk/lib/Version.inc.php

    r149 r159  
    185185
    186186        // Save as new version.
     187        // TODO: after MySQL 5.0.23 is released this query could benefit from INSERT DELAYED.
    187188        $db->query("
    188189            INSERT INTO " . $db->escapeString($this->getParam('db_table')) . " (
  • trunk/services/admins.php

    r153 r159  
    405405
    406406    // Create version.
    407     $version = Version::getInstance($GLOBALS['auth']);
     407    $version = Version::getInstance($auth);
    408408    $version->create('admin_tbl', 'admin_id', $last_insert_id, $frm['username']);
    409409
     
    449449
    450450    // Create version.
    451     $version = Version::getInstance($GLOBALS['auth']);
     451    $version = Version::getInstance($auth);
    452452    $version->create('admin_tbl', 'admin_id', $frm['admin_id'], $frm['username']);
    453453
  • trunk/services/lock.php

    r141 r159  
    4242
    4343// Titles and navigation header.
    44 $nav->addPage(sprintf(_("Locked record: %s"), $lock->getTitle()));
     44$nav->addPage(sprintf(_("Locked record: <em>%s</em>"), $lock->getTitle()));
    4545
    4646// Templates.
  • trunk/services/versions.php

    r143 r159  
    1717 *****************************************************************************/
    1818
    19 $version = Version::getInstance($GLOBALS['auth']);
     19$version = Version::getInstance($auth);
    2020
    2121// Query arguments to retain their values between page requests.
Note: See TracChangeset for help on using the changeset viewer.