------------------------------------------------------------ revno: 857 committer: Jon Phillips <[email protected]> branch nick: aikiframework timestamp: Sat 2011-06-18 02:43:03 -0500 message: * nuked aiki holding tanks in the assets folder where custom aiki code was to be migrated to, but want to start peeling back so we can separate admin from custom/site/app folder. * added comments to php.php code * updated makefiles to remove the */aiki/ folders * This will require a full autogen.sh removed: src/assets/apps/aiki/ src/assets/apps/aiki/Makefile.am src/assets/extensions/aiki/ src/assets/extensions/aiki/Makefile.am src/assets/images/aiki/ src/assets/images/aiki/Makefile.am src/assets/javascript/aiki/ src/assets/javascript/aiki/Makefile.am modified: configure.ac src/assets/apps/Makefile.am src/assets/extensions/Makefile.am src/assets/images/Makefile.am src/assets/javascript/Makefile.am src/libs/php.php
-- lp:aikiframework https://code.launchpad.net/~aikiframework-devel/aikiframework/trunk Your team Aiki Framework Developers is subscribed to branch lp:aikiframework. To unsubscribe from this branch go to https://code.launchpad.net/~aikiframework-devel/aikiframework/trunk/+edit-subscription
=== modified file 'configure.ac' --- configure.ac 2011-06-16 02:07:53 +0000 +++ configure.ac 2011-06-18 07:43:03 +0000 @@ -529,16 +529,12 @@ src/Makefile \ src/assets/Makefile \ src/assets/apps/Makefile \ - src/assets/apps/aiki/Makefile \ src/assets/apps/admin/Makefile \ src/assets/apps/admin/images/Makefile \ src/assets/apps/admin/images/icons/Makefile \ src/assets/images/Makefile \ - src/assets/images/aiki/Makefile \ src/assets/extensions/Makefile \ - src/assets/extensions/aiki/Makefile \ src/assets/javascript/Makefile \ - src/assets/javascript/aiki/Makefile \ src/assets/uploads/Makefile \ src/libs/database/Makefile \ src/libs/Makefile \ === modified file 'src/assets/apps/Makefile.am' --- src/assets/apps/Makefile.am 2011-06-06 05:34:28 +0000 +++ src/assets/apps/Makefile.am 2011-06-18 07:43:03 +0000 @@ -23,13 +23,11 @@ # Subdirectories to be built SUBDIRS = \ - admin \ - aiki + admin # Subdirectories to distribute DIST_SUBDIRS = \ - admin \ - aiki + admin # Additional files to distribute EXTRA_DIST = \ === removed directory 'src/assets/apps/aiki' === removed file 'src/assets/apps/aiki/Makefile.am' --- src/assets/apps/aiki/Makefile.am 2011-06-06 05:34:28 +0000 +++ src/assets/apps/aiki/Makefile.am 1970-01-01 00:00:00 +0000 @@ -1,39 +0,0 @@ -# Process this file with automake to produce Makefile.in -*-Makefile-*- - -# Copyright (c) 2010-2011 Aiki Lab Pte Ltd - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. - -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -# Written by Steven Garcia - -# The source files -aiki_src_files = - -# Subdirectories to be built -SUBDIRS = - -# Subdirectories to distribute -DIST_SUBDIRS = - -# Additional files to distribute -EXTRA_DIST = \ - $(aiki_src_files) - -# The directory to put the files -aiki_srcdir = \ - $(pkgdatadir)/assets/apps/aiki - -# The source data -aiki_src_DATA = \ - $(aiki_src_files) === modified file 'src/assets/extensions/Makefile.am' --- src/assets/extensions/Makefile.am 2011-06-06 06:09:06 +0000 +++ src/assets/extensions/Makefile.am 2011-06-18 07:43:03 +0000 @@ -22,10 +22,10 @@ readme # Subdirectories to be built -SUBDIRS = aiki +SUBDIRS = # Subdirectories to distribute -DIST_SUBDIRS = aiki +DIST_SUBDIRS = # Additional files to distribute EXTRA_DIST = \ === removed directory 'src/assets/extensions/aiki' === removed file 'src/assets/extensions/aiki/Makefile.am' --- src/assets/extensions/aiki/Makefile.am 2011-06-06 06:09:06 +0000 +++ src/assets/extensions/aiki/Makefile.am 1970-01-01 00:00:00 +0000 @@ -1,39 +0,0 @@ -# Process this file with automake to produce Makefile.in -*-Makefile-*- - -# Copyright (c) 2010-2011 Aiki Lab Pte Ltd - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. - -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -# Written by Steven Garcia - -# The source files -aiki_src_files = - -# Subdirectories to be built -SUBDIRS = - -# Subdirectories to distribute -DIST_SUBDIRS = - -# Additional files to distribute -EXTRA_DIST = \ - $(aiki_src_files) - -# The directory to put the files -aiki_srcdir = \ - $(pkgdatadir)/assets/extensions/aiki - -# The source data -aiki_src_DATA = \ - $(aiki_src_files) === modified file 'src/assets/images/Makefile.am' --- src/assets/images/Makefile.am 2011-06-06 06:09:06 +0000 +++ src/assets/images/Makefile.am 2011-06-18 07:43:03 +0000 @@ -24,10 +24,10 @@ favicon.ico # Subdirectories to be built -SUBDIRS = aiki +SUBDIRS = # Subdirectories to distribute -DIST_SUBDIRS = aiki +DIST_SUBDIRS = # Additional files to distribute EXTRA_DIST = \ === removed directory 'src/assets/images/aiki' === removed file 'src/assets/images/aiki/Makefile.am' --- src/assets/images/aiki/Makefile.am 2011-06-06 06:09:06 +0000 +++ src/assets/images/aiki/Makefile.am 1970-01-01 00:00:00 +0000 @@ -1,39 +0,0 @@ -# Process this file with automake to produce Makefile.in -*-Makefile-*- - -# Copyright (c) 2010-2011 Aiki Lab Pte Ltd - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. - -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -# Written by Steven Garcia - -# The source files -aiki_src_files = - -# Subdirectories to be built -SUBDIRS = - -# Subdirectories to distribute -DIST_SUBDIRS = - -# Additional files to distribute -EXTRA_DIST = \ - $(aiki_src_files) - -# The directory to put the files -aiki_srcdir = \ - $(pkgdatadir)/assets/images/aiki - -# The source data -aiki_src_DATA = \ - $(aiki_src_files) === modified file 'src/assets/javascript/Makefile.am' --- src/assets/javascript/Makefile.am 2011-06-15 07:40:41 +0000 +++ src/assets/javascript/Makefile.am 2011-06-18 07:43:03 +0000 @@ -22,12 +22,10 @@ aiki.js # Subdirectories to be built -SUBDIRS = \ - aiki +SUBDIRS = # Subdirectories to distribute -DIST_SUBDIRS = \ - aiki +DIST_SUBDIRS = # Additional files to distribute EXTRA_DIST = \ === removed directory 'src/assets/javascript/aiki' === removed file 'src/assets/javascript/aiki/Makefile.am' --- src/assets/javascript/aiki/Makefile.am 2010-12-27 20:53:48 +0000 +++ src/assets/javascript/aiki/Makefile.am 1970-01-01 00:00:00 +0000 @@ -1,39 +0,0 @@ -# Process this file with automake to produce Makefile.in -*-Makefile-*- - -# Copyright (C) 2010 Aikilab - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. - -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -# Written by Steven Garcia - -# The source files -aiki_src_files = - -# Subdirectories to be built -SUBDIRS = - -# Subdirectories to distribute -DIST_SUBDIRS = - -# Additional files to distribute -EXTRA_DIST = \ - $(aiki_src_files) - -# The directory to put the files -aiki_srcdir = \ - $(pkgdatadir)/assets/javascript/aiki - -# The source data -aiki_src_DATA = \ - $(aiki_src_files) === modified file 'src/libs/php.php' --- src/libs/php.php 2011-06-15 02:54:01 +0000 +++ src/libs/php.php 2011-06-18 07:43:03 +0000 @@ -29,12 +29,16 @@ * * @category Aiki * @package Library + * + * @todo rename class Php */ class php { -// vars user by odd, counter, adn mod functions. +/** + * Variables user by odd, counter, adn mod functions. + */ private $odd=0, $mod=0, @@ -44,28 +48,33 @@ /* - * Parser a text - * @param string $text. Input text. - * @return string. Output text. + * Parse over text + * @param string $text Input text + * @global aiki $aiki global aiki instance + * @return string. Output text. */ - public function parser($text){ + public function parser($text) + { global $aiki; + /** + * @todo why is this not just deleted? kill or keep? + */ //$text = htmlspecialchars_decode($text); $text = stripslashes($text); - if (preg_match ("/\<form(.*)\<php (.*) php\>(.*)\<\/form\>/Us", $text)){ + if (preg_match ("/\<form(.*)\<php (.*) php\>(.*)\<\/form\>/Us", $text)) return $text; - } // now, we will divided the text. The array is always // out of marker, in of markers, out of markers, in of markers $tokens= preg_split("/(<php)|(php>)/", $text); - $parsed = ""; + + $parsed = ""; - do { + do { - $parsed .= current($tokens); + $parsed .= current($tokens); $php_function = trim(next($tokens)); $php_output=""; @@ -74,11 +83,12 @@ $len = strcspn($php_function," -("); $word = ( $len ? substr($php_function,0,$len): ""); - $rest = preg_replace('/;$/',"", trim( substr($php_function,$len+1))); + $rest = preg_replace('/;$/',"",trim( substr($php_function,$len+1))); $rest = preg_replace('/\)$/',"", $rest); //evaluate each case.. - switch ($word) { + switch ($word) + { case ""; break; // 'if' is a very special case @@ -86,11 +96,14 @@ $php_output= $this->php_ifelse($php_function); break; // counters and odds - case "setcounter": $this->setcounter( $this->mtoken($rest)); break; - case "counter" : $php_output = $this->counter($rest); break; - case "odd" : $php_output = $this->odd(); break; - case "mod" : $php_output = $this->mod($rest); break; - + case "setcounter": $this->setcounter( $this->mtoken($rest)); + break; + case "counter" : $php_output = $this->counter($rest); + break; + case "odd" : $php_output = $this->odd(); + break; + case "mod" : $php_output = $this->mod($rest); + break; // getinfo case "getinfo" : $php_output = $this->getinfo($rest); @@ -100,28 +113,33 @@ case "replace": case "str_replace": $partial = $this->mtoken($rest); - if ( isset($partial[2]) ){ - $php_output = str_replace($partial[0],$partial[1],$partial[2]); - } + if ( isset($partial[2]) ) + $php_output = str_replace($partial[0],$partial[1], + $partial[2]); break; case "substr": $partial = $this->mtoken($rest); if ( isset($partial[2])) { - $php_output = substr($partial[0], $partial[1],$partial[2]); + $php_output = + substr($partial[0], $partial[1],$partial[2]); } else { $php_output = substr($partial[0], $partial[1]); } break; case "htmlspecialchars": - $temp= preg_replace( array('/^"(.*)"$/', '/^\'(.*)\'$/'),'$1',$rest); + $temp = preg_replace(array( + '/^"(.*)"$/', '/^\'(.*)\'$/'),'$1',$rest); $php_output = htmlspecialchars($temp); break; case '$aiki': - if ( preg_match('/\$aiki\-\>(.*)\-\>(.*)\((.*)\)\;?/Us', $php_function,$partial) ){ - $php_output = $this->aiki_function($partial[1],$partial[2],$partial[3]); + if ( preg_match('/\$aiki\-\>(.*)\-\>(.*)\((.*)\)\;?/Us', + $php_function,$partial) ) + { + $php_output = $this->aiki_function($partial[1], + $partial[2],$partial[3]); } break; @@ -130,148 +148,200 @@ break; default : - if ( isset($config['debug']) ){ + if ( isset($config['debug']) ) $php_output = "<php $php_function php>"; - } } $parsed .= $php_output; } while ( next($tokens)!== false ) ; - + return $parsed; - } + } // end of parser function + /** - * Internal function to parser argument + * Internal function to parse an argument + * + * @param string $text text for processing + * @param string $separator separating character + * @return string */ - -function mtoken ( $text, $separator=',' ){ +function mtoken ( $text, $separator=',' ) +{ $max = strlen($text); $state= 0 ; /* state 0: waiting a token 1: over ' delimited string 2 over " delimited string 3 over a no delimited string, 4 waiting coma */ - $word = ""; - $resul= array(); + $word = ""; + $result = array(); - for($i=0;$i<$max;$i++){ + for($i=0;$i<$max;$i++) + { $char = $text[$i]; // continue over white space - if ( ( $state==0 || $state==4) && ( $char==" " || $char=="\n" || $char=="\r" || $char=="\t" )) { + if ( ( $state==0 || $state==4) && + ( $char==" " || $char=="\n" || $char=="\r" || $char=="\t" )) + { $continue; - } elseif ( ($i+1)==$max && ($state>0 && $state<4) ) { //last character must be added + } elseif ( ($i+1)==$max && ($state>0 && $state<4) ) + { + //last character must be added if ($char==$separator) { //last character is a separator - $resul[]= $word; - $resul[]= ""; + $result[]= $word; + $result[]= ""; } else { - $resul[]= $word . $char; + $result[]= $word . $char; } $word=""; } elseif ( ( $char=="'" && $state==1) || //anotate string ends. ( $char=='"' && $state==2) || - ( $char==$separator && $state==3) ) { + ( $char==$separator && $state==3) ) + { $state= ( $state==3 ? 0 : 4); - $resul[]= $word ; + $result[]= $word ; $word=""; - } elseif ( $char==$separator && $state==4 ) { //found separator when waiting + } elseif ( $char==$separator && $state==4 ) + { + //found separator when waiting $state=0 ; - } elseif ( $char==$separator && $state==0 ) { //found separator when waiting a token. - $resul[]=""; + } elseif ( $char==$separator && $state==0 ) + { + //found separator when waiting a token. + $result[]=""; $state=0 ; - } elseif ( ($char=="'" || $char=='"' ) && $state==0) { //initiate a string + } elseif ( ($char=="'" || $char=='"' ) && $state==0) + { + //initiate a string $state= ( $char=="'" ? 1: 2) ; - } elseif ( $char=='\\' ) { + } elseif ( $char=='\\' ) + { $i++; $word .= $text[$i]; - } elseif ( $state==0){ + } elseif ( $state==0) + { $state=3; $word = $char; } else { $word .= $char; } - } // for - if ( $word ) { - $resul[]=$word; - } - - return $resul; - } - - - -function evalNeg($text){ - $text= trim($text); - if ( preg_match ( '/^\$_(GET|POST|SESSION|REQUEST|COOKIE)\[(.*)\]$/', $text, $cap )){ - $key= preg_replace ( "/^['\"]|['\"]$/",'',$cap[2]); - switch ( $cap[1] ) { - case "POST" : $text= isset($_POST[$key]) ? $_POST[$key] : "" ; break; - case "GET" : $text= isset($_GET[$key]) ? $_GET[$key] : "" ; break; - case "REQUEST": $text= isset($_REQUEST[$key]) ? $_REQUEST[$key] : "" ; break; - case "SESSION": $text= isset($_SESSION[$key]) ? $_SESSION[$key] : "" ; break; - case "COOKIE" : $text= isset($_COOKIE[$key]) ? $_COOKIE[$key] : "" ; break; - default: - $text=""; - } - } - $text = preg_replace ( "/^(!?)\s?['\"]|['\"]$/",'\\1', $text ); - return ( $text && $text[0]=='!' ? !substr($text,1) : $text ); - } - - -function php_ifelse($text){ - - //divide the text - // @TODO improve this. - $partial= preg_split('/if |then |else /s', $text); - - if ( !isset($partial[3])) { - $partial[3]=""; - } - - if ( preg_match ( '/([^<>=]+)(=|==|>|<|>=|<=|<>| in | not in )([^<>=]+)/is', $partial[1],$evaluation)){ - $first = $this->evalNeg($evaluation[1]); - $second= $this->evalNeg($evaluation[3]); - - switch ( $evaluation[2]){ - case "<" : $condition= $first < $second ; break; - case ">" : $condition= $first > $second ; break; - case "<=": $condition= $first <= $second ; break; - case ">=": $condition= $first >= $second ; break; - case "<>": $condition= $first <> $second ; break; - case "=": - case "==": $condition= $first == $second ; break; - case " in " : $condition = stripos($second,$first)!==false;break; - case " not in ": $condition = stripos($second,$first)===false;break; - } - - } else { - $condition = $this->evalNeg($partial[1]); - } - - return (bool) $condition ? $partial[2]: $partial[3]; - } - - -public function aiki_function($class,$function, $para){ - global $aiki; - - // load class if not exists.. - if (!isset($aiki->$class)){ - $aiki->load($class); - if (!isset($aiki->$class)) { - return "Sorry, [$class] doesn't exist"; - } - } - - if ($para){ - return $aiki->$class->$function($para); - } else { - return $aiki->$class->$function(); - } - -} + } // end of for loop + + if ( $word ) + $result[]=$word; + + return $result; +} // end of mtoken function + + +/** + * Evaluates and extracts value or not from a string + * + * @param string $text text for processing + * @return string + * @todo this function has a bad name + */ +function evalNeg($text) +{ + $text= trim($text); + /** + * @todo $cap is an out of scope variable, needs fixing + */ + if ( preg_match ( '/^\$_(GET|POST|SESSION|REQUEST|COOKIE)\[(.*)\]$/', + $text, $cap )) + { + $key= preg_replace ( "/^['\"]|['\"]$/",'',$cap[2]); + switch ( $cap[1] ) { + case "POST" : $text= isset($_POST[$key]) ? $_POST[$key] : ""; + break; + case "GET" : $text= isset($_GET[$key]) ? $_GET[$key] : ""; + break; + case "REQUEST" : $text= isset($_REQUEST[$key]) ? + $_REQUEST[$key] : "" ; break; + case "SESSION" : $text= isset($_SESSION[$key]) ? + $_SESSION[$key] : "" ; break; + case "COOKIE" : $text= isset($_COOKIE[$key]) ? + $_COOKIE[$key] : "" ; break; + default: + $text=""; + } + } + $text = preg_replace ( "/^(!?)\s?['\"]|['\"]$/",'\\1', $text ); + return ( $text && $text[0]=='!' ? !substr($text,1) : $text ); + +} // end of evalNeg function + + +/** + * Parse a string an evaluate like a php if else statemetn + * + * @param string $text text for processing + * @return bool + */ +function php_ifelse($text) +{ + //divide the text + // @TODO improve this. + $partial= preg_split('/if |then |else /s', $text); + + if ( !isset($partial[3])) { + $partial[3]=""; + } + + if ( preg_match ( + '/([^<>=]+)(=|==|>|<|>=|<=|<>| in | not in )([^<>=]+)/is', + $partial[1],$evaluation)) + { + $first = $this->evalNeg($evaluation[1]); + $second= $this->evalNeg($evaluation[3]); + + switch ( $evaluation[2]) + { + case "<" : $condition= $first < $second ; break; + case ">" : $condition= $first > $second ; break; + case "<=": $condition= $first <= $second ; break; + case ">=": $condition= $first >= $second ; break; + case "<>": $condition= $first <> $second ; break; + case "=": + case "==": $condition= $first == $second ; break; + case " in " : $condition = stripos($second,$first)!==false;break; + case " not in ": $condition = stripos($second,$first)===false;break; + } + } else { + $condition = $this->evalNeg($partial[1]); + } + return (bool) $condition ? $partial[2]: $partial[3]; +} // end of php_ifelse function + + +/** + * Implements a parsed php like function class. + * + * @param string $class classname + * @param string $function function name + * @param string $para some text for processing + * @global aiki $aiki global aiki instance + * @return mixed + */ +public function aiki_function($class,$function, $para) +{ + global $aiki; + + // load class if not exists.. + if (!isset($aiki->$class)) + { + $aiki->load($class); + if (!isset($aiki->$class)) + return "Sorry, [$class] doesn't exist"; + } + + if ($para) + return $aiki->$class->$function($para); + else + return $aiki->$class->$function(); +} // end of aiki_function /* @@ -280,26 +350,45 @@ */ - -function odd(){ +/** + * If number is odd or even, then outputs string for odd or even, respectively. + * @return string + */ +function odd() +{ $this->odd= ( $this->odd==0 ? 1:0); return ( $this->odd ? "odd" : "even"); } -function setcounter($para){ +/** + * Sets a counter + * + * @param array $para array items for parsing into a counter setup + */ +function setcounter($para) +{ $this->counters[$para[0]] = (isset($para[1]) ? $para[1] : 1); $this->increments[$para[0]] = (isset($para[2]) ? (int) $para[2] :1); $this->initialized[$para[0]]= false; } -function counter($counter){ - if ( !isset( $this->counters[$counter]) ) { +/** + * Handles a counter + * + * @param string $counter array key name + * @return integer + */ +function counter($counter) +{ + if ( !isset( $this->counters[$counter]) ) + { $this->counters[$counter]=0; $this->increments[$counter]=1; $this->initialized[$counter]=true; - } elseif ( ! $this->initialized[$counter] ) { + } elseif ( ! $this->initialized[$counter] ) + { $this->initialized[$counter]=true; } else { $this->counters[$counter]+= $this->increments[$counter]; @@ -308,7 +397,14 @@ } -function mod($factor){ +/** + * Standard mod function + * + * @param integer $factor + * @return integer + */ +function mod($factor) +{ $factor= (int)$factor; $cRet = ( $factor != 0 ? $this->mod % $factor: 0); $this->mod++; @@ -317,39 +413,49 @@ /** - * return information about aiki version, and runtime (queries and time) + * Returns information about aiki version, and runtime (queries and time) * - * @param string $what. can be version, hidden-version, queries,hidden-queries,time,hidden-time. - * @return string. + * @param string $what. can be version, hidden-version, queries, + * hidden-queries, time,hidden-time. + * @global array $db global db instance + * @return string */ -function getinfo($what) { - switch ($what) { +function getinfo($what) +{ + switch ($what) + { case "version": case "hidden-version": - return $what=="version" ? AIKI_VERSION : "\n<!-- aikiframework version: ". AIKI_VERSION . "." . AIKI_REVISION . " -->\n"; + return $what=="version" ? + AIKI_VERSION : "\n<!-- aikiframework version: ". AIKI_VERSION . + "." . AIKI_REVISION . " -->\n"; case "queries" : case "hidden-queries" : global $db; - return $what=="queries" ? $db->num_queries : "\n<!-- queries: ". $db->num_queries ."-->\n"; + return $what=="queries" ? + $db->num_queries : "\n<!-- queries: ". $db->num_queries ."-->\n"; case "time": case "hidden-time": global $start_time; $end = (float) array_sum(explode(' ',microtime())); $end_time = sprintf("%.4f", ($end-$start_time)); - return $what=="time" ? $end_time : "\n <!-- Time: ".$end_time." seconds -->\n"; + return $what=="time" ? + $end_time : "\n <!-- Time: ".$end_time." seconds -->\n"; default: return $what; } -} +} // end of getinfo + /** * Determine is a string is a SQL statement and only one. * - * @param string $sql Sql to be tested. - * @return boolean. + * @param string $sql Sql to be tested. + * @return boolean */ -private function is_sql_select_statement( $sql) { +private function is_sql_select_statement( $sql) +{ // with this two step all delimited string was substitute with a q $sql= strtr( $sql, array("\\'"=>"", "\\" . '"' =>"")); $sql= preg_replace("/('[^']*')|(\"[^\"]*\")/"," q ",$sql); @@ -360,16 +466,21 @@ /** * Return the first field of first row of a query. * - * @param string $sql. Must be a select statement. - * @return mixed + * @param string $sql. Must be a select statement. + * @global array $db global db instance + * @return mixed * */ - -private function sql($sql){ +private function sql($sql) +{ global $db; $sql= preg_replace( array('/^"(.*)"$/', '/^\'(.*)\'$/'),'$1',$sql); - if (!$this->is_sql_select_statement($sql) ) { + /** + * @todo bare string must be managed or removed + */ + if (!$this->is_sql_select_statement($sql) ) + { return "invalid SQL SELECT"; } return $db->get_var($sql,0,0);
_______________________________________________ Mailing list: https://launchpad.net/~aikiframework-devel Post to : [email protected] Unsubscribe : https://launchpad.net/~aikiframework-devel More help : https://help.launchpad.net/ListHelp

