Browse code

Codingstyle PSR12 + array syntax

Hanno Böck authored on 30/10/2021 21:18:17
Showing 1 changed files
... ...
@@ -31,10 +31,10 @@ $term = $_GET['term'];
31 31
 
32 32
 $allentries = build_results($term);
33 33
 
34
-$out = array();
34
+$out = [];
35 35
 
36 36
 foreach ($allentries as $entry) {
37
-    $out[] = array('id' => $entry['id'], 'value' => $entry['value']);
37
+    $out[] = ['id' => $entry['id'], 'value' => $entry['value']];
38 38
 }
39 39
 
40 40
 
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.
... ...
@@ -34,12 +34,10 @@ $allentries = build_results($term);
34 34
 $out = array();
35 35
 
36 36
 foreach ($allentries as $entry) {
37
-  $out[] = array('id' => $entry['id'], 'value' => $entry['value']);
37
+    $out[] = array('id' => $entry['id'], 'value' => $entry['value']);
38 38
 }
39 39
 
40 40
 
41 41
 header("Content-Type: application/json");
42 42
 echo json_encode($out);
43 43
 die();
44
-
45
-
Browse code

JSON nicht selbst bauen

Bernd Wurst authored on 28/01/2018 10:52:21
Showing 1 changed files
... ...
@@ -31,18 +31,15 @@ $term = $_GET['term'];
31 31
 
32 32
 $allentries = build_results($term);
33 33
 
34
-$lines = array();
34
+$out = array();
35
+
35 36
 foreach ($allentries as $entry) {
36
-  $lines[] = "  { \"id\": \"".filter_input_general($entry['id'])."\", \"value\": \"".filter_input_general($entry['value'])."\" }";
37
+  $out[] = array('id' => $entry['id'], 'value' => $entry['value']);
37 38
 }
38 39
 
39 40
 
40
-
41 41
 header("Content-Type: application/json");
42
-echo "[\n";
43
-echo implode(",\n", $lines);
44
-echo '
45
-]';
42
+echo json_encode($out);
46 43
 die();
47 44
 
48 45
 
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

VHost-Edit-Seite auf JQuery umgestellt

