<?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); }
$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"; } catch (Exception $e) {