Changeset 214 for trunk/docs/coding_standards.txt
- Timestamp:
- Dec 12, 2006 12:28:01 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/docs/coding_standards.txt
r209 r214 7 7 ====================================================================== 8 8 9 We're following the PEAR coding standards, with minor modifications.10 11 This is essential reading:9 Our standards follow closely the PEAR coding standards. 10 11 Essential reading: 12 12 http://pear.php.net/manual/en/standards.php 13 13 … … 24 24 remains "Auth_SQL" 25 25 26 some_file.i htmlHTML file, which may or may not have some PHP,26 some_file.inc.html HTML file, which may or may not have some PHP, 27 27 but will be included by some other PHP file. Never 28 28 includes sensitive code as these files may be accessed … … 30 30 31 31 script.cli.php A command-line executable script, possibly executed 32 with CRON , usually outputs TEXT, notHTML.33 34 dbname.mysql Database schema file that goes with the application.32 with CRON. Outputs TEXT if any instead of HTML. 33 34 schema.mysql Database schema file that goes with the application. 35 35 36 36 main.screen.css CSS file with media: screen/print/all … … 182 182 // Here comes the HTML... 183 183 ?> 184 <div align="right"class="sc-tiny">185 [ <a href="<?php echo $app->oHREF('contact.php') ?>">Contact us</a> ]184 <div class="sc-tiny"> 185 <a href="<?php echo $app->ohref('/contact.php') ?>">Contact us</a> 186 186 </div> 187 187 <?php … … 200 200 http://java.sun.com/products/jdk/javadoc/writingdoccomments/index.html 201 201 202 Here is an example of the codebase method Email::validEmail(): 203 202 204 <?php 203 205 /** 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 205 213 * 206 214 * @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. 210 217 * @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 213 219 */ 214 function getSetEnumFieldValues()220 function validEmail($email) 215 221 { 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; 223 232 } 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 } 225 240 } 226 241 }
Note: See TracChangeset
for help on using the changeset viewer.