5ab95643fb464dabda4cc9e9a930188d4f17d369
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) 
Bernd Wurst Copyright year update

Bernd Wurst authored 6 years ago

class/domain.php    5) Written 2008-2018 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) 
class/domain.php    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.
class/domain.php   10) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

class/domain.php   11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

class/domain.php   12) http://creativecommons.org/publicdomain/zero/1.0/
class/domain.php   13) 
class/domain.php   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.
class/domain.php   15) */
bernd Ein paar neue Klassen

bernd authored 17 years ago

class/domains.php  16) 
class/domains.php  17) require_once('inc/base.php');
class/domains.php  18) require_once('inc/debug.php');
class/domains.php  19) 
class/domains.php  20) 
Bernd Wurst Alte Klassen entfernt

Bernd Wurst authored 6 years ago

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

bernd authored 17 years ago

class/domains.php  22) {
Bernd Wurst Alte Klassen entfernt

Bernd Wurst authored 6 years ago

class/domain.php   23)     protected $data = array();
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

bernd authored 17 years ago

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

Hanno authored 6 years ago

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

bernd authored 17 years ago

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

Bernd Wurst authored 6 years ago

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

Hanno authored 6 years ago

class/domain.php   38) 
class/domain.php   39)     public function __set($key, $value)
class/domain.php   40)     {
class/domain.php   41)         if (array_key_exists($key, $this->data)) {
class/domain.php   42)             $this->data[$key] = $value;
class/domain.php   43)         } elseif (isset($this->$key)) {
class/domain.php   44)             $this->$key = $value;
class/domain.php   45)         } else {
class/domain.php   46)             $this->data[$key] = $value;
class/domain.php   47)         }
class/domain.php   48)     }
class/domain.php   49) 
class/domain.php   50) 
class/domain.php   51)     public function __get($key)
class/domain.php   52)     {
class/domain.php   53)         if (array_key_exists($key, $this->data)) {
class/domain.php   54)             return $this->data[$key];
class/domain.php   55)         } elseif (isset($this->$key)) {
class/domain.php   56)             return $this->$key;
class/domain.php   57)         }
class/domain.php   58)         // else werfe fehler
class/domain.php   59)     }
class/domain.php   60) 
class/domain.php   61) 
class/domain.php   62)     public function loadByID($id)
class/domain.php   63)     {
class/domain.php   64)         $res = db_query("SELECT * FROM kundendaten.domains WHERE id=?", array($id));
class/domain.php   65)         if ($res->rowCount() < 1) {
class/domain.php   66)             return false;
class/domain.php   67)         }
class/domain.php   68)         $data = $res->fetch();
class/domain.php   69)         $this->parse($data);
class/domain.php   70)     }
class/domain.php   71) 
class/domain.php   72)     public function loadByName($name)
class/domain.php   73)     {
class/domain.php   74)         $raw = $name;
class/domain.php   75)         $utf8 = idn_to_utf8($raw, 0, INTL_IDNA_VARIANT_UTS46);
class/domain.php   76)         $res = db_query("SELECT * FROM kundendaten.domains WHERE CONCAT_WS('.', domainname, tld)=? OR CONCAT_WS('.', domainname, tld)=?", array($raw, $utf8));
class/domain.php   77)         if ($res->rowCount() < 1) {
class/domain.php   78)             return false;
class/domain.php   79)         }
class/domain.php   80)         $data = $res->fetch();
class/domain.php   81)         $this->parse($data);
class/domain.php   82)     }
class/domain.php   83) 
class/domain.php   84)     public function ensure_customerdomain()
class/domain.php   85)     {
class/domain.php   86)         if (! $this->is_customerdomain()) {
class/domain.php   87)             system_failure('Diese Domain gehört nicht Ihrem Kundenaccount.');
class/domain.php   88)         }
class/domain.php   89)     }
class/domain.php   90) 
class/domain.php   91)     public function ensure_userdomain()
class/domain.php   92)     {
class/domain.php   93)         if (! $this->is_userdomain()) {
class/domain.php   94)             system_failure('Diese Domain gehört nicht Ihrem Benutzeraccount.');
class/domain.php   95)         }
class/domain.php   96)     }
class/domain.php   97) 
class/domain.php   98)     public function is_customerdomain()
Bernd Wurst Alte Klassen entfernt

Bernd Wurst authored 6 years ago

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

Hanno authored 6 years ago

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

Bernd Wurst authored 6 years ago

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

Hanno authored 6 years ago

class/domain.php  107)     public function is_userdomain()
class/domain.php  108)     {
class/domain.php  109)         if (! isset($_SESSION['userinfo'])) {
class/domain.php  110)             return false;
class/domain.php  111)         }
class/domain.php  112)         $uid = (int) $_SESSION['userinfo']['uid'];
class/domain.php  113)         return ($this->useraccount == $uid);
class/domain.php  114)     }
class/domain.php  115) 
class/domain.php  116)     public function setup()
class/domain.php  117)     {
class/domain.php  118)         $fields = array();
class/domain.php  119)         $res = db_query("DESCRIBE kundendaten.domains");
class/domain.php  120)         while ($f = $res->fetch(PDO::FETCH_OBJ)) {
class/domain.php  121)             $fields[$f->Field] = $f->Default;
class/domain.php  122)         }
class/domain.php  123)         $this->data = $fields;
class/domain.php  124)         $this->data['id'] = null;
class/domain.php  125)     }
Bernd Wurst Alte Klassen entfernt

Bernd Wurst authored 6 years ago

class/domain.php  126) 
class/domain.php  127) 
bernd Ein paar neue Klassen

bernd authored 17 years ago

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

Hanno authored 6 years ago

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

bernd authored 17 years ago

class/domains.php 143) }
class/domains.php 144) 
class/domains.php 145) 
class/domains.php 146) 
class/domains.php 147) 
class/domains.php 148) 
class/domains.php 149) 
class/domains.php 150) 
Bernd Wurst Übergebe keine Kundennummer...

Bernd Wurst authored 5 years ago

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

bernd authored 17 years ago

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

Bernd Wurst authored 5 years ago

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

Hanno authored 6 years ago

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

Bernd Wurst authored 5 years ago

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

Hanno authored 6 years ago

class/domain.php  163)         $query .= " kunde={$customerno}";
class/domain.php  164)     }
class/domain.php  165)     $query .= " ORDER BY domainname,tld";
class/domain.php  166)     $result = db_query($query, array()); // FIXME Übergebe leeren array um die Warnung zu unterdrücken
class/domain.php  167)     $domains = array();
class/domain.php  168)     DEBUG('Result set is '.$result->rowCount()." rows.<br />\n");
class/domain.php  169)     if ($result->rowCount() > 0) {
class/domain.php  170)         while ($domain = $result->fetch(PDO::FETCH_OBJ)) {
class/domain.php  171)             array_push($domains, new Domain((int) $domain->id));
class/domain.php  172)         }
class/domain.php  173)     }
class/domain.php  174)     DEBUG($domains);
class/domain.php  175)     return $domains;
bernd Ein paar neue Klassen

bernd authored 17 years ago

class/domains.php 176) }
class/domains.php 177) 
class/domains.php 178) 
class/domains.php 179) 
class/domains.php 180) function get_jabberable_domains()
class/domains.php 181) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

bernd authored 17 years ago

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

Hanno authored 6 years ago

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