Changeset 42


Ignore:
Timestamp:
Dec 18, 2005 12:16:03 AM (18 years ago)
Author:
scdev
Message:

detabbed all files ;P

Location:
trunk
Files:
86 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/file_importer.php

    r41 r42  
    2727            $file_text = join('', file($file));
    2828            fclose($fp);
    29            
     29
    3030            // Do something with file contents.
    3131            preg_match('/BALANCE:\s*\$([\.\d]+)/', $file_text, $amt);
     
    6868
    6969/**
    70  * Find all files in directories recursivly with a specified file extension. 
     70 * Find all files in directories recursivly with a specified file extension.
    7171 *
    7272 * @param  string $dir               the full path to the directory to scan
     
    8080{
    8181    static $output;
    82    
     82
    8383    $dir_handle = opendir($dir);
    8484    while ($dir_handle && ($file = readdir($dir_handle)) !== false) {
  • trunk/bin/module_maker/form_template.cli.php

    r41 r42  
    4040if (is_array($cols) && !empty($cols)) {
    4141    foreach ($cols as $col) {
    42        
     42
    4343        // Human readable.
    4444        $field = $col[0];
     
    4848            $primary_key_field = $field;
    4949        }
    50        
     50
    5151        // Column types like this are usually single toggle checkboxes.
    5252        if (preg_match("/enum\('true'\)/", $col[1])) {
    5353            $type = 'toggle';
    5454        }
    55        
     55
    5656        if (in_array($field, $exclude) || $primary_key_field == $field) {
    5757            // Don't add a field for this column.
    5858            continue;
    5959        }
    60        
     60
    6161        // Select menu from the column of a related database table.
    6262        if (preg_match('/.*_id$/i', $field)) {
     
    7979            continue;
    8080        }
    81        
     81
    8282        // File upload.
    8383        if (preg_match('/file|image/i', $field)) {
     
    9696            continue;
    9797        }
    98        
     98
    9999        // Password field.
    100100        if (preg_match('/pass/i', $field)) {
     
    109109            continue;
    110110        }
    111        
     111
    112112        switch ($type) {
    113        
     113
    114114        // Select menu (or radio buttons)
    115115        case 'enum' :
     
    125125E_O_F;
    126126            break;
    127        
     127
    128128        // Set checkboxes
    129129        case 'set' :
     
    137137E_O_F;
    138138            break;
    139        
     139
    140140        // Single checkbox
    141141        case 'toggle' :
     
    149149E_O_F;
    150150            break;
    151            
     151
    152152        // Textarea
    153153        case 'tinytext' :
     
    168168E_O_F;
    169169            break;
    170        
    171            
     170
     171
    172172        // Text
    173173        case 'tinyint' :
     
    179179        case 'integer' :
    180180        case 'bigint' :
    181        
     181
    182182        case 'float' :
    183183        case 'float' :
     
    188188        case 'dec' :
    189189        case 'numeric' :
    190        
     190
    191191        case 'date' :
    192192        case 'datetime' :
     
    194194        case 'time' :
    195195        case 'year' :
    196        
     196
    197197        case 'char' :
    198198        case 'varchar' :
  • trunk/bin/module_maker/list_template.cli.php

    r41 r42  
    4949if (is_array($cols) && !empty($cols)) {
    5050    foreach ($cols as $col) {
    51        
     51
    5252        // Human readable.
    5353        $field = $col[0];
    5454        $title = ucfirst(str_replace('_', ' ', $field));
    5555        $type = preg_replace('/^(\w+).*$/', '\\1', $col[1]);
    56        
     56
    5757        // Get primary key.
    5858        if ('PRI' == $col[3]) {
    5959            $primary_key = $field;
    6060        }
    61        
     61
    6262        // Column headers.
    6363        $headers[$field] = $title;
    64        
     64
    6565        // Column data.
    6666        if (preg_match("/enum\('true'\)/", $col[1])) {
     
    111111    <span class="nowrap commandtext"><a href="<\x3fphp echo App::oHREF(\$_SERVER['PHP_SELF'] . '?op=add'); \x3f>"><\x3fphp echo _("Add <##>"); \x3f></a></span>
    112112    <br />
    113    
     113
    114114    <input type="text" class="small" size="20" name="search_query" value="<\x3fphp echo getFormData('search_query'); \x3f>" title="<\x3fphp echo oTxt(_("Fields searched: <##>.")); \x3f>" />
    115115    <select name="filter_<##>">
  • trunk/bin/module_maker/module.cli.php

    r41 r42  
    1717} else {
    1818    die(basename($_SERVER['argv'][0]) . " Error: invalid arguments. Try like this:
    19    
     19
    2020    " . basename($_SERVER['argv'][0]) . " site_directory name_singular name_plural [clean]
    2121
     
    4646    break;
    4747default :
    48    
     48
    4949}
    5050
     
    9191    trashFile("$public_dir/$public_script");
    9292    trashFile("$public_tpl_dir/$public_list_template");
    93     trashFile("$public_tpl_dir/$public_detail_template");   
     93    trashFile("$public_tpl_dir/$public_detail_template");
    9494    echo "End file cleanup\n";
    9595    die;
     
    163163if (is_array($cols) && !empty($cols)) {
    164164    foreach ($cols as $col) {
    165        
     165
    166166        // Human readable.
    167167        $field = $col[0];
     
    169169        $type = preg_replace('/^(\w+).*$/', '\\1', $col[1]);
    170170        $default = $col[4];
    171        
     171
    172172        // Get primary key.
    173173//         if ('PRI' == $col[3]) {
    174174//             $primary_key = $field;
    175175//         }
    176        
     176
    177177        // Our form will require type="multipart/form-data".
    178178        if (preg_match('/file|image/i', $field)) {
    179179            $upload_file_capability = true;
    180180        }
    181        
     181
    182182        // Column headers.
    183183        $headers[$field] = $field_title;
    184        
     184
    185185        // Get php code for printing variables.
    186186        $public_list_page_vars[] = "<\x3fphp echo oTxt(\$" . $module_name_singular . "_list[\$i]['$field']); \x3f>";
     
    222222    // Form arguments
    223223    $replace['admin_form_tag_init'] = "<form enctype=\"multipart/form-data\" method=\"post\" action=\"<\x3fphp echo \$_SERVER['PHP_SELF']; \x3f>\">\n<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"<##>\" />";
    224    
     224
    225225    // Include statement.
    226226    $replace['admin_upload_include'] = "require_once 'codebase/lib/Upload.inc.php';\n";
     
    245245// Copy uploaded image name into form data.
    246246\$_POST['<##>'] = isset(\$_FILES['<##>']) ? \$_FILES['<##>']['name'] : '';
    247  
     247
    248248
    249249E_O_F;
     
    261261    $replace['admin_upload_insert'] = <<<E_O_F
    262262
    263         // Upload files with prepended primary key.
     263        // Upload files with prepended primary key.
    264264        \$new_file = \$upload->process('<##>',  \$%PRIMARY_KEY% . '_' . getFormData('<##>'));
    265265
     
    443443if ('var' == $op) {
    444444    if (isset($replace[$_SERVER['argv'][5]])) {
    445         echo "\n\n" . $replace[$_SERVER['argv'][5]] . "\n\n";
     445        echo "\n\n" . $replace[$_SERVER['argv'][5]] . "\n\n";
    446446    } else if (isset($skel_files[$_SERVER['argv'][5]])) {
    447447        echo "\n\n" . preg_replace($search, $replace, $skel_files[$_SERVER['argv'][5]]) . "\n\n";
     
    540540    global $user_trash_folder;
    541541    static $file_prefix;
    542    
     542
    543543    if (!isset($file_prefix)) {
    544544        $file_prefix = time();
     
    546546        $file_prefix++;
    547547    }
    548    
     548
    549549    // Make user trash folder.
    550550    if (!dir($user_trash_folder)) {
  • trunk/bin/module_maker/skel/adm_list.ihtml

    r41 r42  
    77    <span class="nowrap commandtext"><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=add'); ?>"><?php echo _("Add %ITEM_TITLE%"); ?></a></span>
    88    <br />
    9    
     9
    1010    <input type="text" class="small" size="20" name="search_query" value="<?php echo getFormData('search_query'); ?>" title="<?php echo oTxt(_("Fields searched: <##> %SEARCH_FIELDS%.")); ?>" />
    1111    <select name="filter_<##>">
  • trunk/bin/module_maker/skel/admin.php

    r41 r42  
    2626 * CONFIG
    2727 *****************************************************************************/
    28  
     28
    2929// Titles and navigation header.
    3030$nav->addPage(_("%TITLE%"), $_SERVER['PHP_SELF']);
    31    
     31
    3232// The object to validate form input.
    3333$fv = new FormValidator();
     
    215215    // Get the information for the form.
    216216    $qid = DB::query("
    217         SELECT * 
     217        SELECT *
    218218        FROM %DB_TBL%
    219219        WHERE %PRIMARY_KEY% = '" . addslashes($id) . "'
     
    227227    // Lock this record.
    228228    $lock->set('%DB_TBL%', '%PRIMARY_KEY%', $id, $frm['<##>']);
    229    
     229
    230230    // Set misc values for the form.
    231231    $frm = array_merge(array(
     
    246246{
    247247    global $lock;
    248    
     248
    249249    $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $id);
    250250    if ($lock->isLocked() && !$lock->isMine()) {
     
    254254    // Break the cache because we are changing the list data.
    255255    SessionCache::breakCache($_SERVER['PHP_SELF']);
    256    
     256
    257257    // Get the information for this object.
    258258    $qid = DB::query("
    259         SELECT <##> 
     259        SELECT <##>
    260260        FROM %DB_TBL%
    261261        WHERE %PRIMARY_KEY% = '" . addslashes($id) . "'
     
    266266        App::dieBoomerangURL();
    267267    }
    268    
     268
    269269    // Delete the record.
    270270    DB::query("DELETE FROM %DB_TBL% WHERE %PRIMARY_KEY% = '" . addslashes($id) . "'");
    271    
     271
    272272    App::raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been deleted."), $name), MSG_SUCCESS, __FILE__, __LINE__);
    273273
     
    279279{
    280280    global $auth;
    281    
     281
    282282    // Break the cache because we are changing the list data.
    283283    SessionCache::breakCache($_SERVER['PHP_SELF']);
    284    
     284
    285285%INSERT%
    286286    $last_insert_id = mysql_insert_id(DB::getDBH());
     
    289289    $version = RecordVersion::getInstance($GLOBALS['auth']);
    290290    $version->create('%DB_TBL%', '%PRIMARY_KEY%', $last_insert_id, $frm['<##>']);
    291    
     291
    292292    App::raiseMsg(sprintf(_("The %ITEM_TITLE% <strong>%s</strong> has been added."), $frm['<##>']), MSG_SUCCESS, __FILE__, __LINE__);
    293    
     293
    294294    return $last_insert_id;
    295295}
     
    298298{
    299299    global $auth, $lock;
    300    
     300
    301301    $lock->select('%DB_TBL%', '%PRIMARY_KEY%', $frm['%PRIMARY_KEY%']);
    302302    if ($lock->isLocked() && !$lock->isMine()) {
     
    308308
    309309%UPDATE%
    310    
     310
    311311    // Create version.
    312312    $version = RecordVersion::getInstance($GLOBALS['auth']);
     
    323323    global $page;
    324324    global $so;
    325    
     325
    326326    $where_clause = '';
    327    
     327
    328328    // Build search query if available.
    329329    if (getFormData('search_query', false)) {
     
    333333        }
    334334    }
    335    
     335
    336336    if (getFormData('filter_<##>', false)) {
    337337        // Limit by filter.
    338338        $where_clause .= (empty($where_clause) ? 'WHERE' : 'AND') . " <##> = '" . addslashes(getFormData('filter_<##>')) . "'";
    339339    }
    340    
     340
    341341    // Count the total number of records so we can do something about the page numbers.
    342342    $qid = DB::query("
    343         SELECT COUNT(*) 
    344         FROM %DB_TBL% 
     343        SELECT COUNT(*)
     344        FROM %DB_TBL%
    345345        $where_clause
    346346    ");
    347347    list($num_results) = mysql_fetch_row($qid);
    348    
     348
    349349    // Set page numbers now we know (needed for next step).
    350350    $page->setTotalItems($num_results);
    351351    $page->calculate();
    352    
     352
    353353    // Final SQL, with sort and page limiters.
    354354    $sql = "
    355         SELECT 
    356             %DB_TBL%.*, 
     355        SELECT
     356            %DB_TBL%.*,
    357357            a1.username AS added_admin_username,
    358358            a2.username AS modified_admin_username
     
    364364        " . $page->getLimitSQL() . "
    365365    ";
    366    
     366
    367367    // A unique key for this query, with the total_items in case db records
    368368    // were added since the last cache. This identifies a unique set of
     
    375375        Prefs::setValue('cache_hash', $cache_hash, $_SERVER['PHP_SELF']);
    376376    }
    377    
     377
    378378    if (SessionCache::isCached($_SERVER['PHP_SELF'])) {
    379379        // Get the cached results.
     
    386386            $list[] = $row;
    387387        }
    388            
     388
    389389        if (isset($list) && !empty($list)) {
    390390            // Cache the results.
     
    397397
    398398function updateRank($ranks)
    399 {   
     399{
    400400    if (!is_array($ranks)) {
    401401        App::logMsg('Saving rank failed, data posted is not an array: ' . $ranks, LOG_ERR, __FILE__, __LINE__);
     
    405405    // Break the cache because we are changing the list data.
    406406    SessionCache::breakCache($_SERVER['PHP_SELF']);
    407    
     407
    408408    // Count the ranks with invalid numbers
    409409    $unspecified_counter = 0;
    410    
     410
    411411    // Go through the array of new ranks.
    412412    foreach ($ranks as $id => $new_rank) {
     
    414414            // Unspecified entries receive a sort order of 10000.
    415415            $new_rank = 10000;
    416             $unspecified_counter++; 
     416            $unspecified_counter++;
    417417        }
    418418        DB::query("
     
    422422        ");
    423423    }
    424    
     424
    425425    App::raiseMsg(_("Records have been reordered with the new rank."), MSG_SUCCESS, __FILE__, __LINE__);
    426426    if ($unspecified_counter > 0) {
  • trunk/bin/module_maker/skel/public.php

    r41 r42  
    11<?php
    22/**
    3  * %PUBLIC_SCRIPT% 
     3 * %PUBLIC_SCRIPT%
    44 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information
    55 *
     
    1818// Titles and navigation header.
    1919$nav->addPage(_("%TITLE%"), $_SERVER['PHP_SELF']);
    20 $nav->setFeature(array('title'=>true)); 
     20$nav->setFeature(array('title'=>true));
    2121
    2222// Instantiate page numbers. Total items are set and calculation is done in the getRecordList function.
     
    3232
    3333if (getFormData('%PRIMARY_KEY%', false)) {
    34    
     34
    3535    // Get requested record.
    3636    $qid = DB::query("
     
    5252        WHERE %PRIMARY_KEY% = '" . addslashes(getFormData('%PRIMARY_KEY%')) . "'
    5353    ");
    54        
     54
    5555    // Set title and main template.
    5656    $nav->addPage($item['<##>']);
     
    5858
    5959} else {
    60    
     60
    6161    // Get the DEFAULT list.
    6262    $%NAME_SINGULAR%_list = array();
    6363    $qid = DB::query("
    64         SELECT * 
    65         FROM %DB_TBL% 
    66         WHERE publish = 'true' 
     64        SELECT *
     65        FROM %DB_TBL%
     66        WHERE publish = 'true'
    6767        " . $so->getSortOrderSQL() . "
    6868        LIMIT 100
     
    7171        $%NAME_SINGULAR%_list[] = $row;
    7272    }
    73    
     73
    7474    // Set page numbers for default list.
    7575    $page->setTotalItems(sizeof($%NAME_SINGULAR%_list));
    7676    $page->calculate();
    77    
     77
    7878
    7979    // Get the FEATURED list.
    8080    $featured_list = array();
    8181    $qid = DB::query("
    82         SELECT * 
    83         FROM %DB_TBL% 
     82        SELECT *
     83        FROM %DB_TBL%
    8484        WHERE publish = 'true'
    8585        AND featured = 'true'
     
    8989        $featured_list[] = $row;
    9090    }
    91    
     91
    9292    // Get the POPULAR list.
    9393    $popular_list = array();
    9494    $qid = DB::query("
    95         SELECT * 
    96         FROM %DB_TBL% 
    97         WHERE publish = 'true' 
     95        SELECT *
     96        FROM %DB_TBL%
     97        WHERE publish = 'true'
    9898        ORDER BY hit_count DESC LIMIT 10
    9999    ");
     
    101101        $popular_list[] = $row;
    102102    }
    103    
     103
    104104    // Get the RECENT list.
    105105    $recent_list = array();
    106106    $qid = DB::query("
    107         SELECT * 
    108         FROM %DB_TBL% 
    109         WHERE publish = 'true' 
     107        SELECT *
     108        FROM %DB_TBL%
     109        WHERE publish = 'true'
    110110        ORDER BY added_datetime DESC LIMIT 10
    111111    ");
     
    113113        $recent_list[] = $row;
    114114    }
    115    
     115
    116116    // Set main template.
    117117    $main_template = '%PUBLIC_LIST_TEMPLATE%';
    118 }   
     118}
    119119
    120120// We have the data, and no errors, so here come the templates.
  • trunk/bin/module_maker/skel/public_list.ihtml

    r41 r42  
    1111        <p>
    1212        <em><?php echo date(App::getParam('date_format'), strtotime($%NAME_SINGULAR%_list[$i]['<##>'])); ?></em> &mdash; <?php echo nl2br(fancyTxt(oTxt($%NAME_SINGULAR%_list[$i]['summary'], true))); ?>
    13            
     13
    1414        <?php if (strlen(trim($%NAME_SINGULAR%_list[$i]['content'])) > 0) { // Link only if content is available. ?>
    1515            <br /><a href="<?php echo App::oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $%NAME_SINGULAR%_list[$i]['%PRIMARY_KEY%']); ?>"><?php echo _("Read more"); ?></a>
    1616        <?php } ?>
    1717        </p>
    18         <?php   
     18        <?php
    1919    }
    2020    if ($page->total_pages > 1) {
     
    3030    ?>
    3131    <h2><?php echo _("Featured %NAME_PLURAL%"); ?></h2>
    32     <?php 
     32    <?php
    3333    foreach ($featured_list as $item) {
    34         ?><h4><a href="<?php echo App::oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $item['%PRIMARY_KEY%']); ?>"><?php echo fancyTxt(oTxt($item['title'])); ?></a></h4><?php   
     34        ?><h4><a href="<?php echo App::oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $item['%PRIMARY_KEY%']); ?>"><?php echo fancyTxt(oTxt($item['title'])); ?></a></h4><?php
    3535    }
    3636}
     
    4242    ?>
    4343    <h2><?php echo _("Popular %NAME_PLURAL%"); ?></h2>
    44     <?php 
     44    <?php
    4545    foreach ($popular_list as $item) {
    46         ?><h4><a href="<?php echo App::oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $item['%PRIMARY_KEY%']); ?>"><?php echo fancyTxt(oTxt($item['title'])); ?></a> </h4><?php   
     46        ?><h4><a href="<?php echo App::oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $item['%PRIMARY_KEY%']); ?>"><?php echo fancyTxt(oTxt($item['title'])); ?></a> </h4><?php
    4747    }
    4848}
     
    5454    ?>
    5555    <h2><?php echo _("Recent %NAME_PLURAL%"); ?></h2>
    56     <?php 
     56    <?php
    5757    foreach ($recent_list as $item) {
    58         ?><h4><a href="<?php echo App::oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $item['%PRIMARY_KEY%']); ?>"><?php echo fancyTxt(oTxt($item['title'])); ?></a> </h4><?php   
     58        ?><h4><a href="<?php echo App::oHREF('/%PUBLIC_SCRIPT%?%PRIMARY_KEY%=' . $item['%PRIMARY_KEY%']); ?>"><?php echo fancyTxt(oTxt($item['title'])); ?></a> </h4><?php
    5959    }
    6060}
  • trunk/bin/module_maker/sql.cli.php

    r41 r42  
    5656if (is_array($cols) && !empty($cols)) {
    5757    foreach ($cols as $col) {
    58        
     58
    5959        // Human readable.
    6060        $field = $col[0];
    6161        $type = preg_replace('/^(\w+).*$/', '\\1', $col[1]);
    6262        $is_primary_key = ('PRI' == $col[3]);
    63        
     63
    6464        $sort_columns .= "\$so->setColumn('$field', '$field ASC', '$field DESC');\n";
    65        
     65
    6666        if ($is_primary_key) {
    6767            // This is the primary key. Deal with separately.
     
    8484        }
    8585    }
    86    
     86
    8787} else {
    8888    die(basename($_SERVER['argv'][0]) . " Warning: $db_tbl does not have any columns.\n");
  • trunk/bin/module_maker/validation.cli.php

    r41 r42  
    3838// Loop through columns
    3939if (is_array($cols) && !empty($cols)) {
    40    
     40
    4141    $o = array();
    4242
    4343    foreach ($cols as $col) {
    44    
     44
    4545        // Human readable.
    4646        $field = $col[0];
     
    4949        $is_primary_key = ('PRI' == $col[3]);
    5050        $unsigned = preg_match('/\s*unsigned\s*$/i', $col[1]);
    51        
     51
    5252        if (in_array($field, $exclude)) {
    5353            continue;
    5454        }
    55        
     55
    5656        // ----------- isEmpty ------------
    5757        $o[] = "\$fv->isEmpty('$field', _(\"<strong>$title</strong> cannot be blank.\"));";
     
    6868            $len_type = 'setenum';
    6969            break;
    70            
     70
    7171        case 'date' :
    7272        case 'datetime' :
     
    7777            $max_length = 127;
    7878            break;
    79            
     79
    8080        case 'tinytext' :
    8181        case 'tinyblob' :
     
    8585            $max_length = 255;
    8686            break;
    87            
     87
    8888        case 'text' :
    8989        case 'blob' :
     
    9191            $max_length = 65535;
    9292            break;
    93            
     93
    9494        case 'mediumtext' :
    9595        case 'mediumblob' :
     
    9797            $max_length = 16777215;
    9898            break;
    99            
     99
    100100        case 'longtext' :
    101101        case 'longblob' :
     
    103103            $max_length = 4294967295;
    104104            break;
    105            
     105
    106106        case 'tinyint' :
    107107        case 'bit' :
     
    116116            }
    117117            break;
    118            
     118
    119119        case 'smallint' :
    120120            $len_type = 'num';
     
    127127            }
    128128            break;
    129            
     129
    130130        case 'mediumint' :
    131131            $len_type = 'num';
     
    138138            }
    139139            break;
    140            
     140
    141141        case 'int' :
    142142        case 'integer' :
     
    150150            }
    151151            break;
    152            
     152
    153153        case 'bigint' :
    154154            $len_type = 'num';
     
    161161            }
    162162            break;
    163            
     163
    164164        case 'float' :
    165165            $len_type = 'num';
     
    167167            $max = 3.40282E+38;
    168168            break;
    169            
     169
    170170        case 'double' :
    171171        case 'double precision' :
     
    178178            $max = 1.79769E+308;
    179179            break;
    180            
     180
    181181        default :
    182182            $len_type = null;
     
    192192            $o[] = "\$fv->numericRange('$field', $min, $max, _(\"<strong>$title</strong> must be a valid number between $min and $max.\"));";
    193193        }
    194        
     194
    195195        // ----------- type check ------------
    196196        switch ($type) {
    197197
    198198        case 'enum' :
    199        
     199
    200200        case 'set' :
    201201            break;
    202        
     202
    203203        case 'char' :
    204204        case 'varchar' :
    205        
     205
    206206        case 'tinytext' :
    207207        case 'text' :
     
    214214//             $o[] = "\$fv->isString('$field', _(\"<strong>$title</strong> must be a string.\"));"; // Pretty useless
    215215            break;
    216        
     216
    217217        case 'tinyint' :
    218218        case 'bit' :
     
    226226            $o[] = "\$fv->isInteger('$field', _(\"<strong>$title</strong> must be an integer.\")$negative_ok);";
    227227            break;
    228        
     228
    229229        case 'float' :
    230230        case 'float' :
     
    238238            $o[] = "\$fv->isFloat('$field', _(\"<strong>$title</strong> must be a valid number.\")$negative_ok);";
    239239            break;
    240        
     240
    241241        case 'date' :
    242242        case 'datetime' :
     
    244244            $o[] = "\$fv->checkRegex('$field', '/^\d{4}-\d{2}-\d{2}$/', true, _(\"<strong>$title</strong> must be a valid date in YYYY-MM-DD format.\"));";
    245245            break;
    246            
     246
    247247        case 'timestamp' :
    248248            $o[] = "\$fv->checkRegex('$field', '/^\d{14}$/', true, _(\"<strong>$title</strong> must be a valid mysql timestamp in YYYYMMDDhhmmss format.\"));";
    249249            break;
    250            
     250
    251251        case 'time' :
    252252            $o[] = "\$fv->checkRegex('$field', '/^\d{1,3}:\d{2}:\d{2}$/', true, _(\"<strong>$title</strong> must be a valid time in hh:mm:ss format.\"));";
    253253            break;
    254        
     254
    255255        case 'year' :
    256256            $o[] = "\$fv->checkRegex('$field', '/^\d{4}$/', true, _(\"<strong>$title</strong> must be a valid year in YYYY format.\"));";
    257257            break;
    258        
     258
    259259        default :
    260260            break;
    261261        }
    262        
     262
    263263        if (preg_match('/email/', $field)) {
    264264            $o[] = "\$fv->validateEmail('$field');";
     
    266266            $o[] = "\$fv->validatePhone('$field');";
    267267        }
    268        
     268
    269269        // Blank between cols?
    270270        $o[] = '';
     
    278278
    279279echo "function validateInput()
    280 {   
     280{
    281281    global \$fv;
    282282
  • trunk/docs/coding_standards.txt

    r41 r42  
    77======================================================================
    88
    9 We're following the PEAR coding standards, with minor modifications. 
     9We're following the PEAR coding standards, with minor modifications.
    1010
    1111This is essential reading:
     
    2020
    2121Auth_SQL.inc.php        One PHP Class to be included. The filename is the
    22                         type of class, underscore, name. Or if in subdirs, 
     22                        type of class, underscore, name. Or if in subdirs,
    2323                        this could be /Auth/SQL.inc.php while the class name
    2424                        remains "Auth_SQL"
     
    2929                        directly in the web root.
    3030
    31 script.cli.php          A command-line executable script, possibly executed 
     31script.cli.php          A command-line executable script, possibly executed
    3232                        with CRON, usually outputs TEXT, not HTML.
    3333
     
    4343
    4444Use an indent of 4 spaces, with no tabs. Code and especially comments should
    45 be wrapped <= 80 characters. Exceptions are made in the case where code 
     45be wrapped <= 80 characters. Exceptions are made in the case where code
    4646readability is significantly improved with longer lines.
    4747
     
    8080        action1;
    8181        break;
    82    
     82
    8383    case 2:
    8484        action2;
    8585        break;
    86    
     86
    8787    default:
    8888        defaultaction;
    8989        break;
    90    
     90
    9191    }
    9292
     
    137137======================================================================
    138138
    139 When functions return boolean values, use 'return false;' or 'return true;' 
     139When functions return boolean values, use 'return false;' or 'return true;'
    140140as opposed to 'return 0;' or 'return 1;' or 'return(-1);'.
    141141
     
    149149
    150150    $something = $blah . funky() . ".\".=" . $blab;
    151    
     151
    152152is better than:
    153    
     153
    154154    $something = $blah.funky().".\".=".$blab;
    155155
     
    159159======================================================================
    160160
    161 Use the single quote marks ' to enclose simple strings whenever possible. 
    162 Double quote marks " require extra parsing and thus slow things down, but 
    163 are necessary if entities there must be swapped-out such as variables or 
     161Use the single quote marks ' to enclose simple strings whenever possible.
     162Double quote marks " require extra parsing and thus slow things down, but
     163are necessary if entities there must be swapped-out such as variables or
    164164control characters.
    165165
     
    196196======================================================================
    197197
    198 Function comments should follow the Javadoc standard, with detailed 
     198Function comments should follow the Javadoc standard, with detailed
    199199function comments and one-line pointers along the way:
    200200http://java.sun.com/products/jdk/javadoc/writingdoccomments/index.html
    201  
     201
    202202    <?php
    203203    /**
     
    215215    {
    216216        $qid = DB::query("SHOW COLUMNS FROM $db_table LIKE '$db_col'",false);
    217            
     217
    218218        $row = mysql_fetch_row($qid);
    219219        if (preg_match('/^enum|^set/i', $row[1]) && preg_match_all("/'([^']*)'/", $row[1], $match)) {
     
    283283======================================================================
    284284
    285 All HTML should be valid XHTML 1.0 verfied with the 
     285All HTML should be valid XHTML 1.0 verfied with the
    286286W3C Markup Validation Service: http://validator.w3.org/
    287287
     
    302302    <td nowrap="nowrap">Example</td>
    303303
    304 All tags must be properly closed. Tags without a closing part must follow the 
     304All tags must be properly closed. Tags without a closing part must follow the
    305305XHTML convention and end with a space and a slash:
    306306
  • trunk/docs/example_config.inc.php

    r41 r42  
    1212// To work around a PHP bug always include this config file with: require_once dirname(__FILE__) . '/_config.inc.php';
    1313if (!preg_match('!^(/|[A-Z]:)!', __FILE__)) {
    14     trigger_error('_config.inc.php include must be specified with an absolute file path (eg: "require_once dirname(__FILE__) . \'/_config.inc.php\';"', E_USER_ERROR);
     14    trigger_error('_config.inc.php include must be specified with an absolute file path (eg: "require_once dirname(__FILE__) . \'/_config.inc.php\';"', E_USER_ERROR);
    1515}
    1616
     
    1919define('COMMON_BASE', realpath(dirname(__FILE__) . '/../'));
    2020
    21 // The DocRoot for this application. SITE_BASE is ifferent from $_SERVER['DOCUMENT_ROOT'] because the 
     21// The DocRoot for this application. SITE_BASE is ifferent from $_SERVER['DOCUMENT_ROOT'] because the
    2222// latter does not change when using the apache Alias directive or URL Rewriting to define a site.
    2323define('SITE_BASE', dirname(__FILE__));
  • trunk/docs/file_layout.txt

    r41 r42  
    55======================================================================================
    66
    7 codebase/ 
    8     bin/ 
     7codebase/
     8    bin/
    99        (generic command-line scripts and applications)
    1010        file_importer.php
     
    1616            list_template.cli.php
    1717            module.cli.php
    18             skel/ 
     18            skel/
    1919                (templates for generating modules)
    2020                adm_form.ihtml
     
    3232        file_layout.txt
    3333        software_licence.txt
    34         todo.txt   
     34        todo.txt
    3535    lib/
    3636        App.inc.php (functions dealing with sessions, href/url/IP manipulation, directories.)
     
    6161        Upload.inc.php (class that manages uploading of files.)
    6262        Utilities.inc.php (functions for general utility: setting defaults, num/string functions, etc.)
    63     services/ 
     63    services/
    6464        (codebase scripts that are only useful when web accessible, i.e. to be used in a doc root)
    6565        admins.php
     
    7979======================================================================================
    8080
    81 global/ 
     81global/
    8282    (global level configuration and libraries for a group of sites/apps)
    8383    config.inc.php (system-wide configuration)
    8484    db_auth.inc.php (db-authentication for CLI scripts. chown'ed by user executing cron, NOT apache).
    8585
    86 docs/ 
     86docs/
    8787    (documents specific to a group of sites/apps)
    8888    tei_db.mysql (db schema)
    89    
    90 bin/ 
     89
     90bin/
    9191    (global level command-line scripts)
    92    
    93 admin/ 
     92
     93admin/
    9494    (DocumentRoot for the admin application)
    9595    _config.inc.php
     
    107107    versions.php (manage db record versions)
    108108
    109 html/ 
     109html/
    110110    (DocumentRoot of main site application)
    111111    _config.inc.php (configuration options and defaults specific to this site. included first in each script.)
  • trunk/docs/revision_history.txt

    r41 r42  
    1010    - will still run if info missing: db creds, log dir, session info.
    1111    - can be located in /usr/local/lib/php if necessary, so accessible by all sites.
    12    
     12
    1313remove interdependencies:
    1414    - App() is the only dependency for other classes. It includes Utilities.inc.php silently.
    1515    - Update libs requiring external files, such as html templates and email templates, classes now self-contained.
    16    
     16
    1717Things with modified interfaces:
    1818    - App
     
    4141        - lang
    4242    - $dbh database handler
    43    
     43
    4444App object:
    4545    - object belongs to a realm, keeping messages and session data within specific site/app.
    4646    - uses the singleton pattern so only one instance of App exists for each app.
    4747    - app object can be accessed globally without reference to object name by calling methods statically, e.g. App:logMsg()
    48     - seperate application and codebase parameters from site configuration variables. 
     48    - seperate application and codebase parameters from site configuration variables.
    4949      Use $app->getParam('var') or App::getParam('var') to get app params.
    5050      F or site configurations do whatever you want (I'm using $cfg['node']['features'] format for configurations)
    51    
     51
    5252App configuration parameters
    5353    - defaults part of the app class
  • trunk/lib/App.inc.php

    r41 r42  
    99 * @version 1.0
    1010 */
    11  
     11
    1212// Message Types.
    1313define('MSG_ERR', 1);
     
    2020
    2121class App {
    22    
     22
    2323    // Name of this application.
    2424    var $app = '_app_';
     
    2929    // Instance of database object.
    3030    var $db;
    31    
     31
    3232    // Array of query arguments will be carried persistently between requests.
    3333    var $_carry_queries = array();
     
    4646        // The location the user will go if the system doesn't knew where else to send them.
    4747        'redirect_home_url' => '/',
    48        
     48
    4949        // SSL URL used when redirecting with App::sslOn().
    5050        'ssl_domain' => null,
    5151        'ssl_enabled' => false,
    52    
     52
    5353        // Character set for page output. Used in the Content-Type header and the HTML <meta content-type> tag.
    5454        'character_set' => 'utf-8',
     
    6363        'session_name' => 'Strangecode',
    6464        'session_use_cookies' => true,
    65    
     65
    6666        // Use database?
    6767        'enable_db' => false,
     
    6969        // Use db-based sessions?
    7070        'enable_db_session_handler' => false,
    71    
     71
    7272        // DB passwords should be set as apache environment variables in httpd.conf, readable only by root.
    7373        'db_server' => 'localhost',
     
    8080        'db_debug' => false, // TRUE = display db errors.
    8181        'db_die_on_failure' => false, // TRUE = script stops on db error.
    82        
     82
    8383        // For classes that require db tables, do we check that a table exists and create if missing?
    8484        'db_create_tables' => true,
     
    8989        // Don't display errors by default; it is preferable to log them to a file.
    9090        'display_errors' => false,
    91    
     91
    9292        // Directory in which to store log files.
    9393        'log_directory' => '',
     
    112112        'log_sms_priority' => false,
    113113        'log_screen_priority' => false,
    114    
     114
    115115        // Email address to receive log event emails.
    116116        'log_to_email_address' => null,
    117        
     117
    118118        // SMS Email address to receive log event SMS messages.
    119119        'log_to_sms_address' => null,
    120        
     120
    121121        // A key for calculating simple cryptographic signatures. Set using as an environment variables in the httpd.conf with 'SetEnv SIGNING_KEY <key>'.
    122122        'signing_key' => 'aae6abd6209d82a691a9f96384a7634a',
    123123    );
    124    
     124
    125125    /**
    126126     * This method enforces the singleton pattern for this class. Only one application is running at a time.
     
    140140        return $instance;
    141141    }
    142    
     142
    143143    /**
    144144     * Constructor.
     
    149149            $this->app .= $app;
    150150        }
    151        
     151
    152152        // Initialize default parameters.
    153153        $this->_params = array_merge($this->_params, $this->_param_defaults);
     
    184184            $this =& App::getInstance();
    185185        }
    186        
     186
    187187        if ($param === null) {
    188188            return $this->_params;
     
    194194        }
    195195    }
    196    
     196
    197197    /**
    198198     * Begin running this application.
     
    207207            return false;
    208208        }
    209        
     209
    210210        // Error reporting.
    211211        ini_set('error_reporting', $this->getParam('error_reporting'));
     
    215215            ini_set('error_log', $this->getParam('log_directory') . '/' . $this->getParam('php_error_log'));
    216216        }
    217        
    218        
     217
     218
    219219        /**
    220220         * 1. Start Database.
    221221         */
    222        
     222
    223223        if ($this->getParam('enable_db')) {
    224        
     224
    225225            // DB connection parameters taken from environment variables in the httpd.conf file, readable only by root.
    226226            if (!empty($_SERVER['DB_SERVER'])) {
     
    236236                $this->setParam(array('db_pass' => $_SERVER['DB_PASS']));
    237237            }
    238            
     238
    239239            // The only instance of the DB object.
    240240            require_once dirname(__FILE__) . '/DB.inc.php';
    241            
     241
    242242            $this->db =& DB::getInstance();
    243            
     243
    244244            $this->db->setParam(array(
    245245                'db_server' => $this->getParam('db_server'),
     
    255255            $this->db->connect();
    256256        }
    257        
    258        
     257
     258
    259259        /**
    260260         * 2. Start PHP session.
    261261         */
    262    
     262
    263263        // Skip session for some user agents.
    264264        if (preg_match('/Atomz|ApacheBench|Wget/i', getenv('HTTP_USER_AGENT'))) {
    265265            $this->setParam(array('enable_session' => false));
    266266        }
    267        
     267
    268268        if (true === $this->getParam('enable_session')) {
    269        
     269
    270270            // Set the session ID to one provided in GET/POST. This is necessary for linking
    271271            // between domains and keeping the same session.
     
    273273                session_id($ses);
    274274            }
    275        
     275
    276276            if (true === $this->getParam('enable_db_session_handler') && true === $this->getParam('enable_db')) {
    277277                // Database session handling.
     
    282282                ));
    283283            }
    284            
     284
    285285            // Session parameters.
    286286            ini_set('session.use_cookies', $this->getParam('session_use_cookies'));
     
    289289            ini_set('session.entropy_length', '512');
    290290            session_name($this->getParam('session_name'));
    291            
     291
    292292            // Start the session.
    293293            session_start();
    294            
     294
    295295            if (!isset($_SESSION[$this->app])) {
    296296                // Access session data using: $_SESSION['...'].
     
    302302            }
    303303        }
    304        
    305        
     304
     305
    306306        /**
    307307         * 3. Misc setup.
     
    319319            $this->setParam(array('signing_key' => $_SERVER['SIGNING_KEY']));
    320320        }
    321        
     321
    322322        // Character set. This should also be printed in the html header template.
    323323        header('Content-type: text/html; charset=' . $this->getParam('character_set'));
    324        
     324
    325325        $this->running = true;
    326326    }
    327    
     327
    328328    /**
    329329     * Stop running this application.
     
    340340        $this->running = false;
    341341    }
    342    
    343    
     342
     343
    344344    /**
    345345     * Add a message to the string globalmessage, which is printed in the header.
     
    359359            $this =& App::getInstance();
    360360        }
    361        
     361
    362362        $message = trim($message);
    363363
     
    365365            return false;
    366366        }
    367        
     367
    368368        // Save message in session under unique key to avoid duplicate messages.
    369369        $_SESSION[$this->app]['messages'][md5($type . $message . $file . $line)] = array(
    370             'type'    => $type, 
     370            'type'    => $type,
    371371            'message' => $message,
    372372            'file'    => $file,
    373373            'line'    => $line
    374374        );
    375        
     375
    376376        if (!in_array($type, array(MSG_NOTICE, MSG_SUCCESS, MSG_WARNING, MSG_ERR))) {
    377             $this->logMsg(sprintf('Invalid MSG_* type: %s', $type), LOG_DEBUG, __FILE__, __LINE__);
    378         }
    379     }
    380    
     377            $this->logMsg(sprintf('Invalid MSG_* type: %s', $type), LOG_DEBUG, __FILE__, __LINE__);
     378        }
     379    }
     380
    381381    /**
    382382     * Prints the HTML for displaying raised messages.
     
    405405                echo '<div class="error">' . $message['message'] . '</div>';
    406406                break;
    407    
     407
    408408            case MSG_WARNING:
    409409                echo '<div class="warning">' . $message['message'] . '</div>';
    410410                break;
    411    
     411
    412412            case MSG_SUCCESS:
    413413                echo '<div class="success">' . $message['message'] . '</div>';
    414414                break;
    415    
     415
    416416            case MSG_NOTICE:
    417417            default:
    418418                echo '<div class="notice">' . $message['message'] . '</div>';
    419419                break;
    420    
     420
    421421            }
    422422            ?></div><?php
    423423        }
    424424    }
    425    
     425
    426426    /**
    427427     * Logs a message to a user defined log file. Additional actions to take for
     
    448448            $this =& App::getInstance();
    449449        }
    450        
     450
    451451        // If priority is not specified, assume the worst.
    452452        if (!$this->logPriorityToString($priority)) {
     
    454454            $priority = LOG_EMERG;
    455455        }
    456    
     456
    457457        // If log file is not specified, don't log to a file.
    458458        if (!$this->getParam('log_directory') || !$this->getParam('log_filename') || !is_dir($this->getParam('log_directory')) || !is_writable($this->getParam('log_directory'))) {
     
    461461            trigger_error(sprintf('Codebase error: log directory (%s) not found or writable.', $this->getParam('log_directory')), E_USER_NOTICE);
    462462        }
    463        
     463
    464464        // Make sure to log in the system's locale.
    465465        $locale = setlocale(LC_TIME, 0);
    466466        setlocale(LC_TIME, 'C');
    467        
     467
    468468        // Data to be stored for a log event.
    469469        $event = array();
     
    478478        $event['message'] = strip_tags(preg_replace('/\s+/', ' ', $message), (!empty($strip_tags_allow[1]) ? join('> ', $strip_tags_allow[1]) . '>' : null));
    479479        $event_str = '[' . join('] [', $event) . ']';
    480        
     480
    481481        // FILE ACTION
    482482        if ($this->getParam('log_file_priority') && $priority <= $this->getParam('log_file_priority')) {
    483483            error_log($event_str . "\n", 3, $this->getParam('log_directory') . '/' . $this->getParam('log_filename'));
    484484        }
    485    
     485
    486486        // EMAIL ACTION
    487487        if ($this->getParam('log_email_priority') && $priority <= $this->getParam('log_email_priority')) {
     
    494494            mail($this->getParam('log_to_email_address'), $subject, $email_msg, $headers, '-f codebase@strangecode.com');
    495495        }
    496        
     496
    497497        // SMS ACTION
    498498        if ($this->getParam('log_sms_priority') && $priority <= $this->getParam('log_sms_priority')) {
     
    502502            mail($this->getParam('log_to_sms_address'), $subject, $sms_msg, $headers, '-f codebase@strangecode.com');
    503503        }
    504    
     504
    505505        // SCREEN ACTION
    506506        if ($this->getParam('log_screen_priority') && $priority <= $this->getParam('log_screen_priority')) {
    507507            echo "[{$event['date']}] [{$event['type']}] [{$event['file:line']}] [{$event['message']}]\n";
    508508        }
    509    
     509
    510510        // Restore original locale.
    511511        setlocale(LC_TIME, $locale);
    512512    }
    513    
     513
    514514    /**
    515515     * Returns the string representation of a LOG_* integer constant.
     
    536536        }
    537537    }
    538    
     538
    539539    /**
    540540     * Sets which query arguments will be carried persistently between requests.
    541      * Values in the _carry_queries array will be copied to URLs (via App::url()) and 
     541     * Values in the _carry_queries array will be copied to URLs (via App::url()) and
    542542     * to hidden input values (via printHiddenSession()).
    543543     *
    544544     * @access  public
    545      * @param   string  $query_key  The key of the query argument to save. 
     545     * @param   string  $query_key  The key of the query argument to save.
    546546     * @author  Quinn Comendant <quinn@strangecode.com>
    547547     * @since   14 Nov 2005 19:24:52
     
    552552            $this =& App::getInstance();
    553553        }
    554        
     554
    555555        // If not already set, and there is a non-empty value provided in the request...
    556556        if (!isset($this->_carry_queries[$query_key]) && getFormData($query_key, false)) {
    557557            // Copy the value of the specified query argument into the _carry_queries array.
    558             $this->_carry_queries[$query_key] = getFormData($query_key);
    559         }
    560     }
    561    
     558            $this->_carry_queries[$query_key] = getFormData($query_key);
     559        }
     560    }
     561
    562562    /**
    563563     * Outputs a fully qualified URL with a query of all the used (ie: not empty)
    564      * keys and values, including optional queries. This allows mindless retention 
     564     * keys and values, including optional queries. This allows mindless retention
    565565     * of query arguments across page requests. If cookies are not
    566566     * used, the session id will be propogated in the URL.
     
    588588            return false;
    589589        }
    590    
     590
    591591        // Get any provided query arguments to include in the final URL.
    592592        // If FALSE is a provided here, DO NOT carry the queries.
     
    611611            }
    612612        }
    613        
     613
    614614        // Get the first delimiter that is needed in the url.
    615615        $delim = strpos($url, '?') !== false ? ini_get('arg_separator.output') : '?';
    616616
    617        
     617
    618618        $q = '';
    619619        if ($do_carry_queries) {
     
    628628            }
    629629        }
    630    
     630
    631631        // Include the necessary SID if the following is true:
    632632        // - no cookie in http request OR cookies disabled in App
     
    634634        // - the link stays on our site
    635635        // - transparent SID propogation with session.use_trans_sid is not being used OR url begins with protocol (using_trans_sid has no effect here)
    636         // OR 
     636        // OR
    637637        // - we must include the SID because we say so (it's used in a context where cookies will not be effective, ie. moving from http to https)
    638638        // AND
     
    642642                (
    643643                    (
    644                         !isset($_COOKIE[session_name()]) 
     644                        !isset($_COOKIE[session_name()])
    645645                        || !$this->getParam('session_use_cookies')
    646                     ) 
     646                    )
    647647                    && $this->getParam('enable_session')
    648                     && isMyDomain($url) 
    649                     && 
     648                    && isMyDomain($url)
     649                    &&
    650650                    (
    651651                        !ini_get('session.use_trans_sid')
    652652                        || preg_match('!^(http|https)://!i', $url)
    653653                    )
    654                 ) 
     654                )
    655655                || $always_include_sid
    656656            )
     
    679679            $this =& App::getInstance();
    680680        }
    681        
     681
    682682        $url = $this->url($url, $carry_args, $always_include_sid);
    683        
     683
    684684        // Replace any & not followed by an html or unicode entity with it's &amp; equivalent.
    685685        $url = preg_replace('/&(?![\w\d#]{1,10};)/', '&amp;', $url);
    686        
     686
    687687        return $url;
    688688    }
    689    
     689
    690690    /**
    691691     * Prints a hidden form element with the PHPSESSID when cookies are not used, as well
    692      * as hidden form elements for GET_VARS that might be in use. 
     692     * as hidden form elements for GET_VARS that might be in use.
    693693     *
    694694     * @param  mixed  $carry_args        Additional url arguments to carry in the query,
     
    707707            return false;
    708708        }
    709    
     709
    710710        // Get any provided query arguments to include in the final hidden form data.
    711711        // If FALSE is a provided here, DO NOT carry the queries.
     
    730730            }
    731731        }
    732        
     732
    733733        // For each existing POST value, we create a hidden input to carry it through a form.
    734734        if ($do_carry_queries) {
     
    740740            }
    741741        }
    742        
     742
    743743        // Include the SID if cookies are disabled.
    744744        if (!isset($_COOKIE[session_name()]) && !ini_get('session.use_trans_sid')) {
     
    746746        }
    747747    }
    748    
     748
    749749    /**
    750750     * Uses an http header to redirect the client to the given $url. If sessions are not used
     
    769769            return false;
    770770        }
    771        
     771
    772772        if ('' == $url) {
    773773            // If URL is not specified, use the redirect_home_url.
    774774            $url = $this->getParam('redirect_home_url');
    775775        }
    776    
     776
    777777        if (preg_match('!^/!', $url)) {
    778778            // If relative URL is given, prepend correct local hostname.
     
    783783
    784784        $url = $this->url($url, $carry_args, $always_include_sid);
    785        
     785
    786786        header(sprintf('Location: %s', $url));
    787787        $this->logMsg(sprintf('dieURL: %s', $url), LOG_DEBUG, __FILE__, __LINE__);
    788        
     788
    789789        // End this application.
    790790        // Recommended, although I'm not sure it's necessary: http://cn2.php.net/session_write_close
     
    792792        die;
    793793    }
    794    
     794
    795795    /**
    796796     * Redirects a user by calling the App::dieURL(). It will use:
     
    808808            return false;
    809809        }
    810        
     810
    811811        // Get URL from stored boomerang. Allow non specific URL if ID not valid.
    812812        if ($this->validBoomerangURL($id, true)) {
     
    829829            $this->logMsg(sprintf('dieBoomerangURL(%s) not found, using redirect_home_url: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    830830        }
    831    
    832            
     831
     832
    833833        // A redirection will never happen immediatly twice.
    834834        // Set the time so ensure this doesn't happen.
     
    836836        $this->dieURL($url, $carry_args);
    837837    }
    838    
     838
    839839    /**
    840840     * Set the URL to return to when App::dieBoomerangURL() is called.
     
    855855        // A redirection will never happen immediatly after setting the boomerangURL.
    856856        // Set the time so ensure this doesn't happen. See App::validBoomerangURL for more.
    857    
     857
    858858        if ('' != $url && is_string($url)) {
    859859            // Delete any boomerang request keys in the query string.
    860860            $url = preg_replace('/boomerang=[\w]+/', '', $url);
    861            
     861
    862862            if (isset($_SESSION[$this->app]['boomerang']['url']) && is_array($_SESSION[$this->app]['boomerang']['url']) && !empty($_SESSION[$this->app]['boomerang']['url'])) {
    863863                // If the URL currently exists in the boomerang array, delete.
     
    866866                }
    867867            }
    868            
     868
    869869            if (isset($id)) {
    870870                $_SESSION[$this->app]['boomerang']['url'][$id] = $url;
     
    879879        }
    880880    }
    881    
     881
    882882    /**
    883883     * Return the URL set for the specified $id.
     
    894894            return false;
    895895        }
    896        
     896
    897897        if (isset($id)) {
    898898            if (isset($_SESSION[$this->app]['boomerang']['url'][$id])) {
     
    907907        }
    908908    }
    909    
     909
    910910    /**
    911911     * Delete the URL set for the specified $id.
     
    922922            return false;
    923923        }
    924        
     924
    925925        $this->logMsg(sprintf('deleteBoomerangURL(%s): %s', $id, $this->getBoomerangURL($id)), LOG_DEBUG, __FILE__, __LINE__);
    926926
     
    931931        }
    932932    }
    933    
     933
    934934    /**
    935935     * Check if a valid boomerang URL value has been set.
     
    947947            return false;
    948948        }
    949        
     949
    950950        if (!isset($_SESSION[$this->app]['boomerang']['url'])) {
    951951            return false;
    952952        }
    953    
     953
    954954        // Time is the timestamp of a boomerangURL redirection, or setting of a boomerangURL.
    955955        // a boomerang redirection will always occur at least several seconds after the last boomerang redirect
    956956        // or a boomerang being set.
    957957        $boomerang_time = isset($_SESSION[$this->app]['boomerang']['time']) ? $_SESSION[$this->app]['boomerang']['time'] : 0;
    958        
     958
    959959        $url = '';
    960960        if (isset($id) && isset($_SESSION[$this->app]['boomerang']['url'][$id])) {
     
    964964            $url = end($_SESSION[$this->app]['boomerang']['url']);
    965965        }
    966    
     966
    967967        $this->logMsg(sprintf('validBoomerangURL(%s) testing: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    968968
     
    981981            return false;
    982982        }
    983        
     983
    984984        $this->logMsg(sprintf('validBoomerangURL(%s) is valid: %s', $id, $url), LOG_DEBUG, __FILE__, __LINE__);
    985985        return true;
     
    995995            $this =& App::getInstance();
    996996        }
    997        
     997
    998998        if (function_exists('apache_get_modules')) {
    999             $modules = apache_get_modules();
     999            $modules = apache_get_modules();
    10001000        } else {
    10011001            // It's safe to assume we have mod_ssl if we can't determine otherwise.
    10021002            $modules = array('mod_ssl');
    10031003        }
    1004        
     1004
    10051005        if ('on' != getenv('HTTPS') && $this->getParam('ssl_enabled') && in_array('mod_ssl', $modules)) {
    10061006            $this->raiseMsg(sprintf(_("Secure SSL connection made to %s"), $this->getParam('ssl_domain')), MSG_NOTICE, __FILE__, __LINE__);
     
    10091009        }
    10101010    }
    1011        
    1012    
     1011
     1012
    10131013    /**
    10141014     * to enforce the user to connect via http (port 80) by redirecting them to
     
    10221022    }
    10231023
    1024    
     1024
    10251025} // End.
    10261026
  • trunk/lib/Auth_File.inc.php

    r41 r42  
    8686    {
    8787        $user_id = trim($user_id);
    88        
     88
    8989        $this->clearAuth();
    9090
     
    189189            }
    190190            break;
    191         default : 
     191        default :
    192192            App::logMsg('Encryption type not found.', LOG_ERR, __FILE__, __LINE__);
    193193        }
     
    209209            }
    210210            break;
    211         default : 
     211        default :
    212212            App::logMsg('Encryption type not found.', LOG_ERR, __FILE__, __LINE__);
    213213        }
  • trunk/lib/Auth_SQL.inc.php

    r41 r42  
    88
    99// Available encryption types for class Auth_SQL.
    10 define('AUTH_ENCRYPT_MD5', 'md5'); 
    11 define('AUTH_ENCRYPT_CRYPT', 'crypt'); 
    12 define('AUTH_ENCRYPT_SHA1', 'sha1'); 
    13 define('AUTH_ENCRYPT_PLAINTEXT', 'plaintext'); 
     10define('AUTH_ENCRYPT_MD5', 'md5');
     11define('AUTH_ENCRYPT_CRYPT', 'crypt');
     12define('AUTH_ENCRYPT_SHA1', 'sha1');
     13define('AUTH_ENCRYPT_PLAINTEXT', 'plaintext');
    1414
    1515class Auth_SQL {
     
    2222    // Default param values.
    2323    var $_default_params = array(
    24    
     24
    2525        // Message displayed by requireLogin().
    2626        'login_required_message' => 'Please login',
    27        
     27
    2828        // Automatically create table and verify columns. Better set to false after site launch.
    2929        'create_table' => true,
    30        
     30
    3131        // The database table containing users to authenticate.
    3232        'db_table' => 'user_tbl',
    33        
     33
    3434        // The name of the primary key for the db_table.
    3535        'db_primary_key' => 'user_id',
    36        
     36
    3737        // The name of the username key for the db_table.
    3838        'db_username_column' => 'username',
    39        
     39
    4040        // If using the db_login_table feature, specify the db_login_table. The primary key must match the primary key for the db_table.
    4141        'db_login_table' => 'user_login_tbl',
    42        
     42
    4343        // The type of encryption to use for passwords stored in the db_table. Use one of the AUTH_ENCRYPT_* types specified above.
    4444        'encryption_type' => AUTH_ENCRYPT_MD5,
     
    5050        // This applies to admins and users. In seconds. 21600 seconds = 6 hours.
    5151        'login_timeout' => 21600,
    52        
     52
    5353        // The maximum amount of time a user is allowed to be idle before their session expires. They will be forced to login again if they expire.
    5454        // This applies to admins and users. In seconds. 3600 seconds = 1 hour.
     
    6565        'login_abuse_max_ips' => 5,
    6666
    67         // The IP address subnet size threshold. Uses a CIDR notation network mask (see CIDR cheatsheet at bottom). 
    68         // Any integar between 0 and 32 is permitted. Setting this to '24' permits any address in a 
     67        // The IP address subnet size threshold. Uses a CIDR notation network mask (see CIDR cheatsheet at bottom).
     68        // Any integar between 0 and 32 is permitted. Setting this to '24' permits any address in a
    6969        // class C network (255.255.255.0) to be considered the same. Setting to '32' compares each IP absolutely.
    7070        // Setting to '0' ignores all IPs, thus disabling login_abuse checking.
    7171        'login_abuse_ip_bitmask' => 32,
    7272
    73         // Specify usernames to exclude from the account abuse detection system. This is specified as a hardcoded array provided at 
     73        // Specify usernames to exclude from the account abuse detection system. This is specified as a hardcoded array provided at
    7474        // class instantiation time, or can be saved in the db_table under the login_abuse_exempt field.
    7575        'login_abuse_exempt_usernames' => array(),
    76        
     76
    7777        // An array of IP blocks that are bypass the remote_addr comparison check. Useful for dynamic IPs or those behind proxy servers.
    7878        'trusted_networks' => array(),
     
    8080        // Allow user accounts to be blocked? Requires the user table to have the columns 'blocked' and 'blocked_reason'
    8181        'blocking' => false,
    82    
     82
    8383        // Use a db_login_table to detect excessive logins. This requires blocking to be enabled.
    8484        'abuse_detection' => false,
     
    106106        }
    107107    }
    108    
     108
    109109    /**
    110110     * Setup the database tables for this class.
     
    117117    {
    118118        static $_db_tested = false;
    119    
     119
    120120        if ($recreate_db || !$_db_tested && $this->getParam('create_table')) {
    121        
     121
    122122            // User table.
    123123            if ($recreate_db) {
     
    154154
    155155            if (!DB::columnExists($this->getParam('db_table'), array(
    156                 $this->getParam('db_primary_key'),
    157                 $this->getParam('db_username_column'),
    158                 'userpass',
    159                 'first_name',
    160                 'last_name',
    161                 'email',
    162                 'user_type',
    163                 'login_abuse_exempt',
    164                 'blocked',
    165                 'blocked_reason',
    166                 'abuse_warning_level',
    167                 'seconds_online',
    168                 'last_login_datetime',
    169                 'last_access_datetime',
    170                 'last_login_ip',
    171                 'added_by_user_id',
    172                 'modified_by_user_id',
    173                 'added_datetime',
    174                 'modified_datetime',
     156                $this->getParam('db_primary_key'),
     157                $this->getParam('db_username_column'),
     158                'userpass',
     159                'first_name',
     160                'last_name',
     161                'email',
     162                'user_type',
     163                'login_abuse_exempt',
     164                'blocked',
     165                'blocked_reason',
     166                'abuse_warning_level',
     167                'seconds_online',
     168                'last_login_datetime',
     169                'last_access_datetime',
     170                'last_login_ip',
     171                'added_by_user_id',
     172                'modified_by_user_id',
     173                'added_datetime',
     174                'modified_datetime',
    175175            ), false, false)) {
    176176                App::logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), LOG_ALERT, __FILE__, __LINE__);
    177177                trigger_error(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), E_USER_ERROR);
    178178            }
    179            
     179
    180180            // Login table is used for abuse_detection features.
    181181            if ($this->getParam('abuse_detection')) {
     
    192192                    KEY remote_ip_binary (remote_ip_binary)
    193193                )");
    194                
     194
    195195                if (!DB::columnExists($this->getParam('db_login_table'), array(
    196196                    $this->getParam('db_primary_key'),
     
    202202                }
    203203            }
    204         }   
     204        }
    205205        $_db_tested = true;
    206206    }
     
    239239        }
    240240    }
    241    
     241
    242242    /**
    243243     * Set the params of an auth object.
     
    279279    {
    280280        $this->initDB();
    281        
     281
    282282        DB::query("
    283             UPDATE " . $this->_params['db_table'] . " SET 
     283            UPDATE " . $this->_params['db_table'] . " SET
    284284            seconds_online = seconds_online + (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(last_access_datetime)),
    285285            last_login_datetime = '0000-00-00 00:00:00'
     
    301301    {
    302302        $this->initDB();
    303        
     303
    304304        // Query DB for user matching credentials.
    305305        $qid = DB::query("
    306             SELECT *, " . $this->_params['db_primary_key'] . " AS user_id 
     306            SELECT *, " . $this->_params['db_primary_key'] . " AS user_id
    307307            FROM " . $this->_params['db_table'] . "
    308308            WHERE " . $this->_params['db_username_column'] . " = '" . addslashes($username) . "'
    309309            AND BINARY userpass = '" . addslashes($this->encryptPassword($password)) . "'
    310310        ");
    311        
     311
    312312        // Return user data if found.
    313313        if ($user_data = mysql_fetch_assoc($qid)) {
     
    331331    {
    332332        $this->initDB();
    333        
     333
    334334        $this->clearAuth();
    335335
     
    351351            'user_data'             => $user_data
    352352        );
    353        
     353
    354354        /**
    355355         * Check if the account is blocked, respond in context to reason. Cancel the login if blocked.
     
    357357        if ($this->getParam('blocking')) {
    358358            if (!empty($user_data['blocked'])) {
    359                
     359
    360360                App::logMsg(sprintf('%s %s (%s) login failed due to blocked account: %s', ucfirst($this->_auth), $this->getVal('user_id'), $this->getVal('username'), $this->getVal('blocked_reason')), LOG_NOTICE, __FILE__, __LINE__);
    361                
     361
    362362                switch ($user_data['blocked_reason']) {
    363363                    case 'account abuse' :
     
    368368                        break;
    369369                }
    370                
     370
    371371                // No login: user is blocked!
    372372                $this->clearAuth();
     
    374374            }
    375375        }
    376        
     376
    377377        /**
    378378         * Check the db_login_table for too many logins under this account.
     
    412412            DB::query("
    413413                INSERT INTO " . $this->_params['db_login_table'] . " (
    414                     " . $this->_params['db_primary_key'] . ", 
    415                     login_datetime, 
     414                    " . $this->_params['db_primary_key'] . ",
     415                    login_datetime,
    416416                    remote_ip_binary
    417417                ) VALUES (
     
    422422            ");
    423423        }
    424        
     424
    425425        // Update user table with this login.
    426426        DB::query("
     
    431431            WHERE " . $this->_params['db_primary_key'] . " = '" . $this->getVal('user_id') . "'
    432432        ");
    433        
     433
    434434        // We're logged-in!
    435435        return true;
     
    449449    {
    450450        $this->initDB();
    451        
     451
    452452        if (isset($user_id)) {
    453453            // Check the login status of a specific user.
     
    465465            return $_SESSION[$this->_sess]['authenticated'];
    466466        }
    467        
     467
    468468        // Tesing login should occur once. This is the first time. Set flag.
    469469        $this->_authentication_tested = true;
     
    472472        if ($trusted_net = ipInRange(getRemoteAddr(), $this->_params['trusted_networks'])) {
    473473            $user_in_trusted_network = true;
    474             App::logMsg(sprintf('%s%s accessing from trusted network %s', 
    475                 ucfirst($this->_auth), 
     474            App::logMsg(sprintf('%s%s accessing from trusted network %s',
     475                ucfirst($this->_auth),
    476476                ($this->getVal('user_id') ? ' ' . $this->getVal('user_id') . ' (' .  $this->getVal('username') . ')' : ''),
    477477                $trusted_net
     
    479479        } else if (preg_match('/proxy.aol.com$/i', getRemoteAddr(true))) {
    480480            $user_in_trusted_network = true;
    481             App::logMsg(sprintf('%s%s accessing from trusted network proxy.aol.com', 
    482                 ucfirst($this->_auth), 
     481            App::logMsg(sprintf('%s%s accessing from trusted network proxy.aol.com',
     482                ucfirst($this->_auth),
    483483                ($this->getVal('user_id') ? ' ' . $this->getVal('user_id') . ' (' .  $this->getVal('username') . ')' : '')
    484484            ), LOG_INFO, __FILE__, __LINE__);
     
    486486            $user_in_trusted_network = false;
    487487        }
    488        
     488
    489489        // Test login with information stored in session. Skip IP matching for users from trusted networks.
    490490        if (isset($_SESSION[$this->_sess])
     
    500500            // Update the DB with the last_access_datetime and increment the seconds_online.
    501501            DB::query("
    502                 UPDATE " . $this->_params['db_table'] . " SET 
     502                UPDATE " . $this->_params['db_table'] . " SET
    503503                seconds_online = seconds_online + (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(last_access_datetime)) + 1,
    504504                last_access_datetime = '" . $this->getVal('last_access_datetime') . "'
     
    517517                App::raiseMsg(sprintf(_("Your %s session has closed. You need to log-in again."), strtolower($this->_auth)), MSG_NOTICE, __FILE__, __LINE__);
    518518            }
    519            
     519
    520520            // Log the reason for login expiration.
    521521            $expire_reasons = array();
     
    565565     * This sets the 'blocked' field for a user in the db_table, and also
    566566     * adds an optional reason
    567      * 
     567     *
    568568     * @param  string   $reason      The reason for blocking the account.
    569569     */
     
    571571    {
    572572        $this->initDB();
    573        
     573
    574574        if ($this->getParam('blocking')) {
    575575            if (strlen(addslashes($reason)) > 255) {
     
    577577                App::logMsg(sprintf('Blocked reason provided is greater than 255 characters: %s', $reason), LOG_WARNING, __FILE__, __LINE__);
    578578            }
    579            
     579
    580580            // Get user_id if specified.
    581581            $user_id = isset($user_id) ? $user_id : $this->getVal('user_id');
     
    590590
    591591    /**
    592      * Unblocks a user in the db_table, and clears any blocked_reason. 
     592     * Unblocks a user in the db_table, and clears any blocked_reason.
    593593     */
    594594    function unblockAccount($user_id=null)
    595595    {
    596596        $this->initDB();
    597        
     597
    598598        if ($this->getParam('blocking')) {
    599599            // Get user_id if specified.
     
    615615     */
    616616    function usernameExists($username)
    617     {   
    618         $this->initDB();
    619        
     617    {
     618        $this->initDB();
     619
    620620        $qid = DB::query("
    621             SELECT 1 
     621            SELECT 1
    622622            FROM " . $this->_params['db_table'] . "
    623623            WHERE " . $this->_params['db_username_column'] . " = '" . addslashes($username) . "'
     
    633633     */
    634634    function getUsername($user_id)
    635     {   
    636         $this->initDB();
    637        
     635    {
     636        $this->initDB();
     637
    638638        $qid = DB::query("
    639639            SELECT " . $this->_params['db_username_column'] . "
     
    679679        return $str;
    680680    }
    681    
     681
    682682    /**
    683683     *
     
    689689            return $password;
    690690            break;
    691            
     691
    692692        case AUTH_ENCRYPT_CRYPT :
    693693            return crypt($password, crypt($password));
    694694            break;
    695            
     695
    696696        case AUTH_ENCRYPT_SHA1 :
    697697            return sha1($password);
    698698            break;
    699            
     699
    700700        case AUTH_ENCRYPT_MD5 :
    701701        default :
     
    706706
    707707    /**
    708      * 
     708     *
    709709     */
    710710    function setPassword($user_id=null, $password)
    711     {   
    712         $this->initDB();
    713              
     711    {
     712        $this->initDB();
     713
    714714        // Get user_id if specified.
    715715        $user_id = isset($user_id) ? $user_id : $this->getVal('user_id');
    716        
     716
    717717        // Issue the password change query.
    718718        DB::query("
    719             UPDATE " . $this->_params['db_table'] . " 
     719            UPDATE " . $this->_params['db_table'] . "
    720720            SET userpass = '" . addslashes($this->encryptPassword($password)) . "'
    721721            WHERE " . $this->_params['db_primary_key'] . " = '" . addslashes($user_id) . "'
     
    733733    {
    734734        $this->initDB();
    735        
     735
    736736        // Get user_id if specified.
    737737        $user_id = isset($user_id) ? $user_id : $this->getVal('user_id');
    738        
     738
    739739        // Reset password of a specific user.
    740740        $qid = DB::query("
     
    746746            return false;
    747747        }
    748        
     748
    749749        // Make sure user has an email on record.
    750750        if (!isset($user_data['email']) || '' == trim($user_data['email'])) {
     
    754754        // Get new password.
    755755        $password = $this->generatePassword();
    756        
     756
    757757        // Update password query.
    758758        $this->setPassword($user_id, $password);
     
    791791        ));
    792792        $email->send();
    793    
     793
    794794        return array(
    795             'username' => $user_data[$this->_params['db_username_column']], 
     795            'username' => $user_data[$this->_params['db_username_column']],
    796796            'userpass' => $password
    797797        );
    798798    }
    799    
     799
    800800    /**
    801801     * If the current user has access to the specified $security_zone, return true.
    802      * If the optional $priv is supplied, test that against the zone. 
     802     * If the optional $priv is supplied, test that against the zone.
    803803     *
    804804     * @param  constant $security_zone   string of comma delimited priviliges for the zone
     
    811811        $zone_members = preg_split('/,\s*/', $security_zone);
    812812        $priv = empty($priv) ? $this->getVal('priv') : $priv;
    813        
    814         // If the current user's privilege level is NOT in that array or if the 
     813
     814        // If the current user's privilege level is NOT in that array or if the
    815815        // user has no privilege, return false. Otherwise the user is clear.
    816816        if (!in_array($priv, $zone_members) || empty($priv)) {
     
    820820        }
    821821    }
    822    
     822
    823823    /**
    824824     * This function tests a list of arguments $security_zone against the priv that the current user has.
    825      * If the user doesn't have one of the supplied privs, die. 
     825     * If the user doesn't have one of the supplied privs, die.
    826826     *
    827827     * @param  constant $security_zone   string of comma delimited priviliges for the zone
     
    831831        return true;
    832832        $zone_members = preg_split('/,\s*/', $security_zone);
    833    
    834         /* If the current user's privilege level is NOT in that array or if the 
     833
     834        /* If the current user's privilege level is NOT in that array or if the
    835835         * user has no privilege, DIE with a message. */
    836836        if (!in_array($this->getVal('priv'), $zone_members) || !$this->getVal('priv')) {
     
    845845// CIDR cheatsheet
    846846//
    847 // Netmask              Netmask (binary)                 CIDR     Notes   
     847// Netmask              Netmask (binary)                 CIDR     Notes
    848848// _____________________________________________________________________________
    849849// 255.255.255.255  11111111.11111111.11111111.11111111  /32  Host (single addr)
     
    856856// 255.255.255.128  11111111.11111111.11111111.10000000  /25  126  useable
    857857// 255.255.255.0    11111111.11111111.11111111.00000000  /24 "Class C" 254 useable
    858 // 
     858//
    859859// 255.255.254.0    11111111.11111111.11111110.00000000  /23    2  Class C's
    860860// 255.255.252.0    11111111.11111111.11111100.00000000  /22    4  Class C's
     
    865865// 255.255.128.0    11111111.11111111.10000000.00000000  /17  128  Class C's
    866866// 255.255.0.0      11111111.11111111.00000000.00000000  /16  "Class B"
    867 //     
     867//
    868868// 255.254.0.0      11111111.11111110.00000000.00000000  /15    2  Class B's
    869869// 255.252.0.0      11111111.11111100.00000000.00000000  /14    4  Class B's
     
    874874// 255.128.0.0      11111111.10000000.00000000.00000000  /9   128  Class B's
    875875// 255.0.0.0        11111111.00000000.00000000.00000000  /8   "Class A"
    876 //   
     876//
    877877// 254.0.0.0        11111110.00000000.00000000.00000000  /7
    878878// 252.0.0.0        11111100.00000000.00000000.00000000  /6
  • trunk/lib/AuthorizeNet.inc.php

    r41 r42  
    3737
    3838require_once dirname(__FILE__) . '/Utilities.inc.php';
    39  
     39
    4040class AuthorizeNet
    4141{
     
    232232        return (
    233233            strtolower($this->getResult('x_md5_hash')) == strtolower(md5(
    234                 $this->md5_hash_value . 
    235                 $this->getParam('x_login') . 
    236                 $this->getResult('x_trans_id') . 
     234                $this->md5_hash_value .
     235                $this->getParam('x_login') .
     236                $this->getResult('x_trans_id') .
    237237                $this->getResult('x_amount')
    238238            ))
  • trunk/lib/CSS.inc.php

    r41 r42  
    11<?php
    22/**
    3  * CSS.inc.css 
     3 * CSS.inc.css
    44 * code by strangecode :: www.strangecode.com :: this document contains copyrighted information
    55 *
     
    1313    // Include these style sheets.
    1414    var $_css_files = array('default' => array());
    15    
     15
    1616    // Cache style sheets?
    1717    var $_params = array(
     
    1919        'character_set' => 'utf-8',
    2020    );
    21    
     21
    2222    /**
    2323     * Set (or overwrite existing) parameters by passing an array of new parameters.
     
    5252        }
    5353    }
    54    
     54
    5555    /**
    5656     * Add a file-path to the array of files to include as CSS.
     
    6464    {
    6565        if (!is_array($apps)) {
    66             $apps = array($apps);
     66            $apps = array($apps);
    6767        }
    6868
     
    103103        sort($files_mtime, SORT_NUMERIC);
    104104        $latest_mtime = array_pop($files_mtime);
    105        
     105
    106106        if ($this->_params['cache_css']) {
    107107            header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $latest_mtime) . ' GMT');
     
    114114        header('Content-Type: text/css; charset=' . $this->_params['character_set']);
    115115    }
    116    
     116
    117117    /**
    118118     * Include CSS files specified by setFile().
     
    130130            return false;
    131131        }
    132        
     132
    133133        foreach ($this->_css_files[$app] as $file) {
    134134            include $file;
    135135        }
    136136    }
    137    
     137
    138138}
    139139?>
  • trunk/lib/Captcha.inc.php

    r41 r42  
    1 <?php 
     1<?php
    22/**
    33 * Captcha.inc.php
     
    1010 */
    1111class Captcha {
    12    
     12
    1313    var $secret_key = 'some random seed text for the md5';
    1414    var $ascii_numbers = array(
     
    9595        )
    9696    );
    97    
     97
    9898    /**
    9999     * Print ASCII number.
     
    109109        if (preg_match('/[^\d]/', $num)) {
    110110            App::logMsg(sprintf('Bad number: %s', $num), LOG_ERR, __FILE__, __LINE__);
    111             return false;
     111            return false;
    112112        }
    113        
     113
    114114        // Number must be an array of strings.
    115115        $num = preg_split('// ', strval($num), -1, PREG_SPLIT_NO_EMPTY);
     
    124124            $output .= "\n";
    125125        }
    126        
     126
    127127        return $output;
    128128    }
    129    
     129
    130130    /**
    131131     * Prints a form to enter captcha, including the required hidden hash form.
     
    148148        <?php
    149149    }
    150    
    151     /**
    152      * Validate submitted number against ascii captcha. 
     150
     151    /**
     152     * Validate submitted number against ascii captcha.
    153153     * Regenerate md5 hash from submitted captcha number and compare with posted hash.
    154154     *
     
    164164
    165165        if ('' == $number . $hash) {
    166             return false;
     166            return false;
    167167        }
    168168
     
    182182        return rand(1000, 9999);
    183183    }
    184        
     184
    185185    /**
    186186     * Generate md5 hash of number using secret key.
     
    196196        return md5($this->secret_key . $input);
    197197    }
    198    
     198
    199199}
    200200
  • trunk/lib/DB.inc.php

    r41 r42  
    99 * @version 1.0.1
    1010 */
    11  
     11
    1212class DB {
    1313
     
    3535        'db_die_on_failure' => false, // TRUE = script stops on db error.
    3636    );
    37    
     37
    3838    // Translate between HTML and MySQL character set names.
    3939    var $mysql_character_sets = array(
     
    4141        'iso-8859-1' => 'latin1',
    4242    );
    43    
     43
    4444    // Caches.
    4545    var $existing_tables;
    4646    var $table_columns;
    47    
     47
    4848    /**
    4949     * This method enforces the singleton pattern for this class.
     
    6363        return $instance;
    6464    }
    65    
     65
    6666    /**
    6767     * Constructor.
     
    119119        }
    120120    }
    121    
     121
    122122    /**
    123123     * Connect to database with credentials in params.
     
    132132            $this =& DB::getInstance();
    133133        }
    134        
     134
    135135        if (!$this->getParam('db_name') || !$this->getParam('db_user') || !$this->getParam('db_pass')) {
    136136            App::logMsg('Database credentials missing.', LOG_EMERG, __FILE__, __LINE__);
    137137            return false;
    138138        }
    139        
     139
    140140        // Connect to database. Always create a new link to the server.
    141         if ($this->dbh = mysql_connect($this->getParam('db_server'), $this->getParam('db_user'), $this->getParam('db_pass'), true)) {   
     141        if ($this->dbh = mysql_connect($this->getParam('db_server'), $this->getParam('db_user'), $this->getParam('db_pass'), true)) {
    142142            // Select database
    143143            mysql_select_db($this->getParam('db_name'), $this->dbh);
    144144        }
    145        
     145
    146146        // Test for connection errors.
    147147        if (!$this->dbh || mysql_error($this->dbh)) {
     
    164164            }
    165165        }
    166        
     166
    167167        // DB connection success!
    168168        $this->_connected = true;
     
    173173        return true;
    174174    }
    175    
     175
    176176    /**
    177177     * Close db connection.
     
    186186            $this =& DB::getInstance();
    187187        }
    188        
    189         if (!$this->_connected) {
    190             return false;
    191         }
    192 
    193         mysql_close($this->dbh);       
    194     }
    195    
     188
     189        if (!$this->_connected) {
     190            return false;
     191        }
     192
     193        mysql_close($this->dbh);
     194    }
     195
    196196    /**
    197197     * Return the current database handler.
     
    207207            $this =& DB::getInstance();
    208208        }
    209        
     209
    210210        if (!$this->_connected) {
    211211            return false;
     
    214214        return $this->dbh;
    215215    }
    216    
     216
    217217    /**
    218218     * Returns connection status
     
    226226        return $this->_connected;
    227227    }
    228    
     228
    229229    /**
    230230     * A wrapper for mysql_query. Allows us to set the database link_identifier,
     
    238238    {
    239239        static $_query_count = 0;
    240        
    241         if (!isset($this) || !is_a($this, 'DB')) {
    242             $this =& DB::getInstance();
    243         }
    244        
     240
     241        if (!isset($this) || !is_a($this, 'DB')) {
     242            $this =& DB::getInstance();
     243        }
     244
    245245        if (!$this->_connected) {
    246246           return false;
     
    252252            echo "<!-- ----------------- Query $_query_count ---------------------\n$debugqry\n-->\n";
    253253        }
    254        
     254
    255255        // Execute!
    256256        $qid = mysql_query($query, $this->dbh);
    257    
     257
    258258        // Error checking.
    259259        if (!$qid || mysql_error($this->dbh)) {
     
    269269            }
    270270        }
    271    
     271
    272272        return $qid;
    273273    }
    274274
    275275    /**
    276      * Loads a list of tables in the current database into an array, and returns 
     276     * Loads a list of tables in the current database into an array, and returns
    277277     * true if the requested table is found. Use this function to enable/disable
    278      * funtionality based upon the current available db tables or to dynamically 
     278     * funtionality based upon the current available db tables or to dynamically
    279279     * create tables if missing.
    280280     *
     
    284284     */
    285285    function tableExists($table, $use_cached_results=true)
    286     {   
    287         if (!isset($this) || !is_a($this, 'DB')) {
    288             $this =& DB::getInstance();
    289         }
    290        
     286    {
     287        if (!isset($this) || !is_a($this, 'DB')) {
     288            $this =& DB::getInstance();
     289        }
     290
    291291        if (!$this->_connected) {
    292292            return false;
     
    307307        }
    308308    }
    309    
     309
    310310    /**
    311311     * Tests if the given array of columns exists in the specified table.
     
    318318     */
    319319    function columnExists($table, $columns, $strict=true, $use_cached_results=true)
    320     {   
    321         if (!isset($this) || !is_a($this, 'DB')) {
    322             $this =& DB::getInstance();
    323         }
    324        
     320    {
     321        if (!isset($this) || !is_a($this, 'DB')) {
     322            $this =& DB::getInstance();
     323        }
     324
    325325        if (!$this->_connected) {
    326326            return false;
     
    331331            return false;
    332332        }
    333        
     333
    334334        // For single-value columns.
    335335        if (!is_array($columns)) {
    336336            $columns = array($columns);
    337337        }
    338        
     338
    339339        if (!isset($this->table_columns[$table]) || !$use_cached_results) {
    340340            // Populate and cache array of current columns for this table.
     
    345345            }
    346346        }
    347    
     347
    348348        if ($strict) {
    349349            // Do an exact comparison of table schemas.
     
    359359        }
    360360    }
    361    
     361
    362362    /**
    363363     * Reset cached items.
     
    372372        $this->table_columns = null;
    373373    }
    374    
     374
    375375} // End.
    376376
  • trunk/lib/DBSessionHandler.inc.php

    r41 r42  
    99
    1010class DBSessionHandler {
    11    
     11
    1212    var $db; // DB object.
    1313
     
    2020        'create_table' => true, // Automatically create table and verify columns. Better set to false after site launch.
    2121    );
    22    
     22
    2323    /**
    2424     * Constructor
    2525     *
    2626     * @access  public
    27      * @param   
    28      * @return 
     27     * @param
     28     * @return
    2929     * @author  Quinn Comendant <quinn@strangecode.com>
    3030     * @since   18 Jul 2005 11:02:50
     
    3333    {
    3434        $this->_params = array_merge($this->_params, $params);
    35        
     35
    3636        if (isset($db)) {
    3737            if (is_a($db, 'DB')) {
    38                 if ($db->isConnected()) {
     38                if ($db->isConnected()) {
    3939                    // Use existing db connection.
    4040                    $this->db =& $db;
    41                 } else {
     41                } else {
    4242                    App::logMsg(sprintf('Provided DB object is not connected. %s', mysql_error($db->dbh)), LOG_ERR, __FILE__, __LINE__);
    43                 }
     43                }
    4444            } else {
    4545                App::logMsg(sprintf('Provided DB object is not valid. %s', gettype($db)), LOG_ERR, __FILE__, __LINE__);
     
    4848            // Create our own new db connection.
    4949            require_once dirname(__FILE__) . '/DB.inc.php';
    50            
     50
    5151            $this->db =& new DB();
    5252            $this->db->setParam(array(
     
    5959                'db_die_on_failure' => $this->_params['db_die_on_failure'],
    6060            ));
    61            
     61
    6262            // Connect to database.
    6363            $this->db->connect();
     
    6767            trigger_error('Invalid DB object or unable to connect to database.', E_USER_ERROR);
    6868        }
    69        
     69
    7070        // Get create tables config from global context.
    7171        if (!is_null(App::getParam('db_create_tables'))) {
    7272            $this->_params['create_table'] = App::getParam('db_create_tables');
    7373        }
    74        
     74
    7575        // Ensure db table is fit.
    7676        $this->initDB();
    77        
     77
    7878        ini_set('session.save_handler', 'user');
    7979        session_set_save_handler(
     
    9797    {
    9898        static $_db_tested = false;
    99    
     99
    100100        if ($recreate_db || !$_db_tested && $this->_params['create_table']) {
    101101            if ($recreate_db) {
     
    110110                KEY last_access (last_access)
    111111            )");
    112            
     112
    113113            if (!$this->db->columnExists($this->_params['db_table'], array('session_id', 'session_data', 'last_access'))) {
    114114                App::logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->_params['db_table']), LOG_ALERT, __FILE__, __LINE__);
    115115                trigger_error(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->_params['db_table']), E_USER_ERROR);
    116116            }
    117         }   
     117        }
    118118        $_db_tested = true;
    119119    }
     
    121121    function dbSessionOpen($save_path, $sess_name)
    122122    {
    123         return true; 
     123        return true;
    124124    }
    125    
     125
    126126    function dbSessionClose()
    127127    {
    128128        return true;
    129129    }
    130    
     130
    131131    function dbSessionRead($session_id)
    132132    {
    133         // Select the data belonging to session $session_id from the session table   
     133        // Select the data belonging to session $session_id from the session table
    134134        $qid = $this->db->query("SELECT session_data FROM " . $this->_params['db_table'] . " WHERE session_id = '" . addslashes($session_id) . "'");
    135        
     135
    136136        // Return the session data that was found
    137137        if (mysql_num_rows($qid) == 1) {
     
    139139            return $row[0];
    140140        }
    141        
     141
    142142        // NOTICE: Output is expected to be an empty string always rather than 'false'.
    143143        return '';
    144144    }
    145    
     145
    146146    function dbSessionWrite($session_id, $session_data)
    147     {   
     147    {
    148148        // Write the serialized session data ($session_data) to the session table
    149149        $this->db->query("REPLACE INTO " . $this->_params['db_table'] . "(session_id, session_data, last_access) VALUES ('" . addslashes($session_id) . "', '" . addslashes($session_data) . "', null)");
    150            
    151         return true;     
     150
     151        return true;
    152152    }
    153    
     153
    154154    function dbSessionDestroy($session_id)
    155155    {
    156156        // Delete from the table all data for the session $session_id
    157157        $this->db->query("DELETE FROM " . $this->_params['db_table'] . " WHERE session_id = '" . addslashes($session_id) . "'");
    158    
    159         return true;     
     158
     159        return true;
    160160    }
    161    
     161
    162162    function dbSessionGarbage($max_lifetime=4000)
    163163    {
    164164        // Delete old values from the session table
    165165        $qid = $this->db->query("DELETE FROM " . $this->_params['db_table'] . " WHERE UNIX_TIMESTAMP(last_access) < " . (time() - $max_lifetime));
    166            
    167         return true;     
     166
     167        return true;
    168168    }
    169169}
  • trunk/lib/Email.inc.php

    r41 r42  
    4040        'regex' => null
    4141    );
    42    
     42
    4343    // String that contains the email body.
    4444    var $_template;
    45    
     45
    4646    // String that contains the email body after replacements.
    4747    var $_template_replaced;
     
    5858    {
    5959        // The regex used in validEmail(). Set here instead of in the default _params above so we can use the concatination . dot.
    60         // This matches an email address as complex as: 
     60        // This matches an email address as complex as:
    6161        //      Bob Smith <bob&smith's/dep=sales!@smith-wick.ca.us> (Sales department)
    6262        // ...and something as simple as:
    6363        //      x@x.com
    6464        $this->setParam(array('regex' => '/^(?:[^,@]*\s+|[^,@]*(<)|)'   // Display name
    65         . '((?:[^.<>\s@\",\[\]]+[^<>\s@\",\[\]])*[^.<>\s@\",\[\]]+)'    // Local-part 
     65        . '((?:[^.<>\s@\",\[\]]+[^<>\s@\",\[\]])*[^.<>\s@\",\[\]]+)'    // Local-part
    6666        . '@'                                                           // @
    6767        . '((?:(\[)|[A-Z0-9]?)'                                         // Domain, first char
     
    165165        }
    166166    }
    167    
     167
    168168    /**
    169169     * Replace variables in template with argument data.
     
    179179        if (!isset($this->_template)) {
    180180            App::logMsg(sprintf('Cannot replace variables, no template defined.', null), LOG_ERR, __FILE__, __LINE__);
    181             return false;
    182         }
    183        
     181            return false;
     182        }
     183
    184184        // Ensure replacements argument is an array.
    185185        if (!is_array($replacements)) {
    186186            App::logMsg(sprintf('Cannot replace variables, invalid replacements.', null), LOG_ERR, __FILE__, __LINE__);
    187             return false;
    188         }
    189        
     187            return false;
     188        }
     189
    190190        // Apply regex pattern to search elements.
    191191        $search = array_keys($replacements);
     
    194194        // Replacement values.
    195195        $replace = array_values($replacements);
    196        
     196
    197197        // Search and replace all values at once.
    198198        $this->_template_replaced = preg_replace($search, $replace, $this->_template);
     
    213213        // Use arguments if provided.
    214214        if (isset($to)) {
    215             $this->setParam(array('to' => $to));
     215            $this->setParam(array('to' => $to));
    216216        }
    217217        if (isset($from)) {
    218             $this->setParam(array('from' => $from));
     218            $this->setParam(array('from' => $from));
    219219        }
    220220        if (isset($subject)) {
    221             $this->setParam(array('subject' => $subject));
     221            $this->setParam(array('subject' => $subject));
    222222        }
    223223        if (isset($headers)) {
    224             $this->setParam(array('headers' => $headers));
     224            $this->setParam(array('headers' => $headers));
    225225        }
    226226
    227227        // Ensure required values exist.
    228228        if (!isset($this->_template)) {
    229             App::logMsg(sprintf('Cannot send email. Template not set.', null), LOG_ERR, __FILE__, __LINE__);
     229            App::logMsg(sprintf('Cannot send email. Template not set.', null), LOG_ERR, __FILE__, __LINE__);
    230230            return false;
    231231        } else if (!isset($this->_params['to'])) {
    232             App::logMsg(sprintf('Cannot send email. TO not defined.', null), LOG_ERR, __FILE__, __LINE__);
     232            App::logMsg(sprintf('Cannot send email. TO not defined.', null), LOG_ERR, __FILE__, __LINE__);
    233233            return false;
    234234        } else if (!isset($this->_params['from'])) {
    235             App::logMsg(sprintf('Cannot send email. FROM not defined.', null), LOG_ERR, __FILE__, __LINE__);
     235            App::logMsg(sprintf('Cannot send email. FROM not defined.', null), LOG_ERR, __FILE__, __LINE__);
    236236            return false;
    237237        } else if (!isset($this->_params['subject'])) {
    238             App::logMsg(sprintf('Cannot send email. SUBJECT not defined.', null), LOG_ERR, __FILE__, __LINE__);
     238            App::logMsg(sprintf('Cannot send email. SUBJECT not defined.', null), LOG_ERR, __FILE__, __LINE__);
    239239            return false;
    240240        }
     
    245245        // Ensure all placeholders have been replaced. Find anything with {...} characters.
    246246        if (preg_match('/({[^}]+})/', $final_body, $unreplaced_match)) {
    247             App::logMsg(sprintf('Cannot send email. Variables left unreplaced in template: %s', (isset($unreplaced_match[1]) ? $unreplaced_match[1] : '')), LOG_ERR, __FILE__, __LINE__);
    248             return false;
    249         }
    250        
     247            App::logMsg(sprintf('Cannot send email. Variables left unreplaced in template: %s', (isset($unreplaced_match[1]) ? $unreplaced_match[1] : '')), LOG_ERR, __FILE__, __LINE__);
     248            return false;
     249        }
     250
    251251        // Final "to" header can have multiple addresses if in an array.
    252252        $final_to = is_array($this->_params['to']) ? join(', ', $this->_params['to']) : $this->_params['to'];
    253        
     253
    254254        // From headers are custom headers.
    255255        $headers = array('From' => $this->_params['from']);
     
    259259            $headers = array_merge($this->_params['headers'], $headers);
    260260        }
    261        
     261
    262262        // Process headers.
    263263        $final_headers = array();
     
    266266        }
    267267        $final_headers = join("\r\n", $final_headers);
    268        
     268
    269269        // This is the address where delivery problems are sent to. We must strip off everything except the local@domain part.
    270270        $envelope_sender_header = sprintf('-f %s', preg_replace('/^.*<?([^\s@\[\]<>()]+\@[A-Za-z0-9.-]{1,}\.[A-Za-z]{2,5})>?$/iU', '$1', $this->_params['from']));
    271        
     271
    272272        // Check for mail header injection attacks.
    273273        $full_mail_content = join("\n", array($final_to, $this->_params['subject'], $final_body, $final_headers, $envelope_sender_header));
    274274        if (preg_match("/(Content-Type:|MIME-Version:|Content-Transfer-Encoding:|[\n\r]Bcc:|[\n\r]Cc:)/i", $full_mail_content)) {
    275             App::logMsg(sprintf('Mail header injection attack in content: %s', $full_mail_content), LOG_WARNING, __FILE__, __LINE__);
    276             sleep(3);
     275            App::logMsg(sprintf('Mail header injection attack in content: %s', $full_mail_content), LOG_WARNING, __FILE__, __LINE__);
     276            sleep(3);
    277277            return false;
    278278        }
     
    283283            return false;
    284284        }
    285        
     285
    286286        return true;
    287287    }
    288    
     288
    289289    /**
    290290     * Validates an email address based on the recommendations in RFC 3696.
    291      * Is more loose than restrictive, to allow the many valid variants of 
     291     * Is more loose than restrictive, to allow the many valid variants of
    292292     * email addresses while catching the most common mistakes. Checks an array too.
    293293     * http://www.faqs.org/rfcs/rfc822.html
  • trunk/lib/FormValidator.inc.php

    r41 r42  
    11<?php
    22/**
    3  * FormValidator.inc.php 
     3 * FormValidator.inc.php
    44 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information
    55 *
     
    2525class FormValidator
    2626{
    27    
     27
    2828    /**
    2929     * Array filling with errors. The key will be the name of the form where
     
    3131     */
    3232    var $errors = array();
    33    
     33
    3434    /**
    3535     * Return the current list of errors.
     
    4343        return $this->errors;
    4444    }
    45    
     45
    4646    /**
    4747     * Add an error to the errors stack.
     
    6464        );
    6565    }
    66    
     66
    6767    /**
    6868     * Check whether any errors have been triggered.
     
    7070     * @param  string $form_name the name of the incoming form variable
    7171     *
    72      * @return bool   true if any errors were found, or if found for 
     72     * @return bool   true if any errors were found, or if found for
    7373     *                a variable of $form_name, false otherwise
    7474     */
     
    7878            foreach ($this->errors as $err) {
    7979                if ($err['name'] == $form_name) {
    80                     return true;   
     80                    return true;
    8181                }
    8282            }
     
    115115                        echo '<div class="error">' . $err['message'] . '</div>';
    116116                        break;
    117            
     117
    118118                    case MSG_WARNING:
    119119                        echo '<div class="warning">' . $err['message'] . '</div>';
    120120                        break;
    121            
     121
    122122                    case MSG_SUCCESS:
    123123                        echo '<div class="success">' . $err['message'] . '</div>';
    124124                        break;
    125            
     125
    126126                    case MSG_NOTICE:
    127127                    default:
     
    134134        }
    135135    }
    136    
     136
    137137    /**
    138138     * If this form has an error, print an error marker like "<<".
     
    164164    function notEmpty($form_name, $msg='')
    165165    {
    166    
     166
    167167        $val = trim(getFormData($form_name));
    168168        if ($val != '') {
     
    184184    function isEmpty($form_name, $msg='')
    185185    {
    186    
     186
    187187        $val = trim(getFormData($form_name));
    188188        if ($val == '') {
     
    255255    /**
    256256     * Check whether input is a float. Don't just use is_float() because the
    257      * data coming from the user is *really* a string. Integers will also 
     257     * data coming from the user is *really* a string. Integers will also
    258258     * pass this test.
    259259     *
     
    293293        }
    294294    }
    295    
     295
    296296    /**
    297297     * Check whether input matches the specified perl regular expression
    298      * pattern. 
     298     * pattern.
    299299     *
    300300     * @param  string $form_name the name of the incoming form variable
     
    325325        }
    326326    }
    327    
     327
    328328    /**
    329329     * Tests if the string length is between specified values. Whitespace excluded for min.
     
    339339    {
    340340        $val = getFormData($form_name);
    341        
     341
    342342        if (strlen(trim($val)) < $min || strlen($val) > $max) {
    343343            $this->addError($form_name, $msg);
     
    375375    /**
    376376     * Validates an email address based on the recommendations in RFC 3696.
    377      * Is more loose than restrictive, to allow the many valid variants of 
     377     * Is more loose than restrictive, to allow the many valid variants of
    378378     * email addresses while catching the most common mistakes.
    379379     * http://www.faqs.org/rfcs/rfc822.html
     
    403403            return false;
    404404        }
    405        
     405
    406406        // We have a match! Here are the captured subpatterns, on which further tests are run.
    407407        $local = $e_parts[2];
     
    415415            return false;
    416416        }
    417        
     417
    418418        // Check domain exists: It's a domain if ip2long fails; Checkdnsrr ensures a MX record exists; Gethostbyname() ensures the domain exists.
    419419        if (ip2long($domain) == '-1' && function_exists('checkdnsrr') && !checkdnsrr($domain . '.', 'MX') && gethostbyname($domain) == $domain) {
     
    422422            return false;
    423423        }
    424        
     424
    425425        return true;
    426426    }
     
    431431//             return false;
    432432//         }
    433 //         
     433//
    434434//         // Test email address format.
    435435//         if ($allow_fullname) {
     
    444444//             }
    445445//         }
    446 //         
     446//
    447447//         // Test length.
    448448//         if (!$this->stringLength($form_name, 0, 255, sprintf(_("<strong>Email address</strong> must contain less than 256 characters."), $email))) {
     
    450450//             return false;
    451451//         }
    452 //         
     452//
    453453//         // Check domain exists and has valid MX record.
    454454//         preg_match('/^[^<>@]*<?[^\s@\[\]<>()]+\@([A-Za-z0-9.-]+\.[A-Za-z]{2,5})>?$/i', $email, $matches);
     
    460460//             }
    461461//         }
    462 //         
     462//
    463463//         return true;
    464464//     }
     
    476476    {
    477477        $phone = getFormData($form_name);
    478        
     478
    479479        return $this->checkRegex($form_name, '/^[0-9 +().-]*$/', true, sprintf(_("The phone number <strong>%s</strong> is not valid."), $phone))
    480480        && $this->stringLength($form_name, 0, 25, sprintf(_("The phone number <strong>%s</strong> is too long"), $phone));
     
    499499        }
    500500    }
    501    
    502    
     501
     502
    503503    /**
    504504     * Verifies credit card number.
     
    515515            $cc_num = getFormData($form_name);
    516516        }
    517        
     517
    518518        if ('' == $cc_num) {
    519519            return false;
    520520        }
    521        
     521
    522522        // Innocent until proven guilty
    523523        $card_is_valid = true;
    524    
     524
    525525        // Get rid of any non-digits
    526526        $cc_num = preg_replace('/[^\d]/', '', $cc_num);
    527    
     527
    528528        // Perform card-specific checks, if applicable
    529529        switch (strtolower($cc_type)) {
     
    558558                break;
    559559        }
    560    
     560
    561561        // The Luhn formula works right to left, so reverse the number.
    562562        $cc_num = strrev($cc_num);
    563        
     563
    564564        $luhn_total = 0;
    565565
     
    573573                $digit *= 2;
    574574            }
    575    
     575
    576576            //  If the result is two digits, add them.
    577577            if (strlen($digit) == 2) {
    578578                $digit = substr($digit,0,1) + substr($digit,1,1);
    579579            }
    580    
     580
    581581            //  Add the current digit to the $luhn_total.
    582582            $luhn_total += $digit;
    583583        }
    584    
     584
    585585        // If it passed (or bypassed) the card-specific check and the Total is evenly divisible by 10, it's cool!
    586586        if ($card_is_valid && $luhn_total % 10 == 0) {
     
    609609        }
    610610    }
    611    
     611
    612612} // THE END
    613613
  • trunk/lib/Google_API.inc.php

    r41 r42  
    99
    1010// Example of use:
    11 // 
     11//
    1212// require_once 'Google_API.php';
    1313// $google = new Google_API('your license key');
     
    4040     */
    4141    var $_licenseKey = '';
    42    
     42
    4343    /**
    4444     * @var    object
     
    4646     */
    4747    var $_soapClient = NULL;
    48    
     48
    4949    /**
    5050     * Constructor.
     
    6060        );
    6161    }
    62    
     62
    6363    /**
    6464     * Retrieves a page by URL from the Google Cache.
     
    8282        return $result;
    8383    }
    84    
     84
    8585    /**
    8686     * Retrieves a spelling suggestion for a phrase.
     
    100100        );
    101101    }
    102    
     102
    103103    /**
    104104     * Performs a web search.
     
    129129        );
    130130    }
    131    
     131
    132132    /**
    133133     * @param  string
     
    149149        }
    150150    }
    151    
     151
    152152    /**
    153153     * getFault
     
    155155     * returns a simple native php array containing the fault data
    156156     *
    157      * @return array 
     157     * @return array
    158158     * @access public
    159159     */
  • trunk/lib/ImageThumb.inc.php

    r41 r42  
    11<?php
    22/**
    3  * ImageThumb.inc.php 
     3 * ImageThumb.inc.php
    44 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information
    55 */
     
    2020
    2121class ImageThumb {
    22    
     22
    2323    // The location for images to create thumbnails from.
    2424    var $source_dir = null;
    25    
     25
    2626    // Specifications for thumbnail images.
    27     var $spec; 
    28    
     27    var $spec;
     28
    2929    // Array of acceptable file extensions (lowercase).
    3030    var $valid_file_extensions = array('jpg', 'jpeg', 'gif', 'png');
    31    
    32     // The uploaded files will be owned by user 'apache'. Set world-read/write 
     31
     32    // The uploaded files will be owned by user 'apache'. Set world-read/write
    3333    // if the website admin needs to read/delete these files. Must be at least 0400 with owner=apache.
    3434    var $dest_file_perms = 0644;
    35    
     35
    3636    // Must be at least 0700 with owner=apache.
    3737    var $dest_dir_perms = 0777;
     
    4242    var $cjpeg_binary = '/usr/bin/cjpeg';
    4343    var $_valid_binaries = true;
    44    
     44
    4545    // Display messages raised in this object?
    4646    var $display_messages = true;
     
    7676    function setSourceDirectory($source_dir)
    7777    {
    78        
     78
    7979        // Set the source directory path, stripping any extra slashes if needed.
    8080        $this->source_dir = preg_replace('!/+$!', '', $source_dir);
    81        
     81
    8282        if (!is_dir($this->source_dir)) {
    8383            App::logMsg(sprintf('ImageThumb error: source directory not found: %s', $this->source_dir), LOG_ERR, __FILE__, __LINE__);
     
    108108        $allow_upscaling = isset($spec['allow_upscaling']) ? $spec['allow_upscaling'] : false;
    109109        $keep_filesize   = isset($spec['keep_filesize']) ? $spec['keep_filesize'] : null;
    110    
     110
    111111        // Define pnmscale arguments.
    112112        switch ($scaling_type) {
     
    144144            break;
    145145        }
    146        
     146
    147147        // Define cjpeg arguments.
    148148        $cjpeg_args = sprintf(' -optimize -quality %s ', escapeshellcmd($quality));
    149149        $cjpeg_args .= (true === $progressive) ? ' -progressive ' : '';
    150        
     150
    151151        $this->spec[] = array(
    152152            'dest_dir' => $dest_dir,
     
    185185            }
    186186        }
    187                
     187
    188188        // If > 0, there was a problem creating dest dirs.
    189189        return (0 == $return_val);
     
    203203            return false;
    204204        }
    205        
     205
    206206        // Ensure we have a source.
    207207        if (!isset($this->source_dir)) {
     
    209209            return false;
    210210        }
    211        
     211
    212212        // To keep this script running even if user tries to stop browser.
    213         ignore_user_abort(true); 
    214         if (!ini_get('safe_mode')) { 
    215             set_time_limit(300); 
    216         }
    217        
     213        ignore_user_abort(true);
     214        if (!ini_get('safe_mode')) {
     215            set_time_limit(300);
     216        }
     217
    218218        // Confirm source image exists.
    219219        if (!file_exists($this->source_dir . '/' . $file_name)) {
     
    222222            return false;
    223223        }
    224        
     224
    225225        // Confirm source image is readable.
    226226        if (!is_readable($this->source_dir . '/' . $file_name)) {
     
    229229            return false;
    230230        }
    231        
     231
    232232        // Confirm source image contains data.
    233233        if (filesize($this->source_dir . '/' . $file_name) < 1) {
     
    236236            return false;
    237237        }
    238        
     238
    239239        // Confirm source image has a valid file extension.
    240240        if (!$this->validFileExtension($file_name)) {
     
    243243            return false;
    244244        }
    245        
     245
    246246        // Output file will be a jpg. Set file extension.
    247247        $file_name = substr($file_name, 0, strrpos($file_name, '.')) . '.jpg';
     
    249249        // This remains zero until something goes wrong.
    250250        $final_return_val = 0;
    251        
     251
    252252        foreach ($this->spec as $s) {
    253        
     253
    254254            // Skip existing thumbnails with file size below $s['keep_filesize'].
    255255            if (file_exists(realpath($this->source_dir . '/' . $s['dest_dir'] . '/' . $file_name)) && isset($s['keep_filesize'])) {
     
    260260                }
    261261            }
    262            
     262
    263263            // Determine if original file size is smaller than specified thumbnail size. Do not scale-up if allow_upscaling config is set to false.
    264264            $image_size = getimagesize(realpath($this->source_dir . '/' . $file_name));
     
    269269                $pnmscale_args = $s['pnmscale_args'];
    270270            }
    271            
     271
    272272            // Execute the command that creates the thumbnail.
    273273            $command = sprintf('%s %s/%s | %s %s | %s %s > %s/%s',
     
    278278                escapeshellcmd($pnmscale_args),
    279279                escapeshellcmd($this->cjpeg_binary),
    280                 escapeshellcmd($s['cjpeg_args']), 
     280                escapeshellcmd($s['cjpeg_args']),
    281281                escapeshellcmd(realpath($this->source_dir . '/' . $s['dest_dir'])),
    282282                escapeshellcmd($file_name)
     
    292292                App::logMsg(sprintf('Image %s failed resizing with return value: %s%s', $s['dest_dir'] . '/' . $file_name, $return_val, empty($output) ? '' : ' (' . getDump($output) . ')'), LOG_ERR, __FILE__, __LINE__);
    293293            }
    294            
     294
    295295            // Return from the command will be > 0 if there was an error.
    296296            $final_return_val += $return_val;
    297297        }
    298        
     298
    299299        // If > 0, there was a problem thumbnailing.
    300300        return (0 == $final_return_val);
     
    314314            return false;
    315315        }
    316        
     316
    317317        // Get all files in source directory.
    318318        $dir_handle = opendir($this->source_dir);
     
    323323            }
    324324        }
    325        
     325
    326326        // Process each found file.
    327327        if (is_array($files) && !empty($files)) {
     
    350350            return false;
    351351        }
    352        
     352
    353353        $ret = 0;
    354354        foreach ($this->spec as $s) {
     
    379379            return false;
    380380        }
    381        
     381
    382382        $file_path_name = $this->source_dir . '/' . $file_name;
    383383        if (!unlink($file_path_name)) {
     
    388388        return true;
    389389    }
    390    
     390
    391391    /**
    392392     * Returns true if file exists.
     
    403403            return false;
    404404        }
    405        
     405
    406406        return file_exists($this->source_dir . '/' . $file_name);
    407407    }
    408    
     408
    409409    /**
    410410     * Tests if extention of $file_name is in the array valid_file_extensions.
     
    419419        return in_array(strtolower($ext[1]), $this->valid_file_extensions);
    420420    }
    421    
     421
    422422    /**
    423423     * An alias for App::raiseMsg that only sends messages if display_messages is true.
  • trunk/lib/MCVE.inc.php

    r41 r42  
    1919    var $connected = false;
    2020    var $conn;
    21    
     21
    2222    function MCVE($username, $password)
    2323    {
     
    2828        }
    2929        if ('' == $username || '' == $password) {
    30             App::logMsg(sprintf('Empty username or password provided.', null), LOG_ERR, __FILE__, __LINE__);
     30            App::logMsg(sprintf('Empty username or password provided.', null), LOG_ERR, __FILE__, __LINE__);
    3131        }
    3232        $this->username = $username;
     
    3939            return true;
    4040        }
    41        
     41
    4242        // Initialize SSL structures and definitions.
    4343        MCVE_InitEngine($ca_bundle_file);
    44        
     44
    4545        // Allocate Connection Structures
    4646        $this->conn = MCVE_InitConn();
    47        
     47
    4848        // Set Connection Method and Locations
    4949        switch ($this->connect_method) {
     
    6969            App::logMsg('Connection method not defined.', LOG_ERR, __FILE__, __LINE__);
    7070        }
    71        
     71
    7272        // Put connection into non-blocking mode, meaning that the client must
    7373        // loop waiting for the transaction to complete. You should always specify
     
    7878            return false;
    7979        }
    80        
     80
    8181        // Maximum of 30s per transaction allowed. Timeout occurs on server-end, not client-end
    8282        if (!MCVE_SetTimeout($this->conn, $this->timeout)) {
     
    8484            return false;
    8585        }
    86        
     86
    8787        // Connect to MCVE, if there's an error, print the exact reason for connection failure
    8888        if (!MCVE_Connect($this->conn)) {
     
    9191            return false;
    9292        }
    93        
     93
    9494        $this->connected = true;
    9595    }
    96    
     96
    9797    function beginTrans()
    9898    {
     
    103103        return $tid;
    104104    }
    105    
     105
    106106    function transParam($tid, $key, $var1, $var2=null)
    107107    {
     
    111111            return MCVE_TransParam($this->conn, $tid, $key, $var1, $var2);
    112112        }
    113        
     113
    114114    }
    115    
     115
    116116    function sendTrans($tid, $type='', $hide_msg=false)
    117117    {
     
    121121            return false;
    122122        }
    123        
    124         // Perform actual communication with MCVE engine. 
     123
     124        // Perform actual communication with MCVE engine.
    125125        // If blocking method is used, loop until transaction is complete
    126126        if ($this->blocking != 1) {
     
    130130            }
    131131        }
    132        
     132
    133133        $ret_status = MCVE_ReturnStatus($this->conn, $tid);
    134134        $ret_code = MCVE_ReturnCode($this->conn, $tid);
    135135        $ret_text = mcve_text_code($ret_code);
    136136        $verbiage = MCVE_TransactionText($this->conn, $tid);
    137    
     137
    138138        // Check to see if transaction was successful or not using a strict success/fail function
    139139        if ($ret_status == MCVE_FAIL) {
     
    144144                App::raiseMsg(sprintf(_("MCVE %s success: %s %s"), $type, $ret_text, ('' == $verbiage ? '' : '(' . trim($verbiage) . ')')), MSG_SUCCESS, __FILE__, __LINE__);
    145145            }
    146             App::logMsg(sprintf(_("MCVE success details. Auth: %s; Batch: %s; Item: %s; TTID: %s; AVS: %s; CV: %s."), 
     146            App::logMsg(sprintf(_("MCVE success details. Auth: %s; Batch: %s; Item: %s; TTID: %s; AVS: %s; CV: %s."),
    147147                MCVE_TransactionAuth($this->conn, $tid),
    148148                MCVE_TransactionBatch($this->conn, $tid),
     
    158158        }
    159159    }
    160    
     160
    161161    function disconnect($tid)
    162162    {
     
    165165            // MCVE_DestroyConn though
    166166            MCVE_DeleteTrans($this->conn, $tid);
    167            
     167
    168168            // Clean up and close MCVE.
    169169            MCVE_DestroyConn($this->conn);
    170170            MCVE_DestroyEngine();
    171            
     171
    172172            $this->connected = false;
    173173        }
  • trunk/lib/Nav.inc.php

    r41 r42  
    33 * The Nav:: class provides a system for working with navigation elements.
    44 * Currently it supports storing page titles and URLs for printing breadcrumbs
    5  * and titles, as well as setting page features such as hiding the page title on 
     5 * and titles, as well as setting page features such as hiding the page title on
    66 * some pages but not others.
    77 *
     
    6060        );
    6161    }
    62    
     62
    6363    /**
    6464     * Set the features of the current page. Future versions of this class
     
    7373    {
    7474        $page_id = $this->_calculatePageID($page_id);
    75        
     75
    7676        if (isset($features) && is_array($features) && isset($this->pages[sizeof($this->pages)-1]['features']) && is_array($this->pages[sizeof($this->pages)-1]['features'])) {
    7777            // Set features for specified page.
     
    9696 * OUTPUT
    9797 *****************************************************************************/
    98  
     98
    9999    /**
    100100     * Get the value of a feature for specified page_id or current page if page_id not specified (future use).
     
    108108    {
    109109        $page_id = $this->_calculatePageID($page_id);
    110        
     110
    111111        if (isset($this->pages[$page_id]['features'][$feature])) {
    112112            switch ($feature) {
     
    123123    }
    124124
    125        
     125
    126126    /**
    127127     * Returns the title of current page.
     
    134134    {
    135135        $page_id = $this->_calculatePageID($page_id);
    136        
     136
    137137        if ($this->getFeature('title', $page_id)) {
    138138            return oTxt($this->pages[$page_id]['title'], true);
     
    163163    {
    164164        $page_id = $this->_calculatePageID($page_id);
    165        
     165
    166166        if ($this->getFeature('path', $page_id)) {
    167167            $path = '';
     
    202202    {
    203203        $page_id = $this->_calculatePageID($page_id);
    204        
     204
    205205        if ($this->getFeature('breadcrumbs')) {
    206206            $breadcrumbs = '';
     
    232232                $pathmark = $this->path_delimiter;
    233233                $crumb_count--;
    234                
     234
    235235                if ($curr_id === $page_id) {
    236236                    // Reached requested page.
     
    253253        echo $this->getBreadcrumbs($page_id);
    254254    }
    255    
     255
    256256    /**
    257257     * Returns a string if the queried page is the current page. One use is to print
     
    272272        }
    273273    }
    274    
     274
    275275    /**
    276276     * Returns the ID of the current page, or the adjusted ID for a given page ID.
     
    289289        }
    290290    }
    291    
    292 } 
     291
     292}
    293293// End of class.
    294294
  • trunk/lib/NodeHeirarchy.inc.php

    r41 r42  
    11<?php
    22/**
    3  * NodeHeirarchy.inc.php 
     3 * NodeHeirarchy.inc.php
    44 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information
    55 */
     
    2323 * @version   1.0
    2424 */
    25  
     25
    2626class NodeHeirarchy {
    2727
     
    5050
    5151    /**
    52      * Boolean indicating whether or not we've set 
     52     * Boolean indicating whether or not we've set
    5353     * the 'active' node type and id.
    5454     * @var bool $node_init
    5555     */
    5656    var $node_init = false;
    57    
     57
    5858    /**
    5959     * Constructor
     
    6666        $this->params = $params;
    6767    }
    68    
     68
    6969    /**
    7070     * Defines the default child_type and child_id for this object.
     
    8585        return $this->toStringID($old_type, $old_id);
    8686    }
    87    
     87
    8888    /**
    8989     * Takes a node type and id and returns them as a serialized identifier like
     
    121121        }
    122122    }
    123    
     123
    124124    /**
    125125     * Takes a singlar node identifier and returns it as components of an array.
     
    156156            }
    157157        }
    158        
     158
    159159        // Make sure this is not empty and an array, even if it has only one value.
    160160        if ('' == $parents) {
     
    165165            $parents = array($parents);
    166166        }
    167        
     167
    168168        // Remove duplicates.
    169169        $parents = array_unique($parents);
    170                
     170
    171171        // Test that this node does not already exist and that the new parents
    172172        // do exist before we continue.
     
    182182                App::logMsg(sprintf(_("Cannot add node <strong>%s %s</strong> to nonexistent parent <strong>%s %s</strong>."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), LOG_ERR, __FILE__, __LINE__);
    183183                return false;
    184             }   
    185         }
    186        
     184            }
     185        }
     186
    187187        // Insert new nodes with the new parents.
    188188        foreach ($parents as $parent_string) {
     
    190190            DB::query("
    191191                INSERT INTO node_tbl (
    192                     parent_type, 
    193                     parent_id, 
    194                     child_type, 
    195                     child_id, 
     192                    parent_type,
     193                    parent_id,
     194                    child_type,
     195                    child_id,
    196196                    relationship_type,
    197197                    title
    198198                ) VALUES (
    199                     '" . addslashes($parent['node_type']) . "', 
    200                     '" . addslashes($parent['node_id']) . "', 
    201                     '" . addslashes($child_type) . "', 
    202                     '" . addslashes($child_id) . "', 
     199                    '" . addslashes($parent['node_type']) . "',
     200                    '" . addslashes($parent['node_id']) . "',
     201                    '" . addslashes($child_type) . "',
     202                    '" . addslashes($child_id) . "',
    203203                    " . (is_null($relationship_type) ? "NULL" : "'" . addslashes($relationship_type) . "'") . ",
    204204                    '" . addslashes($title) . "'
     
    267267     *
    268268     * @return bool      false on error, true otherwise.
    269      */     
     269     */
    270270    function moveNode($new_parents=null, $child_type=null, $child_id=null, $relationship_type=null, $title='')
    271271    {
     
    279279            }
    280280        }
    281        
     281
    282282        // Make sure this is not empty and an array, even if it has only one value.
    283283        if (empty($new_parents)) {
     
    288288            $new_parents = array($new_parents);
    289289        }
    290        
     290
    291291        // Remove duplicates.
    292292        $new_parents = array_unique($new_parents);
     
    299299                App::logMsg(sprintf(_("Cannot move node <strong>%s %s</strong> to nonexistent parent <strong>%s %s</strong>."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), LOG_ERR, __FILE__, __LINE__);
    300300                return false;
    301             }   
     301            }
    302302            if ($this->isAncestor($child_type, $child_id, $parent['node_type'], $parent['node_id'])) {
    303303                App::raiseMsg(sprintf(_("Cannot move node <strong>%s %s</strong> to parent <strong>%s %s</strong> because a node cannot have itself as a parent."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), MSG_ERR, __FILE__, __LINE__);
    304304                App::logMsg(sprintf(_("Cannot move node <strong>%s %s</strong> to parent <strong>%s %s</strong> because a node cannot have itself as a parent."), $child_type, $child_id, $parent['node_type'], $parent['node_id']), LOG_ERR, __FILE__, __LINE__);
    305305                return false;
    306             }   
    307         }
    308        
     306            }
     307        }
     308
    309309        if (empty($title)) {
    310310            // Select the title of the node we are moving, so we can add it again with the same info.
     
    317317            list($title) = mysql_fetch_row($qid);
    318318        }
    319        
     319
    320320        // Delete the nodes with the old parents.
    321321        DB::query("
     
    326326        ");
    327327        App::logMsg(sprintf('moveNode: Deleted node %s %s.', $child_type, $child_id), LOG_DEBUG, __FILE__, __LINE__);
    328        
     328
    329329        // Insert new nodes with the new parents.
    330330        $this->insertNode($new_parents, $child_type, $child_id, $relationship_type, $title);
    331        
     331
    332332        return true;
    333333    }
     
    356356        $qid = DB::query("
    357357            SELECT parent_type, parent_id
    358             FROM node_tbl 
     358            FROM node_tbl
    359359            WHERE child_type = '" . addslashes($child_type) . "'
    360             AND child_id = '" . addslashes($child_id) . "' 
     360            AND child_id = '" . addslashes($child_id) . "'
    361361        ");
    362        
     362
    363363        $parents = array();
    364364        while ($row = mysql_fetch_assoc($qid)) {
     
    391391            }
    392392        }
    393        
     393
    394394        $qid = DB::query("
    395395            SELECT child_type, child_id, title, subnode_quantity
    396             FROM node_tbl 
     396            FROM node_tbl
    397397            WHERE child_type = '" . addslashes($child_type) . "'
    398398            AND child_id = '" . addslashes($child_id) . "'
    399399        ");
    400        
     400
    401401        $children = array();
    402402        while ($row = mysql_fetch_assoc($qid)) {
     
    432432            }
    433433        }
    434        
     434
    435435        $in_clause = '';
    436436        if (isset($type_constraint)) {
     
    440440            $in_clause = "AND child_type IN ('" . join("','", array_map('addslashes', $type_constraint)) . "')";
    441441        }
    442        
     442
    443443        $qid = DB::query("
    444444            SELECT *
    445             FROM node_tbl 
     445            FROM node_tbl
    446446            WHERE parent_type = '" . addslashes($child_type) . "'
    447447            AND parent_id = '" . addslashes($child_id) . "'
     
    449449            " . addslashes($order) . "
    450450        ");
    451        
     451
    452452        $children = array();
    453453        while ($row = mysql_fetch_assoc($qid)) {
     
    464464     * Give the number of children a category has. We are talking about the
    465465     * direct children, on the next level.
    466      * 
     466     *
    467467     * @param string optional $parent The name of the parent from where we begin.
    468468     * @param string $type_constraint  An array of node types to restrict the search to.
     
    481481            }
    482482        }
    483        
     483
    484484        $in_clause = '';
    485485        if (isset($type_constraint)) {
     
    492492        $qid = DB::query("
    493493            SELECT COUNT(*)
    494             FROM node_tbl 
     494            FROM node_tbl
    495495            WHERE parent_type = '" . addslashes($child_type) . "'
    496496            AND parent_id = '" . addslashes($child_id) . "'
     
    519519            }
    520520        }
    521        
     521
    522522        if ($this->getNumberChildren($child_type, $child_id) <= 0) {
    523523            return true;
     
    544544        $family_tree = $this->getAllAncestors($considered_parent_type, $considered_parent_id);
    545545        $family_tree = $this->toStringID($family_tree, -1);
    546        
     546
    547547        if (in_array($this->toStringID($child_type, $child_id), $family_tree)) {
    548548            return true;
     
    571571        static $output = array();
    572572        static $return_flag;
    573        
     573
    574574        $qid = DB::query("
    575575            SELECT parent_type, parent_id, child_type, child_id, title, subnode_quantity
     
    583583                continue;
    584584            }
    585            
     585
    586586            // Build a linear path to root...no wormholes.
    587587            if ($enough_already && $go_linear) {
     
    589589            }
    590590            $enough_already = true;
    591            
     591
    592592            // To prevent duplicates, only add the new found node
    593593            // if not already in the array of ancestors.
     
    596596                $output[] = $row;
    597597            }
    598            
     598
    599599            $this->getAllAncestors($row['parent_type'], $row['parent_id'], $go_linear, false);
    600600        }
     
    630630            }
    631631        }
    632        
     632
    633633        if (isset($parent_type) && isset($parent_id)) {
    634634            $qid = DB::query("
     
    665665     * @param  string  $order            SQL to append to the query of the getChildren
    666666     *                                   call. Ex: 'ORDER BY child_id DESC'
    667      * @return array  Details of from the node table of all nodes below the 
     667     * @return array  Details of from the node table of all nodes below the
    668668     *                specified node: (type, id, title, indent level, selected status)
    669669     */
     
    672672        static $output = array();
    673673        static $is_a_leaf = array();
    674        
     674
    675675        if (!isset($child_type) || !isset($child_id)) {
    676676            if ($this->node_init) {
     
    682682            }
    683683        }
    684        
     684
    685685        if (!is_array($preselected)) {
    686686            $preselected = array($preselected);
    687687        }
    688        
     688
    689689        if ($_return_flag && $include_curr) {
    690690            $my_children = $this->getNode($child_type, $child_id);
     
    709709                $output[] = $row;
    710710                unset($row);
    711                
     711
    712712                // This is so we test if each node is a string only once. We store the result in the is_a_leaf array statically.
    713713                if (!isset($is_a_leaf[$this->toStringID($my_children[$i]['child_type'], $my_children[$i]['child_id'])])) {
     
    731731
    732732    }
    733    
    734    
     733
     734
    735735    /**
    736736     * Counts the number of items linked to each parent node
     
    744744        // Reset all the category counters to zero.
    745745        DB::query("UPDATE node_tbl SET subnode_quantity = 0");
    746        
     746
    747747        // Get all the nodes.
    748748        $qid = DB::query("SELECT DISTINCT child_type, child_id FROM node_tbl");
    749        
     749
    750750        // For each node count the number of children...
    751751        while (list($child_type, $child_id) = mysql_fetch_row($qid)) {
     
    757757        }
    758758    }
    759    
     759
    760760    /**
    761761     * Used internally by setSubnodeQty to add the quantity of subnodes to
     
    772772        $qid = DB::query("
    773773            SELECT parent_type, parent_id
    774             FROM node_tbl 
     774            FROM node_tbl
    775775            WHERE child_type = '" . addslashes($child_type) . "'
    776             AND child_id = '" . addslashes($child_id) . "' 
     776            AND child_id = '" . addslashes($child_id) . "'
    777777        ",false);
    778778        while ((list($parent_type, $parent_id) = mysql_fetch_row($qid)) && $parent_id > 0) {
  • trunk/lib/PEdit.inc.php

    r41 r42  
    22/**
    33 * PEdit:: provides a mechanism to store text in php variables
    4  * which will be printed to the client browser under normal 
     4 * which will be printed to the client browser under normal
    55 * circumstances, but an authenticated user can 'edit' the document--
    66 * data stored in vars will be shown in html form elements to be editied
     
    1616 *  require_once 'codebase/lib/PEdit.inc.php';
    1717 *  $p = new PEdit($auth->hasClearance('pedit'));
    18  * 
     18 *
    1919 *  $title = <<<P_E_D_I_T_title
    2020 *  Using Burritos to Improve Student Learnin'
    2121 *  P_E_D_I_T_title;
    2222 *  $p->set($title, 'title', 'textbox');
    23  * 
     23 *
    2424 *  // Begin content. Include a header or something right here.
    2525 *  $p->printContent('title');
    26  * 
     26 *
    2727 *  // Prints beginning form tags and special hidden forms. (Only happens if page is NOT a archived version.)
    2828 *  $p->formBegin();
    29  * 
     29 *
    3030 *  // Print editing form elements. (Only happens if op == Edit.)
    3131 *  $p->printForm('title');
    32  * 
     32 *
    3333 *  // Print versions list. (Only happens if op == Versions.)
    3434 *  $p->printVersions();
    35  * 
     35 *
    3636 *  // Prints ending form tags and command buttons.(Only happens if page is NOT a archived version.)
    3737 *  $p->formEnd();
    3838 *
    39  * @author  Quinn Comendant <quinn@strangecode.com> 
    40  * @concept Beau Smith <beau@beausmith.com> 
     39 * @author  Quinn Comendant <quinn@strangecode.com>
     40 * @concept Beau Smith <beau@beausmith.com>
    4141 * @version 1.1
    4242 */
     
    5151    // Tags that are not stripped from the POSTed data.
    5252    var $allowed_tags = '<p><h1><h2><h3><h4><h5><h6><div><br><hr><a><img><i><em><b><strong><small><blockquote><ul><ol><li><dl><dt><dd><map><area><table><tr><td>';
    53    
    54    
    55     /** 
     53
     54
     55    /**
    5656     * Constructs a new PEdit object. Initializes what file is being operated on
    57      * (SCRIPT_FILENAME) and what that operation is. The two 
     57     * (SCRIPT_FILENAME) and what that operation is. The two
    5858     * operations that actually modify data (save, restore) are treated differently
    5959     * than view operations (versions, '' - default). They die redirect so you see
    6060     * the page you just modified.
    61      * 
    62      * @access public 
    63      * 
    64      * @param optional array $params  A hash containing connection parameters. 
    65      */ 
     61     *
     62     * @access public
     63     *
     64     * @param optional array $params  A hash containing connection parameters.
     65     */
    6666    function PEdit($authorized=false)
    6767    {
     
    6969            $this->_authorized = true;
    7070        }
    71        
     71
    7272        $this->_filename = $_SERVER['SCRIPT_FILENAME'];
    7373        if (empty($this->_filename)) {
     
    7575            die;
    7676        }
    77        
     77
    7878        $this->op = getFormData('op');
    79        
     79
    8080        switch ($this->op) {
    8181        case 'Save' :
     
    9191        }
    9292    }
    93    
     93
    9494    /**
    9595     * Stores a variable in the pedit data array with the content name, and type of form.
    96      * 
    97      * @access public 
    98      * 
     96     *
     97     * @access public
     98     *
    9999     * @param string $content         The variable containing the text to store.
    100      * @param string $name            The name of the variable. 
    101      * @param string $type            The type of form element to use. 
    102      * @param optional int $form_size The size of the form element. 
     100     * @param string $name            The name of the variable.
     101     * @param string $type            The type of form element to use.
     102     * @param optional int $form_size The size of the form element.
    103103     */
    104104    function set($content, $name, $type, $form_size=null)
    105105    {
    106106        $this->_data[$name] = array(
    107             'type' => $type, 
    108             'content' => $content, 
     107            'type' => $type,
     108            'content' => $content,
    109109            'form_size' => $form_size
    110110        );
    111111    }
    112    
     112
    113113    /**
    114114     * Stores a checkbox variable in the pedit data array with the content name, and type of form.
    115      * 
    116      * @access public 
    117      * 
     115     *
     116     * @access public
     117     *
    118118     * @param string $content            The variable containing the text to store.
    119      * @param string $name               The name of the variable. 
    120      * @param string $corresponding_text The text that corresponds to this checkbox. 
     119     * @param string $name               The name of the variable.
     120     * @param string $corresponding_text The text that corresponds to this checkbox.
    121121     */
    122122    function setCheckbox($content, $name, $corresponding_text)
     
    124124        if (isset($content) && isset($name) && isset($corresponding_text)) {
    125125            $this->_data[$name] = array(
    126                 'type' => 'checkbox', 
    127                 'content' => $content, 
     126                'type' => 'checkbox',
     127                'content' => $content,
    128128                'corresponding_text' => $corresponding_text
    129129            );
     
    131131    }
    132132
    133     /** 
     133    /**
    134134     * Tests if we are should display page contents.
    135      * 
    136      * @access public 
     135     *
     136     * @access public
    137137     *
    138138     * @return bool        true if we are displaying page normally, false if editing page, or viewing versions.
    139      */ 
     139     */
    140140    function displayMode()
    141141    {
     
    144144        }
    145145    }
    146    
    147 
    148     /** 
     146
     147
     148    /**
    149149     * Prints an HTML list of versions of current file, with the filesize
    150      * and links to view and restore the file. 
    151      * 
    152      * @access public 
    153      */ 
     150     * and links to view and restore the file.
     151     *
     152     * @access public
     153     */
    154154    function printVersions()
    155155    {
     
    168168                    <td nowrap="nowrap"><p>&nbsp;&nbsp;&nbsp;[<a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=Restore&with_file=' . $v['filename'] . '&file_hash=' . md5('frog_guts' . $this->_filename)); ?>"><?php echo _("restore"); ?></a>]</p></td>
    169169                    </tr>
    170                     <?php   
     170                    <?php
    171171                }
    172172                ?></table><?php
     
    176176    }
    177177
    178     /** 
     178    /**
    179179     * Returns the contents of a data variable. The variable must first be 'set'.
    180      * 
    181      * @access public 
    182      * 
    183      * @param string $name   The name of the variable to return. 
     180     *
     181     * @access public
     182     *
     183     * @param string $name   The name of the variable to return.
    184184     *
    185185     * @return string        The trimmed content of the named data.
    186      */ 
     186     */
    187187    function getContent($name, $preserve_html=true)
    188188    {
     
    198198    }
    199199
    200     /** 
     200    /**
    201201     * Prints the contents of a data variable. The variable must first be 'set'.
    202      * 
    203      * @access public 
    204      * 
    205      * @param string $name      The name of the variable to print. 
    206      */ 
     202     *
     203     * @access public
     204     *
     205     * @param string $name      The name of the variable to print.
     206     */
    207207    function printContent($name, $preserve_html=true)
    208208    {
    209209        echo $this->getContent($name, $preserve_html);
    210210    }
    211    
    212     /** 
    213      * Prints the HTML forms corresponding to pedit variables. Each variable 
     211
     212    /**
     213     * Prints the HTML forms corresponding to pedit variables. Each variable
    214214     * must first be 'set'.
    215      * 
    216      * @access public 
    217      * 
    218      * @param string $name      The name of the variable. 
    219      */ 
     215     *
     216     * @access public
     217     *
     218     * @param string $name      The name of the variable.
     219     */
    220220    function printForm($name)
    221221    {
     
    245245        }
    246246    }
    247    
    248     /** 
     247
     248    /**
    249249     * Loops through the PEdit data array and prints all the HTML forms corresponding
    250250     * to all pedit variables, in the order in which they were 'set'.
    251      * 
    252      * @access public 
    253      */ 
     251     *
     252     * @access public
     253     */
    254254    function printAllForms()
    255255    {
     
    260260        }
    261261    }
    262    
    263     /** 
    264      * Prints the beginning <form> HTML tag, as well as hidden input forms. 
    265      * 
    266      * @return bool  False if unauthorized or current page is a version. 
    267      */ 
     262
     263    /**
     264     * Prints the beginning <form> HTML tag, as well as hidden input forms.
     265     *
     266     * @return bool  False if unauthorized or current page is a version.
     267     */
    268268    function formBegin()
    269269    {
     
    289289        }
    290290    }
    291    
    292     /** 
     291
     292    /**
    293293     * Prints the endig </form> HTML tag, as well as buttons used during
    294      * different operations. 
    295      * 
    296      * @return bool  False if unauthorized or current page is a version. 
    297      */ 
     294     * different operations.
     295     *
     296     * @return bool  False if unauthorized or current page is a version.
     297     */
    298298    function formEnd()
    299299    {
     
    330330        }
    331331    }
    332    
    333     /** 
     332
     333    /**
    334334     * Saves the POSTed data by overwriting the pedit variables in the
    335      * current file. 
    336      * 
    337      * @access private 
    338      * 
    339      * @return bool  False if unauthorized or on failure. True on success. 
    340      */ 
     335     * current file.
     336     *
     337     * @access private
     338     *
     339     * @return bool  False if unauthorized or on failure. True on success.
     340     */
    341341    function _writeData()
    342342    {
     
    368368                }
    369369            }
    370            
     370
    371371            // Search and replace all blocks.
    372372            $whole_file = preg_replace($search, $replace, $whole_file);
     
    383383                return false;
    384384            }
    385            
     385
    386386            // Open file for writing and truncate to zero length.
    387387            if (is_writable($this->_filename) && $fp = fopen($this->_filename, 'w')) {
     
    402402        }
    403403    }
    404    
    405     /** 
    406      * Makes a copy of the current file with the unix timestamp appended to the 
     404
     405    /**
     406     * Makes a copy of the current file with the unix timestamp appended to the
    407407     * filename. Deletes old versions based on threshold of age and qty.
    408      * 
    409      * @access private 
    410      * 
     408     *
     409     * @access private
     410     *
    411411     * @param optional boolean $do_cleanup    Set to false to turn off the
    412412     *                                        cleanup routine.
    413      * 
    414      * @return bool  False if unauthorized or on failure. True on success. 
    415      */ 
     413     *
     414     * @return bool  False if unauthorized or on failure. True on success.
     415     */
    416416    function _createVersion($do_cleanup=true)
    417417    {
     
    425425        }
    426426        $versions = $this->_getVersions();
    427        
     427
    428428        // Clean up old versions.
    429429        if (is_array($versions) && sizeof($versions) > $this->versions_min_qty && $do_cleanup) {
     
    431431            $oldest = array_pop($versions);
    432432            // Loop while minimum X qty && minimum X days worth but never more than 100 qty.
    433             while ((sizeof($versions) > $this->versions_min_qty 
    434             && $oldest['unixtime'] < mktime(date('H'),date('i'),date('s'),date('m'),date('d')-$this->versions_min_days,date('Y'))) 
     433            while ((sizeof($versions) > $this->versions_min_qty
     434            && $oldest['unixtime'] < mktime(date('H'),date('i'),date('s'),date('m'),date('d')-$this->versions_min_days,date('Y')))
    435435            || sizeof($versions) > 100) {
    436436                unlink(dirname($this->_filename) . '/' . $oldest['filename']);
     
    444444            return false;
    445445        }
    446        
     446
    447447        return true;
    448448    }
    449    
    450     /** 
    451      * Returns an array of all archived versions of the current file, 
     449
     450    /**
     451     * Returns an array of all archived versions of the current file,
    452452     * sorted with newest versions at the top of the array.
    453      * 
     453     *
    454454     * @access private
    455455     *
    456      * @return array  Array of versions. 
    457      */ 
     456     * @return array  Array of versions.
     457     */
    458458    function _getVersions()
    459459    {
     
    464464                preg_match('/.+__(\d+)\.php/', $version, $time);
    465465                $versions[] = array(
    466                     'filename' => $version, 
    467                     'unixtime' => $time[1], 
     466                    'filename' => $version,
     467                    'unixtime' => $time[1],
    468468                    'filesize' => filesize(dirname($this->_filename) . '/' . $version)
    469469                );
     
    478478        }
    479479    }
    480    
    481     /** 
     480
     481    /**
    482482     * Makes a version backup of the current file, then copies the specified
    483      * archived version over the current file. 
    484      * 
    485      * @access private 
    486      * 
     483     * archived version over the current file.
     484     *
     485     * @access private
     486     *
    487487     * @param string $with_file    Filename of archived version to restore.
    488488     *
    489      * @return bool  False if unauthorized. True on success. 
    490      */ 
     489     * @return bool  False if unauthorized. True on success.
     490     */
    491491    function _restoreVersion($with_file)
    492492    {
     
    494494            return false;
    495495        }
    496            
     496
    497497        if (is_writable($this->_filename)) {
    498498            // Make certain a version is created.
     
    501501                return false;
    502502            }
    503        
    504             // Do the actual copy. 
     503
     504            // Do the actual copy.
    505505            if (!copy(dirname($this->_filename) . '/' . $with_file, $this->_filename)) {
    506506                App::logMsg(sprintf('PEdit error: failed copying old version: %s', $with_file), LOG_NOTICE, __FILE__, __LINE__);
    507507                return false;
    508508            }
    509            
     509
    510510            // Success!
    511511            return true;
     
    515515        }
    516516    }
    517    
     517
    518518} // End class.
    519519
  • trunk/lib/PageNumbers.inc.php

    r41 r42  
    1414 * @version   1.61
    1515 */
    16  
     16
    1717require_once dirname(__FILE__) . '/Prefs.inc.php';
    1818
    1919class PageNumbers {
    20    
     20
    2121    var $total_items;       // Total quantity of items.
    2222    var $total_pages;       // The total number of pages.
     
    3232    var $set_page_number_initialized = false;
    3333    var $set_total_items_initialized = false;
    34    
     34
    3535    // These are initialized in the constructor.
    3636    var $per_page_options;
     
    4343    var $right_dbl_arrow;
    4444    var $right_dbl_arrow_disabled;
    45        
     45
    4646    /**
    4747     * PageNumbers constructor. All arguments are depreciated. Use set* functions instead.
     
    5151        // Default options for the quantity per page links.
    5252        $this->per_page_options = array(25, 50, 100, 200);
    53        
     53
    5454        // Default options for the page number links.
    5555        $this->left_arrow = _("back");
     
    6161        $this->right_dbl_arrow = '<strong>&raquo;</strong>';
    6262        $this->right_dbl_arrow_disabled = '<span style="color: #aaaaaa;"><strong>&raquo;</strong></span>';
    63        
    64         // Default url base. This will be set manually after instantiation 
     63
     64        // Default url base. This will be set manually after instantiation
    6565        // in special cases like using a /my/page/# scheme.
    6666        $this->url_base = $_SERVER['PHP_SELF'] . '?page_number=';
    6767    }
    68    
     68
    6969    /**
    7070     * Set the number of items per page.
     
    8888        $this->set_per_page_initialized = true;
    8989    }
    90    
     90
    9191    /**
    9292     * Set the current page number.
     
    112112        $this->set_page_number_initialized = true;
    113113    }
    114    
     114
    115115    /**
    116116     * Set the total number of items.
     
    119119    {
    120120        if (is_numeric($total_items) && $total_items > 0) {
    121             $this->total_items = $total_items;       
    122         } else {
    123             $this->total_items = 0;       
     121            $this->total_items = $total_items;
     122        } else {
     123            $this->total_items = 0;
    124124        }
    125125        $this->set_total_items_initialized = true;
    126126    }
    127    
     127
    128128    /**
    129129     * After $total_items or other options are set, this function calculates
    130      * all the other numbers needed. If you set any variables manually, 
     130     * all the other numbers needed. If you set any variables manually,
    131131     * for example if $page_number comes from
    132132     * some place other than the GET or POST array, you should call this
     
    146146            App::logMsg(sprintf('set_total_items not initialized'), LOG_ERR, __FILE__, __LINE__);
    147147        }
    148    
     148
    149149        // If the specified page exceedes total pages or is less than 1, set the page to 1.
    150150        if ($this->_per_page * $this->current_page >= $this->total_items + $this->_per_page || $this->_per_page * $this->current_page < 1) {
    151151            $this->current_page = 1;
    152152        }
    153        
     153
    154154        // The first item to be shown on this page.
    155155        $this->first_item = ($this->current_page - 1) * $this->_per_page;
    156        
     156
    157157        // The last item to be shown on this page.
    158158        if ($this->total_items < $this->current_page * $this->_per_page) {
     
    161161            $this->last_item = $this->current_page * $this->_per_page - 1;
    162162        }
    163        
     163
    164164        // Zeroing. Just in case. Paranoia. Yeah, negative numbers perturb me.
    165165        if ($this->first_item < 1) {
     
    172172            $this->total_items = 0;
    173173        }
    174                
     174
    175175        // The total number of pages.
    176176        $this->total_pages = ceil($this->total_items / $this->_per_page);
    177        
     177
    178178        // Figure out how many page number links to print.
    179179        if ($this->total_pages >= $this->max_num_links) {
     
    183183        }
    184184    }
    185    
     185
    186186    /**
    187187     * Returns the SQL code to limit query to items that are on current page.
     
    195195            return '';
    196196        }
    197     } 
     197    }
    198198
    199199    /**
     
    221221    /**
    222222     * Outputs an App::oHREF compatible url that goes to the page $page_number.
    223      * Depends on $this->base_url to build the url onto. This is used in the 
     223     * Depends on $this->base_url to build the url onto. This is used in the
    224224     * page_number.ihtml template.
    225225     *
     
    247247    {
    248248        $page_numbers = array();
    249        
     249
    250250        for ($i = 1; $i < $this->total_pages; $i++) {
    251251            $page_numbers[] = array(
     
    255255            );
    256256        }
    257        
     257
    258258        return $page_numbers;
    259259    }
     
    267267    {
    268268        $page_numbers_string = '';
    269        
     269
    270270        if ($this->current_page > $this->total_pages - floor($this->_num_links / 2)) {
    271271            $high_num = $this->total_pages;
     
    278278            $high_num = $low_num + $this->_num_links - 1;
    279279        }
    280        
     280
    281281        if ($this->current_page != 1) {
    282282            // Print "first" and "previous" page links.
     
    299299            }
    300300        }
    301        
     301
    302302        if ($this->_num_links > 0) {
    303303            // Print the current page number.
    304304            $page_numbers_string .= sprintf('<strong>%s</strong>&nbsp;', $this->current_page);
    305305        }
    306        
     306
    307307        if ($this->current_page < $this->total_pages) {
    308308            // Print links to specific page numbers after the current page.
     
    325325            }
    326326        }
    327        
     327
    328328        return $page_numbers_string;
    329329    }
    330    
     330
    331331    function printPageNumbers($carry_args=null)
    332332    {
    333333        echo $this->getPageNumbers($carry_args);
    334334    }
    335    
     335
    336336}
    337337
  • trunk/lib/PageSequence.inc.php

    r41 r42  
    1010 * @version   1.01
    1111 */
    12  
     12
    1313require_once dirname(__FILE__) . '/Prefs.inc.php';
    1414
     
    1919    var $sequence_title = '';
    2020    var $seq = '_sequence_';
    21     var $idle_timeout; 
    22    
     21    var $idle_timeout;
     22
    2323    /**
    2424     * Constructor. Sets the title of this sequence and initializes session variables.
     
    3333            $this->seq .= $params['sequence_title'];
    3434        }
    35        
     35
    3636        // How long before resetting session? 60 minutes.
    3737        $this->idle_timeout = isset($params['idle_timeout']) ? $params['idle_timeout'] : 3600;
    38        
     38
    3939        // Where is user to be redirected after startOver function call?
    4040        $this->start_url = isset($params['start_url']) ? $params['start_url'] : $_SERVER['PHP_SELF'];
    41        
     41
    4242        // Initialize vars if not set.
    4343        if (!isset($_SESSION[$this->seq]['steps'])) {
     
    5050            $_SESSION[$this->seq]['defaults'] = array();
    5151        }
    52        
     52
    5353        // Manage timeout.
    5454        $this->_auto_timeout();
    5555    }
    56    
    57     /**
    58      * Create a new step at the end (or specified position) of the $steps array. 
     56
     57    /**
     58     * Create a new step at the end (or specified position) of the $steps array.
    5959     *
    6060     * @param  string $step_id      Uniqie identifyer for this step.
     
    8585        );
    8686    }
    87    
     87
    8888    /**
    8989     * Set the features of a step. Current step if step_id not specified.
     
    123123        }
    124124    }
    125        
     125
    126126    /**
    127127     * Set the current step id. Which step are we on?
     
    142142        }
    143143    }
    144    
     144
    145145    /**
    146146     * Get the current step id.
     
    157157        }
    158158    }
    159    
     159
    160160    /**
    161161     * Get the current step number.
     
    179179            foreach ($_SESSION[$this->seq]['steps'] as $pos=>$step) {
    180180                if ($step['id'] == $step_id) {
    181                     return $pos;   
     181                    return $pos;
    182182                }
    183183            }
     
    186186        }
    187187    }
    188    
     188
    189189    /**
    190190     * Returns the ID of the step with required=true and completed=false
    191      * and active=true that falls before specified step_id. 
     191     * and active=true that falls before specified step_id.
    192192     *
    193193     * @param  string $curr_step_id ID or number of current step.
     
    212212        return $curr_step_id;
    213213    }
    214    
     214
    215215    /**
    216216     * Returns the next step in the steps array or the first active required
     
    235235        return null;
    236236    }
    237    
     237
    238238    /**
    239239     * To set a set as 'completed'.
     
    246246        $_SESSION[$this->seq]['steps'][$pos]['completed'] = true;
    247247    }
    248    
     248
    249249    /**
    250250     * Prints the a link that returns to the form for a step.
     
    262262        }
    263263    }
    264    
     264
    265265    /**
    266266     * Saves given $step_data (usually coming from $_POST) into $_SESSION
     
    279279        }
    280280    }
    281    
     281
    282282    /**
    283283     * Returns the value saved in $_SESSION for a specific data key.
     
    297297        }
    298298    }
    299    
     299
    300300    /**
    301301     * Deletes all data saved in $_SESSION.
     
    330330        }
    331331    }
    332    
     332
    333333    /**
    334334     * Saves given array (usually coming from $_POST) into $_SESSION
     
    341341        $_SESSION[$this->seq]['data'] = array_merge($_SESSION[$this->seq]['data'], $step_data);
    342342    }
    343    
     343
    344344    /**
    345345     * Reset all vars.
     
    354354        $_SESSION[$this->seq]['last_access_time'] = time();
    355355    }
    356    
     356
    357357    /**
    358358     * Template function to be extended with custom SQL code.
     
    365365        return false;
    366366    }
    367    
     367
    368368    /**
    369369     * Template function to be extended with custom SQL code.
     
    376376        return false;
    377377    }
    378    
    379    
     378
     379
    380380} // END CLASS
    381381
  • trunk/lib/PayPal.inc.php

    r41 r42  
    11<?php
    22/**
    3  * The PayPal:: class provides functions for creating PayPal buttons and for 
     3 * The PayPal:: class provides functions for creating PayPal buttons and for
    44 * receiving PayPal's Instant Payment Notification (IPN) service.
    55 *
     
    88 */
    99class PayPal {
    10    
     10
    1111    // General object parameters.
    1212    var $_params = array(
     
    1414        'test_mode' => false,
    1515    );
    16    
    17     // Options used for specific buttons and links. 
     16
     17    // Options used for specific buttons and links.
    1818    var $_default_button_options = array();
    19    
     19
    2020    // Array of buttons created by newButton().
    2121    var $_buttons = array();
    22    
     22
    2323    // Store the response from the last IPN.
    2424    var $_ipn_response;
    25    
     25
    2626    /**
    2727     * Constructor.
     
    3838            $url = 'www.paypal.com';
    3939        }
    40        
     40
    4141        $this->_default_button_options = array(
    4242            '_global' => array(
     
    5959        );
    6060    }
    61    
    62     /**
    63      * Updates the _default_button_options array with options used for 
     61
     62    /**
     63     * Updates the _default_button_options array with options used for
    6464     * specific buttons, or all buttons if $type is null.
    6565     *
    6666     * @access  public
    6767     *
    68      * @param   mixed   $type       The type of button to set defaults. If null, 
     68     * @param   mixed   $type       The type of button to set defaults. If null,
    6969     *                              sets the global button types.
    7070     * @param   array   $options    Options to set for button.
     
    7878            return false;
    7979        }
    80        
     80
    8181        if (is_null($type) || '_global' == $type) {
    8282            $this->_default_button_options['_global'] = array_merge($this->_default_button_options['_global'], $options);
     
    8585            return false;
    8686        }
    87        
     87
    8888        $this->_default_button_options[$type] = array_merge($this->_default_button_options[$type], $options);
    8989        return true;
    9090    }
    91    
     91
    9292    /**
    9393     * Creates a new element in the _buttons array. Uses _default_button_options
     
    108108            return false;
    109109        }
    110        
     110
    111111        if (!is_array($options) || empty($options)) {
    112112            App::logMsg(sprintf('Invalid options: %s', getDump($options)), LOG_WARNING, __FILE__, __LINE__);
    113113            return false;
    114114        }
    115        
     115
    116116        if (isset($this->_buttons[$name])) {
    117117            App::logMsg(sprintf('Overwriting existing button name: %s', getDump($this->_buttons[$name])), LOG_DEBUG, __FILE__, __LINE__);
    118118        }
    119        
     119
    120120        $this->_buttons[$name] = array(
    121121            'type' => $type,
     
    141141            return false;
    142142        }
    143        
     143
    144144        $query_string = '';
    145145        $delim = '';
     
    156156        $search = array('/%2F/');
    157157        $replace = array('/');
    158        
     158
    159159        return $this->_buttons[$name]['options']['link_url'] . preg_replace($search, $replace, $query_string);
    160160    }
     
    183183        ?>
    184184        <form action="<?php echo $this->_buttons[$name]['options']['button_url']; ?>" method="post">
    185         <?php 
     185        <?php
    186186        if (is_array($this->_buttons[$name]['options']) && !empty($this->_buttons[$name]['options'])) {
    187187            foreach ($this->_buttons[$name]['options'] as $key=>$val) {
     
    192192                }
    193193            }
    194         } 
     194        }
    195195        ?>
    196196        <input type="image" src="<?php echo $this->_buttons[$name]['options']['submit_img']; ?>" border="0" name="submit" alt="<?php echo $this->_buttons[$name]['options']['submit_text']; ?>" />
     
    241241    function incomingIPNRequest()
    242242    {
    243         if ($_SERVER['REQUEST_METHOD'] == 'POST' 
     243        if ($_SERVER['REQUEST_METHOD'] == 'POST'
    244244        && $_SERVER['CONTENT_TYPE'] == 'application/x-www-form-urlencoded'
    245245        && !empty($_POST)) {
     
    258258     */
    259259    function processIPN()
    260     {       
     260    {
    261261        if (getPost('test_ipn') == '1' || $this->getParam('test_mode')) {
    262262            App::logMsg(sprintf('Processing PayPal IPN in test mode: %s', getDump(getFormData())), LOG_DEBUG, __FILE__, __LINE__);
     
    266266            $url = parse_url($this->getParam('paypal_url'));
    267267        }
    268        
     268
    269269        // Read POST request and add 'cmd'.
    270270        $received_data = getPost();
     
    273273            $return_data .= '&' . $post_key . '=' . urlencode($post_val);
    274274        }
    275        
     275
    276276        // Set the port number based on the scheme.
    277         if ($url['scheme'] == "https") { 
     277        if ($url['scheme'] == "https") {
    278278            $url['port'] = 443;
    279279            $ssl = 'ssl://';
     
    282282            $ssl = '';
    283283        }
    284            
     284
    285285        // Open connection to PayPal server.
    286         $fp = fsockopen($ssl . $url['host'], $url['port'], $errnum, $errstr, 30); 
     286        $fp = fsockopen($ssl . $url['host'], $url['port'], $errnum, $errstr, 30);
    287287
    288288        if (!$fp) {
     
    290290            return false;
    291291        } else {
    292             fputs($fp, "POST {$url['path']} HTTP/1.1\r\n"); 
    293             fputs($fp, "Host: {$url['host']}\r\n"); 
    294             fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); 
    295             fputs($fp, "Content-length: " . strlen($return_data) . "\r\n"); 
    296             fputs($fp, "Connection: close\r\n\r\n"); 
    297             fputs($fp, $return_data . "\r\n\r\n"); 
    298                            
     292            fputs($fp, "POST {$url['path']} HTTP/1.1\r\n");
     293            fputs($fp, "Host: {$url['host']}\r\n");
     294            fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
     295            fputs($fp, "Content-length: " . strlen($return_data) . "\r\n");
     296            fputs($fp, "Connection: close\r\n\r\n");
     297            fputs($fp, $return_data . "\r\n\r\n");
     298
    299299            // Loop through the response lines from the server.
    300300            $this->_ipn_response = '';
     
    303303            }
    304304            fclose($fp);
    305            
     305
    306306            App::logMsg(sprintf('IPN response received: %s', $this->_ipn_response), LOG_NOTICE, __FILE__, __LINE__);
    307307            return true;
    308308        }
    309309    }
    310    
     310
    311311    /**
    312312     * Checks the response received from PayPal's IPN upon calling processIPN().
     
    322322            return false;
    323323        }
    324        
     324
    325325        if (empty($this->_ipn_response)) {
    326326            App::logMsg(sprintf('Cannot verify IPN, response empty.', null), LOG_WARNING, __FILE__, __LINE__);
    327327            return false;
    328328        }
    329        
     329
    330330        if (preg_match('/VERIFIED/', $this->_ipn_response)) {
    331331            App::logMsg(sprintf('IPN verified!', null), LOG_DEBUG, __FILE__, __LINE__);
     
    339339        }
    340340    }
    341    
    342    
     341
     342
    343343} // End of class.
    344344
  • trunk/lib/Prefs.inc.php

    r41 r42  
    3030     */
    3131    var $params = array();
    32    
    33    
     32
     33
    3434    /**
    3535     * Prefs constructor.
     
    4343    /**
    4444     * Sets the default value of a preference. The pref will be set only if
    45      * is not set already. 
     45     * is not set already.
    4646     *
    4747     * @param  string $pref      The name of the preference to modify.
     
    5656            $scope =& $this->scope;
    5757        }
    58        
     58
    5959        // No empty values allowed.
    6060        if ('' == $pref || '' == $val || '' == $scope) {
    6161            return false;
    6262        }
    63        
     63
    6464        // Initialized the prefs array.
    6565        if (!isset($_SESSION['_prefs'])) {
    6666            $_SESSION['_prefs'] = array();
    6767        }
    68        
     68
    6969        // In case boolean or null values are passed as a string.
    7070        if ($val == 'true') {
     
    8484
    8585    /**
    86      * Sets the given preferences to the specific value, 
     86     * Sets the given preferences to the specific value,
    8787     *
    8888     * @param  string $pref      The name of the preference to modify.
     
    9797            $scope =& $this->scope;
    9898        }
    99        
     99
    100100        // No empty values allowed.
    101101        if ('' == $pref || '' == $val || '' == $scope) {
    102102            return false;
    103103        }
    104        
     104
    105105        // Initialized the prefs array.
    106106        if (!isset($_SESSION['_prefs'])) {
    107107            $_SESSION['_prefs'] = array();
    108108        }
    109        
     109
    110110        // In case boolean or null values are passed as a string.
    111111        if ($val == 'true') {
     
    120120        return true;
    121121    }
    122    
     122
    123123    /**
    124124     * Returns the value of the requested preference.
     
    134134            $scope =& $this->scope;
    135135        }
    136        
     136
    137137        return (isset($_SESSION['_prefs'][$scope][$pref])) ? $_SESSION['_prefs'][$scope][$pref] : null;
    138138    }
    139    
     139
    140140    /**
    141141     * To see if a preference has been set.
     
    152152            $scope =& $this->scope;
    153153        }
    154        
     154
    155155        return isset($_SESSION['_prefs'][$scope][$pref]);
    156156    }
    157    
     157
    158158    /**
    159159     * Clear a set preference value.
     
    167167            $scope =& $this->scope;
    168168        }
    169        
     169
    170170        if (isset($_SESSION['_prefs'][$scope][$pref])) {
    171171            unset($_SESSION['_prefs'][$scope][$pref]);
     
    181181     *                     preferences listed in the $prefs hash.
    182182     *
    183      * @return mixed       True on success or a PEAR_Error object on failure. 
     183     * @return mixed       True on success or a PEAR_Error object on failure.
    184184     */
    185185    function retrieve()
     
    192192        // FIXME: Database query goes here....
    193193        return false;
    194        
     194
    195195        $_SESSION['_prefs']['loaded'] = true;
    196196    }
     
    211211            return true;
    212212        }
    213        
     213
    214214        /*
    215215         * If a list of preferences to store hasn't been provided in
     
    221221            $prefs = array_merge($_SESSION['_prefs'], $prefs);
    222222        }
    223        
     223
    224224        if (!is_array($prefs) || empty($prefs)) {
    225225            App::raiseMsg(_("No preferences are available."), MSG_ERR, __FILE__, __LINE__);
    226226            App::dieBoomerangURL();
    227227        }
    228        
     228
    229229        // FIXME: Database query goes here....
    230230        return false;
  • trunk/lib/RecordLock.inc.php

    r41 r42  
    3333    {
    3434        static $instances = array();
    35                
     35
    3636        if (!isset($instances[$auth_object->getVal('auth_name')])) {
    3737            $instances[$auth_object->getVal('auth_name')] = new RecordLock($auth_object);
     
    5353
    5454        $this->_auth = $auth_object;
    55        
     55
    5656        // Get create tables config from global context.
    5757        if (!is_null(App::getParam('db_create_tables'))) {
     
    7070    {
    7171        static $_db_tested = false;
    72    
     72
    7373        if ($recreate_db || !$_db_tested && $this->getParam('create_table')) {
    7474            if ($recreate_db) {
     
    8989                KEY record_val (record_val)
    9090            )");
    91            
     91
    9292            if (!DB::columnExists($this->getParam('db_table'), array(
    93                 'lock_id',
    94                 'record_table',
    95                 'record_key',
    96                 'record_val',
    97                 'title',
    98                 'set_by_admin_id',
    99                 'lock_datetime',
     93                'lock_id',
     94                'record_table',
     95                'record_key',
     96                'record_val',
     97                'title',
     98                'set_by_admin_id',
     99                'lock_datetime',
    100100            ), false, false)) {
    101101                App::logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), LOG_ALERT, __FILE__, __LINE__);
    102102                trigger_error(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), E_USER_ERROR);
    103103            }
    104         }   
     104        }
    105105        $_db_tested = true;
    106106    }
     
    151151        // Expire old locks.
    152152        $this->_auto_timeout();
    153        
     153
    154154        if (is_numeric($record_table_or_lock_id) && !isset($record_key) && !isset($record_val)) {
    155155            // Get lock data by lock_id.
    156156            $qid = DB::query("
    157                 SELECT * FROM " . $this->getParam('db_table') . " 
     157                SELECT * FROM " . $this->getParam('db_table') . "
    158158                WHERE lock_id = '" . addslashes($record_table_or_lock_id) . "'
    159159            ");
     
    161161            // Get lock data by record specs
    162162            $qid = DB::query("
    163                 SELECT * FROM " . $this->getParam('db_table') . " 
     163                SELECT * FROM " . $this->getParam('db_table') . "
    164164                WHERE record_table = '" . addslashes($record_table_or_lock_id) . "'
    165165                AND record_key = '" . addslashes($record_key) . "'
     
    189189
    190190    /**
    191      * Returns the status of who set the lock. Use this to ignore locks set by 
     191     * Returns the status of who set the lock. Use this to ignore locks set by
    192192     * the current user.
    193193     *
     
    197197    {
    198198        $this->initDB();
    199        
     199
    200200        if (isset($this->data['lock_id'])) {
    201201            $qid = DB::query("SELECT * FROM " . $this->getParam('db_table') . " WHERE lock_id = '" . addslashes($this->data['lock_id']) . "'");
     
    221221     */
    222222    function set($record_table, $record_key, $record_val, $title='')
    223     {       
     223    {
    224224        $this->initDB();
    225225
    226226        // Expire old locks.
    227227        $this->_auto_timeout();
    228        
     228
    229229        // Remove previous locks if exist. Is this better than using a REPLACE INTO?
    230230        DB::query("
    231             DELETE FROM " . $this->getParam('db_table') . " 
     231            DELETE FROM " . $this->getParam('db_table') . "
    232232            WHERE record_table = '" . addslashes($record_table) . "'
    233233            AND record_key = '" . addslashes($record_key) . "'
    234234            AND record_val = '" . addslashes($record_val) . "'
    235235        ");
    236        
     236
    237237        // Set new lock.
    238238        DB::query("
     
    254254        ");
    255255        $lock_id = mysql_insert_id(DB::getDBH());
    256        
     256
    257257        // Must register this locked record as the current.
    258258        $this->select($lock_id);
    259        
     259
    260260        return $lock_id;
    261261    }
     
    270270        // Expire old locks.
    271271        $this->_auto_timeout();
    272        
     272
    273273        // Delete a specific lock.
    274274        DB::query("
    275             DELETE FROM " . $this->getParam('db_table') . " 
     275            DELETE FROM " . $this->getParam('db_table') . "
    276276            WHERE lock_id = '" . addslashes($this->data['lock_id']) . "'
    277277        ");
    278        
     278
    279279        App::logMsg(sprintf('Removing lock: %s', $this->data['lock_id']), LOG_DEBUG, __FILE__, __LINE__);
    280280    }
     
    284284     */
    285285    function removeAll($user_id=null)
    286     {       
     286    {
    287287        $this->initDB();
    288288
    289289        // Expire old locks.
    290290        $this->_auto_timeout();
    291        
     291
    292292        if (isset($user_id)) {
    293293            // Delete specific user's locks.
     
    309309
    310310        $this->initDB();
    311        
     311
    312312        if (!$_timeout_run) {
    313313            // Delete all old locks.
    314314            DB::query("
    315                 DELETE FROM " . $this->getParam('db_table') . " 
     315                DELETE FROM " . $this->getParam('db_table') . "
    316316                WHERE DATE_ADD(lock_datetime, INTERVAL '" . $this->getParam('auto_timeout') . "' SECOND) < NOW()
    317317            ");
     
    337337        <?php App::printHiddenSession() ?>
    338338        <input type="hidden" name="lock_id" value="<?php echo $this->getID(); ?>" />
    339        
     339
    340340        <p><?php
    341         printf(_("The record <strong>%s</strong> is currently being edited by <strong>%s</strong> (%d minutes elapsed). You cannot modify the record while it is locked by another user."), 
    342             $this->getTitle(), 
    343             $this->getEditor(), 
     341        printf(_("The record <strong>%s</strong> is currently being edited by <strong>%s</strong> (%d minutes elapsed). You cannot modify the record while it is locked by another user."),
     342            $this->getTitle(),
     343            $this->getEditor(),
    344344            date('i', $this->getSecondsElapsed() + 60)
    345345        );
    346346        ?></p>
    347        
     347
    348348        <?php if ($this->getSecondsElapsed() > $this->getParam('timeout')) { ?>
    349349        <p><?php printf(_("You can forcibly unlock the record if you believe the editing session has expired. You might want to confirm with %s before doing this."), $this->getEditor()) ?></p>
    350350        <input type="submit" name="unlock" value="<?php echo _("Unlock"); ?>" />
    351351        <?php } ?>
    352        
     352
    353353        <input type="submit" name="cancel" value="<?php echo _("Cancel"); ?>" />
    354354        </form>
  • trunk/lib/RecordVersion.inc.php

    r41 r42  
    11<?php
    22/**
    3  * The RecordVersion:: class provides a system for saving, reviewing, and 
     3 * The RecordVersion:: class provides a system for saving, reviewing, and
    44 * restoring versions of a record of any DB table. All the data in the record is
    55 * serialized, compressed, and saved in a blob in the version_tbl. Restoring a
    66 * version simply does a REPLACE INTO of the data. It is very simple, and works
    77 * with multiple database tables, but the drawback is that relationships for
    8  * a record cannot be retained. For example, an article from an article_tbl can 
     8 * a record cannot be retained. For example, an article from an article_tbl can
    99 * be saved, but not categories associated to the record in a category_article_tbl.
    1010 * The restored article will simple retain the relationships that the previous
     
    4040    {
    4141        static $instances = array();
    42                
     42
    4343        if (!isset($instances[$auth_object->getVal('auth_name')])) {
    4444            $instances[$auth_object->getVal('auth_name')] = new RecordVersion($auth_object);
     
    5858            trigger_error('Constructor not provided a valid Auth_SQL object.', E_USER_ERROR);
    5959        }
    60        
     60
    6161        $this->_auth = $auth_object;
    62        
     62
    6363        // Get create tables config from global context.
    6464        if (!is_null(App::getParam('db_create_tables'))) {
     
    6666        }
    6767    }
    68    
     68
    6969    /**
    7070     * Setup the database table for this class.
     
    7777    {
    7878        static $_db_tested = false;
    79    
     79
    8080        if ($recreate_db || !$_db_tested && $this->getParam('create_table')) {
    8181            if ($recreate_db) {
     
    9898                KEY record_val (record_val)
    9999            )");
    100            
     100
    101101            if (!DB::columnExists($this->getParam('db_table'), array(
    102102                'version_id',
     
    113113                trigger_error(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->getParam('db_table')), E_USER_ERROR);
    114114            }
    115         }   
     115        }
    116116        $_db_tested = true;
    117117    }
     
    160160    {
    161161        $this->initDB();
    162    
     162
    163163        // Get current record.
    164164        if (!$record = $this->getCurrent($record_table, $record_key, $record_val)) {
     
    166166            return false;
    167167        }
    168                
     168
    169169        // Clean-up old versions.
    170170        $this->deleteOld($record_table, $record_key, $record_val);
    171        
     171
    172172        // Save as new version.
    173173        DB::query("
     
    206206    {
    207207        $this->initDB();
    208    
     208
    209209        // Get version data.
    210210        $qid = DB::query("
    211             SELECT * FROM " . $this->getParam('db_table') . " 
     211            SELECT * FROM " . $this->getParam('db_table') . "
    212212            WHERE version_id = '" . addslashes($version_id) . "'
    213213        ");
     
    228228        // SQLize the keys of the specified versioned record.
    229229        $replace_keys = join(",\n", array_map('addslashes', array_keys($data)));
    230        
     230
    231231        // SQLize the keys of the values of the specified versioned record. (These are more complex because we need to account for SQL null values.)
    232232        $replace_values = '';
     
    236236            $comma = ',';
    237237        }
    238        
     238
    239239        // Replace current record with specified versioned record.
    240240        DB::query("
     
    245245            )
    246246        ");
    247        
     247
    248248        return $record;
    249249    }
     
    252252     * Version garbage collection. Deletes versions older than min_days
    253253     * when quantity of versions exceeds min_qty. If quantity
    254      * exceeds 100 within min_days, the oldest are deleted to bring the 
     254     * exceeds 100 within min_days, the oldest are deleted to bring the
    255255     * quantity back down to min_qty.
    256256     *
     
    264264    {
    265265        $this->initDB();
    266    
     266
    267267        // Get total number of versions for this record.
    268268        $qid = DB::query("
     
    273273        ");
    274274        list($v_count) = mysql_fetch_row($qid);
    275        
     275
    276276        if ($v_count > $this->getParam('min_qty')) {
    277277            if ($v_count > $this->getParam('max_qty')) {
     
    329329    {
    330330        $this->initDB();
    331    
     331
    332332        // Get versions of this record.
    333333        $qid = DB::query("
     
    358358    {
    359359        $this->initDB();
    360    
     360
    361361        // Get version data.
    362362        $qid = DB::query("
    363             SELECT * FROM " . $this->getParam('db_table') . " 
     363            SELECT * FROM " . $this->getParam('db_table') . "
    364364            WHERE version_id = '" . addslashes($version_id) . "'
    365365        ");
     
    377377    {
    378378        $this->initDB();
    379    
     379
    380380        // Get version data.
    381381        $qid = DB::query("
    382             SELECT * FROM " . $this->getParam('db_table') . " 
     382            SELECT * FROM " . $this->getParam('db_table') . "
    383383            WHERE version_id = '" . addslashes($version_id) . "'
    384384        ");
     
    401401    {
    402402        $this->initDB();
    403    
     403
    404404        $qid = DB::query("
    405405            SELECT * FROM " . addslashes($record_table) . "
  • trunk/lib/ScriptTimer.inc.php

    r41 r42  
    11<?php
    22/**
    3  * ScriptTimer.inc.php 
     3 * ScriptTimer.inc.php
    44 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information
    55 */
    6  
     6
    77class ScriptTimer {
    88
     
    1010    var $_timing_start_times;
    1111    var $_timing_stop_times;
    12    
     12
    1313    function start($name='default')
    1414    {
    1515        $this->_timing_start_times[$name] = explode(' ', microtime());
    1616    }
    17    
     17
    1818    function stop($name='default')
    1919    {
    2020        $this->_timing_stop_times[$name] = explode(' ', microtime());
    2121    }
    22    
     22
    2323    function getTime($name='default')
    2424    {
     
    2626            return 0;
    2727        }
    28        
     28
    2929        if (!isset($this->_timing_stop_times[$name])) {
    3030            $stop_time = explode(' ', microtime());
     
    3232            $stop_time = $this->_timing_stop_times[$name];
    3333        }
    34        
     34
    3535        // Do the big numbers first so the small ones aren't lost.
    3636        $current = $stop_time[1] - $this->_timing_start_times[$name][1];
    3737        $current += $stop_time[0] - $this->_timing_start_times[$name][0];
    38        
     38
    3939        return sprintf($this->time_format, $current);
    4040    }
  • trunk/lib/SessionCache.inc.php

    r41 r42  
    8888     * @param str   $var_id       An identifyer for the cached object.
    8989     * @param bool  $force_it_in  If we have something really big that we
    90      *                            still want to cache, setting this true 
     90     *                            still want to cache, setting this true
    9191     *                            allows this.
    9292     *
     
    106106        $serialized_var = serialize($var);
    107107        $serialized_var_len = strlen($serialized_var);
    108        
     108
    109109        if ($serialized_var_len >= $this->getParam('soft_limit') && !$force_it_in) {
    110110            App::logMsg(sprintf('Serialized variable (%s bytes) more than soft_limit (%s bytes).', $serialized_var_len, $this->getParam('soft_limit')), LOG_NOTICE, __FILE__, __LINE__);
    111111            return false;
    112112        }
    113        
     113
    114114        if ($serialized_var_len >= $this->getParam('hard_limit')) {
    115115            App::logMsg(sprintf('Serialized variable (%s bytes) more than hard_limit (%s bytes).', $serialized_var_len, $this->getParam('hard_limit')), LOG_NOTICE, __FILE__, __LINE__);
     
    122122            unset($_SESSION['_session_cache'][$var_id]);
    123123            // Continue to prune the cache if it's length is too long for the new variable to fit, but keep at least MIN_ITEMS at least.
    124             while (strlen(serialize($_SESSION['_session_cache'])) + $serialized_var_len >= $this->getParam('soft_limit') 
     124            while (strlen(serialize($_SESSION['_session_cache'])) + $serialized_var_len >= $this->getParam('soft_limit')
    125125            && sizeof($_SESSION['_session_cache']) >= $this->getParam('min_items')) {
    126126                array_shift($_SESSION['_session_cache']);
     
    128128        }
    129129        $_SESSION['_session_cache'][$var_id] =& $serialized_var;
    130        
     130
    131131        if ($serialized_var_len >= 1024000) {
    132132            App::logMsg(sprintf('Successfully cached oversized variable (%s bytes).', $serialized_var_len), LOG_DEBUG, __FILE__, __LINE__);
    133133        }
    134        
     134
    135135        return $var_id;
    136136    }
    137    
    138     /**
    139      * Retrives an object from the session cache and returns it unserialized. 
     137
     138    /**
     139     * Retrives an object from the session cache and returns it unserialized.
    140140     * It also moves it to the top of the stack, which makes it such that the
    141141     * cache flushing mechanism of putCache deletes the oldest referenced items
     
    155155            return false;
    156156        }
    157        
     157
    158158        $var_id = md5($var_id);
    159159        if (isset($_SESSION['_session_cache'][$var_id])) {
     
    168168        }
    169169    }
    170    
     170
    171171    /**
    172172     * Tells you if the object is cached.
     
    189189        return isset($_SESSION['_session_cache'][$var_id]);
    190190    }
    191    
     191
    192192    /**
    193193     * Tells you if the object is cached.
  • trunk/lib/SortOrder.inc.php

    r41 r42  
    1313 * @requires    This class requires Utilities.inc.php
    1414 * @requires    This class requires Prefs.inc.php
    15  * 
     15 *
    1616 * @author  Quinn Comendant <quinn@strangecode.com>
    1717 * @version 1.6.1
     
    2222
    2323class SortOrder {
    24        
     24
    2525    var $_columns;
    2626    var $sort_by;
     
    3030    var $default_sort;
    3131    var $default_order;
    32    
     32
    3333    /**
    3434     * Constructor. Finds the current sort by and order.
     
    4040     */
    4141    function SortOrder($default_sort = '', $default_order = '')
    42     {       
     42    {
    4343        $this->setDefault($default_sort, $default_order);
    44    
     44
    4545        $this->default_sort = $default_sort;
    4646        $this->default_order = $default_order;
    4747    }
    48    
     48
    4949    /**
    50      * Build an array of valid sort SQL for each DB column. This SQL is reference 
     50     * Build an array of valid sort SQL for each DB column. This SQL is reference
    5151     * by the name and 'asc' or 'desc'.
    5252     *
     
    6262        );
    6363    }
    64    
     64
    6565    /**
    6666     * Set sort and order values. This is how you set new sort values after
     
    8888            $this->sort_by = $default_sort;
    8989        }
    90        
     90
    9191        // Which sort order to use?
    9292        // (1) By GET or POST specification, if available.
     
    103103        }
    104104    }
    105    
    106    
     105
     106
    107107    /**
    108108     * Set sort and order values. This is how you set new sort values after
     
    121121            Prefs::setValue('sort_by', $this->sort_by, $_SERVER['PHP_SELF']);
    122122        }
    123        
     123
    124124        // Set new order value.
    125125        if (isset($order)) {
     
    128128        }
    129129    }
    130    
    131    
     130
     131
    132132    /**
    133133     * Returns the SQL code to sort by set column and set order.
     
    149149            return '';
    150150        }
    151     } 
    152    
    153    
     151    }
     152
     153
    154154    /**
    155155     * Prints a link for a column header with URL sort determining logic.
     
    171171            ?><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?sort=' . $col . '&order=' . $default_order); ?>" title="<?php echo sprintf(_("Sort by %s"), $col_name); ?>"><?php echo $col_name; ?></a><?php
    172172        }
    173     }     
     173    }
    174174
    175175}
  • trunk/lib/SpellCheck.inc.php

    r41 r42  
    99 * @version 1.1
    1010 */
    11  
     11
    1212/* Implementation example:
    1313--------------------------------------------------------------------------------
     
    1717// Instantiate with parameters. In this example we'll set the language and the path to the personal wordlist file.
    1818$spell = new SpellCheck(array(
    19     'language' => 'en', 
     19    'language' => 'en',
    2020    'personal_wordlist' => '/tmp/my_custom_dict'
    2121));
     
    4949        'highlight_end' => '</strong>',
    5050    );
    51    
     51
    5252    var $_pspell_cfg_handle;
    5353    var $_pspell_handle;
    5454    var $_use_personal_wordlist = false;
    5555    var $_errors = array();
    56    
     56
    5757    /**
    5858     * Constructor.
    59     *
     59    *
    6060     * @param  array    $params     Array of parameters (key => val pairs).
    6161     */
    6262    function SpellCheck($params)
    6363    {
    64         if (!is_array($params) || empty($params)) {
    65             trigger_error('SpellCheck parameters not set properly', E_USER_ERROR);
    66         }
    67 
    68         $this->setParam($params);
     64        if (!is_array($params) || empty($params)) {
     65            trigger_error('SpellCheck parameters not set properly', E_USER_ERROR);
     66        }
     67
     68        $this->setParam($params);
    6969
    7070        $this->_pspell_cfg_handle = pspell_config_create($this->getParam('language'));
     
    7575        if ('' != $this->getParam('personal_wordlist')) {
    7676            if (!is_writable(dirname($this->getParam('personal_wordlist'))) || !is_writable($this->getParam('personal_wordlist'))) {
    77                 App::logMsg(sprintf('Personal wordlist file not writable: %s', $this->getParam('personal_wordlist')), LOG_WARNING, __FILE__, __LINE__);
     77                App::logMsg(sprintf('Personal wordlist file not writable: %s', $this->getParam('personal_wordlist')), LOG_WARNING, __FILE__, __LINE__);
    7878            } else {
    7979                pspell_config_personal($this->_pspell_cfg_handle, $this->getParam('personal_wordlist'));
     
    118118        }
    119119    }
    120    
     120
    121121    /**
    122122     * Check whether any errors have been triggered.
     
    136136        $this->_errors = array();
    137137    }
    138    
     138
    139139    /**
    140140     * Check one word.
     
    156156        }
    157157    }
    158    
     158
    159159    /**
    160160     * Suggest the correct spelling for one misspelled word.
     
    171171        return pspell_suggest($this->_pspell_handle, $word);
    172172    }
    173    
     173
    174174    /**
    175175     * Add a word to a personal list.
     
    186186        if ($this->_use_personal_wordlist) {
    187187            if (pspell_add_to_personal($this->_pspell_handle, $word)) {
    188                 App::logMsg(sprintf('Added "%s" to personal wordlist: %s', $word, $this->getParam('personal_wordlist')), LOG_DEBUG, __FILE__, __LINE__);
    189                 return true;           
    190             } else {
    191                 App::logMsg(sprintf('Failed adding "%s" to personal wordlist: %s', $word, $this->getParam('personal_wordlist')), LOG_WARNING, __FILE__, __LINE__);
    192                 return false;
    193             }
    194         }
    195     }
    196    
     188                App::logMsg(sprintf('Added "%s" to personal wordlist: %s', $word, $this->getParam('personal_wordlist')), LOG_DEBUG, __FILE__, __LINE__);
     189                return true;
     190            } else {
     191                App::logMsg(sprintf('Failed adding "%s" to personal wordlist: %s', $word, $this->getParam('personal_wordlist')), LOG_WARNING, __FILE__, __LINE__);
     192                return false;
     193            }
     194        }
     195    }
     196
    197197    /**
    198198     * Save personal list to file.
     
    217217        }
    218218    }
    219    
     219
    220220    /**
    221221     * Returns an array of suggested words for each mispelled word in the given text.
     
    252252        }
    253253    }
    254    
     254
    255255    /**
    256256     * Checks all words in a given string.
     
    284284        }
    285285    }
    286    
     286
    287287    /**
    288288     * Returns a given string with misspelled words highlighted.
     
    310310        return join('', $words);
    311311    }
    312    
     312
    313313    /**
    314314     * Prints the HTML for correcting all mispellings found in the text of one $_FORM element.
     
    326326        <input name="<?php echo $form_name ?>" type="hidden" value="<?php echo getFormData($form_name) ?>" />
    327327        <?php
    328        
     328
    329329        $form_words = $this->getStringSuggestions(getFormData($form_name));
    330330        if (is_array($form_words) && !empty($form_words)) {
     
    337337                <option value="<?php echo $original_word ?>">(<?php echo $original_word ?>)</option>
    338338                <?php
    339                
     339
    340340                foreach ($words as $suggestion) {
    341341                    ?>
     
    343343                    <?php
    344344                }
    345                
     345
    346346                ?>
    347347                </select>
     
    356356        }
    357357    }
    358    
     358
    359359    /**
    360360     * Tests if any form spelling corrections have been submitted.
     
    370370        return (false !== getFormData('spelling_suggestions', false)) || (false !== getFormData('spelling_corrections', false));
    371371    }
    372    
     372
    373373    /**
    374374     * Replace the misspelled words in the text of a specified form with the corrections.
  • trunk/lib/TemplateGlue.inc.php

    r41 r42  
    66
    77/**
    8  * Print URL to download file with BBEdit/Interarchy. "USER" must be a pre-set 
     8 * Print URL to download file with BBEdit/Interarchy. "USER" must be a pre-set
    99 * environment variable. Files must reside within and be relative to env "DOCUMENT_ROOT".
    1010 *
     
    1919
    2020/**
    21  * Returns an image tag for image specified in $src. 
     21 * Returns an image tag for image specified in $src.
    2222 *
    2323 * @param  string $src     File name of the image, including path and file extension.
     
    2828{
    2929    $filepath = preg_match('!://!', $src) ? $src : getenv('DOCUMENT_ROOT') . $src;
    30    
     30
    3131    if (true === ($gis = @getimagesize($filepath)) && !preg_match('/width|height/', $extra)) {
    3232        $image_size = $gis[3];
     
    3434        $image_size = '';
    3535    }
    36    
     36
    3737    return sprintf('<img src="%s" %s alt="%s" %s />',
    3838        $src,
     
    4444
    4545/**
    46  * Prints an image tag for image specified in $src. 
     46 * Prints an image tag for image specified in $src.
    4747 *
    4848 * @param  string $src     File name of the image, including path and file extension.
     
    5858 * Finds the values of an enumeration or set column of a MySQL database, returning them in an array.
    5959 * Use this to generate a pull-down menu of options or to validate the existance
    60  * of options. (Quinn 10 Feb 2001) 
     60 * of options. (Quinn 10 Feb 2001)
    6161 *
    6262 * @param  string $db_table   database table to lookup
     
    6767{
    6868    $qid = DB::query("SHOW COLUMNS FROM " . addslashes($db_table) . " LIKE '" . addslashes($db_col) . "'",false);
    69        
     69
    7070    $row = mysql_fetch_row($qid);
    7171    if (preg_match('/^enum|^set/i', $row[1]) && preg_match_all("/'([^']*)'/", $row[1], $enum)) {
     
    7979/**
    8080 * Prints option fields for a select form. Works only with enum or set
    81  * data types in table columns. 
     81 * data types in table columns.
    8282 *
    8383 * @param  string $db_table   database table to lookup
     
    134134/**
    135135 * Prints checkbox fields. Works only with enum or set
    136  * data types in table columns. 
     136 * data types in table columns.
    137137 *
    138138 * @param  string $db_table      database table to lookup
     
    143143 */
    144144function printSetCheckboxes($db_table, $db_col, $preselected, $columns=1, $flag=null)
    145 {   
     145{
    146146    ?>
    147147    <table>
     
    152152        $preselected = explode(',', $preselected);
    153153    }
    154    
     154
    155155    // Checkbox POST data has the primary data in the keys, and 'on' as the values.
    156156    // Here we assume in all the values of an array are 'on' that we can find the data
     
    160160        $preselected = array_keys($preselected);
    161161    }
    162    
    163     // Retreive values of a Set or ENUM database column. 
     162
     163    // Retreive values of a Set or ENUM database column.
    164164    $values = getSetEnumFieldValues($db_table, $db_col);
    165    
     165
    166166    // Initialize the HTML table generation vars.
    167167    $num_cells = sizeof($values) - 1;
     
    184184        $curr = $num_rows * $col_cnt + $lastrow_add + $row_cnt;
    185185        $col_cnt++;
    186        
     186
    187187        // Look for preselected value.
    188188        if (in_array($v, $preselected)) {
     
    212212/**
    213213 * Prints radio select fields. Works only with enum or set
    214  * data types in table columns. 
     214 * data types in table columns.
    215215 *
    216216 * @param  string $db_table      database table to lookup
     
    221221 */
    222222function printSetRadios($db_table, $db_col, $preselected, $columns=1, $flag=null)
    223 {   
     223{
    224224    ?>
    225225    <table>
     
    230230        $preselected = explode(',', $preselected);
    231231    }
    232    
     232
    233233    // Checkbox POST data has the primary data in the keys, and 'on' as the values.
    234234    // Here we assume in all the values of an array are 'on' that we can find the data
     
    238238        $preselected = array_keys($preselected);
    239239    }
    240    
    241     // Retreive values of a Set or ENUM database column. 
     240
     241    // Retreive values of a Set or ENUM database column.
    242242    $values = getSetEnumFieldValues($db_table, $db_col);
    243    
     243
    244244    // Initialize the HTML table generation vars.
    245245    $num_cells = sizeof($values) - 1;
     
    262262        $curr = $num_rows * $col_cnt + $lastrow_add + $row_cnt;
    263263        $col_cnt++;
    264        
     264
    265265        // Look for preselected value.
    266266        if (in_array($v, $preselected)) {
     
    283283
    284284/**
    285  * Prints a pulldown menu containing the specified values and keys of a table. 
     285 * Prints a pulldown menu containing the specified values and keys of a table.
    286286 *
    287287 * @param  string $db_table         database table to lookup
     
    305305        <?php
    306306    }
    307    
     307
    308308    // When the 'blank' value needs a specific key->val pair.
    309309    if (is_array($blank)) {
     
    323323/**
    324324 * Prints checkbox fields. Works only with enum or set
    325  * data types in table columns. 
     325 * data types in table columns.
    326326 *
    327327 * @param  string $db_table         database table to lookup
     
    339339        $preselected = explode(',', $preselected);
    340340    }
    341    
     341
    342342    // Checkbox POST data has the primary data in the keys, and 'on' as the values.
    343343    // Here we assume in all the values of an array are 'on' that we can find the data
     
    347347        $preselected = array_keys($preselected);
    348348    }
    349    
     349
    350350    $qid = DB::query("SELECT $key_column, $val_column FROM $db_table $extra_clause",false);
    351351    while ($row = mysql_fetch_assoc($qid)) {
    352352        $values[] = $row;
    353353    }
    354    
     354
    355355    // Rearrange array so sort is in vertical columns. FIXME: doesn't work.
    356356//  if ($vert_columns) {
     
    378378        return false;
    379379    }
    380    
     380
    381381    // Initialize the HTML table generation vars.
    382382    $num_cells = sizeof($values) - 1;
     
    396396            $row_cnt++;
    397397        }
    398        
     398
    399399        if ($col_cnt < $cols_lastrow) {
    400400            $lastrow_add = $col_cnt;
     
    402402            $lastrow_add = $cols_lastrow;
    403403        }
    404        
     404
    405405        $curr = $num_rows * $col_cnt + $lastrow_add + $row_cnt;
    406406        $col_cnt++;
    407        
     407
    408408        // Look for preselected value.
    409409        if (in_array($box[$val_column], $preselected)) {
     
    412412            $checked = '';
    413413        }
    414        
     414
    415415        // Print a cell with basic named checkboxes.
    416416        $html_name = $val_column . '[' . $box[$val_column] . ']';
     
    420420        <?php /// FIXME: class=normal?
    421421    }
    422    
     422
    423423    if ($col_cnt < $columns) {
    424424        // This last cell must expand to fill the last blank cells.
  • trunk/lib/Upload.inc.php

    r41 r42  
    11<?php
    22/**
    3  * Upload.inc.php 
     3 * Upload.inc.php
    44 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information
    55 *
     
    2222
    2323class Upload {
    24    
     24
    2525    // General object parameters.
    2626    var $_params = array(
    27    
     27
    2828        // Which messages do we pass to raiseMsg?
    2929        'display_messages' => UPLOAD_MSG_ALL,
    30        
     30
    3131        // Existing files will be overwritten when there is a name conflict?
    3232        'allow_overwriting' => false,
     
    222222        'ice'     => 'x-conference/x-cooltalk',
    223223    );
    224    
     224
    225225    /**
    226226     * Set (or overwrite existing) parameters by passing an array of new parameters.
     
    232232    {
    233233        if (isset($params) && is_array($params)) {
    234        
     234
    235235            // Enforce valid upload_path parameter.
    236236            if (isset($params['upload_path'])) {
     
    249249                $params['upload_path'] = preg_replace('!/+$!', '', $params['upload_path']);
    250250            }
    251        
     251
    252252            // Merge new parameters with old overriding only those passed.
    253253            $this->_params = array_merge($this->_params, $params);
     
    276276    /**
    277277     * Process uploaded files. Processes files existing within the specified $_FILES['form_name'] array.
    278      * It tests for errors, cleans the filename, optionally sets custom file names. It will process 
     278     * It tests for errors, cleans the filename, optionally sets custom file names. It will process
    279279     * multiple files automatically if the file form element is an array (<input type="file" name="myfiles[]" />).
    280280     *
     
    296296            return false;
    297297        }
    298        
     298
    299299        // Ensure the file form element specified actually exists.
    300300        if (!isset($_FILES[$form_name])) {
     
    303303            return false;
    304304        }
    305        
     305
    306306        if (is_array($_FILES[$form_name]['name'])) {
    307307            $files = $_FILES[$form_name];
     
    318318
    319319        // To keep this script running even if user tries to stop browser.
    320         ignore_user_abort(true); 
     320        ignore_user_abort(true);
    321321        ini_set('max_execution_time', 300);
    322322        ini_set('max_input_time', 300);
     
    332332                continue;
    333333            }
    334            
     334
    335335            // Determine final file name.
    336336            if ($num == 1) {
     
    362362            // Clean the file name of bad characters.
    363363            $file_name = $this->cleanFileName($file_name);
    364            
     364
    365365            // If the file name has no extension, use the mime-type extension.
    366366            if (!preg_match('/\.[^.]{1,5}$/', $file_name) && function_exists('mime_content_type')) {
     
    369369                }
    370370            }
    371            
     371
    372372            // Set the path and file name.
    373373            $file_path_name = $this->getParam('upload_path') . '/' . $file_name;
    374            
    375            
     374
     375
    376376            // Check The php upload error messages.
    377377            if (UPLOAD_ERR_INI_SIZE === $files['error'][$i]) {
     
    407407                continue;
    408408            }
    409            
     409
    410410            // Check to be sure it's an uploaded file.
    411411            if (!is_uploaded_file($files['tmp_name'][$i])) {
     
    415415                continue;
    416416            }
    417            
     417
    418418            // Check to be sure the file is not empty.
    419419            if ($files['size'][$i] < 1) {
     
    423423                continue;
    424424            }
    425            
     425
    426426            // Check to be sure the file has a valid file name extension.
    427427            if (!in_array(strtolower($this->getFilenameExtension($file_name)), $this->getParam('valid_file_extensions'))) {
     
    431431                continue;
    432432            }
    433            
     433
    434434            // Check to be sure the file has a unique file name.
    435435            if (!$this->getParam('allow_overwriting') && $this->exists($file_name)) {
     
    439439                continue;
    440440            }
    441            
     441
    442442            // Move the file to the final place.
    443443            if (move_uploaded_file($files['tmp_name'][$i], $file_path_name)) {
     
    462462            }
    463463        }
    464        
     464
    465465        // Return names of files uploaded (or empty array when none processed).
    466466        return $new_file_names;
    467467    }
    468    
     468
    469469    /**
    470470     * Remove file within upload path.
     
    481481            return false;
    482482        }
    483        
     483
    484484        $file_path_name = $this->getParam('upload_path') . '/' . $file_name;
    485485
     
    495495        }
    496496    }
    497    
     497
    498498    /**
    499499     * Renames a file within the upload path.
     
    511511            return false;
    512512        }
    513        
     513
    514514        $old_file_path_name = $this->getParam('upload_path') . '/' . $old_name;
    515515        $new_file_path_name = $this->getParam('upload_path') . '/' . $new_name;
     
    529529        }
    530530    }
    531    
     531
    532532    /**
    533533     * Tests if a file exists within the current upload_path.
     
    544544            return false;
    545545        }
    546        
     546
    547547        return file_exists($this->getParam('upload_path') . '/' . $file_name);
    548548    }
    549549
    550550    /**
    551      * Get filename by glob pattern. Searches a directory for an image that matches the 
     551     * Get filename by glob pattern. Searches a directory for an image that matches the
    552552     * specified glob pattern and returns the filename of the first file found.
    553553     *
     
    620620        return isset($ext[1]) ? $ext[1] : '';
    621621    }
    622    
     622
    623623    /**
    624624     * An alias for App::raiseMsg that only sends messages configured by display_messages.
  • trunk/lib/Utilities.inc.php

    r41 r42  
    6464
    6565/**
    66  * Returns text with appropriate html translations. 
     66 * Returns text with appropriate html translations.
    6767 *
    6868 * @param  string $txt              Text to clean.
    69  * @param  bool   $preserve_html    If set to true, oTxt will not translage <, >, ", or ' 
     69 * @param  bool   $preserve_html    If set to true, oTxt will not translage <, >, ", or '
    7070 *                                  characters into HTML entities. This allows HTML to pass
    7171 *                                  through unmunged.
     
    8585        $search['retain_left_angle']       = '/&lt;/';
    8686        $replace['retain_left_angle']      = '<';
    87        
     87
    8888        $search['retain_right_angle']      = '/&gt;/';
    8989        $replace['retain_right_angle']     = '>';
    90        
     90
    9191        $search['retain_single_quote']     = '/&#039;/';
    9292        $replace['retain_single_quote']    = "'";
    93        
     93
    9494        $search['retain_double_quote']     = '/&quot;/';
    9595        $replace['retain_double_quote']    = '"';
     
    104104
    105105/**
    106  * Returns text with stylistic modifications. 
     106 * Returns text with stylistic modifications.
    107107 *
    108108 * @param  string   $txt  Text to clean.
     
    125125    $search['single_quotes']    = '/(^|[^\w=])(?:\'|&#39;|&lsquo;)([^\']+?)(?:\'|&#39;|&rsquo;)([^\w]|$)/';
    126126    $replace['single_quotes']   = '\\1&lsquo;\\2&rsquo;\\3';
    127    
     127
    128128    // em--dashes  become em&mdash;dashes
    129129    $search['em_dash']          = '/(\s*[^!<-])--([^>-]\s*)/';
     
    133133}
    134134
    135    
     135
    136136/**
    137137 * Generates a hexadecibal html color based on provided word.
     
    159159        }
    160160        break;
    161        
     161
    162162    case 1 :
    163163    default :
     
    219219    $units = array('B', 'KB', 'MB', 'GB', 'TB');
    220220    $ii = count($units) - 1;
    221  
     221
    222222    // Max unit
    223223    $unit = array_search((string) $unit, $units);
     
    225225        $unit = $ii;
    226226    }
    227  
     227
    228228    // Loop
    229229    $i = 0;
     
    232232        $i++;
    233233    }
    234  
     234
    235235    return sprintf($format, $size, $units[$i]);
    236236}
     
    264264 * @param  mixed $var       The variable that is being set.
    265265 * @param  mixed $default   What to set it to if $val is not currently set.
    266  * @return mixed            The resulting value of $var. 
     266 * @return mixed            The resulting value of $var.
    267267 */
    268268function setDefault(&$var, $default='')
     
    307307 */
    308308function urlEncodeArray($data, $prefix='', $_return=true) {
    309    
     309
    310310    // Data is stored in static variable.
    311311    static $args;
    312    
     312
    313313    if (is_array($data)) {
    314314        foreach ($data as $key => $val) {
     
    323323        $args[$prefix] = urlencode($data);
    324324    }
    325    
     325
    326326    if ($_return) {
    327327        // This is not a recursive execution. All recursion is complete.
     
    343343 */
    344344function urlEncodeArrayToString($data, $prefix='') {
    345    
     345
    346346    $array_args = urlEncodeArray($data, $prefix);
    347347    $url_args = '';
     
    378378 * Prints the word "checked" if a variable is set, and optionally matches
    379379 * the desired value, otherwise prints nothing,
    380  * used for printing the word "checked" in a checkbox form input. 
     380 * used for printing the word "checked" in a checkbox form input.
    381381 *
    382382 * @param  mixed $var     the variable to compare
     
    404404 * prints the word "selected" if a variable is set, and optionally matches
    405405 * the desired value, otherwise prints nothing,
    406  * otherwise prints nothing, used for printing the word "checked" in a 
    407  * select form input 
     406 * otherwise prints nothing, used for printing the word "checked" in a
     407 * select form input
    408408 *
    409409 * @param  mixed $var     the variable to compare
     
    450450 *
    451451 * @param  array $date     String date to convert.
    452  * @param  array $format   Date format to pass to date(). 
     452 * @param  array $format   Date format to pass to date().
    453453 *                         Default produces MySQL datetime: 0000-00-00 00:00:00.
    454454 * @return string          SQL-safe date.
     
    462462        $sql_date = date($format, strtotime($date));
    463463    }
    464    
     464
    465465    return $sql_date;
    466466}
     
    477477{
    478478    static $magic_quotes_gpc;
    479    
     479
    480480    if (!isset($magic_quotes_gpc)) {
    481481        $magic_quotes_gpc = get_magic_quotes_gpc();
    482482    }
    483    
     483
    484484    if ($magic_quotes_gpc) {
    485485        if (!is_array($var)) {
     
    562562        App::logMsg(sprintf('Adding signature to empty string.', null), LOG_NOTICE, __FILE__, __LINE__);
    563563    }
    564    
     564
    565565    if (!isset($seed_key)) {
    566566        $seed_key = App::getParam('signing_key');
     
    606606/**
    607607 * Sends empty output to the browser and flushes the php buffer so the client
    608  * will see data before the page is finished processing. 
     608 * will see data before the page is finished processing.
    609609 */
    610610function flushBuffer() {
     
    682682{
    683683    static $urls = array();
    684    
     684
    685685    if (!isset($urls[$url])) {
    686686        if (!preg_match('|\w{1,}\.\w{2,5}/|', $url)) {
     
    695695
    696696/**
    697  * Takes a URL and returns it without the query or anchor portion 
     697 * Takes a URL and returns it without the query or anchor portion
    698698 *
    699699 * @param  string $url   any kind of URI
     
    706706
    707707/**
    708  * Returns the remote IP address, taking into consideration proxy servers. 
     708 * Returns the remote IP address, taking into consideration proxy servers.
    709709 *
    710710 * @param  bool $dolookup   If true we resolve to IP to a host name,
     
    740740        $networks = array($networks);
    741741    }
    742    
     742
    743743    $ip_binary = sprintf('%032b', ip2long($ip));
    744744    foreach ($networks as $network) {
     
    758758        }
    759759    }
    760    
     760
    761761    return false;
    762762}
    763763
    764764/**
    765  * Returns a fully qualified URL to the current script, including the query. 
     765 * Returns a fully qualified URL to the current script, including the query.
    766766 *
    767767 * @return string    a full url to the current script
     
    796796    /**
    797797    * Translates text
    798     * 
     798    *
    799799    * @access public
    800800    * @param string $text the text to be translated
     
    804804        return $text;
    805805    }
    806    
     806
    807807    /**
    808808    * Translates text
    809     * 
     809    *
    810810    * @access public
    811811    * @param string $text the text to be translated
     
    815815        return $text;
    816816    }
    817    
     817
    818818    /**
    819819    * Translates text by domain
    820     * 
     820    *
    821821    * @access public
    822822    * @param string $domain the language to translate the text into
     
    827827        return $text;
    828828    }
    829    
     829
    830830    /**
    831831    * Translates text by domain and category
    832     * 
     832    *
    833833    * @access public
    834834    * @param string $domain the language to translate the text into
     
    840840        return $text;
    841841    }
    842    
     842
    843843    /**
    844844    * Binds the text domain
    845     * 
     845    *
    846846    * @access public
    847847    * @param string $domain the language to translate the text into
    848     * @param string 
     848    * @param string
    849849    * @return string translated text
    850850    */
     
    852852        return $domain;
    853853    }
    854    
     854
    855855    /**
    856856    * Sets the text domain
    857     * 
     857    *
    858858    * @access public
    859859    * @param string $domain the language to translate the text into
  • trunk/services/admins.php

    r41 r42  
    11<?php
    22/**
    3  * admins.php 
     3 * admins.php
    44 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information
    55 */
     
    2323 * CONFIG
    2424 *****************************************************************************/
    25  
     25
    2626// Titles and navigation header.
    2727$nav->addPage(_("Administrators"), $_SERVER['PHP_SELF']);
    28    
     28
    2929// The object to validate form input.
    3030$fv = new FormValidator();
     
    6060 * MAIN
    6161 *****************************************************************************/
    62  
     62
    6363// We may want to use the add/edit interface from another script, so this
    6464// allows us to remember which page we came from so we can go back there.
     
    208208    $fv->isEmpty('username', _("<strong>Username</strong> cannot be blank."));
    209209    $fv->stringLength('username', 0, 255, _("<strong>Username</strong> must contain less than 256 characters."));
    210    
     210
    211211    $fv->isEmpty('userpass', _("<strong>Passwords</strong> cannot be blank."));
    212212    $fv->stringLength('userpass', 6, 36, _("<strong>Passwords</strong> must be between 6 and 36 characters long."));
    213    
     213
    214214    $fv->stringLength('first_name', 0, 255, _("<strong>First name</strong> must contain less than 256 characters."));
    215    
     215
    216216    $fv->stringLength('last_name', 0, 255, _("<strong>Last name</strong> must contain less than 256 characters."));
    217217
     
    219219    $fv->stringLength('email', 0, 255, _("<strong>Email</strong> must contain less than 256 characters."));
    220220    $fv->validateEmail('email');
    221    
     221
    222222    $fv->isEmpty('user_type', _("<strong>User type</strong> cannot be blank."));
    223223    $fv->stringLength('user_type', 0, 255, _("<strong>User type</strong> has an invalid selection."));
     
    265265    // Get the information for the form.
    266266    $qid = DB::query("
    267         SELECT * 
     267        SELECT *
    268268        FROM admin_tbl
    269269        WHERE admin_id = '" . addslashes($id) . "'
     
    274274        App::dieBoomerangURL();
    275275    }
    276    
     276
    277277    // Lock this record.
    278278    $lock->set('admin_tbl', 'admin_id', $id, $frm['username']);
    279    
     279
    280280    // Set misc values for the form.
    281281    $frm = array_merge(array(
     
    312312{
    313313    global $auth, $lock;
    314    
     314
    315315    $lock->select('admin_tbl', 'admin_id', $id);
    316316    if ($lock->isLocked() && !$lock->isMine()) {
     
    320320    // Break the cache because we are changing the list data.
    321321    SessionCache::breakCache($_SERVER['PHP_SELF']);
    322    
     322
    323323    // Get the information for this object.
    324324    $qid = DB::query("
     
    331331        App::dieBoomerangURL();
    332332    }
    333    
     333
    334334    // Get the information for this object.
    335335    $qid = DB::query("SELECT COUNT(*) from admin_tbl");
     
    357357{
    358358    global $auth;
    359    
     359
    360360    // Break the cache because we are changing the list data.
    361361    SessionCache::breakCache($_SERVER['PHP_SELF']);
    362    
     362
    363363    // Insert record data.
    364364    DB::query("
     
    382382    ");
    383383    $last_insert_id = mysql_insert_id(DB::getDBH());
    384    
     384
    385385    // Set admin password.
    386386    $auth->setPassword($last_insert_id, $frm['userpass']);
    387    
     387
    388388    // Create version.
    389389    $version = RecordVersion::getInstance($GLOBALS['auth']);
    390390    $version->create('admin_tbl', 'admin_id', $last_insert_id, $frm['username']);
    391    
     391
    392392    App::raiseMsg(sprintf(_("The Admin <strong>%s</strong> has been added."), $frm['username']), MSG_SUCCESS, __FILE__, __LINE__);
    393    
     393
    394394    return $last_insert_id;
    395395}
     
    398398{
    399399    global $auth, $lock;
    400    
     400
    401401    $lock->select('admin_tbl', 'admin_id', $frm['admin_id']);
    402402    if ($lock->isLocked() && !$lock->isMine()) {
     
    406406    // Break the cache because we are changing the list data.
    407407    SessionCache::breakCache($_SERVER['PHP_SELF']);
    408    
     408
    409409    // If the userpass is left blank or with the filler **** characters, we don't want to update it.
    410410    if (!empty($frm['userpass']) && !preg_match('/[\*]{4,}/', $frm['userpass'])) {
     
    412412        $auth->setPassword($frm['admin_id'], $frm['userpass']);
    413413    }
    414    
     414
    415415    // Update record data.
    416416    DB::query("
     
    440440    global $page;
    441441    global $so;
    442    
     442
    443443    $where_clause = '';
    444    
     444
    445445    // Build search query if available.
    446446    if (getFormData('search_query', false)) {
     
    460460    // Count the total number of records so we can do something about the page numbers.
    461461    $qid = DB::query("
    462         SELECT COUNT(*) 
    463         FROM admin_tbl 
     462        SELECT COUNT(*)
     463        FROM admin_tbl
    464464        $where_clause
    465465    ");
    466466    list($num_results) = mysql_fetch_row($qid);
    467    
     467
    468468    // Set page numbers now we know (needed for next step).
    469469    $page->setTotalItems($num_results);
    470470    $page->calculate();
    471    
     471
    472472    // Final SQL, with sort and page limiters.
    473473    $sql = "
    474         SELECT 
    475             admin_tbl.*, 
     474        SELECT
     475            admin_tbl.*,
    476476            a1.username AS added_admin_username,
    477477            a2.username AS modified_admin_username
     
    483483        " . $page->getLimitSQL() . "
    484484    ";
    485    
     485
    486486    // A unique key for this query, with the total_items in case db records
    487487    // were added since the last cache. This identifies a unique set of
     
    494494        Prefs::setValue('cache_hash', $cache_hash, $_SERVER['PHP_SELF']);
    495495    }
    496    
     496
    497497    if (SessionCache::isCached($_SERVER['PHP_SELF']) && false) {
    498498        // Get the cached results.
     
    505505            $list[] = $row;
    506506        }
    507            
     507
    508508        if (isset($list) && !empty($list)) {
    509509            // Cache the results.
  • trunk/services/css.php

    r41 r42  
    11<?php
    22/**
    3  * css.php 
     3 * css.php
    44 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information
    55 *
  • trunk/services/lock.php

    r41 r42  
    11<?php
    22/**
    3  * lock.php 
     3 * lock.php
    44 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information
    55 */
  • trunk/services/login.php

    r41 r42  
    11<?php
    22/**
    3  * login.php 
     3 * login.php
    44 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information
    55 */
     
    2424    } else {
    2525        App::raiseMsg(_("Login failed, please try again."), MSG_NOTICE, __FILE__, __LINE__);
    26         App::logMsg(sprintf('%s %s failed login using (MD5ed) password: %s', $auth->getVal('auth_name'), $frm['username'], md5($frm['password'])), LOG_NOTICE, __FILE__, __LINE__);
     26        App::logMsg(sprintf('%s %s failed login using (MD5ed) password: %s', ucfirst($auth->getVal('auth_name')), $frm['username'], md5($frm['password'])), LOG_NOTICE, __FILE__, __LINE__);
    2727    }
    2828}
  • trunk/services/logout.php

    r41 r42  
    11<?php
    22/**
    3  * logout.php 
     3 * logout.php
    44 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information
    55 */
  • trunk/services/logs.php

    r41 r42  
    11<?php
    22/**
    3  * logs.php 
     3 * logs.php
    44 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information
    55 */
     
    4848 * MAIN
    4949 *****************************************************************************/
    50  
     50
    5151// Allow realtime file stats.
    52 clearstatcache(); 
     52clearstatcache();
    5353
    5454// What action to take.
     
    6565    App::dieURL($_SERVER['PHP_SELF']);
    6666    break;
    67    
     67
    6868case 'clear' :
    6969//     $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET);
     
    7676    App::dieURL($_SERVER['PHP_SELF']);
    7777    break;
    78    
     78
    7979case 'archive' :
    8080//     $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET);
     
    9090    App::dieURL($_SERVER['PHP_SELF']);
    9191    break;
    92    
     92
    9393// case 'ouput' :
    9494//     $main_template = 'ouput';
    9595//     break;
    96    
     96
    9797case 'download' :
    9898    header('Content-Type: application/octet-stream');
     
    101101    die;
    102102    break;
    103    
     103
    104104default :
    105105    $list =& getLog(Prefs::getValue('log_file', 'logs_module'), getFormData('search_query'));
     
    137137
    138138function deleteLog($log_file)
    139 {   
     139{
    140140    if (!file_exists(App::getParam('log_directory') . '/' . $log_file)) {
    141141        App::raiseMsg(sprintf(_("Log file %s does not exist."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
     
    143143        return false;
    144144    }
    145    
     145
    146146    if (!is_writable(App::getParam('log_directory') . '/' . $log_file) && !is_writable(App::getParam('log_directory'))) {
    147147        App::raiseMsg(sprintf(_("Log file %s could not be deleted."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
     
    149149        return false;
    150150    }
    151    
     151
    152152    if (unlink(App::getParam('log_directory') . '/' . $log_file)) {
    153153        App::raiseMsg(sprintf(_("Log file %s has been deleted."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
     
    162162
    163163function clearLog($log_file)
    164 {   
     164{
    165165    if (!$fp = fopen(App::getParam('log_directory') . '/' . $log_file, 'r+')) {
    166166        App::raiseMsg(sprintf(_("Log file %s could not be opened."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
     
    168168        return false;
    169169    }
    170    
     170
    171171    flock($fp, LOCK_EX);
    172172    $ftruncate_return = ftruncate($fp, 0);
     
    185185
    186186function archiveLog($log_file)
    187 {   
     187{
    188188    $old_file_name = $log_file;
    189189    $new_file_name = $log_file . '__' . date('Y-m-d');
     
    198198        return false;
    199199    }
    200    
     200
    201201    App::raiseMsg(sprintf(_("Log file %s has been archived to %s."), $old_file_name, $new_file_name), MSG_NOTICE, __FILE__, __LINE__);
    202202    App::logMsg(sprintf('Log file %s has been archived to %s.', $old_file_name, $new_file_name), LOG_NOTICE, __FILE__, __LINE__);
     
    205205
    206206function printLog($log_file)
    207 {       
     207{
    208208    if (!is_file(App::getParam('log_directory') . '/' . $log_file)) {
    209209        App::raiseMsg(sprintf(_("Log file %s not found."), $log_file), MSG_WARNING, __FILE__, __LINE__);
     
    216216
    217217function &getLog($log_file, $search_query='')
    218 {   
     218{
    219219    if (!is_file(App::getParam('log_directory') . '/' . $log_file)) {
    220220        App::raiseMsg(sprintf(_("Log file %s not found."), $log_file), MSG_WARNING, __FILE__, __LINE__);
     
    223223    }
    224224    $log = file(App::getParam('log_directory') . '/' . $log_file);
    225    
     225
    226226    if ('' != trim($search_query)) {
    227227        if (getFormData('search_grep')) {
     
    237237{
    238238    global $valid_file_extensions;
    239    
     239
    240240    // Get a list of all files in the log directory.
    241241    $dir_handle = opendir(App::getParam('log_directory'));
  • trunk/services/password.php

    r41 r42  
    11<?php
    22/**
    3  * password.php 
     3 * password.php
    44 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information
    55 */
     
    1414 * CODE CONFIG
    1515 *****************************************************************************/
    16    
     16
    1717// Titles and navigation header.
    1818$nav->addPage(_("Change password"));
     
    4747        }
    4848    }
    49    
     49
    5050    if (!$fv->anyErrors() && false === $auth->authenticate($auth->getVal('username'), $frm['oldpassword'])) {
    5151        $fv->addError('oldpassword', _("Your <strong>Old password</strong> failed authentication."));
  • trunk/services/templates/admin_list.ihtml

    r41 r42  
    66    <span class="nowrap commandtext"><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=add'); ?>"><?php echo _("Add administrator"); ?></a></span>
    77    <br />
    8    
     8
    99    <input type="text" class="small" size="20" name="search_query" value="<?php echo getFormData('search_query'); ?>" title="<?php echo oTxt(_("Fields searched: Admin id, Username, Userpass, First name, Last name, Email, User type, Login abuse exempt, Blocked, Blocked reason, Abuse warning level, Seconds online, Last login datetime, Last access datetime, Last login ip, Added by user id, Modified by user id, Added datetime, Modified datetime.")); ?>" />
    1010    <input type="submit" value="<?php echo _("Search"); ?>" />
  • trunk/services/templates/list_info.ihtml

    r41 r42  
    44    <?php } ?>
    55    <span class="nowrap commanditem commandtext">
    6         <?php printf(_("Listing <strong>%s-%s</strong> of <strong>%s</strong> results on <strong>%s</strong> pages"), (0==$page->total_items ? 0 : $page->first_item+1), (0==$page->total_items ? 0 : $page->last_item+1), $page->total_items, $page->total_pages) ?> 
     6        <?php printf(_("Listing <strong>%s-%s</strong> of <strong>%s</strong> results on <strong>%s</strong> pages"), (0==$page->total_items ? 0 : $page->first_item+1), (0==$page->total_items ? 0 : $page->last_item+1), $page->total_items, $page->total_pages) ?>
    77        &nbsp;&nbsp; <a href="<?php echo App::oHREF($_SERVER['PHP_SELF'], false); ?>"><?php echo _("List all"); ?></a>
    88        &nbsp;&nbsp; <?php echo _("Per page"); ?>:&nbsp;<?php $page->printPerPageLinks() ?>
  • trunk/services/templates/lock.ihtml

    r41 r42  
    1 <?php 
     1<?php
    22if (!is_a($lock, 'RecordLock')) {
    33    return null;
     
    99
    1010    <p><?php
    11     printf(_("The record <strong>%s</strong> is currently being edited by <strong>%s</strong> (%d minutes elapsed). You cannot modify the record while it is locked by another user."), 
    12         $lock->getTitle(), 
    13         $lock->getEditor(), 
     11    printf(_("The record <strong>%s</strong> is currently being edited by <strong>%s</strong> (%d minutes elapsed). You cannot modify the record while it is locked by another user."),
     12        $lock->getTitle(),
     13        $lock->getEditor(),
    1414        date('i', $lock->getSecondsElapsed() + 60)
    1515    );
  • trunk/services/templates/versions_diff.ihtml

    r41 r42  
    1 <div id="commandbox">               
     1<div id="commandbox">
    22<?php if (!getFormData('current', false)) { ?>
    33    <span class="nowrap commandtext"><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=restore', array('version_id', 'version_title')); ?>"><?php echo _("Restore this saved version"); ?></a></span>
  • trunk/services/templates/versions_list.ihtml

    r41 r42  
    99    <th class="padleft"><?php echo _("By"); ?></th>
    1010</tr>
    11 <?php 
     11<?php
    1212$first = true;
    1313foreach ($versions as $v) { ?>
     
    2525    <td class="padleft nowrap"><?php echo $v['editor']; ?></td>
    2626</tr>
    27 <?php 
     27<?php
    2828$first = false;
    29 } 
     29}
    3030?>
    3131</table>
  • trunk/services/templates/versions_view.ihtml

    r41 r42  
    1 <div id="commandbox">               
     1<div id="commandbox">
    22<?php if (!getFormData('current', false)) { ?>
    33    <span class="nowrap commandtext"><a href="<?php echo App::oHREF($_SERVER['PHP_SELF'] . '?op=restore', array('version_id', 'version_title')); ?>"><?php echo _("Restore this saved version"); ?></a></span>
     
    1010<table class="list" border="0" cellspacing="0" cellpadding="4">
    1111<?php
    12 while ((list($k, $v_d) = each($data))) { 
     12while ((list($k, $v_d) = each($data))) {
    1313    ?>
    1414    <tr>
  • trunk/services/versions.php

    r41 r42  
    11<?php
    22/**
    3  * versions.php 
     3 * versions.php
    44 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information
    55 */
     
    110110 * TEMPLATE INITIALIZATION
    111111 *****************************************************************************/
    112  
     112
    113113include 'header.ihtml';
    114114include 'codebase/services/templates/' . $main_template;
  • trunk/tests/AppTest.php

    r41 r42  
    22/**
    33 * PHPUnit test case for App
    4  * 
    5  * The method skeletons below need to be filled in with 
    6  * real data so that the tests will run correctly. Replace 
    7  * all EXPECTED_VAL and PARAM strings with real data. 
    8  * 
     4 *
     5 * The method skeletons below need to be filled in with
     6 * real data so that the tests will run correctly. Replace
     7 * all EXPECTED_VAL and PARAM strings with real data.
     8 *
    99 * Created with PHPUnit_Skeleton on 2005-08-09
    1010 */
     
    124124//         App::dieURL('/die/to/this/url.php');
    125125//     }
    126 // 
     126//
    127127//     function test_dieboomerangurl()
    128128//     {
     
    131131//         $this->assertEquals($expected, $result);
    132132//     }
    133 // 
     133//
    134134//     function test_setboomerangurl()
    135135//     {
     
    138138//         $this->assertEquals($expected, $result);
    139139//     }
    140 // 
     140//
    141141//     function test_getboomerangurl()
    142142//     {
     
    145145//         $this->assertEquals($expected, $result);
    146146//     }
    147 // 
     147//
    148148//     function test_deleteboomerangurl()
    149149//     {
     
    152152//         $this->assertEquals($expected, $result);
    153153//     }
    154 // 
     154//
    155155//     function test_validboomerangurl()
    156156//     {
     
    159159//         $this->assertEquals($expected, $result);
    160160//     }
    161 // 
     161//
    162162//     function test_sslon()
    163163//     {
     
    166166//         $this->assertEquals($expected, $result);
    167167//     }
    168 // 
     168//
    169169//     function test_ssloff()
    170170//     {
  • trunk/tests/Auth_FileTest.php

    r41 r42  
    22/**
    33 * PHPUnit test case for Auth_File
    4  * 
    5  * The method skeletons below need to be filled in with 
    6  * real data so that the tests will run correctly. Replace 
    7  * all EXPECTED_VAL and PARAM strings with real data. 
    8  * 
     4 *
     5 * The method skeletons below need to be filled in with
     6 * real data so that the tests will run correctly. Replace
     7 * all EXPECTED_VAL and PARAM strings with real data.
     8 *
    99 * Created with PHPUnit_Skeleton on 2005-08-09
    1010 */
     
    7171//         $this->assertTrue($true);
    7272//     }
    73 // 
     73//
    7474//     function test_requireadminlogin()
    7575//     {
     
    7878//         $this->assertEquals($expected, $result);
    7979//     }
    80 // 
     80//
    8181//     function test__encrypt()
    8282//     {
     
    8585//         $this->assertEquals($expected, $result);
    8686//     }
    87 // 
     87//
    8888//     function test__salt()
    8989//     {
  • trunk/tests/Auth_SQLTest.php

    r41 r42  
    22/**
    33 * PHPUnit test case for Auth_SQL
    4  * 
    5  * The method skeletons below need to be filled in with 
    6  * real data so that the tests will run correctly. Replace 
    7  * all EXPECTED_VAL and PARAM strings with real data. 
    8  * 
     4 *
     5 * The method skeletons below need to be filled in with
     6 * real data so that the tests will run correctly. Replace
     7 * all EXPECTED_VAL and PARAM strings with real data.
     8 *
    99 * Created with PHPUnit_Skeleton on 2005-08-09
    1010 */
     
    5353            )
    5454        ");
    55        
     55
    5656    }
    5757
     
    212212//         $this->assertEquals($expected, $result);
    213213//     }
    214 // 
     214//
    215215//     function test_requireaccessclearance()
    216216//     {
  • trunk/tests/AuthorizeNetTest.php

    r41 r42  
    22/**
    33 * PHPUnit test case for AuthorizeNet
    4  * 
    5  * The method skeletons below need to be filled in with 
    6  * real data so that the tests will run correctly. Replace 
    7  * all EXPECTED_VAL and PARAM strings with real data. 
    8  * 
     4 *
     5 * The method skeletons below need to be filled in with
     6 * real data so that the tests will run correctly. Replace
     7 * all EXPECTED_VAL and PARAM strings with real data.
     8 *
    99 * Created with PHPUnit_Skeleton on 2005-08-09
    1010 */
     
    6363    {
    6464        $result_code = $this->AuthorizeNet->process();
    65        
     65
    6666        $this->assertTrue(false != $result_code, 'Processing did not return valid response. Do you have net access?');
    6767        $this->assertEquals('3', $result_code);
     
    8989//         $this->assertEquals($expected, $result);
    9090//     }
    91 // 
     91//
    9292//     function test__processresult()
    9393//     {
  • trunk/tests/CSSTest.php

    r41 r42  
    22/**
    33 * PHPUnit test case for CSS
    4  * 
    5  * The method skeletons below need to be filled in with 
    6  * real data so that the tests will run correctly. Replace 
    7  * all EXPECTED_VAL and PARAM strings with real data. 
    8  * 
     4 *
     5 * The method skeletons below need to be filled in with
     6 * real data so that the tests will run correctly. Replace
     7 * all EXPECTED_VAL and PARAM strings with real data.
     8 *
    99 * Created with PHPUnit_Skeleton on 2005-08-09
    1010 */
  • trunk/tests/DBSessionHandlerTest.php

    r41 r42  
    22/**
    33 * PHPUnit test case for DBSessionHandler
    4  * 
    5  * The method skeletons below need to be filled in with 
    6  * real data so that the tests will run correctly. Replace 
    7  * all EXPECTED_VAL and PARAM strings with real data. 
    8  * 
     4 *
     5 * The method skeletons below need to be filled in with
     6 * real data so that the tests will run correctly. Replace
     7 * all EXPECTED_VAL and PARAM strings with real data.
     8 *
    99 * Created with PHPUnit_Skeleton on 2005-08-09
    1010 */
  • trunk/tests/EmailTest.php

    r41 r42  
    22/**
    33 * PHPUnit test case for Email
    4  * 
    5  * The method skeletons below need to be filled in with 
    6  * real data so that the tests will run correctly. Replace 
    7  * all EXPECTED_VAL and PARAM strings with real data. 
    8  * 
     4 *
     5 * The method skeletons below need to be filled in with
     6 * real data so that the tests will run correctly. Replace
     7 * all EXPECTED_VAL and PARAM strings with real data.
     8 *
    99 * Created with PHPUnit_Skeleton on 2005-12-01
    1010 */
     
    3737//         $this->assertEquals($expected, $result);
    3838//     }
    39 // 
     39//
    4040//     function testgetparam()
    4141//     {
     
    4444//         $this->assertEquals($expected, $result);
    4545//     }
    46 // 
     46//
    4747//     function testsettemplate()
    4848//     {
     
    5151//         $this->assertEquals($expected, $result);
    5252//     }
    53 // 
     53//
    5454//     function testsetstring()
    5555//     {
     
    5858//         $this->assertEquals($expected, $result);
    5959//     }
    60 // 
     60//
    6161//     function testreplace()
    6262//     {
     
    6565//         $this->assertEquals($expected, $result);
    6666//     }
    67 // 
     67//
    6868//     function testsend()
    6969//     {
     
    7676    {
    7777        $testpool = file('_email_test_addresses.txt');
    78        
     78
    7979        $gc = 0;
    8080        $bc = 0;
  • trunk/tests/FormValidatorTest.php

    r41 r42  
    22/**
    33 * PHPUnit test case for FormValidator
    4  * 
    5  * The method skeletons below need to be filled in with 
    6  * real data so that the tests will run correctly. Replace 
    7  * all EXPECTED_VAL and PARAM strings with real data. 
    8  * 
     4 *
     5 * The method skeletons below need to be filled in with
     6 * real data so that the tests will run correctly. Replace
     7 * all EXPECTED_VAL and PARAM strings with real data.
     8 *
    99 * Created with PHPUnit_Skeleton on 2005-08-09
    1010 */
  • trunk/tests/Google_APITest.php

    r41 r42  
    55/**
    66 * PHPUnit test case for GoogleAPI
    7  * 
    8  * The method skeletons below need to be filled in with 
    9  * real data so that the tests will run correctly. Replace 
    10  * all EXPECTED_VAL and PARAM strings with real data. 
    11  * 
     7 *
     8 * The method skeletons below need to be filled in with
     9 * real data so that the tests will run correctly. Replace
     10 * all EXPECTED_VAL and PARAM strings with real data.
     11 *
    1212 * Created with PHPUnit_Skeleton on 2005-08-09
    1313 */
  • trunk/tests/ImageThumbTest.php

    r41 r42  
    55/**
    66 * PHPUnit test case for ImageThumb
    7  * 
    8  * The method skeletons below need to be filled in with 
    9  * real data so that the tests will run correctly. Replace 
    10  * all EXPECTED_VAL and PARAM strings with real data. 
    11  * 
     7 *
     8 * The method skeletons below need to be filled in with
     9 * real data so that the tests will run correctly. Replace
     10 * all EXPECTED_VAL and PARAM strings with real data.
     11 *
    1212 * Created with PHPUnit_Skeleton on 2005-08-09
    1313 */
  • trunk/tests/MCVETest.php

    r41 r42  
    55/**
    66 * PHPUnit test case for MCVE
    7  * 
    8  * The method skeletons below need to be filled in with 
    9  * real data so that the tests will run correctly. Replace 
    10  * all EXPECTED_VAL and PARAM strings with real data. 
    11  * 
     7 *
     8 * The method skeletons below need to be filled in with
     9 * real data so that the tests will run correctly. Replace
     10 * all EXPECTED_VAL and PARAM strings with real data.
     11 *
    1212 * Created with PHPUnit_Skeleton on 2005-08-09
    1313 */
  • trunk/tests/NavTest.php

    r41 r42  
    55/**
    66 * PHPUnit test case for Nav
    7  * 
    8  * The method skeletons below need to be filled in with 
    9  * real data so that the tests will run correctly. Replace 
    10  * all EXPECTED_VAL and PARAM strings with real data. 
    11  * 
     7 *
     8 * The method skeletons below need to be filled in with
     9 * real data so that the tests will run correctly. Replace
     10 * all EXPECTED_VAL and PARAM strings with real data.
     11 *
    1212 * Created with PHPUnit_Skeleton on 2005-08-09
    1313 */
  • trunk/tests/NodeHeirarchyTest.php

    r41 r42  
    55/**
    66 * PHPUnit test case for NodeHeirarchy
    7  * 
    8  * The method skeletons below need to be filled in with 
    9  * real data so that the tests will run correctly. Replace 
    10  * all EXPECTED_VAL and PARAM strings with real data. 
    11  * 
     7 *
     8 * The method skeletons below need to be filled in with
     9 * real data so that the tests will run correctly. Replace
     10 * all EXPECTED_VAL and PARAM strings with real data.
     11 *
    1212 * Created with PHPUnit_Skeleton on 2005-08-09
    1313 */
  • trunk/tests/PEditTest.php

    r41 r42  
    55/**
    66 * PHPUnit test case for PEdit
    7  * 
    8  * T\he method skeletons below need to be filled in with 
    9  * real data so that the tests will run correctly. Replace 
    10  * all EXPECTED_VAL and PARAM strings with real data. 
    11  * 
     7 *
     8 * T\he method skeletons below need to be filled in with
     9 * real data so that the tests will run correctly. Replace
     10 * all EXPECTED_VAL and PARAM strings with real data.
     11 *
    1212 * Created with PHPUnit_Skeleton on 2005-08-09
    1313 */
  • trunk/tests/PageNumbersTest.php

    r41 r42  
    55/**
    66 * PHPUnit test case for PageNumbers
    7  * 
    8  * The method skeletons below need to be filled in with 
    9  * real data so that the tests will run correctly. Replace 
    10  * all EXPECTED_VAL and PARAM strings with real data. 
    11  * 
     7 *
     8 * The method skeletons below need to be filled in with
     9 * real data so that the tests will run correctly. Replace
     10 * all EXPECTED_VAL and PARAM strings with real data.
     11 *
    1212 * Created with PHPUnit_Skeleton on 2005-08-09
    1313 */
  • trunk/tests/PageSequenceTest.php

    r41 r42  
    55/**
    66 * PHPUnit test case for PageSequence
    7  * 
    8  * The method skeletons below need to be filled in with 
    9  * real data so that the tests will run correctly. Replace 
    10  * all EXPECTED_VAL and PARAM strings with real data. 
    11  * 
     7 *
     8 * The method skeletons below need to be filled in with
     9 * real data so that the tests will run correctly. Replace
     10 * all EXPECTED_VAL and PARAM strings with real data.
     11 *
    1212 * Created with PHPUnit_Skeleton on 2005-08-09
    1313 */
  • trunk/tests/PayPalTest.php

    r41 r42  
    22/**
    33 * PHPUnit test case for PayPal
    4  * 
    5  * The method skeletons below need to be filled in with 
    6  * real data so that the tests will run correctly. Replace 
    7  * all EXPECTED_VAL and PARAM strings with real data. 
    8  * 
     4 *
     5 * The method skeletons below need to be filled in with
     6 * real data so that the tests will run correctly. Replace
     7 * all EXPECTED_VAL and PARAM strings with real data.
     8 *
    99 * Created with PHPUnit_Skeleton on 2005-08-09
    1010 */
     
    101101//         $result = $this->PayPal->incomingipnrequest();
    102102//     }
    103 // 
     103//
    104104//     function test_processipn()
    105105//     {
    106106//         $result = $this->PayPal->processipn();
    107107//     }
    108 // 
     108//
    109109//     function test_verifiedipn()
    110110//     {
  • trunk/tests/PrefsTest.php

    r41 r42  
    55/**
    66 * PHPUnit test case for Prefs
    7  * 
    8  * The method skeletons below need to be filled in with 
    9  * real data so that the tests will run correctly. Replace 
    10  * all EXPECTED_VAL and PARAM strings with real data. 
    11  * 
     7 *
     8 * The method skeletons below need to be filled in with
     9 * real data so that the tests will run correctly. Replace
     10 * all EXPECTED_VAL and PARAM strings with real data.
     11 *
    1212 * Created with PHPUnit_Skeleton on 2005-08-09
    1313 */
  • trunk/tests/RecordLockTest.php

    r41 r42  
    22/**
    33 * PHPUnit test case for RecordLock
    4  * 
    5  * The method skeletons below need to be filled in with 
    6  * real data so that the tests will run correctly. Replace 
    7  * all EXPECTED_VAL and PARAM strings with real data. 
    8  * 
     4 *
     5 * The method skeletons below need to be filled in with
     6 * real data so that the tests will run correctly. Replace
     7 * all EXPECTED_VAL and PARAM strings with real data.
     8 *
    99 * Created with PHPUnit_Skeleton on 2005-08-09
    1010 */
  • trunk/tests/RecordVersionTest.php

    r41 r42  
    22/**
    33 * PHPUnit test case for RecordVersion
    4  * 
    5  * The method skeletons below need to be filled in with 
    6  * real data so that the tests will run correctly. Replace 
    7  * all EXPECTED_VAL and PARAM strings with real data. 
    8  * 
     4 *
     5 * The method skeletons below need to be filled in with
     6 * real data so that the tests will run correctly. Replace
     7 * all EXPECTED_VAL and PARAM strings with real data.
     8 *
    99 * Created with PHPUnit_Skeleton on 2005-08-09
    1010 */
     
    3737        // Use fresh user table.
    3838        $this->Auth_SQL->initDB(true);
    39        
     39
    4040        // Insert test data.
    4141        DB::query("
     
    5656            )
    5757        ");
    58        
     58
    5959        $this->Auth_SQL->login('testuser', 'testpass');
    60        
     60
    6161        $this->RecordVersion =& RecordVersion::getInstance($this->Auth_SQL);
    6262        $this->RecordVersion->setParam(array('db_table' => 'test_version_tbl'));
  • trunk/tests/ScriptTimerTest.php

    r41 r42  
    55/**
    66 * PHPUnit test case for ScriptTimer
    7  * 
    8  * The method skeletons below need to be filled in with 
    9  * real data so that the tests will run correctly. Replace 
    10  * all EXPECTED_VAL and PARAM strings with real data. 
    11  * 
     7 *
     8 * The method skeletons below need to be filled in with
     9 * real data so that the tests will run correctly. Replace
     10 * all EXPECTED_VAL and PARAM strings with real data.
     11 *
    1212 * Created with PHPUnit_Skeleton on 2005-08-09
    1313 */
  • trunk/tests/SessionCacheTest.php

    r41 r42  
    55/**
    66 * PHPUnit test case for SessionCache
    7  * 
    8  * The method skeletons below need to be filled in with 
    9  * real data so that the tests will run correctly. Replace 
    10  * all EXPECTED_VAL and PARAM strings with real data. 
    11  * 
     7 *
     8 * The method skeletons below need to be filled in with
     9 * real data so that the tests will run correctly. Replace
     10 * all EXPECTED_VAL and PARAM strings with real data.
     11 *
    1212 * Created with PHPUnit_Skeleton on 2005-08-09
    1313 */
  • trunk/tests/SortOrderTest.php

    r41 r42  
    55/**
    66 * PHPUnit test case for SortOrder
    7  * 
    8  * The method skeletons below need to be filled in with 
    9  * real data so that the tests will run correctly. Replace 
    10  * all EXPECTED_VAL and PARAM strings with real data. 
    11  * 
     7 *
     8 * The method skeletons below need to be filled in with
     9 * real data so that the tests will run correctly. Replace
     10 * all EXPECTED_VAL and PARAM strings with real data.
     11 *
    1212 * Created with PHPUnit_Skeleton on 2005-08-09
    1313 */
  • trunk/tests/SpellCheckTest.php

    r41 r42  
    55/**
    66 * PHPUnit test case for SpellCheck
    7  * 
    8  * The method skeletons below need to be filled in with 
    9  * real data so that the tests will run correctly. Replace 
    10  * all EXPECTED_VAL and PARAM strings with real data. 
    11  * 
     7 *
     8 * The method skeletons below need to be filled in with
     9 * real data so that the tests will run correctly. Replace
     10 * all EXPECTED_VAL and PARAM strings with real data.
     11 *
    1212 * Created with PHPUnit_Skeleton on 2005-08-09
    1313 */
  • trunk/tests/TemplateGlueTest.php

    r41 r42  
    55/**
    66 * PHPUnit test case for TemplateGlue
    7  * 
    8  * The method skeletons below need to be filled in with 
    9  * real data so that the tests will run correctly. Replace 
    10  * all EXPECTED_VAL and PARAM strings with real data. 
    11  * 
     7 *
     8 * The method skeletons below need to be filled in with
     9 * real data so that the tests will run correctly. Replace
     10 * all EXPECTED_VAL and PARAM strings with real data.
     11 *
    1212 * Created with PHPUnit_Skeleton on 2005-08-09
    1313 */
  • trunk/tests/UploadTest.php

    r41 r42  
    55/**
    66 * PHPUnit test case for Upload
    7  * 
    8  * The method skeletons below need to be filled in with 
    9  * real data so that the tests will run correctly. Replace 
    10  * all EXPECTED_VAL and PARAM strings with real data. 
    11  * 
     7 *
     8 * The method skeletons below need to be filled in with
     9 * real data so that the tests will run correctly. Replace
     10 * all EXPECTED_VAL and PARAM strings with real data.
     11 *
    1212 * Created with PHPUnit_Skeleton on 2005-08-09
    1313 */
  • trunk/tests/UtilitiesTest.php

    r41 r42  
    55/**
    66 * PHPUnit test case for Utilities
    7  * 
    8  * The method skeletons below need to be filled in with 
    9  * real data so that the tests will run correctly. Replace 
    10  * all EXPECTED_VAL and PARAM strings with real data. 
    11  * 
     7 *
     8 * The method skeletons below need to be filled in with
     9 * real data so that the tests will run correctly. Replace
     10 * all EXPECTED_VAL and PARAM strings with real data.
     11 *
    1212 * Created with PHPUnit_Skeleton on 2005-08-09
    1313 */
  • trunk/tests/_email_test_addresses.txt

    r41 r42  
    44"Bob Smith" asdf@domain.com
    55"Bob Smith"a sldkf &D*&F^*&^# @#*$ @#* asdf@domain.com
    6  "white space" <asdf@domain.com> 
    7  whitespace@domain.com 
     6 "white space" <asdf@domain.com>
     7 whitespace@domain.com
    88asdf@domain.com (hello donkey)
    99<asdf@domain.com>
  • trunk/tests/_skel.php

    r41 r42  
    3939//     if (!preg_match('/^\./', $file) && is_file($dir . '/' . $file)) {
    4040//         echo 'Proccessing ' . realpath($dir . '/' . $file) . "\n";
    41 //         
     41//
    4242//         preg_match('/([^\.]+)\..*$/i', $file, $match);
    4343//         $classname = $match[1];
    44 // 
     44//
    4545//         $ps = new PHPUnit_Skeleton($classname, '../lib/' . $file);
    46 //         
     46//
    4747//         // Generate the test class.
    4848//         // Default settings will not include any parent class methods, but
    4949//         // will include private methods.
    5050//         $ps->createTestClass();
    51 //         
     51//
    5252//         // Write the new test class to file.
    5353//         // By default, code to run the test will be included.
    5454//         $ps->writeTestClass();
    55 // 
     55//
    5656//     }
    5757// }
Note: See TracChangeset for help on using the changeset viewer.