public function test_itsCheckForUpdateTime() { $config = Zend_Registry::get('config'); $this->assertTrue(USVN_Update::itsCheckForUpdateTime()); $config->update = array("lastcheckforupdate" => 10); $this->assertTrue(USVN_Update::itsCheckForUpdateTime()); $config->update = array("lastcheckforupdate" => time() - 10); $this->assertFalse(USVN_Update::itsCheckForUpdateTime()); }
/** * Update file with USVN version number */ public static function updateUSVNAvailableVersionNumber() { if (USVN_Update::itsCheckForUpdateTime()) { $config = Zend_Registry::get('config'); $url = 'http://www.usvn.info'; $http_conf = USVN_Update::setProxyForUpdate(array('maxredirects' => 0, 'timeout' => 30)); // if (defined("PHPUnit_MAIN_METHOD")) // $url = 'http://iceage.usvn.info'; $client = new Zend_Http_Client($url . '/update/' . urlencode($config->version), $http_conf); $client->setParameterPost('sysinfo', USVN_Update::getInformationsAboutSystem()); try { $response = $client->request('POST'); } catch (Exception $e) { // Ugly but we don't want to display error if usvn.info is not available return; } if ($response->getStatus() == 200) { $config->update->availableversion = $response->getBody(); $config->save(); } $config->update->lastcheckforupdate = time(); $config->save(); } }