Exemple #1
0
 public function save_slide_action()
 {
     if (!$_POST['title']) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请填写幻灯片标题')));
     }
     if (!$_POST['category']) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请选择幻灯片分类')));
     }
     if ($_POST['id']) {
         $slide_info = $this->model('slide')->get_slide_by_id($_POST['id']);
         if (!$slide_info) {
             H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('指定幻灯片不存在')));
         }
     }
     if ($slide_info) {
         $this->model('slide')->save_slide($slide_info['id'], $_POST['title'], $_POST['description'], $_POST['link'], $_POST['category']);
         $id = $slide_info['id'];
     } else {
         $id = $this->model('slide')->save_slide(null, $_POST['title'], $_POST['description'], $_POST['link']);
         if (!$id) {
             H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('保存失败')));
         }
     }
     if ($_FILES['img']['name']) {
         AWS_APP::upload()->initialize(array('allowed_types' => 'jpg,jpeg,png,gif', 'upload_path' => get_setting('upload_dir') . '/slide', 'is_image' => TRUE))->do_upload('img');
         if (AWS_APP::upload()->get_error()) {
             switch (AWS_APP::upload()->get_error()) {
                 default:
                     H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('错误代码') . ': ' . AWS_APP::upload()->get_error()));
                     break;
                 case 'upload_invalid_filetype':
                     H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('文件类型无效')));
                     break;
             }
         }
         $upload_data = AWS_APP::upload()->data();
         if (!$upload_data) {
             H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('上传失败, 请与管理员联系')));
         }
         foreach (AWS_APP::config()->get('image')->slide_thumbnail as $key => $val) {
             $thumb_file[$key] = $upload_data['file_path'] . $id . "-" . $key . '.jpg';
             AWS_APP::image()->initialize(array('quality' => 90, 'source_image' => $upload_data['full_path'], 'new_image' => $thumb_file[$key], 'width' => $val['w'], 'height' => $val['h']))->resize();
         }
         @unlink($upload_data['full_path']);
     }
     H::ajax_json_output(AWS_APP::RSM(array('url' => get_js_url('/admin/slide/list/')), 1, null));
 }
Exemple #2
0
 function login($_username, $_password)
 {
     if (H::valid_email($_username)) {
         // 使用 E-mail 登录
         list($uc_uid, $username, $password, $email) = uc_user_login($_username, $_password, 2);
     }
     if ($this->ucenter_charset != 'utf-8') {
         $username = convert_encoding($username, $this->ucenter_charset, 'UTF-8');
     }
     if (!$uc_uid) {
         if ($this->ucenter_charset != 'utf-8') {
             list($uc_uid, $username, $password, $email) = uc_user_login(convert_encoding($_username, 'utf-8', $this->ucenter_charset), $_password);
             if ($username) {
                 $username = convert_encoding($username, $this->ucenter_charset, 'UTF-8');
             }
         } else {
             list($uc_uid, $username, $password, $email) = uc_user_login($_username, $_password);
         }
     }
     if ($username) {
         $username = htmlspecialchars($username);
     }
     if ($uc_uid > 0) {
         if (!($user_info = $this->get_uc_user_info($uc_uid))) {
             if ($site_user_info = $this->model('account')->get_user_info_by_email($email)) {
                 $this->insert('users_ucenter', array('uid' => $site_user_info['uid'], 'uc_uid' => $uc_uid, 'username' => $username, 'email' => $email));
                 return false;
             }
             if ($new_user_id = $this->model('account')->user_register($username, $_password, $email, TRUE)) {
                 if ($exists_uc_id = $this->is_uc_user($email)) {
                     $this->update('users_ucenter', array('username' => $username, 'uid' => $new_user_id), 'uc_uid = ' . intval($exists_uc_id));
                 } else {
                     $this->insert('users_ucenter', array('uid' => $new_user_id, 'uc_uid' => $uc_uid, 'username' => $username, 'email' => $email));
                     if (uc_check_avatar($uc_uid, 'big')) {
                         $avatar = @file_get_contents(UC_API . '/avatar.php?uid=' . $uc_uid . '&size=big');
                         if ($avatar) {
                             AWS_APP::upload()->initialize(array('allowed_types' => 'jpg,jpeg,png,gif', 'upload_path' => get_setting('upload_dir') . '/avatar/' . $this->model('account')->get_avatar($new_user_id, '', 1), 'is_image' => TRUE, 'max_size' => get_setting('upload_avatar_size_limit'), 'file_name' => $this->model('account')->get_avatar($new_user_id, '', 2), 'encrypt_name' => FALSE))->do_upload('aws_upload_file', $avatar);
                             if (!AWS_APP::upload()->get_error()) {
                                 $upload_data = AWS_APP::upload()->data();
                                 if ($upload_data) {
                                     if ($upload_data['is_image'] == 1) {
                                         foreach (AWS_APP::config()->get('image')->avatar_thumbnail as $key => $val) {
                                             $thumb_file[$key] = $upload_data['file_path'] . $this->model('account')->get_avatar($new_user_id, $key, 2);
                                             AWS_APP::image()->initialize(array('quality' => 90, 'source_image' => $upload_data['full_path'], 'new_image' => $thumb_file[$key], 'width' => $val['w'], 'height' => $val['h']))->resize();
                                         }
                                     }
                                     $update_data['avatar_file'] = $this->model('account')->get_avatar($new_user_id, null, 1) . basename($thumb_file['min']);
                                     // 更新主表
                                     $this->model('account')->update_users_fields($update_data, $new_user_id);
                                     if (!$this->model('integral')->fetch_log($new_user_id, 'UPLOAD_AVATAR')) {
                                         $this->model('integral')->process($new_user_id, 'UPLOAD_AVATAR', round(get_setting('integral_system_config_profile') * 0.2), '上传头像');
                                     }
                                 }
                             }
                         }
                     }
                 }
                 $user_info = $this->model('account')->get_user_info_by_uid($new_user_id, true, false);
             }
         } else {
             // Update password
             $this->model('account')->update_user_password_ingore_oldpassword($_password, $user_info['uid'], $user_info['salt']);
             // Update username
             if ($user_info['user_name'] != $username) {
                 if (!$this->model('account')->check_username($username)) {
                     $this->model('account')->update_user_name($username, $user_info['uid']);
                     $this->update('users_ucenter', array('username' => htmlspecialchars($username)), 'uc_uid = ' . intval($uc_uid));
                 }
             }
         }
     }
     return $user_info;
 }
