"; else return ""; } function returnImageTable($pathImage,$Css,$width,$align="", $hspace="",$vspace="") { $wtable=$width+15; if(file_exists($pathImage) && trim($pathImage)!="") return "". "
"; else return ""; } function returnImageTableNoPadd($pathImage,$Css,$width,$align="", $hspace="",$vspace="") { $wtable=$width+15; if(file_exists($pathImage) && trim($pathImage)!="") return "". "
"; else return ""; } function getFileName($file) { $arr = explode("/",$file); if(count($arr)>0) return $arr[count($arr)-1];//tra ve ten file else return ""; } function app_path() { //echo $_SERVER['DOCUMENT_ROOT']; //echo $_SERVER['SCRIPT_NAME']; //echo $_SERVER['SCRIPT_FILENAME']; //echo $_SERVER['PHP_SELF']; return ""; } function returnVirtualPath() { } } ?>drppages = (empty($this->drppages))?1:$this->drppages; $this->curpage = $this->drppages-1; $this->drprows = (empty($this->drprows))?10:$this->drprows; $this->currecord = $this->curpage*$this->drprows; } function strdrprows() { $strdrprow = "Rows: "; return $strdrprow; } function strdrppages() { $strdrppages = $totalpages = ""; if($this->totalrows>$this->drprows){ $totalpages = intval($this->totalrows/$this->drprows); $totalpages = (($this->totalrows%$this->drprows)>0)?($totalpages+1):$totalpages; $strdrppages = "Pages: "; } return $strdrppages; } function strpagging() { if($this->totalrows<=$this->perrow){ return ""; } else { $strreturn = ""; $totalpages = intval($this->totalrows/$this->perrow); $totalpages = (($this->totalrows%$this->perrow)>0)?($totalpages+1):$totalpages; $curpage = $this->curpage + 1; $n = ($this->perpage >= $totalpages)?$totalpages:$this->perpage; $m = intval($this->perpage/2); if($curpage<=$m) { for($i=1;$i<=$n;$i++){ if($curpage==$i){ $strreturn .= " [ $i ] "; } else { $cup = $i-1; $strreturn .= ($strreturn=="")?"[ $i ]":" [ $i ]"; } } if($curpage==1){ $strreturn .= ""; } else { $strreturn = ($curpage>2)?"$this->first $this->previous ... ".$strreturn:"$this->first ... ".$strreturn; } } else { if(($curpage==$totalpages)||(($curpage+1)==$totalpages)) { $st = $totalpages-$this->perpage+1; $fn = $totalpages; for($i=$st;$i<=$fn;$i++){ if($curpage==$i){ $strreturn .= ($strreturn=="")?"$i":" | $i"; } else { $cup = $i-1; $strreturn .= ($strreturn=="")?"[ $i ]":" [ $i ]"; } } if($curpage<$totalpages-1){ $strreturn .= " ... $this->next $this->last"; } else { $strreturn .= ($curpage<$totalpages)?" ... $this->last":""; } } else { $st = $curpage - $m; $fn = $curpage + $m; $fn = ($fn>$totalpages)?$totalpages:$fn; for($i=$st;$i<=$fn;$i++){ if($curpage==$i){ $strreturn .= ($strreturn=="")?"$i":" $i"; } else { $cup = $i-1; $strreturn .= ($strreturn=="")?"[ $i ]":" [ $i ]"; } } $strreturn = "$this->first $this->previous ... ".$strreturn; $strreturn .= " ... $this->next $this->last"; } } return $strreturn; } } // +---------------------------------------------+ // | Author: | // | WebSite: | // +---------------------------------------------+ function showPageOne($page,$url="",$total,$maxpage,$show,$sFirst="",$sBack="",$sNext="",$sLast="") { if ($page>$maxpage) { $num_page=ceil($page/$maxpage); $showpage=($num_page-1)*$maxpage; $end=$showpage+$maxpage; $showpage++; }else { $thispage=1; $showpage=1; $end=$maxpage; } // liet ket cac trang ra $startpage=$showpage; for ($showpage;$showpage<$end+1;$showpage++) { if ($showpage<=$total) { if ($page==$showpage) { $list_page.=" ".$showpage." "; }else { $list_page.=" ".$showpage." "; } } } // them dau trang, trang truoc vao if ($page > $maxpage || $num_page>1) { $back=$startpage-1; if ($num_page>2 || $page>$maxpage) { $list_page1="$sFirst "; } $list_page1.="$sBack "; } // them trang tiep, trang cuoi vao if ($num_page$maxpage)) { $next=$showpage; $list_page2=" $sNext "; $list_page2.=" $sLast "; } if($total>1) $list_page=$list_page1.$list_page.$list_page2; else $list_page = ""; switch ($show) { case "str": return $list_page; break; default: echo $list_page; break; } } # total: tong so mau tin # maxPage so trang tren # show: kieu hien thi function showPageTwo($page,$total,$maxpage,$show,$sFirst="",$sBack="",$sNext="",$sLast="") { $url = $this->pageLink(); if ($page>$maxpage) { $num_page=ceil($page/$maxpage); $showpage=($num_page-1)*$maxpage; $end=$showpage+$maxpage; $showpage++; }else { $thispage=1; $showpage=1; $end=$maxpage; } // liet ket cac trang ra $startpage=$showpage; for ($showpage;$showpage<$end+1;$showpage++) { if ($showpage<=$total) { if($page==0 && $showpage==1){ $list_page.=" [ ".$showpage." ] "; }else{ if ($page==$showpage) { $list_page.=" [ ".$showpage." ] "; }else { $list_page.=" ".$showpage." "; } } } } // them dau trang, trang truoc vao if ($page > $maxpage || $num_page>1) { $back=$startpage-1; if ($num_page>2 || $page>$maxpage) { $list_page1="$sFirst "; } $list_page1.="$sBack "; } // them trang tiep, trang cuoi vao if ($num_page$maxpage)) { $next=$showpage; $list_page2=" $sNext "; $list_page2.=" $sLast "; } if($total>1) $list_page=$list_page1.$list_page.$list_page2; else $list_page = ""; switch ($show) { case "str": return $list_page; break; default: echo $list_page; break; } } # tao link ket den trang function pageLink() { $url = $_SERVER['QUERY_STRING']; $array_url = explode("&",$url); $url=""; foreach($array_url as $key=>$value){ if(strlen($value)>0){ $array_v = explode("=",$value); if($array_v[0]!="p"){ $url.=$array_v[0]."=".$array_v[1]."&"; } } } //cat bo dau & cuoi cung if(strlen($url)>1){ $url = "?".substr($url,0,strlen($url)-1); } return $url; } } ?>"; $connectdb = new connectdb(); return $connectdb->query($sql); } else return NULL; } function __select($sql_select) { if (trim($sql_select) != "") { $connectdb = new connectdb(); return $connectdb->query($sql_select); } else { return NULL; } } //Ham select cac tin khac function selectUnion($fields, $order="", $limit="") { if (trim($fields) != "") { $sql = "$fields $order $limit"; // print $sql."
"; $connectdb = new connectdb(); return $connectdb->query($sql); } else return NULL; } function insertData($table, $sql_insert) { if (trim($table) != "" && trim($sql_insert) != "") { $sql = "insert $table set " . $sql_insert; // print $sql; $connectdb = new connectdb(); return $connectdb->query($sql); } else return NULL; } function insertData2($sql_insert) { if (trim($sql_insert) != "") { $connectdb = new connectdb(); return $connectdb->query($sql_insert); } else return NULL; } function updateData($table, $sql_update, $sql_where="") { if (trim($table) != "" && trim($sql_update) != "") { $sql = "update $table set " . $sql_update . $sql_where; // print $sql; $connectdb = new connectdb(); return $connectdb->query($sql); } else return NULL; } function deleteData($table, $sql_delete="") { if (trim($table) != "" && trim($sql_delete) != "") { $sql = "delete from $table " . $sql_delete; //print $sql; $connectdb = new connectdb(); return $connectdb->query($sql); } else return NULL; } function countData($table="", $sql_where="") { if (trim($table) != "") { $sql = "select count(*) as total from $table " . $sql_where; $connectdb = new connectdb(); return $connectdb->query($sql); } else return NULL; } function orderNumber($rs) { if ($rs) { if ($row = mysql_fetch_array($rs)) return $row["total"] + 1; else return 1; } else return 1; } function getId($table="", $where="") { $id = 1; if (trim($table) != "") { $sql = "select max(id) as id from $table $where"; $connectdb = new connectdb(); $select_id = $connectdb->query($sql); if ($select_id && mysql_num_rows($select_id) > 0) { $r = mysql_fetch_array($select_id); $id = intval(($r["id"] != NULL) ? $r["id"] : 0); $id++; } } return $id; } function searchParent($reqCatId) { global $global_lang; $sql_where = "where lang='$global_lang' and approved='1' and id = $reqCatId "; $result = $this->selectData("*", "menu", $sql_where, "order by arrange", ""); if (@mysql_num_rows($result) > 0) { while ($rchilde = @mysql_fetch_array($result)) { $menu_id = $rchilde["id"]; $menu_ptypeid = $rchilde["ptypeid"]; if ($menu_ptypeid == 0) { return $menu_id; exit; } else { return $this->searchParent($menu_ptypeid); } } } return 0; } function equalParent($reqCatId, $equalId) { global $global_lang; $sql_where = "where lang='$global_lang' and approved='1' and id = $reqCatId "; $result = $this->selectData("*", "menu", $sql_where, "order by arrange", ""); if (@mysql_num_rows($result) > 0) { while ($rchilde = @mysql_fetch_array($result)) { $menu_ptypeid = $rchilde["ptypeid"]; if ($menu_ptypeid == $equalId) { return true; exit; } else { return $this->equalParent($menu_ptypeid, $equalId); } } } return false; } } ?>id = "0" ; $this->approved = "0" ; $this->keyword = "" ; $this->title = "" ; $this->pathimage = "" ; } function getLanguages($condition) { $globalconn = new connectdb() ; $sqlselect = "select * from " . HSDB_LANG . " $condition " ; return @$globalconn->query($sqlselect) ; } function inLanguage($lang) { $result = $this->getLanguages(" where lang = '$lang' ") ; if ( @mysql_num_rows($result) > 0 ) return true ; else return false ; } } ?>id = "0"; $this->approved = "0"; $this->folder = "0"; $this->description = ""; $this->name = ""; $this->pathimage = ""; } function getTemplates($condition) { $globalconn = new connectdb(); $sqlselect = "select * from " . HSDB_TEMPLATES . " $condition "; return $globalconn->query($sqlselect); } function selectData($fields, $table, $where="", $order="", $limit="") { if (trim($fields) != "" && trim($table) != "") { $sql = "select $fields from $table $where $order $limit"; $connectdb = new connectdb(); return $connectdb->query($sql); } else return NULL; } function __select($sql_select) { if (trim($sql_select) != "") { $connectdb = new connectdb(); return $connectdb->query($sql_select); } else { return NULL; } } function insertData($table, $sql_insert) { if (trim($table) != "" && trim($sql_insert) != "") { $sql = "insert $table set " . $sql_insert; $connectdb = new connectdb(); return $connectdb->query($sql); } else return NULL; } function insertData2($sql_insert) { if (trim($sql_insert) != "") { $connectdb = new connectdb(); return $connectdb->query($sql_insert); } else return NULL; } function updateData($table, $sql_update, $sql_where="") { if (trim($table) != "" && trim($sql_update) != "") { $sql = "update $table set " . $sql_update . $sql_where; $connectdb = new connectdb(); return $connectdb->query($sql); } else return NULL; } function deleteData($table, $sql_delete="") { if (trim($table) != "" && trim($sql_delete) != "") { $sql = "delete from $table " . $sql_delete; $connectdb = new connectdb(); return $connectdb->query($sql); } else return NULL; } function countData($table="", $sql_where="") { if (trim($table) != "") { $sql = "select count(*) as total from $table " . $sql_where; $connectdb = new connectdb(); return $connectdb->query($sql); } else return NULL; } function orderNumber($rs) { if ($rs) { if ($row = mysql_fetch_array($rs)) return $row["total"] + 1; else return 1; } else return 1; } function getId($table="", $where="") { $id = 1; if (trim($table) != "") { $sql = "select max(id) as id from $table $where"; $connectdb = new connectdb(); $select_id = $connectdb->query($sql); if ($select_id && mysql_num_rows($select_id) > 0) { $r = mysql_fetch_array($select_id); $id = intval(($r["id"] != NULL) ? $r["id"] : 0); $id++; } } return $id; } function searchParent($reqCatId) { global $global_lang; $sql_where = "where lang='$global_lang' and approved='1' and id = $reqCatId "; $result = $this->selectData("*", "menu", $sql_where, "order by arrange", ""); if (@mysql_num_rows($result) > 0) { while ($rchilde = @mysql_fetch_array($result)) { $menu_id = $rchilde["id"]; $menu_ptypeid = $rchilde["ptypeid"]; if ($menu_ptypeid == 0) { return $menu_id; exit; } else { return $this->searchParent($menu_ptypeid); } } } return 0; } function equalParent($reqCatId, $equalId) { global $global_lang; $sql_where = "where lang='$global_lang' and approved='1' and id = $reqCatId "; $result = $this->selectData("*", "menu", $sql_where, "order by arrange", ""); if (@mysql_num_rows($result) > 0) { while ($rchilde = @mysql_fetch_array($result)) { $menu_ptypeid = $rchilde["ptypeid"]; if ($menu_ptypeid == $equalId) { return true; exit; } else { return $this->equalParent($menu_ptypeid, $equalId); } } } return false; } } ?>