Пример #1
0
 /**
  * 物流对应的地区列表
  */
 function index($id)
 {
     if (!$id) {
         remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error');
     }
     $deliverycn_service = DeliverycnService::get_instance();
     $deliverycn_region_service = Deliverycn_regionService::get_instance();
     //验证此条物流
     $data = $deliverycn_service->get($id);
     if (!$data['id']) {
         remind::set(Kohana::lang('o_global.access_denied'), request::referrer(), 'error');
     }
     //初始化请求结构体
     $query_struct = array('where' => array('deliverycn_id' => $id), 'like' => array(), 'orderby' => array('position' => 'ASC', 'id' => 'ASC'), 'limit' => array('per_page' => 2000, 'offset' => 0));
     // 每页条目数
     controller_tool::request_per_page($query_struct, $request_data);
     $count = $deliverycn_region_service->query_count($query_struct);
     // 模板输出 分页
     $this->pagination = new Pagination(array('total_items' => $count, 'items_per_page' => $query_struct['limit']['per_page']));
     $query_struct['limit']['offset'] = $this->pagination->sql_offset;
     $query_struct['limit']['page'] = $this->pagination->current_page;
     //调用列表
     $deliverycn_regions = $deliverycn_region_service->get_delivery_regions_by_position($query_struct);
     $this->template->content = new View("site/deliverycn/region");
     $this->template->content->deliverycn_regions = $deliverycn_regions;
     $this->template->content->data = $data;
     $this->template->content->regions = $deliverycn_region_service->get_regions();
 }
Пример #2
0
 public static function check_spam()
 {
     $comment = array('comment_type' => 'comment', 'comment_author' => Event::$data->author, 'comment_author_email' => Event::$data->email, 'comment_author_url' => Event::$data->url, 'comment_content' => Event::$data->content, 'referrer' => request::referrer(), 'user_ip' => Event::$data->ip, 'user_agent' => Kohana::user_agent(), 'blog' => url::base(TRUE, 'http'));
     $result = self::send_request('comment', $comment);
     if ($result === 'true') {
         Event::$data->approved = 'no';
         Event::$data->save();
     }
 }
Пример #3
0
 /**
  * Log the customer in
  * @Developer brandon
  * @Date Oct 12, 2010
  */
 public function create()
 {
     if (Auth::instance()->login($this->input->post('customername'), $this->input->post('password'))) {
         url::redirect($this->input->post('redirect_override', request::referrer()));
     } else {
         flash::set_error('Unable to log in');
         url::redirect(request::referrer());
     }
 }
Пример #4
0
 /**
  * Allows a model to be loaded by filename.
  */
 public function add_view($type, $id)
 {
     $this->item_type = $type;
     $this->item_id = $id;
     $this->ip = Input::instance()->ip_address();
     $this->referrer = request::referrer();
     $this->user_agent = Kohana::user_agent();
     $this->save();
 }
Пример #5
0
 public function installed()
 {
     if (request::referrer() !== 'auth') {
         // Do not allow non-referrered requests
         url::redirect('auth');
     }
     $this->template->title = 'Installation Sucessful!';
     $this->template->content = View::factory('auth/installed');
 }
Пример #6
0
 /**
  * Send out the e-mail to the user if we can find their email
  * @developer Brandon Hansen
  * @date May 31, 2010
  */
 public function send_email()
 {
     $user = ORM::factory('user')->find_by_email($this->input->post('email'));
     if ($user->loaded) {
         $email = new Email();
         $email->reset_password($user);
         flash::set_message('We have sent you an e-mail with password reset instructions');
         url::redirect('login');
     } else {
         flash::set_message('We were unable to locate an account with that e-mail address');
         url::redirect(request::referrer());
     }
 }
Пример #7
0
 /**
  * Add a log entry.
  *
  * @param string  $category  an arbitrary category we can use to filter log messages
  * @param string  $message   a detailed log message
  * @param integer $severity  INFO, WARNING or ERROR
  * @param string  $html      an html snippet presented alongside the log message to aid the admin
  */
 private static function _add($category, $message, $html, $severity)
 {
     $log = ORM::factory("log");
     $log->category = $category;
     $log->message = $message;
     $log->severity = $severity;
     $log->html = $html;
     $log->url = substr(url::abs_current(true), 0, 255);
     $log->referer = request::referrer(null);
     $log->timestamp = time();
     $log->user_id = identity::active_user()->id;
     $log->save();
 }
