} $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
<?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); }
/** * Sends sitemap to google webmaster tools. * @param GWTWiki $wiki * @param IGoogleCredentials $user * @return mixed */ function sendSitemap($wiki, $user) { return $this->webmasterToolsUtil->sendSitemap($wiki->getWikiId(), $user); }