示例#1
0
 public function indexAction()
 {
     $pf = NULL;
     if (preg_match('#^(.+)/profile/(.+)$#i', $this->reqs->uri, $regs)) {
         $uname = $regs[2];
         try {
             $this->initdb();
             $_profile = Core_Dao::factory(array('name' => 'user_profile'));
             $user = $_profile->getList(array('uname' => $uname));
             if (isset($user[0]['id'])) {
                 $des = str_split($uname);
                 $path = '/data/user/' . $des['0'] . '/' . $des['1'] . '/' . $des['2'] . '/' . $uname;
                 if (!file_exists(SYS_ROOT . $path . "/w100.png")) {
                     $path = '/data/user';
                 }
                 $pf = $user[0];
                 $pf['photo_path'] = $path;
                 $pf['content'] = Core_Util_Format::richEditFilter($pf['content']);
             }
         } catch (Exception $e) {
             //
         }
     }
     if ($pf === NULL) {
         $this->view->message = Core_Message::get('error', 'Profile not found');
     } else {
         $this->view->profile = $pf;
         $this->view->content = $this->view->render('profile/index');
         unset($pf, $this->view->profile);
     }
     $this->response('layout');
 }
示例#2
0
 public function indexAction()
 {
     try {
         if ($this->session->uid != "0") {
             $_user = Core_Dao::factory(array('name' => 'user'));
             $this->view->user = $_user->getById($this->session->uid);
             $des = str_split($this->session->uname);
             $path = '/data/user/' . $des['0'] . '/' . $des['1'] . '/' . $des['2'] . '/' . $this->session->uname;
             if (!file_exists(SYS_ROOT . $path . "/w100.png")) {
                 $path = '/data/user';
             }
             $this->view->user['photo_path'] = $path;
             $this->view->content = $this->view->render('manage/index');
         } else {
             throw new Exception('Access Denied');
         }
     } catch (Exception $e) {
         $this->view->message = Core_Message::get('error', $e->getMessage());
     }
     unset($this->session);
     $this->response('layout');
 }
示例#3
0
 public function emaildoAction()
 {
     $vars = get_object_vars($this->reqs);
     if (!User_Model_Account_EmailValidate::isValid($vars, $msg)) {
         $this->view->message = Core_Message::get('error', $msg);
         return $this->emailAction();
     }
     try {
         if ($this->session->uid != "0") {
             $_user = Core_Dao::factory(array('name' => 'user'));
             $user = $_user->getById($this->session->uid);
             if (isset($user['pass']) && md5($vars['pass']) == $user['pass']) {
                 $set = array('email' => $vars['email']);
                 $where = array('id' => $this->session->uid);
                 $_user->update($set, $where);
                 $this->view->message = Core_Message::get('success', 'Success');
             } else {
                 $this->view->message = Core_Message::get('error', 'Password do not match');
             }
         }
     } catch (Exception $e) {
         $this->view->message = Core_Message::get('error', 'Unknown');
     }
     $this->emailAction();
 }
示例#4
0
 public function photodoAction()
 {
     $vars = get_object_vars($this->reqs);
     $_user = Core_Dao::factory(array('name' => 'user'));
     $_image = new Core_Util_Image();
     $status = true;
     $profile = null;
     try {
         if ($this->session->uid != "0") {
             $profile = $_user->getById($this->session->uid);
         }
     } catch (Exception $e) {
         //
     }
     if ($profile === null) {
         $msg = Core_Message::get('error', 'Unknown error');
     } else {
         $file_tmp = $_FILES['attachment']['tmp_name'];
         $file_name = $_FILES['attachment']['name'];
         $file_size = $_FILES['attachment']['size'];
         $file_mime = $_FILES['attachment']['type'];
         $file_ext = substr(strrchr(strtolower($file_name), '.'), 1);
         if (!in_array($file_ext, array('png', 'jpg', 'jpeg', 'gif'))) {
             $msg = Core_Message::get('error', 'You must upload a JPG, GIF, or PNG file');
         } else {
             if (is_uploaded_file($file_tmp)) {
                 $des = str_split($profile['uname']);
                 $des_dir = SYS_ROOT . '/data/user/' . $des['0'] . '/' . $des['1'] . '/' . $des['2'];
                 $des_dir .= '/' . $profile['uname'];
                 Core_Util_Directory::mkdir($des_dir);
                 $file_size_stored = @filesize($file_tmp);
                 if ($file_size_stored > 1000000) {
                     @unlink($file_tmp);
                     $max_size = 1000000 / 1000;
                     $msg = Core_Message::get('error', "File size must less than {$max_size} Kb");
                     $status = false;
                 } elseif ($file_size_stored != $file_size) {
                     @unlink($file_tmp);
                     $msg = Core_Message::get('error', 'Unknown error');
                     $status = false;
                 }
                 if ($status && ($imginfo = @getimagesize($file_tmp))) {
                     if (!$imginfo[2]) {
                         @unlink($file_tmp);
                         $msg = Core_Message::get('error', 'Invalid image');
                         $status = false;
                     }
                 }
                 $_image->resampimagejpg(100, 100, $file_tmp, $des_dir . '/w100.png', true);
                 $_image->resampimagejpg(40, 40, $file_tmp, $des_dir . '/w40.png', false);
             }
         }
     }
     if (isset($msg)) {
         $this->view->message = $msg;
     } else {
         $this->view->message = Core_Message::get('success', 'Success');
     }
     $this->photoAction();
 }
示例#5
0
 public function delAction()
 {
     $links = array(array('url' => 'javascript:history.back();', 'title' => 'Back'));
     if (!isset($this->reqs->params['id'])) {
         $this->view->message = Core_Message::get('error', "ID can not be null", $links);
         return $this->response("error/index");
     }
     try {
         $dbentry = Core_Dao::factory(array('name' => 'data_entry'));
         $entry = $dbentry->getById($this->reqs->params['id']);
         if (!isset($entry['id'])) {
             throw new Exception('Entry not found');
         }
         $dbentry->delete(array('id' => $this->reqs->params['id']));
     } catch (Exception $e) {
         $this->view->message = Core_Message::get('error', $e->getMessage());
         return $this->response("error/index");
     }
     $this->view->message = Core_Message::get('success', 'Success');
     $this->response("error/index");
 }
示例#6
0
 public function updoAction()
 {
     $vars = get_object_vars($this->reqs);
     if (!User_Model_Sign_UpValidate::isValid($vars, $msg)) {
         $this->view->message = Core_Message::get('error', $msg);
         return $this->upAction();
     }
     try {
         $this->initdb();
         $_sign = new User_Model_Sign();
         $_sign->up($vars);
         $this->view->message = Core_Message::get('success', 'Success');
         $this->indexAction();
     } catch (Exception $e) {
         $this->view->message = Core_Message::get('error', $e->getMessage());
         $this->upAction();
     }
 }