Example #1
0
<?php

// example: SERVER_ID=5915 php maintenance/wikia/GoogleWebmasterToolsSync/list_users.php --conf /usr/wikia/docroot/wiki.factory/LocalSettings.php
$freeSlotsWarning = 100;
$warningEmails = ["*****@*****.**"];
require_once __DIR__ . "/common.php";
GWTLogHelper::notice(__FILE__ . " script starts.");
try {
    $gwt = new GWTService(null, null, null);
    $users = $gwt->getAvailableUsers();
    $unsyncWikisCount = sizeof($gwt->getWikisToUpload());
    $limitPerAccout = $gwt->getMaxSitesPerAccount();
    $freeSlots = 0;
    foreach ($users as $user) {
        /* @var $user GWTUser */
        $freeSlots += $limitPerAccout - $user->getCount();
    }
    GWTLogHelper::notice("FREE SLOTS: {$freeSlots}");
    if ($freeSlots < $freeSlotsWarning) {
        foreach ($warningEmails as $warningEmail) {
            UserMailer::send(new MailAddress($warningEmail), new MailAddress('*****@*****.**', 'GoogleWebmasterToolsService'), 'GA Webmaster Tools Accounts - ' . $freeSlots . ' slots left', 'There is only ' . $freeSlots . " slots left. Please add new accounts to our database.\n" . 'There is ' . $unsyncWikisCount . ' unsync wikis.', null, 'text/html; charset=ISO-8859-1');
        }
    }
} catch (Exception $ex) {
    GWTLogHelper::error(__FILE__ . " script failed.", $ex);
}
Example #2
0
<?php

$optionsWithArgs = array('i');
require_once __DIR__ . "/common.php";
GWTLogHelper::notice(__FILE__ . " script starts.");
try {
    if (!isset($options['i'])) {
        GWTLogHelper::error("Specify wiki id ( city_id ) (-i)");
        die(1);
    }
    $service = new GWTService();
    $wiki = $service->getWikiRepository()->getById($options['i']);
    if (!$wiki) {
        GWTLogHelper::error("No wiki for " . $options['i'] . "\n");
        die(1);
    }
    if (!$wiki->getUserId()) {
        GWTLogHelper::error("User id empty for " . $wiki->getWikiId() . "\n");
        die(1);
    }
    $user = $service->getUserRepository()->getById($wiki->getUserId());
    $info = $service->verifyWiki($wiki, $user);
    GWTLogHelper::notice(__FILE__ . " script ends.");
} catch (Exception $ex) {
    GWTLogHelper::error(__FILE__ . " script failed.", $ex);
}
Example #3
0
<?php

$optionsWithArgs = array('u', 'w');
require_once __DIR__ . "/common.php";
GWTLogHelper::notice(__FILE__ . " script starts.");
try {
    if (!isset($options['u']) || !isset($options['w'])) {
        GWTLogHelper::error("Specify user (-u) and wikiId (-p)");
        die(1);
    }
    $userRepository = new GWTUserRepository();
    $wikiRepository = new GWTWikiRepository();
    $service = new GWTService($userRepository, $wikiRepository);
    $u = $userRepository->getByEmail($options['u']);
    $w = $wikiRepository->getById($options['w']);
    if ($u == null && $w == null) {
        GWTLogHelper::error("no user or no wiki.");
        die(1);
    }
    $service->uploadWikiAsUser($w, $u);
} catch (Exception $ex) {
    GWTLogHelper::error(__FILE__ . " script failed.", $ex);
}
Example #4
0
<?php

$optionsWithArgs = array('i');
require_once __DIR__ . "/common.php";
GWTLogHelper::notice(__FILE__ . " script starts.");
try {
    if (!isset($options['i'])) {
        GWTLogHelper::error("Specify wiki id (-i)");
        die;
    }
    $service = new GWTService();
    GWTLogHelper::notice("wiki_id: " . $options["i"]);
    $wiki = $service->getWikiRepository()->getById($options['i']);
    if (!$wiki) {
        GWTLogHelper::error("No wiki for " . $options['i'] . "\n");
        die(1);
    }
    if (!$wiki->getUserId()) {
        GWTLogHelper::error("User id empty for " . $wiki->getWikiId() . "\n");
        die(1);
    }
    GWTLogHelper::notice("user_id: " . $wiki->getUserId());
    $user = $service->getUserRepository()->getById($wiki->getUserId());
    GWTLogHelper::notice("email  : " . $user->getEmail());
    $info = $service->sendSitemap($wiki, $user);
    GWTLogHelper::notice(__FILE__ . " script end.");
} catch (Exception $ex) {
    GWTLogHelper::error(__FILE__ . " script failed.", $ex);
}
Example #5
0
<?php

$optionsWithArgs = array('i');
require_once __DIR__ . "/common.php";
GWTLogHelper::notice(__FILE__ . " script starts.");
try {
    if (!isset($options['i'])) {
        GWTLogHelper::error("Specify wikiid (-i)");
        die(1);
    }
    $service = new GWTService();
    $info = $service->getWikiInfo($options['i']);
    var_dump($info);
    GWTLogHelper::notice(__FILE__ . " script ends.");
} catch (Exception $ex) {
    GWTLogHelper::error(__FILE__ . " script failed.", $ex);
}
Example #6
0
<?php

global $IP;
$optionsWithArgs = array('m');
require_once __DIR__ . "/common.php";
GWTLogHelper::notice(__FILE__ . " script starts.");
try {
    $max_wikis_to_sync = 1000;
    if (isset($options['m'])) {
        $max_wikis_to_sync = intval($options['m']);
    }
    $service = new GWTService();
    $users = $service->getAvailableUsers();
    $wikis = $service->getWikisToUpload();
    $userI = 0;
    foreach ($wikis as $i => $wiki) {
        if ($i >= $max_wikis_to_sync) {
            break;
        }
        if ($users[$userI]->getCount() >= $service->getMaxSitesPerAccount()) {
            $service->getUserRepository()->update($users[$userI]);
            $userI++;
        }
        if ($userI >= count($users)) {
            break;
        }
        GWTLogHelper::notice("Synchronizing: " . $wiki->getWikiId() . " " . $users[$userI]->getEmail());
        try {
            GWTLogHelper::notice("upload");
            $service->uploadWikiAsUser($wiki, $users[$userI]);
            sleep(1);