Beispiel #1
0
 /**
  * Sets the URLs used to download new versions of the installed GeoIP databases.
  *
  * Input (query params):
  *   'loc_db' - URL for a GeoIP location database.
  *   'isp_db' - URL for a GeoIP ISP database (optional).
  *   'org_db' - URL for a GeoIP Org database (optional).
  *   'period' - 'weekly' or 'monthly'. Determines how often update is run.
  *
  * Output (json):
  *   'error' - if an error occurs its message is set as the resulting JSON object's
  *             'error' property.
  */
 public function updateGeoIPLinks()
 {
     $this->dieIfGeolocationAdminIsDisabled();
     Piwik::checkUserHasSuperUserAccess();
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         Json::sendHeaderJSON();
         try {
             $this->checkTokenInUrl();
             GeoIPAutoUpdater::setUpdaterOptionsFromUrl();
             // if there is a updater URL for a database, but its missing from the misc dir, tell
             // the browser so it can download it next
             $info = $this->getNextMissingDbUrlInfo();
             if ($info !== false) {
                 return json_encode($info);
             } else {
                 $view = new View("@UserCountry/_updaterNextRunTime");
                 $view->nextRunTime = GeoIPAutoUpdater::getNextRunTime();
                 $nextRunTimeHtml = $view->render();
                 return json_encode(array('nextRunTime' => $nextRunTimeHtml));
             }
         } catch (Exception $ex) {
             return json_encode(array('error' => $ex->getMessage()));
         }
     }
 }