public function ajaxGetCityList($pid = 0) { $condition['cityUpId'] = $pid; $this->load->model('province_model'); $citys = $this->province_model->getCityList($condition); response_to_json(0, 'ok', $citys); }
/** * 图片临时存储 * * @param unknown_type $uuid */ public function printUploadArticleImageTemp() { $this->load->library('form'); $this->load->helper('form/image'); $postData = $this->form->check(imageform_get_upload_attachment()); $errors = $this->form->getLastMessage(); if (false == empty($errors)) { response_to_json(4, $errors); exit; } $check = $this->config->item('check'); $extName = strtolower(substr($postData['Filedata']['value'][0]['name'], strrpos($postData['Filedata']['value'][0]['name'], '.') + 1)); $upload = $this->config->item('upload'); $baseDir = $upload['tempDir'] . '/article/'; if (false == is_dir($baseDir)) { @mkdir($baseDir); } $titag = time(); $finalFullFileName = $baseDir . $titag . '.' . $extName; @move_uploaded_file($postData['Filedata']['value'][0]['tmp_name'], $finalFullFileName); // 生成缩略图 list($width, $height, $type, $attr) = getimagesize($finalFullFileName); $maxSideLength = $width > $height ? $width : $height; // 读取图片缩放配置 $productImageZoom = $this->config->item('articleImageZoom'); $piSize = array(); foreach ($productImageZoom as $k => $sideLength) { $img = new Imagick($finalFullFileName); $zoomFile = $baseDir . $titag . '-' . $k . '.' . $extName; if ($sideLength > $maxSideLength) { copy($finalFullFileName, $zoomFile); } else { if ($width > $height) { $newWidth = $sideLength; $newHeight = intval($sideLength * $height / $width); } else { $newHeight = $sideLength; $newWidth = intval($sideLength * $width / $height); } $img->thumbnailImage($newWidth, $newHeight); $img->writeImage($zoomFile); unset($img); } $size = getimagesize($zoomFile); } $zoomFile_small = $baseDir . $titag . '-small.' . $extName; $result = array('small' => $zoomFile_small, 'original' => $finalFullFileName); response_to_json(0, 'ok', $result); }
protected function _checkPrivileges($class = '', $method = '') { if ($class != 'image' && $method != 'output') { $userInfo = $this->phpsession->get('userInfo', array(), 'admin'); if (true == empty($userInfo)) { if (true == $this->input->is_ajax_request()) { response_to_json(1, '会话已过期', array('location' => site_url('admin/manager/printLogin'))); } else { echo '<script type="text/javascript"> top.location = "' . site_url('admin/manager/printLogin') . '"; </script>'; } exit; } } }
/** * 删除 * * @param string $id */ public function ajaxDeleteBroadcast($ids) { $this->load->model('broadcast_model'); if (strpos($ids, ',') !== false) { $id_arr = explode(',', $ids); } else { $id_arr = array($ids); } foreach ($id_arr as $k => $v) { $condition = array('id' => $v); $affected += $this->broadcast_model->updateBroadcast($condition, array('status' => '-1')); } $errors = $this->broadcast_model->getLastMessage(); $code = 0 == $affected || false == empty($errors) ? 4 : 0; $message = false == empty($errors) ? $errors : (0 == $affected ? '操作失败' : '操作成功'); response_to_json($code, $message); }
public function ajaxUpdateVersion() { if (isset($_POST['s_attachment_path']) === true && !empty($_POST['s_attachment_path'])) { // 读取图片缩放配置 $upload = $this->config->item('upload'); foreach ($_POST['s_attachment_path'] as $key => $filepath) { $flodername = dirname($filepath); if (file_exists($filepath)) { $finalFullFileName = $upload['vsersionpacket'] . '/' . time() . '.zip'; copy($filepath, $finalFullFileName); @rmdir($flodername); } else { response_to_json(5, '文件不存在'); } } } response_to_json(0, 'ok', '操作成功'); }
public function ajaxGetRegisterVerifycodeList() { // 组合条件 $condition = array(); $page = isset($_POST['page']) ? intval($_POST['page']) : 1; $limit = isset($_POST['rows']) ? intval($_POST['rows']) : PAGINATIONLIMIT; $page = 0 == $page ? 1 : $page - 1; if (isset($_POST['from_date']) && $_POST['from_date'] && isset($_POST['end_date']) && $_POST['end_date']) { $condition['createtime'] = array('$betweenin', array(date("Y-m-d H:i:s", strtotime($_POST['from_date'])), date("Y-m-d H:i:s", strtotime($_POST['end_date']) + 86400))); } elseif (isset($_POST['from_date']) && $_POST['from_date']) { $condition['createtime'] = array('$gte', date("Y-m-d H:i:s", strtotime($_POST['from_date']))); } elseif (isset($_POST['end_date']) && $_POST['end_date']) { $condition['createtime'] = array('$lte', date("Y-m-d H:i:s", strtotime($_POST['end_date']) + 86400)); } if (isset($_POST['tel']) && $_POST['tel']) { $condition['tel'] = $_POST['tel']; } $this->load->model('user_model'); $smsList = $this->user_model->getUserCodeList($condition); $data = array('rows' => $smsList); response_to_json(0, 'ok', $data); }
/** * 获取活动的积分日志列表 * * @param number $user_id */ public function ajaxGetActivityScoreList($activity_id = 0, $type = 0) { $page = isset($_POST['page']) ? intval($_POST['page']) : 1; $limit = isset($_POST['rows']) ? intval($_POST['rows']) : PAGINATIONLIMIT; $page = 0 == $page ? 1 : $page - 1; if ($type == 1) { $userscorelogtype = 6; } elseif ($type == 2) { $userscorelogtype = 8; } $condition = array('type' => $userscorelogtype, 'ref_id' => $activity_id, 'status' => array(0, 1)); if (isset($_POST['from_date']) && $_POST['from_date'] && isset($_POST['end_date']) && $_POST['end_date']) { $condition['createtime'] = array('$betweenin', array(date("Y-m-d H:i:s", strtotime($_POST['from_date'])), date("Y-m-d H:i:s", strtotime($_POST['end_date']) + 86400))); } else { if (isset($_POST['from_date']) && $_POST['from_date']) { $condition['createtime'] = array('$gte', date("Y-m-d H:i:s", strtotime($_POST['from_date']))); } else { if (isset($_POST['end_date']) && $_POST['end_date']) { $condition['createtime'] = array('$lte', date("Y-m-d H:i:s", strtotime($_POST['end_date']) + 86400)); } } } $this->load->model('score_model'); $data['rows'] = $this->score_model->getScoreList($condition, '*', $page * $limit, $limit); $data['total'] = $this->score_model->getScoreListTotalnum($condition); response_to_json(0, 'ok', $data); }
/** * 添加修改用户反馈 */ public function ajaxUpdateUserQa() { $this->load->library('form'); $this->form->setHandler('filter_strip_tags_and_clear_space|filter_replace_escape_char'); $this->load->helper('form/qa'); $this->load->model('qa_model'); $postData = $this->form->check(userqaupdateform_get_selector()); $errors = $this->form->getLastMessage(); if (false == empty($errors)) { response_to_json(5, $errors); } $data = array('content' => $postData['content']['value'], 'userid' => $postData['userid']['value'], 'username' => $postData['username']['value'], 'createtime' => date('Y-m-d H:i:s', time())); $id = $this->qa_model->createUserQa($data); $errors = $this->qa_model->getLastMessage(); $code = 0 == $id || false == empty($errors) ? 4 : 0; $message = false == empty($errors) ? $errors : (0 == $id ? '操作失败' : '操作成功'); response_to_json($code, $message); }
/** * 修改用户举报 */ public function ajaxDeleteUserReport($ids, $type) { $this->load->model('report_model'); $this->load->model('article_model'); $this->load->model('comment_model'); if (strpos($ids, ',') !== false) { $id_arr = explode(',', $ids); } else { $id_arr = [$ids]; } $affected = 0; foreach ($id_arr as $k => $v) { $condition = ['id' => $v]; $affected = $this->report_model->updateUserreport($condition, ['status' => $type]); if ($affected) { if ($type == -1) { //判断是帖子还是评论 不同处理方式 $reportInfo = $this->report_model->getUserreport($condition); if ($reportInfo['ref_type'] == 1) { //帖子 $this->article_model->updateArticle(['id' => $reportInfo['ref_id']], ['status' => -1]); } elseif ($reportInfo['ref_type'] == 3) { //评论 $this->comment_model->updateComment(['id' => $reportInfo['ref_id']], ['status' => -2]); } } elseif ($type == 2) { $reportInfo = $this->report_model->getUserreport($condition); if ($reportInfo['ref_type'] == 1) { //帖子 $this->article_model->updateArticle(['id' => $reportInfo['ref_id']], ['status' => 1]); } elseif ($reportInfo['ref_type'] == 3) { //评论 $this->comment_model->updateComment(['id' => $reportInfo['ref_id']], ['status' => 1]); } } } } $errors = $this->report_model->getLastMessage(); $code = 0 == $affected || false == empty($errors) ? 4 : 0; $message = false == empty($errors) ? $errors : (0 == $affected ? '操作失败' : '操作成功'); response_to_json($code, $message); }
/** * 兑换申请审核 * * @param string $id */ public function ajaxDeleteExchange($ids, $status) { $this->load->model('exchange_model'); $this->load->model('user_model'); if (strpos($ids, ',') !== false) { $id_arr = explode(',', $ids); } else { $id_arr = array($ids); } $affected = 0; foreach ($id_arr as $k => $v) { //判断前置状态是否正常 $exchangeInfo = $this->exchange_model->getExchange(array('id' => $v)); if ($status == -1 && $exchangeInfo['status'] != 0 || $status == 1 && $exchangeInfo['status'] != 0 || $status == 2 && $exchangeInfo['status'] != 1) { response_to_json(5, 'ID:' . $v . '您操作有误,请检查前置状态!'); } $affected += $this->exchange_model->updateExchange(array('id' => $v), array('status' => $status, 'updatetime' => date('Y-m-d H:i:s', time()))); // 如果审核不通过则加上相应积分 if ($status == -1 && $affected) { // 用户$exchangeInfo['userid']分数减去兑换的积分数 $userInfo = $this->user_model->getUser(array('id' => $exchangeInfo['userid'])); $affected = $this->user_model->updateUserScore($userInfo, $exchangeInfo['point']); $this->load->model('score_model'); $data_score = array('userid' => $exchangeInfo['userid'], 'score' => $exchangeInfo['point'], 'type' => 5, 'ref_id' => $v, 'status' => 1, 'addsub' => 1, 'createtime' => date('Y-m-d H:i:s', time())); $this->score_model->createUserscore($data_score); } } $errors = $this->exchange_model->getLastMessage(); $code = 0 == $affected || false == empty($errors) ? 4 : 0; $message = false == empty($errors) ? $errors : (0 == $affected ? '操作失败' : '操作成功'); response_to_json($code, $message); }
/** * 反馈添加图片 * @date: 2016年1月25日 下午9:09:30 * @author: Elliot * @param: variable * @return: */ private function uploadFeedbackPic($feedbackid = 0, $uid, $username) { $this->load->library('form'); $this->load->helper('form/article'); $postData = $this->form->check(synform_get_upload_attachment()); $errors = $this->form->getLastMessage(); if (false == empty($errors)) { response_to_json(4, $errors); exit; } $allowType = $this->config->item('allowType'); $allow_img = $allowType['image']; $this->load->helper('path'); $upload = $this->config->item('upload'); $extName = strtolower(substr($postData['Filedata']['value'][0]['name'], strrpos($postData['Filedata']['value'][0]['name'], '.') + 1)); if (false == is_dir($upload['feedbackDir'])) { @mkdir($upload['feedbackDir']); } $baseDir = path_get_absolute_dir($upload['feedbackDir'], $feedbackid, true); $check = $this->config->item('check'); $data = array('ref_id' => intval($feedbackid), 'filename' => strtolower($_FILES['Filedata']['name']), 'filetype' => $extName, 'createtime' => date('Y-m-d H:i:s', time()), 'userid' => $uid, 'username' => $username, 'relative_path' => path_get_url($upload['feedbackDir'], $feedbackid)); $this->load->model('qa_model'); $seca_id = $this->qa_model->createSynAttachment($data); $errors = $this->qa_model->getLastMessage(); if (false == empty($errors) || 0 == $seca_id) { response_to_json(5, false == empty($errors) ? $errors : '创建附件信息失败'); exit; } $finalFullFileName = $baseDir . $seca_id . '.' . $extName; @copy($postData['Filedata']['value'][0]['tmp_name'], $finalFullFileName); // if (in_array($extName, $allow_img)) { // 生成缩略图 list($width, $height, $type, $attr) = getimagesize($finalFullFileName); $maxSideLength = $width > $height ? $width : $height; // 读取图片缩放配置 $productImageZoom = $this->config->item('articleImageZoom'); $piSize = array(); foreach ($productImageZoom as $k => $sideLength) { $img = new Imagick($finalFullFileName); $zoomFile = $baseDir . $seca_id . '-' . $k . '.' . $extName; if ($sideLength > $maxSideLength) { copy($finalFullFileName, $zoomFile); } else { if ($width > $height) { $newWidth = $sideLength; $newHeight = intval($sideLength * $height / $width); } else { $newHeight = $sideLength; $newWidth = intval($sideLength * $width / $height); } $img->thumbnailImage($newWidth, $newHeight); $img->writeImage($zoomFile); unset($img); } $size = getimagesize($zoomFile); } } if (false == is_dir($upload['feedbackDir'])) { @mkdir($upload['feedbackDir']); } response_to_json(0, '附件上传成功', path_get_url($upload['feedbackDir'], $feedbackid) . '/' . $seca_id . '.' . $extName, 1); }
/** * 获取用户的积分日志列表 * * @param number $user_id */ public function ajaxGetUserScoreList($user_id = 0) { $page = isset($_POST['page']) ? intval($_POST['page']) : 1; $limit = isset($_POST['rows']) ? intval($_POST['rows']) : PAGINATIONLIMIT; $page = 0 == $page ? 1 : $page - 1; $condition = array('status' => array(0, 1), 'userid' => $user_id); if (isset($_POST['from_date']) && $_POST['from_date'] && isset($_POST['end_date']) && $_POST['end_date']) { $condition['createtime'] = array('$betweenin', array(date("Y-m-d H:i:s", strtotime($_POST['from_date'])), date("Y-m-d H:i:s", strtotime($_POST['end_date']) + 86400))); } else { if (isset($_POST['from_date']) && $_POST['from_date']) { $condition['createtime'] = array('$gte', date("Y-m-d H:i:s", strtotime($_POST['from_date']))); } else { if (isset($_POST['end_date']) && $_POST['end_date']) { $condition['createtime'] = array('$lte', date("Y-m-d H:i:s", strtotime($_POST['end_date']) + 86400)); } } } // if(isset($_POST['reliable']) && $_POST['reliable'] !=='') // { // $condition['reliable'] = $_POST['reliable']; // } $this->load->model('score_model'); $data['rows'] = $this->score_model->getScoreList($condition, '*', $page * $limit, $limit); $data['total'] = $this->score_model->getScoreListTotalnum($condition); response_to_json(0, 'ok', $data); }
/** * 建立预上下线关系 */ public function buildinventrel() { $this->load->library('form'); $this->form->setHandler('filter_strip_tags_and_clear_space|filter_replace_escape_char'); $this->load->helper('form/manager'); $postData = $this->form->check(buildinventrelform_get_selector()); $errors = $this->form->getLastMessage(); if (false == empty($errors)) { response_to_json(5, $errors); } $data = array('uid' => $postData['uid']['value'], 'phone' => $postData['phone']['value'], 'createtime' => date('Y-m-d H:i:s', time())); $this->load->model('user_model'); //判断是否是自己 $user_ifexist = $this->user_model->getUser(array('id' => $postData['uid']['value'])); if ($user_ifexist && $user_ifexist['tel'] == $postData['phone']['value']) { response_to_json(4, '您不能添加自己的手机号码!'); } //首先判断是否存在对应关系 $intventrel = $this->user_model->getinventrel(['uid' => $postData['uid']['value'], 'phone' => $postData['phone']['value']]); if ($intventrel) { response_to_json(4, '该用户邀请过您,勿重复提交!'); } $id = $this->user_model->createinventrel($data); $errors = $this->user_model->getLastMessage(); $code = 0 == $id || false == empty($errors) ? 4 : 0; $message = false == empty($errors) ? $errors : (0 == $id ? '操作失败' : '操作成功'); response_to_json($code, $message); }