Ejemplo n.º 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');
 }
Ejemplo n.º 2
0
 private static function insert_bot($botname)
 {
     $user = new GWF_User(array('user_id' => 0, 'user_options' => GWF_User::BOT | GWF_User::WEBSPIDER, 'user_name' => $botname, 'user_password' => GWF_Password::hashPasswordS('webspider'), 'user_regdate' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'user_regip' => GWF_IP6::getIP(GWF_IP_EXACT, '127.0.0.1'), 'user_email' => '', 'user_gender' => 'no_gender', 'user_lastlogin' => 0, 'user_lastactivity' => 0, 'user_birthdate' => '00000000', 'user_avatar_v' => 0, 'user_countryid' => 0, 'user_langid' => 0, 'user_langid2' => 0, 'user_level' => 0, 'user_title' => '', 'user_settings' => NULL, 'user_data' => NULL, 'user_credits' => 0.0));
     if (false === $user->insert()) {
         return false;
     }
     echo "Inserted new Bot: {$botname}<br/>";
     return $user;
 }
Ejemplo n.º 3
0
 private function onCrossRegister($username)
 {
     $options = 0;
     $password = GWF_Random::randomKey();
     $user = new GWF_User(array('user_id' => 0, 'user_options' => $options, 'user_name' => $username, 'user_password' => GWF_Password::hashPasswordS($password), 'user_regdate' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'user_regip' => GWF_IP6::getIP(GWF_IP_EXACT), 'user_email' => '', 'user_gender' => 'no_gender', 'user_lastlogin' => time(), 'user_lastactivity' => time(), 'user_birthdate' => '00000000', 'user_avatar_v' => 0, 'user_countryid' => 0, 'user_langid' => 1, 'user_langid2' => 0, 'user_level' => 0, 'user_title' => '', 'user_settings' => '', 'user_data' => '', 'user_credits' => '0.00'));
     if (false === $user->insert()) {
         return false;
     }
     return true;
 }
Ejemplo n.º 4
0
 public static function convert(GWF_User $user, $password)
 {
     if (false === ($row = self::table(__CLASS__)->getRow($user->getID()))) {
         return true;
     }
     $oldHash = self::oldHash($password);
     if ($oldHash !== $row->getVar('pmap_password')) {
         return GWF_Module::getModule('WeChall')->error('err_password');
     }
     $row->delete();
     $user->saveVar('user_password', GWF_Password::hashPasswordS($password));
     return true;
 }
Ejemplo n.º 5
0
 public function onSetup()
 {
     $form = $this->getFormSetup();
     if (false !== ($error = $form->validate($this->module))) {
         return $error . $this->templatePrompt();
     }
     $plain = $newpass = $form->getVar('new_pass');
     if ($newpass !== '') {
         $newpass = GWF_Password::hashPasswordS($newpass);
     }
     $this->module->cfgSaveSuperhash($newpass);
     $key = $newpass === '' ? 'msg_pass_cleared' : 'msg_pass_set';
     return $this->module->message($key, array($plain));
 }
