ErrorMsg[] = DB_ERRORMSG_102; } else { if (isset ($columns) && is_array ($columns)) { $thiz->columns = $columns; } $lcolumns = array_keys ($thiz->columns); // get column names from schema.php // make search string if (strlen ($searchstr) > 0) { $searchstr = 'if ($'.$searchstr; $search = array(" NOT ", " AND ", " && $(", " OR ", " || $(", "=", "> ==","<>", "< ==", "if ($(", " LIKE "); $replace = array(" !", " && $", " && ($", " || $", " || ($", " == ", ">=","!=", "<=", "if (($", "~"); $searchstr = str_replace ($search, $replace, $searchstr); $search = array ("/(\!)(\w+) /", "/= (\d+)/", "/([\(]*)(\S+)~(')*(%*\w+%*)(')*/", "/%/"); $replace = array ("\$2 \$1", "= '\$1'", "\$1preg_match(\"/^\$4$/i\", \$2)", "[\\w\\s]*"); $searchstr = preg_replace ($search, $replace, $searchstr).') { $f = true; } else { $f = false; }'; // check if perf cols are set if (strpos ($searchstr, '$id')) { $idset = true; } } if($idset && preg_match("/id\s+==\s+(\d+)/",$searchstr,$matchid)) { $item=str_replace(array("id","=="),array("\$item","="),$matchid[0]); $item.=";"; eval($item); // $item=$matchid[0]; if(is_file($table."/".$item.$thiz->ext)) // WE GOT DIRECT HIT { $first[0] = trim ($item); $found = false; $fp=fopen($table."/".$item.$thiz->ext,"r"); $tcontent=fread($fp,filesize( $table."/".$item.$thiz->ext)); fclose($fp); $tcontent=str_replace("\n",'',$tcontent); $content = array_merge ($first,explode("\n",$tcontent,strlen($tcontent))); $y = 0;$i = 0; foreach ($lcolumns as $col) { $$col = trim($content[$y++]); if ($col == 'id' || $col == 'lastupd') { settype($$col, "integer"); } if (is_array ($cols)) { if (in_array ($col, $cols)) { $tmp[$col] = $$col; } } else { $tmp[$col] = $$col; } } if (is_array ($tmp)) { if (is_array ($cols)) { // order selected columns as set in SQL-string foreach ($cols as $col) { $tmp2[$col] = $tmp[$col]; } $tmp = $tmp2; } if (strlen ($searchstr) > 0) { // run search string if exist eval ($searchstr); if ($f) { $rs[$i++] = $tmp; } } else { $rs[$i++] = $tmp; } } } }else if ($dh = @opendir ($table)) { $i = 0; while (($item = readdir ($dh)) !== false) { if ($item != "." && $item != ".." && $item != "schema.php" ) { // make recordset $y = 0; // make filename $first[0] = str_replace($thiz->ext,'',trim ($item)); if($lcolumns[1]=='lastupd')$first[1]=0; // bug fix if ((!$idset) || (($idset && $idset == $first[0]) ) || ($idset && $idset == $first[0]) ) { $fp=fopen($table."/".$item,"r"); $tcontent=fread($fp,filesize( $table."/".$item)); fclose($fp); $tcontent=str_replace("\n",'',$tcontent); $content = array_merge ($first,explode("\n",$tcontent,strlen($tcontent))); foreach ($lcolumns as $col) { $$col = trim($content[$y++]); if ($col == 'id' ) { settype($$col, "integer"); } if (is_array ($cols)) { // return selected columns if (in_array ($col, $cols)) { $tmp[$col] = $$col; } } else { // return all columns (*) $tmp[$col] = $$col; } } } ///// if (is_array ($tmp)) { if (is_array ($cols)) { // order selected columns as set in SQL-string foreach ($cols as $col) { $tmp2[$col] = $tmp[$col]; } $tmp = $tmp2; } if (strlen ($searchstr) > 0) { // run search string if exist eval ($searchstr); if ($f) { $rs[$i++] = $tmp; } } else { $rs[$i++] = $tmp; } } ///// } } closedir($dh); } else { $thiz->ErrorMsg[] = DB_ERRORMSG_100; } } if (is_array ($rs)) { $thiz->rowset = $rs; return true; } else { return false; } } ?>