summaryrefslogtreecommitdiffstats
path: root/code
diff options
context:
space:
mode:
authorneoraider <devnull@localhost>2006-01-09 20:49:02 +0100
committerneoraider <devnull@localhost>2006-01-09 20:49:02 +0100
commit73d5e907a797e976e59f328d4f2fd0b8bfcebde6 (patch)
tree98108e9738db75d2688de5f7a68c72253c54c450 /code
parent61f7b4cc39a399a16298453acbe5a8f49ad0513d (diff)
downloadneon-73d5e907a797e976e59f328d4f2fd0b8bfcebde6.tar
neon-73d5e907a797e976e59f328d4f2fd0b8bfcebde6.zip
Allgemein ist jetzt alles etwas weiter. Vieles ist jetzt durch Klassen gel?st, und einige andere Teile von Neon sind jetzt besser strukturiert.
Diffstat (limited to 'code')
-rw-r--r--code/content.inc.php10
-rw-r--r--code/handlers.inc.php13
-rw-r--r--code/message.inc.php4
-rw-r--r--code/user.inc.php33
-rw-r--r--code/util.inc.php2
5 files changed, 57 insertions, 5 deletions
diff --git a/code/content.inc.php b/code/content.inc.php
index 5fc2d76..c92f1b2 100644
--- a/code/content.inc.php
+++ b/code/content.inc.php
@@ -3,15 +3,19 @@
define('CONTENT_INC', 1);
include('code/db.inc.php');
+ include('code/user.inc.php');
+ include('code/handlers.inc.php');
function GetPage($name) {
$res = DBQuery('SELECT access, handler, data FROM pages WHERE name = ?', $name);
- parse_str($res->fields[2], $data);
+ if(($res->fields[0] & (1 << $GLOBALS['user']->GetGid())) == 0)
+ return $GLOBALS['handlers'][$res->fields[1]]->HandleErrorMessage('Forbidden', array('page' => $name));
- include('handlers/' . $res->fields[1]);
+ parse_str($res->fields[2], $data);
+ $data['_page'] = $name;
- return $handlers[$res->fields[1]]($data);
+ return $GLOBALS['handlers'][$res->fields[1]]->HandleContentData($data);
}
}
?>
diff --git a/code/handlers.inc.php b/code/handlers.inc.php
new file mode 100644
index 0000000..d259273
--- /dev/null
+++ b/code/handlers.inc.php
@@ -0,0 +1,13 @@
+<?PHP
+ if(!defined('HANDLERS_INC')) {
+ define('HANDLERS_INC', 1);
+
+ $dir = opendir('handlers');
+
+ while($file = readdir($dir))
+ if($file[0] != '.')
+ include('handlers/' . $file);
+
+ closedir($dir);
+ }
+?>
diff --git a/code/message.inc.php b/code/message.inc.php
index 7f9343d..8e0a3f0 100644
--- a/code/message.inc.php
+++ b/code/message.inc.php
@@ -12,8 +12,8 @@
if($config['language'] != 'en') @include('lang/' . $config['language'] . '.inc.php');
- function Message($type, $subst = array()) {
- return Subst($GLOBALS['message'][$type], $subst);
+ function Message($type, $data = array()) {
+ return Subst($GLOBALS['message'][$type], $data);
}
}
?>
diff --git a/code/user.inc.php b/code/user.inc.php
new file mode 100644
index 0000000..00c7355
--- /dev/null
+++ b/code/user.inc.php
@@ -0,0 +1,33 @@
+<?PHP
+ if(!defined('USER_INC')) {
+ define('USER_INC', 1);
+
+ include('code/db.inc.php');
+
+ class User {
+ var $uid = 0, $gid = 0;
+
+ function User() {
+ if($_GET['id'] && $_GET['sid']) {
+ $res = DBQuery('SELECT id, gid FROM users WHERE id = ? AND sid = ?',
+ array($_GET['id'],$_GET['sid']));
+
+ if($res->RecordCount()) {
+ $this->uid = $res->fields[0];
+ $this->gid = $res->fields[1];
+ }
+ }
+ }
+
+ function GetUid() {
+ return $this->uid;
+ }
+
+ function GetGid() {
+ return $this->gid;
+ }
+ }
+
+ $user = new User;
+ }
+?>
diff --git a/code/util.inc.php b/code/util.inc.php
index 275d3c7..c2a8adf 100644
--- a/code/util.inc.php
+++ b/code/util.inc.php
@@ -8,6 +8,8 @@
foreach($subst as $key => $value)
$tr['$' . $key] = $value;
+ krsort($tr);
+
return strtr($string, $tr);
}
}