Commit 68ce0926 authored by Luke081515's avatar Luke081515

Add LAStats

parent c067f383
Pipeline #1618 passed with stages
in 1 minute and 50 seconds
#!/usr/bin/php
<?php
require_once __DIR__ . '/Cygnus/BotCore.php';
require_once __DIR__ . '/Cygnus/DBCore.php';
/** LAStats.php
* Generates stats about the requests for deletion of the last day
* @Author Luke081515
* @Version 0.1
* @Status Alpha
*/
class LAStats extends Core {
protected $DB;
public function __construct($Account, $Job) {
$this->initcurl($Account, $Job);
$this->connectToDatabase();
$this->generateStats();
}
public function generateStats() {
$today = strtotime('00:00:00');
$yesterday = strtotime('-1 day', $today);
$date = date('j. F o', $yesterday);
$date = str_replace("January", "Januar", $date);
$date = str_replace("February", "Februar", $date);
$date = str_replace("March", "März", $date);
$date = str_replace("May", "Mai", $date);
$date = str_replace("June", "Juni", $date);
$date = str_replace("July", "Juli", $date);
$date = str_replace("October", "Oktober", $date);
$date = str_replace("December", "Dezember", $date);
$page = "Wikipedia:Löschkandidaten/" . $date;
$this->getStats($page, $yesterday);
}
public function getStats($page, $time) {
$res = $this->getTableOfContents($page);
$counter = 0;
$categorys = 0;
$userpages = 0;
$metapages = 0;
$template = 0;
$lists = 0;
$articles = 0;
for ($i = 0; isset($res[$i]); $i++) {
if ($res[$i][0] === "1") {
$counter++;
} else if ($res[$i][0] !== "1" && $counter <= 6) {
switch($counter) {
case 1:
$categorys++;
break;
case 2:
$userpages++;
break;
case 3:
$metapages++;
break;
case 4:
$template++;
break;
case 5:
$lists++;
break;
case 6:
$articles++;
break;
default:
}
}
}
$time = date("Y-m-d H:i:s", $time);
$sql = "INSERT INTO lastats VALUES(\"" . $time . "\", \"Categorys\", " . $categorys . ");";
$this->DB->modify($sql);
$sql = "INSERT INTO lastats VALUES(\"" . $time . "\", \"Userpages\", " . $userpages . ");";
$this->DB->modify($sql);
$sql = "INSERT INTO lastats VALUES(\"" . $time . "\", \"Metapages\", " . $metapages . ");";
$this->DB->modify($sql);
$sql = "INSERT INTO lastats VALUES(\"" . $time . "\", \"Templates\", " . $template . ");";
$this->DB->modify($sql);
$sql = "INSERT INTO lastats VALUES(\"" . $time . "\", \"Lists\", " . $lists . ");";
$this->DB->modify($sql);
$sql = "INSERT INTO lastats VALUES(\"" . $time . "\", \"Articles\", " . $articles . ");";
$this->DB->modify($sql);
}
protected function connectToDatabase () {
$this->DB = new DBCore('root@localhost', 'maintenance');
}
}
$Bot = new LAStats ('Luke081515Bot@dewiki', 'LAStats');
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment