示例#1
0
 public static function is_allowed($permission = 'default', $site_id = 0, $type = NULL)
 {
     $verify = true;
     $site_ids = role::get_site_ids($type);
     //超级管理员root不需要检查权限 zhu modify
     if (role::is_root()) {
         $verify = true;
     } else {
         if ($site_id > 0 && !in_array($site_id, $site_ids)) {
             $verify = false;
         }
         $acl = Session::instance()->get(self::$acl_tag);
         if ($acl) {
             $acl = unserialize($acl);
         } else {
             $acl = self::acl_init();
         }
         $manager = role::get_manager();
         $verify = $acl->is_allowed($manager["username"], $permission);
     }
     //验证操作
     if ($verify) {
         return $site_ids;
     } else {
         if (request::is_ajax()) {
             $return_struct = array('status' => 0, 'code' => 501, 'msg' => Kohana::lang('o_global.access_denied'), 'content' => array());
             die(json_encode($return_struct));
         } else {
             $referrer = tool::referrer_url();
             remind::set('权限不足', $referrer, 'error');
         }
     }
 }
示例#2
0
 public function index($status = NULL)
 {
     //权限检查 得到所有可管理站点ID列表
     role::check('contact_us');
     $this->template->content = new View("user/contact_us_list");
     //搜索功能
     $search_arr = array('id', 'email', 'name', 'message', 'ip');
     $where = array();
     $where_view = array();
     if ($search_arr) {
         foreach ($search_arr as $search_value) {
             if ($this->input->get('search_type') == $search_value && strlen($this->input->get('search_value'))) {
                 $where[$search_value] = $this->input->get('search_value');
                 if ($search_value == 'ip') {
                     $where[$search_value] = tool::myip2long($this->input->get('search_value'));
                 }
             }
         }
         $where_view['search_type'] = $this->input->get('search_type');
         $where_view['search_value'] = $this->input->get('search_value');
     }
     //列表排序
     $orderby_arr = array(0 => array('id' => 'DESC'), 1 => array('id' => 'ASC'), 2 => array('id' => 'ASC'), 3 => array('id' => 'DESC'), 4 => array('email' => 'ASC'), 5 => array('email' => 'DESC'), 6 => array('name' => 'ASC'), 7 => array('name' => 'DESC'), 8 => array('message' => 'ASC'), 9 => array('message' => 'DESC'), 10 => array('date_add' => 'ASC'), 11 => array('date_add' => 'DESC'), 12 => array('ip' => 'ASC'), 13 => array('ip' => 'DESC'));
     $orderby = controller_tool::orderby($orderby_arr);
     //每页显示条数
     $per_page = controller_tool::per_page();
     //调用分页
     if (isset($status) && $status == 'active') {
         $where['active'] = 1;
     }
     $this->pagination = new Pagination(array('total_items' => Mycontact_us::instance()->count($where), 'items_per_page' => $per_page));
     //调用列表
     $this->template->content->contact_us_list = Mycontact_us::instance()->contact_uses($where, $orderby, $per_page, $this->pagination->sql_offset);
     $this->template->content->where = $where_view;
 }
示例#3
0
 public static function send($order_id)
 {
     $order = Myorder::instance($order_id)->get();
     $order['order_product_detail'] = Myorder_product::instance()->order_product_details(array('order_id' => $order['id']));
     $order['skulist'] = '';
     $order['qlist'] = '';
     $order['amtlist'] = '';
     $order['source'] = '1';
     $skulist = array();
     $qlist = array();
     $amtlist = array();
     foreach ($order['order_product_detail'] as $key => $order_product_detail) {
         $skulist[] = $order_product_detail['SKU'];
         $qlist[] = $order_product_detail['quantity'];
         $amtlist[] = $order_product_detail['discount_price'];
     }
     $order['skulist'] = implode("|", $skulist);
     $order['qlist'] = implode("|", $qlist);
     $order['amtlist'] = implode("|", $amtlist);
     $post_url = "http://af.statcount.org/order/";
     $post_var = "order=" . $order['order_num'] . "&amount=" . $order['total_real'] . "&skulist=" . $order['skulist'] . "&qlist=" . $order['qlist'] . "&amtlist=" . $order['amtlist'] . "&cur=" . $order['currency'] . "&source=" . $order['source'];
     $result = tool::curl_pay($post_url, $post_var);
     if (stristr($result == 'SUCCESS')) {
         return true;
     } else {
         return false;
     }
 }