Exemple #3
0
 public function mp_menu_list_image_upload_action()
 {
     AWS_APP::upload()->initialize(array('allowed_types' => 'jpg,jpeg,png,gif', 'upload_path' => get_setting('upload_dir') . '/weixin/list_image/', 'is_image' => TRUE, 'file_name' => str_replace(array('/', '\\', '.'), '', $_GET['attach_access_key']) . '.jpg', 'encrypt_name' => FALSE));
     if ($_GET['attach_access_key']) {
         AWS_APP::upload()->do_upload('aws_upload_file');
     } else {
         return false;
     }
     if (AWS_APP::upload()->get_error()) {
         switch (AWS_APP::upload()->get_error()) {
             default:
                 die("{'error':'错误代码: " . AWS_APP::upload()->get_error() . "'}");
                 break;
             case 'upload_invalid_filetype':
                 die("{'error':'文件类型无效'}");
                 break;
             case 'upload_invalid_filesize':
                 die("{'error':'文件尺寸过大, 最大允许尺寸为 " . get_setting('upload_size_limit') . " KB'}");
                 break;
         }
     }
     if (!($upload_data = AWS_APP::upload()->data())) {
         die("{'error':'上传失败, 请与管理员联系'}");
     }
     if ($upload_data['is_image'] == 1) {
         AWS_APP::image()->initialize(array('quality' => 90, 'source_image' => $upload_data['full_path'], 'new_image' => $upload_data['full_path'], 'width' => 640, 'height' => 320))->resize();
         AWS_APP::image()->initialize(array('quality' => 90, 'source_image' => $upload_data['full_path'], 'new_image' => get_setting('upload_dir') . '/weixin/list_image/square_' . basename($upload_data['full_path']), 'width' => 80, 'height' => 80))->resize();
     }
     H::ajax_json_output(AWS_APP::RSM(null, 1, null));
 }
Exemple #4
0
 public function upload_topic_pic_action()
 {
     if (!($this->user_info['permission']['is_administortar'] or $this->user_info['permission']['is_moderator'])) {
         if (!$this->user_info['permission']['edit_topic']) {
             H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('你没有权限进行此操作')));
         } else {
             if ($this->model('topic')->has_lock_topic($_GET['topic_id'])) {
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('锁定的话题不能编辑')));
             }
         }
     }
     if (!($topic_info = $this->model('topic')->get_topic_by_id($_GET['topic_id']))) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('话题不存在')));
     }
     AWS_APP::upload()->initialize(array('allowed_types' => 'jpg,jpeg,png,gif', 'upload_path' => get_setting('upload_dir') . '/topic/' . gmdate('Ymd'), 'is_image' => TRUE, 'max_size' => get_setting('upload_avatar_size_limit')))->do_upload('aws_upload_file');
     if (AWS_APP::upload()->get_error()) {
         switch (AWS_APP::upload()->get_error()) {
             default:
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('错误代码') . ': ' . AWS_APP::upload()->get_error()));
                 break;
             case 'upload_invalid_filetype':
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('文件类型无效')));
                 break;
             case 'upload_invalid_filesize':
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('文件尺寸过大, 最大允许尺寸为 %s KB', get_setting('upload_size_limit'))));
                 break;
         }
     }
     if (!($upload_data = AWS_APP::upload()->data())) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('上传失败, 请与管理员联系')));
     }
     if ($upload_data['is_image'] == 1) {
         foreach (AWS_APP::config()->get('image')->topic_thumbnail as $key => $val) {
             $thumb_file[$key] = $upload_data['file_path'] . str_replace($upload_data['file_ext'], '_' . $val['w'] . '_' . $val['h'] . $upload_data['file_ext'], basename($upload_data['full_path']));
             AWS_APP::image()->initialize(array('quality' => 90, 'source_image' => $upload_data['full_path'], 'new_image' => $thumb_file[$key], 'width' => $val['w'], 'height' => $val['h']))->resize();
             @unlink(get_setting('upload_dir') . '/topic/' . str_replace(AWS_APP::config()->get('image')->topic_thumbnail['min']['w'] . '_' . AWS_APP::config()->get('image')->topic_thumbnail['min']['h'], $val['w'] . '_' . $val['h'], $topic_info['topic_pic']));
         }
         @unlink(get_setting('upload_dir') . '/topic/' . str_replace('_' . AWS_APP::config()->get('image')->topic_thumbnail['min']['w'] . '_' . AWS_APP::config()->get('image')->topic_thumbnail['min']['h'], '', $topic_info['topic_pic']));
     }
     $this->model('topic')->update_topic($this->user_id, $_GET['topic_id'], null, null, gmdate('Ymd') . '/' . basename($thumb_file['min']));
     #		echo htmlspecialchars(json_encode(array(
     echo json_encode(array('success' => true, 'thumb' => get_setting('upload_url') . '/topic/' . gmdate('Ymd') . '/' . basename($thumb_file['mid']))), ENT_NOQUOTES;
 }
