Esempio n. 1
0
 public function get_index()
 {
     //echo md5('qieyou');exit; f61e83b9c803be5003ceddacfc6010ba
     $name = input_mobilenum($this->input->get('name'), '1004');
     $password = $this->input->get('password');
     $device = $this->input->get('device');
     $device_id = $this->input->get('device_id');
     if (empty($password)) {
         response_msg('1002');
     }
     $user = $this->model->get_user_by_name($name);
     if (!$user) {
         response_msg('1003');
     }
     $password = md5($password . $user['salt']);
     if ($user['user_pass'] != $password) {
         response_msg('1002');
     }
     if ($user['state'] == 'locked') {
         response_msg('1006');
     }
     $user['inn_id'] = $this->model->get_user_inn_by_id($user['user_id']);
     if (!$user['inn_id']) {
         response_msg('1006');
     }
     $data['token'] = $this->model->create_token($user);
     $data['role'] = $user['role'];
     $data['state'] = $user['state'];
     //	$this->user_model->update_login_info($user);
     response_data($data);
 }
Esempio n. 2
0
 public function customerSaveNote()
 {
     $partner_id = $this->input->get('partner_id');
     $note = $this->input->get('note');
     $this->load->model('partners_model');
     if ($this->partners_model->saveNote($this->token['user_id'], $partner_id, $note)) {
         response_msg('1');
         // 成功
     }
     response_msg('-1');
     // 失败
 }
Esempio n. 3
0
 public function check_token()
 {
     if ($this->token) {
         return $this->token;
     }
     if ($this->input->get('token')) {
         $token = $this->input->get('token');
     } else {
         response_msg('4004');
     }
     $sql = 'SELECT * FROM access_token WHERE token = ' . $this->db->escape($token) . '';
     $access_token = $this->db->query($sql)->row_array();
     if (!$access_token) {
         response_msg('4004');
     }
     $this->token = $access_token;
     return $this->token;
 }
Esempio n. 4
0
 /**
  * 处理上传
  * 
  * @param array $sourceArr 要上传的文件信息数组
  * @param string $to 上传文件存放的文件夹,相对
  * @param array $data 要插入或修改的数据数组信息
  * @param array $thumb 缩略图信息,只需要设置宽度和高度即可
  * @return bool 成否与否 
  */
 public function index()
 {
     $this->check_token();
     $type = input_string($this->input->get('type'), array('userheadimg', 'innheadimg', 'product'), FALSE, '5002');
     $thumbs = array();
     switch ($type) {
         case 'innheadimg':
             $thumbs[] = array('width' => 100, 'height' => 100, 'thumb_marker' => 's', 'maintain_ratio' => FALSE);
             $link = 'inn/header/';
             break;
         case 'userheadimg':
             $thumbs[] = array('width' => 100, 'height' => 100, 'thumb_marker' => 's', 'maintain_ratio' => FALSE);
             $link = 'user/headimg/';
             break;
         case 'product':
             $thumbs[] = array('width' => 640, 'height' => 440, 'thumb_marker' => 'm', 'maintain_ratio' => TRUE);
             $thumbs[] = array('width' => 160, 'height' => 110, 'thumb_marker' => 's', 'maintain_ratio' => TRUE);
             $link = 'uploads/';
             break;
     }
     $rs = $this->getUploadedNames($link);
     if ($rs['code'] != '1') {
         response_msg('4000');
     }
     if ($thumbs) {
         $this->load->library('image_lib');
         foreach ($thumbs as $key => $thumb) {
             $thumb = array_merge($this->thumbConfig, $thumb);
             log_message('error', json_encode($thumb));
             $thumb['source_image'] = $this->config->item('uploaded_img_path') . $link . $rs['msg'];
             log_message('error', $thumb['source_image']);
             $this->image_lib->initialize($thumb);
             $this->image_lib->resize();
         }
     }
     response_data($link . $rs['msg']);
 }
