RecordCount = $RecordCount; $this->NumPerPage = $NumPerPage; $this->QueryString = $QueryString; if ($RecordCount - 10 > 0) { $nCount = $RecordCount - 10; $this->TotalPage = ceil($nCount / $NumPerPage) + 1;; } else { $this->TotalPage = 1; } if ($CurrentPage <= 0) { $this->CurrrentPage = 1; } else if ($CurrentPage > $this->TotalPage) { $this->CurrentPage = $this->TotalPage; } else { $this->CurrentPage = $CurrentPage; } if ($this->TotalPage == 0) { $this->ShowPage = 0; } else { $this->ShowPage = $this->CurrentPage; } } function getHTML() { $OutputHtml = ""; $NextPage = $this->CurrentPage + 1; $PrevPage = $this->CurrentPage - 1; if ($this->CurrentPage == 1 || $this->TotalPage == 0) { $OutputHtml .= "QueryString . "1'\">\n"; } else { $OutputHtml .= "QueryString . "1'\">\n"; } if ($this->CurrentPage == 1 || $this->TotalPage == 0) { $OutputHtml .= "QueryString . $PrevPage . "'\">\n"; } else { $OutputHtml .= "QueryString . $PrevPage . "'\">\n"; } if ($this->TotalPage == 0){ $OutputHtml .= "QueryString . "' + this.value \">\n" ; } for ($i = 1; $i <= $this->TotalPage; $i++) { if ($i == $this->CurrentPage) { // $OutputHtml .= "\n"; $i . "頁" . "\n"; } else { // $OutputHtml .= "\n"; "頁" . "\n"; } } $OutputHtml .= ""; if ($this->CurrentPage == $this->TotalPage || $this->TotalPage == 0) { $OutputHtml .= "QueryString . $NextPage . "'\">\n"; } else { $OutputHtml .= "QueryString . $NextPage . "'\">\n"; } if ($this->CurrentPage == $this->TotalPage || $this->TotalPage == 0) { $OutputHtml .= "QueryString . $this->TotalPage . "'\">\n"; } else { $OutputHtml .= "QueryString . $this->TotalPage . "'\">\n"; } // $OutputHtml .= "" . $this->ShowPage . " / " . $OutputHtml .= "" . $this->ShowPage . " / " . $this->TotalPage . "  (" . // iconv("Big5", "UTF-8", "共") . "  " . "共" . "  " . $this->RecordCount. "  " . // iconv("Big5", "UTF-8", "筆") . ")"; // "筆" . ")"; "筆" . ")"; return $OutputHtml; } function Big5getHTML() { $OutputHtml = ""; $NextPage = $this->CurrentPage + 1; $PrevPage = $this->CurrentPage - 1; if ($this->CurrentPage == 1 || $this->TotalPage == 0) { $OutputHtml .= "QueryString . "1'\">\n"; } else { $OutputHtml .= "QueryString . "1'\">\n"; } if ($this->CurrentPage == 1 || $this->TotalPage == 0) { $OutputHtml .= "QueryString . $PrevPage . "'\">\n"; } else { $OutputHtml .= "QueryString . $PrevPage . "'\">\n"; } if ($this->TotalPage == 0){ $OutputHtml .= "QueryString . "' + this.value \">\n" ; } for ($i = 1; $i <= $this->TotalPage; $i++) { if ($i == $this->CurrentPage) { $OutputHtml .= "\n"; } else { $OutputHtml .= "\n"; } } $OutputHtml .= ""; if ($this->CurrentPage == $this->TotalPage || $this->TotalPage == 0) { $OutputHtml .= "QueryString . $NextPage . "'\">\n"; } else { $OutputHtml .= "QueryString . $NextPage . "'\">\n"; } if ($this->CurrentPage == $this->TotalPage || $this->TotalPage == 0) { $OutputHtml .= "QueryString . $this->TotalPage . "'\">\n"; } else { $OutputHtml .= "QueryString . $this->TotalPage . "'\">\n"; } $OutputHtml .= "" . $this->ShowPage . " / " . $this->TotalPage . "  (" . iconv("Big5", "UTF-8", "共") . "  " . $this->RecordCount. "  " . iconv("Big5", "UTF-8", "筆") . ")"; return $OutputHtml; } } ?> ]*>.*?#is','', $_line); // 不允許 tag $_line = strip_tags($_line); // 吃掉空白 $_line = str_replace(" ", "", $_line); if (mb_convert_encoding($_line, "UTF-8", "UTF-8") != $_line) { $aResult[$tag] .= mb_convert_encoding(strip_tags(html_entity_decode($_line)), "UTF-8", "Big5"); } else { $aResult[$tag] .= strip_tags(html_entity_decode($_line)); } $i++; } else { break; } } } } return $aResult; } // 取得產品檔案的內容 function parse_product($aContents) { $aTag = array("!!pid", "!!pname", "!!ccc", "!!des", "!!spec", "!!fea", "!!tab", "!!min", "!!fob", "!!ind", "!!code", "!!ass", "!!owner", "!!price", "!!approval", "!!store", "!!note", "!!product1", "!!product2", "!!style", "!!download", "!!hmeta", "!!dmeta", "!!kmeta", "!!ff", "!!sind1", "!!sind2", "!!mp"); $aResult = array(); for ($i = 0; $i < count($aContents); $i++) { $line = trim($aContents[$i]); if (preg_match("/^BEGIN PRODUCT (\d+) (\d+)/", $line, $matches)) { $aResult['class'] = $matches[2]; } else if (in_array(strtolower($line), $aTag)) { $tag = strtolower(substr($line, 2)); if ($tag != "end" && !isset($aResult[$tag])) { $aResult[$tag] = ""; } for ($j = $i+1; $j < count($aContents); $j++) { $_line = trim($aContents[$j]); if ($_line == "!!end") { break; } if (!in_array(strtolower($_line), $aTag)) { // 吃掉 script $_line = preg_replace('#]*>.*?#is','', $_line); // 不允許 tag $_line = strip_tags($_line); // 吃掉空白 $_line = str_replace(" ", "", $_line); if (mb_convert_encoding($_line, "UTF-8", "UTF-8") != $_line) { $aResult[$tag] .= mb_convert_encoding(strip_tags(html_entity_decode($_line)), "UTF-8", "Big5"); } else { $aResult[$tag] .= strip_tags(html_entity_decode($_line)); } $i++; } else { break; } } } } return $aResult; } // 取得所有上架產品的檔案名稱 function get_product($apocplist, $sup_dir) { $aProductFiles = array(); $cHTMLDir = $sup_dir; $handle = @fopen("$apocplist", "r"); $start = 0; if ($handle) { while (!feof($handle)) { $buffer = fgets($handle, 4096); $buffer = trim($buffer); if ($buffer == "!!plist") { $start = 1; continue; } if ($buffer == "!!end") { break; } if ($start == 1) { $eles = split("###", $buffer); $file = $eles[0]; if ((is_file("$sup_dir/$file.txt") && is_file("$cHTMLDir/$file.html")) || (is_file("$sup_dir/$file.txt") && is_file("$cHTMLDir/$file.htm"))) { array_push($aProductFiles, $file . ".txt"); } } } fclose($handle); } return $aProductFiles; } // 從 .class 或 .class2 取得所有上架產品的檔案名稱 function get_product_by_class($class_file, $sup_dir) { $aProductFiles = array(); $cHTMLDir = $sup_dir; $handle = @fopen("$class_file", "r"); $start = 0; if ($handle) { while (!feof($handle)) { $buffer = fgets($handle, 4096); $buffer = trim($buffer); if (preg_match("/^!!/", $buffer)) { continue; } $file = $buffer; if ((is_file("$sup_dir/$buffer.txt") && is_file("$cHTMLDir/$buffer.html")) || (is_file("$sup_dir/$buffer.txt") && is_file("$cHTMLDir/$buffer.htm"))) { array_push($aProductFiles, $file . ".txt"); } } fclose($handle); } return $aProductFiles; } function get_product_by_txt($sup_dir) { global $A_TXT_COMP_FILE_SET; $aProductFiles = array(); $cHTMLDir = $sup_dir; $dh = opendir($sup_dir); while (($file = readdir($dh)) !== false) { if ($file == "." || $file == "..") { continue; } if (!preg_match("/\.txt$/", $file)) { continue; } if (in_array($file, $A_TXT_COMP_FILE_SET)) { continue; } if (in_array($file, array('billing.txt', 'robots.txt'))) { continue; } $file_html = $sup_dir . "/" . preg_replace("/\.txt$/", ".htm", $file); if (!file_exists($file_html)) { continue; } array_push($aProductFiles, $file); } closedir($dh); return $aProductFiles; } ?>