Пример #8
0
 public function _sort_order()
 {
     $session = Session::instance();
     $sortFunction = "listingNameCmp";
     $currentSort = $session->get('sort_order');
     $currentSortOrder = $session->get('sort_order_direction');
     if (isset($_GET["sort"])) {
         if ($_GET["sort"] == "filename") {
             $sortFunction = "listingNameCmp";
         } else {
             if ($_GET["sort"] == "size") {
                 $sortFunction = "listingSizeCmp";
             } else {
                 if ($_GET["sort"] == "date") {
                     $sortFunction = "listingDateCmp";
                 } else {
                     if ($_GET["sort"] == "kind") {
                         $sortFunction = "listingKindCmp";
                     }
                 }
             }
         }
         $session->set('sort_order', $sortFunction);
         $this->sort_order = $sortFunction;
         if ($currentSort == $sortFunction) {
             $newSortOrder = "Asc";
             if ($currentSortOrder == "Asc") {
                 $newSortOrder = "Desc";
             }
             $session->set('sort_order_direction', $newSortOrder);
             $this->sort_order_direction = $newSortOrder;
         } else {
             if ($sortFunction == "listingDateCmp") {
                 $session->set('sort_order_direction', "Desc");
                 $this->sort_order_direction = "Desc";
             } else {
                 $session->set('sort_order_direction', "Asc");
                 $this->sort_order_direction = "Asc";
             }
         }
         // redirect to avoid url resorting issue
         url::redirect(request::referrer());
         exit;
     } else {
         if ($currentSort != NULL) {
             $this->sort_order = $currentSort;
             $this->sort_order_direction = $currentSortOrder;
         }
     }
 }
 public function delete($templateId)
 {
     //权限检查 得到所有可管理站点ID列表
     role::check('distribution_system_manage');
     $templateDao = Superplaner_Realtime_contract_template::instance();
     $template = $templateDao->get_by_id($templateId);
     if ($template == null) {
         remind::set(Kohana::lang('o_contract.contract_not_exists'), request::referrer(), 'error');
     }
     if (Superplaner_Realtime_contract_template::instance($templateId)->delete()) {
         remind::set(Kohana::lang('o_global.delete_success'), request::referrer(), 'success');
     } else {
         remind::set(Kohana::lang('o_global.delete_error'), request::referrer(), 'error');
     }
 }
Пример #10
0
 /**
  * Add a log entry.
  *
  * @param string  $category  an arbitrary category we can use to filter log messages
  * @param string  $message   a detailed log message
  * @param integer $severity  INFO, WARNING or ERROR
  * @param string  $html      an html snippet presented alongside the log message to aid the admin
  */
 private static function _add($category, $message, $html, $severity)
 {
     $log = ORM::factory("log");
     $log->category = $category;
     $log->message = $message;
     $log->severity = $severity;
     $log->html = $html;
     $log->url = url::abs_current(true);
     $log->referer = request::referrer(null);
     $log->timestamp = time();
     if (module::is_installed("user")) {
         $log->user_id = user::active()->id;
     }
     $log->save();
 }
Пример #11
0
 public function delete($cardTypeId)
 {
     //权限检查 得到所有可管理站点ID列表
     role::check('card_system_manage');
     $cardType = $this->cardTypeDao->get_by_id($cardTypeId);
     if ($cardType == null) {
         remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error');
         return;
     }
     if ($this->cardTypeDao->delete($cardTypeId)) {
         remind::set(Kohana::lang('o_global.delete_success'), 'card/card_type', 'success');
         return;
     } else {
         remind::set(Kohana::lang('o_global.delete_error'), request::referrer(), 'error');
         return;
     }
 }
