function getUsers()
{
    $users = array();
    $sql = "SELECT user_name, user_real_name, user_email from user";
    $res = wfQuery($sql, DB_SLAVE);
    while ($line = wfFetchObject($res, DB_SLAVE)) {
        if (strlen($line->user_email) == 0) {
            continue;
        }
        if (strlen($line->user_real_name) > 0) {
            $users[$line->user_real_name] = $line->user_email;
        } else {
            $users[$line->user_name] = $line->user_email;
        }
    }
    wfFreeResult($res, DB_SLAVE);
    return $users;
}
コード例 #2
0
ファイル: Block.php プロジェクト: BackupTheBerlios/enotifwiki
 function enumBlocks($callback, $tag, $flags = 0)
 {
     global $wgAntiLockFlags;
     $block = new Block();
     if ($flags & EB_FOR_UPDATE) {
         $db =& wfGetDB(DB_MASTER);
         if ($wgAntiLockFlags & ALF_NO_BLOCK_LOCK) {
             $options = '';
         } else {
             $options = 'FOR UPDATE';
         }
         $block->forUpdate(true);
     } else {
         $db =& wfGetDB(DB_SLAVE);
         $options = '';
     }
     $ipblocks = $db->tableName('ipblocks');
     $sql = "SELECT * FROM {$ipblocks} ORDER BY ipb_timestamp DESC {$options}";
     $res = $db->query($sql, 'Block::enumBans');
     while ($row = $db->fetchObject($res)) {
         $block->initFromRow($row);
         if (!($flags & EB_KEEP_EXPIRED)) {
             if (!$block->deleteIfExpired()) {
                 $callback($block, $tag);
             }
         } else {
             $callback($block, $tag);
         }
     }
     wfFreeResult($res);
 }
コード例 #3
0
 function fixUserOptions()
 {
     print "Fixing user options...";
     $res = wfQuery("SELECT user_id,user_options FROM user", DB_MASTER);
     $total = wfNumRows($res);
     $n = 0;
     print " ({$total} total)\n";
     while ($row = wfFetchObject($res)) {
         $id = intval($row->user_id);
         $option = wfStrencode($this->rewriteUserOptions($row->user_options));
         wfQuery("UPDATE user SET user_options='{$option}' WHERE user_id={$id} LIMIT 1", DB_MASTER);
         if (++$n % 50 == 0) {
             print "{$n}\n";
         }
     }
     wfFreeResult($res);
 }
コード例 #4
0
/**
 * This doesn't really work anymore, because self-links are now displayed as
 * unlinked bold text, and are not entered into the link table.
 *
 * @deprecated
 */
function wfSpecialSelfLinks()
{
    global $wgUser, $wgOut, $wgLang, $wgTitle;
    $fname = 'wfSpecialSelfLinks';
    list($limit, $offset) = wfCheckLimits();
    $sql = "SELECT page_namespace,page_title FROM page,links " . "WHERE l_from=l_to AND l_to=page_id " . "LIMIT {$offset}, {$limit}";
    $res = wfQuery($sql, DB_SLAVE, $fname);
    $top = getMaintenancePageBacklink('selflinks');
    $top .= '<p>' . wfMsg('selflinkstext') . "</p><br />\n";
    $top .= wfShowingResults($offset, $limit);
    $wgOut->addHTML("<p>{$top}\n");
    $sl = wfViewPrevNext($offset, $limit, 'REPLACETHIS');
    $sl = str_replace('REPLACETHIS', sns() . ":Maintenance&subfunction=selflinks", $sl);
    $wgOut->addHTML("<br />{$sl}\n");
    $sk = $wgUser->getSkin();
    $s = '<ol start=' . ($offset + 1) . '>';
    while ($obj = wfFetchObject($res)) {
        $title = Title::makeTitle($obj->page_namespace, $obj->page_title);
        $s .= "<li>" . $sk->makeKnownLinkObj($title) . "</li>\n";
    }
    wfFreeResult($res);
    $s .= '</ol>';
    $wgOut->addHTML($s);
    $wgOut->addHTML("<p>{$sl}\n");
}
コード例 #5
0
ファイル: Block.php プロジェクト: puring0815/OpenKore
 function enumBlocks($callback, $tag, $flags = 0)
 {
     global $wgAntiLockFlags;
     $block = new Block();
     if ($flags & Block::EB_FOR_UPDATE) {
         $db =& wfGetDB(DB_MASTER);
         if ($wgAntiLockFlags & ALF_NO_BLOCK_LOCK) {
             $options = '';
         } else {
             $options = 'FOR UPDATE';
         }
         $block->forUpdate(true);
     } else {
         $db =& wfGetDB(DB_SLAVE);
         $options = '';
     }
     if ($flags & Block::EB_RANGE_ONLY) {
         $cond = " AND ipb_range_start <> ''";
     } else {
         $cond = '';
     }
     $now = wfTimestampNow();
     extract($db->tableNames('ipblocks', 'user'));
     $sql = "SELECT {$ipblocks}.*,user_name FROM {$ipblocks},{$user} " . "WHERE user_id=ipb_by {$cond} ORDER BY ipb_timestamp DESC {$options}";
     $res = $db->query($sql, 'Block::enumBlocks');
     $num_rows = $db->numRows($res);
     while ($row = $db->fetchObject($res)) {
         $block->initFromRow($row);
         if ($flags & Block::EB_RANGE_ONLY && $block->mRangeStart == '') {
             continue;
         }
         if (!($flags & Block::EB_KEEP_EXPIRED)) {
             if ($block->mExpiry && $now > $block->mExpiry) {
                 $block->delete();
             } else {
                 call_user_func($callback, $block, $tag);
             }
         } else {
             call_user_func($callback, $block, $tag);
         }
     }
     wfFreeResult($res);
     return $num_rows;
 }