Example #1
0
function getNamespaces()
{
    global $http, $name, $lang, $wiki;
    $namespaces = $http->get('http://' . $lang . '.' . $wiki . '.org/w/api.php?action=query&meta=siteinfo&siprop=namespaces&format=php', false);
    $namespaces = unserialize($namespaces);
    $namespaces = $namespaces['query']['namespaces'];
    if (!$namespaces[0]) {
        toDie('Not a valid wiki.');
    }
    unset($namespaces[-2]);
    unset($namespaces[-1]);
    $namespaces[0]['*'] = 'Article';
    return $namespaces;
}
Example #2
0
function wfMsgGetKey($key)
{
    global $messages;
    $lang = $_GET['lang'];
    if (empty($lang)) {
        $lang = $_GET['uselang'];
    }
    if (isset($messages[$lang])) {
        if (isset($messages[$lang][$key])) {
            return $messages[$lang][$key];
        } else {
            return $messages['en'][$key];
        }
    } else {
        if (isset($messages['en'][$key])) {
            return $messages['en'][$key];
        } else {
            toDie('Error with localization, please fill out a bug report using the link at right.');
        }
    }
}
Example #3
0
        $tmp .= "<li>Network address: {$ip['long']}</li>";
        $tmp .= "<li>Binary: {$ip['bin']}</li>";
        if (isset($_GET['fun'])) {
            $tmp .= "<li>Hexadecimal: {$ip['hex']}</li>";
            $tmp .= "<li>Octal: {$ip['octal']}</li>";
            $tmp .= "<li>Radians: {$ip['radians']}</li>";
            $tmp .= "<li>Base 64: {$ip['base64']}</li>";
            $tmp .= "<li>Letters: {$ip['alpha']}</li>";
        }
        $tmp .= "<li>More info: " . "<a href=\"//ws.arin.net/whois/?queryinput={$ip['ip']}\">WHOIS</a> · " . "<a href=\"//toolserver.org/~luxo/contributions/contributions.php?user={$ip['ip']}\">Global Contribs</a> · " . "<a href=\"//www.robtex.com/rbls/{$ip['ip']}.html\">RBLs</a> · " . "<a href=\"//www.dnsstuff.com/tools/tracert.ch?ip={$ip['ip']}\">Traceroute</a> · " . "<a href=\"//www.infosniper.net/index.php?ip_address={$ip['ip']}\">Geolocate</a> · " . "<a href=\"//toolserver.org/~overlordq/scripts/checktor.fcgi?ip={$ip['ip']}\">TOR</a> · " . "<a href=\"//www.google.com/search?hl=en&q={$ip['ip']}\">Google</a> · " . "<a href=\"//ws.arin.net/whois/?queryinput={$ip['ip']}\">WHOIS</a>" . "</li>";
        $tmp .= "</ul>";
        $ips[] = $tmp;
    }
    $content->assign("list", implode('', $ips));
} else {
    toDie('Invalid type selected.');
}
$content->assign("showstats", "1");
$content->assign("cidr", "{$cidr_info['begin']}/{$cidr_info['suffix']}");
$phptemp->assign("page", "{$cidr_info['begin']}/{$cidr_info['suffix']}");
$content->assign("ip_start", $cidr_info['begin']);
$content->assign("ip_end", $cidr_info['end']);
$content->assign("ip_number", $cidr_info['count']);
//Calculate time taken to execute
$exectime = number_format(microtime(1) - $time, 2, '.', '');
$phptemp->assign("excecutedtime", "Executed in {$exectime} seconds");
$phptemp->assign("memory", "Taken " . number_format(memory_get_usage() / (1024 * 1024), 2, '.', '') . " megabytes of memory to execute.");
$phptemp->assign("curlang", $lang);
$phptemp->assign("langlinks", $langlinks);
$phptemp->assign("source", "ipcalc");
assignContent();
Example #4
0
$lang = str_replace('/', '', $lang);
$wiki = str_replace('/', '', $wiki);
$url = $lang . '.' . $wiki . '.org';
$http = new HTTP('https://' . $url . '/w/');
/*THIS NEEDS UPDATING AS SOON AS LABS IS READY
$tdbr = new Database( 
    'sql-toolserver', 
    $wgDBPort, 
    $wgDBUser, 
    $wgDBPass, 
    'toolserver', 
    true
);*/
$dbInfo = $fnc->getDBInfo($lang, $wiki);
if (isset($dbInfo['error'])) {
    toDie($phptemp->getConf('nowiki', $url));
}
$wgDBname = $dbInfo['dbname'];
$wgDBserver = $dbInfo['server'];
$dbr = new Database($wgDBserver, $wgDBPort, $wgDBUser, $wgDBPass, $wgDBname, true);
$wgNamespaces = $fnc->getNamespaces('enwiki_p');
$cnt = new Counter($name);
$final_array = array('query' => array('count' => array()));
$retUser = $cnt->getName();
$retIP = $cnt->getIP() ? "true" : "false";
$retExists = $cnt->getExists() ? "true" : "false";
$retUID = $cnt->getUID();
$retDeleted = intval($cnt->getDeleted());
$retLive = intval($cnt->getLive());
$retTotal = intval($cnt->getTotal());
$retGroupList = $cnt->getGroupList();
Example #5
0
    $rfad = mysql_fetch_assoc($result);
    $stripped_arfa = preg_replace("/Requests_for_adminship\\//i", "", $arfa);
    $views = $rfad['pulls'];
    if (isset($_GET['debug'])) {
        $viewout = " (Views: {$views}|Key: {$key})";
    } else {
        $viewout = "";
    }
    echo "<li><a href = \"//en.wikipedia.org/wiki/Wikipedia:{$arfa}\">{$stripped_arfa}</a>{$viewout}</li>\n";
    $pid = $rfad['id'];
    $pulls = $rfad['pulls'];
    $pullsnew = $pulls + 1;
    $ud = "UPDATE rfap SET pulls = '{$pullsnew}' WHERE id = '{$pid}';";
    $udr = mysql_query($ud, $tools);
    if (!$udr) {
        toDie("ERROR: No result returned.");
    }
    $nu++;
}
echo "</ol>\n";
$ar = $ns + $nn + $no;
if ($ns > 0) {
    $sp = round($ns / $ar, 3) * 100;
} else {
    $sp = 0;
}
if ($nn > 0) {
    $np = round($nn / $ar, 3) * 100;
} else {
    $np = 0;
}
Example #6
0
function getEditCounts()
{
    global $name, $namespaces, $http, $oldwiki, $oldlang, $oldname, $time;
    if (isset($_GET['debug'])) {
        echo "<span style=\"font-size:100%;\">A" . wfMsg('executed', number_format(microtime(1) - $time, 2, '.', '')) . "</span>";
        flush();
    }
    //Get total edits
    if (ISIPADDRESS == false) {
        //IP addresses don't have a field in the user table, so IPs must be done the old way.
        $query = "SELECT user_editcount, user_id FROM user WHERE user_name = '" . $name . "';";
        $result = mysql_query($query);
        if (!$result) {
            toDie(wfMsg('mysqlerror', mysql_error()));
        }
        $row = mysql_fetch_assoc($result);
        $uid = $row['user_id'];
        if ($uid == 0) {
            toDie(wfMsg('nosuchuser', $name));
        }
    }
    unset($row, $query, $result);
    $query = 'SELECT COUNT(*) AS count FROM archive_userindex WHERE ar_user_text = \'' . $name . '\'';
    $result = mysql_query($query);
    $row = mysql_fetch_assoc($result);
    $edit_count_deleted = $row['count'];
    unset($row, $query, $result);
    $query = 'SELECT COUNT(*) AS count FROM revision_userindex WHERE rev_user_text = \'' . $name . '\'';
    $result = mysql_query($query);
    $row = mysql_fetch_assoc($result);
    $edit_count_live = $row['count'];
    unset($row, $query, $result);
    if (isset($_GET['debug'])) {
        echo "<span style=\"font-size:100%;\">A" . wfMsg('executed', number_format(microtime(1) - $time, 2, '.', '')) . "</span>";
    }
    if (ISIPADDRESS == false) {
        //IPs don't have user groups!
        /*$groups = getUrl( '//'.$oldlang.'.'.$oldwiki.'.org/w/api.php?action=query&list=users&ususers='.urlencode( $oldname ).'&usprop=groups&format=php', false );
        		$groups = unserialize( $groups );
        		$groups = $groups['query']['users']['0']['groups'];*/
        $query = "select * from user_groups where ug_user = '******';";
        $result = mysql_query($query);
        if (!$result) {
            toDie(wfMsg('mysqlerror', mysql_error()));
        }
        $groups = array();
        while ($row = mysql_fetch_assoc($result)) {
            $groups[] = $row['ug_group'];
        }
    }
    if (isset($_GET['debug'])) {
        echo "<span style=\"font-size:100%;\">A" . wfMsg('executed', number_format(microtime(1) - $time, 2, '.', '')) . "</span>";
    }
    $edit_count_total = $edit_count_live + $edit_count_deleted;
    return array($edit_count_total, $edit_count_live, $edit_count_deleted, $groups, $uid);
}
Example #7
0
function getReplag()
{
    $query = "SELECT UNIX_TIMESTAMP() - UNIX_TIMESTAMP(rc_timestamp) as replag FROM recentchanges_userindex ORDER BY rc_timestamp DESC LIMIT 1";
    $result = mysql_query($query);
    if (!$result) {
        toDie("MySQL ERROR! " . mysql_error());
    }
    $row = mysql_fetch_assoc($result);
    $replag = $row['replag'];
    $seconds = floor($replag);
    $text = formatReplag($seconds);
    return array($seconds, $text);
}
Example #8
0
function getEditCounts()
{
    global $name, $namespaces, $http, $oldwiki, $oldlang;
    //Get total edits
    if (ISIPADDRESS == false) {
        //IP addresses don't have a field in the user table, so IPs must be done the old way.
        $query = "SELECT user_id FROM user WHERE user_name = '" . $name . "';";
        $result = mysql_query($query);
        if (!$result) {
            toDie("MySQL error, please report to Cyberpower678 using <a href=\"//en.wikipedia.org/wiki/User talk:Cyberpower678\">the bug reporter.</a> Be sure to report the following SQL error when reporting:<br /><pre>" . mysql_error() . "</pre>");
        }
        $row = mysql_fetch_assoc($result);
        $uid = $row['user_id'];
    }
    unset($row, $query, $result);
    if (ISIPADDRESS == false) {
        //IPs don't have user groups!
        if ($uid == 0) {
            toDie("User does not exist.");
        }
    }
    $edit_sum_maj = 0;
    $edit_sum_min = 0;
    $maj = 0;
    $minn = 0;
    $rmaj = 0;
    $rmin = 0;
    $redit_sum_maj = 0;
    $redit_sum_min = 0;
    $month_totals = array();
    $month_editsummary_totals = array();
    $query = "SELECT rev_comment,rev_timestamp,rev_minor_edit FROM revision_userindex JOIN page ON page_id = rev_page WHERE rev_user_text = '{$name}' AND page_namespace = 0 ORDER BY rev_timestamp DESC";
    $result = mysql_query($query);
    if (!$result) {
        toDie("MySQL error, please report to Cyberpower678 using <a href=\"//en.wikipedia.org/wiki/User talk:Cyberpower678\">the bug reporter.</a> Be sure to report the following SQL error when reporting:<br /><pre>" . mysql_error() . "</pre>");
    }
    while ($row = mysql_fetch_assoc($result)) {
        preg_match('/(\\d\\d\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)(\\d\\d)/', $row['rev_timestamp'], $d);
        list($arr, $year, $month, $day, $hour, $min, $sec) = $d;
        //print_r($d);
        $monthkey = $year . "/" . $month;
        $first_month = strtotime("{$year}-{$month}-{$day}");
        $month_totals[$monthkey]++;
        if ($row['rev_minor_edit'] == 0) {
            if ($row['rev_comment'] !== '') {
                $month_editsummary_totals[$monthkey]++;
                $edit_sum_maj++;
            }
            $maj++;
            if ($rmaj <= 149) {
                $rmaj++;
                if ($row['rev_comment'] != '') {
                    $redit_sum_maj++;
                }
            }
        } else {
            if ($row['rev_comment'] !== '') {
                $month_editsummary_totals[$monthkey]++;
                $edit_sum_min++;
                $minn++;
            } else {
                $minn++;
            }
            //$min++;
            if ($rmin <= 149) {
                $rmin++;
                if ($row['rev_comment'] != '') {
                    $redit_sum_min++;
                }
            }
        }
    }
    /*$query = "SELECT rev_comment,rev_timestamp FROM revision JOIN page ON page_id = rev_page WHERE rev_user_text = '$name' AND page_namespace = 0 AND rev_minor_edit = 1 ORDER BY rev_timestamp DESC";
       $result = mysql_query($query);
       if(!$result) toDie( "MySQL error, please report to Cyberpower678 using <a href=\"//en.wikipedia.org/wiki/User talk:Cyberpower678\">the bug reporter.</a> Be sure to report the following SQL error when reporting:<br /><pre>".mysql_error()."</pre>" );
    
       while ($row = mysql_fetch_assoc($result)) {
          preg_match('/(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/', $row['rev_timestamp'], $d);
          list($arr,$year,$month,$day,$hour,$min,$sec) = $d;
          //print_r($d);
          
          $monthkey = $year."/".$month;
          if ($first_month > strtotime("$year-$month-$day") ) {
             $first_month = strtotime("$year-$month-$day");
          }
          $month_totals[$monthkey]++;
          if ($row['rev_comment'] !== '') {
             $month_editsummary_totals[$monthkey]++;
             $edit_sum_min++;
          }
          
          $min++;
          if ($rmin <= 149) {
             $rmin++;
             if ($row['rev_comment'] != '') {
                $redit_sum_min++;
             }
          }
       }*/
    $last_month = strtotime(date('Ymd'));
    return array($edit_sum_maj, $edit_sum_min, $maj, $minn, $redit_sum_maj, $redit_sum_min, $rmaj, $rmin, $month_totals, $month_editsummary_totals, $first_month, $last_month);
}
Example #9
0
function getEditCounts()
{
    global $name, $namespaces, $http, $oldwiki, $oldlang, $oldname;
    //Get total edits
    if (ISIPADDRESS == false) {
        //IP addresses don't have a field in the user table, so IPs must be done the old way.
        $query = "SELECT user_editcount, user_id FROM user WHERE user_name = '" . $name . "';";
        $result = mysql_query($query);
        if (!$result) {
            toDie(mysql_error(), 'mysqlerror');
        }
        $row = mysql_fetch_assoc($result);
        $uid = $row['user_id'];
        if ($uid == 0) {
            toDie("User does not exist", "nosuchuser");
        }
    }
    unset($row, $query, $result);
    $query = 'SELECT COUNT(*) AS count FROM archive_userindex WHERE ar_user_text = \'' . $name . '\'';
    $result = mysql_query($query);
    $row = mysql_fetch_assoc($result);
    $edit_count_deleted = $row['count'];
    unset($row, $query, $result);
    $query = 'SELECT COUNT(*) AS count FROM revision_userindex WHERE rev_user_text = \'' . $name . '\'';
    $result = mysql_query($query);
    $row = mysql_fetch_assoc($result);
    $edit_count_live = $row['count'];
    unset($row, $query, $result);
    if (ISIPADDRESS == false) {
        //IPs don't have user groups!
        /*$groups = getUrl( '//'.$oldlang.'.'.$oldwiki.'.org/w/api.php?action=query&list=users&ususers='.urlencode( $oldname ).'&usprop=groups&format=php', false );
        		$groups = unserialize( $groups );
        		$groups = $groups['query']['users']['0']['groups'];*/
        $query = "select * from user_groups where ug_user = '******';";
        $result = mysql_query($query);
        if (!$result) {
            toDie(mysql_error(), 'mysqlerror');
        }
        $groups = array();
        while ($row = mysql_fetch_assoc($result)) {
            $groups[] = $row['ug_group'];
        }
    }
    $edit_count_total = $edit_count_live + $edit_count_deleted;
    return array($edit_count_total, $edit_count_live, $edit_count_deleted, $groups, $uid);
}
Example #10
0
//echo "<b>Starting IP:</b> {$cidr_info['begin']}<br />\n";
//echo "<b>Ending IP:</b> {$cidr_info['end']}<br />\n";
//echo "<b>Number of possible IPs:</b> {$cidr_info['count']}<br />\n";
$content->assign("showstats", "1");
$content->assign("cidr", "{$cidr_info['begin']}/{$cidr_info['suffix']}");
$phptemp->assign("page", "{$cidr_info['begin']}/{$cidr_info['suffix']}");
$content->assign("ip_start", $cidr_info['begin']);
$content->assign("ip_end", $cidr_info['end']);
$content->assign("ip_number", $cidr_info['count']);
if (!isset($ip_prefix)) {
    $content->assign("nocontribs", "1");
} else {
    $query = "SELECT page_title,rev_id,rev_user_text,rev_timestamp,rev_minor_edit,rev_comment,page_namespace FROM revision_userindex JOIN page ON page_id = rev_page WHERE rev_user_text LIKE '{$ip_prefix}%' AND rev_user = '******' ORDER BY rev_timestamp DESC;";
    $result = mysql_query($query, $mysql);
    if (!$result) {
        toDie(mysql_error());
    }
    if (mysql_num_rows($result) == 0) {
        $content->assign("nocontribs", "1");
    } else {
        //echo "<ul>\n";
        $c = 0;
        $list = "";
        while ($row = mysql_fetch_assoc($result)) {
            if ($c >= $limit) {
                $continue = $row['rev_timestamp'];
                break;
            }
            if (isset($_GET['continue']) && $_GET['continue'] < $row['rev_timestamp']) {
                continue;
            }