summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2008-10-12 08:55:05 +0000
committerdeva <deva>2008-10-12 08:55:05 +0000
commit2fcc8a388b27747bb534f0beba18114720f9b899 (patch)
tree52fe5737c6f2c43982cfedb10f2f58db1dd84c9d
parentb3bfcb9e6f512b2074dc69bf1af148ec4f4973d4 (diff)
Now files, forums and image cache create their storage dirs themselves, instead of createentities (when they do not already exists that is...)
-rwxr-xr-xcreateentities40
-rw-r--r--forum/utils/files.php20
-rw-r--r--forum/utils/forums.php18
-rw-r--r--forum/utils/imagecache.php12
-rw-r--r--forum/utils/parser.php2
5 files changed, 48 insertions, 44 deletions
diff --git a/createentities b/createentities
index 6b6c775..1ea8d53 100755
--- a/createentities
+++ b/createentities
@@ -18,8 +18,6 @@ else
chmod g+wr data/users.xml
fi
-
-
#
# Create config files
#
@@ -49,41 +47,3 @@ else
echo "Creating htdocs/forum symlink"
(cd htdocs; ln ../forum/htdocs forum -s)
fi
-
-
-#
-# Create a forum storage dir
-#
-if test -d forum/data/forum
-then
- echo "forum/data/forum already exists"
-else
- mkdir forum/data/forum
- chgrp $GROUP forum/data/forum
- chmod g+w forum/data/forum
-fi
-
-#
-# Create imagecache
-#
-if test -d forum/data/imagecache
-then
- echo "forum/data/imagecache already exists"
-else
- mkdir forum/data/imagecache
- chgrp $GROUP forum/data/imagecache
- chmod g+w forum/data/imagecache
-fi
-
-#
-# Create files
-#
-if test -d forum/data/files
-then
- echo "forum/data/files already exists"
-else
- mkdir forum/data/files
- chgrp $GROUP forum/data/files
- chmod g+w forum/data/files
-fi
-
diff --git a/forum/utils/files.php b/forum/utils/files.php
index 6cae023..c698ede 100644
--- a/forum/utils/files.php
+++ b/forum/utils/files.php
@@ -125,9 +125,25 @@ class Files {
public function Files($file)
{
+ global $PERMSTORE;
+
$this->file = $file;
- $this->read();
- }
+ if(file_exists($file)) $this->read();
+ if(!file_exists($PERMSTORE)) {
+ if(!mkdir($PERMSTORE)) {
+ echo"Could not create directory: " . $PERMSTORE;
+ die();
+ }
+ }
+ if(!is_dir($PERMSTORE)) {
+ echo $PERMSTORE . " exists but is not a directory";
+ die();
+ }
+ if(!is_readable($PERMSTORE) || !is_writeable($PERMSTORE) || !is_executable($PERMSTORE)) {
+ echo $PERMSTORE . " exists but does not have the correct permissions. (r/w/x)";
+ die();
+ }
+ }
}
?> \ No newline at end of file
diff --git a/forum/utils/forums.php b/forum/utils/forums.php
index 85e977b..1ee2eb9 100644
--- a/forum/utils/forums.php
+++ b/forum/utils/forums.php
@@ -100,6 +100,24 @@ class Forums {
{
$this->file = $file;
if(file_exists($file)) $this->read();
+ else {
+ if(!file_exists(dirname($file))) {
+ if(!mkdir(dirname($file))) {
+ echo"Could not create directory: " . dirname($file);
+ die();
+ }
+ } else {
+ if(!is_dir(dirname($file))) {
+ echo dirname($file) . " exists but is not a directory";
+ die();
+ } else {
+ if(!is_readable(dirname($file)) || !is_writeable(dirname($file)) || !is_executable(dirname($file))) {
+ echo dirname($file) . " exists but does not have the correct permissions. (r/w/x)";
+ die();
+ }
+ }
+ }
+ }
}
}
diff --git a/forum/utils/imagecache.php b/forum/utils/imagecache.php
index aae5e66..ac3ebc3 100644
--- a/forum/utils/imagecache.php
+++ b/forum/utils/imagecache.php
@@ -40,6 +40,16 @@ function getCachedImage($filename)
global $IMAGECACHE;
$fullfilename = $IMAGECACHE . "/" . urlencode($filename);
+ // Test the storage dir
+ if(!file_exists($IMAGECACHE)) {
+ if(!mkdir($IMAGECACHE)) errorImage("Could not create directory: " . $IMAGECACHE);
+ }
+ if(!is_dir($IMAGECACHE)) errorImage($IMAGECACHE . " exists but is not a directory");
+ if(!is_readable($IMAGECACHE) || !is_writeable($IMAGECACHE) || !is_executable($IMAGECACHE)) {
+ errorImage($IMAGECACHE . " exists but does not have the correct permissions. (r/w/x)");
+ }
+ // end of dir test
+
if(!file_exists($fullfilename)) {
$url = parse_url($filename);
@@ -49,7 +59,7 @@ function getCachedImage($filename)
error_reporting(E_ERROR | E_PARSE);
- switch(tolower($filetype)) {
+ switch(strtolower($filetype)) {
case ".jpeg":
case ".jpg":
$image = imagecreatefromjpeg(urldecode($filename));
diff --git a/forum/utils/parser.php b/forum/utils/parser.php
index b5a80b7..ecf8913 100644
--- a/forum/utils/parser.php
+++ b/forum/utils/parser.php
@@ -39,7 +39,7 @@ function parse($input, $indent = "")
while(strpos($output, $imgendmarker)) $imgendmarker .= $imgendsymbol;
// Find and mark image URLs (so that they don't get converted into normal <a/> links)
- $output = preg_replace("/http:\/\/(.*\.jpg|\.gif|\.png|\.jpeg)/", $imgstartmarker."$1".$imgendmarker, $output);
+ $output = preg_replace("/http:\/\/(.*\.jpg|.*\.gif|.*\.png|.*\.jpeg)/", $imgstartmarker."$1".$imgendmarker, $output);
// Replace URLs with <a></a> tags
$output = preg_replace("/http:\/\/(.*?)([\n ])/s", "<a href=\"http://$1\">$1</a>$2", $output);