コード例 #1
0
ファイル: ManageController.php プロジェクト: eryx/labs
 public function indexAction()
 {
     $_user = new Common_Db_User();
     try {
         if ($this->_session->uid != "0") {
             $user = $_user->getById($this->_session->uid);
         } else {
             $user = null;
         }
     } catch (Exception $e) {
         $user = null;
     }
     $this->view->item = $user;
     $this->loadLayout('layout-simple');
     $this->render('index');
 }
コード例 #2
0
ファイル: AccountManageController.php プロジェクト: eryx/labs
 public function emaildoAction()
 {
     $params = $this->_params;
     if (User_Model_Account_EmailValidate::isValid($params, $msg)) {
         try {
             if ($this->_session->uid != "0") {
                 $_user = new Common_Db_User();
                 //$user = $_user->getById($this->_session->uid);
                 $set = array('email' => $params['email']);
                 $where = array('uid = ?' => $this->_session->uid);
                 $_user->update($set, $where);
                 $this->view->message = Common_Message::get('success', 'Success');
             }
         } catch (Exception $e) {
             $this->view->message = Common_Message::get('error', 'Unknown');
         }
     } else {
         $this->view->message = Common_Message::get('error', $msg);
     }
     $this->loadLayout('layout-simple');
     $this->render('email');
 }
コード例 #3
0
ファイル: Sign.php プロジェクト: eryx/labs
 public function up($params)
 {
     $_user = new Common_Db_User();
     try {
         $user = $_user->getByName($params['uname']);
     } catch (Exception $e) {
         $user = array();
     }
     if (isset($user['uname'])) {
         throw new Exception('This ID is not available, please use another one');
     }
     $pass = md5($params['pass']);
     $uid = Common_Util_Uuid::create();
     $user = array('uid' => $uid, 'uname' => $params['uname'], 'email' => $params['email'], 'pass' => $pass);
     try {
         $_user->insert($user);
     } catch (Exception $e) {
         throw $e;
     }
 }
コード例 #4
0
ファイル: ProfileManageController.php プロジェクト: eryx/labs
 public function photodoAction()
 {
     $params = $this->_params;
     $_user = new Common_Db_User();
     $_image = new Common_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 = Common_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 = Common_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_ENTRY . '/data/user/' . $des['0'] . '/' . $des['1'] . '/' . $des['2'];
                 $des_dir .= '/' . $profile['uname'];
                 Common_Util_Directory::mkdir($des_dir);
                 $file_size_stored = @filesize($file_tmp);
                 if ($file_size_stored > 1000000) {
                     @unlink($file_tmp);
                     $max_size = 1000000 / 1000;
                     $msg = Common_Message::get('error', "File size must less than {$max_size} Kb");
                     $status = false;
                 } elseif ($file_size_stored != $file_size) {
                     @unlink($file_tmp);
                     $msg = Common_Message::get('error', 'Unknown error');
                     $status = false;
                 }
                 if ($status && ($imginfo = @getimagesize($file_tmp))) {
                     if (!$imginfo[2]) {
                         @unlink($file_tmp);
                         $msg = Common_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 = Common_Message::get('success', 'Success');
     }
     $this->loadLayout('layout-simple');
     $this->render('photo');
     //$this->_redirect('/user/manage');
 }