Browse code

Alte Klassen entfernt

Bernd Wurst authored on 23/01/2018 14:01:15
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,114 +0,0 @@
1
-<?php
2
-/*
3
-This file belongs to the Webinterface of schokokeks.org Hosting
4
-
5
-Written 2008-2018 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
-*/
16
-
17
-require_once('inc/base.php');
18
-require_once('inc/debug.php');
19
-
20
-
21
-abstract class KeksData
22
-{
23
-  protected $default_table;
24
-  
25
-  protected $raw_data = array();
26
-  protected $data = array();
27
-  protected $changes = array();
28
-
29
-  function __get($key)
30
-  {
31
-    if (array_key_exists($key, $this->data))
32
-      return $this->data[$key];
33
-    elseif (isset($this->$key))
34
-      return $this->$key;
35
-    // else werfe fehler
36
-  }
37
-
38
-  function __set($key, $value)
39
-  {
40
-    if (array_key_exists($key, $this->raw_data))
41
-    {
42
-      $this->raw_data[$key] = $value;
43
-      $this->changes[$key] = $value;
44
-      $this->parse($this->raw_data);
45
-    }
46
-    elseif (array_key_exists($key, $this->data))
47
-      $this->data[$key] = $value;
48
-      // return false;
49
-    elseif (isset($this->$key))
50
-      $this->$key = $value;
51
-    else
52
-      $this->data[$key] = $value;
53
-  }
54
-
55
-  protected function setup()
56
-  {
57
-    $fields = array();
58
-    $res = db_query("DESCRIBE {$this->default_table}");
59
-    while ($f = $res->fetch(PDO::FETCH_OBJ))
60
-    {
61
-      $fields[$f->Field] = $f->Default;
62
-    }
63
-    $this->raw_data = $fields;
64
-    $this->raw_data['id'] = NULL;
65
-    $this->data = $fields;
66
-    $this->data['id'] = NULL;
67
-  }
68
-
69
-
70
-  function getData($fields, $restriction = NULL, $table = NULL)
71
-  {
72
-    $where = '';
73
-    if ($restriction)
74
-      $where = 'WHERE '.$restriction;
75
-    if (! $table)
76
-      $table = $this->default_table;
77
-    if (is_array($fields))
78
-      $fields = implode(',', $fields);
79
-    
80
-    $res = db_query("SELECT {$fields} FROM {$table} {$where}", array()); // FIXME Übergebe leeren array um die Warnung zu unterdrücken
81
-    $return = array();
82
-    while ($arr = $res->fetch())
83
-      array_push($return, $arr);
84
-    return $return;
85
-  }
86
-
87
-
88
-  function loadByID($id)
89
-  {
90
-    $id = (int) $id;
91
-    DEBUG("requested to load ID »{$id}«");
92
-    $res = $this->getData('*', "id={$id} LIMIT 1");
93
-    if (count($res) < 1)
94
-      return false;
95
-    $this->parse($res[0]);
96
-  }
97
-
98
-
99
-  function save()
100
-  {
101
-    $upd = array();
102
-    foreach ($this->changes as $key => $value)
103
-    {
104
-      $value = db_escape_string($value);
105
-      array_push($upd, "`{$key}`='{$value}'");
106
-    }
107
-    db_query("UPDATE {$this->default_table} SET ".implode(', ', $upd)." WHERE id=?", array($this->data['id']));
108
-  }
109
-
110
-  abstract function parse($data);
111
-
112
-}
113
-
114
-?>
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

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

Einige Statements auf Prepared-statements umgestellt

Bernd Wurst authored on 02/02/2014 16:31:00
Showing 1 changed files
... ...
@@ -77,7 +77,7 @@ abstract class KeksData
77 77
     if (is_array($fields))
78 78
       $fields = implode(',', $fields);
79 79
     
80
-    $res = db_query("SELECT {$fields} FROM {$table} {$where}");
80
+    $res = db_query("SELECT {$fields} FROM {$table} {$where}", array()); // FIXME Übergebe leeren array um die Warnung zu unterdrücken
81 81
     $return = array();
82 82
     while ($arr = $res->fetch())
