Changeset 468


Ignore:
Timestamp:
Feb 20, 2014 3:03:59 AM (10 years ago)
Author:
anonymous
Message:

Completed integrating /branches/eli_branch into /trunk. Changes include:

  • Removed closing ?> from end of files
  • Upgrade old-style contructor methods to use construct() instead.
  • Class properties and methods defined as public, private, static or protected
  • Ensure code runs under E_ALL with only mysql_* deprecated warnings
  • Search for the '@' symbol anywhere it might be used to supress runtime errors, then replace with proper error recovery.
  • Run the php cli -l option to check files for syntax errors.
  • Bring tests up-to-date with latest version and methods of PHPUnit
Location:
trunk
Files:
91 edited
4 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/bin/acl.cli.php

    r415 r468  
    55 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    66 * Copyright 2001-2012 Strangecode, LLC
    7  * 
     7 *
    88 * This file is part of The Strangecode Codebase.
    99 *
     
    1212 * Free Software Foundation, either version 3 of the License, or (at your option)
    1313 * any later version.
    14  * 
     14 *
    1515 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1616 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1717 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1818 * details.
    19  * 
     19 *
    2020 * You should have received a copy of the GNU General Public License along with
    2121 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    113113        break;
    114114    case 'all' :
    115         listObjects('root', 'aro');                               
    116         listObjects('root', 'aco');                               
     115        listObjects('root', 'aro');
     116        listObjects('root', 'aco');
    117117        listObjects('root', 'axo');
    118118        break;
     
    238238but could just as easily be SPICES -> CUISINES -> DISHES. A privilege is
    239239allowed if a user (ARO) can perform an action (ACO) on something (AXO).
    240 For example, with an `ARO->ACO->AXO` of `Bob->edit->4`, Bob can edit article 4. 
    241 If the AXO were omitted (i.e. just `Bob->edit`), this becomes "Bob can edit" 
     240For example, with an `ARO->ACO->AXO` of `Bob->edit->4`, Bob can edit article 4.
     241If the AXO were omitted (i.e. just `Bob->edit`), this becomes "Bob can edit"
    242242(he can edit any object).
    243243
    244 Each access object is stored as a node in hierarchical tree structures. 
     244Each access object is stored as a node in hierarchical tree structures.
    245245A permission granted to a node is applied to all its children. If a child
    246246node is specified a different permission that is more specific than
     
    252252
    253253Where command is any of the following (with arguments):
    254    
     254
    255255    initdb
    256256    list [aro | aco | axo | all | perms]
     
    268268    revoke aro [aco] [axo]
    269269    delete [aro] [aco] [axo]
    270    
    271 
    272 For the add*, mv*, grant, and revoke commands if any of the optional 
    273 args are not provided, 'root' is assumed. For the delete command 
     270
     271
     272For the add*, mv*, grant, and revoke commands if any of the optional
     273args are not provided, 'root' is assumed. For the delete command
    274274'null' is considered a wild-card to delete all objects of that type.
    275275
     
    297297    $db =& DB::getInstance();
    298298    global $this_script;
    299    
     299
    300300    echo "\n";
    301301
     
    324324    $qid = $db->query("SELECT lft, rgt FROM $tbl WHERE name = '" . $db->escapeString($root) . "'");
    325325    list($lft, $rgt) = mysql_fetch_row($qid);
    326    
     326
    327327    $depth = array();
    328    
     328
    329329    // Retrieve all descendants of the root node
    330330    $qid = $db->query("SELECT name, lft, rgt, added_datetime FROM $tbl WHERE lft BETWEEN $lft AND $rgt ORDER BY lft ASC");
     
    334334            array_pop($depth);
    335335        }
    336    
     336
    337337        // Display indented node title.
    338338        printf("%-35s %-5s %-5s %s\n", str_repeat('    ', sizeof($depth)) . $name, $lft, $rgt, date($app->getParam('date_format'), strtotime($added_datetime)));
    339        
     339
    340340        // Add this node to the stack.
    341341        $depth[] = $rgt;
     
    356356    $db =& DB::getInstance();
    357357    global $this_script;
    358    
     358
    359359    // Retrieve access value from db.
    360360    $qid = $db->query("
     
    371371    while ($p = mysql_fetch_assoc($qid)) {
    372372        printf("%-25s %-25s %-25s \033[0;%sm%-6s\033[0m %-10s\n", $p['aro'], $p['aco'], $p['axo'], ('allow' == $p['access'] ? '32' : '31'), $p['access'], date($app->getParam('date_format'), strtotime($p['added_datetime'])));
    373     }   
    374 }
    375 
    376 
    377 ?>
     373    }
     374}
     375
     376
  • trunk/bin/file_importer.php

    r412 r468  
    123123// }
    124124//
    125 // ?>
  • trunk/bin/module_maker/_config.inc.php

    r457 r468  
    7373
    7474
    75 ?>
  • trunk/bin/module_maker/form_template.cli.php

    r412 r468  
    249249
    250250echo join("\n", $output);
    251 
    252 ?>
  • trunk/bin/module_maker/list_template.cli.php

    r461 r468  
    3636    $db_tbl = $_SERVER['argv'][2];
    3737} else {
    38     die(sprintf("Usage: %s site_directory db_table [operation]\nValid operations include: %s", basename($_SERVER['argv'][0]), join(', ', $valid_ops)));
     38    die(sprintf("Usage: %s site_directory db_table [operation]\nValid operations include: %s\n", basename($_SERVER['argv'][0]), join(', ', $valid_ops)));
    3939}
    4040
     
    213213
    214214E_O_F;
    215 
    216 ?>
  • trunk/bin/module_maker/module.cli.php

    r413 r468  
    596596    }
    597597}
    598 
    599 ?>
  • trunk/bin/module_maker/skel/admin.php

    r408 r468  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    236236    $db =& DB::getInstance();
    237237    $app =& App::getInstance();
    238    
     238
    239239    $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $id);
    240240    if ($lock->isLocked() && !$lock->isMine()) {
     
    278278    $db =& DB::getInstance();
    279279    $app =& App::getInstance();
    280    
     280
    281281    $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $id);
    282282    if ($lock->isLocked() && !$lock->isMine()) {
     
    314314    $db =& DB::getInstance();
    315315    $app =& App::getInstance();
    316    
     316
    317317    // Remove any stale cached list data.
    318318    $cache->delete('list');
     
    337337    $db =& DB::getInstance();
    338338    $app =& App::getInstance();
    339    
     339
    340340    $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $frm['%PRIMARY_KEY%']);
    341341    if ($lock->isLocked() && !$lock->isMine()) {
     
    364364    global $tmp_prefs;
    365365    global $cache;
    366     $db =& DB::getInstance();   
    367     $app =& App::getInstance();
    368    
     366    $db =& DB::getInstance();
     367    $app =& App::getInstance();
     368
    369369    $where_clause = '';
    370370
     
    379379    if (getFormData('filter___///__', false)) {
    380380        // Limit by filter.
    381         $where_clause .= (empty($where_clause) ? 'WHERE' : 'AND') . " __///__ = '" . $db->escapeString(getFormData('filter___///__')) . "'";
     381        $where_clause .= (empty($where_clause) ? 'WHERE' : ' AND') . " __///__ = '" . $db->escapeString(getFormData('filter___///__')) . "'";
    382382    }
    383383
     
    425425        return $list;
    426426    }
    427    
     427
    428428    // The list was not cached, so issue the real query.
    429429    $qid = $db->query($sql);
     
    445445    $db =& DB::getInstance();
    446446    $app =& App::getInstance();
    447    
     447
    448448    if (!is_array($ranks)) {
    449449        $app->logMsg('Saving rank failed, data posted is not an array: ' . $ranks, LOG_ERR, __FILE__, __LINE__);
     
    476476    }
    477477}
    478 
    479 ?>
  • trunk/bin/module_maker/skel/public.php

    r396 r468  
    145145include 'footer.ihtml';
    146146
    147 ?>
  • trunk/bin/module_maker/sql.cli.php

    r412 r468  
    55 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    66 * Copyright 2001-2012 Strangecode, LLC
    7  * 
     7 *
    88 * This file is part of The Strangecode Codebase.
    99 *
     
    1212 * Free Software Foundation, either version 3 of the License, or (at your option)
    1313 * any later version.
    14  * 
     14 *
    1515 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1616 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1717 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1818 * details.
    19  * 
     19 *
    2020 * You should have received a copy of the GNU General Public License along with
    2121 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    3636    $db_tbl = $_SERVER['argv'][2];
    3737} else {
    38     die(sprintf("Usage: %s site_directory db_table [operation]\nValid operations include: %s", basename($_SERVER['argv'][0]), join(', ', $valid_ops)));
     38    die(sprintf("Usage: %s site_directory db_table [operation]\nValid operations include: %s\n", basename($_SERVER['argv'][0]), join(', ', $valid_ops)));
    3939}
    4040
     
    218218
    219219echo isset($op) ? '' : "\n\n\n";
    220 ?>
  • trunk/bin/module_maker/validation.cli.php

    r412 r468  
    309309    " . join("\n    ", $o) . "
    310310}";
    311 ?>
  • trunk/docs/codebase_v1-to-v2_upgrade_checklist.txt

    r334 r468  
    1 <?php
    2 
    31=====================================================================
    42In General
     
    86
    97    include SITE_BASE . '/_templates/header.ihtml';
    10    
     8
    119do this:
    1210
    1311    include 'header.ihtml';
    14    
     12
    1513
    16142. CODE_BASE is a defunct constant. The location of the codebase is no longer important as long as it can be found in the currently configured include_path. This will usually include the local site directory (where the codebase normally would be found) as well as the server-wide /usr/lib/php directory where the codebase might be included for the whole server. So now, instead of this:
    1715
    1816    require_once CODE_BASE . '/lib/Utilities.inc.php';
    19    
     17
    2018do this:
    2119
    2220    require_once 'codebase/lib/Utilities.inc.php';
    23    
    24    
     21
     22
    25233. $CFG-> variables are gone. Most of these should be converted into their $app and $auth equivalents. If a $CFG variable is NOT something used by the codebase but is still needed by the website application, I suggest converting these values to a $cfg array. For example, this:
    2624
    2725    $CFG->gallery_images_url = '/gallery_images';
    28    
     26
    2927should become:
    3028
    3129    $cfg['gallery_images_url'] = '/gallery_images';
    32    
     30
    3331And of course change the code where they are used to support the array instead of object-properties. If the array is inside of double-quotes it should be written like:
    3432
    35     "{$cfg['gallery_images_url']}/my/path". 
    36    
    37 If the value used is now to be retrieved from a $object->getParam(...) method call, you'll need to do this: 
     33    "{$cfg['gallery_images_url']}/my/path".
     34
     35If the value used is now to be retrieved from a $object->getParam(...) method call, you'll need to do this:
    3836
    3937    $object->getParam('gallery_images_url') . '/my/path'
     
    4341
    4442    <a href="<?php echo ohref("$CFG->site_url/my/file.php"); ?>">
    45    
     43
    4644to this:
    4745
    4846    <a href="<?php echo $app->ohref("/my/file.php"); ?>">
    49    
     47
    5048(In other words, the URL should be a not-fully-qualified URL starting with a slash.)
    5149
     
    6260        '\1' => '\2'
    6361    ));
    64    
    65    
     62
     63
    66646. Many classes now require object-method calls, and the object must be globally scoped. For example, to call the $cache->exists() method inside a function, be sure to add:
    6765
    6866    global $cache;
    69    
     67
    7068at the top of the function.
    7169
    72    
     70
    7371
    7472=====================================================================
     
    8078---------------------------------------------------------------------
    8179$CFG global variables are converted to object properties specific to their usage.
    82    
     80
    8381For example:
    8482
     
    9896Convert functions to methods.
    9997
    100 raiseMsg(...)                           $app->raiseMsg(...) 
    101 logMsg(...)                             $app->logMsg(...) 
     98raiseMsg(...)                           $app->raiseMsg(...)
     99logMsg(...)                             $app->logMsg(...)
    102100include 'message_header.ihtml';         $app->printRaisedMessages();
    103101$carry_queries = array(... , ...);      $app->carryQuery(...);  //call for each value in array
    104 ohref(...)                              $app->ohref(...) 
    105 printHiddenSession(...);                $app->printHiddenSession(...); 
    106 dieURL(...);                            $app->dieURL(...); 
    107 dieBoomerangURL(...);                   $app->dieBoomerangURL(...); 
    108 setBoomerangURL(...);                   $app->setBoomerangURL(...); 
    109 getBoomerangURL(...);                   $app->getBoomerangURL(...); 
    110 validBoomerangURL(...);                 $app->validBoomerangURL(...); 
    111 deleteBoomerangURL(...);                $app->deleteBoomerangURL(...); 
     102ohref(...)                              $app->ohref(...)
     103printHiddenSession(...);                $app->printHiddenSession(...);
     104dieURL(...);                            $app->dieURL(...);
     105dieBoomerangURL(...);                   $app->dieBoomerangURL(...);
     106setBoomerangURL(...);                   $app->setBoomerangURL(...);
     107getBoomerangURL(...);                   $app->getBoomerangURL(...);
     108validBoomerangURL(...);                 $app->validBoomerangURL(...);
     109deleteBoomerangURL(...);                $app->deleteBoomerangURL(...);
    112110sslOn();                                $app->sslOn();
    113111sslOff();                               $app->sslOff();
     
    121119=====================================================================
    122120DB
    123 ===================================================================== 
     121=====================================================================
    124122
    125123dbQuery(...)                            $db->query(...)
     
    209207
    210208    $lock = new RecordLock($GLOBALS['_admin']);
    211    
     209
    212210to:
    213211
     
    215213    global $auth;
    216214    $lock =& Lock::getInstance($auth);
    217      
     215
    218216And instantiate the original global $lock object in _config.inc.php as follows:
    219217
     
    236234
    237235    $version = new RecordVersion();
    238    
     236
    239237to:
    240238
     
    250248Changed all method calls to now require object calls rather than static calls. In other words, change this:
    251249
    252     if (SessionCache::isCached('mydata')) { 
     250    if (SessionCache::isCached('mydata')) {
    253251        $list = SessionCache::getCache('mydata');
    254252    }
     
    304302
    305303include_once 'form_error_header.ihtml';      $fv->printErrorMessages();
    306 
    307 
    308 ?>
  • trunk/docs/examples/_config.inc.php

    r432 r468  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
    2121 */
    2222
    23 /** 
     23/**
    2424 * _config.inc.php lives in the document root of the site/application. It is the beginning of everything.
    2525 *
     
    2828 * @since   03 Dec 2005 19:09:32
    2929 */
    30  
     30
    3131// The constant __FILE__ must be an absolute directory path, starting with / on unix or C: on windows.
    3232// To work around a PHP bug always include this config file with: require_once dirname(__FILE__) . '/_config.inc.php';
     
    3939define('COMMON_BASE', realpath(dirname(__FILE__) . '/../'));
    4040
    41 // The DocRoot for this application. SITE_BASE is different from $_SERVER['DOCUMENT_ROOT'] because the 
     41// The DocRoot for this application. SITE_BASE is different from $_SERVER['DOCUMENT_ROOT'] because the
    4242// latter does not change when using the apache Alias directive or URL Rewriting to define a site.
    4343define('SITE_BASE', dirname(__FILE__));
     
    148148require_once 'codebase/lib/Cache.inc.php';
    149149$cache = new Cache('global');
    150 $cache->setParam(array('enabled' => true));
     150$cache->setParam(array('enabled' => true)); // TODO: Enable caching after site launch.
    151151
    152152// Setup CSS files to include. These will always be available.
    153153require_once 'codebase/lib/CSS.inc.php';
    154154$css = new CSS();
    155 $css->setParam(array('cache_css' => false)); /// Enable caching after site launch.
     155$css->setParam(array('cache_css' => false)); // TODO: Enable caching after site launch.
    156156$css->setFile('codebase/css/codebase.inc.css');
    157157$css->setFile('codebase/css/utilities.inc.css');
     
    170170// require_once 'global/config.inc.php';
    171171
    172 ?>
  • trunk/docs/examples/contact_form/contact.php

    r413 r468  
    119119}
    120120
    121 ?>
  • trunk/docs/examples/db_auth.inc.php

    r404 r468  
    3535    'db_pass' => '',
    3636));
    37 ?>
  • trunk/docs/examples/example.cli.php

    r396 r468  
    146146
    147147
    148 ?>
  • trunk/docs/examples/script_template.php

    r396 r468  
    6060
    6161
    62 ?>
  • trunk/lib/ACL.inc.php

    r457 r468  
    3939class ACL {
    4040
     41    // A place to keep an object instance for the singleton pattern.
     42    private static $instance = null;
     43
    4144    // Configuration parameters for this object.
    42     var $_params = array(
    43 
     45    private $_params = array(
    4446        // If false nothing will be cached or retrieved. Useful for testing realtime data requests.
    4547        'enable_cache' => true,
     
    5254     * Constructor.
    5355     */
    54     function ACL()
     56    public function __construct()
    5557    {
    5658        $app =& App::getInstance();
     
    7375     * @static
    7476     */
    75     static function &getInstance()
    76     {
    77         static $instance = null;
    78 
    79         if ($instance === null) {
    80             $instance = new ACL();
    81         }
    82 
    83         return $instance;
     77    public static function &getInstance()
     78    {
     79        if (self::$instance === null) {
     80            self::$instance = new self();
     81        }
     82
     83        return self::$instance;
    8484    }
    8585
     
    9191     * @param  array    $params     Array of parameters (key => val pairs).
    9292     */
    93     function setParam($params)
     93    public function setParam($params)
    9494    {
    9595        $app =& App::getInstance();
     
    110110     * @return mixed               Configured parameter value.
    111111     */
    112     function getParam($param)
     112    public function getParam($param)
    113113    {
    114114        $app =& App::getInstance();
     
    129129     * @since   04 Jun 2006 16:41:42
    130130     */
    131     function initDB($recreate_db=false)
     131    public function initDB($recreate_db=false)
    132132    {
    133133        $app =& App::getInstance();
     
    224224    * @since    14 Jun 2006 22:39:29
    225225    */
    226     function add($name, $parent=null, $type)
     226    public function add($name, $parent=null, $type)
    227227    {
    228228        $app =& App::getInstance();
     
    287287
    288288    // Alias functions for the different object types.
    289     function addRequestObject($name, $parent=null)
     289    public function addRequestObject($name, $parent=null)
    290290    {
    291291        return $this->add($name, $parent, 'aro');
    292292    }
    293     function addControlObject($name, $parent=null)
     293    public function addControlObject($name, $parent=null)
    294294    {
    295295        return $this->add($name, $parent, 'aco');
    296296    }
    297     function addXtraObject($name, $parent=null)
     297    public function addXtraObject($name, $parent=null)
    298298    {
    299299        return $this->add($name, $parent, 'axo');
     
    311311    * @since    14 Jun 2006 22:39:29
    312312    */
    313     function remove($name, $type)
     313    public function remove($name, $type)
    314314    {
    315315        $app =& App::getInstance();
     
    368368
    369369    // Alias functions for the different object types.
    370     function removeRequestObject($name)
     370    public function removeRequestObject($name)
    371371    {
    372372        return $this->remove($name, 'aro');
    373373    }
    374     function removeControlObject($name)
     374    public function removeControlObject($name)
    375375    {
    376376        return $this->remove($name, 'aco');
    377377    }
    378     function removeXtraObject($name)
     378    public function removeXtraObject($name)
    379379    {
    380380        return $this->remove($name, 'axo');
     
    393393    * @since    14 Jun 2006 22:39:29
    394394    */
    395     function move($name, $new_parent, $type)
     395    public function move($name, $new_parent, $type)
    396396    {
    397397        $app =& App::getInstance();
     
    490490
    491491    // Alias functions for the different object types.
    492     function moveRequestObject($name, $new_parent=null)
     492    public function moveRequestObject($name, $new_parent=null)
    493493    {
    494494        return $this->move($name, $new_parent, 'aro');
    495495    }
    496     function moveControlObject($name, $new_parent=null)
     496    public function moveControlObject($name, $new_parent=null)
    497497    {
    498498        return $this->move($name, $new_parent, 'aco');
    499499    }
    500     function moveXtraObject($name, $new_parent=null)
     500    public function moveXtraObject($name, $new_parent=null)
    501501    {
    502502        return $this->move($name, $new_parent, 'axo');
     
    516516    * @since    15 Jun 2006 01:58:48
    517517    */
    518     function grant($aro=null, $aco=null, $axo=null, $access='allow')
     518    public function grant($aro=null, $aco=null, $axo=null, $access='allow')
    519519    {
    520520        $app =& App::getInstance();
     
    573573    * @since    15 Jun 2006 04:35:54
    574574    */
    575     function revoke($aro=null, $aco=null, $axo=null)
     575    public function revoke($aro=null, $aco=null, $axo=null)
    576576    {
    577577        return $this->grant($aro, $aco, $axo, 'deny');
     
    591591    * @since    20 Jun 2006 20:16:12
    592592    */
    593     function delete($aro=null, $aco=null, $axo=null)
     593    public function delete($aro=null, $aco=null, $axo=null)
    594594    {
    595595        $app =& App::getInstance();
     
    650650    * @since    15 Jun 2006 03:58:23
    651651    */
    652     function check($aro, $aco=null, $axo=null)
     652    public function check($aro, $aco=null, $axo=null)
    653653    {
    654654        $app =& App::getInstance();
     
    713713    * @since    20 Jan 2014 12:09:03
    714714    */
    715     function requireAllow($aro, $aco=null, $axo=null, $message='', $type=MSG_NOTICE, $file=null, $line=null)
     715    public function requireAllow($aro, $aco=null, $axo=null, $message='', $type=MSG_NOTICE, $file=null, $line=null)
    716716    {
    717717        $app =& App::getInstance();
     
    725725
    726726} // End class.
    727 
    728 
    729 ?>
  • trunk/lib/App.inc.php

    r453 r468  
    4242class App {
    4343
     44    // A place to keep an object instance for the singleton pattern.
     45    private static $instance = null;
     46
    4447    // Namespace of this application instance.
    45     var $_ns;
     48    private $_ns;
    4649
    4750    // If $app->start has run successfully.
    48     var $running = false;
     51    public $running = false;
    4952
    5053    // Instance of database object.
    51     var $db;
     54    public $db;
    5255
    5356    // Array of query arguments will be carried persistently between requests.
    54     var $_carry_queries = array();
     57    private $_carry_queries = array();
    5558
    5659    // Dictionary of global application parameters.
    57     var $_params = array();
     60    private $_params = array();
    5861
    5962    // Default parameters.
    60     var $_param_defaults = array(
     63    private $_param_defaults = array(
    6164
    6265        // Public name and email address for this application.
     
    162165
    163166    /**
     167     * Constructor.
     168     */
     169    public function __construct($namespace='')
     170    {
     171        // Set namespace of application instance.
     172        $this->_ns = $namespace;
     173
     174        // Initialize default parameters.
     175        $this->_params = array_merge($this->_params, $this->_param_defaults);
     176
     177        // Begin timing script.
     178        require_once dirname(__FILE__) . '/ScriptTimer.inc.php';
     179        $this->timer = new ScriptTimer();
     180        $this->timer->start('_app');
     181    }
     182
     183    /**
    164184     * This method enforces the singleton pattern for this class. Only one application is running at a time.
    165185     *
     
    169189     * @static
    170190     */
    171     static function &getInstance($namespace='')
    172     {
    173         static $instance = null;
    174 
    175         if ($instance === null) {
    176             $instance = new App($namespace);
    177         }
    178 
    179         return $instance;
    180     }
    181 
    182     /**
    183      * Constructor.
    184      */
    185     function App($namespace='')
    186     {
    187         // Set namespace of application instance.
    188         $this->_ns = $namespace;
    189 
    190         // Initialize default parameters.
    191         $this->_params = array_merge($this->_params, $this->_param_defaults);
    192 
    193         // Begin timing script.
    194         require_once dirname(__FILE__) . '/ScriptTimer.inc.php';
    195         $this->timer = new ScriptTimer();
    196         $this->timer->start('_app');
     191    public static function &getInstance($namespace='')
     192    {
     193        if (self::$instance === null) {
     194            // TODO: Yep, having a namespace with one singletone instance is not very useful.
     195            self::$instance = new self($namespace);
     196        }
     197
     198        return self::$instance;
    197199    }
    198200
     
    203205     * @param  array    $param     Array of parameters (key => val pairs).
    204206     */
    205     function setParam($param=null)
     207    public function setParam($param=null)
    206208    {
    207209        if (isset($param) && is_array($param)) {
     
    218220     * @return  mixed               Parameter value, or null if not existing.
    219221     */
    220     function getParam($param=null)
     222    public function getParam($param=null)
    221223    {
    222224        if ($param === null) {
     
    225227            return $this->_params[$param];
    226228        } else {
    227             trigger_error(sprintf('Parameter is not set: %s', $param), E_USER_NOTICE);
    228229            return null;
    229230        }
     
    237238     * @since   15 Jul 2005 00:32:21
    238239     */
    239     function start()
     240    public function start()
    240241    {
    241242        if ($this->running) {
     
    275276
    276277            // DB connection parameters taken from environment variables in the httpd.conf file, readable only by root.
    277             if (!empty($_SERVER['DB_SERVER'])) {
     278            if (!empty($_SERVER['DB_SERVER']) && !$this->getParam('db_server')) {
    278279                $this->setParam(array('db_server' => $_SERVER['DB_SERVER']));
    279280            }
    280             if (!empty($_SERVER['DB_NAME'])) {
     281            if (!empty($_SERVER['DB_NAME']) && !$this->getParam('db_name')) {
    281282                $this->setParam(array('db_name' => $_SERVER['DB_NAME']));
    282283            }
    283             if (!empty($_SERVER['DB_USER'])) {
     284            if (!empty($_SERVER['DB_USER']) && !$this->getParam('db_user')) {
    284285                $this->setParam(array('db_user' => $_SERVER['DB_USER']));
    285286            }
    286             if (!empty($_SERVER['DB_PASS'])) {
     287            if (!empty($_SERVER['DB_PASS']) && !$this->getParam('db_pass')) {
    287288                $this->setParam(array('db_pass' => $_SERVER['DB_PASS']));
    288289            }
     
    394395     * @since   17 Jul 2005 17:20:18
    395396     */
    396     function stop()
     397    public function stop()
    397398    {
    398399        session_write_close();
    399         restore_include_path();
    400400        $this->running = false;
    401401        $num_queries = 0;
     
    423423     * @param string $line    __LINE__.
    424424     */
    425     function raiseMsg($message, $type=MSG_NOTICE, $file=null, $line=null)
     425    public function raiseMsg($message, $type=MSG_NOTICE, $file=null, $line=null)
    426426    {
    427427        $message = trim($message);
     
    465465     * @since   21 Dec 2005 13:09:20
    466466     */
    467     function getRaisedMessages()
     467    public function getRaisedMessages()
    468468    {
    469469        if (!$this->running) {
     
    471471            return false;
    472472        }
    473 
    474473        return isset($_SESSION['_app'][$this->_ns]['messages']) ? $_SESSION['_app'][$this->_ns]['messages'] : array();
    475474    }
     
    482481     * @since   21 Dec 2005 13:21:54
    483482     */
    484     function clearRaisedMessages()
     483    public function clearRaisedMessages()
    485484    {
    486485        if (!$this->running) {
     
    503502     * @since   15 Jul 2005 01:39:14
    504503     */
    505     function printRaisedMessages($above='', $below='', $print_gotohash_js=false, $hash='sc-msg')
    506     {
     504    public function printRaisedMessages($above='', $below='', $print_gotohash_js=false, $hash='sc-msg')
     505    {
     506
    507507        if (!$this->running) {
    508508            $this->logMsg(sprintf('Canceled method call %s, application not running.', __FUNCTION__), LOG_NOTICE, __FILE__, __LINE__);
     
    576576     * @param string $line      The line of the file where the log event occurs.
    577577     */
    578     function logMsg($message, $priority=LOG_INFO, $file=null, $line=null)
     578    public function logMsg($message, $priority=LOG_INFO, $file=null, $line=null)
    579579    {
    580580        static $previous_events = array();
     
    690690        // SCREEN ACTION
    691691        if (false !== $this->getParam('log_screen_priority') && $priority <= $this->getParam('log_screen_priority')) {
    692             echo "[{$event['type']}] [{$event['message']}]\n";
     692            file_put_contents('php://stderr', "[{$event['type']}] [{$event['message']}]\n", FILE_APPEND);
    693693        }
    694694
     
    706706     * @return                The string representation of $priority.
    707707     */
    708     function logPriorityToString($priority) {
     708    public function logPriorityToString($priority) {
    709709        $priorities = array(
    710710            LOG_EMERG   => 'emergency',
     
    735735     * @since   13 Oct 2007 11:34:51
    736736     */
    737     function setQuery($query_key, $val)
     737    public function setQuery($query_key, $val)
    738738    {
    739739        if (!is_array($query_key)) {
     
    757757     * @since   14 Nov 2005 19:24:52
    758758     */
    759     function carryQuery($query_key, $default=false)
     759    public function carryQuery($query_key, $default=false)
    760760    {
    761761        if (!is_array($query_key)) {
     
    782782     * @since   18 Jun 2007 20:57:29
    783783     */
    784     function dropQuery($query_key, $unset=false)
     784    public function dropQuery($query_key, $unset=false)
    785785    {
    786786        if (!is_array($query_key)) {
     
    818818     * @return string url with attached queries and, if not using cookies, the session id
    819819     */
    820     function url($url, $carry_args=null, $always_include_sid=false)
     820    public function url($url, $carry_args=null, $always_include_sid=false)
    821821    {
    822822        if (!$this->running) {
     
    909909     * @since   09 Dec 2005 17:58:45
    910910     */
    911     function oHREF($url, $carry_args=null, $always_include_sid=false)
     911    public function oHREF($url, $carry_args=null, $always_include_sid=false)
    912912    {
    913913        $url = $this->url($url, $carry_args, $always_include_sid);
     
    929929     *                                      false  <-- To not carry any queries. If URL already has queries those will be retained.
    930930     */
    931     function printHiddenSession($carry_args=null)
     931    public function printHiddenSession($carry_args=null)
    932932    {
    933933        if (!$this->running) {
     
    995995     * @param   bool    $always_include_sid     Force session id to be added to Location header.
    996996     */
    997     function dieURL($url, $carry_args=null, $always_include_sid=false)
     997    public function dieURL($url, $carry_args=null, $always_include_sid=false)
    998998    {
    999999        if (!$this->running) {
     
    10421042    * @since    31 Mar 2006 19:17:00
    10431043    */
    1044     function dieBoomerangURL($id=null, $carry_args=null, $default_url=null, $queryless_referrer_comparison=false)
     1044    public function dieBoomerangURL($id=null, $carry_args=null, $default_url=null, $queryless_referrer_comparison=false)
    10451045    {
    10461046        if (!$this->running) {
     
    10851085     * FIXME: url garbage collection?
    10861086     */
    1087     function setBoomerangURL($url=null, $id=null)
     1087    public function setBoomerangURL($url=null, $id=null)
    10881088    {
    10891089        if (!$this->running) {
     
    10931093        // A redirection will never happen immediately after setting the boomerangURL.
    10941094        // Set the time so ensure this doesn't happen. See $app->validBoomerangURL for more.
    1095         /// FIXME: Why isn't the time set here under setBoomerangURL() and only under dieBoomerangURL()?
    10961095
    10971096        if ('' != $url && is_string($url)) {
     
    11241123     * @param string  $id     An identification tag for this url.
    11251124     */
    1126     function getBoomerangURL($id=null)
     1125    public function getBoomerangURL($id=null)
    11271126    {
    11281127        if (!$this->running) {
     
    11491148     * @param string  $id     An identification tag for this url.
    11501149     */
    1151     function deleteBoomerangURL($id=null)
     1150    public function deleteBoomerangURL($id=null)
    11521151    {
    11531152        if (!$this->running) {
     
    11711170     * @return bool  True if it is set and valid, false otherwise.
    11721171     */
    1173     function validBoomerangURL($id=null, $use_nonspecificboomerang=false)
     1172    public function validBoomerangURL($id=null, $use_nonspecificboomerang=false)
    11741173    {
    11751174        if (!$this->running) {
     
    12211220     * the same page but with https.
    12221221     */
    1223     function sslOn()
     1222    public function sslOn()
    12241223    {
    12251224        if (function_exists('apache_get_modules')) {
     
    12421241     * a http version of the current url.
    12431242     */
    1244     function sslOff()
     1243    public function sslOff()
    12451244    {
    12461245        if ('' != getenv('HTTPS')) {
     
    12481247        }
    12491248    }
    1250 
    1251 
    12521249} // End.
    1253 
    1254 ?>
  • trunk/lib/Auth_File.inc.php

    r396 r468  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
    2121 */
    2222
    23 /**
     23/*
    2424 * Auth_File.inc.php
    2525 *
     
    3030 * @version 1.2
    3131 */
    32  
     32
    3333// Usage example:
    3434// $auth = new Auth_File();
     
    4040// ));
    4141
    42 // Available encryption types for class Auth_SQL.
    43 define('AUTH_ENCRYPT_MD5', 'md5');
    44 define('AUTH_ENCRYPT_CRYPT', 'crypt');
    45 define('AUTH_ENCRYPT_SHA1', 'sha1');
    46 define('AUTH_ENCRYPT_PLAINTEXT', 'plaintext');
    47 
    4842class Auth_File {
    49    
     43
     44    // Available encryption types for class Auth_File.
     45    const ENCRYPT_MD5 = 'md5';
     46    const ENCRYPT_CRYPT = 'crypt';
     47    const ENCRYPT_SHA1 = 'sha1';
     48    const ENCRYPT_PLAINTEXT = 'plaintext';
     49
    5050    // Namespace of this auth object.
    51     var $_ns;
    52    
     51    private $_ns;
     52
    5353    // Parameters to be specified by setParam().
    54     var $_params = array();
    55     var $_default_params = array(
    56        
     54    private $_params = array();
     55    private $_default_params = array(
     56
    5757        // Full path to htpasswd file.
    5858        'htpasswd_file' => null,
    5959
    60         // The type of encryption to use for passwords stored in the db_table. Use one of the AUTH_ENCRYPT_* types specified above.
    61         'encryption_type' => AUTH_ENCRYPT_CRYPT,
     60        // The type of encryption to use for passwords stored in the db_table. Use one of the self::ENCRYPT_* types specified above.
     61        'encryption_type' => self::ENCRYPT_CRYPT,
    6262
    6363        // The URL to the login script.
     
    7777
    7878    // Associative array of usernames to hashed passwords.
    79     var $_users = array();
    80 
    81     /**
    82      * Constructs a new htpasswd authentication object.
    83      *
    84      * @access public
    85      *
    86      * @param optional array $params  A hash containing parameters.
    87      */
    88     function Auth_File($namespace='')
     79    private $_users = array();
     80
     81    /*
     82    * Constructs a new htpasswd authentication object.
     83    *
     84    * @access public
     85    *
     86    * @param optional array $params  A hash containing parameters.
     87    */
     88    public function __construct($namespace='')
    8989    {
    9090        $this->_ns = $namespace;
     
    9494    }
    9595
    96     /**
    97      * Set the params of an auth object.
    98      *
    99      * @param  array $params   Array of parameter keys and value to set.
    100      * @return bool true on success, false on failure
    101      */
    102     function setParam($params)
     96    /*
     97    * Set the params of an auth object.
     98    *
     99    * @param  array $params   Array of parameter keys and value to set.
     100    * @return bool true on success, false on failure
     101    */
     102    public function setParam($params)
    103103    {
    104104        if (isset($params) && is_array($params)) {
     
    108108    }
    109109
    110     /**
    111      * Return the value of a parameter, if it exists.
    112      *
    113      * @access public
    114      * @param string $param        Which parameter to return.
    115      * @return mixed               Configured parameter value.
    116      */
    117     function getParam($param)
    118     {
    119         $app =& App::getInstance();
    120    
     110    /*
     111    * Return the value of a parameter, if it exists.
     112    *
     113    * @access public
     114    * @param string $param        Which parameter to return.
     115    * @return mixed               Configured parameter value.
     116    */
     117    public function getParam($param)
     118    {
     119        $app = &App::getInstance();
     120
    121121        if (isset($this->_params[$param])) {
    122122            return $this->_params[$param];
     
    127127    }
    128128
    129     /**
    130      * Clear any authentication tokens in the current session. A.K.A. logout.
    131      *
    132      * @access public
    133      */
    134     function clear()
     129    /*
     130    * Clear any authentication tokens in the current session. A.K.A. logout.
     131    *
     132    * @access public
     133    */
     134    public function clear()
    135135    {
    136136        $_SESSION['_auth_file'][$this->_ns] = array('authenticated' => false);
    137137    }
    138138
    139 
    140     /**
    141      * Sets a variable into a registered auth session.
    142      *
    143      * @access public
    144      * @param mixed $key      Which value to set.
    145      * @param mixed $val      Value to set variable to.
    146      */
    147     function set($key, $val)
     139    /*
     140    * Sets a variable into a registered auth session.
     141    *
     142    * @access public
     143    * @param mixed $key      Which value to set.
     144    * @param mixed $val      Value to set variable to.
     145    */
     146    public function set($key, $val)
    148147    {
    149148        if (!isset($_SESSION['_auth_file'][$this->_ns]['user_data'])) {
     
    153152    }
    154153
    155     /**
    156      * Returns a specified value from a registered auth session.
    157      *
    158      * @access public
    159      * @param mixed $key      Which value to return.
    160      * @param mixed $default  Value to return if key not found in user_data.
    161      * @return mixed          Value stored in session.
    162      */
    163     function get($key, $default='')
     154    /*
     155    * Returns a specified value from a registered auth session.
     156    *
     157    * @access public
     158    * @param mixed $key      Which value to return.
     159    * @param mixed $default  Value to return if key not found in user_data.
     160    * @return mixed          Value stored in session.
     161    */
     162    public function get($key, $default='')
    164163    {
    165164        if (isset($_SESSION['_auth_file'][$this->_ns][$key])) {
     
    171170        }
    172171    }
    173     /**
    174      * Find out if a set of login credentials are valid. Only supports
    175      * htpasswd files with DES passwords right now.
    176      *
    177      * @access public
    178      *
    179      * @param string $username      The username to check.
    180      * @param array $password      The password to compare to username.
    181      *
    182      * @return boolean  Whether or not the credentials are valid.
    183      */
    184     function authenticate($username, $password)
    185     {
    186         $app =& App::getInstance();
    187    
     172
     173    /*
     174    * Find out if a set of login credentials are valid. Only supports
     175    * htpasswd files with DES passwords right now.
     176    *
     177    * @access public
     178    *
     179    * @param string $username      The username to check.
     180    * @param array $password      The password to compare to username.
     181    *
     182    * @return boolean  Whether or not the credentials are valid.
     183    */
     184    public function authenticate($username, $password)
     185    {
     186        $app = &App::getInstance();
     187
    188188        if ('' == trim($password)) {
    189189            $app->logMsg(_("No password provided for authentication."), LOG_INFO, __FILE__, __LINE__);
    190190            return false;
    191191        }
    192        
     192
    193193        // Load users file.
    194194        $this->_loadHTPasswdFile();
     
    203203            return false;
    204204        }
    205        
     205
    206206        // Authentication successful!
    207207        return true;
    208208    }
    209209
    210     /**
    211      * If user passes authentication create authenticated session.
    212      *
    213      * @access public
    214      *
    215      * @param string $username     The username to check.
    216      * @param array $password     The password to compare to username.
    217      *
    218      * @return boolean  Whether or not the credentials are valid.
    219      */
    220     function login($username, $password)
     210    /*
     211    * If user passes authentication create authenticated session.
     212    *
     213    * @access public
     214    *
     215    * @param string $username     The username to check.
     216    * @param array $password     The password to compare to username.
     217    *
     218    * @return boolean  Whether or not the credentials are valid.
     219    */
     220    public function login($username, $password)
    221221    {
    222222        $username = mb_strtolower(trim($username));
     
    228228            return false;
    229229        }
    230        
     230
    231231        $_SESSION['_auth_file'][$this->_ns] = array(
    232232            'authenticated' => true,
     
    241241    }
    242242
    243     /**
    244      * Test if user has a currently logged-in session.
    245      *  - authentication flag set to true
    246      *  - username not empty
    247      *  - total logged-in time is not greater than login_timeout
    248      *  - idle time is not greater than idle_timeout
    249      *  - remote address is the same as the login remote address.
    250      *
    251      * @access public
    252      */
    253     function isLoggedIn()
    254     {
    255         $app =& App::getInstance();
    256    
     243    /*
     244    * Test if user has a currently logged-in session.
     245    *  - authentication flag set to true
     246    *  - username not empty
     247    *  - total logged-in time is not greater than login_timeout
     248    *  - idle time is not greater than idle_timeout
     249    *  - remote address is the same as the login remote address.
     250    *
     251    * @access public
     252    */
     253    public function isLoggedIn()
     254    {
     255        $app = &App::getInstance();
     256
    257257        // Some users will access from networks with a changing IP number (i.e. behind a proxy server). These users must be allowed entry by adding their IP to the list of trusted_networks.
    258258        if ($trusted_net = ipInRange(getRemoteAddr(), $this->_params['trusted_networks'])) {
     
    268268        // Test login with information stored in session. Skip IP matching for users from trusted networks.
    269269        if (isset($_SESSION['_auth_file'][$this->_ns])
    270             && true === $_SESSION['_auth_file'][$this->_ns]['authenticated']
    271             && !empty($_SESSION['_auth_file'][$this->_ns]['username'])
    272             && strtotime($_SESSION['_auth_file'][$this->_ns]['login_datetime']) > time() - $this->_params['login_timeout']
    273             && strtotime($_SESSION['_auth_file'][$this->_ns]['last_access_datetime']) > time() - $this->_params['idle_timeout']
    274             && ($_SESSION['_auth_file'][$this->_ns]['remote_ip'] == getRemoteAddr() || $user_in_trusted_network)
     270        && true === $_SESSION['_auth_file'][$this->_ns]['authenticated']
     271        && !empty($_SESSION['_auth_file'][$this->_ns]['username'])
     272        && strtotime($_SESSION['_auth_file'][$this->_ns]['login_datetime']) > time() - $this->_params['login_timeout']
     273        && strtotime($_SESSION['_auth_file'][$this->_ns]['last_access_datetime']) > time() - $this->_params['idle_timeout']
     274        && ($_SESSION['_auth_file'][$this->_ns]['remote_ip'] == getRemoteAddr() || $user_in_trusted_network)
    275275        ) {
    276276            // User is authenticated!
     
    303303    }
    304304
    305     /**
    306      * Redirect user to login page if they are not logged in.
    307      *
    308      * @param string $message The text description of a message to raise.
    309      * @param int    $type    The type of message: MSG_NOTICE,
    310      *                        MSG_SUCCESS, MSG_WARNING, or MSG_ERR.
    311      * @param string $file    __FILE__.
    312      * @param string $line    __LINE__.
    313      * @access public
    314      */
    315     function requireLogin($message='', $type=MSG_NOTICE, $file=null, $line=null)
    316     {
    317         $app =& App::getInstance();
    318    
     305    /*
     306    * Redirect user to login page if they are not logged in.
     307    *
     308    * @param string $message The text description of a message to raise.
     309    * @param int    $type    The type of message: MSG_NOTICE,
     310    *                        MSG_SUCCESS, MSG_WARNING, or MSG_ERR.
     311    * @param string $file    __FILE__.
     312    * @param string $line    __LINE__.
     313    * @access public
     314    */
     315    public function requireLogin($message='', $type=MSG_NOTICE, $file=null, $line=null)
     316    {
     317        $app = &App::getInstance();
     318
    319319        if (!$this->isLoggedIn()) {
    320320            // Display message for requiring login. (RaiseMsg will ignore empty strings.)
     
    326326        }
    327327    }
    328    
    329     /**
    330      * Wrapper function for compatibility with lib/Lock.inc.php.
    331      *
    332      * @param  string  $username    Username to return.
    333      * @return string               Username, or false if none found.
    334      */
    335     function getUsername($username)
    336     {
     328
     329    /*
     330    * Wrapper function for compatibility with lib/Lock.inc.php.
     331    *
     332    * @param  string  $username    Username to return.
     333    * @return string               Username, or false if none found.
     334    */
     335    public function getUsername($username) {
    337336        if ('' != $username) {
    338337            return $username;
     
    351350    * @since    18 Apr 2006 18:17:48
    352351    */
    353     function _loadHTPasswdFile()
    354     {
    355         $app =& App::getInstance();
    356    
     352    private function _loadHTPasswdFile()
     353    {
     354        $app = &App::getInstance();
     355
    357356        static $users = null;
    358        
     357
    359358        if (!file_exists($this->_params['htpasswd_file'])) {
    360359            $app->logMsg(sprintf('htpasswd file missing or not specified: %s', $this->_params['htpasswd_file']), LOG_ERR, __FILE__, __LINE__);
    361360            return false;
    362361        }
    363        
     362
    364363        if (!isset($users)) {
    365364            if (false === ($users = file($this->_params['htpasswd_file']))) {
     
    379378    }
    380379
    381     /**
    382      * Hash a given password according to the configured encryption
    383      * type.
    384      *
    385      * @param string $password              The password to encrypt.
    386      * @param string $encrypted_password    The currently encrypted password to use as salt, if needed.
    387      *
    388      * @return string  The hashed password.
    389      */
    390     function _encrypt($password, $encrypted_password=null)
     380    /*
     381    * Hash a given password according to the configured encryption
     382    * type.
     383    *
     384    * @param string $password              The password to encrypt.
     385    * @param string $encrypted_password    The currently encrypted password to use as salt, if needed.
     386    *
     387    * @return string  The hashed password.
     388    */
     389    private function _encrypt($password, $encrypted_password=null)
    391390    {
    392391        switch ($this->_params['encryption_type']) {
    393         case AUTH_ENCRYPT_PLAINTEXT :
     392        case self::ENCRYPT_PLAINTEXT :
    394393            return $password;
    395394            break;
    396395
    397         case AUTH_ENCRYPT_SHA1 :
     396        case self::ENCRYPT_SHA1 :
    398397            return sha1($password);
    399398            break;
    400399
    401         case AUTH_ENCRYPT_MD5 :
     400        case self::ENCRYPT_MD5 :
    402401            return md5($password);
    403402            break;
    404403
    405         case AUTH_ENCRYPT_CRYPT :
     404        case self::ENCRYPT_CRYPT :
    406405        default :
    407406            return crypt($password, $encrypted_password);
     
    411410
    412411} // end class
    413 ?>
  • trunk/lib/Auth_SQL.inc.php

    r465 r468  
    2828*/
    2929
    30 // Available encryption types for class Auth_SQL.
    31 define('AUTH_ENCRYPT_PLAINTEXT', 1);
    32 define('AUTH_ENCRYPT_CRYPT', 2);
    33 define('AUTH_ENCRYPT_SHA1', 3);
    34 define('AUTH_ENCRYPT_SHA1_HARDENED', 4);
    35 define('AUTH_ENCRYPT_MD5', 5);
    36 define('AUTH_ENCRYPT_MD5_HARDENED', 6);
    37 
    3830require_once dirname(__FILE__) . '/Email.inc.php';
    3931
    4032class Auth_SQL {
    4133
     34    // Available encryption types for class Auth_SQL.
     35    const ENCRYPT_PLAINTEXT = 1;
     36    const ENCRYPT_CRYPT = 2;
     37    const ENCRYPT_SHA1 = 3;
     38    const ENCRYPT_SHA1_HARDENED = 4;
     39    const ENCRYPT_MD5 = 5;
     40    const ENCRYPT_MD5_HARDENED = 6;
     41
    4242    // Namespace of this auth object.
    43     var $_ns;
     43    private $_ns;
    4444
    4545    // Static var for test.
    46     var $_authentication_tested;
     46    private $_authentication_tested;
    4747
    4848    // Parameters to be configured by setParam.
    49     var $_params = array();
    50     var $_default_params = array(
     49    private $_params = array();
     50    private $_default_params = array(
    5151
    5252        // Automatically create table and verify columns. Better set to false after site launch.
     
    6666        'db_login_table' => 'user_login_tbl',
    6767
    68         // The type of encryption to use for passwords stored in the db_table. Use one of the AUTH_ENCRYPT_* types specified above.
     68        // The type of encryption to use for passwords stored in the db_table. Use one of the Auth_SQL::ENCRYPT_* types specified above.
    6969        // Hardened password hashes rely on the same key/salt being used to compare encryptions.
    7070        // Be aware that when using one of the hardened types the App signing_key or $more_salt below cannot change!
    71         'encryption_type' => AUTH_ENCRYPT_MD5,
     71        'encryption_type' => self::ENCRYPT_MD5,
    7272
    7373        // The URL to the login script.
     
    127127     * @param optional array $params  A hash containing parameters.
    128128     */
    129     function Auth_SQL($namespace='')
     129    public function __construct($namespace='')
    130130    {
    131131        $app =& App::getInstance();
     
    153153     * @since   26 Aug 2005 17:09:36
    154154     */
    155     function initDB($recreate_db=false)
     155    public function initDB($recreate_db=false)
    156156    {
    157157        $app =& App::getInstance();
     
    253253     * @return bool true on success, false on failure
    254254     */
    255     function setParam($params)
     255    public function setParam($params)
    256256    {
    257257        if (isset($params['match_remote_ip_exempt_usernames'])) {
     
    274274     * @return mixed               Configured parameter value.
    275275     */
    276     function getParam($param)
     276    public function getParam($param)
    277277    {
    278278        $app =& App::getInstance();
     
    291291     * @access public
    292292     */
    293     function clear()
     293    public function clear()
    294294    {
    295295        $db =& DB::getInstance();
     
    326326     * @param mixed $val      Value to set variable to.
    327327     */
    328     function set($key, $val)
     328    public function set($key, $val)
    329329    {
    330330        if (!isset($_SESSION['_auth_sql'][$this->_ns]['user_data'])) {
     
    342342     * @return mixed          Value stored in session.
    343343     */
    344     function get($key, $default='')
     344    public function get($key, $default='')
    345345    {
    346346        if (isset($_SESSION['_auth_sql'][$this->_ns][$key])) {
     
    361361     * @return mixed  False if credentials not found in DB, or returns DB row matching credentials.
    362362     */
    363     function authenticate($username, $password)
     363    public function authenticate($username, $password)
    364364    {
    365365        $app =& App::getInstance();
     
    369369
    370370        switch ($this->_params['encryption_type']) {
    371         case AUTH_ENCRYPT_CRYPT :
     371        case self::ENCRYPT_CRYPT :
    372372            // Query DB for user matching credentials. Compare cyphertext with salted-encrypted password.
    373373            $qid = $db->query("
     
    378378            ");
    379379            break;
    380         case AUTH_ENCRYPT_PLAINTEXT :
    381         case AUTH_ENCRYPT_MD5 :
    382         case AUTH_ENCRYPT_SHA1 :
     380        case self::ENCRYPT_PLAINTEXT :
     381        case self::ENCRYPT_MD5 :
     382        case self::ENCRYPT_SHA1 :
    383383        default :
    384384            // Query DB for user matching credentials. Directly compare cyphertext with result from encryptPassword().
     
    412412     * @return boolean  Whether or not the credentials are valid.
    413413     */
    414     function login($username, $password)
     414    public function login($username, $password)
    415415    {
    416416        $app =& App::getInstance();
     
    421421        $this->clear();
    422422
    423         if (!$user_data = $this->authenticate($username, $password)) {
     423        if (!($user_data = $this->authenticate($username, $password))) {
    424424            // No login: failed authentication!
    425425            return false;
     
    539539     * @access public
    540540     */
    541     function isLoggedIn($user_id=null)
     541    public function isLoggedIn($user_id=null)
    542542    {
    543543        $app =& App::getInstance();
     
    671671     * @access public
    672672     */
    673     function requireLogin($message='', $type=MSG_NOTICE, $file=null, $line=null)
     673    public function requireLogin($message='', $type=MSG_NOTICE, $file=null, $line=null)
    674674    {
    675675        $app =& App::getInstance();
     
    693693     * @param  string   $reason      The reason for blocking the account.
    694694     */
    695     function blockAccount($user_id=null, $reason='')
     695    public function blockAccount($user_id=null, $reason='')
    696696    {
    697697        $app =& App::getInstance();
     
    723723     * @return boolean              True if the user is blocked, false otherwise.
    724724     */
    725     function isBlocked($user_id=null)
     725    public function isBlocked($user_id=null)
    726726    {
    727727        $db =& DB::getInstance();
     
    745745     * Unblocks a user in the db_table, and clears any blocked_reason.
    746746     */
    747     function unblockAccount($user_id=null)
     747    public function unblockAccount($user_id=null)
    748748    {
    749749        $db =& DB::getInstance();
     
    769769     * @return bool                 True if username exists.
    770770     */
    771     function usernameExists($username)
     771    public function usernameExists($username)
    772772    {
    773773        $db =& DB::getInstance();
     
    789789     * @return string               Username, or false if none found.
    790790     */
    791     function getUsername($user_id)
     791    public function getUsername($user_id)
    792792    {
    793793        $db =& DB::getInstance();
     
    813813     * patterns, at minimum the US State Department standard: cvcddcvc.
    814814     *
    815      * - x    a random upper or lower alpha character or digit
    816      * - C    a random upper or lower consonant
    817      * - V    a random upper or lower vowel
    818      * - c    a random lowercase consonant
    819      * - v    a random lowercase vowel
    820      * - d    a random digit
     815     * - x    A random upper or lower character, digit, or punctuation.
     816     * - C    A random upper or lower consonant.
     817     * - V    A random upper or lower vowel.
     818     * - c    A random lowercase consonant.
     819     * - v    A random lowercase vowel.
     820     * - d    A random digit.
    821821     *
    822822     * @param  string $pattern  a sequence of character types, above.
    823823     * @return string           a password
    824824     */
    825     function generatePassword($pattern='CvcdCvc')
     825    public function generatePassword($pattern='CvcdCvc')
    826826    {
    827827        $app =& App::getInstance();
     
    846846     *
    847847     */
    848     function encryptPassword($password, $salt=null)
     848    public function encryptPassword($password, $salt=null)
    849849    {
    850850        $app =& App::getInstance();
     
    855855
    856856        switch ($this->_params['encryption_type']) {
    857         case AUTH_ENCRYPT_PLAINTEXT :
     857        case self::ENCRYPT_PLAINTEXT :
    858858            return $password;
    859859            break;
    860860
    861         case AUTH_ENCRYPT_CRYPT :
     861        case self::ENCRYPT_CRYPT :
    862862            // If comparing plaintext password with a hash, provide first two chars of the hash as the salt.
    863863            return isset($salt) ? crypt($password, mb_substr($salt, 0, 2)) : crypt($password);
    864864            break;
    865865
    866         case AUTH_ENCRYPT_SHA1 :
     866        case self::ENCRYPT_SHA1 :
    867867            return sha1($password);
    868868            break;
    869869
    870         case AUTH_ENCRYPT_SHA1_HARDENED :
     870        case self::ENCRYPT_SHA1_HARDENED :
    871871            $hash = sha1($app->getParam('signing_key') . $password . $more_salt);
    872872            // Increase key strength by 12 bits.
     
    877877            break;
    878878
    879         case AUTH_ENCRYPT_MD5 :
     879        case self::ENCRYPT_MD5 :
    880880            return md5($password);
    881881            break;
    882882
    883         case AUTH_ENCRYPT_MD5_HARDENED :
     883        case self::ENCRYPT_MD5_HARDENED :
    884884            // Include salt to improve hash
    885885            $hash = md5($app->getParam('signing_key') . $password . $more_salt);
     
    901901     *
    902902     */
    903     function setPassword($user_id=null, $password)
     903    public function setPassword($user_id=null, $password)
    904904    {
    905905        $app =& App::getInstance();
     
    951951     * @return string            The user's new password.
    952952     */
    953     function resetPassword($user_id=null, $reason='')
     953    public function resetPassword($user_id=null, $reason='')
    954954    {
    955955        $app =& App::getInstance();
     
    10161016     * @return bool     true if user is a member of security zone, false otherwise
    10171017     */
    1018     function inClearanceZone($security_zone, $user_type='')
    1019     {
    1020         // return true; /// WTF?
     1018    public function inClearanceZone($security_zone, $user_type='')
     1019    {
    10211020        $zone_members = preg_split('/,\s*/', $security_zone);
    10221021        $user_type = empty($user_type) ? $this->get('user_type') : $user_type;
     
    10391038     * @param  constant $security_zone   string of comma delimited privileges for the zone
    10401039     */
    1041     function requireAccessClearance($security_zone, $message='')
     1040    public function requireAccessClearance($security_zone, $message='')
    10421041    {
    10431042        $app =& App::getInstance();
    10441043
    1045         // return true; /// WTF?
    10461044        $zone_members = preg_split('/,\s*/', $security_zone);
    10471045
     
    10971095// 128.0.0.0        10000000.00000000.00000000.00000000  /1
    10981096// 0.0.0.0          00000000.00000000.00000000.00000000  /0   IP space
    1099 ?>
  • trunk/lib/AuthorizeNet.inc.php

    r396 r468  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    3131 * @date 2004-04-06
    3232 */
    33  
     33
    3434// Example usage
    3535// require_once 'codebase/lib/AuthorizeNet.inc.php';
     
    6161class AuthorizeNet {
    6262
    63     var $post_url = ''; // The URL to post data to.
    64     var $_results = array();
    65     var $_params = array();
    66     var $_default_params = array(
     63    public $post_url = ''; // The URL to post data to.
     64    private $_results = array();
     65    private $_params = array();
     66    private $_default_params = array(
    6767        'x_version'         => '3.1',
    6868        'x_relay_response'  => 'FALSE',
     
    8080
    8181    // Array of response names. Used in the results array.
    82     var $_result_fields = Array(
     82    private $_result_fields = Array(
    8383        'x_response_code',
    8484        'x_response_subcode',
     
    129129     * @param optional array $_params  A hash containing parameters.
    130130     */
    131     function AuthorizeNet($params = array())
     131    public function __construct($params = array())
    132132    {
    133133        $app =& App::getInstance();
     
    143143        $this->_params = $this->_default_params;
    144144        $this->setParam($params);
    145        
     145
    146146        $this->setParam(array('md5_hash_salt' => $app->getParam('signing_key')));
    147147    }
     
    153153     * @param  array    $params     Array of parameters (key => val pairs).
    154154     */
    155     function setParam($params)
     155    public function setParam($params)
    156156    {
    157157        $app =& App::getInstance();
    158    
     158
    159159        if (isset($params) && is_array($params)) {
    160160            // Merge new parameters with old overriding only those passed.
     
    172172     * @return mixed               Configured parameter value.
    173173     */
    174     function getParam($param)
     174    public function getParam($param)
    175175    {
    176176        $app =& App::getInstance();
    177    
     177
    178178        if (isset($this->_params[$param])) {
    179179            return $this->_params[$param];
     
    192192     * @return mixed      False or x_response_code: false = error, 1 = accepted, 2 = declined, 3 = error
    193193     */
    194     function process()
     194    public function process()
    195195    {
    196196        $app =& App::getInstance();
    197    
     197
    198198        if (empty($this->_params['x_login'])) {
    199199            $this->_results['x_response_reason_text'] = _("Transaction gateway temporarily not available. Please try again later.");
     
    245245     * @return array             Returns the results array.
    246246     */
    247     function getResult($key=null)
     247    public function getResult($key=null)
    248248    {
    249249        if (isset($key)) {
     
    265265     * @return bool             True if the hash is valid, false otherwise.
    266266     */
    267     function validMD5Hash()
     267    public function validMD5Hash()
    268268    {
    269269        return (
     
    282282     * @access public
    283283     */
    284     function reset()
     284    public function reset()
    285285    {
    286286        $this->_results = Array();
     
    297297     * @return integer      Transaction result code.
    298298     */
    299     function _processResult($result)
     299    private function _processResult($result)
    300300    {
    301301        $this->_results = Array();
     
    315315    }
    316316}
    317 ?>
  • trunk/lib/CSS.inc.php

    r396 r468  
    3232
    3333    // Include these style sheets.
    34     var $_css_files = array('default' => array());
     34    private $_css_files = array('default' => array());
    3535
    3636    // CSS object parameters.
    37     var $_params = array(
     37    private $_params = array(
    3838        'character_set' => 'utf-8',
    3939        'cache_css' => false,
     
    4848     * @param  array    $params     Array of parameters (key => val pairs).
    4949     */
    50     function setParam($params)
     50    public function setParam($params)
    5151    {
    5252        $app =& App::getInstance();
     
    6767     * @return mixed               Configured parameter value.
    6868     */
    69     function getParam($param)
     69    public function getParam($param)
    7070    {
    7171        $app =& App::getInstance();
     
    8787     * @return  bool    True on success, false on failure.
    8888     */
    89     function setFile($file, $realms='')
     89    public function setFile($file, $realms='')
    9090    {
    9191        $app =& App::getInstance();
     
    115115     * @return  bool    False if no files have been set.
    116116     */
    117     function headers($realm='')
     117    public function headers($realm='')
    118118    {
    119119        $app =& App::getInstance();
     
    157157     * @return  bool    False if no files have been set.
    158158     */
    159     function output($realm='')
     159    public function output($realm='')
    160160    {
    161161        $realm = '' == $realm ? 'default' : $realm;
     
    181181    }
    182182}
    183 ?>
  • trunk/lib/Cache.inc.php

    r405 r468  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    3131 * @since   2001
    3232 */
    33  
    34 // Flags.
    35 define('CACHE_ALLOW_OVERSIZED', 1);
    3633
    3734class Cache {
    3835
     36    // A place to keep object instances for the singleton pattern.
     37    private static $instances = array();
     38
    3939    // Namespace of this instance of Prefs.
    40     var $_ns;
     40    private $_ns;
    4141
    4242    // Configuration parameters for this object.
    43     var $_params = array(
    44        
     43    private $_params = array(
     44
     45        // Type of cache. Currently only 'session' is supported.
     46        'type' => 'session',
     47
    4548        // If false nothing will be cached or retrieved. Useful for testing realtime data requests.
    4649        'enabled' => true,
     
    4851        // The maximum size in bytes of any one variable.
    4952        'item_size_limit' => 4194304, // 4 MB
    50        
     53
    5154        // The maximum size in bytes before the cache will begin flushing out old items.
    5255        'stack_size_limit' => 4194304, // 4 MB
    53        
     56
    5457        // The minimum items to keep in the cache regardless of item or cache size.
    5558        'min_items' => 5,
    5659    );
    57    
     60
    5861    /*
    59     * Constructor
     62    * Constructor. This is publically accessible for compatability with older implementations,
     63    * but the preferred method of instantiation is by use of the singleton pattern:
     64    *   $cache =& Cache::getInstance('namespace');
     65    *   $cache->setParam(array('enabled' => true));
    6066    *
    6167    * @access   public
     
    6571    * @since    05 Jun 2006 23:14:21
    6672    */
    67     function Cache($namespace='')
     73    public function __construct($namespace='')
    6874    {
    6975        $app =& App::getInstance();
    70        
     76
    7177        $this->_ns = $namespace;
    7278
     
    7581            $this->setParam(array('enabled' => false));
    7682        }
    77        
     83
    7884        if (!isset($_SESSION['_cache'][$this->_ns])) {
    7985            $this->clear();
     
    8894     * @static
    8995     */
    90     static function &getInstance($namespace='')
    91     {
    92         static $instances = array();
    93 
    94         if (!array_key_exists($namespace, $instances)) {
    95             $instances[$namespace] = new Cache($namespace);
    96         }
    97 
    98         return $instances[$namespace];
     96    public static function &getInstance($namespace='')
     97    {
     98        if (!array_key_exists($namespace, self::$instances)) {
     99            self::$instances[$namespace] = new self($namespace);
     100        }
     101        return self::$instances[$namespace];
    99102    }
    100103
     
    105108     * @param  array    $params     Array of parameters (key => val pairs).
    106109     */
    107     function setParam($params)
     110    public function setParam($params)
    108111    {
    109112        $app =& App::getInstance();
     
    124127     * @return mixed               Configured parameter value.
    125128     */
    126     function getParam($param)
     129    public function getParam($param)
    127130    {
    128131        $app =& App::getInstance();
    129    
     132
    130133        if (isset($this->_params[$param])) {
    131134            return $this->_params[$param];
     
    138141    /**
    139142     * Stores a new variable in the session cache. The $key should not be numeric
    140      * because the array_shift function will reset the key to the next largest 
     143     * because the array_shift function will reset the key to the next largest
    141144     * int key. Weird behavior I can't understand. For example $cache["123"] will become $cache[0]
    142145     *
    143      * @param str   $key        An identifier for the cached object.
    144      * @param mixed $var        The var to store in the session cache.
    145      * @param bool  $flags      If we have something really big that we
    146      *                          still want to cache, setting this to
    147      *                          CACHE_ALLOW_OVERSIZED allows this.
    148      * @return bool             True on success, false otherwise.
    149      */
    150     function set($key, $var, $flags=0)
     146     * @param str   $key                An identifier for the cached object.
     147     * @param mixed $var                The data to store in the session cache.
     148     * @param bool  $allow_oversized    If we have something really big that we still want to cache, setting this to true allows this.
     149     * @return bool                     True on success, false otherwise.
     150     */
     151    public function set($key, $var, $allow_oversized=false)
    151152    {
    152153        $app =& App::getInstance();
     
    157158        }
    158159
     160        if (is_numeric($key)) {
     161            $app->logMsg(sprintf('Cache::set key value should not be numeric (%s given)', $key), LOG_WARNING, __FILE__, __LINE__);
     162        }
     163
    159164        $var = serialize($var);
    160165        $var_len = mb_strlen($var);
     
    165170        }
    166171
    167         if ($flags & CACHE_ALLOW_OVERSIZED == 0 && $var_len >= $this->getParam('stack_size_limit')) {
     172        if ($allow_oversized && $var_len >= $this->getParam('stack_size_limit')) {
    168173            $app->logMsg(sprintf('Serialized variable (%s bytes) more than stack_size_limit (%s bytes).', $var_len, $this->getParam('stack_size_limit')), LOG_NOTICE, __FILE__, __LINE__);
    169174            return false;
    170         }       
     175        }
    171176
    172177        // Remove any value already stored under this key.
     
    197202     * @return mixed          The requested datum, or false on failure.
    198203     */
    199     function get($key)
     204    public function get($key)
    200205    {
    201206        $app =& App::getInstance();
     
    226231     * @return bool         True if a value exists for the given key.
    227232     */
    228     function exists($key)
     233    public function exists($key)
    229234    {
    230235        $app =& App::getInstance();
     
    244249     * @return bool         True if the value existed before being unset.
    245250     */
    246     function delete($key)
     251    public function delete($key)
    247252    {
    248253        if (array_key_exists($key, $_SESSION['_cache'][$this->_ns])) {
     
    253258        }
    254259    }
    255    
     260
    256261    /*
    257262    * Delete all existing items from the cache.
     
    262267    * @since    05 Jun 2006 23:51:34
    263268    */
    264     function clear()
     269    public function clear()
    265270    {
    266271        $_SESSION['_cache'][$this->_ns] = array();
     
    270275}
    271276
    272 ?>
  • trunk/lib/Captcha.inc.php

    r396 r468  
    5454class Captcha {
    5555
    56     var $secret_key = 'some random seed text for the md5';
    57     var $random_number;
    58     var $ascii_numbers = array(
     56    public $secret_key = 'some random seed text for the md5';
     57    public $random_number;
     58    public $ascii_numbers = array(
    5959        array(
    6060            '  #####   ',
     
    147147     * @since   20 Jan 2006 13:08:22
    148148     */
    149     function Captcha()
     149    public function __construct()
    150150    {
    151151        $app =& App::getInstance();
     
    164164     * @since   07 Dec 2005 21:59:25
    165165     */
    166     function getAsciiNumber($num=null)
     166    public function getAsciiNumber($num=null)
    167167    {
    168168        $app =& App::getInstance();
     
    200200     * @since   07 Dec 2005 22:09:04
    201201     */
    202     function printAsciiNumber()
     202    public function printAsciiNumber()
    203203    {
    204204        $ascii = $this->getAsciiNumber($this->random_number);
     
    213213     * @since   07 Dec 2005 22:09:04
    214214     */
    215     function printForm()
     215    public function printForm()
    216216    {
    217217        $hash = $this->_getMD5key($this->random_number);
     
    231231     * @since   07 Dec 2005 22:19:33
    232232     */
    233     function valid()
     233    public function valid()
    234234    {
    235235        $number = getFormData('sc-captcha-input');
     
    251251     * @since   07 Dec 2005 21:40:25
    252252     */
    253     function _getRandomNumber()
     253    public function _getRandomNumber()
    254254    {
    255255        return mb_substr(strval(rand(10000, 99999)), 0, rand(3, 5));
     
    265265     * @since   07 Dec 2005 21:53:35
    266266     */
    267     function _getMD5key($input)
     267    public function _getMD5key($input)
    268268    {
    269269        return md5($this->secret_key . $input);
     
    272272}
    273273
    274 ?>
  • trunk/lib/Cart.inc.php

    r396 r468  
    7171
    7272    // Namespace of this instance.
    73     var $_ns;
     73    private $_ns;
    7474
    7575    // Configuration parameters for this object.
    76     var $_params = array(
     76    private $_params = array(
    7777    );
    7878
     
    8080     * Cart constructor.
    8181     */
    82     function Cart($namespace='')
     82    public function __construct($namespace='')
    8383    {
    8484        $app =& App::getInstance();
     
    9797     * @param  array $params   Array of param keys and values to set.
    9898     */
    99     function setParam($params=null)
     99    public function setParam($params=null)
    100100    {
    101101        if (isset($params) && is_array($params)) {
     
    112112     * @return mixed               Configured parameter value.
    113113     */
    114     function getParam($param)
     114    public function getParam($param)
    115115    {
    116116        $app =& App::getInstance();
     
    137137    * @since    11 Mar 2008 18:59:37
    138138    */
    139     function add($item_id, $price, $quantity=1, $specs=array())
     139    public function add($item_id, $price, $quantity=1, $specs=array())
    140140    {
    141141        $app =& App::getInstance();
     
    166166    * @since    10 May 2008 16:42:25
    167167    */
    168     function setQty($item_id, $quantity)
     168    public function setQty($item_id, $quantity)
    169169    {
    170170        if ($quantity <= 0) {
     
    195195    * @since    10 May 2008 16:42:25
    196196    */
    197     function setPrice($item_id, $price)
     197    public function setPrice($item_id, $price)
    198198    {
    199199        if (isset($_SESSION['_cart'][$this->_ns]['items'][$item_id])) {
     
    218218    * @since    11 Mar 2008 18:59:48
    219219    */
    220     function remove($item_id)
     220    public function remove($item_id)
    221221    {
    222222        $app =& App::getInstance();
     
    242242    * @since    11 Mar 2008 18:59:55
    243243    */
    244     function get($item_id, $spec_key)
     244    public function get($item_id, $spec_key)
    245245    {
    246246        if (isset($_SESSION['_cart'][$this->_ns]['items'][$item_id][$spec_key])) {
     
    259259    * @since    11 Mar 2008 18:59:55
    260260    */
    261     function getList()
     261    public function getList()
    262262    {
    263263        return $_SESSION['_cart'][$this->_ns]['items'];
     
    277277    * @since    11 Mar 2008 19:00:12
    278278    */
    279     function sum($key='extended_price')
     279    public function sum($key='extended_price')
    280280    {
    281281        $sum = 0;
     
    306306     * as $auth->clear(), such as when logging out.
    307307     */
    308     function clear()
     308    public function clear()
    309309    {
    310310        $_SESSION['_cart'][$this->_ns] = array(
     
    313313    }
    314314}
    315 
    316 
    317 ?>
  • trunk/lib/Currency.inc.php

    r411 r468  
    4141
    4242    // Configuration parameters for this object.
    43     var $_params = array(
     43    private $_params = array(
    4444        'cache_result' => true,
    4545        'cache_dir' => '',
     
    5252     * Cart constructor.
    5353     */
    54     function Currency($params=array())
     54    public function __construct($params=array())
    5555    {
    5656        $app =& App::getInstance();
     
    7979     * @param  array $params   Array of param keys and values to set.
    8080     */
    81     function setParam($params=null)
     81    public function setParam($params=null)
    8282    {
    8383        if (isset($params) && is_array($params)) {
     
    9494     * @return mixed               Configured parameter value.
    9595     */
    96     function getParam($param)
     96    public function getParam($param)
    9797    {
    9898        $app =& App::getInstance();
     
    118118    * @since    05 May 2008 23:50:59
    119119    */
    120     function getValue($amount, $base, $target)
     120    public function getValue($amount, $base, $target)
    121121    {
    122122        if (false !== $rate = $this->getRate($base, $target)) {
     
    138138    * @since    25 May 2011 01:26:24
    139139    */
    140     function getRate($base, $target)
     140    public function getRate($base, $target)
    141141    {
    142142        $app =& App::getInstance();
     
    180180     * @access private
    181181     */
    182     function _performAPICall($parameters=null)
     182    private function _performAPICall($parameters=null)
    183183    {
    184184        $app =& App::getInstance();
     
    251251
    252252
    253 ?>
  • trunk/lib/DB.inc.php

    r465 r468  
    3232class DB {
    3333
     34    // A place to keep an object instance for the singleton pattern.
     35    private static $instance = null;
     36
    3437    // If $db->connect has successfully opened a db connection.
    35     var $_connected = false;
     38    private $_connected = false;
    3639
    3740    // Database handle.
    38     var $dbh;
     41    public $dbh;
    3942
    4043    // Count how many queries run during the whole instance.
    41     var $_query_count = 0;
     44    private $_query_count = 0;
    4245
    4346    // Hash of DB parameters.
    44     var $_params = array();
     47    private $_params = array();
    4548
    4649    // Default parameters.
    47     var $_param_defaults = array(
     50    private $_param_defaults = array(
    4851
    4952        // DB passwords should be set as apache environment variables in httpd.conf, readable only by root.
     
    6467
    6568    // Translate between HTML and MySQL character set names.
    66     var $mysql_character_sets = array(
     69    public $mysql_character_sets = array(
    6770        'utf-8' => 'utf8',
    6871        'iso-8859-1' => 'latin1',
     
    7073
    7174    // Caches.
    72     var $existing_tables;
    73     var $table_columns;
     75    private $existing_tables;
     76    private $table_columns;
    7477
    7578    /**
     
    8083     * @static
    8184     */
    82     static function &getInstance()
    83     {
    84         static $instance = null;
    85 
    86         if ($instance === null) {
    87             $instance = new DB();
    88         }
    89 
    90         return $instance;
     85    public static function &getInstance()
     86    {
     87        if (self::$instance === null) {
     88            self::$instance = new self();
     89        }
     90
     91        return self::$instance;
    9192    }
    9293
     
    9899     * @param  array    $params     Array of parameters (key => val pairs).
    99100     */
    100     function setParam($params)
     101    public function setParam($params)
    101102    {
    102103        $app =& App::getInstance();
     
    117118     * @return mixed               Configured parameter value.
    118119     */
    119     function getParam($param)
     120    public function getParam($param)
    120121    {
    121122        $app =& App::getInstance();
     
    136137     * @since   28 Aug 2005 14:02:49
    137138     */
    138     function connect()
     139    public function connect()
    139140    {
    140141        $app =& App::getInstance();
     
    146147
    147148        // Connect to database. Always create a new link to the server.
    148         if ($this->dbh = mysql_connect($this->getParam('db_server'), $this->getParam('db_user'), $this->getParam('db_pass'), true)) {
     149        if ($this->dbh = @mysql_connect($this->getParam('db_server'), $this->getParam('db_user'), $this->getParam('db_pass'), true)) {
    149150            // Select database
    150151            mysql_select_db($this->getParam('db_name'), $this->dbh);
     
    185186     * @since   28 Aug 2005 14:32:01
    186187     */
    187     function close()
     188    public function close()
    188189    {
    189190        if (!$this->_connected) {
     
    204205    * @since    03 Jul 2013 14:50:23
    205206    */
    206     function reconnect()
     207    public function reconnect()
    207208    {
    208209        $this->close();
     
    221222    * @since    15 Jan 2007 15:59:00
    222223    */
    223     function _fail()
     224    private function _fail()
    224225    {
    225226        if ($this->getParam('db_die_on_failure')) {
     
    240241     * @since   20 Aug 2005 13:50:36
    241242     */
    242     function getDBH()
     243    public function getDBH()
    243244    {
    244245        if (!$this->_connected) {
     
    256257     * @since   28 Aug 2005 14:58:09
    257258     */
    258     function isConnected()
     259    public function isConnected()
    259260    {
    260261        return (true === $this->_connected);
     
    270271     * @since   06 Mar 2006 16:41:32
    271272     */
    272     function escapeString($string)
     273    public function escapeString($string)
    273274    {
    274275        if (!$this->_connected) {
     
    287288     * @return resource         Query identifier
    288289     */
    289     function query($query, $debug=false)
     290    public function query($query, $debug=false)
    290291    {
    291292        $app =& App::getInstance();
     
    336337     * @return bool                         true if given $table exists.
    337338     */
    338     function tableExists($table, $use_cached_results=true)
     339    public function tableExists($table, $use_cached_results=true)
    339340    {
    340341        $app =& App::getInstance();
     
    368369     * @return bool                         true if column(s) exist.
    369370     */
    370     function columnExists($table, $columns, $strict=true, $use_cached_results=true)
     371    public function columnExists($table, $columns, $strict=true, $use_cached_results=true)
    371372    {
    372373        if (!$this->_connected) {
     
    416417    * @since    15 Jun 2006 11:46:05
    417418    */
    418     function numQueries()
     419    public function numQueries()
    419420    {
    420421        return $this->_query_count;
     
    428429     * @since   28 Aug 2005 22:10:50
    429430     */
    430     function resetCache()
     431    public function resetCache()
    431432    {
    432433        $this->existing_tables = null;
     
    436437} // End.
    437438
    438 ?>
  • trunk/lib/DBSessionHandler.inc.php

    r398 r468  
    3232class DBSessionHandler {
    3333
    34     var $db; // DB object.
     34    public $db; // DB object.
    3535
    36     var $_params = array(
     36    private $_params = array(
    3737        'db_table' => 'session_tbl',
    3838
     
    5151     * @since   18 Jul 2005 11:02:50
    5252     */
    53     function DBSessionHandler($db, $params=array())
     53    public function __construct($db, $params=array())
    5454    {
    5555        $app =& App::getInstance();
     
    9494     * @since   26 Aug 2005 17:09:36
    9595     */
    96     function initDB($recreate_db=false)
     96    public function initDB($recreate_db=false)
    9797    {
    9898        $app =& App::getInstance();
     
    121121    }
    122122
    123     function dbSessionOpen($save_path, $sess_name)
     123    public function dbSessionOpen($save_path, $sess_name)
    124124    {
    125125        return true;
    126126    }
    127127
    128     function dbSessionClose()
     128    public function dbSessionClose()
    129129    {       
    130130        return true;
    131131    }
    132132
    133     function dbSessionRead($session_id)
     133    public function dbSessionRead($session_id)
    134134    {
    135135        // Select the data belonging to session $session_id from the session table
     
    146146    }
    147147
    148     function dbSessionWrite($session_id, $session_data)
     148    public function dbSessionWrite($session_id, $session_data)
    149149    {
    150150        // Write the serialized session data ($session_data) to the session table
     
    154154    }
    155155
    156     function dbSessionDestroy($session_id)
     156    public function dbSessionDestroy($session_id)
    157157    {
    158158        // Delete from the table all data for the session $session_id
     
    162162    }
    163163
    164     function dbSessionGarbage($max_lifetime=72000)
     164    public function dbSessionGarbage($max_lifetime=72000)
    165165    {
    166166        // Delete old values from the session table.
     
    171171}
    172172
    173 ?>
  • trunk/lib/Email.inc.php

    r460 r468  
    5656
    5757    // Default parameters, to be overwritten by setParam() and read with getParam()
    58     var $_params = array(
     58    private $_params = array(
    5959        'to' => null,
    6060        'from' => null,
     
    7474
    7575    // String that contains the email body.
    76     var $_template;
     76    private $_template;
    7777
    7878    // String that contains the email body after replacements.
    79     var $_template_replaced;
     79    private $_template_replaced;
    8080
    8181    /**
     
    8787     * @since   28 Nov 2005 12:59:41
    8888     */
    89     function Email($params=null)
     89    public function __construct($params=null)
    9090    {
    9191        // The regex used in validEmail(). Set here instead of in the default _params above so we can use the concatenation . dot.
     
    118118     * @param  array    $params     Array of parameters (key => val pairs).
    119119     */
    120     function setParam($params)
     120    public function setParam($params)
    121121    {
    122122        $app =& App::getInstance();
     
    145145     * @return mixed               Configured parameter value.
    146146     */
    147     function getParam($param)
     147    public function getParam($param)
    148148    {
    149149        $app =& App::getInstance();
     
    165165     * @since   28 Nov 2005 12:56:23
    166166     */
    167     function setTemplate($template)
     167    public function setTemplate($template)
    168168    {
    169169        $app =& App::getInstance();
     
    189189     * @since   28 Nov 2005 12:56:23
    190190     */
    191     function setString($string)
     191    public function setString($string)
    192192    {
    193193        $app =& App::getInstance();
     
    213213     * @since   28 Nov 2005 13:08:51
    214214     */
    215     function replace($replacements)
     215    public function replace($replacements)
    216216    {
    217217        $app =& App::getInstance();
     
    250250     * @since   28 Nov 2005 12:56:09
    251251     */
    252     function send($to=null, $from=null, $subject=null, $headers=null)
     252    public function send($to=null, $from=null, $subject=null, $headers=null)
    253253    {
    254254        $app =& App::getInstance();
     
    364364     * @since   30 Nov 2005 22:00:50
    365365     */
    366     function validEmail($email)
     366    public function validEmail($email)
    367367    {
    368368        $app =& App::getInstance();
     
    388388}
    389389
    390 ?>
  • trunk/lib/FormValidator.inc.php

    r459 r468  
    5858require_once 'codebase/lib/Validator.inc.php';
    5959
    60 class FormValidator extends Validator {
     60class FormValidator {
    6161
    6262    // Class parameters.
    63     var $_params = array(
     63    private $_params = array(
    6464        'error' => ' sc-msg-error ',
    6565        'warning' => ' sc-msg-warning ',
     
    6969
    7070    // Array filling with error messages.
    71     var $errors = array();
     71    public $errors = array();
    7272
    7373    /**
     
    7777     * @param  array    $params     Array of parameters (key => val pairs).
    7878     */
    79     function setParam($params)
     79    public function setParam($params)
    8080    {
    8181        $app =& App::getInstance();
     
    9696     * @return mixed               Configured parameter value.
    9797     */
    98     function getParam($param)
     98    public function getParam($param)
    9999    {
    100100        $app =& App::getInstance();
     
    115115     *                  vals: the message to display for that error
    116116     */
    117     function getErrorList()
     117    public function getErrorList()
    118118    {
    119119        return $this->errors;
     
    130130     * @param   string $line        __LINE__.
    131131     */
    132     function addError($form_name, $msg='', $type=MSG_ERR, $file=null, $line=null)
     132    public function addError($form_name, $msg='', $type=MSG_ERR, $file=null, $line=null)
    133133    {
    134134        $this->errors[] = array(
     
    149149     *                a variable of $form_name, false otherwise
    150150     */
    151     function anyErrors($form_name=null)
     151    public function anyErrors($form_name=null)
    152152    {
    153153        if (isset($form_name)) {
     
    166166     * Reset the error list.
    167167     */
    168     function resetErrorList()
     168    public function resetErrorList()
    169169    {
    170170        $this->errors = array();
     
    182182     * @since   15 Jul 2005 01:39:14
    183183     */
    184     function printErrorMessages($above='', $below='', $print_gotohash_js=false, $hash='sc-msg-formvalidator')
     184    public function printErrorMessages($above='', $below='', $print_gotohash_js=false, $hash='sc-msg-formvalidator')
    185185    {
    186186        $app =& App::getInstance();
     
    238238     *                           not provided, use default.
    239239     */
    240     function err($form_name, $marker=null)
     240    public function err($form_name, $marker=null)
    241241    {
    242242        if (false !== ($type = $this->anyErrors($form_name))) {
     
    274274     * @return bool   true if form is not empty, false otherwise.
    275275     */
    276     function notEmpty($form_name, $msg='')
    277     {
    278         if (parent::notEmpty(getFormData($form_name))) {
     276    public function notEmpty($form_name, $msg='')
     277    {
     278        if (Validator::notEmpty(getFormData($form_name))) {
    279279            return true;
    280280        } else {
     
    290290    * @since    03 Jun 2006 22:56:46
    291291    */
    292     function isEmpty($form_name, $msg='')
     292    public function isEmpty($form_name, $msg='')
    293293    {
    294294        $this->notEmpty($form_name, $msg);
     
    303303     * @return bool   true if form is a string, false otherwise.
    304304     */
    305     function isString($form_name, $msg='')
    306     {
    307         if (parent::isString(getFormData($form_name))) {
     305    public function isString($form_name, $msg='')
     306    {
     307        if (Validator::isString(getFormData($form_name))) {
    308308            return true;
    309309        } else {
     
    321321     * @return bool   true if no errors found, false otherwise
    322322     */
    323     function isNumber($form_name, $msg='')
    324     {
    325         if (parent::isNumber(getFormData($form_name))) {
     323    public function isNumber($form_name, $msg='')
     324    {
     325        if (Validator::isNumber(getFormData($form_name))) {
    326326            return true;
    327327        } else {
     
    340340     * @return bool   true if value is an integer
    341341     */
    342     function isInteger($form_name, $msg='', $negative_ok=false)
    343     {
    344         if (parent::isInteger(getFormData($form_name), $negative_ok)) {
     342    public function isInteger($form_name, $msg='', $negative_ok=false)
     343    {
     344        if (Validator::isInteger(getFormData($form_name), $negative_ok)) {
    345345            return true;
    346346        } else {
     
    360360     * @return bool   true if value is a float
    361361     */
    362     function isFloat($form_name, $msg='', $negative_ok=false)
    363     {
    364         if (parent::isFloat(getFormData($form_name), $negative_ok)) {
     362    public function isFloat($form_name, $msg='', $negative_ok=false)
     363    {
     364        if (Validator::isFloat(getFormData($form_name), $negative_ok)) {
    365365            return true;
    366366        } else {
     
    378378     * @return bool   true if value is a float
    379379     */
    380     function isArray($form_name, $msg='')
    381     {
    382         if (parent::isArray(getFormData($form_name))) {
     380    public function isArray($form_name, $msg='')
     381    {
     382        if (Validator::isArray(getFormData($form_name))) {
    383383            return true;
    384384        } else {
     
    399399     * @return bool   true if value passes regex test
    400400     */
    401     function checkRegex($form_name, $regex, $valid_on_match, $msg='')
    402     {
    403         if (parent::checkRegex(getFormData($form_name), $regex, $valid_on_match)) {
     401    public function checkRegex($form_name, $regex, $valid_on_match=true, $msg='')
     402    {
     403        if (Validator::checkRegex(getFormData($form_name), $regex, $valid_on_match)) {
    404404            return true;
    405405        } else {
     
    419419     * @return bool   true if string length is within given boundaries
    420420     */
    421     function stringLength($form_name, $min, $max, $msg='')
    422     {
    423         if (parent::stringLength(getFormData($form_name), $min, $max)) {
     421    public function stringLength($form_name, $min, $max, $msg='')
     422    {
     423        if (Validator::stringLength(getFormData($form_name), $min, $max)) {
    424424            return true;
    425425        } else {
     
    439439     * @return bool   true if no errors found, false otherwise
    440440     */
    441     function numericRange($form_name, $min, $max, $msg='')
    442     {
    443         if (parent::numericRange(getFormData($form_name), $min, $max)) {
     441    public function numericRange($form_name, $min, $max, $msg='')
     442    {
     443        if (Validator::numericRange(getFormData($form_name), $min, $max)) {
    444444            return true;
    445445        } else {
     
    463463     * @author  Quinn Comendant <quinn@strangecode.com>
    464464     */
    465     function validateEmail($form_name)
     465    public function validateEmail($form_name, $strict=false)
    466466    {
    467467        $app =& App::getInstance();
     
    474474        }
    475475
    476         // Validator::validateEmail() returns a value that relates to the VALIDATE_EMAIL_* constants (defined in Validator.inc.php).
    477         switch (parent::validateEmail($email)) {
    478         case VALIDATE_EMAIL_REGEX_FAIL:
     476        // Validator::validateEmail() returns a value that relates to the Validate::EMAIL_* constants (defined in Validator.inc.php).
     477        switch (Validator::validateEmail($email, $strict)) {
     478        case Validator::EMAIL_REGEX_FAIL:
    479479            // Failed regex match.
    480480            $this->addError($form_name, sprintf(_("The email address <em>%s</em> is formatted incorrectly."), oTxt($email)));
    481481            $app->logMsg(sprintf('The email address %s is not valid.', oTxt($email)), LOG_DEBUG, __FILE__, __LINE__);
    482482            return false;
    483             break;
    484 
    485         case VALIDATE_EMAIL_LENGTH_FAIL :
     483
     484        case Validator::EMAIL_LENGTH_FAIL :
    486485            // Failed length requirements.
    487486            $this->addError($form_name, sprintf(_("The email address <em>%s</em> is too long (email addresses must have fewer than 256 characters)."), oTxt($email)));
    488487            $app->logMsg(sprintf('The email address %s must contain less than 256 characters.', oTxt($email)), LOG_DEBUG, __FILE__, __LINE__);
    489488            return false;
    490             break;
    491 
    492         case VALIDATE_EMAIL_MX_FAIL :
     489
     490        case Validator::EMAIL_MX_FAIL :
    493491            // Failed MX record test.
    494492            $this->addError($form_name, sprintf(_("The email address <em>%s</em> does not have a valid domain name"), oTxt($email)));
    495493            $app->logMsg(sprintf('The email address %s does not have a valid domain name.', oTxt($email)), LOG_INFO, __FILE__, __LINE__);
    496494            return false;
    497             break;
    498 
    499         case VALIDATE_EMAIL_SUCCESS :
     495
     496        case Validator::EMAIL_SUCCESS :
    500497        default :
    501498            return true;
    502             break;
    503499        }
    504500    }
     
    513509     * @return bool    true if no errors found, false otherwise
    514510     */
    515     function validatePhone($form_name)
    516     {
     511    public function validatePhone($form_name)
     512    {
     513        $app =& App::getInstance();
     514
    517515        $phone = getFormData($form_name);
    518516
    519         return (
    520             $this->checkRegex($form_name, '/^[0-9 +().-]*$/', true, sprintf(_("The phone number <em>%s</em> is not valid."), $phone))
    521             && $this->stringLength($form_name, 0, 25, sprintf(_("The phone number <em>%s</em> is too long"), $phone))
    522         );
     517        // Validator::validateEmail() returns a value that relates to the Validate::PHONE_* constants (defined in Validator.inc.php).
     518        switch (Validator::validatePhone($phone)) {
     519        case Validator::PHONE_REGEX_FAIL:
     520            // Failed regex match.
     521            $this->addError($form_name, sprintf(_("The phone number <em>%s</em> is not valid."), oTxt($phone)));
     522            $app->logMsg(sprintf('The phone number %s is not valid.', oTxt($phone)), LOG_DEBUG, __FILE__, __LINE__);
     523            return false;
     524
     525        case Validator::PHONE_LENGTH_FAIL :
     526            // Failed length requirements.
     527            $this->addError($form_name, sprintf(_("The phone number <em>%s</em> is too long (phone number must have fewer than 25 characters)."), oTxt($phone)));
     528            $app->logMsg(sprintf('The phone number %s must contain less than 256 characters.', oTxt($phone)), LOG_DEBUG, __FILE__, __LINE__);
     529            return false;
     530
     531        case Validator::PHONE_SUCCESS :
     532        default :
     533            return true;
     534        }
    523535    }
    524536
     
    531543     * @return bool    true if no errors found, false otherwise
    532544     */
    533     function validateStrDate($form_name, $msg='')
     545    public function validateStrDate($form_name, $msg='')
    534546    {
    535547        $app =& App::getInstance();
    536548
    537         if (parent::validateStrDate(getFormData($form_name, ''))) {
     549        if (Validator::validateStrDate(getFormData($form_name, ''))) {
    538550            return true;
    539551        } else {
     
    550562     *
    551563     * @param  string  $form_name   The name of the incoming form variable.
    552      * @param  string  $cc_type     Optional, card type to do specific checks. One of the CC_TYPE_* constants.
     564     * @param  string  $cc_type     Optional, card type to do specific checks. One of the Validator::CC_TYPE_* constants.
    553565     *
    554566     * @return bool    true if no errors found, false otherwise
    555567     */
    556     function validateCCNumber($form_name, $cc_type=null)
     568    public function validateCCNumber($form_name, $cc_type=null)
    557569    {
    558570        $cc_num = getFormData($form_name);
    559571
    560         if (parent::validateCCNumber($cc_num, $cc_type)) {
     572        if (Validator::validateCCNumber($cc_num, $cc_type)) {
    561573            return true;
    562574        } else {
     
    574586     * @return bool   true if no errors found, false otherwise
    575587     */
    576     function fileUploaded($form_name, $msg='')
    577     {
    578         if (parent::fileUploaded($form_name)) {
     588    public function fileUploaded($form_name, $msg='')
     589    {
     590        if (Validator::fileUploaded($form_name)) {
    579591            return true;
    580592        } else {
     
    586598} // THE END
    587599
    588 ?>
  • trunk/lib/Google_API.inc.php

    r396 r468  
    5353     * @access private
    5454     */
    55     var $_licenseKey = '';
     55    private $_licenseKey = '';
    5656
    5757    /**
     
    5959     * @access private
    6060     */
    61     var $_soapClient = NULL;
     61    private $_soapClient = NULL;
    6262
    6363    /**
     
    6767     * @access public
    6868     */
    69     function Google_API($licenseKey)
     69    public function __construct($licenseKey)
    7070    {
    7171        $this->_licenseKey = $licenseKey;
     
    8282     * @access public
    8383     */
    84     function getCachedPage($url)
     84    public function getCachedPage($url)
    8585    {
    8686        $result = $this->_performAPICall(
     
    104104     * @access public
    105105     */
    106     function getSpellingSuggestion($phrase)
     106    public function getSpellingSuggestion($phrase)
    107107    {
    108108        return $this->_performAPICall(
     
    122122     * @access public
    123123     */
    124     function search($parameters = array())
     124    public function search($parameters = array())
    125125    {
    126126        if (!isset($parameters['query'])) {
     
    150150     * @access private
    151151     */
    152     function _performAPICall($apiCall, $parameters)
     152    private function _performAPICall($apiCall, $parameters)
    153153    {
    154154        $app =& App::getInstance();
     
    167167    }
    168168}
    169 ?>
    170 
    171 
  • trunk/lib/Hierarchy.inc.php

    r441 r468  
    5252     *
    5353     */
    54     var $params = array();
     54    public $params = array();
    5555
    5656
     
    5959     * @var string $child_type
    6060     */
    61     var $child_type;
     61    public $child_type;
    6262
    6363    /**
     
    6565     * @var string $child_id
    6666     */
    67     var $child_id;
     67    public $child_id;
    6868
    6969    /**
     
    7272     * @var bool $node_init
    7373     */
    74     var $node_init = false;
     74    public $node_init = false;
    7575
    7676    /**
     
    8080     *                          configuration or connection parameters.
    8181     */
    82     function Hierarchy($params=array())
     82    public function __construct($params=array())
    8383    {
    8484        $this->params = $params;
     
    9292     *                      if no new ones are specified.
    9393     */
    94     function currentNode($child_type=null, $child_id=null)
     94    public function currentNode($child_type=null, $child_id=null)
    9595    {
    9696        $old_type = isset($this->child_type) ? $this->child_type : $child_type;
     
    113113     *                  otherwise if an array is provided, an array of identifiers is returned.
    114114     */
    115     function toStringID($child_type=null, $child_id=null)
     115    public function toStringID($child_type=null, $child_id=null)
    116116    {
    117117            $app =& App::getInstance();
     
    147147     * @return mixed    Array of node type and id on success, false on failure.
    148148     */
    149     function toArrayID(&$node)
     149    public function toArrayID(&$node)
    150150    {
    151151            $app =& App::getInstance();
     
    167167     * @return bool     true on success, false on error.
    168168     */
    169     function insertNode($parents, $child_type=null, $child_id=null, $relationship_type=null, $title='')
     169    public function insertNode($parents, $child_type=null, $child_id=null, $relationship_type=null, $title='')
    170170    {
    171171        $app =& App::getInstance();
     
    246246     * @return bool      false on error, true otherwise.
    247247     */
    248     function deleteNode($child_type=null, $child_id=null)
     248    public function deleteNode($child_type=null, $child_id=null)
    249249    {
    250250        $app =& App::getInstance();
     
    296296     * @return bool      false on error, true otherwise.
    297297     */
    298     function moveNode($new_parents=null, $child_type=null, $child_id=null, $relationship_type=null, $title='')
     298    public function moveNode($new_parents=null, $child_type=null, $child_id=null, $relationship_type=null, $title='')
    299299    {
    300300            $app =& App::getInstance();
     
    373373     * @return string   The parents as an array of serialized node identifiers.
    374374     */
    375     function getParents($child_type=null, $child_id=null, $type_constraint=null, $order='')
     375    public function getParents($child_type=null, $child_id=null, $type_constraint=null, $order='')
    376376    {
    377377        $app =& App::getInstance();
     
    424424     * @return array   type, id, title, subnode_quantity.
    425425     */
    426     function getNode($child_type=null, $child_id=null)
     426    public function getNode($child_type=null, $child_id=null)
    427427    {
    428428        $app =& App::getInstance();
     
    468468     * @return string  The children as an array of serialized node identifiers.
    469469     */
    470     function getChildren($child_type=null, $child_id=null, $type_constraint=null, $order='')
     470    public function getChildren($child_type=null, $child_id=null, $type_constraint=null, $order='')
    471471    {
    472472        $app =& App::getInstance();
     
    520520     * @return integer
    521521     */
    522     function getNumberChildren($child_type=null, $child_id=null, $type_constraint=null)
     522    public function getNumberChildren($child_type=null, $child_id=null, $type_constraint=null)
    523523    {
    524524        $app =& App::getInstance();
     
    561561     * @return bool      true if a leaf, or false if not or an error
    562562     */
    563     function isLeaf($child_type=null, $child_id=null)
     563    public function isLeaf($child_type=null, $child_id=null)
    564564    {
    565565        $app =& App::getInstance();
     
    595595     *                   parent, or false otherwise, or in case of failure.
    596596     */
    597     function isAncestor($child_type, $child_id, $considered_parent_type, $considered_parent_id)
     597    public function isAncestor($child_type, $child_id, $considered_parent_type, $considered_parent_id)
    598598    {
    599599        $family_tree = $this->getAllAncestors($considered_parent_type, $considered_parent_id);
     
    622622     * @return array     Array of serialized node identifiers.
    623623     */
    624     function getAllAncestors($child_type, $child_id, $go_linear=false, $_return_flag=true)
     624    public function getAllAncestors($child_type, $child_id, $go_linear=false, $_return_flag=true)
    625625    {
    626626        $db =& DB::getInstance();
     
    676676     * @return bool      true if a leaf, or false if not or an error
    677677     */
    678     function nodeExists($child_type=null, $child_id=null, $parent_type=null, $parent_id=null, $relationship_type=null)
     678    public function nodeExists($child_type=null, $child_id=null, $parent_type=null, $parent_id=null, $relationship_type=null)
    679679    {
    680680        $app =& App::getInstance();
     
    728728     *                specified node: (type, id, title, indent level, selected status)
    729729     */
    730     function &getNodeList($preselected=null, $child_type=null, $child_id=null, $type_constraint=null, $include_curr=false, $order='', $_indent=0, $_return_flag=true)
     730    public function &getNodeList($preselected=null, $child_type=null, $child_id=null, $type_constraint=null, $include_curr=false, $order='', $_indent=0, $_return_flag=true)
    731731    {
    732732        $app =& App::getInstance();
     
    801801     * @param  string  $type_constraint  An array of node types to restrict the search to.
    802802     */
    803     function rebuildSubnodeQty($type_constraint=null)
     803    public function rebuildSubnodeQty($type_constraint=null)
    804804    {
    805805        $db =& DB::getInstance();
     
    825825     * all parents recursively.
    826826     */
    827     function setSubnodeQtyToParents($child_type, $child_id, $num_children)
     827    public function setSubnodeQtyToParents($child_type, $child_id, $num_children)
    828828    {
    829829        $db =& DB::getInstance();
     
    848848// THE END
    849849}
    850 
    851 
    852 
    853 
    854 ?>
  • trunk/lib/Image.inc.php

    r452 r468  
    3131
    3232    // Object parameters.
    33     var $_params = array();
     33    private $_params = array();
    3434
    3535    /**
     
    4141     * @since   26 Jan 2005 01:54:50
    4242     */
    43     function Image($params=array())
     43    public function __construct($params=array())
    4444    {
    4545        if (!is_array($params)) {
     
    7272     * @since   26 Jan 2005 01:54:50
    7373      */
    74     function exists($id)
     74    public function exists($id)
    7575    {
    7676        $src = $this->oSrc($id);
     
    9696     * @since   26 Jan 2005 01:54:50
    9797     */
    98     function size($id, $key)
     98    public function size($id, $key)
    9999    {
    100100        $src = $this->oSrc($id);
     
    114114     * @since   26 Jan 2005 01:56:35
    115115     */
    116     function oSrc($id)
     116    public function oSrc($id)
    117117    {
    118118        $file_name = '';
     
    139139     * @since   26 Jan 2005 01:57:33
    140140     */
    141     function oImg($id, $alt='', $extra='')
     141    public function oImg($id, $alt='', $extra='')
    142142    {
    143143        $src = $this->oSrc($id);
     
    158158    }
    159159} // End class
    160 
    161 ?>
  • trunk/lib/ImageThumb.inc.php

    r396 r468  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    4141
    4242class ImageThumb {
    43    
     43
    4444    // General object parameters.
    45     var $_params = array(
     45    private $_params = array(
    4646        // The location for images to create thumbnails from.
    4747        'source_dir' => null,
     
    5858        // Require file to have one of the following file name extensions.
    5959        'valid_file_extensions' => array('jpg', 'jpeg', 'gif', 'png'),
    60        
     60
    6161        // Method to use for resizing. (IMAGETHUMB_METHOD_NETPBM or IMAGETHUMB_METHOD_GD)
    6262        'resize_method' => IMAGETHUMB_METHOD_NETPBM,
     
    7070        'display_messages' => MSG_ALL,
    7171    );
    72    
     72
    7373    // Default image size specs.
    74     var $_default_image_specs = array(
    75         // The destination for an image thumbnail size. 
     74    private $_default_image_specs = array(
     75        // The destination for an image thumbnail size.
    7676        // Use initial / to specify absolute paths, leave off to specify a path relative to source_dir (eg: ../thumbs).
    7777        'dest_dir' => null,
    78        
     78
    7979        // Destination file types. (IMG_JPG, IMG_PNG, IMG_GIF, IMG_WBMP)
    8080        'dest_file_type' => IMG_JPG,
     
    8282        // Destination file types. ('jpg', 'png', 'gif', 'wbmp')
    8383        'dest_file_extension' => 'jpg',
    84        
     84
    8585        // Type of scaling to perform, and sizes used to calculate max dimensions.
    8686        'scaling_type' => IMAGETHUMB_FIT_LARGER,
     
    9696        // If using GD method, apply sharpen filter. Requires PHP > 5.1.
    9797        'sharpen' => true,
    98        
     98
    9999        // Integers between 1-100, useful values are 65-85.
    100100        'sharpen_value' => 75,
     
    108108
    109109    // Final specifications for image sizes, set with setSpec().
    110     var $_image_specs = array();
     110    private $_image_specs = array();
    111111
    112112    /**
     
    116116     * @param  array    $params     Array of parameters (key => val pairs).
    117117     */
    118     function setParam($params)
     118    public function setParam($params)
    119119    {
    120120        $app =& App::getInstance();
     
    160160     * @return mixed               Configured parameter value.
    161161     */
    162     function getParam($param)
    163     {
    164         $app =& App::getInstance();
    165    
     162    public function getParam($param)
     163    {
     164        $app =& App::getInstance();
     165
    166166        if (isset($this->_params[$param])) {
    167167            return $this->_params[$param];
     
    180180     *                          Use to overwrite existing spec array values.
    181181     */
    182     function setSpec($spec, $index=null)
     182    public function setSpec($spec, $index=null)
    183183    {
    184184        $app =& App::getInstance();
     
    188188            $app->logMsg('setSpec error: dest_dir not specified.', LOG_ERR, __FILE__, __LINE__);
    189189        } else {
    190             $spec['dest_dir'] = trim($spec['dest_dir']);           
     190            $spec['dest_dir'] = trim($spec['dest_dir']);
    191191        }
    192192        if (isset($spec['dest_file_type'])) {
     
    233233            $app->logMsg('The "progressive" specification is not used unless IMG_JPG is the dest_file_type.', LOG_INFO, __FILE__, __LINE__);
    234234        }
    235        
     235
    236236        // Add to _image_specs array.
    237237        if (isset($index) && isset($this->_image_specs[$index])) {
     
    241241        } else {
    242242            // Merge with spec defaults.
    243             $final_spec = array_merge($this->_default_image_specs, $spec);           
     243            $final_spec = array_merge($this->_default_image_specs, $spec);
    244244            $this->_image_specs[] = $final_spec;
    245245        }
    246        
     246
    247247        return $final_spec;
    248248    }
    249    
     249
    250250    /*
    251251    * Retrieve a value of a thumb specification.
     
    259259    * @since    08 May 2007 15:26:39
    260260    */
    261     function getSpec($key, $index=null)
     261    public function getSpec($key, $index=null)
    262262    {
    263263        $index = isset($index) ? $index : 0;
     
    271271     * @return  bool true on success, false on failure.
    272272     */
    273     function processAll($runtime_specs=null)
     273    public function processAll($runtime_specs=null)
    274274    {
    275275        $app =& App::getInstance();
     
    313313     * @return  bool true on success, false on failure.
    314314     */
    315     function processFile($file_name, $runtime_specs=null)
     315    public function processFile($file_name, $runtime_specs=null)
    316316    {
    317317        $app =& App::getInstance();
     
    319319        // Source file determined by provided file_name.
    320320        $source_file = realpath(sprintf('%s/%s', $this->getParam('source_dir'), $file_name));
    321        
     321
    322322        // Ensure we have a source.
    323323        if (sizeof($this->_image_specs) < 1) {
     
    326326            } else {
    327327                $app->logMsg(sprintf('Image specifications not set before processing.'), LOG_ERR, __FILE__, __LINE__);
    328                 return false;               
     328                return false;
    329329            }
    330330        }
     
    369369            return false;
    370370        }
    371        
     371
    372372        // To keep this script running even if user tries to stop browser.
    373373        ignore_user_abort(true);
     
    379379
    380380        foreach ($this->_image_specs as $index => $spec) {
    381            
     381
    382382            if (is_array($runtime_specs)) {
    383383                // Override with runtime specs.
    384384                $spec = $this->setSpec($runtime_specs, $index);
    385385            }
    386            
     386
    387387            // Destination filename uses the extension defined by dest_file_extension.
    388388            if ('/' == $spec['dest_dir']{0}) {
     
    393393                $dest_file = sprintf('%s/%s/%s.%s', $this->getParam('source_dir'), $spec['dest_dir'], mb_substr($file_name, 0, mb_strrpos($file_name, '.')), $spec['dest_file_extension']);
    394394            }
    395                  
     395
    396396            // Ensure destination directory exists and is writable.
    397397            if (!is_dir(dirname($dest_file)) || !is_writable(dirname($dest_file))) {
     
    438438        return 0 === $return_val;
    439439    }
    440    
     440
    441441    /*
    442442    * Use the Netpbm and libjpg cjpeg tools to generate a rescaled compressed image.
     
    452452    * @since    19 May 2006 13:55:46
    453453    */
    454     function _resizeWithNetpbm($source_file, $dest_file, $spec)
     454    private function _resizeWithNetpbm($source_file, $dest_file, $spec)
    455455    {
    456456        $app =& App::getInstance();
     
    491491        );
    492492        $app->logMsg(sprintf('ImageThumb Netpbm command: %s', $command), LOG_DEBUG, __FILE__, __LINE__);
    493        
     493
    494494        // Execute!
    495495        exec($command, $output, $return_val);
     
    521521    * @since    19 May 2006 15:46:02
    522522    */
    523     function _resizeWithGD($source_file, $dest_file, $spec)
     523    private function _resizeWithGD($source_file, $dest_file, $spec)
    524524    {
    525525        $app =& App::getInstance();
     
    593593            return 1;
    594594        }
    595        
     595
    596596        // Create destination image data in memory.
    597597        $dest_image_resource = imagecreatetruecolor($dest_image_width, $dest_image_height);
     
    605605            return 1;
    606606        }
    607        
     607
    608608        // Sharpen image using a custom filter matrix.
    609609        if (phpversion() > '5.1' && true === $spec['sharpen'] && $spec['sharpen_value'] > 0) {
    610             $sharpen_value = round((((48 - 10) / (100 - 1)) * (100 - $spec['sharpen_value'])) + 10); /// WTF is this math?
    611             imageconvolution($dest_image_resource, array(array(-1,-1,-1),array(-1,$sharpen_value,-1),array(-1,-1,-1)), ($sharpen_value - 8), 0);
     610            $sharpen_value = round((((48 - 10) / (100 - 1)) * (100 - $spec['sharpen_value'])) + 10); // TODO: WTF is this math?
     611            imageconvolution($dest_image_resource, array(array(-1, -1, -1), array(-1, $sharpen_value, -1),array(-1, -1, -1)), ($sharpen_value - 8), 0);
    612612        }
    613613
     
    662662     * @return  bool true on success, false on failure.
    663663     */
    664     function deleteThumbs($file_name, $use_glob=false)
     664    public function deleteThumbs($file_name, $use_glob=false)
    665665    {
    666666        $app =& App::getInstance();
     
    677677            $dest_dir = '/' == $spec['dest_dir']{0} ? $spec['dest_dir'] : sprintf('%s/%s', $this->getParam('source_dir'), $spec['dest_dir']);
    678678            if ($use_glob) {
    679                 $dest_file = realpath(sprintf('%s/%s', $dest_dir, $this->_glob($file_name, $dest_dir)));               
     679                $dest_file = realpath(sprintf('%s/%s', $dest_dir, $this->_glob($file_name, $dest_dir)));
    680680            } else {
    681681                $dest_file = realpath(sprintf('%s/%s.%s', $dest_dir, mb_substr($file_name, 0, mb_strrpos($file_name, '.')), $spec['dest_file_extension']));
    682             }           
    683            
     682            }
     683
    684684            if (file_exists($dest_file)) {
    685685                if (!unlink($dest_file)) {
     
    700700     * @return  bool true on success, false on failure.
    701701     */
    702     function deleteOriginal($file_name)
     702    public function deleteOriginal($file_name)
    703703    {
    704704        $app =& App::getInstance();
     
    733733     * @return  bool true on success, false on failure.
    734734     */
    735     function exists($file_name)
     735    public function exists($file_name)
    736736    {
    737737        $app =& App::getInstance();
     
    754754     * @return  bool    True on success, false on failure.
    755755     */
    756     function _validFileExtension($file_name)
     756    private function _validFileExtension($file_name)
    757757    {
    758758        preg_match('/.*?\.(\w+)$/i', $file_name, $ext);
    759         return !empty($ext) && in_array(mb_strtolower($ext[1]), $this->getParam('valid_file_extensions'));       
     759        return !empty($ext) && in_array(mb_strtolower($ext[1]), $this->getParam('valid_file_extensions'));
    760760    }
    761761
     
    766766     * @return  bool true on success, false on failure.
    767767     */
    768     function _createDestDirs($filename=null)
     768    private function _createDestDirs($filename=null)
    769769    {
    770770        $app =& App::getInstance();
     
    792792                }
    793793                if (!file_exists($dest_dir)) {
     794                    // Recursively create destination directory.
    794795                    $app->logMsg(sprintf('Creating dest dir: %s', $dest_dir), LOG_DEBUG, __FILE__, __LINE__);
    795                     if (phpversion() > '5') {
    796                         // Recursive.
    797                         if (!file_exists($dest_dir) && !($ret = mkdir($dest_dir, $this->getParam('dest_dir_perms'), true))) {
    798                             $return_val++;
    799                             $app->logMsg(sprintf('mkdir failure: %s', $dest_dir), LOG_ERR, __FILE__, __LINE__);
    800                         }
    801                     } else {
    802                         // Recursive mkdir for php 4.
    803                         $path = '';
    804                         $depth = 0;
    805                         $ret = true;
    806                         foreach (array_diff(explode('/', $dest_dir), array('')) as $dir) {
    807                             $path .= '/' . $dir;
    808                             $depth++;
    809                             /// FIXME: This is a dirty way to make this work when open_basedir prevents looking at the first 3 directories in an absolute path.
    810                             if ($depth > 3 && !($ret = file_exists($path) ? true : mkdir($path, $this->getParam('dest_dir_perms')))) {
    811                                 $return_val++;
    812                                 $app->logMsg(sprintf('mkdir failure: %s', $path), LOG_ERR, __FILE__, __LINE__);
    813                                 break;
    814                             } else {
    815                                 $app->logMsg(sprintf('mkdir attempt: %s', $path), LOG_DEBUG, __FILE__, __LINE__);
    816                             }
    817                         }
     796                    if (!file_exists($dest_dir) && !($ret = mkdir($dest_dir, $this->getParam('dest_dir_perms'), true))) {
     797                        $return_val++;
     798                        $app->logMsg(sprintf('mkdir failure: %s', $dest_dir), LOG_ERR, __FILE__, __LINE__);
    818799                    }
    819 
    820800                    if ($ret) {
    821                         $app->logMsg(sprintf('mkdir success: %s', $dest_dir), LOG_DEBUG, __FILE__, __LINE__);                       
     801                        $app->logMsg(sprintf('mkdir success: %s', $dest_dir), LOG_DEBUG, __FILE__, __LINE__);
    822802                    }
    823803                } else {
     
    844824     * @param string $line    __LINE__.
    845825     */
    846     function _raiseMsg($message, $type, $file, $line)
     826    private function _raiseMsg($message, $type, $file, $line)
    847827    {
    848828        $app =& App::getInstance();
     
    852832        }
    853833    }
    854    
     834
    855835    /**
    856836     * Get filename by glob pattern. Searches a directory for an image that matches the
     
    864844     * @since   15 Nov 2005 20:55:22
    865845     */
    866     function _glob($pattern, $directory)
     846    private function _glob($pattern, $directory)
    867847    {
    868848        $file_list = glob(sprintf('%s/%s', $directory, $pattern));
     
    875855
    876856} // End of class.
    877 ?>
  • trunk/lib/Lock.inc.php

    r424 r468  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    3131class Lock {
    3232
     33    // A place to keep an object instance for the singleton pattern.
     34    private static $instance = null;
     35
    3336    // Configuration of this object.
    34     var $_params = array(
     37    private $_params = array(
    3538        'timeout' => 600,
    3639        'auto_timeout' => 1800,
     
    4447
    4548    // Store lock data from DB.
    46     var $data = array();
     49    private $data = array();
    4750
    4851    // Auth_SQL object from which to access a current user_id.
    49     var $_auth;
     52    private $_auth;
    5053
    5154    /**
     
    5659     * @static
    5760     */
    58     static function &getInstance($auth_object)
    59     {
    60         static $instance = null;
    61 
    62         if ($instance === null) {
    63             $instance = new Lock($auth_object);
    64         }
    65 
    66         return $instance;
     61    public static function &getInstance($auth_object)
     62    {
     63        if (self::$instance === null) {
     64            self::$instance = new self($auth_object);
     65        }
     66
     67        return self::$instance;
    6768    }
    6869
     
    7273     * @param mixed  $auth_object  An Auth_SQL or Auth_FILE object.
    7374     */
    74     function Lock($auth_object)
     75    public function __construct($auth_object)
    7576    {
    7677        $app =& App::getInstance();
     
    9596     * @since   26 Aug 2005 17:09:36
    9697     */
    97     function initDB($recreate_db=false)
     98    public function initDB($recreate_db=false)
    9899    {
    99100        $app =& App::getInstance();
     
    142143     * @param  array $params   Array of param keys and values to set.
    143144     */
    144     function setParam($params=null)
     145    public function setParam($params=null)
    145146    {
    146147        if (isset($params) && is_array($params)) {
     
    157158     * @return mixed               Configured parameter value.
    158159     */
    159     function getParam($param)
    160     {
    161         $app =& App::getInstance();
    162    
     160    public function getParam($param)
     161    {
     162        $app =& App::getInstance();
     163
    163164        if (isset($this->_params[$param])) {
    164165            return $this->_params[$param];
     
    178179     * @param string $title       A title to apply to the lock, for display purposes.
    179180     */
    180     function select($record_table_or_lock_id, $record_key=null, $record_val=null)
     181    public function select($record_table_or_lock_id, $record_key=null, $record_val=null)
    181182    {
    182183        $app =& App::getInstance();
     
    205206        if ($this->data = mysql_fetch_assoc($qid)) {
    206207            $app->logMsg(sprintf('Selecting %slocked record: %s %s %s', ($this->data['set_by_admin_id'] == $this->_auth->get('user_id') ? 'self-' : ''), $record_table_or_lock_id, $record_key, $record_val), LOG_DEBUG, __FILE__, __LINE__);
    207             /// FIX ME: What if admin set lock, but public user is current lock user?
     208            // FIXME: What if admin set lock, but public user is current lock user?
    208209            $this->data['editor'] = $this->_auth->getUsername($this->data['set_by_admin_id']);
    209210            return true;
     
    219220     * @return bool            True if locked.
    220221     */
    221     function isLocked()
     222    public function isLocked()
    222223    {
    223224        return isset($this->data['lock_id']);
     
    230231     * @return bool            True if current user set the lock.
    231232     */
    232     function isMine()
    233     {
    234         $db =& DB::getInstance();
    235    
     233    public function isMine()
     234    {
     235        $db =& DB::getInstance();
     236
    236237        $this->initDB();
    237238
     
    258259     * @return int            The id for the lock (mysql last insert id).
    259260     */
    260     function set($record_table, $record_key, $record_val, $title='')
    261     {
    262         $db =& DB::getInstance();
    263    
     261    public function set($record_table, $record_key, $record_val, $title='')
     262    {
     263        $db =& DB::getInstance();
     264
    264265        $this->initDB();
    265266
     
    304305     * Unlock the currently selected record.
    305306     */
    306     function remove()
     307    public function remove()
    307308    {
    308309        $app =& App::getInstance();
     
    326327     * Unlock all records, or all records for a specified user.
    327328     */
    328     function removeAll($user_id=null)
     329    public function removeAll($user_id=null)
    329330    {
    330331        $app =& App::getInstance();
     
    350351     * Deletes all locks that are older than auto_timeout.
    351352     */
    352     function _auto_timeout()
    353     {
    354         $db =& DB::getInstance();
    355    
     353    public function _auto_timeout()
     354    {
     355        $db =& DB::getInstance();
     356
    356357        static $_timeout_run = false;
    357358
     
    371372     * Redirect to record lock error page.
    372373     */
    373     function dieErrorPage()
     374    public function dieErrorPage()
    374375    {
    375376        $app =& App::getInstance();
     
    381382     * Print error page.
    382383     */
    383     function printErrorHTML()
     384    public function printErrorHTML()
    384385    {
    385386        $app =& App::getInstance();
     
    416417     * Return lock_id of locked record.
    417418     */
    418     function getID()
     419    public function getID()
    419420    {
    420421        return $this->data['lock_id'];
     
    424425     * Return title of locked record.
    425426     */
    426     function getTitle()
     427    public function getTitle()
    427428    {
    428429        return $this->data['title'];
     
    432433     * Return administrator username for locked record.
    433434     */
    434     function getEditor()
     435    public function getEditor()
    435436    {
    436437        return $this->data['editor'];
     
    440441     * Return total seconds since the record was locked.
    441442     */
    442     function getSecondsElapsed()
     443    public function getSecondsElapsed()
    443444    {
    444445        if (isset($this->data['lock_datetime']) && strtotime($this->data['lock_datetime']) < time()) {
     
    451452
    452453} // End of class.
    453 ?>
  • trunk/lib/MCVE.inc.php

    r396 r468  
    3131class MCVE {
    3232
    33     var $username;
    34     var $password;
    35     var $host = 'localhost';
    36     var $ip_port = 8333;
    37     var $ssl_port = 8444;
    38     var $ca_bundle_file = '/usr/share/ssl/certs/ca-bundle.crt';
    39     var $connect_method = 'ip';
    40     var $timeout = 10;
    41     var $blocking = 1;
    42     var $connected = false;
    43     var $conn;
    44 
    45     function MCVE($username, $password)
     33    public $username;
     34    public $password;
     35    public $host = 'localhost';
     36    public $ip_port = 8333;
     37    public $ssl_port = 8444;
     38    public $ca_bundle_file = '/usr/share/ssl/certs/ca-bundle.crt';
     39    public $connect_method = 'ip';
     40    public $timeout = 10;
     41    public $blocking = 1;
     42    public $connected = false;
     43    public $conn;
     44
     45    public function __construct($username, $password)
    4646    {
    4747        $app =& App::getInstance();
     
    5858    }
    5959
    60     function _connect()
     60    private function _connect()
    6161    {
    6262        $app =& App::getInstance();
     
    123123    }
    124124
    125     function beginTrans()
     125    public function beginTrans()
    126126    {
    127127        if (!$this->_connect()) {
     
    134134    }
    135135
    136     function transParam($tid, $key, $var1, $var2=null)
     136    public function transParam($tid, $key, $var1, $var2=null)
    137137    {
    138138        if (!isset($var2)) {
     
    144144    }
    145145
    146     function sendTrans($tid, $type='', $hide_msg=false)
     146    public function sendTrans($tid, $type='', $hide_msg=false)
    147147    {
    148148        $app =& App::getInstance();
     
    191191    }
    192192
    193     function disconnect($tid)
     193    public function disconnect($tid)
    194194    {
    195195        if ($this->connected) {
     
    208208// End of class.
    209209
    210 ?>
  • trunk/lib/Navigation.inc.php

    r464 r468  
    3737
    3838    // Configuration parameters for this object.
    39     var $_params = array(
     39    private $_params = array(
    4040        'head_title' => true,
    4141        'body_title' => true,
     
    4848        'last_crumb_format' => '%s',
    4949    );
    50     var $pages = array();
     50    public $pages = array();
    5151
    5252    /**
    5353     * Navigation constructor.
    5454     */
    55     function Navigation($params=null)
     55    public function __construct($params=null)
    5656    {
    5757        $app =& App::getInstance();
     
    7474     * @param   array   $vars       Additional page variables.
    7575     */
    76     function add($title, $url=null, $vars=array())
     76    public function add($title, $url=null, $vars=array())
    7777    {
    7878        $page = array(
     
    9191     * @param  array    $params     Array of parameters (key => val pairs).
    9292     */
    93     function setParam($params)
     93    public function setParam($params)
    9494    {
    9595        $app =& App::getInstance();
     
    110110     * @return mixed               Configured parameter value.
    111111     */
    112     function getParam($param)
     112    public function getParam($param)
    113113    {
    114114        $app =& App::getInstance();
     
    127127     * @access  public
    128128     */
    129     function clear()
     129    public function clear()
    130130    {
    131131        $this->pages = array();
     
    139139     * @param mixed $val      Value to set variable to.
    140140     */
    141     function set($key, $val)
     141    public function set($key, $val)
    142142    {
    143143        // Set params of current page.
     
    154154     * @return mixed          Value stored in session.
    155155     */
    156     function get($key, $default='')
     156    public function get($key, $default='')
    157157    {
    158158        $curr_page =& $this->pages[sizeof($this->pages) - 1];
     
    205205     * @return  mixed           Path (string) or false if path param is not set.
    206206     */
    207     function getPath($key='title')
     207    public function getPath($key='title')
    208208    {
    209209        if ($this->getParam('path')) {
     
    227227     * @return  string   Breadcrumbs or empty string if breadcrumbs param not set.
    228228     */
    229     function getBreadcrumbs()
     229    public function getBreadcrumbs()
    230230    {
    231231        $app =& App::getInstance();
     
    279279     * @return  mixed   The value set for $return, TRUE by default.
    280280     */
    281     function currentPage($test_uri, $true_return=true, $false_return=false, $strip_query=false)
     281    public function currentPage($test_uri, $true_return=true, $false_return=false, $strip_query=false)
    282282    {
    283283        $actual_uri = $strip_query ? strtok($_SERVER['REQUEST_URI'], '?') : $_SERVER['REQUEST_URI'];
     
    291291}
    292292// End of class.
    293 
    294 ?>
  • trunk/lib/PEdit.inc.php

    r441 r468  
    7070
    7171    // PEdit object parameters.
    72     var $_params = array(
     72    private $_params = array(
    7373        'data_dir' => '',
    7474        'character_set' => 'utf-8',
     
    7777    );
    7878
    79     var $_data = array(); // Array to store loaded data.
    80     var $_data_file = ''; // Full file path to the pedit data file.
    81     var $_authorized = false; // User is authenticated to see extended functions.
    82     var $_data_loaded = false;
    83     var $op = '';
     79    private $_data = array(); // Array to store loaded data.
     80    private $_data_file = ''; // Full file path to the pedit data file.
     81    private $_authorized = false; // User is authenticated to see extended functions.
     82    private $_data_loaded = false;
     83    public $op = '';
    8484
    8585    /**
     
    9393     * @param optional array $params  A hash containing connection parameters.
    9494     */
    95     function PEdit($params)
     95    public function __construct($params)
    9696    {
    9797        $this->setParam($params);
     
    121121     * @param  array    $params     Array of parameters (key => val pairs).
    122122     */
    123     function setParam($params)
     123    public function setParam($params)
    124124    {
    125125        $app =& App::getInstance();
     
    140140     * @return mixed               Configured parameter value.
    141141     */
    142     function getParam($param)
     142    public function getParam($param)
    143143    {
    144144        $app =& App::getInstance();
     
    159159    * @since    12 Apr 2006 12:43:47
    160160    */
    161     function start($initialize_data_file=false)
     161    public function start($initialize_data_file=false)
    162162    {
    163163        $app =& App::getInstance();
     
    217217     * @param array     $options         Additional options to store with this data.
    218218     */
    219     function set($name, $options=array())
     219    public function set($name, $options=array())
    220220    {
    221221        $app =& App::getInstance();
     
    236236     * @return string        The trimmed content of the named data.
    237237     */
    238     function get($name)
     238    public function get($name)
    239239    {
    240240        $name = preg_replace('/\s/', '_', $name);
     
    251251     * @return bool  False if unauthorized or current page is a version.
    252252     */
    253     function formBegin()
     253    public function formBegin()
    254254    {
    255255        $app =& App::getInstance();
     
    288288     * @access public
    289289     */
    290     function printAllForms()
     290    public function printAllForms()
    291291    {
    292292        if ($this->_authorized && $this->op == 'Edit' && is_array($this->_data) && $this->_data_loaded) {
     
    305305     * @param string $type      Type of form to print. Currently only 'text' and 'textarea' supported.
    306306     */
    307     function printForm($name, $type='text')
     307    public function printForm($name, $type='text')
    308308    {
    309309        if ($this->_authorized && $this->op == 'Edit' && $this->_data_loaded) {
     
    345345     * @return bool  False if unauthorized or current page is a version.
    346346     */
    347     function formEnd()
     347    public function formEnd()
    348348    {
    349349        if (!$this->_authorized || empty($this->_data)) {
     
    399399     * @access public
    400400     */
    401     function printVersions()
     401    public function printVersions()
    402402    {
    403403        $app =& App::getInstance();
     
    442442    * @since    12 Apr 2006 10:52:35
    443443    */
    444     function _fileHash()
     444    private function _fileHash()
    445445    {
    446446        $app =& App::getInstance();
     
    457457    * @since    11 Apr 2006 20:36:26
    458458    */
    459     function _loadDataFile()
     459    private function _loadDataFile()
    460460    {
    461461        $app =& App::getInstance();
     
    496496    * @since    11 Apr 2006 20:53:42
    497497    */
    498     function _initializeDataFile()
     498    private function _initializeDataFile()
    499499    {
    500500        $app =& App::getInstance();
     
    512512     * @return bool  False if unauthorized or on failure. True on success.
    513513     */
    514     function _writeData()
     514    private function _writeData()
    515515    {
    516516        $app =& App::getInstance();
     
    560560    * @since    11 Apr 2006 22:48:30
    561561    */
    562     function _filePutContents($filename, $content)
     562    private function _filePutContents($filename, $content)
    563563    {
    564564        $app =& App::getInstance();
     
    610610     * @return bool  False on failure. True on success.
    611611     */
    612     function _createVersion()
     612    private function _createVersion()
    613613    {
    614614        $app =& App::getInstance();
     
    648648    * @since    12 Apr 2006 11:08:11
    649649    */
    650     function _deleteOldVersions()
     650    private function _deleteOldVersions()
    651651    {
    652652        $app =& App::getInstance();
     
    676676     * @return array  Array of versions.
    677677     */
    678     function _getVersions()
     678    private function _getVersions()
    679679    {
    680680        $version_files = array();
     
    707707     * @return bool  False on failure. True on success.
    708708     */
    709     function _restoreVersion($version)
     709    private function _restoreVersion($version)
    710710    {
    711711        $app =& App::getInstance();
     
    742742
    743743} // End class.
    744 
    745 ?>
  • trunk/lib/PageNumbers.inc.php

    r396 r468  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    3939class PageNumbers {
    4040
    41     var $total_items;       // Total quantity of items.
    42     var $total_pages;       // The total number of pages.
    43     var $current_page = 1;  // Current page number.
    44     var $first_item;        // The counter for the first item on this page (zero index).
    45     var $last_item;         // The counter for the last item on this page (zero index).
    46     var $max_num_links = 9; // The max number of links to show on page (odd numbers look best).
    47     var $_num_links;        // The number of links to show on page.
    48     var $_per_page = 25;    // Items per page.
     41    public $total_items;       // Total quantity of items.
     42    public $total_pages;       // The total number of pages.
     43    public $current_page = 1;  // Current page number.
     44    public $first_item;        // The counter for the first item on this page (zero index).
     45    public $last_item;         // The counter for the last item on this page (zero index).
     46    public $max_num_links = 9; // The max number of links to show on page (odd numbers look best).
     47    private $_num_links;        // The number of links to show on page.
     48    private $_per_page = 25;    // Items per page.
    4949
    5050    // Flags to ensure all necessary values have been set before calling calculate().
    51     var $set_per_page_initialized = false;
    52     var $set_page_number_initialized = false;
    53     var $set_total_items_initialized = false;
     51    public $set_per_page_initialized = false;
     52    public $set_page_number_initialized = false;
     53    public $set_total_items_initialized = false;
    5454
    5555    // These are initialized in the constructor.
    56     var $per_page_options;
    57     var $left_arrow;
    58     var $left_arrow_disabled;
    59     var $left_dbl_arrow;
    60     var $left_dbl_arrow_disabled;
    61     var $right_arrow;
    62     var $right_arrow_disabled;
    63     var $right_dbl_arrow;
    64     var $right_dbl_arrow_disabled;
     56    public $per_page_options;
     57    public $left_arrow;
     58    public $left_arrow_disabled;
     59    public $left_dbl_arrow;
     60    public $left_dbl_arrow_disabled;
     61    public $right_arrow;
     62    public $right_arrow_disabled;
     63    public $right_dbl_arrow;
     64    public $right_dbl_arrow_disabled;
    6565
    6666    /**
    6767     * PageNumbers constructor. All arguments are depreciated. Use set* functions instead.
    6868     */
    69     function PageNumbers()
     69    public function __construct()
    7070    {
    7171        // Default options for the quantity per page links.
     
    8585        // in special cases like using a /my/page/# scheme.
    8686        $this->url_base = $_SERVER['PHP_SELF'] . '?page_number=';
    87        
     87
    8888        $this->prefs = new Prefs($_SERVER['PHP_SELF']);
    8989        $this->prefs->setParam(array('persistent' => false));
     
    9393     * Set the number of items per page.
    9494     */
    95     function setPerPage($per_page, $default=25, $save_value=true)
     95    public function setPerPage($per_page, $default=25, $save_value=true)
    9696    {
    9797        // (1) By provided argument, if valid.
     
    115115     * Set the current page number.
    116116     */
    117     function setPageNumber($page_number, $save_value=true)
     117    public function setPageNumber($page_number, $save_value=true)
    118118    {
    119119        // (1) By provided argument, if valid.
     
    139139     * Set the total number of items.
    140140     */
    141     function setTotalItems($total_items)
     141    public function setTotalItems($total_items)
    142142    {
    143143        if (is_numeric($total_items) && $total_items > 0) {
     
    158158     * @access public
    159159     */
    160     function calculate()
     160    public function calculate()
    161161    {
    162162        $app =& App::getInstance();
     
    212212     * Returns the SQL code to limit query to items that are on current page.
    213213     */
    214     function getLimitSQL()
     214    public function getLimitSQL()
    215215    {
    216216        $app =& App::getInstance();
     
    230230     * @access public
    231231     */
    232     function printPerPageLinks($query_key='per_page')
     232    public function printPerPageLinks($query_key='per_page')
    233233    {
    234234        $app =& App::getInstance();
     
    260260     * @access public
    261261     */
    262     function getPageNumURL($page_number, $carry_args=null)
     262    public function getPageNumURL($page_number, $carry_args=null)
    263263    {
    264264        $app =& App::getInstance();
     
    266266        return $app->oHREF($this->url_base . $page_number, $carry_args);
    267267    }
    268     function printPageNumURL($page_number, $carry_args=null)
     268    public function printPageNumURL($page_number, $carry_args=null)
    269269    {
    270270        echo $this->getPageNumURL($page_number, $carry_args);
     
    276276     * @access public
    277277     */
    278     function getPageNumbersArray($carry_args=null)
     278    public function getPageNumbersArray($carry_args=null)
    279279    {
    280280        $page_numbers = array();
     
    296296     * @access public
    297297     */
    298     function getPageNumbers($carry_args=null)
     298    public function getPageNumbers($carry_args=null)
    299299    {
    300300        $page_numbers_string = '';
     
    361361    }
    362362
    363     function printPageNumbers($carry_args=null)
     363    public function printPageNumbers($carry_args=null)
    364364    {
    365365        echo $this->getPageNumbers($carry_args);
     
    368368}
    369369
    370 ?>
  • trunk/lib/PageSequence.inc.php

    r396 r468  
    3535class PageSequence
    3636{
    37     var $current_step_id = 0;
    38     var $start_url;
    39     var $sequence_title = '';
    40     var $seq = '_sequence_';
    41     var $idle_timeout;
     37    public $current_step_id = 0;
     38    public $start_url;
     39    public $sequence_title = '';
     40    public $seq = '_sequence_';
     41    public $idle_timeout;
    4242
    4343    /**
     
    4747     * @access public
    4848     */
    49     function PageSequence($params)
     49    public function __construct($params)
    5050    {
    5151        if (isset($params['sequence_title'])) {
     
    8484     * @access public
    8585     */
    86     function addStep($step_id, $params)
     86    public function addStep($step_id, $params)
    8787    {
    8888        // Keys for the steps array cannot be numeric.
     
    114114     * @return bool true on success, false on failure
    115115     */
    116     function setFeature($step_id=null, $features)
     116    public function setFeature($step_id=null, $features)
    117117    {
    118118        $pos = isset($step_id) ? $this->getPosition($step_id) : $this->getPosition();
     
    134134     * @return mixed          Value stored in session.
    135135     */
    136     function getFeature($step_id, $key, $default='')
     136    public function getFeature($step_id, $key, $default='')
    137137    {
    138138        $pos = isset($step_id) ? $this->getPosition($step_id) : $this->getPosition();
     
    151151     * @access public
    152152     */
    153     function setCurrent($step_id)
     153    public function setCurrent($step_id)
    154154    {
    155155        $app =& App::getInstance();
     
    171171     * @access public
    172172     */
    173     function getID($pos=null)
     173    public function getID($pos=null)
    174174    {
    175175        if (isset($pos)) {
     
    188188     * @access public
    189189     */
    190     function getPosition($step_id=null)
     190    public function getPosition($step_id=null)
    191191    {
    192192        // Get current step id if step not provided.
     
    217217     * @access public
    218218     */
    219     function getRequiredID($curr_step_id)
     219    public function getRequiredID($curr_step_id)
    220220    {
    221221        if ('' === $curr_step_id) {
     
    242242     * @access public
    243243     */
    244     function getNextID()
     244    public function getNextID()
    245245    {
    246246        // Loop through all steps.
     
    263263     * @access public
    264264     */
    265     function complete($step_id=null)
     265    public function complete($step_id=null)
    266266    {
    267267        $pos = isset($step_id) ? $this->getPosition($step_id) : $this->getPosition();
     
    277277     * @access public
    278278     */
    279     function printEditLink($step_id=null)
     279    public function printEditLink($step_id=null)
    280280    {
    281281        $app =& App::getInstance();
     
    296296     * @access public
    297297     */
    298     function setDataDefault($data_key, $data_val)
     298    public function setDataDefault($data_key, $data_val)
    299299    {
    300300        if (!isset($_SESSION[$this->seq]['data'][$data_key])) {
     
    310310     * @access public
    311311     */
    312     function getData($data_key=null)
     312    public function getData($data_key=null)
    313313    {
    314314        if (!isset($data_key)) {
     
    328328     * @access public
    329329     */
    330     function clearData($data_key=null)
     330    public function clearData($data_key=null)
    331331    {
    332332        if (isset($data_key)) {
     
    342342     * Deletes all data that are older than auto_timeout. Set current time if not not expired or not set.
    343343     */
    344     function _auto_timeout()
     344    private function _auto_timeout()
    345345    {
    346346        $app =& App::getInstance();
     
    363363     * @access public
    364364     */
    365     function registerData($step_data)
     365    public function registerData($step_data)
    366366    {
    367367        $_SESSION[$this->seq]['data'] = array_merge($_SESSION[$this->seq]['data'], $step_data);
     
    372372     *
    373373     */
    374     function startOver()
     374    public function startOver()
    375375    {
    376376        $this->current_step_id = 0;
     
    383383} // END CLASS
    384384
    385 ?>
  • trunk/lib/PayPal.inc.php

    r396 r468  
    3333
    3434    // General object parameters.
    35     var $_params = array(
     35    private $_params = array(
    3636        'paypal_url' => 'https://www.paypal.com/cgi-bin/webscr',
    3737        'test_mode' => false,
     
    3939
    4040    // Options used for specific buttons and links.
    41     var $_default_button_options = array();
     41    private $_default_button_options = array();
    4242
    4343    // Array of buttons created by newButton().
    44     var $_buttons = array();
     44    private $_buttons = array();
    4545
    4646    // Store the response from the last IPN.
    47     var $_ipn_response;
     47    private $_ipn_response;
    4848
    4949    /**
     
    5252     * @param   bool    $test_mode  Use PayPal sandbox for testing.
    5353     */
    54     function PayPal($test_mode=false)
     54    public function __construct($test_mode=false)
    5555    {
    5656        if ($test_mode) {
     
    9595     * @return  bool    True on success, false on failure.
    9696     */
    97     function setButtonDefaults($type, $options)
     97    public function setButtonDefaults($type, $options)
    9898    {
    9999        $app =& App::getInstance();
     
    127127     * @return  bool    True on success, false on failure.
    128128     */
    129     function newButton($type, $name, $options=null)
     129    public function newButton($type, $name, $options=null)
    130130    {
    131131        $app =& App::getInstance();
     
    162162     * @return  mixed   Link of button, or false on failure.
    163163     */
    164     function getLink($name)
     164    public function getLink($name)
    165165    {
    166166        $app =& App::getInstance();
     
    196196     * @param   string  $name   Name of button for which to generate link.
    197197     */
    198     function printLink($name)
     198    public function printLink($name)
    199199    {
    200200        echo $this->getLink($name);
     
    208208     * @param   string  $name   Name of button to print.
    209209     */
    210     function printButton($name)
     210    public function printButton($name)
    211211    {
    212212        ?>
     
    234234     * @param  array    $params     Array of parameters (key => val pairs).
    235235     */
    236     function setParam($params)
     236    public function setParam($params)
    237237    {
    238238        $app =& App::getInstance();
     
    253253     * @return mixed               Configured parameter value.
    254254     */
    255     function getParam($param)
     255    public function getParam($param)
    256256    {
    257257        $app =& App::getInstance();
     
    272272     * @return  bool    True if valid, false if invalid.
    273273     */
    274     function incomingIPNRequest()
     274    public function incomingIPNRequest()
    275275    {
    276276        if ($_SERVER['REQUEST_METHOD'] == 'POST'
     
    290290     * @return  bool    True on success, false on failure.
    291291     */
    292     function processIPN()
     292    public function processIPN()
    293293    {
    294294        $app =& App::getInstance();
     
    351351     * @return  bool    True if response contains VERIFIED, false otherwise.
    352352     */
    353     function verifiedIPN()
     353    public function verifiedIPN()
    354354    {
    355355        $app =& App::getInstance();
     
    380380} // End of class.
    381381
    382 ?>
  • trunk/lib/Prefs.inc.php

    r463 r468  
    5555
    5656    // Namespace of this instance of Prefs.
    57     var $_ns;
     57    private $_ns;
    5858
    5959    // Configuration parameters for this object.
    60     var $_params = array(
     60    private $_params = array(
    6161
    6262        // Enable database storage. If this is false, all prefs will live only as long as the session.
     
    8080     * Prefs constructor.
    8181     */
    82     function Prefs($namespace='')
     82    public function __construct($namespace='')
    8383    {
    8484        $app =& App::getInstance();
     
    104104     * @since   04 Jun 2006 16:41:42
    105105     */
    106     function initDB($recreate_db=false)
     106    public function initDB($recreate_db=false)
    107107    {
    108108        $app =& App::getInstance();
     
    142142     * @param  array $params   Array of param keys and values to set.
    143143     */
    144     function setParam($params=null)
     144    public function setParam($params=null)
    145145    {
    146146        if (isset($params) && is_array($params)) {
     
    157157     * @return mixed               Configured parameter value.
    158158     */
    159     function getParam($param)
     159    public function getParam($param)
    160160    {
    161161        $app =& App::getInstance();
     
    176176     * @param  array $defaults  Array of key-value pairs
    177177     */
    178     function setDefaults($defaults)
     178    public function setDefaults($defaults)
    179179    {
    180180        if (isset($defaults) && is_array($defaults)) {
     
    192192     * @param  bool   $persistent   Save this value forever? Set to false and value will exist as long as the session is in use.
    193193     */
    194     function set($key, $val)
     194    public function set($key, $val)
    195195    {
    196196        $app =& App::getInstance();
     
    223223     * @return string           The value of the preference.
    224224     */
    225     function get($key)
     225    public function get($key)
    226226    {
    227227        $app =& App::getInstance();
     
    244244     * @return boolean          True if the preference isset and not empty false otherwise.
    245245     */
    246     function exists($key)
     246    public function exists($key)
    247247    {
    248248        return array_key_exists($key, $_SESSION['_prefs'][$this->_ns]['saved']);
     
    254254     * @param string $key       The name of the preference to delete.
    255255     */
    256     function delete($key)
     256    public function delete($key)
    257257    {
    258258        unset($_SESSION['_prefs'][$this->_ns]['saved'][$key]);
     
    263263     * as $auth->clear(), such as when logging out.
    264264     */
    265     function clear($focus='all')
     265    public function clear($focus='all')
    266266    {
    267267        switch ($focus) {
     
    295295    * @since    04 Jun 2006 16:56:53
    296296    */
    297     function load($force=false)
     297    public function load($force=false)
    298298    {
    299299        $app =& App::getInstance();
     
    352352    * @since    04 Jun 2006 17:12:44
    353353    */
    354     function _isLoaded()
     354    private function _isLoaded()
    355355    {
    356356        if (isset($_SESSION['_prefs'][$this->_ns]['load_datetime'])
     
    373373    * @since    04 Jun 2006 17:19:56
    374374    */
    375     function save()
     375    public function save()
    376376    {
    377377        $app =& App::getInstance();
     
    424424}
    425425
    426 
    427 ?>
  • trunk/lib/ScriptTimer.inc.php

    r396 r468  
    2626class ScriptTimer {
    2727
    28     var $time_format = '%.3f';
    29     var $_timing_start_times = array();
    30     var $_timing_stop_times = array();
    31     var $_timing_cumulative_times = array();
     28    public $time_format = '%.3f';
     29    private $_timing_start_times = array();
     30    private $_timing_stop_times = array();
     31    private $_timing_cumulative_times = array();
    3232   
    33     function start($name='default')
     33    public function start($name='default')
    3434    {
    3535        $this->_timing_start_times[$name] = explode(' ', microtime());
    3636    }
    3737   
    38     function stop($name='default')
     38    public function stop($name='default')
    3939    {
    4040        if (!isset($this->_timing_stop_times[$name]) || !isset($this->_timing_cumulative_times[$name])) {
     
    4646    }
    4747   
    48     function getTime($name='default')
     48    public function getTime($name='default')
    4949    {
    5050        if (!isset($this->_timing_start_times[$name])) {
     
    6262    }
    6363   
    64     function printAll($sort_by_time=false)
     64    public function printAll($sort_by_time=false)
    6565    {
    6666        $names = array_map('strlen', array_keys($this->_timing_start_times));
     
    8181    }
    8282}
    83 
    84 ?>
  • trunk/lib/SortOrder.inc.php

    r457 r468  
    3737class SortOrder {
    3838
    39     var $_columns;
    40     var $sort_by;
    41     var $order;
    42     var $asc_widget;
    43     var $desc_widget;
    44     var $default_sort;
    45     var $default_order;
     39    private $_columns;
     40    public $sort_by;
     41    public $order;
     42    public $asc_widget;
     43    public $desc_widget;
     44    public $default_sort;
     45    public $default_order;
    4646
    4747    /**
     
    5353     *                               current order.
    5454     */
    55     function SortOrder($default_sort = '', $default_order = '')
     55    public function __construct($default_sort = '', $default_order = '')
    5656    {
    5757        $app =& App::getInstance();
     
    8181     * @param string $desc_sql  The sort SQL if $this->order is descending.
    8282     */
    83     function setColumn($name, $asc_sql, $desc_sql)
     83    public function setColumn($name, $asc_sql, $desc_sql)
    8484    {
    8585        $this->_columns[$name] = array(
     
    9999     *                               current order.
    100100     */
    101     function setDefault($default_sort = '', $default_order = '')
     101    public function setDefault($default_sort = '', $default_order = '')
    102102    {
    103103        // Which column to sort by?
     
    139139     *                               for example, for an alphabetical sort)
    140140     */
    141     function set($sort=null, $order=null, $save_value=true)
     141    public function set($sort=null, $order=null, $save_value=true)
    142142    {
    143143        // Set new sort value.
     
    163163     * @return array    Array with keys: sort and order. These can be fed back into the SortOrder::set() method or defaults.
    164164     */
    165     function get()
     165    public function get()
    166166    {
    167167        return array(
     
    174174     * Returns the SQL code to sort by set column and set order.
    175175     */
    176     function getSortOrderSQL()
     176    public function getSortOrderSQL()
    177177    {
    178178        $app =& App::getInstance();
     
    205205     *                               for example, for an alphabetical sort)
    206206     */
    207     function printSortHeader($col, $col_name, $default_order='ASC')
     207    public function printSortHeader($col, $col_name, $default_order='ASC')
    208208    {
    209209        $app =& App::getInstance();
     
    226226}
    227227
    228 ?>
  • trunk/lib/SpellCheck.inc.php

    r425 r468  
    6161class SpellCheck {
    6262
    63     var $_params = array(
     63    private $_params = array(
    6464        'language' => 'en',
    6565        'personal_wordlist' => '', // Text file to save custom words to.
     
    7070    );
    7171
    72     var $_pspell_cfg_handle;
    73     var $_pspell_handle;
    74     var $_use_personal_wordlist = false;
    75     var $_errors = array();
     72    private $_pspell_cfg_handle;
     73    private $_pspell_handle;
     74    private $_use_personal_wordlist = false;
     75    private $_errors = array();
    7676
    7777    /**
     
    8080     * @param  array    $params     Array of parameters (key => val pairs).
    8181     */
    82     function SpellCheck($params)
     82    public function __construct($params)
    8383    {
    8484        $app =& App::getInstance();
     
    118118     * @param  array    $params     Array of parameters (key => val pairs).
    119119     */
    120     function setParam($params)
     120    public function setParam($params)
    121121    {
    122122        $app =& App::getInstance();
     
    137137     * @return mixed               Configured parameter value.
    138138     */
    139     function getParam($param)
     139    public function getParam($param)
    140140    {
    141141        $app =& App::getInstance();
     
    154154     * @return bool   True if any errors were found, false otherwise.
    155155     */
    156     function anyErrors()
     156    public function anyErrors()
    157157    {
    158158        return (sizeof($this->_errors) > 0);
     
    162162     * Reset the error list.
    163163     */
    164     function resetErrorList()
     164    public function resetErrorList()
    165165    {
    166166        $this->_errors = array();
     
    177177     * @since   09 Jun 2005 18:23:51
    178178     */
    179     function check($word)
     179    public function check($word)
    180180    {
    181181        if (pspell_check($this->_pspell_handle, $word)) {
     
    197197     * @since   09 Jun 2005 18:23:51
    198198     */
    199     function suggest($word)
     199    public function suggest($word)
    200200    {
    201201        return pspell_suggest($this->_pspell_handle, $word);
     
    212212     * @since   09 Jun 2005 18:23:51
    213213     */
    214     function add($word)
     214    public function add($word)
    215215    {
    216216        $app =& App::getInstance();
     
    237237     * @since   09 Jun 2005 18:23:51
    238238     */
    239     function save()
     239    public function save()
    240240    {
    241241        $app =& App::getInstance();
     
    263263     * @since   09 Jun 2005 21:29:49
    264264     */
    265     function getStringSuggestions($string)
     265    public function getStringSuggestions($string)
    266266    {
    267267        $corrections = array();
     
    299299     * @since   09 Jun 2005 22:11:27
    300300     */
    301     function checkString($string)
     301    public function checkString($string)
    302302    {
    303303        $errors = array();
     
    331331     * @since   09 Jun 2005 21:29:49
    332332     */
    333     function getStringHighlighted($string, $show_footnote=false)
     333    public function getStringHighlighted($string, $show_footnote=false)
    334334    {
    335335        $words = preg_split('/([\W]+?)/', $string, -1, PREG_SPLIT_DELIM_CAPTURE);
     
    357357     * @since   09 Jun 2005 21:29:49
    358358     */
    359     function printCorrectionForm($form_name)
     359    public function printCorrectionForm($form_name)
    360360    {
    361361        ?>
     
    402402     * @since   09 Jun 2005 23:15:35
    403403     */
    404     function anyFormCorrections()
     404    public function anyFormCorrections()
    405405    {
    406406        return (false !== getFormData('spelling_suggestions', false)) || (false !== getFormData('spelling_corrections', false));
     
    417417     * @since   09 Jun 2005 23:18:51
    418418     */
    419     function applyFormCorrections($form_name)
     419    public function applyFormCorrections($form_name)
    420420    {
    421421        $form_words = preg_split('/([\W]+?)/', getFormData($form_name), -1, PREG_SPLIT_DELIM_CAPTURE);
     
    445445} // End.
    446446
    447 ?>
  • trunk/lib/TemplateGlue.inc.php

    r407 r468  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    2424 * TemplateGlue.inc.php
    2525 */
    26 
    27 /**
    28  * Print URL to download file with BBEdit/Interarchy. "USER" must be a pre-set
    29  * environment variable. Files must reside within and be relative to env "DOCUMENT_ROOT".
    30  *
    31  * @access  public
    32  * @param   mixed   $file   File path relative to DOCUMENT_ROOT (i.e. '/_templates/index.ihtml').
    33  * @return  string  <a> with file basename as text.
    34  */
    35 function bbftp($file)
    36 {
    37     return sprintf('<a href="bbftp://%s@%s:%s%s" title="%s" style="text-decoration: none; border-bottom: blue 1px dotted;">%s</a>', $_SERVER['USER'], $_SERVER['HTTP_HOST'], $_SERVER['DOCUMENT_ROOT'], $file, $file, basename($file));
    38 }
    3926
    4027/**
     
    8976    $app =& App::getInstance();
    9077    $db =& DB::getInstance();
    91    
     78
    9279    $qid = $db->query("SHOW COLUMNS FROM " . $db->escapeString($db_table) . " LIKE '" . $db->escapeString($db_col) . "'",false);
    9380
     
    9582    if (preg_match('/^enum|^set/i', $row[1]) && preg_match_all("/'([^']*)'/", $row[1], $enum)) {
    9683        if ($sort) {
    97             natsort($enum[1]);           
     84            natsort($enum[1]);
    9885        }
    9986        return $enum[1];
     
    329316{
    330317    $db =& DB::getInstance();
    331    
     318
    332319    // Sometimes preselected comes as a comma list.
    333320    if (!is_array($preselected)) {
     
    373360{
    374361    $db =& DB::getInstance();
    375    
     362
    376363    // Sometimes preselected comes as a comma list.
    377364    if (!is_array($preselected)) {
     
    501488    }
    502489}
    503 
    504 ?>
  • trunk/lib/Upload.inc.php

    r415 r468  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    4141
    4242    // General object parameters.
    43     var $_params = array(
     43    private $_params = array(
    4444
    4545        // Which messages do we pass to raiseMsg?
     
    6363
    6464    // Array of files with errors.
    65     var $errors = array();
     65    public $errors = array();
    6666
    6767    // Array of file name extensions and corresponding mime-types.
    68     var $mime_extension_map = array( 'ez' => 'application/andrew-inset', 'hqx' => 'application/mac-binhex40', 'cpt' => 'application/mac-compactpro', 'doc' => 'application/msword', 'bin' => 'application/octet-stream', 'class' => 'application/octet-stream', 'dll' => 'application/octet-stream', 'dms' => 'application/octet-stream', 'exe' => 'application/octet-stream', 'lha' => 'application/octet-stream', 'lzh' => 'application/octet-stream', 'so' => 'application/octet-stream', 'oda' => 'application/oda', 'pdf' => 'application/pdf', 'ai' => 'application/postscript', 'eps' => 'application/postscript', 'ps' => 'application/postscript', 'smi' => 'application/smil', 'smil' => 'application/smil', 'mif' => 'application/vnd.mif', 'xls' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', 'sxc' => 'application/vnd.sun.xml.calc', 'stc' => 'application/vnd.sun.xml.calc.template', 'sxd' => 'application/vnd.sun.xml.draw', 'std' => 'application/vnd.sun.xml.draw.template', 'sxi' => 'application/vnd.sun.xml.impress', 'sti' => 'application/vnd.sun.xml.impress.template', 'sxm' => 'application/vnd.sun.xml.math', 'sxw' => 'application/vnd.sun.xml.writer', 'sxg' => 'application/vnd.sun.xml.writer.global', 'stw' => 'application/vnd.sun.xml.writer.template', 'vsd' => 'application/vnd.visio', 'wbxml' => 'application/vnd.wap.wbxml', 'wmlc' => 'application/vnd.wap.wmlc', 'wmlsc' => 'application/vnd.wap.wmlscriptc', 'bcpio' => 'application/x-bcpio', 'vcd' => 'application/x-cdlink', 'pgn' => 'application/x-chess-pgn', 'Z' => 'application/x-compress', 'cpio' => 'application/x-cpio', 'csh' => 'application/x-csh', 'dcr' => 'application/x-director', 'dir' => 'application/x-director', 'dxr' => 'application/x-director', 'dvi' => 'application/x-dvi', 'spl' => 'application/x-futuresplash', 'gtar' => 'application/x-gtar', 'tgz' => 'application/x-gtar', 'gz' => 'application/x-gzip', 'hdf' => 'application/x-hdf', 'php' => 'application/x-httpd-php', 'php3' => 'application/x-httpd-php3', 'js' => 'application/x-javascript', 'skd' => 'application/x-koan', 'skm' => 'application/x-koan', 'skp' => 'application/x-koan', 'skt' => 'application/x-koan', 'latex' => 'application/x-latex', 'wmd' => 'application/x-ms-wmd', 'wmz' => 'application/x-ms-wmz', 'cdf' => 'application/x-netcdf', 'nc' => 'application/x-netcdf', 'pl' => 'application/x-perl', 'pm' => 'application/x-perl', 'psd' => 'application/x-photoshop', 'sh' => 'application/x-sh', 'shar' => 'application/x-shar', 'swf' => 'application/x-shockwave-flash', 'sit' => 'application/x-stuffit', 'sv4cpio' => 'application/x-sv4cpio', 'sv4crc' => 'application/x-sv4crc', 'tar' => 'application/x-tar', 'tcl' => 'application/x-tcl', 'tex' => 'application/x-tex', 'texi' => 'application/x-texinfo', 'texinfo' => 'application/x-texinfo', 'roff' => 'application/x-troff', 't' => 'application/x-troff', 'tr' => 'application/x-troff', 'man' => 'application/x-troff-man', 'me' => 'application/x-troff-me', 'ms' => 'application/x-troff-ms', 'ustar' => 'application/x-ustar', 'src' => 'application/x-wais-source', 'xht' => 'application/xhtml+xml', 'xhtml' => 'application/xhtml+xml', 'xml' => 'application/xml', 'zip' => 'application/zip', 'au' => 'audio/basic', 'snd' => 'audio/basic', 'kar' => 'audio/midi', 'mid' => 'audio/midi', 'midi' => 'audio/midi', 'mp2' => 'audio/mpeg', 'mp3' => 'audio/mpeg', 'mpga' => 'audio/mpeg', 'aif' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff', 'aiff' => 'audio/x-aiff', 'm3u' => 'audio/x-mpegurl', 'wax' => 'audio/x-ms-wax', 'wma' => 'audio/x-ms-wma', 'ram' => 'audio/x-pn-realaudio', 'rm' => 'audio/x-pn-realaudio', 'rpm' => 'audio/x-pn-realaudio-plugin', 'ra' => 'audio/x-realaudio', 'wav' => 'audio/x-wav', 'pdb' => 'chemical/x-pdb', 'xyz' => 'chemical/x-xyz', 'bmp' => 'image/bmp', 'gif' => 'image/gif', 'ief' => 'image/ief', 'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'png' => 'image/png', 'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'wbmp' => 'image/vnd.wap.wbmp', 'ras' => 'image/x-cmu-raster', 'pnm' => 'image/x-portable-anymap', 'pbm' => 'image/x-portable-bitmap', 'pgm' => 'image/x-portable-graymap', 'ppm' => 'image/x-portable-pixmap', 'rgb' => 'image/x-rgb', 'xbm' => 'image/x-xbitmap', 'xpm' => 'image/x-xpixmap', 'xwd' => 'image/x-xwindowdump', 'iges' => 'model/iges', 'igs' => 'model/iges', 'mesh' => 'model/mesh', 'msh' => 'model/mesh', 'silo' => 'model/mesh', 'vrml' => 'model/vrml', 'wrl' => 'model/vrml', 'ics' => 'text/calendar', 'ifb' => 'text/calendar', 'vcs' => 'text/calendar', 'vfb' => 'text/calendar', 'css' => 'text/css', 'csv' => 'text/csv', 'diff' => 'text/diff', 'patch' => 'text/diff', 'htm' => 'text/html', 'html' => 'text/html', 'shtml' => 'text/html', 'asc' => 'text/plain', 'log' => 'text/plain', 'po' => 'text/plain', 'txt' => 'text/plain', 'rtx' => 'text/richtext', 'rtf' => 'text/rtf', 'sgm' => 'text/sgml', 'sgml' => 'text/sgml', 'tsv' => 'text/tab-separated-values', 'wml' => 'text/vnd.wap.wml', 'wmls' => 'text/vnd.wap.wmlscript', 'etx' => 'text/x-setext', 'vcf' => 'text/x-vcard', 'xsl' => 'text/xml', 'mp4' => 'video/mp4', 'mpe' => 'video/mpeg', 'mpeg' => 'video/mpeg', 'mpg' => 'video/mpeg', 'mov' => 'video/quicktime', 'qt' => 'video/quicktime', 'mxu' => 'video/vnd.mpegurl', 'asf' => 'video/x-ms-asf', 'asx' => 'video/x-ms-asf', 'wm' => 'video/x-ms-wm', 'wmv' => 'video/x-ms-wmv', 'wmx' => 'video/x-ms-wmx', 'wvx' => 'video/x-ms-wvx', 'avi' => 'video/x-msvideo', 'movie' => 'video/x-sgi-movie', 'ice' => 'x-conference/x-cooltalk', );
     68    public $mime_extension_map = array( 'ez' => 'application/andrew-inset', 'hqx' => 'application/mac-binhex40', 'cpt' => 'application/mac-compactpro', 'doc' => 'application/msword', 'bin' => 'application/octet-stream', 'class' => 'application/octet-stream', 'dll' => 'application/octet-stream', 'dms' => 'application/octet-stream', 'exe' => 'application/octet-stream', 'lha' => 'application/octet-stream', 'lzh' => 'application/octet-stream', 'so' => 'application/octet-stream', 'oda' => 'application/oda', 'pdf' => 'application/pdf', 'ai' => 'application/postscript', 'eps' => 'application/postscript', 'ps' => 'application/postscript', 'smi' => 'application/smil', 'smil' => 'application/smil', 'mif' => 'application/vnd.mif', 'xls' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', 'sxc' => 'application/vnd.sun.xml.calc', 'stc' => 'application/vnd.sun.xml.calc.template', 'sxd' => 'application/vnd.sun.xml.draw', 'std' => 'application/vnd.sun.xml.draw.template', 'sxi' => 'application/vnd.sun.xml.impress', 'sti' => 'application/vnd.sun.xml.impress.template', 'sxm' => 'application/vnd.sun.xml.math', 'sxw' => 'application/vnd.sun.xml.writer', 'sxg' => 'application/vnd.sun.xml.writer.global', 'stw' => 'application/vnd.sun.xml.writer.template', 'vsd' => 'application/vnd.visio', 'wbxml' => 'application/vnd.wap.wbxml', 'wmlc' => 'application/vnd.wap.wmlc', 'wmlsc' => 'application/vnd.wap.wmlscriptc', 'bcpio' => 'application/x-bcpio', 'vcd' => 'application/x-cdlink', 'pgn' => 'application/x-chess-pgn', 'Z' => 'application/x-compress', 'cpio' => 'application/x-cpio', 'csh' => 'application/x-csh', 'dcr' => 'application/x-director', 'dir' => 'application/x-director', 'dxr' => 'application/x-director', 'dvi' => 'application/x-dvi', 'spl' => 'application/x-futuresplash', 'gtar' => 'application/x-gtar', 'tgz' => 'application/x-gtar', 'gz' => 'application/x-gzip', 'hdf' => 'application/x-hdf', 'php' => 'application/x-httpd-php', 'php3' => 'application/x-httpd-php3', 'js' => 'application/x-javascript', 'skd' => 'application/x-koan', 'skm' => 'application/x-koan', 'skp' => 'application/x-koan', 'skt' => 'application/x-koan', 'latex' => 'application/x-latex', 'wmd' => 'application/x-ms-wmd', 'wmz' => 'application/x-ms-wmz', 'cdf' => 'application/x-netcdf', 'nc' => 'application/x-netcdf', 'pl' => 'application/x-perl', 'pm' => 'application/x-perl', 'psd' => 'application/x-photoshop', 'sh' => 'application/x-sh', 'shar' => 'application/x-shar', 'swf' => 'application/x-shockwave-flash', 'sit' => 'application/x-stuffit', 'sv4cpio' => 'application/x-sv4cpio', 'sv4crc' => 'application/x-sv4crc', 'tar' => 'application/x-tar', 'tcl' => 'application/x-tcl', 'tex' => 'application/x-tex', 'texi' => 'application/x-texinfo', 'texinfo' => 'application/x-texinfo', 'roff' => 'application/x-troff', 't' => 'application/x-troff', 'tr' => 'application/x-troff', 'man' => 'application/x-troff-man', 'me' => 'application/x-troff-me', 'ms' => 'application/x-troff-ms', 'ustar' => 'application/x-ustar', 'src' => 'application/x-wais-source', 'xht' => 'application/xhtml+xml', 'xhtml' => 'application/xhtml+xml', 'xml' => 'application/xml', 'zip' => 'application/zip', 'au' => 'audio/basic', 'snd' => 'audio/basic', 'kar' => 'audio/midi', 'mid' => 'audio/midi', 'midi' => 'audio/midi', 'mp2' => 'audio/mpeg', 'mp3' => 'audio/mpeg', 'mpga' => 'audio/mpeg', 'aif' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff', 'aiff' => 'audio/x-aiff', 'm3u' => 'audio/x-mpegurl', 'wax' => 'audio/x-ms-wax', 'wma' => 'audio/x-ms-wma', 'ram' => 'audio/x-pn-realaudio', 'rm' => 'audio/x-pn-realaudio', 'rpm' => 'audio/x-pn-realaudio-plugin', 'ra' => 'audio/x-realaudio', 'wav' => 'audio/x-wav', 'pdb' => 'chemical/x-pdb', 'xyz' => 'chemical/x-xyz', 'bmp' => 'image/bmp', 'gif' => 'image/gif', 'ief' => 'image/ief', 'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'png' => 'image/png', 'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'wbmp' => 'image/vnd.wap.wbmp', 'ras' => 'image/x-cmu-raster', 'pnm' => 'image/x-portable-anymap', 'pbm' => 'image/x-portable-bitmap', 'pgm' => 'image/x-portable-graymap', 'ppm' => 'image/x-portable-pixmap', 'rgb' => 'image/x-rgb', 'xbm' => 'image/x-xbitmap', 'xpm' => 'image/x-xpixmap', 'xwd' => 'image/x-xwindowdump', 'iges' => 'model/iges', 'igs' => 'model/iges', 'mesh' => 'model/mesh', 'msh' => 'model/mesh', 'silo' => 'model/mesh', 'vrml' => 'model/vrml', 'wrl' => 'model/vrml', 'ics' => 'text/calendar', 'ifb' => 'text/calendar', 'vcs' => 'text/calendar', 'vfb' => 'text/calendar', 'css' => 'text/css', 'csv' => 'text/csv', 'diff' => 'text/diff', 'patch' => 'text/diff', 'htm' => 'text/html', 'html' => 'text/html', 'shtml' => 'text/html', 'asc' => 'text/plain', 'log' => 'text/plain', 'po' => 'text/plain', 'txt' => 'text/plain', 'rtx' => 'text/richtext', 'rtf' => 'text/rtf', 'sgm' => 'text/sgml', 'sgml' => 'text/sgml', 'tsv' => 'text/tab-separated-values', 'wml' => 'text/vnd.wap.wml', 'wmls' => 'text/vnd.wap.wmlscript', 'etx' => 'text/x-setext', 'vcf' => 'text/x-vcard', 'xsl' => 'text/xml', 'mp4' => 'video/mp4', 'mpe' => 'video/mpeg', 'mpeg' => 'video/mpeg', 'mpg' => 'video/mpeg', 'mov' => 'video/quicktime', 'qt' => 'video/quicktime', 'mxu' => 'video/vnd.mpegurl', 'asf' => 'video/x-ms-asf', 'asx' => 'video/x-ms-asf', 'wm' => 'video/x-ms-wm', 'wmv' => 'video/x-ms-wmv', 'wmx' => 'video/x-ms-wmx', 'wvx' => 'video/x-ms-wvx', 'avi' => 'video/x-msvideo', 'movie' => 'video/x-sgi-movie', 'ice' => 'x-conference/x-cooltalk', );
    6969
    7070    /**
     
    7474     * @param  array    $params     Array of parameters (key => val pairs).
    7575     */
    76     function setParam($params)
     76    public function setParam($params)
    7777    {
    7878        $app =& App::getInstance();
     
    118118     * @return mixed               Configured parameter value.
    119119     */
    120     function getParam($param)
    121     {
    122         $app =& App::getInstance();
    123    
     120    public function getParam($param)
     121    {
     122        $app =& App::getInstance();
     123
    124124        if (isset($this->_params[$param])) {
    125125            return $this->_params[$param];
     
    144144     *                        In this case it is necessary to check the Upload::anyErrors method to discover if any did fail.
    145145     */
    146     function process($form_name, $custom_file_name=null)
     146    public function process($form_name, $custom_file_name=null)
    147147    {
    148148        $app =& App::getInstance();
     
    278278
    279279            // Check to be sure the file has a valid file name extension.
    280             if (!in_array(mb_strtolower($this->getFilenameExtension($file_name)), $this->getParam('valid_file_extensions'))) {
    281                 /// TODO: Add option to allow any extention to be uploaded.
     280            if (!in_array(mb_strtolower(self::getFilenameExtension($file_name)), $this->getParam('valid_file_extensions'))) {
     281                // TODO: Add option to allow any extention to be uploaded.
    282282                $this->_raiseMsg(sprintf(_("The file %s failed uploading: it is an unrecognized type. Files must have one of the following file name extensions: %s."), $file_name, join(', ', $this->getParam('valid_file_extensions'))), MSG_ERR, __FILE__, __LINE__);
    283283                $app->logMsg(sprintf('The uploaded file %s has an unrecognized file name extension.', $file_name), LOG_WARNING, __FILE__, __LINE__);
     
    306306
    307307            // FINAL path and file name, lowercase extension.
    308             $file_extension = mb_strtolower($this->getFilenameExtension($file_name));
     308            $file_extension = mb_strtolower(self::getFilenameExtension($file_name));
    309309            $file_name = sprintf('%s.%s', mb_substr($file_name, 0, mb_strrpos($file_name, '.')), $file_extension);
    310310            $file_path_name = sprintf('%s/%s', $this->getParam('upload_path'), $file_name);
     
    351351     * @return  bool                Success of operation.
    352352     */
    353     function deleteFile($file_name, $use_glob=false)
     353    public function deleteFile($file_name, $use_glob=false)
    354354    {
    355355        $app =& App::getInstance();
     
    384384     * @return  bool                Success of operation.
    385385     */
    386     function moveFile($old_name, $new_name)
     386    public function moveFile($old_name, $new_name)
    387387    {
    388388        $app =& App::getInstance();
     
    419419     * @return  bool                Existence of file.
    420420     */
    421     function exists($file_name)
     421    public function exists($file_name)
    422422    {
    423423        $app =& App::getInstance();
     
    442442     * @since   15 Nov 2005 20:55:22
    443443     */
    444     function getFilenameGlob($pattern)
     444    public function getFilenameGlob($pattern)
    445445    {
    446446        $file_list = glob(sprintf('%s/%s', $this->getParam('upload_path'), $pattern));
     
    458458     * @return  array   List of file names.
    459459     */
    460     function getErrors()
     460    public function getErrors()
    461461    {
    462462        return $this->errors;
     
    468468     * @access  public
    469469     */
    470     function anyErrors()
     470    public function anyErrors()
    471471    {
    472472        return sizeof($this->errors) > 0;
     
    480480     * @return  string              The same name, but cleaned.
    481481     */
    482     function cleanFileName($file_name)
    483     {
    484         $bad  = 'áéíóúàÚìòùÀëïöÌÁÉÍÓÚÀÈÌÒÙÄËÏÖÜâêîÎûÂÊÎÔÛñçÇ@';
    485         $good = 'aeiouaeiouaeiouAEIOUAEIOUAEIOUaeiouAEIOUncCa';
     482    public function cleanFileName($file_name)
     483    {
     484        $bad  = 'áéíóúàÚìòùÀëïöÌÁÉÍÓÚÀÈÌÒÙÄËÏÖÜâêîÎûÂÊÎÔÛñçÇ';
     485        $good = 'aeiouaeiouaeiouAEIOUAEIOUAEIOUaeiouAEIOUncC';
    486486        $file_name = trim($file_name);
    487487        $file_name = strtr($file_name, $bad, $good);
    488         $file_name = preg_replace('/[^-\w.,~_=+()]+/i', '_', $file_name);
     488        $file_name = preg_replace('/[^-\w.,~_=+()@]+/i', '_', $file_name);
    489489        $file_name = mb_substr($file_name, 0, 250);
    490490        return $file_name;
     
    499499     * @return  string              The value found after the dot
    500500     */
    501     function getFilenameExtension($file_name)
     501    static public function getFilenameExtension($file_name)
    502502    {
    503503        preg_match('/.*?\.(\w+)$/i', trim($file_name), $ext);
     
    516516     * @param string $line    __LINE__.
    517517     */
    518     function _raiseMsg($message, $type, $file, $line)
     518    public function _raiseMsg($message, $type, $file, $line)
    519519    {
    520520        $app =& App::getInstance();
     
    526526}
    527527
    528 ?>
  • trunk/lib/Utilities.inc.php

    r465 r468  
    950950
    951951    $add_members = '/usr/lib/mailman/bin/add_members';
    952     /// FIXME: checking of executable is disabled.
     952    // FIXME: checking of executable is disabled.
    953953    if (true || is_executable($add_members) && is_readable($add_members)) {
    954954        $welcome_msg = $send_welcome_message ? 'y' : 'n';
     
    982982
    983983    $remove_members = '/usr/lib/mailman/bin/remove_members';
    984     /// FIXME: checking of executable is disabled.
     984    // FIXME: checking of executable is disabled.
    985985    if (true || is_executable($remove_members) && is_readable($remove_members)) {
    986986        $userack = $send_user_ack ? '' : '--nouserack';
     
    11201120    }
    11211121}
    1122 
    1123 ?>
  • trunk/lib/Validator.inc.php

    r459 r468  
    3131 */
    3232
    33 // Known credit card types.
    34 define('CC_TYPE_VISA', 1);
    35 define('CC_TYPE_MASTERCARD', 2);
    36 define('CC_TYPE_AMEX', 3);
    37 define('CC_TYPE_DISCOVER', 4);
    38 define('CC_TYPE_DINERS', 5);
    39 define('CC_TYPE_JCB', 6);
    40 
    41 // validateEmail return types.
    42 define('VALIDATE_EMAIL_SUCCESS', 0);
    43 define('VALIDATE_EMAIL_REGEX_FAIL', 1);
    44 define('VALIDATE_EMAIL_LENGTH_FAIL', 2);
    45 define('VALIDATE_EMAIL_MX_FAIL', 3);
    46 
    4733class Validator {
    4834
     35    // Known credit card types.
     36    const CC_TYPE_VISA = 1;
     37    const CC_TYPE_MASTERCARD = 2;
     38    const CC_TYPE_AMEX = 3;
     39    const CC_TYPE_DISCOVER = 4;
     40    const CC_TYPE_DINERS = 5;
     41    const CC_TYPE_JCB = 6;
     42
     43    // Validator::validateEmail() return types.
     44    const EMAIL_SUCCESS = 0;
     45    const EMAIL_REGEX_FAIL = 1;
     46    const EMAIL_LENGTH_FAIL = 2;
     47    const EMAIL_MX_FAIL = 3;
     48
     49    // Validator::validatePhone() return types.
     50    const PHONE_SUCCESS = 0;
     51    const PHONE_REGEX_FAIL = 1;
     52    const PHONE_LENGTH_FAIL = 2;
     53
    4954    /**
    5055     * Ensures a value is empty.
     
    5358     * @return bool   true if form is not empty, false otherwise.
    5459     */
    55     function notEmpty($val)
     60    static public function notEmpty($val)
    5661    {
    5762        return '' != trim((string)$val);
     
    6469     * @return bool   true if form is empty, false otherwise.
    6570     */
    66     function isEmpty($val)
     71    static public function isEmpty($val)
    6772    {
    6873        return '' == trim((string)$val);
     
    7580     * @return bool   true if form is a string, false otherwise.
    7681     */
    77     function isString($val)
     82    static public function isString($val)
    7883    {
    7984        return '' == trim((string)$val) || is_string($val);
     
    8691     * @return bool   True if no errors found, false otherwise.
    8792     */
    88     function isNumber($val)
     93    static public function isNumber($val)
    8994    {
    9095        return '' == trim((string)$val) || is_numeric($val);
     
    98103     * @return bool   true if value is an integer
    99104     */
    100     function isInteger($val, $negative_ok=false)
     105    static public function isInteger($val, $negative_ok=false)
    101106    {
    102107        $pattern = $negative_ok ? '/^-?[[:digit:]]+$/' : '/^[[:digit:]]+$/';
     
    112117     * @return bool   true if value is a float
    113118     */
    114     function isFloat($val, $negative_ok=false)
     119    static public function isFloat($val, $negative_ok=false)
    115120    {
    116121        $pattern = $negative_ok ? '/^-?[[:digit:]]*(?:\.?[[:digit:]]+)$/' : '/^[[:digit:]]*(?:\.?[[:digit:]]+)$/';
     
    124129     * @return bool   true if value is a float
    125130     */
    126     function isArray($val)
     131    static public function isArray($val)
    127132    {
    128133        return (is_string($val) && '' == trim((string)$val)) || is_array($val);
     
    138143     * @return bool   true if value passes regex test
    139144     */
    140     function checkRegex($val, $regex, $valid_on_match=true)
     145    static public function checkRegex($val, $regex, $valid_on_match=true)
    141146    {
    142147        return $valid_on_match ? preg_match($regex, $val) : !preg_match($regex, $val);
     
    151156     * @return bool   true if string length is within given boundaries
    152157     */
    153     function stringLength($val, $min, $max)
     158    static public function stringLength($val, $min, $max)
    154159    {
    155160        return mb_strlen(trim((string)$val)) >= $min && mb_strlen($val) <= $max;
     
    164169     * @return bool   True if no errors found, false otherwise.
    165170     */
    166     function numericRange($val, $min, $max)
     171    static public function numericRange($val, $min, $max)
    167172    {
    168173        return '' == trim((string)$val) || (is_numeric($val) && $val >= $min && $val <= $max);
     
    180185     * @access  public
    181186     * @param   string  $val    The input data to validate..
    182      * @return  const           One of the constant values: VALIDATE_EMAIL_SUCCESS|VALIDATE_EMAIL_REGEX_FAIL|VALIDATE_EMAIL_LENGTH_FAIL|VALIDATE_EMAIL_MX_FAIL
     187     * @param   bool    $strict Do we run strict tests?
     188     * @return  const           One of the constant values: Validate::EMAIL_SUCCESS|Validate::EMAIL_REGEX_FAIL|Validate::EMAIL_LENGTH_FAIL|Validate::EMAIL_MX_FAIL
    183189     * @author  Quinn Comendant <quinn@strangecode.com>
    184190     */
    185     function validateEmail($val)
     191    static public function validateEmail($val, $strict=false)
    186192    {
    187193        require_once 'codebase/lib/Email.inc.php';
     
    190196        // Test email address format.
    191197        if (!preg_match($e->getParam('regex'), $val, $e_parts)) {
    192             return VALIDATE_EMAIL_REGEX_FAIL;
     198            return self::EMAIL_REGEX_FAIL;
    193199        }
    194200
     
    203209        // Test length.
    204210        if (mb_strlen($local) > 64 || mb_strlen($domain) > 191) {
    205             return VALIDATE_EMAIL_LENGTH_FAIL;
    206         }
    207 
    208         // Check domain exists: It's a domain if ip2long fails; Checkdnsrr ensures a MX record exists; Gethostbyname() ensures the domain exists.
    209         // Compare ip2long twice for php4 backwards compat.
    210         if ((ip2long($domain) == '-1' || ip2long($domain) === false) && function_exists('checkdnsrr') && !checkdnsrr($domain . '.', 'MX') && gethostbyname($domain) == $domain) {
    211             // FIXME: Do we care?
    212             // return VALIDATE_EMAIL_MX_FAIL;
    213         }
    214 
    215         return VALIDATE_EMAIL_SUCCESS;
     211            return self::EMAIL_LENGTH_FAIL;
     212        }
     213
     214        // Strict tests below.
     215
     216        // Check domain exists: It's a domain if ip2long fails; checkdnsrr ensures a MX record exists; gethostbyname() ensures the domain exists.
     217        if ($strict && ip2long($domain) === false && function_exists('checkdnsrr') && !checkdnsrr($domain . '.', 'MX') && gethostbyname($domain) == $domain) {
     218            return self::EMAIL_MX_FAIL;
     219        }
     220
     221        return self::EMAIL_SUCCESS;
     222    }
     223
     224    /**
     225     * Check whether input is a valid phone number. Notice: it is now set
     226     * to allow characters like - or () or + so people can type in a phone
     227     * number that looks like: +1 (530) 555-1212
     228     *
     229     * @param  string  $form_name the name of the incoming form variable
     230     *
     231     * @return bool    true if no errors found, false otherwise
     232     */
     233    static public function validatePhone($val)
     234    {
     235        if (!self::checkRegex($val, '/^[0-9 +().-]*$/', true)) {
     236            return self::PHONE_REGEX_FAIL;
     237        }
     238        if (!self::stringLength($val, 0, 25)) {
     239            return self::PHONE_LENGTH_FAIL;
     240        }
     241        return self::PHONE_SUCCESS;
    216242    }
    217243
     
    223249     * @return bool    True if no errors found, false otherwise.
    224250     */
    225     function validateStrDate($val)
    226     {
    227         $app =& App::getInstance();
    228 
     251    static public function validateStrDate($val)
     252    {
    229253        if (is_string($val) && '' === trim($val)) {
    230254            // Don't be too bothered about empty strings.
     
    249273     * @return bool    True if no errors found, false otherwise.
    250274     */
    251     function validateCCNumber($val, $cc_type=null)
    252      {
    253          // Get rid of any non-digits
    254          $cc_num = preg_replace('/[^\d]/', '', $val);
    255 
    256          // Perform card-specific checks, if applicable
    257          switch ($cc_type) {
    258              case CC_TYPE_VISA :
    259                  $regex = '/^4\d{15}$|^4\d{12}$/';
    260                  break;
    261              case CC_TYPE_MASTERCARD :
    262                  $regex = '/^5[1-5]\d{14}$/';
    263                  break;
    264              case CC_TYPE_AMEX :
    265                  $regex = '/^3[47]\d{13}$/';
    266                  break;
    267              case CC_TYPE_DISCOVER :
    268                  $regex = '/^6011\d{12}$/';
    269                  break;
    270              case CC_TYPE_DINERS :
    271                  $regex = '/^30[0-5]\d{11}$|^3[68]\d{12}$/';
    272                  break;
    273              case CC_TYPE_JCB :
    274                  $regex = '/^3\d{15}$|^2131|1800\d{11}$/';
    275                  break;
    276              default :
    277                  $regex = '';
    278                  break;
    279          }
    280 
    281          if ('' != $regex && !preg_match($regex, $cc_num)) {
    282              // Invalid format.
    283              return false;
    284          }
    285 
    286          // The Luhn formula works right to left, so reverse the number.
    287          $cc_num = strrev($cc_num);
    288 
    289          $luhn_total = 0;
    290 
    291          $num = mb_strlen($cc_num);
    292          for ($i=0; $i<$num; $i++) {
    293              // Get each digit.
    294              $digit = mb_substr($cc_num, $i, 1);
    295 
    296              //  If it's an odd digit, double it.
    297              if ($i / 2 != floor($i / 2)) {
    298                  $digit *= 2;
    299              }
    300 
    301              //  If the result is two digits, add them.
    302              if (mb_strlen($digit) == 2) {
    303                  $digit = mb_substr($digit, 0, 1) + mb_substr($digit, 1, 1);
    304              }
    305 
    306              //  Add the current digit to the $luhn_total.
    307              $luhn_total += $digit;
    308          }
    309 
    310          // If the Total is evenly divisible by 10, it's cool!
    311          return $luhn_total % 10 == 0;
    312      }
     275    static public function validateCCNumber($val, $cc_type=null)
     276    {
     277        // Get rid of any non-digits
     278        $cc_num = preg_replace('/[^\d]/', '', $val);
     279
     280        // Perform card-specific checks, if applicable
     281        switch ($cc_type) {
     282        case self::CC_TYPE_VISA :
     283            $regex = '/^4\d{15}$|^4\d{12}$/';
     284            break;
     285        case self::CC_TYPE_MASTERCARD :
     286            $regex = '/^5[1-5]\d{14}$/';
     287            break;
     288        case self::CC_TYPE_AMEX :
     289            $regex = '/^3[47]\d{13}$/';
     290            break;
     291        case self::CC_TYPE_DISCOVER :
     292            $regex = '/^6011\d{12}$/';
     293            break;
     294        case self::CC_TYPE_DINERS :
     295            $regex = '/^30[0-5]\d{11}$|^3[68]\d{12}$/';
     296            break;
     297        case self::CC_TYPE_JCB :
     298            $regex = '/^3\d{15}$|^2131|1800\d{11}$/';
     299            break;
     300        default :
     301            $regex = '';
     302            break;
     303        }
     304
     305        if ('' != $regex && !preg_match($regex, $cc_num)) {
     306            // Invalid format.
     307            return false;
     308        }
     309
     310        // The Luhn formula works right to left, so reverse the number.
     311        $cc_num = strrev($cc_num);
     312
     313        $luhn_total = 0;
     314
     315        $num = mb_strlen($cc_num);
     316        for ($i=0; $i<$num; $i++) {
     317            // Get each digit.
     318            $digit = mb_substr($cc_num, $i, 1);
     319
     320            //  If it's an odd digit, double it.
     321            if ($i / 2 != floor($i / 2)) {
     322                $digit *= 2;
     323            }
     324
     325            //  If the result is two digits, add them.
     326            if (mb_strlen($digit) == 2) {
     327                $digit = mb_substr($digit, 0, 1) + mb_substr($digit, 1, 1);
     328            }
     329
     330            //  Add the current digit to the $luhn_total.
     331            $luhn_total += $digit;
     332        }
     333
     334        // If the Total is evenly divisible by 10, it's cool!
     335        return $luhn_total % 10 == 0;
     336    }
    313337
    314338    /**
     
    318342     * @return bool   True if no errors found, false otherwise.
    319343     */
    320     function fileUploaded($form_name)
     344    static public function fileUploaded($form_name)
    321345    {
    322346        if (!isset($_FILES[$form_name]['name']) || empty($_FILES[$form_name]['name'])) {
     
    341365} // THE END
    342366
    343 ?>
  • trunk/lib/Version.inc.php

    r396 r468  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    3939class Version {
    4040
     41    // A place to keep an object instance for the singleton pattern.
     42    private static $instance = null;
     43
    4144    // Configuration of this object.
    42     var $_params = array(
     45    private $_params = array(
    4346        'max_qty' => 100, // Never have more than this many versions of each record.
    4447        'min_qty' => 25, // Keep at least this many versions of each record.
    4548        'min_days' => 7, // Keep ALL versions within this many days, even if MORE than min_qty.
    4649        'db_table' => 'version_tbl',
    47        
     50
    4851        // Automatically create table and verify columns. Better set to false after site launch.
    4952        // This value is overwritten by the $app->getParam('db_create_tables') setting if it is available.
     
    5457
    5558    // Auth_SQL object from which to access a current user_id.
    56     var $_auth;
     59    private $_auth;
    5760
    5861    /**
     
    6366     * @static
    6467     */
    65     static function &getInstance($auth_object)
    66     {
    67         static $instance = null;
    68 
    69         if ($instance === null) {
    70             $instance = new Version($auth_object);
    71         }
    72 
    73         return $instance;
     68    public static function &getInstance($auth_object)
     69    {
     70        if (self::$instance === null) {
     71            self::$instance = new self($auth_object);
     72        }
     73
     74        return self::$instance;
    7475    }
    7576
     
    7980     * @param mixed  $auth_object  An Auth_SQL object.
    8081     */
    81     function Version($auth_object)
     82    public function __construct($auth_object)
    8283    {
    8384        $app =& App::getInstance();
     
    102103     * @since   26 Aug 2005 17:09:36
    103104     */
    104     function initDB($recreate_db=false)
     105    public function initDB($recreate_db=false)
    105106    {
    106107        $app =& App::getInstance();
     
    155156     * @param  array $params   Array of param keys and values to set.
    156157     */
    157     function setParam($params=null)
     158    public function setParam($params=null)
    158159    {
    159160        if (isset($params) && is_array($params)) {
     
    170171     * @return mixed               Configured parameter value.
    171172     */
    172     function getParam($param)
     173    public function getParam($param)
    173174    {
    174175        $app =& App::getInstance();
    175    
     176
    176177        if (isset($this->_params[$param])) {
    177178            return $this->_params[$param];
     
    192193     * @return int                  The id for the version (mysql last insert id).
    193194     */
    194     function create($record_table, $record_key, $record_val, $title='', $notes='')
     195    public function create($record_table, $record_key, $record_val, $title='', $notes='')
    195196    {
    196197        $app =& App::getInstance();
     
    204205            return false;
    205206        }
    206        
     207
    207208        // Get previous version_number.
    208209        $qid = $db->query("
     
    253254     * @return int                  The id for the version (mysql last insert id).
    254255     */
    255     function restore($version_id)
     256    public function restore($version_id)
    256257    {
    257258        $app =& App::getInstance();
     
    314315     * @return mixed                Array of versions, or false if none.
    315316     */
    316     function deleteOld($record_table, $record_key, $record_val)
    317     {
    318         $db =& DB::getInstance();
    319    
     317    public function deleteOld($record_table, $record_key, $record_val)
     318    {
     319        $db =& DB::getInstance();
     320
    320321        $this->initDB();
    321322
     
    381382     * @return mixed                Array of versions, or false if none.
    382383     */
    383     function getList($record_table, $record_key, $record_val)
    384     {
    385         $db =& DB::getInstance();
    386    
     384    public function getList($record_table, $record_key, $record_val)
     385    {
     386        $db =& DB::getInstance();
     387
    387388        $this->initDB();
    388389
    389390        // Get versions of this record.
    390391        $qid = $db->query("
    391             SELECT 
     392            SELECT
    392393                version_id,
    393394                saved_by_user_id,
     
    418419     * @return mixed                Array of data saved in version, or false if none.
    419420     */
    420     function getVerson($version_id)
    421     {
    422         $db =& DB::getInstance();
    423    
     421    public function getVerson($version_id)
     422    {
     423        $db =& DB::getInstance();
     424
    424425        $this->initDB();
    425426
     
    439440     * @return mixed                Array of data saved in version, or false if none.
    440441     */
    441     function getData($version_id)
    442     {
    443         $db =& DB::getInstance();
    444    
     442    public function getData($version_id)
     443    {
     444        $db =& DB::getInstance();
     445
    445446        $this->initDB();
    446447
     
    465466     * @return mixed                Array of data saved in version, or false if none.
    466467     */
    467     function getCurrent($record_table, $record_key, $record_val)
    468     {
    469         $db =& DB::getInstance();
    470    
     468    public function getCurrent($record_table, $record_key, $record_val)
     469    {
     470        $db =& DB::getInstance();
     471
    471472        $this->initDB();
    472473
     
    484485
    485486} // End of class.
    486 ?>
  • trunk/services/admins.php

    r458 r468  
    5555
    5656// Configure the cache object.
    57 $cache = new Cache('admins');
     57$cache =& Cache::getInstance('admins');
    5858$cache->setParam(array('enabled' => false)); // Better leave disabled; the list gets out of sync with the db otherwise, somehow.
    5959
     
    552552}
    553553
    554 ?>
  • trunk/services/css.php

    r396 r468  
    3636}
    3737
    38 ?>
  • trunk/services/lock.php

    r457 r468  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    6969include 'footer.ihtml';
    7070
    71 ?>
  • trunk/services/login.php

    r462 r468  
    3636$login_prefs->setDefaults(array('username' => ''));
    3737
    38 if ('' != $login_prefs->get('username')) {
    39     $frm['remember_me'] = '1';
    40 }
    41 
    4238$frm['username'] = getFormdata('username', $login_prefs->get('username'));
    4339$frm['password'] = getFormdata('password');
     40$frm['remember_me'] = ('' != $login_prefs->get('username')) ? '1' : '';
    4441
    4542if (getFormdata('username', false)) {
     
    6966include 'footer.ihtml';
    7067
    71 ?>
  • trunk/services/logout.php

    r396 r468  
    3838$app->dieURL($app->getParam('redirect_home_url'));
    3939
    40 ?>
  • trunk/services/logs.php

    r457 r468  
    293293
    294294
    295 ?>
  • trunk/services/password.php

    r396 r468  
    8787include 'footer.ihtml';
    8888
    89 ?>
  • trunk/services/phpinfo.php

    r396 r468  
    3838?><h1>$_SERVER dump</h1><?php
    3939dump($_SERVER,1);
    40 ?>
  • trunk/services/reset_password.php

    r396 r468  
    8787include 'footer.ihtml';
    8888
    89 ?>
  • trunk/services/versions.php

    r457 r468  
    136136include 'footer.ihtml';
    137137
    138 ?>
  • trunk/tests/AppTest.php

    r396 r468  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    3030 * Created with PHPUnit_Skeleton on 2005-08-09
    3131 */
    32 require_once 'PHPUnit.php';
    33 class AppTest extends PHPUnit_TestCase {
     32
     33class AppTest extends PHPUnit_Framework_TestCase {
    3434
    3535    var $App;
    3636
    37     function AppTest($name)
    38     {
    39         $this->PHPUnit_TestCase($name);
    40     }
     37    static $shared_session;
    4138
    4239    function setUp()
     
    4441        require dirname(__FILE__) . '/_config.inc.php';
    4542        $this->App =& $app;
     43        $_SESSION = AppTest::$shared_session;
    4644    }
    4745
     
    4947    {
    5048        unset($this->App);
     49        AppTest::$shared_session = $_SESSION;
    5150    }
    5251
     
    6261            'test_config_value' => 1234
    6362        ));
    64         $this->assertTrue(1234 === $this->App->_params['test_config_value']);
     63        $this->assertTrue(1234 === $this->App->getParam('test_config_value'));
    6564    }
    6665
    6766    function test_getParam()
    6867    {
    69         $this->App->_params['test_config_value2'] = 'okay';
     68        //$this->App->setParam('test_config_value2', 'okay');
     69        $this->App->setParam(array(
     70            'test_config_value2' => 'okay'
     71        ));
    7072        $result = $this->App->getParam('test_config_value2');
    7173        $this->assertEquals('okay', $result);
     
    9395    {
    9496        $db =& DB::getInstance();
    95    
     97
    9698        $qid = $db->query("SELECT 2 + 2");
    9799        list($result) = mysql_fetch_row($qid);
     
    104106        $expected = 'My message';
    105107        $app->raiseMsg($expected, MSG_NOTICE, __FILE__, __LINE__);
    106         $msg = current($_SESSION['_app'][$this->App->_ns]['messages']);
     108        $msg = current($_SESSION['_app']['testapp']['messages']);
    107109        $this->assertEquals($expected, $msg['message']);
    108110    }
     
    111113    {
    112114        ob_start();
     115        $this->test_raisemsg();  //had to add this line for phpunit ver. 3.7 ///
    113116        $app =& App::getInstance();
    114117        $app->printraisedmessages();
     
    205208}
    206209// Running the test.
     210/*
    207211$suite = new PHPUnit_TestSuite('AppTest');
    208212$result = PHPUnit::run($suite);
    209213echo $result->toString();
    210 ?>
     214 */
  • trunk/tests/Auth_FileTest.php

    r396 r468  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    120120$result = PHPUnit::run($suite);
    121121echo $result->toString();
    122 ?>
  • trunk/tests/Auth_SQLTest.php

    r457 r468  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    3030 * Created with PHPUnit_Skeleton on 2005-08-09
    3131 */
    32 require_once 'PHPUnit.php';
     32
    3333class Auth_SQLTest extends PHPUnit_TestCase {
    3434
     
    5151            'login_url'         => '/login.php',
    5252            'blocking'          => true,
    53             'encryption_type' => AUTH_ENCRYPT_MD5_HARDENED,
     53            'encryption_type' => Auth_SQL::ENCRYPT_MD5_HARDENED,
    5454        ));
    5555
     
    8080    {
    8181        $db =& DB::getInstance();
    82    
     82
    8383        unset($this->Auth_SQL);
    8484        $db->query("DROP TABLE IF EXISTS test_user_tbl");
     
    145145        $after_logged_in = $this->Auth_SQL->isloggedin();
    146146        $this->assertFalse($after_logged_in, '3. User is still logged in but should not be.');
    147        
     147
    148148        // Testing wrong password.
    149149        $login2 = $this->Auth_SQL->login('testuser', 'wrongpass');
     
    164164    {
    165165        $db =& DB::getInstance();
    166    
     166
    167167        $this->Auth_SQL->login('testuser', 'testpass');
    168168        $this->Auth_SQL->blockaccount(null, 'blocktestuser');
     
    178178    {
    179179        $db =& DB::getInstance();
    180    
     180
    181181        $db->query("
    182182            UPDATE test_user_tbl SET blocked_reason = 'blocktestuser'
     
    212212    function test_encryptpassword()
    213213    {
    214         $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_MD5));
     214        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_MD5));
    215215        $result = $this->Auth_SQL->encryptpassword('123');
    216216        $this->assertEquals('202cb962ac59075b964b07152d234b70', $result);
    217217
    218         $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_MD5_HARDENED));
     218        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_MD5_HARDENED));
    219219        $result = $this->Auth_SQL->encryptpassword('123');
    220220        $this->assertEquals('c55e4ac608a8768ecd758fab971b0646', $result);
    221221
    222         $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_SHA1));
     222        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_SHA1));
    223223        $result = $this->Auth_SQL->encryptpassword('123');
    224224        $this->assertEquals('40bd001563085fc35165329ea1ff5c5ecbdbbeef', $result);
    225225
    226         $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_SHA1_HARDENED));
     226        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_SHA1_HARDENED));
    227227        $result = $this->Auth_SQL->encryptpassword('123');
    228228        $this->assertEquals('33d90af96a5928ac93cbd41fc436e8c55d2768c2', $result);
    229229
    230         $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_PLAINTEXT));
     230        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_PLAINTEXT));
    231231        $result = $this->Auth_SQL->encryptpassword('123');
    232232        $this->assertEquals('123', $result);
    233233
    234         $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_CRYPT));
     234        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_CRYPT));
    235235        $result = $this->Auth_SQL->encryptpassword('123', 'saltstring');
    236236        $this->assertEquals('saEZ6MlWYV9nQ', $result);
     
    240240    {
    241241        $db =& DB::getInstance();
    242    
    243         $this->Auth_SQL->setParam(array('encryption_type' => AUTH_ENCRYPT_SHA1_HARDENED));
     242
     243        $this->Auth_SQL->setParam(array('encryption_type' => Auth_SQL::ENCRYPT_SHA1_HARDENED));
    244244        $this->Auth_SQL->setpassword(null, '123');
    245245        $qid = $db->query("
     
    261261$result = PHPUnit::run($suite);
    262262echo $result->toString();
    263 ?>
  • trunk/tests/AuthorizeNetTest.php

    r396 r468  
    3030 * Created with PHPUnit_Skeleton on 2005-08-09
    3131 */
    32 require_once 'PHPUnit.php';
    33 class AuthorizeNetTest extends PHPUnit_TestCase {
     32
     33class AuthorizeNetTest extends PHPUnit_Framework_TestCase {
    3434
    3535    var $AuthorizeNet;
    36 
    37     function AuthorizeNetTest($name)
    38     {
    39         $this->PHPUnit_TestCase($name);
    40     }
    41 
     36   
     37    static $shared_session;
     38   
    4239    function setUp()
    4340    {
     
    4542        require_once '../lib/AuthorizeNet.inc.php';
    4643
    47         $this->AuthorizeNet =& new AuthorizeNet();
     44        $this->AuthorizeNet = new AuthorizeNet();
    4845        $this->AuthorizeNet->setParam(array(
    4946            'x_login' => 'myaccount',
     
    6158            'x_zip' => '75010',
    6259        ));
     60        $_SESSION = AuthorizeNetTest::$shared_session;
    6361    }
    6462
     
    6664    {
    6765        unset($this->AuthorizeNet);
     66        AuthorizeNetTest::$shared_session = $_SESSION;
    6867    }
    6968
     
    7170    {
    7271        $this->AuthorizeNet->setparam(array('x_Login' => 'myaccount2'));
    73         $this->assertEquals('myaccount2', $this->AuthorizeNet->_params['x_Login']);
     72        $this->assertEquals('myaccount2', $this->AuthorizeNet->getParam('x_Login'));
    7473    }
    7574
     
    119118
    120119}
    121 // Running the test.
    122 $suite = new PHPUnit_TestSuite('AuthorizeNetTest');
    123 $result = PHPUnit::run($suite);
    124 echo $result->toString();
    125 ?>
  • trunk/tests/CSSTest.php

    r396 r468  
    3030 * Created with PHPUnit_Skeleton on 2005-08-09
    3131 */
    32 require_once 'PHPUnit.php';
    33 class CSSTest extends PHPUnit_TestCase {
     32
     33class CSSTest extends PHPUnit_Framework_TestCase {
    3434
    3535    var $CSS;
    3636    var $test_css_file;
    37 
    38     function CSSTest($name)
    39     {
    40         $this->PHPUnit_TestCase($name);
    41     }
    4237
    4338    function setUp()
     
    4641        $this->test_css_file = dirname(__FILE__) . '/../css/codebase.inc.css';
    4742        require_once '../lib/CSS.inc.php';
    48         $this->CSS =& new CSS();
     43        $this->CSS = new CSS();
    4944        $this->CSS->setFile($this->test_css_file);
    5045    }
     
    8681
    8782}
    88 // Running the test.
    89 $suite = new PHPUnit_TestSuite('CSSTest');
    90 $result = PHPUnit::run($suite);
    91 echo $result->toString();
    92 ?>
  • trunk/tests/CacheTest.php

    r396 r468  
    77 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    88 * Copyright 2001-2012 Strangecode, LLC
    9  * 
     9 *
    1010 * This file is part of The Strangecode Codebase.
    1111 *
     
    1414 * Free Software Foundation, either version 3 of the License, or (at your option)
    1515 * any later version.
    16  * 
     16 *
    1717 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1818 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1919 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    2020 * details.
    21  * 
     21 *
    2222 * You should have received a copy of the GNU General Public License along with
    2323 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    3333 * Created with PHPUnit_Skeleton on 2005-08-09
    3434 */
    35 require_once 'PHPUnit.php';
    36 class CacheTest extends PHPUnit_TestCase {
     35
     36class CacheTest extends PHPUnit_Framework_TestCase {
    3737
    3838    var $Cache;
     
    4040    function CacheTest($name)
    4141    {
    42         $this->PHPUnit_TestCase($name);
     42        $this->PHPUnit_Framework_TestCase($name);
    4343    }
    4444
     
    105105
    106106}
    107 // Running the test.
    108 $suite = new PHPUnit_TestSuite('CacheTest');
    109 $result = PHPUnit::run($suite);
    110 echo $result->toString();
    111 ?>
  • trunk/tests/DBSessionHandlerTest.php

    r396 r468  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    3030 * Created with PHPUnit_Skeleton on 2005-08-09
    3131 */
    32 require_once 'PHPUnit.php';
    33 class DBSessionHandlerTest extends PHPUnit_TestCase {
     32
     33class DBSessionHandlerTest extends PHPUnit_Framework_TestCase {
    3434
    3535    var $DBSessionHandler;
    36 
    37     function DBSessionHandlerTest($name)
    38     {
    39         $this->PHPUnit_TestCase($name);
    40     }
    4136
    4237    function setUp()
     
    7368    function test_DBsessionwrite()
    7469    {
     70        if (!isset($_SESSION)) {
     71            $_SESSION = array();
     72        }
    7573        $this->DBSessionHandler->DBsessionwrite(session_id(), serialize($_SESSION));
    7674    }
     
    8785
    8886}
    89 // Running the test.
    90 $suite = new PHPUnit_TestSuite('DBSessionHandlerTest');
    91 $result = PHPUnit::run($suite);
    92 echo $result->toString();
    93 ?>
  • trunk/tests/EmailTest.php

    r399 r468  
    11<?php
     2
    23/**
    34 * The Strangecode Codebase - a general application development framework for PHP
     
    3031 * Created with PHPUnit_Skeleton on 2005-12-01
    3132 */
    32 require_once 'PHPUnit.php';
    33 class EmailTest extends PHPUnit_TestCase {
     33
     34class EmailTest extends PHPUnit_Framework_TestCase {
    3435
    3536    var $Email;
    36 
    37     function EmailTest($name)
    38     {
    39         $this->PHPUnit_TestCase($name);
    40     }
    4137
    4238    function setUp()
     
    4440        require dirname(__FILE__) . '/_config.inc.php';
    4541        require_once '../lib/Email.inc.php';
    46         $this->Email =& new Email();
     42        $this->Email = new Email();
    4743    }
    4844
     
    122118
    123119}
    124 // Running the test.
    125 $suite  = new PHPUnit_TestSuite('EmailTest');
    126 $result = PHPUnit::run($suite);
    127 echo $result->toString();
    128 ?>
  • trunk/tests/FormValidatorTest.php

    r396 r468  
    3030 * Created with PHPUnit_Skeleton on 2005-08-09
    3131 */
    32 require_once 'PHPUnit.php';
    33 class FormValidatorTest extends PHPUnit_TestCase {
     32
     33class FormValidatorTest extends PHPUnit_Framework_TestCase {
    3434
    3535    var $FormValidator;
    36 
    37     function FormValidatorTest($name)
    38     {
    39         $this->PHPUnit_TestCase($name);
    40     }
    4136
    4237    function setUp()
     
    4439        require dirname(__FILE__) . '/_config.inc.php';
    4540        require_once '../lib/FormValidator.inc.php';
    46         $this->FormValidator =& new FormValidator();
     41        $this->FormValidator = new FormValidator();
    4742    }
    4843
     
    294289
    295290}
    296 // Running the test.
    297 $suite = new PHPUnit_TestSuite('FormValidatorTest');
    298 $result = PHPUnit::run($suite);
    299 echo $result->toString();
    300 ?>
  • trunk/tests/Google_APITest.php

    r396 r468  
    3333 * Created with PHPUnit_Skeleton on 2005-08-09
    3434 */
    35 require_once 'PHPUnit.php';
    36 class GoogleAPITest extends PHPUnit_TestCase {
     35
     36class GoogleAPITest extends PHPUnit_Framework_TestCase {
    3737
    3838    var $GoogleAPI;
     
    4040    function GoogleAPITest($name)
    4141    {
    42         $this->PHPUnit_TestCase($name);
     42        $this->PHPUnit_Framework_TestCase($name);
    4343    }
    4444
     
    9191
    9292}
    93 // Running the test.
    94 $suite = new PHPUnit_TestSuite('GoogleAPITest');
    95 $result = PHPUnit::run($suite);
    96 echo $result->toString();
    97 ?>
  • trunk/tests/HierarchyTest.php

    r396 r468  
    3333 * Created with PHPUnit_Skeleton on 2005-08-09
    3434 */
    35 require_once 'PHPUnit.php';
    36 class HierarchyTest extends PHPUnit_TestCase {
     35
     36class HierarchyTest extends PHPUnit_Framework_TestCase {
    3737
    3838    var $Hierarchy;
     
    4040    function HierarchyTest($name)
    4141    {
    42         $this->PHPUnit_TestCase($name);
     42        $this->PHPUnit_Framework_TestCase($name);
    4343    }
    4444
     
    175175
    176176}
    177 // Running the test.
    178 $suite = new PHPUnit_TestSuite('HierarchyTest');
    179 $result = PHPUnit::run($suite);
    180 echo $result->toString();
    181 ?>
  • trunk/tests/ImageThumbTest.php

    r396 r468  
    3333 * Created with PHPUnit_Skeleton on 2005-08-09
    3434 */
    35 require_once 'PHPUnit.php';
    36 class ImageThumbTest extends PHPUnit_TestCase {
     35
     36class ImageThumbTest extends PHPUnit_Framework_TestCase {
    3737
    3838    var $ImageThumb;
     
    4040    function ImageThumbTest($name)
    4141    {
    42         $this->PHPUnit_TestCase($name);
     42        $this->PHPUnit_Framework_TestCase($name);
    4343    }
    4444
     
    119119
    120120}
    121 // Running the test.
    122 $suite = new PHPUnit_TestSuite('ImageThumbTest');
    123 $result = PHPUnit::run($suite);
    124 echo $result->toString();
    125 ?>
  • trunk/tests/LockTest.php

    r396 r468  
    3030 * Created with PHPUnit_Skeleton on 2005-08-09
    3131 */
    32 require_once 'PHPUnit.php';
    33 class LockTest extends PHPUnit_TestCase {
     32
     33class LockTest extends PHPUnit_Framework_TestCase {
    3434
    3535    var $Lock;
    3636    var $Auth_SQL;
    37 
    38     function LockTest($name)
    39     {
    40         $this->PHPUnit_TestCase($name);
    41     }
    4237
    4338    function setUp()
     
    4742        require_once '../lib/Auth_SQL.inc.php';
    4843
    49         $this->Auth_SQL =& new Auth_SQL('test');
     44        $this->Auth_SQL = new Auth_SQL('test');
    5045        $this->Auth_SQL->setParam(array(
    5146            'db_table'          => 'test_user_tbl',
     
    208203    {
    209204        $result = $this->Lock->getsecondselapsed();
    210         $this->assertType('integer', $result);
     205        $this->assertInternalType('integer', $result);
    211206    }
    212207
    213208}
    214 // Running the test.
    215 $suite = new PHPUnit_TestSuite('LockTest');
    216 $result = PHPUnit::run($suite);
    217 echo $result->toString();
    218 ?>
  • trunk/tests/MCVETest.php

    r396 r468  
    3333 * Created with PHPUnit_Skeleton on 2005-08-09
    3434 */
    35 require_once 'PHPUnit.php';
    36 class MCVETest extends PHPUnit_TestCase {
     35
     36class MCVETest extends PHPUnit_Framework_TestCase {
    3737
    3838    var $MCVE;
     
    4040    function MCVETest($name)
    4141    {
    42         $this->PHPUnit_TestCase($name);
     42        $this->PHPUnit_Framework_TestCase($name);
    4343    }
    4444
     
    9191
    9292}
    93 // Running the test.
    94 $suite = new PHPUnit_TestSuite('MCVETest');
    95 $result = PHPUnit::run($suite);
    96 echo $result->toString();
    97 ?>
  • trunk/tests/NavTest.php

    r396 r468  
    3333 * Created with PHPUnit_Skeleton on 2005-08-09
    3434 */
    35 require_once 'PHPUnit.php';
    36 class NavigationTest extends PHPUnit_TestCase {
     35
     36class NavigationTest extends PHPUnit_Framework_TestCase {
    3737
    3838    var $Navigation;
     
    4040    function NavigationTest($name)
    4141    {
    42         $this->PHPUnit_TestCase($name);
     42        $this->PHPUnit_Framework_TestCase($name);
    4343    }
    4444
     
    133133
    134134}
    135 // Running the test.
    136 $suite = new PHPUnit_TestSuite('NavigationTest');
    137 $result = PHPUnit::run($suite);
    138 echo $result->toString();
    139 ?>
  • trunk/tests/PEditTest.php

    r396 r468  
    3333 * Created with PHPUnit_Skeleton on 2005-08-09
    3434 */
    35 require_once 'PHPUnit.php';
    36 class PEditTest extends PHPUnit_TestCase {
     35
     36class PEditTest extends PHPUnit_Framework_TestCase {
    3737
    3838    var $PEdit;
     
    4040    function PEditTest($name)
    4141    {
    42         $this->PHPUnit_TestCase($name);
     42        $this->PHPUnit_Framework_TestCase($name);
    4343    }
    4444
     
    154154
    155155}
    156 // Running the test.
    157 $suite = new PHPUnit_TestSuite('PEditTest');
    158 $result = PHPUnit::run($suite);
    159 echo $result->toString();
    160 ?>
  • trunk/tests/PageNumbersTest.php

    r396 r468  
    3333 * Created with PHPUnit_Skeleton on 2005-08-09
    3434 */
    35 require_once 'PHPUnit.php';
    36 class PageNumbersTest extends PHPUnit_TestCase {
     35
     36class PageNumbersTest extends PHPUnit_Framework_TestCase {
    3737
    3838    var $PageNumbers;
     
    4040    function PageNumbersTest($name)
    4141    {
    42         $this->PHPUnit_TestCase($name);
     42        $this->PHPUnit_Framework_TestCase($name);
    4343    }
    4444
     
    133133
    134134}
    135 // Running the test.
    136 $suite = new PHPUnit_TestSuite('PageNumbersTest');
    137 $result = PHPUnit::run($suite);
    138 echo $result->toString();
    139 ?>
  • trunk/tests/PageSequenceTest.php

    r396 r468  
    3333 * Created with PHPUnit_Skeleton on 2005-08-09
    3434 */
    35 require_once 'PHPUnit.php';
    36 class PageSequenceTest extends PHPUnit_TestCase {
     35
     36class PageSequenceTest extends PHPUnit_Framework_TestCase {
    3737
    3838    var $PageSequence;
     
    4040    function PageSequenceTest($name)
    4141    {
    42         $this->PHPUnit_TestCase($name);
     42        $this->PHPUnit_Framework_TestCase($name);
    4343    }
    4444
     
    182182
    183183}
    184 // Running the test.
    185 $suite = new PHPUnit_TestSuite('PageSequenceTest');
    186 $result = PHPUnit::run($suite);
    187 echo $result->toString();
    188 ?>
  • trunk/tests/PayPalTest.php

    r396 r468  
    3030 * Created with PHPUnit_Skeleton on 2005-08-09
    3131 */
    32 require_once 'PHPUnit.php';
    33 class PayPalTest extends PHPUnit_TestCase {
     32
     33class PayPalTest extends PHPUnit_Framework_TestCase {
    3434
    3535    var $PayPal;
    36 
    37     function PayPalTest($name)
    38     {
    39         $this->PHPUnit_TestCase($name);
    40     }
    4136
    4237    function setUp()
     
    4439        require dirname(__FILE__) . '/_config.inc.php';
    4540        require_once '../lib/PayPal.inc.php';
    46         $this->PayPal =& new PayPal();
     41        $this->PayPal = new PayPal();
    4742
    4843        // Defaults for purchasing classified postings.
     
    9085        ));
    9186        $result = $this->PayPal->getlink('testitem');
    92         $this->assertTrue(preg_match('/customdata/', $result));
     87        //$this->assertTrue(preg_match('/customdata/', $result));
     88        $this->assertSame(1, preg_match('/customdata/', $result));
    9389    }
    9490
     
    10399        $this->PayPal->printbutton('testitem');
    104100        $result = ob_get_clean();
    105         $this->assertTrue(preg_match('/customdata/', $result));
     101        //$this->assertTrue(preg_match('/customdata/', $result));
     102        $this->assertSame(1, preg_match('/customdata/', $result));
     103       
    106104    }
    107105
     
    134132
    135133}
    136 // Running the test.
    137 $suite = new PHPUnit_TestSuite('PayPalTest');
    138 $result = PHPUnit::run($suite);
    139 echo $result->toString();
    140 ?>
  • trunk/tests/PrefsTest.php

    r396 r468  
    3333 * Created with PHPUnit_Skeleton on 2005-08-09
    3434 */
    35 require_once 'PHPUnit.php';
    36 class PrefsTest extends PHPUnit_TestCase {
     35
     36class PrefsTest extends PHPUnit_Framework_TestCase {
    3737
    3838    var $Prefs;
     
    4040    function PrefsTest($name)
    4141    {
    42         $this->PHPUnit_TestCase($name);
     42        $this->PHPUnit_Framework_TestCase($name);
    4343    }
    4444
     
    112112
    113113}
    114 // Running the test.
    115 $suite = new PHPUnit_TestSuite('PrefsTest');
    116 $result = PHPUnit::run($suite);
    117 echo $result->toString();
    118 ?>
  • trunk/tests/ScriptTimerTest.php

    r396 r468  
    3333 * Created with PHPUnit_Skeleton on 2005-08-09
    3434 */
    35 require_once 'PHPUnit.php';
    36 class ScriptTimerTest extends PHPUnit_TestCase {
     35
     36class ScriptTimerTest extends PHPUnit_Framework_TestCase {
    3737
    3838    var $ScriptTimer;
     
    4040    function ScriptTimerTest($name)
    4141    {
    42         $this->PHPUnit_TestCase($name);
     42        $this->PHPUnit_Framework_TestCase($name);
    4343    }
    4444
     
    7777
    7878}
    79 // Running the test.
    80 $suite = new PHPUnit_TestSuite('ScriptTimerTest');
    81 $result = PHPUnit::run($suite);
    82 echo $result->toString();
    83 ?>
  • trunk/tests/SortOrderTest.php

    r396 r468  
    3333 * Created with PHPUnit_Skeleton on 2005-08-09
    3434 */
    35 require_once 'PHPUnit.php';
    36 class SortOrderTest extends PHPUnit_TestCase {
     35
     36class SortOrderTest extends PHPUnit_Framework_TestCase {
    3737
    3838    var $SortOrder;
     
    4040    function SortOrderTest($name)
    4141    {
    42         $this->PHPUnit_TestCase($name);
     42        $this->PHPUnit_Framework_TestCase($name);
    4343    }
    4444
     
    9191
    9292}
    93 // Running the test.
    94 $suite = new PHPUnit_TestSuite('SortOrderTest');
    95 $result = PHPUnit::run($suite);
    96 echo $result->toString();
    97 ?>
  • trunk/tests/SpellCheckTest.php

    r396 r468  
    3333 * Created with PHPUnit_Skeleton on 2005-08-09
    3434 */
    35 require_once 'PHPUnit.php';
    36 class SpellCheckTest extends PHPUnit_TestCase {
     35
     36class SpellCheckTest extends PHPUnit_Framework_TestCase {
    3737
    3838    var $SpellCheck;
     
    4040    function SpellCheckTest($name)
    4141    {
    42         $this->PHPUnit_TestCase($name);
     42        $this->PHPUnit_Framework_TestCase($name);
    4343    }
    4444
     
    154154
    155155}
    156 // Running the test.
    157 $suite = new PHPUnit_TestSuite('SpellCheckTest');
    158 $result = PHPUnit::run($suite);
    159 echo $result->toString();
    160 ?>
  • trunk/tests/TemplateGlueTest.php

    r396 r468  
    3333 * Created with PHPUnit_Skeleton on 2005-08-09
    3434 */
    35 require_once 'PHPUnit.php';
    36 class TemplateGlueTest extends PHPUnit_TestCase {
     35
     36class TemplateGlueTest extends PHPUnit_Framework_TestCase {
    3737
    3838    var $TemplateGlue;
     
    4040    function TemplateGlueTest($name)
    4141    {
    42         $this->PHPUnit_TestCase($name);
     42        $this->PHPUnit_Framework_TestCase($name);
    4343    }
    4444
     
    5656
    5757}
    58 // Running the test.
    59 $suite = new PHPUnit_TestSuite('TemplateGlueTest');
    60 $result = PHPUnit::run($suite);
    61 echo $result->toString();
    62 ?>
  • trunk/tests/UploadTest.php

    r396 r468  
    77 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    88 * Copyright 2001-2012 Strangecode, LLC
    9  * 
     9 *
    1010 * This file is part of The Strangecode Codebase.
    1111 *
     
    1414 * Free Software Foundation, either version 3 of the License, or (at your option)
    1515 * any later version.
    16  * 
     16 *
    1717 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1818 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1919 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    2020 * details.
    21  * 
     21 *
    2222 * You should have received a copy of the GNU General Public License along with
    2323 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    3333 * Created with PHPUnit_Skeleton on 2005-08-09
    3434 */
    35 require_once 'PHPUnit.php';
    36 class UploadTest extends PHPUnit_TestCase {
     35
     36class UploadTest extends PHPUnit_Framework_TestCase {
    3737
    3838    var $Upload;
     
    4040    function UploadTest($name)
    4141    {
    42         $this->PHPUnit_TestCase($name);
     42        $this->PHPUnit_Framework_TestCase($name);
    4343    }
    4444
     
    120120    function test_getfilenameextension()
    121121    {
    122         $result = $this->Upload->getfilenameextension(PARAM);
     122        $result = $this->Upload::getfilenameextension(PARAM);
    123123        $expected = EXPECTED_VAL;
    124124        $this->assertEquals($expected, $result);
     
    126126
    127127}
    128 // Running the test.
    129 $suite = new PHPUnit_TestSuite('UploadTest');
    130 $result = PHPUnit::run($suite);
    131 echo $result->toString();
    132 ?>
  • trunk/tests/UtilitiesTest.php

    r396 r468  
    3333 * Created with PHPUnit_Skeleton on 2005-08-09
    3434 */
    35 require_once 'PHPUnit.php';
    36 class UtilitiesTest extends PHPUnit_TestCase {
     35
     36class UtilitiesTest extends PHPUnit_Framework_TestCase {
    3737
    3838    var $Utilities;
     
    4040    function UtilitiesTest($name)
    4141    {
    42         $this->PHPUnit_TestCase($name);
     42        $this->PHPUnit_Framework_TestCase($name);
    4343    }
    4444
     
    5656
    5757}
    58 // Running the test.
    59 $suite = new PHPUnit_TestSuite('UtilitiesTest');
    60 $result = PHPUnit::run($suite);
    61 echo $result->toString();
    62 ?>
  • trunk/tests/VersionTest.php

    r396 r468  
    3030 * Created with PHPUnit_Skeleton on 2005-08-09
    3131 */
    32 require_once 'PHPUnit.php';
    33 class VersionTest extends PHPUnit_TestCase {
     32
     33class VersionTest extends PHPUnit_Framework_TestCase {
    3434
    3535    var $Version;
    3636    var $Auth_SQL;
    37 
    38     function VersionTest($name)
    39     {
    40         $this->PHPUnit_TestCase($name);
    41     }
    4237
    4338    function setUp()
     
    4742
    4843        require_once '../lib/Auth_SQL.inc.php';
    49         $this->Auth_SQL =& new Auth_SQL('testauth');
     44        $this->Auth_SQL = new Auth_SQL('testauth');
    5045        $this->Auth_SQL->setParam(array(
    5146            'db_table'          => 'test_user_tbl',
     
    116111    {
    117112        $result = $this->Version->create('test_user_tbl', 'user_id', '1', 'Test User', 'First version of user');
    118         $this->assertTrue($result);
     113        $this->assertSame(1, $result);
    119114    }
    120115
     
    190185
    191186}
    192 // Running the test.
    193 $suite = new PHPUnit_TestSuite('VersionTest');
    194 $result = PHPUnit::run($suite);
    195 echo $result->toString();
    196 ?>
  • trunk/tests/_config.inc.php

    r396 r468  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    2828*/
    2929require_once '../lib/App.inc.php';
     30
    3031$app =& App::getInstance('testapp');
    3132
     
    4445    'db_die_on_failure' => true,
    4546    'db_server' => 'localhost',
    46     'db_name' => 'test',
    47     'db_user' => 'root',
     47    'db_name' => getenv('DB_NAME'),
     48    'db_user' => getenv('DB_USER'),
    4849    'db_pass' => getenv('DB_PASS'),
    4950    'display_errors' => true,
     
    5960
    6061$app->start();
    61 ?>
  • trunk/tests/_skel.php

    r412 r468  
    7878// }
    7979
    80 ?>
  • trunk/tests/run_tests.sh

    r399 r468  
    1 #!/bin/sh
     1#!/bin/bash
     2
     3# This script sets-up the test environment and runs all tests.
     4# You'll want to define your local mysql credentials for a test
     5# database as environment variables, e.g., in ~/.bash_profile:
     6#  export DB_NAME="test"
     7#  export DB_USER="test"
     8#  export DB_PASS="..."
    29
    310# Be in the directory with all the tests.
    411cd `dirname $0`;
    512
     13# Get required ENV variables.
     14if [[ -z "$DB_USER$DB_PASS$DB_NAME" ]]; then
     15    echo "MySQL test DB credential environment variables are missing.\nSet these in ~/.bash_profile to avoid seeing these prompts each time.";
     16fi
     17for E in DB_USER DB_PASS DB_NAME; do
     18    while [[ -z ${!E} ]]; do
     19        read -p "$E: " $E;
     20    done
     21    export $E;
     22done
     23
    624# Create database.
    725mysql -e 'CREATE DATABASE IF NOT EXISTS `test`';
    826
    9 # Run tests sequentially.
    10 for foo in *Test.php;
    11 do
    12     php $foo;
    13 done;
     27# Go!
     28echo "Running the tests!";
     29echo "You'll want to 'tail -f /tmp/codebase_test_log' and watch for errors.";
     30
     31# Config options go in phpunit.xml
     32# phpunit --tap | grep -v '^ok '
     33phpunit --stderr
Note: See TracChangeset for help on using the changeset viewer.