Example #1
0
 /**
  * Get wiki info.
  * @param $wikiId - city_id
  * @return null|GWTSiteSyncStatus
  */
 function getWikiInfo($wikiId)
 {
     $wikiId = strval($wikiId);
     $wiki = $this->wikiRepository->getById($wikiId);
     if ($wiki && $wiki->getUserId()) {
         $user = $this->userRepository->getById($wiki->getUserId());
         return $this->webmasterToolsUtil->getInfo($wikiId, $user);
     }
     return null;
 }
Example #2
0
<?php

// example: SERVER_ID=5915 php maintenance/wikia/GoogleWebmasterToolsSync/list_users.php --conf /usr/wikia/docroot/wiki.factory/LocalSettings.php
require_once __DIR__ . "/common.php";
GWTLogHelper::notice(__FILE__ . " script starts.");
try {
    $userRepository = new GWTUserRepository();
    $users = $userRepository->all();
    foreach ($users as $i => $u) {
        echo "[ id = " . $u->getId() . " ]  " . $u->getEmail() . " " . $u->getCount() . "\n";
    }
} catch (Exception $ex) {
    GWTLogHelper::error(__FILE__ . " script failed.", $ex);
}
Example #3
0
<?php

$optionsWithArgs = array('u');
require_once __DIR__ . "/common.php";
GWTLogHelper::notice(__FILE__ . " script starts.");
try {
    $userRepository = new GWTUserRepository();
    if (!isset($options['u'])) {
        GWTLogHelper::error("Specify user (-u).");
        die(1);
    }
    $user = $userRepository->getByEmail($options['u']);
    if ($user == null) {
        GWTLogHelper::error("No such user. Try add_user.php.");
        die(1);
    }
    $util = new WebmasterToolsUtil();
    $sites = $util->getSites($user);
    foreach ($sites as $i => $s) {
        echo $s->getUrl() . " " . $s->getVerified() . "\n";
    }
} catch (Exception $ex) {
    GWTLogHelper::error(__FILE__ . " script failed.", $ex);
}
<?php

// example: SERVER_ID=5915 php maintenance/wikia/GoogleWebmasterToolsSync/list_non_full_users.php --conf /usr/wikia/docroot/wiki.factory/LocalSettings.php
$max_count = 495;
require_once __DIR__ . "/common.php";
GWTLogHelper::notice(__FILE__ . " script starts.");
try {
    $userRepository = new GWTUserRepository();
    $users = $userRepository->allCountLt($max_count);
    foreach ($users as $i => $w) {
        echo $w->getEmail() . " " . $w->getCount() . "\n";
    }
} catch (Exception $ex) {
    GWTLogHelper::error(__FILE__ . " script failed.", $ex);
}
Example #5
0
<?php

// example: SERVER_ID=5915 php maintenance/wikia/GoogleWebmasterToolsSync/remove_user.php --conf /usr/wikia/docroot/wiki.factory/LocalSettings.php -u example@gmail.com
$optionsWithArgs = array('u');
require_once __DIR__ . "/common.php";
GWTLogHelper::notice(__FILE__ . " script starts.");
try {
    if (!isset($options['u'])) {
        GWTLogHelper::error("Specify email (-u)");
        die(1);
    }
    $userRepository = new GWTUserRepository();
    $userRepository->deleteByEmail($options['u']);
    GWTLogHelper::notice(__FILE__ . " script end.");
} catch (Exception $ex) {
    GWTLogHelper::error(__FILE__ . " script failed.", $ex);
}
Example #6
0
     $userId = tryInsertUser($db, $user);
     $res = $db->update("webmaster_sitemaps", array("user_id" => $userId, "upload_date" => "1970-01-01"), array("wiki_id" => $wikiId));
     if (!$res) {
         throw new Exception("Failed to update " . $userId . " " . $wikiId);
     }
 }
 function updateUserWikiCount(DatabaseBase $db, $userId, $wikiCount)
 {
     $res = $db->update("webmaster_user_accounts", array("wikis_number" => $wikiCount), array("user_id" => $userId));
     if (!$res) {
         throw new Exception("Failed to update User id=" . $userId . " count = " . $wikiCount);
     }
 }
 $count = 0;
 $service = new WebmasterToolsUtil();
 $userRepository = new GWTUserRepository($db);
 $accounts = $userRepository->all();
 foreach ($accounts as $i => $u) {
     $sites = $service->getSites($u);
     foreach ($sites as $j => $s) {
         $site = $s->getUrl();
         $count++;
         try {
             tryInsertWiki($db, $site);
             tryUpdateWiki($db, $site, $u);
             GWTLogHelper::notice("Insert: {$site} as " . $u->getEmail());
             if ($count % 50 == 0) {
                 sleep(1);
             }
             // slow down
             //echo $u->getEmail() . " " . $site . " success \n";
Example #7
0
<?php

// example: SERVER_ID=5915 php maintenance/wikia/GoogleWebmasterToolsSync/add_user.php --conf /usr/wikia/docroot/wiki.factory/LocalSettings.php -u u2 -p pass
$optionsWithArgs = array('u', 'p');
require_once __DIR__ . "/common.php";
GWTLogHelper::notice(__FILE__ . " script starts.");
try {
    if (!isset($options['u']) || !isset($options['p'])) {
        GWTLogHelper::warning("Specify user (-u) and password (-p)");
        die;
    }
    $userRepository = new GWTUserRepository();
    $r = $userRepository->create($options['u'], $options['p']);
    if ($r == null) {
        GWTLogHelper::warning("error while inserting user.");
        die;
    }
    GWTLogHelper::notice($r->getId() . " " . $r->getEmail() . "\n");
} catch (Exception $ex) {
    GWTLogHelper::error(__FILE__ . " script failed.", $ex);
}