/** * 显示文本框及处理提交的用户信息 * */ function find_email() { if (!IS_POST) { header("location:/index.php"); } else { $addr = $_SERVER['HTTP_REFERER']; if (empty($_POST['email'])) { $this->show_warning("unsettled_required", 'go_back', $addr); return; } $email = trim($_POST['email']); $model_user =& m('member'); $info = $model_user->get("email='{$email}'"); if (empty($info) || $info['email'] != $email) { $this->show_warning('not_exist', 'go_back', $addr); return; } $word = $this->_rand(); $md5word = md5($word); $res = $this->_password_mod->get($info['user_id']); if (empty($res)) { $info['activation'] = $md5word; $this->_password_mod->add($info); } else { $this->_password_mod->edit($info['user_id'], array('activation' => "{$md5word}")); } $mail = get_mail('touser_find_password', array('user' => $info, 'word' => $word)); $this->_mailto($email, addslashes($mail['subject']), addslashes($mail['message'])); $this->json_result(); return; } }
/** * 显示文本框及处理提交的用户信息 * */ function index() { if (!IS_POST) { $this->import_resource('jquery.plugins/jquery.validate.js'); $this->display("find_password.html"); } else { $addr = $_SERVER['HTTP_REFERER']; if (empty($_POST['username']) || empty($_POST['email']) || empty($_POST['captcha'])) { $this->show_warning("unsettled_required", 'go_back', $addr); return; } if (base64_decode($_SESSION['captcha']) != strtolower($_POST['captcha'])) { $this->show_warning("captcha_faild", 'go_back', $addr); return; } $username = trim($_POST['username']); $email = trim($_POST['email']); /* 简单验证是否是该用户 */ $ms =& ms(); //连接用户系统 $info = $ms->user->get($username, true); if (empty($info) || $info['email'] != $email) { $this->show_warning('not_exist', 'go_back', $addr); return; } $word = $this->_rand(); $md5word = md5($word); $res = $this->_password_mod->get($info['user_id']); if (empty($res)) { $info['activation'] = $md5word; $this->_password_mod->add($info); } else { $this->_password_mod->edit($info['user_id'], array('activation' => "{$md5word}")); } $mail = get_mail('touser_find_password', array('user' => $info, 'word' => $word)); $this->_mailto($email, addslashes($mail['subject']), addslashes($mail['message'])); $this->show_message("sendmail_success", 'back_index', 'index.php'); return; } }
/** * 支付完成后,外部网关的通知地址,在此会进行订单状态的改变,这里严格验证,改变订单状态 * * @author Garbin * @return void */ function notify() { //这里是支付宝,财付通等当订单状态改变时的通知地址 $order_id = 0; if (isset($_POST['order_id'])) { $order_id = intval($_POST['order_id']); } else { $order_id = intval($_GET['order_id']); } if (!$order_id) { /* 无效的通知请求 */ $this->show_warning('no_such_order'); return; } /* 获取订单信息 */ $model_order =& m('order'); $order_info = $model_order->get($order_id); if (empty($order_info)) { /* 没有该订单 */ $this->show_warning('no_such_order'); return; } $model_payment =& m('payment'); $payment_info = $model_payment->get("payment_code='{$order_info['payment_code']}' AND store_id={$order_info['seller_id']}"); if (empty($payment_info)) { /* 没有指定的支付方式 */ $this->show_warning('no_such_payment'); return; } /* 调用相应的支付方式 */ $payment = $this->_get_payment($order_info['payment_code'], $payment_info); /* 获取验证结果 */ $notify_result = $payment->verify_notify($order_info, true); if ($notify_result === false) { /* 支付失败 */ $payment->verify_result(false); return; } //改变订单状态 $this->_change_order_status($order_id, $order_info['extension'], $notify_result); $payment->verify_result(true); if ($notify_result['target'] == ORDER_ACCEPTED) { /* 发送邮件给卖家,提醒付款成功 */ $model_member =& m('member'); $seller_info = $model_member->get($order_info['seller_id']); $mail = get_mail('toseller_online_pay_success_notify', array('order' => $order_info)); $this->_mailto($seller_info['email'], addslashes($mail['subject']), addslashes($mail['message'])); /* 同步发送 */ $this->_sendmail(true); } }
<li><a class='logout' href='includes/logout.php'>Log ud</a></li> </ul> </div> </div> <div id="main"> <div class="header"> <h1>Administrator side</h1> </div> <div class="content"> <p> Her kan du vælge en ny email adresse, hvor alle emails i kontakt vil blive sendt til.<br> Den nuværende email er: <?php echo get_mail($mysqli); ?> <br><br> Indtast den nye email adresse, hvis du ønsker at ændre den:<br> <form class="pure-form pure-form-stacked" method="POST" action="<?php echo $_SERVER["PHP_SELF"]; ?> "> <div> <label for="newemail"></label> <input id ="newemail" type="string" name="newemail"/><br> <input class="btn left" name="email" type="submit" value="Godkend"> </div> </form> <?php
/** * 完成交易(货到付款的订单) * * @author Garbin * @return void */ function finished() { list($order_id, $order_info) = $this->_get_valid_order_info(ORDER_SHIPPED, 'payment_code=\'cod\''); if (!$order_id) { echo Lang::get('no_such_order'); return; } if (!IS_POST) { header('Content-Type:text/html;charset=' . CHARSET); /* 当前用户中心菜单 */ $this->_curitem('seller_order'); /* 当前所处子菜单 */ $this->_curmenu('finished'); $this->assign('_curmenu', 'finished'); $this->assign('order', $order_info); $this->display('seller_order.finished.html'); } else { $now = gmtime(); $model_order =& m('order'); $model_order->edit($order_id, array('status' => ORDER_FINISHED, 'pay_time' => $now, 'finished_time' => $now)); if ($model_order->has_error()) { $this->pop_warning($model_order->get_error()); return; } /* 记录订单操作日志 */ $order_log =& m('orderlog'); $order_log->add(array('order_id' => $order_id, 'operator' => addslashes($this->visitor->get('user_name')), 'order_status' => order_status($order_info['status']), 'changed_status' => order_status(ORDER_FINISHED), 'remark' => $_POST['remark'], 'log_time' => gmtime())); /* 更新累计销售件数 */ $model_goodsstatistics =& m('goodsstatistics'); $model_ordergoods =& m('ordergoods'); $order_goods = $model_ordergoods->find("order_id={$order_id}"); foreach ($order_goods as $goods) { $model_goodsstatistics->edit($goods['goods_id'], "sales=sales+{$goods['quantity']}"); } /* 发送给买家交易完成通知,提示评论 */ $model_member =& m('member'); $buyer_info = $model_member->get($order_info['buyer_id']); $mail = get_mail('tobuyer_cod_order_finish_notify', array('order' => $order_info)); $this->_mailto($buyer_info['email'], addslashes($mail['subject']), addslashes($mail['message'])); $new_data = array('status' => Lang::get('order_finished'), 'actions' => array()); $this->pop_warning('ok'); } }
function reply() { if (!IS_POST) { $ques_id = isset($_GET['ques_id']) && $_GET['ques_id'] != '' ? intval($_GET['ques_id']) : 0; $conditions = ' AND goods_qa.store_id = ' . $_SESSION['user_info']['user_id'] . ' AND ques_id = ' . $ques_id; $my_qa_data = $this->my_qa_mod->get(array('fields' => 'question_content,reply_content,goods_qa.user_id,goods_qa.email,time_post,user_name,goods_qa.goods_id,goods_name', 'join' => 'belongs_to_store,belongs_to_user,belongs_to_goods', 'conditions' => '1=1 ' . $conditions)); if ($my_qa_data['reply_content'] != '') { $this->show_warning('already_replied'); return; } /* 当前位置 */ $this->_curlocal(LANG::get('member_center'), 'index.php?app=member', LANG::get('my_qa'), 'index.php?app=my_qa', LANG::get('reply')); /* 当前用户中心菜单 */ $this->_curitem('my_qa'); /* 当前所处子菜单 */ $this->_curmenu('reply'); $this->assign('_curmenu', 'reply'); $this->assign('page_info', $page); $this->assign('my_qa_data', $my_qa_data); $this->assign('page_title', Lang::get('member_center') . ' - ' . Lang::get('reply')); header('Content-Type:text/html;charset=' . CHARSET); $this->display('my_qa.form.html'); } else { $act = isset($_POST['act']) && $_POST['act'] != '' ? trim($_POST['act']) : ''; $ques_id = isset($_POST['ques_id']) && $_POST['ques_id'] != '' ? intval($_POST['ques_id']) : ''; $content = isset($_POST['content']) && $_POST['content'] != '' ? trim($_POST['content']) : ''; if ($act != 'reply' || $ques_id == '') { $this->show_warning('Hacking Attempt'); return; } if ($content == '') { $this->show_warning('content_not_null'); return; } $user_info = $this->my_qa_mod->get(array('join' => 'belongs_to_goods', 'conditions' => '1 = 1 AND ques_id = ' . $ques_id, 'fields' => 'user_id,email,g.goods_id,goods_name')); extract($user_info); $data = array('reply_content' => $content, 'time_reply' => gmtime(), 'if_new' => '1'); if ($this->my_qa_mod->edit($ques_id, $data)) { $this->pop_warning('ok', 'my_qa_reply'); $mail = get_mail('tobuyer_question_replied', array('id' => $goods_id, 'ques_id' => $ques_id, 'goods_name' => $goods_name)); $this->_mailto($email, addslashes($mail['subject']), addslashes($mail['message'])); } else { $this->pop_warning('reply_failed'); return; } } }
function edit() { import('image.func'); import('uploader.lib'); $id = empty($_GET['id']) ? 0 : intval($_GET['id']); if (!IS_POST) { /* 传给iframe id */ $this->assign('id', $id); $this->assign('belong', BELONG_GOODS); if (!$id || !($goods = $this->_get_goods_info($id))) { $this->show_warning('no_such_goods'); return; } $goods['tags'] = trim($goods['tags'], ','); $this->assign('goods', $goods); /* 取到商品关联的图片 */ $uploadedfiles = $this->_uploadedfile_mod->find(array('fields' => "f.*,goods_image.*", 'conditions' => "store_id=" . $this->_store_id . " AND belong=" . BELONG_GOODS . " AND item_id=" . $id, 'join' => 'belongs_to_goodsimage', 'order' => 'add_time ASC')); $default_goods_images = array(); // 默认商品图片 $other_goods_images = array(); // 其他商品图片 $desc_images = array(); // 描述图片 $recommend_image = array(); //推荐图片 /*if (!empty($goods['default_image'])) { $goods_images }*/ foreach ($uploadedfiles as $key => $uploadedfile) { if ($uploadedfile['instance'] == 'recommend_image') { $recommend_image = $uploadedfile; } else { if ($uploadedfile['goods_id'] == null) { $desc_images[$key] = $uploadedfile; } else { if (!empty($goods['default_image']) && $uploadedfile['thumbnail'] == $goods['default_image']) { $default_goods_images[$key] = $uploadedfile; } else { $other_goods_images[$key] = $uploadedfile; } } } } $this->assign('goods_images', array_merge($default_goods_images, $other_goods_images)); $this->assign('desc_images', $desc_images); $this->assign('recommend_image', $recommend_image); /* 取得商品分类 */ $this->assign('mgcategories', $this->_get_mgcategory_options(0)); // 商城分类第一级 $this->assign('sgcategories', $this->_get_sgcategory_options()); // 店铺分类 //取得地区信息 $region_mod =& m('region'); $this->assign('regions', $region_mod->get_options(0)); /* 当前页面信息 */ $this->_curlocal(LANG::get('member_center'), 'index.php?app=member', LANG::get('my_goods'), 'index.php?app=my_goods', LANG::get('goods_list')); $this->_curitem('my_goods'); $this->_curmenu('edit_goods'); $this->_config_seo('title', Lang::get('member_center') . ' - ' . Lang::get('edit_goods')); $this->import_resource(array('script' => array(array('path' => 'mlselection.js', 'attr' => 'charset="utf-8"'), array('path' => 'jquery.plugins/jquery.validate.js', 'attr' => 'charset="utf-8"'), array('path' => 'jquery.ui/jquery.ui.js', 'attr' => 'charset="utf-8"'), array('path' => 'my_goods.js', 'attr' => 'charset="utf-8"'), array('attr' => 'id="dialog_js" charset="utf-8"', 'path' => 'dialog/dialog.js')), 'style' => 'jquery.ui/themes/ui-lightness/jquery.ui.css')); /* 商品图片批量上传器 */ $this->assign('images_upload', $this->_build_upload(array('obj' => 'GOODS_SWFU', 'belong' => BELONG_GOODS, 'item_id' => $id, 'button_text' => Lang::get('bat_upload'), 'progress_id' => 'goods_upload_progress', 'upload_url' => 'index.php?app=swfupload&instance=goods_image', 'if_multirow' => 1))); /* 编辑器图片批量上传器 */ $this->assign('editor_upload', $this->_build_upload(array('obj' => 'EDITOR_SWFU', 'belong' => BELONG_GOODS, 'item_id' => $id, 'button_text' => Lang::get('bat_upload'), 'button_id' => 'editor_upload_button', 'progress_id' => 'editor_upload_progress', 'upload_url' => 'index.php?app=swfupload&instance=desc_image', 'if_multirow' => 1, 'ext_js' => false, 'ext_css' => false))); /* 所见即所得编辑器 */ extract($this->_get_theme()); $this->assign('build_editor', $this->_build_editor(array('name' => 'description', 'content_css' => SITE_URL . "/themes/store/{$template_name}/styles/{$style_name}" . '/shop.css'))); $this->display('my_goods.form.html'); } else { /* 取得数据 */ $data = $this->_get_post_data($id); $stock =& m("stock"); $notice_email = $stock->find(array('join' => 'be_stock', 'fields' => 'email,sp_id,goods_id', 'conditions' => 'st.goods_id = ' . $id)); if ($notice_email) { foreach ($data['specs'] as $spec_id => $val) { if ($val['stock'] > 0) { foreach ($notice_email as $sid => $email) { if ($email['sp_id'] == $spec_id) { $mail = get_mail('tobuyer_goods_notice_notify_desc', array('email' => $email)); //获取邮件模板,到货通知 $this->_mailto($email['email'], addslashes($mail['subject']), addslashes($mail['message'])); //发送邮件 $stock->drop($sid); } } } } } /* 检查数据 */ if (!$this->_check_post_data($data, $id)) { $this->show_warning($this->get_error()); return; } /* 保存商品 */ if (!$this->_save_post_data($data, $id)) { $this->show_warning($this->get_error()); return; } $this->show_message('edit_ok', 'back_list', 'index.php?app=my_goods', 'edit_again', 'index.php?app=my_goods&act=edit&id=' . $id); } }
/** * 确认订单 * * @author Garbin * @return void */ function confirm_order() { $order_id = isset($_GET['order_id']) ? intval($_GET['order_id']) : 0; if (!$order_id) { echo Lang::get('no_such_order'); return; } $model_order =& m('order'); /* 只有已发货的订单可以确认 */ $order_info = $model_order->get("order_id={$order_id} AND buyer_id=" . $this->visitor->get('user_id') . " AND status=" . ORDER_SHIPPED); if (empty($order_info)) { echo Lang::get('no_such_order'); return; } if (!IS_POST) { header('Content-Type:text/html;charset=' . CHARSET); $this->assign('order', $order_info); $this->display('buyer_order.confirm.html'); } else { $model_order->edit($order_id, array('status' => ORDER_FINISHED, 'finished_time' => gmtime())); if ($model_order->has_error()) { $this->pop_warning($model_order->get_error()); return; } /* 记录订单操作日志 */ $order_log =& m('orderlog'); $order_log->add(array('order_id' => $order_id, 'operator' => addslashes($this->visitor->get('user_name')), 'order_status' => order_status($order_info['status']), 'changed_status' => order_status(ORDER_FINISHED), 'remark' => Lang::get('buyer_confirm'), 'log_time' => gmtime())); /* 发送给卖家买家确认收货邮件,交易完成 */ $model_member =& m('member'); $seller_info = $model_member->get($order_info['seller_id']); $mail = get_mail('toseller_finish_notify', array('order' => $order_info)); $this->_mailto($seller_info['email'], addslashes($mail['subject']), addslashes($mail['message'])); $new_data = array('status' => Lang::get('order_finished'), 'actions' => array('evaluate')); /* 更新累计销售件数 */ $model_goodsstatistics =& m('goodsstatistics'); $model_ordergoods =& m('ordergoods'); $order_goods = $model_ordergoods->find("order_id={$order_id}"); foreach ($order_goods as $goods) { $model_goodsstatistics->edit($goods['goods_id'], "sales=sales+{$goods['quantity']}"); } $this->pop_warning('ok', '', 'index.php?app=buyer_order&act=evaluate&order_id=' . $order_id); } }
/** * 待发货的订单发货 * * @author Garbin * @return void */ function shipped() { list($order_id, $order_info) = $this->_get_valid_order_info(array(ORDER_ACCEPTED, ORDER_SHIPPED)); if (!$order_id) { echo Lang::get('no_such_order'); return; } $model_order =& m('order'); if (!IS_POST) { /* 显示发货表单 */ header('Content-Type:text/html;charset=' . CHARSET); $this->assign('order', $order_info); $this->display('fahuo.shipped.html'); } else { if (!$_POST['invoice_no']) { $this->show_warning('invoice_no_empty'); return; } if (!$_POST['shipping_name']) { $this->show_warning('物流方式不存在'); return; } $edit_data = array('status' => ORDER_SHIPPED, 'invoice_no' => $_POST['invoice_no'], 'shipping_name' => $_POST['shipping_name']); $is_edit = true; if (empty($order_info['invoice_no'])) { /* 不是修改发货单号 */ $edit_data['ship_time'] = gmtime(); $is_edit = false; } $model_order->edit(intval($order_id), $edit_data); if ($model_order->has_error()) { $this->show_warning($model_order->get_error()); return; } #TODO 发邮件通知 /* 记录订单操作日志 */ $order_log =& m('orderlog'); $order_log->add(array('order_id' => $order_id, 'operator' => addslashes($this->visitor->get('user_name')), 'order_status' => order_status($order_info['status']), 'changed_status' => order_status(ORDER_SHIPPED), 'remark' => $_POST['remark'], 'log_time' => gmtime())); /* 发送给买家订单已发货通知 */ $model_member =& m('member'); $buyer_info = $model_member->get($order_info['buyer_id']); $order_info['invoice_no'] = $edit_data['invoice_no']; $mail = get_mail('tobuyer_shipped_notify', array('order' => $order_info)); $this->_mailto($buyer_info['email'], addslashes($mail['subject']), addslashes($mail['message'])); $new_data = array('status' => Lang::get('order_shipped'), 'actions' => array('cancel', 'edit_invoice_no')); if ($order_info['payment_code'] == 'cod') { $new_data['actions'][] = 'finish'; } $this->show_message('发货成功', 'back_list', 'index.php?app=fahuo'); } }
?> </span> </a> <ul class="dropdown-menu"> <li class="dropdown-header clearfix"> <p class="pull-left"> You have <?php echo count(get_mail()["inbox"]); ?> Messages </p> </li> <li class="dropdown-body"> <ul class="dropdown-menu-list withScroll"> <?php $mails = get_mail()["inbox"]; ?> <?php foreach ($mails as $mail) { ?> <li class="clearfix"> <a href="<?php echo site_url(); ?> inbox/show/<?php echo $mail['id']; ?> .html"> <div> <strong><?php echo substr($mail['subject'], 0, 30);
<?php session_start(); include "inc/connect.php"; include "inc/functions.php"; if (!$_SESSION && !$_SESSION['user'] == "admin") { header('Location: index.php'); } $all_mail = get_mail($connexion); if ($_POST) { $add_id = nettoyage($_POST['id']); $add_mail = nettoyage($_POST['mail']); $add_date = nettoyage($_POST['date']); $add_privilege = nettoyage($_POST['privilege']); $result = update_mail($connexion, $add_id, $add_mail, $add_date, $add_privilege); header('Refresh: 2; URL=platform.php'); } include 'inc/template/header.php'; include 'inc/template/admin_page.php'; include 'inc/template/footer.php';
/** * 填写收货人信息,选择配送,支付方式。 * * @author Garbin * @param none * @return void */ function index() { $goods_info = $this->_get_carts_info(); $stores_id = $this->get_stores($goods_info); if ($goods_info === false) { /* 购物车是空的 */ $this->show_no(); return; } if (!IS_POST || $_POST['order_post'] == 1 || $_GET['order_post'] == 1) { /* 根据商品类型获取对应订单类型 */ $goods_type =& gt($goods_info['type']); $order_type =& ot($goods_info['otype']); //是否是团购 /* 显示订单表单 */ $addr_id = isset($_GET['addr_id']) ? $_GET['addr_id'] : 0; $form = $order_type->get_order_form2($stores_id, $addr_id); //分别取出各个店铺的信息配送信息 $address = $form['address']; //该用户的默认的地址 $this->_curlocal(LANG::get('create_order')); $this->_config_seo('title', Lang::get('confirm_order') . ' - ' . Conf::get('site_title')); if ($address) { //该用户的默认的地址 foreach ($goods_info as $id => $val) { if ($id > 0) { $goods_info[$id]['shipping_methods'] = $form['data'][$id]['shipping_methods']; foreach ($goods_info[$id]['shipping_methods'] as $sid => $val) { //循环配送信息 $cod_regions = unserialize($val['cod_regions']); if (is_array($cod_regions) && !empty($cod_regions)) { /* 取得支持货到付款地区的所有下级地区 */ $all_regions = array(); $model_region =& m('region'); foreach ($cod_regions as $region_id => $region_name) { $all_regions = array_merge($all_regions, $model_region->get_descendant($region_id)); } /* 查看订单中指定的地区是否在可货到付款的地区列表中,如果不在,则不显示货到付款的付款方式 */ if (!in_array($address['region_id'], $all_regions)) { unset($goods_info[$id]['shipping_methods'][$sid]); } else { $yunfei[$id] = $val['first_price']; //没有被删除的配送方式id } } else { unset($goods_info[$id]['shipping_methods'][$sid]); $no_shipipng[$sid] = $sid; } } $goods_info[$id]['yunfei'] = $yunfei[$id]; $goods_info[$id]['amount'] += $yunfei[$id]; } } if (empty($yunfei)) { //没有配送方式 $this->show_no(); return false; } foreach ($yunfei as $k => $val) { $yun += floatval($val); //计算总运费 } $goods_info['total'] += $yun + $goods_info['subtotal']; //计算总价格 } //如果有的默认的收货地址 $this->assign('yunfei', $yun); $this->assign('goods_info', $goods_info); $this->assign($form['data']); if (is_wap()) { $this->assign("title", "确认订单"); } $this->display($form['template']); } else { $_POST['postscript'] = array_combine($_POST['order_id'], $_POST['order_message']); //卖家的备忘录 if ($goods_info === false) { /* 购物车是空的 */ $this->show_no(); return; } /* 根据商品类型获取对应的订单类型 */ $goods_type =& gt($goods_info['type']); $order_type =& ot($goods_info['otype']); $form = $order_type->get_order_form2($stores_id, 0); /* 将这些信息传递给订单类型处理类生成订单(你根据我提供的信息生成一张订单) */ $order_id = $order_type->submit_order(array('goods_info' => $goods_info, 'post' => $_POST, 'form' => $form)); if (!$order_id) { $this->show_warning($order_type->get_error()); return; } /* 检查是否添加收货人地址 */ if (isset($_POST['save_address']) && intval(trim($_POST['save_address'])) == 1) { $data = array('user_id' => $this->visitor->get('user_id'), 'consignee' => trim($_POST['consignee']), 'region_id' => $_POST['region_id'], 'region_name' => $_POST['region_name'], 'address' => trim($_POST['address']), 'zipcode' => trim($_POST['zipcode']), 'phone_tel' => trim($_POST['phone_tel']), 'phone_mob' => trim($_POST['phone_mob'])); $model_address =& m('address'); $model_address->add($data); } /* 下单完成后清理商品,如清空购物车,或将团购拍卖的状态转为已下单之类的 */ $this->_clear_goods($order_id); /* 发送邮件 */ $model_order =& m('order'); /* 减去商品库存 */ foreach ($order_id as $id) { $model_order->change_stock('-', $id); } /* 获取订单信息 */ foreach ($order_id as $sid => $val) { $order_info[$sid] = $model_order->get("order_id=" . $val); //3.25 } /* 发送事件 */ $feed_images = array(); foreach ($goods_info as $sid => $val) { if ($sid > 0) { foreach ($val['items'] as $_gi) { $feed_images[$sid][] = array('url' => SITE_URL . '/' . $_gi['goods_image'], 'link' => SITE_URL . '/' . url('app=goods&id=' . $_gi['goods_id'])); } } } foreach ($order_id as $sid => $val) { $this->send_feed('order_created', array('user_id' => $this->visitor->get('user_id'), 'user_name' => addslashes($this->visitor->get('user_name')), 'seller_id' => $order_info[$sid]['seller_id'], 'seller_name' => $order_info[$sid]['seller_name'], 'store_url' => SITE_URL . '/' . url('app=store&id=' . $order_info[$sid]['seller_id']), 'images' => $feed_images[$sid])); } $buyer_address = $this->visitor->get('email'); $model_member =& m('member'); foreach ($order_id as $sid => $val) { //获取用户信息 $member_info[$sid] = $model_member->get($sid); $seller_address[$sid] = $member_info[$sid]['email']; } /* 发送给买家下单通知 */ foreach ($order_id as $sid => $val) { $buyer_mail = get_mail('tobuyer_new_order_notify', array('order' => $order_info[$sid])); $this->_mailto($buyer_address, addslashes($buyer_mail['subject']), addslashes($buyer_mail['message'])); } /* 发送给卖家新订单通知 */ foreach ($order_id as $sid => $val) { $seller_mail[$sid] = get_mail('toseller_new_order_notify', array('order' => $order_info[$sid])); $this->_mailto($seller_address[$sid], addslashes($seller_mail[$sid]['subject']), addslashes($seller_mail[$sid]['message'])); } /* 更新下单次数 */ $model_goodsstatistics =& m('goodsstatistics'); $goods_ids = array(); foreach ($goods_info as $sid => $val) { if ($sid > 0) { foreach ($val['items'] as $goods) { $goods_ids[$sid][] = $goods['goods_id']; } } } foreach ($order_id as $sid => $val) { $model_goodsstatistics->edit($val, 'orders=orders+1'); } /* 更新下单次数 */ $order = implode("-", $order_id); if (is_wap()) { header("location:/cashier-" . $order . ".html"); } else { $this->json_results(array('done' => true, 'url' => "/cashier-" . $order . ".html")); } } }
/** * 确认订单 * * @author Garbin * @return void */ function confirm_order() { $order_id = isset($_GET['order_id']) ? intval($_GET['order_id']) : 0; if (!$order_id) { echo Lang::get('no_such_order'); return; } $model_order =& m('order'); /* 只有已发货的订单可以确认 */ $order_info = $model_order->get("order_id={$order_id} AND buyer_id=" . $this->visitor->get('user_id') . " AND status=" . ORDER_SHIPPED); if (empty($order_info)) { echo Lang::get('no_such_order'); return; } $model_order->edit($order_id, array('status' => ORDER_FINISHED, 'finished_time' => gmtime())); if ($model_order->has_error()) { $this->pop_warning($model_order->get_error()); return; } /* 记录订单操作日志 */ $order_log =& m('orderlog'); $order_log->add(array('order_id' => $order_id, 'operator' => addslashes($this->visitor->get('user_name')), 'order_status' => order_status($order_info['status']), 'changed_status' => order_status(ORDER_FINISHED), 'remark' => Lang::get('buyer_confirm'), 'log_time' => gmtime())); /* 发送给卖家买家确认收货邮件,交易完成 */ $model_member =& m('member'); $seller_info = $model_member->get($order_info['seller_id']); $mail = get_mail('toseller_finish_notify', array('order' => $order_info)); $this->_mailto($seller_info['email'], addslashes($mail['subject']), addslashes($mail['message'])); /* 更新累计销售件数 */ $model_goodsstatistics =& m('goodsstatistics'); $model_ordergoods =& m('ordergoods'); $order_goods = $model_ordergoods->find("order_id={$order_id}"); foreach ($order_goods as $goods) { $model_goodsstatistics->edit($goods['goods_id'], "sales=sales+{$goods['quantity']}"); } $this->json_result(); }
function sendemail() { if (!IS_POST) { $this->show_warning('Hacking Attempt'); return; } else { $code = trim($_POST['code']); $email = trim($_POST['email']); $username = trim($_POST['username']); $ms =& ms(); $info = $ms->user->get($username, true); $mail = get_mail('touser_send_code', array('user' => $info, 'word' => $code)); $mailer =& get_mailer(); $mail_result = $mailer->send($email, addslashes($mail['subject']), addslashes($mail['message']), CHARSET, 1); if ($mail_result) { $_SESSION['email_code'] = md5($email . $code); $_SESSION['last_send_time_email_code'] = time(); $this->json_result('', 'mail_send_succeed'); } else { $this->json_error('mail_send_failure', implode("\n", $mailer->errors)); } } }
<div> <label for="message"><b>Besked</b></label> <textarea rows="10" cols="40" name="message" required></textarea> </div> <br><br><br><br><br><br><br><br><br> <input class="btn right" type="submit" name="submit" value="Send mail"> </form> <?php } else { if (isset($_POST["from"])) { $mailcheck = spamcheck($_POST["from"]); if ($mailcheck == FALSE) { echo "Invalid input"; } else { $to = get_mail($mysqli); $from = $_POST["from"]; $subject = $_POST["subject"]; $message = $_POST["message"]; $message = wordwrap($message, 70); mail($to, $subject, $message, "From: {$from}\n"); echo "Tak for mailen - vi svarer tilbage hurtigst muligt!"; } } } ?> </div> </div> <script src="js/ui.js"></script>
/** * 填写收货人信息,选择配送,支付方式。 * * @author Garbin * @param none * @return void */ function index() { if (!IS_POST) { $goods_info = $this->_get_goods_info(); if ($goods_info === false) { /* 购物车是空的 */ $this->show_warning('goods_empty'); return; } /* 根据商品类型获取对应订单类型 */ $goods_type =& gt($goods_info['type']); $order_type =& ot($goods_type->get_order_type()); /* 显示订单表单 */ $form = $order_type->get_order_form($goods_info['store_id']); if ($form === false) { $this->show_warning($order_type->get_error()); return; } $this->_curlocal(LANG::get('create_order')); $this->assign('page_title', Lang::get('confirm_order_info') . ' - ' . Conf::get('site_title')); $this->assign('goods_info', $goods_info); $this->assign($form['data']); $this->display($form['template']); } else { /* 在此获取生成订单的两个基本要素:用户提交的数据(POST),商品信息(包含商品列表,商品总价,商品总数量,类型),所属店铺 */ $goods_info = $this->_get_goods_info(); if ($goods_info === false) { /* 购物车是空的 */ $this->show_warning('goods_empty'); return; } /* 根据商品类型获取对应的订单类型 */ $goods_type =& gt($goods_info['type']); $order_type =& ot($goods_type->get_order_type()); /* 将这些信息传递给订单类型处理类生成订单(你根据我提供的信息生成一张订单) */ $order_id = $order_type->submit_order(array('goods_info' => $goods_info, 'post' => $_POST)); if (!$order_id) { $this->show_warning($order_type->get_error()); return; } /* 检查是否添加收货人地址 */ if (isset($_POST['save_address']) && intval(trim($_POST['save_address'])) == 1) { $data = array('user_id' => $this->visitor->get('user_id'), 'consignee' => trim($_POST['consignee']), 'region_id' => $_POST['region_id'], 'region_name' => $_POST['region_name'], 'address' => trim($_POST['address']), 'zipcode' => trim($_POST['zipcode']), 'phone_tel' => trim($_POST['phone_tel']), 'phone_mob' => trim($_POST['phone_mob'])); $model_address =& m('address'); $model_address->add($data); } /* 下单完成后清理商品,如清空购物车,或将团购拍卖的状态转为已下单之类的 */ $this->_clear_goods(); /* 发送邮件 */ $model_order =& m('order'); /* 减去商品库存 */ $model_order->change_stock('-', $order_id); /* 获取订单信息 */ $order_info = $model_order->get($order_id); /* 发送事件 */ $feed = array('icon' => 'goods', 'user_id' => $this->visitor->get('user_id'), 'user_name' => addslashes($this->visitor->get('user_name')), 'title' => array('template' => Lang::get('feed_bought_goods_title'), 'data' => array('store' => '<a href="' . SITE_URL . '/index.php?app=store&id=' . $order_info['seller_id'] . '">' . $order_info['seller_name'] . '</a>')), 'body' => array('template' => Lang::get('feed_bought_goods_body'))); $ms =& ms(); $ms->feed->add($feed); $buyer_address = $this->visitor->get('email'); $model_member =& m('member'); $member_info = $model_member->get($goods_info['store_id']); $seller_address = $member_info['email']; /* 发送给买家下单通知 */ $buyer_mail = get_mail('tobuyer_new_order_notify', array('order' => $order_info)); $this->_mailto($buyer_address, addslashes($buyer_mail['subject']), addslashes($buyer_mail['message'])); /* 发送给卖家新订单通知 */ $seller_mail = get_mail('toseller_new_order_notify', array('order' => $order_info)); $this->_mailto($seller_address, addslashes($seller_mail['subject']), addslashes($seller_mail['message'])); /* 更新下单次数 */ $model_goodsstatistics =& m('goodsstatistics'); $goods_ids = array(); foreach ($goods_info['items'] as $goods) { $goods_ids[] = $goods['goods_id']; } $model_goodsstatistics->edit($goods_ids, 'orders=orders+1'); /* 到收银台付款 */ header('Location:index.php?app=cashier&order_id=' . $order_id); } }
function qa() { $goods_qa =& m('goodsqa'); if (!IS_POST) { //如果是用户第一次查看则将是否为最新设为否 $new = empty($_GET['new']) ? '' : trim($_GET['new']); $update_data = array('if_new' => '0'); $question_id = empty($_GET['question_id']) ? '' : intval($_GET['question_id']); if ($question_id != '' && $new == 'yes') { $goods_qa->edit($question_id, $update_data); } $id = empty($_GET['id']) ? 0 : intval($_GET['id']); $ques_id = empty($_GET['ques_id']) ? 0 : intval($_GET['ques_id']); if (!$id) { $this->show_warning('Hacking Attempt'); return; } if ($ques_id != 0) { //查出要回复主题的用户名和id $answer = $goods_qa->get(array('join' => 'belongs_to_user', 'fields' => 'member.user_id,user_name', 'conditions' => '1 = 1 AND ques_id = ' . $ques_id)); $this->assign('answer', $answer); } if (!$this->_assign_common_info($id)) { return; } $this->_assign_goods_qa($id, 10); //是否开启验证码 if (Conf::get('captcha_status.goodsqa')) { $this->assign('captcha', 1); } /*赋值产品咨询*/ $this->display('goods.qa.html'); } else { $content = isset($_POST['content']) && $_POST['content'] != '' ? $_POST['content'] : ''; $type = isset($_POST['type']) && $_POST['type'] != '' ? $_POST['type'] : ''; $email = isset($_POST['email']) && $_POST['email'] != '' ? $_POST['email'] : ''; $hide_name = isset($_POST['hide_name']) && $_POST['hide_name'] != '' ? $_POST['hide_name'] : ''; //对验证码和邮件进行判断 if ($type == 'ask') { if (Conf::get('captcha_status.goodsqa')) { if (base64_decode($_SESSION['captcha']) != strtolower($_POST['captcha'])) { $this->show_warning('captcha_failed'); return; } } if (trim($email) != '') { if (!is_email($email)) { $this->show_warning('email_not_correct'); return; } } if (trim($hide_name) != '') { $user_id = 0; } else { $user_id = $_SESSION['user_info']['user_id']; } } if (trim($content) == '') { $this->show_warning('content_not_null'); return; } $id = empty($_POST['goods_id']) ? 0 : intval($_POST['goods_id']); if (!$id) { $this->show_warning('Hacking Attempt'); return; } $conditions = 'and g.goods_id =' . $id; $goods_mod =& m('goods'); $ids = $goods_mod->get(array('fields' => 'store_id,goods_name', 'conditions' => '1=1 ' . $conditions)); extract($ids); if ($type == 'ask') { $data = array('question_content' => $content, 'goods_id' => $id, 'store_id' => $store_id, 'email' => $email, 'user_id' => $user_id, 'time_post' => time()); if ($goods_qa->add($data)) { $this->show_message('question_successful'); return; } } else { $ques_id = isset($_POST['ques_id']) && $_POST['ques_id'] != '' ? $_POST['ques_id'] : ''; //检查此咨询是否被回复,如果回复则提示 $if_replied = $goods_qa->get(array('fields' => 'reply_content', 'conditions' => '1 = 1 AND ques_id=' . $ques_id)); if (trim($if_replied['reply_content']) != '') { $this->show_warning('already_replied', 'back', "index.php?app=goods&id={$id}"); return; } if ($_SESSION['user_info']['user_id'] != $store_id) { $this->show_warning('permission_denied', 'back', "index.php?app=goods&id={$id}"); return; } $user_info = $goods_qa->get(array('conditions' => '1 = 1 AND ques_id = ' . $ques_id, 'fields' => 'user_id,email')); extract($user_info); $data = array('reply_content' => $content, 'time_reply' => time(), 'if_new' => 1); if ($goods_qa->edit($ques_id, $data)) { $mail = get_mail('tobuyer_question_replied', array('id' => $id, 'ques_id' => $ques_id, 'goods_name' => $goods_name)); $this->_mailto($email, addslashes($mail['subject']), addslashes($mail['message'])); $this->show_message('reply_successful', 'back', "index.php?app=goods&id={$id}"); } else { $this->show_message('reply_failed'); return; } } } }
require "../settings.php"; # decide what to do if (isset($_POST["key"])) { switch ($_POST["key"]) { case "confirm": $OUTPUT = con_mail($_POST); break; case "write": $OUTPUT = write_mail($_POST); break; default: $OUTPUT = get_mail(); } } else { $OUTPUT = get_mail(); } # display output require "../template.php"; # enter new data function get_mail() { global $_POST; extract($_POST); if (!isset($email)) { $email = ""; $msg = ""; } /*//db_conn(YR_DB); // DataBase $S1 = "SELECT * FROM document ORDER BY name";
/** * 填写收货人信息,选择配送,支付方式。 * * @author Garbin * @param none * @return void */ function index() { $goods_info = $this->_get_goods_info(); if ($goods_info === false) { /* 购物车是空的 */ $this->show_warning('goods_empty'); return; } /* 检查库存 */ $goods_beyond = $this->_check_beyond_stock($goods_info['items']); if ($goods_beyond) { $str_tmp = ''; foreach ($goods_beyond as $goods) { $str_tmp .= '<br /><br />' . $goods['goods_name'] . ' ' . $goods['specification'] . ' ' . Lang::get('stock') . ':' . $goods['stock']; } $this->show_warning(sprintf(Lang::get('quantity_beyond_stock'), $str_tmp)); return; } /* 检查买家的收货地址,因为用到了运费模板,如果没有收货地址,无法读取运费 tyioocom delivery */ $address_model =& m('address'); if (!$address_model->get('user_id=' . $this->visitor->get('user_id'))) { $this->show_warning('请先添加你的收货地址', '添加地址', 'index.php?app=my_address'); return; } if (!IS_POST) { /* 根据商品类型获取对应订单类型 */ $goods_type =& gt($goods_info['type']); $order_type =& ot($goods_info['otype']); /* 显示订单表单 */ $form = $order_type->get_order_form($goods_info); if ($form === false) { $this->show_warning($order_type->get_error()); return; } $this->_curlocal(LANG::get('create_order')); //by cengnlaeng // (($goods_info['amount'] >= $goods_info['amount_for_free_fee']) && ($goods_info['amount_for_free_fee'] > 0)) && $logic1=true; // $logic2=($goods_info['quantity'] >= $goods_info['acount_for_free_fee']) && ($goods_info['acount_for_free_fee'] > 0); // if($logic1 || $logic2) // { // $logic2 && $title= sprintf(Lang::get('free_acount_ship_title'),$goods_info['acount_for_free_fee']); // $logic1 && $title= sprintf(Lang::get('free_amount_ship_title'),$goods_info['amount_for_free_fee']); // $this->assign('is_free_fee',true); // $this->assign('free_fee_name',$title); // } //end $this->_config_seo('title', Lang::get('confirm_order') . ' - ' . Conf::get('site_title')); $this->assign('coupon_list', $this->get_available_coupon($goods_info['store_id'], $this->visitor->get('user_id'))); $this->assign('goods_info', $goods_info); $this->assign($form['data']); $this->display($form['template']); } else { /* 在此获取生成订单的两个基本要素:用户提交的数据(POST),商品信息(包含商品列表,商品总价,商品总数量,类型),所属店铺 */ $store_id = isset($_GET['store_id']) ? intval($_GET['store_id']) : 0; if ($goods_info === false) { /* 购物车是空的 */ $this->show_warning('goods_empty'); return; } $item_ids = $_POST['ordergoods']; $goods_info = $this->_refresh_goods_info($item_ids, $store_id); /* 优惠券数据处理 */ if ($goods_info['allow_coupon'] && isset($_POST['coupon_sn']) && !empty($_POST['coupon_sn'])) { $coupon_sn = trim($_POST['coupon_sn']); $coupon_mod =& m('couponsn'); $coupon = $coupon_mod->get(array('fields' => 'coupon.*,couponsn.remain_times', 'conditions' => "coupon_sn.coupon_sn = '{$coupon_sn}'", 'join' => 'belongs_to_coupon')); if (empty($coupon)) { $this->show_warning('involid_couponsn'); exit; } if ($coupon['store_id'] > 0) { if ($coupon['store_id'] != $store_id) { $this->show_warning('involid_couponsn'); exit; } } else { //Change by MingFONG at 20150226 if ($coupon['open_agree_item']) { $store_coupon =& m('store_coupon'); $if_can_use = $store_coupon->get('store_id=' . $store_id . ' AND coupon_id=' . $coupon['coupon_id'] . ' AND if_agree=2'); if (empty($if_can_use)) { $this->show_warning('involid_couponsn'); exit; } } //End of Change by MingFONG at 20150226 } if ($coupon['remain_times'] < 1) { $this->show_warning("times_full"); exit; } $time = gmtime(); if ($coupon['start_time'] > $time) { $this->show_warning("coupon_time"); exit; } if ($coupon['end_time'] < $time) { $this->show_warning("coupon_expired"); exit; } if ($coupon['min_amount'] > $goods_info['amount']) { $this->show_warning("amount_short"); exit; } unset($time); $goods_info['discount'] = $coupon['coupon_value']; } /* 根据商品类型获取对应的订单类型 */ $goods_type =& gt($goods_info['type']); $order_type =& ot($goods_info['otype']); /* 将这些信息传递给订单类型处理类生成订单(你根据我提供的信息生成一张订单) */ $order_id = $order_type->submit_order(array('goods_info' => $goods_info, 'post' => $_POST)); if (!$order_id) { $this->show_warning($order_type->get_error()); return; } //360cd.cn trans //360cd.cn $trans_model =& m('trans'); $trans_model->update_order($order_id); //360cd.cn trans /* 检查是否添加收货人地址 */ if (isset($_POST['save_address']) && intval(trim($_POST['save_address'])) == 1) { $data = array('user_id' => $this->visitor->get('user_id'), 'consignee' => trim($_POST['consignee']), 'region_id' => $_POST['region_id'], 'region_name' => $_POST['region_name'], 'address' => trim($_POST['address']), 'zipcode' => trim($_POST['zipcode']), 'phone_tel' => trim($_POST['phone_tel']), 'phone_mob' => trim($_POST['phone_mob'])); $model_address =& m('address'); $model_address->add($data); } /* 下单完成后清理商品,如清空购物车,或将团购拍卖的状态转为已下单之类的 */ $this->_clear_goods($order_id); /* 发送邮件 */ $model_order =& m('order'); /* 减去商品库存 */ $model_order->change_stock('-', $order_id); /* 获取订单信息 */ $order_info = $model_order->get($order_id); /* 发送事件 */ $feed_images = array(); foreach ($goods_info['items'] as $_gi) { $feed_images[] = array('url' => SITE_URL . '/' . $_gi['goods_image'], 'link' => SITE_URL . '/' . url('app=goods&id=' . $_gi['goods_id'])); } $this->send_feed('order_created', array('user_id' => $this->visitor->get('user_id'), 'user_name' => addslashes($this->visitor->get('user_name')), 'seller_id' => $order_info['seller_id'], 'seller_name' => $order_info['seller_name'], 'store_url' => SITE_URL . '/' . url('app=store&id=' . $order_info['seller_id']), 'images' => $feed_images)); $buyer_address = $this->visitor->get('email'); $model_member =& m('member'); $member_info = $model_member->get($goods_info['store_id']); $seller_address = $member_info['email']; /* 发送给买家下单通知 */ $buyer_mail = get_mail('tobuyer_new_order_notify', array('order' => $order_info)); $this->_mailto($buyer_address, addslashes($buyer_mail['subject']), addslashes($buyer_mail['message'])); /* 发送给卖家新订单通知 */ $seller_mail = get_mail('toseller_new_order_notify', array('order' => $order_info)); $this->_mailto($seller_address, addslashes($seller_mail['subject']), addslashes($seller_mail['message'])); /* 更新下单次数 */ $model_goodsstatistics =& m('goodsstatistics'); $goods_ids = array(); foreach ($goods_info['items'] as $goods) { $goods_ids[] = $goods['goods_id']; } $model_goodsstatistics->edit($goods_ids, 'orders=orders+1'); //发送短信给买家 by andcpp $filename = ROOT_PATH . '/data/msg.inc.php'; if (file_exists($filename)) { $mod_msg =& m('msg'); $order_infos = $model_order->get(array('conditions' => $order_info['order_id'], 'join' => 'has_orderextm', 'include' => array('has_ordergoods'))); $order_type1 =& ot($order_infos['extension']); $order_detail = $order_type1->get_order_detail($order_info['order_id'], $order_infos); foreach ($order_detail['data']['goods_list'] as $key => $order_goods) { $content .= $order_goods['goods_name'] . $order_goods['quantity'] . Lang::get('fen') . ','; } $name = $order_infos['consignee']; $address = $order_infos['address']; $phone = $order_infos['phone_mob']; $user_id = $order_info['seller_id']; $row_msg = $mod_msg->get(array('conditions' => 'msg.user_id=' . $user_id, 'join' => 'belongs_to_user', 'fields' => 'this.*,phone_mob')); $mobile = $row_msg['phone_mob']; //手机号 $smsText = sprintf(Lang::get('sms_buy'), $content, $name, $address, $phone); $checked_functions = $functions = array(); $functions = $this->_get_msg_functions(); $tmp = explode(',', $row_msg['functions']); if ($functions) { foreach ($functions as $func) { $checked_functions[$func] = in_array($func, $tmp); } } if ($row_msg['state'] == 1 && $checked_functions['buy'] == 1 && $row_msg['num'] > 0 && !empty($mobile) && !empty($smsText)) { $this->Sms_Get('SMS_Send', $mobile, $smsText, $user_id); } } //end by psmb /* 到收银台付款 */ header('Location:index.php?app=cashier&order_id=' . $order_id); } }
function edit_reply() { $ques_id = isset($_GET['ques_id']) && $_GET['ques_id'] != '' ? intval($_GET['ques_id']) : 0; if (empty($ques_id)) { echo Lang::get('no_data'); } if (!IS_POST) { $conditions = ' AND goods_qa.store_id = ' . $_SESSION['user_info']['user_id'] . ' AND ques_id = ' . $ques_id; $my_qa_data = $this->my_qa_mod->get(array('fields' => 'question_content,reply_content,goods_qa.user_id,goods_qa.email,time_post,user_name,goods_qa.item_id,goods_qa.item_name,goods_qa.type', 'join' => 'belongs_to_store,belongs_to_user', 'conditions' => '1=1 ' . $conditions)); $this->assign('ques_id', $ques_id); $this->assign('my_qa_data', $my_qa_data); header('Content-Type:text/html;charset=' . CHARSET); $this->display('my_qa.form.html'); } else { $act = isset($_POST['act']) && $_POST['act'] != '' ? trim($_POST['act']) : ''; $ques_id = isset($_POST['ques_id']) && $_POST['ques_id'] != '' ? intval($_POST['ques_id']) : ''; $content = isset($_POST['content']) && $_POST['content'] != '' ? trim($_POST['content']) : ''; if (empty($content)) { $this->pop_warning('content_not_null'); return; } $user_info = $this->my_qa_mod->get(array('conditions' => '1 = 1 AND ques_id = ' . $ques_id, 'fields' => 'user_id,email,item_id,item_name,type')); extract($user_info); $data = array('reply_content' => $content, 'time_reply' => gmtime(), 'if_new' => '1'); if ($this->my_qa_mod->edit($ques_id, $data)) { $this->pop_warning('ok', 'my_qa_edit_reply'); $mail = get_mail('tobuyer_question_replied', array('id' => $goods_id, 'ques_id' => $ques_id, 'goods_name' => $goods_name)); $this->_mailto($email, addslashes($mail['subject']), addslashes($mail['message'])); } else { $this->pop_warning('reply_failed'); return; } } }
/** * 确认订单 * * @author Garbin * @return void */ function confirm_order() { $order_id = isset($_GET['order_id']) ? intval($_GET['order_id']) : 0; if (!$order_id) { echo Lang::get('no_such_order'); return; } $model_order =& m('order'); /* 只有已发货的订单可以确认 */ $order_info = $model_order->get("order_id={$order_id} AND buyer_id=" . $this->visitor->get('user_id') . " AND status=" . ORDER_SHIPPED); if (empty($order_info)) { echo Lang::get('no_such_order'); return; } if (!IS_POST) { header('Content-Type:text/html;charset=' . CHARSET); $this->assign('order', $order_info); $this->display('buyer_order.confirm.html'); } else { $model_order->edit($order_id, array('status' => ORDER_FINISHED, 'finished_time' => gmtime())); if ($model_order->has_error()) { $this->pop_warning($model_order->get_error()); return; } /* 记录订单操作日志 */ $order_log =& m('orderlog'); $order_log->add(array('order_id' => $order_id, 'operator' => addslashes($this->visitor->get('user_name')), 'order_status' => order_status($order_info['status']), 'changed_status' => order_status(ORDER_FINISHED), 'remark' => Lang::get('buyer_confirm'), 'log_time' => gmtime())); /* 发送给卖家买家确认收货邮件,交易完成 */ $model_member =& m('member'); $seller_info = $model_member->get($order_info['seller_id']); $mail = get_mail('toseller_finish_notify', array('order' => $order_info)); $this->_mailto($seller_info['email'], addslashes($mail['subject']), addslashes($mail['message'])); $new_data = array('status' => Lang::get('order_finished'), 'actions' => array('evaluate')); /* 更新累计销售件数 */ $model_goodsstatistics =& m('goodsstatistics'); $model_ordergoods =& m('ordergoods'); $order_goods = $model_ordergoods->find("order_id={$order_id}"); foreach ($order_goods as $goods) { $model_goodsstatistics->edit($goods['goods_id'], "sales=sales+{$goods['quantity']}"); } //更新会员的成长值和等级 by cengnlaeng $model_member->edit_growth($this->visitor->get('user_id'), 'bought', $order_info['goods_amount']); //发送短信给买家 by andcpp $filename = ROOT_PATH . '/data/msg.inc.php'; if (file_exists($filename)) { $mod_msg =& m('msg'); $user_id = $order_info['seller_id']; $row_msg = $mod_msg->get(array('conditions' => 'msg.user_id=' . $user_id, 'join' => 'belongs_to_user', 'fields' => 'this.*,phone_mob')); $mobile = $row_msg['phone_mob']; //手机号 $smsText = sprintf(Lang::get('sms_check'), $order_info['order_sn'], $order_info['buyer_name']); $checked_functions = $functions = array(); $functions = $this->_get_msg_functions(); $tmp = explode(',', $row_msg['functions']); if ($functions) { foreach ($functions as $func) { $checked_functions[$func] = in_array($func, $tmp); } } if ($row_msg['state'] == 1 && $checked_functions['check'] == 1 && $row_msg['num'] > 0 && !empty($mobile) && !empty($smsText)) { $this->Sms_Get('SMS_Send', $mobile, $smsText, $user_id); } } //end by psmb $this->pop_warning('ok', '', 'index.php?app=buyer_order&act=evaluate&order_id=' . $order_id); } }
require_once 'config.php'; // this is called by cron every once in a while and sends the // emails queued in the email_queue table // fetch a list of up to 100 not sent $stmt = $mysqli->prepare('SELECT id, to_address, to_name, subject, body FROM email_queue WHERE success IS NULL ORDER BY created DESC LIMIT 100'); $stmt->execute(); $stmt->store_result(); if ($stmt->num_rows == 0) { exit; } // nothing to do // got stuff so bind variables and work through them $stmt->bind_result($queue_id, $to_address, $to_name, $subject, $body); while ($stmt->fetch()) { $mysqli->query("UPDATE email_queue SET attempt = now(), attempt_count = attempt_count + 1 WHERE id = {$queue_id}"); $mail = get_mail(); $mail->setFrom('*****@*****.**', 'Ten Breaths Map'); $mail->addAddress($to_address, $to_name); $mail->isHTML(true); $mail->Subject = $subject; $mail->Body = $body; if (!$mail->send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; $stmt2 = $mysqli->prepare('UPDATE email_queue SET error = ? WHERE id = ?'); $stmt2->bind_param('si', $mail->ErrorInfo, $queue_id); $stmt2->execute(); } else { $mysqli->query("UPDATE email_queue SET success = now() WHERE id = {$queue_id}"); echo "Email sent to: {$to_address} \n"; }
/** * 填写收货人信息,选择配送,支付方式。 * * @author Garbin * @param none * @return void */ function index() { $goods_info = $this->_get_goods_info(); if ($goods_info === false) { /* 购物车是空的 */ $this->show_warning('goods_empty'); return; } /* 检查库存 */ $goods_beyond = $this->_check_beyond_stock($goods_info['items']); if ($goods_beyond) { $str_tmp = ''; foreach ($goods_beyond as $goods) { $str_tmp .= '<br /><br />' . $goods['goods_name'] . ' ' . $goods['specification'] . ' ' . Lang::get('stock') . ':' . $goods['stock']; } $this->show_warning(sprintf(Lang::get('quantity_beyond_stock'), $str_tmp)); return; } if (!IS_POST) { /* 根据商品类型获取对应订单类型 */ $goods_type =& gt($goods_info['type']); $order_type =& ot($goods_info['otype']); /* 显示订单表单 */ $form = $order_type->get_order_form($goods_info['store_id']); if ($form === false) { $this->show_warning($order_type->get_error()); return; } $this->_curlocal(LANG::get('create_order')); $this->_config_seo('title', Lang::get('confirm_order') . ' - ' . Conf::get('site_title')); $this->assign('goods_info', $goods_info); $this->assign($form['data']); $this->display($form['template']); } else { /* 在此获取生成订单的两个基本要素:用户提交的数据(POST),商品信息(包含商品列表,商品总价,商品总数量,类型),所属店铺 */ $store_id = isset($_GET['store_id']) ? intval($_GET['store_id']) : 0; if ($goods_info === false) { /* 购物车是空的 */ $this->show_warning('goods_empty'); return; } /* 优惠券数据处理 */ if ($goods_info['allow_coupon'] && isset($_POST['coupon_sn']) && !empty($_POST['coupon_sn'])) { $coupon_sn = trim($_POST['coupon_sn']); $coupon_mod =& m('couponsn'); $coupon = $coupon_mod->get(array('fields' => 'coupon.*,couponsn.remain_times', 'conditions' => "coupon_sn.coupon_sn = '{$coupon_sn}' AND coupon.store_id = " . $store_id, 'join' => 'belongs_to_coupon')); if (empty($coupon)) { $this->show_warning('involid_couponsn'); exit; } if ($coupon['remain_times'] < 1) { $this->show_warning("times_full"); exit; } $time = gmtime(); if ($coupon['start_time'] > $time) { $this->show_warning("coupon_time"); exit; } if ($coupon['end_time'] < $time) { $this->show_warning("coupon_expired"); exit; } if ($coupon['min_amount'] > $goods_info['amount']) { $this->show_warning("amount_short"); exit; } unset($time); $goods_info['discount'] = $coupon['coupon_value']; } /* 根据商品类型获取对应的订单类型 */ $goods_type =& gt($goods_info['type']); $order_type =& ot($goods_info['otype']); /* 将这些信息传递给订单类型处理类生成订单(你根据我提供的信息生成一张订单) */ $order_id = $order_type->submit_order(array('goods_info' => $goods_info, 'post' => $_POST)); if (!$order_id) { $this->show_warning($order_type->get_error()); return; } /* 检查是否添加收货人地址 */ if (isset($_POST['save_address']) && intval(trim($_POST['save_address'])) == 1) { $data = array('user_id' => $this->visitor->get('user_id'), 'consignee' => trim($_POST['consignee']), 'region_id' => $_POST['region_id'], 'region_name' => $_POST['region_name'], 'address' => trim($_POST['address']), 'zipcode' => trim($_POST['zipcode']), 'phone_tel' => trim($_POST['phone_tel']), 'phone_mob' => trim($_POST['phone_mob'])); $model_address =& m('address'); $model_address->add($data); } /* 下单完成后清理商品,如清空购物车,或将团购拍卖的状态转为已下单之类的 */ $this->_clear_goods($order_id); /* 发送邮件 */ $model_order =& m('order'); /* 减去商品库存 */ $model_order->change_stock('-', $order_id); /* 获取订单信息 */ $order_info = $model_order->get($order_id); /* 发送事件 */ $feed_images = array(); foreach ($goods_info['items'] as $_gi) { $feed_images[] = array('url' => SITE_URL . '/' . $_gi['goods_image'], 'link' => SITE_URL . '/' . url('app=goods&id=' . $_gi['goods_id'])); } $this->send_feed('order_created', array('user_id' => $this->visitor->get('user_id'), 'user_name' => addslashes($this->visitor->get('user_name')), 'seller_id' => $order_info['seller_id'], 'seller_name' => $order_info['seller_name'], 'store_url' => SITE_URL . '/' . url('app=store&id=' . $order_info['seller_id']), 'images' => $feed_images)); $buyer_address = $this->visitor->get('email'); $model_member =& m('member'); $member_info = $model_member->get($goods_info['store_id']); $seller_address = $member_info['email']; /* 发送给买家下单通知 */ $buyer_mail = get_mail('tobuyer_new_order_notify', array('order' => $order_info)); $this->_mailto($buyer_address, addslashes($buyer_mail['subject']), addslashes($buyer_mail['message'])); /* 发送给卖家新订单通知 */ $seller_mail = get_mail('toseller_new_order_notify', array('order' => $order_info)); $this->_mailto($seller_address, addslashes($seller_mail['subject']), addslashes($seller_mail['message'])); /* 更新下单次数 */ $model_goodsstatistics =& m('goodsstatistics'); $goods_ids = array(); foreach ($goods_info['items'] as $goods) { $goods_ids[] = $goods['goods_id']; } $model_goodsstatistics->edit($goods_ids, 'orders=orders+1'); /* 到收银台付款 */ header('Location:index.php?app=cashier&order_id=' . $order_id); } }
function _mail_to_user($users, $coupon) { foreach ($users as $val) { $mail = get_mail('touser_send_coupon', array('user' => $val, 'coupon' => $coupon)); if (!$mail) { continue; } $this->_mailto($val['email'], addslashes($mail['subject']), addslashes($mail['message'])); } }
function change_pass() { mail(get_mail($_SESSION['mno']), "Password Succesfully Change - from FashionSponge.com", "Your previous Password {$_GET['lastPass']} and Succesfully change to {$_GET['Npass']} ", "Dear " . firstname($_SESSION['mno']) . ","); update1('fs_member_accounts', 'pass', $_GET['Npass'], array('mno', $_SESSION['mno'])); }
/** * 线下支付消息 * * @author Garbin * @return void */ function offline_pay() { if (!IS_POST) { return; } $order_id = isset($_GET['order_id']) ? intval($_GET['order_id']) : 0; $pay_message = isset($_POST['pay_message']) ? trim($_POST['pay_message']) : ''; if (!$order_id) { $this->show_warning('no_such_order'); return; } if (!$pay_message) { $this->show_warning('no_pay_message'); return; } $order_model =& m('order'); $order_info = $order_model->get("order_id={$order_id} AND buyer_id=" . $this->visitor->get('user_id')); if (empty($order_info)) { $this->show_warning('no_such_order'); return; } $edit_data = array('pay_message' => $pay_message); $order_model->edit($order_id, $edit_data); /* 线下支付完成并留下pay_message,发送给卖家付款完成提示邮件 */ $model_member =& m('member'); $seller_info = $model_member->get($order_info['seller_id']); $mail = get_mail('toseller_offline_pay_notify', array('order' => $order_info, 'pay_message' => $pay_message)); $this->_mailto($seller_info['email'], addslashes($mail['subject']), addslashes($mail['message'])); $this->show_message('pay_message_successed', 'view_order', 'index.php?app=buyer_order', 'close_window', 'javascript:window.close();'); }
/** * 支付完成后,外部网关的通知地址,在此会进行订单状态的改变,这里严格验证,改变订单状态 * * @author Garbin * @return void */ function notify() { //这里是支付宝,财付通等当订单状态改变时的通知地址 $order_id = 0; if (isset($_POST['order_id'])) { $order_id = intval($_POST['order_id']); } else { $order_id = intval($_GET['order_id']); } if (!$order_id) { /* 为了兼容Asiapay支付方式*/ if (isset($_POST['Ref']) && !empty($_POST['Ref']) && intval($_POST['Ref']) > 0) { $order_id = intval($_POST['Ref']); } else { /* 无效的通知请求 */ $this->show_warning('no_such_order'); return; } } /* 获取订单信息 */ $model_order =& m('order'); $order_info = $model_order->get($order_id); if (empty($order_info)) { /* 没有该订单 */ $this->show_warning('no_such_order'); return; } $model_payment =& m('payment'); $payment_info = $model_payment->get("payment_code='{$order_info['payment_code']}' AND store_id={$order_info['seller_id']}"); if (empty($payment_info)) { /* 没有指定的支付方式 */ $this->show_warning('no_such_payment'); return; } /* 调用相应的支付方式 */ $payment = $this->_get_payment($order_info['payment_code'], $payment_info); /* 获取验证结果 */ $notify_result = $payment->verify_notify($order_info, true); if ($notify_result === false) { /* 支付失败 */ $payment->verify_result(false); return; } //改变订单状态 $this->_change_order_status($order_id, $order_info['extension'], $notify_result); $payment->verify_result(true); if ($notify_result['target'] == ORDER_ACCEPTED) { /* 发送邮件给卖家,提醒付款成功 */ $model_member =& m('member'); $seller_info = $model_member->get($order_info['seller_id']); $mail = get_mail('toseller_online_pay_success_notify', array('order' => $order_info)); $this->_mailto($seller_info['email'], addslashes($mail['subject']), addslashes($mail['message'])); /* 同步发送 */ $this->_sendmail(true); /*发送短信*/ $filename = ROOT_PATH . '/data/msg.inc.php'; if (file_exists($filename)) { $mod_msg =& m('msg'); $user_id = $order_info['seller_id']; $row_msg = $mod_msg->get(array('conditions' => 'msg.user_id=' . $user_id, 'join' => 'belongs_to_user', 'fields' => 'this.*,phone_mob')); $mobile = $row_msg['phone_mob']; //手机号 $smsText = sprintf(Lang::get('sms_pay'), $order_info['order_sn'], $order_info['buyer_name']); $checked_functions = $functions = array(); $functions = $this->_get_msg_functions(); $tmp = explode(',', $row_msg['functions']); if ($functions) { foreach ($functions as $func) { $checked_functions[$func] = in_array($func, $tmp); } } if ($row_msg['state'] == 1 && $checked_functions['pay'] == 1 && $row_msg['num'] > 0 && !empty($mobile) && !empty($smsText)) { $this->Sms_Get('SMS_Send', $mobile, $smsText, $user_id); } } //end by psmb } }