コード例 #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
 /**
  * module=database
  * ฟอร์ม export
  *
  * @return string
  */
 public function export()
 {
     // Model
     $model = \Kotchasan\Model::create();
     // Form
     $form = Html::create('form', array('id' => 'export_frm', 'class' => 'paper', 'autocomplete' => 'off', 'action' => 'index.php/index/model/database/export', 'target' => '_export'));
     $fieldset = $form->add('fieldset', array('titleClass' => 'icon-export', 'title' => '{LNG_Backup database}'));
     $fieldset->add('div', array('class' => 'subtitle', 'innerHTML' => '{LNG_When you press the button below. GCMS will create <em>:dbname.sql</em> file for save on your computer. This file contains all the information in the database. You can use it to restore your system, or used to move data to another site.}'));
     $structure = Language::get('Structure');
     $datas = Language::get('Datas');
     $content = array();
     $content[] = '<div class=item>';
     $content[] = '<table class="responsive database fullwidth"><tbody id=language_tbl>';
     $content[] = '<tr><td class=tablet></td><td colspan=3 class=left><a href="javascript:setSelect(\'language_tbl\',true)">{LNG_Select all}</a>&nbsp;|&nbsp;<a href="javascript:setSelect(\'language_tbl\',false)">{LNG_Clear selectd}</a></td></tr>';
     $prefix = $model->getSetting('prefix');
     if ($prefix != '') {
         $prefix .= '_';
     }
     foreach ($model->db()->customQuery('SHOW TABLE STATUS', true) as $table) {
         if (preg_match('/^' . $prefix . '(.*?)$/', $table['Name'], $match)) {
             $tr = '<tr>';
             $tr .= '<th>' . $table['Name'] . '</th>';
             $tr .= '<td><label class=nowrap><input type=checkbox name=' . $table['Name'] . '[] value=sturcture checked>&nbsp;' . $structure . '</label></td>';
             $tr .= '<td><label class=nowrap><input type=checkbox name=' . $table['Name'] . '[] value=datas checked>&nbsp;' . $datas . '</label></td>';
             $tr .= '</tr>';
             $content[] = $tr;
         }
     }
     $content[] = '<tr><td class=tablet></td><td colspan=3 class=left><a href="javascript:setSelect(\'language_tbl\',true)">{LNG_Select all}</a>&nbsp;|&nbsp;<a href="javascript:setSelect(\'language_tbl\',false)">{LNG_Clear selectd}</a></td></tr>';
     $content[] = '</tbody></table>';
     $content[] = '</div>';
     $fieldset->appendChild(implode("\n", $content));
     $fieldset = $form->add('fieldset', array('class' => 'submit'));
     // submit
     $fieldset->add('submit', array('class' => 'button ok large', 'value' => '{LNG_Export}'));
     Gcms::$view->setContents(array('/:dbname/' => $model->getSetting('dbname'), '/:size/' => ini_get('upload_max_filesize')), false);
     return $form->render();
 }
コード例 #3
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;
             }
         }
     }
 }