max=$m;//max records $this->url=$u;//url $this->per_page=$p;//numeber results per page $this->cur=$c; $this->name=$n; } function get_n($n){ $out=array("down"=>"","up"=>"","hrefs"=>array(),"names"=>array()); if($this->cur==""||$this->cur<0) $this->cur=0; if(($this->cur+1)>ceil($this->max/$this->per_page)) $this->cur=ceil($this->max/$this->per_page)-1; $out["down"]=$this->cur*$this->per_page; $out["up"]=$this->per_page; if(ceil(($this->cur+1)/$n)>1){ array_push($out["names"],"<<Prev ".$n); array_push($out["hrefs"],$this->url.$this->name."=".(ceil(($this->cur+1)/$n-1)*$n-1)); }else{ array_push($out["names"],"<<Prev ".$n); array_push($out["hrefs"],"#"); } for($i=ceil(($this->cur+1)/$n-1)*$n;$icur+1)/$n)*$n&&$imax/$this->per_page);$i++) if($this->cur==$i){ array_push($out["names"],"".($i+1).""); array_push($out["hrefs"],$this->url.$this->name."=".$i); }else{ array_push($out["names"],($i+1)); array_push($out["hrefs"],$this->url.$this->name."=".$i); } if(ceil(($this->cur+1)/$n)*$nmax/$this->per_page)){ array_push($out["names"],"Next ".$n." >>"); array_push($out["hrefs"],$this->url.$this->name."=".(ceil(($this->cur+1)/$n)*$n)); }else{ array_push($out["names"],"Next ".$n." >>"); array_push($out["hrefs"],"#"); } return $out; } function get($t) { $this->type=$t; //------------arrow(<< < > >>)---------------------------- if($this->type=='arrow'){ $out=array("down"=>"","up"=>"","href1"=>"","href2"=>"","href3"=>"","href4"=>"","src1"=>"","src2"=>""); if($this->cur==""||$this->cur<0) $this->cur=0; if(($this->cur+1)>ceil($this->max/$this->per_page)) $this->cur=ceil($this->max/$this->per_page)-1; $out["down"]=$this->cur*$this->per_page; $out["up"]=$this->per_page; if($this->cur==0){ $out["href1"]="#"; $out["href2"]="#"; $out["src1"]="no"; }else{ $out["href1"]=$this->url.$this->name."=0"; $out["href2"]=$this->url.$this->name."=".($this->cur-1); $out["src1"]="yes"; } if(($this->cur+1)*$this->per_page>=ceil($this->max/$this->per_page)*$this->per_page) { $out["href3"]="#"; $out["href4"]="#"; $out["src2"]="no"; }else{ $out["href3"]=$this->url.$this->name."=".($this->cur+1); $out["href4"]=$this->url.$this->name."=".(ceil($this->max/$this->per_page)-1); $out["src2"]="yes"; } return $out; } //------------arrow(<< < > >>)---------------------------- //------------full string(123456)------------------------- if($this->type=='full'){ $out=array("down"=>"","up"=>"","hrefs"=>array(),"names"=>array()); if($this->cur==""||$this->cur<0) $this->cur=0; if(($this->cur+1)>ceil($this->max/$this->per_page)) $this->cur=ceil($this->max/$this->per_page)-1; $out["down"]=$this->cur*$this->per_page; $out["up"]=$this->per_page; for($i=0;$imax/$this->per_page);$i++) if($this->cur==$i){ array_push($out["names"],($i+1)); array_push($out["hrefs"],"#"); }else{ array_push($out["hrefs"],$this->url.$i); array_push($out["names"],($i+1)); } return $out; } //------------full string(123456)------------------------- //-----------short string(1...34567...20)----------------- if($this->type=='short'){ $out=array("down"=>"","up"=>"","hrefs"=>array(),"names"=>array()); if($this->cur==""||$this->cur<0) $this->cur=0; if(($this->cur+1)>ceil($this->max/$this->per_page)) $this->cur=ceil($this->max/$this->per_page)-1; $out["down"]=$this->cur*$this->per_page; $out["up"]=$this->per_page; if(ceil($this->max/$this->per_page)<8){ for($i=0;$imax/$this->per_page);$i++) if($this->cur==$i){ array_push($out["names"],($i+1)); array_push($out["hrefs"],"#"); }else{ array_push($out["names"],($i+1)); array_push($out["hrefs"],$this->url.$this->name."=".$i); } }else{ if($this->cur<4){ for($i=0;$i<($this->cur+3);$i++) if($this->cur==$i){ array_push($out["names"],($i+1)); array_push($out["hrefs"],"#"); }else{ array_push($out["names"],($i+1)); array_push($out["hrefs"],$this->url.$this->name."=".$i); } array_push($out["hrefs"],"..."); array_push($out["names"],"..."); array_push($out["hrefs"],$this->url.$this->name."=".(ceil($this->max/$this->per_page)-1)); array_push($out["names"],ceil($this->max/$this->per_page)); }else{ array_push($out["names"],"1"); array_push($out["hrefs"],$this->url.$this->name."=0"); array_push($out["names"],"..."); array_push($out["hrefs"],"..."); if(($this->cur+5)>ceil($this->max/$this->per_page)){ for($i=($this->cur-2);$i<(ceil($this->max/$this->per_page));$i++) if($this->cur==$i){ array_push($out["names"],($i+1)); array_push($out["hrefs"],"#"); }else{ array_push($out["names"],($i+1)); array_push($out["hrefs"],$this->url.$this->name."=".$i); } }else{ for($i=($this->cur-2);$i<$this->cur+3;$i++) if($this->cur==$i){ array_push($out["names"],($i+1)); array_push($out["hrefs"],"#"); }else{ array_push($out["names"],($i+1)); array_push($out["hrefs"],$this->url.$this->name."=".$i); } array_push($out["hrefs"],"..."); array_push($out["names"],"..."); array_push($out["hrefs"],$this->url.$this->name."=".(ceil($this->max/$this->per_page)-1)); array_push($out["names"],ceil($this->max/$this->per_page)); } } } return $out; } //-----------short string(1...34567...20)----------------- } }; ?> alert("'.$text.'");'; } //------------------------------- // Obtain specific URL Parameter from URL string //------------------------------- function get_param($param_name) { global $HTTP_POST_VARS; global $HTTP_GET_VARS; $param_value = ""; if(isset($HTTP_POST_VARS[$param_name])) $param_value = $HTTP_POST_VARS[$param_name]; else if(isset($HTTP_GET_VARS[$param_name])) $param_value = $HTTP_GET_VARS[$param_name]; $param_value=str_replace("\\\"","\"",$param_value); $param_value=str_replace("\'","'",$param_value); return $param_value; } //============================================= // Get Cookie //--------------------------------------------- function get_cookie($param_name) { global $HTTP_COOKIE_VARS; global $_COOKIE; $param_value = ""; if(isset($_COOKIE[$param_name])) return $_COOKIE[$param_name]; else if(isset($HTTP_COOKIE_VARS[$param_name])) return $HTTP_COOKIE_VARS[$param_name]; return $param_value; } //------------------------------- // Convert value for use with SQL statament //------------------------------- function tosql($value) { if(!strlen($value)) return ""; else{ $value = mysql_escape_string(stripslashes($value)); /*$value = stripslashes($value); $value = str_replace("\\","\\\\",$value); $value = str_replace("'","\'",$value);*/ } return $value ; } function user_validate($type='admin') { global $_SESSION; global $db; global $TABLE_PREFIX; if ($type == 'admin') { if (empty($_SESSION['session_admin_id'])) $_SESSION['session_admin_id'] = 0; $q = "SELECT adm_id AS id FROM ".$TABLE_PREFIX."admins WHERE adm_id = ".$_SESSION['session_admin_id']; } else { return false; } $db->query($q); if ($db->next_record()) { return true; } else { return false; } } function start_session() { global $_SESSION; session_start(); session_register('session_admin_id'); } function logout($type='admin'){ global $_SESSION; if($type=='admin'){ $_SESSION['session_admin_id']=0; } } //////////////////////////////////////////////////// // User Login Function //================================================== function user_login($type='admin'){ global $_SESSION; global $db; global $TABLE_PREFIX; // Get Login and Password from Form $l=tosql(get_param("login")); $p=tosql(get_param("pass")); if($l=="" || $p=="") return false; if ($type == 'admin') { $sql="SELECT adm_id AS id, adm_pass AS pass FROM ".$TABLE_PREFIX."admins where adm_login='".$l."'"; $session_id='session_admin_id'; } $db->query($sql); // Compare DB and Form login and password if($db->next_record()){ if($db->f("pass")==crypt($p,$db->f("pass"))){ $_SESSION[$session_id]=$db->f("id"); return $db->f("id"); }else{ return false; } }else{ return false; } } //------------------------------- // Lookup field in the database based on SQL query //------------------------------- function get_db_value($sql) { global $db; $db->query($sql); if($db->next_record()) return $db->f(0); else return ""; } //Url validator function is_url($url) { if ( !( $parts = @parse_url( $url ) ) ) return false; else { if ( $parts[scheme] != "http" && $parts[scheme] != "https" && $parts[scheme] != "ftp" && $parts[scheme] != "gopher" ) return false; else if ( !eregi( "^[0-9a-z]([-.]?[0-9a-z])*\.[a-z]{2,3}$", $parts[host], $regs ) ) return false; else if ( !eregi( "^([0-9a-z-]|[\_])*$", $parts[user], $regs ) ) return false; else if ( !eregi( "^([0-9a-z-]|[\_])*$", $parts[pass], $regs ) ) return false; else if ( !eregi( "^[0-9a-z/_\.@~\-]*$", $parts[path], $regs ) ) return false; else if ( !eregi( "^[0-9a-z?&=#\,]*$", $parts[query], $regs ) ) return false; } return true; } //soft redirect page function redirect($where) { print ''; } function categories_array(){ global $db; global $TABLE_PREFIX; $str=array(); $db->query("select * from ".$TABLE_PREFIX."categories order by cat_name"); while($db->next_record()){ $str[]=array("name"=>$db->f("cat_name"),"id"=>$db->f("cat_id")); } return $str; } function categories_box($array,$cat_id=""){ global $TABLE_PREFIX; $str=""; for($i=0;$i ".$array[$i]['name']; }else{ $str.="