示例#4
0
 public static function store($value)
 {
     if (\tool::debug()) {
         \tool::fprint("Storing " . get_called_class() . ":{$value}");
     }
     return Writer::convert('d', $value);
 }
示例#5
0
 public function getList()
 {
     $typeList = array();
     $typeList['catering'] = "餐饮";
     $typeList['variety'] = "便利店";
     $type = tool::getParams('type', '');
     $name = $typeList[$type];
     $searchType = "3";
     $key = isset($_GET['key']) ? trim($_GET['key']) : null;
     //这里是一个坐标值
     $pageNum = isset($_GET['page']) ? trim($_GET['page']) - 1 : 0;
     // $name = "便利店";
     // $key  = "24.459657,118.087648"; //老虎城
     $response = $this->poi->getList($name, $searchType, $key, $pageNum);
     $response = json_decode($response, true);
     if ($response['status'] != 0) {
         $this->send(array('result' => 'fail', 'message' => $response['message']));
     }
     // 返回错误信息.同时记录日志 message
     $list = array();
     $data = $response['results'];
     foreach ($data as $key => $val) {
         $location = $val['location'];
         $item = $value;
         unset($item['location']);
         $item['location'] = $location['lat'] . ',' . $location['lng'];
         $list[$key] = $item;
     }
     $this->send(array('result' => 'success', 'message' => '成功', 'data' => $list));
 }
示例#6
0
 public function add()
 {
     if ($_POST) {
         //标签过滤
         tool::filter_strip_tags($_POST, array('content'));
         $site_next_flow = site::site_next_flow($this->current_flow);
         $submit_target = intval($this->input->post('submit_target'));
         $faq = Myfaq::instance();
         if ($faq->add($_POST)) {
             //判断添加成功去向
             switch ($submit_target) {
                 case 1:
                     remind::set(Kohana::lang('o_global.add_success'), 'site/faq/add', 'success');
                 case 2:
                     remind::set(Kohana::lang('o_global.add_success'), $site_next_flow['url'], 'success');
                 default:
                     remind::set(Kohana::lang('o_global.add_success'), 'site/faq', 'success');
             }
         } else {
             remind::set(Kohana::lang('o_global.add_error'), 'site/faq/add');
         }
     }
     $this->template->content = new View("site/faq_add");
     $this->template->content->title = "site faq add";
 }
示例#7
0
 /**
  * 模块编辑
  */
 public function edit($id)
 {
     $mail_category = Mymail_category::instance($id)->get();
     if (!$mail_category['id']) {
         remind::set(Kohana::lang('o_manage.category_not_exist'), 'manage/mail_category');
     }
     if ($_POST) {
         //标签过滤
         tool::filter_strip_tags($_POST);
         $flag = $this->input->post('flag');
         $data = Mymail_category::instance()->get_by_flag($flag);
         if ($flag != $mail_category['flag']) {
             if ($data['id']) {
                 remind::set(Kohana::lang('o_manage.category_mark_exist'), 'manage/mail_category/add');
             }
         }
         if (Mymail_category::instance($id)->edit($_POST)) {
             remind::set(Kohana::lang('o_global.update_success'), 'manage/mail_category', 'success');
         } else {
             remind::set(Kohana::lang('o_global.update_error'), 'manage/mail_category');
         }
     }
     $this->template->content = new View("manage/mail_category_edit");
     $this->template->content->data = $mail_category;
 }
