Browse Source

Initial import

master
Chris Smith 14 years ago
commit
60f86da8ec
100 changed files with 4875 additions and 0 deletions
  1. 5
    0
      .htaccess
  2. 21
    0
      403.php
  3. 24
    0
      account.php
  4. 74
    0
      addsite.php
  5. 17
    0
      admin.menu.php
  6. 31
    0
      admin.php
  7. 52
    0
      adminannouncements.php
  8. 57
    0
      adminbans.php
  9. 29
    0
      adminbw.php
  10. 41
    0
      admindiscounts.php
  11. 19
    0
      admindomains.php
  12. 20
    0
      adminfinances.php
  13. 18
    0
      admininvoices.php
  14. 18
    0
      adminreports.php
  15. 18
    0
      adminsites.php
  16. 18
    0
      admintickets.php
  17. 18
    0
      adminusers.php
  18. 20
    0
      alltickets.php
  19. 21
    0
      bandwidth.php
  20. 54
    0
      bans.php
  21. 75
    0
      billing.php
  22. 9
    0
      billingref.php
  23. 36
    0
      changepass.php
  24. 24
    0
      checkuser.php
  25. 197
    0
      database.php
  26. 74
    0
      discount.php
  27. 32
    0
      discounts.php
  28. 135
    0
      domains.php
  29. 51
    0
      doticket.php
  30. 78
    0
      doticketreply.php
  31. 72
    0
      editpref.php
  32. 164
    0
      editsite.php
  33. 25
    0
      email.php
  34. 32
    0
      enabledomain.php
  35. 133
    0
      ext/pie.php
  36. 27
    0
      fileman.php
  37. 20
    0
      history.php
  38. 36
    0
      index.php
  39. 20
    0
      invoices.php
  40. 125
    0
      ipn.php
  41. 192
    0
      lib/account.php
  42. 42
    0
      lib/bandwidth.php
  43. 96
    0
      lib/common.php
  44. 47
    0
      lib/dashboard.php
  45. 19
    0
      lib/database.php
  46. 11
    0
      lib/footer.php
  47. 75
    0
      lib/header.php
  48. 65
    0
      lib/log.php
  49. 26
    0
      lib/profiler.php
  50. 67
    0
      login.php
  51. 24
    0
      logout.php
  52. 66
    0
      pages/adddomain.php
  53. 56
    0
      pages/addemail.php
  54. 45
    0
      pages/addmailbox.php
  55. 45
    0
      pages/addsite.php
  56. 36
    0
      pages/admin.actions.php
  57. 40
    0
      pages/admin.addannouncement.php
  58. 99
    0
      pages/admin.adddiscount.php
  59. 44
    0
      pages/admin.addfinances.php
  60. 30
    0
      pages/admin.addipban.php
  61. 45
    0
      pages/admin.announcements.php
  62. 47
    0
      pages/admin.discounts.php
  63. 50
    0
      pages/admin.domains.php
  64. 56
    0
      pages/admin.finances.php
  65. 39
    0
      pages/admin.invoices.php
  66. 56
    0
      pages/admin.ipbans.php
  67. 29
    0
      pages/admin.menu.php
  68. 59
    0
      pages/admin.sites.php
  69. 58
    0
      pages/admin.tickets.php
  70. 37
    0
      pages/admin.userbans.php
  71. 53
    0
      pages/admin.users.php
  72. 31
    0
      pages/adminaddipban.php
  73. 54
    0
      pages/adminbills.php
  74. 34
    0
      pages/adminbw.php
  75. 47
    0
      pages/adminculog.php
  76. 29
    0
      pages/admindiscounts.php
  77. 54
    0
      pages/admindomains.php
  78. 55
    0
      pages/adminipbans.php
  79. 48
    0
      pages/adminlog.php
  80. 59
    0
      pages/adminsites.php
  81. 58
    0
      pages/admintickets.php
  82. 51
    0
      pages/adminusers.php
  83. 56
    0
      pages/alltickets.php
  84. 48
    0
      pages/announcements.php
  85. 6
    0
      pages/bandwidthgraph.php
  86. 33
    0
      pages/bandwidthtable.php
  87. 37
    0
      pages/billing.php
  88. 61
    0
      pages/dbdbs.php
  89. 63
    0
      pages/dbperms.php
  90. 70
    0
      pages/dbusers.php
  91. 24
    0
      pages/discount.php
  92. 21
    0
      pages/domains.adddomain.php
  93. 43
    0
      pages/domains.addsubdomain.php
  94. 74
    0
      pages/domains.list.php
  95. 50
    0
      pages/domains.php
  96. 64
    0
      pages/editpref.php
  97. 62
    0
      pages/editsite.domains.php
  98. 36
    0
      pages/editsite.errors.php
  99. 13
    0
      pages/editsite.overview.php
  100. 0
    0
      pages/editsite.php

+ 5
- 0
.htaccess View File

@@ -0,0 +1,5 @@
1
+RewriteEngine On
2
+
3
+RewriteRule ^([a-z0-9]+)$ /control/$1.php [L]
4
+RewriteRule ^([a-z]+)/([0-9]+)$ /control/$1.php?n=$2 [L]
5
+RewriteRule ^([a-z]+)/([0-9]+)/(.*?)$ /control/$1.php?n=$2&f=$3 [L]

+ 21
- 0
403.php View File

@@ -0,0 +1,21 @@
1
+<?PHP
2
+
3
+ define('FORBIDDEN', true);
4
+ define('NOLOGINREF', true);
5
+
6
+ require_once('lib/common.php');
7
+ require_once('lib/database.php');
8
+ require_once('lib/dashboard.php');
9
+ require_once('lib/account.php');
10
+
11
+ define('TITLE', 'Forbidden');
12
+
13
+ addDashboardItem('Useful links', 'Support section', 'support');
14
+
15
+ if (!defined('REASON')) { header('Location: '.CP_PATH.'login'); }
16
+ 
17
+ require_once('lib/header.php');
18
+ require_once('pages/forbidden.php');
19
+ require_once('lib/footer.php');
20
+
21
+?>

+ 24
- 0
account.php View File

@@ -0,0 +1,24 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/common.php');
5
+ require_once('lib/database.php');
6
+ require_once('lib/account.php');
7
+ 
8
+ define('TITLE', 'My Account');
9
+ 
10
+ addDashboardItem('Frequently asked questions', 'How do I pay outstanding bills?', 'support/008');
11
+ addDashboardItem('Useful links', 'Change password', 'changepass');
12
+ addDashboardItem('Useful links', 'Apply discount', 'discount');
13
+ addDashboardItem('Useful links', 'My invoices', 'invoices');
14
+ addDashboardItem('Useful links', 'Referrals', 'ref');
15
+
16
+ require_once('lib/header.php');
17
+ 
18
+ require_once('pages/prefs.php');
19
+ require_once('pages/packages.php');
20
+  
21
+ require_once('lib/footer.php');
22
+
23
+
24
+?>

+ 74
- 0
addsite.php View File

@@ -0,0 +1,74 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/common.php');
5
+ require_once('lib/account.php');
6
+
7
+ checkAccess(HAS_HOSTING);
8
+ 
9
+ define('TITLE', 'Add site');
10
+ 
11
+ addDashboardItem('Useful links', 'Support center', 'support');
12
+  
13
+ function meep () {
14
+  if (!isset($_POST['docroot']) || !isset($_POST['domain'])) {
15
+   return;
16
+  }
17
+  if (!ctype_digit($_POST['domain'])) {
18
+   define('MESSAGE', 'Invalid domain name');
19
+   return;
20
+  }
21
+  $path = '/home/'.USER.'/'.$_POST['docroot'];
22
+  $path = preg_replace('#/(.*?)/\.\./#','/',$path);
23
+  $path = preg_replace('#//+#','/',$path);
24
+  $path = preg_replace('#/\./#', '/', $path);
25
+  if (substr($path, 0, strlen('/home/'.USER.'/')) != '/home/'.USER.'/') {
26
+   logger::log('Potential attack; attempted to create site with doc root "'.$_POST['docroot'].'"',logger::normal);
27
+   define('MESSAGE', 'Invalid document root');
28
+   return;
29
+  }
30
+  if (substr($path,-1) == '/') { $path = substr($path,0,-1); }
31
+  $sql = 'SELECT user_id, domain_name FROM domains WHERE domain_id = '.m($_POST['domain']);
32
+  $res = mq($sql, __FILE__, __LINE__);
33
+  if (mysql_num_rows($res) == 0) {
34
+   define('MESSAGE', 'No such domain name');
35
+   return;
36
+  }
37
+  $row = mysql_fetch_array($res);
38
+  if ($row['user_id'] != UID) {
39
+   logger::log('Potential attack; attempted to create site with domain name "'.$row['domain_name'].'" (belongs to another user)', logger::normal);
40
+   define('MESSAGE', 'No such domain name');
41
+   return;
42
+  }
43
+  $sql = 'SELECT record_value FROM records WHERE domain_id = '.m($_POST['domain']).' AND record_type = \'UTD\'';
44
+  $re2 = mq($sql, __FILE__, __LINE__);
45
+  if (mysql_num_rows($re2) > 0) {
46
+   define('MESSAGE', 'Domain name is already associated with another site.');
47
+   return;
48
+  }
49
+  $sql = 'INSERT INTO sites (user_id, site_name, site_docroot, site_curdocroot) VALUES ('.UID.', \''.m($row['domain_name']).'\',\''.m($path).'\',\''.m($path).'\')';
50
+  $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
51
+  $id = mysql_insert_id();
52
+  $sql = 'INSERT INTO records (record_type, domain_id, record_value) VALUES (\'UTD\', '.m($_POST['domain']).', \''.m($id).'\')';
53
+  mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
54
+
55
+  $sql  = 'INSERT INTO actions (user_id, action_type, action_value) VALUES (';
56
+  $sql .= UID . ', \'updateconf\', \'bind\')';
57
+  mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
58
+
59
+  logger::log('Added site: '.$row['domain_name'].' ['.$path.']', logger::info);
60
+  header('Location: '.CP_PATH.'editsite/'.$id);
61
+  exit;
62
+ }
63
+
64
+ meep();
65
+
66
+
67
+ require_once('lib/header.php');
68
+ 
69
+ require_once('pages/addsite.php');
70
+ 
71
+ require_once('lib/footer.php');
72
+
73
+
74
+?>

+ 17
- 0
admin.menu.php View File

@@ -0,0 +1,17 @@
1
+<?PHP
2
+
3
+ addDashboardItem('Admin pages', '*Main menu' ,'admin');
4
+ addDashboardItem('Admin pages', 'Ticket management', 'admintickets');
5
+ addDashboardItem('Admin pages', 'Invoice management', 'admininvoices');
6
+ addDashboardItem('Admin pages', 'Ban management', 'adminbans');
7
+ addDashboardItem('Admin pages', 'Discount management', 'admindiscounts');
8
+ addDashboardItem('Admin pages', 'Finances', 'adminfinances');
9
+ addDashboardItem('Admin pages', 'User management', 'adminusers');
10
+ addDashboardItem('Admin pages', 'Domain management', 'admindomains');
11
+ addDashboardItem('Admin pages', 'Site management', 'adminsites');
12
+ addDashboardItem('Admin pages', 'Reports', 'adminreports');
13
+ addDashboardItem('Admin pages', 'Wiki', 'adminwiki');
14
+ addDashboardItem('Admin pages', 'Logs', 'adminlogs');
15
+ addDashboardItem('Admin pages', 'Announcements', 'adminannouncements');
16
+
17
+?>

+ 31
- 0
admin.php View File

@@ -0,0 +1,31 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/account.php');
5
+
6
+ checkAccess(ADMIN);
7
+
8
+ if (count($_POST) > 0) {
9
+  foreach ($_POST as $key => $value) {
10
+   list($service, $action) = explode('_', $key);
11
+   $sql  = 'INSERT INTO actions (user_id, action_type, action_value) VALUES (';
12
+   $sql .= UID . ', \'' . m($action) . '\', \'' . m($service) . '\')';
13
+   mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
14
+   define('MESSAGE', 'Action scheduled');
15
+   break;
16
+  }
17
+ }
18
+
19
+ require_once('admin.menu.php');
20
+ 
21
+ define('TITLE', 'Admin');
22
+
23
+ require_once('lib/header.php');
24
+
25
+ require_once('pages/admin.menu.php');
26
+ require_once('pages/admin.actions.php');
27
+ 
28
+ require_once('lib/footer.php');
29
+
30
+
31
+?>

+ 52
- 0
adminannouncements.php View File

@@ -0,0 +1,52 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/account.php');
5
+
6
+ checkAccess(ADMIN);
7
+ 
8
+ define('TITLE', 'Admin - Announcements');
9
+
10
+ require_once('admin.menu.php');
11
+
12
+ if (get_magic_quotes_gpc()) {
13
+  foreach ($_POST as $k => $v) {
14
+   $_POST[$k] = stripslashes($v);
15
+  }
16
+ }
17
+
18
+ if (isset($_POST['title']) && isset($_POST['type']) && isset($_POST['body'])) {
19
+  if (isset($_POST['preview'])) {
20
+   define('MESSAGE_TITLE', $_POST['title']);
21
+   define('MESSAGE_TYPE', 'preview: ' . $_POST['type']);
22
+   define('MESSAGE_TIME', time());  
23
+   define('MESSAGE_BODY', $_POST['body']);
24
+
25
+   require_once('lib/header.php');
26
+   require_once('pages/viewmessage.php');
27
+  } else {
28
+   $sql  = 'INSERT INTO messages (message_type, message_title, message_time,';
29
+   $sql .= ' message_body) VALUES (\'' . m($_POST['type']) . '\', \'';
30
+   $sql .= m($_POST['title']) . '\', ' . time() . ', \'' . m($_POST['body']);
31
+   $sql .= '\')';
32
+
33
+   mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
34
+
35
+   if ($_POST['type'] == 'announcement') {
36
+    require_once('/home/utd/common/messagemail.php');
37
+    messagemail(mysql_insert_id());  
38
+   }
39
+
40
+   header('Location: ' . CP_PATH . 'adminannouncements');
41
+   exit();
42
+  }
43
+ } else {
44
+  require_once('lib/header.php');
45
+  require_once('pages/admin.announcements.php');
46
+ }
47
+ require_once('pages/admin.addannouncement.php');
48
+ 
49
+ require_once('lib/footer.php');
50
+
51
+
52
+?>

+ 57
- 0
adminbans.php View File

@@ -0,0 +1,57 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/account.php');
5
+
6
+ checkAccess(ADMIN);
7
+ 
8
+ define('TITLE', 'Admin - Ban management');
9
+
10
+ if (isset($_GET['n']) && ctype_digit($_GET['n'])) {
11
+  $sql  = 'SELECT ipban_ip, ipban_expires FROM ipbans WHERE ipban_id = ';
12
+  $sql .= $_GET['n'];
13
+  $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
14
+  $row = mysql_fetch_array($res);
15
+  logger::log('Expiring ban on '.$row['ipban_ip'].' (expirary: '.duration($row[
16
+'ipban_expires'] - time()).'; id: '.$_GET['n'].')', logger::normal);
17
+  $sql = 'UPDATE ipbans SET ipban_expires = 0 WHERE ipban_id = '.$_GET['n'];
18
+  mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
19
+  header('Location: '.CP_PATH.'adminbans');
20
+  exit;
21
+ }
22
+
23
+ if (isset($_GET['d']) && ctype_digit($_GET['d'])) {
24
+  $sql  = 'SELECT ipban_ip, ipban_expires FROM ipbans WHERE ipban_id = ';
25
+  $sql .= $_GET['d'];
26
+  $res  = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
27
+  $row  = mysql_fetch_assoc($res);
28
+
29
+  logger::log('Deleting ban on '.$row['ipban_ip'].' (expirary: '.duration($row['ipban_expires'] - time(), true).'; id: '.$_GET['d'].')', logger::normal);
30
+
31
+  $sql = 'DELETE FROM ipbans WHERE ipban_id = ' . $_GET['d'];
32
+  $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
33
+  header('Location: '.CP_PATH.'adminbans');
34
+  exit;
35
+ }
36
+
37
+ if (isset($_POST['ip'])) {
38
+  $sql  = 'INSERT INTO ipbans (ipban_ip, ipban_message, ipban_expires) VALUES ';
39
+  $sql .= '(\''.m($_POST['ip']).'\', \''.m($_POST['reason']).'\', ';
40
+  $sql .= strtotime($_POST['expirary']).')';
41
+  logger::log('Placing ban on '.$_POST['ip'].' (reason: '.$_POST['reason'].'; expirary: '.duration(strtotime($_POST['expirary'])-time()).')', logger::normal);
42
+  mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
43
+  header('Location: '.CP_PATH.'adminbans');
44
+  exit;
45
+ }
46
+
47
+ require_once('admin.menu.php');
48
+ require_once('lib/header.php');
49
+
50
+ require_once('pages/admin.ipbans.php');
51
+ require_once('pages/admin.addipban.php');
52
+ require_once('pages/admin.userbans.php');
53
+ 
54
+ require_once('lib/footer.php');
55
+
56
+
57
+?>

+ 29
- 0
adminbw.php View File

@@ -0,0 +1,29 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/account.php');
5
+
6
+ checkAccess(ADMIN);
7
+ 
8
+ define('TITLE', 'Admin - Bandwidth');
9
+
10
+  addDashboardItem('Other admin tools', 'Sites', 'adminsites');
11
+  addDashboardItem('Other admin tools', 'Reports', 'reports');
12
+  addDashboardItem('Other admin tools', 'Discounts', 'discounts');
13
+  addDashboardItem('Other admin tools', 'Bans', 'bans');
14
+  addDashboardItem('External tools', 'Wiki', 'http://admin.utd-hosting.com/wiki');
15
+  addDashboardItem('External tools', 'Service monitor', 'http://admin.utd-hosting.com/mon');
16
+  addDashboardItem('External tools', 'Finances', 'http://admin.utd-hosting.com/finances');
17
+ 
18
+ require_once('lib/header.php');
19
+
20
+ if (defined('ADMIN') && ADMIN) {
21
+  require_once('pages/adminbw.php');
22
+ } else {
23
+  define('ERROR', 'You\'re no admin!');
24
+ }
25
+ 
26
+ require_once('lib/footer.php');
27
+
28
+
29
+?>

+ 41
- 0
admindiscounts.php View File

@@ -0,0 +1,41 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/account.php');
5
+
6
+ checkAccess(ADMIN);
7
+ 
8
+ define('TITLE', 'Admin - Discount management');
9
+
10
+ require_once('admin.menu.php');
11
+
12
+ if (isset($_POST['from']) && isset($_POST['to']) && isset($_POST['timequant'])
13
+	&& isset($_POST['timeunit']) && isset($_POST['money'])
14
+	&& isset($_POST['type']) && isset($_POST['package'])
15
+        && isset($_POST['code'])) {
16
+  $message = isset($_POST['message']) ? m($_POST['message']) : '';
17
+  $time = (int) $_POST['timeunit'] * (int) $_POST['timequant'];
18
+
19
+  $sql  = 'INSERT INTO discounts (package_id, discount_code, discount_time, ';
20
+  $sql .= 'discount_money, discount_type, discount_start, discount_end, ';
21
+  $sql .= 'discount_message) VALUES (' . ((int) $_POST['package']) . ', \'';
22
+  $sql .= m($_POST['code']) . '\', ' . $time . ', ' . ((int) $_POST['money']);
23
+  $sql .= ', \'' . m($_POST['type']) . '\', ' . strtotime($_POST['from']);
24
+  $sql .= ', '. strtotime($_POST['to']) . ', \'' . $message . ' \')';
25
+  mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
26
+
27
+  logger::log('Added discount code: ' . $_POST['code'] .' (' . duration($_POST['time'], 0) . ' / ' . $_POST['money'] . ')', logger::information);
28
+
29
+  header('Location: ' . CP_PATH . 'admindiscounts');
30
+  exit();
31
+ }
32
+ 
33
+ require_once('lib/header.php');
34
+
35
+ require_once('pages/admin.discounts.php');
36
+ require_once('pages/admin.adddiscount.php');
37
+ 
38
+ require_once('lib/footer.php');
39
+
40
+
41
+?>

+ 19
- 0
admindomains.php View File

@@ -0,0 +1,19 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/account.php');
5
+
6
+ checkAccess(ADMIN);
7
+ 
8
+ define('TITLE', 'Admin - Domain management');
9
+
10
+ require_once('admin.menu.php');
11
+ 
12
+ require_once('lib/header.php');
13
+
14
+ require_once('pages/admin.domains.php');
15
+ 
16
+ require_once('lib/footer.php');
17
+
18
+
19
+?>

+ 20
- 0
adminfinances.php View File

@@ -0,0 +1,20 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/account.php');
5
+
6
+ checkAccess(ADMIN);
7
+ 
8
+ define('TITLE', 'Admin - Finances');
9
+
10
+ require_once('admin.menu.php');
11
+ 
12
+ require_once('lib/header.php');
13
+
14
+ require_once('pages/admin.finances.php');
15
+ require_once('pages/admin.addfinances.php');
16
+ 
17
+ require_once('lib/footer.php');
18
+
19
+
20
+?>

+ 18
- 0
admininvoices.php View File

@@ -0,0 +1,18 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/account.php');
5
+
6
+ checkAccess(ADMIN);
7
+ 
8
+ define('TITLE', 'Admin - Invoice management');
9
+
10
+ require_once('admin.menu.php');
11
+ require_once('lib/header.php');
12
+
13
+ require_once('pages/admin.invoices.php');
14
+ 
15
+ require_once('lib/footer.php');
16
+
17
+
18
+?>

+ 18
- 0
adminreports.php View File

@@ -0,0 +1,18 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/account.php');
5
+
6
+ checkAccess(ADMIN);
7
+ 
8
+ define('TITLE', 'Admin - Reports');
9
+
10
+ require_once('admin.menu.php'); 
11
+ require_once('lib/header.php');
12
+
13
+ require_once('pages/reports/bigfiles.php');
14
+ 
15
+ require_once('lib/footer.php');
16
+
17
+
18
+?>

+ 18
- 0
adminsites.php View File

@@ -0,0 +1,18 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/account.php');
5
+
6
+ checkAccess(ADMIN);
7
+ 
8
+ define('TITLE', 'Admin - Site management');
9
+
10
+ require_once('admin.menu.php'); 
11
+ require_once('lib/header.php');
12
+
13
+ require_once('pages/admin.sites.php');
14
+ 
15
+ require_once('lib/footer.php');
16
+
17
+
18
+?>

+ 18
- 0
admintickets.php View File

@@ -0,0 +1,18 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/account.php');
5
+
6
+ checkAccess(ADMIN);
7
+ 
8
+ define('TITLE', 'Admin - Ticket management');
9
+
10
+ require_once('admin.menu.php'); 
11
+ require_once('lib/header.php');
12
+
13
+ require_once('pages/admin.tickets.php');
14
+ 
15
+ require_once('lib/footer.php');
16
+
17
+
18
+?>

+ 18
- 0
adminusers.php View File

@@ -0,0 +1,18 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/account.php');
5
+
6
+ checkAccess(ADMIN);
7
+ 
8
+ define('TITLE', 'Admin - User management');
9
+
10
+ require_once('admin.menu.php');
11
+ require_once('lib/header.php');
12
+
13
+ require_once('pages/admin.users.php');
14
+ 
15
+ require_once('lib/footer.php');
16
+
17
+
18
+?>

+ 20
- 0
alltickets.php View File

@@ -0,0 +1,20 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ 
5
+ define('TITLE', ' All Tickets');
6
+ 
7
+ addDashboardItem('Useful links', 'Support center', 'support');
8
+ addDashboardItem('Useful links', 'Raise a ticket', 'tickets');
9
+  
10
+ addDashboardItem('Frequently asked questions', 'Can I file support requests without using the control panel?', 'support/005');
11
+ addDashboardItem('Frequently asked questions', 'How do I reopen a ticket?', 'support/014');
12
+
13
+ require_once('lib/header.php');
14
+ 
15
+ require_once('pages/alltickets.php');
16
+ 
17
+ require_once('lib/footer.php');
18
+
19
+
20
+?>

+ 21
- 0
bandwidth.php View File

@@ -0,0 +1,21 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/account.php');
5
+ 
6
+ define('TITLE', 'Bandwidth breakdown');
7
+ 
8
+ addDashboardItem('Useful links', 'Account overview', '');
9
+ addDashboardItem('Useful links', 'View extended site details', 'sites');
10
+ 
11
+ addDashboardItem('Frequently asked questions', 'What does KiB/MiB/GiB mean?', 'support/003');
12
+
13
+ require_once('lib/header.php');
14
+ 
15
+ require_once('pages/bandwidthgraph.php');
16
+ require_once('pages/bandwidthtable.php');
17
+ 
18
+ require_once('lib/footer.php');
19
+
20
+
21
+?>

+ 54
- 0
bans.php View File

