示例#1
0
 function save_priv()
 {
     need_login('ajax');
     $album['priv_type'] = $this->getPost('priv_type', '0');
     $album['priv_pass'] = $this->getPost('priv_pass');
     $album['priv_question'] = safe_convert($this->getPost('priv_question'));
     $album['priv_answer'] = safe_convert($this->getPost('priv_answer'));
     $id = intval($this->getGet('id'));
     if ($album['priv_type'] == '1') {
         if ($album['priv_pass'] == '') {
             form_ajax_failed('text', lang('album_password_empty'));
         }
     }
     if ($album['priv_type'] == '2') {
         if ($album['priv_question'] == '') {
             form_ajax_failed('text', lang('album_question_empty'));
         }
         if ($album['priv_answer'] == '') {
             form_ajax_failed('text', lang('album_answer_empty'));
         }
     }
     if ($this->mdl_album->update($id, $album)) {
         $this->plugin->trigger('modified_album_priv', $id);
         form_ajax_success('box', lang('modify_album_priv_success'), null, 0.5, $_SERVER['HTTP_REFERER']);
     } else {
         form_ajax_failed('text', lang('modify_album_priv_failed'));
     }
 }
示例#2
0
 function update()
 {
     need_login('ajax');
     $id = intval($this->getGet('id'));
     $data['par_id'] = $this->getPost('par_id') > 0 ? $this->getPost('par_id') : 0;
     $data['name'] = $this->getPost('cate_name');
     $data['sort'] = intval($this->getPost('sort'));
     if ($this->mdl_cate->update(intval($id), $data)) {
         if ($this->getPost('add_nav')) {
             $nav_data['type'] = 1;
             $nav_data['name'] = $data['name'];
             $nav_data['url'] = site_link('albums', 'index', array('cate' => $id));
             $nav_data['sort'] = 100;
             $nav_data['enable'] = 1;
             $mdl_nav =& loader::model('nav');
             $mdl_nav->save($nav_data);
             //清除菜单缓存
             $mdl_nav->clear_nav_cache();
         }
         form_ajax_success('box', lang('edit_category_succ'), null, 0.5, $_SERVER['HTTP_REFERER']);
     } else {
         form_ajax_failed('text', lang('edit_category_fail'));
     }
 }
示例#3
0
 function save_reply()
 {
     if (!$this->setting->get_conf('system.enable_comment')) {
         form_ajax_failed('text', lang('album_comment_closed'));
     }
     $comment['email'] = safe_convert($this->getPost('email'));
     $comment['author'] = safe_convert($this->getPost('author'));
     $comment['content'] = safe_convert($this->getPost('content'));
     $comment['ref_id'] = intval($this->getPost('ref_id'));
     $comment['type'] = intval($this->getPost('type'));
     $comment['reply_author'] = safe_convert($this->getPost('reply_author'));
     $comment['pid'] = intval($this->getPost('pid'));
     $this->plugin->trigger('before_post_comment');
     if ($this->setting->get_conf('system.enable_comment_captcha') && !$this->user->loggedin()) {
         $captcha =& loader::lib('captcha');
         if (!$captcha->check($this->getPost('captcha'))) {
             form_ajax_failed('text', lang('invalid_captcha_code'));
         }
     }
     if ($comment['email'] && !check_email($comment['email'])) {
         form_ajax_failed('text', lang('error_email'));
     }
     if (!$comment['author']) {
         form_ajax_failed('text', lang('error_comment_author'));
     }
     if (!$comment['content']) {
         form_ajax_failed('text', lang('empty_content'));
     }
     if (!$comment['ref_id'] || !$comment['type'] || !$comment['pid'] || !$comment['reply_author']) {
         form_ajax_failed('text', lang('miss_argument'));
     }
     $comment['post_time'] = time();
     $comment['author_ip'] = get_real_ip();
     if ($this->setting->get_conf('system.comment_audit') == 1 && !$this->user->loggedin()) {
         $comment['status'] = 0;
     } else {
         $comment['status'] = 1;
     }
     if ($reply_id = $this->mdl_comment->save($comment)) {
         $comment['id'] = $reply_id;
         $this->output->set('info', $comment);
         $this->plugin->trigger('reply_comment', $reply_id);
         form_ajax_success('text', loader::view('comments/view', false));
     } else {
         form_ajax_failed('text', lang('reply_failed'));
     }
 }
