Example #1
0
 public function action_edit()
 {
     $id = $this->request->param('id');
     if ($id != $this->user) {
         $this->request->redirect(URL::base());
     }
     $view = View::factory('player_edit');
     $view->realname = @real_name_from_id($id);
     if ($_POST) {
         $realname = @$_POST['realname'];
         $current_password = @$_POST['current_password'];
         $new_password = @$_POST['new_password'];
         $confirm_password = @$_POST['confirm_password'];
         if ($new_password) {
             if (!Auth::check_password($current_password)) {
                 array_push($this->template->errors, "Password did not match password on file.");
             }
             if ($new_password != $confirm_password) {
                 array_push($this->template->errors, "New passwords did not match.");
             }
             if (empty($this->template->errors)) {
                 password(name_from_id($id));
             }
         }
         if ($realname) {
             DB::update('users')->set(array('realname' => $realname))->where('id', '=', $id)->execute();
         }
         $this->request->redirect('/player/view/2');
     }
     $this->template->content = $view;
 }
Example #2
0
require_once _ROOT_DIR . '../php_libs/init.php';
$smarty = new Smarty();
$smarty->template_dir = _SMARTY_TEMPLATES_DIR;
$smarty->compile_dir = _SMARTY_TEMPLATES_C_DIR;
$smarty->config_dir = _SMARTY_CONFIG_DIR;
$smarty->cache_dir = _SMARTY_CACHE_DIR;
// Authクラスの読み込み
$auth = new Auth();
$auth->set_authname(_MEMBER_AUTHINFO);
$auth->set_sessname(_MEMBER_SESSNAME);
$auth->start();
if (!empty($_POST['type']) && $_POST['type'] == 'authenticate') {
    // 認証機能
    $MemberModel = new MemberModel();
    $userdata = $MemberModel->get_authinfo($_POST['username']);
    if (!empty($userdata['password']) && $auth->check_password($_POST['password'], $userdata['password'])) {
        $auth->auth_ok($userdata);
    } else {
        // 何もしません
    }
} else {
    if (!empty($_GET['type']) && $_GET['type'] == 'logout') {
        $auth->logout();
    }
}
if ($auth->check()) {
    // 認証済み
    $smarty->assign("title", "会員ページ");
    $file = 'testauth.tpl';
} else {
    // 未認証