Files
Kundenverwaltung/index.php
T
adminandClaude Opus 5 488bc698de Instanzname in die Config, Setup-Luecke geschlossen
Instanz:
- $instanz in der externen Config bestimmt INSTANZ, UPLOADS_PATH und
  SESSION_NAME. Der Verzeichnisname waehlt nur noch die Config-Datei aus
  und ist Fallback, solange $instanz fehlt.
- savePDF() schreibt nicht mehr fest nach DOCUMENT_ROOT."kunden", sondern
  in das Verzeichnis, das es auch aufraeumt. .gitkeep wird nicht mehr
  mitgeloescht.

Sicherheit:
- index.php?action=setup war ohne Login auch bei gueltiger Config
  erreichbar. rebuild-settings.php schrieb $_POST ungeprueft als PHP-Code
  in die Config (Codeausfuehrung, sofern die Datei schreibbar war).
- Setup nur noch ohne gueltige Config, firststart.php und
  rebuild-settings.php pruefen das zusaetzlich selbst.
- Config-Werte werden per var_export() maskiert.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-17 08:44:33 +02:00

115 lines
3.2 KiB
PHP

<?php
require_once("incs/constants.php");
session_name(SESSION_NAME);
session_start();
error_reporting(E_ERROR | E_PARSE);
ini_set("display_errors", "1");
require('./smarty/libs/Smarty.class.php');
setlocale(LC_TIME,"de_DE.utf8");
$smarty = new Smarty;
if(isset($_GET["action"]))
$action = $_GET["action"];
else
$action = "";
if($action=="rechnungadd"){
require_once('./incs/PHPMailer_v6/src/PHPMailer.php');
require_once('./incs/PHPMailer_v6/src/SMTP.php');
require_once('./incs/PHPMailer_v6/src/Exception.php');
}
require_once("update/database-update.php");
require_once("incs/settings.php");
require_once("incs/update.php");
require_once("incs/funcs.php");
require_once("incs/users.php");
require_once("incs/authHelper.php");
PopulateSessionVars();
$errors = array();
$warnings = array();
$messages = array();
$version = getthisversion();
if($version == -1)
{
$errors[] = "Versions-datei kann nicht beschrieben werden, bitte setzen Sie Schreibrechte für das Verzeichnis update/thisversion/";
}
$settings=readsettings();
// Die Ersteinrichtung schreibt die Config neu und kann die Datenbank leeren.
// Sie läuft ohne Login und darf deshalb nur erreichbar sein, solange es
// noch keine gültige Config gibt.
if($settings != "valid")
$action = "setup";
else if($action == "setup")
$action = "";
if($settings == "valid" && $action != "setup")
{
if(!$dbconn = @mysqli_connect($mysql_server, $mysql_user, $mysql_pw))
$err = error("Verbindung zur Datenbank fehlgeschlagen!!");
if(!@mysqli_select_db($dbconn,$mysql_db))
$err = error("Datenbank nicht gefunden!! ($mysql_db)");
$newversion = checknewversion($version);
$status = manageupdate($version, $newversion);
$version = $status[1];
}
$_SESSION["dbconn"] = $dbconn;
$qry = mysqli_query($dbconn,"SELECT id FROM termin WHERE termtime = '0000-00-00 00:00:00' AND (act_date = '0000-00-00 00:00:00' OR act_date < NOW()) AND DATE(datetime) > DATE(DATE_SUB(NOW(), INTERVAL 1 YEAR))");
$unterminiert = mysqli_num_rows($qry);
$qry = mysqli_query($dbconn,"SELECT id FROM termin WHERE DATE_FORMAT(termtime,'%Y-%m-%d') = DATE_FORMAT(NOW(),'%Y-%m-%d') AND done = 0");
$heute = mysqli_num_rows($qry);
include("incs/mysql_ecape_wrapper.php");
$text_version = substr($version, 0, 1).".".substr($version, 1, 1).".".substr($version, 2, 1);
$smarty->assign("SWfirma",$firma);
$_SESSION["firma"] = $firma;
$smarty->assign("text_version",$text_version);
$smarty->display('head.tpl');
if($_SESSION["login"] == "valid")
{
include(checkRightsNInclude());
}
else
{
switch($action)
{
case "setup":
include "./update/firststart.php";
break;
default:
include "./sites/start.php";
break;
}
}
/*
echo <<<ENDE
<!-- another link. uses the same overlay -->
<a href="external-content2.htm" class="noloading" rel="#overlay" style="text-decoration:none">
<button type="button">Show another page</button>
</a>
ENDE;
*/
$termine="<a href='?action=termin&show=list&tabs=2'>".str_pad($unterminiert, 1, '0')." nicht terminiert</a> &nbsp;/&nbsp; <a href='?action=termin'>".str_pad($heute, 1, '0')." heute</a>";
$smarty->assign("termine",$termine);
//$smarty->display("greetings.tpl");
//include("update/firststart.php");
$smarty->display('foot.tpl');
?>