dcc202fb249a446ac15c7cf413b9f1b4a3f31b58
bernd Ein paar neue Klassen

bernd authored 17 years ago

class/domains.php   1) <?php
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

class/domain.php    2) /*
class/domain.php    3) This file belongs to the Webinterface of schokokeks.org Hosting
class/domain.php    4) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 2 years ago

class/domain.php    5) Written by schokokeks.org Hosting, namely
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

class/domain.php    6)   Bernd Wurst <bernd@schokokeks.org>
class/domain.php    7)   Hanno Böck <hanno@schokokeks.org>
class/domain.php    8) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 2 years ago

class/domain.php    9) This code is published under a 0BSD license.
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

class/domain.php   10) 
class/domain.php   11) 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.
class/domain.php   12) */
bernd Ein paar neue Klassen

bernd authored 17 years ago

class/domains.php  13) 
class/domains.php  14) require_once('inc/base.php');
class/domains.php  15) require_once('inc/debug.php');
class/domains.php  16) 
class/domains.php  17) 
Bernd Wurst Alte Klassen entfernt

Bernd Wurst authored 6 years ago

class/domain.php   18) class Domain
bernd Ein paar neue Klassen

bernd authored 17 years ago

class/domains.php  19) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

class/domain.php   20)     protected $data = [];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

class/domain.php   21)     public function __construct($init = null)
bernd Ein paar neue Klassen

bernd authored 17 years ago

class/domains.php  22)     {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

class/domain.php   23)         $this->setup();
class/domain.php   24)         switch (gettype($init)) {
bernd Ein paar neue Klassen

bernd authored 17 years ago

class/domains.php  25)       case 'string':
class/domains.php  26)         $this->loadByName($init);
class/domains.php  27)         break;
class/domains.php  28)       case 'integer':
class/domains.php  29)         $this->loadByID($init);
class/domains.php  30)         break;
class/domains.php  31)       case 'NULL':
class/domains.php  32)         break;
class/domains.php  33)     }
Bernd Wurst Alte Klassen entfernt

Bernd Wurst authored 6 years ago

class/domain.php   34)     }
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

class/domain.php   35) 
class/domain.php   36)     public function __set($key, $value)
class/domain.php   37)     {
class/domain.php   38)         if (array_key_exists($key, $this->data)) {
class/domain.php   39)             $this->data[$key] = $value;
class/domain.php   40)         } elseif (isset($this->$key)) {
class/domain.php   41)             $this->$key = $value;
class/domain.php   42)         } else {
class/domain.php   43)             $this->data[$key] = $value;
class/domain.php   44)         }
class/domain.php   45)     }
class/domain.php   46) 
class/domain.php   47) 
class/domain.php   48)     public function __get($key)
class/domain.php   49)     {
class/domain.php   50)         if (array_key_exists($key, $this->data)) {
class/domain.php   51)             return $this->data[$key];
class/domain.php   52)         } elseif (isset($this->$key)) {
class/domain.php   53)             return $this->$key;
class/domain.php   54)         }
class/domain.php   55)         // else werfe fehler
class/domain.php   56)     }
class/domain.php   57) 
class/domain.php   58) 
class/domain.php   59)     public function loadByID($id)
class/domain.php   60)     {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

class/domain.php   61)         $res = db_query("SELECT * FROM kundendaten.domains WHERE id=?", [$id]);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

class/domain.php   62)         if ($res->rowCount() < 1) {
class/domain.php   63)             return false;
class/domain.php   64)         }
class/domain.php   65)         $data = $res->fetch();
class/domain.php   66)         $this->parse($data);
class/domain.php   67)     }
class/domain.php   68) 
class/domain.php   69)     public function loadByName($name)
class/domain.php   70)     {
class/domain.php   71)         $raw = $name;
class/domain.php   72)         $utf8 = idn_to_utf8($raw, 0, INTL_IDNA_VARIANT_UTS46);
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

class/domain.php   73)         $res = db_query("SELECT * FROM kundendaten.domains WHERE CONCAT_WS('.', domainname, tld)=? OR CONCAT_WS('.', domainname, tld)=?", [$raw, $utf8]);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

class/domain.php   74)         if ($res->rowCount() < 1) {
class/domain.php   75)             return false;
class/domain.php   76)         }
class/domain.php   77)         $data = $res->fetch();
class/domain.php   78)         $this->parse($data);
class/domain.php   79)     }
class/domain.php   80) 
class/domain.php   81)     public function ensure_customerdomain()
class/domain.php   82)     {
class/domain.php   83)         if (! $this->is_customerdomain()) {
class/domain.php   84)             system_failure('Diese Domain gehört nicht Ihrem Kundenaccount.');
class/domain.php   85)         }
class/domain.php   86)     }
class/domain.php   87) 
class/domain.php   88)     public function ensure_userdomain()
class/domain.php   89)     {
class/domain.php   90)         if (! $this->is_userdomain()) {
class/domain.php   91)             system_failure('Diese Domain gehört nicht Ihrem Benutzeraccount.');
class/domain.php   92)         }
class/domain.php   93)     }
class/domain.php   94) 
class/domain.php   95)     public function is_customerdomain()
Bernd Wurst Alte Klassen entfernt

Bernd Wurst authored 6 years ago

class/domain.php   96)     {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

class/domain.php   97)         if (! isset($_SESSION['customerinfo'])) {
class/domain.php   98)             return false;
class/domain.php   99)         }
class/domain.php  100)         $customerno = (int) $_SESSION['customerinfo']['customerno'];
class/domain.php  101)         return ($this->kunde == $customerno);
Bernd Wurst Alte Klassen entfernt

