public function pwddoAction() { $params = $this->_params; if (User_Model_Account_Validate::isPasswordChange($params, $msg)) { try { if ($this->_session->uid != "0") { $_user = new Common_Db_User(); $user = $_user->getById($this->_session->uid); if (isset($user['pass']) && md5($params['pass_current']) == $user['pass']) { $set = array('pass' => md5($params['pass'])); $where = array('uid = ?' => $this->_session->uid); $_user->update($set, $where); $this->view->message = Common_Message::get('success', 'Success'); } else { $this->view->message = Common_Message::get('error', 'Current password do not match'); } } } catch (Exception $e) { $this->view->message = Common_Message::get('error', 'Current password do not match'); } } else { $this->view->message = Common_Message::get('error', $msg); } $this->loadLayout('layout-simple'); $this->render('pwd'); }
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'); }
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'); }