public function fetch() { $remote_archive = new RemoteRequest($this->url); if (Error::is_error($remote_archive->execute())) { throw new Exception('Could not fetch archive at ' . $this->url); } // we should also check content-disposition for filename and the url as fallbacks. // some crazy people like to send application/octet-stream, weirdos! foreach (split("\n", $remote_archive->get_response_headers()) as $line) { if (substr_compare($line, 'Content-Type', 0, 12, true) == 0) { $content_type = $line; break; } } /* Get the MIME type and character set */ preg_match('@Content-Type:\\s+([\\w/\\-+]+)(;\\s+charset=(\\S+))?@i', $content_type, $matches); if (isset($matches[1])) { $mime = $matches[1]; } else { throw new Exception('Could not determine archive type'); } $file = HabariPackages::tempnam(); if (!file_put_contents($file, $remote_archive->get_response_body(), LOCK_EX)) { throw new Exception('Please make the directory ' . dirname($file) . ' writeable by the server'); } $this->md5 = md5_file($file); $this->set_archive_reader($mime, $file); unset($remote_archive); }
public function act_uninstall($handler, $theme) { try { $package = HabariPackages::remove($handler->handler_vars['guid']); Session::notice("{$package->name} {$package->version} was uninstalled."); } catch (Exception $e) { Session::error('Could not complete uninstall: ' . $e->getMessage()); if (DEBUG) { Utils::debug($e); } } }
public static function list_package_types() { if (self::$types) { return self::$types; } self::$types = array('system', 'plugin', 'theme', 'class'); self::$types = array_merge(Plugins::filter('package_types', array()), self::$types); return self::$types; }
<?php include HABARI_PATH . '/system/admin/header.php'; ?> <?php if (HabariPackages::require_updates()) { ?> <div class="container"> <span class="pct25"> </span> <strong class="pct50"><a href="<?php URL::out('admin', 'page=hpm&action=update' . ($type ? "&type={$type}" : '')); ?> ">Update Package List</a></strong> </div> <?php } ?> <div class="container navigator"> <div class="search pct100"><input id="search" type="search" placeholder="Type and wait to search for any entry component" autosave="habaricontent" results="100" value=""></div> <a class="pct50" href="#" onclick="hpm.previous(); return false;">< previous</a> <a class="pct50" style="text-align:right;" href="#" onclick="hpm.next(); return false;">next ></a> </div> <div id="comments" class="container manage comments"> <?php $theme->display('hpm_packages'); ?> </div>
?> <div class="container"> <?php switch ($notice) { case 'permissions': ?> <h2>Incorrect Permission</h2> <p>HPM requires the temporary folder and install location to be writable by the server. Please make the following changes.</p> <?php if (!is_writable(HabariPackages::tempdir())) { ?> <h3>Temporary Folder</h3> <p>Please make <?php echo HabariPackages::tempdir(); ?> writable by the server</p> <p>...explain the process here...</p> <?php } ?> <?php if (!is_writable(HABARI_PATH . '/3rdparty')) { ?> <h3>Install Folder</h3> <p>Please make <?php echo HABARI_PATH . '/3rdparty'; ?> writable by the server</p>