示例#8
0
 public function __construct($name = null, $content = array())
 {
     \tool::fprint("Creating " . get_called_class() . (count($content) ? " with " . count($content) . " elements" : ''));
     parent::__construct();
     $this->name = $name;
     $this->content = $content ? (array) $content : array();
 }
 /**
  * 更新或添加信息
  *
  * @param  array $data 数据包
  * @return true or false
  */
 public function add($data)
 {
     $obj = ORM::factory('account_virtual_log');
     if (!$obj->validate($data)) {
         return FALSE;
     }
     !empty($data['order_num']) && ($obj->order_num = $data['order_num']);
     $obj->user_id = $data['user_id'];
     $obj->log_type = $data['log_type'];
     empty($data['is_in']) && ($data['is_in'] = 0);
     $obj->is_in = $data['is_in'];
     $obj->price = $data['price'];
     $obj->user_money = $data['user_money'];
     $obj->memo = $data['memo'];
     $obj->method = serialize(array('url' => 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER["REQUEST_URI"], 'method' => $_SERVER['REQUEST_METHOD']));
     $obj->ip = tool::get_str_ip();
     $obj->save();
     if ($obj->saved) {
         //更新用户表金额
         $userobj = user::get_instance();
         if ($data['is_in'] == 0) {
             $usermoney = $obj->user_money + $obj->price;
         } else {
             $usermoney = $obj->user_money - $obj->price;
         }
         $userobj->update_virtual_money($data['user_id'], $usermoney);
         return TRUE;
     } else {
         return FALSE;
     }
 }
示例#10
0
 public function save(SplFileObject $file)
 {
     $result = parent::save($file);
     if (isset($this->type)) {
         $result += $file->fwrite(Dictionary::mapName($this->type));
     } else {
         if (count($this->content)) {
             throw new UnexpectedValueException('Populated list needs an explicit type cast.');
         } else {
             $result += $file->fwrite(Dictionary::mapName('TAG_End'));
         }
     }
     $result += $file->fwrite(TAG_Int::store(count($this->content)));
     if (\tool::debug()) {
         \tool::fprint("Storing " . count($this->content) . " values of type {$this->type} @{$file->ftell()} ...");
     }
     $type = $this->type;
     foreach ($this->content as $index => $tag) {
         if (!is_object($tag)) {
             $result += $file->fwrite($type::store($tag));
         } else {
             if ($tag instanceof $this->type) {
                 if (isset($tag->name)) {
                     throw new UnexpectedValueException("List#{$index} is a named tag.");
                 }
                 $result += $tag->save($file);
             } else {
                 throw new UnexpectedValueException("List#{$index} type '" . get_class($tag) . "' doesn't match the list type '{$this->type}'.");
             }
         }
     }
     return $result;
 }
示例#11
0
 /**
  * 模块编辑
  */
 public function edit($id)
 {
     $mail_template = Mymail_template::instance($id)->get();
     if (!$mail_template['id']) {
         remind::set(Kohana::lang('o_manage.template_not_exist'), 'manage/mail_template');
     }
     if ($_POST) {
         //标签过滤
         tool::filter_strip_tags($_POST);
         if (Mymail_template::instance($id)->edit($_POST)) {
             remind::set(Kohana::lang('o_global.update_success'), 'manage/mail_template', 'success');
         } else {
             remind::set(Kohana::lang('o_global.update_error'), 'manage/mail_template');
         }
     }
     $mail_categories = Mymail_category::instance()->mail_categories();
     foreach ($mail_categories as $key => $value) {
         if ($value['id'] == $mail_template['mail_category_id']) {
             $mail_categories[$key]['selected'] = 'selected';
         } else {
             $mail_categories[$key]['selected'] = '';
         }
     }
     $this->template->content = new View("manage/mail_template_edit");
     $this->template->content->data = $mail_template;
     $this->template->content->mail_categories = $mail_categories;
 }