Bernd Wurst authored on 08/02/2014 09:38:35
Showing 1 changed files
... ...
@@ -38,7 +38,7 @@ foreach ($allentries as $entry) {
38 38
 
39 39
 
40 40
 
41
-header("Content-Type: text/javascript");
41
+header("Content-Type: application/json");
42 42
 echo "[\n";
43 43
 echo implode(",\n", $lines);
44 44
 echo '
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

Suche auch bei unvollständiger Eingabe

Bernd Wurst authored on 22/01/2013 08:27:11
Showing 1 changed files
... ...
@@ -15,12 +15,12 @@ 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('inc/security.php');
18 19
 require_once('inc/debug.php');
19 20
 
20 21
 require_once('session/start.php');
21 22
 require_once('su.php');
22 23
 
23
-require_once('class/customer.php');
24 24
 
25 25
 require_role(ROLE_SYSADMIN);
26 26
 
Browse code

Verschiebe Such-Logik in die Include

Bernd Wurst authored on 22/01/2013 08:21:02
Showing 1 changed files
... ...
@@ -28,55 +28,12 @@ require_role(ROLE_SYSADMIN);
28 28
 $_SESSION['su_ajax_timestamp'] = time();
29 29
 
30 30
 $term = $_GET['term'];
31
-$ret = array();
32
-
33
-function add($val, $id, $value) {
34
-  global $ret;
35
-  if (isset($ret[$val]) && is_array($ret[$val])) {
36
-    array_push($ret[$val], array("id" => $id, "value" => $value));
37
-  } else {
38
-    $ret[$val] = array( array("id" => $id, "value" => $value) );
39
-  }
40
-}
41
-
42
-
43
-$result = array_unique(find_customers($term));
44
-sort($result);
45
-foreach ($result as $val) {
46
-  $c = new Customer((int) $val);
47
-  if ($c->id == $term) {
48
-    add(10, "c{$c->id}", "Kunde {$c->id}: {$c->fullname}");
49
-  } else {
50
-    add(90, "c{$c->id}", "Kunde {$c->id}: {$c->fullname}");
51
-  }
52
-  $users = find_users_for_customer($c->id);
53
-  foreach ($users as $u) {
54
-    $realname = $c->fullname;
55
-    if ($u['name']) {
56
-      $realname = $u['name'];
57
-    }
58
-    if ($u['uid'] == $term || $u['username'] == $term) {
59
-      add(15, "u{$u['uid']}", "{$u['username']} (UID {$u['uid']}, {$realname})");
60
-    } elseif (strstr($u['username'], $term)) {
61
-      add(20, "u{$u['uid']}", "{$u['username']} (UID {$u['uid']}, {$realname})");
62
-    } elseif (stristr($u['name'], $term)) {
63
-      add(25, "u{$u['uid']}", "{$u['username']} (UID {$u['uid']}, {$realname})");
64
-    } else {
65
-      add(85, "u{$u['uid']}", "{$u['username']} (UID {$u['uid']}, {$realname})");
66
-    }
67
-  }
68
-}
69 31
 
70
-ksort($ret);
32
+$allentries = build_results($term);
71 33
 
72 34
 $lines = array();
73
-foreach ($ret as $group) {
74
-  usort($group, function ($a, $b) {
75
-    return strnatcmp($a['value'], $b['value']); 
76
-  });
77
-  foreach ($group as $entry) {
78
-    $lines[] = "  { \"id\": \"".filter_input_general($entry['id'])."\", \"value\": \"".filter_input_general($entry['value'])."\" }";
79
-  }
35
+foreach ($allentries as $entry) {
36
+  $lines[] = "  { \"id\": \"".filter_input_general($entry['id'])."\", \"value\": \"".filter_input_general($entry['value'])."\" }";
80 37
 }
81 38
 
82 39
 
Browse code

Ergebnisse sortieren

Bernd Wurst authored on 21/01/2013 17:52:24
Showing 1 changed files
... ...
@@ -71,6 +71,9 @@ ksort($ret);
71 71
 
72 72
 $lines = array();
73 73
 foreach ($ret as $group) {
74
+  usort($group, function ($a, $b) {
75
+    return strnatcmp($a['value'], $b['value']); 
76
+  });
74 77
   foreach ($group as $entry) {
75 78
     $lines[] = "  { \"id\": \"".filter_input_general($entry['id'])."\", \"value\": \"".filter_input_general($entry['value'])."\" }";
76 79
   }
Browse code

Suche Realnames case-insensitive

Bernd Wurst authored on 21/01/2013 17:29:39
Showing 1 changed files
... ...
@@ -59,7 +59,7 @@ foreach ($result as $val) {
59 59
       add(15, "u{$u['uid']}", "{$u['username']} (UID {$u['uid']}, {$realname})");
60 60
     } elseif (strstr($u['username'], $term)) {
61 61
       add(20, "u{$u['uid']}", "{$u['username']} (UID {$u['uid']}, {$realname})");
62
-    } elseif (strstr($u['name'], $term)) {
62
+    } elseif (stristr($u['name'], $term)) {
63 63
       add(25, "u{$u['uid']}", "{$u['username']} (UID {$u['uid']}, {$realname})");
64 64
     } else {
65 65
       add(85, "u{$u['uid']}", "{$u['username']} (UID {$u['uid']}, {$realname})");
Browse code

übersichtlichere Auswahlliste mit Realnames

Bernd Wurst authored on 21/01/2013 17:28:12
Showing 1 changed files
... ...
@@ -50,13 +50,19 @@ foreach ($result as $val) {
50 50
     add(90, "c{$c->id}", "Kunde {$c->id}: {$c->fullname}");
51 51
   }
52 52
   $users = find_users_for_customer($c->id);
53
-  foreach ($users as $uid => $username) {
54
-    if ($uid == $term || $username == $term) {
55
-      add(15, "u{$uid}", "User {$uid}: {$username}");
56
-    } elseif (strstr($username, $term)) {
57
-      add(20, "u{$uid}", "User {$uid}: {$username}");
53
+  foreach ($users as $u) {
54
+    $realname = $c->fullname;
55
+    if ($u['name']) {
56
+      $realname = $u['name'];
57
+    }
58
+    if ($u['uid'] == $term || $u['username'] == $term) {
59
+      add(15, "u{$u['uid']}", "{$u['username']} (UID {$u['uid']}, {$realname})");
60
+    } elseif (strstr($u['username'], $term)) {
61
+      add(20, "u{$u['uid']}", "{$u['username']} (UID {$u['uid']}, {$realname})");
62
+    } elseif (strstr($u['name'], $term)) {
63
+      add(25, "u{$u['uid']}", "{$u['username']} (UID {$u['uid']}, {$realname})");
58 64
     } else {
59
-      add(85, "u{$uid}", "User {$uid}: {$username}");
65
+      add(85, "u{$u['uid']}", "{$u['username']} (UID {$u['uid']}, {$realname})");
60 66
     }
61 67
   }
62 68
 }
Browse code

sanitize output

Bernd Wurst authored on 21/01/2013 16:16:20
Showing 1 changed files
... ...
@@ -66,7 +66,7 @@ ksort($ret);
66 66
 $lines = array();
67 67
 foreach ($ret as $group) {
68 68
   foreach ($group as $entry) {
69
-    $lines[] = "  { \"id\": \"{$entry['id']}\", \"value\": \"{$entry['value']}\" }";
69
+    $lines[] = "  { \"id\": \"".filter_input_general($entry['id'])."\", \"value\": \"".filter_input_general($entry['value'])."\" }";
70 70
   }
71 71
 }
72 72
 
Browse code

Erzeuge sortierte Ausgabe der Resultate für schnellre navigation in den Ergebnissen

Bernd Wurst authored on 21/01/2013 15:59:01
Showing 1 changed files
... ...
@@ -27,20 +27,55 @@ require_role(ROLE_SYSADMIN);
27 27
 # Save the timestamp of this request to the session, so we accept only actions performed some seconds after this
28 28
 $_SESSION['su_ajax_timestamp'] = time();
29 29
 
30
-header("Content-Type: text/javascript");
31
-echo "[\n";
30
+$term = $_GET['term'];
31
+$ret = array();
32
+
33
+function add($val, $id, $value) {
34
+  global $ret;
35
+  if (isset($ret[$val]) && is_array($ret[$val])) {
36
+    array_push($ret[$val], array("id" => $id, "value" => $value));
37
+  } else {
38
+    $ret[$val] = array( array("id" => $id, "value" => $value) );
39
+  }
40
+}
41
+
32 42
 
33
-$result = array_unique(find_customers($_GET['term']));
43
+$result = array_unique(find_customers($term));
34 44
 sort($result);
35 45
 foreach ($result as $val) {
36 46
   $c = new Customer((int) $val);
37
-  echo " {\"id\": \"c{$c->id}\", \"value\": \"Kunde {$c->id}: {$c->fullname}\"},\n";
47
+  if ($c->id == $term) {
48
+    add(10, "c{$c->id}", "Kunde {$c->id}: {$c->fullname}");
49
+  } else {
50
+    add(90, "c{$c->id}", "Kunde {$c->id}: {$c->fullname}");
51
+  }
38 52
   $users = find_users_for_customer($c->id);
39 53
   foreach ($users as $uid => $username) {
40
-    echo " {\"id\": \"u{$uid}\", \"label\": \"User {$uid}: {$username}\"},\n";
54
+    if ($uid == $term || $username == $term) {
55
+      add(15, "u{$uid}", "User {$uid}: {$username}");
56
+    } elseif (strstr($username, $term)) {
57
+      add(20, "u{$uid}", "User {$uid}: {$username}");
58
+    } else {
59
+      add(85, "u{$uid}", "User {$uid}: {$username}");
60
+    }
61
+  }
62
+}
63
+
64
+ksort($ret);
65
+
66
+$lines = array();
67
+foreach ($ret as $group) {
68
+  foreach ($group as $entry) {
69
+    $lines[] = "  { \"id\": \"{$entry['id']}\", \"value\": \"{$entry['value']}\" }";
41 70
   }
42 71
 }
43
-echo ' {}
72
+
73
+
74
+
75
+header("Content-Type: text/javascript");
76
+echo "[\n";
77
+echo implode(",\n", $lines);
78
+echo '
44 79
 ]';
45 80
 die();
46 81
 
Browse code

su-Modul auf jQuery umgestellt (ohne weitere Verbesserungen der Usability)

Bernd Wurst authored on 20/01/2013 12:09:29
Showing 1 changed files
... ...
@@ -24,19 +24,24 @@ require_once('class/customer.php');
24 24
 
25 25
 require_role(ROLE_SYSADMIN);
26 26
 
27
-$ajax_formtoken = generate_form_token('su_su_ajax');
27
+# Save the timestamp of this request to the session, so we accept only actions performed some seconds after this
28
+$_SESSION['su_ajax_timestamp'] = time();
28 29
 
29
-$result = array_unique(find_customers($_GET['q']));
30
+header("Content-Type: text/javascript");
31
+echo "[\n";
32
+
33
+$result = array_unique(find_customers($_GET['term']));
30 34
 sort($result);
31 35
 foreach ($result as $val) {
32 36
   $c = new Customer((int) $val);
33
-  echo '<div style="margin-bottom: 0.5em;">'.internal_link('su.php', 'Kunde '.$c->id.': <strong>'.$c->fullname.'</strong>', 'type=customer&id='.$c->id.'&formtoken='.$ajax_formtoken);
37
+  echo " {\"id\": \"c{$c->id}\", \"value\": \"Kunde {$c->id}: {$c->fullname}\"},\n";
34 38
   $users = find_users_for_customer($c->id);
35 39
   foreach ($users as $uid => $username) {
36
-    echo '<p style="padding:0; margin:0;margin-left: 2em;">'.internal_link('', 'User »'.$username.'« (UID '.$uid.')', 'type=systemuser&uid='.$uid.'&formtoken='.$ajax_formtoken).'</p>';
40
+    echo " {\"id\": \"u{$uid}\", \"label\": \"User {$uid}: {$username}\"},\n";
37 41
   }
38
-  echo '</div>';
39 42
 }
43
+echo ' {}
44
+]';
40 45
 die();
41 46
 
42 47
 
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
 require_once('inc/debug.php');
Browse code

Neues AJAX-su

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

bernd authored on 03/12/2008 07:28:32
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,28 @@
1
+<?php
2
+
3
+require_once('inc/base.php');
4
+require_once('inc/debug.php');
5
+
6
+require_once('session/start.php');
7
+require_once('su.php');
8
+
9
+require_once('class/customer.php');
10
+
11
+require_role(ROLE_SYSADMIN);
12
+
13
+$ajax_formtoken = generate_form_token('su_su_ajax');
14
+
15
+$result = array_unique(find_customers($_GET['q']));
16
+sort($result);
17
+foreach ($result as $val) {
18
+  $c = new Customer((int) $val);
19
+  echo '<div style="margin-bottom: 0.5em;">'.internal_link('su.php', 'Kunde '.$c->id.': <strong>'.$c->fullname.'</strong>', 'type=customer&id='.$c->id.'&formtoken='.$ajax_formtoken);
20
+  $users = find_users_for_customer($c->id);
21
+  foreach ($users as $uid => $username) {
22
+    echo '<p style="padding:0; margin:0;margin-left: 2em;">'.internal_link('', 'User »'.$username.'« (UID '.$uid.')', 'type=systemuser&uid='.$uid.'&formtoken='.$ajax_formtoken).'</p>';
23
+  }
24
+  echo '</div>';
25
+}
26
+die();
27
+
28
+