administration.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <?php
  2. /*
  3. *
  4. * OGP - Open Game Panel
  5. * Copyright (C) 2008 - 2018 The OGP Development Team
  6. *
  7. * http://www.opengamepanel.org/
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. *
  23. */
  24. function exec_ogp_module()
  25. {
  26. global $db,$view;
  27. echo "<h2>".get_lang('administration')."</h2>";
  28. echo "<table class='administration-table'>";
  29. ### MAIN ICONS
  30. echo "<tr>\n";
  31. $menus = $db->getMenusForGroup('admin');
  32. foreach ($menus as $key => $row) {
  33. if ( !empty( $row['subpage'] ) )
  34. $name[$key] = $row['subpage'];
  35. else
  36. $name[$key] = $row['module'];
  37. $translation[$key] = get_lang($name[$key]);
  38. }
  39. array_multisort($translation, $name, SORT_DESC, $menus);
  40. $td = 0;
  41. foreach ( $menus as $menu )
  42. {
  43. $module = $menu['module'];
  44. if ( !empty( $menu['subpage'] ) )
  45. {
  46. $subpage = "&amp;p=".$menu['subpage'];
  47. $button = $menu['subpage'];
  48. }
  49. else
  50. {
  51. $subpage = "";
  52. $button = $menu['module'];
  53. }
  54. $button_url = "?m=".$module.$subpage;
  55. if ( preg_match( '/\\_?\\_/', get_lang("$button") ) )
  56. {
  57. $button_name = $menu['menu_name'];
  58. }
  59. else
  60. {
  61. $button_name = get_lang("$button");
  62. }
  63. echo "<td><a class='administration-buttons' href='".$button_url."' /><div><img src='modules/administration/images/$button.png' /><br>$button_name</div></a></td><td class='administration-buttons-hmargin' ></td>\n";
  64. $td++;
  65. if($td == 4)
  66. {
  67. echo "</tr><tr class='administration-buttons-vmargin' ><td></td></tr><tr>\n";
  68. $td = 0;
  69. }
  70. }
  71. echo "<td><a class='administration-buttons' href='?m=administration&p=banlist' />".
  72. "<div><img src='modules/administration/images/banlist.png' /><br>".get_lang('ban_list')."</div></a></td>".
  73. "<td class='administration-buttons-hmargin' ></td>\n";
  74. echo "</tr>\n";
  75. echo "</table>\n";
  76. ### END MAIN ICONS
  77. ### DB BACKUP
  78. echo "<h2>".get_lang('db_backup')."</h2>";
  79. ?>
  80. <table class='administration-table'>
  81. <tr>
  82. <td>
  83. <form method="POST">
  84. <button name="download"><?php print_lang('download_db_backup'); ?></button>
  85. </form>
  86. <br>
  87. <form method="POST" enctype="multipart/form-data">
  88. <label for="file"><?php print_lang('sql_file'); ?>:</label>
  89. <input type="file" name="file" id="file" />
  90. <button name="restore"><?php print_lang('restore_db_backup'); ?></button>
  91. </form>
  92. </td>
  93. </tr>
  94. </table>
  95. <?php
  96. if(isset($_POST['download']))
  97. {
  98. require('includes/config.inc.php');
  99. $randomdir = genRandomString('20');
  100. @mkdir($randomdir);
  101. @chmod($randomdir, 0700);
  102. $file = $db_name . "_" . date("Y-m-d-H-i-s") . '.sql';
  103. $backupFile = $randomdir."/".$file;
  104. $command = "mysqldump --skip-opt --single-transaction --add-drop-table --create-options --extended-insert --quick --set-charset -u $db_user -p$db_pass $db_name > $backupFile";
  105. @system($command);
  106. $view->refresh('?m=administration&p=backupdwl&randir='.$randomdir.'&dwfile='.$file.'&type=cleared', 0);
  107. }
  108. if(isset($_POST['restore']))
  109. {
  110. require('includes/config.inc.php');
  111. $command = "mysql --user=$db_user --password=$db_pass $db_name < ".$_FILES["file"]["tmp_name"];
  112. @system($command);
  113. }
  114. ### END OF DB BACKUP
  115. ### ADD ICONS TO IFRAME FORM.
  116. echo "<h2>".get_lang('external_links')."</h2>";
  117. ?>
  118. <table class='center'>
  119. <td>
  120. <form action="" method=POST ><b><?php print_lang('name'); ?>:</b><input name="name" type=text size=10> <b><?php print_lang('url'); ?>:</b>
  121. <input name="url" type=text size=40>
  122. <input type=submit value='<?php print_lang('add_it'); ?>'>
  123. </form>
  124. </td>
  125. </tr>
  126. </table>
  127. <table class='administration-table'>
  128. <tr>
  129. <?php
  130. if(isset($_POST['url']))
  131. {
  132. $add_link = $db->addAdminExternalLink($_POST['name'],$_POST['url'],$_SESSION['user_id']);
  133. if($add_link == FALSE) print_failure(get_lang('imposible_add_link_this_to_databse'));
  134. }
  135. ### END FOR ADD ICONS TO IFRAME FORM.
  136. ### ICONS TO FRAMES
  137. if(isset($_POST['link_id']))
  138. {
  139. $external_links = $db->delAdminExternalLink($_POST['link_id'],$_SESSION['user_id']);
  140. if($external_links == TRUE)
  141. echo get_lang_f('link_has_been_removed', $_POST['name']);
  142. else
  143. print_failure(get_lang('link_does_not_exist'));
  144. }
  145. echo "<tr>\n";
  146. $external_links = $db->getAdminExternalLinks($_SESSION['user_id']);
  147. $td2 = 0;
  148. if($external_links != 0)
  149. {
  150. foreach ( $external_links as $external_link )
  151. {
  152. $url = $external_link['url'];
  153. $name = $external_link['name'];
  154. $link_id = $external_link['link_id'];
  155. echo "<td>";
  156. echo "<a href='?m=administration&amp;p=iframe&amp;external_link=".$url."' ><img class='administration-buttons' src='modules/administration/images/link.png' /><br>".$name."</a>\n";
  157. echo "<form action='' method='POST' ><input type='hidden' name='name' value='".$name."'><input type='hidden' name='link_id' value='".$link_id."'><input type='image' src='modules/administration/images/remove.gif' class='remove-button' onsubmit=".'"submit-form();"'."></form>";
  158. echo "</td>";
  159. $td2++;
  160. if($td2 == 4)
  161. {
  162. echo "</tr><tr>\n";
  163. $td2 = 0;
  164. }
  165. }
  166. }
  167. echo "</tr>\n".
  168. "</table>\n";
  169. ### END ICONS TO FRAMES
  170. ### CHANGE MENU ORDER
  171. if ( isset( $_POST['changeOrder'] ) )
  172. {
  173. foreach($_POST as $key => $value)
  174. {
  175. if( preg_match( "/^change_button/", $key ) )
  176. {
  177. list($trash,$module_id) = explode("-", $key);
  178. $new_pos = $value;
  179. $db->changeMenuPosition( $module_id, $new_pos );
  180. }
  181. }
  182. }
  183. echo "<h2>".get_lang('change_buttons_order')."</h2>";
  184. echo "<table class='center'>".
  185. "<tr>".
  186. "<form method=POST >";
  187. $menus = $db->getMenusForGroup('user');
  188. $pos = 0;
  189. foreach ( $menus as $menu )
  190. {
  191. $module = $menu['module'];
  192. if ( !empty( $menu['subpage'] ) )
  193. {
  194. $subpage = "&amp;p=".$menu['subpage'];
  195. $button = $menu['subpage'];
  196. if (isset($_GET['p']) AND $_GET['p'] == $menu['subpage'] ) $menu_link_class = 'user_menu_link_selected'; else $menu_link_class = 'user_menu_link';
  197. }
  198. else
  199. {
  200. $subpage = "";
  201. $button = $menu['module'];
  202. if (isset($_GET['m']) AND $_GET['m'] == $menu['module'] ) $menu_link_class = 'user_menu_link_selected'; else $menu_link_class = 'user_menu_link';
  203. }
  204. $button_url = "?m=".$module.$subpage;
  205. if ( preg_match( '/\\_?\\_/', get_lang("$button") ) )
  206. {
  207. $button_name = $menu['menu_name'];
  208. }
  209. else
  210. {
  211. $button_name = get_lang("$button");
  212. }
  213. echo "<td><input type=text name='change_button-".$menu['module_id']."' value=".$menu['pos']." style='text-align:right;width:20px;' > $button_name</input></td>\n";
  214. $pos++;
  215. }
  216. echo "</tr>\n".
  217. "<tr>\n".
  218. "<td colspan=$pos ><input type=submit name=changeOrder value='".get_lang('change_buttons_order')."' />\n".
  219. "</form>\n".
  220. "</td>\n".
  221. "</tr>\n".
  222. "</table>\n";
  223. }
  224. ?>