public function do_add_quota()
 {
     $data['user_id'] = $GLOBALS['user_info']['id'];
     $data['name'] = strim($_REQUEST['name']);
     $data['borrow_amount'] = floatval($_REQUEST['borrow_amount']);
     $data['description'] = replace_public(btrim($_REQUEST['description']));
     $data['description'] = valid_tag($data['description']);
     $data['is_effect'] = 1;
     $user_view_info = $GLOBALS['user_info']['view_info'];
     $user_view_info = unserialize($user_view_info);
     $new_view_info_arr = array();
     for ($i = 1; $i <= intval($_REQUEST['file_upload_count']); $i++) {
         $img_info = array();
         $img = replace_public(strim($_REQUEST['file_' . $i]));
         if ($img != "") {
             $img_info['name'] = strim($_REQUEST['file_name_' . $i]);
             $img_info['img'] = $img;
             $img_info['is_user'] = 1;
             $user_view_info[] = $img_info;
             $ss = $user_view_info;
             end($ss);
             $key = key($ss);
             $new_view_info_arr[$key] = $img_info;
         }
     }
     $datas['view_info'] = serialize($user_view_info);
     $GLOBALS['db']->autoExecute(DB_PREFIX . "user", $datas, "UPDATE", "id=" . $GLOBALS['user_info']['id']);
     $data['view_info'] = array();
     foreach ($_REQUEST['file_key'] as $k => $v) {
         if (isset($user_view_info[$v])) {
             $data['view_info'][$v] = $user_view_info[$v];
         }
     }
     foreach ($new_view_info_arr as $k => $v) {
         $data['view_info'][$k] = $v;
     }
     $data['view_info'] = serialize($data['view_info']);
     $data['create_time'] = TIME_UTC;
     //申请时间
     $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_quota_submit", $data);
     if ($GLOBALS['db']->insert_id()) {
         showSuccess('提交成功,等待管理员审核', 0, url("index", "uc_deal_quota"));
     } else {
         showErr('提交失败', 0, url("index", "uc_deal_quota"));
     }
 }
 public function update()
 {
     if (intval($_POST['id']) == 0) {
         showErr($GLOBALS['lang']['ERROR_TITLE'], 0, url("biz", "profile"));
         exit;
     }
     $id = intval($_POST['id']);
     $s_account_info = es_session::get("account_info");
     $location_ids = $s_account_info['location_ids'];
     $info = $GLOBALS['db']->getRow(" SELECT * FROM " . DB_PREFIX . "supplier_location WHERE id = " . intval($id) . " and id in (" . implode(",", $s_account_info['location_ids']) . ")");
     if (!$info) {
         showErr("门店不存在或者没有编辑该门店的权限");
     }
     $data['preview'] = str_replace(get_domain() . APP_ROOT, ".", addslashes(htmlspecialchars(trim($_POST['preview']))));
     $data['tags'] = addslashes(htmlspecialchars(trim($_POST['tags'])));
     $data['address'] = addslashes(htmlspecialchars(trim($_POST['address'])));
     $data['route'] = addslashes(htmlspecialchars(trim($_POST['route'])));
     $data['tel'] = addslashes(htmlspecialchars(trim($_POST['tel'])));
     $data['contact'] = addslashes(htmlspecialchars(trim($_POST['contact'])));
     $data['open_time'] = addslashes(htmlspecialchars(trim($_POST['open_time'])));
     $data['api_address'] = addslashes(htmlspecialchars(trim($_POST['api_address'])));
     $data['xpoint'] = $_POST['xpoint'];
     $data['ypoint'] = $_POST['ypoint'];
     $data['sms_content'] = addslashes(htmlspecialchars(trim($_POST['sms_content'])));
     $data['brief'] = addslashes(trim(replace_public($_POST['brief'])));
     $data['brief'] = valid_tag($data['brief']);
     $data['id'] = intval($_POST['id']);
     $data['seo_title'] = addslashes(htmlspecialchars(trim($_POST['seo_title'])));
     $data['seo_keyword'] = addslashes(htmlspecialchars(trim($_POST['seo_keyword'])));
     $data['seo_description'] = addslashes(htmlspecialchars(trim($_POST['seo_description'])));
     $rs = $GLOBALS['db']->autoExecute(DB_PREFIX . "supplier_location", $data, "UPDATE", " id = " . intval($_POST['id']));
     if ($rs) {
         //更新统计
         syn_supplier_locationcount($data);
         syn_supplier_location_match($data['id']);
         $cache_id = md5("store" . "view" . $data['id']);
         $GLOBALS['tmpl']->clear_cache('store_view.html', $cache_id);
         showSuccess($GLOBALS['lang']['SUPPLIER_MODIFY_SUCCESS'], 0, url("biz", "profile#modify", array("id" => intval($_POST['id']))));
     }
 }
 function savedeal()
 {
     $is_ajax = intval($_REQUEST['is_ajax']);
     if (!$GLOBALS['user_info']) {
         showErr($GLOBALS['lang']['PLEASE_LOGIN_FIRST'], $is_ajax);
     }
     $t = trim($_REQUEST['t']);
     if (!in_array($t, array("save", "publish"))) {
         showErr($GLOBALS['lang']['ERROR_TITLE'], $is_ajax);
     }
     if ($t == "save") {
         $data['is_delete'] = 2;
     } else {
         $data['is_delete'] = 0;
     }
     $data['name'] = strim($_REQUEST['borrowtitle']);
     if (empty($data['name'])) {
         showErr("请输入借款标题", $is_ajax);
     }
     $data['publish_wait'] = 1;
     $icon_type = strim($_REQUEST['imgtype']);
     if ($icon_type == "") {
         showErr("请选择借款图片类型", $is_ajax);
     }
     $icon_type_arr = array('upload' => 1, 'userImg' => 2, 'systemImg' => 3);
     $data['icon_type'] = $icon_type_arr[$icon_type];
     if (intval($data['icon_type']) == 0) {
         showErr("请选择借款图片类型", $is_ajax);
     }
     switch ($data['icon_type']) {
         case 1:
             if (strim($_REQUEST['icon']) == '') {
                 showErr("请上传图片", $is_ajax);
             } else {
                 $data['icon'] = replace_public(strim($_REQUEST['icon']));
             }
             break;
         case 2:
             $data['icon'] = replace_public(get_user_avatar($GLOBALS['user_info']['id'], 'big'));
             break;
         case 3:
             if (intval($_REQUEST['systemimgpath']) == 0) {
                 showErr("请选择系统图片", $is_ajax);
             } else {
                 $data['icon'] = $GLOBALS['db']->getOne("SELECT icon FROM " . DB_PREFIX . "deal_loan_type WHERE id=" . intval($_REQUEST['systemimgpath']));
             }
             break;
     }
     $data['type_id'] = intval($_REQUEST['borrowtype']);
     if ($data['type_id'] == 0) {
         showErr("请选择借款用途", $is_ajax);
     }
     $data['borrow_amount'] = floatval($_REQUEST['borrowamount']);
     if ($data['borrow_amount'] < (int) trim(app_conf('MIN_BORROW_QUOTA')) || $data['borrow_amount'] > (int) trim(app_conf('MAX_BORROW_QUOTA')) || $data['borrow_amount'] % 50 != 0) {
         showErr("请正确输入借款金额", $is_ajax);
     }
     //判断是否需要额度
     if ($GLOBALS['db']->getOne("SELECT is_quota FROM " . DB_PREFIX . "deal_loan_type WHERE id=" . $data['type_id']) == 1) {
         if (intval($GLOBALS['user_info']['quota']) != 0) {
             $can_use_quota = get_can_use_quota($GLOBALS['user_info']['id']);
             if ($data['borrow_amount'] > intval($can_use_quota)) {
                 showErr("输入借款的借款金额超过您的可用额度<br>您当前可用额度为:" . $can_use_quota, $is_ajax);
             }
         }
     }
     $data['repay_time'] = intval($_REQUEST['repaytime']);
     if ($data['repay_time'] == 0) {
         showErr("借款期限", $is_ajax);
     }
     $data['rate'] = floatval($_REQUEST['apr']);
     $data['repay_time_type'] = intval($_REQUEST['repaytime_type']);
     $level_list = load_auto_cache("level");
     $min_rate = 0;
     $max_rate = 0;
     $is_rate_lock = false;
     foreach ($level_list['repaytime_list'][$GLOBALS['user_info']['level_id']] as $kkk => $vvv) {
         if ($data['repay_time_type'] == 1) {
             if ($data['repay_time'] == intval($vvv[0]) && $vvv[1] == $data['repay_time_type']) {
                 $min_rate = $vvv[2];
                 $max_rate = $vvv[3];
             }
         } else {
             if ($data['repay_time'] <= intval($vvv[0]) && intval($vvv[1]) == $data['repay_time_type'] && $is_rate_lock == false) {
                 $min_rate = $vvv[2];
                 $max_rate = $vvv[3];
                 $is_rate_lock = true;
             } elseif ($data['repay_time'] > intval($vvv[0]) && intval($vvv[1]) == $data['repay_time_type']) {
                 $min_rate = $vvv[2];
                 $max_rate = $vvv[3];
             }
         }
     }
     if (floatval($data['rate']) <= 0 || floatval($data['rate']) > $max_rate || floatval($data['rate']) < $min_rate) {
         showErr("请正确输入借款利率", $is_ajax);
     }
     $data['enddate'] = intval($_REQUEST['enddate']);
     $data['description'] = replace_public(btrim($_REQUEST['borrowdesc']));
     $data['description'] = valid_tag($data['description']);
     if (trim($data['description']) == '') {
         showErr("请输入项目描述", $is_ajax);
     }
     $user_view_info = $GLOBALS['user_info']['view_info'];
     $user_view_info = unserialize($user_view_info);
     $new_view_info_arr = array();
     for ($i = 1; $i <= intval($_REQUEST['file_upload_count']); $i++) {
         $img_info = array();
         $img = replace_public(strim($_REQUEST['file_' . $i]));
         if ($img != "") {
             $img_info['name'] = strim($_REQUEST['file_name_' . $i]);
             $img_info['img'] = $img;
             $img_info['is_user'] = 1;
             $user_view_info[] = $img_info;
             $ss = $user_view_info;
             end($ss);
             $key = key($ss);
             $new_view_info_arr[$key] = $img_info;
         }
     }
     $datas['view_info'] = serialize($user_view_info);
     $GLOBALS['db']->autoExecute(DB_PREFIX . "user", $datas, "UPDATE", "id=" . $GLOBALS['user_info']['id']);
     $data['view_info'] = array();
     foreach ($_REQUEST['file_key'] as $k => $v) {
         if (isset($user_view_info[$v])) {
             $data['view_info'][$v] = $user_view_info[$v];
         }
     }
     foreach ($new_view_info_arr as $k => $v) {
         $data['view_info'][$k] = $v;
     }
     $data['view_info'] = serialize($data['view_info']);
     //资金运转
     $data['remark_1'] = strim(replace_public($_REQUEST['remark_1']));
     $data['remark_1'] = valid_tag($data['remark_1']);
     //风险控制措施
     $data['remark_2'] = strim(replace_public($_REQUEST['remark_2']));
     $data['remark_2'] = valid_tag($data['remark_2']);
     //政策及市场分析
     $data['remark_3'] = strim(replace_public($_REQUEST['remark_3']));
     $data['remark_3'] = valid_tag($data['remark_3']);
     //企业背景
     $data['remark_4'] = strim(replace_public($_REQUEST['remark_4']));
     $data['remark_4'] = valid_tag($data['remark_4']);
     //企业信息
     $data['remark_5'] = strim(replace_public($_REQUEST['remark_5']));
     $data['remark_5'] = valid_tag($data['remark_5']);
     //项目相关资料
     $data['remark_6'] = strim(replace_public($_REQUEST['remark_6']));
     $data['remark_6'] = valid_tag($data['remark_6']);
     //$data['voffice'] = intval($_REQUEST['voffice']);
     //$data['vposition'] = intval($_REQUEST['vposition']);
     $data['voffice'] = 1;
     $data['vposition'] = 1;
     $data['is_effect'] = 1;
     $data['deal_status'] = 0;
     $data['agency_id'] = intval($_REQUEST['agency_id']);
     $data['agency_status'] = 1;
     $data['warrant'] = intval($_REQUEST['warrant']);
     $data['guarantor_margin_amt'] = floatval($_REQUEST['guarantor_margin_amt']);
     $data['guarantor_pro_fit_amt'] = floatval($_REQUEST['guarantor_pro_fit_amt']);
     $data['user_id'] = intval($GLOBALS['user_info']['id']);
     $data['loantype'] = intval($_REQUEST['loantype']);
     if ($data['repay_time_type'] == 0) {
         $data['loantype'] = 2;
     }
     //当为天的时候
     if ($data['repay_time_type'] == 0) {
         $true_repay_time = 1;
     } else {
         $true_repay_time = $data['repay_time'];
     }
     //本金担保
     if ($data['warrant'] == 1) {
         $data['guarantor_amt'] = $data['borrow_amount'];
     } elseif ($data['warrant'] == 2) {
         //等额本息
         if ($data['loantype'] == 0) {
             $data['guarantor_amt'] = pl_it_formula($data['borrow_amount'], $data['rate'] / 12 / 100, $true_repay_time) * $true_repay_time;
         } elseif ($data['loantype'] == 1) {
             $data['guarantor_amt'] = av_it_formula($data['borrow_amount'], $data['rate'] / 12 / 100) * $true_repay_time + $data['borrow_amount'];
         } elseif ($data['loantype'] == 2) {
             $data['guarantor_amt'] = $data['borrow_amount'] * $data['rate'] / 12 / 100 * $true_repay_time + $data['borrow_amount'];
         }
     }
     $data['create_time'] = TIME_UTC;
     $module = "INSERT";
     $jumpurl = url("index", "borrow#steptwo");
     $condition = "";
     $deal_id = $GLOBALS['db']->getOne("SELECT id FROM " . DB_PREFIX . "deal WHERE ((is_delete=2 or is_delete=3) or (is_delete=0 and publish_wait=1)) AND user_id=" . $GLOBALS['user_info']['id']);
     if ($deal_id > 0) {
         $module = "UPDATE";
         if ($t == "save") {
             $jumpurl = url("index", "borrow#stepone");
         }
         $condition = "id = {$deal_id}";
     } else {
         if ($t == "save") {
             $jumpurl = url("index", "borrow#stepone");
         }
     }
     $GLOBALS['db']->autoExecute(DB_PREFIX . "deal", $data, $module, $condition);
     if ($module == "INSERT") {
         $deal_id = $GLOBALS['db']->insert_id();
     }
     require_once APP_ROOT_PATH . 'app/Lib/deal.php';
     $deal = get_deal($deal_id);
     //发送验证通知
     if ($t != "save" && trim(app_conf('CUSTOM_SERVICE')) != '' && ($GLOBALS['user_info']['idcardpassed'] == 0 || $GLOBALS['user_info']['incomepassed'] == 0 || $GLOBALS['user_info']['creditpassed'] == 0 || $GLOBALS['user_info']['workpassed'] == 0)) {
         $ulist = explode(",", trim(app_conf('CUSTOM_SERVICE')));
         $ulist = array_filter($ulist);
         if ($ulist) {
             $uuid = $ulist[array_rand($ulist)];
             if ($uuid > 0) {
                 $content = app_conf("SHOP_TITLE") . "用户您好,请尽快上传必要信用认证材料(包括身份证认证、工作认证、收入认证、信用报告认证)。另外,多上传一些可选信用认证,有助于您提高借款额度,也有利于出借人更多的了解您的情况,以便让您更快的筹集到所需的资金。请您点击'我要贷款',之后点击相应的审核项目,进入后,可先阅读该项信用认证所需材料及要求,然后按要求上传资料即可。 如果您有任何问题请您拨打客服电话 " . app_conf('SHOP_TEL') . " 或给客服邮箱发邮件 " . app_conf("REPLY_ADDRESS") . " 我们会及时给您回复。";
                 require_once APP_ROOT_PATH . 'app/Lib/message.php';
                 //添加留言
                 $message['title'] = $content;
                 $message['content'] = htmlspecialchars(addslashes(valid_str($content)));
                 $message['title'] = valid_str($message['title']);
                 $message['create_time'] = TIME_UTC;
                 $message['rel_table'] = "deal";
                 $message['rel_id'] = $deal_id;
                 $message['user_id'] = $uuid;
                 $message['is_effect'] = 1;
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "message", $message);
                 //添加到动态
                 insert_topic("message", $message['rel_id'], $message['user_id'], get_user_name($message['user_id'], false), $GLOBALS['user_info']['id']);
                 //自己给自己留言不执行操作
                 if ($deal['user_id'] != $message['user_id']) {
                     $msg_conf = get_user_msg_conf($deal['user_id']);
                     //站内信
                     if ($msg_conf['sms_asked'] == 1) {
                         $notices['shop_title'] = app_conf("SHOP_TITLE");
                         $notices['shop_tel'] = app_conf('SHOP_TEL');
                         $notices['shop_address'] = app_conf("REPLY_ADDRESS");
                         /*{$notice.shop_title}用户您好,请尽快上传必要信用认证材料(包括身份证认证、工作认证、收入认证、信用报告认证)。另外,多上传一些可选信用认证,有助于您提高借款额度,也有利于出借人更多的了解您的情况,以便让您更快的筹集到所需的资金。请您点击'我要贷款',之后点击相应的审核项目,进入后,可先阅读该项信用认证所需材料及要求,然后按要求上传资料即可。 如果您有任何问题请您拨打客服电话{$notice.shop_tel}或给客服邮箱发邮件{$notice.shop_address}我们会及时给您回复。*/
                         $notices['url'] = "“<a href=\"" . $deal_info['url'] . "\">" . $deal_info['name'] . "</a>”";
                         $notices['user_name'] = get_user_name($message['user_id']);
                         $notices['money'] = $user_load_data['true_repay_money'] + $user_load_data['impose_money'];
                         $tmpl_content = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "msg_template where name = 'TPL_WORDS_MSG'", false);
                         $GLOBALS['tmpl']->assign("notice", $notices);
                         $contents = $GLOBALS['tmpl']->fetch("str:" . $tmpl_content['content']);
                         send_user_msg("", $contents, 0, $deal['user_id'], TIME_UTC, 0, true, 13, $message['rel_id']);
                     }
                     //邮件
                     if ($msg_conf['mail_asked'] == 1 && app_conf('MAIL_ON') == 1) {
                         $tmpl = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "msg_template where name = 'TPL_MAIL_DEAL_MSG'");
                         $tmpl_content = $tmpl['content'];
                         $notice['user_name'] = $GLOBALS['user_info']['user_name'];
                         $notice['msg_user_name'] = get_user_name($message['user_id'], false);
                         $notice['deal_name'] = $deal['name'];
                         $notice['deal_url'] = SITE_DOMAIN . url("index", "deal", array("id" => $deal['id']));
                         $notice['message'] = $message['content'];
                         $notice['site_name'] = app_conf("SHOP_TITLE");
                         $notice['site_url'] = SITE_DOMAIN . APP_ROOT;
                         $notice['help_url'] = SITE_DOMAIN . url("index", "helpcenter");
                         $GLOBALS['tmpl']->assign("notice", $notice);
                         $msg = $GLOBALS['tmpl']->fetch("str:" . $tmpl_content);
                         $msg_data['dest'] = $GLOBALS['user_info']['email'];
                         $msg_data['send_type'] = 1;
                         $msg_data['title'] = get_user_name($message['user_id'], false) . "给您的标留言!";
                         $msg_data['content'] = addslashes($msg);
                         $msg_data['send_time'] = 0;
                         $msg_data['is_send'] = 0;
                         $msg_data['create_time'] = TIME_UTC;
                         $msg_data['user_id'] = $GLOBALS['user_info']['id'];
                         $msg_data['is_html'] = $tmpl['is_html'];
                         $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_msg_list", $msg_data);
                         //插入
                     }
                 }
             }
         }
     }
     if ($is_ajax == 1) {
         showSuccess($GLOBALS['lang']['SUCCESS_TITLE'], $is_ajax, $jumpurl);
     } else {
         app_redirect($jumpurl);
     }
 }
 public function save()
 {
     $ajax = intval($_REQUEST['ajax']);
     if (!check_ipop_limit(get_client_ip(), "project_save", 5)) {
         showErr("提交太频繁", $ajax, "");
     }
     if (!$GLOBALS['user_info']) {
         showErr("", $ajax, url_wap("user#login"));
     }
     $id = intval($_REQUEST['id']);
     $item = $GLOBALS['db']->getRow("select * from  " . DB_PREFIX . "deal where id={$id} and user_id=" . $GLOBALS['user_info']['id']);
     if (!$item && $id > 0) {
         showErr("项目不存在", $ajax, "");
     }
     $is_edit = $item['is_edit'];
     $is_effect = $item['is_effect'];
     if ($id > 0 && $is_effect == 1) {
         showErr("项目已提交,不能更改", $ajax, "");
     }
     $data['name'] = strim($_REQUEST['name']);
     if ($data['name'] == "") {
         showErr("请填写项目名称", $ajax, "");
     }
     if (msubstr($data['name'], 0, 25) != $data['name']) {
         showErr("项目名称不超过25个字", $ajax, "");
     }
     $data['cate_id'] = intval($_REQUEST['cate_id']);
     if ($data['cate_id'] == 0) {
         showErr("请选择项目分类", $ajax, "");
     }
     $data['province'] = strim($_REQUEST['province']);
     if ($data['province'] == '') {
         showErr("请选择省份", $ajax, "");
     }
     $data['city'] = strim($_REQUEST['city']);
     if ($data['city'] == '') {
         showErr("请选择城市", $ajax, "");
     }
     $data['brief'] = strim($_REQUEST['brief']);
     $data['image'] = replace_public(addslashes(trim($_REQUEST['image'])));
     if ($data['image'] == "") {
         showErr("上传封面图片", $ajax, "");
     }
     require_once APP_ROOT_PATH . "system/libs/words.php";
     $data['tags'] = implode(" ", words::segment($data['name']));
     $data['description'] = replace_public(addslashes(trim(valid_tag($_REQUEST['description']))));
     //
     $data['vedio'] = strim($_REQUEST['vedio']);
     if ($data['vedio'] != "") {
         require_once APP_ROOT_PATH . "system/utils/vedio.php";
         $vedio = fetch_vedio_url($data['vedio']);
         if ($vedio != "") {
             $data['source_vedio'] = $vedio;
         } else {
             showErr("非法的视频地址", $ajax, "");
         }
     }
     $data['limit_price'] = floatval($_REQUEST['limit_price']);
     if ($data['limit_price'] <= 0) {
         showErr("请输入正确的目标金额", $ajax, "");
     }
     $data['deal_days'] = floatval($_REQUEST['deal_days']);
     if ($data['deal_days'] <= 0) {
         showErr("请输入正确的上线天数", $ajax, "");
     }
     $data['is_edit'] = 1;
     if ($id > 0) {
         $savenext = intval($_REQUEST['savenext']);
         $GLOBALS['db']->autoExecute(DB_PREFIX . "deal", $data, "UPDATE", "id=" . $id, "SILENT");
         //追加faq
         $GLOBALS['db']->query("delete from " . DB_PREFIX . "deal_faq where deal_id = " . $id);
         $sort = 1;
         foreach ($_REQUEST['question'] as $kk => $question_item) {
             if (strim($_REQUEST['question'][$kk]) != "" && strim($_REQUEST['answer'][$kk]) != "" && strim($_REQUEST['question'][$kk]) != "请输入问题" && strim($_REQUEST['answer'][$kk]) != "请输入答案") {
                 $faq_item['deal_id'] = $id;
                 $faq_item['question'] = strim($_REQUEST['question'][$kk]);
                 $faq_item['answer'] = strim($_REQUEST['answer'][$kk]);
                 $faq_item['sort'] = $sort;
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_faq", $faq_item);
                 $sort++;
             }
         }
         $GLOBALS['db']->query("update " . DB_PREFIX . "deal set deal_extra_cache = '' where id = " . $id);
         if ($savenext == 0) {
             showSuccess($id, $ajax, "");
         } else {
             showSuccess("", $ajax, url_wap("project#add_item", array("id" => $id)));
         }
     } else {
         $data['user_id'] = intval($GLOBALS['user_info']['id']);
         $data['user_name'] = $GLOBALS['user_info']['user_name'];
         $data['create_time'] = get_gmtime();
         $savenext = intval($_REQUEST['savenext']);
         $GLOBALS['db']->autoExecute(DB_PREFIX . "deal", $data, "INSERT", "", "SILENT");
         $data_id = intval($GLOBALS['db']->insert_id());
         if ($data_id == 0) {
             showErr("保存失败,请联系管理员", $ajax, "");
         } else {
             es_session::delete("deal_image");
             //追加faq
             $sort = 1;
             foreach ($_REQUEST['question'] as $kk => $question_item) {
                 if (strim($_REQUEST['question'][$kk]) != "" && strim($_REQUEST['answer'][$kk]) != "" && strim($_REQUEST['question'][$kk]) != "请输入问题" && strim($_REQUEST['answer'][$kk]) != "请输入答案") {
                     $faq_item['deal_id'] = $data_id;
                     $faq_item['question'] = strim($_REQUEST['question'][$kk]);
                     $faq_item['answer'] = strim($_REQUEST['answer'][$kk]);
                     $faq_item['sort'] = $sort;
                     $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_faq", $faq_item);
                     $sort++;
                 }
             }
             if ($savenext == 0) {
                 showSuccess($data_id, $ajax, "");
             } else {
                 showSuccess("", $ajax, url_wap("project#add_item", array("id" => $data_id)));
             }
         }
     }
 }
 public function submit_deal_coin()
 {
     $ajax = intval($_REQUEST['ajax']);
     if (!check_ipop_limit(get_client_ip(), "project_submit_deal_coin", 5)) {
         showErr("提交太频繁", $ajax, "");
     }
     if (!$GLOBALS['user_info']) {
         showErr("", $ajax, url("user#login"));
     }
     $id = intval($_REQUEST['id']);
     $item = $GLOBALS['db']->getRow("select * from  " . DB_PREFIX . "deal where id={$id} and user_id=" . $GLOBALS['user_info']['id']);
     if (!$item && $id > 0) {
         showErr("项目不存在", $ajax, "");
     }
     $is_edit = $item['is_edit'];
     $is_effect = $item['is_effect'];
     if ($id > 0 && $is_effect == 1) {
         showErr("项目已提交,不能更改", $ajax, "");
     }
     $data['name'] = strim($_REQUEST['name']);
     if ($data['name'] == "") {
         showErr("请填写项目名称", $ajax, "");
     }
     if (msubstr($data['name'], 0, 25) != $data['name']) {
         showErr("项目名称不超过25个字", $ajax, "");
     }
     $data['province'] = strim($_REQUEST['province']);
     if ($data['province'] == '') {
         showErr("请选择省份", $ajax, "");
     }
     $data['city'] = strim($_REQUEST['city']);
     if ($data['city'] == '') {
         showErr("请选择城市", $ajax, "");
     }
     $data['brief'] = strim($_REQUEST['brief']);
     $data['image'] = replace_public(addslashes(trim($_REQUEST['image'])));
     if ($data['image'] == "") {
         showErr("上传封面图片", $ajax, "");
     }
     require_once APP_ROOT_PATH . "system/libs/words.php";
     $data['tags'] = implode(" ", words::segment($data['name']));
     $data['description'] = replace_public(addslashes(trim(valid_tag($_REQUEST['description']))));
     $data['vedio'] = strim($_REQUEST['vedio']);
     if ($data['vedio'] != "") {
         require_once APP_ROOT_PATH . "system/utils/vedio.php";
         $vedio = fetch_vedio_url($data['vedio']);
         if ($vedio != "") {
             $data['source_vedio'] = $vedio;
         } else {
             showErr("非法的视频地址", $ajax, "");
         }
     }
     $data['limit_price'] = floatval($_REQUEST['limit_price']);
     if ($data['limit_price'] <= 0) {
         showErr("请输入正确的目标金额", $ajax, "");
     }
     $data['deal_days'] = floatval($_REQUEST['deal_days']);
     if ($data['deal_days'] <= 0) {
         showErr("请输入正确的上线天数", $ajax, "");
     }
     $data['is_edit'] = 0;
     $data['is_effect'] = 0;
     $data['type'] = 4;
     $data['user_id'] = intval($GLOBALS['user_info']['id']);
     $data['user_name'] = $GLOBALS['user_info']['user_name'];
     $data['create_time'] = get_gmtime();
     $savenext = intval($_REQUEST['savenext']);
     $GLOBALS['db']->autoExecute(DB_PREFIX . "deal", $data, "INSERT", "", "SILENT");
     $data_id = intval($GLOBALS['db']->insert_id());
     if ($data_id == 0) {
         showErr("保存失败,请联系管理员", $ajax, "");
     } else {
         //添加deal_code
         $short_name = $GLOBALS['db']->getOne("select short_name from " . DB_PREFIX . "deal_cate where id = " . $data["cate_id"]);
         $code = $short_name . "" . $data_id;
         $zero_num = 8 - strlen($code);
         $deal_code = $short_name;
         for ($i = 0; $i < $zero_num; $i++) {
             $deal_code = $deal_code . "0";
         }
         $deal_code = $deal_code . "" . $data_id;
         $data["deal_code"] = $deal_code;
         $GLOBALS['db']->autoExecute(DB_PREFIX . "deal", $data, "UPDATE", "id=" . $data_id, "SILENT");
         es_session::delete("deal_image");
         //追加faq
         $sort = 1;
         foreach ($_REQUEST['question'] as $kk => $question_item) {
             if (strim($_REQUEST['question'][$kk]) != "" && strim($_REQUEST['answer'][$kk]) != "" && strim($_REQUEST['question'][$kk]) != "请输入问题" && strim($_REQUEST['answer'][$kk]) != "请输入答案") {
                 $faq_item['deal_id'] = $data_id;
                 $faq_item['question'] = strim($_REQUEST['question'][$kk]);
                 $faq_item['answer'] = strim($_REQUEST['answer'][$kk]);
                 $faq_item['sort'] = $sort;
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_faq", $faq_item);
                 $sort++;
             }
         }
         $GLOBALS['msg']->manage_msg($GLOBALS['msg']::MSG_ZC_STATUS, 'admin', array('deal_id' => $data_id, 'deal_status' => $GLOBALS['msg']::CROW_EXAMINE));
         showSuccess("提交成功,等待管理员审核!", $ajax, url("account#project"));
     }
 }
 public function update()
 {
     $adm_session = session('admin_info');
     if ($adm_session == '') {
         //尚未登录
         $this->error('您尚未登陆,正在跳转到登陆页面。。。', __APP__ . '/Home/Admin/login');
     }
     $data = M("Goods")->create();
     //开始验证有效性
     //$this->assign("jumpUrl",u(MODULE_NAME."/add"));
     if (!check_empty($data['name'])) {
         $this->error("请输入商品名称");
     }
     if (!check_empty($data['total_price'])) {
         $this->error("商品价格不能为空");
     }
     if (!check_empty($data['image'])) {
         $this->error("请上传商品图片");
     }
     if (!check_empty($data['unit_price'])) {
         $this->error("每份价格不能为空");
     }
     if (!check_empty($data['number'])) {
         $this->error("请输入商品份数");
     }
     if (!check_empty($data['description'])) {
         $this->error("请输入商品图文详情");
     }
     $data['description'] = addslashes(trim(valid_tag($data['description'])));
     $goods_id = $_REQUEST['id'];
     $list = M("Goods")->where("id={$goods_id}")->save($data);
     // 根据条件更新记录
     if (false !== $list) {
         //成功提示
         $this->success('商品修改成功', __APP__ . '/Home/Index/main');
     } else {
         //错误提示
         $this->error('商品修改失败');
     }
 }
 public function submit_modify()
 {
     $s_account_info = es_session::get("account_info");
     $account_id = intval($s_account_info['id']);
     $id = intval($_REQUEST['id']);
     $data = $GLOBALS['db']->getRow("select d.* from " . DB_PREFIX . "deal as d left join " . DB_PREFIX . "deal_location_link as l on l.deal_id = d.id where d.id = " . $id . " and publish_wait = 1 and l.location_id in (" . implode(",", $s_account_info['location_ids']) . ")");
     if (!$data) {
         showErr("产品不存在或者没有编辑该产品的权限");
     }
     $data['name'] = addslashes(htmlspecialchars(trim($_REQUEST['name'])));
     $data['sub_name'] = addslashes(htmlspecialchars(trim($_REQUEST['sub_name'])));
     $data['origin_price'] = doubleval($_REQUEST['origin_price']);
     $data['balance_price'] = doubleval($_REQUEST['balance_price']);
     $data['max_bought'] = intval($_REQUEST['max_bought']);
     $data['brief'] = addslashes(htmlspecialchars(trim($_REQUEST['brief'])));
     $data['is_shop'] = intval($_REQUEST['is_shop']);
     $data['any_refund'] = intval($_REQUEST['any_refund']);
     $data['expire_refund'] = intval($_REQUEST['expire_refund']);
     $data['auto_order'] = intval($_REQUEST['auto_order']);
     if ($data['is_shop'] == 1) {
         $data['is_coupon'] = 0;
         $data['shop_cate_id'] = intval($_REQUEST['shop_cate_id']);
         $data['cate_id'] = 0;
     } else {
         $data['is_coupon'] = 1;
         $data['shop_cate_id'] = 0;
         $data['cate_id'] = intval($_REQUEST['cate_id']);
     }
     $data['city_id'] = intval($_REQUEST['city_id']);
     $data['icon'] = addslashes(htmlspecialchars(trim(replace_public($_REQUEST['icon']))));
     $data['img'] = addslashes(htmlspecialchars(trim(replace_public($_REQUEST['img']))));
     $data['description'] = trim(replace_public($_REQUEST['descript']));
     $data['description'] = valid_tag($data['description']);
     $data['account_id'] = intval($account_id);
     $data['publish_wait'] = 1;
     $data['create_time'] = get_gmtime();
     $data['is_effect'] = 0;
     $data['supplier_id'] = intval($s_account_info['supplier_id']);
     $data['begin_time'] = trim($_REQUEST['begin_time']) == '' ? 0 : to_timespan($_REQUEST['begin_time']);
     $data['end_time'] = trim($_REQUEST['end_time']) == '' ? 0 : to_timespan($_REQUEST['end_time']);
     $GLOBALS['db']->autoExecute(DB_PREFIX . "deal", $data, "UPDATE", "id=" . $data['id']);
     $deal_id = $data['id'];
     if ($deal_id > 0) {
         $GLOBALS['db']->query("delete from " . DB_PREFIX . "deal_gallery where deal_id = " . $deal_id . " and sort < 6");
         if ($_REQUEST['img0'] != '') {
             $deal_gallery_0 = array("img" => addslashes(htmlspecialchars(trim(replace_public($_REQUEST['img0'])))), "deal_id" => $deal_id, "sort" => 0);
             $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_gallery", $deal_gallery_0);
         }
         if ($_REQUEST['img1'] != '') {
             $deal_gallery_1 = array("img" => addslashes(htmlspecialchars(trim(replace_public($_REQUEST['img1'])))), "deal_id" => $deal_id, "sort" => 1);
             $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_gallery", $deal_gallery_1);
         }
         if ($_REQUEST['img2'] != '') {
             $deal_gallery_2 = array("img" => addslashes(htmlspecialchars(trim(replace_public($_REQUEST['img2'])))), "deal_id" => $deal_id, "sort" => 2);
             $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_gallery", $deal_gallery_2);
         }
         if ($_REQUEST['img3'] != '') {
             $deal_gallery_3 = array("img" => addslashes(htmlspecialchars(trim(replace_public($_REQUEST['img3'])))), "deal_id" => $deal_id, "sort" => 3);
             $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_gallery", $deal_gallery_3);
         }
         if ($_REQUEST['img4'] != '') {
             $deal_gallery_4 = array("img" => addslashes(htmlspecialchars(trim(replace_public($_REQUEST['img4'])))), "deal_id" => $deal_id, "sort" => 4);
             $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_gallery", $deal_gallery_4);
         }
         if ($_REQUEST['img5'] != '') {
             $deal_gallery_5 = array("img" => addslashes(htmlspecialchars(trim(replace_public($_REQUEST['img5'])))), "deal_id" => $deal_id, "sort" => 5);
             $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_gallery", $deal_gallery_5);
         }
         $GLOBALS['db']->query("delete from " . DB_PREFIX . "deal_cate_type_deal_link where deal_id = " . $deal_id);
         foreach ($_REQUEST['deal_cate_type_id'] as $deal_cate_type_id) {
             if ($deal_cate_type_id > 0) {
                 $deal_cate_type_link = array("deal_id" => $deal_id, "deal_cate_type_id" => intval($deal_cate_type_id));
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_cate_type_deal_link", $deal_cate_type_link);
             }
         }
         showSuccess("提交成功,请等待管理员审核");
     } else {
         showErr("发布失败");
     }
 }
 public function submit_modify()
 {
     $s_account_info = es_session::get("account_info");
     $account_id = intval($s_account_info['id']);
     $id = intval($_REQUEST['id']);
     $data = $GLOBALS['db']->getRow("select e.* from " . DB_PREFIX . "event as e left join " . DB_PREFIX . "event_location_link as l on l.event_id = e.id where e.id = " . $id . " and e.publish_wait = 1 and l.location_id in (" . implode(",", $s_account_info['location_ids']) . ")");
     if (!$data) {
         showErr("活动不存在或者没有编辑该活动的权限");
     }
     $event_id = $data['id'] = $id;
     $data['name'] = addslashes(htmlspecialchars(trim($_REQUEST['name'])));
     $data['icon'] = addslashes(htmlspecialchars(replace_public(trim($_REQUEST['icon']))));
     $data['event_begin_time'] = trim($_REQUEST['event_begin_time']) == '' ? 0 : to_timespan($_REQUEST['event_begin_time']);
     $data['event_end_time'] = trim($_REQUEST['event_end_time']) == '' ? 0 : to_timespan($_REQUEST['event_end_time']);
     $data['submit_begin_time'] = trim($_REQUEST['submit_begin_time']) == '' ? 0 : to_timespan($_REQUEST['submit_begin_time']);
     $data['submit_end_time'] = trim($_REQUEST['submit_end_time']) == '' ? 0 : to_timespan($_REQUEST['submit_end_time']);
     $data['city_id'] = intval($_REQUEST['city_id']);
     $data['cate_id'] = intval($_REQUEST['cate_id']);
     $data['address'] = addslashes(htmlspecialchars(trim($_REQUEST['address'])));
     $data['brief'] = addslashes(htmlspecialchars(trim($_REQUEST['brief'])));
     $data['content'] = addslashes(trim(replace_public($_REQUEST['content'])));
     $data['content'] = valid_tag($data['content']);
     $data['user_id'] = intval($account_id);
     $data['publish_wait'] = 1;
     $data['is_effect'] = 0;
     $data['supplier_id'] = intval($s_account_info['supplier_id']);
     $data['xpoint'] = doubleval($_REQUEST['xpoint']);
     $data['ypoint'] = doubleval($_REQUEST['ypoint']);
     $GLOBALS['db']->autoExecute(DB_PREFIX . "event", $data, "UPDATE", "id=" . $data['id']);
     if ($event_id > 0) {
         $GLOBALS['db']->query("delete from " . DB_PREFIX . "event_field where event_id = " . $event_id);
         foreach ($_REQUEST['field_id'] as $k => $field_id) {
             $event_field = array();
             $event_field['event_id'] = $event_id;
             $event_field['field_show_name'] = addslashes(htmlspecialchars($_REQUEST['field_show_name'][$k]));
             $event_field['field_type'] = addslashes(htmlspecialchars($_REQUEST['field_type'][$k]));
             $event_field['value_scope'] = addslashes(htmlspecialchars($_REQUEST['value_scope'][$k]));
             $event_field['sort'] = $k;
             $GLOBALS['db']->autoExecute(DB_PREFIX . "event_field", $event_field);
         }
         showSuccess("提交成功,请等待管理员审核");
     } else {
         showErr("发布失败");
     }
 }
 public function submit_modify()
 {
     $s_account_info = es_session::get("account_info");
     $account_id = intval($s_account_info['id']);
     $id = intval($_REQUEST['id']);
     $data = $GLOBALS['db']->getRow("select y.* from " . DB_PREFIX . "youhui as y left join " . DB_PREFIX . "youhui_location_link as l on l.youhui_id = y.id where y.id = " . $id . " and y.publish_wait = 1 and l.location_id in (" . implode(",", $s_account_info['location_ids']) . ")");
     if (!$data) {
         showErr("优惠不存在或者没有编辑该优惠的权限");
     }
     $data['id'] = intval($_REQUEST['id']);
     $data['name'] = addslashes(htmlspecialchars(trim($_REQUEST['name'])));
     $data['total_num'] = addslashes(htmlspecialchars(trim($_REQUEST['total_num'])));
     $data['send_type'] = intval($_REQUEST['send_type']);
     if ($data['send_type'] > 0) {
         $data['is_print'] = 0;
     } else {
         $data['is_print'] = 1;
     }
     $data['is_sms'] = 1;
     $data['sms_content'] = addslashes(htmlspecialchars(trim($_REQUEST['sms_content'])));
     $data['begin_time'] = trim($_REQUEST['begin_time']) == '' ? 0 : to_timespan($_REQUEST['begin_time']);
     $data['end_time'] = trim($_REQUEST['end_time']) == '' ? 0 : to_timespan($_REQUEST['end_time']);
     $data['deal_cate_id'] = intval($_REQUEST['cate_id']);
     $data['city_id'] = intval($_REQUEST['city_id']);
     $data['icon'] = addslashes(htmlspecialchars(trim(replace_public($_REQUEST['icon']))));
     $data['image'] = addslashes(htmlspecialchars(trim(replace_public($_REQUEST['image']))));
     $data['brief'] = addslashes(htmlspecialchars(trim($_REQUEST['brief'])));
     $data['description'] = addslashes(trim(replace_public($_REQUEST['descript'])));
     $data['description'] = valid_tag($data['description']);
     $data['user_id'] = intval($account_id);
     $data['publish_wait'] = 1;
     $data['create_time'] = get_gmtime();
     $data['is_effect'] = 0;
     $data['supplier_id'] = intval($s_account_info['supplier_id']);
     foreach ($s_account_info['location_ids'] as $id) {
         $location_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "supplier_location where id = " . $id);
         if ($location_info) {
             $data['xpoint'] = $location_info['xpoint'];
             $data['ypoint'] = $location_info['ypoint'];
             break;
         }
     }
     $GLOBALS['db']->autoExecute(DB_PREFIX . "youhui", $data, "UPDATE", "id=" . $data['id']);
     $youhui_id = $data['id'];
     if ($youhui_id > 0) {
         $GLOBALS['db']->query("delete from " . DB_PREFIX . "deal_cate_type_youhui_link where youhui_id = " . $youhui_id);
         foreach ($_REQUEST['deal_cate_type_id'] as $deal_cate_type_id) {
             if ($deal_cate_type_id > 0) {
                 $deal_cate_type_link = array("youhui_id" => $youhui_id, "deal_cate_type_id" => intval($deal_cate_type_id));
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_cate_type_youhui_link", $deal_cate_type_link);
             }
         }
         showSuccess("提交成功,请等待管理员审核");
     } else {
         showErr("发布失败");
     }
 }
 public function index()
 {
     $root = array();
     $email = strim($GLOBALS['request']['email']);
     //用户名或邮箱
     $pwd = strim($GLOBALS['request']['pwd']);
     //密码
     //检查用户,用户密码
     $user = user_check($email, $pwd);
     $user_id = intval($user['id']);
     if ($user_id > 0) {
         $root['user_login_status'] = 1;
         $id = intval($_REQUEST['id']);
         $is_edit = $GLOBALS['db']->getOne("select is_edit from " . DB_PREFIX . "deal where id = " . $id);
         $is_effect = $GLOBALS['db']->getOne("select is_effect from " . DB_PREFIX . "deal where id = " . $id);
         if ($id > 0 && $is_effect == 1) {
             $root['info'] = "项目已提交,不能更改";
         }
         $data['name'] = strim($_REQUEST['name']);
         if ($data['name'] == "") {
             $root['info'] = "请填写项目名称";
         }
         if (msubstr($data['name'], 0, 25) != $data['name']) {
             $root['info'] = "项目名称不超过25个字";
         }
         $data['cate_id'] = intval($_REQUEST['cate_id']);
         if ($data['cate_id'] == 0) {
             $root['info'] = "请选择项目分类";
         }
         $data['province'] = strim($_REQUEST['province']);
         if ($data['province'] == '') {
             $root['info'] = "请选择省份";
         }
         $data['city'] = strim($_REQUEST['city']);
         if ($data['city'] == '') {
             $root['info'] = "请选择城市";
         }
         $data['brief'] = strim($_REQUEST['brief']);
         $data['image'] = replace_public(addslashes(trim($_REQUEST['image'])));
         if ($data['image'] == "") {
             $root['info'] = "上传封面图片";
         }
         require_once APP_ROOT_PATH . "system/libs/words.php";
         $data['tags'] = implode(" ", words::segment($data['name']));
         $data['description'] = replace_public(addslashes(trim(valid_tag($_REQUEST['description']))));
         //
         $data['vedio'] = strim($_REQUEST['vedio']);
         if ($data['vedio'] != "") {
             require_once APP_ROOT_PATH . "system/utils/vedio.php";
             $vedio = fetch_vedio_url($data['vedio']);
             if ($vedio != "") {
                 $data['source_vedio'] = $vedio;
             } else {
                 $root['info'] = "非法的视频地址";
             }
         }
         $data['limit_price'] = doubleval($_REQUEST['limit_price']);
         if ($data['limit_price'] <= 0) {
             $root['info'] = "请输入正确的目标金";
         }
         $data['deal_days'] = doubleval($_REQUEST['deal_days']);
         if ($data['deal_days'] <= 0) {
             $root['info'] = "请输入正确的上线天数";
         }
         $data['is_edit'] = 1;
         if ($id > 0) {
             $savenext = intval($_REQUEST['savenext']);
             $GLOBALS['db']->autoExecute(DB_PREFIX . "deal", $data, "UPDATE", "id=" . $id, "SILENT");
             //追加faq
             $GLOBALS['db']->query("delete from " . DB_PREFIX . "deal_faq where deal_id = " . $id);
             $sort = 1;
             foreach ($_REQUEST['question'] as $kk => $question_item) {
                 if (strim($_REQUEST['question'][$kk]) != "" && strim($_REQUEST['answer'][$kk]) != "" && strim($_REQUEST['question'][$kk]) != "请输入问题" && strim($_REQUEST['answer'][$kk]) != "请输入答案") {
                     $faq_item['deal_id'] = $id;
                     $faq_item['question'] = strim($_REQUEST['question'][$kk]);
                     $faq_item['answer'] = strim($_REQUEST['answer'][$kk]);
                     $faq_item['sort'] = $sort;
                     $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_faq", $faq_item);
                     $sort++;
                 }
             }
             $GLOBALS['db']->query("update " . DB_PREFIX . "deal set deal_extra_cache = '' where id = " . $id);
             if ($savenext == 0) {
                 showSuccess($id, $ajax, "");
             } else {
                 showSuccess("", $ajax, url("project#add_item", array("id" => $id)));
             }
         } else {
             $data['user_id'] = intval($GLOBALS['user_info']['id']);
             $data['user_name'] = $GLOBALS['user_info']['user_name'];
             $data['create_time'] = NOW_TIME;
             $savenext = intval($_REQUEST['savenext']);
             $GLOBALS['db']->autoExecute(DB_PREFIX . "deal", $data, "INSERT", "", "SILENT");
             $data_id = intval($GLOBALS['db']->insert_id());
             if ($data_id == 0) {
                 $root['info'] = "保存失败,请联系管理员";
             } else {
                 es_session::delete("deal_image");
                 //追加faq
                 $sort = 1;
                 foreach ($_REQUEST['question'] as $kk => $question_item) {
                     if (strim($_REQUEST['question'][$kk]) != "" && strim($_REQUEST['answer'][$kk]) != "" && strim($_REQUEST['question'][$kk]) != "请输入问题" && strim($_REQUEST['answer'][$kk]) != "请输入答案") {
                         $faq_item['deal_id'] = $data_id;
                         $faq_item['question'] = strim($_REQUEST['question'][$kk]);
                         $faq_item['answer'] = strim($_REQUEST['answer'][$kk]);
                         $faq_item['sort'] = $sort;
                         $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_faq", $faq_item);
                         $sort++;
                     }
                 }
                 if ($savenext == 0) {
                     showSuccess($data_id, $ajax, "");
                 } else {
                     showSuccess("", $ajax, url("project#add_item", array("id" => $data_id)));
                 }
             }
         }
     } else {
         $root['response_code'] = 0;
         $root['show_err'] = "未登录";
         $root['user_login_status'] = 0;
     }
     output($root);
 }
