summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcreateentities26
-rw-r--r--forum/utils/users.php8
2 files changed, 11 insertions, 23 deletions
diff --git a/createentities b/createentities
index db9845d..6b6c775 100755
--- a/createentities
+++ b/createentities
@@ -3,21 +3,8 @@
GROUP="apache"
#
-# Create user files
+# Create user file
#
-if test -f forum/data/users.xml
-then
- echo "forum/data/users.xml already exists."
-else
- echo "Creating forum/data/users.xml"
- echo "<?xml version='1.0' encoding='UTF-8'?>" > forum/data/users.xml
- echo "<users>" >> forum/data/users.xml
- echo " <user enabled='on' uid='0' gid='0' notified='0' username='admin' password='8456c0209aaa9ca04730a3160caf6e5e6b5ea389' name='Administrator' avatar='default.gif' email=''/>" >> forum/data/users.xml
- echo "</users>" >> forum/data/users.xml
- chgrp $GROUP forum/data/users.xml
- chmod g+wr forum/data/users.xml
-fi
-
if test -f data/users.xml
then
echo "data/users.xml already exists."
@@ -65,20 +52,15 @@ fi
#
-# Create a forum
+# Create a forum storage dir
#
if test -d forum/data/forum
then
echo "forum/data/forum already exists"
else
mkdir forum/data/forum
- echo "<?xml version='1.0' encoding='UTF-8'?>" > forum/data/forum/forums.xml
- echo "<forums>" >> forum/data/forum/forums.xml
- echo " <forum fid='1' readlist='1' writelist='1' name='Test Forum'/>" >> forum/data/forum/forums.xml
- echo "</forums>" >> forum/data/forum/forums.xml
- mkdir forum/data/forum/1
- chgrp $GROUP forum/data/forum/1
- chmod g+w forum/data/forum/1
+ chgrp $GROUP forum/data/forum
+ chmod g+w forum/data/forum
fi
#
diff --git a/forum/utils/users.php b/forum/utils/users.php
index 99aaffc..93cc23c 100644
--- a/forum/utils/users.php
+++ b/forum/utils/users.php
@@ -129,7 +129,13 @@ class Users {
public function Users($file)
{
$this->file = $file;
- $this->read();
+ if(file_exists($file)) $this->read();
+ else {
+ // Create default users.xml file.
+ $user = new User(true, 0, 0, "admin", "8456c0209aaa9ca04730a3160caf6e5e6b5ea389", "Administrator", "", "", 0);
+ $this->add($user);
+ $this->write();
+ }
}
}