private static function _recFormat($rec) { $rec["id"]=0+$rec["id"]; $rec["pid"]=0+$rec["pid"]; $rec["width"]=0+$rec["width"]; $rec["height"]=0+$rec["height"]; $rec["bytes"]=0+$rec["bytes"]; $rec["type"]=0+$rec["type"]; $rec["name_id"]=0+$rec["name_id"]; $rec["name_sized"]=0+$rec["name_sized"]; if(lib::mquotes_runtime()) { $rec["title"]=stripslashes($rec["title"]); $rec["credit"]=stripslashes($rec["credit"]); } $rec["filename"]=($rec["name"]?(($rec["name_id"]?($rec["id"].$rec["size_delim"]):"").$rec["name"]):$rec["id"]).(($rec["type"]==MEDIA_TYPE_IMG)?($rec["name_sized"]?($rec["size_delim"].$rec["width"]."x".$rec["height"]):""):"").".".$rec["extension"]; $rec["file_path"]=$rec["directory"]."/".$rec["filename"]; /* if(!$rec["bytes"]) { $fs=false; if(@file_exists($file))$fs=@filesize($rec["file_path"]); if($fs)db::q("UPDATE ".db::tnm(self::$class)." SET `bytes`=".$fs." WHERE `id`=".$rec["id"],false); } */ $rec["url"]=FLEX_APP_DIR_ROOT.$rec["file_path"]; $rec["url_thumb"]=self::_thumb($rec,self::$config["uploaderThumbExt"]); return $rec; }
public static function fetch($fields=array(),$filters=array(),$order=array(),$range=array()) { $sl=self::$c->silent(); $t=db::tMeta(self::$class); $fs=array_keys($t); $sel=array(); if(is_string($fields) && $fields!="")$fields=explode(",",$fields); if(!is_array($fields))$fields=array(); foreach($fields as $field) { if(!is_string($field))continue; if(!in_array($field,$fs))continue; $sel[]="`".$field."`"; } if(!count($sel))$sel=$fs; $fts=array(); foreach($filters as $filter) { if(is_string($filter)) { $fts[]=$filter; continue; } if(is_array($filter)) { if(isset($filter[0]) && (in_array($filter[0],$fs)) && isset($filter[1]) && isset($filter[2])) { if(($t[$filter[0]]["type"]=="string") || ($t[$filter[0]]["type"]=="text")) { $filter[2]="".$filter[2]; $type="string"; } else $type="other"; $fts[]=array($type,$filter[2],"AND",$filter[0],$filter[1]); } } } $fts=db::filtersMake($fts,true,true,false); $q="SELECT ".implode(",",$sel)." FROM ".db::tnm(self::$class).($fts?(" WHERE ".$fts):""); if(!is_array($order))$c=0; else $c=count($order); if($c)$q.=" ORDER BY `".$order[0]."`".(isset($order[1])?(" ".$order[1]):""); if(!is_array($range))$c=0; else $c=count($range); if($c>0)$q.=" LIMIT ".($c==1?("0,".$range[0]):($range[0].",".$range[1])); $r=db::q($q,!self::$c->silent()); if($r===false)return false; $recs=array(); $mqrt=lib::mquotes_runtime(); while($rec=@mysql_fetch_assoc($r)) { if(isset($rec["id"]))$rec["id"]=0+$rec["id"]; if(isset($rec["act"]))$rec["act"]=0+$rec["act"]; if(isset($rec["nolayout"]))$rec["nolayout"]=0+$rec["nolayout"]; if(isset($rec["show_title"]))$rec["show_title"]=0+$rec["show_title"]; if(isset($rec["alias"]) && $mqrt)$rec["alias"]=stripslashes($rec["alias"]); if(isset($rec["title"]) && $mqrt)$rec["title"]=stripslashes($rec["title"]); if(isset($rec["meta_description"]) && $mqrt)$rec["meta_description"]=stripslashes($rec["meta_description"]); if(isset($rec["meta_keywords"]) && $mqrt)$rec["meta_keywords"]=stripslashes($rec["meta_keywords"]); $recs[]=$rec; } return $recs; }