Exemple #5
0
 public function create_qr_code($scene_id)
 {
     if (!$scene_id) {
         return AWS_APP::lang()->_t('scene_id 错误');
     }
     $result = $this->model('openid_weixin_weixin')->access_request(get_setting('weixin_app_id'), get_setting('weixin_app_secret'), 'qrcode/create', 'POST', $this->replace_post(array('action_name' => 'QR_LIMIT_SCENE', 'action_info' => array('scene' => array('scene_id' => intval($scene_id))))));
     if (!$result) {
         $this->delete('weixin_qr_code', 'scene_id = ' . intval($scene_id));
         return AWS_APP::lang()->_t('远程服务器忙');
     }
     if ($result['errcode']) {
         $this->delete('weixin_qr_code', 'scene_id = ' . intval($scene_id));
         return $result['errmsg'];
     }
     if (!$result['ticket']) {
         $this->delete('weixin_qr_code', 'scene_id = ' . intval($scene_id));
         return AWS_APP::lang()->_t('获取 ticket 失败');
     }
     $this->update('weixin_qr_code', array('ticket' => $result['ticket']), 'scene_id = ' . intval($scene_id));
     $qr_code = curl_get_contents('https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=' . urlencode($result['ticket']));
     if (!$qr_code) {
         $this->delete('weixin_qr_code', 'scene_id = ' . intval($scene_id));
         return AWS_APP::lang()->_t('换取二维码失败');
     }
     $img_file_name = intval($scene_id) . '.jpg';
     AWS_APP::upload()->initialize(array('allowed_types' => 'jpg', 'upload_path' => get_setting('upload_dir') . '/weixin_qr_code', 'is_image' => TRUE, 'overwrite' => TRUE, 'file_name' => $img_file_name));
     AWS_APP::upload()->do_upload($img_file_name, $qr_code);
     $upload_error = AWS_APP::upload()->get_error();
     if ($upload_error) {
         $this->delete('weixin_qr_code', 'scene_id = ' . intval($scene_id));
         return AWS_APP::lang()->_t('保存二维码图片失败,错误为 %s', $upload_error);
     }
     $upload_data = AWS_APP::upload()->data();
     if (!$upload_data) {
         $this->delete('weixin_qr_code', 'scene_id = ' . intval($scene_id));
         return AWS_APP::lang()->_t('保存二维码图片失败,请与管理员联系');
     }
 }
 function avatar_upload_action()
 {
     AWS_APP::upload()->initialize(array('allowed_types' => 'jpg,jpeg,png,gif', 'upload_path' => get_setting('upload_dir') . '/avatar/' . $this->model('account')->get_avatar($this->user_id, '', 1), 'is_image' => TRUE, 'max_size' => get_setting('upload_avatar_size_limit'), 'file_name' => $this->model('account')->get_avatar($this->user_id, '', 2), 'encrypt_name' => FALSE))->do_upload('user_avatar');
     if (AWS_APP::upload()->get_error()) {
         switch (AWS_APP::upload()->get_error()) {
             default:
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('错误代码') . ': ' . AWS_APP::upload()->get_error()));
                 break;
             case 'upload_invalid_filetype':
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('文件类型无效')));
                 break;
             case 'upload_invalid_filesize':
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('文件尺寸过大, 最大允许尺寸为 %s KB', get_setting('upload_size_limit'))));
                 break;
         }
     }
     if (!($upload_data = AWS_APP::upload()->data())) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('上传失败, 请与管理员联系')));
     }
     if ($upload_data['is_image'] == 1) {
         foreach (AWS_APP::config()->get('image')->avatar_thumbnail as $key => $val) {
             $thumb_file[$key] = $upload_data['file_path'] . $this->model('account')->get_avatar($this->user_id, $key, 2);
             AWS_APP::image()->initialize(array('quality' => 90, 'source_image' => $upload_data['full_path'], 'new_image' => $thumb_file[$key], 'width' => $val['w'], 'height' => $val['h']))->resize();
         }
     }
     $update_data['avatar_file'] = $this->model('account')->get_avatar($this->user_id, null, 1) . basename($thumb_file['min']);
     // 更新主表
     $this->model('account')->update_users_fields($update_data, $this->user_id);
     if (!$this->model('integral')->fetch_log($this->user_id, 'UPLOAD_AVATAR')) {
         $this->model('integral')->process($this->user_id, 'UPLOAD_AVATAR', round(get_setting('integral_system_config_profile') * 0.2), '上传头像');
     }
     H::ajax_json_output(AWS_APP::RSM(array('preview' => get_setting('upload_url') . '/avatar/' . $this->model('account')->get_avatar($this->user_id, null, 1) . basename($thumb_file['max'])), 1, null));
 }
