/** * Edits php.ini * * @author Art <*****@*****.**> * @return PHP */ protected function editIni() { $timezone = SET::$s->php_date_timezone; $ini = $this->unzipped_destination . 'php.ini'; if (!$timezone) { $timezone = 'Europe/London'; _echo('Your timezone setting wasn\'t found. Setting it to Europe/London.'); SET::$s->php_date_timezone = $timezone; SET::$s->save(); } $contents = file_get_contents($ini); $err_log_dir = '"' . str_replace(DIRECTORY_SEPARATOR, '/', DIR_LOGS) . 'php/php_errors.log"'; if ($contents) { $contents = str_ireplace([';date.timezone =', '; extension_dir = "ext"', ';error_log = php_errors.log'], ['date.timezone = ' . $timezone, 'extension_dir = "' . $this->unzipped_destination . 'ext"', 'error_log = ' . $err_log_dir . ''], $contents); if (file_put_contents($ini, $contents) !== false) { _echo('php.ini edited'); } else { $msg = 'Failed to edit php.ini. You will have to set the following yourself:' . PHP_EOL . "\t Find ';date.timezone =' and change it to 'date.timezone = ' . {$timezone}'" . PHP_EOL . "\t Find '; extension_dir = \"ext\"' and change it to 'extension_dir = \"ext\"'" . PHP_EOL . "\t Find ';error_log = php_errors.log' and change it to 'error_log = {$err_log_dir}'"; _echo($msg . PHP_EOL . 'Press ENTER to continue'); \IO::readline(); } } else { _echo('Failed to open php.ini for editing. You will have to set the timezone yourself.'); } return $this; }
/** * Checks if the www dir is set up * * @author Art <*****@*****.**> */ protected function checkWebDir() { if (!SET::$s->web_dir) { $new_dir = \IO::readline('Your default website name was not found - please enter a name (defaults to my-default-website if left empty)'); if (!$new_dir) { $new_dir = 'my-default-website'; } SET::$s->web_dir = $new_dir; SET::$s->save(); } if (!file_exists(DIR_WWW . SET::$s->web_dir . DIRECTORY_SEPARATOR)) { mkdir(DIR_WWW . SET::$s->web_dir . DIRECTORY_SEPARATOR, 777, true); } }
/** * Prompts to download a version * * @author Art <*****@*****.**> * @return AbstractBinSetup */ protected function promptDownload() { if (!empty($this->links)) { $version_numbers = array_keys($this->links); _echo('The following versions were found for download: ' . PHP_EOL . "\t" . implode(PHP_EOL . "\t", $version_numbers)); $io = trim(\IO::readline('Which version would you like to download? Input N to abort')); if (!$io) { $this->promptDownload(); } elseif ($io == 'n') { die('Aborting.'); } elseif (!isset($this->links[$io])) { _echo('The version you selected is not available for download.'); $this->promptDownload(); } else { _echo('Contacting download server...'); $this->version = $io; $this->download(); return $this; } } else { die('Aborting.'); } return $this; }
<?php _echo('Checking remote version...'); $remote_version = trim(file_get_contents('https://raw.githubusercontent.com/Alorel/AloWAMP/master/src/VERSION')); $local_version = trim(file_get_contents(DIR_INDEX . 'VERSION')); _echo('Local version: ' . $local_version); _echo('Remote version: ' . $remote_version); if (version_compare($local_version, $remote_version, '<')) { $loop = true; do { $io = trim(IO::readline('Would you like to download the update? [Y\\N]')); switch ($io) { case '': continue; case 'y': shell_exec('start ' . HOMEPAGE); $loop = false; break; default: $loop = false; } } while ($loop); } else { _echo('You have the newest version'); }
<?php if (\IO::readline('Are you sure you want to reset your installation? You will lose all configuration, but not your website data. [Y/N]') == 'y') { $items = [DIR_BIN, DIR_LOGS, DIR_TMP, DIR_CORE . 'settings.ini']; foreach ($items as $i) { if (file_exists($i)) { if (is_dir($i)) { shell_exec('rd /s /q "' . rtrim($i, '\\/') . '"'); } else { unlink($i); } } } _echo('Reset completed.'); } else { _echo('Reset aborted'); }
/** * Checks and creates the memcache directory * * @author Art <*****@*****.**> * @return Setup */ function checkMemcache() { if (file_exists(DIR_MEMCACHE)) { _echo('Memcache OK'); } else { $rl = \IO::readline('Memcache not found. Would you like to download it? It\'s an optional module. [Y/N]'); switch ($rl) { case 'y': _echo('Contacting download server...'); new \Setup\Memcache(); break; case 'n': _echo('Memcache skipped'); break; default: return $this->checkMemcache(); } } return $this; }