コード例 #1
0
ファイル: SetupGPGKey.php プロジェクト: sinfocol/gwf3
 public function execute()
 {
     if (false === ($user = GWF_User::getByID(Common::getGet('userid')))) {
         return GWF_HTML::err('ERR_UNKNOWN_USER');
     }
     $tmpfile = GWF_PATH . 'extra/temp/gpg/' . $user->getVar('user_id');
     if (!is_file($tmpfile) || !is_readable($tmpfile)) {
         return GWF_HTML::err('ERR_FILE_NOT_FOUND', array($tmpfile));
     }
     if (false === ($file_content = file_get_contents($tmpfile))) {
         return GWF_HTML::err('ERR_FILE_NOT_FOUND', array($tmpfile));
     }
     if (false === unlink($tmpfile)) {
         return GWF_HTML::err('ERR_WRITE_FILE', array($tmpfile));
     }
     if (false === ($fingerprint = GWF_PublicKey::grabFingerprint($file_content))) {
         return $this->module->error('err_gpg_key');
     }
     if (Common::getGet('token') !== $fingerprint) {
         return $this->module->error('err_gpg_token');
     }
     if (false === GWF_PublicKey::updateKey($user->getID(), $file_content)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $user->saveOption(GWF_User::EMAIL_GPG, true)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_setup_gpg');
 }
コード例 #2
0
ファイル: install.php プロジェクト: sinfocol/gwf3
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";