b7eab74246d854497836baec51f7eec54467ee04
Bernd Wurst In neues Modul ausgelagert

Bernd Wurst authored 6 years ago

modules/handles/include/handles.php     1) <?php
modules/handles/include/handles.php     2) /*
modules/handles/include/handles.php     3) This file belongs to the Webinterface of schokokeks.org Hosting
modules/handles/include/handles.php     4) 
Bernd Wurst Copyright year update

Bernd Wurst authored 6 years ago

modules/handles/include/handles.php     5) Written 2008-2018 by schokokeks.org Hosting, namely
Bernd Wurst In neues Modul ausgelagert

Bernd Wurst authored 6 years ago

modules/handles/include/handles.php     6)   Bernd Wurst <bernd@schokokeks.org>
modules/handles/include/handles.php     7)   Hanno Böck <hanno@schokokeks.org>
modules/handles/include/handles.php     8) 
modules/handles/include/handles.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.
modules/handles/include/handles.php    10) 
modules/handles/include/handles.php    11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see 
modules/handles/include/handles.php    12) http://creativecommons.org/publicdomain/zero/1.0/
modules/handles/include/handles.php    13) 
modules/handles/include/handles.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.
modules/handles/include/handles.php    15) */
modules/handles/include/handles.php    16) 
modules/handles/include/handles.php    17) require_once('inc/debug.php');
modules/handles/include/handles.php    18) require_role(array(ROLE_CUSTOMER));
modules/handles/include/handles.php    19) 
Bernd Wurst Setzen als Kundenkontakte e...

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php  20) require_once('contactapi.php');
Bernd Wurst API-Funktionen um Kontakte...

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php  21) 
Bernd Wurst $usage ist ein array

Bernd Wurst authored 6 years ago

modules/handles/include/handles.php    22) /*
Bernd Wurst Kontakt kopieren

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php  23) Todo:
modules/contacts/include/contacts.php  24)     - "separate Rechnungsadresse einrichten" / "Zusätzliche Adresse für den Notfall"
modules/contacts/include/contacts.php  25)     - Domaininhaber festlegen    
Bernd Wurst $usage ist ein array

Bernd Wurst authored 6 years ago

modules/handles/include/handles.php    26) */
modules/handles/include/handles.php    27) 
modules/handles/include/handles.php    28) 
Bernd Wurst Vorbereitung für edit/new

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php  29) function new_contact() {
modules/contacts/include/contacts.php  30)     return array("id" => NULL,
modules/contacts/include/contacts.php  31)         "state" => NULL,
modules/contacts/include/contacts.php  32)         "lastchange" => time(),
modules/contacts/include/contacts.php  33)         "nic_handle" => NULL,
modules/contacts/include/contacts.php  34)         "nic_id" => NULL,
modules/contacts/include/contacts.php  35)         "company" => NULL,
modules/contacts/include/contacts.php  36)         "name" => NULL,
modules/contacts/include/contacts.php  37)         "address" => NULL,
modules/contacts/include/contacts.php  38)         "zip" => NULL,
modules/contacts/include/contacts.php  39)         "city" => NULL,
modules/contacts/include/contacts.php  40)         "country" => "DE",
modules/contacts/include/contacts.php  41)         "phone" => NULL,
modules/contacts/include/contacts.php  42)         "mobile" => NULL,
modules/contacts/include/contacts.php  43)         "fax" => NULL,
modules/contacts/include/contacts.php  44)         "email" => NULL,
modules/contacts/include/contacts.php  45)         "pgp_id" => NULL,
modules/contacts/include/contacts.php  46)         "pgp_key" => NULL,
modules/contacts/include/contacts.php  47)         "customer" => $_SESSION['customerinfo']['customerno']);
modules/contacts/include/contacts.php  48) }
modules/contacts/include/contacts.php  49) 
modules/contacts/include/contacts.php  50) 
modules/contacts/include/contacts.php  51) function get_contact($id)
modules/contacts/include/contacts.php  52) {
modules/contacts/include/contacts.php  53)     $args = array(
modules/contacts/include/contacts.php  54)         "cid" => (int) $_SESSION['customerinfo']['customerno'],
modules/contacts/include/contacts.php  55)         "id" => (int) $id);
modules/contacts/include/contacts.php  56)     $result = db_query("SELECT id, state, lastchange, nic_id, nic_handle, company, name, address, zip, city, country, phone, mobile, fax, email, pgp_id, pgp_key FROM kundendaten.contacts WHERE id=:id AND customer=:cid", $args);
modules/contacts/include/contacts.php  57)     if ($result->rowCount() == 0) {
modules/contacts/include/contacts.php  58)         system_failure("Kontakt nicht gefunden oder gehört nicht diesem Kunden");
modules/contacts/include/contacts.php  59)     }
Bernd Wurst Zeige bestehende Daten in d...

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php  60)     $contact = $result->fetch();
Bernd Wurst Vorbereitung für edit/new

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php  61)     return $contact;
modules/contacts/include/contacts.php  62) }
modules/contacts/include/contacts.php  63) 
Bernd Wurst Umbenennung Datenbank handl...

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php  64) function get_contacts() {
Bernd Wurst In neues Modul ausgelagert

Bernd Wurst authored 6 years ago

modules/handles/include/handles.php    65)     $cid = (int) $_SESSION['customerinfo']['customerno'];
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php  66)     $result = db_query("SELECT id, state, lastchange, nic_id, nic_handle, company, name, address, zip, city, country, phone, mobile, fax, email, pgp_id, pgp_key FROM kundendaten.contacts WHERE (state<>'deleted' OR state IS NULL) AND customer=? ORDER BY id", array($cid));
Bernd Wurst In neues Modul ausgelagert

