Exemple #1
0
 private function onRegister()
 {
     $form = $this->getForm();
     $errorsA = $errorsB = '';
     if (false !== ($errorsA = $form->validate($this->module)) || false !== ($errorsB = $this->onRegisterB())) {
         return $errorsA . $errorsB . $this->templateForm();
     }
     $username = Common::getPost('username');
     $password = Common::getPost('password');
     $email = Common::getPost('email');
     $birthdate = sprintf('%04d%02d%02d', Common::getPost('birthdatey'), Common::getPost('birthdatem'), Common::getPost('birthdated'));
     $default_country = $this->module->cfgDetectCountry() ? GWF_IP2Country::detectCountryID() : 0;
     $countryid = $form->getVar('countryid', $default_country);
     require_once GWF_CORE_PATH . 'module/Register/GWF_UserActivation.php';
     $token = GWF_UserActivation::generateToken();
     $ua = new GWF_UserActivation(array('username' => $username, 'email' => $email, 'token' => $token, 'birthdate' => $birthdate, 'countryid' => $countryid, 'password' => GWF_Password::hashPasswordS($password), 'timestamp' => time(), 'ip' => GWF_IP6::getIP(GWF_IP_EXACT)));
     if (false === $ua->insert()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)) . $this->templateForm();
     }
     if ($this->module->wantEmailActivation()) {
         return $this->sendEmail($username, $email, $token, $password);
     } else {
         GWF_Website::redirect(GWF_WEB_ROOT . 'quick_activate/' . $token);
     }
     return $this->module->message('msg_registered');
 }
 private static function deleteOldActivations(Module_Register $module)
 {
     $cut = time() - $module->getActivationThreshold();
     self::log('Deleting user activations older than ' . GWF_Time::displayTimestamp($cut));
     $table = new GWF_UserActivation(false);
     $result = $table->deleteWhere("timestamp<{$cut}");
     if (0 < ($nDeleted = $table->affectedRows($result))) {
         self::log(sprintf('Deleted %d old user activations.', $nDeleted));
     }
 }
Exemple #3
0
 private function templateAdmin()
 {
     $headers = array(array($this->module->lang('th_username'), 'username', 'ASC'), array($this->module->lang('th_token'), 'token', 'ASC'), array($this->module->lang('th_email'), 'email', 'ASC'), array($this->module->lang('th_birthdate'), 'birthdate', 'ASC'), array($this->module->lang('th_countryid'), 'countryid', 'ASC'), array($this->module->lang('th_timestamp'), 'timestamp', 'ASC'), array($this->module->lang('th_ip'), 'ip', 'ASC'));
     $tVars = array('headers' => GWF_Table::displayHeaders1($headers, GWF_WEB_ROOT . 'index.php?mo=Register&me=Admin&by=%BY%&dir=%DIR%&page=1'), 'activations' => $this->table->selectAll('*', '', $this->orderby, NULL, $this->ipp, GWF_PageMenu::getFrom($this->page, $this->ipp)), 'pagemenu' => $this->getPageMenu());
     return $this->module->template('admin.tpl', $tVars);
 }