prefix("phone_book") . "` where `sn` = '{$sn}' "; $result = $xoopsDB->query($sql) or web_error($sql); $all = $xoopsDB->fetchArray($result); //以下會產生這些變數: $sn, $cate_sn, $name, $birthday, $phone, $email, $zip, $county, $city, $addr, $note foreach ($all as $k => $v) { $$k = $v; } //取得分類資料(phone_book_cate) $phone_book_cate_arr = get_phone_book_cate($cate_sn); //過濾讀出的變數值 $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); $xoopsTpl->assign('sn', $sn); $xoopsTpl->assign('cate_sn', $cate_sn); $xoopsTpl->assign('cate_sn_title', $phone_book_cate_arr['cate_title']); $xoopsTpl->assign('name', $name); $xoopsTpl->assign('birthday', $birthday); $xoopsTpl->assign('phone', $phone); $xoopsTpl->assign('email', $email); $xoopsTpl->assign('zip', $zip); $xoopsTpl->assign('county', $county); $xoopsTpl->assign('city', $city); $xoopsTpl->assign('addr', $addr); $xoopsTpl->assign('note', $note); $xoopsTpl->assign('action', $_SERVER['PHP_SELF']); $xoopsTpl->assign('now_op', 'show_one_phone_book'); $sql = "select cate_sn, cate_title from `" . $xoopsDB->prefix("phone_book_cate") . "` where `cate_enable` = '1' order by cate_sort"; $result = $xoopsDB->query($sql) or web_error($sql); while(list($csn, $cate_title) = $xoopsDB->fetchRow($result)){ $arr[$csn]=$cate_title; } $arr['selected']=$cate_sn; $json=json_encode($arr); $json=str_replace('"',"'",$json); include_once XOOPS_ROOT_PATH."/modules/tadtools/jeditable.php"; $file="save_phone_book.php"; $jeditable = new jeditable(); //此處加入欲直接點擊編輯的欄位設定 $jeditable->setTextCol("#name", $file, '240px', '36px', "{'sn':$sn }", "點擊編輯"); $jeditable->setTextAreaCol("#note", $file, '500px', '150px', "{'sn':$sn, 'op':'textarea'}", "點擊編輯"); $jeditable->setSelectCol("#cate_sn", $file, $json, "{'sn' : $sn}", "點擊編輯"); $jeditable_set=$jeditable->render(); $xoopsTpl->assign("jeditable_set",$jeditable_set); if(!file_exists(XOOPS_ROOT_PATH."/modules/tadtools/tinymap.php")){ redirect_header("http://campus-xoops.tn.edu.tw/modules/tad_modules/index.php?module_sn=1",3, _TAD_NEED_TADTOOLS); } include_once XOOPS_ROOT_PATH."/modules/tadtools/tinymap.php"; $tinymap=new tinymap("#map"); $tinymap->set_key('AIzaSyAhBIfRsNsXTWY9orYMg3wUXouwyjA_L2g'); $tinymap->set_option('center',"{$county}{$city}{$addr}",true); $tinymap_code=$tinymap->render(); $xoopsTpl->assign('tinymap_code',$tinymap_code); //將姓名轉為圖片 if(!file_exists(XOOPS_ROOT_PATH . "/uploads/{$sn}.png") or $_FILES['userfile']['tmp_name']){ $pic=mk_name_pic($sn,$name); }else{ $pic=XOOPS_URL . "/uploads/{$sn}.png"; } $xoopsTpl->assign('pic',$pic); } //將姓名轉為圖片 function mk_name_pic($sn,$name=""){ header("Content-type: image/png"); $im = @imagecreatetruecolor(400, 100) or die("無法建立GD圖片"); imagesavealpha($im, true); // $colour = imagecolorallocate($im, 255, 255, 255); $trans_colour = imagecolorallocatealpha($im, 0, 255, 0, 50); imagefill($im, 0, 0, $trans_colour); $bg=!empty($_FILES['userfile']['tmp_name'])?$_FILES['userfile']['tmp_name']:"images/bg1.jpg"; list($width, $height) = getimagesize($bg); $height=round($width/4,0); $y=($height-100)/2+100; $bg_im = imagecreatefromjpeg($bg); imagecopyresampled($im, $bg_im, 0, 0, 0, $y, 400, 100, $width, $height); $text_color = imagecolorallocate($im, 0, 0, 0); $text_color2 = imagecolorallocate($im, 255, 255, 255); $gd = gd_info(); if ($gd['JIS-mapped Japanese Font Support']) { $name = iconv("UTF-8", "shift_jis", $name); } imagettftext($im, 60, 0, 75, 80, $text_color, "./font4.ttf", $name); imagettftext($im, 60, 0, 74, 79, $text_color2, "./font4.ttf", $name); if(imagepng($im, XOOPS_ROOT_PATH . "/uploads/{$sn}.png")){ imagedestroy($im); return XOOPS_URL . "/uploads/{$sn}.png"; } } //以流水號取得某筆phone_book_cate資料 function get_phone_book_cate($cate_sn = '') { global $xoopsDB; if (empty($cate_sn)) { return; } $sql = "select * from `" . $xoopsDB->prefix("phone_book_cate") . "` where `cate_sn` = '{$cate_sn}'"; $result = $xoopsDB->query($sql) or web_error($sql); $data = $xoopsDB->fetchArray($result); return $data; } //列出所有phone_book資料 function list_phone_book($def_cate_sn = "", $def_county="", $def_city="", $def_keyword="") { global $xoopsDB, $xoopsTpl, $isAdmin; //get_jquery(true); $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"; //getPageBar($原sql語法, 每頁顯示幾筆資料, 最多顯示幾個頁數選項); $PageBar = getPageBar($sql, 20, 10, null, null, $bootstrap); $bar = $PageBar['bar']; $sql = $PageBar['sql']; $total = $PageBar['total']; $result = $xoopsDB->query($sql) or web_error($sql); $all_content = ''; $i = 0; 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); $all_content[$i]['sn'] = $sn; $all_content[$i]['cate_sn'] = $cate_sn; $all_content[$i]['cate_title'] = $phone_book_cate_arr[$cate_sn]['cate_title']; $all_content[$i]['name'] = $name; $all_content[$i]['birthday'] = $birthday; $all_content[$i]['phone'] = $phone; $all_content[$i]['email'] = $email; $all_content[$i]['zip'] = $zip; $all_content[$i]['county'] = $county; $all_content[$i]['city'] = $city; $all_content[$i]['addr'] = $addr; $all_content[$i]['note'] = $note; $i++; } $xoopsTpl->assign('bar', $bar); $xoopsTpl->assign('action', $_SERVER['PHP_SELF']); $xoopsTpl->assign('isAdmin', $isAdmin); $xoopsTpl->assign('all_content', $all_content); $xoopsTpl->assign('now_op', 'list_phone_book'); $xoopsTpl->assign('cate_sn', $cate_sn); $xoopsTpl->assign('cate_arr', get_phone_book_cate_arr()); $xoopsTpl->assign('def_cate_sn', $def_cate_sn); $xoopsTpl->assign('def_county', $def_county); $xoopsTpl->assign('def_city', $def_city); $xoopsTpl->assign('def_keyword', $def_keyword); //擷取縣市陣列 $county_arr=get_county_arr(); //套用到樣板 $xoopsTpl->assign('county_arr', $county_arr); //表格自適應 if(file_exists(XOOPS_ROOT_PATH."/modules/tadtools/FooTable.php")){ include_once XOOPS_ROOT_PATH."/modules/tadtools/FooTable.php"; $FooTable = new FooTable(); $FooTableJS=$FooTable->render(true); $xoopsTpl->assign('FooTableJS' , $FooTableJS); } } //擷取縣市陣列 function get_county_arr(){ global $xoopsDB; $sql = "select county from `" . $xoopsDB->prefix("phone_book") . "` group by county order by zip"; $result = $xoopsDB->query($sql) or web_error($sql); while (list($county) = $xoopsDB->fetchRow($result)) { $county_arr[] = $county; } return $county_arr; } /*-----------執行動作判斷區----------*/ include_once $GLOBALS['xoops']->path('/modules/system/include/functions.php'); $op = system_CleanVars($_REQUEST, 'op', '', 'string'); $city = system_CleanVars($_REQUEST, 'city', '', 'string'); $sn = system_CleanVars($_REQUEST, 'sn', '', 'int'); $cate_sn = system_CleanVars($_REQUEST, 'cate_sn', '', 'int'); $county = system_CleanVars($_REQUEST, 'county', '', 'string'); $keyword = system_CleanVars($_REQUEST, 'keyword', '', 'string'); switch ($op) { /*---判斷動作請貼在下方---*/ default: if (empty($sn)) { list_phone_book($cate_sn,$county,$city,$keyword); } else { show_one_phone_book($sn); } break; /*---判斷動作請貼在上方---*/ } /*-----------秀出結果區--------------*/ $xoopsTpl->assign("toolbar", toolbar_bootstrap($interface_menu)); $xoopsTpl->assign("isAdmin", $isAdmin); include_once XOOPS_ROOT_PATH . '/footer.php'; ```
進階搜尋
36人線上 (23人在瀏覽線上書籍)
會員: 0
訪客: 36