4-6-1
                        加強資料保護
                    
                
                                                            
                             
                            
                                
                                    您沒有觀看影片的權限
                                    請先登入,登入後,確認您的權限後,即可觀看影片。
                                 
                             
                         
                                                    
	- 看起來很OK?但其實危險重重,例如,修改報名時,只要在網址加入 id ,就有可能可以看到他人的資訊
- 加入第二個參數 $uid,若該參數有值時,會同時加入篩選條件,確保只會篩出原始報名者資料 影片中資料庫大小寫不正確,一律改為小寫 prefix("tad_signup_data")
//以流水號取得某筆資料
public static function get($id = '', $uid = '')
{
    global $xoopsDB;
    if (empty($id)) {
        return;
    }
    $and_uid = $uid ? "and `uid`='$uid'" : '';
    $sql = "select * from `" . $xoopsDB->prefix("tad_signup_data") . "`
    where `id` = '{$id}' $and_uid";
    $result = $xoopsDB->query($sql) or Utility::web_error($sql, __FILE__, __LINE__);
    $data = $xoopsDB->fetchArray($result);
    return $data;
}
   
- 搜尋其他地方有用到 get()的地方,看是否要加入,例如修改create()時,若不是管理員,就強制只能讀取自己的資料,讀不到資料就轉走。 這部份錄影時沒做完整,請務必加上最後的轉向動作
//編輯表單
public static function create($action_id, $id = '')
{
    global $xoopsTpl, $xoopsUser;
    $uid = $_SESSION['tad_signup_adm'] ? null : $xoopsUser->uid();
    //抓取預設值
    $db_values = empty($id) ? [] : self::get($id, $uid);
    if ($id and empty($db_values)) {
        redirect_header($_SERVER['PHP_SELF'] . "?id={$action_id}", 3, "查無報名無資料,無法修改");
    }
    /*--- 略 ---*/
}
   
- 還有 show()也一樣的處理
//以流水號秀出某筆資料內容
public static function show($id = '')
{
    global $xoopsDB, $xoopsTpl, $xoopsUser;
    if (empty($id)) {
        return;
    }
    $id = (int) $id;
    $uid = $_SESSION['tad_signup_adm'] ? null : $xoopsUser->uid();
    $data = self::get($id, $uid);
    if (empty($data)) {
        redirect_header($_SERVER['PHP_SELF'], 3, "查無報名無資料,無法觀看");
    }
    /*---略---*/
}
   
 link to  https://github.com/tadlearn/tad_signup/commit/968f88edef46ec91797659cfbb5162a643683ab2 \
link to  https://github.com/tadlearn/tad_signup/commit/968f88edef46ec91797659cfbb5162a643683ab2 \