コード例 #1
0
 /**
  * แสดงผล
  *
  * @return string
  */
 public function render(Request $request)
 {
     // อ่านข้อมูลสมาชิก
     $model = new Model();
     $user = $model->db()->createQuery()->from('user')->where(array('id', (int) $_SESSION['login']['id']))->first();
     $template = Template::create('member', 'member', 'profile');
     $contents = array('/<NEWREGISTER>(.*)<\\/NEWREGISTER>/isu' => $request->request('action')->toString() === 'newregister' ? '\\1' : '', '/<IDCARD>(.*)<\\/IDCARD>/isu' => empty(self::$cfg->member_idcard) ? '' : '\\1', '/{ACCEPT}/' => Mime::getEccept(self::$cfg->user_icon_typies));
     // ข้อมูลฟอร์ม
     foreach ($user as $key => $value) {
         if ($key == 'sex') {
             $datas = array();
             foreach (Language::get('SEXES') as $k => $v) {
                 $sel = $k == $value ? ' selected' : '';
                 $datas[] = '<option value="' . $k . '"' . $sel . '>' . $v . '</option>';
             }
             $contents['/{SEX}/'] = implode('', $datas);
         } elseif ($key === 'subscrib') {
             $contents['/{SUBSCRIB}/'] = $value == 1 ? 'checked' : '';
         } elseif ($key === 'icon') {
             if (is_file(ROOT_PATH . self::$cfg->usericon_folder . $value)) {
                 $icon = WEB_URL . self::$cfg->usericon_folder . $value;
             } else {
                 $icon = WEB_URL . 'skin/img/noicon.jpg';
             }
             $contents['/{ICON}/'] = $icon;
         } else {
             $contents['/{' . strtoupper($key) . '}/'] = $value;
         }
     }
     $template->add($contents);
     // after render
     Gcms::$view->setContents(array('/:type/' => empty(self::$cfg->user_icon_typies) ? 'jpg' : implode(', ', self::$cfg->user_icon_typies)), false);
     return $template->render();
 }
コード例 #2
0
 /**
  * ฟังก์ชั่นส่งอีเมล์ลืมรหัสผ่าน
  */
 public function forgot(Request $request)
 {
     // ค่าที่ส่งมา
     $email = $request->post('login_username')->url();
     if (empty($email)) {
         if ($request->post('action')->toString() === 'forgot') {
             self::$login_message = Language::get('Please fill out this form');
         }
     } else {
         self::$text_username = $email;
         // ค้นหาอีเมล์หรือโทรศัพท์
         $model = new Model();
         $user_table = $model->getFullTableName('user');
         $search = $model->db()->first($user_table, array(array('email', $email), array('fb', '0')));
         if ($search === false) {
             self::$login_message = Language::get('not a registered user');
         } else {
             // รหัสผ่านใหม่
             $password = Text::rndname(6);
             // ข้อมูลอีเมล์
             $replace = array('/%PASSWORD%/' => $password, '/%EMAIL%/' => $search->email);
             // send mail
             $err = Email::send(3, 'member', $replace, $search->email);
             if (empty($err)) {
                 // อัปเดทรหัสผ่านใหม่
                 $model->db()->update($user_table, (int) $search->id, array('password' => md5($password . $search->email)));
                 // คืนค่า
                 self::$login_message = Language::get('Your message was sent successfully');
                 self::$request = $request->withParsedBody(array('action' => 'login'));
             } else {
                 self::$login_message = $err;
             }
         }
     }
 }