:::

6-2 /html.php

<?php
/**
 * Phone Book module
 *
 * You may not change or alter any portion of this comment or credits
 * of supporting developers from this source code or any supporting source code
 * which is considered copyrighted (c) material of the original comment or credit authors.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @copyright  The XOOPS Project http://sourceforge.net/projects/xoops/
 * @license    http://www.fsf.org/copyleft/gpl.html GNU public license
 * @package    Phone Book
 * @since      2.5
 * @author     tad
 * @version    $Id $
 **/

/*-----------引入檔案區--------------*/
include "header.php";

/*-----------功能函數區--------------*/

include_once $GLOBALS['xoops']->path('/modules/system/include/functions.php');
$def_city    = system_CleanVars($_REQUEST, 'city', '', 'string');
$def_cate_sn = system_CleanVars($_REQUEST, 'cate_sn', '', 'int');
$def_county    = system_CleanVars($_REQUEST, 'county', '', 'string');
$def_keyword    = system_CleanVars($_REQUEST, 'keyword', '', 'string');


$and_name=$and_cate_sn=$and_city="";
if(!empty($def_keyword)){
    $and_name="and (`name` like '%{$def_keyword}%' or `city` like '%{$def_keyword}%' or `county` like '%{$def_keyword}%' or `addr` like '%{$def_keyword}%')";
}else{
    $and_cate_sn = empty($def_cate_sn) ? "" : "and `cate_sn` = '{$def_cate_sn}'";
    $and_county = empty($def_county) ? "" : "and `county` = '{$def_county}'";
    $and_city = empty($def_city) ? "" : "and `city` = '{$def_city}'";
}

//取得分類資料
$phone_book_cate_arr = get_phone_book_cate_arr();

$myts = MyTextSanitizer::getInstance();

$sql = "select * from `" . $xoopsDB->prefix("phone_book") . "` where 1 $and_cate_sn $and_county $and_city $and_name";

$result = $xoopsDB->query($sql)
or web_error($sql);

$html="<table border=1>";
while ($all = $xoopsDB->fetchArray($result)) {
    //以下會產生這些變數: $sn, $cate_sn, $name, $birthday, $phone, $email, $zip, $county, $city, $addr, $note
    foreach ($all as $k => $v) {
        $$k = $v;
    }

    //過濾讀出的變數值
    $name     = $myts->htmlSpecialChars($name);
    $birthday = $myts->htmlSpecialChars($birthday);
    $phone    = $myts->htmlSpecialChars($phone);
    $email    = $myts->htmlSpecialChars($email);
    $zip      = $myts->htmlSpecialChars($zip);
    $county   = $myts->htmlSpecialChars($county);
    $city     = $myts->htmlSpecialChars($city);
    $addr     = $myts->htmlSpecialChars($addr);
    $note     = $myts->displayTarea($note, 0, 1, 0, 1, 1);

    $html.="
    <tr>
      <td>$name</td>
      <td>$birthday</td>
      <td>$phone</td>
      <td>$email</td>
      <td>{$zip}{$county}{$city}{$addr}</td>
      <td>{$phone_book_cate_arr[$cate_sn]['cate_title']}</td>
    </tr>
    ";
}

$html.="</table>";

$content="<!DOCTYPE html>
<html lang=\"zh-TW\">
<head>
  <meta charset=\"UTF-8\">
  <title>Document</title>
</head>
<body>
  {$html}
</body>
</html>
";

$filename=iconv("UTF-8", "Big5", "{$def_county}{$def_city}通訊錄");
//匯出
file_put_contents(XOOPS_ROOT_PATH . "/uploads/{$filename}.html", $content);
//下載
header("Content-type: text/html");
header("Content-Disposition: attachment; filename={$filename}.html");
echo $content;


// if (file_put_contents(XOOPS_ROOT_PATH . "/uploads/{$filename}.html", $content)) {
//     redirect_header('index.php', 3, '已完成!');
// }
exit;

 


:::

搜尋

QR Code 區塊

https%3A%2F%2Ftad0616.cp22.secserverpros.com%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbdsn%3D1249%26tbsn%3D39

書籍目錄

展開 | 闔起

線上使用者

353人線上 (137人在瀏覽線上書籍)

會員: 0

訪客: 353

更多…