Exemplo n.º 1
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);
}
Exemplo n.º 2
0
        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);
            GWTLogHelper::notice("verify");
            $service->verifyWiki($wiki, $users[$userI]);
            GWTLogHelper::notice("sendsitemap");
            $service->sendSitemap($wiki, $users[$userI]);
            if ($i % 10 == 0) {
                sleep(1);
            }
        } catch (Exception $e) {
            GWTLogHelper::error("Error while synchronizing " . $wiki->getWikiId() . " " . $users[$userI]->getEmail());
            GWTLogHelper::error("" . $e->getMessage());
        }
    }
    GWTLogHelper::notice(__FILE__ . " script ends.");
} catch (Exception $ex) {
    GWTLogHelper::error(__FILE__ . " script failed.", $ex);
}