Пример #12
0
 public function update($photo_id)
 {
     access::verify_csrf();
     $photo = ORM::factory("item", $photo_id);
     access::required("view", $photo);
     access::required("edit", $photo);
     $form = photo::get_edit_form($photo);
     $valid = $form->validate();
     if ($valid) {
         $new_ext = pathinfo($form->edit_item->filename->value, PATHINFO_EXTENSION);
         $old_ext = pathinfo($photo->name, PATHINFO_EXTENSION);
         if (strcasecmp($new_ext, $old_ext)) {
             $form->edit_item->filename->add_error("illegal_extension", 1);
             $valid = false;
         }
     }
     if ($valid) {
         if ($form->edit_item->filename->value != $photo->name || $form->edit_item->slug->value != $photo->slug) {
             // Make sure that there's not a name or slug conflict
             if ($row = db::build()->select(array("name", "slug"))->from("items")->where("parent_id", "=", $photo->parent_id)->where("id", "<>", $photo->id)->and_open()->where("name", "=", $form->edit_item->filename->value)->or_where("slug", "=", $form->edit_item->slug->value)->close()->execute()->current()) {
                 if ($row->name == $form->edit_item->filename->value) {
                     $form->edit_item->filename->add_error("name_conflict", 1);
                 }
                 if ($row->slug == $form->edit_item->slug->value) {
                     $form->edit_item->slug->add_error("slug_conflict", 1);
                 }
                 $valid = false;
             }
         }
     }
     if ($valid) {
         $watching_album = $photo->url() != ($location = parse_url(request::referrer(), PHP_URL_PATH));
         $photo->title = $form->edit_item->title->value;
         $photo->description = $form->edit_item->description->value;
         $photo->slug = $form->edit_item->slug->value;
         $photo->rename($form->edit_item->filename->value);
         $photo->save();
         module::event("item_edit_form_completed", $photo, $form);
         log::success("content", "Updated photo", "<a href=\"{$photo->url()}\">view</a>");
         message::success(t("Saved photo %photo_title", array("photo_title" => html::purify($photo->title))));
         print json_encode(array("result" => "success", "location" => $watching_album ? $location : $photo->url()));
     } else {
         print json_encode(array("result" => "error", "form" => $form->__toString()));
     }
 }
Пример #13
0
 /**
  * 修改用户地址
  */
 function do_edit($id)
 {
     //权限验证
     $site_id_list = role::check('user_edit');
     if (!$id) {
         remind::set(Kohana::lang('o_global.bad_request'), 'user/address');
     }
     if ($_POST) {
         $data = $_POST;
         //标签过滤
         tool::filter_strip_tags($data);
         $data['date_upd'] = date('Y-m-d H:i:s');
         if (Myaddress::instance($id)->edit($data)) {
             remind::set(Kohana::lang('o_global.update_success'), request::referrer(), 'success');
         } else {
             remind::set(Kohana::lang('o_global.update_error'), request::referrer(), 'error');
         }
     }
 }
Пример #14
0
 public function delete($moneyExchangeId)
 {
     //权限检查 得到所有可管理站点ID列表
     role::check('card_system_manage');
     $moneyExchange = $this->moneyExchangeDao->get_by_id($moneyExchangeId);
     if ($moneyExchange == null) {
         remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error');
         return;
     }
     if ($moneyExchange['flag'] == 2) {
         remind::set("不能删除生效中的汇率方案", request::referrer(), 'error');
         return;
     }
     if ($this->moneyExchangeDao->delete($moneyExchange)) {
         remind::set(Kohana::lang('o_global.delete_success'), 'card/money_exchange', 'success');
         return;
     } else {
         remind::set(Kohana::lang('o_global.delete_error'), request::referrer(), 'error');
         return;
     }
 }
Пример #15
0
 public function login($tag_id = NULL)
 {
     if ($this->auth->logged_in('login')) {
         url::redirect();
     }
     $this->template->title = 'Login';
     if (!$this->session->get('referer')) {
         $this->session->set('referer', request::referrer());
     }
     $this->template->content = View::factory('shadadmin/users/login')->bind('errors', $errors);
     $post = Validation::factory($_POST)->pre_filter('trim')->add_rules('username', 'required')->add_rules('password', 'required');
     if ($post->validate()) {
         $user = ORM::factory('user', $post->username);
         if (!$user->loaded) {
             $post->add_error('username', 'not_found');
         } elseif ($this->auth->login($user, $post->password)) {
             url::redirect($this->session->get_once('referer'));
         } else {
             $post->add_error('password', 'incorrect_password');
         }
     }
     $errors = $post->errors('errors_users_login');
     $this->template->navigation = '';
 }
Пример #16
0
 /**
  * Refund the order
  * @developer Brandon Hansen
  * @date Oct 23, 2010
  */
 public function refund()
 {
     $order = ORM::factory('order', $this->input->post('id'));
     $order->refund();
     url::redirect(request::referrer());
 }
Пример #17
0
 /**
  * Debug function
  *
  * @param  string  $data  Data returned from cURL connection.
  * @param  array   $post  Post data array
  */
 private function debugo($data, $post)
 {
     $method = !$post ? 'Get' : 'Post';
     print '<a href="' . request::referrer() . '">Back</a><br/>';
     print '<h3>Status:</h3>' . $this->status;
     print '<h3>Url:</h3>' . $this->last;
     if (strpos($this->last, ' ')) {
         print '<br/><b style="color:red">Warning:</b> You have a space in your url';
     }
     print '<h3>Method:</h3>' . $method;
     if ($method == 'Post') {
         print '<h2>Post Data:</h2>';
         foreach ($post as $key => $val) {
             print "[<em>{$key}</em>] => {$val}<br/>";
         }
     }
     print '<h3>Format:</h3>' . $this->format;
     print '<h3>Response Data:</h3>';
     // print data
     if ($this->format == 'json') {
         print Kohana::debug(json_decode($data));
     } else {
         if ($this->format == 'xml') {
             print nl2br(htmlentities($data));
         } else {
             print $data;
         }
     }
     // call Profiler
     new Profiler();
 }
