public function add() { needLogin(); if (!($id = $this->_get('id', 'intval'))) { $this->error('参数错误:missing id'); } $model = M("Deal"); $deal = $model->where("id={$id}")->field('content,shop_connect', true)->find(); //未找到团购 if (!$deal) { $this->error("不存在的团购哦~~"); } if (!($cart = session("cart"))) { $cart = array("{$id}" => 0); } else { if (!$cart[$id]) { $cart[$id] = 0; } } $new_count = $cart[$id] + 1; //数量超过限制 if ($new_count + $deal['brought_count'] > $deal['max_brought']) { $this->error("该团购已经达到最大数量限制", __URL__); } if ($new_count > $deal['user_max_brought']) { $this->error("该团购一个用户最多只能购买{$deal['user_max_brought']}件", __URL__); } //已经结束。。更多。。。 $cart[$id] = $new_count; session("cart", $cart); redirect(__URL__); }
protected function idisplay($title) { needLogin(); $model = D('User'); $uid = getUserId(); $data = $model->find($uid); $this->assign("user", $data); $this->assign("tpname", 'inc:uc_order_' . ACTION_NAME); $this->display('User:user', $title); }
<?php require_once "php/include.php"; needLogin(); if (!$admin) { header('Location: ./'); exit; } switch ($_GET["action"]) { case 'update_leaderboards': chdir("php"); require_once "update_leaderboards.php"; break; case 'test_bots': chdir("php"); require_once "test_bots.php"; break; }
public function update() { needLogin(); $modoel = D("User"); if (getUserId() != $this->_post('id')) { $this->error("无权操作"); } if ($modoel->create()) { $modoel->save(); $user_info = $modoel->find(getUserId()); session("user_info", $user_info); } $this->success("更新成功", __URL__); exit; }
<?php session_start(); require dirname(__FILE__) . "/lib/header.php"; needLogin($DBmain); if (!is_numeric($_GET['act'])) { $_GET['act'] = -1; } $now = time(); $result = $DBmain->query("SELECT * FROM `main`\n LEFT JOIN `department` ON `deptID` = `voteDept`\n WHERE `mainID` = {$_GET['act']} AND `status` != 3; "); if ($result->num_rows <= 0) { locate($URLPv . 'index.php'); } $row = $result->fetch_array(MYSQLI_BOTH); if (isset($_POST['idea'])) { $str = $_POST['id'][0]; for ($i = 1; $i < count($_POST['id']); $i++) { $str .= ',' . $_POST['id'][$i]; } $DBmain->query("INSERT INTO `draft` (`user`, `actID`, `idea`, `picItem`)\n\t\t\t\t\t\t\tVALUES ('{$_SESSION['loginID']}', '{$_GET['act']}', \n\t\t\t\t\t\t\t\t'{$_POST['idea']}', '{$str}'); "); locate($URLPv . "view.php?act={$_GET['act']}"); } else { ?> <div class="container"> <form action="add.php?act=<?php echo $_GET['act']; ?> " method="post"> <h2 class="text-center"><?php echo $row['title'];