if (is_array($info)) { while ($k = key($info)) { $tpl['info_' . $k] = $info[$k]; next($info); } } $app->render('profile.html', $tpl); }); $app->post('/ajax_save_pwd', function () use($app) { $post = $app->request()->post(); $auth = new AUTH($_SESSION['auth_uid']); if ($auth->login($post['old_pwd'])) { if ($post['new_pwd'] != $post['confirm_pwd']) { $msg = array('class' => 'error', 'msg' => '兩次輸入的密碼不同'); } else { $rt = $auth->setpwd($post['new_pwd']); if ($rt) { $msg = array('class' => 'success', 'msg' => '變更密碼完成'); } else { $msg = array('class' => 'error', 'msg' => '變更失敗'); } } } else { $msg = array('class' => 'error', 'msg' => '舊密碼錯誤'); } $app->render('_notice.html', $msg); }); $app->post('/ajax_save_info', function () use($app) { $post = $app->request()->post(); $data = array('name' => $post['info_name'], 'phone' => $post['info_phone'], 'email' => $post['info_email']); $user = ORM::for_table('account')->where('acc_name', $_SESSION['auth_uid'])->find_one();
} if ($post['account_type'] == 'db') { if ($post['account_pwd'] != $post['account_pwd2']) { $msg = array('class' => 'error', 'msg' => '兩次輸入的密碼不同'); } } if ($msg == '') { $company = serialize(array('name' => $post['account_name'], 'phone' => $post['account_phone'], 'email' => $post['account_email'])); $acc = ORM::for_table('account')->where('acc_name', $post['account_id'])->find_one(); $acc->acc_auth_type = $post['account_type']; $acc->acc_flag = $post['account_flag']; $acc->acc_company = $company; $acc->save(); if ($post['account_type'] == 'db' && $post['account_pwd'] != '') { $auth = new AUTH($post['account_id']); $auth->setpwd($post['account_pwd']); } $msg = array('class' => 'success', 'msg' => '帳號修改完成'); } $app->render('_notice.html', $msg); }); /* * 刪除 */ $app->get('/user_delete/:id', function ($id) use($app) { $app->applyHook('account.check_sysadmin'); $type_words = AUTH::get_support_auth_type(); $tpl = array('breadcrumb_title' => '刪除帳號', 'type_words' => $type_words); $user = ORM::for_table('account')->where('acc_name', $id)->find_one(); $tpl['acc_name'] = $user->acc_name; $tpl['acc_auth_type'] = $user->acc_auth_type;