Changeset 502


Ignore:
Timestamp:
Dec 30, 2014 10:24:51 PM (9 years ago)
Author:
anonymous
Message:

Many minor fixes during pulso development

Location:
trunk
Files:
37 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/acl.cli.php

    r484 r502  
    4444// Make sure necessary files exist.
    4545define('COMMON_BASE', realpath('.'));
    46 $db_quth_file = COMMON_BASE . '/global/db_auth.inc.php';
    47 if (!file_exists($db_quth_file)) {
    48     die(sprintf("%s error: the current directory must be common site directory (i.e. the parent directory of the document root) AND the global/db_auth.inc.php file must exist.\n", $this_script));
    49 }
    50 
    51 if (fileowner($db_quth_file) != getmyuid()) {
     46$db_auth_file = false;
     47$rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(COMMON_BASE));
     48$rii->setMaxDepth(2);
     49foreach ($rii as $filename => $file) {
     50    if (mb_strpos($filename, 'db_auth.inc.php') !== false) {
     51        $db_auth_file = $filename;
     52        break;
     53    }
     54}
     55if (!$db_auth_file) {
     56    die(sprintf("%s error: the current directory must be common site directory (i.e. the parent directory of the document root) AND the db_auth.inc.php file must exist.\n", $this_script));
     57}
     58if (fileowner($db_auth_file) != getmyuid()) {
    5259    die(sprintf("%s error: you must execute this script as the owner of the web files.\n", $this_script));
    5360}
    5461
    5562// Set include path.
    56 ini_set('include_path', get_include_path()
    57     . PATH_SEPARATOR . COMMON_BASE
    58 );
     63ini_set('include_path', get_include_path() . PATH_SEPARATOR . COMMON_BASE);
    5964
    6065/********************************************************************
     
    8388    'log_filename' => 'site_log',
    8489));
    85 require_once 'global/db_auth.inc.php';
     90require_once $db_auth_file;
    8691
    8792// Start application-based functionality: database, session, environment, ini setup, etc.
     
    104109if (!$db->tableExists('acl_tbl')) {
    105110    printf("This project doesn't appear to be using ACL (there is no acl_tbl in the %s DB).\n", $app->getParam('db_name'));
     111    $app->stop();
    106112    die;
    107113}
     
    220226    break;
    221227}
     228
     229$app->stop();
     230die;
    222231
    223232
     
    309318    case 'aro' :
    310319        $tbl = 'aro_tbl';
    311         printf("%-35s %-5s %-5s %s\n", 'Request objects', 'lft', 'rgt', 'Added');
     320        printf("%-45s %s\n", 'Request objects', 'Added');
    312321        break;
    313322    case 'aco' :
    314323        $tbl = 'aco_tbl';
    315         printf("%-35s %-5s %-5s %s\n", 'Control objects', 'lft', 'rgt', 'Added');
     324        printf("%-45s %s\n", 'Control objects', 'Added');
    316325        break;
    317326    case 'axo' :
    318327        $tbl = 'axo_tbl';
    319         printf("%-35s %-5s %-5s %s\n", 'Xtra objects', 'lft', 'rgt', 'Added');
     328        printf("%-45s %s\n", 'Xtra objects', 'Added');
    320329        break;
    321330    default :
     
    325334    }
    326335
    327     echo "-----------------------------------------------------------\n";
     336    echo "---------------------------------------------------------------------\n";
    328337
    329338    // Retrieve the left and right value of the $root node.
     
    342351
    343352        // Display indented node title.
    344         printf("%-35s %-5s %-5s %s\n", str_repeat('    ', sizeof($depth)) . $name, $lft, $rgt, date($app->getParam('date_format'), strtotime($added_datetime)));
     353        printf("%-45s %s\n", str_repeat('    ', sizeof($depth)) . $name, date($app->getParam('date_format') . ' ' . $app->getParam('time_format'), strtotime($added_datetime)));
    345354
    346355        // Add this node to the stack.
     
    373382    ");
    374383    echo "\n";
    375     printf("%-25s %-25s %-25s %-6s %-10s\n", 'Request objects', 'Control objects', 'Xtra objects', '', 'Added');
     384    printf("%-25s %-25s %-25s %-6s %-10s\n", 'Request objects', 'Control objects', 'Xtra objects', 'Grant', 'Added');
    376385    echo "------------------------------------------------------------------------------------------------\n";
    377386    while ($p = mysql_fetch_assoc($qid)) {
  • trunk/lib/ACL.inc.php

    r484 r502  
    3737require_once dirname(__FILE__) . '/Cache.inc.php';
    3838
    39 class ACL {
     39class ACL
     40{
    4041
    4142    // A place to keep an object instance for the singleton pattern.
     
    4950        // Automatically create table and verify columns. Better set to false after site launch.
    5051        'create_table' => false,
     52
     53        // Maximum allowed length of names.
     54        // This value can be increased only if {aro,aco,axo}_tbl.name VARCHAR length is increased.
     55        'name_max_length' => 32.
    5156    );
    5257
     
    149154            $db->query("
    150155                CREATE TABLE IF NOT EXISTS acl_tbl (
    151                     aro_id SMALLINT(11) UNSIGNED NOT NULL DEFAULT '0',
    152                     aco_id SMALLINT(11) UNSIGNED NOT NULL DEFAULT '0',
    153                     axo_id SMALLINT(11) UNSIGNED NOT NULL DEFAULT '0',
     156                    aro_id SMALLINT UNSIGNED NOT NULL DEFAULT '0',
     157                    aco_id SMALLINT UNSIGNED NOT NULL DEFAULT '0',
     158                    axo_id SMALLINT UNSIGNED NOT NULL DEFAULT '0',
    154159                    access ENUM('allow', 'deny') DEFAULT NULL,
    155160                    added_datetime DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
     
    180185                    CREATE TABLE IF NOT EXISTS {$a_o}_tbl (
    181186                        {$a_o}_id SMALLINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
    182                         name VARCHAR(32) NOT NULL DEFAULT '',
    183                         lft MEDIUMINT(9) UNSIGNED NOT NULL DEFAULT '0',
    184                         rgt MEDIUMINT(9) UNSIGNED NOT NULL DEFAULT '0',
     187                        name VARCHAR(" . $this->getParam('name_max_length') . ") NOT NULL DEFAULT '',
     188                        lft MEDIUMINT UNSIGNED NOT NULL DEFAULT '0',
     189                        rgt MEDIUMINT UNSIGNED NOT NULL DEFAULT '0',
    185190                        added_datetime DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
    186191                        UNIQUE KEY name (name(15)),
     
    255260        if ('' == trim($name) || '' == trim($parent)) {
    256261            $app->logMsg(sprintf('Cannot add node, parent (%s) or name (%s) missing.', $name, $parent), LOG_WARNING, __FILE__, __LINE__);
     262            return false;
     263        }
     264
     265        // Ensure node node name fits in the column size.
     266        // This value can be increased if {aro,aco.axo}_tbl.name VARCHAR length is increased.
     267        if (strlen(trim($name)) > $this->getParam('name_max_length')) {
     268            $app->logMsg(sprintf('Cannot add node, %s character limit exceeded for name "%s"', $this->getParam('name_max_length'), $name, $parent), LOG_WARNING, __FILE__, __LINE__);
    257269            return false;
    258270        }
     
    718730
    719731        if (!$this->check($aro, $aco, $axo)) {
    720             $message = '' == trim($message) ? sprintf(_("You have insufficient privileges to view <em>%s %s</em>"), $aco, $axo) : $message;
     732            $message = '' == trim($message) ? sprintf(_("Sorry, you have insufficient privileges for <em>%s %s</em>."), $aco, $axo) : $message;
    721733            $app->raiseMsg($message, $type, $file, $line);
    722734            $app->dieBoomerangURL();
  • trunk/lib/App.inc.php

    r501 r502  
    4040require_once dirname(__FILE__) . '/Utilities.inc.php';
    4141
    42 class App {
     42class App
     43{
    4344
    4445    // Minimum version of PHP required for this version of the Codebase.
     
    627628        }
    628629
    629         // Make sure to log in the system's locale.
    630         $locale = setlocale(LC_TIME, 0);
    631         setlocale(LC_TIME, 'C');
    632 
    633630        // Strip HTML tags except any with more than 7 characters because that's probably not a HTML tag, e.g. <email@address.com>.
    634631        preg_match_all('/(<[^>\s]{7,})[^>]*>/', $message, $strip_tags_allow);
     
    678675        }
    679676
     677        // Make sure to log in the system's locale.
     678        $locale = setlocale(LC_TIME, 0);
     679        setlocale(LC_TIME, 'C');
     680
    680681        // Data to be stored for a log event.
    681682        $event = array(
     
    692693        $event_short['url'] = truncate($event_short['url'], 120);
    693694
     695        // Restore original locale.
     696        setlocale(LC_TIME, $locale);
    694697
    695698        // FILE ACTION
     
    702705        if (false !== $this->getParam('log_email_priority') && $priority <= $this->getParam('log_email_priority') && $send_notifications) {
    703706            $hostname = (isset($_SERVER['HTTP_HOST']) && '' != $_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : php_uname('n');
    704             $subject = sprintf('[%s %s] %s', $hostname, $event['type'], mb_substr($message, 0, 64));
     707            $subject = sprintf('[%s %s] %s', $hostname, $event['type'], mb_substr($event['message'], 0, 64));
    705708            $email_msg = sprintf("A %s log event occurred on %s\n\n", $event['type'], $hostname);
    706709            $headers = 'From: ' . $this->getParam('site_email');
     
    724727            file_put_contents('php://stderr', "[{$event['type']}] [{$event['message']}]\n", FILE_APPEND);
    725728        }
    726 
    727         // Restore original locale.
    728         setlocale(LC_TIME, $locale);
    729 
    730         unset($event, $event_short);
    731729
    732730        return true;
     
    850848     *                                     header('Location...') redirections.
    851849     *
     850     * @param   bool    $include_csrf_token     Set to true to include the csrf_token in the form. Only use this for forms with action="post" to prevent the token from being revealed in the URL.
    852851     * @return string url with attached queries and, if not using cookies, the session id
    853852     */
    854     public function url($url, $carry_args=null, $always_include_sid=false)
     853    public function url($url, $carry_args=null, $always_include_sid=false, $include_csrf_token=false)
    855854    {
    856855        if (!$this->running) {
    857856            $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
    858857            return false;
     858        }
     859
     860        if ($this->getParam('csrf_token_enabled') && $include_csrf_token) {
     861            // Include the csrf_token as a carried query argument.
     862            // This token can be validated upon form submission with $app->verifyCSRFToken() or $app->requireValidCSRFToken()
     863            $carry_args = is_array($carry_args) ? $carry_args : array();
     864            $carry_args = array_merge($carry_args, array($this->getParam('csrf_token_name') => $this->getCSRFToken()));
    859865        }
    860866
     
    938944     *
    939945     * @access  public
    940      * @param   string  $url    Input URL to parse.
    941      * @return  string          URL passed through $app->url() and then & turned to $amp;.
     946     * @param   (see param reference for url() method)
     947     * @return  string          URL passed through $app->url() with ampersamds transformed to $amp;
    942948     * @author  Quinn Comendant <quinn@strangecode.com>
    943949     * @since   09 Dec 2005 17:58:45
    944950     */
    945     public function oHREF($url, $carry_args=null, $always_include_sid=false)
    946     {
    947         $url = $this->url($url, $carry_args, $always_include_sid);
    948 
    949         // Replace any & not followed by an html or unicode entity with it's &amp; equivalent.
     951    public function oHREF($url, $carry_args=null, $always_include_sid=false, $include_csrf_token=false)
     952    {
     953        // Process the URL.
     954        $url = $this->url($url, $carry_args, $always_include_sid, $include_csrf_token);
     955
     956        // Replace any & not followed by an html or unicode entity with its &amp; equivalent.
    950957        $url = preg_replace('/&(?![\w\d#]{1,10};)/', '&amp;', $url);
    951958
     
    10931100            return false;
    10941101        }
    1095         $this->logMsg(sprintf('Verified CSRF token %s is in %s', $user_submitted_csrf_token, $csrf_token), LOG_DEBUG, __FILE__, __LINE__);
     1102        $this->logMsg(sprintf('Verified CSRF token %s', $user_submitted_csrf_token), LOG_DEBUG, __FILE__, __LINE__);
    10961103        return true;
    10971104    }
     
    11421149        }
    11431150
    1144         if ('' == $url) {
     1151        if (!$url) {
    11451152            // If URL is not specified, use the redirect_home_url.
    11461153            $url = $this->getParam('redirect_home_url');
     
    12951302        }
    12961303
    1297         $this->logMsg(sprintf('deleteBoomerangURL(%s): %s', $id, $this->getBoomerangURL($id)), LOG_DEBUG, __FILE__, __LINE__);
    1298 
    12991304        if (isset($id) && isset($_SESSION['_app'][$this->_ns]['boomerang']['url'][$id])) {
     1305            $url = $this->getBoomerangURL($id);
    13001306            unset($_SESSION['_app'][$this->_ns]['boomerang']['url'][$id]);
    13011307        } else if (is_array($_SESSION['_app'][$this->_ns]['boomerang']['url'])) {
    1302             array_pop($_SESSION['_app'][$this->_ns]['boomerang']['url']);
    1303         }
     1308            $url = array_pop($_SESSION['_app'][$this->_ns]['boomerang']['url']);
     1309        }
     1310        $this->logMsg(sprintf('deleteBoomerangURL(%s): %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    13041311    }
    13051312
  • trunk/lib/Auth_File.inc.php

    r484 r502  
    4040// ));
    4141
    42 class Auth_File {
     42class Auth_File
     43{
    4344
    4445    // Available encryption types for class Auth_File.
  • trunk/lib/Auth_SQL.inc.php

    r501 r502  
    3030require_once dirname(__FILE__) . '/Email.inc.php';
    3131
    32 class Auth_SQL {
     32class Auth_SQL
     33{
    3334
    3435    // Available hash types for class Auth_SQL.
     
    181182                userpass VARCHAR(255) NOT NULL DEFAULT '',
    182183                userpass_hashtype TINYINT UNSIGNED NOT NULL DEFAULT '0',
    183                 first_name VARCHAR(255) NOT NULL DEFAULT '',
    184                 last_name VARCHAR(255) NOT NULL DEFAULT '',
     184                first_name VARCHAR(50) NOT NULL DEFAULT '',
     185                last_name VARCHAR(50) NOT NULL DEFAULT '',
    185186                email VARCHAR(255) NOT NULL DEFAULT '',
    186                 login_abuse_exempt ENUM('TRUE') DEFAULT NULL,
    187                 blocked ENUM('TRUE') DEFAULT NULL,
     187                login_abuse_exempt ENUM('true') DEFAULT NULL,
     188                blocked ENUM('true') DEFAULT NULL,
    188189                blocked_reason VARCHAR(255) NOT NULL DEFAULT '',
    189                 abuse_warning_level TINYINT(4) NOT NULL DEFAULT '0',
    190                 seconds_online INT(11) NOT NULL DEFAULT '0',
     190                abuse_warning_level TINYINT NOT NULL DEFAULT '0',
     191                seconds_online INT NOT NULL DEFAULT '0',
    191192                last_login_datetime DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
    192193                last_access_datetime DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
    193                 last_login_ip VARCHAR(255) NOT NULL DEFAULT '0.0.0.0',
    194                 added_by_user_id SMALLINT(11) DEFAULT NULL,
    195                 modified_by_user_id SMALLINT(11) DEFAULT NULL,
     194                last_login_ip VARCHAR(45) NOT NULL DEFAULT '0.0.0.0',
     195                added_by_user_id SMALLINT DEFAULT NULL,
     196                modified_by_user_id SMALLINT DEFAULT NULL,
    196197                added_datetime DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
    197198                modified_datetime DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
    198199                KEY " . $this->getParam('db_username_column') . " (" . $this->getParam('db_username_column') . "),
    199200                KEY userpass (userpass),
    200                 KEY email (email)
     201                KEY email (email),
     202                KEY last_login_datetime (last_login_datetime),
     203                KEY last_access_datetime (last_access_datetime)
    201204            )");
    202205
     
    327330            $db->query("
    328331                UPDATE " . $this->_params['db_table'] . " SET
    329                 seconds_online = seconds_online + (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(last_access_datetime)),
     332                seconds_online = seconds_online + ABS(UNIX_TIMESTAMP() - UNIX_TIMESTAMP(last_access_datetime)),
    330333                last_login_datetime = '0000-00-00 00:00:00'
    331334                WHERE " . $this->_params['db_primary_key'] . " = '" . $this->get('user_id') . "'
     
    635638            $db->query("
    636639                UPDATE " . $this->_params['db_table'] . " SET
    637                 seconds_online = seconds_online + (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(last_access_datetime)) + 1,
     640                seconds_online = seconds_online + ABS(UNIX_TIMESTAMP() - UNIX_TIMESTAMP(last_access_datetime)) + 1,
    638641                last_access_datetime = '" . $this->get('last_access_datetime') . "'
    639642                WHERE " . $this->_params['db_primary_key'] . " = '" . $this->get('user_id') . "'
     
    981984        // Issue the password change query.
    982985        $db->query("
    983             UPDATE " . $this->_params['db_table'] . "
    984             SET userpass = '" . $db->escapeString($this->encryptPassword($password, null, $hash_type)) . "'
    985             $userpass_hashtype_clause
     986            UPDATE " . $this->_params['db_table'] . " SET
     987                userpass = '" . $db->escapeString($this->encryptPassword($password, null, $hash_type)) . "',
     988                modified_datetime = NOW(),
     989                modified_by_user_id = '" . $db->escapeString($user_id) . "'
     990                $userpass_hashtype_clause
    986991            WHERE " . $this->_params['db_primary_key'] . " = '" . $db->escapeString($user_id) . "'
    987992        ");
  • trunk/lib/AuthorizeNet.inc.php

    r484 r502  
    5959// }
    6060
    61 class AuthorizeNet {
     61class AuthorizeNet
     62{
    6263
    6364    public $post_url = ''; // The URL to post data to.
  • trunk/lib/CSS.inc.php

    r484 r502  
    2929 * @version 1.2
    3030 */
    31 class CSS {
     31class CSS
     32{
    3233
    3334    // Include these style sheets.
  • trunk/lib/Cache.inc.php

    r484 r502  
    3232 */
    3333
    34 class Cache {
     34class Cache
     35{
    3536
    3637    // A place to keep object instances for the singleton pattern.
  • trunk/lib/Captcha.inc.php

    r479 r502  
    5252-------------------------------------------------------------------------------------
    5353 */
    54 class Captcha {
     54class Captcha
     55{
    5556
    5657    public $secret_key = 'some random seed text for the md5';
  • trunk/lib/Cart.inc.php

    r484 r502  
    6868---------------------------------------------------------------------
    6969 */
    70 class Cart {
     70class Cart
     71{
    7172
    7273    // Namespace of this instance.
  • trunk/lib/Currency.inc.php

    r500 r502  
    3838 */
    3939
    40 class Currency {
     40class Currency
     41{
    4142
    4243    // Configuration parameters for this object.
  • trunk/lib/DB.inc.php

    r497 r502  
    3030 */
    3131
    32 class DB {
     32class DB
     33{
    3334
    3435    // A place to keep an object instance for the singleton pattern.
  • trunk/lib/DBSessionHandler.inc.php

    r484 r502  
    3030 */
    3131
    32 class DBSessionHandler {
     32class DBSessionHandler
     33{
    3334
    3435    public $db; // DB object.
  • trunk/lib/Email.inc.php

    r500 r502  
    5353*/
    5454
    55 class Email {
     55class Email
     56{
    5657
    5758    // Default parameters, to be overwritten by setParam() and read with getParam()
     
    244245    }
    245246
     247    /*
     248    * Returns the body of the current email. This can be used to store the message that is being sent.
     249    * It will use the original template, or the replaced template if it has been processed.
     250    *
     251    * @access   public
     252    * @return   string  Message body.
     253    * @author   Quinn Comendant <quinn@strangecode.com>
     254    * @version  1.0
     255    * @since    18 Nov 2014 21:15:19
     256    */
     257    public function getBody()
     258    {
     259        $final_body = isset($this->_template_replaced) ? $this->_template_replaced : $this->_template;
     260        // Ensure all placeholders have been replaced. Find anything with {...} characters.
     261        if (preg_match('/({[^}]+})/', $final_body, $unreplaced_match)) {
     262            unset($unreplaced_match[0]);
     263            $app->logMsg(sprintf('Cannot get email body. Unreplaced variables in template: %s', getDump($unreplaced_match)), LOG_ERR, __FILE__, __LINE__);
     264            return false;
     265        }
     266        return $final_body;
     267    }
     268
    246269    /**
    247270     * Send email using PHP's mail() function.
     
    295318        // Ensure all placeholders have been replaced. Find anything with {...} characters.
    296319        if (preg_match('/({[^}]+})/', $final_body, $unreplaced_match)) {
    297             $app->logMsg(sprintf('Cannot send email. At least one variable left unreplaced in template: %s', (isset($unreplaced_match[1]) ? $unreplaced_match[1] : '')), LOG_ERR, __FILE__, __LINE__);
     320            unset($unreplaced_match[0]);
     321            $app->logMsg(sprintf('Cannot send email. Unreplaced variables in template: %s', getDump($unreplaced_match)), LOG_ERR, __FILE__, __LINE__);
    298322            return false;
    299323        }
  • trunk/lib/FormValidator.inc.php

    r497 r502  
    5858require_once 'codebase/lib/Validator.inc.php';
    5959
    60 class FormValidator {
     60class FormValidator
     61{
    6162
    6263    // Class parameters.
  • trunk/lib/HTML.inc.php

    r500 r502  
    3838*/
    3939
    40 class HTML {
     40class HTML
     41{
    4142
    4243    // Browsers add names and ids of form controls as properties to the FORM. This results in the properties of the form being replaced.
  • trunk/lib/Hierarchy.inc.php

    r479 r502  
    4242 */
    4343
    44 class Hierarchy {
     44class Hierarchy
     45{
    4546
    4647    /**
  • trunk/lib/Image.inc.php

    r484 r502  
    2828 * @since   14 Apr 2006 20:07:29
    2929 */
    30 class Image {
     30class Image
     31{
    3132
    3233    // Object parameters.
  • trunk/lib/ImageThumb.inc.php

    r484 r502  
    4040define('IMAGETHUMB_METHOD_GD', 7);
    4141
    42 class ImageThumb {
     42class ImageThumb
     43{
    4344
    4445    // General object parameters.
  • trunk/lib/JS.inc.php

    r484 r502  
    2929 * @version 1.2
    3030 */
    31 class JS {
     31class JS
     32{
    3233
    3334    // Include these style sheets.
  • trunk/lib/Lock.inc.php

    r497 r502  
    2929 * @version 2.1
    3030 */
    31 class Lock {
     31class Lock
     32{
    3233
    3334    // A place to keep an object instance for the singleton pattern.
  • trunk/lib/Navigation.inc.php

    r497 r502  
    3434 * @version 2.0
    3535 */
    36 class Navigation {
     36class Navigation
     37{
    3738
    3839    // Configuration parameters for this object.
  • trunk/lib/PEdit.inc.php

    r484 r502  
    6767
    6868 */
    69 class PEdit {
     69class PEdit
     70{
    7071
    7172    // PEdit object parameters.
  • trunk/lib/PageNumbers.inc.php

    r484 r502  
    3737require_once dirname(__FILE__) . '/Prefs.inc.php';
    3838
    39 class PageNumbers {
     39class PageNumbers
     40{
    4041
    4142    public $total_items;       // Total quantity of items.
  • trunk/lib/PayPal.inc.php

    r484 r502  
    3030 * @version 1.0
    3131 */
    32 class PayPal {
     32class PayPal
     33{
    3334
    3435    // General object parameters.
  • trunk/lib/Prefs.inc.php

    r484 r502  
    5252---------------------------------------------------------------------
    5353 */
    54 class Prefs {
     54class Prefs
     55{
    5556
    5657    // Namespace of this instance of Prefs.
  • trunk/lib/ScriptTimer.inc.php

    r484 r502  
    2424 * ScriptTimer.inc.php
    2525 */
    26 class ScriptTimer {
     26class ScriptTimer
     27{
    2728
    2829    public $time_format = '%.3f';
  • trunk/lib/SortOrder.inc.php

    r497 r502  
    3535require_once dirname(__FILE__) . '/Prefs.inc.php';
    3636
    37 class SortOrder {
     37class SortOrder
     38{
    3839
    3940    protected $_columns;
  • trunk/lib/SpellCheck.inc.php

    r484 r502  
    5959*/
    6060
    61 class SpellCheck {
     61class SpellCheck
     62{
    6263
    6364    protected $_params = array(
  • trunk/lib/Upload.inc.php

    r488 r502  
    3838define('UPLOAD_USER_ERR_MOVE_FAILED', 104);
    3939
    40 class Upload {
     40class Upload
     41{
    4142
    4243    // General object parameters.
  • trunk/lib/Utilities.inc.php

    r500 r502  
    941941/**
    942942 * Signs a value using md5 and a simple text key. In order for this
    943  * function to be useful (i.e. secure) the key must be kept secret, which
     943 * function to be useful (i.e. secure) the salt must be kept secret, which
    944944 * means keeping it as safe as database credentials. Putting it into an
    945945 * environment variable set in httpd.conf is a good place.
    946  *
    947  * TODO: consider using more bits-per-character, such as done with:
    948  * http://www.php.net/manual/en/function.sha1.php#86239
    949  * http://blog.kevburnsjr.com/php-unique-hash
    950946 *
    951947 * @access  public
     
    999995 * @param   string  $signed_val A value with appended signature.
    1000996 * @param   string  $salt       (Optional) A text key to use for computing the signature.
     997 * @param   string  $length (Optional) The length of the added signature.
    1001998 * @return  bool    True if the signature matches the var.
    1002999 */
  • trunk/lib/Validator.inc.php

    r500 r502  
    3131 */
    3232
    33 class Validator {
     33class Validator
     34{
    3435
    3536    // Known credit card types.
  • trunk/lib/Version.inc.php

    r497 r502  
    3737 * @version 2.1
    3838 */
    39 class Version {
     39class Version
     40{
    4041
    4142    // A place to keep an object instance for the singleton pattern.
     
    290291        }
    291292
    292         // Replace current record with specified versioned record.
     293        // Disable foreign_key_checks to prevent ON DELETE triggers or restrictions.
     294        $db->query("SET SESSION foreign_key_checks = 0");
     295        // Replace current record with specified versioned record. Consider converting this SQL to use INSERT 
 ON DUPLICATE KEY UPDATE 

    293296        $db->query("
    294             REPLACE INTO " . $record['record_table'] . " (
     297        REPLACE INTO " . $record['record_table'] . " (
    295298                $replace_keys
    296299            ) VALUES (
    297300                $replace_values
    298             )
    299         ");
     301            );
     302        ");
     303        // Re-enable foreign_key_checks.
     304        $db->query("SET SESSION foreign_key_checks = 1");
    300305
    301306        return $record;
     
    468473    {
    469474        $db =& DB::getInstance();
    470 
    471         $this->initDB();
     475        $app =& App::getInstance();
     476
     477        $this->initDB();
     478
     479        if (!$record_table || !$record_key || !$record_val) {
     480            $app->logMsg(sprintf('Invalid current version args: %s, %s, %s.', $record_table, $record_key, $record_val), LOG_ERR, __FILE__, __LINE__);
     481            return false;
     482        }
    472483
    473484        $qid = $db->query("
  • trunk/services/templates/versions_diff.ihtml

    r497 r502  
    4545            $action_links = array();
    4646            if (!getFormData('current', false)) {
    47                 $action_links[] = array('href' => $app->oHREF($_SERVER['PHP_SELF'] . '?op=restore', array('version_id', 'version_title')), 'value' => _("Restore this saved version"), 'class' => 'small button alert', 'accesskey' => 'r');
     47                $action_links[] = array('href' => $app->oHREF('?op=restore', array('version_id', 'version_title')), 'value' => _("Restore this saved version"), 'class' => 'small button alert', 'accesskey' => 'r');
    4848            }
    49             $action_links[] = array('href' => $app->ohref(oTxt($_SERVER['PHP_SELF'])), 'value' => _("Cancel"), 'class' => 'small button secondary', 'accesskey' => 'b');
     49            $action_links[] = array('href' => $app->ohref('?op=cancel'), 'value' => _("Cancel"), 'class' => 'small button secondary', 'accesskey' => 'c');
    5050            HTML::printButtons($action_links);
    5151            ?>
  • trunk/services/templates/versions_list.ihtml

    r497 r502  
    5050                <div class="sc-help"><?php printf(_("When there are more than %s versions, those over %s days old are deleted."), $version->getParam('min_qty'), $version->getParam('min_days')); ?></div>
    5151                <?php
    52                 HTML::printButtons(array(
    53                     array('name' => 'op', 'value' => _("Cancel"), 'class' => 'small button secondary', 'accesskey' => 'c'),
    54                 ));
     52                // Buttons.
     53                $action_links = array();
     54                $action_links[] = array('href' => $app->ohref('?op=cancel'), 'value' => _("Cancel"), 'class' => 'small button secondary', 'accesskey' => 'c');
     55                HTML::printButtons($action_links);
    5556                ?>
    5657            </div>
  • trunk/services/templates/versions_view.ihtml

    r497 r502  
    2828            $action_links = array();
    2929            if (!getFormData('current', false)) {
    30                 $action_links[] = array('href' => $app->oHREF($_SERVER['PHP_SELF'] . '?op=restore', array('version_id', 'version_title')), 'value' => _("Restore this saved version"), 'class' => 'small button alert', 'accesskey' => 'r');
     30                $action_links[] = array('href' => $app->oHREF('?op=restore', array('version_id', 'version_title')), 'value' => _("Restore this saved version"), 'class' => 'small button alert', 'accesskey' => 'r');
    3131            }
    32             $action_links[] = array('href' => $app->ohref(oTxt($_SERVER['PHP_SELF'])), 'value' => _("Cancel"), 'class' => 'small button secondary', 'accesskey' => 'b');
     32            $action_links[] = array('href' => $app->ohref('?op=cancel'), 'value' => _("Cancel"), 'class' => 'small button secondary', 'accesskey' => 'c');
    3333            HTML::printButtons($action_links);
    3434            ?>
  • trunk/services/versions.php

    r497 r502  
    7878switch (getFormData('op')) {
    7979
    80 case _("Cancel") :
    81     $app->dieBoomerangURL('versions', false);
     80case 'cancel' :
     81    if ($app->validBoomerangURL('version')) {
     82        // Display boomerang page.
     83        $app->dieBoomerangURL('version');
     84    }
     85    // Display default page.
     86    $app->dieURL(false, false);
    8287    break;
    8388
Note: See TracChangeset for help on using the changeset viewer.