Example #1
0
 public function doWebPaper()
 {
     global $_GPC, $_W;
     $op = $_GPC['op'];
     $weid = $_W['uniacid'];
     $types_config = $this->_types_config;
     if ($op == 'edit') {
         //编辑
         $id = intval($_GPC['id']);
         $tid = intval($_GPC['tid']);
         $year_array = array();
         for ($i = date("Y"); $i >= 2000; $i--) {
             $year_array[] = $i;
         }
         if (checksubmit()) {
             $insert = array('weid' => $weid, 'displayorder' => $_GPC['displayorder'], 'title' => $_GPC['title'], 'level' => $_GPC['level'], 'year' => $_GPC['year'], 'tid' => $_GPC['tid'], 'description' => $_GPC['description'], 'status' => $_GPC['status'], 'pcate' => $_GPC['pcate']);
             if (empty($id)) {
                 pdo_insert('ewei_exam_paper', $insert);
             } else {
                 pdo_update('ewei_exam_paper', $insert, array('id' => $id));
             }
             message("试卷信息保存成功!", $this->createWebUrl('paper'), "success");
         }
         if (!empty($id)) {
             $item = pdo_fetch("select * from " . tablename('ewei_exam_paper') . " where id=:id limit 1", array(":id" => $id));
             $tid = $item['tid'];
         }
         if (!empty($item)) {
             $paper_category = pdo_fetch("select id, cname as title from " . tablename('ewei_exam_paper_category') . " where id=:id limit 1", array(':id' => $item['pcate']));
         }
         //            if(!empty($item)){
         //                $paper = pdo_fetch("select id,title from ".tablename('ewei_exam_paper')." where id=:id limit 1",array(':id'=>$item['paperid']));
         //            }
         $type_item = pdo_fetch("select * from " . tablename('ewei_exam_paper_type') . " where id=:id limit 1", array(':id' => $tid));
         $types = unserialize($type_item['types']);
         if (!empty($id)) {
             $question_array = array();
             $question_array['id'] = $id;
             $question_array['types'] = $types;
             $d_question = $this->getDefaultPaperQuestion($question_array);
             $now_question_data = $d_question['data'];
         }
         //print_r($question_item);exit;
         include $this->template('paper_form');
     } else {
         if ($op == 'editquestion') {
             session_start();
             $_SESSION['last_url'] = $_SERVER['REQUEST_URI'];
             //编辑
             $id = intval($_GPC['id']);
             $tid = intval($_GPC['tid']);
             if (checksubmit()) {
                 //更改排序
                 foreach ($_GPC['displayorder'] as $k => $v) {
                     if (empty($v)) {
                         $v = 0;
                     }
                     pdo_update('ewei_exam_paper_question', array('displayorder' => $v), array('paperid' => $id, 'questionid' => $k));
                 }
             }
             if (!empty($id)) {
                 $item = pdo_fetch("select * from " . tablename('ewei_exam_paper') . " where id=:id limit 1", array(":id" => $id));
                 $tid = $item['tid'];
             }
             if (!empty($item)) {
                 $paper_category = pdo_fetch("select id, cname as title from " . tablename('ewei_exam_paper_category') . " where id=:id limit 1", array(':id' => $item['pcate']));
             }
             $type_item = pdo_fetch("select * from " . tablename('ewei_exam_paper_type') . " where id=:id limit 1", array(':id' => $tid));
             $types = unserialize($type_item['types']);
             if (!empty($id)) {
                 $question_array = array();
                 $question_array['id'] = $id;
                 $question_array['types'] = $types;
                 $d_question = $this->getDefaultPaperQuestion($question_array);
                 $now_question_data = $d_question['data'];
             }
             $question_item = get_paper_question_list($id);
             //print_r($question_item);exit;
             include $this->template('paper_question_form');
         } else {
             if ($op == 'delete') {
                 $id = intval($_GPC['id']);
                 pdo_delete("ewei_exam_paper_question", array("paperid" => $id));
                 //pdo_delete("ewei_exam_paper_member", array("questionid" => $id));
                 //pdo_delete("ewei_exam_paper_member_data", array("questionid" => $id));
                 pdo_delete("ewei_exam_paper", array("id" => $id));
                 message("试题信息删除成功!", referer(), "success");
             } else {
                 if ($op == 'deleteall') {
                     foreach ($_GPC['idArr'] as $k => $id) {
                         $id = intval($id);
                         pdo_delete("ewei_exam_paper_question", array("paperid" => $id));
                         //pdo_delete("ewei_exam_paper_member", array("questionid" => $id));
                         //pdo_delete("ewei_exam_paper_member_data", array("questionid" => $id));
                         pdo_delete("ewei_exam_paper", array("id" => $id));
                     }
                     $this->web_message('试题信息删除成功!', '', 0);
                     exit;
                 } else {
                     if ($op == 'showall') {
                         if ($_GPC['show_name'] == 'showall') {
                             $show_status = 1;
                         } else {
                             $show_status = 0;
                         }
                         foreach ($_GPC['idArr'] as $k => $id) {
                             $id = intval($id);
                             if (!empty($id)) {
                                 pdo_update('ewei_exam_paper', array('status' => $show_status), array('id' => $id));
                             }
                         }
                         //message('操作成功!', '', 0);
                         exit;
                     } else {
                         if ($op == 'status') {
                             $id = intval($_GPC['id']);
                             if (empty($id)) {
                                 message('抱歉,传递的参数错误!', '', 'error');
                             }
                             $temp = pdo_update('ewei_exam_paper', array('status' => $_GPC['status']), array('id' => $id));
                             if ($temp == false) {
                                 message('抱歉,刚才操作数据失败!', '', 'error');
                             } else {
                                 message('状态设置成功!', referer(), 'success');
                             }
                         } else {
                             if ($op == 'query') {
                                 $kwd = trim($_GPC['keyword']);
                                 $sql = "SELECT p.id, p.title, p.description,t.types, t.score FROM " . tablename('ewei_exam_paper') . " AS p";
                                 $sql .= " LEFT JOIN " . tablename('ewei_exam_paper_type') . " AS t on p.tid = t.id";
                                 $sql .= " WHERE p.weid = :weid";
                                 $params = array();
                                 $params[':weid'] = $_W['uniacid'];
                                 if (!empty($kwd)) {
                                     $sql .= " AND p.title LIKE :title";
                                     $params[':title'] = "%{$kwd}%";
                                 }
                                 $ds = pdo_fetchall($sql, $params);
                                 foreach ($ds as $key => $value) {
                                     $value['types'] = unserialize($value['types']);
                                     $d_question = $this->getDefaultPaperQuestion($value);
                                     $ds[$key]['now_score'] = $d_question['score'];
                                     $now_question_data = $d_question['data'];
                                     $pager_str = '该试卷包含 ';
                                     foreach ($value['types'] as $k => $v) {
                                         if ($v['has'] == 1) {
                                             $pager_str .= $types_config[$k] . "(" . $now_question_data[$k]['num'] . "/" . $v['num'] . ")道 ";
                                         }
                                     }
                                     $ds[$key]['pager_str'] = $pager_str;
                                 }
                                 include $this->template('paper_query');
                             } else {
                                 $pindex = max(1, intval($_GPC['page']));
                                 $psize = 20;
                                 $sql = "";
                                 $params = array();
                                 if (!empty($_GPC['title'])) {
                                     $sql .= ' AND p.title LIKE :keywords';
                                     $params[':keywords'] = "%{$_GPC['title']}%";
                                 }
                                 if (!empty($_GPC['level'])) {
                                     $sql .= ' AND p.level=:level';
                                     $params[':level'] = intva($_GPC['level']);
                                 }
                                 if (!empty($_GPC['pcate'])) {
                                     $pcate = intval($_GPC['pcate']);
                                     //判断是否为一级分类
                                     $cate_sql = "SELECT id FROM " . tablename('ewei_exam_paper_category');
                                     $cate_sql .= " WHERE parentid = " . $pcate;
                                     $cate_sql .= " AND weid = " . $weid;
                                     //$cate_sql .= " AND status = 1";
                                     $item = pdo_fetchall($cate_sql);
                                     $cate_num = count($item);
                                     if ($cate_num == 0) {
                                         $sql .= " AND p.pcate = :pcate";
                                         $params[':pcate'] = $pcate;
                                     } else {
                                         if ($cate_num > 0) {
                                             $item[$cate_num]['id'] = $pcate;
                                             $cate_str = '';
                                             foreach ($item as $k => $v) {
                                                 $cate_str .= $v['id'] . ",";
                                             }
                                             $cate_str = trim($cate_str, ",");
                                             $sql .= " AND p.pcate in (" . $cate_str . ")";
                                         }
                                     }
                                 }
                                 $pindex = max(1, intval($_GPC['page']));
                                 $psize = 20;
                                 $select_sql = "SELECT p.*, t.score, t.times FROM " . tablename('ewei_exam_paper') . " as p";
                                 $select_sql .= " LEFT JOIN " . tablename('ewei_exam_paper_type') . " as t on p.tid = t.id";
                                 $select_sql .= " WHERE p.weid = '{$_W['uniacid']}'  {$sql} ORDER BY displayorder DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize;
                                 $list = pdo_fetchall($select_sql, $params);
                                 $count_sql = "SELECT COUNT(p.id) FROM " . tablename('ewei_exam_paper') . " as p";
                                 $count_sql .= " LEFT JOIN " . tablename('ewei_exam_paper_type') . " as t on p.tid = t.id";
                                 $count_sql .= " WHERE p.weid = '{$_W['uniacid']}'" . $sql;
                                 $category = pdo_fetchall("SELECT * FROM " . tablename('ewei_exam_paper_category') . " WHERE weid = '{$_W['uniacid']}' AND status = 1 ORDER BY parentid ASC, displayorder DESC");
                                 //print_r($category);exit;
                                 $total = pdo_fetchcolumn($count_sql, $params);
                                 $pager = pagination($total, $pindex, $psize);
                                 include $this->template('paper');
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Example #2
0
                 // Charisma restriction. Has to be more than 0 otherwise pointless restriction
                 $char_resist_list .= $lang['Adr_char_cha'] . ' [' . $row['item_restrict_cha'] . ']; ';
             }
             $char_resist_list = substr($char_resist_list, 0, strlen($char_resist_list) - 2);
             if ($row['item_restrict_level'] > '1' || $row['item_restrict_str'] > '0' || $row['item_restrict_dex'] > '0' || $row['item_restrict_con'] > '0' || $row['item_restrict_int'] > '0' || $row['item_restrict_wis'] > '0' || $row['item_restrict_cha'] > '0') {
                 $template->assign_block_vars('view_store.items.resist_chars', array("CHAR_RESIST_LIST" => $char_resist_list, "L_CHAR_RESIST_LIST" => $lang['Adr_char_restrict_title']));
             }
             ##==== END: Show any level or characteristic restrictions for this item ===##
             $i++;
         } while ($row = $db->sql_fetchrow($result));
     }
     ##=== START: show all items or just those available to user?
     $points_check_sql = $show_only_mine == '1' ? ' AND item_price <= ' . $points : '';
     $item_sql = $show_only_mine == '1' ? $item_sql : '';
     ##=== END: show all items or just those available to user?
     $cat_sql = $cat ? 'AND item_type_use = ' . intva($cat) : '';
     $sql = "SELECT count(*) AS total FROM " . ADR_SHOPS_ITEMS_TABLE . " \n\t\t\t\tWHERE item_store_id = {$shop_id} \n\t\t\t\tAND item_owner_id = 1 \n\t\t\t\tAND item_auth = 0\n\t\t\t\t{$item_sql}\n\t\t\t\t{$points_check_sql}\n\t\t\t\t{$cat_sql}\n\n\t\t\t\t{$zone_restriction_1}\n\n\t\t\t\tAND item_duration > 0 ";
     if (!($result = $db->sql_query($sql))) {
         message_die(GENERAL_ERROR, 'Error getting total users', '', __LINE__, __FILE__, $sql);
     }
     if ($total = $db->sql_fetchrow($result)) {
         $total_items = $total['total'];
         $pagination = generate_pagination("adr_shops.{$phpEx}?mode=view_store&amp;mode2={$mode2}&amp;order={$sort_order}&amp;shop_id=" . $shop_id . "", $total_items, $board_config['topics_per_page'], $start) . '&nbsp;';
     }
     $template->assign_vars(array('ORDER_BY' => $order_by, 'ACTION_SELECT' => $action_select, 'SELECT_CAT' => $select_category, 'SELECT_QUANTITY' => $select_quantity, 'STORE_ID' => $shop_id, 'STORE_NAME' => $store_name, 'STORE_DESC' => $store_desc, 'SHOP_OWNER_ID' => $shop_owner_id, 'POINTS' => number_format(get_reward($user_id)), 'SHOW_LINK' => $show_link, 'L_POINTS' => $lang['Adr_my'] . get_reward_name(), 'L_SHOW_LINK' => $show_type, "L_SELECT_CAT" => $lang['Adr_items_select'], "L_SELECT_QUANTITY" => $lang['Adr_items_select_quantity'], "L_ITEM_NAME" => $lang['Adr_shops_categories_item_name'], "L_ITEM_DESC" => $lang['Adr_shops_categories_item_desc'], "L_ITEM_QUALITY" => $lang['Adr_items_quality'], "L_ITEM_POWER" => $lang['Adr_items_power'], "L_ITEM_WEIGHT" => $lang['Adr_character_weight'], "L_ITEM_DURATION" => $lang['Adr_items_duration'], "L_ACTION" => $lang['Adr_items_action'], "L_ITEM_IMG" => $lang['Adr_races_image'], "L_ITEM_PRICE" => $lang['Adr_items_price'], "L_ITEM_TYPE" => $lang['Adr_items_type_use'], "L_NO_ITEMS" => $lang['Adr_items_none'], 'L_SELECT_SORT_METHOD' => $lang['Select_sort_method'], 'L_ORDER' => $lang['Order'], 'L_SORT' => $lang['Sort'], 'L_SUBMIT' => $lang['Submit'], 'S_MODE_SELECT' => $select_sort_mode, 'S_ORDER_SELECT' => $select_sort_order, 'PAGINATION' => $pagination, 'PAGE_NUMBER' => sprintf($lang['Page_of'], floor($start / $board_config['topics_per_page']) + 1, ceil($total_items / $board_config['topics_per_page'])), 'L_GOTO_PAGE' => $lang['Goto_page'], 'S_MODE_ACTION' => append_sid("adr_shops.{$phpEx}?mode=view_store&amp;shop_id=" . $shop_id . "")));
     break;
 case 'view_store_admin':
     $template->assign_block_vars('view_store', array());
     if ($userdata['user_level'] != ADMIN) {
         // Send user PM notification...
         $member_id = 2;