JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
fix enc_ functions for image/thumb parts
[wfpl.git] / uploader.php
index 0c962c2..e661882 100644 (file)
@@ -1,9 +1,25 @@
 <?php
 
-require_once('code/wfpl/template.php');
-require_once('code/wfpl/encode.php');
-require_once('code/wfpl/session.php');
-require_once('code/wfpl/upload.php'); # FIXME for path_to() which should be somewhere else
+#  Copyright (C) 2007 Jason Woofenden
+#
+#  This program is free software: you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation, either version 3 of the License, or
+#  (at your option) any later version.
+#  
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#  
+#  You should have received a copy of the GNU General Public License
+#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+
+require_once(__DIR__.'/'.'template.php');
+require_once(__DIR__.'/'.'encode.php');
+require_once(__DIR__.'/'.'session.php');
+require_once(__DIR__.'/'.'upload.php'); # FIXME for path_to() which should be somewhere else
 
 # This function is for making an uploader with a progress bar.
 #
@@ -35,17 +51,17 @@ function uploader($progress_url = '') {
        }
 
        $html = new tem();
-       $html->load('code/wfpl/uploader/uploader.html');
+       $html->load(__DIR__.'/'.'uploader/uploader.html');
        $html->set('filename', $filename);
        $html->set('host', $GLOBALS['wfpl_uploader_host']);
        $html->set('port', $GLOBALS['wfpl_uploader_port']);
        $html->show('main');
        $html = $html->get('main');
 
-       $css = read_whole_file('code/wfpl/uploader/uploader.css');
+       $css = read_whole_file(__DIR__.'/'.'uploader/uploader.css');
 
        $javascript = new tem();
-       $javascript->load('code/wfpl/uploader/progress.js');
+       $javascript->load(__DIR__.'/'.'uploader/progress.js');
        $javascript->set('url', $progress_url);
        $javascript = $javascript->run();
 
@@ -64,7 +80,7 @@ function uploader_move($tmp_filename, $filename) {
 # start a daemon to accept file uploads and give progress indicators
 # if the port is used (eg if the daemon is already running) this will do nothing.
 function uploader_daemon_start($port) {
-       exec(path_to('tcpserver') . " -q -R -H -llocalhost 0 $port " . path_to('perl') . ' code/wfpl/uploader/daemon.pl ' . $GLOBALS['wfpl_uploader_path'] . ' >/dev/null 2>/dev/null < /dev/null &');
+       exec(path_to('tcpserver') . " -q -R -H -llocalhost 0 $port " . path_to('perl') . ' lib/wfpl/uploader/daemon.pl ' . $GLOBALS['wfpl_uploader_path'] . ' >/dev/null 2>/dev/null < /dev/null &');
 }
 
 /* call this to respond to the javascript async request for progress on the upload */
@@ -78,8 +94,8 @@ function wfpl_uploader_progress() {
 
        $file = $_REQUEST['wfpl_upload_progress'];
        $file = strtolower($file);
-       $file = ereg_replace('[^a-z0-9.-]', '_', $file);
-       $file = ereg_replace('^[.-]', '_', $file);
+       $file = preg_replace('|[^a-z0-9.-]|', '_', $file);
+       $file = preg_replace('|^[.-]|', '_', $file);
        $file = $GLOBALS['wfpl_uploader_path'] . "/progress/$file";
        
        $waited = 0;