工作程式

出自六年制學程
跳轉到: 導覽搜尋

出 $html1,$html2 的條件判斷

  1. 只要沒有引用 login.php 或 etable.php 就直接出,免條件判斷。如下面的(一)和(三)。
  2. 也可以使用 ajax 更新畫面,不靠翻頁。此時要找一個靠 ajax 傳遞的變數來判斷不用重刷畫面。如下面的(二)。
  3. !isset($_REQUEST['exec_type']) 條件是給有登入或使用 etable 的工作程式用的,只要 exec_type 沒了,就重刷新頁,同時重做 theme 和「登出」鈕。如下面的(四)和(五)。
  4. 可以穿透諸 site 的 /webContent.php ,任何時候 theme 都不重刷,不用出 $html1,$html2 。如下面的(六)。

(一)免登入,未使用資料庫(預設連資料庫,不管工作程式須不須要)

<?php
include_once 'userConstant.php' 或 'constant.php';	// 載入伺服器參數
include_once 'theme.php';				// 載入 site 布景,順便會載入 site 常、變數,連資料庫
$str=…;
echo $html1;
echo $str;
echo $html2;
?>

(二)使用 ajax 更新畫面,不靠翻頁

<?php
include_once 'userConstant.php' 或 'constant.php';
include_once 'theme.php';
include CLASS_FILE_PATH.'/database/login.php';	// 只用 login::js() ,不使用 login()
if(!isset($_REQUEST['某個透過ajax傳送的變數'])){echo $html1.login::js();}
…
if(!isset($_REQUEST['某個透過ajax傳送的變數'])){echo $html2;}
?>

(三)免登入,使用資料庫(預設連資料庫,不管工作程式須不須要)

<?php
include_once 'userConstant.php' 或 'constant.php';
include_once 'theme.php';	// 載入 site 布景,順便會載入 site 常、變數,連資料庫
$result=DB::queryF("…");
$str=…;
while($row=mysqli_fetch_assoc($result)){$str.=…;}
echo $html1;
echo $str;
echo $html2;
?>

(四)登入而不使用etable,須要判別 exec_type ,以避免反復出「登出」鈕

<?php
include_once 'userConstant.php' 或 'constant.php';
include_once 'theme.php';	// 載入 site 布景,順便會載入 site 常、變數,連資料庫
if(!isset($_REQUEST['exec_type'])){echo $html1;}	// 本行須在 theme.php 與 $login->logon(); 之間
include_once CLASS_FILE_PATH."/database/login.php";
$login = new login;
$login->errPrompt="<br/><span style='color:red;'>僅允許………</span>";
$login->loginTable=array('tableName'=>'認證表','name'=>'帳號欄','psd'=>'密碼欄','grp'=>'群組欄','canWorkGrp'=>'通過群組');
$login->logon();
if(isset($login->checkin) && $login->checkin==1){$str=…;}
echo $str;
if(!isset($_REQUEST['exec_type'])){echo $html2;}
?>

(五)使用 etable ,是否登入不影響結構。須要判別 exec_type ,以避免反復出 theme

<?php
include 'userConstant.php' 或 'constant.php';
include 'theme.php';
if(!isset($_REQUEST['exec_type'])){echo $html1;}	// 本行須在 theme.php 與 $ET->main(); 之間
include CLASS_FILE_PATH.'/database/etable.php';
$ET = new etable;
$ET->errPrompt=…;	// 本行在須登入時才出現
$ET->loginTable=…;	// 本行在須登入時才出現
$ET->sql[0]="…";
$ET->main();
if(!isset($_REQUEST['exec_type'])){echo $html2;}
?>

(六)用 webContent 表中的內容穿透各種不同的 theme

全伺服器共用:

  1. webContent 資料表,其中可穿透諸 site 的內容 path 長這樣「/webContent.php/頁名」,其他的頁名都會帶其隸屬的 site 。
  2. webContent.js:造 javascript 的 webContent 函式。
  3. webContent.php,能適應諸 site 的通用欄值映射程式:
<?php
include_once './constant.php';
include_once CLASS_FILE_PATH."/database/DB.php";
require_once(CLASS_FILE_PATH."/database/etloc_ct.php");
$dsnConnection=DB::connect(DSN);
echo webContent($_SERVER['REQUEST_URI']);	// 由 constant.php 載入 GfWebContent.php 所定義
?>

工作程式(通常是 theme.php):

"<script language = 'javascript' src='/webContent.js' ></script>
<a href='' onClick=\"webContent('/webContent.php/頁名?ajax=1','div的ID');return false;\">◎◎◎◎◎</a>"