@@ -0,0 +1,54 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/account.php');
5
+ 
6
+ define('TITLE', 'Admin - Ban management');
7
+
8
+ addDashboardItem('Other admin tools', 'Overview', 'admin');
9
+ addDashboardItem('Other admin tools', 'Sites', 'adminsites');
10
+ addDashboardItem('Other admin tools', 'Reports', 'reports');
11
+ addDashboardItem('Other admin tools', 'Discounts', 'discounts');
12
+ addDashboardItem('External tools', 'Wiki', 'http://admin.utd-hosting.com/wiki'
13
+);
14
+ addDashboardItem('External tools', 'Service monitor', 'http://admin.utd-hostin
15
+g.com/mon');
16
+ addDashboardItem('External tools', 'Finances', 'http://admin.utd-hosting.com/f
17
+inances');
18
+
19
+ if (defined('ADMIN') && isset($_GET['n']) && ctype_digit($_GET['n'])) {
20
+  $sql  = 'SELECT ipban_ip, ipban_expires FROM ipbans WHERE ipban_id = ';
21
+  $sql .= $_GET['n'];
22
+  $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
23
+  $row = mysql_fetch_array($res);
24
+  logger::log('Expiring ban on '.$row['ipban_ip'].' (expirary: '.duration($row[
25
+'ipban_expires'] - time()).'; id: '.$_GET['n'].')', logger::normal);
26
+  $sql = 'UPDATE ipbans SET ipban_expires = 0 WHERE ipban_id = '.$_GET['n'];
27
+  mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
28
+  header('Location: '.CP_PATH.'bans');
29
+  exit;
30
+ }
31
+ if (defined('ADMIN') && isset($_POST['ip'])) {
32
+  $sql  = 'INSERT INTO ipbans (ipban_ip, ipban_message, ipban_expires) VALUES ';
33
+  $sql .= '(\''.m($_POST['ip']).'\', \''.m($_POST['reason']).'\', ';
34
+  $sql .= strtotime($_POST['expirary']).')';
35
+  logger::log('Placing ban on '.$_POST['ip'].' (reason: '.$_POST['reason'].'; expirary: '.duration(strtotime($_POST['expirary'])-time()).')', logger::normal);
36
+  mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
37
+  header('Location: '.CP_PATH.'bans');
38
+  exit;
39
+ }
40
+
41
+ 
42
+ require_once('lib/header.php');
43
+
44
+ if (defined('ADMIN') && ADMIN) {
45
+  require_once('pages/adminipbans.php');
46
+  require_once('pages/adminaddipban.php');
47
+ } else {
48
+  define('ERROR', 'You\'re no admin!');
49
+ }
50
+ 
51
+ require_once('lib/footer.php');
52
+
53
+
54
+?>

+ 75
- 0
billing.php View File

@@ -0,0 +1,75 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/common.php');
5
+ require_once('lib/database.php');
6
+ require_once('lib/account.php');
7
+ 
8
+ define('TITLE', 'Billing');
9
+ 
10
+ addDashboardItem('Frequently asked questions', 'How do I pay outstanding bills?', 'support/008');
11
+
12
+ function foo() {
13
+  if (!isset($_POST['code']) || m($_POST['code']) != $_POST['code']) {
14
+   return;
15
+  }
16
+  $sql = 'SELECT discount_id, discount_time, discount_money, discount_start, discount_end, discount_type, discount_message FROM discounts WHERE discount_code = \''.$_POST['code'].'\''; 
17
+  $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
18
+  if (mysql_num_rows($res) == 0) {
19
+   define('MESSAGE', 'That discount code does not exist.');
20
+   l('Non-existant discount code used: '.$_POST['code']);
21
+   return;
22
+  } 
23
+  $row = mysql_fetch_array($res);
24
+  if ($row['discount_start'] > time()) {
25
+   define('MESSAGE', 'That discount is not yet valid.'); 
26
+   l('Discount code used prematurely: '.$_POST['code']);
27
+   return;
28
+  }
29
+  if ($row['discount_end'] < time()) {
30
+   define('MESSAGE', 'That discount is no longer valid.');
31
+   l('Discount code expired: '.$_POST['code']);
32
+   return;
33
+  }
34
+  if ($row['discount_type'] != 'general') {
35
+   define('MESSAGE', 'That discount is for new signups only.');
36
+   l('Signup discount code used: '.$_POST['code']);
37
+   return;
38
+  }
39
+  $sql2 = 'SELECT du_id FROM discountusers WHERE discount_id = '.$row['discount_id'].' AND user_id = '.UID;
40
+  $res2 = mysql_query($sql2) or mf(__FILE__, __LINE__, $sql2);
41
+  if (mysql_num_rows($res2) > 0) {
42
+   define('MESSAGE', 'You have already claimed that discount.');
43
+   l('Already used discount code: '.$_POST['code']);
44
+   return;
45
+  }
46
+  $sql2 = 'SELECT bill_id, bill_due, bill_amount FROM billing WHERE user_id = '.UID.' AND bill_paid <> 2';
47
+  $res2 = mysql_query($sql2) or mf(__FILE__, __LINE__, $sql2);
48
+  $row2 = mysql_fetch_array($res2);
49
+  $row2['bill_due'] += $row['discount_time'];
50
+  $row2['bill_amount'] -= $row['discount_money'];
51
+  $sql2 = 'UPDATE billing SET bill_due = '.$row2['bill_due'].', bill_amount = '.$row2['bill_amount'].', bill_paid = 0 WHERE bill_id = '.$row2['bill_id'];
52
+  mysql_query($sql2) or mf(__FILE__, __LINE__, $sql2);
53
+  $sql2 = 'INSERT INTO discountusers (discount_id, user_id) VALUES ('.$row['discount_id'].','.UID.')';
54
+  mysql_query($sql2) or mf(__FILE__, __LINE__, $sql2);
55
+  l('Discount code applied: '.$_POST['code']);
56
+  if ($row['discount_time'] > 0 && $row['discount_money'] == 0) {
57
+   define('MESSAGE', 'Your current billing period has been extended by '.round($row['discount_time']/2629728,2).' month(s). '.$row['discount_message']);
58
+  } elseif ($row['discount_time'] == 0) {
59
+   define('MESSAGE', 'Your next bill has been reduced by £'.($row['discount_money']/100).'. '.$row['discount_message']);
60
+  } else {
61
+   define('MESSAGE', 'Your current billing period has been extended by '.round($row['discount_time']/2629728,2).' month(s), and the next bill has been reduced bby £'.($row['discount_money']/100).'. '.$row['discount_message']);
62
+  }
63
+ }
64
+ 
65
+ foo();
66
+
67
+ require_once('lib/header.php');
68
+ 
69
+ require_once('pages/billing.php');
70
+ if (!defined('NODISCOUNT')) { require_once('pages/discount.php'); }
71
+  
72
+ require_once('lib/footer.php');
73
+
74
+
75
+?>

+ 9
- 0
billingref.php View File

@@ -0,0 +1,9 @@
1
+<?PHP
2
+
3
+ define('NOBILLREF', true);
4
+
5
+ define('MESSAGE', 'Your access to this control panel is restricted, pending payment of your overdue bills.<br>Please e-mail support@utd-hosting.com if you require assistance.');
6
+
7
+ require('billing.php');
8
+
9
+?>

+ 36
- 0
changepass.php View File

@@ -0,0 +1,36 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/account.php');
5
+ 
6
+ define('TITLE', 'Change password');
7
+ 
8
+ addDashboardItem('Useful links', 'Account overview', '');
9
+ addDashboardItem('Useful links', 'My account', 'account');
10
+
11
+ if (isset($_POST['curpass']) && isset($_POST['pass1']) && isset($_POST['pass2'])) {
12
+  if ($_POST['pass1'] == $_POST['pass2']) {
13
+   if (md5(USER.$_POST['curpass']) == PASS) {
14
+    if (($error = validPass($_POST['pass1'])) === true) {
15
+     changePass(UID, $_POST['pass1']);     
16
+     logger::log('Changed password.',logger::information);
17
+     define('MESSAGE', 'Password updated.');
18
+    } else {
19
+     define('MESSAGE', $error);
20
+    }
21
+   } else {
22
+    define('MESSAGE', 'Incorrect password. Please enter your current password.');
23
+   }
24
+  } else {
25
+   define('MESSAGE', 'Your passwords do not match. Please re-enter your new password.');
26
+  }
27
+ }
28
+ 
29
+ require_once('lib/header.php');
30
+ 
31
+ require_once('pages/pass.php');
32
+ 
33
+ require_once('lib/footer.php');
34
+
35
+
36
+?>

+ 24
- 0
checkuser.php View File

@@ -0,0 +1,24 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/account.php');
5
+
6
+ checkAccess(ADMIN);
7
+ 
8
+ define('TITLE', 'Check user');
9
+
10
+ addDashboardItem('Other admin tools', 'Overview', 'admin');
11
+ addDashboardItem('Other admin tools', 'Reports', 'reports');
12
+ 
13
+ require_once('lib/header.php');
14
+
15
+ if (defined('ADMIN') && ADMIN) {
16
+  require_once('pages/adminculog.php');
17
+ } else {
18
+  define('ERROR', 'You\'re no admin!');
19
+ }
20
+ 
21
+ require_once('lib/footer.php');
22
+
23
+
24
+?>

+ 197
- 0
database.php View File

@@ -0,0 +1,197 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/common.php');
5
+ require_once('lib/account.php');
6
+
7
+ checkAccess(HAS_HOSTING);
8
+
9
+ if (isset($_POST['action'])) {
10
+  if ($_POST['action'] == 'adduser' && isset($_POST['dbuser']) && isset($_POST['dbpass'])) {
11
+   if (strlen(USER.'_'.$_POST['dbuser']) <= 16) {
12
+    $sql = 'INSERT INTO db_users (user_id, dbuser_name) VALUES ('.UID.', \'';
13
+    $sql .= USER.'_'.m($_POST['dbuser']).'\')';
14
+    $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
15
+    if (mysql_affected_rows() > 0) {
16
+     //GRANT USAGE ON * . * TO 'test'@'localhost' IDENTIFIED BY '***' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 ;
17
+     logger::log('Database user created: '.$_POST['dbuser'],logger::info);
18
+     $sql = 'GRANT USAGE ON *.* to \''.USER.'_';
19
+     $sql .= m($_POST['dbuser']).'\'@\'localhost\'';
20
+     $sql .= ' IDENTIFIED BY \''.m($_POST['dbpass']).'\'';
21
+     $sql .= ' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0';
22
+     $sql .= ' MAX_UPDATES_PER_HOUR 0';
23
+     $l = mysql_connect('localhost', 'root', 'mysql32159');;
24
+     mysql_select_db('admin', $l);
25
+     mysql_query($sql,$l) or mf(__FILE__, __LINE__, $sql);
26
+     mysql_close($l);
27
+     $_redodb = true; require('lib/database.php'); unset($_redodb);
28
+    } else {
29
+     define('MESSAGE', 'Unable to add. Please raise a ticket.');
30
+    }
31
+   } else {
32
+    define('MESSAGE', 'The total length of MySQL usernames (including \''.USER.'_\') must be sixteen characters or under.');
33
+   }
34
+  } elseif ($_POST['action'] == 'adddb' && isset($_POST['newdb'])) {
35
+   $sql = 'INSERT INTO db_dbs (user_id, db_name) VALUES ('.UID.', \'';
36
+   $sql .= USER.'_'.m($_POST['newdb']).'\')';
37
+   $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
38
+   if (mysql_affected_rows() > 0) {
39
+    //GRANT ALL PRIVILEGES ON `admin` . * TO 'md87'@'localhost' WITH GRANT OPTION ;
40
+    logger::log('Database created: '.$_POST['newdb'], logger::info);
41
+    $sql = 'CREATE DATABASE `'.USER.'_'.m($_POST['newdb']).'`';
42
+    $l = mysql_connect('localhost', 'root', 'mysql32159');;
43
+    mysql_select_db('admin', $l);
44
+    mysql_query($sql,$l) or mf(__FILE__, __LINE__, $sql);
45
+    $sql = 'GRANT ALL PRIVILEGES ON `'.USER.'_'.m($_POST['newdb']).'`.* TO \''.USER.'\'@\'localhost\'';
46
+    mysql_query($sql,$l) or mf(__FILE__, __LINE__, $sql);
47
+    mysql_close($l);
48
+    $_redodb = true; require('lib/database.php'); unset($_redodb);
49
+   } else {
50
+    define('MESSAGE', 'Unable to add. Please raise a ticket.');
51
+   }
52
+  } elseif ($_POST['action'] == 'perms') {
53
+   $sql = 'SELECT dbuser_id, dbuser_name FROM db_users WHERE user_id = '.UID;
54
+   $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
55
+   $users = array();
56
+   while ($row = mysql_fetch_array($res)) {
57
+    $users[($row[0])] = $row[1];
58
+   }
59
+   $sql = 'SELECT db_id, db_name FROM db_dbs WHERE user_id = '.UID;
60
+   $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
61
+   $dbs = array();
62
+   while ($row = mysql_fetch_array($res)) {
63
+    $dbs[($row[0])] = str_replace('_','\_',$row[1]);
64
+   }
65
+   $sql = 'SELECT db_perms.dbuser_id, db_id FROM db_perms NATURAL JOIN db_users WHERE user_id = '.UID;
66
+   $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
67
+   $perms = array();
68
+   while ($row = mysql_fetch_array($res)) {
69
+    if (!isset($perms[($row[0])])) { $perms[($row[0])] = array(); }
70
+    $perms[($row[0])][($row[1])] = true;
71
+   }
72
+   $remove = $perms; $add = array();
73
+   foreach ($_POST as $k => $v) {
74
+    if ($v != 'on' && $v != 'checked') { continue; }
75
+    $bits = explode('_', $k);
76
+    if ($bits[0] != 'dbp') { continue; }
77
+    if (!isset($dbs[($bits[1])])) { continue; }
78
+    if (!isset($users[($bits[2])])) { continue; }
79
+    if (isset($remove[($bits[2])][($bits[1])])) {
80
+     unset($remove[($bits[2])][($bits[1])]);
81
+    } else {
82
+     if (!isset($add[($bits[2])])) { $add[($bits[2])] = array(); }
83
+     $add[($bits[2])][($bits[1])] = true;
84
+    }
85
+   }
86
+   $l = mysql_connect('localhost', 'root', 'mysql32159');;
87
+   mysql_select_db('admin', $l);
88
+   mysql_query($sql,$l) or mf(__FILE__, __LINE__, $sql);
89
+
90
+   foreach ($remove as $user => $dat) {
91
+    foreach ($dat as $db => $true) {
92
+     $sql = 'DELETE FROM db_perms WHERE dbuser_id = '.$user.' AND db_id = '.$db;
93
+     mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
94
+     $sql = 'REVOKE ALL PRIVILEGES ON `'.$dbs[$db].'`.* FROM \''.$users[$user].'\'@\'localhost\'';
95
+     mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
96
+     logger::log('Revoked db permission: '.$users[$user].' on '.$dbs[$db],logger::info);
97
+    }
98
+   }
99
+
100
+   foreach ($add as $user => $dat) {
101
+    foreach ($dat as $db => $true) {
102
+     $sql = 'INSERT INTO db_perms (dbuser_id, db_id) VALUES ('.$user.', '.$db.')';
103
+     mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
104
+     $sql = 'GRANT ALL PRIVILEGES ON `'.$dbs[$db].'`.* TO \''.$users[$user].'\'@\'localhost\'';
105
+     mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
106
+     logger::log('Added db permission: '.$users[$user].' on '.$dbs[$db], logger::info);
107
+    }
108
+   } 
109
+
110
+   mysql_close($l);
111
+   $_redodb = true; require('lib/database.php'); unset($_redodb);
112
+   header('Location: '.CP_PATH.'database');
113
+   exit;
114
+  }
115
+ }
116
+
117
+ if (isset($_POST['delete'])) {
118
+  if (isset($_POST['confirm'])) {
119
+   $sql = 'SELECT db_id, db_name FROM db_dbs WHERE user_id = '.UID.' AND (0';
120
+   foreach ($_POST as $k => $v) {
121
+    if (substr($k,0,2) == 'db' && ctype_digit(substr($k,2))) {
122
+     $sql .= ' OR db_id = '.m(substr($k,2));
123
+    }
124
+   }
125
+   $sql .= ')';
126
+   $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
127
+   $targets = array();
128
+   while ($row = mysql_fetch_array($res)) {
129
+    $sql = 'DELETE FROM db_perms WHERE db_id = '.$row['db_id'];
130
+    mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
131
+    $sql = 'DELETE FROM db_dbs WHERE db_id = '.$row['db_id'];
132
+    mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
133
+    logger::log('Deleted MySQL database: '.$row['db_name'], logger::info);
134
+    $targets[] = $row['db_name'];
135
+   }
136
+   $l = mysql_connect('localhost', 'root', 'mysql32159');;
137
+   mysql_select_db('admin', $l);
138
+   foreach ($targets as $db) {
139
+    $sql = 'DROP DATABASE `'.m($db).'`'; 
140
+    mysql_query($sql,$l) or mf(__FILE__, __LINE__, $sql);
141
+   }
142
+   mysql_close($l);
143
+   $_redodb = true; require('lib/database.php'); unset($_redodb);
144
+   header('Location: '.CP_PATH.'database');
145
+   exit;
146
+  } else {
147
+   define('MESSAGE', 'Please confirm database deletion');
148
+  }
149
+ } elseif (isset($_POST['userdelete'])) {
150
+  if (isset($_POST['confirm'])) {
151
+   $sql = 'SELECT dbuser_id, dbuser_name FROM db_users WHERE user_id = '.UID.' AND (0';
152
+   foreach ($_POST as $k => $v) {
153
+    if (substr($k,0,4) == 'user' && ctype_digit(substr($k,4))) {
154
+     $sql .= ' OR dbuser_id = '.m(substr($k,4));
155
+    }
156
+   }
157
+   $sql .= ')';
158
+   $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
159
+   $targets = array();
160
+   while ($row = mysql_fetch_array($res)) {
161
+    $sql = 'DELETE FROM db_perms WHERE dbuser_id = '.$row['dbuser_id'];
162
+    mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
163
+    $sql = 'DELETE FROM db_users WHERE dbuser_id = '.$row['dbuser_id'];
164
+    mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
165
+    logger::log('Deleted MySQL user: '.$row['dbuser_name'], logger::info);
166
+    $targets[] = $row['dbuser_name'];
167
+   }
168
+   $l = mysql_connect('localhost', 'root', 'mysql32159');;
169
+   mysql_select_db('admin', $l);
170
+   foreach ($targets as $db) {
171
+    $sql = 'DROP USER \''.m($db)."'@'localhost'";
172
+    mysql_query($sql,$l) or mf(__FILE__, __LINE__, $sql);
173
+   }
174
+   mysql_close($l);
175
+   $_redodb = true; require('lib/database.php'); unset($_redodb);
176
+   header('Location: '.CP_PATH.'database');
177
+   exit;
178
+  } else {
179
+   define('MESSAGE', 'Please confirm user deletion');
180
+  }
181
+ }
182
+
183
+ 
184
+ define('TITLE', 'Databases');
185
+ 
186
+ addDashboardItem('Useful links', 'phpMyAdmin', 'phpMyAdmin');
187
+
188
+ require_once('lib/header.php');
189
+ 
190
+ require_once('pages/dbusers.php');
191
+ require_once('pages/dbdbs.php');
192
+ require_once('pages/dbperms.php');
193
+ 
194
+ require_once('lib/footer.php');
195
+
196
+
197
+?>

+ 74
- 0
discount.php View File

@@ -0,0 +1,74 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/common.php');
5
+ require_once('lib/database.php');
6
+ require_once('lib/account.php');
7
+ 
8
+ define('TITLE', 'Apply Discount');
9
+ 
10
+ addDashboardItem('Frequently asked questions', 'How do I pay outstanding bills?', 'support/008');
11
+
12
+ function foo() {
13
+  if (!isset($_POST['code']) || m($_POST['code']) != $_POST['code']) {
14
+   return;
15
+  }
16
+  $sql = 'SELECT discount_id, discount_time, discount_money, discount_start, discount_end, discount_type, discount_message FROM discounts WHERE discount_code = \''.$_POST['code'].'\''; 
17
+  $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
18
+  if (mysql_num_rows($res) == 0) {
19
+   define('MESSAGE', 'That discount code does not exist.');
20
+   logger::log('Non-existant discount code used: '.$_POST['code'],logger::normal);
21
+   return;
22
+  } 
23
+  $row = mysql_fetch_array($res);
24
+  if ($row['discount_start'] > time()) {
25
+   define('MESSAGE', 'That discount is not yet valid.'); 
26
+   logger::log('Discount code used prematurely: '.$_POST['code'],logger::normal);
27
+   return;
28
+  }
29
+  if ($row['discount_end'] < time()) {
30
+   define('MESSAGE', 'That discount is no longer valid.');
31
+   logger::log('Discount code expired: '.$_POST['code'],logger::normal);
32
+   return;
33
+  }
34
+  if ($row['discount_type'] != 'general') {
35
+   define('MESSAGE', 'That discount is for new signups only.');
36
+   logger::log('Signup discount code used: '.$_POST['code'],logger::normal);
37
+   return;
38
+  }
39
+  $sql2 = 'SELECT du_id FROM discountusers WHERE discount_id = '.$row['discount_id'].' AND user_id = '.UID;
40
+  $res2 = mysql_query($sql2) or mf(__FILE__, __LINE__, $sql2);
41
+  if (mysql_num_rows($res2) > 0) {
42
+   define('MESSAGE', 'You have already claimed that discount.');
43
+   logger::log('Already used discount code: '.$_POST['code'],logger::normal);
44
+   return;
45
+  }
46
+  $sql2 = 'SELECT up_id, up_expires, up_cost FROM userpackages WHERE user_id = '.UID.' AND up_active = 1';
47
+  $res2 = mysql_query($sql2) or mf(__FILE__, __LINE__, $sql2);
48
+  $row2 = mysql_fetch_array($res2);
49
+  $row2['up_expires'] += $row['discount_time'];
50
+  $row2['up_cost'] -= $row['discount_money'];
51
+  $sql2 = 'UPDATE userpackages SET up_expires = '.$row2['up_expires'].', up_cost = '.$row2['up_cost'].' WHERE up_id = '.$row2['up_id'];
52
+  mysql_query($sql2) or mf(__FILE__, __LINE__, $sql2);
53
+  $sql2 = 'INSERT INTO discountusers (discount_id, user_id) VALUES ('.$row['discount_id'].','.UID.')';
54
+  mysql_query($sql2) or mf(__FILE__, __LINE__, $sql2);
55
+  logger::log('Discount code applied: '.$_POST['code'],logger::information);
56
+  if ($row['discount_time'] > 0 && $row['discount_money'] == 0) {
57
+   define('MESSAGE', 'Your current billing period has been extended by '.duration($row['discount_time']).'. '.$row['discount_message']);
58
+  } elseif ($row['discount_time'] == 0) {
59
+   define('MESSAGE', 'Your next bill has been reduced by &pound;'.($row['discount_money']/100).'. '.$row['discount_message']);
60
+  } else {
61
+   define('MESSAGE', 'Your current billing period has been extended by '.discount($row['discount_time']).', and the next bill has been reduced by &pound;'.($row['discount_money']/100).'. '.$row['discount_message']);
62
+  }
63
+ }
64
+ 
65
+ foo();
66
+
67
+ require_once('lib/header.php');
68
+ 
69
+ require_once('pages/discount.php'); 
70
+  
71
+ require_once('lib/footer.php');
72
+
73
+
74
+?>

+ 32
- 0
discounts.php View File

@@ -0,0 +1,32 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/account.php');
5
+ 
6
+ define('TITLE', 'Discounts');
7
+
8
+ addDashboardItem('Other admin tools', 'Reports', 'reports');
9
+ addDashboardItem('Other admin tools', 'Overview', 'admin');
10
+ addDashboardItem('Other admin tools', 'Sites', 'adminsites');
11
+ addDashboardItem('Other admin tools', 'Bans', 'bans');
12
+
13
+  addDashboardItem('External tools', 'Wiki', 'http://admin.utd-hosting.com/wiki'
14
+);
15
+  addDashboardItem('External tools', 'Service monitor', 'http://admin.utd-hostin
16
+g.com/mon');
17
+  addDashboardItem('External tools', 'Finances', 'http://admin.utd-hosting.com/f
18
+inances');
19
+
20
+ 
21
+ require_once('lib/header.php');
22
+
23
+ if (defined('ADMIN') && ADMIN) {
24
+  require_once('pages/admindiscounts.php');
25
+ } else {
26
+  define('ERROR', 'You\'re no admin!');
27
+ }
28
+ 
29
+ require_once('lib/footer.php');
30
+
31
+
32
+?>

+ 135
- 0
domains.php View File

@@ -0,0 +1,135 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/account.php');
5
+ require_once('lib/database.php');
6
+
7
+ checkAccess(HAS_HOSTING || HAS_DNS);
8
+
9
+ function meep() {
10
+  if (isset($_POST['action'])) {
11
+   if ($_POST['action'] == 'deldom' && isset($_POST['domain']) && preg_match('/^[0-9]+$/',$_POST['domain'])) {
12
+    $sql = 'SELECT user_id, domain_name FROM domains WHERE domain_id = '.$_POST['domain'];
13
+    $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
14
+    if (mysql_num_rows($res) == 0) {
15
+     define('MESSAGE', 'No such domain!');
16
+     return;
17
+    }
18
+    $row = mysql_fetch_array($res);
19
+    $dn = $row['domain_name'];
20
+    if (!defined('ADMIN') && $row['user_id'] != UID) {
21
+     define('MESSAGE', 'You do not control that domain.');
22
+     return;
23
+    }
24
+    $sql = 'SELECT s.site_name FROM sites AS s, records AS r WHERE r.domain_id = '.m($_POST['domain']).' AND r.record_type = \'UTD\' AND s.site_id = r.record_value';
25
+    $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
26
+    if (mysql_num_rows($res) > 0) {
27
+     $row = mysql_fetch_array($res);
28
+     define('MESSAGE', 'That domain is associated with the site '.$row['site_name'].' and thus cannot be deleted.');
29
+     return;
30
+    }
31
+
32
+    $sql = 'SELECT domain_parent FROM domains WHERE domain_id = '.$_POST['domain'];
33
+    $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
34
+    $row = mysql_fetch_assoc($res);
35
+
36
+    $sql = 'UPDATE domains SET domain_parent = '.$row['domain_parent'].' WHERE';
37
+    $sql .= ' domain_parent = '.$_POST['domain'];
38
+    mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
39
+
40
+    $sql = 'DELETE FROM domains WHERE domain_id = '.$_POST['domain'];
41
+    mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
42
+
43
+    $sql = 'DELETE FROM records WHERE domain_id = '.$_POST['domain'];
44
+    mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
45
+
46
+    define('MESSAGE', 'The domain \''.$dn.'\' has been deleted.');
47
+    logger::log('Domain deleted: '.$dn,logger::information);    
48
+   } elseif ($_POST['action'] == 'add' && isset($_POST['domain'])) {
49
+    if (!preg_match('/^[a-z][a-z0-9\-\.]*\.[a-z]{2,}$/i', $_POST['domain'])) {
50
+     define('MESSAGE', 'Invalid domain name. Must start with a letter and contain only letters, numbers, hyphens and periods.'); 
51
+     return;
52
+    } 
53
+
54
+    $parts = explode('.', $_POST['domain']);
55
+    $string = '';
56
+    while (count($parts) > 0) {
57
+     if ($string != '') { $string = '.'.$string; }
58
+     $string = array_pop($parts).$string;
59
+     $sql = 'SELECT domain_name FROM domains WHERE domain_name = \''.m(strtolower($string)).'\'';
60
+     $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
61
+     if (mysql_num_rows($res) > 0) {
62
+      define('MESSAGE', 'That domain, or a parent domain, is already registered. Please contact UTD-Hosting support.');
63
+      return;
64
+     }
65
+    }
66
+
67
+    $sql  = 'INSERT INTO domains (user_id, domain_name, domain_enabled) VALUES ('.UID.', \'';
68
+    $sql .= m($_POST['domain']).'\', 0)';
69
+    $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
70
+
71
+    logger::log('Added domain: '.$_POST['domain'],logger::information);
72
+
73
+    // Hacky!
74
+    $_POST['subject'] = 'New domain: '.$_POST['domain'];
75
+    $_POST['body'] = 'The user has requested to have the domain name '.$_POST['domain'].' associated with their account.';
76
+    require('doticket.php');
77
+    exit;
78
+    // Add ticket
79
+
80
+   } elseif ($_POST['action'] == 'addsub' && isset($_POST['subdomain']) && isset($_POST['subdomaind'])) {
81
+    if (!preg_match('/^[0-9]+$/',$_POST['subdomaind'])) { return; }
82
+
83
+    $sql = 'SELECT user_id, domain_name, domain_enabled FROM domains WHERE domain_id = '.m($_POST['subdomaind']);
84
+    $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
85
+    if (mysql_num_rows($res) == 0) {
86
+     define('MESSAGE', 'Invalid domain');
87
+     return;
88
+    }
89
+    $row = mysql_fetch_array($res);
90
+    $dn = $row['domain_name'];
91
+    if ($row['domain_enabled'] == '0') {
92
+     define('MESSAGE', 'That domain hasn\'t been enabled yet.');
93
+     return;
94
+    }
95
+    if (!defined('ADMIN') && $row['user_id'] != UID) {
96
+     define('MESSAGE', 'You do not control that domain.');
97
+     return;
98
+    }
99
+    if (!preg_match('/^[a-z][a-z0-9\-]*$/i', $_POST['subdomain'])) {
100
+     define('MESSAGE', 'Invalid subdomain. Must start with a letter and contain only letters, numbers and \'-\'.');
101
+     return;
102
+    }
103
+    $target = strtolower($_POST['subdomain'].'.'.$dn);
104
+    $sql = 'SELECT domain_name FROM domains WHERE domain_name = \''.$target.'\'';
105
+    $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
106
+    if (mysql_num_rows($res) != 0) {
107
+     define('MESSAGE', 'That domain already exists!');
108
+     return;
109
+    }
110
+    $sql = 'INSERT INTO domains (user_id, domain_name, domain_enabled';
111
+    $sql .= ', domain_parent) VALUES ('.UID.',\''.$target.'\',1,'.m($_POST['subdomaind']).')';
112
+    mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
113
+    logger::log('Added subdomain: '.$target, logger::information);
114
+    define('MESSAGE', 'Added new domain \''.$target.'\''); 
115
+   }
116
+  }
117
+ }
118
+
119
+ meep();
120
+ 
121
+ define('TITLE', 'Domains');
122
+
123
+ addDashboardItem('Frequently asked questions', 'How do I register a domain name?', 'support/200');
124
+ addDashboardItem('Useful links', 'Create a new site', 'addsite');
125
+ 
126
+ require_once('lib/header.php');
127
+ 
128
+ require_once('pages/domains.list.php');
129
+ require_once('pages/domains.addsubdomain.php');
130
+ require_once('pages/domains.adddomain.php');
131
+ 
132
+ require_once('lib/footer.php');
133
+
134
+
135
+?>

+ 51
- 0
doticket.php View File

@@ -0,0 +1,51 @@
1
+<?PHP
2
+
3
+ require_once('lib/account.php');
4
+ require_once('lib/dashboard.php');
5
+ require_once('lib/database.php');
6
+
7
+ if (get_magic_quotes_gpc() == 1) {
8
+  foreach ($_POST as $k => $v) { $_POST[$k] = stripslashes($v); }
9
+ }
10
+
11
+ if (isset($_POST['body']) && isset($_POST['subject'])) {
12
+  if (USER == 'demo') {
13
+   define('MESSAGE','Sorry. The demo account can\'t raise tickets.');
14
+  } elseif (strlen($_POST['body']) < 10) {
15
+   define('MESSAGE', 'Please enter a complete description of the problem.');
16
+  } elseif (strlen($_POST['subject']) < 5) {
17
+   define('MESSAGE', 'Please enter a complete subject.');
18
+  } else {
19
+
20
+   $sql  = 'INSERT INTO tickets (user_id, ticket_title, ticket_body, ';
21
+   $sql .= 'ticket_time, ticket_status) VALUES ('.UID.', \''.m($_POST['subject']).'\', ';
22
+   $sql .= '\''.m($_POST['body']).'\', '.time().', \'new\')';
23
+   mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
24
+   
25
+   $id = mysql_insert_id();
26
+   $sql = 'UPDATE tickets SET ticket_thread = '.$id.' WHERE ticket_id = '.$id;
27
+   mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
28
+
29
+   require('../common/ticketmail.php');
30
+
31
+   adminTicketMail($id);
32
+   logger::log('Raised ticket: '.$_POST['subject'], logger::normal);
33
+
34
+   header('Location: '.CP_PATH.'viewticket/'.$id);
35
+   die;
36
+  }
37
+ } else {
38
+  define('MESSAGE', 'No ticket data submitted');	 
39
+ }
40
+ 
41
+ define('TITLE', 'Error');
42
+ 
43
+ addDashboardItem('Useful links', 'Support center', 'support');
44
+ addDashboardItem('Useful links', 'Raise a new ticket', 'tickets');
45
+ 
46
+ addDashboardItem('Frequently asked questions', 'Can I file support requests without using the control panel?', 'support/005'); 
47
+ 
48
+ require_once('lib/header.php');
49
+ require_once('lib/footer.php');
50
+
51
+?>

+ 78
- 0
doticketreply.php View File

@@ -0,0 +1,78 @@
1
+<?PHP
2
+
3
+ require_once('lib/account.php');
4
+ require_once('lib/dashboard.php');
5
+ require_once('lib/database.php');
6
+
7
+ if (get_magic_quotes_gpc() == 1) {
8
+  foreach ($_POST as $k => $v) { $_POST[$k] = stripslashes($v); }
9
+ }
10
+
11
+ if (isset($_POST['message']) && isset($_POST['status']) && isset($_POST['thread'])) {
12
+  if (USER == 'demo') {
13
+   define('MESSAGE','Sorry. The demo account can\'t reply to tickets.');
14
+  } elseif (!preg_match('/^[0-9]+$/', $_POST['thread'])) {
15
+   define('MESSAGE', 'Invalid ticket thread.');
16
+  } else {
17
+
18
+   $sql = 'SELECT user_id, ticket_status, ticket_title FROM tickets WHERE ticket_id = '.$_POST['thread'];
19
+   $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
20
+   $row = mysql_fetch_array($res);
21
+   define('TTITLE', $row['ticket_title']);
22
+   if ((UID != $row[0]) && (!defined('ADMIN'))) {
23
+    define('MESSAGE', 'You don\'t have access to reply to that ticket.');
24
+   } else {
25
+
26
+    $opts = array(); $opts[($row[1])] = true;
27
+    switch ($row[1]) {
28
+     case 'new': case 'reopened':
29
+      $opts['closed'] = true;
30
+      if (defined('ADMIN')) { $opts['assigned'] = true; }
31
+     break;
32
+     case 'assigned':
33
+      $opts['closed'] = true;
34
+      break;
35
+     case 'closed':
36
+      $opts['reopened'] = true;
37
+      break;
38
+    }
39
+    
40
+    if (!isset($opts[($_POST['status'])])) {
41
+     define('MESSAGE', 'Invalid/unknown status');
42
+    } else {
43
+ 
44
+     $sql  = 'INSERT INTO tickets (user_id, ticket_title, ticket_body, ';
45
+     $sql .= 'ticket_time, ticket_status, ticket_thread) VALUES ('.UID.', \'\', ';
46
+     $sql .= '\''.m($_POST['message']).'\', '.time().', \'reply\', ';
47
+     $sql .= $_POST['thread'].')';
48
+     mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
49
+
50
+     if (file_exists('/home/utd/common/ticketmail.php')) {
51
+      require_once('/home/utd/common/ticketmail.php');
52
+      ticketmail(mysql_insert_id());
53
+      logger::log('Replied to ticket "'.TTITLE.'"', logger::normal);
54
+     }
55
+
56
+     $sql  = 'UPDATE tickets SET ticket_status = \''.$_POST['status'].'\' WHERE ticket_id = '.$_POST['thread'];
57
+     mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
58
+
59
+     header('Location: '.CP_PATH.'viewticket/'.$_POST['thread']);
60
+     die;
61
+    }
62
+   }
63
+  }
64
+ } else {
65
+  define('MESSAGE', 'No ticket data submitted');	 
66
+ }
67
+ 
68
+ define('TITLE', 'Error');
69
+ 
70
+ addDashboardItem('Useful links', 'Support center', 'support');
71
+ addDashboardItem('Useful links', 'Raise a new ticket', 'tickets');
72
+ 
73
+ addDashboardItem('Frequently asked questions', 'Can I file support requests without using the control panel?', 'support/005'); 
74
+ 
75
+ require_once('lib/header.php');
76
+ require_once('lib/footer.php');
77
+
78
+?>

+ 72
- 0
editpref.php View File

@@ -0,0 +1,72 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/account.php');
5
+ require_once('lib/common.php');
6
+
7
+ if (!isset($_GET['n']) || !ctype_digit($_GET['n']) || $_GET['n'] < 1 || $_GET['n'] > 5) {
8
+  header('Location: '.CP_PATH.'account');
9
+  exit;
10
+ }
11
+
12
+ $fields = array(1=>'users.user_email', 2=>'', 3=>'userdetails.ud_name',
13
+                4=>'userdetails.ud_address', 5=>'userdetails.ud_telephone');
14
+
15
+ $prefs = array(1=>'e-mail address', 3=>'full name', 4=>'address',
16
+                5=>'telephone number');
17
+
18
+ if (isset($_POST['value'])) {
19
+  list($table, $col) = explode('.', $fields[($_GET['n'])]);
20
+  
21
+  if ($table == 'userdetails') {
22
+   $sql = 'SELECT user_id FROM userdetails WHERE user_id = '.UID;
23
+   $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
24
+   if (mysql_num_rows($res) == 0) {
25
+    $sql = 'INSERT INTO userdetails (user_id) VALUES ('.UID.')';
26
+    mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
27
+   } 
28
+  }
29
+  
30
+  $sql  = 'UPDATE '.$table.' SET '.$col.' = \''.m($_POST['value']).'\' WHERE ';
31
+  $sql .= 'user_id = '.UID;
32
+  logger::log('Changed '.$prefs[($_GET['n'])].' to '.$_POST['value'],logger::information);
33
+  mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
34
+  header('Location: '.CP_PATH.'account');
35
+  exit;
36
+ }
37
+
38
+ if (isset($_POST['mail'])) {
39
+  $m = array('mail_announce'=>'announcement','mail_tickets'=>'ticket reply',
40
+		'mail_warning'=>'warning','mail_over'=>'overring');
41
+  $sql  = 'SELECT mail_announce, mail_tickets, mail_warning, mail_over FROM ';
42
+  $sql .= 'users WHERE user_id = '.UID;
43
+  $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
44
+  $row = mysql_fetch_assoc($res);
45
+  foreach ($row as $key => $value) {
46
+   if ($value == 1 && !isset($_POST[$key])) {
47
+    logger::log('Opted out of '.$m[$key].' e-mail.', logger::information);
48
+    $sql = 'UPDATE users SET '.$key.' = 0 WHERE user_id = '.UID;
49
+    mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
50
+   }
51
+   if ($value == 0 && isset($_POST[$key])) {
52
+    logger::log('Opted to receive '.$m[$key].' e-mail.',logger::information);
53
+    $sql = 'UPDATE users SET '.$key.' = 1 WHERE user_id = '.UID;
54
+    mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
55
+   }
56
+  }
57
+  header('Location: '.CP_PATH.'account');
58
+  exit;
59
+ }
60
+ 
61
+ define('TITLE', 'Edit User preferences');
62
+ 
63
+ addDashboardItem('Useful links', 'Account overview', '');
64
+ 
65
+ require_once('lib/header.php');
66
+
67
+ require_once('pages/editpref.php');
68
+ 
69
+ require_once('lib/footer.php');
70
+
71
+
72
+?>

+ 164
- 0
editsite.php View File

@@ -0,0 +1,164 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/account.php');
5
+
6
+ checkAccess(HAS_HOSTING);
7
+
8
+ if (isset($_POST['site'])) { $_GET['n'] = $_POST['site']; }
9
+
10
+ $errors = array();
11
+
12
+ function foo () {
13
+  global $errors;
14
+
15
+  if (!isset($_POST['task'])) { return; }
16
+
17
+  if (isset($_POST['site']) && preg_match('/^[0-9]+$/', $_POST['site'])) {
18
+   $sql  = 'SELECT user_name, users.user_id FROM sites NATURAL JOIN users ';
19
+   $sql .= 'WHERE site_id = '.$_POST['site'];
20
+   $res  = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
21
+   $row  = mysql_fetch_array($res);
22
+
23
+   if ($row['user_id'] != UID && !defined('ADMIN')) {
24
+    $errors[] = 'You do not control that site.';
25
+    return;
26
+   }
27
+
28
+   if ($row['user_id'] != UID && defined('ADMIN') && ADMIN) {
29
+    define('SUID', $row['user_id']);
30
+    define('SUSER', $row['user_name']);
31
+   }
32
+
33
+   if ($_POST['task'] == 'domains') {
34
+    $sql  = 'DELETE FROM records WHERE record_type = \'UTD\' AND ';
35
+    $sql .= 'record_value = '.$_POST['site'];
36
+    mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
37
+
38
+    foreach ($_POST as $key => $val) {
39
+     if (substr($key,0,6) == 'domain') {
40
+      $dom = (int)substr($key,6);
41
+      $sql = 'SELECT domain_name, user_id FROM domains WHERE domain_id = '.$dom;
42
+      $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
43
+      $row = mysql_fetch_array($res);
44
+
45
+      if ($row['user_id'] != UID && !defined('ADMIN')) {
46
+       $errors[] = 'You do not control the domain \''.$row['domain_name'].'\'';
47
+       continue;
48
+      }
49
+
50
+      $sql = 'SELECT * FROM records WHERE record_type = \'UTD\' AND domain_id = '.$dom;
51
+      $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
52
+      if (mysql_num_rows($res) > 0) {
53
+       $errors[] = 'The domain \''.$row['domain_name'].'\' is already associated with another site.';
54
+       continue;
55
+      }
56
+
57
+      $sql = 'INSERT INTO records (domain_id, record_type, record_value) VALUES ('.$dom.', \'UTD\', \''.$_POST['site'].'\')';
58
+      mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
59
+     }
60
+    } 
61
+
62
+    $sql  = 'INSERT INTO actions (user_id, action_type, action_value) VALUES (';
63
+    $sql .= UID . ', \'updateconf\', \'bind\')';
64
+    mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
65
+
66
+   } elseif ($_POST['task'] == 'webserver') {
67
+    $update = false;
68
+
69
+    $sql  = 'SELECT site_php, site_index, site_htaccess FROM sites';
70
+    $sql .= ' WHERE site_id = ' . $_POST['site'];
71
+    $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
72
+    $row = mysql_fetch_assoc($res);
73
+
74
+    if ($row['site_php'] != $_POST['phpversion']) {
75
+     $update = true;
76
+     $sql  = 'UPDATE sites SET site_php = \''. m($_POST['phpversion']);
77
+     $sql .= '\' WHERE site_id = ' . $_POST['site'];
78
+     mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
79
+    }
80
+
81
+    $index = isset($_POST['index']) ? '1' : '0';
82
+    $htaccess = isset($_POST['htaccess']) ? '1': '0';
83
+ 
84
+    if ($row['site_index'] != $index || $row['site_htaccess'] != $htaccess) {
85
+     $update = true;
86
+     $sql  = 'UPDATE sites SET site_index = '.$index.', site_htaccess = ';
87
+     $sql .= $htaccess.' WHERE site_id = '.$_POST['site'];
88
+     mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
89
+    }
90
+
91
+    if ($update) {
92
+     $sql  = 'INSERT INTO actions (user_id, action_type, action_value) ';
93
+     $sql .= 'VALUES (' . UID . ', \'updateconf\', \'apache\')';
94
+     mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
95
+    }
96
+   } else {
97
+    return;
98
+   }
99
+  }
100
+ }
101
+
102
+ foo();
103
+
104
+ if (count($errors) > 0) {
105
+  $error = 'The following errors were encountered:<ul><li>'.implode('<li>',$errors).'</ul>';
106
+  define('TITLE', 'Error');
107
+ } elseif (!isset($_GET['n']) || !preg_match('/^[0-9]+$/',$_GET['n'])) {
108
+   $error = 'Invalid site ID!';
109
+   define('TITLE', 'Error');
110
+ } else {
111
+   $site = $_GET['n'];
112
+   $sql = 'SELECT site_id, users.user_id, user_name,  site_name, site_docroot FROM sites NATURAL JOIN users WHERE site_id = '.$site;
113
+   $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
114
+   
115
+   if (mysql_num_rows($res) == 0) {
116
+     $error = 'There is no such site with that ID.';
117
+     define('TITLE', 'Error');
118
+   } else {
119
+   
120
+    $row = mysql_fetch_array($res);
121
+   
122
+    if ($row['user_id'] != UID && !defined('ADMIN')) {
123
+	  $error = 'You do not own this site.';
124
+	  define('TITLE', 'Error');
125
+    } else {
126
+     if ($row['user_id'] != UID && defined('ADMIN') && ADMIN) {
127
+      define('SUID', $row['user_id']);
128
+      define('SUSER', $row['user_name']);
129
+     }
130
+
131
+      define('SITE_ID', $row['site_id']);
132
+      define('SITE_NAME', $row['site_name']);
133
+      define('SITE_DOCROOT', $row['site_docroot']);
134
+      define('TITLE', 'Edit site: '.$row['site_name']);
135
+    }
136
+   }
137
+ } 
138
+ 
139
+ addDashboardItem('Useful links', 'Support center', 'support');
140
+ addDashboardItem('Useful links', 'Site overview', 'sites');
141
+  
142
+ addDashboardItem('Frequently asked questions', 'What do I do if my site isn\'t working?', 'support/002');
143
+ addDashboardItem('Frequently asked questions', 'What does \'document root\' mean?', 'support/015');
144
+ addDashboardItem('Frequently asked questions', 'What does KiB/MiB/GiB mean?', 'support/003');
145
+ addDashboardItem('Frequently asked questions', 'How do I configure PHP for my site?', 'support/001');
146
+
147
+ if (isset($error)) {
148
+  define('MESSAGE', $error);
149
+ }
150
+
151
+ require_once('lib/header.php');
152
+
153
+ if (!defined('SUSER')) { define('SUSER', USER); define('SUID', UID); }
154
+ 
155
+ if (!isset($error)) {
156
+  require_once('pages/editsite.overview.php');
157
+  require_once('pages/editsite.webserver.php');
158
+  require_once('pages/editsite.domains.php');
159
+  require_once('pages/editsite.errors.php');
160
+ }
161
+ 
162
+ require_once('lib/footer.php');
163
+
164
+?>

+ 25
- 0
email.php View File

@@ -0,0 +1,25 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/account.php');
5
+
6
+ checkAccess(HAS_HOSTING);
7
+ 
8
+ define('TITLE', 'E-Mail settings');
9
+ 
10
+ addDashboardItem('Useful links', 'Account overview', '');
11
+ addDashboardItem('Frequently asked questions', 'How do mailboxes and e-mail addresses work?', 'support/027'); 
12
+ 
13
+ define('MESSAGE', 'Sorry, this function hasn\'t been implemented yet. Please <a href="'.CP_PATH.'tickets">raise a ticket</a> for assistance.');
14
+
15
+ require_once('lib/header.php');
16
+ 
17
+ require_once('pages/email.php');
18
+ require_once('pages/addemail.php');
19
+ require_once('pages/mailbox.php');
20
+ require_once('pages/addmailbox.php');
21
+ 
22
+ require_once('lib/footer.php');
23
+
24
+
25
+?>

+ 32
- 0
enabledomain.php View File

@@ -0,0 +1,32 @@
1
+<?PHP
2
+
3
+ require_once('lib/account.php');
4
+ require_once('lib/dashboard.php');
5
+ require_once('lib/database.php');
6
+
7
+ checkAccess(ADMIN);
8
+
9
+ if (isset($_GET['n']) && ctype_digit($_GET['n'])) {
10
+  if (defined('ADMIN') && ADMIN) {
11
+   $sql = 'UPDATE domains SET domain_enabled = 1 WHERE domain_id = '.m($_GET['n']);
12
+   mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
13
+   header('Location: '.CP_PATH.'admin');
14
+   exit;
15
+  } else {
16
+   define('MESSAGE', 'Insufficient access');
17
+  }
18
+ } else {
19
+  define('MESSAGE', 'Invalid domain ID');	 
20
+ }
21
+ 
22
+ define('TITLE', 'Error');
23
+ 
24
+ addDashboardItem('Useful links', 'Support center', 'support');
25
+ addDashboardItem('Useful links', 'Raise a new ticket', 'tickets');
26
+ 
27
+ addDashboardItem('Frequently asked questions', 'Can I file support requests without using the control panel?', 'support/005'); 
28
+ 
29
+ require_once('lib/header.php');
30
+ require_once('lib/footer.php');
31
+
32
+?>

+ 133
- 0
ext/pie.php View File

@@ -0,0 +1,133 @@
1
+<?PHP
2
+
3
+define('PIE_MAX_SEGS',6); // Maximum number of segments
4
+
5
+function pieSort ($item1, $item2) {
6
+ 
7
+ return ($item2 - $item1);
8
+ 
9
+}
10
+
11
+
12
+function doPie ($title, $items) {
13
+ 
14
+ assert(is_array($items));
15
+ 
16
+ uasort($items,'pieSort');
17
+ 
18
+ if (count($items) > PIE_MAX_SEGS) {
19
+  
20
+  $other = 0;
21
+  
22
+  $i = PIE_MAX_SEGS - 1;
23
+  
24
+  foreach ($items as $key => $value) {
25
+   $i--;
26
+   
27
+   if ($i < 0) {
28
+    
29
+    $other += $value;
30
+    unset($items[$key]);
31
+    
32
+   }
33
+   
34
+  }
35
+  
36
+  $items['Other'] = $other;
37
+  
38
+ }
39
+ 
40
+ $im = imagecreate(500,315);
41
+ 
42
+ $white = imagecolorallocate($im,255,255,255);
43
+ 
44
+ imagefill($im,0,0,$white);
45
+ 
46
+ $total = 0;
47
+ 
48
+ foreach ($items as $name => $value) {
49
+  
50
+  $total += $value;
51
+  
52
+ }
53
+ 
54
+ $colours = array('138-103-173', '000-000-128', '030-144-255', '000-100-000',
55
+                  '060-179-113', '173-173-047', '189-183-107', '255-215-000',
56
+                  '205-092-092', '205-133-063', '255-000-000', '255-069-000',
57
+                  '255-105-180', '148-000-211', '147-112-219', '112-138-144',
58
+                  '100-100-100'); 
59
+                  
60
+ $black = imagecolorallocate($im,0,0,0);
61
+ 
62
+ if ($total != 0) { $dpv = 360/$total; } else { $dpv = 360; }
63
+ 
64
+ $last = 0;
65
+ 
66
+ $keypos = 0;
67
+ 
68
+ foreach ($items as $name => $value) {
69
+  
70
+  $colour = explode('-',array_shift($colours));
71
+  
72
+  $colour = imagecolorallocate($im, $colour[0], $colour[1], $colour[2]);
73
+  
74
+  $cur = $dpv * $value;
75
+  
76
+  imagefilledarc($im, 250, 160, 175, 175, $last, $last+$cur, $colour, IMG_ARC_PIE);
77
+  imagefilledarc($im, 250, 160, 175, 175, $last, $last+$cur, $black, IMG_ARC_EDGED | IMG_ARC_NOFILL);
78
+  
79
+  $mid = ($last + $last + $cur)/2;
80
+  
81
+  $multX = $multY = 1;
82
+  
83
+  if ($mid >= 180) { $multY = -1; }
84
+  
85
+  if ($mid >= 90 && $mid < 270) { $multX = -1; }
86
+  
87
+  $deltaX = abs(cos(deg2rad($mid)))*(175/3.5)*$multX;
88
+   
89
+  $deltaY = abs(sin(deg2rad($mid)))*(175/3.5)*$multY;
90
+   
91
+  $posX = 250 + $deltaX; $posY = 160 + $deltaY;
92
+   
93
+  $endX = 250 + ($deltaX * 2.3); $endY = 160 + ($deltaY * 2.3);
94
+   
95
+  if (($value/$total)*100 > 2.3) {   
96
+   
97
+   imageline($im, $posX, $posY, $endX, $endY, $black);
98
+   
99
+   imageline($im, $endX, $endY, $endX + $multX * (imagefontwidth(2)*strlen($name)+5), $endY, $black);
100
+  
101
+   if ($multX == 1) {
102
+    imagestring($im, 2, $endX + 2, $endY - 12, $name, $black);
103
+    imagestring($im, 1, $endX + 2, $endY + 2, '['.round($value*100/$total,1).'%]',$black);
104
+   } else {
105
+    imagestring($im, 2, $endX - 2 - imagefontwidth(2)*strlen($name), $endY - 12, $name, $black);
106
+    imagestring($im, 1, $endX - (imagefontwidth(1)*strlen('['.round($value*100/$total,1).'%]')) , $endY + 2, '['.round($value*100/$total,1).'%]',$black);
107
+   }
108
+   
109
+  } else {
110
+   
111
+   if ($keypos == 0) {
112
+    
113
+    imagestring($im,1,5,303,'Key:',$black);
114
+    $keypos += imagefontwidth(1)*4 + 10;
115
+    
116
+   }
117
+   
118
+   imagestring($im,1,$keypos,303,$name.' ['.round($value*100/$total,1).'%]',$colour);
119
+   $keypos += imagefontwidth(1)*strlen($name.' ['.round($value*100/$total,1).'%]') + 10;
120
+   
121
+  }
122
+   
123
+  $last += $cur;
124
+  
125
+ }
126
+ 
127
+ imagestring($im, 3, 250 - imagefontwidth(3)*strlen($title)/2, 5, $title, $black);
128
+ 
129
+ return $im;
130
+ 
131
+}
132
+
133
+?>

+ 27
- 0
fileman.php View File

@@ -0,0 +1,27 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/account.php');
5
+ 
6
+ define('TITLE', 'File manager demo');
7
+ 
8
+ addDashboardItem('Useful links', 'Add a new site', 'addsite');
9
+ addDashboardItem('Useful links', 'phpMyAdmin', 'phpMyAdmin');
10
+ addDashboardItem('Useful links', 'Historic bandwidth/hdd usage', 'history');
11
+ addDashboardItem('Useful links', 'View or raise tickets', 'tickets');
12
+ addDashboardItem('Useful links', 'View extended site details', 'sites');
13
+ 
14
+ addDashboardItem('Frequently asked questions', 'What do I do if my site isn\'t working?', 'support/002');
15
+ addDashboardItem('Frequently asked questions', 'What does KiB/MiB/GiB mean?', 'support/003');
16
+ addDashboardItem('Frequently asked questions', 'How do I configure PHP for my site?', 'support/001');
17
+ addDashboardItem('Frequently asked questions', 'How do I pay outstanding bills?', 'support/008');
18
+ addDashboardItem('Frequently asked questions', 'What does the status column mean?', 'support/004');
19
+
20
+ require_once('lib/header.php');
21
+ 
22
+ require_once('pages/fileman.php');
23
+ 
24
+ require_once('lib/footer.php');
25
+
26
+
27
+?>

+ 20
- 0
history.php View File

@@ -0,0 +1,20 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/account.php');
5
+ 
6
+ define('TITLE', 'Historic usage data');
7
+ 
8
+ addDashboardItem('Useful links', 'Account overview', '');
9
+ addDashboardItem('Useful links', 'View extended site details', 'sites');
10
+ 
11
+ addDashboardItem('Frequently asked questions', 'What does KiB/MiB/GiB mean?', 'support/003');
12
+
13
+ require_once('lib/header.php');
14
+ 
15
+ require_once('pages/historic.php');
16
+ 
17
+ require_once('lib/footer.php');
18
+
19
+
20
+?>

+ 36
- 0
index.php View File

@@ -0,0 +1,36 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/account.php');
5
+ require_once('lib/profiler.php');
6
+ 
7
+ define('TITLE', 'Account overview');
8
+ 
9
+ if (HAS_HOSTING) {
10
+  addDashboardItem('Useful links', 'Add a new site', 'addsite');
11
+  addDashboardItem('Useful links', 'phpMyAdmin', 'phpMyAdmin');
12
+  addDashboardItem('Useful links', 'Historic bandwidth/hdd usage', 'history');
13
+ }
14
+ if (HAS_DNS) {
15
+  addDashboardItem('Useful links', 'DNS control panel', 'dns');
16
+ }
17
+ addDashboardItem('Useful links', 'View or raise tickets', 'tickets');
18
+ addDashboardItem('Useful links', 'Support section', 'support');
19
+
20
+ if (HAS_HOSTING) { 
21
+  addDashboardItem('Frequently asked questions', 'What do I do if my site isn\'t working?', 'support/002');
22
+  addDashboardItem('Frequently asked questions', 'What does KiB/MiB/GiB mean?', 'support/003');
23
+  addDashboardItem('Frequently asked questions', 'How do I configure PHP for my site?', 'support/001');
24
+ }
25
+ addDashboardItem('Frequently asked questions', 'How do I pay outstanding invoices?', 'support/008');
26
+
27
+ require_once('lib/header.php');
28
+ 
29
+ require_once('pages/announcements.php');
30
+ require_once('pages/ticketoverview.php');
31
+ require_once('pages/supsearch.php');
32
+ 
33
+ require_once('lib/footer.php');
34
+
35
+
36
+?>

+ 20
- 0
invoices.php View File

@@ -0,0 +1,20 @@
1
+<?PHP
2
+
3
+ require_once('lib/dashboard.php');
4
+ require_once('lib/common.php');
5
+ require_once('lib/database.php');
6
+ require_once('lib/account.php');
7
+ 
8
+ define('TITLE', 'Invoices');
9
+ 
10
+ addDashboardItem('Frequently asked questions', 'How do I pay outstanding invoices?', 'support/008');
11
+ addDashboardItem('Useful links', 'Apply discount', 'discount');
12
+
13
+ require_once('lib/header.php');
14
+ 
15
+ require_once('pages/billing.php');
16
+ require_once('pages/packages.php');
17
+  
18
+ require_once('lib/footer.php');
19
+
20
+?>

+ 125
- 0
ipn.php View File

@@ -0,0 +1,125 @@
1
+<?PHP
2
+
3
+ require_once('lib/common.php');
4
+ require_once('lib/database.php');
5
+
6
+ // Log the transaction
7
+ $count = count(glob('/home/utd/public_html/ipn/*.html'));
8
+ $count++; $id = str_pad($count,5,'0',STR_PAD_LEFT); define('ID', $id);
9
+
10
+ $data = '<html><head><title>IPN Transaction details</title></head><body>';
11
+ $data .= '<h2>Post details</h2><table>';
12
+ foreach ($_POST as $k => $v) {
13
+  $data .= '<tr><td>'.htmlentities($k).'</td>';
14
+  $data .= '<td>'.htmlentities($v).'</td></tr>';
15
+ }
16
+ $data .= '</table><h2>Server details</h2><table>';
17
+ foreach ($_SERVER as $k => $v) {
18
+  if (is_array($v)) { continue; }
19
+  $data .= '<tr><td>'.htmlentities($k).'</td>';
20
+  $data .= '<td>'.htmlentities($v).'</td></tr>';
21
+ }
22
+ $data .= '</table></html>';
23
+
24
+ file_put_contents('/home/utd/public_html/ipn/'.ID.'.html', $data);
25
+
26
+ // Read the post from PayPal system and add 'cmd'
27
+ $req = 'cmd=_notify-validate';
28
+
29
+ foreach ($_POST as $key => $value) {
30
+  $value = urlencode(stripslashes($value));
31
+  $req .= "&$key=$value";
32
+ }
33
+
34
+ // Post back to PayPal system to validate
35
+ $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
36
+ $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
37
+ $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
38
+
39
+ $sb = '';
40
+
41
+ $fp = fsockopen ('www.'.$sb.'paypal.com', 80, $errno, $errstr, 30);
42
+ if (!$fp) { fail('Unable to connect to paypal'); }
43
+
44
+ // assign posted variables to local variables
45
+ $item_name = $_POST['item_name'];
46
+ $item_number = $_POST['item_number'];
47
+ $payment_status = $_POST['payment_status'];
48
+ $payment_amount = $_POST['mc_gross'];
49
+ $payment_currency = $_POST['mc_currency'];
50
+ $txn_id = $_POST['txn_id'];
51
+ $receiver_email = strtolower($_POST['receiver_email']);
52
+ $payer_email = $_POST['payer_email'];
53
+
54
+ function fail($m) {
55
+  logger::log(chr(2).'IPN'.chr(2).': Transaction '.ID.': Failure: '.$m, logger::important);
56
+  exit;
57
+ }
58
+ 
59
+ if (!$fp) {
60
+  fail('HTTP error when posting back: '.$errstr);
61
+ } else {
62
+  fputs ($fp, $header . $req);
63
+  while (!feof($fp)) {
64
+   $res = fgets ($fp, 1024);
65
+   if (strcmp ($res, "VERIFIED") == 0) {
66
+    // check the payment_status is Completed
67
+    if ($payment_status != 'Completed') {
68
+     fail('Payment status is '.$payment_status.' (expected "Completed")');
69
+    }
70
+
71
+    // check that txn_id has not been previously processed
72
+    // check that receiver_email is your Primary PayPal email
73
+    if ($receiver_email != 'chris87@gmail.com'
74
+	 && $receiver_email != 'accounts@utd-hosting.com') {
75
+     fail('Receiver is '.$receiver_email);
76
+    }
77
+
78
+    // check that payment_amount/payment_currency are correct
79
+    if ($payment_currency != 'GBP') {
80
+     fail('Invalid currency: '.$payment_currency);
81
+    }
82
+
83
+    $id = preg_replace('~^.*#([0-9]+)$~', '\1', $item_name);
84
+    if (!is_numeric($id)) {
85
+     fail('Unable to parse item_name: '.$item_name); 
86
+    }
87
+
88
+    $sql = 'SELECT user_id, user_name, bill_total, bill_paid';
89
+    $sql .= ' FROM bills NATURAL JOIN users WHERE bill_id = '.$id; 
90
+    $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
91
+    if (mysql_num_rows($res) == 1) {
92
+     $row = mysql_fetch_array($res);
93
+     $amount = $payment_amount * 100;
94
+     if ($amount != $row['bill_total'] || $row['bill_paid'] == 1) {
95
+      fail('bill_total is incorrect, or bill already paid'); 
96
+     }  
97
+
98
+     $sql = 'UPDATE bills SET bill_paid = 1 WHERE bill_id = '.$id;
99
+     $res = mysql_query($sql) or fail('SQL error: '.mysql_error());
100
+
101
+     $sql = 'UPDATE userpackages, billitems, packages SET up_cost = package_cost, up_expires = up_expires + package_duration WHERE bill_id = '.$id.' AND userpackages.up_id = billitems.up_id AND packages.package_id = userpackages.package_id';
102
+     $res = mysql_query($sql) or fail('SQL error: '.mysql_error());
103
+
104
+     $sql = 'SELECT finance_balance FROM finances ORDER BY finance_time DESC';
105
+     $res = mysql_query($sql) or fail('SQL error: '.mysql_error());
106
+     $ro2 = mysql_fetch_array($res); $balance = $ro2[0];
107
+     $sql = 'INSERT INTO finances (finance_time, finance_desc, user_id,';
108
+     $sql .= ' finance_receipts, finance_payments, finance_balance) VALUES (';
109
+     $sql .= time().', \'Bill payment\', '.$row['user_id'].', ';
110
+     $sql .= $row['bill_amount'].', '.($_POST['mc_fee']*100).', ';
111
+     $sql .= ($balance+$row['bill_amount']-($_POST['mc_fee']*100)).')';
112
+     $res = mysql_query($sql) or fail('SQL error: '.mysql_error());
113
+
114
+     logger::log('User '.chr(2).$row['user_name'].chr(2).': Bill '.$id.' paid.', logger::normal);
115
+    } else { 
116
+     fail('Bill not found: '.$id);
117
+    }
118
+   } else if (strcmp ($res, "INVALID") == 0) {
119
+    fail('INVALID REQUEST -- INVESTIGATE -- http://admin.utd-hosting.com/ipn/'.ID.'.html');
120
+   }
121
+  }
122
+  fclose ($fp);
123
+ }
124
+
125
+?>

+ 192
- 0
lib/account.php View File

@@ -0,0 +1,192 @@
1
+<?PHP
2
+
3
+ require_once('lib/common.php');
4
+ require_once('lib/profiler.php');
5
+ require_once('lib/database.php');
6
+
7
+ // Check IP bans
8
+ $sql  = 'SELECT ipban_message, ipban_expires FROM ipbans WHERE ipban_ip = \'';
9
+ $sql .= m($_SERVER['REMOTE_ADDR']).'\' AND ipban_expires > '.time();
10
+ $res = mq($sql, __FILE__, __LINE__);
11
+ 
12
+ if (mysql_num_rows($res) > 0) {
13
+  if (!defined('FORBIDDEN')) {
14
+   header('Location: '.CP_PATH.'403');
15
+   exit;
16
+  } else {
17
+   $row = mysql_fetch_array($res);
18
+   define('REASON', $row['ipban_message']);
19
+   define('EXPIRES', $row['ipban_expires']);
20
+  }
21
+ }
22
+
23
+ // Check to see if they're logged in
24
+ if (!isset($_COOKIE['utdsid']) && !defined('NOLOGINREF')) {
25
+  header('Location: '.CP_PATH.'login');
26
+  exit;
27
+ }
28
+ 
29
+ // Prune old sessions
30
+ $sql  = 'DELETE FROM sessions WHERE session_last < '.(time()-60*60);
31
+ $sql .= ' OR session_start < '.(time()-60*60*24);
32
+ mq($sql, __FILE__, __LINE__); 
33
+
34
+ // Select the user's session
35
+ $sql  = 'SELECT user_id, user_pass, user_name, user_admin, user_tac, ';
36
+ $sql .= 'session_spoof FROM sessions NATURAL JOIN users WHERE session_ident ';
37
+ $sql .= '= \''.m($_COOKIE['utdsid']).'\'';
38
+
39
+ $res = mq($sql, __FILE__, __LINE__);
40
+
41
+ // Make sure it exists
42
+ if (mysql_num_rows($res) <> 1  && !defined('NOLOGINREF')) {
43
+  header('Location: '.CP_PATH.'login');
44
+  exit;
45
+ } elseif (mysql_num_rows($res) == 1) {
46
+  $row = mysql_fetch_array($res);
47
+
48
+  // Read the first line of the T&C (the version number)
49
+  $fh = fopen('/home/utd/common/tac.txt','r');
50
+  $tac = trim(fgets($fh));
51
+  fclose($fh);
52
+
53
+  // Check they've agreed to it
54
+  if ((int)$tac > (int)$row['user_tac'] && !defined('NOTACREF')) {
55
+   header('Location: '.CP_PATH.'tac');
56
+   exit;
57
+  }
58
+  
59
+  // Check to see if it's an admin spoofing a user
60
+  if ($row['session_spoof'] != '0' && $row['user_admin'] == '1') {
61
+   $sql  = 'SELECT user_id, user_pass, user_name, user_admin, user_tac FROM ';
62
+   $sql .= 'users WHERE user_id = '.m($row['session_spoof']);
63
+   $res  = mq($sql, __FILE__, __LINE__);
64
+   define('SPOOF', $row['user_id']);
65
+   $row  = mysql_fetch_array($res);
66
+  }
67
+
68
+  // Define some nice constants
69
+  define('USER', $row[2]);
70
+  define('PASS', $row[1]);
71
+  define('UID', $row[0]);
72
+  define('TAC', $row[4]);
73
+  if ($row[3] == '1') { define('ADMIN', True); }
74
+
75
+  // Let's see what packages they have access to
76
+  $sql  = 'SELECT package_type FROM userpackages NATURAL JOIN packages WHERE ';
77
+  $sql .= 'user_id = '.UID.' AND up_active = 1';
78
+  $res  = mq($sql, __FILE__, __LINE__);
79
+  $packages = array('hosting'=>false,'dns'=>false,'backup'=>false,'ssh'=>false);
80
+  while ($row = mysql_fetch_array($res)) {
81
+   $packages[($row['package_type'])] = true;
82
+  }
83
+  foreach ($packages as $key=>$value) {
84
+   define('HAS_'.strtoupper($key),$value);
85
+  }
86
+ }
87
+
88
+ // Function to change a user's password
89
+ function changePass ($uid, $newpass) {
90
+  $sql = 'SELECT user_name FROM users WHERE user_id = '.m($uid);
91
+  $res = mq($sql, __FILE__, __LINE__);
92
+  $row = mysql_fetch_array($res);
93
+  $uname = $row[0];
94
+
95
+  $sql  = 'UPDATE users SET user_pass = \''.md5($uname.$newpass).'\' WHERE '; 
96
+  $sql .= 'user_name = \''.m($uname).'\'';
97
+  mq($sql) or mf(__FILE__, __LINE__, $sql);
98
+
99
+  $sql  = 'SET PASSWORD FOR \''.m($uname).'\'@\'localhost\' = PASSWORD(\'';
100
+  $sql .= md5($uname.$newpass).'\')';
101
+  $l = mysql_connect('localhost', 'root', 'mysql32159');;
102
+  mysql_select_db('admin', $l);
103
+  mq($sql,$l) or mf(__FILE__, __LINE__, $sql);
104
+  mysql_close($l);
105
+  $_redodb = true; require('/home/utd/control/lib/database.php'); unset($_redodb);
106
+
107
+  $sql  = 'INSERT INTO actions (user_id, action_type, action_value) VALUES (';
108
+  $sql .= m($uid).', \'pass\', \''.m($newpass).'\')';
109
+  mq($sql) or mf(__FILE__, __LINE__, $sql);
110
+ }
111
+
112
+ function addUser ($username, $email, $pass, $tac, $slots = 1) {
113
+  if (!ctype_digit($slots) || $slots < 1 || $slots > 3) {
114
+   $slots = 1;
115
+  }
116
+
117
+  $sql  = 'INSERT INTO users (user_name, user_pass, user_email, user_tac, ';
118
+  $sql .= 'band_total, hdd_total) VALUES (\''.m($username).'\', \'invalid\'';
119
+  $sql .= ', \''.m($email).'\', '.((int)$tac).', '.(50000000000*$slots).', ';
120
+  $sql .= (3500000000*$slots).')';
121
+  mq($sql) or mf(__FILE__, __LINE__, $sql);
122
+  $uid = mysql_insert_id();
123
+
124
+  $sql  = 'GRANT USAGE ON *.* TO \''.m($username).'\'@\'localhost\' IDENTIFIED';
125
+  $sql .= 'BY \'dummypass123445\'';
126
+  $l = mysql_connect('localhost', 'root', 'mysql32159');;
127
+  mysql_select_db('admin', $l);
128
+  mq($sql,$l) or mf(__FILE__, __LINE__, $sql);
129
+  mysql_close($l);
130
+  $_redodb = true; require('/home/utd/control/lib/database.php'); unset($_redodb);
131
+
132
+  $fqdn = m($username.'.utd-hosting.com');
133
+
134
+  $sql  = 'INSERT INTO domains (user_id, domain_name, domain_enabled, domain_parent) VALUES (';
135
+  $sql .= (int)$uid.', \''.$fqdn.'\', 1, 16)';
136
+  mq($sql) or mf(__FILE__, __LINE__, $sql);
137
+  $domain = mysql_insert_id();
138
+
139
+  $docroot = m('/home/'.$username.'/public_html');
140
+  $sql  = 'INSERT INTO sites (user_id, site_name, site_docroot, ';
141
+  $sql .= 'site_curdocroot) VALUES ('.(int)$uid.', \''.$fqdn;
142
+  $sql .= '\', \''.$docroot.'\', \''.$docroot.'\')';
143
+  mq($sql) or mf(__FILE__, __LINE__, $sql);
144
+  $site = mysql_insert_id();
145
+
146
+  $sql  = 'INSERT INTO records (domain_id, record_type, record_value) VALUES (';
147
+  $sql .= (int)$domain.', \'UTD\', \''.(int)$site.'\')';
148
+  mq($sql) or mf(__FILE__, __LINE__, $sql);
149
+
150
+  $sql  = 'INSERT INTO billing (bill_due, user_id, bill_paid, bill_amount) ';
151
+  $sql .= ' VALUES ('.time().', '.(int)$uid.', 1, '.(3500*$slots).')';
152
+  mq($sql) or mf(__FILE__, __LINE__, $sql);
153
+
154
+  $sql  = 'INSERT INTO actions (user_id, action_type, action_value) VALUES (';
155
+  $sql .= (int)$uid.', \'create\', \'...\')';
156
+  mq($sql) or mf(__FILE__, __LINE__, $sql);
157
+
158
+  changePass($uid, $pass);
159
+ }
160
+
161
+ // Returns true if $pass is complex enough, or an error message if not
162
+ function validPass ($pass) {
163
+  if (preg_match('/[a-z]/',$pass)) {
164
+   if (preg_match('/[A-Z]/',$pass)) {
165
+    if (preg_match('/[0-9]/', $pass)) {
166
+     if (strlen($pass) < 5 || strlen($pass) > 20) {
167
+      return 'Please ensure your password is 5-20 characters long';
168
+     } else {
169
+      return true;
170
+     }
171
+    } else {
172
+     return 'Please ensure your password includes some numbers';
173
+    }
174
+   } else {
175
+    return 'Please ensure your password includes some uppercase letters';
176
+   }
177
+  } else {
178
+   return 'Please ensure your password includes some lowercase letters';
179
+  }
180
+ }
181
+
182
+ function checkAccess($conditions) {
183
+  if ($conditions !== true) {
184
+   define('REASON', 'Insufficient access'); 
185
+   require('403.php');
186
+   exit(); 
187
+  }
188
+ }
189
+ 
190
+ define('LIB_ACCOUNT', true);
191
+
192
+?>

+ 42
- 0
lib/bandwidth.php View File

@@ -0,0 +1,42 @@
1
+<?PHP
2
+
3
+ if (defined('NOBILLREF')) { return; }
4
+
5
+ require_once('lib/profiler.php');
6
+
7
+ $sql = 'SELECT band_total, band_used, hdd_total, hdd_used FROM users WHERE user_id = '.UID;
8
+ $ress = mq($sql, __FILE__, __LINE__);
9
+ $row = mysql_fetch_array($ress);
10
+
11
+ $used = round($row[1] * (150/($row[0])),0);
12
+ $free = 150 - $used;
13
+
14
+ $hused = round($row[3] * (150/($row[2])),0);
15
+ $hfree = 150 - $hused;
16
+
17
+ $sql  = 'SELECT MIN(up_expires) FROM userpackages WHERE';
18
+ $sql .= ' user_id = '.UID.' AND up_invoice = 1 AND up_active = 1';
19
+ $ress = mq($sql, __FILE__, __LINE__);
20
+ $pay = mysql_fetch_array($ress);
21
+ $next = $pay[0];
22
+?>
23
+<table id="bandwidth" class="righthead">
24
+ <tr>
25
+  <th>Bandwidth</th>
26
+  <td>
27
+   <img src="<?PHP echo CP_PATH; ?>res/bandout-001.png" alt="[Red]" title="Bandwidth used" width="<?PHP echo $used; ?>" height="10"><img src="<?PHP echo CP_PATH; ?>res/bandfree-001.png" alt="[Green]" title="Free bandwidth" width="<?PHP echo $free; ?>" height="10">
28
+  </td>
29
+  <td><?PHP echo niceSize($row[1]).' / '.niceSize($row[0]); ?></td>
30
+ </tr>
31
+ <tr>
32
+  <th>Hard drive</th>
33
+  <td>
34
+   <img src="<?PHP echo CP_PATH; ?>res/bandout-001.png" alt="[Red]" title="Hard drive space used" width="<?PHP echo $hused; ?>" height="10"><img src="<?PHP echo CP_PATH; ?>res/bandfree-001.png" alt="[Green]" title="Free space" width="<?PHP echo $hfree; ?>" height="10">
35
+  </td>
36
+  <td><?PHP echo niceSize($row[3]).' / '.niceSize($row[2]); ?></td>
37
+ </tr>
38
+ <tr>
39
+  <th>Next payment</th>
40
+  <td colspan="2" style="text-align: center"><?PHP echo date('l, jS F, Y', $next); ?></td>
41
+ </tr>
42
+</table>

+ 96
- 0
lib/common.php View File

@@ -0,0 +1,96 @@
1
+<?PHP
2
+
3
+ if (strpos(__FILE__, 'control-dev') !== false) {
4
+  define('CP_PATH', '/dev/');
5
+  define('DEVELOPMENT', True);
6
+ } else {
7
+  define('CP_PATH', '/control/');
8
+  define('DEVELOPMENT', False);
9
+ }
10
+
11
+ require_once('lib/database.php');
12
+ require_once('lib/log.php');
13
+ 
14
+ function NiceSize($bytes) {
15
+  $sizes = array();
16
+  $sizes[1024] = ' <abbr title="Kibibytes">KiB</abbr>';
17
+  $sizes[(1024*1024)] = ' <abbr title="Mebibytes">MiB</abbr>';
18
+  $sizes[(1024*1024*1024)] = ' <abbr title="Gibibytes">GiB</abbr>';
19
+  krsort($sizes);
20
+  foreach ($sizes as $val => $name) {
21
+   if ($bytes > ($val * 1.2)) {
22
+    return round($bytes/$val, 2).$name;
23
+   }
24
+  }
25
+  return $bytes.' <abbr title="Bytes">B</abbr>';
26
+ }
27
+ 
28
+ function h ($text) { return htmlspecialchars($text); } 
29
+ function m ($a) { return mysql_real_escape_string($a); }
30
+ function l ($message, $uid = false) { 
31
+  logger::log($message, $uid);
32
+ }
33
+
34
+ function botlog ($message) {
35
+  logger::log($message);
36
+ }
37
+
38
+ function bfc ($ip) {
39
+  if (file_exists('/home/utd/bruteforce.dat')) {
40
+   $data = unserialize(file_get_contents('/home/utd/bruteforce.dat'));
41
+  } else {
42
+   $data = array();
43
+  }
44
+  foreach ($data as $uip => $attempts) {
45
+   foreach ($attempts as $id => $time) {
46
+    if ($time < time()-1800) { unset($data[$uip][$id]); }
47
+   }
48
+   if (count($data[$uip]) == 0) { unset($data[$uip]); }
49
+  }
50
+  if (!isset($data[$ip])) { $data[$ip] = array(); }
51
+  $data[$ip][] = time();
52
+  file_put_contents('/home/utd/bruteforce.dat', serialize($data));
53
+  if (count($data[$ip]) > 4) {
54
+   $sql  = 'INSERT INTO ipbans (ipban_ip, ipban_expires, ipban_message) ';
55
+   $sql .= 'VALUES (\''.m($ip).'\', '.(time()+60*60*24).', \'Too many login';
56
+   $sql .= ' attempts.\')';
57
+   mysql_query($sql);
58
+   logger::log('Placing IP ban on '.$ip.' for bruteforcing',logger::important);
59
+   header('Location: '.CP_PATH.'403');
60
+   exit;
61
+  }
62
+ }
63
+
64
+ function duration ($secs, $dopast = false) {
65
+  $res = '';
66
+  $times = array();
67
+  $times['year'] = (60*60*24*365);
68
+  $times['month'] = (60*60*24*30);
69
+  $times['week'] = (60*60*24*7);
70
+  $times['day'] = (60*60*24);
71
+  $times['hour'] = (60*60);
72
+  if ($secs < $times['hour']) { $times['minute'] = 60; }
73
+  if ($secs < $times['minute']) { $times['second'] = 1; }
74
+
75
+  foreach ($times as $name => $val) {
76
+   if ($secs >= $val) {
77
+    $years = floor($secs/$val);
78
+    $res .= ', '.$years.' '.$name.(($years!=1)?'s':'');
79
+    $secs = $secs % $val;
80
+   }
81
+  }
82
+
83
+  $res = substr($res, 2);
84
+
85
+  if ($res == '' && $dopast === true) {
86
+   $res = 'now';
87
+  } elseif ($res == '' && $dopast == '0') {
88
+   $res = '0 seconds';
89
+  }
90
+
91
+  return $res;
92
+ }
93
+ 
94
+ define('LIB_COMMON', true);
95
+
96
+?>

+ 47
- 0
lib/dashboard.php View File

@@ -0,0 +1,47 @@
1
+<?PHP
2
+
3
+if (defined('LIB_DASHBOARD')) { return; }
4
+
5
+$dbitems = array();
6
+
7
+function addDashboardItem ($category, $title, $url) {
8
+  global $dbitems;
9
+  
10
+  if (!isset($dbitems[$category])) {
11
+    $dbitems[$category] = array();
12
+  }
13
+  
14
+  $dbitems[$category][$title] = $url;
15
+}
16
+
17
+function generateDashboard () {
18
+  global $dbitems;
19
+  
20
+  ksort($dbitems);
21
+  
22
+  foreach ($dbitems as $k => $v) { ksort($dbitems[$k]); }
23
+  
24
+  echo '<div id="dashboard">';
25
+  
26
+  foreach ($dbitems as $category => $data) {
27
+    echo '<h2>'.$category.'</h2><ul>';  
28
+    foreach ($data as $title => $url) {
29
+      if ($url[0] != '#' && substr($url,0,7) != 'http://' && substr($url,0,8) != 'https://') { 
30
+	    $url = CP_PATH.$url;
31
+      }
32
+      echo '<li><a href="'.htmlspecialchars($url).'"';
33
+      if ($title[0] == '*') {
34
+       echo ' style="font-weight: bold;"';
35
+       $title = substr($title, 1);
36
+      }
37
+      echo '>'.$title.'</a></li>';
38
+    }
39
+    echo '</ul>';
40
+  }
41
+  
42
+  echo '</div>';
43
+}
44
+
45
+define('LIB_DASHBOARD', true);
46
+
47
+?>

+ 19
- 0
lib/database.php View File

@@ -0,0 +1,19 @@
1
+<?PHP
2
+
3
+ if (defined('LIB_DB') && !isset($_redodb)) { return; }
4
+
5
+ require_once('lib/profiler.php');
6
+ require_once('lib/log.php');
7
+
8
+ mysql_connect('localhost', '', '');
9
+ mysql_select_db('');
10
+
11
+ if (!function_exists('mf')) {
12
+  function mf ($file, $line, $sql) {
13
+   logger::log($file.'<'.$line.'>: MySQL query failed: '.mysql_error().' [SQL: '.$sql.']', logger::important);
14
+  }
15
+ }
16
+
17
+ define('LIB_DB', true);
18
+
19
+?>

+ 11
- 0
lib/footer.php View File

@@ -0,0 +1,11 @@
1
+<?PHP
2
+ if (DEVELOPMENT) {
3
+#  require_once('pages/profiler.php');
4
+ }
5
+?>
6
+  <div id="footer">
7
+   &copy; Copyright UTD-Hosting, 2005-2007, all rights reserved.
8
+   Release 5.
9
+  </div>
10
+ </body>
11
+</html>

+ 75
- 0
lib/header.php View File

@@ -0,0 +1,75 @@
1
+<?PHP
2
+
3
+ require_once('lib/common.php'); 
4
+ require_once('lib/profiler.php');
5
+ require_once('lib/account.php'); 
6
+ require_once('lib/dashboard.php'); 
7
+
8
+?>
9
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
10
+<html>
11
+ <head>
12
+  <title>UTD-Hosting :: <?PHP echo TITLE; ?></title>
13
+  <link rel="stylesheet" type="text/css" href="<?PHP echo CP_PATH; ?>res/style-002.css">
14
+  <script src="<?PHP echo CP_PATH; ?>res/script-001.js" type="text/javascript"></script>
15
+ </head>
16
+ <body>
17
+  <div id="header">
18
+   <h1><img src="<?PHP echo CP_PATH; ?>res/logo-001.png" alt="UTD-Hosting" title="UTD-Hosting"></h1>
19
+  </div>
20
+<?PHP
21
+
22
+ if (DEVELOPMENT) { echo '<div id="dev">Development version</div>'; }
23
+
24
+ if (defined('USER')) { require_once('lib/bandwidth.php'); }
25
+
26
+?>  
27
+  <div id="menu">
28
+   <div id="menuleft">
29
+    <?PHP if (defined('USER') && !defined('NOBILLREF')) { ?>
30
+    <a href="<?PHP echo CP_PATH; ?>">Account overview</a> |
31
+    <?PHP if (HAS_DNS || HAS_HOSTING) { ?>
32
+     <a href="<?PHP echo CP_PATH; ?>domains">Domains</a> |
33
+    <?PHP } ?>
34
+    <?PHP if (HAS_DNS) { ?>
35
+     <a href="<?PHP echo CP_PATH; ?>dns">DNS</a> |
36
+    <?PHP } ?>
37
+    <?PHP if (HAS_HOSTING) { ?>
38
+     <a href="<?PHP echo CP_PATH; ?>email">E-mail</a> |
39
+     <a href="<?PHP echo CP_PATH; ?>database">Databases</a> |
40
+     <a href="<?PHP echo CP_PATH; ?>sites">Sites</a> |
41
+    <?PHP } ?>
42
+    <?PHP if (HAS_SSH) { ?>
43
+     <a href="<?PHP echo CP_PATH; ?>ssh">SSH</a> |
44
+    <?PHP } ?>
45
+    <a href="<?PHP echo CP_PATH; ?>tickets">Tickets</a>
46
+    <?PHP } else { ?>
47
+    UTD-Hosting control panel
48
+    <?PHP } ?>
49
+   </div>
50
+   <div id="menuright">
51
+    <?PHP if (defined('USER') && !defined('NOBILLREF')) { ?>
52
+    <a href="<?PHP echo CP_PATH; ?>account">My Account</a> |
53
+    <a href="<?PHP echo CP_PATH; ?>invoices">My Invoices</a> |
54
+    <a href="<?PHP echo CP_PATH; ?>support">Support</a> |
55
+    <?PHP if (defined('ADMIN') && ADMIN) { ?>
56
+    <a href="<?PHP echo CP_PATH; ?>admin" style="font-weight: bold;">Admin</a> |
57
+    <?PHP } ?>
58
+    <a href="<?PHP echo CP_PATH; ?>logout">Log out</a>
59
+    <?PHP } else { ?>
60
+    <a href="<?PHP echo CP_PATH; ?>support">Support</a> 
61
+    <?PHP if (!defined('USER')) { ?>
62
+     | <a href="<?PHP echo CP_PATH; ?>login">Log in</a>
63
+    <?PHP } else { ?>
64
+     | <a href="<?PHP echo CP_PATH; ?>billing" style="font-weight: bold;">Billing</a>
65
+    <?PHP } } ?>
66
+   </div>
67
+  </div>
68
+  <?PHP generateDashboard(); ?>
69
+  <?PHP if (defined('MESSAGE')) { ?>
70
+  <div id="message">
71
+   <div>
72
+    <?PHP echo MESSAGE; ?>
73
+   </div>
74
+  </div>
75
+  <?PHP } ?>

+ 65
- 0
lib/log.php View File

@@ -0,0 +1,65 @@
1
+<?PHP
2
+
3
+ require_once('lib/database.php');
4
+
5
+ class logger {
6
+
7
+  const unknown = "'unknown'";
8
+  const critical = "'critical'";
9
+  const important = "'important'";
10
+  const normal = "'normal'";
11
+  const information = "'info'";
12
+  const info = "'info'";
13
+
14
+  static function log ($message, $uid = false, $level = logger::unknown) {
15
+   if ($uid !== false && !ctype_digit((string)$uid)) {
16
+    $temp = $level;
17
+    $level = $uid;
18
+    $uid = $temp;
19
+   }
20
+
21
+   if ($uid === false || !ctype_digit((string)$uid)) {
22
+    if (defined('UID')) { $uid = UID; } else { $uid = 5; }
23
+   }
24
+
25
+   if (DEVELOPMENT) {
26
+    $message = 'DEV: '.$message;
27
+   }
28
+
29
+   $sql  = 'INSERT INTO log (user_id, log_level, log_time, log_message) ';
30
+   $sql .= 'VALUES('.$uid.', '.$level.', '.time().', \''.m($message).'\')';
31
+   mysql_query($sql);
32
+
33
+   $botmsg = '';
34
+   switch ($level) {
35
+    case self::critical:
36
+     $botmsg = chr(2).chr(3).'4CRITICAL:'.chr(3).chr(2); break;
37
+    case self::important:
38
+     $botmsg = chr(2).'IMPORTANT:'.chr(2); break;
39
+    case self::normal:
40
+     $botmsg = 'NORMAL:'; break;
41
+    case self::unknown:
42
+     $botmsg = 'UNKNOWN:'; break;
43
+    case self::information:
44
+     $botmsg = chr(3).'14INFORMATION:'.chr(3); break;
45
+   }
46
+
47
+   if ($uid != 5) {
48
+    $sql = 'SELECT user_name FROM users WHERE user_id = '.$uid;
49
+    $res = mysql_query($sql);
50
+    $row = mysql_fetch_array($res);
51
+    $botmsg .= ' User '.$row['user_name'].':';
52
+   }
53
+
54
+   $botmsg .= ' '.$message;
55
+
56
+   if ($fh = @fsockopen('utd-hosting.com',3302,$errno,$errstr,0.1)) {
57
+    fputs($fh, '... #utd.staff '.$botmsg."\r\n");
58
+    fclose($fh);
59
+   }
60
+
61
+  } 
62
+
63
+ }
64
+
65
+?>

+ 26
- 0
lib/profiler.php View File

@@ -0,0 +1,26 @@
1
+<?php
2
+
3
+ require_once('lib/common.php');
4
+
5
+ if (DEVELOPMENT) {
6
+  $_queries = array();
7
+ }
8
+
9
+ function mq($sql, $file = '/home/utd/control-dev/Unknown', $line = 'Unknown') {
10
+  if (DEVELOPMENT) {
11
+   $start = microtime(true);
12
+  }
13
+
14
+  $res = mysql_query($sql) or mf($file, $line, $sql);
15
+
16
+  if (DEVELOPMENT) {
17
+   $end = microtime(true);
18
+   
19
+   global $_queries;
20
+   $_queries[] = array($sql, $end - $start, $file, $line);
21
+  }
22
+
23
+  return $res;
24
+ }
25
+
26
+?>

+ 67
- 0
login.php View File

@@ -0,0 +1,67 @@
1
+<?PHP
2
+
3
+ require_once('lib/common.php');
4
+ require_once('lib/database.php');
5
+ require_once('lib/dashboard.php');
6
+ 
7
+ define('NOLOGINREF', true); // So we don't go round in circles
8
+
9
+ require_once('lib/account.php');
10
+
11
+ if (isset($_POST['username']) && isset($_POST['password'])) {
12
+   
13
+   $pass = md5($_POST['username'].$_POST['password']);
14
+   $user = mysql_real_escape_string($_POST['username']);
15
+
16
+   $sql = 'SELECT user_id FROM users WHERE user_name = \''.$user.'\' AND user_pass = \''.$pass.'\'';
17
+   $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
18
+
19
+   if (mysql_num_rows($res) == 1) {
20
+     $row = mysql_fetch_array($res);
21
+     $uid = $row['user_id'];
22
+     $sip = mysql_real_escape_string($_SERVER['REMOTE_ADDR']);
23
+
24
+     $sql  = 'INSERT INTO sessions (user_id, session_ip, session_start, session_last';
25
+     $sql .= ',session_ident) VALUES ('.$uid.', \''.$sip.'\', '.time().', '.time();
26
+     $sql .= ', \'null\')';
27
+     mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
28
+
29
+     $id = mysql_insert_id();
30
+
31
+     $sid = md5($uid.$sip.$id);
32
+
33
+     $sql = 'UPDATE sessions SET session_ident = \''.$sid.'\' WHERE session_id = '.$id;
34
+     mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
35
+
36
+     setcookie('utdsid', $sid, time()+60*60*24, '/');
37
+     logger::log('Login from '.$_SERVER['REMOTE_ADDR'],$uid,logger::information);
38
+ 
39
+     header('Location: '.CP_PATH);
40
+   } else {
41
+     $sql = 'SELECT user_pass FROM users WHERE user_name = \''.m($_POST['username']).'\'';
42
+     $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
43
+     $row = mysql_fetch_array($res);
44
+     if ($row['user_pass']{0} == '!') {
45
+      define('MESSAGE', 'This account is locked. Please contact support@utd-hosting.com for assistance.');
46
+      logger::log('Log in attempt for locked account '.$_POST['username'].' by '.$_SERVER['REMOTE_ADDR'], logger::normal);
47
+     } else {
48
+      define('MESSAGE', 'Invalid username/password combination');
49
+      logger::log('Invalid login attempt for user '.$_POST['username'].' by '.$_SERVER['REMOTE_ADDR'], logger::normal); 
50
+      bfc($_SERVER['REMOTE_ADDR']);
51
+     }
52
+   }
53
+   
54
+ }
55
+ 
56
+ addDashboardItem('Useful links', 'Recover password', 'recoverpw');
57
+ addDashboardItem('Frequently asked questions', 'Can I give other users access to my control panel?', 'support/006');
58
+ addDashboardItem('Frequently asked questions', 'What do I do if I forget my username?', 'support/007');
59
+ addDashboardItem('Frequently asked questions', 'Can I file support requests without using the control panel?', 'support/005');
60
+
61
+ define('TITLE', 'Login');
62
+ 
63
+ require_once('lib/header.php');
64
+ require_once('pages/login.php');
65
+ require_once('lib/footer.php');
66
+
67
+?>

+ 24
- 0
logout.php View File

@@ -0,0 +1,24 @@
1
+<?PHP
2
+ 
3
+ define('NOLOGINREF', true); // So we don't go round in circles
4
+ define('NOTACREF', true);
5
+
6
+ require_once('lib/common.php');
7
+ require_once('lib/database.php');
8
+ require_once('lib/account.php');
9
+
10
+ if (defined('SPOOF')) {
11
+  $sql  = 'UPDATE sessions SET session_spoof = 0 WHERE session_ident = \'';
12
+  $sql .= m($_COOKIE['utdsid']).'\'';
13
+  mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
14
+  logger::log('Stopped spoofing user '.USER, logger::normal, SPOOF);
15
+  header('Location: '.CP_PATH);
16
+  exit;
17
+ } else {
18
+  logger::log('Manual logout',logger::info);
19
+  setcookie('utdsid','', time()-24*24*60, '/');
20
+  header('Location: '.CP_PATH.'login');
21
+  exit;
22
+ }
23
+ 
24
+?>

+ 66
- 0
pages/adddomain.php View File

@@ -0,0 +1,66 @@
1
+<?PHP
2
+
3
+ $sql = 'SELECT domain_id, domain_name FROM domains WHERE domain_enabled = 1 AND user_id = '.UID;
4
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
5
+
6
+ if (mysql_num_rows($res) > 0) {
7
+?>
8
+<form name="submd" action="<?PHP echo CP_PATH; ?>domains" method="post" onSubmit="return validateSubdomainForm();">
9
+<input type="hidden" name="action" value="addsub">
10
+<div class="block">
11
+ <h2>Add a new subdomain</h2>
12
+ <div class="innerblock">
13
+  <p class="blurb">
14
+   You can add a new subdomain to any of your existing domains. Subdomains
15
+   are added instantly, and you can use them right away. You will need to
16
+   make sure that the subdomain resolves to the correct IP address.
17
+  </p>
18
+  <table class="form leftpad">
19
+   <tr>
20
+    <td><input type="text" name="subdomain" id="subdomain" class="inflat" style="width: 120px;"></td>
21
+    <td style="width: 10px;">.</td>
22
+    <td>
23
+     <select name="subdomaind" id="subdomaind" style="inflat">
24
+<?PHP
25
+
26
+ while ($row = mysql_fetch_array($res)) { 
27
+  if (strpos($row['domain_name'],'*')) { continue; }
28
+  echo '<option value="'.$row['domain_id'].'">'.$row['domain_name'].'</option>';
29
+ }
30
+
31
+?>
32
+     </select>
33
+    </td>
34
+    <td style="width:100%;"><span id="subdomainerr" class="validation"></span></td>
35
+   </tr>
36
+   <tr><td colspan="3" style="text-align: right;">
37
+    <input type="submit" value="Add">
38
+   </td></tr>
39
+  </table>
40
+ </div>
41
+</div>
42
+</form>
43
+<?PHP } ?>
44
+<form name="md" action="<?PHP echo CP_PATH; ?>domains" method="post" onSubmit="return validateDomainForm();">
45
+<input type="hidden" name="action" value="add">
46
+<div class="block">
47
+ <h2>Add a new domain</h2>
48
+ <div class="innerblock">
49
+  <p class="blurb">
50
+   Before you can use a new domain, a UTD-Hosting staff member will have to confirm that the
51
+   domain belongs to you. This is to ensure that other customers do not "steal" your domains,
52
+   and vice-versa.
53
+  </p>
54
+  <table class="form leftpad">
55
+   <tr>
56
+    <td><input type="text" name="domain" id="domain" class="inflat" style="width: 120px;"></td>
57
+    <td style="width:100%;"><span id="domainerr" class="validation"></span></td>
58
+   </tr>
59
+   <tr><td style="text-align: right;">
60
+    <input type="submit" value="Add">
61
+   </td></tr>
62
+  </table>
63
+ </div>
64
+</div>
65
+</form>
66
+

+ 56
- 0
pages/addemail.php View File

@@ -0,0 +1,56 @@
1
+<form action="<?PHP echo CP_PATH; ?>email" method="post">
2
+<div class="block">
3
+ <h2>Add e-mail address</h2>
4
+ <div class="innerblock">
5
+  <p class="blurb">
6
+   This will associated an e-mail address with an existing mailbox. 
7
+  </p>
8
+  <table class="form leftpad">
9
+   <tr>
10
+    <th>E-Mail address</th>
11
+    <td><input type="text" name="email_user" class="inflat"> @
12
+<select name="email_domain" class="inflat">
13
+<?PHP
14
+
15
+ $sql = 'SELECT domain_name, domain_id FROM domains WHERE user_id = '.UID.' AND domain_enabled = 1 ORDER BY domain_name';
16
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
17
+ $found = false;
18
+ while ($row = mysql_fetch_array($res)) {
19
+  $found = true;
20
+  echo '<option value="'.$row['domain_id'].'">'.h($row['domain_name']).'</option>';
21
+ }
22
+ if (!$found) { echo '<option value="err">&lt;No domains&gt;</option>'; }
23
+
24
+?>
25
+    </select></td>
26
+   </tr>
27
+   <tr>
28
+    <th>Mailbox</th>
29
+    <td><select name="email_mailbox" class="inflat">
30
+<?PHP
31
+
32
+ $sql = 'SELECT mailbox_id, mailbox_user, domain_name FROM mailboxes NATURAL JOIN domains WHERE user_id = '.UID.' ORDER BY mailbox_user, domain_name';
33
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
34
+ 
35
+ if (mysql_num_rows($res) == 0) {
36
+  echo '<option value="err">&lt;No mailboxes&gt;</option>'; 
37
+ } else {
38
+  while ($row = mysql_fetch_assoc($res)) {
39
+   echo '<option value="'.$row['mailbox_id'].'">';
40
+   echo h($row['mailbox_user'] . '@' . $row['domain_name']);
41
+   echo '</option>';
42
+  }
43
+ }
44
+
45
+?>
46
+    </select></td>
47
+   </tr>
48
+   <tr>
49
+    <th>Actions</th>
50
+    <td><input type="submit" value="Add"> <input type="reset" value="Cancel"></td>
51
+    <td></td>
52
+   </tr>
53
+  </table>
54
+ </div>
55
+</div>
56
+</form>

+ 45
- 0
pages/addmailbox.php View File

@@ -0,0 +1,45 @@
1
+<form action="<?PHP echo CP_PATH; ?>email" method="post">
2
+<div class="block">
3
+ <h2>Add mailbox</h2>
4
+ <div class="innerblock">
5
+  <p class="blurb">
6
+   This will create a new mailbox. For more information on how mailboxes and
7
+   e-mail addresses work, see <a href="<?PHP echo CP_PATH; ?>support/027">this
8
+   support article</a>. 
9
+  </p>
10
+  <table class="form leftpad">
11
+   <tr>
12
+    <th>Mailbox name</th>
13
+    <td><input type="text" name="mailbox_user" class="inflat"> @
14
+<select name="mailbox_domain" class="inflat">
15
+<?PHP
16
+
17
+ $sql = 'SELECT domain_name, domain_id FROM domains WHERE user_id = '.UID.' AND domain_enabled = 1 ORDER BY domain_name';
18
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
19
+ $found = false;
20
+ while ($row = mysql_fetch_array($res)) {
21
+  $found = true;
22
+  echo '<option value="'.$row['domain_id'].'">'.h($row['domain_name']).'</option>';
23
+ }
24
+ if (!$found) { echo '<option value="err">&lt;No domains&gt;</option>'; }
25
+
26
+?>
27
+    </select></td>
28
+   </tr>
29
+   <tr>
30
+    <th>Mailbox password</th>
31
+    <td><input type="password" name="mailbox_pass1" class="inflat"></td>
32
+   </tr>
33
+   <tr>
34
+    <th>Confirm password</th>
35
+    <td><input type="password" name="mailbox_pass2" class="inflat"></td>
36
+   </tr>
37
+   <tr>
38
+    <th>Actions</th>
39
+    <td><input type="submit" value="Add"> <input type="reset" value="Cancel"></td>
40
+    <td></td>
41
+   </tr>
42
+  </table>
43
+ </div>
44
+</div>
45
+</form>

+ 45
- 0
pages/addsite.php View File

@@ -0,0 +1,45 @@
1
+<form action="<?PHP echo CP_PATH; ?>addsite" method="post">
2
+<div class="block">
3
+ <h2>Add site</h2>
4
+ <div class="innerblock">
5
+  <p class="blurb">
6
+   This will create a new site. If your domain name (or subdomain) is not
7
+   listed, please ensure that you have added it to the <a href="<?PHP echo CP_PATH; ?>domains">domains page</a>, and that it is not associated with an existing site.
8
+  </p>
9
+  <table class="form leftpad">
10
+   <tr>
11
+    <th>Primary domain</th>
12
+    <td><select name="domain" class="inflat">
13
+<?PHP
14
+
15
+ $sql = 'SELECT domain_name, domain_id FROM domains WHERE user_id = '.UID.' AND domain_enabled = 1';
16
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
17
+ $found = false;
18
+ while ($row = mysql_fetch_array($res)) {
19
+  $sql = 'SELECT record_value FROM records WHERE domain_id = '.$row['domain_id'].' AND record_type = \'UTD\'';
20
+  $re2 = mysql_query($sql) or mf(__FILE__, __LINE__, $sql); 
21
+  if (mysql_num_rows($re2) == 0) {
22
+   $found = true;
23
+   echo '<option value="'.$row['domain_id'].'">'.h($row['domain_name']).'</option>';
24
+  }
25
+ }
26
+ if (!$found) { echo '<option value="err">&lt;No domains&gt;</option>'; }
27
+
28
+?>
29
+    </select></td>
30
+    <td><a href="<?PHP echo CP_PATH; ?>support/018">Help</a></td>
31
+   </tr>
32
+   <tr>
33
+    <th>Document root</th>
34
+    <td><input type="text" name="docroot" value="/public_html" class="inflat"></td>
35
+    <td><a href="<?PHP echo CP_PATH; ?>support/015">Help</a></td>
36
+   </tr>
37
+   <tr>
38
+    <th>Actions</th>
39
+    <td><input type="submit" value="Add"> <input type="reset" value="Cancel"></td>
40
+    <td></td>
41
+   </tr>
42
+  </table>
43
+ </div>
44
+</div>
45
+</form>

+ 36
- 0
pages/admin.actions.php View File

@@ -0,0 +1,36 @@
1
+<?PHP
2
+ require_once('lib/database.php'); 
3
+ require_once('lib/common.php'); 
4
+?>
5
+<div class="block">
6
+<form action="<?PHP echo CP_PATH; ?>admin" method="post">
7
+ <h2>ADMIN: Schedule actions</h2>
8
+ <table class="innerblock">
9
+  <tr>
10
+   <th>Service</th>
11
+   <th>Update config</th>
12
+   <th>Restart</th>
13
+  </tr>
14
+<?PHP
15
+
16
+ $services = array('apache', 'bind', 'postfix', 'sshkeys');
17
+
18
+ $i = 0;
19
+
20
+ foreach ($services as $service) {
21
+?>
22
+  <tr class="<?PHP echo ($i == 0) ? 'even' : 'odd'; ?>">
23
+   <td><?PHP echo ucfirst($service); ?></td>
24
+   <td><input type="submit" name="<?PHP echo $service; ?>_updateconf" value="Update config"></td>
25
+   <td><input type="submit" name="<?PHP echo $service; ?>_restart" value="Restart" <?PHP
26
+    if ($service == 'sshkeys') { echo ' disabled="disabled"'; }
27
+   ?>></td>
28
+  </tr>
29
+<?PHP
30
+   $i = 1 - $i;
31
+ }
32
+
33
+?>    
34
+ </table>
35
+ </form>
36
+</div>

+ 40
- 0
pages/admin.addannouncement.php View File

@@ -0,0 +1,40 @@
1
+<form action="<?PHP echo CP_PATH; ?>adminannouncements" method="post">
2
+<div class="block">
3
+ <h2>ADMIN: Create message</h2>
4
+ <div class="innerblock">
5
+  <p class="blurb">
6
+   You must preview announcements before submitting. Announcements
7
+   will be e-mailed to users who have opted to receive them as soon as the
8
+   announcement is submitted.
9
+  </p>
10
+  <table class="form leftpad"> 
11
+   <tr>
12
+    <th>Title</th>
13
+    <td><input type="text" name="title" id="title" class="inflat"<?PHP if (isset($_POST['title'])) { echo ' value="'.h($_POST['title']).'"'; } ?>></td>
14
+   </tr><tr>
15
+    <th>Type</th>
16
+    <td><select name="type" class="inflat">
17
+     <option value="admin"<?PHP if ($_POST['type'] == 'admin') { echo ' selected="selected"'; } ?>>Admin</option>
18
+     <option value="announcement"<?PHP if ($_POST['type'] == 'announcement') { echo ' selected="selected"'; } ?>>Announcement</option>
19
+     <option value="information"<?PHP if ($_POST['type'] == 'information') { echo ' selected="selected"'; } ?>>Information</option>
20
+    </select></td>
21
+   </tr><tr>
22
+    <th width="10%">Body</th>
23
+    <td><textarea name="body" id="body" class="inflat"><?PHP
24
+     if (isset($_POST['body'])) { echo h($_POST['body']); }
25
+    ?></textarea></td>
26
+   </tr><tr>
27
+     <td colspan="2" style="text-align: right;">
28
+      <input type="reset" value="Reset">
29
+<?PHP if (defined('MESSAGE_BODY')) { ?>
30
+      <input type="submit" name="submit" value="Submit">
31
+<?PHP } else { ?>
32
+      <input type="submit" name="preview" value="Preview">
33
+<?PHP } ?>
34
+     </td>
35
+     <td width="100%">&nbsp;</td>
36
+   </tr>
37
+  </table>
38
+ </div>
39
+</div>
40
+</form>

+ 99
- 0
pages/admin.adddiscount.php View File

@@ -0,0 +1,99 @@
1
+<?PHP
2
+
3
+ function randLetter($set) {
4
+  global $codes;
5
+  $num = rand(65,90);
6
+  $codes[$set] += $num - 65;
7
+  return chr($num);
8
+ }
9
+
10
+ do {
11
+  $codes = array();
12
+  for ($i = 0; $i < 4; $i++) {
13
+   for ($j = 0; $j < 4; $j++) {
14
+    $code .= randLetter($i);
15
+   }
16
+   $code .= '-';
17
+  }
18
+
19
+  for ($i = 0; $i < 4; $i++) {
20
+   $code .= chr(($codes[$i] % 26) + 65);
21
+  }
22
+
23
+  $sql  = 'SELECT discount_code FROM discounts WHERE discount_code = ';
24
+  $sql .= '\'' . m($code) . '\'';
25
+  $res  = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
26
+ } while (mysql_num_rows($res) != 0);
27
+?>
28
+<form action="<?PHP echo CP_PATH; ?>admindiscounts" method="post">
29
+<input type="hidden" name="code" value="<?PHP echo $code; ?>">
30
+<div class="block">
31
+ <h2>ADMIN: Add discount</h2>
32
+ <div class="innerblock">
33
+  <p class="blurb">
34
+   The discount message may be blank. If non-blank it is displayed immediately
35
+   after the discount applied message (so you may want to start messages with
36
+   <code>&lt;br&gt;&lt;br&gt;</code> &mdash; HTML is allowed).
37
+  </p>
38
+  <table class="form leftpad" style="width: auto;"> 
39
+   <tr>
40
+    <th>Code</th>
41
+    <td><input type="text" name="codeinput" class="inflat" value="<?PHP echo $code; ?>" disabled="disabled" style="width: 352px;"></td>
42
+   </tr><tr>
43
+    <th>Message</th>
44
+    <td><input type="text" name="message" class="inflat" style="width: 352px;"></td>
45
+   </tr><tr>
46
+    <th>Valid period</th>
47
+    <td>
48
+     <input type="text" class="inflat" name="from" value="now">
49
+     <input type="text" class="inflat" name="to" value="+1 month">
50
+    </td>
51
+   </tr><tr>
52
+    <th>Time</th>
53
+    <td>
54
+     <input type="text" name="timequant" value="0" class="inflat">
55
+     <select name="timeunit" class="inflat">
56
+      <option value="1">Seconds</option>
57
+      <option value="60">Minutes</option>
58
+      <option value="3600">Hours</option>
59
+      <option value="86400">Days</option>
60
+      <option value="2592000">Months</option>
61
+      <option value="31536000">Years</option>
62
+     </select>
63
+    </tr>
64
+   </tr><tr>
65
+    <th>Money (pence)</th>
66
+    <td><input type="text" name="money" value="0" class="inflat"></td>
67
+   </tr><tr>
68
+    <th>Type</th>
69
+    <td>
70
+     <select name="type" class="inflat">
71
+      <option value="general">General</option>
72
+      <option value="signup">Signup</option>
73
+     </select>
74
+    </td>
75
+   </tr><tr>
76
+    <th>Package</th>
77
+    <td>
78
+     <select name="package" class="inflat">
79
+<?PHP
80
+
81
+ $sql = 'SELECT package_id, package_name FROM packages ORDER BY package_name';
82
+ $res = mysql_query($sql);
83
+ while ($row = mysql_fetch_assoc($res)) {
84
+  echo '<option value="'.$row['package_id'].'">'.h($row['package_name']);
85
+  echo '</option>';
86
+ }
87
+?>
88
+     </select>
89
+    </td>
90
+   </tr><tr>
91
+     <td colspan="2" style="text-align: right;">
92
+      <input type="reset" value="Reset">
93
+      <input type="submit" name="submit" value="Submit">
94
+     </td>
95
+   </tr>
96
+  </table>
97
+ </div>
98
+</div>
99
+</form>

+ 44
- 0
pages/admin.addfinances.php View File

@@ -0,0 +1,44 @@
1
+<form action="." method="post">
2
+<div class="block" id="add">
3
+ <h2>Add transaction</h2>
4
+ <div class="innerblock">
5
+  <table class="form">
6
+   <tr>
7
+    <th>Date</th>
8
+    <td>
9
+     <input type="text" name="date" value="<?PHP echo date('Y-m-d'); ?>" class="inflat">
10
+    </td>
11
+   </tr>
12
+   <tr>
13
+    <th>Description</th>
14
+    <td>
15
+     <input type="text" name="desc" class="inflat">
16
+    </td>
17
+   </tr>
18
+   <tr>
19
+    <th>User</th>
20
+    <td>
21
+     <select name="user" class="inflat">
22
+      <option value="5">N/A</option>
23
+<?PHP
24
+
25
+ $sql = 'SELECT user_id, user_name FROM users WHERE user_pass != \'invalid\' ORDER BY user_name';
26
+ $res = mysql_query($sql);
27
+ while ($row = mysql_fetch_array($res)) {
28
+  echo '<option value="'.$row[0].'">'.$row[1].'</option>';
29
+ }
30
+?>
31
+     </select>
32
+    </td>
33
+   </tr>
34
+   <tr>
35
+    <th>Amount</th>
36
+    <td><input type="text" name="amount" value="35" class="inflat"></td>
37
+   </tr>
38
+   <tr>
39
+    <td></td><td><input type="submit" value="Add"></td>
40
+   </tr>
41
+  </table>
42
+ </div>
43
+</div>
44
+</form>

+ 30
- 0
pages/admin.addipban.php View File

@@ -0,0 +1,30 @@
1
+<form action="<?PHP echo CP_PATH; ?>adminbans" method="post">
2
+<div class="block">
3
+ <h2>ADMIN: Add IP ban</h2>
4
+ <div class="innerblock">
5
+  <p class="blurb">
6
+   IP Addresses are strictly matched (i.e., no ranges are allowed).
7
+   The reason specified is exposed to the banned user, so keep it civil.
8
+   Expirary time should be formatted as specified <a href="http://www.gnu.org/software/tar/manual/html_node/tar_109.html">here</a>. Most commonly you'll just
9
+   want '+1 day' or so.
10
+  </p>
11
+  <table class="form leftpad">
12
+   <tr>
13
+    <th><label for="ip">IP Address</label></th>
14
+    <td><input type="text" name="ip" class="inflat"></td>
15
+   </tr>
16
+   <tr>
17
+    <th><label for="reason">Reason</label></th>
18
+    <td><input type="text" name="reason" class="inflat"></td>
19
+   </tr>
20
+   <tr>
21
+    <th><label for="expirary">Expirary</label></th>
22
+    <td><input type="text" name="expirary" class="inflat"></td>
23
+   </tr>
24
+   <tr><td colspan="2" style="text-align: right;">
25
+    <input type="submit" value="Add">
26
+   </td></tr>
27
+  </table>
28
+ </div>
29
+</div>
30
+</form>

+ 45
- 0
pages/admin.announcements.php View File

@@ -0,0 +1,45 @@
1
+<?PHP
2
+ require_once('lib/database.php');
3
+ require_once('lib/common.php');
4
+?>
5
+<div class="block">
6
+ <h2>ADMIN: Announcements and messages</h2>
7
+ <table class="innerblock">
8
+  <tr>
9
+   <th>&nbsp;</th>
10
+   <th>Title</th>
11
+   <th>View</th>
12
+   <th>Type</th>
13
+   <th>Date</th>
14
+  </tr>
15
+<?PHP
16
+
17
+ $sql = 'SELECT message_id, message_type, message_title, message_time FROM messages ORDER BY message_time';
18
+ 
19
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
20
+ 
21
+ $i = 0;
22
+ $n = 0;
23
+
24
+ if (mysql_num_rows($res) == 0) {
25
+  echo '<tr><td colspan="5" style="font-style: italic; text-align: center;">';
26
+  echo 'There are no current announcements</td></tr>';
27
+ }
28
+  
29
+ while ($row = mysql_fetch_array($res)) {
30
+  $n++;
31
+?>
32
+  <tr<?PHP if ($i == 1) { echo ' class="odd"'; } ?>>
33
+   <td><?PHP echo $n; ?>.</td>
34
+   <td><?PHP echo $row['message_title']; ?></td>
35
+   <td><a href="<?PHP echo CP_PATH; ?>viewmessage/<?PHP echo $row['message_id']; ?>">View</a></td>
36
+   <td><?PHP echo ucfirst($row['message_type']); ?></td>
37
+   <td><?PHP echo substr(gmdate('r', $row['message_time']),0,-6); ?></td>
38
+  </tr>
39
+ <?PHP
40
+  $i = 1 - $i;
41
+ }
42
+
43
+?>  
44
+ </table>
45
+</div>

+ 47
- 0
pages/admin.discounts.php View File

@@ -0,0 +1,47 @@
1
+<?PHP
2
+ require_once('lib/database.php');
3
+ require_once('lib/common.php'); 
4
+?>
5
+<div class="block" id="log">
6
+ <h2>ADMIN: Discounts</h2>
7
+ <table class="innerblock">
8
+  <tr>
9
+   <th>&nbsp;</th>
10
+   <th>Code</th>
11
+   <th>Time</th>
12
+   <th>Money</th>
13
+   <th>Type</th>
14
+   <th>Package</th>
15
+   <th>Start</th>
16
+   <th>End</th>
17
+  </tr>
18
+<?PHP
19
+
20
+ $i = 0;
21
+ $n = 0;
22
+
23
+ $sql  = 'SELECT discount_id, discount_code, discount_time, discount_money, ';
24
+ $sql .= 'discount_type, discount_start, discount_end, package_name FROM ';
25
+ $sql .= 'discounts NATURAL JOIN packages ORDER BY discount_end';
26
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
27
+
28
+ while ($row = mysql_fetch_array($res)) {
29
+  $n++;
30
+  echo '<tr class="'.(($i != 0) ? 'odd':'even').'">';
31
+  echo ' <td>' . $n . '.</td>';
32
+  echo ' <td style="font-family: monospace;">' . h($row['discount_code']) . '</td>';
33
+  echo ' <td>' . duration($row['discount_time']) . '</td>';
34
+  echo ' <td>&pound;' . ($row['discount_money'] / 100) . '</td>';
35
+  echo ' <td>' . ucfirst($row['discount_type']) . '</td>';
36
+  echo ' <td>' . h($row['package_name']) . '</td>';
37
+  echo ' <td' . ($row['discount_start'] > time() ? ' style="color: red"' : '') . '>';
38
+  echo substr(date('r', $row['discount_start']), 0, -15) . '</td>';
39
+  echo ' <td' . ($row['discount_end'] < time() ? ' style="color: red"' : '') . '>';
40
+  echo substr(date('r', $row['discount_end']), 0, -15) . '</td>';
41
+  echo '</tr>';
42
+  $i = 1 - $i;
43
+ }
44
+
45
+?>    
46
+ </table>
47
+</div>

+ 50
- 0
pages/admin.domains.php View File

@@ -0,0 +1,50 @@
1
+<div class="block" id="domains">
2
+<h2>ADMIN: All domains</h2>
3
+<table class="innerblock">
4
+  <tr><th>&nbsp;</th><th>Domain</th><th>User</th><th>Site</th>
5
+  <th>DNS</th>
6
+  <th>Enabled?</td></tr>
7
+<?PHP
8
+
9
+ $sql = 'SELECT domain_id, domain_name, domain_enabled, domains.user_id, user_name FROM domains NATURAL JOIN users ORDER BY user_name, domain_name';
10
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
11
+
12
+ $i = 0;
13
+ $n = 0;
14
+
15
+ while ($row = mysql_fetch_array($res)) {
16
+  $n++;
17
+  $sql2 = 'SELECT r.record_value, s.site_name, s.site_id FROM records AS r, sites AS s WHERE r.domain_id = '.$row['domain_id'].' AND r.record_type = \'UTD\' AND s.site_id = r.record_value';
18
+  $res2 = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
19
+  if (mysql_num_rows($res2) > 0) {
20
+   $row2 = mysql_fetch_array($res2);
21
+   $asite = $row2['site_name'];
22
+   $asiteid = $row2['site_id'];
23
+  } else {
24
+   $asite = '';
25
+  }
26
+
27
+?>
28
+   <tr class="<?PHP echo ($i == 0) ? 'even' : 'odd'; ?>">
29
+    <td><?PHP echo $n; ?>.</td>
30
+    <td><?PHP echo h($row['domain_name']); ?></td>
31
+    <td><a href="<?PHP echo CP_PATH.'checkuser/'.$row['user_id']; ?>"><?PHP echo h($row['user_name']); ?></a></td>
32
+    <td><?PHP if ($asite != '') { ?>
33
+     <a href="<?PHP echo CP_PATH; ?>editsite/<?PHP echo $asiteid; ?>"><?PHP echo h($asite); ?></a>
34
+     </td>
35
+     <?PHP } else { ?>None</td><?PHP } ?><td>
36
+<?PHP if (gethostbyname($row['domain_name']) != '63.246.141.80') { ?>
37
+      <a href="<?PHP echo CP_PATH; ?>support/017" style="color: red;">Error</a>
38
+<?PHP } else { echo 'OK'; } ?>
39
+     </td><td>
40
+     <?PHP if ($row['domain_enabled'] != '1') { ?>
41
+     <a href="<?PHP echo CP_PATH; ?>enabledomain/<?PHP echo $row['domain_id']; ?>">Enable</a>
42
+     <?PHP } else { echo 'Enabled'; } ?>
43
+    </td>
44
+   </tr>
45
+<?PHP
46
+  $i = 1 - $i;
47
+ }
48
+?>
49
+  </table>
50
+</div>

+ 56
- 0
pages/admin.finances.php View File

@@ -0,0 +1,56 @@
1
+<div class="block" id="overview">
2
+ <h2>Overview</h2>
3
+ <table class="innerblock">
4
+  <tr>
5
+   <th>ID</th>
6
+   <th>Date</th>
7
+   <th>Description</th>
8
+   <th>User</th>
9
+   <th>Receipts</th>
10
+   <th>Payments</th>
11
+   <th>Balance</th>
12
+  </tr>
13
+<?PHP
14
+
15
+ function fn($n, $hl = false) {
16
+  $r = '&pound;'.abs(intval($n/100)).'.'.str_pad(abs($n%100),2,'0',STR_PAD_LEFT);
17
+  if ($n < 0) { $r = '-'.$r; }
18
+  if ($hl && $n < 0) {
19
+   $r = '<span style="color: red;">'.$r.'</span>';
20
+  }
21
+  return $r;
22
+ }
23
+
24
+ $sql  = 'SELECT finance_id, finance_time, finance_desc, user_name, ';
25
+ $sql .= 'finance_receipts, finance_payments, finance_balance FROM ';
26
+ $sql .= 'finances NATURAL JOIN users ORDER BY finance_time';
27
+ $res = mysql_query($sql) or print(mysql_error());
28
+ $i = 0;
29
+ $n = 0;
30
+ while ($row = mysql_fetch_assoc($res)) {
31
+  $i = 1 - $i;
32
+  $n++;
33
+?>
34
+  <tr class="<?PHP echo ($i == 1) ? 'even' : 'odd'; ?>">
35
+   <td><?PHP echo $n; ?>.</td>
36
+   <td><?PHP echo date('Y-m-d', $row['finance_time']); ?></td>
37
+   <td><?PHP echo htmlentities($row['finance_desc']); ?></td>
38
+   <td>
39
+    <?PHP
40
+     if ($row['user_name'] != 'admin') {
41
+      echo $row['user_name'];
42
+     } else {
43
+      echo '---';
44
+     }
45
+    ?>
46
+   </td>
47
+   <td><?PHP echo fn($row['finance_receipts']); ?></td>
48
+   <td><?PHP echo fn($row['finance_payments']); ?></td>
49
+   <td><?PHP echo fn($row['finance_balance'],true); ?></td>
50
+  </tr>
51
+<?PHP
52
+ }
53
+
54
+?>
55
+ </table>
56
+</div>

+ 39
- 0
pages/admin.invoices.php View File

@@ -0,0 +1,39 @@
1
+<?PHP
2
+
3
+ if (!defined('ADMIN') || !ADMIN) { die('Admins only!'); }
4
+
5
+?><div class="block" id="bills">
6
+ <h2>ADMIN: All bills</h2>
7
+ <table class="innerblock">
8
+  <tr>
9
+   <th>&nbsp;</th>
10
+   <th>User</th>
11
+   <th>Type</th>
12
+   <th>Amount</th>
13
+   <th>Due on</th> 
14
+   <th>Status</th>
15
+  </tr>
16
+<?PHP
17
+
18
+/* $sql = 'SELECT bill_id, bill_due, package_name, bill_amount, user_name, users.user_id, bill_paid FROM billing NATURAL JOIN users, packages WHERE packages.package_id = billing.package_id ORDER BY bill_due';
19
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
20
+ $status = array(2=>'Paid',1=>'DUE',0=>'Future');
21
+ $i = 1;
22
+ while ($row = mysql_fetch_array($res)) {
23
+  $i = 1 - $i;
24
+  ?>
25
+  <tr class="<?PHP echo ($i == 0) ? 'even' : 'odd'; ?>">
26
+   <td><?PHP echo $row['bill_id']; ?>.</td>
27
+   <td><a href="<?PHP echo CP_PATH.'checkuser/'.$row['user_id']; ?>"><?PHP echo $row['user_name']; ?></a></td>
28
+   <td><?PHP echo $row['package_name']; ?></td>
29
+   <td>&pound;<?PHP echo money_format('%i',$row['bill_amount']/100); ?></td>
30
+   <td><?PHP echo date('r',$row['bill_due']); ?></td>
31
+   <td>
32
+    <?PHP echo $status[($row['bill_paid'])]; ?>
33
+   </td>
34
+  </tr>
35
+  <?PHP
36
+ }*/
37
+?> 
38
+ </table>
39
+</div>

+ 56
- 0
pages/admin.ipbans.php View File

@@ -0,0 +1,56 @@
1
+<?PHP
2
+ require_once('lib/database.php');
3
+ require_once('lib/common.php'); 
4
+?>
5
+<div class="block" id="users">
6
+ <h2>ADMIN: IP Bans</h2>
7
+ <table class="innerblock">
8
+  <tr>
9
+   <th>&nbsp;</th>
10
+   <th>IP</th>
11
+   <th>Reason</th>
12
+   <th>Expires in</th>
13
+   <th>Actions</th>
14
+  </tr>
15
+<?PHP
16
+
17
+ $i = 0;
18
+ $n = 0; 
19
+ $sql = 'SELECT ipban_id, ipban_ip, ipban_expires, ipban_message FROM ipbans';
20
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
21
+
22
+ if (mysql_num_rows($res) == 0) {
23
+  echo '<tr><td colspan="5" style="text-align: center; font-style: italic;">';
24
+  echo 'No IP bans</td></tr>';
25
+ }
26
+ 
27
+ while ($row = mysql_fetch_array($res)) {
28
+  $n++;
29
+?>
30
+  <tr class="<?PHP echo ($i == 0) ? 'even' : 'odd'; ?>">
31
+   <td><?PHP echo $n; ?>.</td>
32
+   <td><?PHP echo h($row['ipban_ip']); ?></td>
33
+   <td><?PHP echo h($row['ipban_message']); ?></td>
34
+<?PHP
35
+ if ($row['ipban_expires'] < time()) { 
36
+  echo '<td style="color: red;">Expired</td><td>';
37
+ } else {
38
+  echo '<td>'.duration($row['ipban_expires'] - time()).'</td>'; 
39
+?>
40
+   <td>
41
+    <a href="?n=<?PHP echo $row['ipban_id']; ?>">
42
+     Remove
43
+    </a> or
44
+<?PHP
45
+ }
46
+?>
47
+    <a href="?d=<?PHP echo $row['ipban_id']; ?>">Delete</a>
48
+   </td>
49
+  </tr>
50
+<?PHP
51
+   $i = 1 - $i;
52
+ }
53
+
54
+?>    
55
+ </table>
56
+</div>

+ 29
- 0
pages/admin.menu.php View File

@@ -0,0 +1,29 @@
1
+<?PHP
2
+ require_once('lib/database.php');
3
+ require_once('lib/common.php');
4
+?>
5
+<div class="block" id="tickets">
6
+ <h2>ADMIN: Admin menu</h2>
7
+ <div class="innerblock doublelist">
8
+  <div style="float: left; width: 50%; padding: 0px;">
9
+   <ul>
10
+    <li><a href="<?PHP echo CP_PATH; ?>admintickets">Ticket management</a></li>
11
+    <li><a href="<?PHP echo CP_PATH; ?>admininvoices">Invoice management</a></li>
12
+    <li><a href="<?PHP echo CP_PATH; ?>adminbans">Ban management</a></li>
13
+    <li><a href="<?PHP echo CP_PATH; ?>admindiscounts">Discount management</a></li>
14
+    <li><a href="<?PHP echo CP_PATH; ?>adminfinances">Finances</a></li>
15
+    <li><a href="<?PHP echo CP_PATH; ?>adminlogs">Logs</a></li>
16
+   </ul>
17
+  </div>
18
+  <div style="margin-left: 50%;">
19
+   <ul>
20
+    <li><a href="<?PHP echo CP_PATH; ?>adminusers">User management</a></li>
21
+    <li><a href="<?PHP echo CP_PATH; ?>admindomains">Domain management</a></li>
22
+    <li><a href="<?PHP echo CP_PATH; ?>adminsites">Site management</a></li>
23
+    <li><a href="<?PHP echo CP_PATH; ?>adminannouncements">Announcements</a></li>
24
+    <li><a href="<?PHP echo CP_PATH; ?>adminreports">Reports</a></li>
25
+    <li><a href="<?PHP echo CP_PATH; ?>adminwiki">Wiki</a></li>
26
+   </ul>
27
+  </div>
28
+ </div>
29
+</div>

+ 59
- 0
pages/admin.sites.php View File

@@ -0,0 +1,59 @@
1
+<?PHP
2
+ if (!defined('LIB_DATABASE')) { require_once('lib/database.php'); }
3
+ if (!defined('LIB_COMMON')) { require_once('lib/common.php'); } 
4
+ if (!defined('ADMIN') || !ADMIN) { die('Admins only'); }
5
+?>
6
+<div class="block" id="sites">
7
+ <h2>ADMIN: All Sites</h2>
8
+ <table class="innerblock">
9
+  <tr>
10
+   <th>&nbsp;</th>
11
+   <th>Name</th>
12
+   <th>User</th>
13
+   <th>Settings</th>
14
+   <th>Stats</th>
15
+   <th>Bandwidth</th>
16
+   <th>Status</th>
17
+  </tr>
18
+<?PHP
19
+
20
+ $i = 0;
21
+ 
22
+ /*
23
+  /usr/local/apache/htdocs/bandquota - Bandwidth overing
24
+  /usr/local/apache/htdocs/bill      - Unpaid bill
25
+ */
26
+ 
27
+ $sql = 'SELECT site_id, site_name, site_bandin, site_bandout, site_docroot, site_curdocroot, user_name, sites.user_id FROM sites NATURAL JOIN users';
28
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
29
+ 
30
+ while ($row = mysql_fetch_array($res)) {
31
+?>
32
+  <tr class="<?PHP echo ($i == 0) ? 'even' : 'odd'; ?>">
33
+   <td><?PHP echo $row['site_id']; ?>.</td>
34
+   <td><?PHP echo $row['site_name']; ?></td>
35
+   <td><a href="<?PHP echo CP_PATH; ?>checkuser/<?PHP echo $row['user_id']; ?>"><?PHP echo $row['user_name']; ?></a></td>
36
+   <td><a href="<?PHP echo CP_PATH; ?>editsite/<?PHP echo $row['site_id']; ?>">Settings</a></td>
37
+   <td><a href="<?PHP echo CP_PATH; ?>sitestats/<?PHP echo $row['site_id']; ?>">Stats</a></td>
38
+   <td><?PHP echo NiceSize($row['site_bandin'] + $row['site_bandout']); ?></td>
39
+<?PHP
40
+
41
+ if (!is_dir($row['site_docroot'])) {
42
+   echo '<td class="err">Invalid docroot</td>';
43
+ } elseif ($row['site_docroot'] == '/usr/local/apache/htdocs/bandquota') {
44
+   echo '<td class="err">Disabled - bandwidth exceeded</td>';
45
+ } elseif ($row['site_docroot'] == '/usr/local/apache/htdocs/bill') {
46
+   echo '<td class="err">Disabled - unpaid bill</td>';
47
+ } else {
48
+   echo '<td>OK</td>';
49
+ }
50
+
51
+?>
52
+  </tr>
53
+<?PHP
54
+   $i = 1 - $i;
55
+ }
56
+
57
+?>    
58
+ </table>
59
+</div>

+ 58
- 0
pages/admin.tickets.php View File

@@ -0,0 +1,58 @@
1
+<?PHP
2
+ if (!defined('LIB_DATABASE')) { require_once('lib/database.php'); }
3
+ if (!defined('LIB_COMMON')) { require_once('lib/common.php'); } 
4
+ if (!defined('ADMIN') || !ADMIN) { die('Admins only!'); }
5
+?>
6
+<div class="block" id="tickets">
7
+ <h2>ADMIN: All tickets opened in the past month</h2>
8
+ <table class="innerblock">
9
+  <tr>
10
+   <th>&nbsp;</th>
11
+   <th>Title</th>
12
+   <th>User</th>
13
+   <th>View</th>
14
+   <th>Date</th>
15
+   <th>Replies</th>
16
+   <th>Status</th>
17
+  </tr>
18
+<?PHP
19
+
20
+ $i = 0;
21
+ 
22
+ $sql = 'SELECT ticket_id, ticket_status, ticket_title, ticket_time, user_name, tickets.user_id FROM tickets NATURAL JOIN users WHERE ticket_thread = ticket_id AND ticket_time > '.(time() - 60*60*24*31);
23
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
24
+
25
+ if (mysql_num_rows($res) == 0) {
26
+  echo '<tr><td colspan="7" style="font-style: italic; text-align: center;">No tickets opened recently</td></tr>';
27
+ }
28
+ 
29
+ while ($row = mysql_fetch_array($res)) {
30
+   $sql2 = 'SELECT COUNT(*) FROM tickets WHERE ticket_thread = '.$row['ticket_id'];
31
+   $res2 = mysql_query($sql2) or mf(__FILE__, __LINE__, $sql2);
32
+   $num = mysql_fetch_array($res2); $num = (int)$num[0] - 1;
33
+?>
34
+  <tr class="<?PHP echo ($i == 0) ? 'even' : 'odd'; ?>">
35
+   <td><?PHP echo $row['ticket_id']; ?>.</td>
36
+   <td><?PHP echo htmlspecialchars($row['ticket_title']); ?></td>
37
+   <td><a href="<?PHP echo CP_PATH.'checkuser/'.$row['user_id']; ?>">
38
+    <?PHP echo $row['user_name']; ?></a></td>
39
+   <td><a href="<?PHP echo CP_PATH; ?>viewticket/<?PHP echo $row['ticket_id']; ?>">View</a></td>
40
+   <td><?PHP echo substr(gmdate('r', $row['ticket_time']),0,-6); ?></td>
41
+   <td><?PHP echo $num; ?></td>
42
+<?PHP
43
+
44
+ if ($row['ticket_status'] == 'new' || $row['ticket_status'] == 'reopened') {
45
+   echo '<td class="err">'.ucfirst($row['ticket_status']).'</td>';
46
+ } else {
47
+   echo '<td>'.ucfirst($row['ticket_status']).'</td>';
48
+ }
49
+
50
+?>
51
+  </tr>
52
+<?PHP
53
+   $i = 1 - $i;
54
+ }
55
+
56
+?>    
57
+ </table>
58
+</div>

+ 37
- 0
pages/admin.userbans.php View File

@@ -0,0 +1,37 @@
1
+<?PHP
2
+ require_once('lib/database.php');
3
+ require_once('lib/common.php'); 
4
+?>
5
+<div class="block" id="users">
6
+ <h2>ADMIN: Username blocks</h2>
7
+ <table class="innerblock">
8
+  <tr>
9
+   <th>&nbsp;</th>
10
+   <th>Username</th>
11
+  </tr>
12
+<?PHP
13
+
14
+ $i = 0;
15
+ $n = 0; 
16
+ $sql = 'SELECT bu_id, bu_name FROM banneduser';
17
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
18
+
19
+ if (mysql_num_rows($res) == 0) {
20
+  echo '<tr><td colspan="2" style="text-align: center; font-style: italic;">';
21
+  echo 'No username blocks</td></tr>';
22
+ }
23
+ 
24
+ while ($row = mysql_fetch_array($res)) {
25
+  $n++;
26
+?>
27
+  <tr class="<?PHP echo ($i == 0) ? 'even' : 'odd'; ?>">
28
+   <td><?PHP echo $n; ?>.</td>
29
+   <td><?PHP echo h($row['bu_name']); ?></td>
30
+  </tr>
31
+<?PHP
32
+   $i = 1 - $i;
33
+ }
34
+
35
+?>    
36
+ </table>
37
+</div>

+ 53
- 0
pages/admin.users.php View File

@@ -0,0 +1,53 @@
1
+<?PHP
2
+ require_once('lib/database.php');
3
+ require_once('lib/common.php'); 
4
+?>
5
+<div class="block" id="users">
6
+ <h2>ADMIN: Users</h2>
7
+ <table class="innerblock">
8
+  <tr>
9
+   <th>&nbsp;</th>
10
+   <th>Name</th>
11
+   <th>E-Mail</th>
12
+   <th>Bandwidth</th>
13
+   <th>HDD</th>
14
+   <th>Actions</th>
15
+  </tr>
16
+<?PHP
17
+
18
+ $i = 0;
19
+ $n = 0;
20
+ 
21
+ $sql = 'SELECT user_id, user_name, user_email, band_used, band_total, hdd_used, hdd_total FROM users ORDER BY user_name';
22
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
23
+ 
24
+ while ($row = mysql_fetch_array($res)) {
25
+  $n++;
26
+?>
27
+  <tr class="<?PHP echo ($i == 0) ? 'even' : 'odd'; ?>">
28
+   <td><?PHP echo $n; ?>.</td>
29
+   <td><?PHP echo h($row['user_name']); ?></td>
30
+   <td><?PHP echo h($row['user_email']); ?></td>
31
+   <td><?PHP
32
+ $p = round(100 * $row['band_used'] / $row['band_total'],0);
33
+ echo '<img src="'.CP_PATH.'res/bandout.png" style="width: '.$p.'px; height: 10px;" alt="Used" title="'.$p.'% used">';
34
+ echo '<img src="'.CP_PATH.'res/bandfree.png" style="width: '.(100-$p).'px; height: 10px;" alt="Free" title="'.(100-$p).'% free">';
35
+?></td>
36
+   <td><?PHP
37
+ $p = round(100 * $row['hdd_used'] / $row['hdd_total'],0);
38
+ echo '<img src="'.CP_PATH.'res/bandout.png" style="width: '.$p.'px; height: 10px;" alt="Used" title="'.$p.'% used">';
39
+ echo '<img src="'.CP_PATH.'res/bandfree.png" style="width: '.(100-$p).'px; height: 10px;" alt="Free" title="'.(100-$p).'% free">';
40
+?></td>
41
+  <td>
42
+   <a href="<?PHP echo CP_PATH.'checkuser/'.$row['user_id']; ?>">Check</a>
43
+   |
44
+   <a href="<?PHP echo CP_PATH.'spoofuser/'.$row['user_id']; ?>">Spoof</a>
45
+  </td>
46
+  </tr>
47
+<?PHP
48
+   $i = 1 - $i;
49
+ }
50
+
51
+?>    
52
+ </table>
53
+</div>

+ 31
- 0
pages/adminaddipban.php View File

@@ -0,0 +1,31 @@
1
+<?PHP if (!defined('ADMIN') || !ADMIN) { die('Admins only'); } ?>
2
+<form action="<?PHP echo CP_PATH; ?>bans" method="post">
3
+<div class="block">
4
+ <h2>Add IP ban</h2>
5
+ <div class="innerblock">
6
+  <p class="blurb">
7
+   IP Addresses are strictly matched (i.e., no ranges are allowed).
8
+   The reason specified is exposed to the banned user, so keep it civil.
9
+   Expirary time should be formatted as specified <a href="http://www.gnu.org/software/tar/manual/html_node/tar_109.html">here</a>. Most commonly you'll just
10
+   want '+1 day' or so.
11
+  </p>
12
+  <table class="form leftpad">
13
+   <tr>
14
+    <th><label for="ip">IP Address</label></th>
15
+    <td><input type="text" name="ip" class="inflat"></td>
16
+   </tr>
17
+   <tr>
18
+    <th><label for="reason">Reason</label></th>
19
+    <td><input type="text" name="reason" class="inflat"></td>
20
+   </tr>
21
+   <tr>
22
+    <th><label for="expirary">Expirary</label></th>
23
+    <td><input type="text" name="expirary" class="inflat"></td>
24
+   </tr>
25
+   <tr><td colspan="2" style="text-align: right;">
26
+    <input type="submit" value="Add">
27
+   </td></tr>
28
+  </table>
29
+ </div>
30
+</div>
31
+</form>

+ 54
- 0
pages/adminbills.php View File

@@ -0,0 +1,54 @@
1
+<?PHP
2
+
3
+ if (!defined('ADMIN') || !ADMIN) { die('Admins only!'); }
4
+
5
+?><div class="block" id="bills">
6
+ <h2>ADMIN: All bills</h2>
7
+<!--
8
+<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
9
+<input type="hidden" name="cmd" value="_xclick">
10
+<input type="hidden" name="business" value="chris87@gmail.com">
11
+<input type="hidden" name="item_name" value="UTD-Hosting one year slot">
12
+<input type="hidden" name="item_number" value="UID">
13
+<input type="hidden" name="amount" value="35.00">
14
+<input type="hidden" name="no_shipping" value="1">
15
+<input type="hidden" name="no_note" value="1">
16
+<input type="hidden" name="currency_code" value="GBP">
17
+<input type="hidden" name="bn" value="PP-BuyNowBF">
18
+<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but02.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
19
+</form>
20
+https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=chris87%40gmail%2ecom&item_name=UTD%2dHosting%20one%20year%20slot&item_number=UID&amount=35%2e00&no_shipping=1&no_note=1&currency_code=GBP&bn=PP%2dBuyNowBF&charset=UTF%2d8
21
+-->
22
+ <table class="innerblock">
23
+  <tr>
24
+   <th>&nbsp;</th>
25
+   <th>User</th>
26
+   <th>Type</th>
27
+   <th>Amount</th>
28
+   <th>Due on</th> 
29
+   <th>Status</th>
30
+  </tr>
31
+<?PHP
32
+
33
+ $sql = 'SELECT bill_id, bill_due, package_name, bill_amount, user_name, users.user_id, bill_paid FROM billing NATURAL JOIN users, packages WHERE packages.package_id = billing.package_id ORDER BY bill_due';
34
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
35
+ $status = array(2=>'Paid',1=>'DUE',0=>'Future');
36
+ $i = 1;
37
+ while ($row = mysql_fetch_array($res)) {
38
+  $i = 1 - $i;
39
+  ?>
40
+  <tr class="<?PHP echo ($i == 0) ? 'even' : 'odd'; ?>">
41
+   <td><?PHP echo $row['bill_id']; ?>.</td>
42
+   <td><a href="<?PHP echo CP_PATH.'checkuser/'.$row['user_id']; ?>"><?PHP echo $row['user_name']; ?></a></td>
43
+   <td><?PHP echo $row['package_name']; ?></td>
44
+   <td>&pound;<?PHP echo money_format('%i',$row['bill_amount']/100); ?></td>
45
+   <td><?PHP echo date('r',$row['bill_due']); ?></td>
46
+   <td>
47
+    <?PHP echo $status[($row['bill_paid'])]; ?>
48
+   </td>
49
+  </tr>
50
+  <?PHP
51
+ }
52
+?> 
53
+ </table>
54
+</div>

+ 34
- 0
pages/adminbw.php View File

@@ -0,0 +1,34 @@
1
+<?PHP
2
+
3
+ if (!defined('ADMIN') || !ADMIN) { die('Admins only!'); }
4
+
5
+?><div class="block" id="bills">
6
+ <h2>ADMIN: Live bandwidth</h2>
7
+ <table class="innerblock">
8
+  <tr>
9
+   <th>&nbsp;</th>
10
+   <th>User</th>
11
+   <th>In</th>
12
+   <th>Out</th>
13
+   <th>Total</th> 
14
+  </tr>
15
+<?PHP
16
+
17
+ $sql = 'SELECT * FROM iptdata ORDER BY ipt_user';
18
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
19
+ $i = 1;
20
+ while ($row = mysql_fetch_array($res)) {
21
+  $i = 1 - $i;
22
+  ?>
23
+  <tr class="<?PHP echo ($i == 0) ? 'even' : 'odd'; ?>">
24
+   <td><?PHP echo $row['ipt_id']; ?>.</td>
25
+   <td><?PHP echo $row['ipt_user']; ?></td>
26
+   <td><?PHP echo NiceSize($row['ipt_in']); ?></td>
27
+   <td><?PHP echo NiceSize($row['ipt_out']); ?></td>
28
+   <td><?PHP echo NiceSize($row['ipt_in']+$row['ipt_out']); ?></td>
29
+  </tr>
30
+  <?PHP
31
+ }
32
+?> 
33
+ </table>
34
+</div>

+ 47
- 0
pages/adminculog.php View File

@@ -0,0 +1,47 @@
1
+<?PHP
2
+ if (!defined('LIB_DATABASE')) { require_once('lib/database.php'); }
3
+ if (!defined('LIB_COMMON')) { require_once('lib/common.php'); }
4
+ if (!defined('ADMIN') || !ADMIN) { die('Admins only'); }
5
+?>
6
+<div class="block" id="log">
7
+ <h2>ADMIN: Control panel log</h2>
8
+ <table class="innerblock">
9
+  <tr>
10
+   <th>Time</th>
11
+   <th>Level</th>
12
+   <th>Message</th>
13
+  </tr>
14
+<?PHP
15
+
16
+ $i = 0;
17
+
18
+ $sql  = 'SELECT user_id, user_name, log_level, log_time, log_message FROM log ';
19
+ $sql .= 'NATURAL JOIN users WHERE user_id = '.m($_GET['n']).' ORDER BY log_time DESC LIMIT 0,50';
20
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
21
+ while ($row = mysql_fetch_array($res)) {
22
+  echo '<tr class="'.(($i != 0) ? 'odd':'even').'"><td>'.substr(gmdate('r',$row['log_time']),0,-6).'</td>';
23
+
24
+   switch($row['log_level']) {
25
+  case 'critical':
26
+   echo '<td style="color: red; font-weight: bold;">Critical</td>';
27
+   break;
28
+  case 'important':
29
+   echo '<td style="font-weight: bold;">Important</td>';
30
+   break;
31
+  case 'normal':
32
+  case 'unknown':
33
+   echo '<td>'.ucfirst($row['log_level']).'</td>';
34
+   break;
35
+  case 'info':
36
+   echo '<td style="color: gray">Information</td>';
37
+ }
38
+
39
+  echo '<td>'. $row['log_message'].'</td></tr>';
40
+
41
+  $i = 1 - $i;
42
+ }
43
+
44
+?>
45
+ </table>
46
+</div>
47
+

+ 29
- 0
pages/admindiscounts.php View File

@@ -0,0 +1,29 @@
1
+<?PHP
2
+ if (!defined('LIB_DATABASE')) { require_once('lib/database.php'); }
3
+ if (!defined('LIB_COMMON')) { require_once('lib/common.php'); } 
4
+ if (!defined('ADMIN') || !ADMIN) { die('Admins only'); }
5
+?>
6
+<div class="block" id="log">
7
+ <h2>ADMIN: Control panel log</h2>
8
+ <table class="innerblock">
9
+  <tr>
10
+   <th>Time</th>
11
+   <th>User</th>
12
+   <th>Message</th>
13
+  </tr>
14
+<?PHP
15
+
16
+ $i = 0;
17
+
18
+ $sql = 'SELECT u.user_name, l.* FROM log AS l, users AS u WHERE u.user_id = l.user_id ORDER BY l.log_time DESC LIMIT 0,20';
19
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
20
+ while ($row = mysql_fetch_array($res)) {
21
+  echo '<tr class="'.(($i != 0) ? 'odd':'even').'"><td>'.gmdate('r',$row['log_time']).'</td><td><a href="'.CP_PATH.'checkuser/'.$row['user_id'].'">';
22
+  echo $row['user_name'].'</a></td><td>'. $row['log_message'].'</td></tr>';
23
+
24
+  $i = 1 - $i;
25
+ }
26
+
27
+?>    
28
+ </table>
29
+</div>

+ 54
- 0
pages/admindomains.php View File

@@ -0,0 +1,54 @@
1
+<?PHP
2
+
3
+ if (!defined('ADMIN') || !ADMIN) { die('Admins only'); }
4
+
5
+?>
6
+<div class="block" id="domains">
7
+<h2>ADMIN: All domains</h2>
8
+<table class="innerblock">
9
+  <tr><th>&nbsp;</th><th>Domain</th><th>User</th><th>Site</th>
10
+  <th>DNS</th>
11
+  <th>Enabled?</td></tr>
12
+<?PHP
13
+
14
+ $sql = 'SELECT domain_id, domain_name, domain_enabled, domains.user_id, user_name FROM domains NATURAL JOIN users ORDER BY user_name, domain_name';
15
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
16
+
17
+ $i = 0;
18
+
19
+ while ($row = mysql_fetch_array($res)) {
20
+  $sql2 = 'SELECT r.record_value, s.site_name, s.site_id FROM records AS r, sites AS s WHERE r.domain_id = '.$row['domain_id'].' AND r.record_type = \'UTD\' AND s.site_id = r.record_value';
21
+  $res2 = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
22
+  if (mysql_num_rows($res2) > 0) {
23
+   $row2 = mysql_fetch_array($res2);
24
+   $asite = $row2['site_name'];
25
+   $asiteid = $row2['site_id'];
26
+  } else {
27
+   $asite = '';
28
+  }
29
+
30
+?>
31
+   <tr class="<?PHP echo ($i == 0) ? 'even' : 'odd'; ?>">
32
+    <td><?PHP echo h($row['domain_id']); ?></td>
33
+    <td><?PHP echo h($row['domain_name']); ?></td>
34
+    <td><a href="<?PHP echo CP_PATH.'checkuser/'.$row['user_id']; ?>"><?PHP echo h($row['user_name']); ?></a></td>
35
+    <td><?PHP if ($asite != '') { ?>
36
+     <a href="<?PHP echo CP_PATH; ?>editsite/<?PHP echo $asiteid; ?>"><?PHP echo h($asite); ?></a>
37
+     </td>
38
+     <?PHP } else { ?>None</td><?PHP } ?><td>
39
+<?PHP if (gethostbyname($row['domain_name']) != '63.246.141.80') { ?>
40
+      <a href="<?PHP echo CP_PATH; ?>support/017" style="color: red;">Error</a>
41
+<?PHP } else { echo 'OK'; } ?>
42
+     </td><td>
43
+     <?PHP if ($row['domain_enabled'] != '1') { ?>
44
+     <a href="<?PHP echo CP_PATH; ?>enabledomain/<?PHP echo $row['domain_id']; ?>">Enable</a>
45
+     <?PHP } else { echo 'Enabled'; } ?>
46
+    </td>
47
+   </tr>
48
+<?PHP
49
+  $i = 1 - $i;
50
+ }
51
+?>
52
+  </table>
53
+</div>
54
+</div>

+ 55
- 0
pages/adminipbans.php View File

@@ -0,0 +1,55 @@
1
+<?PHP
2
+ if (!defined('LIB_DATABASE')) { require_once('lib/database.php'); }
3
+ if (!defined('LIB_COMMON')) { require_once('lib/common.php'); } 
4
+ if (!defined('ADMIN') || !ADMIN) { die('Admins only'); }
5
+?>
6
+<div class="block" id="users">
7
+ <h2>ADMIN: IP Bans</h2>
8
+ <table class="innerblock">
9
+  <tr>
10
+   <th>&nbsp;</th>
11
+   <th>IP</th>
12
+   <th>Reason</th>
13
+   <th>Expires in</th>
14
+   <th>Actions</th>
15
+  </tr>
16
+<?PHP
17
+
18
+ $i = 0;
19
+ 
20
+ $sql = 'SELECT ipban_id, ipban_ip, ipban_expires, ipban_message FROM ipbans';
21
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
22
+
23
+ if (mysql_num_rows($res) == 0) {
24
+  echo '<tr><td colspan="5" style="text-align: center; font-style: italic;">';
25
+  echo 'No IP bans</td></tr>';
26
+ }
27
+ 
28
+ while ($row = mysql_fetch_array($res)) {
29
+?>
30
+  <tr class="<?PHP echo ($i == 0) ? 'even' : 'odd'; ?>">
31
+   <td><?PHP echo $row['ipban_id']; ?>.</td>
32
+   <td><?PHP echo h($row['ipban_ip']); ?></td>
33
+   <td><?PHP echo h($row['ipban_message']); ?></td>
34
+<?PHP
35
+ if ($row['ipban_expires'] < time()) { 
36
+  echo '<td style="color: red;">Expired</td><td>-</td>';
37
+ } else {
38
+  echo '<td>'.duration($row['ipban_expires'] - time()).'</td>'; 
39
+?>
40
+   <td>
41
+    <a href="<?PHP echo CP_PATH; ?>bans/<?PHP echo $row['ipban_id']; ?>">
42
+     Remove
43
+    </a>
44
+   </td>
45
+<?PHP
46
+ }
47
+?>
48
+  </tr>
49
+<?PHP
50
+   $i = 1 - $i;
51
+ }
52
+
53
+?>    
54
+ </table>
55
+</div>

+ 48
- 0
pages/adminlog.php View File

@@ -0,0 +1,48 @@
1
+<?PHP
2
+ if (!defined('LIB_DATABASE')) { require_once('lib/database.php'); }
3
+ if (!defined('LIB_COMMON')) { require_once('lib/common.php'); }
4
+ if (!defined('ADMIN') || !ADMIN) { die('Admins only'); }
5
+?>
6
+<div class="block" id="log">
7
+ <h2>ADMIN: Control panel log</h2>
8
+ <table class="innerblock">
9
+  <tr>
10
+   <th>Time</th>
11
+   <th>User</th>
12
+   <th>Level</th>
13
+   <th>Message</th>
14
+  </tr>
15
+<?PHP
16
+
17
+ $i = 0;
18
+
19
+ $sql  = 'SELECT user_id, user_name, log_level, log_time, log_message FROM log ';
20
+ $sql .= 'NATURAL JOIN users ORDER BY log_time DESC LIMIT 0,25';
21
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
22
+ while ($row = mysql_fetch_array($res)) {
23
+  echo '<tr class="'.(($i != 0) ? 'odd':'even').'"><td>'.gmdate('r',$row['log_time']).'</td><td><a href="'.CP_PATH.'checkuser/'.$row['user_id'].'">';
24
+  echo $row['user_name'].'</a></td>';
25
+  
26
+   switch($row['log_level']) {
27
+  case 'critical':
28
+   echo '<td style="color: red; font-weight: bold;">Critical</td>';
29
+   break;
30
+  case 'important':
31
+   echo '<td style="font-weight: bold;">Important</td>';
32
+   break;
33
+  case 'normal':
34
+  case 'unknown':
35
+   echo '<td>'.ucfirst($row['log_level']).'</td>';
36
+   break;
37
+  case 'info':
38
+   echo '<td style="color: gray">Information</td>';
39
+ }
40
+  
41
+  echo '<td>'. $row['log_message'].'</td></tr>';
42
+
43
+  $i = 1 - $i;
44
+ }
45
+
46
+?>
47
+ </table>
48
+</div>

+ 59
- 0
pages/adminsites.php View File

@@ -0,0 +1,59 @@
1
+<?PHP
2
+ if (!defined('LIB_DATABASE')) { require_once('lib/database.php'); }
3
+ if (!defined('LIB_COMMON')) { require_once('lib/common.php'); } 
4
+ if (!defined('ADMIN') || !ADMIN) { die('Admins only'); }
5
+?>
6
+<div class="block" id="sites">
7
+ <h2>ADMIN: All Sites</h2>
8
+ <table class="innerblock">
9
+  <tr>
10
+   <th>&nbsp;</th>
11
+   <th>Name</th>
12
+   <th>User</th>
13
+   <th>Settings</th>
14
+   <th>Stats</th>
15
+   <th>Bandwidth</th>
16
+   <th>Status</th>
17
+  </tr>
18
+<?PHP
19
+
20
+ $i = 0;
21
+ 
22
+ /*
23
+  /usr/local/apache/htdocs/bandquota - Bandwidth overing
24
+  /usr/local/apache/htdocs/bill      - Unpaid bill
25
+ */
26
+ 
27
+ $sql = 'SELECT site_id, site_name, site_bandin, site_bandout, site_docroot, site_curdocroot, user_name, sites.user_id FROM sites NATURAL JOIN users';
28
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
29
+ 
30
+ while ($row = mysql_fetch_array($res)) {
31
+?>
32
+  <tr class="<?PHP echo ($i == 0) ? 'even' : 'odd'; ?>">
33
+   <td><?PHP echo $row['site_id']; ?>.</td>
34
+   <td><?PHP echo $row['site_name']; ?></td>
35
+   <td><a href="<?PHP echo CP_PATH; ?>checkuser/<?PHP echo $row['user_id']; ?>"><?PHP echo $row['user_name']; ?></a></td>
36
+   <td><a href="<?PHP echo CP_PATH; ?>editsite/<?PHP echo $row['site_id']; ?>">Settings</a></td>
37
+   <td><a href="<?PHP echo CP_PATH; ?>sitestats/<?PHP echo $row['site_id']; ?>">Stats</a></td>
38
+   <td><?PHP echo NiceSize($row['site_bandin'] + $row['site_bandout']); ?></td>
39
+<?PHP
40
+
41
+ if (!is_dir($row['site_docroot'])) {
42
+   echo '<td class="err">Invalid docroot</td>';
43
+ } elseif ($row['site_docroot'] == '/usr/local/apache/htdocs/bandquota') {
44
+   echo '<td class="err">Disabled - bandwidth exceeded</td>';
45
+ } elseif ($row['site_docroot'] == '/usr/local/apache/htdocs/bill') {
46
+   echo '<td class="err">Disabled - unpaid bill</td>';
47
+ } else {
48
+   echo '<td>OK</td>';
49
+ }
50
+
51
+?>
52
+  </tr>
53
+<?PHP
54
+   $i = 1 - $i;
55
+ }
56
+
57
+?>    
58
+ </table>
59
+</div>

+ 58
- 0
pages/admintickets.php View File

@@ -0,0 +1,58 @@
1
+<?PHP
2
+ if (!defined('LIB_DATABASE')) { require_once('lib/database.php'); }
3
+ if (!defined('LIB_COMMON')) { require_once('lib/common.php'); } 
4
+ if (!defined('ADMIN') || !ADMIN) { die('Admins only!'); }
5
+?>
6
+<div class="block" id="tickets">
7
+ <h2>ADMIN: All tickets opened in the past month</h2>
8
+ <table class="innerblock">
9
+  <tr>
10
+   <th>&nbsp;</th>
11
+   <th>Title</th>
12
+   <th>User</th>
13
+   <th>View</th>
14
+   <th>Date</th>
15
+   <th>Replies</th>
16
+   <th>Status</th>
17
+  </tr>
18
+<?PHP
19
+
20
+ $i = 0;
21
+ 
22
+ $sql = 'SELECT ticket_id, ticket_status, ticket_title, ticket_time, user_name, tickets.user_id FROM tickets NATURAL JOIN users WHERE ticket_thread = ticket_id AND ticket_time > '.(time() - 60*60*24*31);
23
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
24
+
25
+ if (mysql_num_rows($res) == 0) {
26
+  echo '<tr><td colspan="7" style="font-style: italic; text-align: center;">No tickets opened recently</td></tr>';
27
+ }
28
+ 
29
+ while ($row = mysql_fetch_array($res)) {
30
+   $sql2 = 'SELECT COUNT(*) FROM tickets WHERE ticket_thread = '.$row['ticket_id'];
31
+   $res2 = mysql_query($sql2) or mf(__FILE__, __LINE__, $sql2);
32
+   $num = mysql_fetch_array($res2); $num = (int)$num[0] - 1;
33
+?>
34
+  <tr class="<?PHP echo ($i == 0) ? 'even' : 'odd'; ?>">
35
+   <td><?PHP echo $row['ticket_id']; ?>.</td>
36
+   <td><?PHP echo htmlspecialchars($row['ticket_title']); ?></td>
37
+   <td><a href="<?PHP echo CP_PATH.'checkuser/'.$row['user_id']; ?>">
38
+    <?PHP echo $row['user_name']; ?></a></td>
39
+   <td><a href="<?PHP echo CP_PATH; ?>viewticket/<?PHP echo $row['ticket_id']; ?>">View</a></td>
40
+   <td><?PHP echo substr(gmdate('r', $row['ticket_time']),0,-6); ?></td>
41
+   <td><?PHP echo $num; ?></td>
42
+<?PHP
43
+
44
+ if ($row['ticket_status'] == 'new' || $row['ticket_status'] == 'reopened') {
45
+   echo '<td class="err">'.ucfirst($row['ticket_status']).'</td>';
46
+ } else {
47
+   echo '<td>'.ucfirst($row['ticket_status']).'</td>';
48
+ }
49
+
50
+?>
51
+  </tr>
52
+<?PHP
53
+   $i = 1 - $i;
54
+ }
55
+
56
+?>    
57
+ </table>
58
+</div>

+ 51
- 0
pages/adminusers.php View File

@@ -0,0 +1,51 @@
1
+<?PHP
2
+ if (!defined('LIB_DATABASE')) { require_once('lib/database.php'); }
3
+ if (!defined('LIB_COMMON')) { require_once('lib/common.php'); } 
4
+ if (!defined('ADMIN') || !ADMIN) { die('Admins only'); }
5
+?>
6
+<div class="block" id="users">
7
+ <h2>ADMIN: Users</h2>
8
+ <table class="innerblock">
9
+  <tr>
10
+   <th>&nbsp;</th>
11
+   <th>Name</th>
12
+   <th>E-Mail</th>
13
+   <th>Bandwidth</th>
14
+   <th>HDD</th>
15
+   <th>Actions</th>
16
+  </tr>
17
+<?PHP
18
+
19
+ $i = 0;
20
+ 
21
+ $sql = 'SELECT user_id, user_name, user_email, band_used, band_total, hdd_used, hdd_total FROM users';
22
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
23
+ 
24
+ while ($row = mysql_fetch_array($res)) {
25
+?>
26
+  <tr class="<?PHP echo ($i == 0) ? 'even' : 'odd'; ?>">
27
+   <td><?PHP echo $row['user_id']; ?>.</td>
28
+   <td><?PHP echo h($row['user_name']); ?></td>
29
+   <td><?PHP echo h($row['user_email']); ?></td>
30
+   <td><?PHP
31
+ $p = round(100 * $row['band_used'] / $row['band_total'],0);
32
+ echo '<img src="'.CP_PATH.'res/bandout.png" style="width: '.$p.'px; height: 10px;" alt="Used" title="'.$p.'% used">';
33
+ echo '<img src="'.CP_PATH.'res/bandfree.png" style="width: '.(100-$p).'px; height: 10px;" alt="Free" title="'.(100-$p).'% free">';
34
+?></td>
35
+   <td><?PHP
36
+ $p = round(100 * $row['hdd_used'] / $row['hdd_total'],0);
37
+ echo '<img src="'.CP_PATH.'res/bandout.png" style="width: '.$p.'px; height: 10px;" alt="Used" title="'.$p.'% used">';
38
+ echo '<img src="'.CP_PATH.'res/bandfree.png" style="width: '.(100-$p).'px; height: 10px;" alt="Free" title="'.(100-$p).'% free">';
39
+?></td>
40
+  <td>
41
+   <a href="<?PHP echo CP_PATH.'checkuser/'.$row['user_id']; ?>">Check</a>
42
+   <a href="<?PHP echo CP_PATH.'spoofuser/'.$row['user_id']; ?>">Spoof</a>
43
+  </td>
44
+  </tr>
45
+<?PHP
46
+   $i = 1 - $i;
47
+ }
48
+
49
+?>    
50
+ </table>
51
+</div>

+ 56
- 0
pages/alltickets.php View File

@@ -0,0 +1,56 @@
1
+<?PHP
2
+ if (!defined('LIB_DATABASE')) { require_once('lib/database.php'); }
3
+ if (!defined('LIB_COMMON')) { require_once('lib/common.php'); } 
4
+?>
5
+<div class="block">
6
+ <h2>My tickets</h2>
7
+ <table class="innerblock">
8
+  <tr>
9
+   <th>&nbsp;</th>
10
+   <th>Title</th>
11
+   <th>View</th>
12
+   <th>Date</th>
13
+   <th>Replies</th>
14
+   <th>Status</th>
15
+  </tr>
16
+<?PHP
17
+
18
+ $i = 0;
19
+ $n = 0;
20
+ 
21
+ $sql = 'SELECT ticket_id, ticket_status, ticket_title, ticket_time FROM tickets WHERE ticket_thread = ticket_id AND user_id = '.UID;
22
+ $res = mq($sql, __FILE__, __LINE__);
23
+
24
+ if (mysql_num_rows($res) == 0) {
25
+  echo '<tr><td colspan="6" style="font-style: italic; text-align: center;">No tickets opened recently</td></tr>';
26
+ }
27
+ 
28
+ while ($row = mysql_fetch_array($res)) {
29
+   $n ++;
30
+   $sql2 = 'SELECT COUNT(*) FROM tickets WHERE ticket_thread = '.$row['ticket_id'];
31
+   $res2 = mq($sql2, __FILE__, __LINE__);
32
+   $num = mysql_fetch_array($res2); $num = (int)$num[0] - 1;
33
+?>
34
+  <tr class="<?PHP echo ($i == 0) ? 'even' : 'odd'; ?>">
35
+   <td><?PHP echo $n; ?>.</td>
36
+   <td><?PHP echo htmlspecialchars($row['ticket_title']); ?></td>
37
+   <td><a href="<?PHP echo CP_PATH; ?>viewticket/<?PHP echo $row['ticket_id']; ?>">View</a></td>
38
+   <td><?PHP echo substr(gmdate('r', $row['ticket_time']),0,-6); ?></td>
39
+   <td><?PHP echo $num; ?></td>
40
+<?PHP
41
+
42
+ if ($row['ticket_status'] == 'new' || $row['ticket_status'] == 'reopened') {
43
+   echo '<td class="err">'.ucfirst($row['ticket_status']).'</td>';
44
+ } else {
45
+   echo '<td>'.ucfirst($row['ticket_status']).'</td>';
46
+ }
47
+
48
+?>
49
+  </tr>
50
+<?PHP
51
+   $i = 1 - $i;
52
+ }
53
+
54
+?>    
55
+ </table>
56
+</div>

+ 48
- 0
pages/announcements.php View File

@@ -0,0 +1,48 @@
1
+<?PHP
2
+ require_once('lib/profiler.php');
3
+ require_once('lib/database.php');
4
+ require_once('lib/common.php');
5
+?>
6
+<div class="block">
7
+ <h2>Announcements and messages</h2>
8
+ <table class="innerblock">
9
+  <tr>
10
+   <th>&nbsp;</th>
11
+   <th>Title</th>
12
+   <th>View</th>
13
+   <th>Type</th>
14
+   <th>Date</th>
15
+  </tr>
16
+<?PHP
17
+
18
+ $sql = 'SELECT message_id, message_type, message_title, message_time FROM messages WHERE message_time > ' . strtotime('-6 months');
19
+ if (!defined('ADMIN')) { $sql .= ' AND message_type <> \'admin\''; }
20
+ $sql .= ' ORDER BY message_time LIMIT 0,5';
21
+ 
22
+ $res = mq($sql) or mf(__FILE__, __LINE__, $sql);
23
+ 
24
+ $i = 0;
25
+ $n = 0;
26
+
27
+ if (mysql_num_rows($res) == 0) {
28
+  echo '<tr><td colspan="5" style="font-style: italic; text-align: center;">';
29
+  echo 'There are no current announcements</td></tr>';
30
+ }
31
+  
32
+ while ($row = mysql_fetch_array($res)) {
33
+  $n++;
34
+?>
35
+  <tr<?PHP if ($i == 1) { echo ' class="odd"'; } ?>>
36
+   <td><?PHP echo $n; ?>.</td>
37
+   <td><?PHP echo $row['message_title']; ?></td>
38
+   <td><a href="<?PHP echo CP_PATH; ?>viewmessage/<?PHP echo $row['message_id']; ?>">View</a></td>
39
+   <td><?PHP echo ucfirst($row['message_type']); ?></td>
40
+   <td><?PHP echo substr(gmdate('r', $row['message_time']),0,-6); ?></td>
41
+  </tr>
42
+ <?PHP
43
+  $i = 1 - $i;
44
+ }
45
+
46
+?>  
47
+ </table>
48
+</div>

+ 6
- 0
pages/bandwidthgraph.php View File

@@ -0,0 +1,6 @@
1
+<div class="block">
2
+ <h2>Bandwidth usage graph</h2>
3
+ <div class="innerblock" style="text-align: center;">
4
+  <img src="<?PHP echo CP_PATH; ?>res/bandwidth.php" alt="Bandwidth graph">
5
+ </div>
6
+</div>

+ 33
- 0
pages/bandwidthtable.php View File

@@ -0,0 +1,33 @@
1
+<div class="block">
2
+ <h2>Bandwidth usage</h2>
3
+ <table class="innerblock">
4
+  <tr>
5
+   <th>&nbsp;</th>
6
+   <th>Site</th>
7
+   <th>Bandwidth in</th>
8
+   <th>Bandwidth out</th>
9
+   <th>Bandwidth total</th>
10
+  </tr>
11
+<?PHP
12
+
13
+ $sql = 'SELECT site_id, site_name, site_bandin, site_bandout FROM sites WHERE user_id = '.UID.' ORDER BY (site_bandin + site_bandout) DESC';
14
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
15
+ $i = 0;
16
+ $n = 0;
17
+ while ($row = mysql_fetch_array($res)) {
18
+  $n++;
19
+
20
+  echo '<tr class="';
21
+  if ($i) { echo 'odd'; } else { echo 'even'; }
22
+  echo '"><td>'.$n.'.</td>';
23
+  echo '<td>'.$row['site_name'].'</td>';
24
+  echo '<td>'.NiceSize($row['site_bandin']).'</td>';
25
+  echo '<td>'.NiceSize($row['site_bandout']).'</td>';
26
+  echo '<td>'.NiceSize($row['site_bandin'] + $row['site_bandout']).'</td>';
27
+  echo '</tr>';
28
+  $i = 1 - $i;
29
+ }
30
+
31
+?>
32
+ </table>
33
+</div>

+ 37
- 0
pages/billing.php View File

@@ -0,0 +1,37 @@
1
+<div class="block">
2
+ <h2>Invoices</h2>
3
+ <table class="innerblock">
4
+  <tr>
5
+   <th>&nbsp;</th>
6
+   <th>Date issued</th>
7
+   <th>Date due</th>
8
+   <th>Value</th> 
9
+   <th>Paid</th>
10
+   <th>Actions</th>
11
+  </tr>
12
+<?PHP
13
+
14
+ $sql = 'SELECT bill_id, bill_due, bill_generated, bill_total, bill_paid FROM bills WHERE user_id = '.UID.' ORDER BY bill_due';
15
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
16
+ $i = 0;
17
+ if (mysql_num_rows($res) == 0) {
18
+  echo '<tr><td style="font-style: italic; text-align: center;" colspan="6">There are no invoices on record for your account</td></tr>';
19
+ }
20
+ while ($row = mysql_fetch_array($res)) {
21
+  $i++;
22
+  ?>
23
+  <tr class="<?PHP echo ($i % 2 == 1) ? 'even' : 'odd'; ?>">
24
+   <td><?PHP echo $i; ?>.</td>
25
+   <td><?PHP echo date('r',$row['bill_generated']); ?></td>
26
+   <td><?PHP echo date('r',$row['bill_due']); ?></td>
27
+   <td>&pound;<?PHP echo money_format('%i',$row['bill_total']/100); ?></td>
28
+   <td><?PHP echo ($row['bill_paid'] == 0) ? 'Outstanding' : 'Paid'; ?></td>
29
+   <td>
30
+    <a href="<?PHP echo CP_PATH; ?>viewinvoice/<?PHP echo $row['bill_id']; ?>">View</a>
31
+   </td>
32
+  </tr>
33
+  <?PHP
34
+ }
35
+?> 
36
+ </table>
37
+</div>

+ 61
- 0
pages/dbdbs.php View File

@@ -0,0 +1,61 @@
1
+<?PHP
2
+ require_once('lib/database.php'); 
3
+ require_once('lib/common.php'); 
4
+?>
5
+<div class="block">
6
+ <h2>MySQL databases</h2>
7
+<form action="<?PHP echo CP_PATH; ?>database" method="post">
8
+ <table class="innerblock bottomdiv">
9
+  <tr>
10
+   <th>&nbsp;</th>
11
+   <th>Name</th>
12
+   <th></th>
13
+  </tr>
14
+<?PHP
15
+
16
+ $i = 0;
17
+ 
18
+ $sql = 'SELECT db_id, db_name FROM db_dbs WHERE user_id = '.UID;
19
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
20
+ 
21
+ while ($row = mysql_fetch_array($res)) {
22
+?>
23
+  <tr class="<?PHP echo ($i == 0) ? 'even' : 'odd'; ?>">
24
+   <td><input type="checkbox" name="db<?PHP echo $row['db_id']; ?>" id="db<?PHP echo $row['db_id']; ?>"<?PHP if (isset($_POST['delete'])) { if(isset($_POST['db'.$row['db_id']])) { echo ' checked="checked"'; }; echo ' disabled="disabled"'; } ?>>
25
+   <td><?PHP echo $row['db_name']; ?></td>
26
+<?PHP if (isset($_POST['delete']) && isset($_POST['db'.$row['db_id']])) { ?>
27
+   <input type="hidden" name="db<?PHP echo $row['db_id']; ?>" value="delete">
28
+   <td style="color: red;">This database will be deleted</td>
29
+<?PHP } else { ?>
30
+    <td></td>
31
+<?PHP } ?>
32
+  </tr>
33
+<?PHP
34
+   $i = 1 - $i;
35
+ }
36
+
37
+?>    
38
+ </table>
39
+ <div class="innerblock">
40
+  <p>With selected:</p>
41
+  <blockquote>
42
+<?PHP if (isset($_POST['delete']) && !isset($_POST['confirm'])) { ?>
43
+   <input type="hidden" name="confirm" value="confirm">
44
+   <input type="submit" name="delete" value="Confirm deletion">
45
+   <input type="submit" name="cancel" value="Cancel">
46
+<?PHP } else { ?>
47
+   <input type="submit" name="delete" id="delete" value="Delete">
48
+<?PHP } ?>
49
+  </blockquote>
50
+ </div>
51
+ </form>
52
+ <div class="innerblock" style="padding-top: 0px;">
53
+  <p>Add new database:</p>
54
+  <form action="<?PHP echo CP_PATH; ?>database" method="post">
55
+   <input type="hidden" name="action" value="adddb">
56
+   <blockquote>Name: <?PHP echo USER; ?>_<input type="text" name="newdb">
57
+    <input type="submit" value="Add">
58
+   </blockquote>
59
+  </form>  
60
+ </div>
61
+</div>

+ 63
- 0
pages/dbperms.php View File

@@ -0,0 +1,63 @@
1
+<?PHP
2
+ require_once('lib/database.php'); 
3
+ require_once('lib/common.php'); 
4
+?>
5
+<div class="block">
6
+ <h2>Database permissions</h2>
7
+<form action="<?PHP echo CP_PATH; ?>database" method="post">
8
+ <input type="hidden" name="action" value="perms">
9
+ <table class="innerblock bottomdiv">
10
+  <tr>
11
+   <th>Database \ User</th>
12
+<?PHP
13
+
14
+ $sql = 'SELECT dbuser_id, dbuser_name FROM db_users WHERE user_id = '.UID.' ORDER BY dbuser_name';
15
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
16
+ $users = array();
17
+ while ($row = mysql_fetch_array($res)) {
18
+  $users[] = $row[0];
19
+  echo '<th>'.h(preg_replace('/^[^_]*_/','',$row[1])).'</th>';
20
+ }
21
+
22
+ $sql = 'SELECT db_perms.dbuser_id, db_id FROM db_perms NATURAL JOIN db_users WHERE user_id = '.UID;
23
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
24
+ $perms = array();
25
+ while ($row = mysql_fetch_array($res)) {
26
+  if (!isset($perms[($row[0])])) { $perms[($row[0])] = array(); }
27
+  $perms[($row[0])][($row[1])] = true;
28
+ }
29
+
30
+?>
31
+  </tr>
32
+<?PHP
33
+
34
+ $i = 0;
35
+ 
36
+ $sql = 'SELECT db_id, db_name FROM db_dbs WHERE user_id = '.UID.' ORDER BY db_name';
37
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql); 
38
+ 
39
+ while ($row = mysql_fetch_array($res)) {
40
+?>
41
+  <tr class="<?PHP echo ($i == 0) ? 'even' : 'odd'; ?>">
42
+   <td><?PHP echo h($row[1]); ?></td>
43
+<?PHP
44
+ foreach ($users as $uid) {
45
+   echo '<td><input type="checkbox" name="dbp_'.$row['db_id'].'_'.$uid.'"';
46
+   if (isset($perms[$uid][($row['db_id'])])) {
47
+    echo ' checked="checked"';
48
+   }
49
+   echo '></td>';
50
+ }
51
+?>
52
+  </tr>
53
+<?PHP
54
+   $i = 1 - $i;
55
+ }
56
+
57
+?>    
58
+ </table>
59
+ <div class="innerblock">
60
+  <input type="submit" value="Update">
61
+ </div>
62
+ </form>
63
+</div>

+ 70
- 0
pages/dbusers.php View File

@@ -0,0 +1,70 @@
1
+<?PHP
2
+ require_once('lib/database.php'); 
3
+ require_once('lib/common.php'); 
4
+?>
5
+<div class="block">
6
+<form action="<?PHP echo CP_PATH; ?>database" method="post">
7
+<input type="hidden" name="action" value="edituser">
8
+ <h2>MySQL user accounts</h2>
9
+ <table class="innerblock bottomdiv">
10
+  <tr>
11
+   <th>&nbsp;</th>
12
+   <th>Name</th>
13
+   <th>Host</th>
14
+   <th></th>
15
+  </tr>
16
+<?PHP
17
+
18
+ $i = 0;
19
+ 
20
+ $sql  = 'SELECT dbuser_id, dbuser_name FROM db_users WHERE user_id = '.UID;
21
+ $sql .= ' ORDER BY dbuser_name';
22
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
23
+ 
24
+ while ($row = mysql_fetch_array($res)) {
25
+?>
26
+  <tr class="<?PHP echo ($i == 0) ? 'even' : 'odd'; ?>">
27
+   <td><input type="checkbox" name="user<?PHP echo $row['dbuser_id']; ?>" id="user<?PHP echo $row['dbuser_id']; ?>"<?PHP if (isset($_POST['userdelete'])) { if(isset($_POST['user'.$row['dbuser_id']])) { echo ' checked="checked"'; }; echo ' disabled="disabled"'; } ?>>
28
+   <td><?PHP echo $row['dbuser_name']; ?></td>
29
+   <td>localhost</td>
30
+<?PHP if (isset($_POST['userdelete']) && isset($_POST['user'.$row['dbuser_id']])) { ?>
31
+   <input type="hidden" name="user<?PHP echo $row['dbuser_id']; ?>" value="delete">
32
+   <td style="color: red;">This user will be deleted</td>
33
+<?PHP } else { ?>
34
+    <td></td>
35
+<?PHP } ?>
36
+  </tr>
37
+<?PHP
38
+   $i = 1 - $i;
39
+ }
40
+
41
+?>    
42
+ </table>
43
+ <div class="innerblock">
44
+  <p>With selected:</p>
45
+  <blockquote>
46
+<?PHP if (isset($_POST['userdelete']) && !isset($_POST['confirm'])) { ?>
47
+   <input type="hidden" name="confirm" value="confirm">
48
+   <input type="submit" name="userdelete" value="Confirm deletion">
49
+   <input type="submit" name="cancel" value="Cancel">
50
+<?PHP } else { ?>
51
+   <input type="submit" name="userdelete" value="Delete"><!--<span style="margin: 0px 20px;">or</span>
52
+   <input type="password" name="pass"><input type="submit" name="cpass" value="Change password">-->
53
+<?PHP } ?>
54
+  </blockquote>
55
+ </div>
56
+ </form>
57
+ <div class="innerblock" style="margin-top: 0px; padding-top: 0px;">
58
+ <form action="<?PHP echo CP_PATH; ?>database" method="post">
59
+  <input type="hidden" name="action" value="adduser">
60
+  <p>Add new user:</p>
61
+  <blockquote>
62
+  <label for="dbuser">Username:</label>
63
+  <?PHP echo USER; ?>_<input type="text" name="dbuser">
64
+  <label for="dbpass">Password:</label>
65
+  <input type="password" name="dbpass">
66
+  <input type="submit" value="Add">
67
+  </blockquote>
68
+ </form>
69
+ </div>
70
+</div>

+ 24
- 0
pages/discount.php View File

@@ -0,0 +1,24 @@
1
+<div class="block">
2
+ <h2>Use discount code</h2>
3
+ <div class="innerblock">
4
+  <p class="blurb">
5
+   Please enter the full discount code below. 
6
+  </p>
7
+  <form name="discount" action="<?PHP echo CP_PATH; ?>discount" method="post">
8
+   <table class="form leftpad">
9
+    <tr>
10
+     <th><label for="code">Code</label></th>
11
+     <td><input class="inflat" type="text" name="code" id="code"></td>
12
+    </tr>
13
+    <tr>
14
+     <td colspan="2" style="text-align: right;">
15
+      <input type="submit" value="Use discount code">
16
+     </td>
17
+     <td style="width: 100%;">
18
+      &nbsp;
19
+     </td>
20
+    </tr>
21
+   </table>
22
+  </form>
23
+ </div>
24
+</div>

+ 21
- 0
pages/domains.adddomain.php View File

@@ -0,0 +1,21 @@
1
+<form name="md" action="<?PHP echo CP_PATH; ?>domains" method="post" onSubmit="return validateDomainForm();">
2
+<input type="hidden" name="action" value="add">
3
+<div class="block">
4
+ <h2>Add a new domain</h2>
5
+ <div class="innerblock">
6
+  <p class="blurb">
7
+   Before you can use a new domain, a UTD-Hosting staff member will have to confirm that the
8
+   domain belongs to you.
9
+  </p>
10
+  <table class="form leftpad">
11
+   <tr>
12
+    <td><input type="text" name="domain" id="domain" class="inflat" style="width: 120px;"></td>
13
+    <td style="width:100%;"><span id="domainerr" class="validation"></span></td>
14
+   </tr>
15
+   <tr><td style="text-align: right;">
16
+    <input type="submit" value="Add">
17
+   </td></tr>
18
+  </table>
19
+ </div>
20
+</div>
21
+</form>

+ 43
- 0
pages/domains.addsubdomain.php View File

@@ -0,0 +1,43 @@
1
+<?PHP
2
+
3
+ $sql = 'SELECT domain_id, domain_name FROM domains WHERE domain_enabled = 1 AND user_id = '.UID;
4
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
5
+
6
+ if (mysql_num_rows($res) > 0) {
7
+?>
8
+<form name="submd" action="<?PHP echo CP_PATH; ?>domains" method="post" onSubmit="return validateSubdomainForm();">
9
+<input type="hidden" name="action" value="addsub">
10
+<div class="block">
11
+ <h2>Add a new subdomain</h2>
12
+ <div class="innerblock">
13
+  <p class="blurb">
14
+   You can add a new subdomain to any of your existing domains. Subdomains
15
+   are added instantly, and you can use them right away. You will need to
16
+   make sure that the subdomain resolves to the correct IP address.
17
+  </p>
18
+  <table class="form leftpad">
19
+   <tr>
20
+    <td><input type="text" name="subdomain" id="subdomain" class="inflat" style="width: 120px;"></td>
21
+    <td style="width: 10px;">.</td>
22
+    <td>
23
+     <select name="subdomaind" id="subdomaind" class="inflat">
24
+<?PHP
25
+
26
+ while ($row = mysql_fetch_array($res)) { 
27
+  if (strpos($row['domain_name'],'*')) { continue; }
28
+  echo '<option value="'.$row['domain_id'].'">'.$row['domain_name'].'</option>';
29
+ }
30
+
31
+?>
32
+     </select>
33
+    </td>
34
+    <td style="width:100%;"><span id="subdomainerr" class="validation"></span></td>
35
+   </tr>
36
+   <tr><td colspan="3" style="text-align: right;">
37
+    <input type="submit" value="Add">
38
+   </td></tr>
39
+  </table>
40
+ </div>
41
+</div>
42
+</form>
43
+<?PHP } ?>

+ 74
- 0
pages/domains.list.php View File

@@ -0,0 +1,74 @@
1
+<div class="block">
2
+<h2>Domains</h2>
3
+<div class="innerblock">
4
+  <p class="blurb">
5
+   A domain may not be deleted while it is associated with a site.
6
+  </p>
7
+  <table class="form">
8
+<?PHP
9
+
10
+ $sql = 'SELECT domain_id, domain_name, domain_parent FROM domains WHERE domain_enabled = 1 AND user_id = '.UID.' ORDER BY domain_name';
11
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
12
+
13
+ if (mysql_num_rows($res) == 0) {
14
+  echo '<p>You do not have any domains associated with your account.</p>';
15
+ }
16
+
17
+ $doms = array();
18
+ 
19
+ while ($row = mysql_fetch_array($res)) {
20
+  if (!isset($doms[$row['domain_parent']])) {
21
+   $doms[$row['domain_parent']] = array();
22
+  }
23
+  $doms[$row['domain_parent']][] = $row;
24
+ }
25
+
26
+ foreach ($doms[0] as $row) {
27
+  doDomain($row);
28
+ }
29
+
30
+ function doDomain($row, $indent = 0) {
31
+  global $doms;
32
+
33
+  $sql2 = 'SELECT r.record_value, s.site_name, s.site_id FROM records AS r, sites AS s WHERE r.domain_id = '.$row['domain_id'].' AND r.record_type = \'UTD\' AND s.site_id = r.record_value';
34
+  $res2 = mysql_query($sql2) or mf(__FILE__, __LINE__, $sql2);
35
+  if (mysql_num_rows($res2) > 0) {
36
+   $row2 = mysql_fetch_array($res2);
37
+   $asite = $row2['site_name'];
38
+   $asiteid = $row2['site_id'];
39
+  } else {
40
+   $asite = '';
41
+  }
42
+
43
+  $name = h($row['domain_name']);
44
+?>
45
+   <tr>
46
+    <td<?PHP echo $indent == 0 ? ' style="font-weight: bold;"' : ''; ?>>
47
+     <?PHP echo str_repeat('&gt; ', $indent).$name; ?>
48
+    </td>
49
+    <td><?PHP if ($asite != '') { ?>
50
+     Associated with <a href="<?PHP echo CP_PATH; ?>editsite/<?PHP echo $asiteid; ?>"><?PHP echo h($asite); ?></a>.
51
+     </td><td>
52
+<?PHP if (gethostbyname($row['domain_name']) != '63.246.141.80') { ?>
53
+      <a href="<?PHP echo CP_PATH; ?>support/017" style="color: red;">DNS Error</a>
54
+<?PHP } ?>
55
+     <?PHP } else { ?>Not associated with any site.</td><td>
56
+<?PHP if (gethostbyname($row['domain_name']) != '63.246.141.80') { ?>
57
+      <a href="<?PHP echo CP_PATH; ?>support/017" style="color: red;">DNS Error</a>
58
+<?PHP } ?>
59
+     </td><td>
60
+     <form action="<?PHP echo CP_PATH; ?>domains" method="post"><input type="hidden" name="action" value="deldom"><input type="hidden" name="domain" value="<?PHP echo $row['domain_id']; ?>"><input type="submit" value="Delete"></form><?PHP } ?>
61
+    </td>
62
+   </tr>
63
+<?PHP
64
+  if (isset($doms[$row['domain_id']])) {
65
+   foreach ($doms[$row['domain_id']] as $nrow) {
66
+    doDomain($nrow, $indent + 1);
67
+   }
68
+  }
69
+ }
70
+
71
+?>
72
+  </table>
73
+</div>
74
+</div>

+ 50
- 0
pages/domains.php View File

@@ -0,0 +1,50 @@
1
+<div class="block">
2
+<h2>Domains</h2>
3
+<div class="innerblock">
4
+  <p class="blurb">
5
+   A domain may not be deleted while it is associated with a site.
6
+  </p>
7
+  <table class="form">
8
+<?PHP
9
+
10
+ $sql = 'SELECT domain_id, domain_name FROM domains WHERE domain_enabled = 1 AND user_id = '.UID;
11
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
12
+
13
+ if (mysql_num_rows($res) == 0) {
14
+  echo '<p>You do not have any domains associated with your account.</p>';
15
+ }
16
+ 
17
+ while ($row = mysql_fetch_array($res)) {
18
+  $sql2 = 'SELECT r.record_value, s.site_name, s.site_id FROM records AS r, sites AS s WHERE r.domain_id = '.$row['domain_id'].' AND r.record_type = \'UTD\' AND s.site_id = r.record_value';
19
+  $res2 = mysql_query($sql2) or mf(__FILE__, __LINE__, $sql2);
20
+  if (mysql_num_rows($res2) > 0) {
21
+   $row2 = mysql_fetch_array($res2);
22
+   $asite = $row2['site_name'];
23
+   $asiteid = $row2['site_id'];
24
+  } else {
25
+   $asite = '';
26
+  }
27
+
28
+?>
29
+   <tr>
30
+    <td><?PHP echo h($row['domain_name']); ?></td>
31
+    <td><?PHP if ($asite != '') { ?>
32
+     Associated with <a href="<?PHP echo CP_PATH; ?>editsite/<?PHP echo $asiteid; ?>"><?PHP echo h($asite); ?></a>.
33
+     </td><td>
34
+<?PHP if (gethostbyname($row['domain_name']) != '63.246.141.80') { ?>
35
+      <a href="<?PHP echo CP_PATH; ?>support/017" style="color: red;">DNS Error</a>
36
+<?PHP } ?>
37
+     <?PHP } else { ?>Not associated with any site.</td><td>
38
+<?PHP if (gethostbyname($row['domain_name']) != '63.246.141.80') { ?>
39
+      <a href="<?PHP echo CP_PATH; ?>support/017" style="color: red;">DNS Error</a>
40
+<?PHP } ?>
41
+     </td><td>
42
+     <form action="<?PHP echo CP_PATH; ?>domains" method="post"><input type="hidden" name="action" value="deldom"><input type="hidden" name="domain" value="<?PHP echo $row['domain_id']; ?>"><input type="submit" value="Delete"></form><?PHP } ?>
43
+    </td>
44
+   </tr>
45
+<?PHP
46
+ }
47
+?>
48
+  </table>
49
+</div>
50
+</div>

+ 64
- 0
pages/editpref.php View File

@@ -0,0 +1,64 @@
1
+<div class="block">
2
+ <h2>Edit preference</h2>
3
+<?PHP
4
+ if ($_GET['n'] != 2) {
5
+ $sql  = 'SELECT '.$fields[($_GET['n'])].' FROM users NATURAL JOIN userdetails';
6
+ $sql .= ' WHERE user_id = '.UID;
7
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
8
+ $row = mysql_fetch_array($res);
9
+
10
+?>
11
+ <div class="innerblock">
12
+  <p>
13
+   Please enter your <?PHP echo $prefs[($_GET['n'])]; ?>.
14
+  </p>
15
+  <form action="<?PHP echo CP_PATH; ?>editpref/<?PHP echo $_GET['n']; ?>" method="post">
16
+   <input type="text" name="value" value="<?PHP echo htmlentities($row[0]); ?>">
17
+   <input type="submit" value="Submit">
18
+ </form>
19
+  <p>Please be aware that providing false information may lead to termination
20
+   of your UTD-Hosting account.</p>
21
+ </div>
22
+<?PHP } else { 
23
+ $sql  = 'SELECT mail_announce, mail_tickets, mail_warning, mail_over FROM ';
24
+ $sql .= 'users WHERE user_id = '.UID;
25
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
26
+ $row = mysql_fetch_array($res);
27
+?>
28
+ <div class="innerblock">
29
+  <p>Please select your mailing preferences</p>
30
+  <form action="<?PHP echo CP_PATH; ?>editpref/2" method="post">
31
+  <input type="hidden" name="mail" value="tr00">
32
+  <table class="form">
33
+   <tr>
34
+    <td><input type="checkbox" name="mail_announce"<?PHP if ($row['mail_announce']) { echo ' checked="checked"'; } ?>></td>
35
+    <td>Announcements</td>
36
+    <td>Low volume announcements about UTD-Hosting</td>
37
+   </tr>
38
+   <tr>
39
+    <td><input type="checkbox" name="mail_tickets"<?PHP if ($row['mail_tickets']) { echo ' checked="checked"'; } ?>></td>
40
+    <td>Tickets</td>
41
+    <td>Notification of replies to your tickets</td>
42
+   </tr>
43
+   <tr>
44
+    <td><input type="checkbox" name="mail_warning"<?PHP if ($row['mail_warning']) { echo ' checked="checked"'; } ?>></td>
45
+    <td>Warnings</td>
46
+    <td>Automatic warning when you near your HDD or BW limit</td>
47
+   </tr>
48
+   <tr>
49
+    <td><input type="checkbox" name="mail_over"<?PHP if ($row['mail_over']) { echo ' checked="checked"'; } ?></td>
50
+    <td>Overrings</td>
51
+    <td>Automatic message when you exceed your HDD or BW limit</td>
52
+   </tr>
53
+   <tr>
54
+    <td></td>
55
+    <td>
56
+     <input type="submit" value="Update">
57
+    </td>
58
+   </tr>
59
+  </table>
60
+  <p>Note that Warnings and Overrings are currently not implemented. This
61
+  functionality will be added at a future time.</p>
62
+ </div>
63
+<?PHP } ?>
64
+</div>

+ 62
- 0
pages/editsite.domains.php View File

@@ -0,0 +1,62 @@
1
+<div class="block">
2
+ <h2>Domain associations</h2>
3
+ <div class="innerblock">
4
+  <p class="blurb">
5
+   To view this website, you must associate it with at least one domain name.
6
+   You will then be able to view the site simply by typing the domain name
7
+   in your browser.
8
+  </p>
9
+  <form action="<?PHP echo CP_PATH; ?>editsite" method="POST">
10
+  <input type="hidden" name="task" value="domains">
11
+  <input type="hidden" name="site" value="<?PHP echo SITE_ID; ?>">
12
+  <table class="form">
13
+<?PHP
14
+
15
+ $sql = 'SELECT domain_id, domain_name, domain_parent FROM domains WHERE domain_enabled = 1 AND user_id = '.SUID.' ORDER BY domain_name';
16
+ $res = mysql_query($sql) or mf(__FILE__, __LINE__, $sql);
17
+
18
+ $doms = array();
19
+
20
+ while ($row = mysql_fetch_array($res)) {
21
+  $doms[$row['domain_parent']][] = $row;
22
+ }
23
+
24
+ foreach ($doms[0] as $row) {
25
+  doDomain($row);
26
+ }
27
+
28
+ function doDomain($row, $indent = 0) {
29
+  $sql2 = 'SELECT r.record_value, s.site_name FROM records AS r, sites AS s WHERE r.domain_id = '.$row['domain_id'].' AND r.record_type = \'UTD\' AND s.site_id = r.record_value';
30
+  $res2 = mysql_query($sql2) or mf(__FILE__, __LINE__, $sql2);
31
+  if (mysql_num_rows($res2) > 0) {
32
+   $row2 = mysql_fetch_array($res2);
33
+   $asite = $row2['site_name'];
34
+  } else {
35
+   $asite = '';
36
+  }
37
+
38
+?>
39
+   <tr>
40
+    <td><input type="checkbox" id="domain<?PHP echo $row['domain_id']; ?>" name="domain<?PHP echo $row['domain_id']; ?>"<?PHP if ($asite == SITE_NAME) { echo " checked=\"checked\""; } elseif ($asite != '') { echo " disabled=\"disabled\""; } ?>></td>
41
+    <td<?PHP echo $indent == 0 ? ' style="font-weight: bold;"' : ''; ?>>
42
+     <?PHP echo str_repeat('&gt; ', $indent).h($row['domain_name']); ?>
43
+    </td>
44
+    <td><?PHP if ($asite != '' && $asite != SITE_NAME) { ?>
45
+     Already associated with <?PHP echo h($asite); ?>.
46
+     <?PHP } ?>
47
+    </td>
48
+   </tr>
49
+<?PHP
50
+  global $doms;
51
+  if (isset($doms[$row['domain_id']])) {
52
+   foreach ($doms[$row['domain_id']] as $nrow) {
53
+    doDomain($nrow, $indent+1);
54
+   }
55
+  }
56
+ }
57
+?>
58
+   <tr><td colspan="2" style="text-align: right"><input type="submit" value="Save"></td></tr>
59
+  </table>
60
+  </form>
61
+ </div>
62
+</div>

+ 36
- 0
pages/editsite.errors.php View File

@@ -0,0 +1,36 @@
1
+<div class="block">
2
+ <h2>Recent errors</h2>
3
+ <table class="innerblock">
4
+  <tr>
5
+   <th>Time</th>
6
+   <th>Type</th>
7
+   <th>Client</th>
8
+   <th>Message</th>
9
+  </tr>
10
+<?PHP
11
+ $file = '/usr/local/apache/logs/'.str_pad(SITE_ID,3,'0',STR_PAD_LEFT).'-error_log';
12
+ if (file_exists($file) && ($size = filesize($file)) > 0) {
13
+  $fh = fopen($file,'r');
14
+  if ($size < 1024*50) { $size = 1024*50; }
15
+  fseek($fh, $size - 1024*50);
16
+  $lines = array();
17
+  while (!feof($fh)) {
18
+   $lines[] = fgets($fh);
19
+  } 
20
+  array_shift($lines); // Could be incomplete
21
+  $lines = array_reverse($lines);
22
+  $lines = array_slice($lines, 0, 10);
23
+  $i = 0;
24
+  foreach ($lines as $line) {
25
+   if (preg_match('/^\[(.*?)\] \[(.*?)\]( \[client (.*?)\])? (.*)$/', $line, $matches)) {
26
+    echo '<tr'.(($i == 1)?' class="odd"':'').'><td>'.$matches[1].'</td><td>'.$matches[2].'</td><td>'.$matches[4].'</td><td>'.$matches[5].'</td></tr>';
27
+    $i = 1 - $i;
28
+   }
29
+  }
30
+  fclose($fh);
31
+ } else {
32
+  echo '<tr><td colspan="4" style="font-style: italic; text-align: center;">No errors</td></tr>';
33
+ }
34
+?>
35
+ </table>
36
+</div>

+ 13
- 0
pages/editsite.overview.php View File

@@ -0,0 +1,13 @@
1
+<div class="block">
2
+ <h2>General settings and information</h2>
3
+ <table class="innerblock righthead">
4
+  <tr>
5
+   <th>Site name</th>
6
+   <td><?PHP echo h(SITE_NAME); ?></td>
7
+  </tr>
8
+  <tr>
9
+   <th>Document root</th>
10
+   <td><?PHP echo h(substr(SITE_DOCROOT,strlen('/home/'.SUSER))); ?></td>
11
+  </tr>
12
+ </table>
13
+</div>

+ 0
- 0
pages/editsite.php View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save