客戶網站目錄下的Templates中添加一個叫做att-form.php 的檔案做客製化定義 -支援已認證白名單功能 -Siteoffice開關 2012.x.x 網址結構abs 單層網頁結構 為 語系/(sheet or page).html 意即 先找sheet是否有符合該網頁名稱,再到page裡面找 沒有的話return 404 index 是例外 為首頁 不需要預設元素 EX: http://www.aaa.com/index_ja.html http://www.aaa.com/jp/company.html http://www.aaa.com/en/contact.html #sheet內資料 結構為 /語系/sheet名稱/ID值.html 該ID不存在 回傳404 EX: http://www.aaa.com/en/product/abc-aaa.html ** 特定頁面以$LNG,$SHEET,$ID為全域變數貫串之 $LNG語系可由指定常數 DEFAULT_LNG 來取得預設語系 當該語系為預設語系時 網址可為 http://www.aaa.com/product/abc-aaa.html http://www.aaa.com/index.html ##模板有分為預設模版即客製模版 客製模版將較預設模版被優先讀取 預設模版位置為 ps,default為不指定特定模板的情況下 預先讀取的目錄 /opt/lampp/readyscript/pc2-template/default/ 客製模版位置為 各網站的Templates目錄 模板開發用i18n多語系方式開發 方便轉換多語系模版 Excel資料語系自動轉換 1.規避字 2.置換字 特定字詞指定翻譯語系轉換文字 3.特定語系資料庫轉換特定語言(ex:tw 轉日文,韓文||en 轉成 德語,西班牙....) 2011.4.29 導向機制支援正則 寫法分為兩種 1.一般導向 (黑色粗體字) 2.正則導向 (紅色粗體字) 請注意 正則規則需要以#開頭 以#i結尾 array('en','product','HLT-700'), '/eng/products/prd_content.aspx?NO=1054&Vcode=1284' => array('en','product','HLT-660'), '/eng/products/prd_content.aspx?NO=1055&Vcode=1284' => array('en','product','HSD-240'), ); 2011.5.30 添加簡易複合查詢function pc::getComplexObj 2011.11.23 新增jplayer支援 MP3: audio/mpeg MP4: audio/mp4 video/mp4 OGG: audio/ogg video/ogg WebM: audio/webm video/webm WAV: audio/wav ?> */ //error_reporting(E_ALL ^ E_NOTICE); $load = sys_getloadavg(); $CPU = $load[0]; $CPU_limit = trim(shell_exec("/bin/grep -c processor /proc/cpuinfo")); if(!is_numeric($CPU_limit)){ $CPU_limit = 2 * 8; }else{ $CPU_limit = $CPU_limit * 6; } //if($CPU > 30){ if($_SERVER['REMOTE_ADDR']=="notest" || ($CPU > $CPU_limit)){ $googlebot = "/^(64\.233\.17[23]|66\.102\.[6-9]|66\.249\.(6[469]|7[579]|8[0-57-9]|9[0-3]))\.\d{1,3}$/"; if(!preg_match($googlebot,$_SERVER['REMOTE_ADDR'])){ header("HTTP/1.1 429 Too Many Requests"); header("Content-Type: text/html"); header("Pragma: no-cache"); header("Cache-Control: no-cache, must-revalidate, no-transform"); header("CPU-Limit: {$CPU} {$CPU_limit}"); require "libs/anti-ddos-lite/anti-ddos-lite.php"; } } mb_internal_encoding("UTF-8"); $time_start = microtime(true); ini_set('output_buffering', 4096); ini_set('session.cookie_lifetime', 1800); ini_set('session.gc_maxlifetime', 1800); set_include_path(implode(PATH_SEPARATOR, array( get_include_path() , '/APP/excel2site/include' ))); require ("/APP/readyscript/config/settings.php"); define('ADDITION_LIB', '/APP/excel2site'); define('ROOTDIR', $_SERVER["DOCUMENT_ROOT"]); define('VIP_BLANK_PIC','vip-blank-pic.jpg'); define('TEMPLATE_PATH', ROOTDIR . '/Templates/'); define('FRONT_TEMPLATE_PATH', '/Templates/'); define('CACHE_PATH', ROOTDIR . '/cache/'); define('S3_URI', '//resource.ready-market.com'); define('TPL_CONF', TEMPLATE_PATH . 'tpl.conf'); //導入設定變數為常數 if (file_exists(TEMPLATE_PATH . "setting.inc.php")) { require (TEMPLATE_PATH . "setting.inc.php"); } define('MINIFY_MIN_DIR', 'min/'); require (MINIFY_MIN_DIR."/lib/Minify/Loader.php"); Minify_Loader::register(); require ("libs/pc2.class.php"); $DETECT = null; //瀏覽器檢查 -start $DETECT = new Mobile_Detect(); //瀏覽器檢查 -end if(isset($_GET['ncs'])){ $ts = gmdate("D, d M Y H:i:s") . " GMT"; header("Expires: $ts"); header("Last-Modified: $ts"); header("Pragma: no-cache"); header("Cache-Control: no-cache, must-revalidate, no-transform"); echo "Remove caches Ready to start...
\n"; $rs = pc::makeDBLock(TEMPLATE_PATH); if($rs){ echo "1.Only read from DB
\n"; $rs = pc::rmCache(CACHE_V2_PATH); if($rs){ echo "2.Cache Remove
\n"; } $rs = pc::delProxyCache(); if($rs){ echo "2-1.Proxy Cache Remove
"; } $rs_1 = pc::rmDBLock(TEMPLATE_PATH); if($rs_1){ echo "3.Release DB LOCK
"; } }else{ print 'Error:'.TEMPLATE_PATH.' write permission denied
'; } $url = pc::selfURL(); $url = substr($url,0,-4); echo "GO BACK"; exit(); } if ((@constant('TP_DEBUG') === FALSE) && (FALSE === pc::checkDBLock(TEMPLATE_PATH)) && (false === pc::is_secret())) { //若有符合快取 則立即輸出 ps,除錯模式開啟則快取關閉 $cururi = pc::selfURL(); $cururi = html::urisort($cururi); if ($output = pc::cache_text($cururi)) { $gmt = pc::cache_gmtime($cururi); $eTag = md5($output); $uri = parse_url($_SERVER['REQUEST_URI']); $ext = pathinfo($uri['path'],PATHINFO_EXTENSION); $gmt = pc::cache_gmtime($cururi); $eTag = md5($output); if($ext == 'xml'){ header("Content-Type: application/xml; charset=UTF-8"); header("X-Robots-Tag: noindex"); } header("Cache-Control: no-transform"); header("Last-modified: {$gmt}"); header("ETag: {$eTag}"); echo $output; exit(); }else{ $ts = gmdate("D, d M Y H:i:s") . " GMT"; header("Expires: $ts"); header("Last-Modified: $ts"); header("Pragma: no-cache"); header("Cache-Control: no-cache, must-revalidate, no-transform"); } } require (FPPATH); //define('PAGE_LIMIT',20); define('__READYMARKET__', ' '); define('IMG_SCRIPT', dirname($_SERVER['SCRIPT_NAME']) . '/img.php'); define('AJAX', dirname($_SERVER['SCRIPT_NAME']) . '/x.php'); define('AJAX_SCRIPT', dirname($_SERVER['SCRIPT_NAME']) . '/ajax.php'); define('CART_SCRIPT', dirname($_SERVER['SCRIPT_NAME']) . '/jcart/'); define('QRCODE_SCRIPT', dirname($_SERVER['SCRIPT_NAME']) . '/qrcode/'); define('REDIRECT_SCRIPT', dirname($_SERVER['SCRIPT_NAME']) . '/redirect.php'); define('PUBLIC_Min_PATH', dirname($_SERVER['SCRIPT_NAME']) . '/min/'); define('PUBLIC_EBOOK_PATH', dirname($_SERVER['SCRIPT_NAME']) . '/ebook/'); require (BASEPATH . "/includes/DB.Libs.php"); require(BASEPATH."/fb/lib/class.phpmailer.php"); require (BASEPATH . "/includes/Setting.Libs.php"); //require(BASEPATH."/includes/simple_html_dom.php"); //開始載入必要程式庫 require (ADDITION_LIB . "/include/db/shared/ez_sql_core.php"); require (ADDITION_LIB . "/include/db/pdo/ez_sql_pdo.php"); require (ADDITION_LIB . "/include/task.class.php"); require ("qrcode/barcode.class.php"); require ('/APP/ui/ui.core.class.php'); require ('libs/form/Zebra_Form.php'); $LngMap = require ("/APP/readyscript/config/lang.list.php"); $firephp = FirePHP::getInstance(true); if (@constant('TP_DEBUG') === TRUE) { $firephp->setEnabled(true); } else { $firephp->setEnabled(false); } //INTERLINK $INTERLINK = array(); //目前語系 $LNG = ''; //目前支援語系 $LNGS = array(); //目前讀取資料 $SHEET = ''; //目前讀取資料ID $ID = ''; //資料庫連線 $CDB = ''; //萬用物件 $OBJ = []; $SEOSETTING = []; //tab 標籤物件 只出現在底層頁 $TAB_OBJ = []; $OBJ_NEXT = FALSE; $OBJ_PRE = FALSE; $LNG_LST = require (BASEPATH . '/config/lang.list.php'); $SETTING = ''; $IS_404 = FALSE; //$_EXT = array('pdf','xls','xlsx','doc','docx','zip','rar','dwg'); $_EXT = array("pdf","rar","zip","flv","txt","swf","mp3","mp4","doc","docx","xls","xlsx","bz2","dwg"); $VIPFNS = array(); $ALLOW_EXT = array( 'html', 'htm', 'rss', 'json', 'xml', 'jpg', 'jpeg', 'gif', 'png', ); $ALLOW_EXT = array_merge($_EXT,$ALLOW_EXT); $NAME_SPAC = array( 'desc_html', 'desc', 'spec', 'name', 'flash', 'image', 'gallerys', 'tab_desc_html', 'tab_desc', 'tab_spec', 'tab_gallerys' ); $DOMAIN = pc::selfDomainURL(); $IS_INDEX = FALSE; $TPL_PATH = ''; //for flash $js_bottom = ''; $DIFF_LNG = array(); //error_reporting(E_ALL & ~E_NOTICE); set_exception_handler(array('pc','exceptionhandle')); set_error_handler(array( 'pc', 'errorHandler' )); $vipfp = TEMPLATE_PATH . task::$vipfn; if(file_exists($vipfp)){ $VIPFNS = @require($vipfp); $uritmp = parse_url ($_SERVER['REQUEST_URI']); $reqfn = basename($uritmp['path']); if($vplng = $VIPFNS[$reqfn]){ $reduri = pc::uri($vplng,'attachment',$reqfn); //圖片檢查 如果格式為圖檔(gif,jpg,jpeg,png) 導引到空白圖 /** $ext = strtolower(pathinfo($reqfn,PATHINFO_EXTENSION)); if(in_array($ext,array('png','gif','jpg','jpeg'))){ //檢查預設圖檔是否存在 if(file_exists(TEMPLATE_PATH . 'pic/' . VIP_BLANK_PIC)){ $reduri = FRONT_TEMPLATE_PATH . 'pic/' . VIP_BLANK_PIC; }else{ //沒圖就導到空白圖 $reduri = 'https:' . S3_URI . '/images/' . VIP_BLANK_PIC; } } */ header("Location: {$reduri}", TRUE, 301); exit(); } } unset($vipfp); //檢查redirect定義是否存在-start if ((empty($_SESSION)) && file_exists(TEMPLATE_PATH . "/redirect.inc.php")) { $fn = TEMPLATE_PATH . "/redirect.inc.php"; //是否使用正則取代 $is_p_replace = false; //var_dump($redirect); $handle = fopen($fn,'r'); if ($handle) { while (($buffer = fgets($handle, 4096)) !== false) { if(preg_match('/(.+)=>(.+)/im',$buffer,$mt)){ $buffer = trim($buffer); if('//' == substr($buffer,0,2)){continue;} $rs = explode("=>",$buffer,2); $rs = eval("return array({$rs[0]},{$rs[1]});"); if(!is_array($rs)){continue;} list($p, $u) = $rs; if(empty($p)){continue;} if (is_array($u['4'])) { $uri_301 = pc::uri($u[0], $u[1], $u[2], $u[3], true, $u[4]); }elseif (is_string($u)) { if (false !== strstr($u, '$')) { $is_p_replace = true; } $uri_301 = $u; } else { $uri_301 = pc::uri($u[0], $u[1], $u[2], $u[3]); } if (substr($p, 0, 1) === '#') { //執行正則網址置換 $reqUrl = $_SERVER['REQUEST_URI']; $p = $p; } else { //執行一般網址置換 $reqUrl = html::urisort($_SERVER['REQUEST_URI']); $p = html::urisort($p); //$_SERVER['REQUEST_URI'] = html::urisort($p); $p = '#' . preg_quote($p) . '#i'; } if (@preg_match($p, $reqUrl, $mt)) { if (true == $is_p_replace) { $uri_301 = preg_replace($p, $uri_301, $reqUrl); } header("Via: {$buffer}::{$p}::"); header("Location: {$uri_301}", TRUE, 301); exit(); } } } fclose($handle); } } //檢查redirect定義是否存在-end $sysrows = pc::getSysSetting(); $firephp->info(USE_TPL, 'USE_TPL'); if ($sysrows) { foreach ($sysrows as $row) { $key = strtoupper($row['key']); if (!defined($key)) { if ($key == 'GOOGLE_TRACKER_ID') { define('GOOGLE_ANALYTIC', $row['value']); } if ($key == 'TRACKER_ID') { define('TRACKER', $row['value']); $firephp->info(TRACKER, 'TRACKER'); } define($key, $row['value']); } } } //導入模組 $ext_libs = pc::getAllowController(); //robots.txt 模組 -start if ($_SERVER['REQUEST_URI'] == "/robots.txt") { if (ROBOT_STATUS == '1') { $output = 'User-agent: * Allow: /'; } else { $output = 'User-agent: * Disallow: /'; } if( (stristr($_SERVER['SERVER_NAME'],'dev.ready-sale.com') !== false) || (stristr($_SERVER['SERVER_NAME'],'demo.ready-market.com') !== false) || (stristr($_SERVER['SERVER_NAME'],'demo.ready-online.com') !== false) || (stristr($_SERVER['SERVER_NAME'],'demo5.ready-market.com') !== false) || (stristr($_SERVER['SERVER_NAME'],'demo3.ready-market.com') !== false) || (stristr($_SERVER['SERVER_NAME'],'demo2.ready-market.com') !== false) ){ $output = 'User-agent: * Disallow: /'; } echo $output; exit(); } //robots.txt 模組 -end unset($sysrows); //模板實體路徑 if ((!empty($_GET['tpl']))) { pc::front_session_start(); $use_tpl = USE_TPL; if ($_GET['tpl']) { $use_tpl = $_GET['tpl']; $_SESSION['tpl'] = $use_tpl; } elseif ($_SESSION['tpl']) { $use_tpl = $_SESSION['tpl']; } else { $use_tpl = USE_TPL; } define('CURRENT_TPL', $use_tpl); define('PUBLIC_TMPDIR', BASEPATH . '/pc2-template/' . CURRENT_TPL . '/'); //前端訪問模板路徑 define('TPL_ROOT', '/' . ALIESSUFFIX . '/pc2-template/' . CURRENT_TPL . '/'); unset($use_tpl); //echo 'is tpl'; }else { if (@constant('USE_MOBILE_TPL')) { if ($DETECT->isMobile() && (!($DETECT->isAndroidtablet() || $DETECT->isIpad()))) { //if($DETECT->isMobile()){ define('CURRENT_TPL', USE_MOBILE_TPL); UI::$user_setting_fn = 'tpl-mobile.conf.php';; //echo 'is mobile'; include ('libs/mobile/jqmPhp.php'); } else { define('CURRENT_TPL', USE_TPL); //echo 'is not mobile'; } } else { define('CURRENT_TPL', USE_TPL); } //模版設計偵測-start if((!empty($_GET['tplconf']))){ pc::admin_session_start(); if($_SESSION['login_user_group_id'] == 204){ $_SESSION['is_tpl'] = true; setcookie(pc::$SESSION_TPL_COOKIE_NAME, "1", strtotime( '+10 days' ), '/'); }elseif($_SESSION['is_admin'] !== true){ setcookie(pc::$SESSION_TPL_COOKIE_NAME, "1", strtotime( '-10 days' ), '/'); $index_uri = pc::uri(null,$SHEET,'index'); html::redirect($index_uri); }else{ $_SESSION['is_tpl'] = true; setcookie(pc::$SESSION_TPL_COOKIE_NAME, "1", strtotime( '+10 days' ), '/'); } }elseif(pc::is_tpl_edit()){ pc::admin_session_start(); if(FALSE === UI::is_edit_mode()){ session_destroy(); setcookie(pc::$SESSION_TPL_COOKIE_NAME, "1", strtotime( '-10 days' ), '/'); $index_uri = pc::uri(null,$SHEET,'index'); html::redirect($index_uri); } } //模版設計偵測-end //模板實體路徑 define('PUBLIC_TMPDIR', BASEPATH . '/pc2-template/' . CURRENT_TPL . '/'); //前端訪問模板路徑 define('TPL_ROOT', '/' . ALIESSUFFIX . '/pc2-template/' . CURRENT_TPL . '/'); //檢查是否進入私密模式 (可以操作session不讀快取) if (TRUE === pc::is_secret()) { pc::front_session_start(); } } if (!is_dir(PUBLIC_TMPDIR)) { header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found"); header("Status: 404 Not Found"); die(PUBLIC_TMPDIR . "不存在"); } $firephp->info($_SERVER, '_SERVER'); $firephp->info($_GET, '_GET'); if (!defined('DEFAULT_LNG')) { define('DEFAULT_LNG', 'en'); } if (!file_exists(TEMPLATE_PATH . '/db_' . DEFAULT_LNG . '.sqlite3')) { $firephp->error(TEMPLATE_PATH . '/db_' . DEFAULT_LNG . '.sqlite3', '預設DB不存在'); exit(); } if (file_exists(TEMPLATE_PATH . '/DIFF.php')) { $DIFF_LNG = require (TEMPLATE_PATH . '/DIFF.php'); } if (false === empty($_SERVER['REQUEST_URI'])) { $ui_a = explode('/', $_SERVER['REQUEST_URI']); $uri = parse_url($_SERVER['REQUEST_URI']); $info = pathinfo($uri['path']); if (isset($info['extension']) && (!in_array(strtolower($info['extension']) , $ALLOW_EXT))) { $IS_404 = true; } $file_name = $info['filename']; $dirs = $info['dirname']; if (false === empty($dirs)) { $dtmp = explode('/', $dirs); $dir_1 = $dtmp[1]; $dir_2 = $dtmp[2]; $dir_level = count($dtmp); } //掃描現有翻譯 $LNGS = pc::getSiteLngs(); $MLNGS = pc::getLng(); // 決定語系$LNG if (false == empty($dir_1) && in_array($dir_1, $LNGS)) { $LNG = $dir_1; } elseif ($info['dirname'] == '/' && in_array($info['basename'], $LNGS)) { $LNG = $info['basename']; }elseif (false == empty($dir_1) && in_array(strtolower($dir_1), array_map('strtolower', $LNGS))) { //小寫比對 $lKey = array_search(strtolower($dir_1), array_map('strtolower', $LNGS)); $LNG = $LNGS[$lKey]; $redUrl = str_replace("/{$dir_1}/","/{$LNG}/",$_SERVER['REQUEST_URI']); html::redirect($redUrl); exit(); } elseif ($info['dirname'] == '/' && in_array(strtolower($info['basename']), array_map('strtolower', $LNGS))) { $lKey = array_search(strtolower($info['basename']), array_map('strtolower', $LNGS)); $LNG = $LNGS[$lKey]; $redUrl = str_replace("/{$info[basename]}","/{$LNG}",$_SERVER['REQUEST_URI']); html::redirect($redUrl); exit(); }elseif((!empty($_GET['lng'])) && (in_array($_GET['lng'], $LNGS))) { $LNG = trim($_GET['lng']); } else { $LNG = DEFAULT_LNG; } /** if ($dir_level >= 3 && $LNG != $dir_1) { //$IS_404 = true; $firephp->info("[136]網址不正確"); } **/ //鎖定語系 pc::loadI18n(PUBLIC_TMPDIR, $LNG); $CPU = pc::GetCpuLoad(false,true); $firephp->info($CPU,'CPU'); if($CPU > 20){ $fn = '/cache/hcpu-'.date('Y-m-d', strtotime("now")).'.log'; $fp = fopen($fn, "a"); fwrite($fp, date('Y-m-d H:i:s', strtotime("now")). " ".$CPU. " ".$_SERVER['REMOTE_ADDR']. " ".pc::selfURL()."\n"); fclose($fp); //hcpu 直接關閉搜尋功能 if($SHEET == "search"){ $red_uri = pc::uri(null,$SHEET,'index'); html::redirect($red_uri); exit(); } } $firephp->info($MLNGS,'$MLNGS'); //決定語系後 才後決定讀取的資料庫 $CDB = pc::getCDB(); if(false === $CDB){ $IS_404 = TRUE; $LNG = DEFAULT_LNG; $CDB = pc::getCDB(); $firephp->info('404'); } $SHEETS = pc::getSheets(); /* if (isset($_GET['debugMode']) && ($_GET['debugMode'] === '1') && ($LNG === 'tr')) { putenv('LC_ALL=tr_TR.utf8'); setlocale(LC_ALL, 'tr_TR.utf8'); bindtextdomain(CURRENT_TPL, '/APP/readyscript/pc2-template/customized-anko/locale'); bind_textdomain_codeset(CURRENT_TPL, 'UTF-8'); textdomain(CURRENT_TPL); echo _("HOME"); exit(0); } */ // $pages = pc::getPageIds(); $pages = method_exists('pc', 'getPageIds') ? pc::getPageIds() : pc::getpageids(); $SETTING = pc::getSetting(); $SEOSETTING = pc::getSeoSetting(); //欄位別名 $FIELD_ALIAS = pc::buildArrayMap(pc::getObjs('field_alias', '', 'id')); if (in_array('interlink_alias', $SHEETS)) { $INTERLINK = pc::buildArrayMap(pc::getObjs('interlink_alias', '', 'num', null, 0, 'id AS \'name\',name_alt,name AS \'id\'')); } //添加search 類別 if (is_array($SHEETS)) array_push($SHEETS, 'search'); if(!empty($ext_libs)){ $firephp->info(array_keys($ext_libs), 'EXT_SHEETS'); } //決定$SHEET if (false == empty($dir_1) && in_array($dir_1, $SHEETS)) { $SHEET = $dir_1; $ID = $file_name; } elseif (false == empty($dir_2) && in_array($dir_2, $SHEETS)) { //$LNG = DEFAULT_LNG; $SHEET = $dir_2; $ID = $file_name; }elseif (($dirs == '/' || $LNG === $dir_1) && (in_array($file_name, $SHEETS) || in_array($file_name, $pages))) { //$LNG = $dir_1; if (in_array($file_name, $SHEETS)) { $SHEET = $file_name; $ID = 'index'; }elseif (in_array($file_name, $pages)) { $SHEET = 'page'; $ID = $file_name; } } //決定是否引用EXT額外模組 if (false == empty($dir_1) && isset($ext_libs[$dir_1]) && (in_array($file_name,$ext_libs[$dir_1]))) { $SHEET = $dir_1; $ID = $file_name; } elseif (false == empty($dir_2) && isset($ext_libs[$dir_2]) && (in_array($file_name,$ext_libs[$dir_2]))) { //$LNG = DEFAULT_LNG; $SHEET = $dir_2; $ID = $file_name; } elseif(false == empty($dir_2) && isset($ext_libs[$dir_2]) && (in_array('default',$ext_libs[$dir_2]))){ $SHEET = $dir_2; $ID = 'default'; } if(!isset($ext_libs[$SHEET])){ //決定$ID if ((true == empty($info['basename']) || $SHEET == 'index' || $SHEET == '') && empty($info['extension'])) { //啟動首頁模式 $info['extension'] = 'html'; $SHEET = 'index'; $ID = 'index'; $IS_INDEX = TRUE; $firephp->info('首頁模式'); } elseif ($SHEET == 'search') { $search_type = pcc::getSearchType(); //預先載入晉階搜尋參數 search::getAdvConds(); $where = search::buildSqlWhere(); if (strlen($where) > 3) { //跨語系關鍵字處理 -start if($search_type == '_search' && (false === empty($_GET['q'])) && (true === is_string($_GET['q']))){ $kwMapfn = TEMPLATE_PATH.'/'.KW_MAP.'/'.".{$LNG}.php"; $kwMap = []; $kw = str_ireplace('%20',' ',trim($_GET['q'])); if(true === file_exists($kwMapfn)){ $kwMap = @include($kwMapfn); } if(isset($kwMap[$kw])){ $q = $kwMap[$kw]; $conds = array(); $f = '_desc'; $asiaLng = array("zh-TW","zh-CN","ja","ko","th","iw"); $kwWhere = ''; if(in_array($LNG,$asiaLng)){ $kwWhere .= "`_desc` LIKE " . $CDB->escape('%' . trim($q) . '%'); }else{ if(false === strstr($q,'"')){ $q = '"'.$q.'*"' ; } $kwWhere .= "`_desc` MATCH " . $CDB->escape('' . $q . ''); } if(!empty($kwWhere)){ $kwWhere = "WHERE {$kwWhere}"; $kwTmp = pc::getSingleTgObj($kwMap['srclng'],$search_type,'index',$kwWhere,'rowid',1000,0,'id'); //var_dump($kwTmp,$kwMap['srclng'],$search_type,'index',$kwWhere); $kwIds = []; foreach($kwTmp as $kr){ $kwIds[] = $kr['id']; } if(!empty($kwIds)){ $where = "id IN (".pc::array2sql($kwIds).")"; } unset($kwIds,$asiaLng,$kwWhere); } } } search::buildOther(); $where = " WHERE ({$where})"; $OBJ = pc::getSingleObj($search_type, 'index', $where); $COUNT = pc::$count; if($COUNT == 0){ $httpReferer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'NO'; header('SR-HIT: 0'); if($httpReferer !== 'NO'){ $fn = '/cache/searchNull-'.date('Y-m', strtotime("now")).'.log'; $fp = fopen($fn, "a"); fwrite($fp, date('Y-m-d H:i:s', strtotime("now")). "\t".$CPU. "\t".pc::selfURL(). "\t".$httpReferer. "\t".$search_type. "\t".$where. "\n"); fclose($fp); } } } else { $firephp->error($where, 'search where null'); $OBJ = array(); $COUNT = 0; } } else { $ID = urldecode($ID); if (in_array($SHEET, $SHEETS) && $SHEET != 'index') { $OBJ = []; if($SHEET == "404"){ $IS_404 = TRUE; $IS_INDEX = FALSE; }else{ $OBJ = pcc::getSingleObj($SHEET, $ID); } if(empty($OBJ) && $ID != 'index'){ //當SHEET存在 但$ID無法比對 則導到該SHEET集合頁 $index_uri = pc::uri(null,$SHEET,'index'); html::redirect($index_uri); } } /* $ID = urldecode($ID); if($info['extension']!='xml' && ($info['dirname']!='/' && $info['basename']!='index.html')){ $OBJ = pcc::getSingleObj($SHEET,$ID); } */ } }else{ //EXT模組 call_user_func("controller_{$SHEET}::init"); if( method_exists("controller_{$SHEET}","view_{$ID}") ){ call_user_func("controller_{$SHEET}::view_{$ID}"); }elseif(method_exists("controller_{$SHEET}","view_default")){ call_user_func("controller_{$SHEET}::view_default"); }else{ $firephp->error('404-ext'); header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found"); header("Status: 404 Not Found"); $tpl = pc::show404(); echo $tpl; exit; } } if (FALSE === empty($OBJ['id'])) { //單筆資料 $ID = $OBJ['id']; //單筆資料美化 $OBJ = pcc::rowFactory($OBJ); $firephp->info($OBJ, 'OBJ'); if ( isset($info['extension'])&& (in_array(strtolower($info['extension']) , array('html','htm'))) && (!empty($OBJ['R301'])) ) { //開始301導向 if(false !== strstr($OBJ['R301'], '::')) { $nodes = explode("::", $OBJ['R301']); if(count($nodes) == 2){ $uri_301 = pc::uri(null, $nodes[0], $nodes[1]); }elseif(count($nodes) > 2){ $uri_301 = pc::uri($nodes[0], $nodes[1],$nodes[2]); } } elseif('http://' === substr($OBJ['R301'], 0, 7) || 'https://' === substr($OBJ['R301'], 0, 7)) { $uri_301 = $OBJ['R301']; } elseif('/' == substr($OBJ['R301'],0,1)){ $OBJ['R301'] = html::autoReplace($OBJ['R301']); $uri_301 = $OBJ['R301']; } else { $uri_301 = pc::uri(null, null, $OBJ['R301']); } header("Location: {$uri_301}", TRUE, 301); exit(); } //添加link欄位轉頁處理 避免promotion變成頁面 by tung 20150702 if (!empty($OBJ['link'])) { //開始301導向 if(false !== strstr($OBJ['link'], '::')) { $nodes = explode("::", $OBJ['link']); if(count($nodes) == 2){ $uri_301 = pc::uri(null, $nodes[0], $nodes[1]); }elseif(count($nodes) > 2){ $uri_301 = pc::uri($nodes[0], $nodes[1],$nodes[2]); } } elseif('http://' === substr($OBJ['link'], 0, 7) || 'https://' === substr($OBJ['link'], 0, 7)) { $uri_301 = $OBJ['link']; } elseif('/' == substr($OBJ['link'],0,1)){ $OBJ['link'] = html::autoReplace($OBJ['link']); $uri_301 = $OBJ['link']; } else { $uri_301 = pc::uri(null, null, $OBJ['link']); } header("Location: {$uri_301}", TRUE, 301); exit(); } } elseif ((in_array($file_name, $LNGS) && $SHEET == '') || ($SHEET == 'index' && $ID == 'index')) { //首頁 $ID = 'index'; $IS_INDEX = TRUE; } elseif ($SHEET == $file_name) { //多筆資料 $ID = 'index'; } elseif ($file_name == 'index' && $SHEET != '') { $ID = 'index'; //$SHEET = 'index'; } elseif ('404' == $file_name) { $ID = '404'; } else { $IS_404 = TRUE; $IS_INDEX = FALSE; } $firephp->info($ID, 'ID'); $firephp->info($SHEET, 'SHEET'); $firephp->info($LNG, 'LNG'); $firephp->info($LNGS, 'LNGS'); $firephp->info($ALLOW_EXT,'$ALLOW_EXT'); if (TRUE === $IS_404 && $file_name != 'sitemap' && (!in_array(strtolower($info['extension']) , $_EXT))) { $firephp->info("[636]網址不正確"); //偵測 是否有符合模組啟動 $firephp->error('404'); header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found"); header("Status: 404 Not Found"); $tpl = pc::show404(); echo $tpl; exit; } $firephp->info($info, '$info'); //add for fix ex: /en/product/ will output blank page 2011.10.26 if (empty($info['extension'])) { $info['extension'] = 'html'; } /** * Use SEO Excel * 1. Meta Off: * Title只放公司名稱 * Meta中的keyword與description都顯示為「This is a temporary version for our customer reviewed only.」 * 2. Title, Keyword, Description為空字串 * 全參照pc::defaultSeo() * 3. Block為空字串 * 若($sheetName === '' || $sheetName === 'index')為真時,則參照Seo_Excel * 中home_seo_block全域設定值,反之,則參照rm_seo_block全域設定值 */ $seo = new stdClass; if (defined('META_SWITCH') && META_SWITCH === 'Off') { define('USE_SEO_EXCEL', 'Off'); $seo = pc::defaultSeo(); } else if (defined('U_SEO')) { if (U_SEO === 'On') { /** * 當db_$lang.sqlite3存在且有相對應的Seo Table時,則啟用Seo模組, * 反之,則使用pc::defaultSeo()中預設的SEO組合 */ if (($SHEET === '') || ($SHEET === 'index')) { if (false === $seoParams = pc::getSeo('setting')) { define('USE_SEO_EXCEL', 'Off'); $seo = pc::defaultSeo(); } else {// 首頁 //導入預設值 有符合seo excel設定再覆蓋 $seo = pc::defaultSeo(); define('USE_SEO_EXCEL', 'On'); array_walk( $seoParams, function ($row) use (&$seo) { switch (true) { case ($row['id'] === 'title'): case ($row['id'] === 'keyword'): case ($row['id'] === 'description'): case ($row['id'] === 'B_H1'): case ($row['id'] === 'B_H2'): $seo->{$row['id']} = (trim($row['name']) === '') ? pc::defaultSeo($row['id']) : $row['name']; break; case ($row['id'] === 'home_seo_block'): $seo->block = (trim($row['name']) === '') ? pc::defaultSeo('block') : $row['name']; break; default: break; } } ); } } else { if (false === $seoParams = pc::getSeo($SHEET, 'index')) { define('USE_SEO_EXCEL', 'Off'); $seo = pc::defaultSeo(); } else { define('USE_SEO_EXCEL', 'On'); if ($ID === '' || $ID === 'index') { // 集合頁 $seo = pc::defaultSeo(); array_walk( $seoParams, function ($value, $field) use (&$seo) { $seo->{$field} = ($value === '') ? pc::defaultSeo($field) : $value; } ); } else { // 底層頁 if($SHEET == "compare" && $ID !='cart' && (false !== $seoParams = pc::getSeo($SHEET, 'index'))) { //導入預設值 有符合seo excel設定再覆蓋 $seo = pc::defaultSeo(); array_walk( $seoParams, function ($value, $field) use (&$seo, $SHEET) { $seo->{$field} = ($value === '') ? pc::defaultSeo($field) : $value; } ); }elseif (false === $seoParams = pc::getSeo($SHEET, $ID)) { $seo = pc::defaultSeo(); } else { //導入預設值 有符合seo excel設定再覆蓋 $seo = pc::defaultSeo(); array_walk( $seoParams, function ($value, $field) use (&$seo, $SHEET) { $seo->{$field} = ($value === '') ? pc::defaultSeo($field) : $value; } ); } } } } unset($seoParams); } else { define('USE_SEO_EXCEL', 'Off'); $seo = pc::defaultSeo(); } } else { define('USE_SEO_EXCEL', 'Off'); $seo = pc::defaultSeo(); } switch (strtolower($info['extension'])) { case 'html': case 'htm': if ((isset($OBJ['is_show'])) && strtolower($OBJ['is_show']) == 'no') { $uri_301 = pc::uri(null, 'search', 'index', $OBJ['name'], true, array( 'q' => $OBJ['name'], 'type' => 'all', )); header("Location: {$uri_301}", TRUE, 301); exit; } foreach(array_keys($ext_libs) as $cl){ if(method_exists("controller_{$cl}","end")){ call_user_func("controller_{$cl}::end"); } } if ($SHEET == 'attachment' && $_GET['a'] == 'download') { if(file_exists(TEMPLATE_PATH . '/att/' . $OBJ['id'])){ pc::dl_file(TEMPLATE_PATH . '/att/' . $OBJ['id']); }elseif(file_exists(task::vipfn(TEMPLATE_PATH . '/att/' . $OBJ['id']))){ pc::dl_file(task::vipfn(TEMPLATE_PATH . '/att/' . $OBJ['id'])); }elseif(file_exists(TEMPLATE_PATH . '/pic/' . $OBJ['id'])){ pc::dl_file(TEMPLATE_PATH . '/pic/' . $OBJ['id']); }elseif(file_exists(task::vipfn(TEMPLATE_PATH . '/pic/' . $OBJ['id']))){ pc::dl_file(task::vipfn(TEMPLATE_PATH . '/pic/' . $OBJ['id'])); } exit(); } if (U_SEO === 'On') { pc::loadAdmTpl('jsonld-tpl'); pc::loadAdmTpl('ui/open-graph-tpl'); } if(defined('GDPR_FOOT')){ html::JS_(dirname(pc::selfDomainURL().$_SERVER['SCRIPT_NAME'])."/js/gdpr/script.js"); html::CSS(dirname(pc::selfDomainURL().$_SERVER['SCRIPT_NAME'])."/js/gdpr/style.css"); } $tpl = pc::loadTpl(); if($_SESSION['is_tpl'] != true){ $tpl = html::autoReplace($tpl); } $tpl = html::jscss_replace($tpl); if(empty($_SESSION) && (false === pc::checkDBLock(TEMPLATE_PATH))){ $tmp = $_GET; unset($tmp['page'],$tmp['lng'],$tmp['type']); $tmp = array_filter($tmp); if($SHEET == 'search' && (count($tmp) <= 3)){ //四層以上的搜尋 不予快取 }elseif($SHEET == 'member'){ //do nothing }else{ $cururi = pc::selfURL(); $cururi = pc::selfDomainURL().html::urisort($cururi); pc::cache_text($cururi , $tpl, "write"); } } break; case 'json': if($_GET['pw'] !== PC2_PASSWORD){ exit(); } header("Content-Type: application/json; charset=UTF-8"); $items = pcc::getObjs($SHEET, null, 'sort', 10000, 0, 'id,name,image,desc'); $tpl = json_encode($items); if(empty($_SESSION) && (false === pc::checkDBLock(TEMPLATE_PATH))){ pc::cache_text(pc::selfURL() , $tpl, "write"); } echo $tpl; exit(); break; case 'rss': header("Content-Type: application/xml; charset=UTF-8"); unset($OBJ); $items = pcc::getObjs($SHEET, null, 'sort', 1000, 0, 'id,name,image,desc'); $Feed = new FeedWriter(RSS2); $Feed->setTitle($SETTING['title']); $Feed->setLink(pc::selfURL()); $Feed->setDescription($SETTING['description']); //var_dump($items); if (is_array($items)) { foreach ($items as $item) { $newItem = $Feed->createNewItem(); $newItem->setTitle($item['name']); $newItem->setLink($DOMAIN . pcc::uri(null, $SHEET, $item['id'], $item['name'])); // if (file_exists(TEMPLATE_PATH . '/pic/' . $item['image'])) { $img_html = ''; } $newItem->setDate(gmdate('D, d M Y H:i:s', strtotime('now')) . ' GMT'); $newItem->setDescription('by ' . html::esc_block($SETTING['company']) . '
' . html::esc_html($img_html) . '