Пример #18
0
 public function open_bill_detail($openBillId)
 {
     //权限检查 得到所有可管理站点ID列表
     role::check('card_system_manage');
     if ($openBillId == null) {
         remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error');
         return;
     }
     $openBill = $this->issueBillDao->get_by_id($openBillId);
     if ($openBill == null) {
         remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error');
         return;
     }
     $this->template->content = new View("card/open_bill_detail");
     $this->template->content->openBill = $openBill;
     $this->template->content->channelList = $this->salesChannelMap;
 }
Пример #19
0
 public function detail($cardId)
 {
     //权限检查 得到所有可管理站点ID列表
     role::check('card_system_manage');
     if ($cardId == null) {
         remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error');
         return;
     }
     $card = $this->cardDao->get_by_id($cardId);
     if ($card == null) {
         remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error');
         return;
     }
     $this->template->content = new View("card/card_detail");
     $this->template->content->card = $card;
 }
Пример #20
0
 /**
  * 改变留言状态
  */
 function do_active($id)
 {
     //权限验证
     role::check('contact_us_manage');
     if (!$id) {
         remind::set(Kohana::lang('o_global.bad_request'), 'user/contact_us');
     }
     $contact_us = Mycontact_us::instance($id)->get();
     $data = array();
     $data['active'] = $contact_us['active'] == 1 ? 0 : 1;
     if (Mycontact_us::instance($id)->edit($data)) {
         remind::set(Kohana::lang('o_global.update_success'), request::referrer(), 'success');
     } else {
         remind::set(Kohana::lang('o_global.update_error'), request::referrer(), 'error');
     }
 }
Пример #21
0
 public function do_delete_all()
 {
     role::check('promotion_coupon');
     $coupon_id_array = $this->input->post('id');
     if (!(is_array($coupon_id_array) && count($coupon_id_array))) {
         remind::set(Kohana::lang('o_promotion.select_cpn'), request::referrer(), 'error');
     }
     $count = 0;
     $false_count = 0;
     foreach ($coupon_id_array as $key => $coupon_id) {
         // 验证 - 数据有效性
         $coupon = Mycoupon::instance($coupon_id)->get();
         if (!$coupon['id']) {
             $false_count++;
             continue;
         }
         if (Mycoupon::instance()->delete($coupon_id)) {
             $count++;
         } else {
             $false_count++;
         }
     }
     if ($false_count) {
         remind::set(Kohana::lang('o_promotion.have') . $false_count . Kohana::lang('o_promotion.num_cpn_cannot_delete'), request::referrer(), 'error');
     } else {
         remind::set(Kohana::lang('o_promotion.success_delete') . $count . Kohana::lang('o_promotion.num_cpn'), request::referrer(), 'success');
     }
 }
Пример #22
0
 /**
  * 虚拟充值
  * @param unknown_type $id
  */
 function recharge_virtual_money($id)
 {
     //权限检查 得到所有可管理站点ID列表
     role::check('user_recharge');
     if ($_POST) {
         //标签过滤
         tool::filter_strip_tags($_POST);
         $userobj = user::get_instance();
         $usermoney = $userobj->get_user_virtual_money($id);
         if ($_POST['money'] > 0) {
             $money_type_name = '竞波币';
             //记录日志
             $data_log = array();
             $data_log['order_num'] = date('YmdHis') . rand(0, 99999);
             $data_log['user_id'] = $id;
             $data_log['log_type'] = 6;
             //参照config acccount_type 设置
             $data_log['is_in'] = 0;
             $data_log['price'] = $_POST['money'];
             $data_log['user_money'] = $usermoney;
             $data_log['memo'] = $_POST['memo'];
             account_virtual_log::get_instance()->add($data_log);
             //$um = user_money::get_instance()->update_money($data_log['is_in'], $data_log['user_id'], $data_log['price'], $data_log['log_type'], $data_log['order_num'], $money_type, $data_log['memo']);
             //添加日志
             $logs_data = array();
             $logs_data['manager_id'] = $this->manager_id;
             $logs_data['user_log_type'] = 29;
             $logs_data['ip'] = tool::get_long_ip();
             $logs_data['memo'] = "成功为用户{$id}充值{$money_type_name}{$_POST['money']}";
             ulog::instance()->add($logs_data);
             remind::set($money_type_name . '充值成功', request::referrer(), 'success');
         }
     }
     $this->template->content = new View("user/user_recharge_virtual");
     $this->template->content->data = Myuser::instance($id)->get();
 }
