Changeset 32


Ignore:
Timestamp:
Dec 11, 2005 7:33:45 PM (18 years ago)
Author:
scdev
Message:
 
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/install.sh

    r31 r32  
    1414
    1515# If old log locations exists, copy to new directory.
    16 if [ -f "$sitebase/codebase/logs/app_error_log" ] || [ -f "$sitebase/codebase/logs/php_error_log" ]; then
     16if [ `ls -1 $sitebase/codebase/logs/ | wc -l` -gt 0 ]; then
    1717    echo "Moving logs to new log directory: $sitebase/log/";
    18     mv -v --backup $sitebase/codebase/logs/* $sitebase/log/;
     18    mv -vfb $sitebase/codebase/logs/* $sitebase/log/;
    1919fi
    2020
  • trunk/lib/App.inc.php

    r31 r32  
    8181       
    8282        // For classes that require db tables, do we check that a table exists and create if missing?
    83         'db_create_tables' => null,
     83        'db_create_tables' => true,
    8484
    8585        // The level of error reporting. Don't set this to 0 to suppress messages, instead use display_errors to control display.
     
    366366            $this =& App::getInstance();
    367367        }
    368 
    369         if (!$this->running) {
     368       
     369        $message = trim($message);
     370
     371        if (!$this->running || '' == $message) {
    370372            return false;
    371373        }
     
    543545    /**
    544546     * Sets which query arguments will be carried persistently between requests.
    545      * Values in the _carry_queries array will be copied to URLs (via oHREF()) and
     547     * Values in the _carry_queries array will be copied to URLs (via App::url()) and
    546548     * to hidden input values (via printHiddenSession()).
    547549     *
     
    566568    /**
    567569     * Outputs a fully qualified URL with a query of all the used (ie: not empty)
    568      * keys and values, including optional queries. This allows simple printing of
    569      * links without needing to know which queries to add to it. If cookies are not
     570     * keys and values, including optional queries. This allows mindless retention
     571     * of query arguments across page requests. If cookies are not
    570572     * used, the session id will be propogated in the URL.
    571573     *
    572      * @param  string $url                 The initial url
    573      * @param  mixed  $carry_args          Additional url arguments to carry in the query,
    574      *                                     or FALSE to prevent carrying queries. Can be any of the following formats:
    575      *                                     -array('key1', key2', key3')  <-- to save these keys if in the form data.
    576      *                                     -array('key1'=>'value', key2'='value')  <-- to set keys to default values if not present in form data.
    577      *                                     -false  <-- To not carry any queries. If URL already has queries those will be retained.
     574     * @param  string $url              The initial url
     575     * @param  mixed  $carry_args       Additional url arguments to carry in the query,
     576     *                                  or FALSE to prevent carrying queries. Can be any of the following formats:
     577     *                                      array('key1', key2', key3')  <-- to save these keys if in the form data.
     578     *                                      array('key1'=>'value', key2'='value')  <-- to set keys to default values if not present in form data.
     579     *                                      false  <-- To not carry any queries. If URL already has queries those will be retained.
    578580     *
    579581     * @param  mixed  $always_include_sid  Always add the session id, even if using_trans_sid = true. This is required when
     
    583585     * @return string url with attached queries and, if not using cookies, the session id
    584586     */
    585     function oHREF($url='', $carry_args=null, $always_include_sid=false)
     587    function url($url, $carry_args=null, $always_include_sid=false)
    586588    {
    587589        if (!isset($this) || !is_a($this, 'App')) {
     
    617619       
    618620        // Get the first delimiter that is needed in the url.
    619         $delim = preg_match('/\?/', $url) ? ini_get('arg_separator.output') : '?';
     621        $delim = strpos($url, '?') !== false ? ini_get('arg_separator.output') : '?';
     622
    620623       
    621624        $q = '';
     
    667670        }
    668671    }
     672
     673    /**
     674     * Returns a HTML-friendly URL processed with App::url and & replaced with &amp;
     675     *
     676     * @access  public
     677     * @param   string  $url    Input URL to parse.
     678     * @return  string          URL with App::url() and htmlentities() applied.
     679     * @author  Quinn Comendant <quinn@strangecode.com>
     680     * @since   09 Dec 2005 17:58:45
     681     */
     682    function oHREF($url, $carry_args=null, $always_include_sid=false)
     683    {
     684        if (!isset($this) || !is_a($this, 'App')) {
     685            $this =& App::getInstance();
     686        }
     687       
     688        $url = $this->url($url, $carry_args, $always_include_sid);
     689       
     690        // Replace any & not followed by an html or unicode entity with it's &amp; equivalent.
     691        $url = preg_replace('/&(?![\w\d#]{1,10};)/', '&amp;', $url);
     692       
     693        return $url;
     694    }
    669695   
    670696    /**
     
    674700     * @param  mixed  $carry_args        Additional url arguments to carry in the query,
    675701     *                                   or FALSE to prevent carrying queries. Can be any of the following formats:
    676      *                                   -array('key1', key2', key3')  <-- to save these keys if in the form data.
    677      *                                   -array('key1'=>'value', key2'='value')  <-- to set keys to default values if not present in form data.
    678      *                                   -false  <-- To not carry any queries. If URL already has queries those will be retained.
     702     *                                      array('key1', key2', key3')  <-- to save these keys if in the form data.
     703     *                                      array('key1'=>'value', key2'='value')  <-- to set keys to default values if not present in form data.
     704     *                                      false  <-- To not carry any queries. If URL already has queries those will be retained.
    679705     */
    680706    function printHiddenSession($carry_args=null)
    681     {   
     707    {
    682708        if (!isset($this) || !is_a($this, 'App')) {
    683709            $this =& App::getInstance();
     
    762788        }
    763789
    764         $url = $this->oHREF($url, $carry_args, $always_include_sid);
     790        $url = $this->url($url, $carry_args, $always_include_sid);
    765791       
    766792        header(sprintf('Location: %s', $url));
  • trunk/lib/Auth_SQL.inc.php

    r31 r32  
    2222    // Default param values.
    2323    var $_default_params = array(
     24   
     25        // Message displayed by requireLogin().
     26        'login_required_message' => 'Please login',
    2427       
    2528        // Automatically create table and verify columns. Better set to false after site launch.
     
    537540     * Redirect user to login page if they are not logged in.
    538541     *
    539      * @param string $msg    The text description of a message to raise.
     542     * @param string $message The text description of a message to raise.
    540543     * @param int    $type    The type of message: MSG_NOTICE,
    541544     *                        MSG_SUCCESS, MSG_WARNING, or MSG_ERR.
     
    544547     * @access public
    545548     */
    546     function requireLogin($msg='', $type=MSG_NOTICE, $file=null, $line=null)
     549    function requireLogin($message='', $type=MSG_NOTICE, $file=null, $line=null)
    547550    {
    548551        if (!$this->isLoggedIn()) {
    549             if ('' != $msg) {
    550                 App::raiseMsg($msg, $type, $file, $line);
    551             }
     552            // Display message for requiring login.
     553            App::raiseMsg($message, $type, $file, $line);
     554
    552555            // Login scripts must have the same 'login' tag for boomerangURL verification/manipulation.
    553556            App::setBoomerangURL(absoluteMe(), 'login');
     
    820823     * @param  constant $security_zone   string of comma delimited priviliges for the zone
    821824     */
    822     function requireAccessClearance($security_zone, $msg='')
     825    function requireAccessClearance($security_zone, $message='')
    823826    {
    824827        return true;
     
    828831         * user has no privilege, DIE with a message. */
    829832        if (!in_array($this->getVal('priv'), $zone_members) || !$this->getVal('priv')) {
    830             $msg = empty($msg) ? _("You have insufficient privileges to view that page.") : $msg;
    831             App::raiseMsg($msg, MSG_NOTICE, __FILE__, __LINE__);
     833            $message = empty($message) ? _("You have insufficient privileges to view that page.") : $message;
     834            App::raiseMsg($message, MSG_NOTICE, __FILE__, __LINE__);
    832835            App::dieBoomerangURL();
    833836        }
  • trunk/lib/Captcha.inc.php

    r31 r32  
    142142        ?>
    143143        <label for="sc-captcha"><?php echo _("Reverse Turing Test") ?></label>
    144         <p class="help">Please enter the number here to prove you are a human. This is a measure to prevent spam robots from submitting this form.</p>
    145         <pre style="font-size: 1px;"><?php echo $ascii ?></pre>
     144        <p class="help"><?php echo _("Please type the following number to prove you are a human. This is a measure to prevent spam robots from submitting this form.") ?></p>
     145        <pre style="font-size: 0.5em;"><?php echo $ascii ?></pre>
    146146        <input name="sc-captcha" id="sc-captcha" type="text" />
    147147        <input name="sc-captcha-hash" type="hidden" value="<?php echo $hash ?>" />
  • trunk/lib/TemplateGlue.inc.php

    r31 r32  
    105105        }
    106106    }
    107     foreach ($values as $item) {
    108         $selected = ($item == $preselected) ? ' selected' : '';
    109         ?><option value="<?php echo $item; ?>"<?php echo $selected; ?>><?php echo oTxt($item); ?></option>
     107    foreach ($values as $v) {
     108        $selected = ($v == $preselected) ? ' selected' : '';
     109        ?><option value="<?php echo $v; ?>"<?php echo $selected; ?>><?php echo oTxt($v); ?></option>
     110        <?php
     111    }
     112}
     113
     114/**
     115 * Prints radio buttons from a set/enum column.
     116 *
     117 * @param  string $db_table   database table to lookup
     118 * @param  string $db_col     database column to lookup
     119 */
     120function printEnumRadios($name, $db_table, $db_col, $preselected, $blank=false)
     121{
     122    $values = getSetEnumFieldValues($db_table, $db_col);
     123    if ($values === false) {
     124        return false;
     125    }
     126
     127    foreach ($values as $v) {
     128        $selected = ($v == $preselected) ? ' selected' : '';
     129        ?><input type="radio" name="<?php echo $name ?>" id="<?php echo $v; ?>" value="<?php echo $v; ?>"<?php echo $selected; ?> /><label for="<?php echo $v; ?>"><?php echo oTxt($v); ?></label>
    110130        <?php
    111131    }
     
    150170    $row_cnt = 0;
    151171    $col_cnt = 0;
    152     foreach ($values as $item) {
     172    foreach ($values as $v) {
    153173        if ($col_cnt == $columns) {
    154174            // Begin a new row.
     
    166186       
    167187        // Look for preselected value.
    168         if (in_array($item, $preselected)) {
     188        if (in_array($v, $preselected)) {
    169189            $checked = ' checked="checked"';
    170190        } else {
     
    173193        if ('allone' == $flag) {
    174194            // Print a cell with multidimentioal array checkboxes.
    175             $html_name = 'dbcol[' . $db_col . '][' . $item . ']';
     195            $html_name = 'dbcol[' . $db_col . '][' . $v . ']';
    176196        } else {
    177197            // Print a cell with basic named checkboxes.
    178             $html_name = $db_col . '[' . $item . ']';
    179         }
    180         ?><td><input type="checkbox" name="<?php echo $html_name ?>" id="<?php echo $html_name ?>"<?php echo $checked; ?> /><label for="<?php echo $html_name ?>"><?php echo oTxt($item); ?></label></td>
     198            $html_name = $db_col . '[' . $v . ']';
     199        }
     200        ?><td><input type="checkbox" name="<?php echo $html_name ?>" id="<?php echo $html_name ?>"<?php echo $checked; ?> /><label for="<?php echo $html_name ?>"><?php echo oTxt($v); ?></label></td>
    181201        <?php
    182202    }
     
    228248    $row_cnt = 0;
    229249    $col_cnt = 0;
    230     foreach ($values as $item) {
     250    foreach ($values as $v) {
    231251        if ($col_cnt == $columns) {
    232252            // Begin a new row.
     
    244264       
    245265        // Look for preselected value.
    246         if (in_array($item, $preselected)) {
     266        if (in_array($v, $preselected)) {
    247267            $checked = ' checked="checked"';
    248268        } else {
     
    250270        }
    251271        // Print a cell with basic named checkboxes.
    252         ?><td><input type="radio" name="<?php echo $db_col; ?>" id="<?php echo $db_col; ?>" value="<?php echo $item ?>"<?php echo $checked; ?> /><label for="<?php echo $db_col ?>"><?php echo oTxt($item); ?></label></td>
     272        ?><td><input type="radio" name="<?php echo $db_col; ?>" id="<?php echo $db_col; ?>" value="<?php echo $v ?>"<?php echo $checked; ?> /><label for="<?php echo $db_col ?>"><?php echo oTxt($v); ?></label></td>
    253273        <?php
    254274    }
  • trunk/lib/Utilities.inc.php

    r31 r32  
    9797
    9898    // & becomes &amp;. Exclude any occurance where the & is followed by a alphanum or unicode caracter.
    99     $search['ampersand']        = '/&((?![\w\d#]{1,10};))/';
    100     $replace['ampersand']       = '&amp;\\1';
     99    $search['ampersand']        = '/&(?![\w\d#]{1,10};)/';
     100    $replace['ampersand']       = '&amp;';
    101101
    102102    return preg_replace($search, $replace, htmlentities($txt, ENT_QUOTES, App::getParam('character_set')));
Note: See TracChangeset for help on using the changeset viewer.