' . html::esc_block($item['desc']) . '

' . '
' . html::esc_block($SETTING['company']) . ''); //Now add the feed item $Feed->addItem($newItem); } } $tpl = $Feed->generateFeed(true); if(empty($_SESSION) && (false === pc::checkDBLock(TEMPLATE_PATH))){ pc::cache_text(pc::selfURL() , $tpl, "write"); } break; case 'xml': $firephp->info('sitemap mode'); header("Content-Type: application/xml; charset=UTF-8"); header("X-Robots-Tag: noindex"); if ($info['filename'] == 'sitemap') { $tpl = Sitemap::genIndex(); } elseif ($SHEET == 'index') { $items = array(); //首頁 $items[] = array( 'loc' => $GLOBALS['DOMAIN'] . '/index.html', 'lastmod' => gmdate('D, d M Y H:i:s', strtotime('now')) . ' GMT', 'changefreq' => 'weekly', ); //各語系首頁 foreach ($LNGS as $l) { $items[] = array( 'loc' => $GLOBALS['DOMAIN'] . '/' . $l . '/index.html', 'lastmod' => gmdate('D, d M Y H:i:s', strtotime('now')) . ' GMT', 'changefreq' => 'weekly', ); } $tpl = Sitemap::genUrl($items, $SHEET); } elseif (false === empty($SHEET)) { $sitemap_limit = 10000; $sitemap_page = ($_GET['page']?$_GET['page']:0); $allfields = pc::getSheetCol($SHEET); $imgfields = ['id','name']; foreach($allfields as $f){ if($f=='image'){ $imgfields[] = $f; }elseif(substr($f,0,4) == 'alt_'){ $imgfields[] = $f; }elseif(substr($f,0,6) == 'image_'){ $imgfields[] = $f; }elseif(substr($f,0,9) == 'gallerys_'){ $imgfields[] = $f; }elseif($f == 'gallerys'){ $imgfields[] = $f; } } $items = pcc::getSingleObj($SHEET,'index','', 'sort', $sitemap_limit, ($sitemap_page * $sitemap_limit), implode(',',$imgfields)); $tpl = Sitemap::genUrl($items, $SHEET); $dom = new DomDocument(); $dom->loadXML($tpl); $dom->formatOutput = true; //output xml $tpl = $dom->saveXML(); } if(empty($_SESSION) && (false === pc::checkDBLock(TEMPLATE_PATH))){ pc::cache_text(pc::selfURL() , $tpl, "write"); } break; case "gif": case "png": case "jpeg": case "jpg": $im = imagecreate(1, 1); $white = imagecolorallocate($im, 255, 255, 255); imagesetpixel($im, 1, 1, $white); imageColorTransparent($im, $white); switch ($info['extension']) { /** case "gif": $ctype="image/gif"; imagegif($im); break; case "png": $ctype="image/png"; imagepng($im); break; case "jpeg": case "jpg": $ctype="image/jpg"; imagejpeg($im);break; case "gif": $ctype="image/gif"; imagegif($im); break; */ default: $ctype = "image/gif"; imagegif($im); break; } header("content-type:$ctype"); imagedestroy($im); exit(); break; default: $tmp = parse_url(urldecode($_SERVER['REQUEST_URI'])); if(in_array(strtolower($info['extension']), array('xls','xlsx'))){ $match = array( 'excel-last', '.seo' ); $is_sys_excel = false; foreach($match as $m){ if(false !== strstr($info['basename'],$m)){ header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found"); header("Status: 404 Not Found"); $OBJ = array(); $SHEET= '404'; $ID= '404'; $tpl = pc::show404(); echo $tpl; exit(); } } } //robot偵測 if(pc::crawlerDetect($_SERVER['HTTP_USER_AGENT']) === true){ pc::dl_file(ROOTDIR.$tmp['path']); exit(); } if(in_array(strtolower($info['extension']), $_EXT)): $tmp = parse_url(urldecode($_SERVER['REQUEST_URI'])); $is_ebook = false; if(false !== stristr($tmp['path'],'Templates/ebook')){ $is_ebook = true; } if ((true === $is_ebook) && (file_exists(ROOTDIR.$tmp['path']))) { pc::dl_file(ROOTDIR.$tmp['path']); exit(); }elseif ((!ATT_FORM) && (file_exists(ROOTDIR.$tmp['path']))) { #當開關為OFF 檔案又存在 直接下載 pc::dl_file(ROOTDIR.$tmp['path']); exit(); }elseif(!file_exists(ROOTDIR.$tmp['path'])){ #當檔案不存在 跳出404 header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found"); header("Status: 404 Not Found"); $OBJ = array(); $SHEET= '404'; $ID= '404'; $tpl = pc::show404(); echo $tpl; exit(); } pc::front_session_start(); $sysdb = pc::getSYSDB(); //舊log資料整合-start att::oldLogsync($sysdb); //舊log資料整合-end //當網址query參數裡面有code 則開始buyer認證程序 if(!empty($_GET['code'])){ $code = trim($_GET['code']); $auth_rs = att::auth_process($sysdb,$code); $_SESSION['auth_rs'] = $auth_rs; $uri_301 = $tmp['path']; /** if(empty($auth_rs)){ //認證碼錯誤 目前暫定不予提示 $uri_301 = $tmp['path']; header("Location: {$uri_301}", TRUE, 301); //var_dump("E-Location: {$uri_301}", TRUE, 301); exit(); }else{ header("Location: {$uri_301}", TRUE, 301); exit(); } */ } if(att::sessionChk() == TRUE && (empty($_GET['code']))){ if($_SESSION['auth_rs'] === '1'){ //初次認證成功 為避免下載紀錄重複 所以只下載不紀錄 $_SESSION['auth_rs'] = ''; pc::dl_file(ROOTDIR.$tmp['path']); exit(); }else{ att::download_log($sysdb,true); } } $attFormElms = att::getFields(); if(empty($attFormElms)){ die('Setting error'); } //偵測是否開啟附件下載客製功能-end $attForm = new Zebra_Form('attForm'); $attForm = att::authForm($attForm,$attFormElms); $SHEET = 'page'; $ID = 'attachment-form'; $OBJ['id'] = $ID; if ($attForm->validate()) { //<檢查附件下載紀錄資料表(download_log) // -是否需要修改欄位 //var_dump($_POST); att::fieldsync($sysdb,$attFormElms); //<檢查email是否已認證通過 via buyer table $chek_val = trim($_POST['text_email']); $SQL = "SELECT * FROM `buyer` WHERE email=".$sysdb->escape($chek_val); $buyer_check = $sysdb->get_row($SQL,ARRAY_A); // -不存在 => if(empty($buyer_check)): // -寄發認證信 $rs = att::authMail($sysdb); att::download_log($sysdb,false); elseif(empty($buyer_check['is_auth'])): //已有填寫表單 但點選認證連結 認證未通過 $rs = att::authMail($sysdb,$buyer_check); att::download_log($sysdb,false); else: // -已通過 => // -立即給予下載 並開通15分鐘內無限下載模式 att::downloadAllow(); att::download_log($sysdb,true); endif; if($rs){ // 寄件成功 顯示成功訊息 $OBJ['name'] = _('Authentication email was sent'); $OBJ['desc'] = _('Please go to your email account to receive the file link.'); //$OBJ['desc_html'] = '100% free file downloads and no registration.'; //$output = "