Bernd Wurst authored 6 years ago

modules/handles/include/handles.php    67)     $ret = array();
Bernd Wurst Umbenennung Datenbank handl...

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php  68)     while ($contact = $result->fetch()) {
modules/contacts/include/contacts.php  69)         $ret[$contact['id']] = $contact;
Bernd Wurst In neues Modul ausgelagert

Bernd Wurst authored 6 years ago

modules/handles/include/handles.php    70)     }
modules/handles/include/handles.php    71)     DEBUG($ret);
modules/handles/include/handles.php    72)     return $ret;
modules/handles/include/handles.php    73) }
modules/handles/include/handles.php    74) 
Bernd Wurst Prüfe Telefonnummer

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php  75) 
Bernd Wurst Neue Darstellung der Kontak...

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php  76) function is_domainholder($contactid) {
modules/contacts/include/contacts.php  77)     $contactid = (int) $contactid;
modules/contacts/include/contacts.php  78)     $result = db_query("SELECT id FROM kundendaten.domains WHERE owner=? OR admin_c=?", array($contactid, $contactid));
modules/contacts/include/contacts.php  79)     if ($result->rowCount() > 0) {
modules/contacts/include/contacts.php  80)         return true;
modules/contacts/include/contacts.php  81)     }
modules/contacts/include/contacts.php  82)     return false;
modules/contacts/include/contacts.php  83) }
modules/contacts/include/contacts.php  84) 
Bernd Wurst Prüfe Telefonnummer

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php  85) function possible_domainholders() {
modules/contacts/include/contacts.php  86)     $allcontacts = get_contacts();
modules/contacts/include/contacts.php  87)     $ret = array();
modules/contacts/include/contacts.php  88)     foreach ($allcontacts as $id => $c) {
Bernd Wurst API-Funktionen um Kontakte...

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php  89)         if (possible_domainholder($c)) {
Bernd Wurst Prüfe Telefonnummer

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php  90)             $ret[$id] = $c;
modules/contacts/include/contacts.php  91)         }
modules/contacts/include/contacts.php  92)     }
modules/contacts/include/contacts.php  93)     return $ret;
modules/contacts/include/contacts.php  94) }
modules/contacts/include/contacts.php  95) 
Bernd Wurst API-Funktionen um Kontakte...

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php  96) function possible_domainholder($c)
modules/contacts/include/contacts.php  97) {
modules/contacts/include/contacts.php  98)     if ($c['name'] && $c['address'] && $c['zip'] && $c['city'] && $c['country'] && $c['phone'] && $c['email']) {
modules/contacts/include/contacts.php  99)         return true;
modules/contacts/include/contacts.php 100)     }
modules/contacts/include/contacts.php 101)     return false;
modules/contacts/include/contacts.php 102) }
Bernd Wurst Prüfe Telefonnummer

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php 103) 
Bernd Wurst Speichern der Änderungen mö...

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php 104) function have_mailaddress($email) 
modules/contacts/include/contacts.php 105) {
modules/contacts/include/contacts.php 106)     $cid = (int) $_SESSION['customerinfo']['customerno'];
modules/contacts/include/contacts.php 107)     $result = db_query("SELECT id FROM kundendaten.contacts WHERE customer=? AND email=?", array($cid, $email));
modules/contacts/include/contacts.php 108)     if ($result->rowCount() > 0) {
modules/contacts/include/contacts.php 109)         return true;
modules/contacts/include/contacts.php 110)     }
modules/contacts/include/contacts.php 111)     return false;
modules/contacts/include/contacts.php 112) }
modules/contacts/include/contacts.php 113) 
Bernd Wurst In neues Modul ausgelagert