Пример #23
0
 /**
  * 删除
  */
 public function do_delete($id)
 {
     $total_products = 0;
     $total = 0;
     if (!$id) {
         remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error');
     }
     //验证
     $order_product_service = Order_productService::get_instance();
     $data = $order_product_service->get($id);
     if (!$data['id']) {
         remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error');
     }
     if ($order_product_service->remove($data['id'])) {
         if (Myorder::instance($data['order_id'])->update_total()) {
             remind::set(Kohana::lang('o_global.delete_success'), 'order/order/edit/id/' . $data['order_id'], 'success');
         } else {
             remind::set(Kohana::lang('o_global.delete_error'), 'order/order/edit/id/' . $data['order_id'], 'error');
         }
     } else {
         remind::set(Kohana::lang('o_global.delete_error'), 'order/order/edit/id/' . $data['order_id'], 'error');
     }
 }
Пример #24
0
 public function delete($cardIssueSerialId)
 {
     //权限检查 得到所有可管理站点ID列表
     role::check('card_system_manage');
     $cardIssueSerial = $this->cardIssueSerialDao->get_by_id($cardIssueSerialId);
     if ($cardIssueSerial == null) {
         remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error');
         return;
     }
     // check the sub cards' flag
     $where = array();
     $where['mgrnum >='] = $cardIssueSerial['bgnnum'];
     $where['mgrnum <='] = $cardIssueSerial['endnum'];
     $where['flag'] = Ac_card_Model::FLAG_ISSUED;
     $cardCount = $this->cardDao->count_items_with_condition($where);
     if ($cardCount != $cardIssueSerial['endnum'] - $cardIssueSerial['bgnnum'] + 1) {
         remind::set('该发行批次的卡中,存在已被使用的卡, 不能删除该批次', request::referrer(), 'error');
         return;
     }
     // update the sub cards' flag
     $newValues = array();
     $newValues['flag'] = Ac_card_Model::FLAG_UNISSUE;
     $newValues['issueid'] = 0;
     //		$newValues['issuetime'] = null;
     $newValues['updtime'] = date("Y-m-d H:i:s", time());
     if ($this->cardDao->batch_update($newValues, $where) == false) {
         remind::set('更新卡状态失败', request::referrer(), 'error');
         return;
     }
     // update the issueBill flag
     $updBillData = array();
     $updBillData['id'] = $cardIssueSerial['billid'];
     $updBillData['flag'] = Ac_issuebill_Model::FLAG_DELETED;
     $updBillData['updtime'] = date("Y-m-d H:i:s", time());
     $this->issueBillDao->edit($updBillData);
     // delete the card issue serial
     if ($this->cardIssueSerialDao->delete($cardIssueSerialId) == false) {
         remind::set(Kohana::lang('o_global.delete_error'), request::referrer(), 'error');
         return;
     }
     $aLog = array();
     $aLog['userid'] = $this->manager['id'];
     $aLog['apdtime'] = date('Y-m-d H:i:s', time());
     $aLog['target'] = Ac_cardlog_Model::TARGET_CARD_ISSUE;
     $aLog['targetid'] = $cardIssueSerialId;
     $aLog['action'] = Ac_cardlog_Model::ACTION_REMOVE;
     $aLog['detail'] = 'Del the cardIssueSerial: ' . $cardIssueSerialId . '(' . $cardIssueSerial['bgnnum'] . '-' . $cardIssueSerial['endnum'] . ')';
     $this->cardLogDao->add($aLog);
     remind::set(Kohana::lang('o_global.delete_success'), 'card/card_issue_serial', 'success');
 }
