Browse code

Codingstyle PSR12 + array syntax

Hanno Böck authored on 30/10/2021 21:18:17
Showing 1 changed files
... ...
@@ -20,7 +20,7 @@ require_once('inc/debug.php');
20 20
 
21 21
 class Domain
22 22
 {
23
-    protected $data = array();
23
+    protected $data = [];
24 24
     public function __construct($init = null)
25 25
     {
26 26
         $this->setup();
... ...
@@ -61,7 +61,7 @@ class Domain
61 61
 
62 62
     public function loadByID($id)
63 63
     {
64
-        $res = db_query("SELECT * FROM kundendaten.domains WHERE id=?", array($id));
64
+        $res = db_query("SELECT * FROM kundendaten.domains WHERE id=?", [$id]);
65 65
         if ($res->rowCount() < 1) {
66 66
             return false;
67 67
         }
... ...
@@ -73,7 +73,7 @@ class Domain
73 73
     {
74 74
         $raw = $name;
75 75
         $utf8 = idn_to_utf8($raw, 0, INTL_IDNA_VARIANT_UTS46);
76
-        $res = db_query("SELECT * FROM kundendaten.domains WHERE CONCAT_WS('.', domainname, tld)=? OR CONCAT_WS('.', domainname, tld)=?", array($raw, $utf8));
76
+        $res = db_query("SELECT * FROM kundendaten.domains WHERE CONCAT_WS('.', domainname, tld)=? OR CONCAT_WS('.', domainname, tld)=?", [$raw, $utf8]);
77 77
         if ($res->rowCount() < 1) {
78 78
             return false;
79 79
         }
... ...
@@ -115,7 +115,7 @@ class Domain
115 115
 
116 116
     public function setup()
117 117
     {
118
-        $fields = array();
118
+        $fields = [];
119 119
         $res = db_query("DESCRIBE kundendaten.domains");
120 120
         while ($f = $res->fetch(PDO::FETCH_OBJ)) {
121 121
             $fields[$f->Field] = $f->Default;
... ...
@@ -163,8 +163,8 @@ function get_domain_list($customerno = null, $uid = null)
163 163
         $query .= " kunde={$customerno}";
164 164
     }
165 165
     $query .= " ORDER BY domainname,tld";
166
-    $result = db_query($query, array()); // FIXME Übergebe leeren array um die Warnung zu unterdrücken
167
-    $domains = array();
166
+    $result = db_query($query, []); // FIXME Übergebe leeren array um die Warnung zu unterdrücken
167
+    $domains = [];
168 168
     DEBUG('Result set is '.$result->rowCount()." rows.<br />\n");
169 169
     if ($result->rowCount() > 0) {
170 170
         while ($domain = $result->fetch(PDO::FETCH_OBJ)) {
... ...
@@ -184,7 +184,7 @@ function get_jabberable_domains()
184 184
 
185 185
     $domains = get_domain_list($customerno);
186 186
     DEBUG($domains);
187
-    $result = array( new Domain() );
187
+    $result = [ new Domain() ];
188 188
     $result[0]->id = 0;
189 189
     $result[0]->fqdn = config('masterdomain');
190 190
     foreach ($domains as $dom) {
Browse code

Übergebe keine Kundennummer beim Auflisten der Userdomains im vhost-Modul

Bernd Wurst authored on 07/08/2019 06:59:51
Showing 1 changed files
... ...
@@ -148,14 +148,18 @@ class Domain
148 148
 
149 149
 
150 150
 
151
-function get_domain_list($customerno, $uid = null)
151
+function get_domain_list($customerno = null, $uid = null)
152 152
 {
153
-    $customerno = (int) $customerno;
153
+    if ($customerno == null && $uid === null) {
154
+        DEBUG('get_domain_list() wurde aufgerufen mit leerem Kunde und leerem User!');
155
+        system_failure('Interner Fehler');
156
+    }
154 157
     $query = "SELECT id FROM kundendaten.domains WHERE";
155 158
     if ($uid !== null) {
156 159
         $uid = (int) $uid;
157 160
         $query .= " useraccount={$uid}";
158 161
     } else {
162
+        $customerno = (int) $customerno;
159 163
         $query .= " kunde={$customerno}";
160 164
     }
161 165
     $query .= " ORDER BY domainname,tld";
Browse code

Fix coding style with php-cs-checker, see https://cs.sensiolabs.org/

Hanno authored on 26/06/2018 13:58:19
Showing 1 changed files
... ...
@@ -8,7 +8,7 @@ Written 2008-2018 by schokokeks.org Hosting, namely
8 8
 
9 9
 To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
10 10
 
11
-You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see 
11
+You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see
12 12
 http://creativecommons.org/publicdomain/zero/1.0/
13 13
 
14 14
 Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
... ...
@@ -21,11 +21,10 @@ require_once('inc/debug.php');
21 21
 class Domain
22 22
 {
23 23
     protected $data = array();
24
-  function __construct($init = NULL)
25
-  {
26
-    $this->setup();
27
-    switch (gettype($init))
24
+    public function __construct($init = null)
28 25
     {
26
+        $this->setup();
27
+        switch (gettype($init)) {
29 28
       case 'string':
30 29
         $this->loadByName($init);
31 30
         break;
... ...
@@ -35,105 +34,112 @@ class Domain
35 34
       case 'NULL':
36 35
         break;
37 36
     }
38
-  }
39
-
40
-  function __set($key, $value)
41
-  {
42
-    if (array_key_exists($key, $this->data)) {
43
-      $this->data[$key] = $value;
44
-    } elseif (isset($this->$key)) {
45
-      $this->$key = $value;
46
-    } else {
47
-      $this->data[$key] = $value;
48 37
     }
49
-  }
50
-
51
-
52
-  function __get($key)
53
-  {
54
-    if (array_key_exists($key, $this->data))
55
-      return $this->data[$key];
56
-    elseif (isset($this->$key))
57
-      return $this->$key;
58
-    // else werfe fehler
59
-  }
60
-
61
-
62
-  function loadByID($id)
63
-  {
64
-      $res = db_query("SELECT * FROM kundendaten.domains WHERE id=?", array($id));
65
-      if ($res->rowCount() < 1)
66
-         return false;
67
-      $data = $res->fetch();
68
-      $this->parse($data);
69
-  }
70
-
71
-   function loadByName($name)
72
-  {
73
-      $raw = $name;
74
-      $utf8 = idn_to_utf8($raw, 0, INTL_IDNA_VARIANT_UTS46);
75
-      $res = db_query("SELECT * FROM kundendaten.domains WHERE CONCAT_WS('.', domainname, tld)=? OR CONCAT_WS('.', domainname, tld)=?", array($raw, $utf8));
76
-      if ($res->rowCount() < 1)
77
-         return false;
78
-      $data = $res->fetch();
79
-      $this->parse($data);
80
-  }
81
-
82
-  function ensure_customerdomain()
83
-  {
84
-    if (! $this->is_customerdomain() )
85
-      system_failure('Diese Domain gehört nicht Ihrem Kundenaccount.');
86
-  }
87
-
88
-  function ensure_userdomain()
89
-  {
90
-    if (! $this->is_userdomain() )
91
-      system_failure('Diese Domain gehört nicht Ihrem Benutzeraccount.');
92
-  }
93
-
94
-  function is_customerdomain()
95
-  {
96
-    if (! isset($_SESSION['customerinfo']) )
97
-      return false;
98
-    $customerno = (int) $_SESSION['customerinfo']['customerno'];
99
-    return ($this->kunde == $customerno);
100
-  }
101
-
102
-  function is_userdomain()
103
-  {
104
-    if (! isset($_SESSION['userinfo']) )
105
-      return false;
106
-    $uid = (int) $_SESSION['userinfo']['uid'];
107
-    return ($this->useraccount == $uid);
108
-  }
109
-
110
-  function setup()
111
-  {
112
-    $fields = array();
113
-    $res = db_query("DESCRIBE kundendaten.domains");
114
-    while ($f = $res->fetch(PDO::FETCH_OBJ))
38
+
39
+    public function __set($key, $value)
40
+    {
41
+        if (array_key_exists($key, $this->data)) {
42
+            $this->data[$key] = $value;
43
+        } elseif (isset($this->$key)) {
44
+            $this->$key = $value;
45
+        } else {
46
+            $this->data[$key] = $value;
47
+        }
48
+    }
49
+
50
+
51
+    public function __get($key)
52
+    {
53
+        if (array_key_exists($key, $this->data)) {
54
+            return $this->data[$key];
55
+        } elseif (isset($this->$key)) {
56
+            return $this->$key;
57
+        }
58
+        // else werfe fehler
59
+    }
60
+
61
+
62
+    public function loadByID($id)
63
+    {
64
+        $res = db_query("SELECT * FROM kundendaten.domains WHERE id=?", array($id));
65
+        if ($res->rowCount() < 1) {
66
+            return false;
67
+        }
68
+        $data = $res->fetch();
69
+        $this->parse($data);
70
+    }
71
+
72
+    public function loadByName($name)
73
+    {
74
+        $raw = $name;
75
+        $utf8 = idn_to_utf8($raw, 0, INTL_IDNA_VARIANT_UTS46);
76
+        $res = db_query("SELECT * FROM kundendaten.domains WHERE CONCAT_WS('.', domainname, tld)=? OR CONCAT_WS('.', domainname, tld)=?", array($raw, $utf8));
77
+        if ($res->rowCount() < 1) {
78
+            return false;
79
+        }
80
+        $data = $res->fetch();
81
+        $this->parse($data);
82
+    }
83
+
84
+    public function ensure_customerdomain()
85
+    {
86
+        if (! $this->is_customerdomain()) {
87
+            system_failure('Diese Domain gehört nicht Ihrem Kundenaccount.');
88
+        }
89
+    }
90
+
91
+    public function ensure_userdomain()
92
+    {
93
+        if (! $this->is_userdomain()) {
94
+            system_failure('Diese Domain gehört nicht Ihrem Benutzeraccount.');
95
+        }
96
+    }
97
+
98
+    public function is_customerdomain()
115 99
     {
116
-      $fields[$f->Field] = $f->Default;
100
+        if (! isset($_SESSION['customerinfo'])) {
101
+            return false;
102
+        }
103
+        $customerno = (int) $_SESSION['customerinfo']['customerno'];
104
+        return ($this->kunde == $customerno);
117 105
     }
118
-    $this->data = $fields;
119
-    $this->data['id'] = NULL;
120
-  }
121 106
 
107
+    public function is_userdomain()
108
+    {
109
+        if (! isset($_SESSION['userinfo'])) {
110
+            return false;
111
+        }
112
+        $uid = (int) $_SESSION['userinfo']['uid'];
113
+        return ($this->useraccount == $uid);
114
+    }
115
+
116
+    public function setup()
117
+    {
118
+        $fields = array();
119
+        $res = db_query("DESCRIBE kundendaten.domains");
120
+        while ($f = $res->fetch(PDO::FETCH_OBJ)) {
121
+            $fields[$f->Field] = $f->Default;
122
+        }
123
+        $this->data = $fields;
124
+        $this->data['id'] = null;
125
+    }
122 126
 
123 127
 
124
-  function parse($data)
125
-  {
126
-    DEBUG($data);
127
-    foreach (array_keys($this->data) as $key)
128
-      if (array_key_exists($key, $data))
129
-        $this->data[$key] = $data[$key];
130
-    $this->data['fqdn'] = $data['domainname'].'.'.$data['tld'];
131
-    $this->data['punycode'] = idn_to_ascii($this->data['fqdn'], 0, INTL_IDNA_VARIANT_UTS46);
132
-    $this->data['is_idn'] = ($this->data['fqdn'] != $this->data['punycode']);
133
-    $this->data['reg_date'] = $data['registrierungsdatum'];
134
-    $this->data['cancel_date'] = $data['kuendigungsdatum'];
135
-  }
136 128
 
129
+    public function parse($data)
130
+    {
131
+        DEBUG($data);
132
+        foreach (array_keys($this->data) as $key) {
133
+            if (array_key_exists($key, $data)) {
134
+                $this->data[$key] = $data[$key];
135
+            }
136
+        }
137
+        $this->data['fqdn'] = $data['domainname'].'.'.$data['tld'];
138
+        $this->data['punycode'] = idn_to_ascii($this->data['fqdn'], 0, INTL_IDNA_VARIANT_UTS46);
139
+        $this->data['is_idn'] = ($this->data['fqdn'] != $this->data['punycode']);
140
+        $this->data['reg_date'] = $data['registrierungsdatum'];
141
+        $this->data['cancel_date'] = $data['kuendigungsdatum'];
142
+    }
137 143
 }
138 144
 
139 145
 
... ...
@@ -142,48 +148,45 @@ class Domain
142 148
 
143 149
 
144 150
 
145
-function get_domain_list($customerno, $uid = NULL)
151
+function get_domain_list($customerno, $uid = null)
146 152
 {
147
-  $customerno = (int) $customerno;
148
-  $query = "SELECT id FROM kundendaten.domains WHERE";
149
-  if ($uid !== NULL)
150
-  {
151
-    $uid = (int) $uid;
152
-    $query .= " useraccount={$uid}";
153
-  }
154
-  else
155
-  {
156
-    $query .= " kunde={$customerno}";
157
-  }
158
-  $query .= " ORDER BY domainname,tld";
159
-  $result = db_query($query, array()); // FIXME Übergebe leeren array um die Warnung zu unterdrücken
160
-  $domains = array();
161
-  DEBUG('Result set is '.$result->rowCount()." rows.<br />\n");
162
-  if ($result->rowCount() > 0)
163
-    while ($domain = $result->fetch(PDO::FETCH_OBJ))
164
-      array_push($domains, new Domain((int) $domain->id));
165
-  DEBUG($domains);
166
-	return $domains;	
153
+    $customerno = (int) $customerno;
154
+    $query = "SELECT id FROM kundendaten.domains WHERE";
155
+    if ($uid !== null) {
156
+        $uid = (int) $uid;
157
+        $query .= " useraccount={$uid}";
158
+    } else {
159
+        $query .= " kunde={$customerno}";
160
+    }
161
+    $query .= " ORDER BY domainname,tld";
162
+    $result = db_query($query, array()); // FIXME Übergebe leeren array um die Warnung zu unterdrücken
163
+    $domains = array();
164
+    DEBUG('Result set is '.$result->rowCount()." rows.<br />\n");
165
+    if ($result->rowCount() > 0) {
166
+        while ($domain = $result->fetch(PDO::FETCH_OBJ)) {
167
+            array_push($domains, new Domain((int) $domain->id));
168
+        }
169
+    }
170
+    DEBUG($domains);
171
+    return $domains;
167 172
 }
168 173
 
169 174
 
170 175
 
171 176
 function get_jabberable_domains()
172 177
 {
173
-  require_role(ROLE_CUSTOMER);
174
-  $customerno = (int) $_SESSION['customerinfo']['customerno'];
175
-
176
-  $domains = get_domain_list($customerno);
177
-  DEBUG($domains);
178
-  $result = array( new Domain() );
179
-  $result[0]->id = 0;
180
-  $result[0]->fqdn = config('masterdomain');
181
-  foreach ($domains as $dom)
182
-  {
183
-    if ($dom->jabber)
184
-      $result[] = $dom;
185
-  }
186
-  return $result;
178
+    require_role(ROLE_CUSTOMER);
179
+    $customerno = (int) $_SESSION['customerinfo']['customerno'];
187 180
 
181
+    $domains = get_domain_list($customerno);
182
+    DEBUG($domains);
183
+    $result = array( new Domain() );
184
+    $result[0]->id = 0;
185
+    $result[0]->fqdn = config('masterdomain');
186
+    foreach ($domains as $dom) {
187
+        if ($dom->jabber) {
188
+            $result[] = $dom;
189
+        }
190
+    }
191
+    return $result;
188 192
 }
189
-
Browse code

hardening the domain input

Bernd Wurst authored on 06/02/2018 17:38:01
Showing 1 changed files
... ...
@@ -70,7 +70,9 @@ class Domain
70 70
 
71 71
    function loadByName($name)
72 72
   {
73
-      $res = db_query("SELECT * FROM kundendaten.domains WHERE CONCAT_WS('.', domainname, tld)=?", array($name));
73
+      $raw = $name;
74
+      $utf8 = idn_to_utf8($raw, 0, INTL_IDNA_VARIANT_UTS46);
75
+      $res = db_query("SELECT * FROM kundendaten.domains WHERE CONCAT_WS('.', domainname, tld)=? OR CONCAT_WS('.', domainname, tld)=?", array($raw, $utf8));
74 76
       if ($res->rowCount() < 1)
75 77
          return false;
76 78
       $data = $res->fetch();
Browse code

Alte Klassen entfernt

Bernd Wurst authored on 23/01/2018 14:01:15
Showing 1 changed files
... ...
@@ -17,14 +17,12 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
17 17
 require_once('inc/base.php');
18 18
 require_once('inc/debug.php');
19 19
 
20
-require_once('class/keksdata.php');
21 20
 
22
-
23
-class Domain extends KeksData
21
+class Domain
24 22
 {
23
+    protected $data = array();
25 24
   function __construct($init = NULL)
26 25
   {
27
-    $this->default_table = 'kundendaten.domains';
28 26
     $this->setup();
29 27
     switch (gettype($init))
30 28
     {
... ...
@@ -39,13 +37,44 @@ class Domain extends KeksData
39 37
     }
40 38
   }
41 39
 
42
-  function loadByName($name)
40
+  function __set($key, $value)
43 41
   {
44
-    $name = db_escape_string($name);
45
-    $res = $this->getData("*", "CONCAT_WS('.', domainname, tld)='{$name}' LIMIT 1");
46
-    if (count($res) < 1)
47
-      return false;
48
-    $this->parse($res[0]);
42
+    if (array_key_exists($key, $this->data)) {
43
+      $this->data[$key] = $value;
44
+    } elseif (isset($this->$key)) {
45
+      $this->$key = $value;
46
+    } else {
47
+      $this->data[$key] = $value;
48
+    }
49
+  }
50
+
51
+
52
+  function __get($key)
53
+  {
54
+    if (array_key_exists($key, $this->data))
55
+      return $this->data[$key];
56
+    elseif (isset($this->$key))
57
+      return $this->$key;
58
+    // else werfe fehler
59
+  }
60
+
61
+
62
+  function loadByID($id)
63
+  {
64
+      $res = db_query("SELECT * FROM kundendaten.domains WHERE id=?", array($id));
65
+      if ($res->rowCount() < 1)
66
+         return false;
67
+      $data = $res->fetch();
68
+      $this->parse($data);
69
+  }
70
+
71
+   function loadByName($name)
72
+  {
73
+      $res = db_query("SELECT * FROM kundendaten.domains WHERE CONCAT_WS('.', domainname, tld)=?", array($name));
74
+      if ($res->rowCount() < 1)
75
+         return false;
76
+      $data = $res->fetch();
77
+      $this->parse($data);
49 78
   }
50 79
 
51 80
   function ensure_customerdomain()
... ...
@@ -76,6 +105,20 @@ class Domain extends KeksData
76 105
     return ($this->useraccount == $uid);
77 106
   }
78 107
 
108
+  function setup()
109
+  {
110
+    $fields = array();
111
+    $res = db_query("DESCRIBE kundendaten.domains");
112
+    while ($f = $res->fetch(PDO::FETCH_OBJ))
113
+    {
114
+      $fields[$f->Field] = $f->Default;
115
+    }
116
+    $this->data = $fields;
117
+    $this->data['id'] = NULL;
118
+  }
119
+
120
+
121
+
79 122
   function parse($data)
80 123
   {
81 124
     DEBUG($data);
... ...
@@ -142,4 +185,3 @@ function get_jabberable_domains()
142 185
 
143 186
 }
144 187
 
145
-?>
Browse code

Copyright year update

Bernd Wurst authored on 13/01/2018 06:07:05
Showing 1 changed files
... ...
@@ -2,7 +2,7 @@
2 2
 /*
3 3
 This file belongs to the Webinterface of schokokeks.org Hosting
4 4
 
5
-Written 2008-2014 by schokokeks.org Hosting, namely
5
+Written 2008-2018 by schokokeks.org Hosting, namely
6 6
   Bernd Wurst <bernd@schokokeks.org>
7 7
   Hanno Böck <hanno@schokokeks.org>
8 8
 
Browse code

Punycode-Konvertierung findet in der Domain-Klasse statt

Bernd Wurst authored on 09/01/2018 05:42:48
Showing 1 changed files
... ...
@@ -83,6 +83,8 @@ class Domain extends KeksData
83 83
       if (array_key_exists($key, $data))
84 84
         $this->data[$key] = $data[$key];
85 85
     $this->data['fqdn'] = $data['domainname'].'.'.$data['tld'];
86
+    $this->data['punycode'] = idn_to_ascii($this->data['fqdn'], 0, INTL_IDNA_VARIANT_UTS46);
87
+    $this->data['is_idn'] = ($this->data['fqdn'] != $this->data['punycode']);
86 88
     $this->data['reg_date'] = $data['registrierungsdatum'];
87 89
     $this->data['cancel_date'] = $data['kuendigungsdatum'];
88 90
   }
Browse code

Entferne den FQDN aus Fehlermeldungen

Bernd Wurst authored on 02/03/2017 13:51:25
Showing 1 changed files
... ...
@@ -51,13 +51,13 @@ class Domain extends KeksData
51 51
   function ensure_customerdomain()
52 52
   {
53 53
     if (! $this->is_customerdomain() )
54
-      system_failure('Die Domain »'.$this->data['fqdn'].'« gehört nicht Ihrem Kundenaccount.');
54
+      system_failure('Diese Domain gehört nicht Ihrem Kundenaccount.');
55 55
   }
56 56
 
57 57
   function ensure_userdomain()
58 58
   {
59 59
     if (! $this->is_userdomain() )
60
-      system_failure('Die Domain »'.$this->data['fqdn'].'« gehört nicht Ihrem Benutzeraccount.');
60
+      system_failure('Diese Domain gehört nicht Ihrem Benutzeraccount.');
61 61
   }
62 62
 
63 63
   function is_customerdomain()
Browse code

Lizenzinfos in eigenes Modul ausgelagert und Copyright auf 2014 angepasst

Bernd Wurst authored on 08/02/2014 05:45:07
Showing 1 changed files
... ...
@@ -2,7 +2,7 @@
2 2
 /*
3 3
 This file belongs to the Webinterface of schokokeks.org Hosting
4 4
 
5
-Written 2008-2013 by schokokeks.org Hosting, namely
5
+Written 2008-2014 by schokokeks.org Hosting, namely
6 6
   Bernd Wurst <bernd@schokokeks.org>
7 7
   Hanno Böck <hanno@schokokeks.org>
8 8
 
Browse code

Einige Statements auf Prepared-statements umgestellt

Bernd Wurst authored on 02/02/2014 16:31:00
Showing 1 changed files
... ...
@@ -109,7 +109,7 @@ function get_domain_list($customerno, $uid = NULL)
109 109
     $query .= " kunde={$customerno}";
110 110
   }
111 111
   $query .= " ORDER BY domainname,tld";
112
-  $result = db_query($query);
112
+  $result = db_query($query, array()); // FIXME Übergebe leeren array um die Warnung zu unterdrücken
113 113
   $domains = array();
114 114
   DEBUG('Result set is '.$result->rowCount()." rows.<br />\n");
115 115
   if ($result->rowCount() > 0)
Browse code

Umstellung auf PDO-Datenbankverbindung

Bernd Wurst authored on 01/02/2014 18:38:23
Showing 1 changed files
... ...
@@ -14,7 +14,6 @@ http://creativecommons.org/publicdomain/zero/1.0/
14 14
 Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
15 15
 */
16 16
 
17
-require_once('inc/db_connect.php');
18 17
 require_once('inc/base.php');
19 18
 require_once('inc/debug.php');
20 19
 
... ...
@@ -42,7 +41,7 @@ class Domain extends KeksData
42 41
 
43 42
   function loadByName($name)
44 43
   {
45
-    $name = mysql_real_escape_string($name);
44
+    $name = db_escape_string($name);
46 45
     $res = $this->getData("*", "CONCAT_WS('.', domainname, tld)='{$name}' LIMIT 1");
47 46
     if (count($res) < 1)
48 47
       return false;
... ...
@@ -112,9 +111,9 @@ function get_domain_list($customerno, $uid = NULL)
112 111
   $query .= " ORDER BY domainname,tld";
113 112
   $result = db_query($query);
114 113
   $domains = array();
115
-  DEBUG('Result set is '.mysql_num_rows($result)." rows.<br />\n");
116
-  if (mysql_num_rows($result) > 0)
117
-    while ($domain = mysql_fetch_object($result))
114
+  DEBUG('Result set is '.$result->rowCount()." rows.<br />\n");
115
+  if ($result->rowCount() > 0)
116
+    while ($domain = $result->fetch(PDO::FETCH_OBJ))
118 117
       array_push($domains, new Domain((int) $domain->id));
119 118
   DEBUG($domains);
120 119
 	return $domains;	
Browse code

Updated copyright notice (2012 => 2013)

Bernd Wurst authored on 19/01/2013 10:49:50
Showing 1 changed files
... ...
@@ -2,7 +2,7 @@
2 2
 /*
3 3
 This file belongs to the Webinterface of schokokeks.org Hosting
4 4
 
5
-Written 2008-2012 by schokokeks.org Hosting, namely
5
+Written 2008-2013 by schokokeks.org Hosting, namely
6 6
   Bernd Wurst <bernd@schokokeks.org>
7 7
   Hanno Böck <hanno@schokokeks.org>
8 8
 
Browse code

Added license tags for CC0, README and COPYING

Bernd Wurst authored on 11/03/2012 15:40:04
Showing 1 changed files
... ...
@@ -1,4 +1,18 @@
1 1
 <?php
2
+/*
3
+This file belongs to the Webinterface of schokokeks.org Hosting
4
+
5
+Written 2008-2012 by schokokeks.org Hosting, namely
6
+  Bernd Wurst <bernd@schokokeks.org>
7
+  Hanno Böck <hanno@schokokeks.org>
8
+
9
+To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
10
+
11
+You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see 
12
+http://creativecommons.org/publicdomain/zero/1.0/
13
+
14
+Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
15
+*/
2 16
 
3 17
 require_once('inc/db_connect.php');
4 18
 require_once('inc/base.php');
Browse code

Schreibe auch hin, welche Domain das Problem sind

git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@1607 87cf0b9e-d624-0410-a070-f6ee81989793

bernd authored on 20/01/2010 07:19:05
Showing 1 changed files
... ...
@@ -38,13 +38,13 @@ class Domain extends KeksData
38 38
   function ensure_customerdomain()
39 39
   {
40 40
     if (! $this->is_customerdomain() )
41
-      system_failure('Diese Domain gehört nicht Ihrem Kundenaccount.');
41
+      system_failure('Die Domain »'.$this->data['fqdn'].'« gehört nicht Ihrem Kundenaccount.');
42 42
   }
43 43
 
44 44
   function ensure_userdomain()
45 45
   {
46 46
     if (! $this->is_userdomain() )
47
-      system_failure('Diese Domain gehört nicht Ihrem Benutzeraccount.');
47
+      system_failure('Die Domain »'.$this->data['fqdn'].'« gehört nicht Ihrem Benutzeraccount.');
48 48
   }
49 49
 
50 50
   function is_customerdomain()
Browse code

neue Bilder, mehr SSL-Zertifikate-Verwaltung

git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@1445 87cf0b9e-d624-0410-a070-f6ee81989793

bernd authored on 29/08/2009 17:08:03
Showing 1 changed files
... ...
@@ -100,8 +100,8 @@ function get_domain_list($customerno, $uid = NULL)
100 100
   $domains = array();
101 101
   DEBUG('Result set is '.mysql_num_rows($result)." rows.<br />\n");
102 102
   if (mysql_num_rows($result) > 0)
103
-    while ($domain = mysql_fetch_object($result)->id)
104
-      array_push($domains, new Domain((int) $domain));
103
+    while ($domain = mysql_fetch_object($result))
104
+      array_push($domains, new Domain((int) $domain->id));
105 105
   DEBUG($domains);
106 106
 	return $domains;	
107 107
 }
Browse code

Mehr config-optionen und config via Wrapper-Funktion benutzen

git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@1376 87cf0b9e-d624-0410-a070-f6ee81989793

bernd authored on 23/05/2009 15:24:52
Showing 1 changed files
... ...
@@ -35,6 +35,34 @@ class Domain extends KeksData
35 35
     $this->parse($res[0]);
36 36
   }
37 37
 
38
+  function ensure_customerdomain()
39
+  {
40
+    if (! $this->is_customerdomain() )
41
+      system_failure('Diese Domain gehört nicht Ihrem Kundenaccount.');
42
+  }
43
+
44
+  function ensure_userdomain()
45
+  {
46
+    if (! $this->is_userdomain() )
47
+      system_failure('Diese Domain gehört nicht Ihrem Benutzeraccount.');
48
+  }
49
+
50
+  function is_customerdomain()
51
+  {
52
+    if (! isset($_SESSION['customerinfo']) )
53
+      return false;
54
+    $customerno = (int) $_SESSION['customerinfo']['customerno'];
55
+    return ($this->kunde == $customerno);
56
+  }
57
+
58
+  function is_userdomain()
59
+  {
60
+    if (! isset($_SESSION['userinfo']) )
61
+      return false;
62
+    $uid = (int) $_SESSION['userinfo']['uid'];
63
+    return ($this->useraccount == $uid);
64
+  }
65
+
38 66
   function parse($data)
39 67
   {
40 68
     DEBUG($data);
... ...
@@ -89,7 +117,7 @@ function get_jabberable_domains()
89 117
   DEBUG($domains);
90 118
   $result = array( new Domain() );
91 119
   $result[0]->id = 0;
92
-  $result[0]->fqdn = "schokokeks.org";
120
+  $result[0]->fqdn = config('masterdomain');
93 121
   foreach ($domains as $dom)
94 122
   {
95 123
     if ($dom->jabber)
Browse code

some updates

git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@1134 87cf0b9e-d624-0410-a070-f6ee81989793

bernd authored on 13/08/2008 07:09:36
Showing 1 changed files
... ...
@@ -37,6 +37,7 @@ class Domain extends KeksData
37 37
 
38 38
   function parse($data)
39 39
   {
40
+    DEBUG($data);
40 41
     foreach (array_keys($this->data) as $key)
41 42
       if (array_key_exists($key, $data))
42 43
         $this->data[$key] = $data[$key];
Browse code

Domains alphabetisch sortieren

git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@626 87cf0b9e-d624-0410-a070-f6ee81989793

bernd authored on 13/08/2007 13:16:15
Showing 1 changed files
... ...
@@ -60,12 +60,13 @@ function get_domain_list($customerno, $uid = NULL)
60 60
   if ($uid !== NULL)
61 61
   {
62 62
     $uid = (int) $uid;
63
-    $query .= " useraccount={$uid};";
63
+    $query .= " useraccount={$uid}";
64 64
   }
65 65
   else
66 66
   {
67
-    $query .= " kunde={$customerno};";
67
+    $query .= " kunde={$customerno}";
68 68
   }
69
+  $query .= " ORDER BY domainname,tld";
69 70
   $result = db_query($query);
70 71
   $domains = array();
71 72
   DEBUG('Result set is '.mysql_num_rows($result)." rows.<br />\n");
Browse code

Domain-Klasse benutzen

git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@536 87cf0b9e-d624-0410-a070-f6ee81989793

bernd authored on 05/07/2007 18:43:18
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,100 @@
1
+<?php
2
+
3
+require_once('inc/db_connect.php');
4
+require_once('inc/base.php');
5
+require_once('inc/debug.php');
6
+
7
+require_once('class/keksdata.php');
8
+
9
+
10
+class Domain extends KeksData
11
+{
12
+  function __construct($init = NULL)
13
+  {
14
+    $this->default_table = 'kundendaten.domains';
15
+    $this->setup();
16
+    switch (gettype($init))
17
+    {
18
+      case 'string':
19
+        $this->loadByName($init);
20
+        break;
21
+      case 'integer':
22
+        $this->loadByID($init);
23
+        break;
24
+      case 'NULL':
25
+        break;
26
+    }
27
+  }
28
+
29
+  function loadByName($name)
30
+  {
31
+    $name = mysql_real_escape_string($name);
32
+    $res = $this->getData("*", "CONCAT_WS('.', domainname, tld)='{$name}' LIMIT 1");
33
+    if (count($res) < 1)
34
+      return false;
35
+    $this->parse($res[0]);
36
+  }
37
+
38
+  function parse($data)
39
+  {
40
+    foreach (array_keys($this->data) as $key)
41
+      if (array_key_exists($key, $data))
42
+        $this->data[$key] = $data[$key];
43
+    $this->data['fqdn'] = $data['domainname'].'.'.$data['tld'];
44
+    $this->data['reg_date'] = $data['registrierungsdatum'];
45
+    $this->data['cancel_date'] = $data['kuendigungsdatum'];
46
+  }
47
+
48
+}
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+function get_domain_list($customerno, $uid = NULL)
57
+{
58
+  $customerno = (int) $customerno;
59
+  $query = "SELECT id FROM kundendaten.domains WHERE";
60
+  if ($uid !== NULL)
61
+  {
62
+    $uid = (int) $uid;
63
+    $query .= " useraccount={$uid};";
64
+  }
65
+  else
66
+  {
67
+    $query .= " kunde={$customerno};";
68
+  }
69
+  $result = db_query($query);
70
+  $domains = array();
71
+  DEBUG('Result set is '.mysql_num_rows($result)." rows.<br />\n");
72
+  if (mysql_num_rows($result) > 0)
73
+    while ($domain = mysql_fetch_object($result)->id)
74
+      array_push($domains, new Domain((int) $domain));
75
+  DEBUG($domains);
76
+	return $domains;	
77
+}
78
+
79
+
80
+
81
+function get_jabberable_domains()
82
+{
83
+  require_role(ROLE_CUSTOMER);
84
+  $customerno = (int) $_SESSION['customerinfo']['customerno'];
85
+
86
+  $domains = get_domain_list($customerno);
87
+  DEBUG($domains);
88
+  $result = array( new Domain() );
89
+  $result[0]->id = 0;
90
+  $result[0]->fqdn = "schokokeks.org";
91
+  foreach ($domains as $dom)
92
+  {
93
+    if ($dom->jabber)
94
+      $result[] = $dom;
95
+  }
96
+  return $result;
97
+
98
+}
99
+
100
+?>