示例#4
0
 function save_nav()
 {
     need_login('ajax_box');
     $mdl_nav =& Loader::model('nav');
     $names = $this->getPost('name');
     $urls = $this->getPost('url');
     $sorts = $this->getPost('sort');
     $dels = $this->getPost('del');
     $enables = $this->getPost('enable');
     $flag = true;
     //编辑及删除
     if ($names) {
         foreach ($names as $key => $name) {
             $key = intval($key);
             $name = trim($name);
             $urls[$key] = isset($urls[$key]) ? trim($urls[$key]) : '';
             if (isset($dels[$key])) {
                 //delete 记录
                 $mdl_nav->delete($key);
             } else {
                 $data = array();
                 if ($name) {
                     $data['name'] = $name;
                 }
                 if ($urls[$key]) {
                     $data['url'] = $urls[$key];
                 }
                 if ($sorts[$key]) {
                     $data['sort'] = intval($sorts[$key]);
                 }
                 if (isset($enables[$key])) {
                     $data['enable'] = 1;
                 } else {
                     $data['enable'] = 0;
                 }
                 if (!$mdl_nav->update($key, $data)) {
                     $flag = false;
                 }
             }
         }
     }
     //新增
     $newnames = $this->getPost('namenew');
     $newurls = $this->getPost('urlnew');
     $newsorts = $this->getPost('sortnew');
     if ($newnames) {
         foreach ($newnames as $key => $newname) {
             $newname = trim($newname);
             $newurls[$key] = trim($newurls[$key]);
             if ($newname == '') {
                 continue;
             }
             if ($newurls[$key] == '') {
                 $flag = false;
                 continue;
             }
             $data = array('name' => $newname, 'url' => $newurls[$key], 'sort' => $newsorts[$key] ? intval($newsorts[$key]) : 100, 'enable' => 1);
             if (!$mdl_nav->save($data)) {
                 $flag = false;
             }
         }
     }
     //清除菜单缓存
     $mdl_nav->clear_nav_cache();
     if ($flag) {
         form_ajax_success('box', lang('nav_save_succ'), null, 0.5, $_SERVER['HTTP_REFERER']);
     } else {
         form_ajax_failed('box', lang('nav_save_fail'), null, 2, $_SERVER['HTTP_REFERER']);
     }
 }
示例#5
0
文件: users.ctl.php 项目: vluo/myPoto
 function save_profile()
 {
     need_login('ajax');
     $current_id = $this->user->get_field('id');
     $arr['user_nicename'] = safe_convert($this->getPost('user_nicename'));
     $new_pass = $this->getPost('new_pass');
     $old_pass = $this->getPost('old_pass');
     $new_pass_again = $this->getPost('new_pass_again');
     $extra_arr = $this->getPost('extra');
     if ($extra_arr['email'] && !check_email($extra_arr['email'])) {
         form_ajax_failed('text', lang('error_email'));
     }
     if ($new_pass) {
         if (!$this->user->check_pass($current_id, md5($old_pass))) {
             form_ajax_failed('text', lang('old_pass_error'));
         }
         if ($new_pass != $new_pass_again) {
             form_ajax_failed('text', lang('pass_twice_error'));
         }
         $arr['user_pass'] = md5($new_pass);
     }
     if ($this->user->update($current_id, $arr)) {
         $this->user->save_extra($current_id, $extra_arr);
         form_ajax_success('box', lang('modify_success') . ($new_pass ? lang('pass_edit_ok') : ''), null, 0.5, $_SERVER['HTTP_REFERER']);
     } else {
         form_ajax_failed('text', lang('modify_failed'));
     }
 }
示例#6
0
 function save_desc()
 {
     need_login('ajax');
     $id = intval($this->getGet('id'));
     $desc = safe_convert($this->getPost('desc'));
     if ($desc == '') {
         form_ajax_failed('text', lang('empty_photo_desc'));
     }
     if ($this->mdl_photo->update($id, array('desc' => $desc))) {
         $this->plugin->trigger('modified_photo_desc', $id);
         form_ajax_success('text', $desc);
     } else {
         form_ajax_failed('text', lang('modify_photo_desc_failed'));
     }
     return;
 }