Please go to your email account to receive the file link.

"; $OBJ['desc_html'] = "

"._('For any further questions, you can also').":
1. ". _('check out the') . " "._('Link')."
2. "._('Send an inquiry to our company directly.')."

"; }else{ // 寄件失敗 顯示失敗訊息 $OBJ = array(); $OBJ['name'] = _("False to send mail"); $OBJ['desc'] = _("Please make sure this email address is correct."); $cssPath = dirname($_SERVER['SCRIPT_NAME']).'/libs/form/public/css/zebra_form.css'; $jsPath = dirname($_SERVER['SCRIPT_NAME']).'/libs/form/public/javascript/zebra_form.js'; $output .= $attForm->render('',true); //添加表單zebra_form 的 css與js html::JS_(<<').appendTo("head"); jQuery.getScript("{$jsPath}"); }); EOF ); if(in_array($ID, $pages)){ $OBJ = pc::getSingleObj($SHEET,$ID); }else{ $OBJ['desc'] = <<{$fn}

Your download will start in 10 seconds...

Problems with the download? Please use this direct link, or try Contact us

EOF; html::JS_(<< settings.endNumber + 1) { jQuery(this).css("fontSize", settings.startFontSize).text(to - 1).countDown(settings, to - 1); } else { settings.callBack(this); } }); }); }; jQuery(document).ready(function(){ jQuery("#countdown").countDown({ startNumber: 10, callBack: function(me) { jQuery("#cd_txt").text("Start download...").css("font-weight", "bold"); location.replace('{$dlurl}'); } }); }); EOF ); }else{ //下載表單顯示 $cssPath = dirname($_SERVER['SCRIPT_NAME']).'/libs/form/public/css/zebra_form.css'; $jsPath = dirname($_SERVER['SCRIPT_NAME']).'/libs/form/public/javascript/zebra_form.js'; // $output .= $attForm->render('',true); //添加表單zebra_form 的 css與js $mobile_js = ''; if ($DETECT->isMobile() && (!($DETECT->isAndroidtablet() || $DETECT->isIpad()))) { //$output = str_replace('
client_side_validation(false); $form_op = $attForm->render('',true); $form_op = str_replace(' jQuery(document).bind("mobileinit", function () { jQuery.mobile.ajaxEnabled = false; }); EOF; }else{ $form_op = $attForm->render('',true); } $output =<< {$form_op} EOF; } $OBJ = array(); if(in_array($ID, $pages)){ $OBJ = pc::getSingleObj($SHEET,$ID); }else{ $OBJ['id'] = $ID; $OBJ['name'] = _('Downloads Center'); $OBJ['name_sub'] = _('100% free file downloads'); $OBJ['desc'] = _("In order to prevent spam robots").' , '. _("we will need you to provide the following information."). _("Our system will send you a download pdf file link to your email account"). '.' . _("Please note that all information will be strictly kept confidential."); } $OBJ['desc_html'] = $output; } $OBJ['id'] = $ID; $IS_404 = false; $tpl = pc::loadTpl(); html::JS_($jsPath); $tpl = html::autoReplace($tpl); $tpl = html::jscss_replace($tpl); $zfclient = << EOF; $tpl = str_ireplace(' ',"{$zfclient}",$tpl); endif; break; } //$tpl = pcc::loadTpl(); echo $tpl; exit(); } ?> 跑步机上插,欧美男男GAY可播放免费不卡,朝鲜妇女bbw,美人被教官强伦姧免费看