})); Route::post('account', array('before' => 'check', 'main' => function () { $account = Input::get(array('username', 'email', 'password')); $validator = new Validator($account); $validator->check('username')->is_max(3, 'Please enter a username'); $validator->check('email')->is_email('Please enter a valid email address'); $validator->check('password')->is_max(6, 'Please enter a password, at least 6 characters long'); if ($errors = $validator->errors()) { Input::flash(); Notify::error($errors); return Response::redirect('account'); } Session::put('install.account', $account); // run install process try { Installer::run(); } catch (Exception $e) { Input::flash(); Notify::error($e->getMessage()); return Response::redirect('account'); } return Response::redirect('complete'); })); /* Complete */ Route::get('complete', function () { // check we have a database if (!Session::get('install')) { Notify::error('Please select your language'); return Response::redirect('start');
define('TEMPLATE_DIR', JETHRO_ROOT . '/templates/'); // Load configuration if (!is_readable(JETHRO_ROOT . '/conf.php')) { trigger_error('Jethro configuration file not found. You need to copy conf.php.sample to conf.php and edit it before Jethro can run', E_USER_ERROR); exit; } require_once JETHRO_ROOT . '/conf.php'; // Initialise system if (!defined('DSN')) { define('DSN', constant('PRIVATE_DSN')); } require_once JETHRO_ROOT . '/include/init.php'; // Set up the user system require_once JETHRO_ROOT . '/include/user_system.class.php'; require_once JETHRO_ROOT . '/include/system_controller.class.php'; $GLOBALS['user_system'] = new User_System(); if ($GLOBALS['user_system']->getCurrentUser() == NULL) { System_Controller::checkConfigHealth(); // Nobody is logged in, so show login screen or installer if (!$GLOBALS['user_system']->hasUsers()) { require_once JETHRO_ROOT . '/include/installer.class.php'; $installer = new Installer(); $installer->run(); } else { $GLOBALS['user_system']->printLogin(); } } else { // We have a user, so run the system $GLOBALS['system'] = System_Controller::get(); System_Controller::get()->run(); }
#!/usr/bin/env php <?php /** * The installer sub-stub for extension phars */ namespace pharext; define("PHAREXT_PHAR", __FILE__); spl_autoload_register(function ($c) { return include strtr($c, "\\_", "//") . ".php"; }); #include <pharext/Exception.php> #include <pharext/Tempname.php> #include <pharext/Tempfile.php> #include <pharext/Tempdir.php> #include <pharext/Archive.php> namespace pharext; if (extension_loaded("Phar")) { \Phar::interceptFileFuncs(); \Phar::mapPhar(); $phardir = "phar://" . __FILE__; } else { $archive = new Archive(__FILE__); $phardir = $archive->extract(); } set_include_path("{$phardir}:" . get_include_path()); $installer = new Installer(); $installer->run($argc, $argv); __halt_compiler();
} } protected static function cloneDirs($dirsPath, $targetDir) { $dirResource = opendir($dirsPath); if (!$dirResource) { static::$quiet || (print "[30;1;31mCan't read dir[0m" . PHP_EOL); return; } while ($fileName = readdir($dirResource)) { if ($fileName == '.' || $fileName == '..') { continue; } if (false !== in_array($fileName, static::$ignoreList)) { continue; } static::cloneItem($dirsPath . DIRECTORY_SEPARATOR . $fileName, $targetDir); } closedir($dirResource); } public static function run($sourseDir, $targetDir, $ignoreList = [], $forceRewrite = false, $quiet = false) { static::$ignoreList = $ignoreList; static::$forceRewrite = $forceRewrite; static::$quiet = $quiet; static::cloneDirs($sourseDir, $targetDir); echo PHP_EOL; } } \Installer::run($currentDir, $targetDir, $ignoreList, $rewrite, $quiet);
<?php $CONFIG['SOFTWARE'] = 'TypeShow Update'; $CONFIG['PACKAGE_NAME'] = 'typeshow.update.zip'; $CONFIG['PACKAGE_URL'] = 'http://update.typeshow.net/' . $CONFIG['PACKAGE_NAME']; // Protect extracted package directories //$CONFIG['PROTECT'][] = 'admin'; //$CONFIG['PROTECT'][] = 'resources'; // Where to go after finish... $CONFIG['AFTER_INSTALL'] = 'index.html?please_refresh'; // Help files $FAQ['NO_FILESYSTEM_ACCESS'] = 'http://typeshow.net/faq/#no_filesystem_access'; $FAQ['NO_ZIP_SUPPORT'] = 'http://typeshow.net/faq/#no_zip_support'; $FAQ['DOWNLOAD_RESTRICTIONS'] = 'http://typeshow.net/faq/#php_download_restrictions'; Installer::run('..'); class Installer { private static $software; private static $package; private static $packageUrl; private static $folder; private static $me; public static function run($folder = '.') { global $FAQ, $CONFIG; self::$folder = $folder; self::$software = $CONFIG['SOFTWARE']; self::$package = $CONFIG['PACKAGE_NAME']; self::$packageUrl = $CONFIG['PACKAGE_URL']; self::$me = basename(__FILE__); $step = 1;