Ejemplo n.º 6
0
 private function onChangePass(GWF_AccountChange $ac)
 {
     $form = $this->getForm();
     if (false !== ($errors = $form->validate($this->module))) {
         return $errors . $this->templateChange($ac);
     }
     $user = $ac->getUser();
     $password = $form->getVar('password');
     GWF_Hook::call(GWF_Hook::CHANGE_PASSWD, $user, array($password, ''));
     $ac->delete();
     if (false === $user->saveVar('user_password', GWF_Password::hashPasswordS($password))) {
         return GWF_HTML::err('ERR_GENERAL', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_pass_changed');
 }
Ejemplo n.º 7
0
$user = Dog::getUser();
$plugin = Dog::getPlugin();
$argv = $plugin->argv();
$argc = count($argv);
$plen = $plugin->getConf('passlen');
if ($argc === 0) {
    $plugin->showHelp();
} elseif ($argc === 1) {
    if ($user->isRegistered()) {
        return $plugin->rply('already');
    } elseif (strlen($argv[0]) < $plen) {
        $plugin->rply('pasweak', array($plen));
    } else {
        $user->saveVar('user_pass', GWF_Password::hashPasswordS($plugin->argv(0)));
        // 		Dog_ModuleGWF::executeHook('register', $user);
        $user->setLoggedIn();
        return $plugin->rply('success');
    }
} elseif ($argc === 2) {
    if (!GWF_Password::checkPasswordS($argv[0], $user->getPass())) {
        return $plugin->rply('failed');
    } elseif (strlen($argv[1]) < $plen) {
        $plugin->rply('pasweak', array($plen));
    } else {
        $user->saveVar('user_pass', GWF_Password::hashPasswordS($argv[1]));
        $user->setLoggedIn();
        return $plugin->rply('changed');
    }
} else {
    $plugin->showHelp();
}
Ejemplo n.º 8
0
 private static function fixWeChallUser(Module_WeChall $module)
 {
     if (false === ($user = GWF_User::getByName('WeChall'))) {
         $user = new GWF_User(array('user_name' => 'WeChall', 'user_email' => '*****@*****.**', 'user_password' => GWF_Password::hashPasswordS('wechallbot'), 'user_regdate' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'user_regip' => GWF_IP6::getIP(GWF_IP_EXACT, '127.0.0.1'), 'user_lastactivity' => time(), 'user_options' => GWF_User::BOT));
         if (false === $user->insert()) {
             echo GWF_HTML::error('WeChall Install', 'Can not find user WeChall');
             $uid = 0;
         } else {
             $uid = $user->getID();
         }
     } else {
         $uid = $user->getID();
     }
     if (false === $module->saveModuleVar('wc_uid', $uid)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return '';
 }
Ejemplo n.º 9
0
 private function onEditPassword($newpass)
 {
     $user = $this->user;
     if ($newpass === '') {
         return array();
     }
     unset($_POST['password']);
     if (false === $user->saveVar('user_password', GWF_Password::hashPasswordS($newpass))) {
         GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__), true, true);
         return array();
     }
     GWF_Hook::call(GWF_Hook::CHANGE_PASSWD, $user, array($newpass, ''));
     return array($this->module->lang('msg_userpass_changed', array($user->displayUsername(), GWF_HTML::display($newpass))));
 }
Ejemplo n.º 10
0
 public static function createAdmin($username, $password, $email, &$output)
 {
     if (false === ($user = GWF_User::getByName($username))) {
         $user = new GWF_User(array('user_name' => $username, 'user_email' => $email, 'user_password' => GWF_Password::hashPasswordS($password), 'user_regdate' => GWF_Time::getDate(GWF_Date::LEN_SECOND), 'user_regip' => GWF_IP6::getIP(GWF_IP_EXACT), 'user_lastactivity' => time()));
         if (false === $user->insert()) {
             return false;
         }
     }
     $userid = $user->getID();
     if (false === GWF_UserGroup::addToGroup($userid, GWF_Group::getByName(GWF_Group::ADMIN)->getID())) {
         return false;
     }
     if (false === GWF_UserGroup::addToGroup($userid, GWF_Group::getByName(GWF_Group::STAFF)->getID())) {
         return false;
     }
     $output .= GWF_HTML::message('Install Wizard', sprintf('Added new admin user: %s - Password: [censored]', $username));
     return true;
 }
Ejemplo n.º 11
0
require 'key2.key';
$key2 = ob_get_contents();
ob_end_clean();
chdir("../../../");
require_once "challenge/html_head.php";
$title = '2013 New Years Special';
html_head("Install: {$title}");
if (!GWF_User::isAdminS()) {
    return htmlSendToLogin("Better be admin !");
}
$solution = false;
$score = 4;
$url = "challenge/quangntenemy/2013NYS/index.php";
$creators = "quangntenemy";
$tags = 'Special,Crypto';
WC_Challenge::installChallenge($title, $solution, $score, $url, $creators, $tags, true, WC_Challenge::CHALL_CASE_I);
if (!($user = GWF_User::getByName('Rudolph2013'))) {
    $user = new GWF_User(array('user_id' => '0', 'user_options' => GWF_User::BOT | GWF_User::MAIL_APPROVED | GWF_User::EMAIL_GPG, 'user_name' => 'Rudolph2013', 'user_password' => GWF_Password::hashPasswordS('quangster'), 'user_regdate' => GWF_Time::getDate(), 'user_email' => '*****@*****.**'));
    $user->insert();
} else {
    $user->saveOption(GWF_User::EMAIL_GPG, true);
}
GWF_PublicKey::updateKey($user->getID(), $key1);
if (!($user = GWF_User::getByName('Silvester2013'))) {
    $user = new GWF_User(array('user_id' => '0', 'user_options' => GWF_User::BOT | GWF_User::MAIL_APPROVED | GWF_User::EMAIL_GPG, 'user_name' => 'Silvester2013', 'user_password' => GWF_Password::hashPasswordS('quangster'), 'user_regdate' => GWF_Time::getDate(), 'user_email' => '*****@*****.**'));
    $user->insert();
} else {
    $user->saveOption(GWF_User::EMAIL_GPG, true);
}
GWF_PublicKey::updateKey($user->getID(), $key2);
require_once "challenge/html_foot.php";