setup bug fixes for recent PHP versions

This commit is contained in:
RobbBienert 2024-10-06 01:13:55 +02:00
parent 46f9843a03
commit 57628ef1a1
2 changed files with 25 additions and 17 deletions

View file

@ -25,7 +25,9 @@
if(!file_exists(dirname( __FILE__ ).DIRECTORY_SEPARATOR.'personal'.DIRECTORY_SEPARATOR.'settings.inc.php')) { if(!file_exists(dirname( __FILE__ ).DIRECTORY_SEPARATOR.'personal'.DIRECTORY_SEPARATOR.'settings.inc.php')) {
if(dirname($_SERVER['SCRIPT_NAME']) !== "/") $dir = dirname($_SERVER['SCRIPT_NAME']); if(dirname($_SERVER['SCRIPT_NAME']) !== "/") $dir = dirname($_SERVER['SCRIPT_NAME']);
header("Location: http://".$_SERVER['HTTP_HOST'].$dir."/setup.php"); require_once('scripts'.DIRECTORY_SEPARATOR.'proto.inc.php');
header('Location: '.proto()."://{$_SERVER['HTTP_HOST']}$dir/setup.php");
exit;
} }
require_once('.'.DIRECTORY_SEPARATOR.'scripts'.DIRECTORY_SEPARATOR.'prepend.inc.php'); require_once('.'.DIRECTORY_SEPARATOR.'scripts'.DIRECTORY_SEPARATOR.'prepend.inc.php');

View file

@ -11,15 +11,16 @@
error_reporting(E_ALL ^ E_NOTICE); error_reporting(E_ALL ^ E_NOTICE);
header("Content-Type: text/html; charset=UTF-8"); header("Content-Type: text/html; charset=UTF-8");
// defining to avoid notifications
define("JLOG_NEW_VERSION", '1.1.0'); define("JLOG_NEW_VERSION", '1.1.0');
define("JLOG_SETUP", true); define("JLOG_SETUP", true);
define("JLOG_ADMIN", false); define("JLOG_ADMIN", false);
$basepath = dirname( __FILE__ ).DIRECTORY_SEPARATOR; $basepath = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
// defining to avoid notifications require_once('scripts'.DIRECTORY_SEPARATOR.'proto.inc.php');
define("JLOG_WEBSITE", $_SERVER["HTTP_HOST"]); define("JLOG_WEBSITE", $_SERVER["HTTP_HOST"]);
define("JLOG_PATH", dirname("http://".$_SERVER["HTTP_HOST"].$_SERVER["SCRIPT_NAME"])); define("JLOG_PATH", dirname(proto()."://{$_SERVER["HTTP_HOST"]}{$_SERVER["SCRIPT_NAME"]}"));
// read prefered language from browser // read prefered language from browser
$dir = opendir('.'.DIRECTORY_SEPARATOR.'lang'); $dir = opendir('.'.DIRECTORY_SEPARATOR.'lang');
@ -45,7 +46,7 @@
require('.'.DIRECTORY_SEPARATOR.'scripts'.DIRECTORY_SEPARATOR.'url_syntax.php'); require('.'.DIRECTORY_SEPARATOR.'scripts'.DIRECTORY_SEPARATOR.'url_syntax.php');
require('.'.DIRECTORY_SEPARATOR.'scripts'.DIRECTORY_SEPARATOR.'version.inc.php'); require('.'.DIRECTORY_SEPARATOR.'scripts'.DIRECTORY_SEPARATOR.'version.inc.php');
define("JLOG_NEW_VERSION", JLOG_SOFTWARE_VERSION); define("JLOG_NEW_VERSION", JLOG_SOFTWARE_VERSION); // causes warning because of redefinition
define("JLOG_PHPV", JLOG_SOFTWARE_PHPV); define("JLOG_PHPV", JLOG_SOFTWARE_PHPV);
define("JLOG_MYSQLV", JLOG_SOFTWARE_MYSQLV); define("JLOG_MYSQLV", JLOG_SOFTWARE_MYSQLV);
@ -54,6 +55,8 @@
$l['admin']['submit'] = $l['admin']['s_install']; $l['admin']['submit'] = $l['admin']['s_install'];
$setup = new Settings($l); $setup = new Settings($l);
$c = ''; // content to display
if($_POST) { if($_POST) {
$setup->importDataByArray(strip($_POST)); $setup->importDataByArray(strip($_POST));
@ -176,10 +179,13 @@
global $l; global $l;
# FIXME: MySQL has a new API! $connect = new mysqli($data['jlog_db_url'], $data['jlog_db_user'], $data['jlog_db_pwd'], $data['jlog_db']);
if(!@mysql_connect($data['jlog_db_url'], $data['jlog_db_user'], $data['jlog_db_pwd'])) $errors[] = "Falsche Zugangsdaten | ".mysql_error(); if(!$connect) {
elseif(!@mysql_select_db($data['jlog_db'])) $errors[] = "Datenbank ".$data['jlog_db']." extistiert nicht".mysql_error(); $errors[] = "Falsche Zugangsdaten"; // mysqli_error is not available (?)
elseif(!version_compare(mysql_get_server_info(), JLOG_MYSQLV, ">=") == 1) $errors[] = $l['admin']['s_mysqlv_tolow']; }
elseif(!version_compare($connect->server_version, JLOG_MYSQLV, ">=") == 1) {
$errors[] = $l['admin']['s_mysqlv_tolow'];
}
else { else {
new Query("SET NAMES utf8"); new Query("SET NAMES utf8");
$create['content'] = new Query($sql['content']); $create['content'] = new Query($sql['content']);
@ -225,11 +231,11 @@
function do_htmlpage($content) { function do_htmlpage($content) {
return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" return '<!DOCTYPE html>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="'.JLOG_LANGUAGE.'
<html xmlns="http://www.w3.org/1999/xhtml">
<title>SETUP Jlog ' . JLOG_NEW_VERSION . '</title> <title>SETUP Jlog ' . JLOG_NEW_VERSION . '</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="scripts/css/admin.css" type="text/css" /> <link rel="stylesheet" href="scripts/css/admin.css" type="text/css" />
<style type="text/css"> <style type="text/css">
body { body {
@ -238,7 +244,7 @@
font-family: verdana, sans-serif; font-family: verdana, sans-serif;
font-size: 100.01%; font-size: 100.01%;
} }
#container { main {
font-size: 0.9em; font-size: 0.9em;
background: white; background: white;
padding: 20px; padding: 20px;
@ -265,10 +271,10 @@
</style> </style>
</head> </head>
<body> <body>
<div id="container"> <main>
<h1><a href="http://jeenaparadies.net/projects/jlog/" title="Jlog v'.JLOG_NEW_VERSION.'"><img id="logo" src="http://jeenaparadies.net/img/jlog-logo.png" style="width: 210px; height: 120px;" alt="Jlog" /></a> SETUP</h1> <h1><a href="https://github.com/jeena/jlog/" title="Jlog v'.JLOG_NEW_VERSION.'"><img id="logo" src="http://jeenaparadies.net/img/jlog-logo.png" style="width: 210px; height: 120px;" alt="Jlog" /></a> SETUP</h1>
'.$content.' '.$content.'
</div> </main>
</body> </body>
</html>'; </html>';
} }