83 83
       array_push($return, $arr);
... ...
@@ -104,7 +104,7 @@ abstract class KeksData
104 104
       $value = db_escape_string($value);
105 105
       array_push($upd, "`{$key}`='{$value}'");
106 106
     }
107
-    db_query("UPDATE {$this->default_table} SET ".implode(', ', $upd)." WHERE id={$this->data['id']};");
107
+    db_query("UPDATE {$this->default_table} SET ".implode(', ', $upd)." WHERE id=?", array($this->data['id']));
108 108
   }
109 109
 
110 110
   abstract function parse($data);
Browse code

Umstellung auf PDO-Datenbankverbindung

Bernd Wurst authored on 01/02/2014 18:38:23
Showing 1 changed files
... ...
@@ -14,7 +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/db_connect.php');
18 17
 require_once('inc/base.php');
19 18
 require_once('inc/debug.php');
20 19
 
... ...
@@ -57,7 +56,7 @@ abstract class KeksData
57 56
   {
58 57
     $fields = array();
59 58
     $res = db_query("DESCRIBE {$this->default_table}");
60
-    while ($f = mysql_fetch_object($res))
59
+    while ($f = $res->fetch(PDO::FETCH_OBJ))
61 60
     {
62 61
       $fields[$f->Field] = $f->Default;
63 62
     }
... ...
@@ -80,7 +79,7 @@ abstract class KeksData
80 79
     
81 80
     $res = db_query("SELECT {$fields} FROM {$table} {$where}");
82 81
     $return = array();
83
-    while ($arr = mysql_fetch_assoc($res))
82
+    while ($arr = $res->fetch())
84 83
       array_push($return, $arr);
85 84
     return $return;
86 85
   }
... ...
@@ -102,7 +101,7 @@ abstract class KeksData
102 101
     $upd = array();
103 102
     foreach ($this->changes as $key => $value)
104 103
     {
105
-      $value = mysql_real_escape_string($value);
104
+      $value = db_escape_string($value);
106 105
       array_push($upd, "`{$key}`='{$value}'");
107 106
     }
108 107
     db_query("UPDATE {$this->default_table} SET ".implode(', ', $upd)." WHERE id={$this->data['id']};");
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/db_connect.php');
4 18
 require_once('inc/base.php');
Browse code

schokokeks.org-Domain ist wieder benutzbar

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

bernd authored on 16/08/2007 20:08:27
Showing 1 changed files
... ...
@@ -31,7 +31,8 @@ abstract class KeksData
31 31
       $this->parse($this->raw_data);
32 32
     }
33 33
     elseif (array_key_exists($key, $this->data))
34
-      return false;
34
+      $this->data[$key] = $value;
35
+      // return false;
35 36
     elseif (isset($this->$key))
36 37
       $this->$key = $value;
37 38
     else
... ...
@@ -46,6 +47,8 @@ abstract class KeksData
46 47
     {
47 48
       $fields[$f->Field] = $f->Default;
48 49
     }
50
+    $this->raw_data = $fields;
51
+    $this->raw_data['id'] = NULL;
49 52
     $this->data = $fields;
50 53
     $this->data['id'] = NULL;
51 54
   }
Browse code

Cookie einen eindeutigen Namen geben

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

