8d92bc6da2d5b83b63bab9844cf3cd80af76fdb3
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

1) <?php
2) 
3) require_once("inc/base.php");
4) require_once("inc/error.php");
5) require_once("inc/security.php");
6) 
7) require_once('class/domain.php');
8) 
9) function list_vhosts()
10) {
11)   $uid = (int) $_SESSION['userinfo']['uid'];
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

12)   $result = db_query("SELECT id,fqdn,docroot,docroot_is_default,php,options FROM vhosts.v_vhost WHERE uid={$uid} ORDER BY domain,hostname");
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

13)   $ret = array();
14)   while ($item = mysql_fetch_assoc($result))
15)     array_push($ret, $item);
16)   return $ret;
17) }
18) 
19) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

20) function empty_vhost()
21) {
22)   $vhost['hostname'] = '';
23)   
24)   $domainlist = get_domain_list($_SESSION['customerinfo']['customerno'],
25)                                 $_SESSION['userinfo']['uid']);
26)   $dom = $domainlist[0];
27) 
28)   $vhost['domain_id'] = $dom->id;
29)   $vhost['domain'] = $dom->fqdn;
30)   
31)   $vhost['homedir'] = $_SESSION['userinfo']['homedir'];
32)   $vhost['docroot'] = NULL;
33)   $vhost['php'] = 'mod_php';
34)   $vhost['logtype'] = NULL;
35)     
36)   $vhost['options'] = '';
37)   return $vhost;
38) }
39) 
40) 
41) function domainselect($selected = NULL, $selectattribute = '')
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

42) {
43)   global $domainlist;
44)   if ($domainlist == NULL)
45)     $domainlist = get_domain_list($_SESSION['customerinfo']['customerno'],
46)                                   $_SESSION['userinfo']['uid']);
47)   $selected = (int) $selected;
48) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

49)   $ret = '<select id="domain" name="domain" size="1" '.$selectattribute.' >';
bernd neues VHosts-Modul (unbenut...

bernd authored 16 years ago

50)   foreach ($domainlist as $dom)
51)   {
52)     $s = '';
53)     if ($selected == $dom->id)
54)       $s = ' selected="selected" ';
55)     $ret .= "<option value=\"{$dom->id}\"{$s}>{$dom->fqdn}</option>\n";
56)   }
57)   $ret .= '</select>';
58)   return $ret;
59) }
60) 
61) 
62) 
63) function get_vhost_details($id)
64) {
65)   $id = (int) $id;
66)   $uid = (int) $_SESSION['userinfo']['uid'];
67)   $result = db_query("SELECT * FROM vhosts.v_vhost WHERE uid={$uid} AND id={$id}");
68)   if (mysql_num_rows($result) != 1)
69)     system_failure('Interner Fehler beim Auslesen der Daten');
70) 
71)   return mysql_fetch_assoc($result);
72) }
73) 
74) 
75) 
76) function get_aliases($vhost)
77) {
78)   $vhost = (int) $vhost;
79)   $result = db_query("SELECT id,fqdn,options FROM vhosts.v_alias WHERE vhost={$vhost}");
80)   $ret = array();
81)   while ($item = mysql_fetch_assoc($result))
82)     array_push($ret, $item);
83)   return $ret;
84) }
85) 
bernd VHosts können bearbeitet we...

bernd authored 16 years ago

86) function delete_vhost($id)
87) {
88)   $id = (int) $id;
89)   if ($id == 0)
90)     system_failure("id == 0");
91)   $vhost = get_vhost_details($id);
92)   db_query("DELETE FROM vhosts.vhost WHERE id={$vhost['id']} LIMIT 1");
93) }
94) 
95) function save_vhost($vhost)
96) {
97)   if (! is_array($vhost))
98)     system_failure('$vhost kein array!');
99)   $id = (int) $vhost['id'];
100)   $hostname = maybe_null($vhost['hostname']);
101)   $domain = (int) $vhost['domainid'];
102)   if ($domain == 0)
103)     system_failure("Domain == 0");
104)   $docroot = maybe_null($vhost['docroot']);
105)   $php = maybe_null($vhost['php']);
106)   $logtype = maybe_null($vhost['logtype']);
107)   $options = mysql_real_escape_string( $vhost['options'] );
108) 
109)   if ($id != 0)
110)     db_query("UPDATE vhosts.vhost SET hostname={$hostname}, domain={$domain}, docroot={$docroot}, php={$php}, logtype={$logtype}, options='{$options}' WHERE id={$id} LIMIT 1");
111)   else
112)     db_query("INSERT INTO vhosts.vhost (user, hostname, domain, docroot, php, logtype, options) VALUES ({$_SESSION['userinfo']['uid']}, {$hostname}, {$domain}, {$docroot}, {$php}, {$logtype}, '{$options}')");
113)   
114) }
115) 
116)