PageRenderTime 49ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/server/add.php

http://lansuite.googlecode.com/
PHP | 92 lines | 73 code | 17 blank | 2 comment | 22 complexity | f4704077185612dd4dcc7c1d38c8b506 MD5 | raw file
Possible License(s): LGPL-3.0, AGPL-1.0, LGPL-2.1
  1. <?php
  2. function CheckIP($ip) {
  3. global $cfg;
  4. if ($cfg['sys_internet'] == 0) $ip_address = gethostbyname($ip);
  5. else $ip_address = $ip;
  6. $explode = explode('.', $ip_address);
  7. $count = count($explode);
  8. if ($count != 4) return t('Bitte gib eine gültige IP Adresse ein');
  9. elseif ($explode[0] > 255 or $explode[1] > 255 or $explode[2] > 255 or $explode[3] > 255) return t('Bitte gib eine gültige IP Adresse ein');
  10. return false;
  11. }
  12. function CheckMAC($mac) {
  13. if ($mac) {
  14. $explode = explode('-', $mac);
  15. $count = count($explode);
  16. if ($count != 6) return t('Bitte gib eine gültige MAC Adresse ein');
  17. }
  18. return false;
  19. }
  20. function CheckPort($port) {
  21. if ($port < 1 or $port > 65535) return t('Der Port muss zwischen 1 und 65535 liegen');
  22. return false;
  23. }
  24. if ($auth['type'] <= 1) $get_paid = $db->qry_first('SELECT paid FROM %prefix%party_user WHERE user_id = %int% AND party_id = %int%', $auth['userid'], $party->party_id);
  25. if ($cfg['server_ip_auto_assign']) {
  26. $IPBase = substr($cfg['server_ip_auto_assign'], 0, strrpos($cfg['server_ip_auto_assign'], '.'));
  27. $IPArea = substr($cfg['server_ip_auto_assign'], strrpos($cfg['server_ip_auto_assign'], '.') + 1, strlen($cfg['server_ip_auto_assign']));
  28. $IPStart = substr($IPArea, 0, strrpos($IPArea, '-'));
  29. if (!$cfg['server_ip_next']) $cfg['server_ip_next'] = $IPStart;
  30. $IPEnd = substr($IPArea, strrpos($IPArea, '-') + 1, strlen($IPArea));
  31. }
  32. if ($cfg['server_ip_auto_assign'] and $cfg['server_ip_next'] > $IPEnd) $func->information(t('Es sind keine freien IPs mehr vorhanden. Bitte einen Administrator darum den vorgesehenen Bereich zu erhöhren'), "index.php?mod=server");
  33. elseif ($cfg["server_admin_only"] and $auth['type'] <= 1) $func->information(t('Nur Adminsitratoren dürfen Server hinzufügen'), "index.php?mod=server");
  34. elseif (!$get_paid['paid'] and $auth["type"] <= 1) $func->information(t('Du musst zuerst bezahlen, um Server hinzufügen zu dürfen'), "index.php?mod=server");
  35. else {
  36. $dsp->NewContent(t('Server'), t('Hinzufügen und Aendern der Server'));
  37. include_once('inc/classes/class_masterform.php');
  38. $mf = new masterform();
  39. if (!$_GET['serverid']) {
  40. if ($auth['type'] > 1) $mf->AddDropDownFromTable(t('Besitzer'), 'owner', 'userid', 'username', 'user', '', 'type > 0');
  41. else $mf->AddFix('owner', $auth['userid']);
  42. }
  43. $mf->AddField(t('Name'), 'caption');
  44. //Party-Liste
  45. if ($func->isModActive('party')) {
  46. $party_list = array('' => t('KEINE'));
  47. $row = $db->qry("SELECT party_id, name FROM %prefix%partys");
  48. while($res = $db->fetch_array($row)) $party_list[$res['party_id']] = $res['name'];
  49. $db->free_result($row);
  50. $mf->AddField(t('Party'), 'party_id', IS_SELECTION, $party_list, $party->party_id);
  51. }
  52. $selections = array();
  53. $selections['gameserver'] = t('Gameserver');
  54. $selections['ftp'] = t('FTP Server');
  55. $selections['irc'] = t('IRC Server');
  56. $selections['web'] = t('Web Server');
  57. $selections['proxy'] = t('Proxy Server');
  58. $selections['misc'] = t('Sonstiger Server');
  59. $mf->AddField(t('Servertyp'), 'type', IS_SELECTION, $selections, FIELD_OPTIONAL);
  60. if ($cfg['server_ip_auto_assign']) $mf->AddFix('ip', $IPBase .'.'. $cfg['server_ip_next']);
  61. else $mf->AddField(t('IP / Domain'), 'ip', '', '', '', 'CheckIP');
  62. $mf->AddField(t('Port'), 'port', '', '', '', 'CheckPort');
  63. $mf->AddField(t('MAC-Adresse'), 'mac', '', '', FIELD_OPTIONAL, 'CheckMAC');
  64. $mf->AddField(t('Betriebssystem'), 'os', '', '', FIELD_OPTIONAL);
  65. $mf->AddField(t('CPU (MHz)'), 'cpu', '', '', FIELD_OPTIONAL);
  66. $mf->AddField(t('RAM (MB)'), 'ram', '', '', FIELD_OPTIONA);
  67. $mf->AddField(t('HDD (GB)'), 'hdd', '', '', FIELD_OPTIONA);
  68. $mf->AddField(t('Passwort geschützt'), 'pw', '', '', FIELD_OPTIONA);
  69. $mf->AddField(t('Beschreibung'), 'text', '', LSCODE_ALLOWED, FIELD_OPTIONA);
  70. if ($mf->SendForm('index.php?mod=server&action=add', 'server', 'serverid', $_GET['serverid'])) {
  71. // Increase auto IP
  72. if ($cfg['server_ip_auto_assign']) $db->qry('UPDATE %prefix%config SET cfg_value = %int% WHERE cfg_key = \'server_ip_next\'', $cfg['server_ip_next'] + 1);
  73. };
  74. }
  75. ?>