partstock/pages/edit_config.php

165 lines
7.5 KiB
PHP
Raw Normal View History

2018-12-17 17:50:23 +01:00
<?php
if (UserGetLogin()=="root")
{
//////////////////
//save Config
if ($ToDo=="SaveConfig")
{
//create new config file array
$ConfigFileArray = array();
$ConfigFileArray[count($ConfigFileArray)]=' $CfgStdTemplate = "'.$_POST['CfgStdTemplate'].'";'."\n";
$ConfigFileArray[count($ConfigFileArray)]=' $CfgStdLanguage = "'.$_POST['CfgStdLanguage'].'";'."\n";
$ConfigFileArray[count($ConfigFileArray)]=' $CfgStdTimeZone = "'.$_POST['CfgStdTimeZone'].'";'."\n";
$ConfigFileArray[count($ConfigFileArray)]=' $CfgStdTimeFormat = "'.$_POST['CfgStdTimeFormat'].'";'."\n";
if ( ($_POST['Password1']==$_POST['Password2']) && (trim($_POST['Password1'])) )
{
$ConfigFileArray[count($ConfigFileArray)]=' $CfgRootPassword = "'.md5($_POST['Password1']).'";'."\n";
MessageWarning(LangSpellHtml('SentencePasswordChangedWarning'));
UserLogout();
}
else
{
include "config.php";
$ConfigFileArray[count($ConfigFileArray)] = ' $CfgRootPassword = "'.$CfgRootPassword.'";'."\n";
}
$ConfigFileArray[count($ConfigFileArray)]=' $CfgLogfile = "'.$_POST['CfgLogfile'].'";'."\n";
$ConfigFileArray[count($ConfigFileArray)]=' $CfgLogfileMaxLines = "'.$_POST['CfgLogfileMaxLines'].'";'."\n";
$ConfigFileArray[count($ConfigFileArray)]=' $CfgSetDebugMode = "'.$_POST['CfgSetDebugMode'].'";'."\n";
$ConfigFileArray[count($ConfigFileArray)]=' $CfgMysqlHost = "'.$_POST['CfgMysqlHost'].'";'."\n";
$ConfigFileArray[count($ConfigFileArray)]=' $CfgMysqlUser = "'.$_POST['CfgMysqlUser'].'";'."\n";
$ConfigFileArray[count($ConfigFileArray)]=' $CfgMysqlPwd = "'.$_POST['CfgMysqlPwd'].'";'."\n";
$ConfigFileArray[count($ConfigFileArray)]=' $CfgMysqlDatabase = "'.$_POST['CfgMysqlDatabase'].'";'."\n";
$ConfigFileArray[count($ConfigFileArray)]=' $CfgLoginTimeout = "'.$_POST['CfgLoginTimeout'].'";'."\n";
$ConfigFileArray[count($ConfigFileArray)]=' $CfgLockAutoReleaseTime = "'.$_POST['CfgLockAutoReleaseTime'].'";'."\n";
//save config file
$ConfigFileHandler=fopen("./config.php","w");
fputs($ConfigFileHandler,"<?php\n");
foreach ($ConfigFileArray as $Line)
{
fputs($ConfigFileHandler,$Line);
}
fputs($ConfigFileHandler,"?>\n");
fclose($ConfigFileHandler);
}
include("./includes/load_config.php");
}
if (UserGetLogin()=="root")
{
//////////////////
//global content
include ("config.php");
$GlobalContent.='<form action="index.php?Page=EditConfig&ToDo=SaveConfig" method="post">'."\n";
$GlobalContent.='<table>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <th>CfgStdTemplate</th>'."\n";
$GlobalContent.=' <td><select name="CfgStdTemplate">'."\n";
$AvailableTemplates=OtherGetAvailableTemplates();
foreach ($AvailableTemplates as $x)
{
$GlobalContent.=' <option value="'.$x.'" '.(($x==$CfgStdTemplate)? 'selected':'').'>'.$x.'</option>'."\n";
}
$GlobalContent.=' </select><td>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <th>CfgStdLanguage</th>'."\n";
$GlobalContent.=' <td><select name="CfgStdLanguage">'."\n";
$AvailableTemplates=LangGetAvailableLanguages();
foreach ($AvailableTemplates as $x)
{
$GlobalContent.=' <option value="'.$x.'" '.(($x==$CfgStdLanguage)? 'selected':'').'>'.$x.'</option>'."\n";
}
$GlobalContent.=' </select><td>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <th>CfgStdTimeZone</th>'."\n";
$GlobalContent.=' <td><input type="text" name="CfgStdTimeZone" value="'.$CfgStdTimeZone.'"></td>'."\n";
$GlobalContent.=' <td>'."\n";
$GlobalContent.=' <a href="http://www.php.net/manual/en/timezones.php" title="" target="new">'."\n";
$GlobalContent.=' '.OtherGetIcon('Help',"Button")."\n";
$GlobalContent.=' </a>'."\n";
$GlobalContent.=' </td>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <th>CfgStdTimeFormat</th>'."\n";
$GlobalContent.=' <td><input type="text" name="CfgStdTimeFormat" value="'.$CfgStdTimeFormat.'"></td>'."\n";
$GlobalContent.=' <td>'."\n";
$GlobalContent.=' <a href="http://www.php.net/manual/en/function.date.php" title="" target="new">'."\n";
$GlobalContent.=' '.OtherGetIcon('Help',"Button")."\n";
$GlobalContent.=' </a>'."\n";
$GlobalContent.=' </td>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <th>'.LangSpellHtml('UserSettingsSetNewPassword').'</th>'."\n";
$GlobalContent.=' <td><input type="password" name="Password1" value=""></td>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <th>'.LangSpellHtml('UserSettingsConfirmNewPassword').'</th>'."\n";
$GlobalContent.=' <td><input type="password" name="Password2" value=""></td>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <th>CfgLogfile</th>'."\n";
$GlobalContent.=' <td><input type="text" name="CfgLogfile" value="'.$CfgLogfile.'"></td>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <th>CfgLogfileMaxLines</th>'."\n";
$GlobalContent.=' <td><input type="text" name="CfgLogfileMaxLines" value="'.$CfgLogfileMaxLines.'"></td>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <th>CfgSetDebugMode</th>'."\n";
$GlobalContent.=' <td><select name="CfgSetDebugMode">'."\n";
$GlobalContent.=' <option value="True" '.((strtolower($CfgSetDebugMode)=="true")? "selected":"").'>True</option>'."\n";
$GlobalContent.=' <option value="False" '.((strtolower($CfgSetDebugMode)!="true")? "selected":"").'>False</option>'."\n";
$GlobalContent.=' </select></td>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <th>CfgMysqlHost</th>'."\n";
$GlobalContent.=' <td><input type="text" name="CfgMysqlHost" value="'.$CfgMysqlHost.'"></td>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <th>CfgMysqlUser</th>'."\n";
$GlobalContent.=' <td><input type="text" name="CfgMysqlUser" value="'.$CfgMysqlUser.'"></td>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <th>CfgMysqlPwd</th>'."\n";
$GlobalContent.=' <td><input type="text" name="CfgMysqlPwd" value="'.$CfgMysqlPwd.'"></td>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <th>CfgMysqlDatabase</th>'."\n";
$GlobalContent.=' <td><input type="text" name="CfgMysqlDatabase" value="'.$CfgMysqlDatabase.'"></td>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <th>CfgLoginTimeout</th>'."\n";
$GlobalContent.=' <td><input type="text" name="CfgLoginTimeout" value="'.$CfgLoginTimeout.'"></td>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <th>CfgLockAutoReleaseTime</th>'."\n";
$GlobalContent.=' <td><input type="text" name="CfgLockAutoReleaseTime" value="'.$CfgLockAutoReleaseTime.'"></td>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.=' <th>'.LangSpellHtml('ButtonSave').'</th>'."\n";
$GlobalContent.=' <td><input type="submit" value="'.LangSpellHtml('ButtonSave').'" class="Button"></td>'."\n";
$GlobalContent.=' <tr>'."\n";
$GlobalContent.='</table>'."\n";
$GlobalContent.='</form>'."\n";
}
else
{
MessageError(LangSpell("ScentenceNoUserRights"));
}
?>