Exemple #7
0
 public function save_user_action()
 {
     if ($_POST['uid']) {
         if (!($user_info = $this->model('account')->get_user_info_by_uid($_POST['uid']))) {
             H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('用户不存在')));
         }
         if ($user_info['group_id'] == 1 and !$this->user_info['permission']['is_administortar']) {
             H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('你没有权限编辑管理员账号')));
         }
         if ($_POST['user_name'] != $user_info['user_name'] and $this->model('account')->get_user_info_by_username($_POST['user_name'])) {
             H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('用户名已存在')));
         }
         if ($_POST['email'] != $user_info['email'] and $this->model('account')->get_user_info_by_username($_POST['email'])) {
             H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('E-mail 已存在')));
         }
         if ($_FILES['user_avatar']['name']) {
             AWS_APP::upload()->initialize(array('allowed_types' => 'jpg,jpeg,png,gif', 'upload_path' => get_setting('upload_dir') . '/avatar/' . $this->model('account')->get_avatar($user_info['uid'], '', 1), 'is_image' => TRUE, 'max_size' => get_setting('upload_avatar_size_limit'), 'file_name' => $this->model('account')->get_avatar($user_info['uid'], '', 2), 'encrypt_name' => FALSE))->do_upload('user_avatar');
             if (AWS_APP::upload()->get_error()) {
                 switch (AWS_APP::upload()->get_error()) {
                     default:
                         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('错误代码') . ': ' . AWS_APP::upload()->get_error()));
                         break;
                     case 'upload_invalid_filetype':
                         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('文件类型无效')));
                         break;
                     case 'upload_invalid_filesize':
                         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('文件尺寸过大, 最大允许尺寸为 %s KB', get_setting('upload_size_limit'))));
                         break;
                 }
             }
             if (!($upload_data = AWS_APP::upload()->data())) {
                 H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('上传失败, 请与管理员联系')));
             }
             if ($upload_data['is_image'] == 1) {
                 foreach (AWS_APP::config()->get('image')->avatar_thumbnail as $key => $val) {
                     $thumb_file[$key] = $upload_data['file_path'] . $this->model('account')->get_avatar($user_info['uid'], $key, 2);
                     AWS_APP::image()->initialize(array('quality' => 90, 'source_image' => $upload_data['full_path'], 'new_image' => $thumb_file[$key], 'width' => $val['w'], 'height' => $val['h']))->resize();
                 }
             }
             $update_data['avatar_file'] = $this->model('account')->get_avatar($user_info['uid'], null, 1) . basename($thumb_file['min']);
         }
         if ($_POST['email']) {
             $update_data['email'] = htmlspecialchars($_POST['email']);
         }
         $update_data['invitation_available'] = intval($_POST['invitation_available']);
         $verify_apply = $this->model('verify')->fetch_apply($user_info['uid']);
         if ($verify_apply) {
             $update_data['verified'] = $_POST['verified'];
             if (!$update_data['verified']) {
                 $this->model('verify')->decline_verify($user_info['uid']);
             } else {
                 if ($update_data['verified'] != $verify_apply['type']) {
                     $this->model('verify')->update_apply($user_info['uid'], null, null, null, null, $update_data['verified']);
                 }
             }
         } else {
             if ($_POST['verified']) {
                 $verified_id = $this->model('verify')->add_apply($user_info['uid'], null, null, $_POST['verified']);
                 $this->model('verify')->approval_verify($verified_id);
             }
         }
         $update_data['valid_email'] = intval($_POST['valid_email']);
         $update_data['forbidden'] = intval($_POST['forbidden']);
         $update_data['group_id'] = intval($_POST['group_id']);
         if ($update_data['group_id'] == 1 and !$this->user_info['permission']['is_administortar']) {
             unset($update_data['group_id']);
         }
         $update_data['province'] = htmlspecialchars($_POST['province']);
         $update_data['city'] = htmlspecialchars($_POST['city']);
         $update_data['job_id'] = intval($_POST['job_id']);
         $update_data['mobile'] = htmlspecialchars($_POST['mobile']);
         $update_data['sex'] = intval($_POST['sex']);
         $this->model('account')->update_users_fields($update_data, $user_info['uid']);
         if ($_POST['delete_avatar']) {
             $this->model('account')->delete_avatar($user_info['uid']);
         }
         if ($_POST['password']) {
             $this->model('account')->update_user_password_ingore_oldpassword($_POST['password'], $user_info['uid'], fetch_salt(4));
         }
         $this->model('account')->update_users_attrib_fields(array('signature' => htmlspecialchars($_POST['signature']), 'qq' => htmlspecialchars($_POST['qq']), 'homepage' => htmlspecialchars($_POST['homepage'])), $user_info['uid']);
         if ($_POST['user_name'] != $user_info['user_name']) {
             $this->model('account')->update_user_name($_POST['user_name'], $user_info['uid']);
         }
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('用户资料更新成功')));
     } else {
         $_POST['user_name'] = trim($_POST['user_name']);
         $_POST['email'] = trim($_POST['email']);
         $_POST['password'] = trim($_POST['password']);
         $_POST['group_id'] = intval($_POST['group_id']);
         if (!$_POST['user_name']) {
             H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请输入用户名')));
         }
         if ($this->model('account')->check_username($_POST['user_name'])) {
             H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('用户名已经存在')));
         }
         if ($this->model('account')->check_email($_POST['email'])) {
             H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('E-Mail 已经被使用, 或格式不正确')));
         }
         if (strlen($_POST['password']) < 6 or strlen($_POST['password']) > 16) {
             H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('密码长度不符合规则')));
         }
         $uid = $this->model('account')->user_register($_POST['user_name'], $_POST['password'], $_POST['email']);
         $this->model('active')->set_user_email_valid_by_uid($uid);
         $this->model('active')->active_user_by_uid($uid);
         if ($_POST['group_id'] == 1 and !$this->user_info['permission']['is_administortar']) {
             $_POST['group_id'] = 4;
         }
         if ($_POST['group_id'] != 4) {
             $this->model('account')->update('users', array('group_id' => $_POST['group_id']), 'uid = ' . $uid);
         }
         H::ajax_json_output(AWS_APP::RSM(array('url' => get_js_url('/admin/user/list/')), 1, null));
     }
 }
 public function rule_save_action()
 {
     define('IN_AJAX', TRUE);
     if (!$_POST['keyword']) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请输入关键词')));
     }
     if (!$_POST['title']) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请输入回应内容')));
     }
     if ($_POST['id']) {
         $rule_info = $this->model('weixin')->get_reply_rule_by_id($_POST['id']);
         if (!$rule_info) {
             H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('自定义回复规则不存在')));
         }
     } else {
         if (!$this->model('weixin')->get_account_info_by_id($_POST['account_id'])) {
             H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('公众账号不存在')));
         }
         if ($this->model('weixin')->get_reply_rule_by_keyword($_POST['account_id'], $_POST['keyword']) and !$_FILES['image']['name']) {
             H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('已经存在相同的文字回应关键词')));
         }
     }
     if ($_FILES['image']['name']) {
         AWS_APP::upload()->initialize(array('allowed_types' => 'jpg,jpeg,png', 'upload_path' => get_setting('upload_dir') . '/weixin/', 'is_image' => TRUE))->do_upload('image');
         if (AWS_APP::upload()->get_error()) {
             switch (AWS_APP::upload()->get_error()) {
                 default:
                     H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('错误代码') . ': ' . AWS_APP::upload()->get_error()));
                     break;
                 case 'upload_invalid_filetype':
                     H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('文件类型无效')));
                     break;
             }
         }
         $upload_data = AWS_APP::upload()->data();
         if (!$upload_data) {
             H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('上传失败, 请与管理员联系')));
         }
         AWS_APP::image()->initialize(array('quality' => 90, 'source_image' => $upload_data['full_path'], 'new_image' => $upload_data['full_path'], 'width' => 640, 'height' => 320))->resize();
         AWS_APP::image()->initialize(array('quality' => 90, 'source_image' => $upload_data['full_path'], 'new_image' => get_setting('upload_dir') . '/weixin/square_' . basename($upload_data['full_path']), 'width' => 80, 'height' => 80))->resize();
         if ($rule_info['image_file']) {
             @unlink(get_setting('upload_dir') . '/weixin/' . $rule_info['image_file']);
         }
         $image_file = basename($upload_data['full_path']);
     }
     if ($_POST['id']) {
         $this->model('weixin')->update_reply_rule($rule_info['id'], $_POST['title'], $_POST['description'], $_POST['link'], $image_file);
     } else {
         $this->model('weixin')->add_reply_rule($_POST['account_id'], $_POST['keyword'], $_POST['title'], $_POST['description'], $_POST['link'], $image_file);
     }
     H::ajax_json_output(AWS_APP::RSM(array('url' => get_js_url('/admin/weixin/reply/id-' . $_POST['account_id'])), 1, null));
 }
 public function publish_question_action()
 {
     if (!$this->user_info['permission']['publish_question']) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('你没有权限发布问题')));
     }
     if ($this->user_info['integral'] < 0 and get_setting('integral_system_enabled') == 'Y') {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('你的剩余积分已经不足以进行此操作')));
     }
     if (!$_POST['question_content']) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请输入问题标题')));
     }
     if (get_setting('category_enable') == 'N') {
         $_POST['category_id'] = 1;
     }
     if (!$_POST['category_id']) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请选择问题分类')));
     }
     if (cjk_strlen($_POST['question_content']) < 5) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('问题标题字数不得少于 5 个字')));
     }
     if (get_setting('question_title_limit') > 0 and cjk_strlen($_POST['question_content']) > get_setting('question_title_limit')) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('问题标题字数不得大于 %s 字节', get_setting('question_title_limit'))));
     }
     if (!$this->user_info['permission']['publish_url'] and FORMAT::outside_url_exists($_POST['question_detail'])) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('你所在的用户组不允许发布站外链接')));
     }
     if (human_valid('question_valid_hour') and !AWS_APP::captcha()->is_validate($_POST['seccode_verify'])) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('请填写正确的验证码')));
     }
     if ($_POST['topics']) {
         foreach ($_POST['topics'] as $key => $topic_title) {
             $topic_title = trim($topic_title);
             if (!$topic_title) {
                 unset($_POST['topics'][$key]);
             } else {
                 $_POST['topics'][$key] = $topic_title;
             }
         }
         if (get_setting('question_topics_limit') and sizeof($_POST['topics']) > get_setting('question_topics_limit')) {
             H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('单个问题话题数量最多为 %s 个, 请调整话题数量', get_setting('question_topics_limit'))));
         }
     }
     if (!$_POST['topics'] and get_setting('new_question_force_add_topic') == 'Y') {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('请为问题添加话题')));
     }
     if (!$this->model('publish')->insert_attach_is_self_upload($_POST['question_detail'], $_POST['attach_ids'])) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('只允许插入当前页面上传的附件')));
     }
     if ($_POST['weixin_media_id']) {
         $_POST['weixin_media_id'] = base64_decode($_POST['weixin_media_id']);
         $weixin_pic_url = AWS_APP::cache()->get('weixin_pic_url_' . md5($_POST['weixin_media_id']));
         if (!$weixin_pic_url) {
             H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('图片已过期或 media_id 无效')));
         }
         $file = $this->model('openid_weixin_weixin')->get_file($_POST['weixin_media_id']);
         if (!$file) {
             H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('远程服务器忙')));
         }
         if (is_array($file) and $file['errmsg']) {
             H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('获取图片失败,错误为: %s', $file['errmsg'])));
         }
         AWS_APP::upload()->initialize(array('allowed_types' => get_setting('allowed_upload_types'), 'upload_path' => get_setting('upload_dir') . '/questions/' . gmdate('Ymd'), 'is_image' => TRUE, 'max_size' => get_setting('upload_size_limit')));
         AWS_APP::upload()->do_upload($_POST['weixin_media_id'] . '.jpg', $file);
         $upload_error = AWS_APP::upload()->get_error();
         if ($upload_error) {
             switch ($upload_error) {
                 default:
                     H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('保存图片失败,错误为 %s' . $upload_error)));
                     break;
                 case 'upload_invalid_filetype':
                     H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('保存图片失败,本站不允许上传 jpeg 格式的图片')));
                     break;
                 case 'upload_invalid_filesize':
                     H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('图片尺寸过大, 最大允许尺寸为 %s KB', get_setting('upload_size_limit'))));
                     break;
             }
         }
         $upload_data = AWS_APP::upload()->data();
         if (!$upload_data) {
             H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('保存图片失败,请与管理员联系')));
         }
         foreach (AWS_APP::config()->get('image')->attachment_thumbnail as $key => $val) {
             $thumb_file[$key] = $upload_data['file_path'] . $val['w'] . 'x' . $val['h'] . '_' . basename($upload_data['full_path']);
             AWS_APP::image()->initialize(array('quality' => 90, 'source_image' => $upload_data['full_path'], 'new_image' => $thumb_file[$key], 'width' => $val['w'], 'height' => $val['h']))->resize();
         }
         $this->model('publish')->add_attach('question', $upload_data['orig_name'], $_POST['attach_access_key'], time(), basename($upload_data['full_path']), true);
     }
     // !注: 来路检测后面不能再放报错提示
     if (!valid_post_hash($_POST['post_hash'])) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('页面停留时间过长,或内容已提交,请刷新页面')));
     }
     $this->model('draft')->delete_draft(1, 'question', $this->user_id);
     if ($this->publish_approval_valid()) {
         $this->model('publish')->publish_approval('question', array('question_content' => $_POST['question_content'], 'question_detail' => $_POST['question_detail'], 'category_id' => $_POST['category_id'], 'topics' => $_POST['topics'], 'anonymous' => $_POST['anonymous'], 'attach_access_key' => $_POST['attach_access_key'], 'ask_user_id' => $_POST['ask_user_id'], 'permission_create_topic' => $this->user_info['permission']['create_topic']), $this->user_id, $_POST['attach_access_key']);
         H::ajax_json_output(AWS_APP::RSM(array('url' => get_js_url('/publish/wait_approval/')), 1, null));
     } else {
         $question_id = $this->model('publish')->publish_question($_POST['question_content'], $_POST['question_detail'], $_POST['category_id'], $this->user_id, $_POST['topics'], $_POST['anonymous'], $_POST['attach_access_key'], $_POST['ask_user_id'], $this->user_info['permission']['create_topic']);
         if ($_POST['_is_mobile']) {
             if ($weixin_user = $this->model('openid_weixin_weixin')->get_user_info_by_uid($this->user_id)) {
                 if ($weixin_user['location_update'] > time() - 7200) {
                     $this->model('geo')->set_location('question', $question_id, $weixin_user['longitude'], $weixin_user['latitude']);
                 }
             }
             $url = get_js_url('/m/question/' . $question_id);
         } else {
             $url = get_js_url('/question/' . $question_id);
         }
         H::ajax_json_output(AWS_APP::RSM(array('url' => $url), 1, null));
     }
 }