Exemple #11
0
         $openid_url = $_GET['openid_identifier'];
     }
     require 'class.dopeopenid.php';
     openid_auth($openid_url);
 }
 if (stripos($request_uri, 'logout') === 0) {
     // logout on linkpit.co.cc/logout
     $_SESSION['OPENID_AUTH'] = false;
     $_SESSION['OPENID_IDENTITY'] = "";
     session_destroy();
     header('Location: ' . $FULLPATH);
 }
 //no Login or log out to be done now. Only tag, URL and tag|url parsing to be done
 $dbp = dbConnect();
 //If the request_uri is a valid tag as in linkpit.co.cc/atag
 if (valid_tag($request_uri)) {
     if ($url = get_url_from_tag($request_uri)) {
         //get the corresponding URL
         //if the tag is registered.
         //echo "SESSION[NEWTAG]=".$_SESSION['newtag'];
         if (isset($_SESSION['newtag']) && $_SESSION['newtag'] == $request_uri) {
             //if this is the first time and this user registered the tag, congratulate him
             unset($_SESSION['newtag']);
             $message = <<<MSG
                             Congratulations, your <a href="{$url}">URL</a> has now been linked to the tag: <a href="{$FULLPATH}{$request_uri}"><b><u>{$request_uri}</u></b></a> <br/>
                             You can now go to this URL by visiting <br/>
                             <b><a href="{$FULLPATH}{$request_uri}">{$FULLPATH}{$request_uri}</a><br/></b>
                             You can copy-paste the following Linkpit URL and pass it on:<br/>
                             <input type='text' value='{$FULLPATH}{$request_uri}' size='30' style="border: 1px #000000 solid;  solid;text-align: center;
                             font-family: Arial, Sans-Serif;font-size: 16px;background-color: #B1B1B1;padding: 5px;" readonly="readonly" /><br/>
                             Opt the new way to pass URLs across chat rooms, Email and SMSs. Pass on <b>[{$request_uri}]</b> instead of passing http://linkpit.co.cc/{$request_uri} and tell them about Linkpit, if they ask about this strange syntax!
Exemple #12
0
 function save_create()
 {
     require_once APP_ROOT_PATH . 'app/Lib/uc.php';
     if (!$GLOBALS['user_info']) {
         app_redirect(url("user#login"));
     }
     $order = $GLOBALS["db"]->getRow("select * from " . DB_PREFIX . "licai where user_id =" . $GLOBALS["user_info"]["id"] . " and status =0 and verify = 0");
     if ($order) {
         showErr("您已经有申请的理财在审核,请耐心等待");
     }
     $data = array();
     $data["name"] = $_REQUEST["name"];
     $lc_sn = $GLOBALS["db"]->getOne("select max(id) from " . DB_PREFIX . "licai");
     $data['sort'] = $lc_sn + 1;
     $data["licai_sn"] = "LC" . to_date(TIME_UTC, "Y") . "" . str_pad($lc_sn + 1, 7, 0, STR_PAD_LEFT);
     $data["user_id"] = intval($GLOBALS['user_info']["id"]);
     $data['img'] = strim($_REQUEST['img']);
     $data['begin_buy_date'] = strim($_REQUEST['begin_buy_date']);
     $data['end_buy_date'] = strim($_REQUEST['end_buy_date']);
     $data['begin_interest_date'] = strim($_REQUEST['begin_interest_date']);
     $data['end_date'] = strim($_REQUEST['end_date']);
     $data['min_money'] = floatval($_REQUEST['min_money']);
     $data['max_money'] = floatval($_REQUEST['max_money']);
     $data['scope'] = strim($_REQUEST['scope']);
     $data['profit_way'] = strim($_REQUEST['profit_way']);
     $data['time_limit'] = intval($_REQUEST['time_limit']);
     $data['begin_interest_type'] = intval($_REQUEST['begin_interest_type']);
     $data['product_size'] = strim($_REQUEST['product_size']);
     $data['type'] = intval($_REQUEST['type']);
     $data['status'] = 0;
     $data['purchasing_time'] = strim($_REQUEST['purchasing_time']);
     $data['description'] = replace_public(btrim($_REQUEST['description']));
     $data['description'] = valid_tag($data['description']);
     $data['brief'] = replace_public(btrim($_REQUEST['brief']));
     $data['brief'] = valid_tag($data['brief']);
     $data['rule_info'] = replace_public(btrim($_REQUEST['rule_info']));
     $data['rule_info'] = valid_tag($data['rule_info']);
     $data['net_value'] = strim($_REQUEST['net_value']);
     $data['fund_key'] = strim($_REQUEST['fund_key']);
     $data['fund_type_id'] = intval($_REQUEST['fund_type_id']);
     $data['fund_brand_id'] = intval($_REQUEST['fund_brand_id']);
     //$data['risk_rank'] = intval($_REQUEST['risk_rank']); //风险等级
     $data['verify'] = 0;
     if ($data['name'] == "") {
         showErr("请输入名称");
     }
     if ($data['begin_buy_date'] == "" || $data['begin_buy_date'] == '00000000') {
         showErr("请选择理财开始购买时间");
     }
     if ($data['max_money'] == 0) {
         showErr("单笔最大购买限额");
     }
     //余额宝
     if ($data['type'] == 0) {
         if ($data['end_date'] == "" || $data['end_date'] == '00000000') {
             showErr("请选择理财结束时间");
         }
     } else {
         if ($data['begin_interest_date'] == "" || $data['begin_interest_date'] == '00000000') {
             showErr("请选择起息时间");
         }
         if ($data['time_limit'] && ($data['end_date'] == "" || $data['end_date'] == '00000000')) {
             showErr("项目结束时间和理财期限至少填写一个");
         }
     }
     $GLOBALS['db']->autoExecute(DB_PREFIX . "licai", $data, "INSERT");
     showSuccess("提交成功,等待管理员审核", 0, url("index", "licai#uc_published_lc"));
 }