class squashweb {
-var $basepath;
var $configs = array();
var $files = array();
var $subfolders = array();
var $userrights;
var $history = array();
-function set_root($root) {
- $this->basepath = $root;
-}
-
function get_configs() {
return $this->configs;
}
for ($i=0; $i<$depth; $i++)
$layout .= " ";
- if ($dir = opendir($path)) {
+ if ($dir = opendir(SQUASHER_UPLOADS_DIR.$path)) {
$layout .= "<div style='clear:both;' >\n";
$f = 0;
while (false !== ($file = readdir($dir))) {
foreach ($files_array as $f_index => $file) {
if (($file{0} !== ".") && ($file !== ".."))
{
- $filename = $path."/".$file;
- if (!is_file($filename) && $this->got_rights_array($filename) > 0) {
+ $filename = $path=='/' ? $path.$file : $path.'/'.$file;
+ if (!is_file(SQUASHER_UPLOADS_DIR.$filename) && $this->got_rights_array($filename) > 0) {
$f++;
- if (substr($filename,0,strlen($this->basepath))==$this->basepath)
- $name = substr($filename,strlen($this->basepath));
+ $name = $filename;
$check = $this->got_rights_array_admin($filename, $this->userrights);
$check_all = '';
$check_allow = '';
if (!is_array($haystack))
$haystack = $this->folderrights;
- if (substr($needle, 0, strlen($this->basepath)) == $this->basepath)
- $needle=substr($needle,strlen($this->basepath));
// check root rights
if ($needle{0} == '/' && @$haystack['__access__'] == 2 )
if (!is_array($haystack))
$haystack = $this->folderrights;
- if (substr($needle, 0, strlen($this->basepath)) == $this->basepath)
- $needle = substr($needle, strlen($this->basepath));
// check root rights
if ($needle{0} == '/' && @$haystack['__access__'] == 2 )
if (!is_array($haystack))
$haystack = $this->folderrights;
- if (substr($needle, 0, strlen($this->basepath)) == $this->basepath)
- $needle=substr($needle, strlen($this->basepath));
// check root rights
if($needle{0}=='/' && @$haystack['__access__'] == 2 )
}
function read_single_file($path, $file) {
- $filename = $path."/".$file;
+ $filename = $path=='/' ? $path.$file : $path.'/'.$file;
+ $fsfilename = SQUASHER_UPLOADS_DIR.$filename; // name on the file system
$i = 0;
if ($this->got_rights_array($path) > 0) {
- if (is_file($filename.'.Completed'))
- $file.='.Completed';
- if (is_file($filename.'.InProgress'))
- $file.='.InProgress';
- if (is_file($filename.'.Starting'))
- $file.='.Starting';
- if (is_file($filename.'.Processed'))
- $file.='.Processed';
- $filename = $path . "/" . $file;
- $handle = @fopen($filename, "rb");
- if (strpos($file,'.Completed'))
+ if (is_file($fsfilename.'.Completed'))
$ext='.Completed';
- if (strpos($file,'.InProgress'))
+ if (is_file($fsfilename.'.InProgress'))
$ext='.InProgress';
- if (strpos($file,'.Starting'))
+ if (is_file($fsfilename.'.Starting'))
$ext='.Starting';
- if (strpos($file,'.Processed'))
+ if (is_file($fsfilename.'.Processed'))
$ext='.Processed';
+ $fsfilename .= $ext;
+ $handle = @fopen($fsfilename, "rb");
$sub_pos = strpos($file, $ext);
$base_name = substr($file, 0, $sub_pos);
- $filecontent = @fread($handle, @filesize($filename));
+ $filecontent = @fread($handle, @filesize($fsfilename));
$config[$i] = explode("\r\n", $filecontent);
/***
* $config:: array
* [5] -> chunkcount
* [6] -> CRC32 checksum
***/
- if (@filesize($filename) > 0) {
+ if (@filesize($fsfilename) > 0) {
$h = md5($path."/".$config[$i][2]);
$this->configs[$h] = $config[$i];
$this->configs[$h]['squashed'] = true;
$this->configs[$h]['path'] = $path;
$this->configs[$h]['status'] = substr($ext, 1);
$this->configs[$h]['mime'] = $this->set_mime($this->configs[$h][2]);
- $this->configs[$h]['hidden'] = (is_file($path.'/'.$base_name.'.hidden')) ? true : false ;
+ $this->configs[$h]['hidden'] = is_file(SQUASHER_UPLOADS_DIR.$path.'/'.$base_name.'.hidden');
//to prevent dates of 1-1-1970 we set te dates of the config file
- $this->configs[$h]['added'] = filectime($filename);
- $this->configs[$h]['lastchange'] = filemtime($filename);
+ $this->configs[$h]['added'] = filectime($fsfilename);
+ $this->configs[$h]['lastchange'] = filemtime($fsfilename);
fclose($handle);
$this->populate_stats($path, $h);
//insert hash in db
function read_directory($path, $getsubs=false, $getfirstfiles=true, $getdeepfiles=true, $populate=true) {
-
- if ($dir = @opendir($path)) {
- $i = 0;
- $last = 1;
- while (false !== ($file = readdir($dir))) {
- if (($file{0} !== ".") && substr($file,0,1) !== "SQ") {
- $filename = $path."/".$file;
- if (!is_file($filename) && strpos($filename, './uploads/recieving')===false) {
- if ($getsubs) {
- if ($this->got_rights_array_recursive($filename) > 0) {
- $key = substr($path, strlen($this->basepath)) . '/' . $file;
- $this->subfolders[$key] = $file;
- }
- }
- if ($getdeepfiles)
- $this->read_directory($filename, false, $getdeepfiles, $getdeepfiles, $populate);
- } elseif (strpos($filename,'./uploads/ftp')) { //ftp files
- if ($this->got_rights_array($path) > 0 && !strpos($filename, '.hidden') ) {
- $h = md5($filename);
- $name_only = substr($filename, strlen($path)+1);
- $file_structure = explode('.', $name_only);
- $ext = array_pop($file_structure);
- $base_name = array_pop($file_structure);
+ $fsdir = $path=='/' ? SQUASHER_UPLOADS_DIR : SQUASHER_UPLOADS_DIR.$path;
+ $hdir = @opendir(SQUASHER_UPLOADS_DIR.$path);
+ if (!$hdir)
+ return;
+ $i = 0;
+ while (false !== ($file = readdir($hdir))) {
+ if ($file{0} == "." || substr($file,0,2) == "SQ")
+ continue; // skip this file
+ $filename = $path=='/' ? $path.$file : $path.'/'.$file;
+ $fsfilename = SQUASHER_UPLOADS_DIR.$filename; // name on the file system
+ if (!is_file($fsfilename) && strpos($filename, '/recieving/')!==0) {
+ if ($getsubs) {
+ if ($this->got_rights_array_recursive($filename) > 0) {
+ $key = $path;
+ if ($key != '/')
+ $key .= '/';
+ $key .= $file;
+ $this->subfolders[$key] = $file;
+ }
+ }
+ if ($getdeepfiles)
+ $this->read_directory($filename, false, $getdeepfiles, $getdeepfiles, $populate);
+ } elseif (strpos($filename,'/ftp/')===0) {
+ //ftp files
+ if ($this->got_rights_array($path) > 0 && !strpos($filename, '.hidden') ) {
+ $h = md5($filename);
+ $name_only = substr($filename, strlen($path)+1); // this is $file
+ $file_structure = explode('.', $name_only); // array of dot separated name fragment
+ $ext = array_pop($file_structure); // extension
+ $base_name = array_pop($file_structure); // (erk)
+ $this->configs[$h]['path'] = $path;
+ $this->configs[$h][0] = 'manual ftp';
+ $this->configs[$h][2] = $name_only;
+ $this->configs[$h][3] = filesize($fsfilename);
+ $this->configs[$h]['added'] = filectime($fsfilename);
+ $this->configs[$h]['lastchange'] = filemtime($fsfilename);
+ $this->configs[$h]['status'] = 'unknown';
+ $this->configs[$h]['squashed'] = false;
+ $this->configs[$h]['mime'] = $this->set_mime($name_only);
+ $this->configs[$h]['hidden'] = is_file(SQUASHER_UPLOADS_DIR.$path.'/'.$base_name.'.hidden');
+ }
+ } elseif ($getfirstfiles) {
+ //squashed files
+ if ($this->got_rights_array($path) > 0) {
+ if (strpos($filename, '.Completed') || strpos($filename, '.InProgress') || strpos($filename, '.Starting') || strpos($filename, '.Processed')) {
+ $i++;
+ $handle = @fopen($fsfilename, "rb");
+ if (strpos($file,'.Completed'))
+ $ext='.Completed';
+ if (strpos($file,'.InProgress'))
+ $ext='.InProgress';
+ if (strpos($file,'.Starting'))
+ $ext='.Starting';
+ if (strpos($file,'.Processed'))
+ $ext='.Processed';
+ $sub_pos = strpos($file, $ext);
+ $base_name = substr($file, 0, $sub_pos);
+ $filecontent = @fread($handle, @filesize($fsfilename));
+ $config[$i] = explode("\r\n", $filecontent);
+
+ /***
+ * $config:: array
+ * [0] -> versioncode
+ * [1] -> date&time
+ * [2] -> filename
+ * [3] -> filesize
+ * [4] -> chunksize
+ * [5] -> chunkcount
+ * [6] -> CRC32 checksum
+ ***/
+
+ if (@filesize($fsfilename) > 0) {
+ $h = md5($path."/".$config[$i][2]);
+ $this->configs[$h] = $config[$i];
+ $this->configs[$h]['squashed'] = true;
$this->configs[$h]['path'] = $path;
- $this->configs[$h][0] = 'manual ftp';
- $this->configs[$h][2] = $name_only;
- $this->configs[$h][3] = filesize($filename);
- $this->configs[$h]['added'] = filectime($filename);
- $this->configs[$h]['lastchange'] = filemtime($filename);
- $this->configs[$h]['status'] = 'unknown';
- $this->configs[$h]['squashed'] = false;
- $this->configs[$h]['mime'] = $this->set_mime($name_only);
- $this->configs[$h]['hidden'] = (is_file($path.'/'.$base_name.'.hidden')) ? true : false ;
- }
- } elseif ($getfirstfiles) {
- //squashed files
- if ($this->got_rights_array($path) > 0) {
- if (strpos($filename, '.Completed') || strpos($filename, '.InProgress') || strpos($filename, '.Starting') || strpos($filename, '.Processed')) {
- $i++;
- $handle = @fopen($filename, "rb");
- if (strpos($file,'.Completed'))
- $ext='.Completed';
- if (strpos($file,'.InProgress'))
- $ext='.InProgress';
- if (strpos($file,'.Starting'))
- $ext='.Starting';
- if (strpos($file,'.Processed'))
- $ext='.Processed';
- $sub_pos = strpos($file, $ext);
- $base_name = substr($file, 0, $sub_pos);
- $filecontent = @fread($handle, @filesize($filename));
- $config[$i] = explode("\r\n", $filecontent);
-
- /***
- * $config:: array
- * [0] -> versioncode
- * [1] -> date&time
- * [2] -> filename
- * [3] -> filesize
- * [4] -> chunksize
- * [5] -> chunkcount
- * [6] -> CRC32 checksum
- ***/
-
- if (@filesize($filename) > 0) {
- $h = md5($path."/".$config[$i][2]);
- $this->configs[$h] = $config[$i];
- $this->configs[$h]['squashed'] = true;
- $this->configs[$h]['path'] = $path;
- $this->configs[$h]['status'] = substr($ext, 1);
- $this->configs[$h]['mime'] = $this->set_mime($this->configs[$h][2]);
- $this->configs[$h]['hidden'] = (is_file($path.'/'.$base_name.'.hidden')) ? true : false ;
- //to prevent dates of 1-1-1970 we set te dates of the config file
- $this->configs[$h]['added'] = filectime($filename);
- $this->configs[$h]['lastchange'] = filemtime($filename);
- fclose($handle);
- $this->populate_stats($path, $h);
- //insert hash in db
- $this->update_hash($h, $path."/".$config[$i][2]);
- //check stats
- $this->check_stats($h);
- }
- }
+ $this->configs[$h]['status'] = substr($ext, 1);
+ $this->configs[$h]['mime'] = $this->set_mime($this->configs[$h][2]);
+ $this->configs[$h]['hidden'] = is_file(SQUASHER_UPLOADS_DIR.$path.'/'.$base_name.'.hidden');
+ //to prevent dates of 1-1-1970 we set te dates of the config file
+ $this->configs[$h]['added'] = filectime($fsfilename);
+ $this->configs[$h]['lastchange'] = filemtime($fsfilename);
+ fclose($handle);
+ $this->populate_stats($path, $h);
+ //insert hash in db
+ $this->update_hash($h, $path."/".$config[$i][2]);
+ //check stats
+ $this->check_stats($h);
}
}
}
}
}
+ closedir($hdir);
}
function check_stats($h) {
$filepath=$config['path'].'/'.$config[2];
if ($this->history[$h]['completed']=="1") {
//don't display broken file, remove it instead
- unlink($config['path'].'/'.$config[2].'.Completed');
+ unlink(SQUASHER_UPLOADS_DIR.$config['path'].'/'.$config[2].'.Completed');
unset($this->configs[$h]);
if (!$count)
mysql_query($qlog);
} else {
//do move
- rename($config['path'].'/'.$config[2].'.Completed', $config['path'].'/'.$config[2].'.InProgress');
+ rename(SQUASHER_UPLOADS_DIR.$config['path'].'/'.$config[2].'.Completed',
+ SQUASHER_UPLOADS_DIR.$config['path'].'/'.$config[2].'.InProgress');
$this->configs[$h]['status'] = 'InProgress';
//mail n4m
}
}
+/* unused function */
+/*
function path_to_arraystring($path, $arrayname) {
$path_values = explode('/', $path);
$return = $arrayname;
$return.= "['".$value."']";
}
return $return;
-}
+} */
function populate_stats($path, $h) {
/***
if ($this->history[$h]['completed']=="1") {
$file_part = $path."/SQ".zfill(1,6)."-".$config[2];
- if (!is_file($file_part))
+ if (!is_file(SQUASHER_UPLOADS_DIR.$file_part))
$file_part = $path."/SQ".zfill(1,3)."-".$config[2];
- if (is_file($file_part)) {
- $this->configs[$h]['added'] = filectime($file_part);
+ if (is_file(SQUASHER_UPLOADS_DIR.$file_part)) {
+ $this->configs[$h]['added'] = filectime(SQUASHER_UPLOADS_DIR.$file_part);
$file_part = $path."/SQ".zfill($config[5],6)."-".$config[2];
- if (!is_file($file_part))
+ if (!is_file(SQUASHER_UPLOADS_DIR.$file_part))
$file_part = $path."/SQ".zfill($config[5],3)."-".$config[2];
- if (is_file($file_part))
- $this->configs[$h]['lastchange'] = filemtime($file_part);
+ if (is_file(SQUASHER_UPLOADS_DIR.$file_part))
+ $this->configs[$h]['lastchange'] = filemtime(SQUASHER_UPLOADS_DIR.$file_part);
for ($i=1; $i<=$config[5]; $i++)
$this->configs[$h]['stats'][$i] = "1.00";
} else {
$this->configs[$h]['stats'][$i]="1.00";
} else {
$file_part = $path."/SQ".zfill($i,6)."-".$config[2];
- if (!is_file($file_part))
+ if (!is_file(SQUASHER_UPLOADS_DIR.$file_part))
$file_part = $path."/SQ".zfill($i,3)."-".$config[2];
- if (is_file($file_part)) {
- $handle = fopen($file_part, "rb");
- $size_this = filesize($file_part);
- $added = filectime($file_part);
- $last_changed = filemtime($file_part);
+ if (is_file(SQUASHER_UPLOADS_DIR.$file_part)) {
+ $handle = fopen(SQUASHER_UPLOADS_DIR.$file_part, "rb");
+ $size_this = filesize(SQUASHER_UPLOADS_DIR.$file_part);
+ $added = filectime(SQUASHER_UPLOADS_DIR.$file_part);
+ $last_changed = filemtime(SQUASHER_UPLOADS_DIR.$file_part);
if ($this->configs[$h]['added'] > $added || !is_numeric($this->configs[$h]['added']))
$this->configs[$h]['added'] = $added;
if ($this->configs[$h]['lastchange'] < $last_changed)
}
}
+
+/* unused function
function read_config($path, $filename) {
if (is_file($path."/".$filename.".InProgress")) {
$config_handle = fopen($path."/".$filename.".InProgress", "r");
$config = explode("\n", $config_content);
return $config;
+}
+*/
// print_r($config);
/* $file_count = $config[5];
$last=1;
}
return $merged_file;
*/
-}
+/**
+ * Outputs one file (echo)
+ * @param string $path Absolute path within SQUASHER_UPLOADS_DIR
+ * @param string $filename File name in $path
+ * @param bool $tovar Returns content rather than outputing it
+ * @return file content if $tovar; or void
+ */
function print_files($path, $filename, $tovar=false) {
- if (strpos($path, './uploads/ftp')) {
- $filestring = $path.'/'.$filename;
- if (is_file($filestring)) {
- $handle = fopen($filestring, "rb");
+ $fsfilename = SQUASHER_UPLOADS_DIR.$path.'/'.$filename;
+ if (strpos($path.'/', '/ftp/')===0) {
+ if (is_file($fsfilename)) {
+ $handle = fopen($fsfilename, 'rb');
while (!feof($handle))
{
print(fread($handle, 1024));
}
}
} else {
- if (is_file($path."/".$filename.".InProgress")) {
- $config_handle = fopen($path."/".$filename.".InProgress", "r");
- $conf_path=$path."/".$filename.".InProgress";
- } elseif (is_file($path."/".$filename.".Completed" )) {
- $config_handle = fopen($path."/".$filename.".Completed", "r");
- $conf_path=$path."/".$filename.".Completed";
- } elseif (is_file($path."/".$filename.".Starting" )) {
- $config_handle = fopen($path."/".$filename.".Starting", "r");
- $conf_path=$path."/".$filename.".Starting";
- } elseif (is_file($path."/".$filename.".Processed" )) {
- $config_handle = fopen($path."/".$filename.".Processed", "r");
- $conf_path=$path."/".$filename.".Processed";
- } else{
- return "Not Found";
- }
+ if (is_file($fsfilename.'.InProgress'))
+ $conf_path = $fsfilename.'.InProgress';
+ elseif (is_file($fsfilename.'.Completed' ))
+ $conf_path = $fsfilename.'.Completed';
+ elseif (is_file($fsfilename.'.Starting' ))
+ $conf_path = $fsfilename.'.Starting';
+ elseif (is_file($fsfilename.'.Processed' ))
+ $conf_path = $fsfilename.'.Processed';
+ else
+ return 'Not Found';
+ $config_handle = fopen($conf_path, 'r');
$config_content = fread($config_handle, filesize($conf_path));
fclose($config_handle);
$config = explode("\n",$config_content);
$last_part_size = ( $config[3] - ( ( $config[5] -1 ) * $config[4] ) );
for ($i=0;$i<=$file_count;$i++)
{
- $file_part = $path."/SQ".zfill($i,6)."-".$filename;
+ $file_part = SQUASHER_UPLOADS_DIR.$path."/SQ".zfill($i,6)."-".$filename;
if (!is_file($file_part))
$file_part = $path."/SQ".zfill($i,3)."-".$filename;
if (is_file($file_part))
}
}
+/* unused function */
+/*
function check_md5($h) {
$return = false;
$config = $this->configs[$h];
$return=true;
return $return;
-}
+} */
+/* unused function */
+/*
function file_crc($file_string) {
//$file_string = file_get_contents($file);
$crc = crc32($file_string);
return sprintf("%u\n", $crc);
-}
+} */
+/* unused function */
+/*
function file_crc_debug($file) {
$file_string = file_get_contents($file);
$crc = crc32($file_string);
return sprintf("%u\n", $crc);
-}
-
+} */
+
+/**
+ * Delete one file
+ *
+ * @param string $h Md5 hash of the file path, in lower case
+ * @param array $s Session credidentials
+ */
function delete_file($h, $s) {
$request = $this->get_config($h);
- $filepath=$request['path'].'/'.$request[2];
- if (strpos($request['path'], './uploads/ftp')) {
+ $filepath = $request['path'].'/'.$request[2];
+ if (strpos($request['path'], '/ftp/')===0) {
#remove file
- if (is_file($filepath))
- @unlink($filepath);
- if (is_file($filepath.'.hidden'))
- @unlink($filepath.'.hidden');
+ $fsfilepath = SQUASHER_UPLOADS_DIR.$filepath;
+ if (is_file($fsfilepath))
+ @unlink($fsfilepath);
+ if (is_file($fsfilepath.'.hidden'))
+ @unlink($fsfilepath.'.hidden');
} else {
+ $fspath = SQUASHER_UPLOADS_DIR.$request['path'];
#remove fileparts
for ($i=0;$i<=$request[5];$i++) {
- $part_six = $request['path']."/SQ".zfill($i,6)."-".$request[2];
- $part_three = $request['path']."/SQ".zfill($i,3)."-".$request[2];
+ $part_six = $fspath.'/SQ'.zfill($i,6).'-'.$request[2];
+ $part_three = $fspath.'/SQ'.zfill($i,3).'-'.$request[2];
if (is_file($part_six))
@unlink($part_six);
if (is_file($part_three))
- @unlink($part_six);
+ @unlink($part_three);
}
#remove config file
- if (is_file($request['path'].'/'.$request[2].'.hidden')) @unlink($request['path'].'/'.$request[2].'.hidden');
- if (is_file($request['path'].'/'.$request[2].'.Completed')) @unlink($request['path'].'/'.$request[2].'.Completed');
- if (is_file($request['path'].'/'.$request[2].'.InProgress'))@unlink($request['path'].'/'.$request[2].'.InProgress');
- if (is_file($request['path'].'/'.$request[2].'.Processed')) @unlink($request['path'].'/'.$request[2].'.Processed');
- if (is_file($request['path'].'/'.$request[2].'.Starting')) @unlink($request['path'].'/'.$request[2].'.Starting');
+ if (is_file($fspath.'/'.$request[2].'.hidden'))
+ @unlink($fspath.'/'.$request[2].'.hidden');
+ if (is_file($fspath.'/'.$request[2].'.Completed'))
+ @unlink($fspath.'/'.$request[2].'.Completed');
+ if (is_file($fspath.'/'.$request[2].'.InProgress'))
+ @unlink($fspath.'/'.$request[2].'.InProgress');
+ if (is_file($fspath.'/'.$request[2].'.Processed'))
+ @unlink($fspath.'/'.$request[2].'.Processed');
+ if (is_file($fspath.'/'.$request[2].'.Starting'))
+ @unlink($fspath.'/'.$request[2].'.Starting');
}
#Update DB
}
*/
+/**
+ * Get mime-type from filename
+ *
+ * Defaults to 'application/octet-stream'
+ *
+ * @param string $filename The filename with an extension
+ * @return string mime type
+ */
function set_mime($filename) {
$ext_arr = explode('.', $filename);
$ext = strtolower(array_pop($ext_arr));
$squashweb->update_history();
-//set root directory
-$basedir = "../uploads";
-if (isset($_GET['path']) && $_GET['path']!=NULL && strlen($_GET['path'])!=1) {
- $subf = $_GET['path'];
- $path = $basedir . $subf;
-} else {
- $subf = '/';
- $path = $basedir;
+$requestpath = @$_GET['path'];
+if (!$requestpath || strlen($requestpath)<1 || $requestpath[0]!='/') {
+ $requestpath = '/';
}
-$squashweb->set_root($basedir);
-
if (@$_GET['f'] || @$_GET['tools']=='hide' || @$_GET['tools']=='unhide' || @$_GET['tools']=='delete') {
$getdeepfiles=true;
$populate=false;
#$squashweb->read_directory($path, false, true, false, false);
} else {
//parse folders for readable files
- $squashweb->read_directory($path, true, true, $getdeepfiles, $populate);
+ $squashweb->read_directory($requestpath, true, true, $getdeepfiles, $populate);
}
//check if a file is requested
} elseif (@$_GET['tools']=="hide" && @$_GET['h']) {
if ($_SESSION['creds']['user_level'] > 99) {
$request = $squashweb->get_config($_GET['h']);
- $handle = fopen($request['path'].'/'.$request[2].'.hidden', 'x');
+ $handle = fopen(SQUASHER_UPLOADS_DIR.$request['path'].'/'.$request[2].'.hidden', 'x');
fwrite($handle, 'hidden by '.$_SESSION['creds']['user_name']);
fclose($handle);
- $path=substr($request['path'], strlen($basedir));
+ $path=$request['path'];
header( 'Location: '.$_SERVER['PHP_SELF'].'?path='.$path) ;
}
} elseif (@$_GET['tools']=="unhide" && isset($_GET['h'])) {
if ($_SESSION['creds']['user_level'] > 99) {
$request = $squashweb->get_config($_GET['h']);
- @unlink($request['path'].'/'.$request[2].'.hidden');
- $path=substr($request['path'], strlen($basedir));
+ @unlink(SQUASHER_UPLOADS_DIR.$request['path'].'/'.$request[2].'.hidden');
+ $path=$request['path'];
header( 'Location: '.$_SERVER['PHP_SELF'].'?path='.$path) ;
}
} elseif (@$_GET['tools']=="delete" && isset($_GET['h'])) {
$request = $squashweb->get_config($h);
$squashweb->delete_file($h, $_SESSION['creds']);
}
- $path=substr($request['path'], strlen($basedir));
+ $path=$request['path'];
header( 'Location: '.$_SERVER['PHP_SELF'].'?path='.$path);
}
$newname = $_POST['newname'];
$subs = explode('/', $path);
if (in_array('..', $subs))
- die(); // Hard fails when trying to play above basedir
+ die(); // Hard fails when trying to play above SQUASHER_UPLOADS_DIR
if ($squashweb->got_rights_array_admin($path) > 0) {
umask(002); // don't remove g+w
- mkdir($basedir.'/'.$path.'/'.$newname);
+ mkdir(SQUASHER_UPLOADS_DIR.$path.'/'.$newname);
}
header( 'Location: ?path='.$path.'/'.$newname) ;
$path = $_GET['path'];
$subs = explode('/', $path);
if (in_array('..', $subs))
- die(); // Hard fails when trying to play above basedir
+ die(); // Hard fails when trying to play above SQUASHER_UPLOADS_DIR
if ($squashweb->got_rights_array_admin($path) > 0) {
- rmdir($basedir.$path);
+ rmdir(SQUASHER_UPLOADS_DIR.$path);
}
array_pop($subs);
$path=implode("/", $subs);
$smarty->assign('edited_user', @$_GET['user']);
- $tree = $squashweb->show_rights_tree($path, 0, @$_GET['user']);
+ $tree = $squashweb->show_rights_tree($requestpath, 0, @$_GET['user']);
$smarty->assign('style', $tree['style']);
$smarty->assign('layout', $tree['layout']);
***/
$configs_num = $squashweb->get_configs();
-
$configs_sorted = named_records_sort($configs_num, 'lastchange', true);
$configs = array();
- $paths = array();
foreach ($configs_sorted as $key => $value) {
$configs[$key]['squashed'] = $value['squashed'];
$configs[$key]['chunk_size'] = $value[4];
$configs[$key]['chunks'] = $value[5];
$configs[$key]['crc'] = $value[6];
- $paths[substr($value['path'], strlen($basedir))]=array_pop(explode('/',$value['path']));
(strpos($value['mime'],'ideo')) ? $embedable=true : $embedable=false;
(@array_sum($value['stats']) == $value[5]) ? $finished=true : $finished=false;
//set base folders
$basepath['/'] = 'top';
$bpath = '';
- foreach (explode('/', $subf) as $key => $value) {
+ foreach (explode('/', $requestpath) as $key => $value) {
if ($value != '') {
$bpath .= '/'.$value;
$basepath[$bpath] = $value;
$smarty->assign('folderrights', $squashweb->folderrights());
$smarty->assign('squashed', $configs);
- $smarty->assign('paths', $paths);
$smarty->assign('base', $basepath);
- $smarty->assign('currentfolder', $subf);
+ $smarty->assign('currentfolder', $requestpath);
$subs = $squashweb->subfolders();
if ($subs)
asort($subs);