Bernd Wurst authored 6 years ago

modules/handles/include/handles.php   114) 
Bernd Wurst Setzen als Kundenkontakte e...

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php 115) function possible_kundenkontakt($c) {
modules/contacts/include/contacts.php 116)     if ($c['name'] && $c['email']) {
modules/contacts/include/contacts.php 117)         return true;
modules/contacts/include/contacts.php 118)     }
modules/contacts/include/contacts.php 119) }
modules/contacts/include/contacts.php 120) 
modules/contacts/include/contacts.php 121) 
modules/contacts/include/contacts.php 122) function set_kundenkontakt($typ, $id) {
modules/contacts/include/contacts.php 123)     if (! $id) {
modules/contacts/include/contacts.php 124)         $id = NULL;
modules/contacts/include/contacts.php 125)     } else {
modules/contacts/include/contacts.php 126)         $id = (int) $id;
modules/contacts/include/contacts.php 127)     }
modules/contacts/include/contacts.php 128)     $args = array(
modules/contacts/include/contacts.php 129)         "kunde" => (int) $_SESSION['customerinfo']['customerno'],
modules/contacts/include/contacts.php 130)         "contact" => $id
modules/contacts/include/contacts.php 131)         );
modules/contacts/include/contacts.php 132)     $field = NULL;
modules/contacts/include/contacts.php 133)     if ($typ == 'kunde') {
modules/contacts/include/contacts.php 134)         $field = 'contact_kunde';
modules/contacts/include/contacts.php 135)     } elseif ($typ == 'extern') {
modules/contacts/include/contacts.php 136)         $field = 'contact_extern';
modules/contacts/include/contacts.php 137)     } elseif ($typ == 'rechnung') {
modules/contacts/include/contacts.php 138)         $field = 'contact_rechnung';
modules/contacts/include/contacts.php 139)     } else {
modules/contacts/include/contacts.php 140)         system_failure("Falscher Typ!");
modules/contacts/include/contacts.php 141)     }
modules/contacts/include/contacts.php 142)     db_query("UPDATE kundendaten.kunden SET ".$field."=:contact WHERE id=:kunde", $args);
modules/contacts/include/contacts.php 143) }
modules/contacts/include/contacts.php 144) 
Bernd Wurst Umbenennung Datenbank handl...

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php 145) function get_kundenkontakte() {
Bernd Wurst In neues Modul ausgelagert

Bernd Wurst authored 6 years ago

modules/handles/include/handles.php   146)     $cid = (int) $_SESSION['customerinfo']['customerno'];
Bernd Wurst Umbenennung Datenbank handl...

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php 147)     $result = db_query("SELECT contact_kunde, contact_extern, contact_rechnung FROM kundendaten.kunden WHERE id=?", array($cid));
Bernd Wurst In neues Modul ausgelagert

Bernd Wurst authored 6 years ago

