/** * @param array $formData * @param HtmlForm $form * * @return bool|string * @throws DBUnexpectedError * @throws Exception * @throws MWException */ public static function processInput(array $formData, HtmlForm $form) { error_reporting(0); global $wgCreateWikiSQLfiles, $IP; $DBname = $formData['dbname']; $founderName = $formData['founder']; $dbw = wfGetDB(DB_MASTER); $dbTest = $dbw->query('SHOW DATABASES LIKE ' . $dbw->addQuotes($DBname) . ';'); $rows = $dbTest->numRows(); $dbTest->free(); if ($rows !== 0) { return wfMessage('createwiki-error-dbexists')->plain(); } $farmerLogEntry = new ManualLogEntry('farmer', 'createandpromote'); $farmerLogEntry->setPerformer($form->getUser()); $farmerLogEntry->setTarget($form->getTitle()); $farmerLogEntry->setComment($formData['comment']); $farmerLogEntry->setParameters(array('4::wiki' => $DBname, '5::founder' => $founderName)); $farmerLogID = $farmerLogEntry->insert(); $farmerLogEntry->publish($farmerLogID); $dbw->query('SET storage_engine=InnoDB;'); $dbw->query('CREATE DATABASE ' . $dbw->addIdentifierQuotes($DBname) . ';'); $dbw->selectDB($DBname); foreach ($wgCreateWikiSQLfiles as $file) { $dbw->sourceFile($file); } $dbw->insert('site_stats', array('ss_row_id' => 1)); $dbw->close(); // Add DNS record to cloudflare global $wgCreateWikiUseCloudFlare, $wgCloudFlareUser, $wgCloudFlareKey; if ($wgCreateWikiUseCloudFlare) { $domainPrefix = substr($DBname, 0, -4); $cloudFlare = new cloudflare_api($wgCloudFlareUser, $wgCloudFlareKey); $cloudFlareResult = $cloudFlare->rec_new('orain.org', 'CNAME', $domainPrefix, 'lb.orain.org'); if (!is_object($cloudFlareResult) || $cloudFlareResult->result !== 'success') { wfDebugLog('CreateWiki', 'CloudFlare FAILED to add CNAME for ' . $domainPrefix . '.orain.org'); } else { wfDebugLog('CreateWiki', 'CloudFlare CNAME added for ' . $domainPrefix . '.orain.org'); } } // Create local account for founder (hack) $out = exec("php5 {$IP}/extensions/CentralAuth/maintenance/createLocalAccount.php " . escapeshellarg($founderName) . ' --wiki ' . escapeshellarg($DBname)); if (!strpos($out, 'created')) { return wfMessage('createwiki-error-usernotcreated')->plain(); } require_once "{$IP}/includes/UserRightsProxy.php"; // Grant founder sysop and bureaucrat rights $founderUser = UserRightsProxy::newFromName($DBname, $founderName); $newGroups = array('sysop', 'bureaucrat'); array_map(array($founderUser, 'addGroup'), $newGroups); $founderUser->invalidateCache(); $form->getOutput()->addWikiMsg('createwiki-success', $DBname); return true; }
//counter $offset = 0; // $ips_used = 0; // $i_offset = 0; // $end = false; // $ip_array = array(); $dns_zone_array = array(); $difference = 0; if (!file_exists($seed_dump)) { echo "Didn't find seed_dump at {$seed_dump}\n"; } else { $cf = new cloudflare_api($user, $key); $response_object = $cf->rec_load_all($domain); //ALL dns entries of domain $response_json = json_encode($response_object); //make objects to JSON $response_array = json_decode($response_json, true); //make JSON to array, thanks php if (isset($response_array["err_code"])) { if ($response_array["err_code"] == "E_UNAUTH") { echo "Auth failed, check your email and key!"; } } //write IPs into array $ip_raw = file($seed_dump); //read seed_dump into array $ip_numbers_in_file = count($ip_raw);