Пример #25
0
 public function do_edit()
 {
     // 收集请求数据
     $request_data = $this->input->post();
     $session = Session::instance();
     $session->set_flash('sessionErrorData', $request_data);
     //标签过滤
     tool::filter_strip_tags($request_data);
     $pmts_id = $this->input->post('pmts_id');
     $promotion = Mypromotion::instance($request_data['id'])->get();
     if (!$promotion['id']) {
         remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error');
     }
     //促销规则时间效验
     if (strtotime($request_data['time_end']) + 24 * 3600 < time()) {
         remind::set(Kohana::lang('o_promotion.time_end'), request::referrer(), 'error');
     }
     if (strtotime($request_data['time_begin']) > strtotime($request_data['time_end'])) {
         remind::set(Kohana::lang('o_promotion.begin_time_over_end'), request::referrer(), 'error');
     }
     $dayTimeStamp = 24 * 3600;
     $request_data['time_end'] = date('Y-m-d H:i:s', strtotime($request_data['time_end']) + $dayTimeStamp);
     $time_begin = strtotime($request_data['time_begin']);
     $time_end = strtotime($request_data['time_end']);
     //促销规则时间必须在促销活动时间内
     $promotion_activity = Mypromotion_activity::instance($promotion['pmta_id'])->get();
     if (!$promotion_activity['id']) {
         remind::set(Kohana::lang('o_global.access_denied'), request::referrer(), 'error');
     }
     $pmta_time_begin = strtotime($promotion_activity['pmta_time_begin']);
     $pmta_time_end = strtotime($promotion_activity['pmta_time_end']);
     if ($pmta_time_begin > $time_begin || $pmta_time_end < $time_end) {
         remind::set(Kohana::lang('o_promotion.promotion_out_time_range'), request::referrer(), 'error');
     }
     //验证打折值与订单优惠条件
     if (isset($request_data['discount_type'])) {
         if (isset($request_data['price']) && (!preg_match('/^\\d{1,12}(\\.\\d{0,3})?$/', $request_data['price']) || $request_data['price'] < 0)) {
             remind::set(Kohana::lang('o_promotion.cpn_price_error'), request::referrer(), 'error');
         }
         if ($request_data['discount_type'] == 0 && $request_data['price'] > 1) {
             remind::set(Kohana::lang('o_promotion.cpn_price_error'), request::referrer(), 'error');
         }
     }
     if (isset($request_data['quantity_from']) && (!preg_match('/^\\d+$/', $request_data['quantity_from']) || $request_data['quantity_from'] < 0) || isset($request_data['quantity_to']) && (!preg_match('/^\\d+$/', $request_data['quantity_to']) || $request_data['quantity_to'] < 0) || isset($request_data['quantity_from']) && $request_data['quantity_from'] >= $request_data['quantity_to']) {
         remind::set(Kohana::lang('o_promotion.buy_quantitys_error'), request::referrer(), 'error');
     }
     $moneyError = '';
     // extra process needed for IDs
     switch ($pmts_id) {
         case 5:
             // get_gifts_buy_anything
         // get_gifts_buy_anything
         case 6:
             // get_gifts_price_morethan
             $moneyError = '订单金额错误';
             $gift_related_ids = $this->input->post('gift_related_ids');
             if (empty($gift_related_ids)) {
                 remind::set(Kohana::lang('o_promotion.select_gift'), request::referrer(), 'error');
             }
             $request_data['gift_related_ids'] = Mypromotion::enclose_ids($gift_related_ids, ',');
             break;
         case 1:
             // discount_category
             $related_ids = $this->input->post('related_ids');
             if (empty($related_ids)) {
                 remind::set(Kohana::lang('o_promotion.select_cpn_category'), request::referrer(), 'error');
             }
             empty($moneyError) && ($moneyError = '订单金额错误');
         case 2:
             // discount_product_during
             empty($moneyError) && ($moneyError = '订单金额错误');
         case 3:
             // discount_product_quantity_morethan
         // discount_product_quantity_morethan
         case 12:
             // discount_cart_buy_product
         // discount_cart_buy_product
         case 16:
             // free_shipping_buy_product
             if (!isset($related_ids)) {
                 $related_ids = $this->input->post('related_ids');
             }
             if (empty($related_ids)) {
                 remind::set(Kohana::lang('o_promotion.select_product'), request::referrer(), 'error');
             }
             // enclose selected category ids with comma
             $request_data['related_ids'] = Mypromotion::enclose_ids($related_ids, ',');
             break;
         case 7:
             // get_gifts_product_price_morethan
             $related_ids = $this->input->post('related_ids');
             $gift_related_ids = $this->input->post('gift_related_ids');
             empty($moneyError) && ($moneyError = '货品金额错误');
             if (empty($related_ids)) {
                 remind::set(Kohana::lang('o_promotion.select_product'), request::referrer(), 'error');
             }
             if (empty($gift_related_ids)) {
                 remind::set(Kohana::lang('o_promotion.select_gift'), request::referrer(), 'error');
             }
             // enclose selected category ids with comma
             $request_data['related_ids'] = Mypromotion::enclose_ids($related_ids, ',');
             $request_data['gift_related_ids'] = Mypromotion::enclose_ids($gift_related_ids, ',');
             break;
         case 8:
             // get_1_buy_n
             break;
         case 9:
             // get_another_cat_buy_cat
             $related_ids = $this->input->post('related_ids');
             $gift_related_ids = $this->input->post('gift_related_ids');
             if (empty($related_ids)) {
                 remind::set(Kohana::lang('o_promotion.select_cpn_category'), request::referrer(), 'error');
             }
             if (empty($gift_related_ids)) {
                 remind::set(Kohana::lang('o_promotion.select_gift_category'), request::referrer(), 'error');
             }
             // separate selected category ids with comma
             $request_data['related_ids'] = Mypromotion::enclose_ids($related_ids, ',');
             $request_data['gift_related_ids'] = Mypromotion::enclose_ids($gift_related_ids, ',');
             break;
         case 10:
             // get_catgift_price_morethan
             $gift_related_ids = $this->input->post('gift_related_ids');
             empty($moneyError) && ($moneyError = '订单金额错误');
             if (empty($gift_related_ids)) {
                 remind::set(Kohana::lang('o_promotion.select_gift_category'), request::referrer(), 'error');
             }
             // separate selected category ids with comma
             $request_data['gift_related_ids'] = Mypromotion::enclose_ids($gift_related_ids, ',');
             break;
         case 11:
             empty($moneyError) && ($moneyError = '购物车金额错误');
             break;
         case 14:
             empty($moneyError) && ($moneyError = '订单金额错误');
             break;
     }
     //验证
     if (isset($request_data['money_from']) && (!preg_match('/^\\d{1,12}(\\.\\d{0,3})?$/', $request_data['money_from']) || $request_data['money_from'] < 0) || isset($request_data['money_to']) && (!preg_match('/^\\d{1,12}(\\.\\d{0,3})?$/', $request_data['money_to']) || $request_data['money_to'] < 0) || isset($request_data['money_from']) && $request_data['money_from'] >= $request_data['money_to']) {
         remind::set($moneyError, request::referrer(), 'error');
     }
     if (Mypromotion::instance()->edit($request_data)) {
         $session->delete('sessionErrorData');
         //promotion::delete_memcache($promotion['site_id']);
         remind::set(Kohana::lang('o_global.update_success'), "promotion/promotion_activity", 'success');
     } else {
         remind::set(Kohana::lang('o_global.update_error'), request::referrer(), 'error');
     }
 }