示例#7
0
 function save()
 {
     @set_time_limit(0);
     @ignore_user_abort(true);
     $type = $this->getGet('t');
     $album_id = intval($this->getRequest('aid'));
     if (!$album_id) {
         showError(lang('pls_sel_album'));
     }
     if ($type == 'multi') {
         need_login('ajax');
         /*$files_count = intval($this->getPost('muilti_uploader_count'));
           for($i=0;$i<$files_count;$i++){
               $filename = $this->getPost("muilti_uploader_{$i}_tmpname");
               $realname = $this->getPost("muilti_uploader_{$i}_name");
               $purename = file_pure_name($filename);
               $purerealname = file_pure_name($realname);
               $photorow = $this->mdl_photo->get_photo_by_name_aid($album_id,$purename);
               if($photorow){
                   $this->mdl_photo->update($photorow['id'],array('name'=>$purerealname));
               }
           }
           */
         $this->mdl_album->update_photos_num($album_id);
         $this->mdl_album->check_repare_cover($album_id);
         $gourl = site_link('photos', 'index', array('aid' => $album_id));
         form_ajax_success('box', lang('upload_photo_success'), null, 1, $gourl);
     } else {
         need_login('page');
         $this->output->set('album_id', $album_id);
         $album_info = $this->mdl_album->get_info($album_id);
         $this->output->set('album_info', $album_info);
         $page_title = lang('upload_photo') . ' - ' . $this->setting->get_conf('site.title');
         $page_keywords = $this->setting->get_conf('site.keywords');
         $page_description = $this->setting->get_conf('site.description');
         $this->page_init($page_title, $page_keywords, $page_description);
         $imglib =& loader::lib('image');
         $supportType = $imglib->supportType();
         $empty_num = 0;
         $error = '';
         $allowsize = allowsize($this->setting->get_conf('upload.allow_size'));
         if (isset($_FILES['imgs'])) {
             foreach ($_FILES['imgs']['name'] as $k => $upfile) {
                 if (!empty($upfile)) {
                     $filesize = $_FILES['imgs']['size'][$k];
                     $tmpfile = $_FILES['imgs']['tmp_name'][$k];
                     $filename = $upfile;
                     $fileext = file_ext($filename);
                     if ($_FILES['imgs']['error'][$k] == 1) {
                         $error .= lang('failed_larger_than_server', $filename) . '<br />';
                         continue;
                     }
                     if ($allowsize && $filesize > $allowsize) {
                         $error .= lang('failed_larger_than_usetting', $filename) . '<br />';
                         continue;
                     }
                     if ($filesize == 0) {
                         $error .= lang('failed_if_file', $filename) . '<br />';
                         continue;
                     }
                     if (!in_array($fileext, $supportType)) {
                         $error .= lang('failed_not_support', $filename) . '<br />';
                         continue;
                     }
                     if (!$this->mdl_photo->save_upload($album_id, $tmpfile, $filename, true, array('cate_id' => $album_info['cate_id']))) {
                         $error .= lang('file_upload_failed', $filename) . '<br />';
                     }
                 } else {
                     $empty_num++;
                 }
             }
         } else {
             $error = lang('need_sel_upload_file');
         }
         if (isset($_FILES['imgs']) && $empty_num == count($_FILES['imgs']['name'])) {
             $this->output->set('msginfo', '<div class="failed">' . lang('need_sel_upload_file') . '</div>');
         } else {
             $this->mdl_album->update_photos_num($album_id);
             $this->mdl_album->check_repare_cover($album_id);
             if ($error) {
                 $this->output->set('msginfo', '<div class="failed">' . $error . '</div>');
             } else {
                 $this->output->set('msginfo', '<div class="success">' . lang('upload_photo_success') . '<a href="' . site_link('photos', 'index', array('aid' => $album_id)) . '">' . lang('view_album') . '</a></div>');
             }
         }
         $crumb_nav = array();
         $crumb_nav[] = array('name' => lang('upload_photo'));
         $this->page_crumb($crumb_nav);
         loader::view('upload/normal');
     }
 }