Bernd Wurst authored 6 years ago

class/domain.php  102)     }
class/domain.php  103) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

class/domain.php  104)     public function is_userdomain()
class/domain.php  105)     {
class/domain.php  106)         if (! isset($_SESSION['userinfo'])) {
class/domain.php  107)             return false;
class/domain.php  108)         }
class/domain.php  109)         $uid = (int) $_SESSION['userinfo']['uid'];
class/domain.php  110)         return ($this->useraccount == $uid);
class/domain.php  111)     }
class/domain.php  112) 
class/domain.php  113)     public function setup()
class/domain.php  114)     {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

class/domain.php  115)         $fields = [];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

class/domain.php  116)         $res = db_query("DESCRIBE kundendaten.domains");
class/domain.php  117)         while ($f = $res->fetch(PDO::FETCH_OBJ)) {
class/domain.php  118)             $fields[$f->Field] = $f->Default;
class/domain.php  119)         }
class/domain.php  120)         $this->data = $fields;
class/domain.php  121)         $this->data['id'] = null;
class/domain.php  122)     }
Bernd Wurst Alte Klassen entfernt

Bernd Wurst authored 6 years ago

class/domain.php  123) 
class/domain.php  124) 
bernd Ein paar neue Klassen

bernd authored 17 years ago

class/domains.php 125) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

class/domain.php  126)     public function parse($data)
class/domain.php  127)     {
class/domain.php  128)         DEBUG($data);
class/domain.php  129)         foreach (array_keys($this->data) as $key) {
class/domain.php  130)             if (array_key_exists($key, $data)) {
class/domain.php  131)                 $this->data[$key] = $data[$key];
class/domain.php  132)             }
class/domain.php  133)         }
class/domain.php  134)         $this->data['fqdn'] = $data['domainname'].'.'.$data['tld'];
class/domain.php  135)         $this->data['punycode'] = idn_to_ascii($this->data['fqdn'], 0, INTL_IDNA_VARIANT_UTS46);
class/domain.php  136)         $this->data['is_idn'] = ($this->data['fqdn'] != $this->data['punycode']);
class/domain.php  137)         $this->data['reg_date'] = $data['registrierungsdatum'];
class/domain.php  138)         $this->data['cancel_date'] = $data['kuendigungsdatum'];
class/domain.php  139)     }
bernd Ein paar neue Klassen

bernd authored 17 years ago

class/domains.php 140) }
class/domains.php 141) 
class/domains.php 142) 
class/domains.php 143) 
class/domains.php 144) 
class/domains.php 145) 
class/domains.php 146) 
class/domains.php 147) 
Bernd Wurst Übergebe keine Kundennummer...

Bernd Wurst authored 5 years ago

class/domain.php  148) function get_domain_list($customerno = null, $uid = null)
bernd Ein paar neue Klassen

bernd authored 17 years ago

class/domains.php 149) {
Bernd Wurst Übergebe keine Kundennummer...

Bernd Wurst authored 5 years ago

class/domain.php  150)     if ($customerno == null && $uid === null) {
class/domain.php  151)         DEBUG('get_domain_list() wurde aufgerufen mit leerem Kunde und leerem User!');
class/domain.php  152)         system_failure('Interner Fehler');
class/domain.php  153)     }
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

class/domain.php  154)     $query = "SELECT id FROM kundendaten.domains WHERE";
class/domain.php  155)     if ($uid !== null) {
class/domain.php  156)         $uid = (int) $uid;
class/domain.php  157)         $query .= " useraccount={$uid}";
class/domain.php  158)     } else {
Bernd Wurst Übergebe keine Kundennummer...

Bernd Wurst authored 5 years ago

class/domain.php  159)         $customerno = (int) $customerno;
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

class/domain.php  160)         $query .= " kunde={$customerno}";
class/domain.php  161)     }
class/domain.php  162)     $query .= " ORDER BY domainname,tld";
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

class/domain.php  163)     $result = db_query($query, []); // FIXME Übergebe leeren array um die Warnung zu unterdrücken
class/domain.php  164)     $domains = [];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

class/domain.php  165)     DEBUG('Result set is '.$result->rowCount()." rows.<br />\n");
class/domain.php  166)     if ($result->rowCount() > 0) {
class/domain.php  167)         while ($domain = $result->fetch(PDO::FETCH_OBJ)) {
class/domain.php  168)             array_push($domains, new Domain((int) $domain->id));
class/domain.php  169)         }
class/domain.php  170)     }
class/domain.php  171)     DEBUG($domains);
class/domain.php  172)     return $domains;
bernd Ein paar neue Klassen

bernd authored 17 years ago

class/domains.php 173) }
class/domains.php 174) 
class/domains.php 175) 
class/domains.php 176) 
class/domains.php 177) function get_jabberable_domains()
class/domains.php 178) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

class/domain.php  179)     require_role(ROLE_CUSTOMER);
class/domain.php  180)     $customerno = (int) $_SESSION['customerinfo']['customerno'];
bernd Ein paar neue Klassen

bernd authored 17 years ago

class/domains.php 181) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

class/domain.php  182)     $domains = get_domain_list($customerno);
class/domain.php  183)     DEBUG($domains);
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

class/domain.php  184)     $result = [ new Domain() ];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

class/domain.php  185)     $result[0]->id = 0;
class/domain.php  186)     $result[0]->fqdn = config('masterdomain');
class/domain.php  187)     foreach ($domains as $dom) {
class/domain.php  188)         if ($dom->jabber) {
class/domain.php  189)             $result[] = $dom;
class/domain.php  190)         }
class/domain.php  191)     }
class/domain.php  192)     return $result;