コード例 #1
0
ファイル: pear-database-user.php プロジェクト: stof/pearweb
 static function activate($uid, $karmalevel = 'pear.dev')
 {
     require_once 'Damblan/Karma.php';
     global $dbh, $auth_user;
     $karma = new Damblan_Karma($dbh);
     $user = user::info($uid, null, 0);
     if (!isset($user['registered'])) {
         return false;
     }
     @($arr = unserialize($user['userinfo']));
     include_once 'pear-database-note.php';
     note::removeAll($uid);
     $data = array();
     $data['registered'] = 1;
     $data['active'] = 1;
     /* $data['ppp_only'] = 0; */
     if (is_array($arr)) {
         $data['userinfo'] = $arr[1];
     }
     $data['created'] = gmdate('Y-m-d H:i');
     $data['createdby'] = $auth_user->handle;
     $data['handle'] = $user['handle'];
     user::update($data, true);
     $karma->grant($user['handle'], $karmalevel);
     if ($karma->has($user['handle'], 'pear.dev')) {
         include_once 'pear-rest.php';
         $pear_rest = new pearweb_Channel_REST_Generator(PEAR_REST_PATH, $dbh);
         $pear_rest->saveMaintainerREST($user['handle']);
         $pear_rest->saveAllMaintainersREST();
     }
     include_once 'pear-database-note.php';
     note::add($uid, "Account opened");
     $msg = "Your PEAR account request has been opened.\n" . "To log in, go to http://" . PEAR_CHANNELNAME . "/ and click on \"login\" in\n" . "the top-right menu.\n";
     $xhdr = 'From: ' . $auth_user->handle . '@php.net';
     if (!DEVBOX) {
         mail($user['email'], "Your PEAR Account Request", $msg, $xhdr, '-f ' . PEAR_BOUNCE_EMAIL);
     }
     return true;
 }
コード例 #2
0
ファイル: report.php プロジェクト: stof/pearweb
require_once 'services/HoneyPot.php';
$errors = array();
$ok_to_submit_report = false;
// Instantiate the numeral captcha object.
$numeralCaptcha = new Text_CAPTCHA_Numeral();
if (isset($_POST['save']) && isset($_POST['pw'])) {
    // non-developers don't have $user set
    setcookie('MAGIC_COOKIE', base64_encode(':' . $_POST['pw']), time() + 3600 * 24 * 12, '/', '.php.net');
}
// captcha is not necessary if the user is logged in
if (isset($auth_user) && $auth_user->registered) {
    if (auth_check('pear.voter') && !auth_check('pear.dev') && !auth_check('pear.bug')) {
        // auto-grant bug tracker karma if it isn't present
        require_once 'Damblan/Karma.php';
        $karma = new Damblan_Karma($dbh);
        $karma->grant($auth_user->user, 'pear.bug');
    }
    if (isset($_SESSION['answer'])) {
        unset($_SESSION['answer']);
    }
    if (isset($_POST['in'])) {
        $_POST['in']['email'] = $auth_user->email;
    }
}
if (isset($_POST['in'])) {
    $errors = incoming_details_are_valid($_POST['in'], 1, isset($auth_user) && $auth_user->registered);
    /**
     * Check if session answer is set, then compare
     * it with the post captcha value. If it's not
     * the same, then it's an incorrect password.
     */
コード例 #3
0
ファイル: karma.php プロジェクト: stof/pearweb
     if (!validate_csrf_token($csrf_token_name)) {
         report_error('Invalid token.');
         response_footer();
         exit;
     }
     include_once 'pear-database-note.php';
     switch ($_GET['action']) {
         case "remove":
             $res = $karma->remove($handle, $_GET['level']);
             if ($res) {
                 echo "Successfully <b>removed</b> karma &quot;" . htmlspecialchars($_GET['level']) . "&quot;<br /><br />";
                 note::add($handle, 'removed ' . $_GET['level'] . ' karma', $auth_user->handle);
             }
             break;
         case "grant":
             $res = $karma->grant($handle, $_POST['level']);
             if ($res) {
                 echo "Successfully <b>added</b> karma &quot;" . htmlspecialchars($_POST['level']) . "&quot;<br /><br />";
                 note::add($handle, 'added ' . $_POST['level'] . ' karma', $auth_user->handle);
             }
             break;
     }
 }
 $user_karma = $karma->get($handle);
 if (count($user_karma) == 0) {
     echo 'No karma yet';
 } else {
     $table = new HTML_Table('style="width: 90%"');
     $table->setCaption('Karma levels for ' . htmlspecialchars($handle), 'style="background-color: #CCCCCC;"');
     $table->addRow(array("Level", "Added by", "Added at", "Remove"), null, 'th');
     foreach ($user_karma as $item) {