public function index() { $id = intval($_REQUEST['id']); $deal_info = $GLOBALS['db']->getRow("select d.*,dl.level as deal_level,dc.name as deal_type from " . DB_PREFIX . "deal as d left join " . DB_PREFIX . "deal_level as dl on dl.id=d.user_level left join " . DB_PREFIX . "deal_cate as dc on dc.id=d.cate_id where d.id = " . $id . " and d.is_delete = 0 and (d.is_effect = 1 or (d.is_effect = 0 and d.user_id = " . intval($GLOBALS['user_info']['id']) . "))"); $access = get_level_access($GLOBALS['user_info'], $deal_info); $GLOBALS['tmpl']->assign("access", $access); if (!$deal_info) { app_redirect(url_wap("index")); } if ($deal_info['is_effect'] == 1) { log_deal_visit($deal_info['id']); } $wx = array(); $wx['img_url'] = $deal_info['image']; $wx['title'] = $deal_info['name']; $wx['desc'] = $deal_info['brief']; $GLOBALS['tmpl']->assign('wx', $wx); $deal_info = cache_deal_extra($deal_info); if ($deal_info['type'] == 1) { $this->init_deal_page(@$deal_info); } else { init_deal_page_wap(@$deal_info); } $limit = "0,3"; $log_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_log where deal_id = " . $deal_info['id'] . " order by create_time desc limit " . $limit); foreach ($log_list as $k => $v) { if ($v['user_id']) { $user_ids[] = $v['user_id']; } } $user_ids = array_filter($user_ids); if ($user_ids) { $user_id_str = implode(',', array_filter($user_ids)); $user_list_array = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "user where id in (" . $user_id_str . ") "); foreach ($user_list_array as $k => $v) { foreach ($log_list as $k_log => $v_log) { if ($v['id'] == $v_log['user_id']) { $v['avatar'] = get_user_avatar_root($v["id"], "middle"); $log_list[$k_log]['user_info'] = $v; } } } } $log_num = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_log where deal_id = " . $deal_info['id']); $GLOBALS['tmpl']->assign("log_list", $log_list); $GLOBALS['tmpl']->assign("log_num", intval($log_num)); $comment_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_comment where deal_id = " . $id . " and log_id = 0 and status=1 order by create_time desc limit " . $limit); $comment_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_comment where deal_id = " . $id . " and log_id = 0 and status=1 "); $user_ids = array(); foreach ($comment_list as $k => $v) { if ($v['user_id']) { $user_ids[] = $v['user_id']; } } $user_ids = array_filter($user_ids); if ($user_ids) { $user_id_str = implode(',', array_filter($user_ids)); $user_list_array = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "user where id in (" . $user_id_str . ") "); foreach ($user_list_array as $k => $v) { foreach ($comment_list as $k_comment => $v_comment) { if ($v['id'] == $v_comment['user_id']) { $v['avatar'] = get_user_avatar_root($v["id"], "middle"); $comment_list[$k_comment]['user_info'] = $v; } } } } $GLOBALS['tmpl']->assign("info_url", url_wap("deal#info", array("id" => $id))); $GLOBALS['tmpl']->assign("comment_list", $comment_list); $GLOBALS['tmpl']->assign("comment_count", intval($comment_count)); $GLOBALS['tmpl']->assign("deal_index_url", url_wap("deal#index", array("id" => $id))); $GLOBALS['tmpl']->assign("usermessage_url", url_wap("ajax#usermessage", array("id" => $deal_info['user_id']))); $GLOBALS['tmpl']->assign("home_url", url_wap("deal#home", array("id" => $deal_info['user_id']))); if ($deal_info['type'] == 1) { set_deal_status($deal_info); $GLOBALS['tmpl']->assign("id", $id); $user_name = $GLOBALS['user_info']['user_name']; $GLOBALS['tmpl']->assign("user_name", $user_name); $deal_info['business_create_time'] = to_date($deal_info['business_create_time'], 'Y-m-d'); $cates = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate where id =" . $deal_info['cate_id']); //编辑及管理团队 $stock_list = unserialize($deal_info['stock']); $GLOBALS['tmpl']->assign("stock_list", $stock_list); $unstock_list = unserialize($deal_info['unstock']); $GLOBALS['tmpl']->assign("unstock_list", $unstock_list); //项目历史执行资料 $history_list = unserialize($deal_info['history']); $GLOBALS['tmpl']->assign("history_list", $history_list); $total_history_income = 0; $total_history_out = 0; $total_history = 0; foreach ($history_list as $key => $v) { $total_history_income += floatval($v["info"]["item_income"]); $total_history_out += floatval($v["info"]["item_out"]); $total_history = $total_history_income - $total_history_out; } $GLOBALS['tmpl']->assign("total_history_income", $total_history_income); $GLOBALS['tmpl']->assign("total_history_out", $total_history_out); $GLOBALS['tmpl']->assign("total_history", $total_history); //未来三年内计划 $plan_list = unserialize($deal_info['plan']); $GLOBALS['tmpl']->assign("plan_list", $plan_list); $total_plan_income = 0; $total_plan_out = 0; $total_plan = 0; foreach ($plan_list as $key => $v) { $total_plan_income += floatval($v["info"]["item_income"]); $total_plan_out += floatval($v["info"]["item_out"]); $total_plan = $total_plan_income - $total_plan_out; } $GLOBALS['tmpl']->assign("total_plan_income", $total_plan_income); $GLOBALS['tmpl']->assign("total_plan_out", $total_plan_out); $GLOBALS['tmpl']->assign("total_plan", $total_plan); //项目附件 $attach_list = unserialize($deal_info['attach']); $GLOBALS['tmpl']->assign("attach_list", $attach_list); //资质证明 $audit_data_list = unserialize($deal_info['audit_data']); $GLOBALS['tmpl']->assign("audit_data_list", $audit_data_list); //跟投、领投信息列表 get_investor_info($id, 1); $GLOBALS['tmpl']->assign('now', NOW_TIME); $GLOBALS['tmpl']->assign("cates", $cates); $GLOBALS['tmpl']->assign("deal_item", $deal_info); $GLOBALS['tmpl']->display("deal_investor_show.html"); } else { // //print_r($deal_info);exit; $GLOBALS['tmpl']->display("deal_details.html"); } }
public function project_follow() { if (app_conf("INVEST_STATUS") == 1) { showErr("股权众筹已经关闭"); } //get_mortgate(); $access = get_level_access($GLOBALS['user_info'], $deal_info); $GLOBALS['tmpl']->assign("access", $access); //获取项目的ID $id = intval($_REQUEST['deal_id']); $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . $id . " and is_delete = 0 and is_effect = 1"); $deal_info['deal_type'] = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate where id=" . $deal_info['cate_id']); $deal_info['login_time'] = $GLOBALS['db']->getOne("select login_time from " . DB_PREFIX . "user where id=" . $deal_info['user_id']); $deal_info['user_icon'] = $GLOBALS['user_level'][$deal_info['user_level']]['icon']; $deal_info['is_investor'] = $GLOBALS['db']->getOne("select is_investor from " . DB_PREFIX . "user where id=" . $deal_info['user_id']); $deal_info = cache_deal_extra($deal_info); // $comment_count = $GLOBALS['db']->getOne("select count(*) from ".DB_PREFIX."deal_comment where deal_id = ".$id." and log_id = 0 and status=1"); // $GLOBALS['tmpl']->assign('comment_count',$comment_count); $this->init_deal_page(@$deal_info); set_deal_status($deal_info); //股权众筹 $GLOBALS['tmpl']->assign("id", $id); $user_name = $GLOBALS['user_info']['user_name']; $GLOBALS['tmpl']->assign("user_name", $user_name); $cate = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate where id =" . $deal_info['cate_id']); $GLOBALS['tmpl']->assign("cate", $cate); //跟投、领投信息列表 get_investor_info($id, 1); $GLOBALS['tmpl']->display("project_follow.html"); }
function checkLogin($levels) { session_start(); $kt = explode(' ', $levels); if (!$_SESSION['logged_in']) { $access = FALSE; if (isset($_COOKIE['cookie_id'])) { //if we have a cookie $query = mysql_query('SELECT * FROM users WHERE id = "' . mysql_real_escape_string($_COOKIE['cookie_id']) . '"'); if (mysql_num_rows($query) == 1) { $row = mysql_fetch_assoc($query); } if ($_COOKIE['authenticate'] == md5(getIP() . $row['password'] . $_SERVER['USER_AGENT'])) { //we set the sessions so we don't repeat this step over and over again $_SESSION['user_id'] = $row['id']; $_SESSION['logged_in'] = TRUE; //now we check the level access, we might not have the permission if (in_array(get_level_access($_SESSION['user_id']), $kt)) { //we do?! horray! $access = TRUE; } } } } else { $access = FALSE; if (in_array(get_level_access($_SESSION['user_id']), $kt)) { $access = TRUE; } } if ($access == FALSE) { header("Location: " . $mURL . "login.php"); } }
public function activity() { $access = get_level_access($GLOBALS['user_info'], $deal_info); $GLOBALS['tmpl']->assign("access", $access); $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']); $deal_info['login_time'] = $GLOBALS['db']->getOne("select login_time from " . DB_PREFIX . "user where id=" . $deal_info['user_id']); $deal_info['user_icon'] = $GLOBALS['user_level'][$deal_info['user_level']]['icon']; $deal_info['is_investor'] = $GLOBALS['db']->getOne("select is_investor from " . DB_PREFIX . "user where id=" . $deal_info['user_id']); //权益交易相关参数 //程超 2015-11-13 $deal_info['deal_title'] = "【" . $deal_info['deal_code'] . "】" . $deal_info['name']; $deal_info["repaid_day"] = $GLOBALS['db']->getOne("select repaid_day from " . DB_PREFIX . "deal_item where deal_id = " . $deal_info["id"] . " limit 0,1"); //$trade_begin_time = intval($deal_info["end_time"])+24*3600; $delivery_begin_time = intval($deal_info["trade_end_time"]) + intval($deal_info["repaid_day"]) * 24 * 3600; $GLOBALS['tmpl']->assign("trade_begin_time", to_date($deal_info["trade_begin_time"], "Y年m月d日H时i分")); $GLOBALS['tmpl']->assign("delivery_begin_time", to_date($delivery_begin_time, "Y年m月d日H时i分")); //添加结束 $profit_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "profit where deal_id =" . $id); $ticket_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "ticket where deal_id =" . $id); $activity_count = $profit_count + $ticket_count; $GLOBALS['tmpl']->assign("activity_count", $activity_count); if (!$deal_info) { app_redirect(url("index")); } $deal_info = cache_deal_extra($deal_info); $this->init_deal_page($deal_info); $comment_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_comment where deal_id = " . $id . " and log_id = 0 and status=1"); $GLOBALS['tmpl']->assign('comment_count', $comment_count); $id = intval($_REQUEST['id']); $ticket_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "ticket where deal_id=" . $id); $GLOBALS['tmpl']->assign("ticket_list", $ticket_list); $profit_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "profit where deal_id =" . $id); $GLOBALS['tmpl']->assign("profit_list", $profit_list); $GLOBALS['tmpl']->display("deal_activity.html"); }