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

Move config files to a dedicated directory #892

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
18 changes: 9 additions & 9 deletions install.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms
$db[\'dbname\']=\''.$dbname.'\';
?>';

if(!is_writable('./other/dbconfig.php')) {
if(!is_writable('./configs/dbconfig.php')) {
$err_msg = $lang['isntwicfg'];
$err_lvl = 2;
} else {
Expand Down Expand Up @@ -483,7 +483,7 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms
$err_msg = sprintf($lang['instdbsuc'], $dbname); $err_lvl = NULL;
$install_webuser = 1;

$dbconfig = fopen('./other/dbconfig.php','w');
$dbconfig = fopen('./configs/dbconfig.php','w');
if(!fwrite($dbconfig, $newconfig)) {
$err_msg = $lang['isntwicfg'];
$err_lvl = 2;
Expand Down Expand Up @@ -520,7 +520,7 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms
}
}

if(!is_writable('./other/dbconfig.php')) {
if(!is_writable('./configs/dbconfig.php')) {
$err_msg = $lang['isntwicfg'];
$err_lvl = 2;
}
Expand All @@ -540,7 +540,7 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms
}

if(isset($_POST['confweb'])) {
require_once('other/dbconfig.php');
require_once('configs/dbconfig.php');
$user=$_POST['user'];
$pass=password_hash($_POST['pass'], PASSWORD_DEFAULT);
$logpath = addslashes(__DIR__.DIRECTORY_SEPARATOR."logs".DIRECTORY_SEPARATOR);
Expand Down Expand Up @@ -688,7 +688,7 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms
unset($err_msg);
unset($err_lvl);
$err_msg = '';
if(!is_writable('./other/dbconfig.php')) {
if(!is_writable('./configs/dbconfig.php')) {
$err_msg = $lang['isntwicfg']; $err_lvl = 3;
}

Expand Down Expand Up @@ -753,16 +753,16 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms
unset($err_msg); $err_msg = sprintf($lang['insterr3'],'exec','//php.net/manual/en/book.exec.php',get_cfg_var('cfg_file_path')); $err_lvl = 3;
} else {
if ($err_msg == NULL) {
require_once('other/phpcommand.php');
require_once('configs/phpcommand.php');
exec("$phpcommand -v", $phpversioncheck);
$output = '';
foreach($phpversioncheck as $line) $output .= print_r($line, true).'<br>';
if(empty($phpversioncheck) || strtoupper(substr($phpversioncheck[0], 0, 3)) != "PHP") {
$err_msg .= sprintf($lang['chkphpcmd'], "\"other/phpcommand.php\"", "<u>\"other/phpcommand.php\"</u>", '<pre>'.$phpcommand.'</pre>', '<pre>'.$output.'</pre><br><br>', '<pre>php -v</pre>'); $err_lvl = 3;
$err_msg .= sprintf($lang['chkphpcmd'], "\"configs/phpcommand.php\"", "<u>\"configs/phpcommand.php\"</u>", '<pre>'.$phpcommand.'</pre>', '<pre>'.$output.'</pre><br><br>', '<pre>php -v</pre>'); $err_lvl = 3;
} else {
$exploded = explode(' ',$phpversioncheck[0]);
if($exploded[1] != phpversion()) {
$err_msg .= sprintf($lang['chkphpmulti'], phpversion(), "<u>\"other/phpcommand.php\"</u>", $exploded[1], "\"other/phpcommand.php\"</u>", "\"other/phpcommand.php\"</u>", '<pre>'.$phpcommand.'</pre>');
$err_msg .= sprintf($lang['chkphpmulti'], phpversion(), "<u>\"configs/phpcommand.php\"</u>", $exploded[1], "\"configs/phpcommand.php\"</u>", "\"configs/phpcommand.php\"</u>", '<pre>'.$phpcommand.'</pre>');
if(getenv('PATH')!='') {
$err_msg .= "<br><br>".sprintf($lang['chkphpmulti2'], '<br>'.getenv('PATH')); $err_lvl = 2;
}
Expand Down Expand Up @@ -1072,4 +1072,4 @@ function install($type, $host, $user, $pass, $dbname, $lang, $mysqlcon, &$err_ms
});
</script>
</body>
</html>
</html>
4 changes: 2 additions & 2 deletions jobs/check_db.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function check_double_cldbid($mysqlcon,$cfg,$dbname) {
function set_new_version($mysqlcon,$cfg,$dbname) {
if($mysqlcon->exec("INSERT INTO `$dbname`.`cfg_params` (`param`,`value`) VALUES ('version_current_using','{$cfg['version_latest_available']}') ON DUPLICATE KEY UPDATE `value`=VALUES(`value`)") === false) {
enter_logfile(1," An error happens due updating the Ranksystem Database:".print_r($mysqlcon->errorInfo(), true));
shutdown($mysqlcon,1," Check the database connection and properties in other/dbconfig.php and check also the database permissions.");
shutdown($mysqlcon,1," Check the database connection and properties in configs/dbconfig.php and check also the database permissions.");
} else {
$cfg['version_current_using'] = $cfg['version_latest_available'];
enter_logfile(4," Database successfully updated!");
Expand Down Expand Up @@ -555,4 +555,4 @@ function check_writable($cfg,$mysqlcon) {
if(isset($updatedone) && $updatedone === TRUE) return TRUE;
return FALSE;
}
?>
?>
31 changes: 29 additions & 2 deletions jobs/update_rs.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function update_rs($mysqlcon,$lang,$cfg,$dbname,$norotate=NULL) {
if(!is_dir(dirname(__DIR__).DIRECTORY_SEPARATOR.$thisFileName)) {
$contents = $zip->getFromName($thisFileName);
$updateThis = '';
if($thisFileName == 'other/dbconfig.php' || $thisFileName == 'install.php' || $thisFileName == 'other/phpcommand.php' || $thisFileName == 'logs/autostart_deactivated') {
if($thisFileName == 'configs/dbconfig.php' || $thisFileName == 'install.php' || $thisFileName == 'configs/phpcommand.php' || $thisFileName == 'logs/autostart_deactivated') {
enter_logfile(5," Did not touch ".$thisFileName,$norotate);
} else {
if(($updateThis = fopen(dirname(__DIR__).DIRECTORY_SEPARATOR.$thisFileName, 'w')) === false) {
Expand Down Expand Up @@ -141,6 +141,33 @@ function update_rs($mysqlcon,$lang,$cfg,$dbname,$norotate=NULL) {
$countwrongfiles++;
}

/**
* Migrate config files when necessary from `other/` to `configs/`.
*/
foreach (['dbconfig.php', 'phpcommand.php'] as $config_file) {
$config_file_source_path = dirname(__DIR__).DIRECTORY_SEPARATOR.'other'.DIRECTORY_SEPARATOR.$config_file;
$config_file_destination_path = dirname(__DIR__).DIRECTORY_SEPARATOR.'configs'.DIRECTORY_SEPARATOR.$config_file;

enter_logfile(4," Migrating config file '$config_file_source_path' to '$config_file_destination_path'...",$norotate);

if (! is_file($config_file_source_path)) {
enter_logfile(4," The config file '$config_file' is already migrated. Nothing todo.",$norotate);
continue;
}

if (! copy($config_file_source_path, $config_file_destination_path)) {
enter_logfile(3," Failed to copy the config file '$config_file' to the new target directory (see above). Please move this file manually.",$norotate);
continue;
}

if (! unlink($config_file_source_path)) {
enter_logfile(3," Failed to delete the config file '$config_file' from the old directory (see above). Please delete this file manually.",$norotate);
continue;
}

enter_logfile(5," Successfully migrated the config file '$config_file'.",$norotate);
}

if(!unlink(dirname(__DIR__).DIRECTORY_SEPARATOR.'update'.DIRECTORY_SEPARATOR.'ranksystem_'.$cfg['version_latest_available'].'.zip')) {
enter_logfile(3," Could not clean update folder. Please remove the unneeded file ".dirname(__DIR__).DIRECTORY_SEPARATOR."update".DIRECTORY_SEPARATOR."ranksystem_".$cfg['version_latest_available'].".zip",$norotate);
} else {
Expand Down Expand Up @@ -172,4 +199,4 @@ function update_rs($mysqlcon,$lang,$cfg,$dbname,$norotate=NULL) {

$sqlexec .= "UPDATE `$dbname`.`job_check` SET `timestamp`='$nowtime' WHERE `job_name`='get_version';\n";
return($sqlexec);
}
}
6 changes: 3 additions & 3 deletions languages/core_ar_العربية_arab.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
$lang['insterr2'] = "%1\$s is needed but seems not to be installed. Install <a href=\"%2\$s\" target=\"_blank\">%1\$s</a> and try it again!<br>Path to your PHP config file, if one is defined and loaded: %3\$s";
$lang['insterr3'] = "PHP %1\$s function is needed to be enabled but seems to be disabled. Please enable the PHP <a href=\"%2\$s\" target=\"_blank\">%1\$s</a> function and try it again!<br>Path to your PHP config file, if one is defined and loaded: %3\$s";
$lang['insterr4'] = "Your PHP version (%s) is below 5.5.0. Update your PHP and try it again!";
$lang['isntwicfg'] = "Can't save the database configuration! Please edit the 'other/dbconfig.php' with a chmod 740 (on windows 'full access') and try again after.";
$lang['isntwicfg'] = "Can't save the database configuration! Please edit the 'configs/dbconfig.php' with a chmod 740 (on windows 'full access') and try again after.";
$lang['isntwicfg2'] = "Configurate Webinterface";
$lang['isntwichm'] = "Write Permissions failed on folder \"%s\". Please give them a chmod 740 (on windows 'full access') and try to start the Ranksystem again.";
$lang['isntwiconf'] = "Open the %s to configure the Ranksystem!";
Expand Down Expand Up @@ -461,7 +461,7 @@
$lang['wiconferr'] = "There is an error in the configuration of the Ranksystem. Please go to the webinterface and correct the rank settings!";
$lang['widaform'] = "نظام التاريخ";
$lang['widaformdesc'] = "اختر كيفية ضهور التاريخ.<br><br>Example:<br>%a ايام, %h ساعات, %i دقائق, %s ثوان";
$lang['widbcfgerr'] = "'other/dbconfig.php'خلل عند حفظ تعديلات قاعدة البيانات فشل الاتصال مع ";
$lang['widbcfgerr'] = "'configs/dbconfig.php'خلل عند حفظ تعديلات قاعدة البيانات فشل الاتصال مع ";
$lang['widbcfgsuc'] = "تعديلات قاعدة البيانات حفظت بنجاح";
$lang['widbg'] = "Log-Level";
$lang['widbgdesc'] = "Set up the Log-Level of the Ranksystem. With this you can decide, how much information should be written to the file \"ranksystem.log\"<br><br>The higher the Log-Level, the more information you'll get.<br><br>Changing the Log-Level will take effect with the next restart of the Ranksystem bot.<br><br>Please don't let the Ranksystem running longer on \"6 - DEBUG\" this could impair your filesystem!";
Expand Down Expand Up @@ -705,4 +705,4 @@
$lang['wiverifydesc'] = "Enter here the channel-ID of the verification channel.<br><br>This channel need to be set up <u>manual</u> on your TeamSpeak server. Name, permissions and other properties could be defined for your choice; only user should be possible to join this channel!<br><br>The verification is done by the respective user himself on the statistics-page (/stats/). This is only necessary if the website visitor can't automatically be matched/related with the TeamSpeak user.<br><br>To verify the TeamSpeak user, he has to be in the verification channel. There he is able to receive a token with which he can verify himself for the statistics page.";
$lang['wivlang'] = "Language";
$lang['wivlangdesc'] = "Choose a default language for the Ranksystem.<br><br>The language is also selectable on the websites for the users and will be stored for the session.";
?>
?>
6 changes: 3 additions & 3 deletions languages/core_az_Azərbaycan_az.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
$lang['insterr2'] = "%1\$s tələb olunur, lakin quraşdırılmamışdır. Yüklə <a href=\"%2\$s\" target=\"_blank\">%1\$s</a> və yenidən cəhd edin!<br>Path to your PHP config file, if one is defined and loaded: %3\$s";
$lang['insterr3'] = "PHP %1\$s function is needed to be enabled but seems to be disabled. Please enable the PHP <a href=\"%2\$s\" target=\"_blank\">%1\$s</a> function and try it again!<br>Path to your PHP config file, if one is defined and loaded: %3\$s";
$lang['insterr4'] = "PHP versiyanız (%s) 5.5.0-dən aşağıdır. PHP-ni yeniləyin və yenidən cəhd edin!";
$lang['isntwicfg'] = "Verilənlər bazası konfiqurasiyasını saxlaya bilmir! Tam yazma icazələrini təyin edin 'other/dbconfig.php' (Linux: chmod 740; Windows: 'full access') və sonra yenidən cəhd edin.";
$lang['isntwicfg'] = "Verilənlər bazası konfiqurasiyasını saxlaya bilmir! Tam yazma icazələrini təyin edin 'configs/dbconfig.php' (Linux: chmod 740; Windows: 'full access') və sonra yenidən cəhd edin.";
$lang['isntwicfg2'] = "Veb-interfeysin konfiqurasiyası";
$lang['isntwichm'] = "\"%s\" qovluğunda qeyd icazəsi yoxdur. Tam hüquqlar verin (Linux: chmod 740; Windows: 'full access') və Ranksystem'i yenidən başlatmağa çalışın.";
$lang['isntwiconf'] = "Ranksystem'i konfiqurasiya etmək üçün %s açın!";
Expand Down Expand Up @@ -461,7 +461,7 @@
$lang['wiconferr'] = "Ranksystem-in konfiqurasiyasında bir səhv var. Veb-interfeysə keçin və rank parametrləri düzəlt!";
$lang['widaform'] = "Tarix formatı";
$lang['widaformdesc'] = "Göstərilən tarix formatını seçin.<br><br>Məsələn:<br>%a gün, %h saat, %i dəqiqə, %s saniyə";
$lang['widbcfgerr'] = "Verilənlər bazası konfiqurasiyaları qənaət edərkən səhv baş verdi! 'other/dbconfig.php' bağlantısı uğursuz oldu.";
$lang['widbcfgerr'] = "Verilənlər bazası konfiqurasiyaları qənaət edərkən səhv baş verdi! 'configs/dbconfig.php' bağlantısı uğursuz oldu.";
$lang['widbcfgsuc'] = "Verilənlər bazası konfiqurasiyaları uğurla qeyd edildi.";
$lang['widbg'] = "Log Səviyyəsi";
$lang['widbgdesc'] = "Sıralama sistemi log səviyyəsi seçin. Bununla siz \"ranksystem.log\" faylına neçə məlumatın yazılmasına qərar verə bilərsiniz.<br><br>Giriş səviyyəsinin nə qədər yüksək olduğu halda daha çox məlumat alacaqsınız.<br><br>Giriş Səviyyəsinin dəyişdirilməsi Ranksystem botun yenidən başlaması ilə qüvvəyə çatır.<br><br>Xahiş edirik Ranksystem-ın \"6 - DEBUG\" üzərindən daha uzun müddət çalışmasına imkan verməyin, bu sizin fayl sisteminizə zərbə vuracaq!";
Expand Down Expand Up @@ -705,4 +705,4 @@
$lang['wiverifydesc'] = "Burada doğrulama kanalının kanal ID daxil edin.<br><br>Bu kanalın qurulması lazımdır. <u>Əl ilə</u> qurmalısız. Ad, icazələr və digər xüsusiyyətlər sizin seçiminizlə müəyyənləşdirilə bilər; yalnız istifadəçi bu kanala qoşulmalıdır!<br><br>Verifikasiya statistik məlumat səhifəsində müvafiq istifadəçi tərəfindən həyata keçirilir (/stats/). Bu, yalnız veb interfeysin istifadəçisinin, TeamSpeak istifadəçisiyle avtomatik olaraq eşleşmemesi / uyğunlaşmaması lazımdır.<br><br>TeamSpeak istifadəçisini yoxlamaq üçün yoxlama kanalında olmalıdır. O, özü statistika səhifəsi üçün özünü təsdiqləyə biləcək bir möcüzə ala bilir.";
$lang['wivlang'] = "Dil";
$lang['wivlangdesc'] = "Rank Sistemi üçün standart bir dil seçin.<br><br>Dil, həmçinin istifadəçilər üçün saytlarda seçilə bilər və sessiya üçün saxlanacaq.";
?>
?>
6 changes: 3 additions & 3 deletions languages/core_cz_Čeština_cz.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
$lang['insterr2'] = "%1\$s je potřebný k instalaci, ale není nainstalován! Nainstalujte ho pomocí <a href=\"%2\$s\" target=\"_blank\">%1\$s</a> a zkuste to znovu!<br>Path to your PHP config file, if one is defined and loaded: %3\$s";
$lang['insterr3'] = "PHP %1\$s function is needed to be enabled but seems to be disabled. Please enable the PHP <a href=\"%2\$s\" target=\"_blank\">%1\$s</a> function and try it again!<br>Path to your PHP config file, if one is defined and loaded: %3\$s";
$lang['insterr4'] = "Vaše PHP verze (%s) je nižší než 5.5.0. Prosím aktulizujte PHP a zkuste to znovu!";
$lang['isntwicfg'] = "Nemohu uložit konfiguraci do databáze! Prosím přidělte všechna práva souboru 'other/dbconfig.php' (Linux: chmod 740; Windows: 'full access') a zkuste to znovu!";
$lang['isntwicfg'] = "Nemohu uložit konfiguraci do databáze! Prosím přidělte všechna práva souboru 'configs/dbconfig.php' (Linux: chmod 740; Windows: 'full access') a zkuste to znovu!";
$lang['isntwicfg2'] = "Nakonfigurujte webinterface";
$lang['isntwichm'] = "Práva pro zápis do složky \"%s\" nejsou plná! Prosím přidělte všechna práva pomocí (Linux: chmod 740; Windows: 'full access') a aktulizujte (obnovte- F5) stránku.";
$lang['isntwiconf'] = "Otevřete %s pro nastavení Ranksystemu.";
Expand Down Expand Up @@ -461,7 +461,7 @@
$lang['wiconferr'] = "Došlo k chybě v konfiguraci systému Ranks. Přejděte na webové rozhraní a opravte nastavení jádra. Zvláště zkontrolujte konfiguraci 'rank'!";
$lang['widaform'] = "Časový formát";
$lang['widaformdesc'] = "Vyberte formát zobrazení data.<br><br>Příklad:<br>% a dny,% h hodiny,% i mins,% s secs";
$lang['widbcfgerr'] = "Chyba při ukládání konfigurací databáze! Připojení selhalo nebo chyba zápisu pro 'other / dbconfig.php'";
$lang['widbcfgerr'] = "Chyba při ukládání konfigurací databáze! Připojení selhalo nebo chyba zápisu pro 'configs/dbconfig.php'";
$lang['widbcfgsuc'] = "Databázové konfigurace byly úspěšně uloženy.";
$lang['widbg'] = "Log-Level";
$lang['widbgdesc'] = "Set up the Log-Level of the Ranksystem. With this you can decide, how much information should be written to the file \"ranksystem.log\"<br><br>The higher the Log-Level, the more information you'll get.<br><br>Changing the Log-Level will take effect with the next restart of the Ranksystem bot.<br><br>Please don't let the Ranksystem running longer on \"6 - DEBUG\" this could impair your filesystem!";
Expand Down Expand Up @@ -706,4 +706,4 @@
$lang['wiverifydesc'] = "Enter here the channel-ID of the verification channel.<br><br>This channel need to be set up <u>manual</u> on your TeamSpeak server. Name, permissions and other properties could be defined for your choice; only user should be possible to join this channel!<br><br>The verification is done by the respective user himself on the statistics-page (/stats/). This is only necessary if the website visitor can't automatically be matched/related with the TeamSpeak user.<br><br>To verify the TeamSpeak user, he has to be in the verification channel. There he is able to receive a token with which he can verify himself for the statistics page.";
$lang['wivlang'] = "Jazyk";
$lang['wivlangdesc'] = "Nastavte hlavní jazyk pro Ranksystem<br><br>Jazyk můžete kdykoliv změnit.";
?>
?>
Loading