[Cs-content-commits] SF.net SVN: cs-content:[481] trunk/1.0
PHP Templating & Includes System
Brought to you by:
crazedsanity
From: <cra...@us...> - 2010-07-28 00:49:23
|
Revision: 481 http://cs-content.svn.sourceforge.net/cs-content/?rev=481&view=rev Author: crazedsanity Date: 2010-07-28 00:49:16 +0000 (Wed, 28 Jul 2010) Log Message: ----------- Fix cleaning for numeric values. /cs_globalFunctions.class.php: * string_from_array(): -- fix SQL quoting for int/integer/numeric/number/decimal/float values when an array of values is passed. -- add "-" to the list of excluded characters -- add "number" and "int" as synonyms for integer/numeric /tests/testOfCSGlobalFunctions.php: * test_cleanString(): -- integer/numeric both return negative numbers (the "-" isn't cleaned) Modified Paths: -------------- trunk/1.0/cs_globalFunctions.class.php trunk/1.0/tests/testOfCSGlobalFunctions.php Added Paths: ----------- trunk/1.0/useForCLI.patch Modified: trunk/1.0/cs_globalFunctions.class.php =================================================================== --- trunk/1.0/cs_globalFunctions.class.php 2010-07-12 23:37:31 UTC (rev 480) +++ trunk/1.0/cs_globalFunctions.class.php 2010-07-28 00:49:16 UTC (rev 481) @@ -176,7 +176,12 @@ } else { //now format it properly. - $array[$myIndex] = $this->cleanString($array[$myIndex], $myCleanStringArg); + $myUseSqlQuotes = null; + if(in_array($myCleanStringArg, array('int', 'integer', 'numeric', 'number', 'decimal', 'float'))) { + $myUseSqlQuotes = false; + } + $array[$myIndex] = $this->cleanString($array[$myIndex], $myCleanStringArg, $myUseSqlQuotes); + unset($myUseSqlQuotes); } } } @@ -507,15 +512,17 @@ $cleanThis = preg_replace("/[^0-9-+() ]/","",$cleanThis); break; + case "int": case "integer": case "numeric": + case "number": //Remove everything that's not numeric. if(is_null($cleanThis)) { $cleanThis = "NULL"; $sqlQuotes = 0; } else { - $cleanThis = preg_replace("/[^0-9]/","",$cleanThis); + $cleanThis = preg_replace("/[^0-9\-]/","",$cleanThis); } break; Modified: trunk/1.0/tests/testOfCSGlobalFunctions.php =================================================================== --- trunk/1.0/tests/testOfCSGlobalFunctions.php 2010-07-12 23:37:31 UTC (rev 480) +++ trunk/1.0/tests/testOfCSGlobalFunctions.php 2010-07-28 00:49:16 UTC (rev 481) @@ -54,8 +54,8 @@ 'email' => '@_-34..JuSTTHIS', 'email_plus_spaces' => '@_-34..JuST THIS', 'phone_fax' => '()+-34 ', - 'integer' => '34', - 'numeric' => '34', + 'integer' => '-34', + 'numeric' => '-34', 'decimal' => '34..', 'float' => '34..', 'name' => '\'JuSTTHIS', @@ -72,7 +72,7 @@ $cleanedData = $gf->cleanString($cleanThis, $name); //NOTE::: passing "%" in the message data causes an exception with the simpletest framework. - $this->assertEqual($expected, $cleanedData); + $this->assertEqual($expected, $cleanedData, "Cleaning test '". $name ."' FAILED... expected=(". $expected ."), got (". $cleanedData ."), "); } Added: trunk/1.0/useForCLI.patch =================================================================== --- trunk/1.0/useForCLI.patch (rev 0) +++ trunk/1.0/useForCLI.patch 2010-07-28 00:49:16 UTC (rev 481) @@ -0,0 +1,53 @@ +Index: code/lib/cs-content/cs_genericPage.class.php +=================================================================== +--- code/lib/cs-content/cs_genericPage.class.php (revision 480) ++++ code/lib/cs-content/cs_genericPage.class.php (working copy) +@@ -277,7 +277,7 @@ + if(!strlen($out)) { + $this->gfObj->debug_print($out); + $this->gfObj->debug_print($this->mainTemplate); +- $this->gfObj->debug_print("MANUAL FILE CONTENTS::: ". htmlentities(file_get_contents($this->tmplDir .'/'. $this->mainTemplate))); ++ $this->gfObj->debug_print("MANUAL FILE CONTENTS::: ". htmlentities(file_get_contents($this->mainTemplate))); + exit(__METHOD__ .": mainTemplate (". $this->mainTemplate .") was empty...?"); + } + +Index: code/lib/cs-content/contentSystem.class.php +=================================================================== +--- code/lib/cs-content/contentSystem.class.php (revision 480) ++++ code/lib/cs-content/contentSystem.class.php (working copy) +@@ -99,7 +99,7 @@ + /** + * The CONSTRUCTOR. Duh. + */ +- public function __construct($siteRoot=null) { ++ public function __construct($siteRoot=null, $section=null) { + parent::__construct(); + + //setup the section stuff... +@@ -109,8 +109,12 @@ + //figure out the section & subsection stuff. + $requestUri = preg_replace('/\/$/', '', $_SERVER['REQUEST_URI']); + $this->fullSectionArr = explode('/', $requestUri); //TODO: will this cope with an APPURL being set? +- $this->section = $this->clean_url($_SERVER['REQUEST_URI']); + ++ if(is_null($section)) { ++ $section = @$_SERVER['REQUEST_URI']; ++ } ++ $this->section = $this->clean_url($section); ++ + $this->initialize_locals($siteRoot); + }//end __construct() + //------------------------------------------------------------------------ +@@ -736,8 +740,10 @@ + * Called when something is broken. + */ + private function die_gracefully($details=NULL) { +- if(isset($_SERVER['SERVER_PROTOCOL']) && $this->templateObj->template_file_exists('system/404.shared.tmpl')) { +- header('HTTP/1.0 404 Not Found'); ++ if($this->templateObj->template_file_exists('system/404.shared.tmpl')) { ++ if(isset($_SERVER['SERVER_PROTOCOL'])) { ++ header('HTTP/1.0 404 Not Found'); ++ } + //Simple "Page Not Found" error... show 'em. + $this->templateObj->add_template_var('main', $this->templateObj->file_to_string('system/404.shared.tmpl')); + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |