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 @@ function list_system_users()
20 20
 
21 21
     $result = db_query("SELECT uid,username FROM system.v_useraccounts ORDER BY username");
22 22
 
23
-    $ret = array();
23
+    $ret = [];
24 24
     while ($item = $result->fetch(PDO::FETCH_OBJ)) {
25 25
         array_push($ret, $item);
26 26
     }
... ...
@@ -34,7 +34,7 @@ function list_customers()
34 34
 
35 35
     $result = db_query("SELECT id, IF(firma IS NULL, CONCAT_WS(' ', vorname, nachname), CONCAT(firma, ' (', CONCAT_WS(' ', vorname, nachname), ')')) AS name FROM kundendaten.kunden");
36 36
 
37
-    $ret = array();
37
+    $ret = [];
38 38
     while ($item = $result->fetch(PDO::FETCH_OBJ)) {
39 39
         array_push($ret, $item);
40 40
     }
... ...
@@ -44,7 +44,7 @@ function list_customers()
44 44
 function customer_details($id)
45 45
 {
46 46
     $id = (int) $id;
47
-    $result = db_query("SELECT id, IF(firma IS NULL, CONCAT_WS(' ', vorname, nachname), CONCAT(firma, ' (', CONCAT_WS(' ', vorname, nachname), ')')) AS name FROM kundendaten.kunden WHERE id=?", array($id));
47
+    $result = db_query("SELECT id, IF(firma IS NULL, CONCAT_WS(' ', vorname, nachname), CONCAT(firma, ' (', CONCAT_WS(' ', vorname, nachname), ')')) AS name FROM kundendaten.kunden WHERE id=?", [$id]);
48 48
     if ($result->rowCount() < 1) {
49 49
         return null;
50 50
     }
... ...
@@ -55,8 +55,8 @@ function customer_details($id)
55 55
 
56 56
 function find_customers($string)
57 57
 {
58
-    $args = array(":string" => '%'.chop($string).'%', ":number" => $string);
59
-    $return = array();
58
+    $args = [":string" => '%'.chop($string).'%', ":number" => $string];
59
+    $return = [];
60 60
     $result = db_query("SELECT k.id FROM kundendaten.kunden AS k LEFT JOIN system.useraccounts AS u ON (k.id=u.kunde) WHERE ".
61 61
                      "firma LIKE :string OR firma2 LIKE :string OR ".
62 62
                      "nachname LIKE :string OR vorname LIKE :string OR ".
... ...
@@ -85,9 +85,9 @@ function find_customers($string)
85 85
 function find_users_for_customer($id)
86 86
 {
87 87
     $id = (int) $id;
88
-    $return = array();
88
+    $return = [];
89 89
     $result = db_query("SELECT uid, username, name FROM system.useraccounts WHERE ".
90
-                     "kunde=?", array($id));
90
+                     "kunde=?", [$id]);
91 91
     while ($entry = $result->fetch()) {
92 92
         $return[] = $entry;
93 93
     }
... ...
@@ -101,14 +101,14 @@ function find_users_for_customer($id)
101 101
 function build_results($term)
102 102
 {
103 103
     global $ret;
104
-    $ret = array();
104
+    $ret = [];
105 105
 
106 106
     $add = function ($val, $id, $value) {
107 107
         global $ret;
108 108
         if (isset($ret[$val]) && is_array($ret[$val])) {
109
-            array_push($ret[$val], array("id" => $id, "value" => $value));
109
+            array_push($ret[$val], ["id" => $id, "value" => $value]);
110 110
         } else {
111
-            $ret[$val] = array( array("id" => $id, "value" => $value) );
111
+            $ret[$val] = [ ["id" => $id, "value" => $value] ];
112 112
         }
113 113
     };
114 114
 
... ...
@@ -142,7 +142,7 @@ function build_results($term)
142 142
 
143 143
     ksort($ret);
144 144
 
145
-    $allentries = array();
145
+    $allentries = [];
146 146
     foreach ($ret as $group) {
147 147
         usort($group, function ($a, $b) {
148 148
             return strnatcmp($a['value'], $b['value']);
Browse code

remove whitespace in empty lines

Hanno authored on 26/06/2018 23:36:40
Showing 1 changed files
... ...
@@ -19,7 +19,7 @@ function list_system_users()
19 19
     require_role(ROLE_SYSADMIN);
20 20
 
21 21
     $result = db_query("SELECT uid,username FROM system.v_useraccounts ORDER BY username");
22
-  
22
+
23 23
     $ret = array();
24 24
     while ($item = $result->fetch(PDO::FETCH_OBJ)) {
25 25
         array_push($ret, $item);
... ...
@@ -33,7 +33,7 @@ function list_customers()
33 33
     require_role(ROLE_SYSADMIN);
34 34
 
35 35
     $result = db_query("SELECT id, IF(firma IS NULL, CONCAT_WS(' ', vorname, nachname), CONCAT(firma, ' (', CONCAT_WS(' ', vorname, nachname), ')')) AS name FROM kundendaten.kunden");
36
-  
36
+
37 37
     $ret = array();
38 38
     while ($item = $result->fetch(PDO::FETCH_OBJ)) {
39 39
         array_push($ret, $item);
... ...
@@ -102,7 +102,7 @@ function build_results($term)
102 102
 {
103 103
     global $ret;
104 104
     $ret = array();
105
-  
105
+
106 106
     $add = function ($val, $id, $value) {
107 107
         global $ret;
108 108
         if (isset($ret[$val]) && is_array($ret[$val])) {
... ...
@@ -141,7 +141,7 @@ function build_results($term)
141 141
     }
142 142
 
143 143
     ksort($ret);
144
-  
144
+
145 145
     $allentries = array();
146 146
     foreach ($ret as $group) {
147 147
         usort($group, function ($a, $b) {
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.
... ...
@@ -16,46 +16,48 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
16 16
 
17 17
 function list_system_users()
18 18
 {
19
-  require_role(ROLE_SYSADMIN);
19
+    require_role(ROLE_SYSADMIN);
20 20
 
21
-  $result = db_query("SELECT uid,username FROM system.v_useraccounts ORDER BY username");
21
+    $result = db_query("SELECT uid,username FROM system.v_useraccounts ORDER BY username");
22 22
   
23
-  $ret = array();
24
-  while ($item = $result->fetch(PDO::FETCH_OBJ))
25
-    array_push($ret, $item);
26
-  return $ret;
23
+    $ret = array();
24
+    while ($item = $result->fetch(PDO::FETCH_OBJ)) {
25
+        array_push($ret, $item);
26
+    }
27
+    return $ret;
27 28
 }
28 29
 
29 30
 
30 31
 function list_customers()
31 32
 {
32
-  require_role(ROLE_SYSADMIN);
33
+    require_role(ROLE_SYSADMIN);
33 34
 
34
-  $result = db_query("SELECT id, IF(firma IS NULL, CONCAT_WS(' ', vorname, nachname), CONCAT(firma, ' (', CONCAT_WS(' ', vorname, nachname), ')')) AS name FROM kundendaten.kunden");
35
+    $result = db_query("SELECT id, IF(firma IS NULL, CONCAT_WS(' ', vorname, nachname), CONCAT(firma, ' (', CONCAT_WS(' ', vorname, nachname), ')')) AS name FROM kundendaten.kunden");
35 36
   
36
-  $ret = array();
37
-  while ($item = $result->fetch(PDO::FETCH_OBJ))
38
-    array_push($ret, $item);
39
-  return $ret;
37
+    $ret = array();
38
+    while ($item = $result->fetch(PDO::FETCH_OBJ)) {
39
+        array_push($ret, $item);
40
+    }
41
+    return $ret;
40 42
 }
41 43
 
42
-function customer_details($id) 
44
+function customer_details($id)
43 45
 {
44
-    $id = (int) $id; 
46
+    $id = (int) $id;
45 47
     $result = db_query("SELECT id, IF(firma IS NULL, CONCAT_WS(' ', vorname, nachname), CONCAT(firma, ' (', CONCAT_WS(' ', vorname, nachname), ')')) AS name FROM kundendaten.kunden WHERE id=?", array($id));
46 48
     if ($result->rowCount() < 1) {
47
-        return NULL;
49
+        return null;
48 50
     }
49 51
     $kunde = $result->fetch();
50 52
     return $kunde;
51 53
 }
52 54
 
53 55
 
54
-function find_customers($string) 
56
+function find_customers($string)
55 57
 {
56
-  $args = array(":string" => '%'.chop($string).'%', ":number" => $string);
57
-  $return = array();
58
-  $result = db_query("SELECT k.id FROM kundendaten.kunden AS k LEFT JOIN system.useraccounts AS u ON (k.id=u.kunde) WHERE ".
58
+    $args = array(":string" => '%'.chop($string).'%', ":number" => $string);
59
+    $return = array();
60
+    $result = db_query("SELECT k.id FROM kundendaten.kunden AS k LEFT JOIN system.useraccounts AS u ON (k.id=u.kunde) WHERE ".
59 61
                      "firma LIKE :string OR firma2 LIKE :string OR ".
60 62
                      "nachname LIKE :string OR vorname LIKE :string OR ".
61 63
                      "adresse LIKE :string OR adresse2 LIKE :string OR ".
... ...
@@ -63,118 +65,123 @@ function find_customers($string)
63 65
                      "notizen LIKE :string OR email_rechnung LIKE :string OR ".
64 66
                      "email LIKE :string OR email_extern LIKE :string OR u.name LIKE :string OR ".
65 67
                      "u.username LIKE :string OR k.id=:number OR u.uid=:number", $args);
66
-  while ($entry = $result->fetch())
67
-    $return[] = $entry['id'];
68
+    while ($entry = $result->fetch()) {
69
+        $return[] = $entry['id'];
70
+    }
68 71
 
69
-  unset($args[':number']);
70
-  $result = db_query("SELECT kunde FROM kundendaten.domains WHERE kunde IS NOT NULL AND (
72
+    unset($args[':number']);
73
+    $result = db_query("SELECT kunde FROM kundendaten.domains WHERE kunde IS NOT NULL AND (
71 74
                       domainname LIKE :string OR CONCAT_WS('.', domainname, tld) LIKE :string
72 75
                       )", $args);
73 76
 
74
-  while ($entry = $result->fetch())
75
-    $return[] = $entry['kunde'];
77
+    while ($entry = $result->fetch()) {
78
+        $return[] = $entry['kunde'];
79
+    }
76 80
 
77
-  return $return;
81
+    return $return;
78 82
 }
79 83
 
80 84
 
81 85
 function find_users_for_customer($id)
82 86
 {
83
-  $id = (int) $id;
84
-  $return = array();
85
-  $result = db_query("SELECT uid, username, name FROM system.useraccounts WHERE ".
87
+    $id = (int) $id;
88
+    $return = array();
89
+    $result = db_query("SELECT uid, username, name FROM system.useraccounts WHERE ".
86 90
                      "kunde=?", array($id));
87
-  while ($entry = $result->fetch())
88
-    $return[] = $entry;
91
+    while ($entry = $result->fetch()) {
92
+        $return[] = $entry;
93
+    }
89 94
 
90
-  return $return;
95
+    return $return;
91 96
 }
92 97
 
93 98
 
94 99
 
95 100
 
96
-function build_results($term) {
97
-  global $ret;
98
-  $ret = array();
99
-  
100
-  $add = function($val, $id, $value) {
101
+function build_results($term)
102
+{
101 103
     global $ret;
102
-    if (isset($ret[$val]) && is_array($ret[$val])) {
103
-      array_push($ret[$val], array("id" => $id, "value" => $value));
104
-    } else {
105
-      $ret[$val] = array( array("id" => $id, "value" => $value) );
106
-    }
107
-  };
108
-
109
-
110
-  $result = array_unique(find_customers($term));
111
-  sort($result);
112
-  foreach ($result as $val) {
113
-    $c = customer_details($val);
114
-    if ($c['id'] == $term) {
115
-      $add(10, "c{$c['id']}", "Kunde {$c['id']}: {$c['name']}");
116
-    } else {
117
-      $add(90, "c{$c['id']}", "Kunde {$c['id']}: {$c['name']}");
118
-    }
119
-    $users = find_users_for_customer($c['id']);
120
-    foreach ($users as $u) {
121
-      $realname = $c['name'];
122
-      if ($u['name']) {
123
-        $realname = $u['name'];
124
-      }
125
-      if ($u['uid'] == $term || $u['username'] == $term) {
126
-        $add(15, "u{$u['uid']}", "{$u['username']} (UID {$u['uid']}, {$realname})");
127
-      } elseif (strstr($u['username'], $term)) {
128
-        $add(20, "u{$u['uid']}", "{$u['username']} (UID {$u['uid']}, {$realname})");
129
-      } elseif (stristr($u['name'], $term)) {
130
-        $add(25, "u{$u['uid']}", "{$u['username']} (UID {$u['uid']}, {$realname})");
131
-      } else {
132
-        $add(85, "u{$u['uid']}", "{$u['username']} (UID {$u['uid']}, {$realname})");
133
-      }
104
+    $ret = array();
105
+  
106
+    $add = function ($val, $id, $value) {
107
+        global $ret;
108
+        if (isset($ret[$val]) && is_array($ret[$val])) {
109
+            array_push($ret[$val], array("id" => $id, "value" => $value));
110
+        } else {
111
+            $ret[$val] = array( array("id" => $id, "value" => $value) );
112
+        }
113
+    };
114
+
115
+
116
+    $result = array_unique(find_customers($term));
117
+    sort($result);
118
+    foreach ($result as $val) {
119
+        $c = customer_details($val);
120
+        if ($c['id'] == $term) {
121
+            $add(10, "c{$c['id']}", "Kunde {$c['id']}: {$c['name']}");
122
+        } else {
123
+            $add(90, "c{$c['id']}", "Kunde {$c['id']}: {$c['name']}");
124
+        }
125
+        $users = find_users_for_customer($c['id']);
126
+        foreach ($users as $u) {
127
+            $realname = $c['name'];
128
+            if ($u['name']) {
129
+                $realname = $u['name'];
130
+            }
131
+            if ($u['uid'] == $term || $u['username'] == $term) {
132
+                $add(15, "u{$u['uid']}", "{$u['username']} (UID {$u['uid']}, {$realname})");
133
+            } elseif (strstr($u['username'], $term)) {
134
+                $add(20, "u{$u['uid']}", "{$u['username']} (UID {$u['uid']}, {$realname})");
135
+            } elseif (stristr($u['name'], $term)) {
136
+                $add(25, "u{$u['uid']}", "{$u['username']} (UID {$u['uid']}, {$realname})");
137
+            } else {
138
+                $add(85, "u{$u['uid']}", "{$u['username']} (UID {$u['uid']}, {$realname})");
139
+            }
140
+        }
134 141
     }
135
-  }
136 142
 
137
-  ksort($ret);
143
+    ksort($ret);
138 144
   
139
-  $allentries = array();
140
-  foreach ($ret as $group) {
141
-    usort($group, function ($a, $b) {
142
-      return strnatcmp($a['value'], $b['value']); 
143
-    });
144
-    foreach ($group as $entry) {
145
-      $allentries[] = $entry;
145
+    $allentries = array();
146
+    foreach ($ret as $group) {
147
+        usort($group, function ($a, $b) {
148
+            return strnatcmp($a['value'], $b['value']);
149
+        });
150
+        foreach ($group as $entry) {
151
+            $allentries[] = $entry;
152
+        }
146 153
     }
147
-  }
148
-  unset($ret);
149
-  return $allentries;
154
+    unset($ret);
155
+    return $allentries;
150 156
 }
151 157
 
152 158
 
153
-function su($type, $id) {
154
-  $role = NULL;
155
-  $admin_user = $_SESSION['userinfo']['username'];
156
-  $_SESSION['admin_user'] = $admin_user;
157
-  $role = find_role($id, '', True);
158
-  if (!$role) {
159
-    unset($_SESSION['admin_user']);
160
-    return False;
161
-  }
162
-  setup_session($role, $id);
163
-  if ($type == 'c') {
164
-    if (! (ROLE_CUSTOMER & $_SESSION['role'])) {
165
-      session_destroy();
166
-      system_failure('Es wurde ein "su" zu einem Kundenaccount angefordert, das war aber kein Kundenaccount!');
159
+function su($type, $id)
160
+{
161
+    $role = null;
162
+    $admin_user = $_SESSION['userinfo']['username'];
163
+    $_SESSION['admin_user'] = $admin_user;
164
+    $role = find_role($id, '', true);
165
+    if (!$role) {
166
+        unset($_SESSION['admin_user']);
167
+        return false;
167 168
     }
168
-  } elseif ($type == 'u') {
169
-    if (! (ROLE_SYSTEMUSER & $_SESSION['role'])) {
170
-      session_destroy();
171
-      system_failure('Es wurde ein "su" zu einem Benutzeraccount angefordert, das war aber kein Benutzeraccount!');
169
+    setup_session($role, $id);
170
+    if ($type == 'c') {
171
+        if (! (ROLE_CUSTOMER & $_SESSION['role'])) {
172
+            session_destroy();
173
+            system_failure('Es wurde ein "su" zu einem Kundenaccount angefordert, das war aber kein Kundenaccount!');
174
+        }
175
+    } elseif ($type == 'u') {
176
+        if (! (ROLE_SYSTEMUSER & $_SESSION['role'])) {
177
+            session_destroy();
178
+            system_failure('Es wurde ein "su" zu einem Benutzeraccount angefordert, das war aber kein Benutzeraccount!');
179
+        }
180
+    } elseif ($type) {
181
+        // wenn type leer ist, dann ist es auch egal
182
+        system_failure('unknown type');
172 183
     }
173
-  } elseif ($type) {
174
-    // wenn type leer ist, dann ist es auch egal
175
-    system_failure('unknown type');
176
-  }
177 184
 
178
-  redirect('../../go/index/index');
179
-  die();
185
+    redirect('../../go/index/index');
186
+    die();
180 187
 }
Browse code

Alte Klassen entfernt

Bernd Wurst authored on 23/01/2018 14:01:15
Showing 1 changed files
... ...
@@ -14,9 +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/base.php');
18
-require_once('class/customer.php');
19
-
20 17
 function list_system_users()
21 18
 {
22 19
   require_role(ROLE_SYSADMIN);
... ...
@@ -42,6 +39,17 @@ function list_customers()
42 39
   return $ret;
43 40
 }
44 41
 
42
+function customer_details($id) 
43
+{
44
+    $id = (int) $id; 
45
+    $result = db_query("SELECT id, IF(firma IS NULL, CONCAT_WS(' ', vorname, nachname), CONCAT(firma, ' (', CONCAT_WS(' ', vorname, nachname), ')')) AS name FROM kundendaten.kunden WHERE id=?", array($id));
46
+    if ($result->rowCount() < 1) {
47
+        return NULL;
48
+    }
49
+    $kunde = $result->fetch();
50
+    return $kunde;
51
+}
52
+
45 53
 
46 54
 function find_customers($string) 
47 55
 {
... ...
@@ -102,15 +110,15 @@ function build_results($term) {
102 110
   $result = array_unique(find_customers($term));
103 111
   sort($result);
104 112
   foreach ($result as $val) {
105
-    $c = new Customer((int) $val);
106
-    if ($c->id == $term) {
107
-      $add(10, "c{$c->id}", "Kunde {$c->id}: {$c->fullname}");
113
+    $c = customer_details($val);
114
+    if ($c['id'] == $term) {
115
+      $add(10, "c{$c['id']}", "Kunde {$c['id']}: {$c['name']}");
108 116
     } else {
109
-      $add(90, "c{$c->id}", "Kunde {$c->id}: {$c->fullname}");
117
+      $add(90, "c{$c['id']}", "Kunde {$c['id']}: {$c['name']}");
110 118
     }
111
-    $users = find_users_for_customer($c->id);
119
+    $users = find_users_for_customer($c['id']);
112 120
     foreach ($users as $u) {
113
-      $realname = $c->fullname;
121
+      $realname = $c['name'];
114 122
       if ($u['name']) {
115 123
         $realname = $u['name'];
116 124
       }
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

Generelle Su-Möglichkeit für alle Kundenaccounts zu ihren eigenen Usern

Bernd Wurst authored on 29/10/2015 20:46:09
Showing 1 changed files
... ...
@@ -142,3 +142,31 @@ function build_results($term) {
142 142
 }
143 143
 
144 144
 
145
+function su($type, $id) {
146
+  $role = NULL;
147
+  $admin_user = $_SESSION['userinfo']['username'];
148
+  $_SESSION['admin_user'] = $admin_user;
149
+  $role = find_role($id, '', True);
150
+  if (!$role) {
151
+    unset($_SESSION['admin_user']);
152
+    return False;
153
+  }
154
+  setup_session($role, $id);
155
+  if ($type == 'c') {
156
+    if (! (ROLE_CUSTOMER & $_SESSION['role'])) {
157
+      session_destroy();
158
+      system_failure('Es wurde ein "su" zu einem Kundenaccount angefordert, das war aber kein Kundenaccount!');
159
+    }
160
+  } elseif ($type == 'u') {
161
+    if (! (ROLE_SYSTEMUSER & $_SESSION['role'])) {
162
+      session_destroy();
163
+      system_failure('Es wurde ein "su" zu einem Benutzeraccount angefordert, das war aber kein Benutzeraccount!');
164
+    }
165
+  } elseif ($type) {
166
+    // wenn type leer ist, dann ist es auch egal
167
+    system_failure('unknown type');
168
+  }
169
+
170
+  redirect('../../go/index/index');
171
+  die();
172
+}
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

* Weitere Module auf prepared-statements umgestellt * Warnung beim Aufruf von db_escape_string() und maybe_null() hinzugefügt

Bernd Wurst authored on 03/02/2014 16:57:44
Showing 1 changed files
... ...
@@ -45,22 +45,23 @@ function list_customers()
45 45
 
46 46
 function find_customers($string) 
47 47
 {
48
-  $string = db_escape_string(chop($string));
48
+  $args = array(":string" => '%'.chop($string).'%', ":number" => $string);
49 49
   $return = array();
50 50
   $result = db_query("SELECT k.id FROM kundendaten.kunden AS k LEFT JOIN system.useraccounts AS u ON (k.id=u.kunde) WHERE ".
51
-                     "firma LIKE '%{$string}%' OR firma2 LIKE '%{$string}%' OR ".
52
-                     "nachname LIKE '%{$string}%' OR vorname LIKE '%{$string}%' OR ".
53
-                     "adresse LIKE '%{$string}%' OR adresse2 LIKE '%{$string}%' OR ".
54
-                     "ort LIKE '%{$string}%' OR pgp_id LIKE '%{$string}%' OR ".
55
-                     "notizen LIKE '%{$string}%' OR email_rechnung LIKE '%{$string}%' OR ".
56
-                     "email LIKE '%{$string}%' OR email_extern LIKE '%{$string}%' OR u.name LIKE '%{$string}%' OR ".
57
-                     "u.username LIKE '%{$string}%' OR k.id='{$string}' OR u.uid='{$string}';");
51
+                     "firma LIKE :string OR firma2 LIKE :string OR ".
52
+                     "nachname LIKE :string OR vorname LIKE :string OR ".
53
+                     "adresse LIKE :string OR adresse2 LIKE :string OR ".
54
+                     "ort LIKE :string OR pgp_id LIKE :string OR ".
55
+                     "notizen LIKE :string OR email_rechnung LIKE :string OR ".
56
+                     "email LIKE :string OR email_extern LIKE :string OR u.name LIKE :string OR ".
57
+                     "u.username LIKE :string OR k.id=:number OR u.uid=:number", $args);
58 58
   while ($entry = $result->fetch())
59 59
     $return[] = $entry['id'];
60 60
 
61
+  unset($args[':number']);
61 62
   $result = db_query("SELECT kunde FROM kundendaten.domains WHERE kunde IS NOT NULL AND (
62
-                      domainname LIKE '%{$string}%' OR CONCAT_WS('.', domainname, tld) LIKE '%{$string}%'
63
-                      )");
63
+                      domainname LIKE :string OR CONCAT_WS('.', domainname, tld) LIKE :string
64
+                      )", $args);
64 65
 
65 66
   while ($entry = $result->fetch())
66 67
     $return[] = $entry['kunde'];
... ...
@@ -74,7 +75,7 @@ function find_users_for_customer($id)
74 75
   $id = (int) $id;
75 76
   $return = array();
76 77
   $result = db_query("SELECT uid, username, name FROM system.useraccounts WHERE ".
77
-                     "kunde='{$id}';");
78
+                     "kunde=?", array($id));
78 79
   while ($entry = $result->fetch())
79 80
     $return[] = $entry;
80 81
 
Browse code

Umstellung auf PDO-Datenbankverbindung

Bernd Wurst authored on 01/02/2014 18:38:23
Showing 1 changed files
... ...
@@ -24,7 +24,7 @@ function list_system_users()
24 24
   $result = db_query("SELECT uid,username FROM system.v_useraccounts ORDER BY username");
25 25
   
26 26
   $ret = array();
27
-  while ($item = mysql_fetch_object($result))
27
+  while ($item = $result->fetch(PDO::FETCH_OBJ))
28 28
     array_push($ret, $item);
29 29
   return $ret;
30 30
 }
... ...
@@ -37,7 +37,7 @@ function list_customers()
37 37
   $result = db_query("SELECT id, IF(firma IS NULL, CONCAT_WS(' ', vorname, nachname), CONCAT(firma, ' (', CONCAT_WS(' ', vorname, nachname), ')')) AS name FROM kundendaten.kunden");
38 38
   
39 39
   $ret = array();
40
-  while ($item = mysql_fetch_object($result))
40
+  while ($item = $result->fetch(PDO::FETCH_OBJ))
41 41
     array_push($ret, $item);
42 42
   return $ret;
43 43
 }
... ...
@@ -45,7 +45,7 @@ function list_customers()
45 45
 
46 46
 function find_customers($string) 
47 47
 {
48
-  $string = mysql_real_escape_string(chop($string));
48
+  $string = db_escape_string(chop($string));
49 49
   $return = array();
50 50
   $result = db_query("SELECT k.id FROM kundendaten.kunden AS k LEFT JOIN system.useraccounts AS u ON (k.id=u.kunde) WHERE ".
51 51
                      "firma LIKE '%{$string}%' OR firma2 LIKE '%{$string}%' OR ".
... ...
@@ -55,14 +55,14 @@ function find_customers($string)
55 55
                      "notizen LIKE '%{$string}%' OR email_rechnung LIKE '%{$string}%' OR ".
56 56
                      "email LIKE '%{$string}%' OR email_extern LIKE '%{$string}%' OR u.name LIKE '%{$string}%' OR ".
57 57
                      "u.username LIKE '%{$string}%' OR k.id='{$string}' OR u.uid='{$string}';");
58
-  while ($entry = mysql_fetch_assoc($result))
58
+  while ($entry = $result->fetch())
59 59
     $return[] = $entry['id'];
60 60
 
61 61
   $result = db_query("SELECT kunde FROM kundendaten.domains WHERE kunde IS NOT NULL AND (
62 62
                       domainname LIKE '%{$string}%' OR CONCAT_WS('.', domainname, tld) LIKE '%{$string}%'
63 63
                       )");
64 64
 
65
-  while ($entry = mysql_fetch_assoc($result))
65
+  while ($entry = $result->fetch())
66 66
     $return[] = $entry['kunde'];
67 67
 
68 68
   return $return;
... ...
@@ -75,7 +75,7 @@ function find_users_for_customer($id)
75 75
   $return = array();
76 76
   $result = db_query("SELECT uid, username, name FROM system.useraccounts WHERE ".
77 77
                      "kunde='{$id}';");
78
-  while ($entry = mysql_fetch_assoc($result))
78
+  while ($entry = $result->fetch())
79 79
     $return[] = $entry;
80 80
 
81 81
   return $return;
Browse code

Suche auch bei unvollständiger Eingabe

Bernd Wurst authored on 22/01/2013 08:27:11
Showing 1 changed files
... ...
@@ -15,6 +15,7 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r
15 15
 */
16 16
 
17 17
 require_once('inc/base.php');
18
+require_once('class/customer.php');
18 19
 
19 20
 function list_system_users()
20 21
 {
Browse code

Verschiebe Such-Logik in die Include

Bernd Wurst authored on 22/01/2013 08:21:02
Showing 1 changed files
... ...
@@ -83,6 +83,60 @@ function find_users_for_customer($id)
83 83
 
84 84
 
85 85
 
86
-
86
+function build_results($term) {
87
+  global $ret;
88
+  $ret = array();
89
+  
90
+  $add = function($val, $id, $value) {
91
+    global $ret;
92
+    if (isset($ret[$val]) && is_array($ret[$val])) {
93
+      array_push($ret[$val], array("id" => $id, "value" => $value));
94
+    } else {
95
+      $ret[$val] = array( array("id" => $id, "value" => $value) );
96
+    }
97
+  };
98
+
99
+
100
+  $result = array_unique(find_customers($term));
101
+  sort($result);
102
+  foreach ($result as $val) {
103
+    $c = new Customer((int) $val);
104
+    if ($c->id == $term) {
105
+      $add(10, "c{$c->id}", "Kunde {$c->id}: {$c->fullname}");
106
+    } else {
107
+      $add(90, "c{$c->id}", "Kunde {$c->id}: {$c->fullname}");
108
+    }
109
+    $users = find_users_for_customer($c->id);
110
+    foreach ($users as $u) {
111
+      $realname = $c->fullname;
112
+      if ($u['name']) {
113
+        $realname = $u['name'];
114
+      }
115
+      if ($u['uid'] == $term || $u['username'] == $term) {
116
+        $add(15, "u{$u['uid']}", "{$u['username']} (UID {$u['uid']}, {$realname})");
117
+      } elseif (strstr($u['username'], $term)) {
118
+        $add(20, "u{$u['uid']}", "{$u['username']} (UID {$u['uid']}, {$realname})");
119
+      } elseif (stristr($u['name'], $term)) {
120
+        $add(25, "u{$u['uid']}", "{$u['username']} (UID {$u['uid']}, {$realname})");
121
+      } else {
122
+        $add(85, "u{$u['uid']}", "{$u['username']} (UID {$u['uid']}, {$realname})");
123
+      }
124
+    }
125
+  }
126
+
127
+  ksort($ret);
128
+  
129
+  $allentries = array();
130
+  foreach ($ret as $group) {
131
+    usort($group, function ($a, $b) {
132
+      return strnatcmp($a['value'], $b['value']); 
133
+    });
134
+    foreach ($group as $entry) {
135
+      $allentries[] = $entry;
136
+    }
137
+  }
138
+  unset($ret);
139
+  return $allentries;
140
+}
87 141
 
88 142
 
Browse code

übersichtlichere Auswahlliste mit Realnames

Bernd Wurst authored on 21/01/2013 17:28:12
Showing 1 changed files
... ...
@@ -72,10 +72,10 @@ function find_users_for_customer($id)
72 72
 {
73 73
   $id = (int) $id;
74 74
   $return = array();
75
-  $result = db_query("SELECT uid, username FROM system.useraccounts WHERE ".
75
+  $result = db_query("SELECT uid, username, name FROM system.useraccounts WHERE ".
76 76
                      "kunde='{$id}';");
77 77
   while ($entry = mysql_fetch_assoc($result))
78
-    $return[$entry['uid']] = $entry['username'];
78
+    $return[] = $entry;
79 79
 
80 80
   return $return;
81 81
 }
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/base.php');
4 18
 
Browse code

Tabelle 'kundenkontakt' komplett entfernt

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

bernd authored on 21/02/2010 08:26:39
Showing 1 changed files
... ...
@@ -32,14 +32,13 @@ function find_customers($string)
32 32
 {
33 33
   $string = mysql_real_escape_string(chop($string));
34 34
   $return = array();
35
-  $result = db_query("SELECT k.id FROM kundendaten.kunden AS k LEFT JOIN kundendaten.kundenkontakt AS kk ".
36
-                     "ON (kk.kundennr = k.id) LEFT JOIN system.useraccounts AS u ON (k.id=u.kunde) WHERE ".
35
+  $result = db_query("SELECT k.id FROM kundendaten.kunden AS k LEFT JOIN system.useraccounts AS u ON (k.id=u.kunde) WHERE ".
37 36
                      "firma LIKE '%{$string}%' OR firma2 LIKE '%{$string}%' OR ".
38 37
                      "nachname LIKE '%{$string}%' OR vorname LIKE '%{$string}%' OR ".
39 38
                      "adresse LIKE '%{$string}%' OR adresse2 LIKE '%{$string}%' OR ".
40 39
                      "ort LIKE '%{$string}%' OR pgp_id LIKE '%{$string}%' OR ".
41
-                     "notizen LIKE '%{$string}%' OR kk.name LIKE '%{$string}%' OR ".
42
-                     "kk.wert LIKE '%{$string}%' OR u.name LIKE '%{$string}%' OR ".
40
+                     "notizen LIKE '%{$string}%' OR email_rechnung LIKE '%{$string}%' OR ".
41
+                     "email LIKE '%{$string}%' OR email_extern LIKE '%{$string}%' OR u.name LIKE '%{$string}%' OR ".
43 42
                      "u.username LIKE '%{$string}%' OR k.id='{$string}' OR u.uid='{$string}';");
44 43
   while ($entry = mysql_fetch_assoc($result))
45 44
     $return[] = $entry['id'];
Browse code

Finde Kunden auch anhand von DOmains

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

bernd authored on 10/01/2009 12:31:09
Showing 1 changed files
... ...
@@ -44,6 +44,13 @@ function find_customers($string)
44 44
   while ($entry = mysql_fetch_assoc($result))
45 45
     $return[] = $entry['id'];
46 46
 
47
+  $result = db_query("SELECT kunde FROM kundendaten.domains WHERE kunde IS NOT NULL AND (
48
+                      domainname LIKE '%{$string}%' OR CONCAT_WS('.', domainname, tld) LIKE '%{$string}%'
49
+                      )");
50
+
51
+  while ($entry = mysql_fetch_assoc($result))
52
+    $return[] = $entry['kunde'];
53
+
47 54
   return $return;
48 55
 }
49 56
 
Browse code

AJAXified

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

bernd authored on 22/09/2008 17:29:57
Showing 1 changed files
... ...
@@ -1,5 +1,6 @@
1 1
 <?php
2 2
 
3
+require_once('inc/base.php');
3 4
 
4 5
 function list_system_users()
5 6
 {
... ...
@@ -27,4 +28,41 @@ function list_customers()
27 28
 }
28 29
 
29 30
 
30
-?>
31
+function find_customers($string) 
32
+{
33
+  $string = mysql_real_escape_string(chop($string));
34
+  $return = array();
35
+  $result = db_query("SELECT k.id FROM kundendaten.kunden AS k LEFT JOIN kundendaten.kundenkontakt AS kk ".
36
+                     "ON (kk.kundennr = k.id) LEFT JOIN system.useraccounts AS u ON (k.id=u.kunde) WHERE ".
37
+                     "firma LIKE '%{$string}%' OR firma2 LIKE '%{$string}%' OR ".
38
+                     "nachname LIKE '%{$string}%' OR vorname LIKE '%{$string}%' OR ".
39
+                     "adresse LIKE '%{$string}%' OR adresse2 LIKE '%{$string}%' OR ".
40
+                     "ort LIKE '%{$string}%' OR pgp_id LIKE '%{$string}%' OR ".
41
+                     "notizen LIKE '%{$string}%' OR kk.name LIKE '%{$string}%' OR ".
42
+                     "kk.wert LIKE '%{$string}%' OR u.name LIKE '%{$string}%' OR ".
43
+                     "u.username LIKE '%{$string}%' OR k.id='{$string}' OR u.uid='{$string}';");
44
+  while ($entry = mysql_fetch_assoc($result))
45
+    $return[] = $entry['id'];
46
+
47
+  return $return;
48
+}
49
+
50
+
51
+function find_users_for_customer($id)
52
+{
53
+  $id = (int) $id;
54
+  $return = array();
55
+  $result = db_query("SELECT uid, username FROM system.useraccounts WHERE ".
56
+                     "kunde='{$id}';");
57
+  while ($entry = mysql_fetch_assoc($result))
58
+    $return[$entry['uid']] = $entry['username'];
59
+
60
+  return $return;
61
+}
62
+
63
+
64
+
65
+
66
+
67
+
68
+
Browse code

Su-Login für Admins

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

bernd authored on 30/07/2007 13:02:55
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,30 @@
1
+<?php
2
+
3
+
4
+function list_system_users()
5
+{
6
+  require_role(ROLE_SYSADMIN);
7
+
8
+  $result = db_query("SELECT uid,username FROM system.v_useraccounts ORDER BY username");
9
+  
10
+  $ret = array();
11
+  while ($item = mysql_fetch_object($result))
12
+    array_push($ret, $item);
13
+  return $ret;
14
+}
15
+
16
+
17
+function list_customers()
18
+{
19
+  require_role(ROLE_SYSADMIN);
20
+
21
+  $result = db_query("SELECT id, IF(firma IS NULL, CONCAT_WS(' ', vorname, nachname), CONCAT(firma, ' (', CONCAT_WS(' ', vorname, nachname), ')')) AS name FROM kundendaten.kunden");
22
+  
23
+  $ret = array();
24
+  while ($item = mysql_fetch_object($result))
25
+    array_push($ret, $item);
26
+  return $ret;
27
+}
28
+
29
+
30
+?>