/usb/Uniform_Server/releases/UniServer5_7_LabsXooFoo/UniServer/home/admin/www/msd/inc/configuration/config_files.php

https://github.com/krisxoofoo/XooFoo · PHP · 206 lines · 177 code · 10 blank · 19 comment · 28 complexity · fd5fe4f04312d16f49977eb55f9d74ea MD5 · raw file

  1. <?php
  2. /**
  3. * This file is part of MySQLDumper released under the GNU/GPL 2 license
  4. * http://www.mysqldumper.net
  5. *
  6. * @package MySQLDumper
  7. * @version SVN: $rev: 1207 $
  8. * @author $Author$
  9. * @lastmodified $Date$
  10. */
  11. if (!defined('MSD_VERSION')) die('No direct access.');
  12. $oldConfig = $config['config_file'];
  13. if (isset($_GET['config'])) {
  14. $oldDatabases = $databases;
  15. $databases = array();
  16. if (isset($_POST['save'])) {
  17. unset($_POST['save']);
  18. }
  19. if (getConfig($_GET['config'])) {
  20. $config['config_file'] = $_GET['config'];
  21. $_SESSION['config_file'] = $_GET['config'];
  22. $oldConfig = $_GET['config'];
  23. $msg = '<p class="success">'
  24. . sprintf($lang['L_CONFIG_LOADED'], $config['config_file'])
  25. . '</p>';
  26. } else {
  27. getConfig($oldConfig);
  28. $databases = $oldDatabases;
  29. $msg = '<p class="error">'
  30. . sprintf(
  31. $lang['L_ERROR_LOADING_CONFIGFILE'],
  32. $config['config_file']
  33. ) . '</p>';
  34. }
  35. }
  36. if (isset($_GET['config_delete'])) {
  37. $deleteConfig = urldecode($_GET['config_delete']);
  38. if ($deleteConfig == $config['config_file']) {
  39. //actaul configuration was deleted, fall back to mysqldumper-conf
  40. $config['config_file'] = 'mysqldumper';
  41. $_SESSION['config_file'] = $config['config_file'];
  42. getConfig($config['config_file']);
  43. }
  44. $del = @unlink('./' . $config['paths']['config'] . $deleteConfig . '.php');
  45. if ($del) {
  46. // delete Perl config file
  47. $delFile = $config['paths']['config'] . $deleteConfig . '.conf.php';
  48. $del = @unlink('./' . $delFile);
  49. }
  50. if ($del === false) {
  51. $msg = '<p class="error">'
  52. . sprintf($lang['L_ERROR_DELETING_CONFIGFILE'], $deleteConfig)
  53. . '</p>';
  54. } else {
  55. $msg = '<p class="success">'
  56. . sprintf($lang['L_SUCCESS_DELETING_CONFIGFILE'], $deleteConfig)
  57. . '</p>';
  58. }
  59. $sel = 'configs';
  60. }
  61. $tplConfigurationConfigFiles = new MSDTemplate();
  62. $tplConfigurationConfigFiles->set_filenames(
  63. array(
  64. 'tplConfigurationConfigFiles' => 'tpl/configuration/configFiles.tpl'
  65. )
  66. );
  67. $tplConfigurationConfigFiles->assign_vars(
  68. array(
  69. 'ICON_SAVE' => $icon['small']['save'],
  70. 'ICON_SEARCH' => $icon['search'],
  71. 'ICON_EDIT' => $icon['edit'],
  72. 'ICON_DELETE' => $icon['delete']
  73. )
  74. );
  75. $i = 0;
  76. $configs = getConfigFilenames();
  77. // iterate config files and print settings to screen
  78. foreach ($configs as $c) {
  79. $i++;
  80. unset($databases);
  81. $databases = array();
  82. getConfig($c);
  83. $rowclass = ($i % 2) ? 'dbrow' : 'dbrow1';
  84. if ($oldConfig == $c) {
  85. $rowclass = 'dbrowsel'; // highlight active configuration
  86. }
  87. // Generate configuration output
  88. $outputstringMultisettings = '';
  89. $dbsToBackup = array();
  90. // look up which databases are set to be dumped
  91. prepareDumpProcess();
  92. $dbs = array_keys($dump['databases']);
  93. $dbsToBackup = implode(', ', $dbs);
  94. $tplConfigurationConfigFiles->assign_block_vars(
  95. 'ROW',
  96. array(
  97. 'ROWCLASS' => $rowclass,
  98. 'NR' => $i,
  99. 'CONFIG_ID' => sprintf("%03d", $i),
  100. 'CONFIG_NAME' => $c,
  101. 'CONFIG_NAME_URLENCODED' => urlencode($c),
  102. 'DB_HOST' => $config['dbhost'],
  103. 'DB_USER' => $config['dbuser'],
  104. 'NR_OF_DATABASES' => sizeof($databases),
  105. 'DBS_TO_BACKUP' => $dbsToBackup . '&nbsp;',
  106. 'ATTACH_BACKUP' =>
  107. $config['email']['attach_backup'] == 1 ?
  108. $lang['L_YES'] : $lang['L_NO']
  109. )
  110. );
  111. if (count($databases) > 0) {
  112. $a = 1;
  113. foreach ($databases as $dbName => $val) {
  114. $tplConfigurationConfigFiles->assign_block_vars(
  115. 'ROW.LIST_DBS',
  116. array(
  117. 'ROWCLASS' => $a % 2 ? 'dbrow' : 'dbrow1',
  118. 'NR' => $a,
  119. 'DB_NAME_URLENCODED' => base64_encode($dbName),
  120. 'DB_NAME' => $dbName
  121. )
  122. );
  123. $a++;
  124. }
  125. }
  126. // is Multipart used?
  127. if ($config['multi_part'] == 1) {
  128. $tplConfigurationConfigFiles->assign_block_vars(
  129. 'ROW.USE_MULTIPART',
  130. array(
  131. 'MULTIPART_FILESIZE' =>
  132. byteOutput($config['multipart_groesse'])
  133. )
  134. );
  135. }
  136. // send mail after backup?
  137. if ($config['send_mail'] == 1) {
  138. $recipientsCc = implodeSubarray(
  139. $config['email']['recipient_cc'],
  140. 'address'
  141. );
  142. if ($config['email']['recipient_name'] > '') {
  143. $recipient = $config['email']['recipient_name'];
  144. } else {
  145. $recipient = $config['email']['recipient_address'];
  146. }
  147. $tplConfigurationConfigFiles->assign_block_vars(
  148. 'ROW.SEND_EMAIL',
  149. array(
  150. 'RECIPIENT' => $recipient,
  151. 'RECIPIENT_CC' =>
  152. $recipientsCc > '' ? $recipientsCc : $lang['L_NO']
  153. )
  154. );
  155. $bytes = $config['email_maxsize1'] * 1024;
  156. if ($config['email_maxsize2'] == 2) $bytes = $bytes * 1024;
  157. if ($config['email']['attach_backup'] == 1) {
  158. $tplConfigurationConfigFiles->assign_block_vars(
  159. 'ROW.SEND_EMAIL.EMAIL_MAX_SIZE',
  160. array(
  161. 'SIZE' => byteOutput($bytes)
  162. )
  163. );
  164. }
  165. }
  166. // FTP settings
  167. foreach ($config['ftp'] as $ftp) {
  168. if ($ftp['transfer'] > 0) {
  169. $ftpSettings = sprintf(
  170. $lang['L_FTP_SEND_TO'], $ftp['server'], $ftp['dir']
  171. );
  172. $tplConfigurationConfigFiles->assign_block_vars(
  173. 'ROW.SEND_FTP',
  174. array(
  175. 'FTP_SETTINGS' => Html::replaceQuotes($ftpSettings)
  176. )
  177. );
  178. }
  179. }
  180. // Show delete-button if it is not the standard config file
  181. if ($c != 'mysqldumper') {
  182. $confirmDelete = sprintf($lang['L_CONFIRM_CONFIGFILE_DELETE'], $c);
  183. $tplConfigurationConfigFiles->assign_block_vars(
  184. 'ROW.DELETE_CONFIG',
  185. array(
  186. 'CONFIRM_DELETE' => Html::getJsQuote($confirmDelete)
  187. )
  188. );
  189. }
  190. }
  191. unset($databases);
  192. $databases = array();
  193. $_SESSION['config_file'] = $oldConfig;
  194. $config['config_file'] = $oldConfig;
  195. // reload actual configuration
  196. getConfig($oldConfig);