?
Path : /home/admin/domains/happytokorea.com/public_html/libs-bak/ |
Current File : /home/admin/domains/happytokorea.com/public_html/libs-bak/backoff.php |
<? class backoff extends MySql { var $_Limit; var $_total; var $_Next_Page; var $_Start; var $_a; var $_z; var $_az; var $_link; var $_first_page_link; var $_previous_page_link; var $_last_page_link; var $_next_page_link; var $_Page; var $_total_links; function setOrder(){ if($this->_Page==1){$count=$this->_total;return $count;}else{ $cal_page=$this->_Page-1; $perpage=$cal_page*$this->_Limit; $count=$this->_total-$perpage; return $count; } } function setOrderMin2Max(){ if($this->_Page==1){$count=1; return $count;}else{ $count=($this->_Page-1)*$this->_Limit; return $count; } } function setPage(){ if($_GET['page']){$this->_Page = $_GET['page'];}else{$this->_Page = 1;} return $this->_Page; } function MakeLinkNavigator2($MLlink, $MLget, $MLvalue, $what){ $getQueryString = ""; if (!empty($_SERVER['QUERY_STRING'])) { $params = explode("&", $_SERVER['QUERY_STRING']); $newParams = array(); foreach ($params as $param) { if (stristr($param, $MLget) == false) { array_push($newParams, $param); } }//end foreach $params as $param if (count($newParams) != 0) { $getQueryString = "&" . implode("&", $newParams); } }//end if empty($_SERVER['..... $getQueryString = sprintf("%s=%s%s",$MLget , $MLvalue, $getQueryString); $this->_link = $MLlink."?".$getQueryString; // $this->_link=$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']; if($what == 1){return $this->_link;} if($what == 0){return $newParams;} }//end function MakeLinkNavigato function MakeLinkNavigator($NEW_LINK,$LINK){ if(!$_GET){ $output.=$PHPSELF.'?'; } if($_GET){ $output.="?"; foreach ($_GET as $key => $value){ if($key != "$NEW_LINK"){ $output.= "$key=$value&"; } } } $output.="$NEW_LINK=$LINK"; return $output; }//end function MakeLinkNavigato function total_links($total_link){ if($total_link==""){ $this->_total_links = 10; }else{ $this->_total_links=$total_link;} return $this->_total_links; } function PageNavigator(){ //Total links / navigator if($this->_total_links>$this->_Next_Page ){$this->_total_links=$this->_Next_Page;} $Ceil2total_links = ceil($this->_total_links/2); $Floor2total_links = floor($this->_total_links/2); $this->_first_page_link = $this->MakeLinkNavigator2($_SERVER['PHP_SELF'], "page", 1, 1); $this->_previous_page_link = $this->MakeLinkNavigator2($_SERVER['PHP_SELF'], "page", $this->_Page-1, 1); $this->_last_page_link = $this->MakeLinkNavigator2($_SERVER['PHP_SELF'], "page", $this->_Next_Page , 1); $this->_next_page_link = $this->MakeLinkNavigator2($_SERVER['PHP_SELF'], "page", $this->_Page+1, 1); $this->_a = 1; $this->_z = $this->_total_links; if( $this->_Next_Page<=$this->_total_links){ $this->_z = $this->_Next_Page; }else{ if(isset($this->_Page) && ($this->_Page > $Ceil2total_links)){ $this->_a = $this->_Page-$Floor2total_links; $this->_z = $this->_Page+$Floor2total_links; } if(isset($this->_Page) && ($this->_Page > ($this->_Limit-$Ceil2total_links))){ $this->_a = $this->_Next_Page-$this->_total_links+1; $this->_z = $this->_Next_Page; } } }//end function function jump2page(){ $output.="<form name=\"navigator1\" action=\"\" method='GET'> Jump Page: <select style='width: 50px;' name=\"page\" id=\"page\" onChange=\"navigator1.submit();\">"; for($this->_az=1; $this->_az<= $this->_Next_Page; $this->_az++){ if($this->_az==$this->_Page){$pgnr=' selected';}else{$pgnr='';} $output.= "<option value='{$this->_az}'{$pgnr}>{$this->_az}-{$this->_Next_Page}</option>"; } $output.="</select>"; if($_GET){ foreach ($_GET as $key => $value){ if($key != "Submit" && $key != "page"){ $output.= "<input type='hidden' name='$key' value='$value'>\n"; } } } $output.="</form>"; return $output; }//end jump function PageLink(){ $output.="หน้า | "; $show_links=$this->_total_links; //$perpage=10; $perpage=$this->_Limit $total_links=ceil($this->_total/$this->_Limit);//ปัดขึ้น $center_link=ceil($this->_total_links/2); if($this->_Page<=$center_link){//แสดงในหน้าแรก for($i=1;$i<$show_links+1;$i++){ if($this->_Page==$i){ $output.= "<span class=\"seo_page_navigator_me\"> <a href='".$this->MakeLinkNavigator("page", $i)."' >{$i}</a> "; }else{ $output.= "<span class=\"seo_page_navigator\"> <a href='".$this->MakeLinkNavigator("page", $i)."'>{$i}</a></span> "; } } }else if($total_links-$this->_Page<$center_link){//แสดงหน้าสุดท้าย for($i=($total_links-$show_links+1);$i<$total_links+1;$i++){ if($this->_Page==$i){ $output.= "<span class=\"seo_page_navigator_me\"> <a href='".$this->MakeLinkNavigator("page", $i)."' >{$i}</a> "; }else{ $output.= "<span class=\"seo_page_navigator\"> <a href='".$this->MakeLinkNavigator("page", $i)."'>{$i}</a></span> "; } } }else{//แสดงหน้ากลาง for($i=$this->_Page-$center_link;$i<$this->_Page;$i++){ if($this->_Page==$i){ $output.= "<span class=\"seo_page_navigator_me\"> <a href='".$this->MakeLinkNavigator("page", $i)."' >{$i}</a> "; }else{ $output.= "<span class=\"seo_page_navigator\"> <a href='".$this->MakeLinkNavigator("page", $i)."'>{$i}</a></span> "; } } for($i=$this->_Page;$i<($this->_Page+$center_link);$i++){ if($this->_Page==$i){ $output.= "<span class=\"seo_page_navigator_me\"> <a href='".$this->MakeLinkNavigator("page", $i)."' >{$i}</a> "; }else{ $output.= "<span class=\"seo_page_navigator\"> <a href='".$this->MakeLinkNavigator("page", $i)."'>{$i}</a></span> "; } } } return $output; }//end LinkPage function PageLink2(){ $output.="หน้า | "; for($i=$this->_a; $i<=$this->_z; $i++){ if($this->_Page == $i){ $output.= "<span id='this_page'>{$i}</span> "; }else{ $output.= " <a href='".$this->MakeLinkNavigator($_SERVER['PHP_SELF'], "page", $i, 1)."'>{$i}</a> "; } } return $output; }//end function total_record(){ $output.="ทั้งหมด ".$this->_total." รายการ "; $output.="หน้า {$this->_Page} / ".$this->_Next_Page.""; return $output; }//end function jum2page function PreNext(){ if( $this->_Next_Page > 1){ if($this->_Page>1){ $output.= "<a href='{$this->_first_page_link}'><img src=\"images/first.png\" border=0></a> "; $output.= "<a href='{$this->_previous_page_link}'><img src=\"images/pre.png\" border=0></a> "; }else{ $output.= "<img src=\"images/first_off.png\" border=0> "; $output.= "<img src=\"images/pre_off.png\" border=0> "; } if($this->_Page< $this->_Next_Page){ $output.= "<a href='{$this->_next_page_link}'><img src=\"images/next.png\" border=0></a> "; $output.= "<a href='{$this->_last_page_link}'><img src=\"images/last.png\" border=0></a> "; }else{ $output.= "<img src=\"images/next_off.png\" border=0> "; $output.= "<img src=\"images/first_off.png\" border=0> "; } }else{$output.= "<img src=\"images/first_off.png\" border=0> "; $output.= "<img src=\"images/pre_off.png\" border=0> "; $output.= "<img src=\"images/next_off.png\" border=0> "; $output.= "<img src=\"images/last_off.png\" border=0> "; }//end if $this->_Next_Page>1 return $output; } function PerPageDropList(){ //$this->_link=$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']; $list=array("5","10","15","20","25","30","35","40","45","50"); $output=" <form method=\"GET\" action=\"\" name=\"listpage\"> <select size=\"1\" name=\"limit\" onchange=\"document.listpage.submit()\">"; foreach($list as $key=>$value){ if($value==$this->_Limit){$pgnr=' selected';}else{$pgnr='';} $output.= "<option value='{$value}'{$pgnr}>{$value}</option>"; } if (!in_array($this->_Limit, $list)) { $output.="<option value='$this->_Limit' selected>$this->_Limit</option"; } $output.="</select>"; if($_GET){ foreach ($_GET as $key => $value){ if($key != "Submit"&&$key!="limit"){ $output.= "<input type='hidden' name='$key' value='$value'>\n"; } } } $output.="</form>"; return $output; } function set_per_page(){ $output.="<form method=\"GET\" action=\"\" name=\"listpage2\"> <table width=\"180\"><tr><td width=\"80\" align=\"left\"># Per Page</td><td width=\"100\" align=\"left\"> <input type='textbox' name='limit' size=3 value=\"$this->_Limit\"> <input type='Submit' value=' Ok '>"; if($_GET){ foreach ($_GET as $key => $value){ if($key != "Submit"&&$key!="limit"){ $output.= "<input type='hidden' name='$key' value='$value'>\n"; } } } $output.="</td></tr></table></form>"; return $output; } function setLimit($limit){ global $_Limit; $this->_Limit=$_GET['limit']; if($this->_Limit==""){$this->_Limit=$_Limit;} if($this->_Limit==""){$this->_Limit=$limit;} $_SESSION['_Limit']=$this->_Limit; return $this->_Limit; } }//end class ?>