$max_ln)) $ret_valu='false'; switch ($typ) { case 'str': if(!(preg_match($str_string, $vlu))) $ret_valu='false'; break; case 'name': if(!(preg_match($name_string, $vlu))) $ret_valu='false'; break; case 'num': if(!(preg_match($num_string, $vlu))) $ret_valu='false'; break; case 'phone': if(!(preg_match($phone_string, $vlu))) $ret_valu='false'; break; case 'email': if(!(preg_match($email_string, $vlu))) $ret_valu='false'; break; case 'website': if(!(preg_match($website_string, $vlu))) $ret_valu='false'; break; } } return $ret_valu; } function strFrmat($string){ $string = trim($string); $inChar=array("'"); $outChar=array("'"); $string = str_replace($inChar, $outChar, $string); return $string; } function strUnFrmat($string){ $string = trim($string); $inChar=array("'"); $outChar=array("'"); $string = str_replace($inChar, $outChar, $string); return $string; } function addRecord($table, $record, $printquery = 0) { $k = 0; foreach($record as $key => $val) { $FIELDS[$k] = "`".$key."`"; $VALUES[$k] = "'".($val)."'"; $k++; } $txtFIELDS= implode (',' , $FIELDS); $txtVALUES= implode (',' , $VALUES); $query = "insert into ".$table." (".$txtFIELDS.") values (".$txtVALUES.")"; mysql_query($query); if ($printquery == 1) echo "
QUERY :
".$query."
"; $id=mysql_insert_id(); return $id; } function updateRecord($table, $record, $cond, $printquery = 0) { $k = 0; foreach($record as $key => $val) { $UPARR[$k] = "`".$key."` = '".($val)."'"; $k++; } $UPTXT = implode (',' , $UPARR); $query = "update ".$table." set ".$UPTXT." where ".$cond; if ($printquery == 1) echo "
QUERY :
".$query."
"; mysql_query($query); } function deleteRecord($table, $cond, $printquery = 0) { $query="delete from ".$table." where ".$cond; if ($printquery == 1) echo "
QUERY :
".$query."
"; mysql_query($query); } function saveOrders($table, $ordArr, $idsArr, $printquery = 0) { for ($i=0; $i < sizeof($idsArr); $i++) { $query="update ".$table." set `order`='".$ordArr[$i]."' where id='".$idsArr[$i]."'"; mysql_query($query); } if ($printquery == 1) echo "
QUERY :
".$query."
"; } function swapStatus($table, $cond, $printquery = 0) { $query="update ".$table." set status=abs(status-1) where ".$cond; if ($printquery == 1) echo "
QUERY :
".$query."
"; mysql_query($query); } ?> QUERY :
".$query."
"; $result=mysql_query($query); if ($result) { $num=mysql_num_rows($result); for ($i=0; $i<$num; $i++) { $row=mysql_fetch_array($result); $s[$i]=$row; } } return $s; } function getAllData($table, $cond, $printquery = 0) { $query="select * from ".$table." where ".$cond; if ($printquery == 1) echo "
QUERY :
".$query."
"; $result=mysql_query($query); if ($result) { $num=mysql_num_rows($result); for ($i=0; $i<$num; $i++) { $row=mysql_fetch_array($result); $s[$i]=$row; } } return $s; } function getDataByPages($table, $cond, $page, $rpp, $printquery = 0) { if ($page != 1000000001) { $start=($page-1)* $rpp; $query="select * from ".$table." where ".$cond." limit ".$start.", ".$rpp; } else $query="select * from ".$table." where ".$cond; if ($printquery == 1) echo "
QUERY :
".$query."
"; $result=mysql_query($query); if ($result) { $num=mysql_num_rows($result); for ($i=0; $i<$num; $i++) { $row=mysql_fetch_array($result); $s[$i]=$row; } } return $s; } function countDataPages($table, $cond, $rpp, $field, $printquery = 0) { if($field=='') $field='id'; $query="select count(".$field.") from ".$table." where ".$cond; if ($printquery == 1) echo "
QUERY :
".$query."
"; $result=mysql_query($query); if ($result) { $row=mysql_fetch_array($result); return ceil($row[0]/$rpp); } } function getDefaultOrder($table, $cond = 1, $printquery = 0) { $query="select max(`order`) from ".$table." where ".$cond; if ($printquery == 1) echo "
QUERY :
".$query."
"; $result=mysql_query($query); if ($result) { $res=mysql_fetch_array($result); return ($res[0]+1); } } function getMinOrder($table, $cond = 1, $printquery = 0) { $query="select min(`order`) from ".$table." where ".$cond; if ($printquery == 1) echo "
QUERY :
".$query."
"; $result=mysql_query($query); if ($result) { $res=mysql_fetch_array($result); return ($res[0]-1); } } function getDetails($table, $cond, $printquery = 0) { $query="select * from ".$table." where ".$cond; if ($printquery == 1) echo "
QUERY :
".$query."
"; $result=mysql_query($query); if ($result) { $res=mysql_fetch_array($result); return $res; } } function getTitle($table, $title, $cond, $printquery = 0) { $query="select ".$title." from ".$table." where ".$cond; if ($printquery == 1) echo "
QUERY :
".$query."
"; $result=mysql_query($query); if ($result) { $res=mysql_fetch_array($result); return $res; } } ?> ', '
','', '
', ' ' , '

' , '

'); $str = str_replace ($replaceArr , ' ' , $str); $str = strip_tags($str); $wordsArr = explode(' ' , $str); $totalWords = sizeof($wordsArr); for ($i = 0; $i < min($numOfWords, $totalWords); $i++) { $finalRes[$i] = $wordsArr[$i]; } $strRes = implode (' ' , $finalRes); return $strRes; } function stripTxt($str, $striped) { return str_replace($striped , '', $str); } function strip_only($str, $tags, $stripContent = false) { $content = ''; if(!is_array($tags)) { $tags = (strpos($str, '>') !== false ? explode('>', str_replace('<', '', $tags)) : array($tags)); if(end($tags) == '') array_pop($tags); } foreach($tags as $tag) { if ($stripContent) $content = '(.+]*>|)'; $str = preg_replace('#]*>'.$content.'#is', '', $str); } return $str; } function formatData($string) { $string = trim($string); $string = addslashes($string); return $string; } function unFormatData($string) { $replaceArr = array ("\r", "\n" , "\t"); $string = str_replace ($replaceArr , ' ' , $string ); if(is_array($string)) $string = stripslashes($string[0]); else $string = stripslashes($string); $string = strip_only($string, '