Advertisement
Guest User

Untitled

a guest
Jun 1st, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.71 KB | None | 0 0
  1. <?php
  2. /*
  3. *
  4. * OGP - Open Game Panel
  5. * Copyright (C) Copyright (C) 2008 - 2013 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.  
  25. require_once("modules/config_games/server_config_parser.php");
  26. require_once("includes/funkciok.php");
  27.  
  28. function exec_ogp_module()
  29. {
  30. global $db;
  31. $isAdmin = $db->isAdmin( $_SESSION['user_id'] );
  32. $home_id = $_GET['home_id'];
  33.  
  34. if( $isAdmin )
  35. $game_home['access_rights'] = "ufpetc";
  36. else
  37. $game_home = $db->getUserGameHome($_SESSION['user_id'],$home_id);
  38.  
  39. if ( !$game_home and !$isAdmin )
  40. return;
  41.  
  42. $submit = isset($_REQUEST['submit']) ? $_REQUEST['submit'] : "";
  43.  
  44. $home_info = $db->getGameHomeWithoutMods($home_id);
  45. $home_id = $home_info['home_id'];
  46. $enabled_mods = $db->getHomeMods($home_id);
  47.  
  48. if( $isAdmin and isset( $_POST['change_home_cfg_id'] ) )
  49. {
  50. if( !empty($enabled_mods) )
  51. {
  52. foreach ( $enabled_mods as $enabled_rows )
  53. {
  54. $db->delGameMod($enabled_rows['mod_id']);
  55. }
  56. }
  57. $home_cfg_id = $home_info['home_cfg_id'];
  58. $new_home_cfg_id = $_POST['home_cfg_id'];
  59. if($db->updateHomeCfgId($home_id, $new_home_cfg_id))
  60. {
  61. echo json_encode(array('result' => 'success', 'info' => successfully_changed_game_server));
  62. $db->logger( successfully_changed_game_server ." HOME ID:$home_id - ". change_game_type .":old home_cfg_id:$home_cfg_id, new home_cfg_id:$new_home_cfg_id");
  63. }
  64. else
  65. echo json_encode(array('result' => 'failure', 'info' => 'Error while updating game type.'));
  66. return;
  67. }
  68.  
  69. $server_xml = read_server_config(SERVER_CONFIG_LOCATION.$home_info['home_cfg_file']);
  70. include('includes/lib_remote.php');
  71. $remote = new OGPRemoteLibrary($home_info['agent_ip'],$home_info['agent_port'],$home_info['encryption_key']);
  72. $ftp_installed = $db->isModuleInstalled('ftp');
  73.  
  74. if( isset($_REQUEST['change_name']) )
  75. {
  76. $server_name = strip_tags(strip_real_escape_string($_POST['server_name']));
  77. if ( $db->changeHomeName($home_id, $server_name) === TRUE )
  78. {
  79. echo json_encode(array('result' => 'success', 'info' => successfully_changed_game_server));
  80. $db->logger( successfully_changed_game_server ." HOME ID:$home_id - ". game_server_name .":$server_name");
  81. }
  82. else
  83. echo json_encode(array('result' => 'failure', 'info' => 'Name update failed.'));
  84. return;
  85. }
  86. elseif ( isset($_REQUEST['change_control_password']) )
  87. {
  88. $control_password = $_POST['control_password'];
  89. if($control_password != "")
  90. {
  91. $control_password = validate_login($control_password);
  92. if(!$control_password)
  93. {
  94. echo json_encode(array('result' => 'failure', 'info' => 'Not allowed characters'));
  95. return;
  96. }
  97. }
  98.  
  99. if ( $db->changeHomeControlPassword($home_id, $control_password) === TRUE )
  100. {
  101. echo json_encode(array('result' => 'success', 'info' => control_password_updated_successfully));
  102. $db->logger( control_password_updated_successfully ." HOME ID:$home_id - ". game_control_password .":$control_password");
  103. }
  104. else
  105. echo json_encode(array('result' => 'failure', 'info' => control_password_update_failed));
  106. return;
  107. }
  108. elseif( isset( $_REQUEST['change_ftp_login']) && preg_match("/t/",$game_home['access_rights']) > 0 )
  109. {
  110. // Is FTP Module Installed?
  111. if($ftp_installed){
  112. if ($db->IsFtpEnabled($home_id) OR $isAdmin)
  113. {
  114. $post_ftp_login = $_POST['ftp_login'];
  115. if($post_ftp_login != "")
  116. {
  117. $post_ftp_login = validate_login($post_ftp_login);
  118. if(!$post_ftp_login)
  119. {
  120. echo json_encode(array('result' => 'failure', 'info' => 'Not allowed characters'));
  121. return;
  122. }
  123. }
  124. else
  125. {
  126. echo json_encode(array('result' => 'failure', 'info' => 'Empty input not permitted.'));
  127. return;
  128. }
  129.  
  130. $host_stat = $remote->status_chk();
  131. $user_exists = FALSE;
  132. $host_online = FALSE;
  133. if( $host_stat === 1 )
  134. {
  135. $host_online = TRUE;
  136. $ftp_accounts_list = $remote->ftp_mgr("list");
  137. $ftp_accounts = explode("\n",$ftp_accounts_list);
  138.  
  139. foreach($ftp_accounts as $ftp_account)
  140. {
  141. if( $ftp_account != "" )
  142. {
  143. list($ftp_login, $ftp_path) = explode("\t",$ftp_account);
  144. $ftp_login = trim($ftp_login);
  145. if ($ftp_login == $post_ftp_login)
  146. {
  147. $user_exists = TRUE;
  148. break;
  149. }
  150. }
  151. }
  152. }
  153. if( $host_online and ! $user_exists )
  154. {
  155. $old_login = isset($home_info['ftp_login']) ? $home_info['ftp_login'] : $home_id;
  156. $change_login_delete_old = $remote->ftp_mgr("userdel", $old_login);
  157. if ($change_login_delete_old !== 0)
  158. {
  159. require_once("smsconfig2.php");
  160. $szerverid = $post_ftp_login;
  161. $jelszo = $home_info['ftp_password'];
  162. $eleres = $home_info['home_path'];
  163. //$change_login_add_new =
  164. mysql_query("INSERT INTO ftp_users (userid,admin_id,passwd,rawpasswd,uid,gid,shell,homedir,status) VALUES ('$szerverid','1002','$encryptedPassword','$jelszo','1002','1002','/bin/sh','$eleres','ok')", $mysql_kap2);
  165. //$change_login_add_new = $remote->ftp_mgr("useradd", $post_ftp_login, $home_info['ftp_password'], $home_info['home_path']);
  166. }
  167.  
  168. if (isset($change_login_add_new) and $change_login_add_new !== 0)
  169. {
  170. if ( $db->changeFtpLogin($home_id,$post_ftp_login) === TRUE )
  171. {
  172. echo json_encode(array('result' => 'success', 'info' => successfully_changed_game_server));
  173. $db->logger( successfully_changed_game_server ." HOME ID:$home_id - ". server_ftp_login .":$post_ftp_login");
  174. }
  175. }
  176. else
  177. {
  178. echo json_encode(array('result' => 'failure', 'info' => error_ocurred_on_remote_server .
  179. " " . ftp_login_can_not_be_changed));
  180. }
  181. }
  182. else
  183. {
  184. echo json_encode(array('result' => 'failure', 'info' => error_ocurred_on_remote_server .
  185. " " . ftp_login_can_not_be_changed));
  186. }
  187. }
  188. }
  189. return;
  190. }
  191. elseif( isset( $_REQUEST['change_ftp_password']) && preg_match("/t/",$game_home['access_rights']) > 0 )
  192. {
  193. // Is FTP Module Installed?
  194. if($ftp_installed){
  195. if ($db->IsFtpEnabled($home_id) OR $isAdmin)
  196. {
  197. $ftp_password = $_POST['ftp_password'];
  198. if($ftp_password != "")
  199. {
  200. $ftp_password = validate_login($ftp_password);
  201. if(!$ftp_password)
  202. {
  203. echo json_encode(array('result' => 'failure', 'info' => 'Not allowed characters'));
  204. return;
  205. }
  206. }
  207. else
  208. {
  209. echo json_encode(array('result' => 'failure', 'info' => 'Empty input not permitted.'));
  210. return;
  211. }
  212.  
  213. $ftp_login = isset($home_info['ftp_login']) ? $home_info['ftp_login'] : $home_id;
  214. $change_passwd_on_remote = $remote->ftp_mgr("passwd", $ftp_login, $ftp_password);
  215. if ($change_passwd_on_remote !== 0)
  216. {
  217. if ( $db->changeFtpPassword($home_id,clean_path($ftp_password)) === TRUE )
  218. {
  219. echo json_encode(array('result' => 'success', 'info' => successfully_changed_game_server));
  220. $db->logger( successfully_changed_game_server ." HOME ID:$home_id - ". server_ftp_password .":$ftp_password");
  221. }
  222. }
  223. else
  224. {
  225. echo json_encode(array('result' => 'failure', 'info' => error_ocurred_on_remote_server .
  226. " " . ftp_password_can_not_be_changed));
  227. }
  228. }
  229. }
  230. return;
  231. }
  232. elseif (isset($_POST["force_mod_id"]))
  233. {
  234. $force_mod_id = $_POST['force_mod_id'];
  235. $ip_id = $_POST['ip_id'];
  236. $port = $_POST['port'];
  237.  
  238. if ( $db->forceModAtAddress($ip_id, $port, $force_mod_id) )
  239. {
  240. echo json_encode(array('result' => 'success', 'info' => successfully_assigned_mod_to_address));
  241. $db->logger( successfully_assigned_mod_to_address );
  242.  
  243. }
  244. else
  245. echo json_encode(array('result' => 'failure', 'info' => "Failed to assign mod to address."));
  246. return;
  247. }
  248. elseif ( $isAdmin )
  249. {
  250. if( isset( $_REQUEST['create_ftp']) )
  251. {
  252. require_once("smsconfig2.php");
  253. $login = isset($home_info['ftp_login']) ? $home_info['ftp_login'] : $home_id;
  254. $create_ftp = mysql_query($sqlCmdd,$mysql_kap);
  255. $sqlCmdd = "INSERT INTO ftp_users (userid,admin_id,passwd,rawpasswd,uid,gid,shell,homedir,status) VALUES ('$login','1002','$encryptedPassword','$jelszo','1002','1002','/bin/sh','$eleres','ok')";
  256. //$create_ftp = mysql_query("INSERT INTO ftp_users (userid,admin_id,passwd,rawpasswd,uid,gid,shell,homedir,status) VALUES ('$login','1002','$encryptedPassword','$jelszo','1002','1002','/bin/sh','$eleres','ok')", $mysql_kap2);
  257. //$remote->ftp_mgr("useradd", $login, $home_info['ftp_password'], $home_info['home_path']);
  258. if ($create_ftp === 0)
  259. {
  260. $result = error_ocurred_on_remote_server ." ". ftp_can_not_be_switched_on;
  261. $type = "failure";
  262. }
  263. else
  264. {
  265. $db->changeFtpStatus('enabled',$home_id);
  266. $result = successfully_changed_game_server;
  267. $type = "success";
  268. $db->logger( successfully_changed_game_server ." HOME ID:$home_id - ". change_ftp_account_status .":enabled");
  269. }
  270. }
  271. else if( isset( $_REQUEST['delete_ftp']) )
  272. {
  273. $login = isset($home_info['ftp_login']) ? $home_info['ftp_login'] : $home_id;
  274. $delete_ftp = $remote->ftp_mgr("userdel", $login);
  275. if ($delete_ftp === 0)
  276. {
  277. $result = error_ocurred_on_remote_server ." ". ftp_can_not_be_switched_off;
  278. $type = "failure";
  279. }
  280. else
  281. {
  282. $db->changeFtpStatus('disabled',$home_id);
  283. $result = successfully_changed_game_server;
  284. $type = "success";
  285. $db->logger( successfully_changed_game_server ." HOME ID:$home_id - ". change_ftp_account_status .":disabled");
  286. }
  287. }
  288. else if( isset( $_REQUEST['change_user_id_main']) )
  289. {
  290. $user_id_main = $_POST['user_id_main'];
  291. $old_home = $db->getUserGameHome($home_info['user_id_main'],$home_id);
  292. if(isset($_POST['deleteoldassigns']))
  293. {
  294. $db->unassignHomeFrom("user",$home_info['user_id_main'],$home_id);
  295. $home_groups = $db->getGroupsForHome($home_info['home_id']);
  296. if( isset( $home_groups ) )
  297. {
  298. foreach($home_groups as $home_group)
  299. {
  300. $db->unassignHomeFrom("group",$home_group['group_id'],$home_id);
  301. }
  302. }
  303. }
  304.  
  305. if ( $db->changeUserIdMain($home_id,$user_id_main) == TRUE )
  306. {
  307. $db->assignHomeTo("user",$user_id_main,$home_id,$old_home['access_rights']);
  308. echo json_encode(array('result' => 'success', 'info' => successfully_changed_game_server));
  309. $db->logger( successfully_changed_game_server ." HOME ID:$home_id - ". change_user_id_main .":$user_id_main");
  310. }
  311. echo json_encode(array('result' => 'failure', 'info' => "Unable to change main user."));
  312. return;
  313. }
  314. else if( isset( $_REQUEST['change_home'] ) )
  315. {
  316. $home_path = strip_real_escape_string($_POST['home_path']);
  317. if(preg_match("/^[a-z]\:\\\\/i",$home_path))
  318. $home_path = rtrim($remote->exec("cygpath -a $home_path"));
  319. if(preg_match("/^\//",$home_path))
  320. {
  321. if ( $db->changeHomePath($home_id,clean_path($home_path)) === TRUE )
  322. {
  323. if($ftp_installed){
  324. if ($db->IsFtpEnabled($home_id))
  325. {
  326. $login = isset($home_info['ftp_login']) ? $home_info['ftp_login'] : $home_id;
  327. $delte_old_ftp_account = $remote->ftp_mgr("userdel", $login);
  328. if ($delte_old_ftp_account !== 0)
  329. {
  330. mysql_query("INSERT INTO ftp_users (userid,admin_id,passwd,rawpasswd,uid,gid,shell,homedir,status) VALUES ('$login','1002','$encryptedPassword','$jelszo','1002','1002','/bin/sh','$eleres','ok')", $mysql_kap2);
  331. //$create_new_ftp_account = $remote->mysql_query("INSERT INTO ftp_users (userid,admin_id,passwd,rawpasswd,uid,gid,shell,homedir,status) VALUES ('$login','1002','$encryptedPassword','$jelszo','1002','1002','/bin/sh','$eleres','ok')", $mysql_kap2);
  332. //$remote->ftp_mgr("useradd", $login, $home_info['ftp_password'], $home_path);
  333. }
  334.  
  335. if (isset($create_new_ftp_account) and $create_new_ftp_account !== 0)
  336. {
  337. echo json_encode(array('result' => 'success', 'info' => successfully_changed_game_server));
  338. $db->logger( successfully_changed_game_server ." HOME ID:$home_id - ". home_path .":$home_path");
  339. }
  340. else
  341. {
  342. echo json_encode(array('result' => 'failure', 'info' => error_ocurred_on_remote_server .
  343. " " . ftp_login_can_not_be_changed));
  344. }
  345. }
  346. else
  347. {
  348. echo json_encode(array('result' => 'success', 'info' => successfully_changed_game_server));
  349. $db->logger( successfully_changed_game_server ." HOME ID:$home_id - ". home_path .":$home_path");
  350. }
  351. }
  352. else
  353. {
  354. echo json_encode(array('result' => 'success', 'info' => successfully_changed_game_server));
  355. $db->logger( successfully_changed_game_server ." HOME ID:$home_id - ". home_path .":$home_path");
  356. }
  357. }
  358. else
  359. echo json_encode(array('result' => 'failure', 'info' => selected_path_already_in_use));
  360. }
  361. else
  362. echo json_encode(array('result' => 'failure', 'info' => invalid_path));
  363. return;
  364. }
  365. else if( isset( $_REQUEST['master_server'] ) )
  366. {
  367. if ( isset( $_POST['add'] ) )
  368. $action = "add";
  369. else
  370. $action = "remove";
  371. if ( $db->setMasterServer($action, $home_id, $home_info['home_cfg_id'], $home_info['remote_server_id']) === TRUE )
  372. {
  373. $result = successfully_changed_game_server;
  374. $type = "success";
  375. $db->logger( successfully_changed_game_server ." HOME ID:$home_id - ". set_as_master_server .":$action");
  376. }
  377. }
  378.  
  379. if( isset($_REQUEST['add_mod']) )
  380. {
  381. $mod_cfg_id = $_POST['mod_cfg_id'];
  382. if ( $db->addModToGameHome($home_id,$mod_cfg_id) === FALSE )
  383. {
  384. $result = get_lang_f('failed_to_assing_mod_to_home',$mod_cfg_id);
  385. $type = "failure";
  386. }
  387. else
  388. {
  389. $result = get_lang_f('successfully_assigned_mod_to_home',$mod_cfg_id);
  390. $type = "success";
  391. $db->logger(get_lang_f('successfully_assigned_mod_to_home',$mod_cfg_id)." [HOME ID:$home_id]");
  392. }
  393. }
  394.  
  395. else if($submit == "delete_mod")
  396. {
  397. $mod_id = $_GET['mod_id'];
  398. if ( $db->delGameMod($mod_id) === TRUE )
  399. {
  400. $result = successfully_removed_mod;
  401. $type = "success";
  402. $db->logger( successfully_removed_mod ." [MOD ID:$mod_id HOME ID:$home_id]");
  403. }
  404. }
  405.  
  406. else if(isset($_REQUEST['set_options']))
  407. {
  408. $maxplayers = 0 + @$_POST['maxplayers'];
  409. $cliopts = $_POST['cliopts'];
  410. $cpus = $_POST['cpus'];
  411. $nice = $_POST['nice'];
  412. $mod_cfg_id = $_POST['mod_cfg_id'];
  413.  
  414. if ( $db->updateGameModParams($maxplayers,$cliopts,$cpus,$nice,$home_id,$mod_cfg_id) === TRUE )
  415. {
  416. echo json_encode(array('result' => 'success', 'info' => successfully_modified_mod));
  417. $db->logger( successfully_modified_mod ." [MOD CFG ID:$mod_cfg_id HOME ID:$home_id]");
  418. }
  419. else
  420. echo json_encode(array('result' => 'failure', 'info' => "The mod could not be changed."));
  421. return;
  422. }
  423. }
  424. ?>
  425. <link rel="stylesheet" href="js/jquery/ui/themes/base/jquery.ui.all.css">
  426. <script type="text/javascript" src="js/jquery/jquery-1.11.0.min.js"></script>
  427. <script type="text/javascript" src="js/jquery/ui/jquery-ui-1.10.4.min.js"></script>
  428. <script type="text/javascript" src="js/modules/user_games.js"></script>
  429. <?php
  430. echo "<h2>". editing_home_called ." \"".$home_info['home_name']."\"</h2><div id='result' >";
  431. if(isset($result))
  432. {
  433. if($type == 'success')
  434. print_success($result);
  435. elseif($type = 'failure')
  436. print_failure($result);
  437. }
  438. echo "</div>";
  439. $home_info = $db->getGameHomeWithoutMods($home_id);
  440. $custom_fileds_access_enabled = preg_match("/c/",$game_home['access_rights']) > 0 ? TRUE : FALSE;
  441. echo "<p>";
  442. echo "<a href='?m=gamemanager&p=game_monitor&home_id=$home_id'>&lt;&lt; ". back_to_game_monitor ."</a>";
  443. if ( $isAdmin )
  444. {
  445. echo " &nbsp; ";
  446. echo "<a href='?m=user_games'>&lt;&lt; ". back_to_game_servers ."</a>";
  447. $custom_fileds_access_enabled = TRUE;
  448. }
  449. if( isset($server_xml->custom_fields) and $custom_fileds_access_enabled )
  450. echo " &nbsp; <a href='?m=user_games&p=custom_fields&home_id=".$home_id."'>". go_to_custom_fields ." &gt;&gt;</a>";
  451.  
  452. echo "</p>";
  453. echo "<table class='center' id='main_settings' >";
  454. if ( $isAdmin )
  455. {
  456. // Form to change game type
  457. echo "<tr><td rowspan='2' class='right'>". game_type .":</td><td class='left'>";
  458. echo "<form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>";
  459. $game_cfgs = $db->getGameCfgs();
  460. $host_stat = $remote->status_chk();
  461. if( $host_stat === 1)
  462. $os = $remote->what_os();
  463. else
  464. $os = "Unknown OS";
  465. echo "<select name='home_cfg_id' >";
  466. // Linux 64 bits + wine
  467. if( preg_match("/Linux/", $os) AND preg_match("/64/", $os) AND preg_match("/wine/", $os) )
  468. {
  469. foreach ( $game_cfgs as $row )
  470. {
  471. if ( preg_match("/linux/", $row['game_key']) )
  472. {
  473. $selected = $home_info['home_cfg_id'] == $row['home_cfg_id'] ? 'selected="selected"' : "";
  474. echo "<option value='".$row['home_cfg_id']."' $selected>".$row['game_name'];
  475. if ( preg_match("/64/", $row['game_key']) ) echo " (64 bit)";
  476. echo "</option>\n";
  477. }
  478. }
  479. echo "<option style='background:black;color:white;' value=''>". wine_games .":</option>\n";
  480. foreach ( $game_cfgs as $row )
  481. {
  482. if ( preg_match("/win/", $row['game_key']) )
  483. {
  484. $selected = $home_info['home_cfg_id'] == $row['home_cfg_id'] ? 'selected="selected"' : "";
  485. echo "<option value='".$row['home_cfg_id']."' $selected>".$row['game_name'];
  486. if ( preg_match("/64/", $row['game_key']) ) echo " (64 bit)";
  487. echo "</option>\n";
  488. }
  489. }
  490. }
  491. // Linux 64 bits
  492. elseif( preg_match("/Linux/", $os) AND preg_match("/64/", $os) )
  493. {
  494. foreach ( $game_cfgs as $row )
  495. {
  496. if ( preg_match("/linux/", $row['game_key']))
  497. {
  498. $selected = $home_info['home_cfg_id'] == $row['home_cfg_id'] ? 'selected="selected"' : "";
  499. echo "<option value='".$row['home_cfg_id']."' $selected>".$row['game_name'];
  500. if ( preg_match("/64/", $row['game_key']) ) echo " (64 bit)";
  501. echo "</option>\n";
  502. }
  503. }
  504. }
  505. // Linux 32 bits + wine
  506. elseif( preg_match("/Linux/", $os) AND preg_match("/wine/", $os) )
  507. {
  508. foreach ( $game_cfgs as $row )
  509. {
  510. if ( preg_match("/linux32/", $row['game_key']) )
  511. {
  512. $selected = $home_info['home_cfg_id'] == $row['home_cfg_id'] ? 'selected="selected"' : "";
  513. echo "<option value='".$row['home_cfg_id']."' $selected>".$row['game_name']."</option>\n";
  514. }
  515. }
  516. echo "<option style='background:black;color:white;' value=''>". wine_games ."</option>\n";
  517. foreach ( $game_cfgs as $row )
  518. {
  519. if ( preg_match("/win32/", $row['game_key']) )
  520. {
  521. $selected = $home_info['home_cfg_id'] == $row['home_cfg_id'] ? 'selected="selected"' : "";
  522. echo "<option value='".$row['home_cfg_id']."' $selected>".$row['game_name']."</option>\n";
  523. }
  524. }
  525. }
  526. // Linux 32 bits
  527. elseif( preg_match("/Linux/", $os) )
  528. {
  529. foreach ( $game_cfgs as $row )
  530. {
  531. if ( preg_match("/linux32/", $row['game_key']) )
  532. {
  533. $selected = $home_info['home_cfg_id'] == $row['home_cfg_id'] ? 'selected="selected"' : "";
  534. echo "<option value='".$row['home_cfg_id']."' $selected>".$row['game_name']."</option>\n";
  535. }
  536. }
  537. }
  538. // Windows 64 bits (CYGWIN)
  539. elseif( preg_match("/CYGWIN/", $os) AND preg_match("/64/", $os))
  540. {
  541. foreach ( $game_cfgs as $row )
  542. {
  543. if ( preg_match("/win/", $row['game_key']) )
  544. {
  545. $selected = $home_info['home_cfg_id'] == $row['home_cfg_id'] ? 'selected="selected"' : "";
  546. echo "<option value='".$row['home_cfg_id']."' $selected>".$row['game_name'];
  547. if ( preg_match("/64/", $row['game_key']) ) echo " (64 bit)";
  548. echo "</option>\n";
  549. }
  550. }
  551. }
  552. // Windows 32 bits (CYGWIN)
  553. elseif( preg_match("/CYGWIN/", $os))
  554. {
  555. foreach ( $game_cfgs as $row )
  556. {
  557. if ( preg_match("/win32/", $row['game_key']) )
  558. {
  559. $selected = $home_info['home_cfg_id'] == $row['home_cfg_id'] ? 'selected="selected"' : "";
  560. echo "<option value='".$row['home_cfg_id']."' $selected>".$row['game_name']."</option>\n";
  561. }
  562. }
  563. }
  564. elseif ( $os == "Unknown OS" )
  565. {
  566. foreach ( $game_cfgs as $row )
  567. {
  568. $selected = $home_info['home_cfg_id'] == $row['home_cfg_id'] ? 'selected="selected"' : "";
  569. echo "<option value='".$row['home_cfg_id']."' $selected>".$row['game_name'];
  570. if ( preg_match("/64/", $row['game_key']) ) echo " (64 bit)";
  571. echo "</option>\n";
  572. }
  573. }
  574. echo "</select>";
  575. echo "<input type='submit' name='change_home_cfg_id' value='". change_game_type ."' />";
  576. echo "</form></td></tr>";
  577. echo "<tr><td colspan='2' class='info'>". change_game_type_info ."</td></tr>";
  578. // Form to edit main user.
  579. echo "<tr><td class='right'>". user_id_main .":</td><td class='left'>";
  580. echo "<form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>";
  581. echo "<input type='hidden' name='home_id' value=\"$home_id\" />\n";
  582. echo "<select name='user_id_main'>";
  583. $user = $db->getUserById($home_info['user_id_main']);
  584. echo "<option value='".$home_info['user_id_main']."'>".$user['users_login']."</option>\n";
  585. $users = $db->getUserList();
  586. foreach ( $users as $user ){
  587. // Only users and admins can be assigned homes... not subusers
  588. if(is_null($user['users_parent'])){
  589. if($home_info['user_id_main'] != $user['user_id']){
  590. echo "<option value='".$user['user_id']."'>".$user['users_login']."</option>\n";
  591. }
  592. }
  593. }
  594. echo "</select><br>";
  595. echo "<input type='checkbox' name='deleteoldassigns' id='deleteoldassigns' style='width:auto;' /><label for='deleteoldassigns' >". Delete_old_user_assigned_homes ."</label>";
  596. echo "<input type='submit' name='change_user_id_main' value='". change_user_id_main ."' />";
  597. echo "</form>";
  598. echo "</td></tr><tr><td colspan='2' class='info'>" . change_user_id_main_info ."</td></tr>";
  599.  
  600. // Form to edit game path.
  601. echo "<tr><td class='right'>". home_path .":</td><td class='left'>".
  602. "<form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>".
  603. "<input type='hidden' name='home_id' value=\"$home_id\" />\n".
  604. "<input type='text' size='30' name='home_path' value=\"".str_replace('"', "&quot;", $home_info['home_path'])."\" />".
  605. "<input type='submit' name='change_home' value='". change_home ."' id='change_home_path' />".
  606. "</form><button data-path=\"".str_replace('"', "&quot;", $home_info['home_path'])."\" data-home-id='".$home_id."' id='browse'>".
  607. browse ."</button></td></tr>".
  608. "<tr><td colspan='2' class='info'>". change_home_info ."</td></tr>";
  609.  
  610. //Jquery path browser dialog
  611. echo "<div id='dialog".
  612. "' data-select_home_path='". select_home_path .
  613. "' data-set_this_path='". set_this_path .
  614. "' data-cancel='". cancel .
  615. "' ></div>";
  616. }
  617.  
  618. // Form to edit game name
  619. echo "<tr><td class='right'>". game_server_name .":</td><td class='left'>";
  620. echo "<form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>";
  621. echo "<input type='hidden' name='home_id' value=\"$home_id\" />\n";
  622. echo "<input type='text' size='30' name='server_name' value=\"".str_replace('"', "&quot;", $home_info['home_name'])."\" />";
  623. echo "<input type=submit name='change_name' value='". change_name ."' />";
  624. echo "</form></td></tr>";
  625. echo "<tr><td colspan='2' class='info'>". change_name_info ."</td></tr>";
  626.  
  627. // Form to edit control password
  628. echo "<tr><td class='right'>". game_control_password .":</td><td class='left'>";
  629. echo "<form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>";
  630. echo "<input type='hidden' name='home_id' value=\"$home_id\" />\n";
  631. echo "<input type='text' size='30' name='control_password' value=\"".str_replace('"', "&quot;", $home_info['control_password'])."\" />";
  632. echo "<input type='submit' name='change_control_password' value='". change_control_password ."' />";
  633. echo "</form></td></tr>";
  634. echo "<tr><td colspan='2' class='info'>". change_control_password_info ."</td></tr>";
  635. if ( preg_match("/t/",$game_home['access_rights']) > 0 && $ftp_installed && $db->IsFtpEnabled($home_id) )
  636. {
  637. // Form to edit control ftp login
  638. $ftp_login = isset($home_info['ftp_login']) ? $home_info['ftp_login'] : $home_id;
  639. echo "<tr><td class='right'>". server_ftp_login .":</td><td class='left'>";
  640. echo "<form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>";
  641. echo "<input type='text' size='30' name='ftp_login' value=\"".str_replace('"', "&quot;", $ftp_login)."\" />";
  642. echo "<input type='submit' name='change_ftp_login' value='". change_ftp_login ."' />";
  643. echo "</form></td></tr>";
  644. echo "<tr><td colspan='2' class='info'>". change_ftp_login_info ."</td></tr>";
  645. // Form to edit control ftp password
  646. echo "<tr><td class='right'>". server_ftp_password .":</td><td class='left'>";
  647. echo "<form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>";
  648. echo "<input type='text' size='30' name='ftp_password' value=\"".str_replace('"', "&quot;", $home_info['ftp_password'])."\" />";
  649. echo "<input type='submit' name='change_ftp_password' value='". change_ftp_password ."' />";
  650. echo "</form></td></tr>";
  651. echo "<tr><td colspan='2' class='info'>". change_ftp_password_info ."</td></tr>";
  652. }
  653. if ( $isAdmin && $ftp_installed )
  654. {
  655. // Forms to enable/disable ftp account
  656. echo "<tr>";
  657. echo "<td class='right'>". change_ftp_account_status .":</td>";
  658. echo "<td class='left'>";
  659. if ( !$db->IsFtpEnabled( $home_id ) )
  660. {
  661. echo "<div style='display:block;float:left;' ><form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>";
  662. echo "<input type='submit' name='create_ftp' value='". ftp_on ."' />";
  663. echo "</form></div>";
  664. }
  665. else
  666. {
  667. echo "<div style='display:block;float:left;' ><form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>";
  668. echo "<input type='submit' name='delete_ftp' value='". ftp_off ."' />";
  669. echo "</form></div>";
  670. }
  671. echo "</td></tr>";
  672. echo "<tr><td colspan='2' class='info'>". change_ftp_account_status_info ."</td>";
  673. echo "</tr>";
  674. }
  675.  
  676. if ( $isAdmin )
  677. {
  678. $master_server_home_id = $db->getMasterServer( $home_info['remote_server_id'], $home_info['home_cfg_id'] );
  679. if( $master_server_home_id != FALSE AND $master_server_home_id == $home_id )
  680. $checked = 'checked ="checked"';
  681. else
  682. $checked = "";
  683. // Form to enable/disable as master server for local update
  684. echo "</tr><tr><td class='right'>". master_server_for_clon_update .":</td><td class='left'>";
  685. echo "<form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>";
  686. echo "<input type='checkbox' name='add' $checked />";
  687. echo "<input type='submit' name='master_server' value='". set_as_master_server ."' />";
  688. echo "</form></td></tr>";
  689. echo "<tr><td colspan='2' class='info'>". set_as_master_server_for_local_clon_update .
  690. " (".get_lang_f( 'only_available_for', $server_xml->game_name, $home_info['remote_server_name']).")</td></tr>";
  691. }
  692.  
  693. echo "</table>";
  694.  
  695. if ( $isAdmin )
  696. {
  697. $avail_ips = $db->getRemoteServerIPs($home_info['remote_server_id']);
  698.  
  699. $ip_array = array();
  700.  
  701. if ( is_array($avail_ips) && !empty($avail_ips) )
  702. {
  703. echo "<h3>". ips_and_ports ."</h3>";
  704. $screen_running = $remote->is_screen_running(OGP_SCREEN_TYPE_HOME,$home_info['home_id']) === 1;
  705. if( ! $screen_running )
  706. {
  707. if( isset($_REQUEST['set_ip']) )
  708. {
  709. $ip_id = $_POST['ip'];
  710. $ip_row = $db->resultQuery( "SELECT ip FROM OGP_DB_PREFIXremote_server_ips WHERE ip_id=".$ip_id );
  711. $ip = $ip_row['0']['ip'];
  712. $port = $_POST['port'];
  713. $port = (int)(trim($port));
  714. $home_id = $_POST['home_id'];
  715.  
  716. if ( !isPortValid($port) )
  717. {
  718. print_failure( port_range_error );
  719. }
  720. else
  721. {
  722. if ( $db->addGameIpPort($home_id, $ip_id, $port) === FALSE )
  723. {
  724. print_failure(get_lang_f('ip_port_already_in_use', $ip, $port));
  725. }
  726. else {
  727. print_success(get_lang_f('successfully_assigned_ip_port_to_server_id', $ip, $port, $home_id));
  728. $db->logger(get_lang_f('successfully_assigned_ip_port_to_server_id', $ip, $port, $home_id));
  729. }
  730. }
  731. }
  732.  
  733. if (isset($_REQUEST["delete_ip"]))
  734. {
  735. $del_ip = $_GET['ip'];
  736. $del_port = $_GET['port'];
  737.  
  738. if ( $db->delGameIpPort($home_id,$del_ip,$del_port) )
  739. {
  740. print_success( successfully_assigned_ip_port );
  741. $db->logger( successfully_assigned_ip_port ." [unassigned]");
  742. }
  743. else
  744. print_failure("Failed to unassign ip:port.");
  745. }
  746.  
  747. echo "<form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>\n";
  748. echo "<input type='hidden' name='home_id' value=\"$home_id\" />\n";
  749. echo ip .":<select name='ip' onchange='this.form.submit();'>";
  750.  
  751. foreach($avail_ips as $value)
  752. {
  753. $selected = ( isset($_POST['ip']) and $_POST['ip'] == $value['ip_id'] ) ? "selected='selected'" : "";
  754. echo "<option value='".$value['ip_id']."' $selected >".$value['ip']."</option>\n";
  755. }
  756.  
  757. echo "</select>";
  758.  
  759. $ip_id = isset($_POST['ip']) ? $_POST['ip'] : $avail_ips[0]['ip_id'];
  760. $port = $db->getNextAvailablePort($ip_id,$home_info['home_cfg_id']);
  761.  
  762. echo " ". port .":<input type='text' name='port' value='".$port."' size='6' />";
  763. echo "<input type='submit' name='set_ip' value='". set_ip ."' />";
  764. echo "</form>";
  765. $assigned = $db->getHomeIpPorts($home_id);
  766. if( empty($assigned) )
  767. {
  768. print_failure( no_ip_ports_assigned );
  769. }
  770. else
  771. {
  772. foreach ( $assigned as $assigned_rows )
  773. {
  774. $force_mod = "";
  775. $align = "center";
  776. if( !empty($enabled_mods) and count($enabled_mods) > 1 )
  777. {
  778. $force_mod .= "<td align='left'>\n".
  779. "<form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>\n".
  780. "<input type='hidden' name='ip_id' value=".$assigned_rows['ip_id']." />".
  781. "<input type='hidden' name='port' value=".$assigned_rows['port']." />".
  782. "<select name='force_mod_id' onchange='this.form.submit();'>".
  783. "<option value='0' >". force_mod_on_this_address ."</option>";
  784. foreach($enabled_mods as $mod)
  785. {
  786. $selected = $mod['mod_id'] == $assigned_rows['force_mod_id'] ? "selected='selected'" : "";
  787. $force_mod .= "<option value='".$mod['mod_id']."' $selected>".$mod['mod_name']."</option>";
  788. }
  789. $force_mod .= "</select>\n</form>\n</td>\n";
  790. $align = "right";
  791. }
  792. echo "<table class='center'><tr><td align='$align'>".$assigned_rows['ip'].":".$assigned_rows['port'].
  793. " <a href='?m=user_games&amp;p=edit&amp;home_id=$home_id&amp;delete_ip&amp;ip=".
  794. $assigned_rows['ip_id']."&amp;port=".$assigned_rows['port'].
  795. "'>[ ". delete ." ]</a></td>\n".
  796. $force_mod.
  797. "</tr>\n</table>\n";
  798. }
  799. }
  800. }
  801. else
  802. {
  803. print_failure( server_is_running_change_addresses_not_available );
  804. }
  805. }
  806. else
  807. {
  808. print_failure( no_ip_addresses_configured ."<a href='?m=server'>". server_page ."</a>." );
  809. }
  810. echo "<div id='mods'></div>";
  811. }
  812. else
  813. {
  814. $assigned = $db->getHomeIpPorts($home_id);
  815. if( !empty($assigned) and !empty($enabled_mods) and count($enabled_mods) > 1 )
  816. {
  817. echo "<table class='center'>\n".
  818. "<tr>\n".
  819. "<td colspan='2' align='center'>".
  820. "<h3>". switch_mods ."</h3>".
  821. "</td>\n".
  822. "</tr>\n";
  823. $force_mod = "";
  824. foreach ( $assigned as $assigned_rows )
  825. {
  826. $force_mod .= "<tr>\n<td align='right' style='width:50%' >".get_lang_f('switch_mod_for_address',$assigned_rows['ip'].":".$assigned_rows['port']).
  827. "</td>\n<td align='left' style='width:50%' >\n".
  828. "<form action='?m=user_games&p=edit&home_id=".$home_id."' method='post'>\n".
  829. "<input type='hidden' name='ip_id' value=".$assigned_rows['ip_id']." />".
  830. "<input type='hidden' name='port' value=".$assigned_rows['port']." />".
  831. "<select name='force_mod_id' onchange='this.form.submit();'>".
  832. "<option value='0' >". force_mod_on_this_address ."</option>";
  833. foreach($enabled_mods as $mod)
  834. {
  835. $selected = $mod['mod_id'] == $assigned_rows['force_mod_id'] ? "selected='selected'" : "";
  836. $force_mod .= "<option value='".$mod['mod_id']."' $selected>".$mod['mod_name']."</option>";
  837. }
  838. $force_mod .= "</select>\n</form>\n</td>\n</tr>\n";
  839. }
  840. echo $force_mod."</table>\n";
  841. }
  842. }
  843. }
  844. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement