dblink; $currentdate=date('Y/m/d H:i:s'); $chinese_month=array("","一","二","三","四","五","六","七","八","九","十","十一","十二"); function getIP() { $ip; if (getenv("HTTP_CLIENT_IP")) $ip = getenv("HTTP_CLIENT_IP"); else if(getenv("HTTP_X_FORWARDED_FOR")) $ip = getenv("HTTP_X_FORWARDED_FOR"); else if(getenv("REMOTE_ADDR")) $ip = getenv("REMOTE_ADDR"); else $ip = "UNKNOWN"; return $ip; } function getCroppedImage($file,$target_width=80,$target_height=80,$pointer=1,$link=0){ if( !file_exists($file) ){ return ""; } $size=getimagesize($file); $width=$size[0]; $height=$size[1]; if($width>$target_width){ $margin_left=-($width-$target_width)/2; }else{ $margin_left=0; } if($height>$target_height){ $margin_top=-($height-$target_height)/2; }else{ $margin_top=($target_height-$height)/2; } if($pointer==1){ $cursor="pointer"; }else{ $cursor="default"; } /*$temp='onclick="window.open(this.parentNode.parentNode.href,\'_top\',\'\'); ';*/ if($link==1){ $temp='
'; }else{ $temp='
'; } return $temp; } function generatePassword($length=9, $strength=0) { $vowels = 'aeuy'; $consonants = 'bdghjmnpqrstvz'; if ($strength & 1) { $consonants .= 'BDGHJLMNPQRSTVWXZ'; } if ($strength & 2) { $vowels .= "AEUY"; } if ($strength & 4) { $consonants .= '23456789'; } if ($strength & 8) { $consonants .= '@#$%'; } $password = ''; $alt = time() % 2; for ($i = 0; $i < $length; $i++) { if ($alt == 1) { $password .= $consonants[(rand() % strlen($consonants))]; $alt = 0; } else { $password .= $vowels[(rand() % strlen($vowels))]; $alt = 1; } } return $password; } function funPrintCheckBoxImg($input,$value,$fieldname){ $temp_array=split(",",$input); if(count($temp_array)>0){ if( in_array($value, $temp_array) ){ $check=true; }else{ $check=false; } }else{ if( strstr($input, $value) ){ $check=true; }else{ $check=false; } } if($check){ $checked="checked=true"; print ''; }else{ print ''; } } function funPrintCheckBox_status($input,$value){ $temp_array=$input; if(count($temp_array)>0){ if( in_array($value, $temp_array) ){ $check=true; }else{ $check=false; } }else{ if( strstr($input, $value) ){ $check=true; }else{ $check=false; } } if($check){ $checked="checked=true"; }else{ $checked="x"; } return $checked; } function funPrintCheckBox($input,$value,$fieldname){ $temp_array=split(",",$input); if(count($temp_array)>0){ if( in_array($value, $temp_array) ){ $check=true; }else{ $check=false; } }else{ if( strstr($input, $value) ){ $check=true; }else{ $check=false; } } if($check){ $checked="checked=true"; }else{ $checked=""; } print ''; } function add_prefix($imagePath,$prefix="s"){ if($imagePath!=""){ $temp=explode("/",$imagePath); $temp[count($temp)-1]=$prefix."_".$temp[count($temp)-1]; $temp_string=implode("/",$temp); return $temp_string; }else{ return ""; } } function funSmile($input,$count){ for($i=0;$i<$count;$i++){ $temp.=$input; } //funSmile return $temp; } function arrayToTable($input){ $output= ' '; if(count($input)>0){ foreach($input as $key => $value) { $output.=' '; } } $output.='
'.htmlspecialchars(ucfirst($key)).'\'.$'.htmlspecialchars($key).'.\'
'; print $output; } function funCurrencyNT($input){ return ($input/4); } function funOrderNo2($input){ return str_pad($input, 4, "0", STR_PAD_LEFT); } function funOrderNo($input){ return str_pad($input, 6, "0", STR_PAD_LEFT); } function j_goto($input,$target="_top"){ print ' '; } function j_alert($input){ $input = str_replace("\n", '\n', $input); $input = str_replace("\r", '', $input); print ' '; } function funMyCurrency2($input){ return number_format($input, 0, ".", ","); } function funMyCurrency($input){ return number_format($input, 2, ".", ","); } function funMyNumber($input){ return number_format($input, 0, ".", ","); } function funHKD2USD($input){ return number_format($input/7.8, 2, ".", ","); } function pw_encode($password) { for ($i = 1; $i <= 8; $i++) $seed .= substr('0123456789abcdef', rand(0,15), 1); return md5($seed.$password).$seed; } function pw_check($password,$stored_value) { $stored_seed = substr($stored_value,32,8); if (md5($stored_seed.$password).$stored_seed == $stored_value) return TRUE; else return FALSE; } function funGenTrRadio($fieldname,$displaytext=""){ Global $row; $value=$row[$fieldname]; $myid=$fieldname; if($displaytext==""){ $displaytext=$fieldname; $displaytext=str_replace("_"," ",$displaytext); $displaytext=ucwords($displaytext); } if($value==""){ $value=0; } $checked[$value]="checked"; $temp=' '.$displaytext.': Yes      No '; print $temp; } function funGenTrText($fieldname,$displaytext="",$type=0){ Global $row; $value=$row[$fieldname]; $myid=$fieldname; if($displaytext==""){ $displaytext=$fieldname; $displaytext=ucfirst($displaytext); } if($type==0){ $temp=' '.$displaytext.': '; }else if($type==-1){ $temp=' '.$displaytext.': '.nl2br($value).' '; }else if($type==1){ $temp=' '.$displaytext.':
'; }else if($type==2){ @require_once("../fckeditor/fckeditor.php"); print ' '.$displaytext.': '; $oFCKeditor = new FCKeditor("$fieldname"); $oFCKeditor->BasePath = '../fckeditor/'; $oFCKeditor->Value = "$value"; $oFCKeditor->Height = '700'; $oFCKeditor->Width = '750'; $oFCKeditor->Create(); print ' '; } if($type!=2){ print $temp; } } function yesNostr($display, $lang="0") { $str = ""; if ($display == 1) { if ($lang == "chi") { $str = '顯示'; } else { $str = 'Yes'; } } else { if ($lang == "chi") { $str = '隱藏'; } else { $str = 'No'; } } return $str; } function hide($input){ if($input==""){ return ' style="display:none" '; } } function funShowAttachment($file){ $lower_filename=strtolower($file); if( strstr($lower_filename,".jpg") || strstr($lower_filename,".jpeg") || strstr($lower_filename,".gif") || strstr($lower_filename,".png") ){ return '
'.funMakeImage("../../".$file,80,80,1).'
'; } } // jason debug code function s($var){ $output='
'.htmlspecialchars($var).' = '.htmlspecialchars($GLOBALS[$var]).'
'; if($GLOBALS[$var]==""){ $output='
Value = '.htmlspecialchars($var).'
'; } print $output; } function a($input){ $output.= '
'; if(count($input)>0){ foreach($input as $key => $value) { $output.='
'.htmlspecialchars($key).' = '.htmlspecialchars($value).'
'; } } $output.='
'; print $output; } function funRemoveAllAttachment($tbname,$attachdir,$value){ global $db; $attachment_Array=funGetAllAttachment($tbname,$value); foreach($attachment_Array as $filename){ @unlink("../../".$attachdir.$filename); } $sql = "DELETE FROM `attachment` WHERE `table_name` = '$tbname' and `table_id` = '$value'"; $db->query($sql); } function funGetAttachment($table_name,$table_id,$col_name){ global $db; $sql = " SELECT file_name 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); return $row["file_name"]; } function funGetAllAttachment($table_name,$table_id){ global $db; $sql = " SELECT col_name,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["file_name"]; } return $myAttachment; } function funGetCategoryOption2($in_table,$in_value="",$field="name",$sorting="sorting"){ global $db; $sql = "SELECT id, type,$field FROM `".$in_table."` order by $sorting "; $result = $db->query($sql); $type_str[0]="HK"; $type_str[1]="PRC"; $type_str[2]="Maintenance"; while($row = mysql_fetch_assoc($result)){ if($row[id]==$in_value){ $selected='selected'; }else{ $selected=""; } $out.=' '; } return $out; } function funGetCategoryOption($in_table,$in_value="",$field="name",$sorting="sorting"){ global $db; $sql = "SELECT id ,$field FROM `".$in_table."` order by $sorting "; $result = $db->query($sql); while($row = mysql_fetch_assoc($result)){ if($row[id]==$in_value){ $selected='selected'; }else{ $selected=""; } $out.=' '; } return $out; } //=============================== // 載入 class.convert.php if($convertBig5ToGb==1){ require_once("class.convert.php"); } $symbol=array("_","A","B","C","D","E","F","G","H","I","J","K"); function funGenList($SQLcmd="",$linkTo="productlist.php",$perRow=1,$myTemplate="",$recordPerPage=100,$targetWidth=100,$targetHeight=100){ $link =$GLOBALS[link]; $id =$GLOBALS[id]; $table_name =$GLOBALS[table_name]; $templateSpecial =$GLOBALS[templateSpecial]; $page =$GLOBALS[page]; $imgPath =$GLOBALS[imgPath]; $convertBig5ToGb =$GLOBALS[convertBig5ToGb]; $numOfTemplate=count($myTemplate); $tdWidth=ceil(100/$perRow); global $pageList; global $pageBack; global $pageNext; global $page; global $print_item; // // remove limit if(strpos($SQLcmd," limit")>0){ $SQLcmd=substr($SQLcmd,0,strpos($SQLcmd," limit")); } // recordPerPage=0 means no limit if($recordPerPage==0 || $recordPerPage==null){ $recordPerPage=1000; } // 分頁 ====================== $totalOfRecord=mysql_num_rows(mysql_query($SQLcmd , $link)); $numOfPage=ceil($totalOfRecord /$recordPerPage); if($totalOfRecord<=$recordPerPage || $page==null){ $page=1; } if($page*$recordPerPage>$totalOfRecord){ $page=$numOfPage; } $start=($page*$recordPerPage)-$recordPerPage; if($start<0){ $start=0; } // get parameter if($_GET!=null){ $HTTP_GET_VARS=$_GET; } for($i=0; $i".$k." "; }else{ // current page $pageList.="[".$k."] "; // back page $back=($k-1); if($back<=0){ $pageBack="".$pageBack.""; }else{ $pageBack= "$pageBack "; } // next page $next=($k+1); if($next>$numOfPage){ $pageNext="".$pageNext.""; }else{ $pageNext= "$pageNext "; } } } // ====================== // hide pagelist if($numOfPage<=1){ //$pageList=""; } // add limit $SQLcmd.=" limit $start,$recordPerPage "; // total of this page $result = mysql_query($SQLcmd , $link); $total=mysql_affected_rows(); $i=0; $j=0; $print_all=""; // table template ======== $print_all.=' '; While ($row = mysql_fetch_array($result)){ // clear variable ======== $this_date=""; $this_edate=""; $this_name=""; $this_nameLink=""; $this_cname=""; $this_cnameLink=""; $this_ename=""; $this_enameLink=""; $this_photo1Path=""; $this_photo1=""; $this_photo1Link=""; $this_photo1Popup=""; $this_photo2=""; $this_photo2Link=""; $this_photo2Popup=""; $this_description=""; $this_content=""; $this_econtent=""; // get all field ===== $this_id=$row[id]; $this_date=$row[date]; $this_code=$row[code]; $this_edate=$row[edate]; $this_time=$row[time]; $this_phone=$row[phone]; $this_name=$row[name]; $this_cname=$row[cname]; $this_ename=$row[ename]; $this_description=$row[description]; $this_content=$row[content]; $this_econtent=$row[econtent]; $this_photo1Path=$row[photo1]; $this_photo2Path=$row[photo2]; $this_photo3Path=$row[photo3]; $this_photo4Path=$row[photo4]; // convert Big5 To Gb if($convertBig5ToGb==1){ $this_name=big52gb($row[name]); $this_cname=big52gb($row[cname]); $this_description=big52gb($row[description]); $this_content=big52gb($row[content]); } // resize ===== if (file_exists($imgPath."s".$row[photo1]) && $row[photo1]!="") { $image_size = getimagesize($imgPath."s".$row[photo1]); $size = imageResize($image_size[0], $image_size[1], $targetWidth,$targetHeight); } else { $size=""; } if (file_exists($imgPath."".$row[photo1]) && $row[photo1]!="") { $image_size = getimagesize($imgPath."".$row[photo1]); $sizeLarge = imageResize($image_size[0], $image_size[1], $targetWidth,$targetHeight); } else { $sizeLarge=""; } if (file_exists($imgPath."s".$row[photo2]) && $row[photo2]!="") { $image_size = getimagesize($imgPath."s".$row[photo2]); $size2= imageResize($image_size[0], $image_size[1], $targetWidth,$targetHeight); } else { $size2=""; } if (file_exists($imgPath."s".$row[photo3]) && $row[photo3]!="") { $image_size = getimagesize($imgPath."s".$row[photo3]); $size3= imageResize($image_size[0], $image_size[1], $targetWidth,$targetHeight); } else { $size3=""; } if (file_exists($imgPath."s".$row[photo4]) && $row[photo4]!="") { $image_size =getimagesize($imgPath."s".$row[photo4]); $size4= imageResize($image_size[0], $image_size[1], $targetWidth,$targetHeight); } else { $size4=""; } // get all field ===== $this_name=$this_name; $this_nameLink="".$this_name.""; if($this_cname!=""){ $this_cname=$this_cname; $this_cnameLink="".$this_cname.""; } if($this_ename!=""){ $this_ename=$this_ename; $this_enameLink="".$this_ename.""; } if($this_photo1Path!=""){ $this_photo1Path=$this_photo1Path; $this_photo1=""; $this_photo1Large=""; $this_photo1Link="".$this_photo1.""; $this_photo1Popup="".$this_photo1.""; if($linkTo=="viewimage.php"){ $this_photo1Popup="".$this_photo1.""; } } if($this_photo2Path!=""){ $this_photo2Path=$this_photo2Path; $this_photo2=""; $this_photo2Link="".$this_photo2.""; $this_photo2Popup="".$this_photo2.""; if($linkTo=="viewimage.php"){ $this_photo2Popup="".$this_photo2.""; } } if($this_photo3Path!=""){ $this_photo3Path=$this_photo3Path; $this_photo3=""; $this_photo3Link="".$this_photo3.""; $this_photo3Popup="".$this_photo3.""; if($linkTo=="viewimage.php"){ $this_photo3Popup="".$this_photo3.""; } } if($this_photo4Path!=""){ $this_photo4Path=$this_photo4Path; $this_photo4=""; $this_photo4Link="".$this_photo4.""; $this_photo4Popup="".$this_photo4.""; if($linkTo=="viewimage.php"){ $this_photo4Popup="".$this_photo4.""; } } if(strlen($this_description)>200){ $this_description=substr($this_description,0,200)."..."; } $this_description=nl2br($this_description); $this_description=$this_description; if($this_content!=""){ $temp_array=split("\n",$this_content); $this_contenPoint='
'; for($x=0;$x"; } } $this_contenPoint.="
"; //$this_content } // content template ======== if($id==""){ $id=$row[id]; } // select template if($numOfTemplate>1){ $template=$myTemplate[$j]; if($id==$this_id && $templateSpecial!=""){ $template=$templateSpecial; } $j++; if(($j)>=$numOfTemplate){ $j=0; } }else{ $template=$myTemplate; if($id==$this_id && $templateSpecial!=""){ $template=$templateSpecial; } } //=== if($template==""){ $content=' '.$this_name.' '.$this_cname.' '; }else{ $x=0; $print_color=''; for($o=2;$o<=9;$o++){ if($row['color'.$o]!=""){ $x++; //print $row['color'.$i]; //$colorName[]=$row['color'.$i]; /*$colorPhoto[]='
'.$symbol[$x].' - '.$row['color'.$i].'
'; */ $symbol=array("_","A","B","C","D","E","F","G","H","I","J","K"); $print_color.=$symbol[$x].' - '.$row['color'.$o].'
'; //$my_option.=''; } } // example $dateInt= str2time($this_date, 'Y-m-d'); $this_date2=date("Y.m.d",$dateInt); $content=$template; $content = str_replace("%this_id%", $this_id, $content); $content = str_replace("%this_date%", $this_date, $content); $content = str_replace("%this_date2%", $this_date2, $content); $content = str_replace("%this_edate%", $this_edate, $content); $content = str_replace("%this_code%", $this_code, $content); $content = str_replace("%this_time%", $this_time, $content); $content = str_replace("%this_phone%", $this_phone, $content); $content = str_replace("%this_name%", $this_name, $content); $content = str_replace("%this_nameLink%", $this_nameLink, $content); $content = str_replace("%this_cname%", $this_ename, $content); $content = str_replace("%this_cnameLink%", $this_cnameLink, $content); $content = str_replace("%this_ename%", $this_cname, $content); $content = str_replace("%this_enameLink%", $this_enameLink, $content); //=== $content = str_replace("%this_photo1%", $this_photo1, $content); $content = str_replace("%this_photo1Large%", $this_photo1Large, $content); $content = str_replace("%this_photo1Path%", $this_photo1Path ,$content); $content = str_replace("%this_photo1Link%", $this_photo1Link, $content); $content = str_replace("%this_photo1Popup%", $this_photo1Popup, $content); $content = str_replace("%this_photo2%", $this_photo2, $content); $content = str_replace("%this_photo2Path%", $this_photo2Path ,$content); $content = str_replace("%this_photo2Link%", $this_photo2Link, $content); $content = str_replace("%this_photo2Popup%", $this_photo2Popup, $content); $content = str_replace("%this_photo3%", $this_photo3, $content); $content = str_replace("%this_photo3Path%", $this_photo3Path ,$content); $content = str_replace("%this_photo3Link%", $this_photo3Link, $content); $content = str_replace("%this_photo3Popup%", $this_photo3Popup, $content); $content = str_replace("%this_photo4%", $this_photo4, $content); $content = str_replace("%this_photo4Path%", $this_photo4Path ,$content); $content = str_replace("%this_photo4Link%", $this_photo4Link, $content); $content = str_replace("%this_photo4Popup%", $this_photo4Popup, $content); //== $content = str_replace("%this_description%", $this_description, $content); $content = str_replace("%this_content%", $this_content, $content); $content = str_replace("%this_econtent%", $this_econtent, $content); $content = str_replace("%this_contenPoint%", $this_contenPoint, $content); // new $this_photo_small=funGetAttachment($table_name,$this_id,"small_photo"); $this_photo_large_path=funGetAttachment($table_name,$this_id,"large_photo"); $this_file1_path=funGetAttachment($table_name,$this_id,"file1"); $this_photo_small=funMakeImage($imgPath.$this_photo_small,$targetWidth,$targetHeight); $content = str_replace("%this_photo_small%", $this_photo_small, $content); $content = str_replace("%this_photo_large%", $this_photo_large, $content); $content = str_replace("%this_photo_large_path%", $this_photo_large_path, $content); $content = str_replace("%this_file1_path%", $this_file1_path, $content); $content = str_replace("%imgPath%", $imgPath, $content); //$template=''.$this_name; /* $content = str_replace("%this_price%", $row[price], $content); if($row[hot]==1){ $price_str="Online Price"; }else{ $price_str="Price"; } $content = str_replace("%this_price_str%", $price_str, $content); $sprice=$row[sprice]; $price=$row[price]; if($sprice!=""){ $all="$".$price.""."Weekly Special:"."$".$sprice.""; }else{ $all="$".$price; } $content = str_replace("%this_price2%", $all, $content); $content = str_replace("%this_size2%", $print_color, $content);*/ } //======== // td template ======== $print_item[]=$content; $print_all.=''; $print_all.=$content; $print_all.=''; if(($i+1) % $perRow==0 && ($i+1)<$total){ $print_all.=''; } $i++; } // add empty td ===== if($perRow>1 && (($i) % $perRow)>0 && (($i) % $perRow)<=$perRow){ for($j=($i % $perRow)+1;$j<=$perRow;$j++){ $print_all.=' '; } } // close table $print_all.=' '; return $print_all; } function funGetCatName($table="",$id=1,$linkTo=""){ global $catName; global $catLink; $link =$GLOBALS[link]; $SQLcmd=" select name,id from `".$table."` where id='$id' "; $result=mysql_query($SQLcmd,$link); $array=mysql_fetch_array($result); $catName=$array[name]; $catLink=''.$catName.''; } // resize image function // function imageResize($width, $height, $targetw, $targeth) { $percentage = 1; if (($width > $targetw) || ($height > $targeth)) { $width_diff = $width - $targetw; $height_diff = $height - $targeth; if ($width_diff >= $height_diff) { $percentage = ($targetw / $width); } else { $percentage = ($targeth / $height); } } $width = round($width * $percentage); $height = round($height * $percentage); $percentage = 1; //gets the new value and applies the percentage, then rounds the value if (($width > $targetw) || ($height > $targeth)) { $width_diff = $width - $targetw; $height_diff = $height - $targeth; if ($width_diff >= $height_diff) { $percentage = ($targetw / $width); } else { $percentage = ($targeth / $height); } } $width = round($width * $percentage); $height = round($height * $percentage); return "width='$width' height='$height'"; } // return a resized image function funMakeImage($photoPath,$targetWidth=100,$targetHeight=100,$enlarge=0){ $temp=array_reverse(split('/',$photoPath)); $filename=$temp[0]; // resize ===== if (file_exists($photoPath) && strstr($photoPath,'.') && $filename!="" ) { $image_size = getimagesize($photoPath); $size = imageResize($image_size[0], $image_size[1], $targetWidth,$targetHeight); if($enlarge==1){ return ""; }else{ return ""; } } else { $size=""; } } function str2time($strStr, $strPattern = null) { // an array of the valide date characters, see: http://php.net/date#AEN21898 $arrCharacters = array( 'd', // day 'm', // month 'y', // year, 2 digits 'Y', // year, 4 digits 'H', // hours 'i', // minutes 's' // seconds ); // transform the characters array to a string $strCharacters = implode('', $arrCharacters); // splits up the pattern by the date characters to get an array of the delimiters between the date characters $arrDelimiters = preg_split('~['.$strCharacters.']~', $strPattern); // transform the delimiters array to a string $strDelimiters = quotemeta(implode('', array_unique($arrDelimiters))); // splits up the date by the delimiters to get an array of the declaration $arrStr = preg_split('~['.$strDelimiters.']~', $strStr); // splits up the pattern by the delimiters to get an array of the used characters $arrPattern = preg_split('~['.$strDelimiters.']~', $strPattern); // if the numbers of the two array are not the same, return false, because the cannot belong together if (count($arrStr) !== count($arrPattern)) { return false; } // creates a new array which has the keys from the $arrPattern array and the values from the $arrStr array $arrTime = array(); for ($i = 0;$i < count($arrStr);$i++) { $arrTime[$arrPattern[$i]] = $arrStr[$i]; } // gernerates a 4 digit year declaration of a 2 digit one by using the current year if (isset($arrTime['y']) && !isset($arrTime['Y'])) { $arrTime['Y'] = substr(date('Y'), 0, 2) . $arrTime['y']; } // if a declaration is empty, it will be filled with the current date declaration foreach ($arrCharacters as $strCharacter) { if (empty($arrTime[$strCharacter])) { $arrTime[$strCharacter] = date($strCharacter); } } // checks if the date is a valide date if (!checkdate($arrTime['m'], $arrTime['d'], $arrTime['Y'])) { return false; } // generates the timestamp $intTime = mktime($arrTime['H'], $arrTime['i'], $arrTime['s'], $arrTime['m'], $arrTime['d'], $arrTime['Y']); // returns the timestamp return $intTime; } // ============================== function funGetCount($filename="count.dat"){ //==================================== // simple counter //data file name $datafile=$filename; //length of the counter $length = 10; //Don't update the following lines if (!file_exists($datafile)) { $fout = fopen($datafile, "w"); $count = 0; fwrite($fout, $count, 100); fclose($fout); } $file = fopen($datafile,"r"); $count = fread($file, 100); $count++; fclose($file); $fileb = fopen($datafile,"w"); fwrite($fileb, $count, 100); fclose($fileb); $j = 0; $cntn = strlen($count); while($j < $length-$cntn) { //echo("0"); $j++; } return $count; } //==================================== // ================= /*setcookie('cookie_memberid'); setcookie('cookie_s'); */ $memberid=$_SESSION["memberid"]; $s=$_SESSION["s"]; if(empty($memberid)){ $memberid=$_COOKIE["cookie_memberid"]; $s=$_COOKIE["cookie_s"]; } if($memberid!=""){ if(pw_check($memberid,$s)){ $_SESSION["this_memberid"]=$memberid; }else{ $memberid=''; $_SESSION["this_memberid"]=''; } } // ================= $this_memberid=$_SESSION["this_memberid"]; // check member area ====== $memberArea=array( "shopping_cart.php", "support_download.php", "member_home.php", "member2db.php", "member_editprofile.php", "editentry2db.php", "mdeleteentry.php", "moveentry.php", "updatepassword.php" ); $currentFilename=$_SERVER['PHP_SELF']; $temp = split("/", $currentFilename); $currentFilename=$temp[count($temp)-1]; //$currentFilename.="X".$_SERVER['QUERY_STRING']; if (in_array($currentFilename, $memberArea) && !isMember()) { header('Location: member_login.php?to='.$currentFilename.'&query_string='.urlencode($_SERVER['QUERY_STRING'])); }else{ } $to=$_GET["to"]; $query_string=($_GET["query_string"]); if(!empty($query_string)){ $to=$to.'?'.$query_string; } // ======= function funGetMemberName(){ $memberid=$_SESSION["this_memnerid"]; $strsql = "select * from `member` where id='$memberid'"; $result=mysql_query($strsql); $array=mysql_fetch_array($result); if($array[sex]=="Male"){ //$member_name="Mr ".$array[lastname]; $member_name=$array[firstname]." ".$array[lastname]; }else{ //$member_name="Ms ".$array[lastname]; } $member_name=$array[loginname]; return $member_name; } function isMember(){ if($_SESSION["this_memberid"]=="" || $_SESSION["this_memberid"]==null){ return false; }else{ return true; } } // get one field function funGetField($tablename,$id,$field="name"){ $strsql = "SELECT $field FROM `$tablename` where id='$id' "; //print $strsql; if($result=mysql_query($strsql)){ $row = mysql_fetch_array($result); } return $row[$field]; } function funGetNewProduct($tablename,$mywhere,$field="name", $order=""){ $strsql = "SELECT $field FROM `$tablename` where 1 and $field!='' and $mywhere $order "; //print $strsql; if($result=mysql_query($strsql)){ $row = mysql_fetch_array($result); } return $row[$field]; } // get option function funGetOpt($tablename){ $strsql = "SELECT * FROM `$tablename` where status='1' order BY sorting , id desc"; $result=mysql_query($strsql); while($row = mysql_fetch_array($result)){ $output.=''; } return $output; } ?>