. */ // This script is disabled by default. Change below to true before running. $enabled = false; /* -------------------------------------------- */ /* no user modifications should be needed below */ if (version_compare(PHP_VERSION, '5.4.0', '<')) { die("Sorry, ulogger will not work with PHP version lower than 5.4 (you have " . PHP_VERSION . ")"); } define("ROOT_DIR", dirname(__DIR__)); require_once(ROOT_DIR . "/helpers/user.php"); require_once(ROOT_DIR . "/helpers/config.php"); require_once(ROOT_DIR . "/lang.php"); $command = isset($_REQUEST['command']) ? $_REQUEST['command'] : NULL; $prefix = preg_replace('/[^a-z0-9_]/i', '', uConfig::$dbprefix); $tPositions = $prefix . "positions"; $tTracks = $prefix . "tracks"; $tUsers = $prefix . "users"; $messages = []; switch ($command) { case "setup": $queries = []; // positions $queries[] = "DROP TABLE IF EXISTS `$tPositions`"; $queries[] = "CREATE TABLE `$tPositions` ( `id` int(11) NOT NULL AUTO_INCREMENT, `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `user_id` int(11) NOT NULL, `track_id` int(11) NOT NULL, `latitude` double NOT NULL, `longitude` double NOT NULL, `altitude` double DEFAULT NULL, `speed` double DEFAULT NULL, `bearing` double DEFAULT NULL, `accuracy` int(11) DEFAULT NULL, `provider` varchar(100) DEFAULT NULL, `comment` varchar(255) DEFAULT NULL, `image_id` int(11) DEFAULT NULL, PRIMARY KEY (`id`), KEY `index_trip_id` (`track_id`), KEY `index_user_id` (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8"; // tracks $queries[] = "DROP TABLE IF EXISTS `$tTracks`"; $queries[] = "CREATE TABLE `$tTracks` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `name` varchar(255) DEFAULT NULL, `comment` varchar(1024) DEFAULT NULL, PRIMARY KEY (`id`), KEY `user_id` (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8"; // users $queries[] = "DROP TABLE IF EXISTS `$tUsers`"; $queries[] = "CREATE TABLE `$tUsers` ( `id` int(11) NOT NULL AUTO_INCREMENT, `login` varchar(15) CHARACTER SET latin1 NOT NULL, `password` varchar(255) CHARACTER SET latin1 NOT NULL DEFAULT '', PRIMARY KEY (`id`), UNIQUE KEY `login` (`login`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8"; $error = false; mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); try { $mysqli = new mysqli(uConfig::$dbhost, uConfig::$dbuser, uConfig::$dbpass, uConfig::$dbname); } catch (mysqli_sql_exception $e ) { $messages[] = "{$langSetup["dbconnectfailed"]}"; $messages[] = sprintf($langSetup["serversaid"], "" . $e->getMessage() . ""); $messages[] = $langSetup["checkdbsettings"]; break; } try { $mysqli->set_charset('utf8'); foreach ($queries as $query) { $mysqli->query($query); } } catch (mysqli_sql_exception $e) { $messages[] = "{$langSetup["dbqueryfailed"]}"; $messages[] = sprintf($langSetup["serversaid"], "" . $e->getMessage() . ""); $error = true; } $mysqli->close(); if (!$error) { $messages[] = "{$langSetup["dbtablessuccess"]}"; $messages[] = $langSetup["setupuser"]; $form = "
"; $form .= ""; $form .= ""; $form .= ""; $form .= "
"; $form .= "
"; $messages[] = $form; } break; case "adduser": $login = isset($_REQUEST['login']) ? $_REQUEST['login'] : NULL; $pass = isset($_REQUEST['pass']) ? $_REQUEST['pass'] : NULL; if (uUser::add($login, $pass) !== false) { $messages[] = "{$langSetup["congratulations"]}"; $messages[] = $langSetup["setupcomplete"]; $messages[] = "{$langSetup["disablewarn"]}
"; $messages[] = sprintf($langSetup["disabledesc"], "\$enabled", "false"); } else { $messages[] = "{$langSetup["setupfailed"]}"; } break; default: $messages[] = "" . $langSetup["welcome"]; if (!isset($enabled) || $enabled === false) { $messages[] = sprintf($langSetup["disabledwarn"], "\$enabled", "true"); $messages[] = sprintf($langSetup["lineshouldread"], "
\$enabled = false;
", "
\$enabled = true;"); $messages[] = $langSetup["dorestart"]; $messages[] = "
"; break; } if (!function_exists('password_hash')) { $messages[] = $langSetup["passfuncwarn"]; $messages[] = $langSetup["passfunchack"]; $messages[] = sprintf($langSetup["lineshouldread"], "
//require_once(ROOT_DIR . \"/helpers/password.php\");
", "
require_once(ROOT_DIR . \"/helpers/password.php\");"); $messages[] = $langSetup["dorestart"]; $messages[] = "
"; break; } if (!uConfig::isFileLoaded()) { $messages[] = $langSetup["createconfig"]; $messages[] = $langSetup["dorestart"]; $messages[] = "
"; break; } if (empty(uConfig::$dbname) || empty(uConfig::$dbhost) || empty(uConfig::$dbuser)) { $messages[] = sprintf($langSetup["nodbsettings"], "\$dbname, \$dbhost, \$dbuser, \$dbpass"); $messages[] = $langSetup["dorestart"]; $messages[] = "
"; break; } $messages[] = sprintf($langSetup["scriptdesc"], "'$tPositions', '$tTracks', '$tUsers'", "" . uConfig::$dbname . ""); $messages[] = $langSetup["scriptdesc2"]; $messages[] = "
"; break; } ?> <?= $lang["title"] ?>