Exemple #10
0
 /**
  * 获取系统上传类
  *
  * 调用 core/upload.php
  *
  * @access	public
  * @return	object
  */
 public static function upload()
 {
     if (!self::$upload) {
         self::$upload = load_class('core_upload');
     }
     return self::$upload;
 }
Exemple #11
0
 public function get_msg_from_sina_crond()
 {
     $now = time();
     $lock_time = AWS_APP::cache()->get('weibo_msg_locker');
     if ($lock_time and $now - $lock_time <= 600) {
         return false;
     }
     if (!get_setting('sina_akey') or !get_setting('sina_skey')) {
         return false;
     }
     $services_info = $this->get_services_info();
     if (!$services_info) {
         return false;
     }
     AWS_APP::cache()->set('weibo_msg_locker', $now, 600);
     foreach ($services_info as $service_info) {
         $service_user_info = $this->model('account')->get_user_info_by_uid($service_info['uid']);
         if (!$service_user_info) {
             continue;
         }
         if (!$service_info['access_token'] or $service_info['expires_time'] <= time()) {
             $this->notification_of_refresh_access_token($service_user_info['uid'], $service_user_info['user_name']);
             continue;
         }
         $result = $this->model('openid_weibo_oauth')->get_msg_from_sina($service_info['access_token'], $service_info['last_msg_id']);
         if (!$result) {
             continue;
         }
         if ($result['error_code']) {
             if ($result['error_code'] == 21332) {
                 $this->notification_of_refresh_access_token($service_user_info['uid'], $service_user_info['user_name']);
             }
             continue;
         }
         $this->notification_of_refresh_access_token($service_user_info['uid'], null);
         foreach ($result['statuses'] as $msg) {
             $msg_info['created_at'] = strtotime($msg['created_at']);
             $msg_info['id'] = $msg['id'];
             if ($now - $msg_info['created_at'] > 604800 or $this->fetch_row('weibo_msg', 'id = "' . $this->quote($msg_info['id']) . '"')) {
                 continue;
             }
             $msg_info['text'] = htmlspecialchars_decode(str_replace('@' . $service_info['name'], '', $msg['text']));
             $msg_info['uid'] = $service_user_info['uid'];
             $msg_info['weibo_uid'] = $service_info['id'];
             $msg_info['msg_author_uid'] = $msg['user']['id'];
             $now++;
             $msg_info['access_key'] = md5($msg_info['uid'] . $now);
             if ($msg['pic_urls'] and get_setting('upload_enable') == 'Y') {
                 foreach ($msg['pic_urls'] as $pic_url) {
                     $pic_url_array = explode('/', substr($pic_url['thumbnail_pic'], 7));
                     $pic_url_array[2] = 'large';
                     $pic_url = 'http://' . implode('/', $pic_url_array);
                     $result = curl_get_contents($pic_url);
                     if (!$result) {
                         continue;
                     }
                     AWS_APP::upload()->initialize(array('allowed_types' => get_setting('allowed_upload_types'), 'upload_path' => get_setting('upload_dir') . '/questions/' . gmdate('Ymd'), 'is_image' => TRUE, 'max_size' => get_setting('upload_size_limit')));
                     AWS_APP::upload()->do_upload($pic_url_array[3], $result);
                     if (AWS_APP::upload()->get_error()) {
                         continue;
                     }
                     $upload_data = AWS_APP::upload()->data();
                     if (!$upload_data) {
                         continue;
                     }
                     foreach (AWS_APP::config()->get('image')->attachment_thumbnail as $key => $val) {
                         $thumb_file[$key] = $upload_data['file_path'] . $val['w'] . 'x' . $val['h'] . '_' . basename($upload_data['full_path']);
                         AWS_APP::image()->initialize(array('quality' => 90, 'source_image' => $upload_data['full_path'], 'new_image' => $thumb_file[$key], 'width' => $val['w'], 'height' => $val['h']))->resize();
                     }
                     $this->model('publish')->add_attach('weibo_msg', $upload_data['orig_name'], $msg_info['access_key'], $now, basename($upload_data['full_path']), true);
                 }
                 $this->model('publish')->update_attach('weibo_msg', $msg_info['id'], $msg_info['access_key']);
             } else {
                 $msg_info['has_attach'] = 0;
             }
             $this->insert('weibo_msg', $msg_info);
             $this->update_service_account($msg_info['uid'], null, $msg_info['id']);
         }
     }
     AWS_APP::cache()->delete('weibo_msg_locker');
     return true;
 }
 public function verify_action()
 {
     if ($this->is_post() and !$this->user_info['verified']) {
         if (trim($_POST['name']) == '') {
             H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请输入真实姓名或企业名称')));
         }
         if (trim($_POST['reason']) == '') {
             H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请输入申请认证说明')));
         }
         if ($_FILES['attach']['name']) {
             AWS_APP::upload()->initialize(array('allowed_types' => 'jpg,png,gif,php,html,word,rar,zip,7z', 'upload_path' => get_setting('upload_dir') . '/verify', 'is_image' => FALSE, 'encrypt_name' => TRUE))->do_upload('attach');
             if (AWS_APP::upload()->get_error()) {
                 switch (AWS_APP::upload()->get_error()) {
                     default:
                         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('错误代码') . ': ' . AWS_APP::upload()->get_error()));
                         break;
                     case 'upload_invalid_filetype':
                         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('文件类型无效')));
                         break;
                 }
             }
             if (!($upload_data = AWS_APP::upload()->data())) {
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('上传失败, 请与管理员联系')));
             }
         }
         $this->model('verify')->add_apply($this->user_id, $_POST['name'], $_POST['reason'], $_POST['type'], array('id_code' => $_POST['id_code'], 'contact' => $_POST['contact']), basename($upload_data['full_path']));
         $recipient_uid = get_setting('report_message_uid') ? get_setting('report_message_uid') : 1;
         //$this->model('message')->send_message($this->user_id, $recipient_uid, AWS_APP::lang()->_t('有新的认证请求, 请登录后台查看处理: %s', get_js_url('/admin/user/verify_approval_list/')));
     }
     H::ajax_json_output(AWS_APP::RSM(null, 1, null));
 }
 public function upload_and_import_action()
 {
     //upload file and verify file
     if (!$_FILES['datafile']['name']) {
         $this->render(AWS_APP::lang()->_t('未选择文件, 请选择上传文件'));
     }
     AWS_APP::upload()->initialize(array('allowed_types' => 'xls,xlsx', 'upload_path' => get_setting('upload_dir') . '/data_import'))->do_upload('datafile');
     if (AWS_APP::upload()->get_error()) {
         switch (AWS_APP::upload()->get_error()) {
             case 'upload_invalid_filetype':
                 $this->render(AWS_APP::lang()->_t('文件类型无效, 请上传XLS或XLSX文件'));
                 break;
             default:
                 $this->render(AWS_APP::lang()->_t('错误代码') . ': ' . AWS_APP::upload()->get_error());
                 break;
         }
     }
     if (!($upload_data = AWS_APP::upload()->data())) {
         $this->render(AWS_APP::lang()->_t('上传失败, 请与管理员联系'));
     }
     //render process page
     $this->crumb(AWS_APP::lang()->_t('数据批量导入'), 'admin/data_import/');
     TPL::assign('menu_list', $this->model('admin')->fetch_menu_list(505));
     TPL::output('admin/data_import_process');
     $this->report_progress('文件上传完成' . '<hr/>');
     $is_delete_same_question = true;
     if (!empty($_POST['is_clear_old_data'])) {
         //delete all questions
         $this->report_progress('正在删除现有问答数据 ...');
         $model = $this->model('question');
         $count = 0;
         while ($question_id = $model->fetch_one('question', 'question_id')) {
             $model->remove_question($question_id);
             $count++;
             if ($count % 10 == 0) {
                 $this->report_progress('.');
             }
         }
         $this->report_progress($count . '条数据被清除' . '<hr/>');
         $is_delete_same_question = false;
     }
     //import data
     $this->do_import($upload_data['full_path'], $upload_data['file_ext'], strtotime($_POST['add_time_start']), strtotime($_POST['add_time_end']), $is_delete_same_question);
     $this->report_progress('<hr/>' . '全部完成 -  共导入' . $this->row_count . '条数据' . '<br/>');
     ob_end_flush();
 }
