public function index() { $root = array(); $root['response_code'] = 1; $id = intval($_REQUEST['id']); $email = strim($GLOBALS['request']['email']); // 用户名或邮箱 $pwd = strim($GLOBALS['request']['pwd']); // 密码 // 检查用户,用户密码 $user = user_check($email, $pwd); $user_id = intval($user['id']); $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . $id . " and is_delete = 0 and (is_effect = 1 or (is_effect = 0 and user_id = " . intval($GLOBALS['user_info']['id']) . "))"); if (!$deal_info) { app_redirect(url("index")); } $deal_info = cache_deal_extra($deal_info); init_deal_page($deal_info); $page_size = $GLOBALS['m_config']['page_size']; $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * $page_size . "," . $page_size; $log_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_log where deal_id = " . $deal_info['id'] . " order by create_time desc limit " . $limit); $log_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_log where deal_id = " . $deal_info['id']); $url = url_wap("deal#show", array("id" => $id)); $root['url'] = $url; $last_time_key = ""; foreach ($log_list as $k => $v) { $log_list[$k]['image'] = get_user_avatar_root($v["user_id"], "middle"); //用户头像 //$log_list[$k]['image'] = get_abs_img_root(get_spec_image($v['image'],640,240,1)); $log_list[$k]['pass_time'] = pass_date($v['create_time']); $online_time = online_date($v['create_time'], $deal_info['begin_time']); $log_list[$k]['online_time'] = $online_time['info']; $log_list[$k]['comment_data_cache'] = null; $log_list[$k]['deal_info_cache'] = null; if ($online_time['key'] != $last_time_key) { $last_time_key = $log_list[$k]['online_time_key'] = $online_time['key']; } $log_list[$k] = cache_log_comment($log_list[$k]); } $root['log_list'] = $log_list; // require APP_ROOT_PATH.'app/Lib/page.php'; // $page = new Page($log_count,$page_size); //初始化分页对象 // $p = $page->show(); // $root['pages'] = $p; $root['page'] = array("page" => $page, "page_total" => ceil($log_count / $page_size), "page_size" => intval($page_size), 'total' => intval($log_count)); output($root); }
public function index() { $root = array(); $root['response_code'] = 1; $id = intval($_REQUEST['id']); $update_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_log where id = " . $id); $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . intval($update_info['deal_id']) . " and is_delete = 0 and (is_effect = 1 or (is_effect = 0 and user_id = " . intval($GLOBALS['user_info']['id']) . "))"); if (!$deal_info) { app_redirect(url("index")); } $deal_info = cache_deal_extra($deal_info); init_deal_page($deal_info); $log_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_log where id = " . $id); foreach ($log_list as $k => $v) { $log_list[$k]['pass_time'] = pass_date($v['create_time']); $online_time = online_date($v['create_time'], $deal_info['begin_time']); $log_list[$k]['online_time'] = $online_time['info']; if ($online_time['key'] != $last_time_key) { $last_time_key = $log_list[$k]['online_time_key'] = $online_time['key']; } $log_list[$k]['comment_count'] = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_comment where log_id = " . $v['id'] . " and deal_id = " . $deal_info['id']); $page_size = $GLOBALS['m_config']['page_size']; $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * $page_size . "," . $page_size; $log_list[$k]['comment_list'] = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_comment where log_id = " . $v['id'] . " and deal_id = " . $deal_info['id'] . " order by create_time desc limit " . $limit); // require APP_ROOT_PATH.'app/Lib/page.php'; // $page = new Page($log_list[$k]['comment_count'],$page_size); //初始化分页对象 // $p = $page->show(); // $GLOBALS['tmpl']->assign('pages',$p); $root['page'] = array("page" => $page, "page_total" => ceil($log_list[$k]['comment_count'] / $page_size), "page_size" => intval($page_size), 'total' => intval($log_list[$k]['comment_count'])); } $root['log_list'] = $log_list; output($root); }
public function dealupdate() { $id = intval($_REQUEST['id']); $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . $id . " and is_delete = 0 and (is_effect = 1 or (is_effect = 0 and user_id = " . intval($GLOBALS['user_info']['id']) . "))"); if (!$deal_info) { ajax_return(array("step" => 0)); } else { $GLOBALS['tmpl']->assign("deal_info", $deal_info); } $page_size = DEALUPDATE_PAGE_SIZE; $step_size = DEALUPDATE_STEP_SIZE; $step = intval($_REQUEST['step']); if ($step == 0) { $step = 1; } $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * $page_size + ($step - 1) * $step_size . "," . $step_size; $log_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_log where deal_id = " . $deal_info['id'] . " order by create_time desc limit " . $limit); $log_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_log where deal_id = " . $deal_info['id']); if (!$log_list) { ajax_return(array("step" => 0)); } if (($page - 1) * $page_size + ($step - 1) * $step_size + count($log_list) >= $log_count) { //最后一页 $log_list[] = array("deal_id" => $deal_info['id'], "create_time" => $deal_info['begin_time'] + 1, "id" => 0); } $last_time_key = ""; foreach ($log_list as $k => $v) { $log_list[$k]['pass_time'] = pass_date($v['create_time']); $online_time = online_date($v['create_time'], $deal_info['begin_time']); $log_list[$k]['online_time'] = $online_time['info']; if ($online_time['key'] != $last_time_key) { $last_time_key = $log_list[$k]['online_time_key'] = $online_time['key']; } $log_list[$k] = cache_log_comment($log_list[$k]); } $GLOBALS['tmpl']->assign("log_list", $log_list); $data['html'] = $GLOBALS['tmpl']->fetch("inc/time_line_item.html"); //$data['html'] = "select * from ".DB_PREFIX."deal_log where deal_id = ".$deal_info['id']." order by create_time desc limit ".$limit; if ($step * $step_size < $page_size) { if ($log_count <= ($page - 1) * $page_size + ($step - 1) * $step_size + $step_size) { $data['step'] = 0; ajax_return($data); } else { $data['step'] = $step + 1; ajax_return($data); } } else { $data['step'] = 0; ajax_return($data); } }
public function fav() { if (!$GLOBALS['user_info']) { app_redirect(url("user#login")); } $GLOBALS['tmpl']->assign("page_title", "我关注的项目动态"); $cate_result = load_dynamic_cache("INDEX_CATE_LIST"); if ($cate_result === false) { $cate_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_cate order by sort asc"); $cate_result = array(); foreach ($cate_list as $k => $v) { $cate_result[$v['id']] = $v; } set_dynamic_cache("INDEX_CATE_LIST", $cate_result); } $GLOBALS['tmpl']->assign("cate_list", $cate_result); $rand_deals = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal where is_delete = 0 and is_effect = 1 and begin_time < " . NOW_TIME . " and (end_time >" . NOW_TIME . " or end_time = 0) order by rand() limit 3"); $GLOBALS['tmpl']->assign("rand_deals", $rand_deals); $page_size = DEALUPDATE_PAGE_SIZE; $step_size = DEALUPDATE_STEP_SIZE; $step = intval($_REQUEST['step']); if ($step == 0) { $step = 1; } $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * $page_size + ($step - 1) * $step_size . "," . $step_size; $GLOBALS['tmpl']->assign("current_page", $page); $sql = "select dl.* from " . DB_PREFIX . "deal_log as dl left join " . DB_PREFIX . "deal_focus_log as dfl on dl.deal_id = dfl.deal_id where dfl.user_id = " . intval($GLOBALS['user_info']['id']) . " order by dl.create_time desc limit " . $limit; $sql_count = "select count(*) from " . DB_PREFIX . "deal_log as dl left join " . DB_PREFIX . "deal_focus_log as dfl on dl.deal_id = dfl.deal_id where dfl.user_id = " . intval($GLOBALS['user_info']['id']); $log_list = $GLOBALS['db']->getAll($sql); $log_count = $GLOBALS['db']->getOne($sql_count); foreach ($log_list as $k => $v) { $log_list[$k]['pass_time'] = pass_date($v['create_time']); $online_time = online_date($v['create_time'], $deal_info['begin_time']); $log_list[$k]['online_time'] = $online_time['info']; $log_list[$k]['comment_count'] = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_comment where log_id = " . $v['id']); $log_list[$k]['comment_list'] = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_comment where log_id = " . $v['id'] . " order by create_time desc limit 3"); if ($log_list[$k]['comment_count'] <= count($log_list[$k]['comment_list'])) { $log_list[$k]['more_comment'] = false; } else { $log_list[$k]['more_comment'] = true; } $log_list[$k]['deal_info'] = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . $v['deal_id']); if ($log_list[$k]['deal_info']) { $log_list[$k]['deal_info']['remain_days'] = floor(($log_list[$k]['deal_info']['end_time'] - NOW_TIME) / (24 * 3600)); $log_list[$k]['deal_info']['percent'] = round($log_list[$k]['deal_info']['support_amount'] / $log_list[$k]['deal_info']['limit_price'] * 100); } } $GLOBALS['tmpl']->assign('log_list', $log_list); $pager = new Page($log_count, $page_size); //初始化分页对象 $p = $pager->show(); $GLOBALS['tmpl']->assign('pages', $p); $GLOBALS['tmpl']->assign("ajaxurl", url("ajax#newsfav", array("p" => $page))); $GLOBALS['tmpl']->display("news.html"); }
public function updatedetail() { $id = intval($_REQUEST['id']); $update_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_log where id = " . $id); $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . intval($update_info['deal_id']) . " and is_delete = 0 and (is_effect = 1 or (is_effect = 0 and user_id = " . intval($GLOBALS['user_info']['id']) . "))"); if (!$deal_info) { app_redirect(url("index")); } init_deal_page($deal_info); $log_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_log where id = " . $id); foreach ($log_list as $k => $v) { $log_list[$k]['pass_time'] = pass_date($v['create_time']); $online_time = online_date($v['create_time'], $deal_info['begin_time']); $log_list[$k]['online_time'] = $online_time['info']; if ($online_time['key'] != $last_time_key) { $last_time_key = $log_list[$k]['online_time_key'] = $online_time['key']; } $log_list[$k]['comment_count'] = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_comment where log_id = " . $v['id'] . " and deal_id = " . $deal_info['id']); $page_size = DEAL_COMMENT_PAGE_SIZE; $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * $page_size . "," . $page_size; $log_list[$k]['comment_list'] = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_comment where log_id = " . $v['id'] . " and deal_id = " . $deal_info['id'] . " order by create_time desc limit " . $limit); require APP_ROOT_PATH . 'app/Lib/page.php'; $page = new Page($log_list[$k]['comment_count'], $page_size); //初始化分页对象 $p = $page->show(); $GLOBALS['tmpl']->assign('pages', $p); } $GLOBALS['tmpl']->assign("log_list", $log_list); $GLOBALS['tmpl']->display("deal_updatedetail.html"); }
public function newsfav() { $page_size = DEALUPDATE_PAGE_SIZE; $step_size = DEALUPDATE_STEP_SIZE; $step = intval($_REQUEST['step']); if ($step == 0) { $step = 1; } $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * $page_size + ($step - 1) * $step_size . "," . $step_size; $sql = "select dl.* from " . DB_PREFIX . "deal_log as dl left join " . DB_PREFIX . "deal_focus_log as dfl on dl.deal_id = dfl.deal_id where dfl.user_id = " . intval($GLOBALS['user_info']['id']) . " order by dl.create_time desc limit " . $limit; $sql_count = "select count(*) from " . DB_PREFIX . "deal_log as dl left join " . DB_PREFIX . "deal_focus_log as dfl on dl.deal_id = dfl.deal_id where dfl.user_id = " . intval($GLOBALS['user_info']['id']); $log_list = $GLOBALS['db']->getAll($sql); $log_count = $GLOBALS['db']->getOne($sql_count); foreach ($log_list as $k => $v) { $log_list[$k]['pass_time'] = pass_date($v['create_time']); $online_time = online_date($v['create_time'], $deal_info['begin_time']); $log_list[$k]['online_time'] = $online_time['info']; $log_list[$k]['comment_count'] = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_comment where log_id = " . $v['id']); $log_list[$k]['comment_list'] = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_comment where log_id = " . $v['id'] . " order by create_time desc limit 3"); if ($log_list[$k]['comment_count'] <= count($log_list[$k]['comment_list'])) { $log_list[$k]['more_comment'] = false; } else { $log_list[$k]['more_comment'] = true; } $log_list[$k]['deal_info'] = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . $v['deal_id']); if ($log_list[$k]['deal_info']) { $log_list[$k]['deal_info']['remain_days'] = floor(($log_list[$k]['deal_info']['end_time'] - NOW_TIME) / (24 * 3600)); $log_list[$k]['deal_info']['percent'] = round($log_list[$k]['deal_info']['support_amount'] / $log_list[$k]['deal_info']['limit_price'] * 100); } } $GLOBALS['tmpl']->assign('log_list', $log_list); $data['html'] = $GLOBALS['tmpl']->fetch("inc/news_item.html"); if ($step * $step_size < $page_size) { if ($log_count <= ($page - 1) * $page_size + ($step - 1) * $step_size + $step_size) { $data['step'] = 0; ajax_return($data); } else { $data['step'] = $step + 1; ajax_return($data); } } else { $data['step'] = 0; ajax_return($data); } }
public function update() { $id = intval($_REQUEST['id']); $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . $id . " and is_delete = 0 and (is_effect = 1 or (is_effect = 0 and user_id = " . intval($GLOBALS['user_info']['id']) . "))"); $deal_info['deal_type'] = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate where id=" . $deal_info['cate_id']); if (!$deal_info) { app_redirect(url_wap("index")); } $deal_info = cache_deal_extra($deal_info); init_deal_page_wap($deal_info); $page_size = 15; $step_size = 5; $step = intval($_REQUEST['step']); if ($step == 0) { $step = 1; } $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * $page_size + ($step - 1) * $step_size . "," . $step_size; $GLOBALS['tmpl']->assign("current_page", $page); $log_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_log where deal_id = " . $deal_info['id'] . " order by create_time desc limit " . $limit); $log_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_log where deal_id = " . $deal_info['id']); if (!$log_list || ($page - 1) * $page_size + ($step - 1) * $step_size + count($log_list) >= $log_count) { //最后一页 $log_list[] = array("deal_id" => $deal_info['id'], "create_time" => $deal_info['begin_time'] + 1, "id" => 0); } $last_time_key = ""; foreach ($log_list as $k => $v) { $log_list[$k]['pass_time'] = pass_date($v['create_time']); $online_time = online_date($v['create_time'], $deal_info['begin_time']); $log_list[$k]['online_time'] = $online_time['info']; if ($online_time['key'] != $last_time_key) { $last_time_key = $log_list[$k]['online_time_key'] = $online_time['key']; } $log_list[$k] = cache_log_comment($log_list[$k]); } $GLOBALS['tmpl']->assign("log_list", $log_list); require APP_ROOT_PATH . 'wap/app/page.php'; $page = new Page($log_count, $page_size); //初始化分页对象 $p = $page->show(); $GLOBALS['tmpl']->assign('pages', $p); $GLOBALS['tmpl']->display("deal_update.html"); }