File title: Template + > File create time: 23/4/2008 + > File last modife date: 8/7/2008 + ============================================= +-------------------------------------------------------------------------- */ class evalTpl { // Global Variables var $VARS = array(); var $DIR = "."; var $EXT = ""; var $TPL_STACK = array(); // Options var $USE_RELATIVE_DIR = false; // Main keyword objs var $MARK_OPEN = '{'; var $MARK_CLOSE = '}'; var $MARK_VAR = '$'; var $MARK_IF = 'if'; var $MARK_ENDIF = '/if'; var $MARK_ELSE = 'else'; var $MARK_ELSEIF = 'elseif'; var $MARK_FOREACH = 'each'; var $MARK_ENDFOREACH = '/each'; var $MARK_FOREACH_ITEM = 'item'; var $MARK_FOREACH_FROM = 'from'; var $MARK_FOREACH_KEY = 'key'; var $MARK_INCLUDE = 'include'; /** * Compile template **/ function compile($name) { $tpl = $this->tpl_read($name); if ($tpl === null) { return false; } if (trim($tpl) == '') return $tpl; $this->TPL_STACK[] = "$name"; $var = $this->parser_tpl($tpl,true); array_pop($this->TPL_STACK); if (!is_array($this->TPL_STACK)) $this->TPL_STACK = array(); if ($var === null) { return null; } return $var; } /** * Output template **/ function output($name,$return=false) { if ($return == false) echo $this->compile($name); elseif ($return == true) return $this->compile($name); } function replace($content,$url=''){ $content=str_replace('href="/','href="'.$url.'/',$content); $content=str_replace('src="/','src="'.$url.'/',$content); $content=str_replace("href='/","href='".$url."/",$content); $content=str_replace("src='/","src='".$url."/",$content); $content=str_replace('href="/','href="'.$url.'/',$content); $content=str_replace('background="/','background="'.$url.'/',$content); $content=str_replace('value="/','value="'.$url.'/',$content); $content=str_replace("src='/","src='".$url.'/',$content); //$content=str_replace('"','',$content); return $content; } function cache($name,$filename,$path,$url='') { $a = $this->compile($name); if($url !==''){ $a = $this->replace($a,$url); } if(is_dir($path)) { $handle = $path .'/'. $filename; if(($handle = fopen($handle,'w')) === FALSE) { return false; } else { if (fwrite($handle, $a) === FALSE) { return false; } else return true; fclose($handle); } } } function loadcache($filename,$path,$return=false) { $PathCachedFile = $path .'/'. $filename; if($handle = fopen($PathCachedFile, 'r')) { if($rvx = fread($handle, filesize($PathCachedFile))) { if($return==false) return $rvx; return $rvx; } } } function loadcache1($filename,$path,$return=false) { $PathCachedFile = $path .'/'. $filename; if($handle = fopen($PathCachedFile, 'r')) { if($rvx = fread($handle, filesize($PathCachedFile))) { if($return==false) return $rvx; echo $rvx; } } } /** * Return the template content **/ function DeleteCache($filename,$path,$time='') { $dirHandler = $path .'/'. $filename; $time_cache=$this->CacheCreateTime($filename,$path); $time_del=intval(time()-$time_cache); if ($time_del > $time){ unlink($dirHandler); // Delete cache file } // fclose($path); } function CacheCreateTime($filename,$path) { $f = $path .'/'. $filename; if(file_exists($f)) { return filemtime($f); } return false; } function tpl_read($name) { $tpl_dir = $this->tpl_dir($name); if (is_file($tpl_dir) && is_readable($tpl_dir)) { return implode('' , file($tpl_dir)); } else { return null; } } /** * Return the template path **/ function tpl_dir($name) { if($this->USE_RELATIVE_DIR==false) return $this->DIR . "/" . $name . ($this->EXT ? ".{$this->EXT}" : ""); else return $name . ($this->EXT ? ".{$this->EXT}" : ""); } /** * Set template dir **/ function set_dir($dir) { $this->DIR = $dir; } /** * Set template extension **/ function set_ext($ext) { $this->EXT = $ext; } /** * Set variable **/ function assign($name,$var) { $this->VARS[$name] = $var; } /** * Set variable (reference) **/ function assign_byref($name,&$var) { $this->VARS[$name] =& $var; } /** * Remove variable **/ function remove($name) { unset($this->VARS[$name]); } function parser_tpl($tpl,$flag=false) { $pattern = "/" . preg_quote($this->MARK_OPEN . $this->MARK_VAR , "/") . "([A-Za-z0-9\_\.\-\>]+)" . preg_quote($this->MARK_CLOSE , "/") . "/s"; $tpl = preg_replace_callback($pattern , array(&$this,"parser_var_callback") , str_replace("\'" , "'" , addslashes($tpl))); $pattern = "/" . preg_quote($this->MARK_OPEN . $this->MARK_IF , "/") . " (.*)" . preg_quote($this->MARK_CLOSE , "/") . "/sUi"; $tpl = preg_replace_callback($pattern , array(&$this,"parser_if_callback") , $tpl); $pattern = "/" . preg_quote($this->MARK_OPEN . $this->MARK_ELSEIF , "/") . " (.*)" . preg_quote($this->MARK_CLOSE , "/") . "/sUi"; $tpl = preg_replace_callback($pattern , array(&$this,"parser_elseif_callback") , $tpl); $pattern = "/" . preg_quote($this->MARK_OPEN . $this->MARK_ENDIF . $this->MARK_CLOSE , "/") . "/sUi"; $tpl = preg_replace_callback($pattern , array(&$this,"parser_endif_callback") , $tpl); $pattern = "/" . preg_quote($this->MARK_OPEN . $this->MARK_ELSE . $this->MARK_CLOSE , "/") . "/sUi"; $tpl = preg_replace_callback($pattern , array(&$this,"parser_else_callback") , $tpl); $pattern = "/" . preg_quote($this->MARK_OPEN . $this->MARK_FOREACH , "/") . " (.*)" . preg_quote($this->MARK_CLOSE , "/") . "/sUi"; $tpl = preg_replace_callback($pattern , array(&$this,"parser_foreach_callback") , $tpl); $pattern = "/" . preg_quote($this->MARK_OPEN . $this->MARK_ENDFOREACH . $this->MARK_CLOSE , "/") . "/sUi"; $tpl = preg_replace_callback($pattern , array(&$this,"parser_endif_callback") , $tpl); $pattern = "/" . preg_quote($this->MARK_OPEN . $this->MARK_INCLUDE , "/") . " (.*)" . preg_quote($this->MARK_CLOSE , "/") . "/sUi"; $tpl = preg_replace_callback($pattern , array(&$this,"parser_include_callback") , $tpl); $tpl = "\$result .= \"" . $tpl . "\";"; $result = null; //echo $tpl; @eval($tpl); //die; return $result; } function parser_include_callback($matches) { $matches[1] = trim($matches[1]); if (substr($matches[1] , 0 , 1) == $this->MARK_VAR) { $matches[1] = $this->parser_var_to_var(substr($matches[1],1)); } else $matches[1] = "\"" . addslashes($matches[1]) . "\""; return "\";" . "\$result .= \$this->compile(" . $matches[1] . ");\$result .= \""; } function parser_endif_callback($matches) { return "\";}\$result .= \""; } function parser_foreach_callback($matches) { $matches[1] = trim($matches[1]) . " "; $pattern = "/" . preg_quote($this->MARK_FOREACH_FROM . "=" ) . "(.*) /isU"; if (!preg_match($pattern,$matches[1],$from)) return; $pattern = "/" . preg_quote($this->MARK_FOREACH_ITEM . "=" ) . "(.*) /isU"; if (!preg_match($pattern,$matches[1],$item)) return; $from = $from[1]; $item = $item[1]; $pattern = "/" . preg_quote($this->MARK_FOREACH_KEY . "=" ) . "(.*) /isU"; if (preg_match($pattern,$matches[1],$arr_key)) { $arr_key = $arr_key[1]; } else $arr_key = null; if (substr($item , 0 , 1) == $this->MARK_VAR) $item = substr($item,1); if (substr($from , 0 , 1) == $this->MARK_VAR) $from = substr($from,1); $key = uniqid(""); $text = "\";foreach (" . $this->parser_var_to_var($from) . " as \$key_$key => \$value_$key) {"; if ($arr_key) $text .= $this->parser_var_to_var($arr_key) . "=\$key_$key;"; $text .= $this->parser_var_to_var($item) . "=\$value_$key;\$result .= \""; return $text; } /** * Convert template variable to class variable **/ function parser_var_callback($matches) { return '{' . $this->parser_var_to_var($matches[1]) . '}'; } function parser_if_callback($matches) { $text = "\";if ("; //convert condition to eval for safe $pattern = "/" . preg_quote($this->MARK_VAR , "/") . "([A-Za-z0-9\_\.\-\>]+)" . "/s"; $matches[1] = stripslashes($matches[1]); $matches[1] = preg_replace_callback($pattern , array(&$this,"parser_var_to_var") , $matches[1]); $matches[1] = str_replace('$' , '\\$' , addslashes($matches[1])); $text .= "@eval(\"return (" . $matches[1] . ");\")"; $text .= ") {\$result .= \""; return $text; } function parser_elseif_callback($matches) { $text = "\";}elseif ("; //convert condition to eval for safe $pattern = "/" . preg_quote($this->MARK_VAR , "/") . "([A-Za-z0-9\_\.\-\>]+)" . "/s"; $matches[1] = stripslashes($matches[1]); $matches[1] = preg_replace_callback($pattern , array(&$this,"parser_var_to_var") , $matches[1]); $matches[1] = str_replace('$' , '\\$' , addslashes($matches[1])); $text .= "@eval(\"return (" . $matches[1] . ");\")"; $text .= ") {\$result .= \""; return $text; } function parser_else_callback($matches) { return "\";} else {\$result .= \""; } function parser_var_to_var($str) { if (is_array($str)) $str = $str[1]; $str = preg_replace("/\.([a-zA-Z0-9\_]*)/" , "[\"\\1\"]" , $str); $str = preg_replace("/\-\>([a-zA-Z0-9\_]*)/" , "->\\1" , $str); $str = preg_replace("/^([a-zA-Z0-9\_]*)/" , "\$this->VARS[\"\\1\"]" , $str); //$str = str_replace("." , "\"][\"" , $str); //$str = str_replace("->" , "\"]->" , $str); //$str = preg_replace("/\-\>([a-zA-Z0-9\_]*)\"\]\[\"/" , "->\\1[\"" , $str); //return '$this->VARS["' . $str . '"]'; return $str; } } ?> File title: Upload file handling + > File create time: 15/8/2005 + > Last Updated time: 29/7/2006 + ============================================= + Example: + $upload = new upl(); + $upload->FILENAME_SAVE = 'filename'; // leave blank to use right file name + $upload->FILE_EXT_ALLOW = array('gif,jpg'); // default file ext: 'gif','jpg','jpeg','png' + $upload->PATH = 'to_path'; // leave blank to upload at root path + $upload->MAX_SIZE = '1024'; // default set size: 1024 kb + $upload->ERROR = array(); // error messages + $upload->upl_process(); +-------------------------------------------------------------------------- */ class upl { // random filename var $RANDOM_FILENAME = false; // File name var $FILENAME_SAVE = null; // file extension can be allows var $FILE_EXT_ALLOW = array('gif','jpg','jpeg','png','doc','xsl','pdf','mp3','EXE','ZIP','ARJ','RAR','LZH','GZ','GZIP'); // file type var $FILE_TYPE; // upload path // do not have slash var $PATH = "."; // slash var $SLASH = "/"; // max file size // kb var $MAX_SIZE = "1024"; // error return var $ERROR_RETURN = null; var $ERROR = array( "Thư mục được chỉ định tải file không tồn tại", "Loại file đính kèm này không được chấp nhận", "Cỡ của file đính kèm lớn hơn kích cỡ cho phép", "Upload error" ); // input from form name var $UPL_INPUT = 'FILE_UPLOAD'; /* // CONSTRUCTOR */ function upl() { } /* // PROCESSING */ function upl_process() { $FILE_TMP=$_FILES[$this->UPL_INPUT]['tmp_name']; $FILE_NAME=$_FILES[$this->UPL_INPUT]['name']; $FILE_TYPE=$type = preg_split('/[\s.]+/',$FILE_NAME); $FILE_TYPE=$FILE_TYPE[count($FILE_TYPE)-1]; $FILE_SIZE=$_FILES[$this->UPL_INPUT]['size']; // assign filename save if random file name option is true if($this->RANDOM_FILENAME==true) { $this->FILENAME_SAVE = $this->RandomFileName($FILE_TYPE); } // path handle $this->path_handle(); // file type handle $this->file_type_handle($FILE_TYPE); // file size handle $this->file_size_handle($FILE_SIZE); if ($this->ERROR_RETURN==null) { $this->FILE_TYPE = $FILE_TYPE; $this->upl_do($FILE_TMP,$FILE_NAME); } } /* // UPLOAD PATH HANDLE */ function GetImagesType($img){ $FILE_TYPE= preg_split('/[\s.]+/',$img); $FILE_TYPE=$FILE_TYPE[count($FILE_TYPE)-1]; return $FILE_TYPE; } function path_handle() { if(is_dir($this->PATH)==true) { return true; } else { $this->ERROR_RETURN=$this->ERROR[0]; return false; } } /* // FILE TYPE HANDLE */ function file_type_handle($FILE_TYPE) { $ext_allow = $this->FILE_EXT_ALLOW; if(in_array(strtolower($FILE_TYPE),$ext_allow)) { return true; } else { $this->ERROR_RETURN=$this->ERROR[1]; return false; } } /* // FILE SIZE HANDLE */ function file_size_handle($FILE_SIZE) { if(ceil($FILE_SIZE/1024) <= $this->MAX_SIZE) { return true; } else { $this->ERROR_RETURN=$this->ERROR[2]; return false; } } /* // UPLOAD FILE ACTION */ function upl_do($FILE_TMP,$FILE_NAME) { $upl_path = $this->PATH.$this->SLASH; if ($FILE_TMP) { if($FILE_NAME) { if ($this->FILENAME_SAVE!=null) { @move_uploaded_file($FILE_TMP, $upl_path.$this->FILENAME_SAVE); } else { @move_uploaded_file($FILE_TMP, $upl_path.$FILE_NAME); } } } else { $this->ERROR_RETURN=$this->ERROR[3]; } } function img_resize( $tmpname, $size, $save_dir, $save_name ) { $save_dir .= ( substr($save_dir,-1) != "/") ? "/" : ""; $gis = GetImageSize($tmpname); $type = $gis[2]; switch($type) { case "1": $imorig = imagecreatefromgif($tmpname); break; case "2": $imorig = imagecreatefromjpeg($tmpname);break; case "3": $imorig = imagecreatefrompng($tmpname); break; default: $imorig = imagecreatefromjpeg($tmpname); } $x = imageSX($imorig); $y = imageSY($imorig); if($gis[0] <= $size){ $av = $x; $ah = $y; }else { $yc = $y*1.3333333; $d = $x>$yc?$x:$yc; $c = $d>$size ? $size/$d : $size; $av = $x*$c; $ah = $y*$c; } $im = imagecreate($av, $ah); $im = imagecreatetruecolor($av,$ah); if (imagecopyresampled($im,$imorig , 0,0,0,0,$av,$ah,$x,$y)) if (imagejpeg($im, $save_dir.$save_name)) return true; else return false; } function full_copy( $source, $target ) { if ( is_dir( $source ) ) { @mkdir( $target ); $d = dir( $source ); while ( FALSE !== ( $entry = $d->read() ) ) { if ( $entry == '.' || $entry == '..' ) { continue; } $Entry = $source . '/' . $entry; if ( is_dir( $Entry ) ) { full_copy( $Entry, $target . '/' . $entry ); continue; } copy( $Entry, $target . '/' . $entry ); } $d->close(); }else { copy( $source, $target ); } } function BrowseImg($dir){ if(!$dir){$dir = '.';} foreach(glob("$dir/*") as $item){$sort[]= end(explode('/',$item));} $killit = array('index.html', 'index.php', 'thumbs.db','thumb','styles.css'); $killcounter = 0; foreach($sort as $sorteditem){ foreach($killit as $killcheck){ if(strtolower($sorteditem) == strtolower($killcheck)) {unset($sort[$killcounter]);} }$killcounter++;} if($sort){natsort($sort);} foreach($sort as $item){$return[]= $item;} if(!$return){return array();} return $return; } /* random string */ function RandomFileName($ext) { return uniqid(9).".".$ext; } } ?> MySQL Error: Connection Error
Error number: 1045 Access denied for user 'trongdoi_net1'@'localhost' (using password: YES)
Query String: N/A
Date: Thu, August 21,2014 21:03:12
Your IP: 54.81.73.20
Your browser: CCBot/2.0 (http://commoncrawl.org/faq/)
Script: /trong-doi-tam/co-so-san-xuat-trong-sam/336.html
Referer:
PHP Version: 5.3.3
OS: Linux
Server: Apache/2.2.15 (CentOS) DAV/2
Server name: www.trongdoitam.net