f ( "Company_SN" ) ); $Company_NO = $rs->f ( "Company_NO" ); $company_filea = dirname ( dirname ( __FILE__ ) ) . "/customer/" . $Company_NO; } else { $fileshow = new Recordset ( "SELECT * FROM $Table_Name WHERE $Table_SN = $Product_SN" ); $rs = new Recordset ( "select Company_NO from Company where Company_SN=" . $fileshow->f ( "Company_SN" ) ); $Company_NO = $rs->f ( "Company_NO" ); $company_filea = dirname ( dirname ( __FILE__ ) ) . "/customer/" . $Company_NO; } if ($Table_Name == "Company_Site" || $Table_Name == "Company_Site_Function" || $Table_Name == "Site_Banner") { $company_file = $company_filea . "/Company_Site"; //$Field = urlencode($fileshow->Field("$Field_Name")); $Field = $fileshow->Field ( "$Field_Name" ); ////$file = $company_file . '/' . $Field; ////output ( $file, $Field_Name ); header ( "Location: http://agency.twinner.com.tw/customer/$Company_NO/Company_Site/$Field" ); //echo(""); //echo file_read("$company_file/$Field"); } else if ($Table_Name == "Product_Site_Classify" || $Table_Name == "Product" || $Table_Name == "Product_Other_Image" || $Table_Name == "Product_Site_Classify_Images") { $company_file = $company_filea . "/Product"; $Field = $fileshow->Field ( "$Field_Name" ); ////$file = $company_file . '/' . $Field; ////output ( $file, $Field_Name ); header ( "Location:http://agency.twinner.com.tw/customer/$Company_NO/Product/$Field" ); //$Field = urlencode($fileshow->Field("$Field_Name")); //echo(""); //echo "Location:../customer/$Company_NO/Company_Site/$Field"; //echo file_read("$company_file/$Field"); } else { echo $fileshow->Field ( "$Field_Name" ); } function output($file,$Field_Name) { $mime = 'mimetype.txt'; $fp = fopen ( $mime, 'r' ); if ($fp) { $mime = array (); while ( false !== ($line = fgetcsv ( $fp, 1023, ',' )) ) { $mime [$line [0]] = $line [1]; } fclose ( $fp ); } if (file_exists ( $file )) { $ext = strtolower ( pathinfo ( $file, PATHINFO_EXTENSION ) ); $filename = strtolower ( pathinfo ( $file, PATHINFO_BASENAME ) ); if (array_key_exists ( $ext, $mime )) { $mime = $mime [$ext]; } else { $info = @getimagesize ( $file ); if ($info !== false) { $mime = $info ['mime']; } else { $mime = 'application/octet-stream'; } } $length = filesize($file); header ( "Content-Type: $mime" ); header ( "Content-Length: " . $length ); header ( 'Cache-Control: maxage=3600' ); //Adjust maxage appropriately header ( "Cache-Control: private, must-revalidate" ); // HTTP/1.1 header ( "Pragma: private" ); // HTTP/1.0 //header ( "Content-Disposition: attachment; filename=" . $filename ); header ( "Content-Disposition: inline; filename=" . $filename ); ob_clean (); flush (); readfile ( $file ); exit (); } else { if($Field_Name == "Product_1_SImage" || $Field_Name == "Product_1_MImage" || $Field_Name == "Product_1_LImage"){ $file = dirname ( dirname ( __FILE__ ) )."/images/sample-s.gif"; $ext = strtolower ( pathinfo ( $file, PATHINFO_EXTENSION ) ); $filename = strtolower ( pathinfo ( $file, PATHINFO_BASENAME ) ); if (array_key_exists ( $ext, $mime )) { $mime = $mime [$ext]; } else { $info = @getimagesize ( $file ); if ($info !== false) { $mime = $info ['mime']; } else { $mime = 'application/octet-stream'; } } $length = filesize($file); header ( "Content-Type: $mime" ); header ( "Content-Length: " . $length ); header ( 'Cache-Control: maxage=3600' ); //Adjust maxage appropriately header ( "Cache-Control: private, must-revalidate" ); // HTTP/1.1 header ( "Pragma: private" ); // HTTP/1.0 //header ( "Content-Disposition: attachment; filename=" . $filename ); header ( "Content-Disposition: inline; filename=" . $filename ); ob_clean (); flush (); readfile ( $file ); }else{ echo "ERROR: Could not find the file $file."; } exit (); } } ?>