Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation errors #613

Closed
jcm4atx opened this issue Mar 3, 2023 · 1 comment
Closed

Installation errors #613

jcm4atx opened this issue Mar 3, 2023 · 1 comment

Comments

@jcm4atx
Copy link

jcm4atx commented Mar 3, 2023

Whether I use the source code or online installer I get a long error message. I have all prerequisites installed. I'm running Apache on Debian.

errors[] = $message; } protected $warnings = array(); public function warning($message) { $this->warnings[] = $message; } public function run() { $string = ""; if (!empty($this->errors)) { foreach ($this->errors as $error) { $string .= '

' . $error . "
"; } } if (!empty($this->warnings)) { foreach ($this->warnings as $warning) { $string .= '

' . $warning . "
"; } } return $string; } } class Settings { protected $user = ""; protected $userPassword = ""; protected $siteUrl = ""; protected $overwriteEmptyForm = array( "social.twitter" => "", "social.facebook" => "", ); protected function extractUser() { $this->user = (string)$_REQUEST["user_name"]; unset($_REQUEST["user_name"]); $this->userPassword = (string)$_REQUEST["user_password"]; unset($_REQUEST["user_password"]); } protected function convertRequestToConfig() { $array = array(); foreach ($_REQUEST as $name => $value) { if (!is_string($value) || empty($value)) continue; $name = str_replace("_", ".", $name); $array[$name] = $value; } foreach ($this->overwriteEmptyForm as $name => $value) { if (!isset($array[$name])) { $array[$name] = $value; } } return $array; } protected function generateSiteUrl() { $dir = trim(dirname(substr($_SERVER["SCRIPT_FILENAME"], strlen($_SERVER["DOCUMENT_ROOT"]))), '/'); if ($dir == '.' || $dir == '..') { $dir = ''; } $port = ''; if ($_SERVER["SERVER_PORT"] != "80") { $port = ':' . $_SERVER["SERVER_PORT"]; } $scheme = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http'; if ($dir === '') { $this->siteUrl = $scheme . '://' . trim($_SERVER['SERVER_NAME'], "/") . $port . "/"; return; } $this->siteUrl = $scheme . '://' . trim($_SERVER['SERVER_NAME'], "/") . $port . "/" . $dir . '/'; } protected function overwriteINI($data, $string) { foreach ($data as $word => $value) { $string = preg_replace("/^" . $word . " = .+$/m", $word . ' = "' . $value . '"', $string); } return $string; } protected function saveConfigs() { $this->extractUser(); //save config.ini $config = array( "site.url" => $this->siteUrl, "timezone" => $this->getTimeZone(), ); $config += $this->convertRequestToConfig(); $configFile = file_get_contents("config/config.ini.example"); $configFile = $this->overwriteINI($config, $configFile); file_put_contents("config/config.ini", $configFile); //save users/[Username].ini $userFile = file_get_contents("config/users/username.ini.example"); $parsed = parse_ini_string($userFile); if (isset($parsed['encryption'])) { $userFile = $this->overwriteINI(array( 'encryption' => 'sha512', 'password' => hash('sha512', $this->userPassword), 'role' => 'admin', ), $userFile); } else { $userFile = $this->overwriteINI(array( "password" => $this->userPassword, 'role' => 'admin', ), $userFile); } file_put_contents("config/users/" . $this->user . ".ini", $userFile); } protected function testTheEnvironment() { $message = new Message; if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50300) { $message->error('HTMLy requires at least PHP 5.3 to run.'); } if (!in_array('https', stream_get_wrappers())) { $message->error('Installer needs the https wrapper, please install openssl.'); } if (function_exists('apache_get_modules') && !in_array('mod_rewrite', apache_get_modules())) { $message->warning('mod_rewrite must be enabled if you use Apache.'); } if (!is__writable("./")) { $message->error('no permission to write in the Directory.'); } return $message->run(); } public function __construct() { $message = $this->testTheEnvironment(); $this->generateSiteUrl(); if (!empty($message)) { echo $message; } elseif ($this->runForm()) { unlink(__FILE__); header("Location:" . $this->siteUrl . "add/content?type=post"); exit(); } } protected function getTimeZone() { static $ip; if (empty($ip)) { $ip = @file_get_contents("http://ipecho.net/plain"); if (!is_string($ip)) { $ip = $_SERVER['REMOTE_ADDR']; } } $json = @json_decode(@file_get_contents("http://ip-api.com/json/" . $ip), true); if (isset($json['timezone'])) return $json['timezone']; return 'Europe/Berlin'; } protected function runForm() { if (from($_REQUEST, 'user_name') && from($_REQUEST, 'user_password')) { $this->saveConfigs(); $_SESSION[$this->siteUrl]["user"] = $this->user; return true; } else { unset($_SESSION[$this->siteUrl]["user"]); return false; } } } if(from($_SERVER,'QUERY_STRING') == "rewriteRule.html") { echo "YES!"; die(); } $samesite = 'strict'; if(PHP_VERSION_ID < 70300) { session_set_cookie_params('samesite='.$samesite); } else { session_set_cookie_params(['samesite' => $samesite]); } session_start(); new Settings; ?> 
@jcm4atx
Copy link
Author

jcm4atx commented Mar 3, 2023

I ended up resolving this myself by completely removing PHP and all related Apache modules and reinstalling.

@jcm4atx jcm4atx closed this as completed Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant