public function setOnlineDebugUrl()
 {
     $OnlineDebugKeyDB = new OnlineDebugKeyModelDB();
     $insertArr = array();
     $insertArr['rand_key'] = md5(mt_rand(1, 10000) + time());
     $insertArr['redirect'] = $_POST['redirect'];
     //$insertArr['expire'] = $_POST['expire'];
     $insertArr['expire'] = time() + 86400;
     $insertArr['valid'] = 1;
     $rs = $OnlineDebugKeyDB->insert($insertArr);
     $rs ? Message::showSucc('设置成功', $insertArr['rand_key']) : Message::showError('设置失败');
 }
 public function set()
 {
     $v = 1;
     $OnlineDebugKeyDB = new OnlineDebugKeyModelDB();
     $row = $OnlineDebugKeyDB->getRow("SELECT * FROM `" . $OnlineDebugKeyDB->getTableName() . "` WHERE `valid`=1 AND `rand_key`=?", array($_GET['rand_key']));
     if (!empty($row['rand_key'])) {
         $expire = intval($row['expire']);
         if ($expire != 0) {
             $expire = time() + $expire;
         }
         setcookie('dagger_online_debug', $v, $expire, '/', '.sina.com.cn', false, true);
         $OnlineDebugKeyDB->update(array('valid' => 0), array('rand_key' => $row['rand_key']));
         if (!empty($row['redirect'])) {
             header("Location: {$row['redirect']}");
         }
     } else {
         Message::showError('无效的请求');
     }
     exit;
 }