$val) { $val = stripslashes($val); if ($bReplaceDoubleQuote) $val = str_replace('"', $newDoubleQuote, $val); $in[$key] = $val; } } } function validate_text_input(&$in) { if (get_magic_quotes_gpc()) return; if (!is_array($in)) { $in = addslashes($in); return; } else { foreach ($in as $key => $val) { $val = addslashes($val); $in[$key] = $val; } } } function paging($start_page, $page_size, $total, $url_template) { $num = (int)($total/$page_size); if ($num*$page_size<$total) $num++; if ($num<=1) return ""; $ret = ""; for ($i=1; $i<=$num; ++$i) { $strPage = ""; if ($i>1) { $strPage = $i; } $url = str_replace("[PG]", $strPage, $url_template); if ($i==$start_page) { $text = "$i"; } else { $text = "$i"; } if ($ret!="") $ret .= " "; $ret .= $text; } return $ret; } function pagingmoreAPT($page, $numpage, $specialtyDir, $option) { global $domain, $keyword; if ($option == 1) $tail = ".html"; else $tail = ""; $iFPage = $page - 5; if($iFPage<1){$iFPage=1;} if($numpage<10) { $iLPage = $iFPage + $numpage - 1; } else { if(($numpage-$page)>4){$iLPage = $iFPage + 9;}else{$iLPage=$numpage;} } if($numpage>1) { echo "
Pages ".$page." of ".$numpage."
"; if($page>5) { echo "First "; } for($i=$iFPage;$i<=$iLPage-1;$i++){ if(trim($page)==$i) { echo "$i "; } else { echo "$i "; } } if($numpage>$page) { echo "Last "; } } } function isEmail($email) { if (!preg_match("/^([a-zA-Z0-9\._-]+)@([a-zA-Z0-9\._-]+)\.([a-zA-Z]+)$/" , $email)) { return false; } if (false!==strpos($email, ".@") || false!==strpos($email, "@.")) return false; if (false!==strpos($email, "-@") || false!==strpos($email, "@-")) return false; if (false!==strpos($email, "_@") || false!==strpos($email, "@_")) return false; return true; } function name2url($name) { $name = str_replace(" & ", " ", $name); $name = str_replace("&", " ", $name); $name = str_replace(",", " ", $name); $name = str_replace('"', " ", $name); $name = str_replace(".", " ", $name); $name = str_replace("'", " ", $name); $name = str_replace("(", " ", $name); $name = str_replace(")", " ", $name); $name = str_replace(" ", "-", $name); $name = str_replace(" ", "-", $name); $name = str_replace(" ", "-", $name); $name = trim($name, " -"); return strtolower($name); } function strProper($str) { return ucwords(strtolower($str)); /* if ($str != "") { $noUp = array('um','uma','o','a','de','do','da','em'); $str = trim($str); $str = strtoupper($str[0]) . strtolower(substr($str, 1)); for($i=1; $ihostname = $hostname; $this->username = $username; $this->password = $password; $this->database = $database; $args = func_get_args(); register_shutdown_function( array( &$this, '_destructor' ) ); call_user_func_array( array( &$this, '_constructor' ), $args ); } /*---------------------------------------------------------*/ /*---------------------------------------------------------*/ function _constructor(){ //$this->oConn = mysql_connect($this->hostname,$this->username,$this->password) or die("Could not connect server:".mysql_error()); $this->oConn = mysqli_connect($this->hostname,$this->username,$this->password) or die("Could not connect server:".mysql_error()); //mysql_select_db($this->database) or die("Could not select database:".mysql_error()); mysqli_select_db($this->oConn, $this->database) or die("Could not select database:".mysql_error()); } /*---------------------------------------------------------*/ /*---------------------------------------------------------*/ function _destructor(){ //mysql_close($this->oConn); mysqli_close($this->oConn); } } ?>