/** * Update::run() * * @return */ public function run() { $info = $this->getInfo(); $this->checkForUpdates(); if ($this->updateAvailable) { /** * 8. verificar que exista el archivo update.php * 9. importar update.php y ejecutar el proceso * */ $requirements = $this->checkRequirements($info['requirements']); if ($requirements) { return $requirements; } $response = $this->handler->fetch($info['url_update']); if (isset($response['body']) && $response['successful']) { $file_update = $response['body']; } else { $file_update = $response; } $file_saved = DIR_ROOT . "updates/update.zip"; $f = fopen($file_saved, 'wb'); fwrite($f, $file_update); fclose($f); echo __LINE__ . ': ' . sha1_file($file_saved) . '===' . $info['checksum'] . '<br />'; if (file_exists($file_saved) && sha1_file($file_saved) === $info['checksum']) { $zip = new PclZip(); $zip->setZipName($file_saved); if ($zip->extract(PCLZIP_OPT_PATH, DIR_ROOT, PCLZIP_OPT_REPLACE_NEWER) > 0) { unlink($file_saved); if (file_exists(DIR_ROOT . 'update.php')) { include_once DIR_ROOT . 'update.php'; if (function_exists('upgradeNecoTienda')) { upgradeNecoTienda($this->registry, VERSION); } unlink(DIR_ROOT . 'update.php'); } } else { return $zip->errorInfo(true); } } else { return false; } } else { //TODO: Ya esta actualizada } }