示例#12
0
 /**
  * 改变状态
  */
 function do_active($id)
 {
     //权限验证
     role::check('user_charge');
     if (!$id) {
         remind::set(Kohana::lang('o_global.bad_request'), 'user/user_charge');
     }
     $db = Database::instance();
     $data = array_shift($db->query('SELECT * FROM user_charge_order WHERE id=' . $id)->result_array(false));
     if ($data['id'] <= 0 || $data['status'] > 0) {
         remind::set(Kohana::lang('o_global.bad_request'), 'user/user_charge');
     }
     $logodata = array();
     $logodata['manager_id'] = $this->manager_id;
     $logodata['ip'] = tool::get_str_ip();
     $logodata['user_log_type'] = 27;
     $logodata['method'] = __CLASS__ . '::' . __METHOD__ . '()';
     $logodata['memo'] = "充值订单号:" . $data['order_num'] . ", 购买拍点数:" . $data['price'] . ", 充值金额:" . $data['money'];
     $sql = "UPDATE user_charge_order SET status=1 WHERE id='" . $id . "' ";
     if ($db->query($sql)) {
         //充值用户Money
         $sql_reward = "UPDATE users \r\n                            SET user_money = user_money+" . $data['price'] . "\r\n                            WHERE id='" . $data['user_id'] . "'\r\n                          ";
         $db->query($sql_reward);
         //操作log
         ulog::add($logodata);
         remind::set(Kohana::lang('o_global.update_success'), 'user/user_charge', 'success');
     } else {
         //操作log
         ulog::add($logodata, 1);
         remind::set(Kohana::lang('o_global.update_error'), 'user/user_charge', 'error');
     }
 }
示例#13
0
 public function edit($cardTypeId)
 {
     //权限检查 得到所有可管理站点ID列表
     role::check('card_system_manage');
     if ($cardTypeId == null) {
         remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error');
         return;
     }
     $cardType = $this->cardTypeDao->get_by_id($cardTypeId);
     if ($cardType == null) {
         remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error');
         return;
     }
     if ($_POST) {
         $data = $_POST;
         $data['id'] = $cardType['id'];
         $data['name'] = $_POST['name'];
         //标签过滤
         tool::filter_strip_tags($data);
         if ($this->cardTypeDao->edit($data)) {
             remind::set(Kohana::lang('o_global.update_success'), 'card/card_type', 'success');
         } else {
             remind::set(Kohana::lang('o_global.update_error'), request::referrer(), 'error');
         }
     }
     $this->template->content = new View("card/card_type_edit");
     $this->template->content->cardType = $cardType;
 }
示例#14
0
 /**
  * 计算出彩票的注数 适用于竞彩部分
  * Enter description here ...
  * @param unknown_type $code
  * codes:46:[1,2]/47:[胜]/48:[胜]/49:[胜]
  * @param unknown_type $chuanfa
  * 2串1
  */
 public function zhushu($codes, $chuanfa)
 {
     $arrcode = explode('/', $codes);
     if ($chuanfa == '单关') {
         $chuan_code = 1;
     } else {
         $chuans = explode('串', $chuanfa);
         $chuan_code = $chuans[0] . $chuans[1];
     }
     $zhushu_info = self::$zhushufenpei[$chuan_code];
     $return = 0;
     for ($i = 0; $i < count($zhushu_info); $i++) {
         if ($zhushu_info[$i] > 0) {
             $j = $i + 1;
             $r = tool::get_combination($arrcode, $j, '/');
             for ($k = 0; $k < count($r); $k++) {
                 $code_t1 = explode('/', $r[$k]);
                 $match_re = 1;
                 for ($l = 0; $l < count($code_t1); $l++) {
                     $t1 = explode(':', $code_t1[$l]);
                     $match_no = $t1[0];
                     $no_len = strlen($match_no) + 2;
                     $t2 = substr(substr($code_t1[$l], $no_len), 0, -1);
                     $t3 = explode(',', $t2);
                     $match_re *= count($t3);
                 }
                 $return += $match_re;
             }
         }
     }
     return $return;
 }
