Ignore:
Timestamp:
Dec 12, 2006 12:28:01 AM (17 years ago)
Author:
quinn
Message:

Q - Final check-in before releasing trunk as version 2.1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/docs/coding_standards.txt

    r209 r214  
    77======================================================================
    88
    9 We're following the PEAR coding standards, with minor modifications.
    10 
    11 This is essential reading:
     9Our standards follow closely the PEAR coding standards.
     10
     11Essential reading:
    1212http://pear.php.net/manual/en/standards.php
    1313
     
    2424                        remains "Auth_SQL"
    2525
    26 some_file.ihtml         HTML file, which may or may not have some PHP,
     26some_file.inc.html      HTML file, which may or may not have some PHP,
    2727                        but will be included by some other PHP file. Never
    2828                        includes sensitive code as these files may be accessed
     
    3030
    3131script.cli.php          A command-line executable script, possibly executed
    32                         with CRON, usually outputs TEXT, not HTML.
    33 
    34 dbname.mysql            Database schema file that goes with the application.
     32                        with CRON. Outputs TEXT if any instead of HTML.
     33
     34schema.mysql            Database schema file that goes with the application.
    3535
    3636main.screen.css         CSS file with media: screen/print/all
     
    182182        // Here comes the HTML...
    183183        ?>
    184         <div align="right" class="sc-tiny">
    185         [&nbsp;<a href="<?php echo $app->oHREF('contact.php') ?>">Contact us</a>&nbsp;]
     184        <div class="sc-tiny">
     185            <a href="<?php echo $app->ohref('/contact.php') ?>">Contact us</a>
    186186        </div>
    187187        <?php
     
    200200http://java.sun.com/products/jdk/javadoc/writingdoccomments/index.html
    201201
     202Here is an example of the codebase method Email::validEmail():
     203
    202204    <?php
    203205    /**
    204      * Description of function.
     206     * Validates an email address based on the recommendations in RFC 3696.
     207     * Is more loose than restrictive, to allow the many valid variants of
     208     * email addresses while catching the most common mistakes. Checks an array too.
     209     * http://www.faqs.org/rfcs/rfc822.html
     210     * http://www.faqs.org/rfcs/rfc2822.html
     211     * http://www.faqs.org/rfcs/rfc3696.html
     212     * http://www.faqs.org/rfcs/rfc1035.html
    205213     *
    206214     * @access  public
    207      * @param   string  $db_table   Database table.
    208      * @param   string  $db_column  Database column containing set or enum datatype.
    209      * @return  array               The set/enum values or false on failure.
     215     * @param   mixed  $email  Address to check, string or array.
     216     * @return  bool    Validity of address.
    210217     * @author  Quinn Comendant <quinn@strangecode.com>
    211      * @version 1.0
    212      * @since   24 Feb 2004 19:34:04
     218     * @since   30 Nov 2005 22:00:50
    213219     */
    214     function getSetEnumFieldValues()
     220    function validEmail($email)
    215221    {
    216         $db =& DB::getInstance();
    217        
    218         $qid = $db->query("SHOW COLUMNS FROM $db_table LIKE '$db_col'",false);
    219 
    220         $row = mysql_fetch_row($qid);
    221         if (preg_match('/^enum|^set/i', $row[1]) && preg_match_all("/'([^']*)'/", $row[1], $match)) {
    222             return $match[1];
     222        $app =& App::getInstance();
     223   
     224        // If an array, check values recursively.
     225        if (is_array($email)) {
     226            foreach ($email as $e) {
     227                if (!$this->validEmail($e)) {
     228                    return false;
     229                }
     230            }
     231            return true;
    223232        } else {
    224             return false;
     233            // To be valid email address must match regex and fit within the lenth constraints.
     234            if (preg_match($this->getParam('regex'), $email, $e_parts) && strlen($e_parts[2]) < 64 && strlen($e_parts[3]) < 255) {
     235                return true;
     236            } else {
     237                $app->logMsg(sprintf('Invalid email: %s', $email), LOG_INFO, __FILE__, __LINE__);
     238                return false;
     239            }
    225240        }
    226241    }
Note: See TracChangeset for help on using the changeset viewer.