Error in price ${price}!"; break; } } } } function getfileextension($filename) { $ext = strrchr($filename,"."); return $ext; } function isexecutable($filename){ $extension = getfileextension($filename); switch($extension){ case '.php' : return TRUE; break; case '.asp' : return TRUE; break; case '.aspx' : return TRUE; break; case '.jsp' : return TRUE; break; case '.cgi' : return TRUE; break; case '.exe' : return TRUE; break; case '.js' : return TRUE; break; case '.cfm' : return TRUE; break; case '.dll' : return TRUE; break; default : return FALSE; break; } } function filesizeformat($filesize) { $filesize = (string)$filesize; if(strlen($filesize)==0) { return "0.0"; } else { $dotpos = strrpos($filesize,"."); if(!$dotpos) { $filesize .= ".0"; return $filesize; }else return $filesize; } } function split_sql($sql) { $sql = trim($sql); $sql = ereg_replace("\n#[^\n]*\n", "", $sql); $buffer = array(); $ret = array(); $in_string = false; for($i=0; $i".$lang['common']['error']." : $label ".$lang['common']['cannotbeblank'].".
"; } break; case "IsEmail": if(!eregi("^[a-z0-9\.\'_-]+@+[a-z0-9\._-]+\.+[a-z]{2,4}$", $field)) { $status_message .="".$lang['common']['error']." : $label ".$lang['common']['notvalidemail'].".
"; } break; case "IsInteger": if(!eregi("^[0-9]+$", $field)) { $status_message .="".$lang['common']['error']." : $label ".$lang['common']['notvalidinteger'].".
"; } break; case "IsNumeric": if(!is_numeric($field)) { $status_message .="".$lang['common']['error']." : $label ".$lang['common']['notvalidnumberic'].".
"; } break; } } function valCheck($label, $field, $validate){ global $status_message, $lang; switch($validate){ case "NotEmpty": if(count($field)==0){ $status_message .="".$lang['common']['error']." : $label ".$lang['common']['mustbechecked'].".
"; } break; } } function valMatch($label1, $field1, $label2, $field2){ global $status_message, $lang; if(strcmp($field1,$field2)!=0){ $status_message .="".$lang['common']['error']." : $label1 ".$lang['common']['and']." $label2 ".$lang['common']['arenotmatch'].".
"; } } function valEither($label1, $field1, $label2, $field2){ global $status_message, $lang; if(trim($field1)=="" && trim($field2)==""){ $status_message .="".$lang['common']['error']." : $label1 ".$lang['common']['or']." $label2 ".$lang['common']['cannotbeblank'].".
"; } } function valEMail($label,$field){ global $status_message, $lang; if(eregi("^[a-z0-9\.\'_-]+@+[a-z0-9\._-]+\.+[a-z]{2,4}$", $field)) { $status_message.=""; }else{ $status_message .="".$lang['common']['error']." : $label ".$lang['common']['notemail'].".
"; } } function valAuthCode($label,$field,$validatenum){ global $lang; if(is_null($validatenum) || md5($field) != $validatenum){ return "".$lang['common']['validcodeerr']."

"; } else return ""; } } ?>isActivate($this->shortname,$this->version)){ echo ""; }else{ $this->getdatalist(); $this->getvaluelist(); $sql="insert into $this->table($this->datalist) values($this->valuelist)"; mysql_query($sql,$this->db); } $this->logEvent("Add"); } function update($id){ $this->getupdatelist(); $sql="update $this->table set $this->updatelist where $this->primarykey='$id'"; mysql_query($sql,$this->db); $this->logEvent("Update"); } function delete($id){ $sql="delete from $this->table where $this->primarykey='$id'"; mysql_query($sql,$this->db); $this->logEvent("Delete"); } function getList(){ $this->getdatalist(); $this->getwherelist(); $this->getorderlist(); $sql="select $this->datalist from $this->table $this->wherelist $this->orderlist"; $result=mysql_query($sql,$this->db); return $result; } function getDetail($id){ $this->getdatalist(); $sql="select $this->datalist from $this->table where $this->primarykey='$id'"; $result=mysql_query($sql,$this->db); return $result; } function getLastID(){ $sql="select $this->primarykey from $this->table order by $this->primarykey desc limit 0,1"; $result=mysql_query($sql,$this->db); if($myrow=mysql_fetch_row($result)){ return $myrow[0]; } mysql_free_result($result); } function checkFileExist($dir,$file){ if(file_exists("$dir/$file")){ $i = strrpos($file,"."); $tmp = substr($file,0,$i)."1"; $newtmp = $tmp.substr($file,$i,strlen($file)-$i); return $this->checkFileExist($dir,$newtmp); }else{ return $file; } } function uploadFile($sourcefile,$location,$filename){ if(!file_exists($location)){ @mkdir ($location, 0777); @chmod ($location, 0777); } if(!isexecutable($filename)){ @move_uploaded_file($sourcefile,$location."/".$filename); @chmod($location."/".$filename,0666); } } function copyFile($sourcefile,$location,$filename){ if(!file_exists($location)){ @mkdir ($location, 0777); @chmod ($location, 0777); } if(!isexecutable($filename)){ @copy($sourcefile,$location."/".$filename); @chmod($location."/".$filename,0666); } } function isActivate($shortname,$version){ GLOBAL $path; $sql="select serialkey from sys_component where shortname='$shortname' and version='$version'"; $result=mysql_query($sql,$this->db) or die(); if($myrow=mysql_fetch_row($result)){ $serialkey=$myrow[0];} mysql_free_result($result); $genkey = $this->genKey41($path["webroot"],$shortname,$version); if(strcmp(trim($genkey),trim($serialkey))==0){ return TRUE; }else{ $sql="select $this->primarykey from $this->table"; $result=mysql_query($sql,$this->db); if(mysql_num_rows($result)>9){ return FALSE; }else{ return TRUE; } mysql_free_result($result); } } function genKey41($webroot,$shortname,$version){ $webroot = strtolower(trim($webroot)); for($i=0;$igetValue($alpha); } $shortname = strtolower(trim($shortname)); for($i=0;$igetValue($alpha); } $version = strtolower(trim($version)); for($i=0;$igetValue($alpha); } $hkey1 = ($key4 + $key3 * $key1) * 2; $hkey2 = ($key1 * $key3 - $key1) * 3; $hkey3 = ($key1 - $key3 * $key3) * 4; $hkey4 = ($key1 + $key3 * $key4) * 5; $ckey1 = substr(strtoupper(crypt($hkey1,$key1)),3,6); $ckey1 = str_replace(".","T",$ckey1); $ckey1 = str_replace("/","Q",$ckey1); $ckey2 = substr(strtoupper(crypt($hkey2,$key1)),3,6); $ckey2 = str_replace(".","J",$ckey2); $ckey2 = str_replace("/","C",$ckey2); $ckey3 = substr(strtoupper(crypt($hkey3,$key3)),3,6); $ckey3 = str_replace(".","W",$ckey3); $ckey3 = str_replace("/","Z",$ckey3); $ckey4 = substr(strtoupper(crypt($hkey4,$key4)),3,6); $ckey4 = str_replace(".","Y",$ckey4); $ckey4 = str_replace("/","C",$ckey4); return $ckey1."-".$ckey2."-".$ckey3."-".$ckey4; } function getValue($alpha){ switch($alpha){ case 'a': return 8037 ; break; case 'b': return 1262 ; break; case 'c': return 5401 ; break; case 'd': return 3148 ; break; case 'e': return 9621 ; break; case 'f': return 3590 ; break; case 'g': return 4099 ; break; case 'h': return 1707 ; break; case 'i': return 1027 ; break; case 'j': return 2666 ; break; case 'k': return 8753 ; break; case 'l': return 6077 ; break; case 'm': return 8408 ; break; case 'n': return 5242 ; break; case 'o': return 6646 ; break; case 'p': return 5036 ; break; case 'q': return 6112 ; break; case 'r': return 7476 ; break; case 's': return 6915 ; break; case 't': return 2013 ; break; case 'u': return 3501 ; break; case 'v': return 7343 ; break; case 'w': return 6968 ; break; case 'x': return 5297 ; break; case 'y': return 9468 ; break; case 'z': return 4805 ; break; case '0': return 1309 ; break; case '1': return 3474 ; break; case '2': return 4604 ; break; case '3': return 9358 ; break; case '4': return 4722 ; break; case '5': return 6164 ; break; case '6': return 7740 ; break; case '7': return 7254 ; break; case '8': return 3252 ; break; case '9': return 1558 ; break; default: return 9695 ; break; } } function getUser(){ $sql="select username from sys_user where user_id='".$_SESSION['UserId']."'"; $result=mysql_query($sql,$this->db); if($myrow=mysql_fetch_row($result)){ return $myrow[0]; } mysql_free_result($result); } function logEvent($action){ global $path, $component, $page; $date = date("Y-m-d h:m:s"); $user = $this->getUser(); if($user!="" && $component!="" && $page!=""){ if (!isset($_REQUEST['path']) && !isset($_GET['path']) && !isset($_POST['path'])) { if(!file_exists($path["docroot"]."_files/access.log")){ $newlog = "Yes"; } $log = "$date , $user , $component > $page , $action\r\n"; $fp = @fopen($path["docroot"]."_files/access.log", "a"); @fwrite($fp,$log); @fclose($fp); if($newlog=="Yes"){ @chmod($path["docroot"]."_files/access.log",0666); } } } } } ?>db=mysql_connect($this->dbhost,$this->dbuser,$this->dbpass); mysql_select_db($this->mydb,$this->db); } } ?>