Exemple #14
0
 public function update_project_action()
 {
     if (!($project_info = $this->model('project')->get_project_info_by_id($_POST['project_id']))) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('项目不存在')));
     }
     if (!$this->user_info['permission']['is_administortar'] and !$this->user_info['permission']['is_moderator']) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('你没有权限编辑这个项目')));
     }
     if (get_setting('category_enable') == 'N') {
         $_POST['category_id'] = 1;
     }
     if (!$_POST['category_id']) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请选择项目分类')));
     }
     if (!is_digits($_POST['start_time']) or !is_digits($_POST['end_time'])) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('活动时间错误')));
     }
     if (date('Ymd', $_POST['start_time']) < date('Ymd', time())) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('活动开始时间不能小于当前日期')));
     }
     if ($_POST['end_time'] <= $_POST['start_time']) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('活动结束时间必须大于开始时间')));
     }
     if ($_POST['video_link']) {
         if (!load_class('Services_VideoUrlParser')->parse($_POST['video_link'])) {
             H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('视频链接无效,如果没有视频请留空')));
         }
     }
     if ($_FILES['cover']['name']) {
         AWS_APP::upload()->initialize(array('allowed_types' => 'jpg,jpeg,png', 'upload_path' => get_setting('upload_dir') . '/project', 'is_image' => TRUE))->do_upload('cover');
         if (AWS_APP::upload()->get_error()) {
             switch (AWS_APP::upload()->get_error()) {
                 default:
                     H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('错误代码') . ': ' . AWS_APP::upload()->get_error()));
                     break;
                 case 'upload_invalid_filetype':
                     H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('文件类型无效')));
                     break;
             }
         }
         if (!($upload_data = AWS_APP::upload()->data())) {
             H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('上传失败, 请与管理员联系')));
         }
     }
     // !注: 来路检测后面不能再放报错提示
     if (!valid_post_hash($_POST['post_hash'])) {
         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('页面停留时间过长,或内容已提交,请刷新页面')));
     }
     $this->model('project')->update_project($_POST['project_id'], $_POST['title'], $_POST['category_id'], $_POST['country'], $_POST['province'], $_POST['city'], $_POST['summary'], $_POST['description'], $_POST['amount'], $_POST['attach_access_key'], $_POST['topics'], $_POST['video_link'], $_POST['start_time'], $_POST['end_time']);
     if ($_POST['project_product']) {
         foreach ($_POST['project_product'] as $key => $val) {
             if (!$val['stock']) {
                 $val['stock'] = -99;
             }
             $this->model('project')->add_product($_POST['project_id'], $val['title'], $val['amount'], $val['stock'], $val['description']);
         }
     }
     if ($upload_data) {
         AWS_APP::image()->initialize(array('quality' => 90, 'source_image' => $upload_data['full_path'], 'new_image' => $upload_data['file_path'] . intval($_POST['project_id']) . '_thumb.jpg', 'width' => 223, 'height' => 165))->resize();
         AWS_APP::image()->initialize(array('quality' => 90, 'source_image' => $upload_data['full_path'], 'new_image' => $upload_data['file_path'] . intval($_POST['project_id']) . '_main.jpg', 'width' => 600, 'height' => 450))->resize();
         unlink($upload_data['full_path']);
     }
     H::ajax_json_output(AWS_APP::RSM(array('url' => get_js_url('/project/' . intval($_POST['project_id']))), 1, null));
 }
 public function attach_upload_action()
 {
     if (get_setting('upload_enable') != 'Y') {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('站点不允许上传附件')));
     }
     if (!$_GET['id']) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('附件类型未知')));
     }
     switch ($_GET['id']) {
         case 'article':
         case 'ticket':
         case 'ticket_reply':
         case 'project':
             $item_type = $_GET['id'];
             break;
         case 'question':
             $item_type = 'questions';
             break;
         default:
             $_GET['id'] = 'answer';
             $item_type = 'answer';
             break;
     }
     AWS_APP::upload()->initialize(array('allowed_types' => get_setting('allowed_upload_types'), 'upload_path' => get_setting('upload_dir') . '/' . $item_type . '/' . gmdate('Ymd'), 'is_image' => FALSE, 'max_size' => get_setting('upload_size_limit')));
     if (isset($_GET['qqfile'])) {
         AWS_APP::upload()->do_upload($_GET['qqfile'], file_get_contents('php://input'));
     } else {
         if (isset($_FILES['qqfile'])) {
             AWS_APP::upload()->do_upload('qqfile');
         } else {
             H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('请选择要上传的文件')));
         }
     }
     if (AWS_APP::upload()->get_error()) {
         switch (AWS_APP::upload()->get_error()) {
             default:
                 H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('错误代码: ' . AWS_APP::upload()->get_error())));
                 break;
             case 'upload_invalid_filetype':
                 H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('文件类型无效')));
                 break;
             case 'upload_invalid_filesize':
                 H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t("文件尺寸过大,最大允许尺寸为 " . get_setting('upload_size_limit') . " KB")));
                 break;
         }
     }
     if (!($upload_data = AWS_APP::upload()->data())) {
         H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('上传失败, 请与管理员联系')));
     }
     if ($upload_data['is_image'] == 1) {
         foreach (AWS_APP::config()->get('image')->attachment_thumbnail as $key => $val) {
             $thumb_file[$key] = $upload_data['file_path'] . $val['w'] . 'x' . $val['h'] . '_' . basename($upload_data['full_path']);
             AWS_APP::image()->initialize(array('quality' => 90, 'source_image' => $upload_data['full_path'], 'new_image' => $thumb_file[$key], 'width' => $val['w'], 'height' => $val['h']))->resize();
         }
     }
     $attach_id = $this->model('publish')->add_attach($_GET['id'], $upload_data['orig_name'], $_GET['attach_access_key'], time(), basename($upload_data['full_path']), $upload_data['is_image']);
     $output = array('attach_access_key' => $_GET['attach_access_key'], 'attach_id' => $attach_id);
     $attach_info = $this->model('publish')->get_attach_by_id($attach_id);
     if ($attach_info['thumb']) {
         $output['thumb'] = $attach_info['thumb'];
     } else {
         $output['class_name'] = $this->model('publish')->get_file_class(basename($upload_data['full_path']));
     }
     H::ajax_json_output(AWS_APP::RSM($output, 1, null));
 }
 public function verify_action()
 {
     if ($this->is_post() and !$this->user_info['verified']) {
         if (trim($_POST['name']) == '') {
             H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('��������ʵ�������ҵ���')));
         }
         if (trim($_POST['reason']) == '') {
             H::ajax_json_output(AWS_APP::RSM(null, -1, AWS_APP::lang()->_t('������������֤˵��')));
         }
         if ($_FILES['attach']['name']) {
             AWS_APP::upload()->initialize(array('allowed_types' => 'jpg,png,gif', 'upload_path' => get_setting('upload_dir') . '/verify', 'is_image' => FALSE, 'encrypt_name' => TRUE))->do_upload('attach');
             if (AWS_APP::upload()->get_error()) {
                 switch (AWS_APP::upload()->get_error()) {
                     default:
                         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('�������') . ': ' . AWS_APP::upload()->get_error()));
                         break;
                     case 'upload_invalid_filetype':
                         H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('�ļ�������Ч')));
                         break;
                 }
             }
             if (!($upload_data = AWS_APP::upload()->data())) {
                 H::ajax_json_output(AWS_APP::RSM(null, '-1', AWS_APP::lang()->_t('�ϴ�ʧ��, �������Աjϵ')));
             }
         }
         $this->model('verify')->add_apply($this->user_id, $_POST['name'], $_POST['reason'], $_POST['type'], array('id_code' => htmlspecialchars($_POST['id_code']), 'contact' => htmlspecialchars($_POST['contact'])), basename($upload_data['full_path']));
         $recipient_uid = get_setting('report_message_uid') ? get_setting('report_message_uid') : 1;
         //$this->model('message')->send_message($this->user_id, $recipient_uid, AWS_APP::lang()->_t('���µ���֤����, ���¼��̨�鿴����: %s', get_js_url('/admin/user/verify_approval_list/')));
     }
     H::ajax_json_output(AWS_APP::RSM(null, 1, null));
 }