示例#15
0
文件: tool.php 项目: gittrue/VIF
 public static function getInstance()
 {
     if (self::$Instance == NULL) {
         $class = __CLASS__;
         self::$Instance = new $class();
     }
     return self::$Instance;
 }
示例#16
0
 function comment_js_action() {
     front::check_type(front::get('aid'));
     $comment=new comment();
     $this->view->comments=$comment->getrows('state=1 and aid='.front::get('aid'),20,'1');
     $this->view->aid=front::get('aid');
     echo  tool::text_javascript($this->fetch());
     exit;
 }
示例#17
0
 /**
  * 发起团
  * http://localhost/beauty/index.php?m=ruan&c=index&a=create
  */
 public function create()
 {
     $data = tool::getParams("data", '');
     $data['created'] = strtotime(date('Y-m-d H:i:s'));
     $data['orderNum'] = 0;
     $result = parent::save($data);
     echo json_encode(array('code' => '0', 'message' => '成功', 'data' => $result));
 }
 public function write(Tag $tag)
 {
     \tool::fprint("Writing ... " . get_called_class() . "@{$this->file->ftell()}");
     $tmp = new SplFileObject('php://memory', 'wb+');
     $tag->save($tmp);
     $pos = $tmp->ftell();
     $tmp->fseek(0);
     return $this->file->fwrite(gzencode($tmp->fread($pos), 9, FORCE_GZIP));
 }
示例#19
0
 /**
  * 用户昵称是否存在
  * http://local.meizai.com/api.php?m=user&a=checknickname&nickname=aaa
  */
 public function checkNickname()
 {
     $nickname = tool::getParams('nickname', '');
     $data = $this->dao->select("*")->from(TABLE_USER)->where('nickname')->eq($nickname)->fetch();
     if ($data) {
         $this->send(array('result' => 'fail', 'message' => '昵称已经存在'));
     }
     $this->send(array('result' => 'success', 'message' => '昵称不存在'));
 }
示例#20
0
 public function getAllNavPrice()
 {
     $all = parent::select(array('id', 'price_left', 'price_right'), array('order' => ' price_left ASC,price_right ASC '));
     foreach ($all as $value) {
         $value->price = '';
         $value->price .= $value->price_left . '-' . $value->price_right;
     }
     return tool::setFormItem($all, 'price', 'price');
 }