Пример #26
0
 public function delete($salesChannelId)
 {
     //权限检查 得到所有可管理站点ID列表
     role::check('card_system_manage');
     $salesChannel = $this->salesChannelDao->get_by_id($salesChannelId);
     if ($salesChannel == null) {
         remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error');
         return;
     }
     $where = array();
     $where['channelid'] = $salesChannelId;
     $count = $this->cardIssueSerialDao->count_items_with_condition($where);
     if ($count > 0) {
         remind::set('仍有卡发行依赖该渠道,不能删除', request::referrer(), 'error');
         return;
     }
     if ($this->salesChannelDao->delete($salesChannelId)) {
         $aLog = array();
         $aLog['userid'] = $this->manager['id'];
         $aLog['apdtime'] = date('Y-m-d H:i:s', time());
         $aLog['target'] = Ac_cardlog_Model::TARGET_SALE_CHANNEL;
         $aLog['targetid'] = $salesChannelId;
         $aLog['action'] = Ac_cardlog_Model::ACTION_REMOVE;
         $aLog['detail'] = 'Del the saleChannel: ' . $salesChannelId;
         $this->cardLogDao->add($aLog);
         remind::set(Kohana::lang('o_global.delete_success'), 'card/sales_channel', 'success');
         return;
     }
     remind::set(Kohana::lang('o_global.delete_error'), 'card/sales_channel', 'error');
 }
