require_once("config.inc.php"); require_once("include/class.database.php"); require_once("include/class.page.php"); require_once("include/class.imagetransform.php"); require_once("include/class.phpmailer.php"); require_once("include/class.smtp.php"); require_once("include/class.cart.php"); require_once("include/class.ui.php"); require_once("include/class.member.php"); //ini_set("error_reporting","E_ALL & ~E_NOTICE"); $db = new database; $db->connect($dbhost, $dbuser, $dbpw, $dbname); $db->show_time(false); session_start(); //cart session /* if (!isset($_SESSION["cart"])) { $_SESSION["cart"] = & new classCart(); } $cart = &$_SESSION["cart"]; //Member session if (!isset($_SESSION["member"])) { $_SESSION["member"] = & new Member($dbhost, $dbuser, $dbpw, $dbname); } $member = &$_SESSION["member"]; */ unset($dbhost, $dbuser, $dbpw, $dbname); // Translate function getpost() { if(count($_POST)) { foreach($_POST as $key => $value) { global ${$key}; if (is_array($value)) { $temp_array = array(); foreach($value as $key2 => $value2) { if (get_magic_quotes_gpc() == 1) { $temp_array[$key2] = stripslashes(trim($value2)); } else { $temp_array[$key2] = trim($value2); } } ${$key} = $temp_array; } else { if (get_magic_quotes_gpc() == 1) { ${$key} =stripslashes(trim($value)); } else { ${$key} = trim($value); } } } } } function getget() { if(count($_GET)) { foreach($_GET as $key => $value) { global ${$key}; if (is_array($value)) { $temp_array = array(); foreach($value as $key2 => $value2) { if (get_magic_quotes_gpc() == 1) { $temp_array[$key2] = stripslashes(trim($value2)); } else { $temp_array[$key2] = trim($value2); } } ${$key} = $temp_array; } else { if (get_magic_quotes_gpc() == 1) { ${$key} =stripslashes(trim($value)); } else { ${$key} = trim($value); } } } } } function dayConvert($day) { switch($day) { case "Monday": return "星期一"; case "Tuesday": return "星期二"; case "Wednesday": return "星期三"; case "Thursday": return "星期四"; case "Friday": return "星期五"; case "Saturday": return "星期六"; case "Sunday": return "星期日"; default: return "Error"; } } function escapeit($text) { if (get_magic_quotes_gpc() == 1) { $text = stripslashes($text); } if ( !is_numeric($text) ) { $text = mysql_real_escape_string($text); } return $text; } function color($text) { $color = ''; $text = strtolower($text); switch($text) { case "display": $color = "#669900"; break; case "hidden": $color = "#FF0000"; break; case "alipay": $color = "#FFCC66"; break; case "paypal": $color = "#0099FF"; break; default: $color = $text; break; } return $color; } function nl2html($str) { return nl2br(htmlspecialchars($str)); } function add_dot($val, $limit) { $result = ''; if(mb_strlen($val, 'UTF-8') > $limit) { $result = mb_substr($val, 0, $limit, 'UTF-8').'...'; } else { $result = $val; } return $result; } function genphoto($file, $destination, $width="", $height="", $prefix="") { if ($file != "") { $temp = split("\.", $file); $ext = $temp[count($temp)-1]; $filename = randStr(12, "NUMBER").".".$ext; $imgTrans = new imageTransform(); $imgTrans->sourceFile = $destination.$file; $imgTrans->targetFile = $destination.$prefix."_".$filename; $imgTrans->chmodValue = 0777; $imgTrans->resizeToWidth = $width; $imgTrans->resizeToHeight = $height; $imgTrans->jpegOutputQuality = 80; $imgTrans->resize(); } } function resize_photo($file, $source, $destination, $width="", $height="") { if ($file != "") { $filename = $file; $imgTrans = new imageTransform(); $imgTrans->sourceFile = $source.$file; $imgTrans->targetFile = $destination.$filename; $imgTrans->chmodValue = 0777; $imgTrans->resizeToWidth = $width; $imgTrans->resizeToHeight = $height; $imgTrans->jpegOutputQuality = 80; $imgTrans->resizeIfSmaller = false; $imgTrans->resize(); } } function add_attachment($file, $destination, $destination2, $destination3, $destination4, $destination5, $path, $table_name, $table_id="", $temp_id="", $col_name, $sorting=0) { global $db; if ($file != "") { $realname = $file["name"]; $temp = split("\.", $realname); $ext = $temp[count($temp)-1]; $filename = randStr(12, "NUMBER").".".$ext; while (file_exists($destination.$filename)) { $filename = randStr(12, "NUMBER").".".$ext; } //move_uploaded_file($file, $destination.$filename); move_uploaded_file($file["tmp_name"], $destination.$filename); chmod($destination.$filename, 0777); if ($re_name != "") { $filename = $re_name."_".$filename; } if ($table_id != "") { $sql = "SELECT `attachment_id`, `file_name` FROM `attachment` WHERE `table_name` = '".$table_name."' AND `table_id` = '".$table_id."' AND `col_name` = '".$col_name."'"; $rs = $db->query($sql); if (mysql_num_rows($rs) > 0 && (trim($table_id) != "")) { $rowfile = $db->fetch_array($rs); if ($destination != "") { @unlink($destination.$rowfile["file_name"]); } if ($destination2 != "") { @unlink($destination2.$rowfile["file_name"]); } if ($destination3 != "") { @unlink($destination3.$rowfile["file_name"]); } if ($destination4 != "") { @unlink($destination4.$rowfile["file_name"]); } if ($destination5 != "") { @unlink($destination5.$rowfile["file_name"]); } $attachment_id = $rowfile["attachment_id"]; $sql = "UPDATE `attachment` SET `file_name` = '".$filename."', `real_name` = '".$realname."', `upload_date` = '".date("Y-m-d")."', `upload_time` = '".date("H:i:s")."' WHERE `table_name` = '".$table_name."' AND `table_id` = '".$table_id."' AND `col_name` = '".$col_name."'"; $db->query($sql); } else { $sql = "INSERT INTO `attachment` ( `attachment_id` , `table_name` , `table_id` , `temp_id`, `col_name`, `file_name` , `real_name` , `path` , `sorting` , `upload_date` , `upload_time` , `user_id` ) VALUES ( NULL , '".$table_name."', '".$table_id."', '".$temp_id."', '".$col_name."', '".$filename."', '".$realname."', '".$path."', '".$sorting."', '".date("Y-m-d")."', '".date("H:i:s")."', '0' );"; $db->query($sql); $attachment_id = $db->insert_id(); } } else if ($temp_id != "") { $sql = "SELECT `attachment_id`, `file_name` FROM `attachment` WHERE `table_name` = '".$table_name."' AND `temp_id` = '".$temp_id."' AND `col_name` = '".$col_name."'"; $rs = $db->query($sql); if (mysql_num_rows($rs) > 0 && (trim($temp_id) != "")) { $rowfile = $db->fetch_array($rs); if ($destination != "") { @unlink($destination.$rowfile["file_name"]); } if ($destination2 != "") { @unlink($destination2.$rowfile["file_name"]); } if ($destination3 != "") { @unlink($destination3.$rowfile["file_name"]); } if ($destination4 != "") { @unlink($destination4.$rowfile["file_name"]); } if ($destination5 != "") { @unlink($destination5.$rowfile["file_name"]); } $attachment_id = $rowfile["attachment_id"]; $sql = "UPDATE `attachment` SET `file_name` = '".$filename."', `real_name` = '".$realname."', `upload_date` = '".date("Y-m-d")."', `upload_time` = '".date("H:i:s")."' WHERE `table_name` = '".$table_name."' AND `temp_id` = '".$temp_id."' AND `col_name` = '".$col_name."'"; $db->query($sql); } else { $sql = "INSERT INTO `attachment` ( `attachment_id` , `table_name` , `table_id` , `temp_id`, `col_name`, `file_name` , `real_name` , `path` , `sorting` , `upload_date` , `upload_time` , `user_id` ) VALUES ( NULL , '".$table_name."', '".$table_id."', '".$temp_id."', '".$col_name."', '".$filename."', '".$realname."', '".$path."', '".$sorting."', '".date("Y-m-d")."', '".date("H:i:s")."', '0' );"; $db->query($sql); $attachment_id = $db->insert_id(); } } $file_array = array(); $file_array["attachment_id"] = $attachment_id; $file_array["filename"] = $filename; $file_array["realname"] = $realname; $file_array["colname"] = $colname; return $file_array; } } function getrowdata($data_name, $row) { for($i=0; $i < sizeof($data_name);$i++) { $col_name = $data_name[$i]; global ${$col_name}; switch($col_name) { default: ${$col_name} = $row[$col_name]; } } } function del_attachment($attachment_id,$prefix_path="../../"){ global $db; $sql = "SELECT `file_name`, `path` FROM `attachment` WHERE `attachment_id` = '".escapeit($attachment_id)."'"; $row = $db->getrow($sql); @unlink($prefix_path.$row["path"]."original/".$row["file_name"]); @unlink($prefix_path.$row["path"]."thumb_s/".$row["file_name"]); $sql = "DELETE FROM `attachment` WHERE `attachment_id` = '".escapeit($attachment_id)."'"; $db->query($sql); } function del_all_attachment($table_name,$value,$prefix_path="../../"){ global $db; $sql = "SELECT `file_name`, `path` FROM `attachment` WHERE `table_name` = '".escapeit($table_name)."' AND `table_id` = '".escapeit($value)."'"; $rs = $db->query($sql); while ($row = $db->fetch_array($rs)) { @unlink($prefix_path.$row["path"]."original/".$row["file_name"]); @unlink($prefix_path.$row["path"]."thumb_s/".$row["file_name"]); } $sql = "DELETE FROM `attachment` WHERE `table_name` = '".escapeit($table_name)."' AND `table_id` = '".escapeit($value)."'"; $db->query($sql); } function get_attachment($table_name,$table_id,$col_name){ global $db; $sql = " SELECT `attachment_id`, `path`, `real_name`, `file_name`, `attach_caption` FROM `attachment` WHERE `table_name`='".$table_name."' and `table_id`='".$table_id."' and `col_name`='".$col_name."' "; $result = $db->query($sql); $row = mysql_fetch_assoc($result); $array["attachment_id"] = $row["attachment_id"]; $array["path"] = $row["path"]; $array["real_name"] = $row["real_name"]; $array["file_name"] = $row["file_name"]; $array["attach_caption"] = $row["attach_caption"]; $sql = 'select `attachment_id`, `path`, `real_name`, `file_name` FROM `attachment` where `table_name`="'.$table_name.'" and `table_id`="'.$table_id.'" and `col_name` LIKE "%'.$col_name.'%"'; //echo $sql; $rs = $db->query($sql); $array["count"] = mysql_num_rows($rs); return $array; } function get_all_attachment($table_name,$table_id){ global $db; $sql = " SELECT col_name,path,file_name FROM `attachment` WHERE `table_name`='".$table_name."' and `table_id`='".$table_id."' "; $result = $db->query($sql); while($row = mysql_fetch_assoc($result)){ $myAttachment[$row["col_name"]]=$row["path"].$row["file_name"]; } return $myAttachment; } function show_attachment($file){ $lower_filename=strtolower($file); if( strstr($lower_filename,".jpg") || strstr($lower_filename,".jpeg") || strstr($lower_filename,".gif") || strstr($lower_filename,".png") ){ return '