bernd authored on 26/07/2007 10:56:10
Showing 1 changed files
... ...
@@ -9,7 +9,9 @@ abstract class KeksData
9 9
 {
10 10
   protected $default_table;
11 11
   
12
+  protected $raw_data = array();
12 13
   protected $data = array();
14
+  protected $changes = array();
13 15
 
14 16
   function __get($key)
15 17
   {
... ...
@@ -22,8 +24,14 @@ abstract class KeksData
22 24
 
23 25
   function __set($key, $value)
24 26
   {
25
-    if (array_key_exists($key, $this->data))
26
-      $this->data[$key] = $value;
27
+    if (array_key_exists($key, $this->raw_data))
28
+    {
29
+      $this->raw_data[$key] = $value;
30
+      $this->changes[$key] = $value;
31
+      $this->parse($this->raw_data);
32
+    }
33
+    elseif (array_key_exists($key, $this->data))
34
+      return false;
27 35
     elseif (isset($this->$key))
28 36
       $this->$key = $value;
29 37
     else
... ...
@@ -64,6 +72,7 @@ abstract class KeksData
64 72
   function loadByID($id)
65 73
   {
66 74
     $id = (int) $id;
75
+    DEBUG("requested to load ID »{$id}«");
67 76
     $res = $this->getData('*', "id={$id} LIMIT 1");
68 77
     if (count($res) < 1)
69 78
       return false;
... ...
@@ -71,6 +80,17 @@ abstract class KeksData
71 80
   }
72 81
 
73 82
 
83
+  function save()
84
+  {
85
+    $upd = array();
86
+    foreach ($this->changes as $key => $value)
87
+    {
88
+      $value = mysql_real_escape_string($value);
89
+      array_push($upd, "`{$key}`='{$value}'");
90
+    }
91
+    db_query("UPDATE {$this->default_table} SET ".implode(', ', $upd)." WHERE id={$this->data['id']};");
92
+  }
93
+
74 94
   abstract function parse($data);
75 95
 
76 96
 }
Browse code

Domain-Klasse benutzen

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

bernd authored on 05/07/2007 18:43:18
Showing 1 changed files
... ...
@@ -39,6 +39,7 @@ abstract class KeksData
39 39
       $fields[$f->Field] = $f->Default;
40 40
     }
41 41
     $this->data = $fields;
42
+    $this->data['id'] = NULL;
42 43
   }
43 44
 
44 45
 
... ...
@@ -64,6 +65,8 @@ abstract class KeksData
64 65
   {
65 66
     $id = (int) $id;
66 67
     $res = $this->getData('*', "id={$id} LIMIT 1");
68
+    if (count($res) < 1)
69
+      return false;
67 70
     $this->parse($res[0]);
68 71
   }
69 72
 
Browse code

Ein paar neue Klassen

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

bernd authored on 05/07/2007 18:22:41
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,75 @@
1
+<?php
2
+
3
+require_once('inc/db_connect.php');
4
+require_once('inc/base.php');
5
+require_once('inc/debug.php');
6
+
7
+
8
+abstract class KeksData
9
+{
10
+  protected $default_table;
11
+  
12
+  protected $data = array();
13
+
14
+  function __get($key)
15
+  {
16
+    if (array_key_exists($key, $this->data))
17
+      return $this->data[$key];
18
+    elseif (isset($this->$key))
19
+      return $this->$key;
20
+    // else werfe fehler
21
+  }
22
+
23
+  function __set($key, $value)
24
+  {
25
+    if (array_key_exists($key, $this->data))
26
+      $this->data[$key] = $value;
27
+    elseif (isset($this->$key))
28
+      $this->$key = $value;
29
+    else
30
+      $this->data[$key] = $value;
31
+  }
32
+
33
+  protected function setup()
34
+  {
35
+    $fields = array();
36
+    $res = db_query("DESCRIBE {$this->default_table}");
37
+    while ($f = mysql_fetch_object($res))
38
+    {
39
+      $fields[$f->Field] = $f->Default;
40
+    }
41
+    $this->data = $fields;
42
+  }
43
+
44
+
45
+  function getData($fields, $restriction = NULL, $table = NULL)
46
+  {
47
+    $where = '';
48
+    if ($restriction)
49
+      $where = 'WHERE '.$restriction;
50
+    if (! $table)
51
+      $table = $this->default_table;
52
+    if (is_array($fields))
53
+      $fields = implode(',', $fields);
54
+    
55
+    $res = db_query("SELECT {$fields} FROM {$table} {$where}");
56
+    $return = array();
57
+    while ($arr = mysql_fetch_assoc($res))
58
+      array_push($return, $arr);
59
+    return $return;
60
+  }
61
+
62
+
63
+  function loadByID($id)
64
+  {
65
+    $id = (int) $id;
66
+    $res = $this->getData('*', "id={$id} LIMIT 1");
67
+    $this->parse($res[0]);
68
+  }
69
+
70
+
71
+  abstract function parse($data);
72
+
73
+}
74
+
75
+?>