modules/handles/include/handles.php   148)     $res = $result->fetch();
Bernd Wurst Umbenennung Datenbank handl...

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php 149)     $ret = array("kunde" => $res['contact_kunde'],
modules/contacts/include/contacts.php 150)                  "extern" => $res['contact_extern'],
modules/contacts/include/contacts.php 151)                  "rechnung" => $res['contact_rechnung']);
Bernd Wurst In neues Modul ausgelagert

Bernd Wurst authored 6 years ago

modules/handles/include/handles.php   152)     return $ret;
modules/handles/include/handles.php   153) }
modules/handles/include/handles.php   154) 
Bernd Wurst Speichern der Änderungen mö...

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php 155) function save_emailaddress($id, $email) 
modules/contacts/include/contacts.php 156) {
Bernd Wurst Speichere E-Mail-Adresse oh...

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php 157)     // Speichert eine E-Mail-Adresse direkt, z.B. wenn diese schonmal geprüt wurde
modules/contacts/include/contacts.php 158)     $args = array("cid" => (int) $_SESSION['customerinfo']['customerno'],
modules/contacts/include/contacts.php 159)         "id" => (int) $id,
modules/contacts/include/contacts.php 160)         "email" => $email);
modules/contacts/include/contacts.php 161)     db_query("UPDATE kundendaten.contacts SET email=:email WHERE id=:id AND customer=:cid", $args);    
Bernd Wurst Speichern der Änderungen mö...

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php 162) }
modules/contacts/include/contacts.php 163) 
modules/contacts/include/contacts.php 164) function save_contact($c)
modules/contacts/include/contacts.php 165) {
Bernd Wurst API-Funktionen um Kontakte...

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php 166)     if ($c['nic_id']) {
modules/contacts/include/contacts.php 167)         if (! possible_domainholder($c)) {
modules/contacts/include/contacts.php 168)             system_failure("Sie haben ein Feld geleert, das für die Eigenschaft als Domaininhaber erhalten bleiben muss. Ihre Änderungen wurden nicht gespeichert.");
modules/contacts/include/contacts.php 169)         }
modules/contacts/include/contacts.php 170)     }
Bernd Wurst Speichern der Änderungen mö...

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php 171)     for ($i=0;array_key_exists($i, $c);$i++) {
modules/contacts/include/contacts.php 172)         unset($c[$i]);
modules/contacts/include/contacts.php 173)     }
modules/contacts/include/contacts.php 174)     unset($c['state']);
modules/contacts/include/contacts.php 175)     unset($c['lastchange']);
modules/contacts/include/contacts.php 176)     unset($c['email']);
modules/contacts/include/contacts.php 177)     $c['customer'] = (int) $_SESSION['customerinfo']['customerno'];
modules/contacts/include/contacts.php 178)     if ($c['id']) {
modules/contacts/include/contacts.php 179)         // Kontakt bestaht schon, Update
Bernd Wurst API-Funktionen um Kontakte...

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php 180)         db_query("UPDATE kundendaten.contacts SET nic_id=:nic_id, nic_handle=:nic_handle, company=:company, name=:name, address=:address, zip=:zip, city=:city, country=:country, phone=:phone, mobile=:mobile, fax=:fax, pgp_id=:pgp_id, pgp_key=:pgp_key WHERE id=:id AND customer=:customer", $c);
Bernd Wurst Speichern der Änderungen mö...

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php 181)     } else {
modules/contacts/include/contacts.php 182)         unset($c['id']);
modules/contacts/include/contacts.php 183)         // Neu anlegen
Bernd Wurst API-Funktionen um Kontakte...

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php 184)         db_query("INSERT INTO kundendaten.contacts (nic_id, nic_handle, customer, company, name, address, zip, city, country, phone, mobile, fax, pgp_id, pgp_key) VALUES (:nic_id, :nic_handle, :customer, :company, :name, :address, :zip, :city, :country, :phone, :mobile, :fax, :pgp_id, :pgp_key)", $c);
Bernd Wurst Speichern der Änderungen mö...

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php 185)         $c['id'] = db_insert_id();
modules/contacts/include/contacts.php 186)     }
modules/contacts/include/contacts.php 187)     return $c['id'];
modules/contacts/include/contacts.php 188) }
modules/contacts/include/contacts.php 189) 
modules/contacts/include/contacts.php 190) 
modules/contacts/include/contacts.php 191) function send_emailchange_token($id, $email)
modules/contacts/include/contacts.php 192) {
modules/contacts/include/contacts.php 193)     if (! check_emailaddr($email)) {
modules/contacts/include/contacts.php 194)         system_falure("Die E-Mail-Adresse scheint nicht gültig zu sein.");
modules/contacts/include/contacts.php 195)     }
modules/contacts/include/contacts.php 196)     $args = array("id" => (int) $id,
modules/contacts/include/contacts.php 197)         "email" => $email,
modules/contacts/include/contacts.php 198)         "token" => random_string(20));
modules/contacts/include/contacts.php 199) 
modules/contacts/include/contacts.php 200)     db_query("INSERT INTO kundendaten.mailaddress_token (token, expire, contact, email) VALUES (:token, NOW() + INTERVAL 1 DAY, :id, :email)" , $args);
modules/contacts/include/contacts.php 201)     DEBUG('Token erzeugt: '.print_r($args, true));
modules/contacts/include/contacts.php 202)     $message = 'Diese E-Mail-Adresse wurde angegeben als möglicher Domaininhaber oder Kundenkontakt bei schokokeks.org Hosting.
modules/contacts/include/contacts.php 203) 
modules/contacts/include/contacts.php 204) Bitte bestätigen Sie mit einem Klick auf den nachfolgenden Link, dass diese E-Mail-Adresse funktioniert und verwendet werden soll:
modules/contacts/include/contacts.php 205) 
modules/contacts/include/contacts.php 206)     '.config('webinterface_url').'/verify'.$args['token'].'
modules/contacts/include/contacts.php 207) 
modules/contacts/include/contacts.php 208) Wenn Sie diesen Link nicht innerhalb von 24 Stunden abrufen, wird Ihre Adresse gelöscht und nicht verwendet.
modules/contacts/include/contacts.php 209) Sollten Sie mit der Verwendung Ihrer E-Mail-Adresse nicht einverstanden sein, so ignorieren Sie daher bitte diese Nachricht oder teilen Sie uns dies mit.
modules/contacts/include/contacts.php 210) 
modules/contacts/include/contacts.php 211) -- 
modules/contacts/include/contacts.php 212) schokokeks.org GbR, Bernd Wurst, Johannes Böck
modules/contacts/include/contacts.php 213) Köchersberg 32, 71540 Murrhardt
modules/contacts/include/contacts.php 214) 
modules/contacts/include/contacts.php 215) https://schokokeks.org
modules/contacts/include/contacts.php 216) ';
modules/contacts/include/contacts.php 217)     # send welcome message
modules/contacts/include/contacts.php 218)     mail($email, '=?UTF-8?Q?Best=C3=A4tigung_Ihrer_E-Mail-Adresse?=', $message, "X-schokokeks-org-message: verify\nFrom: ".config('company_name').' <'.config('adminmail').">\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\n");
modules/contacts/include/contacts.php 219)  
modules/contacts/include/contacts.php 220) }
Bernd Wurst E-Mail-Adresse verifizieren...

Bernd Wurst authored 6 years ago

modules/handles/include/handles.php   221) 
Bernd Wurst Umbenennung Datenbank handl...

Bernd Wurst authored 6 years ago

modules/contacts/include/contacts.php 222) function update_pending($contactid) {
modules/contacts/include/contacts.php 223)     $contactid = (int) $contactid;
modules/contacts/include/contacts.php 224)     $result = db_query("SELECT email FROM kundendaten.mailaddress_token WHERE contact=?", array($contactid));
Bernd Wurst E-Mail-Adresse verifizieren...

Bernd Wurst authored 6 years ago

modules/handles/include/handles.php   225)     if ($result->rowCount() == 0) {
modules/handles/include/handles.php   226)         return NULL;
modules/handles/include/handles.php   227)     }
modules/handles/include/handles.php   228)     $res = $result->fetch();
modules/handles/include/handles.php   229)     return $res['email'];
modules/handles/include/handles.php   230) }
modules/handles/include/handles.php   231) 
modules/handles/include/handles.php   232) 
modules/handles/include/handles.php   233)