示例#21
0
 public function index()
 {
     $user_query_struct = array('where' => array(), 'like' => array(), 'orderby' => array(), 'limit' => array('per_page' => 20, 'offset' => 0));
     /* 搜索功能 */
     $search_arr = array('id', 'email', 'firstname', 'lastname', 'ip', 'mobile', 'real_name');
     $search_value = $this->input->get('search_value');
     $search_type = $this->input->get('search_type');
     $where_view = array();
     if ($search_arr) {
         foreach ($search_arr as $value) {
             if ($search_type == $value && strlen($search_value) > 0) {
                 $user_query_struct['like'][$value] = $search_value;
                 //$user_query_struct['where'][$value] = $search_value;
                 if ($value == 'ip') {
                     $user_query_struct['like'][$value] = tool::myip2long($search_value);
                     //$user_query_struct['where'][$value] = tool::myip2long($search_value);
                 }
             }
         }
         $where_view['search_type'] = $search_type;
         $where_view['search_value'] = $search_value;
     }
     /* 列表排序 */
     $orderby_arr = array(0 => array('id' => 'DESC'), 1 => array('id' => 'ASC'), 4 => array('email' => 'ASC'), 5 => array('email' => 'DESC'), 6 => array('firstname' => 'ASC'), 7 => array('firstname' => 'DESC'), 8 => array('lastname' => 'ASC'), 9 => array('lastname' => 'DESC'), 10 => array('date_add' => 'ASC'), 11 => array('date_add' => 'DESC'), 12 => array('ip' => 'ASC'), 13 => array('ip' => 'DESC'), 14 => array('active' => 'ASC'), 15 => array('active' => 'DESC'), 16 => array('register_mail_active' => 'ASC'), 17 => array('register_mail_active' => 'DESC'));
     $orderby = controller_tool::orderby($orderby_arr);
     $user_query_struct['orderby'] = $orderby;
     /* 每页显示条数 */
     $per_page = controller_tool::per_page();
     $user_query_struct['limit']['per_page'] = $per_page;
     /* 调用分页 */
     $this->pagination = new Pagination(array('total_items' => Myuser::instance()->query_count($user_query_struct), 'items_per_page' => $per_page));
     $user_query_struct['limit']['offset'] = $this->pagination->sql_offset;
     $user_list = Myuser::instance()->query_assoc($user_query_struct);
     //找出所有的站点的用户等级信息
     $user_levelservice = User_levelService::get_instance();
     $query_struct = array('where' => array('active' => 1));
     $user_levels = $user_levelservice->index($query_struct);
     $tmp = array();
     foreach ($user_levels as $user_level) {
         if ($user_level['is_default']) {
             $tmp['default'] = $user_level;
         }
         $tmp[$user_level['id']] = $user_level;
     }
     $user_levels = $tmp;
     foreach ($user_list as $key => $value) {
         $users[$key]['level'] = '';
         if (!empty($user_levels[$value['level_id']])) {
             $users[$key]['level'] = $user_levels[$value['level_id']]['name_manage'];
         } else {
             //$users[$key]['level'] = $user_levels['default']['name_manage'];
         }
     }
     $this->template->content = new View("superplaner/agent_select_list");
     $this->template->content->where = $where_view;
     $this->template->content->user_list = $user_list;
 }
示例#22
0
 /**
  * edit 
  */
 public function edit($id)
 {
     $action = Myaction::instance($id)->get();
     if (!$action['id']) {
         remind::set(Kohana::lang('o_manage.resources_not_exist'), 'manage/action');
     }
     if ($_POST) {
         //标签过滤
         tool::filter_strip_tags($_POST);
         $name = $this->input->post('name');
         $resource = $this->input->post('resource');
         $parent_id = $this->input->post('parent_id');
         if ($name != $action['name']) {
             $data = Myaction::instance()->get_by_name($name);
             if ($data['id']) {
                 remind::set(Kohana::lang('o_manage.resources_name_exist'), 'manage/action/add');
             }
         }
         if ($resource != $action['resource']) {
             $data = Myaction::instance()->get_by_resource($resource);
             if ($data['id']) {
                 remind::set(Kohana::lang('o_manage.resources_mark_exist'), 'manage/action/add');
             }
         }
         //zhu add 上级资源不能选择自身,子项
         if ($parent_id > 0) {
             if ($action['id'] == $parent_id) {
                 remind::set(Kohana::lang('o_manage.parent_action_is_self'), 'manage/action/edit/' . $id);
             }
             $sub_ac = Myaction::instance()->actions($id);
             if (is_array($sub_ac) && count($sub_ac)) {
                 foreach ($sub_ac as $ac) {
                     if ($ac['id'] == $parent_id) {
                         remind::set(Kohana::lang('o_manage.parent_action_is_child'), 'manage/action/edit/' . $id);
                     }
                 }
             }
         }
         //zhu add end
         if (Myaction::instance($id)->edit($_POST)) {
             remind::set(Kohana::lang('o_global.update_success'), 'manage/action', 'success');
         } else {
             remind::set(Kohana::lang('o_global.update_error'), 'manage/action/edit/' . $id);
         }
     }
     $actions = Myaction::instance()->actions();
     foreach ($actions as $key => $value) {
         $actions[$key]['selected'] = '';
         if ($actions['id'] = $action['parent_id']) {
             $actions[$key]['selected'] = 'selected';
         }
     }
     $this->template->content = new View("manage/action_edit");
     $this->template->content->actions = $actions;
     $this->template->content->data = $action;
 }