Пример #27
0
 function del_country()
 {
     $return_struct = array();
     $request_data = $this->input->get();
     // 修改返回状态数据
     $return_struct['status'] = 1;
     $return_struct['code'] = 200;
     $return_struct['msg'] = 'ok';
     $delivery_service = DeliveryService::get_instance();
     $delivery_country_service = Delivery_countryService::get_instance();
     if (empty($request_data['delivery_id']) or empty($request_data['ids'])) {
         remind::set(Kohana::lang('o_global.access_denied'), request::referrer(), 'error');
     }
     $delivery = $delivery_service->get($request_data['delivery_id']);
     if ($delivery['site_id'] != $this->site_id) {
         remind::set(Kohana::lang('o_global.access_denied'), request::referrer(), 'error');
     }
     $query_ids = explode('-', $request_data['ids']);
     foreach ($query_ids as $ids) {
         $delivery_countries = $delivery_country_service->get($ids);
         if ($delivery_countries['delivery_id'] != $delivery['id']) {
             remind::set(Kohana::lang('o_global.access_denied'), request::referrer(), 'error');
             break;
         }
         if (!$delivery_country_service->remove($ids)) {
             $return_struct['status'] = 0;
             $return_struct['code'] = 501;
             break;
         }
     }
     header('Content-Type: text/javascript; charset=UTF-8');
     exit(json_encode($return_struct));
 }
Пример #28
0
 /**
  * 改变留言状态
  */
 function do_active($id)
 {
     //权限验证
     role::check('user_show');
     if (!$id) {
         remind::set(Kohana::lang('o_global.bad_request'), 'user/user_show');
     }
     $db = Database::instance();
     $data = array_shift($db->query('SELECT * FROM user_show WHERE id=' . $id)->result_array(false));
     if ($data['id'] <= 0) {
         remind::set(Kohana::lang('o_global.bad_request'), 'user/user_show');
     }
     $status = $data['status'] == 1 ? 0 : 1;
     $sql = "UPDATE user_show SET status='" . $status . "' WHERE id='" . $id . "' ";
     if ($db->query($sql)) {
         remind::set(Kohana::lang('o_global.update_success'), request::referrer(), 'success');
     } else {
         remind::set(Kohana::lang('o_global.update_error'), request::referrer(), 'error');
     }
 }
Пример #29
0
 /**
  * Delete image
  * @return void
  * @param integer id of item
  * @param integer id of picture
  * @param string dir with images
  */
 public function delete_image($id, $image, $dir)
 {
     // Check for user permission
     if (user::is_got()) {
         // Page settings
         $this->set_title(Kohana::lang('gallery.delete_image'));
         $this->add_breadcrumb(Kohana::lang('gallery.delete_image'), url::current());
         // Set redirect URL
         if (isset($_POST['redirect'])) {
             $redirect = $_POST['redirect'];
         } else {
             $redirect = request::referrer();
         }
         $form = array('redirect' => $redirect);
         if ($_POST) {
             if (isset($_POST['yes'])) {
                 // Clicked on yes = delete image
                 unlink('./data/' . $dir . '/' . $id . '_' . $image . '.jpg');
                 unlink('./data/' . $dir . '/' . $id . '_' . $image . '_m.jpg');
                 url::redirect($form['redirect']);
             } else {
                 url::redirect($form['redirect']);
             }
         }
         // View
         $this->template->content = new View('admin/delete_image');
         $this->template->content->form = $form;
     }
 }
Пример #30
0
 /**
  * 建站流程中的添加新支付
  */
 function do_flow_add()
 {
     //权限验证
     //$this->profiler = new Profiler;
     $site_id_list = role::check('manage_payment');
     $payment_type_ids = $_POST['payment_type_id'];
     foreach ((array) $payment_type_ids as $key => $payment_type_id) {
         $data = array();
         $data['manager_id'] = role::root_manager_id();
         $data['payment_type_id'] = $payment_type_id;
         $data['account'] = $this->input->post('account') ? $this->input->post('account') : '';
         switch ($payment_type_id) {
             case '1':
             case '2':
                 $data['account'] = '';
                 $payment = Mypayment::instance();
                 if ($payment->payment_exist($data)) {
                     remind::set(Kohana::lang('o_global.you_have_this_payment'), '', 'error');
                     break;
                 }
                 if ($payment->add($data)) {
                     remind::set(Kohana::lang('o_global.add_success'), '', 'success');
                 } else {
                     remind::set(Kohana::lang('o_global.add_error'), request::referrer(), 'error');
                 }
                 break;
             case '3':
             case '4':
                 $payment = Mypayment::instance();
                 if ($payment->payment_exist($data)) {
                     remind::set(Kohana::lang('o_global.you_have_this_payment'), '', 'error');
                     break;
                 }
                 if ($payment->add($data)) {
                     remind::set(Kohana::lang('o_global.add_success'), '', 'success');
                 } else {
                     remind::set(Kohana::lang('o_global.add_error'), request::referrer(), 'error');
                 }
                 break;
         }
     }
     url::redirect('manage/site_payment');
 }