Esempio n. 5
0
 private function check_product_value($add = FALSE)
 {
     log_message('error', json_encode($this->input->post()));
     $data = array();
     $inn = $this->model->get_inn_info_by_inn_id($this->token['inn_id'], FALSE);
     $price = input_empty($this->input->post('price'), FALSE, '4003');
     $price = sprintf("%.2f", $price);
     if ($price < 0) {
         response_msg('2016');
     }
     $old_price = input_empty($this->input->post('old_price'), 0);
     $old_price = sprintf("%.2f", $old_price);
     if ($old_price == 0) {
         $old_price = $price;
     } else {
         if ($old_price < $price) {
             response_msg('2017');
         }
     }
     if ($add) {
         $data['category'] = input_int($this->input->post('cid'), 0, FALSE, FALSE, '2004');
         if ($data['category'] == 6) {
             response_msg('4001');
         }
         $data['category_id'] = input_int($this->input->post('ccid'), 0, FALSE, FALSE, '2006');
         $data['tuan_end_time'] = $this->input->post('tuan_end_time') ? strtotime($this->input->post('tuan_end_time')) : '';
         $data['tuan_end_time'] = input_int($data['tuan_end_time'], $_SERVER['REQUEST_TIME'], $_SERVER['REQUEST_TIME'] + 31536000, $_SERVER['REQUEST_TIME'] + 31536000);
         //有效期1年以内 过期下架
     }
     $data['product_name'] = input_empty($this->input->post('product_name'), FALSE, '4003');
     $data['price'] = $price;
     $data['old_price'] = $old_price;
     $data['quantity'] = input_int($this->input->post('quantity'), 0, FALSE, FALSE, '2015');
     $data['note'] = $this->input->post('note', TRUE);
     $data['booking_info'] = $this->input->post('booking_info', TRUE);
     $data['thumb'] = input_empty($this->input->post('thumb'), 0);
     $data['product_images'] = input_empty($this->input->post('product_images'), FALSE, '2019');
     $data['product_images'] = explode(',', $data['product_images']);
     foreach ($data['product_images'] as $key => $row) {
         $info = explode('.', strrev($row));
         $gallery[] = strrev($info[1]) . 'm.' . strrev($info[0]);
         if ($key == 0) {
             $data['thumb'] = strrev($info[1]) . 's.' . strrev($info[0]);
         }
     }
     if (empty($data['thumb'])) {
         response_msg('2018');
     }
     $data['product_images'] = implode(',', $data['product_images']);
     $data['gallery'] = implode(',', $gallery);
     $data['detail_images'] = input_empty($this->input->post('detail_images'), '');
     $data['content'] = mb_substr($data['note'], 0, 50, 'utf-8');
     return $data;
 }
Esempio n. 6
0
 public function removepartners()
 {
     $ids = $this->input->get('ids');
     if (!$ids) {
         response_msg('4000');
     }
     $partner_ids = explode(',', $ids);
     if (!$partner_ids) {
         response_msg('1021');
     }
     $rows = implode(',', $partner_ids);
     $partners = $this->model->edit_user_partner('rm', $this->token['user_id'], $rows);
     if ($partners == count($partner_ids)) {
         response_msg('1');
     }
     response_msg('4000');
 }
Esempio n. 7
0
 /**
  * 处理退款申请
  * ajax POST
  */
 public function orderRefund()
 {
     $this->check_finance_auth_in_controller();
     $action = input_string($this->input->post('action'), array('rejected', 'settled'), 'rejected');
     $sanction = $this->input->post('sanction', TRUE);
     $refund_id = input_int($this->input->post('refund_id'), 1, FALSE, FALSE, '请求错误!');
     switch ($action) {
         case 'rejected':
             //关闭入口
             show_404();
         case 'settled':
             $refund = $this->model->get_order_refund_by_id($refund_id);
             break;
     }
     if (!$refund || $refund['state'] != 'applying') {
         response_msg("请求错误!");
     }
     $done = array('user_id' => $this->get_user_id(), 'sanction' => $sanction);
     $rs = $this->model->settled_order_refund($refund, $done);
     response_code($rs ? '1' : '-1');
 }
Esempio n. 8
0
function input_identity_number($id_card, $msg)
{
    if (strlen($id_card) == 15) {
        return idcard_15to18($id_card);
    }
    if (idcard_checksum18($id_card)) {
        return $id_card;
    }
    response_msg($msg);
}
Esempio n. 9
0
File: inn.php Progetto: qiuai/qieyou
 /**
  * submit the cash out apply
  */
 public function applyCash()
 {
     $apply_amount = input_empty($this->input->post('apply_amount'), FALSE, '4001');
     $apply['amount'] = sprintf("%.2f", $apply_amount);
     if ($apply['amount'] <= 0) {
         response_msg('4001');
     }
     $innInfo = $this->model->get_inn_info_by_inn_id($this->token['inn_id']);
     if (!$innInfo) {
         response_msg('1018');
     }
     if ($innInfo['account'] - $innInfo['withdrawing'] < $apply_amount) {
         response_msg('1022');
     }
     $apply['user_id'] = $this->token['user_id'];
     $apply['inn_id'] = $this->token['inn_id'];
     $this->_LoadModel('finance');
     $rs = $this->finance_model->inn_apply_cashout($apply);
     if (!$rs) {
         response_msg('5001');
     }
     response_msg('1');
 }
Esempio n. 10
0
function check_luhn($num, $msg)
{
    $card_len = strlen($num);
    $i = 0;
    $num_i = array();
    do {
        if (!$i) {
            $num_x = $card_len % 2 ? 1 : 2;
        } else {
            $num_x = $num_x == 1 ? 2 : 1;
        }
        $num_i[$i] = $num[$i] * $num_x;
        $num_i[$i] = $num_i[$i] > 9 ? $num_i[$i] - 9 : $num_i[$i];
    } while (isset($num[++$i]));
    $sum = array_sum($num_i);
    if ($sum % 10 == 0) {
        return $num;
    }
    response_msg($msg);
}