示例#23
0
 public static function store($value)
 {
     if ($value < -2147483648 || $value > 2147483647) {
         throw new RangeException('Value is out of allowed range for given type.');
     }
     if (\tool::debug()) {
         \tool::fprint("Storing " . get_called_class() . ":{$value}");
     }
     return Writer::convert('l', (int) $value);
 }
示例#24
0
 public static function store($value)
 {
     $len = strlen($value);
     if ($len < 0 || $len > 32767) {
         throw new \LengthException('Valid string length range is 0..32767.');
     }
     if (\tool::debug()) {
         \tool::fprint("Storing " . get_called_class() . ":{$value}");
     }
     return TAG_Short::store($len) . $value;
 }
示例#25
0
 /**
  * 获取账户信息
  *
  */
 public static function get($account_id)
 {
     $post_url = "http://manage.backstage-gateway.com/account";
     $post_var = "account_id=" . $account_id;
     $result = tool::curl_pay($post_url, $post_var);
     $res = @unserialize(stripcslashes($result));
     if (!is_array($res)) {
         log::write('data_error', $result, __FILE__, __LINE__);
     }
     return $res;
 }
示例#26
0
 public static function change_password($manager_id = 0, $status = 0)
 {
     $user_log_type_id = 26;
     $ip = tool::get_str_ip();
     $data = array();
     $data['manager_id'] = $manager_id;
     $data['ip'] = $ip;
     $data['user_log_type'] = $user_log_type_id;
     $data['status'] = $status;
     return Myuser_log::instance()->add($data);
 }
示例#27
0
 public function save(SplFileObject $file)
 {
     $result = parent::save($file) + $file->fwrite(TAG_Int::store(count($this->content)));
     if (\tool::debug()) {
         \tool::fprint("Storing " . count($this->content) . " values @{$file->ftell()} ...");
     }
     ksort($this->content);
     foreach ($this->content as $value) {
         $result += $file->fwrite(TAG_Byte::store($value));
     }
     return $result;
 }
示例#28
0
 /**
  * edit menu
  */
 public function edit($id)
 {
     $menu = Mymenu::instance($id)->get();
     if (!$menu['id']) {
         remind::set(Kohana::lang('o_global.bad_request'), 'manage/menu');
     }
     if ($_POST) {
         //标签过滤
         tool::filter_strip_tags($_POST);
         $target = $this->input->post('target');
         $parent_id = $this->input->post('parent_id');
         if ($menu['target'] != $target) {
             $data = Mymenu::instance($id)->get_by_target($target);
             if ($data['id']) {
                 remind::set(Kohana::lang('o_manage.mark_has_exist'), 'manage/menu/edit/' . $id);
             }
         }
         /* 最多只能添加三级菜单 */
         if ($parent_id > 0) {
             $parent_menu = Mymenu::instance($parent_id)->get();
             if ($parent_menu['level_depth'] >= 3) {
                 remind::set(Kohana::lang('o_manage.menu_can_not_add_level'), 'manage/menu/add');
             }
         }
         /* 添加 */
         if (Mymenu::instance($id)->edit($_POST)) {
             remind::set(Kohana::lang('o_global.update_success'), 'manage/menu', 'success');
         } else {
             remind::set(Kohana::lang('o_global.update_error'), 'manage/menu/edit/' . $id);
         }
     }
     $menus = Mymenu::instance()->menus();
     foreach ($menus as $key => $value) {
         if ($value['id'] == $menu['parent_id']) {
             $menus[$key]['selected'] = 'selected';
         } else {
             $menus[$key]['selected'] = '';
         }
     }
     $actions = Myaction::instance()->actions();
     foreach ($actions as $key => $value) {
         if ($value['id'] == $menu['action_id']) {
             $actions[$key]['selected'] = 'selected';
         } else {
             $actions[$key]['selected'] = '';
         }
     }
     $this->template->content = new View("manage/menu_edit");
     $this->template->content->data = $menu;
     $this->template->content->menus = $menus;
     $this->template->content->actions = $actions;
 }
示例#29
0
 /**
  * 往支付网关发送数据
  * 用于pp支付或者其他跳转支付的验证流程
  * 参数是order数组等等
  * 注意pay_id必须
  */
 public static function send_payment_detail($order, $pay_id, $secure_code, $submit_url)
 {
     //$post_url = "https://www.backstage-gateway.com/pp";
     $post_url = $submit_url;
     $post_var = "order_num=" . $order['order_num'] . "&order_amount=" . $order['total_real'] . "&order_currency=" . $order['currency'] . "&billing_firstname=" . $order['billing_firstname'] . "&billing_lastname=" . $order['billing_lastname'] . "&billing_address=" . $order['billing_address'] . "&billing_zip=" . $order['billing_zip'] . "&billing_city=" . $order['billing_city'] . "&billing_state=" . $order['billing_state'] . "&billing_country=" . $order['billing_country'] . "&billing_telephone=" . $order['billing_phone'] . "&billing_ip_address=" . long2ip($order['ip']) . "&billing_email=" . $order['email'] . "&shipping_firstname=" . $order['shipping_firstname'] . "&shipping_lastname=" . $order['shipping_lastname'] . "&shipping_address=" . $order['shipping_address'] . "&shipping_zip=" . $order['shipping_zip'] . "&shipping_city=" . $order['shipping_city'] . "&shipping_state=" . $order['shipping_state'] . "&shipping_country=" . $order['shipping_country'] . "&trans_id=" . $order['trans_id'] . "&secure_code=" . $secure_code . "&site_id=" . $pay_id;
     $result = tool::curl_pay($post_url, $post_var);
     $res = @unserialize(stripcslashes($result));
     if (is_array($res)) {
         return true;
     } else {
         return false;
     }
 }
示例#30
0
 /**
  * Template loading and setup routine.
  */
 public function __construct()
 {
     parent::__construct();
     // checke request is ajax
     $this->ajax_request = request::is_ajax();
     // Load the template
     $this->template = new View($this->template);
     if ($this->auto_render == TRUE) {
         Event::add('system.post_controller', array($this, '_render'));
     }
     /**
      * 判断用户登录情况
      */
     if (isset($_REQUEST['session_id'])) {
         $session = Session::instance($_REQUEST['session_id']);
         $manager = role::get_manager($_REQUEST['session_id']);
     } else {
         $session = Session::instance();
         $manager = role::get_manager();
     }
     /* 当前请求的URL */
     $current_url = urlencode(url::current(TRUE));
     //zhu
     if (isset($manager['id'])) {
         $active_time = $session->get('Opococ_manager_active_time');
         //用户最后操作时间
         $session->set('Opococ_manager_active_time', time());
         //用户最后操作时间
         $login_ip = $session->get('Opococ_manager_login_ip');
         //用户登录的IP
         //操作超时
         if (time() - $active_time > Kohana::config('login.time_out')) {
             $session->delete('Opococ_manager');
             $session->delete('Opococ_manager_active_time');
             $session->delete('Opococ_manager_login_ip');
             remind::set(Kohana::lang('o_global.first_login'), 'login?request_url=' . $current_url);
         }
         //用户IP(登录状态更换IP需要重新登录)
         $ip = tool::get_long_ip();
         if ($ip != $login_ip) {
             remind::set(Kohana::lang('o_global.login_again'), 'login?request_url=' . $current_url);
         }
         $this->manager = $manager;
         $this->manager_id = $manager['id'];
         $this->manager_name = $manager['name'];
         $this->manager_is_admin = role::is_root($manager['name']) ? 1 : $manager['is_admin'];
         $this->template->manager_data = $manager;
     } else {
         remind::set(Kohana::lang('o_global.first_login'), 'login?request_url=' . $current_url);
     }
 }