First git import
authorJan Bakuwel <jan.bakuwel@greenpeace.org>
Mon, 6 Feb 2017 20:24:00 +0000 (09:24 +1300)
committerJean-Michel Vourgère <jvourger@greenpeace.org>
Thu, 23 Feb 2017 15:20:12 +0000 (04:20 +1300)
19 files changed:
img/gp1.gif [new file with mode: 0644]
img/gplogo.gif [new file with mode: 0644]
img/gplogobottomright.gif [new file with mode: 0644]
img/squash.gif [new file with mode: 0644]
img/tree-folder.gif [new file with mode: 0644]
img/tree-line.gif [new file with mode: 0644]
include/connect.inc.php.example [new file with mode: 0644]
index.php [new file with mode: 0644]
js/md5.js [new file with mode: 0644]
squasher.class.php [new file with mode: 0644]
squasher.php [new file with mode: 0644]
templates/admin.tpl [new file with mode: 0644]
templates/index.tpl [new file with mode: 0644]
templates/index2.tpl [new file with mode: 0644]
templates/index_streaming.tpl [new file with mode: 0644]
templates/login.tpl [new file with mode: 0644]
templates/logs.tpl [new file with mode: 0644]
templates/udmin.tpl [new file with mode: 0644]
templates/wip_massdelete.tpl [new file with mode: 0644]

diff --git a/img/gp1.gif b/img/gp1.gif
new file mode 100644 (file)
index 0000000..f4982da
Binary files /dev/null and b/img/gp1.gif differ
diff --git a/img/gplogo.gif b/img/gplogo.gif
new file mode 100644 (file)
index 0000000..3d00ce6
Binary files /dev/null and b/img/gplogo.gif differ
diff --git a/img/gplogobottomright.gif b/img/gplogobottomright.gif
new file mode 100644 (file)
index 0000000..29ec0ef
Binary files /dev/null and b/img/gplogobottomright.gif differ
diff --git a/img/squash.gif b/img/squash.gif
new file mode 100644 (file)
index 0000000..6744ceb
Binary files /dev/null and b/img/squash.gif differ
diff --git a/img/tree-folder.gif b/img/tree-folder.gif
new file mode 100644 (file)
index 0000000..4ed9c2a
Binary files /dev/null and b/img/tree-folder.gif differ
diff --git a/img/tree-line.gif b/img/tree-line.gif
new file mode 100644 (file)
index 0000000..b59b20d
Binary files /dev/null and b/img/tree-line.gif differ
diff --git a/include/connect.inc.php.example b/include/connect.inc.php.example
new file mode 100644 (file)
index 0000000..ec6cff9
--- /dev/null
@@ -0,0 +1,10 @@
+<?\r
+\r
+// start session\r
+session_start();\r
+\r
+//connect to db\r
+$link_db = mysql_connect("dbip", "dbuser", "dbpassword");\r
+mysql_select_db("squasher", $link_db);\r
+\r
+?>\r
diff --git a/index.php b/index.php
new file mode 100644 (file)
index 0000000..0422277
--- /dev/null
+++ b/index.php
@@ -0,0 +1,52 @@
+<?
+
+require_once("include/connect.inc.php");
+
+require_once("squasher.class.php");
+
+//login info
+$vars[user]=$_POST[user];
+$vars[pass]=$_POST[pass];
+$vars[debug]=$_GET[debug];
+$vars[newtpl]=$_GET[newtpl];
+$tools=$_GET[tools];
+
+foreach($_POST AS $key => $value) $submitted[$key]=$value;
+
+$saltplus=md5($_SERVER[REMOTE_ADDR].":".$_SERVER[REMOTE_PORT]."|".$_SERVER[HTTP_USER_AGENT]);
+$salt=md5($_SERVER[REMOTE_ADDR]."|".$_SERVER[HTTP_USER_AGENT]);
+
+//(md5(md5('jasper').$salt) == $vars[user]) ? $vun = "Username validated" : $vun = "Username incorrect";
+//(md5(md5('test'  ).$salt) == $vars[pass]) ? $vpw = "Password validated" : $vpw = "Password incorrect";
+//echo $vun . ' <br/> ' . $vpw;
+
+if ($tools=="logout"){
+       session_destroy();
+       $_SESSION[creds][validated]=false;
+       header( 'Location: '.$_SERVER['PHP_SELF'] ) ;
+}
+
+if (!$_SESSION[creds][validated]){
+       validate_user($vars,$salt);
+}
+
+if ($_SESSION[creds][validated] || isset($_GET['f'])){ 
+//if ($_SESSION[creds][validated]){
+//load squasher
+       include("squasher.php");
+}else{
+
+//show login
+
+require_once("smarty/Smarty.class.php");
+
+$smarty = new Smarty;
+
+$smarty->assign('salt',$salt);
+$smarty->assign('vun',$vun);
+$smarty->assign('vpw',$vpw);
+$smarty->assign('debug',$debug);
+$smarty->display('login.tpl');
+
+}
+?>
\ No newline at end of file
diff --git a/js/md5.js b/js/md5.js
new file mode 100644 (file)
index 0000000..46d2aab
--- /dev/null
+++ b/js/md5.js
@@ -0,0 +1,256 @@
+/*
+ * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
+ * Digest Algorithm, as defined in RFC 1321.
+ * Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
+ * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
+ * Distributed under the BSD License
+ * See http://pajhome.org.uk/crypt/md5 for more info.
+ */
+
+/*
+ * Configurable variables. You may need to tweak these to be compatible with
+ * the server-side, but the defaults work in most cases.
+ */
+var hexcase = 0;  /* hex output format. 0 - lowercase; 1 - uppercase        */
+var b64pad  = ""; /* base-64 pad character. "=" for strict RFC compliance   */
+var chrsz   = 8;  /* bits per input character. 8 - ASCII; 16 - Unicode      */
+
+/*
+ * These are the functions you'll usually want to call
+ * They take string arguments and return either hex or base-64 encoded strings
+ */
+function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
+function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
+function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
+function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
+function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
+function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
+
+/*
+ * Perform a simple self-test to see if the VM is working
+ */
+function md5_vm_test()
+{
+  return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
+}
+
+/*
+ * Calculate the MD5 of an array of little-endian words, and a bit length
+ */
+function core_md5(x, len)
+{
+  /* append padding */
+  x[len >> 5] |= 0x80 << ((len) % 32);
+  x[(((len + 64) >>> 9) << 4) + 14] = len;
+
+  var a =  1732584193;
+  var b = -271733879;
+  var c = -1732584194;
+  var d =  271733878;
+
+  for(var i = 0; i < x.length; i += 16)
+  {
+    var olda = a;
+    var oldb = b;
+    var oldc = c;
+    var oldd = d;
+
+    a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
+    d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
+    c = md5_ff(c, d, a, b, x[i+ 2], 17,  606105819);
+    b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
+    a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
+    d = md5_ff(d, a, b, c, x[i+ 5], 12,  1200080426);
+    c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
+    b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
+    a = md5_ff(a, b, c, d, x[i+ 8], 7 ,  1770035416);
+    d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
+    c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
+    b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
+    a = md5_ff(a, b, c, d, x[i+12], 7 ,  1804603682);
+    d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
+    c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
+    b = md5_ff(b, c, d, a, x[i+15], 22,  1236535329);
+
+    a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
+    d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
+    c = md5_gg(c, d, a, b, x[i+11], 14,  643717713);
+    b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
+    a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
+    d = md5_gg(d, a, b, c, x[i+10], 9 ,  38016083);
+    c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
+    b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
+    a = md5_gg(a, b, c, d, x[i+ 9], 5 ,  568446438);
+    d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
+    c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
+    b = md5_gg(b, c, d, a, x[i+ 8], 20,  1163531501);
+    a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
+    d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
+    c = md5_gg(c, d, a, b, x[i+ 7], 14,  1735328473);
+    b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
+
+    a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
+    d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
+    c = md5_hh(c, d, a, b, x[i+11], 16,  1839030562);
+    b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
+    a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
+    d = md5_hh(d, a, b, c, x[i+ 4], 11,  1272893353);
+    c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
+    b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
+    a = md5_hh(a, b, c, d, x[i+13], 4 ,  681279174);
+    d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
+    c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
+    b = md5_hh(b, c, d, a, x[i+ 6], 23,  76029189);
+    a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
+    d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
+    c = md5_hh(c, d, a, b, x[i+15], 16,  530742520);
+    b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
+
+    a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
+    d = md5_ii(d, a, b, c, x[i+ 7], 10,  1126891415);
+    c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
+    b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
+    a = md5_ii(a, b, c, d, x[i+12], 6 ,  1700485571);
+    d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
+    c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
+    b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
+    a = md5_ii(a, b, c, d, x[i+ 8], 6 ,  1873313359);
+    d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
+    c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
+    b = md5_ii(b, c, d, a, x[i+13], 21,  1309151649);
+    a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
+    d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
+    c = md5_ii(c, d, a, b, x[i+ 2], 15,  718787259);
+    b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
+
+    a = safe_add(a, olda);
+    b = safe_add(b, oldb);
+    c = safe_add(c, oldc);
+    d = safe_add(d, oldd);
+  }
+  return Array(a, b, c, d);
+
+}
+
+/*
+ * These functions implement the four basic operations the algorithm uses.
+ */
+function md5_cmn(q, a, b, x, s, t)
+{
+  return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
+}
+function md5_ff(a, b, c, d, x, s, t)
+{
+  return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
+}
+function md5_gg(a, b, c, d, x, s, t)
+{
+  return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
+}
+function md5_hh(a, b, c, d, x, s, t)
+{
+  return md5_cmn(b ^ c ^ d, a, b, x, s, t);
+}
+function md5_ii(a, b, c, d, x, s, t)
+{
+  return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
+}
+
+/*
+ * Calculate the HMAC-MD5, of a key and some data
+ */
+function core_hmac_md5(key, data)
+{
+  var bkey = str2binl(key);
+  if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
+
+  var ipad = Array(16), opad = Array(16);
+  for(var i = 0; i < 16; i++)
+  {
+    ipad[i] = bkey[i] ^ 0x36363636;
+    opad[i] = bkey[i] ^ 0x5C5C5C5C;
+  }
+
+  var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
+  return core_md5(opad.concat(hash), 512 + 128);
+}
+
+/*
+ * Add integers, wrapping at 2^32. This uses 16-bit operations internally
+ * to work around bugs in some JS interpreters.
+ */
+function safe_add(x, y)
+{
+  var lsw = (x & 0xFFFF) + (y & 0xFFFF);
+  var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
+  return (msw << 16) | (lsw & 0xFFFF);
+}
+
+/*
+ * Bitwise rotate a 32-bit number to the left.
+ */
+function bit_rol(num, cnt)
+{
+  return (num << cnt) | (num >>> (32 - cnt));
+}
+
+/*
+ * Convert a string to an array of little-endian words
+ * If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
+ */
+function str2binl(str)
+{
+  var bin = Array();
+  var mask = (1 << chrsz) - 1;
+  for(var i = 0; i < str.length * chrsz; i += chrsz)
+    bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
+  return bin;
+}
+
+/*
+ * Convert an array of little-endian words to a string
+ */
+function binl2str(bin)
+{
+  var str = "";
+  var mask = (1 << chrsz) - 1;
+  for(var i = 0; i < bin.length * 32; i += chrsz)
+    str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
+  return str;
+}
+
+/*
+ * Convert an array of little-endian words to a hex string.
+ */
+function binl2hex(binarray)
+{
+  var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
+  var str = "";
+  for(var i = 0; i < binarray.length * 4; i++)
+  {
+    str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
+           hex_tab.charAt((binarray[i>>2] >> ((i%4)*8  )) & 0xF);
+  }
+  return str;
+}
+
+/*
+ * Convert an array of little-endian words to a base-64 string
+ */
+function binl2b64(binarray)
+{
+  var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+  var str = "";
+  for(var i = 0; i < binarray.length * 4; i += 3)
+  {
+    var triplet = (((binarray[i   >> 2] >> 8 * ( i   %4)) & 0xFF) << 16)
+                | (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
+                |  ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
+    for(var j = 0; j < 4; j++)
+    {
+      if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
+      else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
+    }
+  }
+  return str;
+}
diff --git a/squasher.class.php b/squasher.class.php
new file mode 100644 (file)
index 0000000..c2f2eb9
--- /dev/null
@@ -0,0 +1,1064 @@
+<?PHP
+require_once("include/connect.inc.php");
+
+function zfill($n,$a) {
+  return str_repeat("0",max(0,$a-strlen($n))).$n;
+}
+
+function named_records_sort($named_recs, $order_by, $reverse=false, $flags=0)
+{
+       $named_hash = array();
+       foreach($named_recs as $key => $fields)$named_hash[$key] = $fields[$order_by];
+
+       if($reverse) arsort($named_hash,$flags=0) ;
+       else asort($named_hash, $flags=0);
+
+       $sorted_records = array();
+       foreach($named_hash as $key => $val)$sorted_records[$key] = $named_recs[$key];
+       return $sorted_records;
+}
+
+function validate_user($vars,$salt){
+       $creds[validated] = false;
+       $query="SELECT * FROM users";
+       $q_result = mysql_query($query);
+       while ($fetched_object = mysql_fetch_object($q_result)){
+               if (md5(md5($fetched_object->user_name).$salt) == $vars[user]){
+                       if (md5($fetched_object->user_pass.$salt) == $vars[pass]){
+                               //validated
+                               $creds[user_id] = $fetched_object->user_id;
+                               $creds[user_name] = $fetched_object->user_name;
+                               $creds[user_level] = $fetched_object->user_level;
+                               $creds[validated] = true;
+                               $log_hash=NULL;
+                               $log_hash=(isset($vars['f'])) ? $vars['f'] : $vars['h'] ;
+                               if ($log_hash==NULL)$log_hash=str_repeat("0",32);
+                               $q="insert into log (hash,action,user_id,user_name,ip,date) values ('{$log_hash}','login','".$creds['user_id']."','".$creds['user_name']."','".$_SERVER[REMOTE_ADDR]."',NOW())";
+                               mysql_query($q);
+                       }
+               }
+       }
+       $_SESSION[creds] = $creds;
+       return $creds[validated];
+}
+
+class squashweb {
+
+var $basepath;
+var $configs;
+var $stats;
+var $files;
+var $subfolders;
+var $folderrights;
+var $userrights;
+var $history;
+
+function set_root($root){
+       $this->basepath = $root;
+}
+
+function get_configs(){
+       return $this->configs;
+}
+
+function subfolders(){
+       return $this->subfolders;
+}
+
+function get_config($h){
+       
+       return $this->configs[$h];
+}
+
+function folderrights(){
+       return $this->folderrights;
+}
+
+function userrights(){
+       return $this->userrights;
+}
+
+function update_history(){
+       $q="SELECT md5_hash,file,completed,checked FROM file_hash";
+       $r=mysql_query($q);
+       while($o=mysql_fetch_object($r)){
+               $this->history[$o->md5_hash]['file']=$o->file;
+               $this->history[$o->md5_hash]['completed']=$o->completed;
+               $this->history[$o->md5_hash]['checked']=$o->checked;
+       }
+}
+
+function got_rights_checkbox($needle){
+       $result = $this->got_rights_array($needle,'',0,'userrights');
+       switch($result){
+               case 0 :
+                       $return = '';
+                       break;
+               case 1 :
+               case 2 :
+                       $return = 'checked';
+                       break;
+       }
+       return $return;
+}
+
+function get_users($user_level){
+       $q = "SELECT * FROM users WHERE user_level < '".$user_level."' order by user_name asc";
+       $r = mysql_query($q);
+       
+       while ($o = mysql_fetch_object($r)){
+               $return[$o->user_id]['id']              = $o->user_id;
+               $return[$o->user_id]['name']    = $o->user_name;
+               $return[$o->user_id]['level']   = $o->user_level;
+               $return[$o->user_id]['enabled'] = ($o->user_pass == '') ? false : true ;;
+       }
+       
+       return $return;
+}
+
+function get_logs($type='all'){
+       $q="SELECT log.* FROM log WHERE log.user_id != '1' and ip != '87.233.211.2' ";
+       if($_SESSION[creds][user_id] == 1)$q="SELECT log.* FROM log WHERE log.user_id != 'x' ";
+       switch($type){
+       case "delete":
+               $q.= " and log.action = 'delete'";
+               break;
+       case "download":
+               $q.= " and log.action = 'download'";
+               break;
+       case "login":
+               $q.= " and log.action = 'login'";
+               break;
+       case "debug":
+               $q.= " and log.action = 'debug'";
+               break;
+       default:
+               $q.= "";
+               break;
+       }
+
+       $today     =" and date > date(date_add(now(), interval -0 day)) ";
+       $yesterday =" and date < date(date_add(now(), interval -0 day)) and date > date(date_add(now(), interval -1 day)) ";
+       $lastweek  =" and date < date(date_add(now(), interval -1 day)) and date > date(date_add(now(), interval -6 day)) ";
+       $older     =" and date < date(date_add(now(), interval -7 day)) and date > date(date_add(now(), interval -30 day)) ";
+
+       $order=" order by log.log_id desc ";
+       $r = mysql_query($q.$today.$order);
+       while($a = mysql_fetch_array($r)){
+               $qu="select users.user_name from users left join log on users.user_id = log.user_id where log.ip='{$a[ip]}' group by users.user_name";
+               $ru = mysql_query($qu);
+               $a[users_from_ip]=" | ";
+               while($au = mysql_fetch_array($ru))$a[users_from_ip].=$au[user_name]." | ";
+               $return['today'][$a['log_id']]=$a;
+       }
+       $r = mysql_query($q.$yesterday.$order);
+       while($a = mysql_fetch_array($r)){
+               $qu="select users.user_name from users left join log on users.user_id = log.user_id where log.ip='{$a[ip]}' group by users.user_name";
+               $ru = mysql_query($qu);
+               $a[users_from_ip]=" | ";
+               while($au = mysql_fetch_array($ru))$a[users_from_ip].=$au[user_name]." | ";
+               $return['yesterday'][$a['log_id']]=$a;
+       }
+       $r = mysql_query($q.$lastweek.$order);
+       while($a = mysql_fetch_array($r)){
+               $qu="select users.user_name from users left join log on users.user_id = log.user_id where log.ip='{$a[ip]}' group by users.user_name";
+               $ru = mysql_query($qu);
+               $a[users_from_ip]=" | ";
+               while($au = mysql_fetch_array($ru))$a[users_from_ip].=$au[user_name]." | ";
+               $return['lastweek'][$a['log_id']]=$a;
+       }
+       $r = mysql_query($q.$older.$order);
+       while($a = mysql_fetch_array($r)){
+               $qu="select users.user_name from users left join log on users.user_id = log.user_id where log.ip='{$a[ip]}' group by users.user_name";
+               $ru = mysql_query($qu);
+               $a[users_from_ip]=" | ";
+               while($au = mysql_fetch_array($ru))$a[users_from_ip].=$au[user_name]." | ";
+               $return['older'][$a['log_id']]=$a;
+       }
+
+       return $return;
+}
+
+function insert_users($submitted,$admin_level){
+       $q = "INSERT INTO users (user_name,user_pass,user_level) values ('".$submitted[u][user_name]."','".md5($submitted[u][user_pass])."','".$submitted[u][user_level]."')";
+       $r = mysql_query($q);
+}
+
+function update_users($submitted){
+       $q = "UPDATE users SET user_name = '".$submitted[u][user_name]."', user_pass = '".md5($submitted[u][user_pass])."', user_level = '".$submitted[u][user_level]."' WHERE user_id = '".$submitted[u][user_id]."'";
+       $r = mysql_query($q);
+}
+
+function disable_users($submitted){
+       $q = "UPDATE users SET user_name = '".$submitted[u][user_name]."', user_pass = '', user_level = '".$submitted[u][user_level]."' WHERE user_id = '".$submitted[u][user_id]."'";
+       $r = mysql_query($q);
+}
+
+function remove_users($submitted){
+       $q = "DELETE FROM users WHERE user_id = '".$submitted[u][user_id]."'";
+       $r = mysql_query($q);
+}
+
+function give_rights($user_id,$type='folderrights'){
+               
+       $q = "SELECT folder_path, access FROM user_rights WHERE user_id = '".$user_id."'";
+       $r = mysql_query($q);
+       while ($o = mysql_fetch_object($r)){
+
+               //clean vars            
+               $arr_string = '$this->'.$type;
+               
+               //get foldernames from path
+               if($o->folder_path != '/'){
+                       $path = $o->folder_path;
+                       if($path{0}=='/')$path=substr($path,1);
+                       $folder_arr = explode('/',$path);
+
+                       //create folder structure array
+                       foreach ($folder_arr AS $key => $value){
+                               $arr_string .= "['".$value."']";
+                       }
+               }
+               $arr_string .= "['__access__']";
+               
+               //choose access icon
+               // access = # --deny-all
+               // access = * --allow-dir-only
+               // access = @ --allow-inc-subs
+/*             switch($o->access){
+                       case 0 :
+                               $icon = '#';
+                               break;
+                       case 1 :
+                               $icon = '*';
+                               break;
+                       case 2 :
+                               $icon = '@';
+                               break;
+               }*/
+               //echo $arr_string." = '".$icon."'\n";
+               //echo $arr_string." = '".$o->access."';";
+               eval($arr_string." = '".$o->access."';");
+       }
+       
+       return $this->folderrights;
+}
+
+function update_rights($submitted,$admin_level){
+       $q = "SELECT count(*) result FROM users WHERE user_id = '".$submitted['edited_user']."' AND user_level < '".$admin_level."'";
+       $r = mysql_query($q);
+       $o = mysql_fetch_object($r);
+       
+       if ($o->result){
+               foreach ($submitted[m] AS $path => $access){
+                       $p_q = "SELECT count(*) result FROM user_rights WHERE user_id = '".$submitted['edited_user']."' AND folder_path = '".$path."'";
+                       $p_r = mysql_query($p_q);
+                       $p_o = mysql_fetch_object($p_r);
+                       if ($p_o->result == 1) mysql_query("UPDATE user_rights SET access = ".$access." WHERE folder_path = '".$path."' AND user_id = '".$submitted['edited_user']."'");
+                       if ($p_o->result == 0) mysql_query("INSERT INTO user_rights (user_id,folder_path,access) values ('".$submitted['edited_user']."','".$path."','".$access."') ");
+               }
+       }
+}
+
+
+function show_rights_tree($path,$depth=0,$userid=0){
+
+       if ($userid==0)return false;
+       if ($depth==0)$this->give_rights($userid,'userrights');
+
+       // access = # | 0 --deny-all
+       // access = * | 1 --allow-dir-only
+       // access = @ | 2 --allow-inc-subs
+
+       for ($i=0;$depth > $i; $i++)$layout .= " ";
+       if ($dir = opendir($path)){
+               $layout .= "<div style='clear:both;' >\n";
+               $f=0;
+               while (false !== ($file = readdir($dir))) { $files_array[]=$file; }
+                asort($files_array);
+                foreach ($files_array as $f_index => $file)
+                {
+//             while (false !== ($file = readdir($dir))) 
+//             {                                
+                       if (($file{0} !== ".") && ($file !== "..")) 
+                       {
+                               $filename = $path."/".$file;
+                               if (!is_file($filename)){if ($this->got_rights_array($filename) > 0)
+                               {
+                                       $f++;
+                                       if(substr($filename,0,strlen($this->basepath))==$this->basepath) $name=substr($filename,strlen($this->basepath));
+                                       //$check = $this->got_rights_checkbox($filename);
+                                       $check = $this->got_rights_array_admin($filename,'',0,'userrights');
+                                               $check_all = '';
+                                               $check_allow = '';
+                                               $check_deny = '';
+                                       switch($check){
+                                               case 2:
+                                                       $check_all = 'checked';
+                                                       break;
+                                               case 1:
+                                                       $check_allow = 'checked';
+                                                       break;
+                                               case 0:
+                                               default:
+                                                       $check_deny = 'checked';
+                                                       break;
+                                       }
+
+                                       if($f==1)$style[$depth] = ".depth".$depth."{float:right;width:".(600-($depth*10))."px;border-left:2px solid #FFFFFF;border-top:1px solid #FFFFFF;background:#".dechex(14-$depth).dechex(14-$depth).dechex(14-$depth).dechex(14-$depth).dechex(14-$depth).dechex(14-$depth).";}";
+                                       if($f==1)$layout .= "<div class='depth".$depth."'>";
+                                       $layout .= "<div class='white_border' >".$file."</div>\n";
+                                       $layout .= "<div class='check_deny'><input name='m[".$name."]' value=0 type=radio ".$check_deny."></div>\n";
+                                       $layout .= "<div class='check_allow'><input name='m[".$name."]' value=1 type=radio ".$check_allow."></div>\n";
+                                       $layout .= "<div class='check_all'><input name='m[".$name."]' value=2 type=radio ".$check_all."></div>\n";
+                                       $sub_return = $this->show_rights_tree($filename,$depth+1,$userid);
+                                       if(is_array($style) && is_array($sub_return['style']))$style = $style + $sub_return['style'];
+                                       $layout .= $sub_return['layout'];
+                               }}
+                       }
+               }
+               if($f!=0)$layout .= "</div>";
+               $layout .= "</div>\n";
+       }
+
+       $return['style'] = $style;
+       $return['layout'] = $layout;
+
+       return $return;
+}
+
+function got_rights_path($needle,$haystack){
+       
+       if(!is_array($haystack)) $haystack = $this->folderrights;
+       foreach($haystack as $v){
+               if(!is_array($v)){
+                       if($needle == $v) return true;
+               }
+               else{
+                       if(is_in_array($needle, $v, $case_sensitive) === true) return true;
+               }
+       }
+       return false;
+}
+
+function got_rights_array($needle,$haystack='',$c=0,$type='folderrights'){
+
+       if(!is_array($haystack)) eval('$haystack = $this->'.$type.';');
+       if(substr($needle,0,strlen($this->basepath))==$this->basepath) $needle=substr($needle,strlen($this->basepath));
+
+       //if($needle{0}=='.')$needle=substr($needle,strlen($this->basepath));
+
+       //check root rights
+       if($needle{0}=='/' && $haystack['__access__'] == 2 ) return 2;
+
+       //check folder tights
+       if($needle{0}=='/')$needle=substr($needle,1);
+       
+       $needle_arr = explode('/',$needle);
+       $n = count($needle_arr);
+       $d = $c+1;
+
+       foreach($haystack as $k => $v){
+               if($needle_arr[$c] == $k){
+                       if(!is_array($v['__access__'])){
+                               if (($v['__access__'] == '@' || $v['__access__'] == 2)                     ) return 2;
+                               if (($v['__access__'] == '*' || $v['__access__'] == 1) && $d == $n ) return 1;
+                               if (($v['__access__'] == '#' || $v['__access__'] == 0) && $d == $n ) return 0;
+                       }else{
+                               $return = $this->got_rights_array($needle, $v, $d);
+                       }
+               }
+       }
+       return $return;
+}
+
+function got_rights_array_admin($needle,$haystack='',$c=0,$type='folderrights'){
+
+       if(!is_array($haystack)) eval('$haystack = $this->'.$type.';');
+       if(substr($needle,0,strlen($this->basepath))==$this->basepath) $needle=substr($needle,strlen($this->basepath));
+       
+       //if($needle{0}=='.')$needle=substr($needle,strlen($this->basepath));
+
+       //check root rights
+       if($needle{0}=='/' && $haystack['__access__'] == 2 ) return 2;
+
+       //check folder rights
+       if($needle{0}=='/')$needle=substr($needle,1);
+
+       $needle_arr = explode('/',$needle);
+       $n = count($needle_arr);
+       $d = $c+1;
+       $return = 0;
+
+       if($c < $n){
+               if($haystack['__access__'] == 2)return $haystack['__access__'];
+               if(is_array($haystack[$needle_arr[$c]]))$return = $this->got_rights_array_admin($needle, $haystack[$needle_arr[$c]], $d);
+       }else{
+               if($haystack['__access__'] > 0)$return = $haystack['__access__'];
+       }
+
+       return $return;
+}
+
+function got_rights_array_recursive($needle,$haystack='',$c=0,$type='folderrights'){
+
+       if(!is_array($haystack)) eval('$haystack = $this->'.$type.';');
+       if(substr($needle,0,strlen($this->basepath))==$this->basepath) $needle=substr($needle,strlen($this->basepath));
+       
+       //if($needle{0}=='.')$needle=substr($needle,strlen($this->basepath));
+
+       //check root rights
+       if($needle{0}=='/' && $haystack['__access__'] == 2 ) return 2;
+
+       //check folder rights
+       if($needle{0}=='/')$needle=substr($needle,1);
+       
+       $needle_arr = explode('/',$needle);
+       $n = count($needle_arr);
+       $d = $c+1;
+       $return = 0;
+       
+       foreach($haystack as $k => $v){
+               if($needle_arr[$c] == $k){
+                       if($c < $n){
+                               if($v['__access__'] == 2) $return = $return + $v['__access__'];
+                               $return = $return + $this->got_rights_array_recursive($needle, $v, $d);
+                       }else{
+                               $return = $return + $this->in_array_recursive($v);
+                       }
+               }elseif($c == $n){
+                       $return = $return + $v['__access__'];
+                       if($k != '__access__')$return = $return + $this->in_array_recursive($v);
+               }
+       }
+
+       return $return;
+}
+
+function in_array_recursive($haystack){
+       $return = 0;
+       if (is_array($haystack))foreach ($haystack as $key1 => $value1){
+               if (is_array($value1)){
+                       $return = $return + $this->in_array_recursive($value1);
+               }
+               elseif($value1 > 0){
+                       return $value1;
+               }
+       }
+       return $return;
+}
+
+function read_single_file($path,$file){
+       $filename = $path."/".$file;
+       $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') )$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);
+               }
+       }
+}
+
+
+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')){
+                                       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);
+                                               $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);
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+}
+
+function check_stats($h){
+       $config = $this->get_config($h);
+       $count = @array_sum($config['stats']);
+       if ($config['status']=='Completed' && $count != $config[5]){
+               $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');
+                       unset($this->configs[$h]);
+
+                       if (!$count)$count = 0;
+                       $m_subject="Squasher Debug: File Removed";
+                       $m_body="Upload removed: \n File: ".$config['path']."/".$config[2]." \n Status: ".$config['status']." \n Chunks: ".$count." out of ".$config[5];
+                       mail('jasper@netformatie.nl',$m_subject,$m_body,"From: support@netformatie.nl");
+                       $qlog="insert into log (hash,file,action,user_id,user_name,ip,date) values ('{$h}','{$filepath}','debug','-1','squasher-web','cleanup',NOW())";
+                       mysql_query($qlog);
+
+               }else{
+                       //do move
+                       rename($config['path'].'/'.$config[2].'.Completed',$config['path'].'/'.$config[2].'.InProgress');
+                       $this->configs[$h]['status']='InProgress';
+
+                       //mail n4m
+                       if (!$count)$count = 0;
+                       $m_subject="Squasher Debug: Upload Error";
+                       $m_body="Upload error: \n File: ".$config['path']."/".$config[2]." \n Status: ".$config['status']." \n Chunks: ".$count." out of ".$config[5];
+                       mail('support@netformatie.nl',$m_subject,$m_body,"From: squasher@netformatie.nl");
+                       mail('jan@netformatie.nl',$m_subject,$m_body,"From: support@netformatie.nl");
+                       mail('joop@netformatie.nl',$m_subject,$m_body,"From: support@netformatie.nl");
+                       mail('jasper@netformatie.nl',$m_subject,$m_body,"From: support@netformatie.nl");
+
+                       //do sms
+                       //wget -o/dev/null "http://www.mollie.nl/xml/sms/?username=netformatie&password=SMSdolsi&originator=Netformatie&recipients=${ENGINEER}&message=${CALLERID}";
+
+                       //mail RO
+                       $ship=explode('/',$config['path']);
+                       if($ship[2] == 'myas' || $ship[2] == 'myez' || $ship[2] == 'myrw')mail('ro1@'.$ship[2].'.greenpeace.org','Squasher: '.$config[2].' resume request','The squasher server has detected an upload error. Please resume the squasher transmission for '.$config[2].' to correct this problem.',"From: support@netformatie.nl\nX-Priority: 1");
+
+                       $qlog="insert into log (hash,file,action,user_id,user_name,ip,date) values ('{$h}','{$filepath}','debug','-1','squasher-web','retry',NOW())";
+                       mysql_query($qlog);
+
+               }
+       }elseif($config['status']=='Completed' && $count == $config[5]){
+               if($this->history[$h]['completed']==0)mysql_query("UPDATE file_hash SET completed = 1 WHERE md5_hash = '".$h."'");
+       }
+}
+
+function update_hash($hash,$path){
+       $check_hash_query="select * from file_hash where md5_hash = '".$hash."'";
+       $check_hash_result=mysql_query($check_hash_query);
+       if(mysql_num_rows($check_hash_result) == 0){
+               $insert_hash_query="INSERT INTO file_hash (md5_hash,file) values ('".$hash."','".$path."')";
+               mysql_query($insert_hash_query);
+       }
+}
+
+function path_to_arraystring($path,$arrayname){
+       $path_values = explode('/',$path);
+       $return = $arrayname;
+       foreach ($path_values AS $key => $value){
+               if ($value != '.' && $value != '')$return.= "['".$value."']";
+       }
+       return $return;
+}
+
+function populate_stats($path,$h){
+       /***
+       *       $config:: array
+       *       [0]     ->      versioncode
+       *       [1]     ->      date&time
+       *       [2]     ->      filename
+       *       [3]     ->      filesize
+       *       [4]     ->      chunksize
+       *       [5]     ->      chunkcount
+       *       [6]     ->      CRC32 checksum
+       ***/
+       $config = $this->configs[$h];
+
+       $q = "SELECT * FROM file_hash WHERE md5_hash = '{$h}'";
+       $r = mysql_query($q);
+       $o = mysql_fetch_object($r);
+       $validated_chunks = $o->validated_chunks;
+       
+       if($this->history[$h]['completed']=="1"){
+               $file_part = $path."/SQ".zfill(1,6)."-".$config[2];
+               if (!is_file($file_part))$file_part = $path."/SQ".zfill(1,3)."-".$config[2];
+               if (is_file($file_part)){
+                       $this->configs[$h]['added'] = filectime($file_part);
+                       $file_part = $path."/SQ".zfill($config[5],6)."-".$config[2];
+                       if (!is_file($file_part))$file_part = $path."/SQ".zfill($config[5],3)."-".$config[2];
+                       if (is_file($file_part)) $this->configs[$h]['lastchange'] = filemtime($file_part);
+                       for ($i=1;$i<=$config[5];$i++) 
+                       {
+                               $this->configs[$h]['stats'][$i]="1.00";
+                       }
+               }else{
+                       //failsafe voor verwijderde bestanden
+                       mysql_query("UPDATE file_hash SET completed = 0 WHERE md5_hash = '".$h."'");
+               }
+       }else{
+               $keep_validating = true;
+               for ($i=1;$i<=$config[5];$i++){
+                       if ($validated_chunks > $i){
+                               $this->configs[$h]['stats'][$i]="1.00";
+                       }else{
+                               $file_part = $path."/SQ".zfill($i,6)."-".$config[2];
+                               if (!is_file($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 ($this->configs[$h]['added'] > $added || !is_numeric($this->configs[$h]['added'])) $this->configs[$h]['added'] = $added;
+                                       if ($this->configs[$h]['lastchange'] < $last_changed) $this->configs[$h]['lastchange'] = $last_changed;
+                                       if ($i != $config[5]){
+                                               $this->configs[$h]['stats'][$i]=number_format((1/$config[4])*$size_this, 2, '.', '');
+                                       //number_format((100/$config[4])*$size_this, 2, '.', '')."%";
+                                       }else{
+                                               $this->configs[$h]['stats'][$i]=number_format((1/($config[3]-($config[4]*($config[5]-1))))*$size_this, 2, '.', '');
+                                               //number_format((100/($config[3]-($config[4]*($config[5]-1))))*$size_this, 2, '.', '')."%";
+                                       }
+                                       fclose($handle);
+                                       if ($config[4] == $size_this && $keep_validating){
+                                               $validated_chunks = $i;
+                                       }else{
+                                               $keep_validating = false;
+                                       }
+                               }else{
+                                       $this->configs[$h]['stats'][$i]="0.00";
+                                       //$this->configs[$h]['stats'][$i]="0.00%";
+                                       
+                               }
+                       }
+               }
+               mysql_query("UPDATE file_hash SET validated_chunks = '{$validated_chunks}' WHERE md5_hash = '".$h."'");
+       }
+}
+
+function read_config($path,$filename){
+               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";
+               }
+    $config_content = fread($config_handle, filesize($conf_path));
+               fclose($config_handle);
+               $config = explode("\n",$config_content);
+               
+               return $config;
+//             print_r($config);
+/*             $file_count = $config[5];
+               $last=1;
+    for ($i=1;$i<=$file_count;$i++) 
+    {
+       $file_part = $path."/SQ".zfill($i,6)."-".$filename;
+       if (is_file($file_part))
+       {
+        
+        $handle = fopen($file_part, "rb");
+        $size_this = filesize($file_part);                                     
+                               //$stats[$i]=round((100/$config[4])*$size_this)."%";
+                               if ((($size_this==$config[4] && ($last+1)==$i) )|| $i == $config[5]){
+                                       $merged_file.=fread($handle, filesize($file_part));                             
+                                       $last = $i;
+                               }
+        fclose($handle);
+       }
+     }
+     return $merged_file;
+     */
+   }
+
+function print_files($path,$filename,$tovar = false){
+       if(strpos($path,'./uploads/ftp')){
+               $filestring=$path.'/'.$filename;
+               if (is_file($filestring)){
+                       $handle = fopen($filestring, "rb");
+                       while (!feof($handle))
+                       {
+                               print(fread($handle, 1024));
+                               ob_flush();
+                               flush();
+                       }
+               }
+       }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";
+               }
+               $config_content = fread($config_handle, filesize($conf_path));
+               fclose($config_handle);
+               $config = explode("\n",$config_content);
+//             print_r($config);
+               $file_count = $config[5];
+               $last=0;
+               $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;
+                       if (!is_file($file_part))$file_part = $path."/SQ".zfill($i,3)."-".$filename;
+                       if (is_file($file_part))
+                       {
+                               $handle = fopen($file_part, "rb");
+                               $size_this = filesize($file_part);
+                               if ( ( ( $size_this==$config[4] ) && ( ($last+1)==$i ) ) || ( ( $i == $config[5] ) && ( $size_this==$last_part_size ) && ( ($last+1)==$i ) ) ){
+                                       if ($tovar){
+                                               $merged_file.=fread($handle, $size_this);
+                                               $last = $i;
+                                       }else{                          
+                                               while (!feof($handle))
+                                               {
+                                                       print(fread($handle, 4096));
+                                               #       @ob_flush();
+                                               #       @flush();
+                                               }
+                                               $last = $i;
+                                       }
+                               }
+                               fclose($handle);
+                       }
+               }
+               if($tovar)return $merged_file;
+       }
+}
+
+       function check_md5($h){
+               $return=false;
+               $config=$this->configs[$h];
+               $var=$this->print_files($config['path'],$config[2],true);
+               $hash=md5($var);
+               if($hash==$config[6])$return=true;
+               
+               return $return;
+       }
+
+       function file_crc($file_string){
+       //$file_string = file_get_contents($file);
+
+       $crc = crc32($file_string);
+       return sprintf("%u\n", $crc);
+}
+
+       function file_crc_debug($file){
+       $file_string = file_get_contents($file);
+
+       $crc = crc32($file_string);
+       return sprintf("%u\n", $crc);
+}
+
+       function delete_file($h,$s){
+               $request = $this->get_config($h);
+               if(strpos($request['path'],'./uploads/ftp')){
+                       $filepath=$request['path'].'/'.$request[2];
+                       #remove file
+                       if(is_file($filepath))                          @unlink($filepath);
+                       if(is_file($filepath.'.hidden'))        @unlink($filepath.'.hidden');
+               }else{
+                       #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];
+                               if(is_file($part_six))          @unlink($part_six);
+                               if(is_file($part_three))        @unlink($part_six);
+                       }
+                       #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');
+               }
+
+               #Update DB
+               $q="delete from file_hash where file_hash = '{$h}'";
+               mysql_query($q);
+               $q="insert into log (hash,file,action,user_id,user_name,ip,date) values ('{$h}','{$filepath}','delete','".$s['user_id']."','".$s['user_name']."','".$_SERVER[REMOTE_ADDR]."',NOW())";
+               mysql_query($q);
+
+               #Send debug mail
+               $m_name=$s['user_name'];
+               $m_subject="Squasher Debug: File Deleted by {$m_name}";
+               $m_body="File Deleted: \n Requested by: {$m_name} \n File: {$filepath}";
+               mail('jasper@netformatie.nl',$m_subject,$m_body,"From: support@netformatie.nl");
+       }
+
+       function show_files() {
+
+       $path = "./uploads/";
+
+       if ($dir = opendir($path)){
+               $i=1;
+               $last=1;
+               $files=array();
+               $files_merged=array();
+               while (false !== ($file = readdir($dir))) 
+               {
+                       if (($file !== ".") && ($file !== "..")) 
+                       { 
+                               $filename = $path.$file;
+                               $handle = fopen($filename, "rb");
+                               $size_this = filesize($filename);
+                               if ($i==1) $size_first = $size_this;
+                               $filecontent = fread($handle, filesize($filename));
+                               $files[$i++]=$filename;
+                               $files_merged[$file_base][]=$filename;
+                               fclose($handle);
+                       }
+               }
+       }
+       echo "<pre>";
+       print_r($files);
+       print_r($files_merged);
+       echo "</pre>";
+}
+
+       function set_mime($filename){
+               $ext_arr = explode('.',$filename);
+               $ext = strtolower(array_pop($ext_arr));
+               switch($ext){
+                       case 'avi':
+                               $mime = 'video/avi';
+                               break;
+                       case 'mpeg':
+                       case 'mpg':
+                               $mime = 'video/mpeg';                                   //MPEG Video
+                               break;
+                       case 'exe':
+                       case 'bat':
+                       case 'doc':
+                       case 'xls':
+                               $mime = 'application/octet-stream';
+                               break;
+                       case 'gif':
+                               $mime = 'image/gif';                                    //GIF Image
+                               break;
+                       case 'jpg':
+                       case 'jpeg':
+                               $mime = 'image/jpeg';                                   //JPEG Image
+                               break;
+                       case 'png':
+                               $mime = 'image/png';                                    //PNG Image
+                               break;
+                       case 'wav':
+                       case 'wave':
+                               $mime = 'audio/wav';                                    //WAV Audio
+                               break;
+                       case 'mp3':
+                               $mime = 'audio/mpeg';                                   //MP3 Audio
+                               break;
+                       case 'mov':
+                               $mime   =       'video/mov';                                    //Quicktime Video
+                               break;
+                       case 'wmv':
+                               $mime   =       'video/x-ms-wmv';                       //Windows WMV video
+                               break;
+                       case 'wma':
+                               $mime   =       'audio/x-ms-wma';                       //Windows WMA audio
+                               break;
+                       case 'rm':
+                               $mime   =       'audio/x-realaudio';    //RealPlayer Audio/Video (.rm)
+                               break;
+                       case 'ram':
+                               $mime   =       'audio/x-pn-realaudio'; //RealPlayer Audio/Video (.ram)
+                               break;
+                       case 'pdf':
+                               $mime   =       'application/pdf';              //PDF Document
+                               break;
+                       case 'doc':
+                               $mime   =       'application/msword';   //MS Word .doc file
+                               break;
+                       case 'zip':
+                               $mime   =       'application/zip';              //Zip File
+                               break;
+                       default:
+                               $mime = 'application/octet-stream';
+                               break;                          
+               }
+               //$return['mime']=$mime;
+               //$return['ext']=$ext;
+               
+               return $mime;
+       }
+       
+       function embed_video($h){
+       /*JASPER FIX, use config->systemurl */
+               ?>
+      <!-- begin embedded WindowsMedia file... -->
+      <table border='0' cellpadding='0' align="center">
+      <tr><td>
+      <OBJECT id='mediaPlayer'
+      classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' 
+      codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'
+      standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'>
+      <param name='fileName' value="http://master.squasher.netformatie.nl/?x=asx&f=<?=$h;?>">
+      <param name='animationatStart' value='true'>
+      <param name='transparentatStart' value='true'>
+      <param name='autoStart' value="true">
+      <param name='showControls' value="true">
+      <param name='loop' value="true">
+                       <param name="BufferingTime" value="3">
+      <EMBED type='application/x-mplayer2'
+        pluginspage='http://microsoft.com/windows/mediaplayer/en/download/'
+        id='mediaPlayer' name='mediaPlayer' autosize='1' 
+        bgcolor='darkblue' showcontrols="true" showtracker='-1' 
+        showdisplay='0' showstatusbar='-1' videoborder3d='-1' width='480' height='320'
+        src="http://master.squasher.netformatie.nl/?x=asx&f=<?=$h;?>" autostart="true" designtimesp='5311' loop="true">
+      </EMBED>
+      </OBJECT>
+      </td></tr>
+      <!-- ...end embedded WindowsMedia file -->
+       <!-- begin link to launch external media player... -->
+        <tr><td align='center'>
+        <a href="http://master.squasher.netformatie.nl/?x=asx&f=<?=$h;?>" style='font-size: 85%;' target='_blank'>Launch in external player</a>
+        <!-- ...end link to launch external media player... -->
+        </td></tr>
+      </table>
+               <?
+       }
+
+       function create_playlist($h,$t='asx',$title='Title'){
+               switch ($t){
+
+                       case 'asx':
+
+header('Content-Disposition: attachment; filename="stream.asx"');
+echo '<ASX version="3.0">
+<title>Squasher Streaming Video</title>
+       <Entry>
+               <title>Video Stream</title>
+               <ref HREF="http://master.squasher.netformatie.nl/?a=x&f='.$h.'"/>
+       </Entry>
+</ASX>';
+
+                               break;
+
+                       case 'vlc':
+
+header('Content-Disposition: attachment; filename="stream.'.$t.'"');
+echo '#EXTM3U
+#EXTINF:-1,Squasher Streaming Video - '.$title.'
+http://master.squasher.netformatie.nl/?a=x&f='.$h.'';
+                       
+                               break;
+
+                       case 'm3u':
+                       default:
+
+header('Content-Disposition: attachment; filename="stream.m3u"');
+echo '#EXTM3U
+#EXTINF:-1,Squasher Streaming Video - '.$title.'
+http://master.squasher.netformatie.nl/?a=x&f='.$h.'';
+                       
+                               break;
+               }
+       }
+}
+?>
diff --git a/squasher.php b/squasher.php
new file mode 100644 (file)
index 0000000..658d888
--- /dev/null
@@ -0,0 +1,256 @@
+<?
+if (!$_SESSION[creds][validated] && !isset($_GET['f']))exit();
+
+require_once("squasher.class.php");
+
+$squashweb = new squashweb();
+
+$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{
+       $path = $basedir;
+}
+$squashweb->set_root($basedir);
+
+if ((isset($_GET['f']) && $_GET['f']!=NULL) || (isset($_GET['d']) && $_GET['d']!=NULL) || $_GET['show_all']==true || $_GET['tools']=='hide' || $_GET['tools']=='unhide' || $_GET['tools']=='delete'){
+       $getdeepfiles=true;
+       $populate=false;
+}else{
+       $getdeepfiles=false;
+       $populate=true;
+}
+
+//update folder rights if form is submitted
+if($submitted['edited_user'] > 0 && $submitted['formtype'] == 'folderrights') $squashweb->update_rights($submitted,$_SESSION[creds][user_level]);
+
+//set folder rights
+if (isset($_GET['f']) && $_GET['f']!=NULL){
+       $squashweb->give_rights(0);
+}else{
+       $squashweb->give_rights($_SESSION[creds][user_id]);
+}
+
+if (isset($_GET['f']) && $_GET['f']!=NULL){
+       $f_q = "SELECT * FROM file_hash WHERE md5_hash = '".$_GET['f']."'";
+       $f_r = mysql_query($f_q);
+       $f_o = mysql_fetch_object($f_r);
+
+       //log downloads
+       @mysql_query("INSERT INTO log (hash,file,action,user_id,user_name,ip,date) VALUES ('".$_GET['f']."','{$f_o->file}','download','".$_SESSION[creds][user_id]."','".$_SESSION[creds][user_name]."','".$_SERVER[REMOTE_ADDR]."',NOW())");
+
+       $_hpath_arr=explode("/",$f_o->file);
+       $file=array_pop($_hpath_arr); //Remove filename
+       $path=implode("/",$_hpath_arr);
+       $squashweb->read_single_file($path,$file);
+       #$squashweb->read_directory($path,false,true,false,false);
+}else{
+       //parse folders for readable files
+       $squashweb->read_directory($path,true,true,$getdeepfiles,$populate);
+}
+
+//check if a file is requested
+if (isset($_GET['f']) && $_GET['f']!=NULL){
+       //get the config of requested file
+       $request = $squashweb->get_config($_GET['f']);
+       
+       //------------------------------------
+       //-check-file-and-request-type--start-
+       //------------------------------------
+       if (strpos($request['mime'],'ideo') && isset($_GET['d'])){ //embed video
+               $squashweb->embed_video($_GET['f']);    
+       }
+       elseif (strpos($request['mime'],'ideo') && isset($_GET['x'])){  //show stream playlist
+               $squashweb->create_playlist($_GET['f'],$_GET['x'],$request[2]);
+       }
+       else{   //show requested file
+       #       header('Cache-control: private');
+               header('Content-Disposition: attachment; filename="'.$request[2].'"');
+               header("Content-Type: ".$request['mime']);
+               if($request[3])header('Content-Length: '.$request[3]);
+               #@ob_flush();
+               @flush();
+               $squashweb->print_files($request['path'],$request[2]);
+       }
+       //---------------------------------
+       //-check-file-and-request-type-end-
+       //---------------------------------
+
+}elseif ($tools=="hide" && isset($_GET['h'])){
+       if ($_SESSION[creds][user_level] > 99){
+               $request = $squashweb->get_config($_GET['h']);
+               $handle = fopen($request['path'].'/'.$request[2].'.hidden', 'x');
+               fwrite($handle, 'hidden by '.$_SESSION[creds][user_name]);
+               fclose($handle);
+               $path=substr($request['path'],strlen($basedir));
+               header( 'Location: '.$_SERVER['PHP_SELF'].'?path='.$path) ;
+       }
+}elseif ($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));
+               header( 'Location: '.$_SERVER['PHP_SELF'].'?path='.$path) ;
+       }
+}elseif ($tools=="delete" && isset($_GET['h'])){
+       if ($_SESSION[creds][user_level] > 99){
+               if ($_GET['h'] == "multiple"){
+                       $h_post = $_POST['h'];
+                       foreach ($h_post as $h_key => $h){
+                               $request = $squashweb->get_config($h);
+                               $squashweb->delete_file($h,$_SESSION[creds]);
+                       }
+               }else{
+                       $h = $_GET['h'];
+                       $request = $squashweb->get_config($h);
+                       $squashweb->delete_file($h,$_SESSION[creds]);
+               }
+               $path=substr($request['path'],strlen($basedir));
+               header( 'Location: '.$_SERVER['PHP_SELF'].'?path='.$path);
+       }
+}elseif ($_GET['tools']=='access' && $_SESSION[creds][user_level] > 100){
+
+require_once("smarty/Smarty.class.php");
+
+$smarty = new Smarty;
+
+       $smarty->assign('user_level',$_SESSION[creds][user_level]);
+       $smarty->assign('user_name',$_SESSION[creds][user_name]);
+       $smarty->assign('users',$squashweb->get_users($_SESSION[creds][user_level]));
+
+       $smarty->assign('edited_user',$_GET['user']);
+       
+       $tree = $squashweb->show_rights_tree($path,0,$_GET['user']);
+       
+       $smarty->assign('style',$tree[style]);
+       $smarty->assign('layout',$tree[layout]);
+       
+       $smarty->assign('debug',$vars[debug]);
+       $smarty->assign('folderrights',$squashweb->folderrights());
+       $smarty->assign('userrights',$squashweb->userrights());
+       $smarty->display('admin.tpl');
+       
+}elseif ($_GET['tools']=='users' && $_SESSION[creds][user_level] > 100){
+
+if ($submitted[type]=="update"){$squashweb->update_users($submitted);}
+if ($submitted[type]=="disable"){$squashweb->disable_users($submitted);}
+if ($submitted[type]=="delete"){$squashweb->remove_users($submitted);}
+if ($submitted[type]=="new"){$squashweb->insert_users($submitted,$_SESSION[creds][user_level]);}
+require_once("smarty/Smarty.class.php");
+
+$smarty = new Smarty;
+
+       $smarty->assign('user_level',$_SESSION[creds][user_level]);
+       $smarty->assign('user_name',$_SESSION[creds][user_name]);
+       $smarty->assign('users',$squashweb->get_users($_SESSION[creds][user_level]));
+
+       if ($_SESSION[creds][user_level] > 199){
+       $smarty->assign('user_levels', array(155 => 'admin' , 55 => 'user' ) );
+       }else{
+       $smarty->assign('user_levels', array(55 => 'user' ) );
+       }
+       $smarty->assign('debug',$vars[debug]);
+
+       $smarty->display('udmin.tpl');
+
+}elseif ($_GET['tools']=='logs' && $_SESSION[creds][user_level] > 100){
+       $logtype=($_GET['logtype']) ? $_GET['logtype'] : 'all';
+       require_once("smarty/Smarty.class.php");
+
+       $smarty = new Smarty;
+
+       $smarty->assign('user_level',$_SESSION[creds][user_level]);
+       $smarty->assign('user_name',$_SESSION[creds][user_name]);
+       $smarty->assign('logtype',$logtype);
+       $smarty->assign('logs',$squashweb->get_logs($logtype));
+
+       $smarty->display('logs.tpl');
+
+}else{ //show overview
+
+require_once("smarty/Smarty.class.php");
+
+$smarty = new Smarty;
+
+       /***
+       *       $config:: array
+       *       [0]     ->      versioncode
+       *       [1]     ->      date&time
+       *       [2]     ->      filename
+       *       [3]     ->      filesize
+       *       [4]     ->      chunksize
+       *       [5]     ->      chunkcount
+       *       [6]     ->      CRC32 checksum
+       ***/
+       
+$configs_num = $squashweb->get_configs();
+
+$configs_sorted = named_records_sort($configs_num,'lastchange',true);
+
+foreach ($configs_sorted AS $key => $value){
+       $configs[$key]['squashed'] = $value['squashed'];
+       $configs[$key]['version'] = $value[0];
+       //$configs[$key]['date'] = $value[1]; //removed because user local creation date is irrelevant
+       $configs[$key]['name'] = $value[2];
+       $configs[$key]['size'] = $value[3];
+       $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;
+
+       $configs[$key]['embedable'] = $embedable;
+       $configs[$key]['finished'] = $finished;
+       $configs[$key]['mime'] = $value['mime'];
+       $configs[$key]['status'] = $value['status'];
+       $configs[$key]['hidden'] = $value['hidden'];
+       $configs[$key]['chunks_finished'] = @array_sum($value['stats']);
+       if($finished){
+               $configs[$key]['chunks_partial'] = $configs[$key]['chunks_finished'];
+       }else{
+               $continue=true;
+               foreach($value['stats'] AS $sk => $sv){
+                       if($continue){
+                               $configs[$key]['chunks_partial']=$configs[$key]['chunks_partial']+$sv;
+                               if($sv != '1.00')$continue=false;
+                       }
+               }
+       }
+       $configs[$key]['date'] = date('d.m.y - H:i:s - T',$value['added']);
+       $configs[$key]['lastchange'] = date('d.m.y - H:i:s - T',$value['lastchange']);
+}
+
+
+//set base folders
+       $basepath['/']='&nbsp;top&nbsp;';
+foreach (explode('/',$subf) AS $key => $value){
+       if ($value != ''){
+               $bpath.='/'.$value;
+               $basepath[$bpath]=$value;
+       }
+}
+$smarty->assign('debug',$vars[debug]);
+$smarty->assign('user_level',$_SESSION[creds][user_level]);
+$smarty->assign('user_name',$_SESSION[creds][user_name]);
+$smarty->assign('folderrights',$squashweb->folderrights());
+
+$smarty->assign('squashed',$configs);
+$smarty->assign('paths',$paths);
+$smarty->assign('base',$basepath);
+$smarty->assign('currentfolder',$subf);
+$subs = $squashweb->subfolders();
+asort($subs);
+$smarty->assign('subfolders',$subs);
+
+//if($vars[debug])print_r($configs);
+if(!$vars[newtpl])$smarty->display('index.tpl'); //Display normal template
+if($vars[newtpl])$smarty->display('wip_massdelete.tpl'); //Display Work In Progress template
+
+}
+?>
diff --git a/templates/admin.tpl b/templates/admin.tpl
new file mode 100644 (file)
index 0000000..af3152a
--- /dev/null
@@ -0,0 +1 @@
+{literal}<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Squasher</title><style>body{background-color:#E2EBD8;text-align:center;min-width:1000px;}.wrapper{width: 1000px;margin: 10px auto;}.container{border:5px solid;border-color:#FFFFFF;color:#003300;left:50%;background: #FFFFFF;}.control{float:right;text-align:right;}.menucontainer{background-color:#FFFFFF;}.menu{text-align:center;}.menuhead{float:left;background-color:#66CC00;color:#003300;margin:1px;border:1px solid;border-color:#66CC00;}.menuitem{float:left;background-color:#C7F09E;color:#003300;margin:1px;border:1px solid;border-color:#E2EBD8;}.menuitem_selected{float:left;background-color:#339900;color:#FFFFFF;margin:1px;border:1px solid;border-color:#E2EBD8;}.menuitem:hover{background-color:#339900;color:#FFFFFF;}.content{float:left;padding-right:5px;width:600px;}.item, .status1, .status2, .status3{position:relative;color:#003300;width:400px;height:36px;border:2px solid;border-color:#FFFFFF;font-size:12px;}.item{background-color:#E2EBD8;}.status1{background-color:#FFCCCC;}.status2{background-color:#FFFFCC;}.status3{background-color:#CCFFCC;}.name{position:absolute;left:1px;top:1px;padding-left:1px;}.center{float:left;height:inherit;padding-left:1px;}.chunks{position:absolute;left:1px;bottom:1px;padding-left:1px;}.size{position:absolute;left:100px;bottom:1px;padding-left:1px;}.status{position:absolute;right:2px;top:1px;padding-left:1px;}.stream{position:absolute;float:right;bottom:1px;padding-left:1px;}.download{position:absolute;right:2px;bottom:1px;padding-left:1px;}.clear{clear:both;height:1px;}.spacer{clear:both;height:10px;}.videoframe{float:left;width:500px;height:400px;padding-left:25px;}.banner{background-color:#66CC00;text-align:center;width:100%;height:45px;background:#66CC00 url(img/squash.gif) no-repeat 30px 50%;}.titel{background-color:#66CC00;text-align:center;}.footer{background-color:#66CC00;text-align:center;background:#66CC00 url(img/gplogobottomright.gif) no-repeat 100%;}.bottomimage{background: #FFFFFF url(img/gp1.gif) no-repeat 95% 95%;float:right;width:300px;height:146px;}a{color:#003300;}a:hover{color:#FF6600;}.white_border{float:left;border-top:0px solid #FFFFFF;border-bottom:0px solid #FFFFFF;}.check_all, .check_allow, .check_deny{float:right;height:20px;}.sample_all, .sample_allow, .sample_deny{float:left;height:20px;}.check_all, .sample_all{background-color:#AAEEAA;}.check_allow, .sample_allow{background-color:#EEEEAA;}.check_deny, .sample_deny{background-color:#EEAAAA;}{/literal}{foreach item=style_row from=$style}{$style_row}{/foreach}</style></head><body align="center" style="min-width:1000px;"><div class="wrapper"><div class="container">     <div class="banner">&nbsp;<div class="control">{if $user_level > 99}<a href="?">home</a>&nbsp;|&nbsp;<a href="?tools=access">access</a>&nbsp;|{/if}{if $user_level > 99}&nbsp;<a href="?tools=users">users</a>&nbsp;|&nbsp;<a href="?tools=logs">logs</a>&nbsp;|{/if}&nbsp;<a href="index.php?tools=logout">logout({$user_name})</a>&nbsp;</div></div>  <div class="spacer"></div>      <div class="menucontainer">     <div class="menu">      <div class="menuhead">users</div>       {foreach item=user key=user_id from=$users}<div {if $user_id eq $edited_user}class="menuitem_selected"{else}class="menuitem"{/if} onClick="location.href='?tools=access&user={$user.id}'" style="cursor:pointer" >{$user.name}</div>{/foreach}  </div>  <div class="clear"></div>       <div class="menu">{*    <div class="menuhead">subfolders</div>  {foreach item=folder key=folderpath from=$subfolders}<div class="menuitem" onClick="location.href='?path={$folderpath}'" style="cursor:pointer" >{$folder}</div>{/foreach}*}    </div>  <div class="clear"></div>       </div>  <div class="spacer"></div>      <div class="content">   {if $layout}    <div class="legend">  <div class='sample_all'><!--input name='sample' value=2 type=radio /-->&nbsp; allow this and all underlying folders &nbsp;</div>  <div class='sample_allow'><!--input name='sample' value=1 type=radio /-->&nbsp; allow this folder &nbsp;</div>  <div class='sample_deny'><!--input name='sample' value=0 type=radio /-->&nbsp; deny access to this folder &nbsp;</div>  </div>  <form method='post'>    <input type='hidden' name='formtype' value='folderrights' />    <input type='hidden' name='edited_user' value={$edited_user} />{$layout}        <div style='float:left;'><input type='submit' value='Save'/></div>      </form>{/if}    </div>  <div class="bottomimage"></div> <div class="clear"></div>       <div class="spacer"></div>      <div class="footer">&nbsp;</div></div></div>{if $debug}{debug}{/if}</body></html>
\ No newline at end of file
diff --git a/templates/index.tpl b/templates/index.tpl
new file mode 100644 (file)
index 0000000..41a3468
--- /dev/null
@@ -0,0 +1,389 @@
+{literal}<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<title>Squasher</title>
+<style>
+
+body{
+background-color:#E2EBD8;
+min-width:1000px;
+font-family:Arial Narrow;
+font-size:16px;
+}
+
+.wrapper{
+width: 1000px;
+margin: 10px auto;
+}
+
+.container{
+border:5px solid;
+border-color:#FFFFFF;
+color:#FFFFFF;
+left:50%;
+background: #FFFFFF;
+}
+
+.control{
+float:right;
+text-align:right;
+}
+
+.menucontainer{
+background-color:#FFFFFF;
+}
+
+.menu{
+text-align:center;
+}
+
+.menuhead{
+float:left;
+background-color:#66CC00;
+color:#003300;
+margin:1px;
+border:1px solid;
+border-color:#66CC00;
+}
+
+.menuitem{
+float:left;
+background-color:#C7F09E;
+color:#003300;
+margin:1px;
+border:1px solid;
+border-color:#E2EBD8;
+}
+
+.menuitem:hover{
+background-color:#339900;
+color:#FFFFFF;
+}
+
+.content{
+float:left;
+padding-right:5px;
+}
+
+.item, .status1, .status2, .status3{
+position:relative;
+color:#003300;
+width:600px;
+border:2px solid;
+border-color:#FFFFFF;
+font-size:12px;
+}
+
+.item{
+background-color:#E2EBD8;
+}
+.status1{
+background-color:#FFCCCC;
+}
+.status2{
+background-color:#FFFFCC;
+}
+.status3{
+background-color:#CCFFCC;
+}
+
+.name{
+float:left;
+left:1px;
+top:1px;
+padding-left:1px;
+z-index:50;
+}
+
+.center{
+float:left;
+height:inherit;
+padding-left:1px;
+}
+
+.chunks{
+float:right;
+padding-left:2px;
+padding-right:3px;
+}
+
+.size{
+float:right;
+padding-left:2px;
+padding-right:3px;
+}
+
+.added{
+float:left;
+padding-left:2px;
+padding-right:3px;
+}
+
+.updated{
+float:left;
+padding-left:2px;
+padding-right:3px;
+}
+
+.status{
+float:right;
+top:1px;
+padding-right:2px;
+text-align:right;
+z-index:10;
+}
+
+.stream{
+float:right;
+padding-left:1px;
+padding-right:2px;
+}
+
+.download{
+float:right;
+padding-left:1px;
+padding-right:2px;
+}
+
+.clear{
+clear:both;
+height:1px;
+font-size: 0;
+}
+
+.spacer{
+clear:both;
+height:10px;
+}
+
+.videoframe{
+float:left;
+width:500px;
+height:400px;
+padding-left:25px;
+}
+
+.banner{
+background-color:#66CC00;
+text-align:center;
+width:100%;
+height:45px;
+background:#66CC00 url(img/squash.gif) no-repeat 30px 50%;
+}
+
+.titel{
+background-color:#66CC00;
+text-align:center;
+}
+
+.footer{
+background-color:#66CC00;
+text-align:center;
+background:#66CC00 url(img/gplogobottomright.gif) no-repeat 100%;
+}
+
+.bottomimage{
+background: #FFFFFF url(img/gp1.gif) no-repeat 95% 95%;
+float:right;
+width:300px;
+height:146px;
+}
+
+.massdelete{
+#position:absolute;
+#bottom:0;
+float:right;
+width:300px;
+#height:146px;
+}
+
+.deletebox{
+#visibility: hidden;
+}
+
+.filler{
+position:relative;
+float:right;
+width:300px;
+#height:500px;
+}
+
+a{
+color:#003300;
+}
+
+a:hover{
+color:#FF6600;
+}
+
+</style>
+  <script type="text/javascript" language="JavaScript">
+   function toggle_id(hideshow){
+    if(document.getElementById(hideshow).style.visibility == 'visible') {
+     document.getElementById(hideshow).style.visibility = 'hidden';
+    }else{
+     document.getElementById(hideshow).style.visibility = 'visible';
+    }
+   }
+   function selectAllList() {
+    var aSelect = document.deletetool["h[]"];
+    var aSelectLen = aSelect.length;
+    for(i = 0; i < aSelectLen; i++) {
+     aSelect.options[i].selected = true;
+    }
+   }
+  </script></head>
+{/literal}
+<body style="min-width:1000px;">
+<div class="wrapper">
+<div class="container">
+
+       <div class="banner">&nbsp;<div class="control">{if $user_level > 99}<a href="?">home</a>&nbsp;|&nbsp;<a href="?tools=access">access</a>&nbsp;|{/if}{if $user_level > 99}&nbsp;<a href="?tools=users">users</a>&nbsp;|&nbsp;<a href="?tools=logs">logs</a>&nbsp;|{/if}&nbsp;<a href="index.php?tools=logout">logout({$user_name})</a>&nbsp;</div></div>
+
+       <div class="spacer"></div>
+
+       <div class="menucontainer">
+
+       <div class="menu">
+       
+       <div class="menuhead">current folder</div>
+       
+       {foreach item=crumb key=cookie from=$base}<div class="menuitem" onClick="location.href='?path={$cookie}'" style="cursor:pointer" >{$crumb}</div>{/foreach}
+       
+       </div>
+       
+       <div class="clear"></div>
+       
+       <div class="menu">
+       
+       <div class="menuhead">subfolders</div>
+       
+       {foreach item=folder key=folderpath from=$subfolders}<div class="menuitem" onClick="location.href='?path={$folderpath}'" style="cursor:pointer" >{$folder}</div>{/foreach}
+       
+       </div>
+       
+       <div class="clear"></div>
+{*     
+       <div class="menu">
+       
+       {foreach item=dir key=path from=$paths}{if $path!=$currentfolder}<div class="menuitem" onClick="location.href='squasher.php?path={$path}'" style="cursor:pointer" >{$dir}</div>{/if}{/foreach}
+       
+       </div>
+       
+       
+       
+       <div class="clear"></div>*}
+       
+       </div>
+       
+       <div class="spacer"></div>
+
+<div class="content">
+{foreach item=item key=id from=$squashed}
+{counter assign=mass_delete_size print=false}
+{if $item.squashed}{*These items are in chunks / uploaded by the squasher tool*}
+
+{if $item.hidden eq false OR $user_level > 99 }
+               <div class={if $item.finished==true}"status3"{elseif $item.finished!=true && $item.embedable==true}"status2"{elseif $item.finished!=true && $item.embedable!=true}"status1"{else}"item"{/if}>
+
+                               <div class="name">{$item.name} {if $user_level > 99}{if $item.hidden}<font color=red>|<a href='?tools=unhide&h={$id}'>publish</a>|</font>{else}<font color=green>|<a href='?tools=hide&h={$id}'>hide</a>|</font>{/if}{if $user_level > 100}<font color=red>|<a href='?tools=delete&h={$id}' onClick="javascript:return confirm('Are you sure you want to permanently delete {$item.name}?')">delete</a>|</font>{/if}{/if}</div>
+
+                               <div class="status">status: {$item.status}</div>
+
+               <div class="clear"></div>
+
+               <div class="added">added: {$item.date}</div>
+               
+                               <!--div class="chunks"></div-->
+                               <div class="size">size:&nbsp;{if $item.size>(1024*1024)}{math equation="((x / 1024) / 1024) * (y / z)" x=$item.size y=$item.chunks_finished z=$item.chunks format="%.2f"}&nbsp;/&nbsp;{math equation="(x / 1024) / 1024" x=$item.size format="%.2f"}mb{elseif $item.size>(1024)}{math equation="(x / 1024) * (y / z)" x=$item.size y=$item.chunks_finished z=$item.chunks format="%.2f"}&nbsp;/&nbsp;{math equation="(x / 1024)" x=$item.size format="%.2f"}kb{else}{math equation="x * (y / z)" x=$item.size y=$item.chunks_finished z=$item.chunks format="%.0f"}&nbsp;/&nbsp;{$item.size}b{/if}({math equation="(y / x) * 100" x=$item.chunks y=$item.chunks_finished format="%.0f"}%)</div>
+
+               <div class="clear"></div>
+
+               <div class="updated">last updated: {$item.lastchange}</div>
+
+
+{if $item.finished==true}
+                               <div class="download"><a href='?f={$id}'>download</a></div>
+{/if}
+{if $item.embedable eq true and $item.finished eq false}
+       {if $item.mime=='video/mpeg'}
+                               <div class="stream"><a href='?f={$id}'>download ({math equation="(y / x) * 100" x=$item.chunks y=$item.chunks_partial format="%.0f"}%)</a></div>
+       {/if}
+{/if}
+
+               <div class="clear"></div>
+               </div>
+       
+               <div class="clear"></div>
+{/if}
+
+{else}{*These items are plain files / uploaded manually by the user via ftp*}
+
+{if $item.hidden eq false OR $user_level > 99 }
+               <div class={if $item.finished==true}"status3"{elseif $item.finished!=true && $item.embedable==true}"status2"{elseif $item.finished!=true && $item.embedable!=true}"status1"{else}"item"{/if}>
+
+                               <div class="name">{$item.name} {if $user_level > 99}{if $item.hidden}<font color=red>|<a href='?tools=unhide&h={$id}'>publish</a>|</font>{else}<font color=green>|<a href='?tools=hide&h={$id}'>hide</a>|</font>{/if}{if $user_level > 199}<font color=red>|<a href='?tools=delete&h={$id}' onClick="javascript:return confirm('Are you sure you want to permanently delete {$item.name}?')">delete</a>|</font>{/if}{/if}</div>
+
+                               <div class="status">status: {$item.status}</div>
+
+               <div class="clear"></div>
+
+               <div class="added">added: {$item.date}</div>
+
+                               <div class="size">size:&nbsp;{if $item.size>(1024*1024)}{math equation="(x / 1024) / 1024" x=$item.size format="%.2f"}mb{elseif $item.size>(1024)}{math equation="(x / 1024)" x=$item.size format="%.2f"}kb{else}{$item.size}b{/if}</div>
+
+               <div class="clear"></div>
+
+               <div class="updated">last updated: {$item.lastchange}</div>
+
+
+{if $item.finished==true}
+                               <div class="download"><a href='?f={$id}'>download</a></div>
+{/if}
+{if $item.embedable eq true and $item.finished eq false}
+       {if $item.mime=='video/mpeg'}
+                               <div class="stream"><a href='?f={$id}'>download (partial)</a></div>
+       {/if}
+{/if}
+
+
+               <div class="clear"></div>
+               </div>
+       
+               <div class="clear"></div>
+{/if}
+{/if}
+{/foreach}
+
+       </div>
+
+       <div class="filler">
+       <div class="bottomimage"></div>
+{if $user_level > 100 and $mass_delete_size > 1}
+               <div class="massdelete"><br>
+<div class="deletebox" id="deletebox">
+       <form name="deletetool" action="?tools=delete&h=multiple" method="post" onSubmit='return confirm("Are you sure you want to delete the selected files? \nThis page may take a while to reload while the files are removed.");'>
+               <select multiple="" size="{$mass_delete_size}" id="h" name="h[]" width="300px">
+{foreach item=item key=id from=$squashed}
+                       <option value="{$id}" title="{$item.name}">{$item.name|truncate:39}</option>
+{/foreach}
+               </select>
+               <input type="button" value="Select All" OnClick="selectAllList();" ><input type="reset" value="Clear"><input type="submit" value="Delete Selected Items">
+       </form>
+</div>
+{*<br><input type="button" value=":show deletion tool:" OnClick="toggle_id('deletebox');" >*}
+       </div>
+{/if}
+       </div>
+       <div class="clear"></div>
+
+       <div class="spacer"></div>
+
+       <div class="footer">&nbsp;</div>
+
+</div>
+</div>
+{if $debug}{debug}{/if}
+</body>
+</html>
diff --git a/templates/index2.tpl b/templates/index2.tpl
new file mode 100644 (file)
index 0000000..896f880
--- /dev/null
@@ -0,0 +1,348 @@
+{literal}<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<title>Squasher</title>
+<style>
+
+body{
+background-color:#E2EBD8;
+min-width:1000px;
+font-family:Arial Narrow;
+font-size:16px;
+}
+
+.wrapper{
+width: 1000px;
+margin: 10px auto;
+}
+
+.container{
+border:5px solid;
+border-color:#FFFFFF;
+color:#FFFFFF;
+left:50%;
+background: #FFFFFF;
+}
+
+.control{
+float:right;
+text-align:right;
+}
+
+.menucontainer{
+background-color:#FFFFFF;
+}
+
+.menu{
+text-align:center;
+}
+
+.menuhead{
+float:left;
+background-color:#66CC00;
+color:#003300;
+margin:1px;
+border:1px solid;
+border-color:#66CC00;
+}
+
+.menuitem{
+float:left;
+background-color:#C7F09E;
+color:#003300;
+margin:1px;
+border:1px solid;
+border-color:#E2EBD8;
+}
+
+.menuitem:hover{
+background-color:#339900;
+color:#FFFFFF;
+}
+
+.content{
+float:left;
+padding-right:5px;
+}
+
+.item, .status1, .status2, .status3{
+position:relative;
+color:#003300;
+width:400px;
+height:50px;
+border:2px solid;
+border-color:#FFFFFF;
+font-size:12px;
+}
+
+.item{
+background-color:#E2EBD8;
+}
+.status1{
+background-color:#FFCCCC;
+}
+.status2{
+background-color:#FFFFCC;
+}
+.status3{
+background-color:#CCFFCC;
+}
+
+.name{
+float:left;
+left:1px;
+top:1px;
+padding-left:1px;
+z-index:50;
+}
+
+.center{
+float:left;
+height:inherit;
+padding-left:1px;
+}
+
+.chunks{
+float:right;
+padding-left:2px;
+padding-right:3px;
+}
+
+.size{
+float:right;
+padding-left:2px;
+padding-right:3px;
+}
+
+.added{
+float:left;
+padding-left:2px;
+padding-right:3px;
+}
+
+.updated{
+float:left;
+padding-left:2px;
+padding-right:3px;
+}
+
+.status{
+float:right;
+top:1px;
+padding-right:2px;
+text-align:right;
+z-index:10;
+}
+
+.stream{
+float:right;
+padding-left:1px;
+padding-right:2px;
+}
+
+.download{
+float:right;
+padding-left:1px;
+padding-right:2px;
+}
+
+.clear{
+clear:both;
+height:1px;
+font-size: 0;
+}
+
+.spacer{
+clear:both;
+height:10px;
+}
+
+.videoframe{
+float:left;
+width:500px;
+height:400px;
+padding-left:25px;
+}
+
+.banner{
+background-color:#66CC00;
+text-align:center;
+width:100%;
+height:45px;
+background:#66CC00 url(img/squash.gif) no-repeat 30px 50%;
+}
+
+.titel{
+background-color:#66CC00;
+text-align:center;
+}
+
+.footer{
+background-color:#66CC00;
+text-align:center;
+background:#66CC00 url(img/gplogobottomright.gif) no-repeat 100%;
+}
+
+.bottomimage{
+background: #FFFFFF url(img/gp1.gif) no-repeat 95% 95%;
+float:right;
+width:300px;
+height:146px;
+}
+
+a{
+color:#003300;
+}
+
+a:hover{
+color:#FF6600;
+}
+
+</style>
+</head>
+{/literal}
+<body style="min-width:1000px;">
+<div class="wrapper">
+<div class="container">
+
+       <div class="banner">&nbsp;<div class="control">{if $user_level > 99}<a href="?">home</a>&nbsp;|&nbsp;<a href="?tools=access">access</a>&nbsp;|{/if}{if $user_level > 99}&nbsp;<a href="?tools=users">users</a>&nbsp;|{/if}&nbsp;<a href="index.php?tools=logout">logout({$user_name})</a>&nbsp;</div></div>
+
+       <div class="spacer"></div>
+
+       <div class="menucontainer">
+
+       <div class="menu">
+
+       <div class="menuhead">current folder</div>
+
+       {foreach item=crumb key=cookie from=$base}<div class="menuitem" onClick="location.href='?path={$cookie}'" style="cursor:pointer" >{$crumb}</div>{/foreach}
+
+       </div>
+
+       <div class="clear"></div>
+
+       <div class="menu">
+
+       <div class="menuhead">subfolders</div>
+
+       {foreach item=folder key=folderpath from=$subfolders}<div class="menuitem" onClick="location.href='?path={$folderpath}'" style="cursor:pointer" >{$folder}</div>{/foreach}
+
+       </div>
+
+       <div class="clear"></div>
+{*     
+       <div class="menu">
+
+       {foreach item=dir key=path from=$paths}{if $path!=$currentfolder}<div class="menuitem" onClick="location.href='squasher.php?path={$path}'" style="cursor:pointer" >{$dir}</div>{/if}{/foreach}
+
+       </div>
+
+
+
+       <div class="clear"></div>*}
+
+       </div>
+
+       <div class="spacer"></div>
+
+<div class="content">
+{foreach item=item key=id from=$squashed}
+
+{if $item.squashed}{*These items are in chunks / uploaded by the squasher tool*}
+
+{if $item.hidden eq false OR $user_level > 99 }
+       <div class={if $item.finished==true}"status3"{elseif $item.finished!=true && $item.embedable==true}"status2"{elseif $item.finished!=true && $item.embedable!=true}"status1"{else}"item"{/if}>
+
+               <div class="name">{$item.name} {if $user_level > 99}{if $item.hidden}<font color=red>|<a href='?tools=unhide&h={$id}'>publish</a>|</font>{else}<font color=green>|<a href='?tools=hide&h={$id}'>hide</a>|</font>{/if}{if $user_level > 199}<font color=red>|<a href='?tools=delete&h={$id}' onClick="javascript:return confirm('Are you sure you want to permanently delete {$item.name}?')">delete</a>|</font>{/if}{/if}</div>
+
+               <div class="status">status: {$item.status}</div>
+
+       <div class="clear"></div>
+
+               <div class="added">added: {$item.date}</div>
+
+               <div class="chunks">({math equation="(y / x) * 100" x=$item.chunks y=$item.chunks_finished format="%.0f"}%)</div>
+               <div class="size">size:&nbsp;{if $item.size>(1024*1024)}{math equation="((x / 1024) / 1024) * (y / z)" x=$item.size y=$item.chunks_finished z=$item.chunks format="%.2f"}&nbsp;/&nbsp;{math equation="(x / 1024) / 1024" x=$item.size format="%.2f"}mb{elseif $item.size>(1024)}{math equation="(x / 1024) * (y / z)" x=$item.size y=$item.chunks_finished z=$item.chunks format="%.2f"}&nbsp;/&nbsp;{math equation="(x / 1024)" x=$item.size format="%.2f"}kb{else}{math equation="x * (y / z)" x=$item.size y=$item.chunks_finished z=$item.chunks format="%.0f"}&nbsp;/&nbsp;{$item.size}b{/if}</div>
+
+       <div class="clear"></div>
+
+               <div class="updated">last updated: {$item.lastchange}</div>
+
+
+{if $item.finished==true}
+               <div class="download"><a href='?f={$id}'>download</a></div>
+{/if}
+{if $item.embedable==true}
+       {if $item.finished==false}
+               <div class="download"><a href='?f={$id}'>download</a></div>
+       {/if}
+       {if $item.mime=='video/mpeg'}
+               <div class="stream"><a href='?d=x&f={$id}' target='videoframe'>sttreaming(embedded)</a></div>
+       {/if}
+               <div class="stream"><a href='?x=vlc&f={$id}'>streaming(vlc)</a></div>
+               <!--div class="stream">streaming </div-->
+{/if}
+
+       </div>
+       
+{/if}
+
+{else}{*These items plain files / uploaded manually by the user via ftp*}
+
+{if $item.hidden eq false OR $user_level > 99 }
+               <div class={if $item.finished==true}"status3"{elseif $item.finished!=true && $item.embedable==true}"status2"{elseif $item.finished!=true && $item.embedable!=true}"status1"{else}"item"{/if}>
+
+                               <div class="name">{$item.name} {if $user_level > 99}{if $item.hidden}<font color=red>|<a href='?tools=unhide&h={$id}'>publish</a>|</font>{else}<font color=green>|<a href='?tools=hide&h={$id}'>hide</a>|</font>{/if}{if $user_level > 199}<font color=red>|<a href='?tools=delete&h={$id}' onClick="javascript:return confirm('Are you sure you want to permanently delete {$item.name}?')">delete</a>|</font>{/if}{/if}</div>
+
+                               <div class="status">status: {$item.status}</div>
+
+               <div class="clear"></div>
+
+               <div class="added">added: {$item.date}</div>
+
+                               <div class="size">size:&nbsp;{if $item.size>(1024*1024)}{math equation="(x / 1024) / 1024" x=$item.size format="%.2f"}mb{elseif $item.size>(1024)}{math equation="(x / 1024)" x=$item.size format="%.2f"}kb{else}{$item.size}b{/if}</div>
+
+               <div class="clear"></div>
+
+               <div class="updated">last updated: {$item.lastchange}</div>
+
+
+{if $item.finished==true}
+                               <div class="download"><a href='?f={$id}'>download</a></div>
+{/if}
+{if $item.embedable==true}
+       {if $item.finished==false}
+                               <div class="download"><a href='?f={$id}'>download</a></div>
+       {/if}
+       {if $item.mime=='video/mpeg'}
+                               <div class="stream"><a href='?d=x&f={$id}' target='videoframe'>embed</a></div>
+       {/if}
+                               <div class="stream"><a href='?x=vlc&f={$id}'>vlc</a></div>
+                               <div class="stream">streaming: </div>
+{/if}
+
+               </div>
+       
+               <div class="clear"></div>
+{/if}
+{/if}
+{/foreach}
+
+       </div>
+
+       <iframe class="videoframe" NAME='videoframe' FRAMEBORDER=0 SCROLLING=0 ></iframe>
+
+       <div class="bottomimage"></div>
+       
+       <div class="clear"></div>
+
+       <div class="spacer"></div>
+
+       <div class="footer">&nbsp;</div>
+
+</div>
+</div>
+{if $debug}{debug}{/if}
+</body>
+</html>
diff --git a/templates/index_streaming.tpl b/templates/index_streaming.tpl
new file mode 100644 (file)
index 0000000..c34731e
--- /dev/null
@@ -0,0 +1,349 @@
+{literal}<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<title>Squasher</title>
+<style>
+
+body{
+background-color:#E2EBD8;
+min-width:1000px;
+font-family:Arial Narrow;
+font-size:16px;
+}
+
+.wrapper{
+width: 1000px;
+margin: 10px auto;
+}
+
+.container{
+border:5px solid;
+border-color:#FFFFFF;
+color:#FFFFFF;
+left:50%;
+background: #FFFFFF;
+}
+
+.control{
+float:right;
+text-align:right;
+}
+
+.menucontainer{
+background-color:#FFFFFF;
+}
+
+.menu{
+text-align:center;
+}
+
+.menuhead{
+float:left;
+background-color:#66CC00;
+color:#003300;
+margin:1px;
+border:1px solid;
+border-color:#66CC00;
+}
+
+.menuitem{
+float:left;
+background-color:#C7F09E;
+color:#003300;
+margin:1px;
+border:1px solid;
+border-color:#E2EBD8;
+}
+
+.menuitem:hover{
+background-color:#339900;
+color:#FFFFFF;
+}
+
+.content{
+float:left;
+padding-right:5px;
+}
+
+.item, .status1, .status2, .status3{
+position:relative;
+color:#003300;
+width:400px;
+height:50px;
+border:2px solid;
+border-color:#FFFFFF;
+font-size:12px;
+}
+
+.item{
+background-color:#E2EBD8;
+}
+.status1{
+background-color:#FFCCCC;
+}
+.status2{
+background-color:#FFFFCC;
+}
+.status3{
+background-color:#CCFFCC;
+}
+
+.name{
+float:left;
+left:1px;
+top:1px;
+padding-left:1px;
+z-index:50;
+}
+
+.center{
+float:left;
+height:inherit;
+padding-left:1px;
+}
+
+.chunks{
+float:right;
+padding-left:2px;
+padding-right:3px;
+}
+
+.size{
+float:right;
+padding-left:2px;
+padding-right:3px;
+}
+
+.added{
+float:left;
+padding-left:2px;
+padding-right:3px;
+}
+
+.updated{
+float:left;
+padding-left:2px;
+padding-right:3px;
+}
+
+.status{
+float:right;
+top:1px;
+padding-right:2px;
+text-align:right;
+z-index:10;
+}
+
+.stream{
+float:right;
+padding-left:1px;
+padding-right:2px;
+}
+
+.download{
+float:right;
+padding-left:1px;
+padding-right:2px;
+}
+
+.clear{
+clear:both;
+height:1px;
+font-size: 0;
+}
+
+.spacer{
+clear:both;
+height:10px;
+}
+
+.videoframe{
+float:left;
+width:500px;
+height:400px;
+padding-left:25px;
+}
+
+.banner{
+background-color:#66CC00;
+text-align:center;
+width:100%;
+height:45px;
+background:#66CC00 url(img/squash.gif) no-repeat 30px 50%;
+}
+
+.titel{
+background-color:#66CC00;
+text-align:center;
+}
+
+.footer{
+background-color:#66CC00;
+text-align:center;
+background:#66CC00 url(img/gplogobottomright.gif) no-repeat 100%;
+}
+
+.bottomimage{
+background: #FFFFFF url(img/gp1.gif) no-repeat 95% 95%;
+float:right;
+width:300px;
+height:146px;
+}
+
+a{
+color:#003300;
+}
+
+a:hover{
+color:#FF6600;
+}
+
+</style>
+</head>
+{/literal}
+<body style="min-width:1000px;">
+<div class="wrapper">
+<div class="container">
+
+       <div class="banner">&nbsp;<div class="control">{if $user_level > 99}<a href="?">home</a>&nbsp;|&nbsp;<a href="?tools=access">access</a>&nbsp;|{/if}{if $user_level > 99}&nbsp;<a href="?tools=users">users</a>&nbsp;|{/if}&nbsp;<a href="index.php?tools=logout">logout({$user_name})</a>&nbsp;</div></div>
+
+       <div class="spacer"></div>
+
+       <div class="menucontainer">
+
+       <div class="menu">
+       
+       <div class="menuhead">current folder</div>
+       
+       {foreach item=crumb key=cookie from=$base}<div class="menuitem" onClick="location.href='?path={$cookie}'" style="cursor:pointer" >{$crumb}</div>{/foreach}
+       
+       </div>
+       
+       <div class="clear"></div>
+       
+       <div class="menu">
+       
+       <div class="menuhead">subfolders</div>
+       
+       {foreach item=folder key=folderpath from=$subfolders}<div class="menuitem" onClick="location.href='?path={$folderpath}'" style="cursor:pointer" >{$folder}</div>{/foreach}
+       
+       </div>
+       
+       <div class="clear"></div>
+{*     
+       <div class="menu">
+       
+       {foreach item=dir key=path from=$paths}{if $path!=$currentfolder}<div class="menuitem" onClick="location.href='squasher.php?path={$path}'" style="cursor:pointer" >{$dir}</div>{/if}{/foreach}
+       
+       </div>
+       
+       
+       
+       <div class="clear"></div>*}
+       
+       </div>
+       
+       <div class="spacer"></div>
+
+<div class="content">
+{foreach item=item key=id from=$squashed}
+
+{if $item.squashed}{*These items are in chunks / uploaded by the squasher tool*}
+
+{if $item.hidden eq false OR $user_level > 99 }
+               <div class={if $item.finished==true}"status3"{elseif $item.finished!=true && $item.embedable==true}"status2"{elseif $item.finished!=true && $item.embedable!=true}"status1"{else}"item"{/if}>
+
+                               <div class="name">{$item.name} {if $user_level > 99}{if $item.hidden}<font color=red>|<a href='?tools=unhide&h={$id}'>publish</a>|</font>{else}<font color=green>|<a href='?tools=hide&h={$id}'>hide</a>|</font>{/if}{if $user_level > 199}<font color=red>|<a href='?tools=delete&h={$id}' onClick="javascript:return confirm('Are you sure you want to permanently delete {$item.name}?')">delete</a>|</font>{/if}{/if}</div>
+
+                               <div class="status">status: {$item.status}</div>
+
+               <div class="clear"></div>
+
+               <div class="added">added: {$item.date}</div>
+               
+                               <!--div class="chunks"></div-->
+                               <div class="size">size:&nbsp;{if $item.size>(1024*1024)}{math equation="((x / 1024) / 1024) * (y / z)" x=$item.size y=$item.chunks_finished z=$item.chunks format="%.2f"}&nbsp;/&nbsp;{math equation="(x / 1024) / 1024" x=$item.size format="%.2f"}mb{elseif $item.size>(1024)}{math equation="(x / 1024) * (y / z)" x=$item.size y=$item.chunks_finished z=$item.chunks format="%.2f"}&nbsp;/&nbsp;{math equation="(x / 1024)" x=$item.size format="%.2f"}kb{else}{math equation="x * (y / z)" x=$item.size y=$item.chunks_finished z=$item.chunks format="%.0f"}&nbsp;/&nbsp;{$item.size}b{/if}({math equation="(y / x) * 100" x=$item.chunks y=$item.chunks_finished format="%.0f"}%)</div>
+
+               <div class="clear"></div>
+
+               <div class="updated">last updated: {$item.lastchange}</div>
+
+
+{if $item.finished==true}
+                               <div class="download"><a href='?f={$id}'>download</a></div>
+{/if}
+{if $item.embedable==true}
+       {if $item.finished==false}
+                               <div class="download"><a href='?f={$id}'>download</a></div>
+       {/if}
+       {if $item.mime=='video/mpeg'}
+                               <div class="stream"><a href='?d=x&f={$id}' target='videoframe'>embed</a></div>
+       {/if}
+                               <div class="stream"><a href='?x=vlc&f={$id}'>vlc</a></div>
+                               <div class="stream">streaming: </div>
+{/if}
+
+               </div>
+       
+               <div class="clear"></div>
+{/if}
+
+{else}{*These items plain files / uploaded manually by the user via ftp*}
+
+{if $item.hidden eq false OR $user_level > 99 }
+               <div class={if $item.finished==true}"status3"{elseif $item.finished!=true && $item.embedable==true}"status2"{elseif $item.finished!=true && $item.embedable!=true}"status1"{else}"item"{/if}>
+
+                               <div class="name">{$item.name} {if $user_level > 99}{if $item.hidden}<font color=red>|<a href='?tools=unhide&h={$id}'>publish</a>|</font>{else}<font color=green>|<a href='?tools=hide&h={$id}'>hide</a>|</font>{/if}{if $user_level > 199}<font color=red>|<a href='?tools=delete&h={$id}' onClick="javascript:return confirm('Are you sure you want to permanently delete {$item.name}?')">delete</a>|</font>{/if}{/if}</div>
+
+                               <div class="status">status: {$item.status}</div>
+
+               <div class="clear"></div>
+
+               <div class="added">added: {$item.date}</div>
+
+                               <div class="size">size:&nbsp;{if $item.size>(1024*1024)}{math equation="(x / 1024) / 1024" x=$item.size format="%.2f"}mb{elseif $item.size>(1024)}{math equation="(x / 1024)" x=$item.size format="%.2f"}kb{else}{$item.size}b{/if}</div>
+
+               <div class="clear"></div>
+
+               <div class="updated">last updated: {$item.lastchange}</div>
+
+
+{if $item.finished==true}
+                               <div class="download"><a href='?f={$id}'>download</a></div>
+{/if}
+{if $item.embedable==true}
+       {if $item.finished==false}
+                               <div class="download"><a href='?f={$id}'>download</a></div>
+       {/if}
+       {if $item.mime=='video/mpeg'}
+                               <div class="stream"><a href='?d=x&f={$id}' target='videoframe'>streaming(embedded)</a></div>
+       {/if}
+                               <div class="stream"><a href='?x=vlc&f={$id}'>streaming(vlc)</a></div>
+                               <!--div class="stream">streaming: </div-->
+{/if}
+
+               </div>
+       
+               <div class="clear"></div>
+{/if}
+{/if}
+{/foreach}
+
+       </div>
+
+       <iframe class="videoframe" NAME='videoframe' FRAMEBORDER=0 SCROLLING=0 ></iframe>
+
+       <div class="bottomimage"></div>
+       
+       <div class="clear"></div>
+
+       <div class="spacer"></div>
+
+       <div class="footer">&nbsp;</div>
+
+</div>
+</div>
+{if $debug}{debug}{/if}
+</body>
+</html>
diff --git a/templates/login.tpl b/templates/login.tpl
new file mode 100644 (file)
index 0000000..88e5d33
--- /dev/null
@@ -0,0 +1,160 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<title>Squasher</title>
+<style>
+{literal}
+body{
+background-color:#E2EBD8;
+text-align:center;
+min-width:400px;
+min-height:300px;
+}
+
+.wrapper{
+width: 240px;
+height: 160px;
+margin: 10% auto;
+}
+
+.container{
+position:relative;
+width: 240px;
+height: 160px;
+border:5px solid;
+border-color:#FFFFFF;
+color:#FFFFFF;
+background: #C7F09E;
+}
+
+.login{
+left:0px;
+top:20px;
+width:100%;
+}
+
+.username{
+position:absolute;
+left:0px;
+top:24px;
+height:22px;
+width:100%;
+text-align:center;
+}
+
+.password{
+position:absolute;
+left:0px;
+top:64px;
+height:22px;
+width:100%;
+text-align:center;
+}
+
+.fsubmit{
+position:absolute;
+right:25px;
+bottom:27px;
+text-align:center;
+}
+
+.header{
+position:absolute;
+top:0px;
+left:0px;
+width:100%;
+background-color:#66CC00;
+border-bottom:5px solid;
+border-color:#FFFFFF;
+}
+
+.footer{
+position:absolute;
+bottom:0px;
+left:0px;
+width:100%;
+background-color:#66CC00;
+border-top:5px solid;
+border-color:#FFFFFF;
+}
+
+.bottomimage{
+background: #FFFFFF url(img/gp1.gif) no-repeat 95% 95%;
+float:right;
+width:200px;
+height:146px;
+}
+
+a{
+color:#003300;
+}
+
+a:hover{
+color:#FF6600;
+}
+
+input{
+border:1px solid #FFFFFF;
+width:160px;
+height:20px;
+background-color:#FFFFFF;
+color:#003300;
+text-align:center;
+}
+
+input:hover{
+border:1px solid #003300;
+color:#003300;
+}
+
+button{
+border:1px solid #C7F09E;
+background:#C7F09E;
+}
+
+.submit{
+border:1px solid #C7F09E;
+background:#C7F09E;
+}
+
+.submit:hover{
+border:1px solid #003300;
+}
+
+.debug{
+float:none;
+bottom:0px;
+text-align:left;
+color:#E2EBD8;
+}
+{/literal}
+</style>
+<script type="text/javascript" src="js/md5.js"></script>
+<script language="javascript">
+function hasher(){ldelim}
+       var salt = '{$salt}';
+       document.loginform.user.value=hex_md5(hex_md5(document.loginform.user.value)+salt);
+       document.loginform.pass.value=hex_md5(hex_md5(document.loginform.pass.value)+salt);
+{rdelim}
+</script>
+<body align="center" style="min-width:400px;min-height:300px;">
+<div class="wrapper">
+<div class="container">
+
+       <div class="header">&nbsp;</div>
+
+       <div class="login">
+       <form name="loginform" onSubmit="hasher();" method="post">
+               <div class="username">--username--<br/><input name="user" type=password value=""/></div>
+               <div class="password">--password--<br/><input name="pass" type=password value=""/></div>
+               <div class="fsubmit"><button class="submit" type=submit>login</button></a></div>
+       </form>
+       </div>
+
+       <div class="footer">&nbsp;</div>
+
+</div>
+</div>
+{if $debug}{debug}{/if}
+</body>
+</html>
diff --git a/templates/logs.tpl b/templates/logs.tpl
new file mode 100644 (file)
index 0000000..f8fd544
--- /dev/null
@@ -0,0 +1 @@
+{literal}<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Squasher</title><style>body{background-color:#E2EBD8;text-align:center;min-width:1000px;}.wrapper{width: 1000px;margin: 10px auto;}.container{border:5px solid;border-color:#FFFFFF;color:#003300;left:50%;background: #FFFFFF;}.control{float:right;text-align:right;}.menucontainer{background-color:#FFFFFF;}.menu{text-align:center;}.menuhead{float:left;background-color:#66CC00;color:#003300;margin:1px;border:1px solid;border-color:#66CC00;}.menuitem{float:left;background-color:#C7F09E;color:#003300;margin:1px;border:1px solid;border-color:#E2EBD8;}.menuitem_selected{float:left;background-color:#339900;color:#FFFFFF;margin:1px;border:1px solid;border-color:#E2EBD8;}.menuitem:hover{background-color:#339900;color:#FFFFFF;}tr.logentry_download{background-color:#C7F09E;color:#003300;margin:1px;border:1px solid;border-color:#C7F09E;}tr.logentry_download:hover{background-color:#339900;color:#FFFFFF;}tr.logentry_delete{background-color:#C7F09E;color:#003300;margin:1px;border:1px solid;border-color:#C7F09E;}tr.logentry_delete:hover{background-color:#339900;color:#FFFFFF;}tr.logentry_login{background-color:#C7F09E;color:#003300;margin:1px;border:1px solid;border-color:#C7F09E;}tr.logentry_login:hover{background-color:#339900;color:#FFFFFF;}tr.logentry_header{background-color:#339900;color:#FFFFFF;border:1px solid;border-color:#C7F09E;}.content{float:left;padding-right:5px;width:600px;}.item, .status1, .status2, .status3{position:relative;color:#003300;width:400px;height:36px;border:2px solid;border-color:#FFFFFF;font-size:12px;}.item{background-color:#E2EBD8;}.status1{background-color:#FFCCCC;}.status2{background-color:#FFFFCC;}.status3{background-color:#CCFFCC;}.name{position:absolute;left:1px;top:1px;padding-left:1px;}.center{float:left;height:inherit;padding-left:1px;}.chunks{position:absolute;left:1px;bottom:1px;padding-left:1px;}.size{position:absolute;left:100px;bottom:1px;padding-left:1px;}.status{position:absolute;right:2px;top:1px;padding-left:1px;}.stream{position:absolute;float:right;bottom:1px;padding-left:1px;}.download{position:absolute;right:2px;bottom:1px;padding-left:1px;}.clear{clear:both;height:1px;}.spacer{clear:both;height:10px;}.videoframe{float:left;width:500px;height:400px;padding-left:25px;}.banner{background-color:#66CC00;text-align:center;width:100%;height:45px;background:#66CC00 url(img/squash.gif) no-repeat 30px 50%;}.titel{background-color:#66CC00;text-align:center;}.footer{background-color:#66CC00;text-align:center;background:#66CC00 url(img/gplogobottomright.gif) no-repeat 100%;}.bottomimage{background: #FFFFFF url(img/gp1.gif) no-repeat 95% 95%;float:right;width:300px;height:146px;}a{color:#003300;}a:hover{color:#FF6600;}.white_border{float:left;border-top:0px solid #FFFFFF;border-bottom:0px solid #FFFFFF;}.check_all, .check_allow, .check_deny{float:right;height:20px;}.sample_all, .sample_allow, .sample_deny{float:left;height:20px;}.check_all, .sample_all{background-color:#AAEEAA;}.check_allow, .sample_allow{background-color:#EEEEAA;}.check_deny, .sample_deny{background-color:#EEAAAA;}{/literal}{foreach item=style_row from=$style}{$style_row}{/foreach}</style></head><body align="center" style="min-width:1000px;"><div class="wrapper"><div class="container">   <div class="banner">&nbsp;<div class="control">{if $user_level > 99}<a href="?">home</a>&nbsp;|&nbsp;<a href="?tools=access">access</a>&nbsp;|{/if}{if $user_level > 99}&nbsp;<a href="?tools=users">users</a>&nbsp;|&nbsp;<a href="?tools=logs">logs</a>&nbsp;|{/if}&nbsp;<a href="index.php?tools=logout">logout({$user_name})</a>&nbsp;</div></div>  <div class="spacer"></div>      <div class="menucontainer">     <div class="menu">      <div class="menuhead">&nbsp;logs&nbsp;</div>    <div {if $logtype eq "all"     }class="menuitem_selected"{else}class="menuitem"{/if} onClick="location.href='?tools=logs&logtype=all'"      style="cursor:pointer" >&nbsp;all&nbsp;</div>       <div {if $logtype eq "delete"  }class="menuitem_selected"{else}class="menuitem"{/if} onClick="location.href='?tools=logs&logtype=delete'"   style="cursor:pointer" >&nbsp;delete&nbsp;</div>    <div {if $logtype eq "download"}class="menuitem_selected"{else}class="menuitem"{/if} onClick="location.href='?tools=logs&logtype=download'" style="cursor:pointer" >&nbsp;download&nbsp;</div>  <div {if $logtype eq "login"   }class="menuitem_selected"{else}class="menuitem"{/if} onClick="location.href='?tools=logs&logtype=login'"    style="cursor:pointer" >&nbsp;login&nbsp;</div>     <div {if $logtype eq "debug"   }class="menuitem_selected"{else}class="menuitem"{/if} onClick="location.href='?tools=logs&logtype=debug'"    style="cursor:pointer" >&nbsp;squasher&nbsp;</div>  </div>  <div class="clear"></div>       <div class="menu">      </div>  <div class="clear"></div>       </div>  <div class="spacer"></div>      <div class="content">  <table style="border-spacing:0;spacing:0;padding:0;width:990px;background-color:#C7F09E;">   <tr class="logentry_header" align="center">    <td width='*' colspan="5">Today</td>   </tr>{foreach item=entry from=$logs.today key=id}   <tr class="logentry_{$entry.action}" align="left">    <td width='160px'>&nbsp;{$entry.date}</td>    <td width='40px' >&nbsp;{$entry.user_name}</td>    <td width='120px' title="{$entry.users_from_ip}">&nbsp;{$entry.ip}</td>    <td width='80px' >&nbsp;{$entry.action}</td>    <td width='*' title="{$entry.file|substr:10}{if $entry.ip eq 'retry'}\n : This file did not pass validation. A request was mailed to the RO to restart the upload.{/if}{if $entry.ip eq 'cleanup'}\n : This file entry was missing all chunks. This entry was removed.{/if}">&nbsp;{$entry.file|substr:10:64}</td>   </tr>{foreachelse}   <tr style="background-color:#C7F09E;" align="center">    <td width='*' colspan="3"><hr></td>    <td width='120px'>Log is empty</td>    <td width='*'><hr></td>   </tr>{/foreach}   <tr class="logentry_header" align="center">    <td width='*' colspan="5">Yesterday</td>   </tr>{foreach item=entry from=$logs.yesterday key=id}   <tr class="logentry_{$entry.action}" align="left">    <td width='160px'>&nbsp;{$entry.date}</td>    <td width='40px' >&nbsp;{$entry.user_name}</td>    <td width='120px' title="{$entry.users_from_ip}">&nbsp;{$entry.ip}</td>    <td width='80px'>&nbsp;{$entry.action}</td>    <td width='*' title="{$entry.file|substr:10}{if $entry.ip eq 'retry'}\n : This file did not pass validation. A request was mailed to the RO to restart the upload.{/if}{if $entry.ip eq 'cleanup'}\n : This file entry was missing all chunks. This entry was removed.{/if}">&nbsp;{$entry.file|substr:10:64}</td>   </tr>{foreachelse}   <tr style="background-color:#C7F09E;" align="center">    <td width='*' colspan="3"><hr></td>    <td width='120px'>Log is empty</td>    <td width='*'><hr></td>   </tr>{/foreach}   <tr class="logentry_header" align="center">    <td width='*' colspan="5">Last week</td>   </tr>{foreach item=entry from=$logs.lastweek key=id}   <tr class="logentry_{$entry.action}" align="left">    <td width='160px'>&nbsp;{$entry.date}</td>    <td width='40px' >&nbsp;{$entry.user_name}</td>    <td width='120px' title="{$entry.users_from_ip}">&nbsp;{$entry.ip}</td>    <td width='80px'>&nbsp;{$entry.action}</td>    <td width='*' title="{$entry.file|substr:10}{if $entry.ip eq 'retry'}\n : This file did not pass validation. A request was mailed to the RO to restart the upload.{/if}{if $entry.ip eq 'cleanup'}\n : This file entry was missing all chunks. This entry was removed.{/if}">&nbsp;{$entry.file|substr:10:64}</td>   </tr>{foreachelse}   <tr style="background-color:#C7F09E;" align="center">    <td width='*' colspan="3"><hr></td>    <td width='120px'>Log is empty</td>    <td width='*'><hr></td>   </tr>{/foreach}   <tr class="logentry_header" align="center">    <td width='*' colspan="5">Older</td>   </tr>{foreach item=entry from=$logs.older key=id}   <tr class="logentry_{$entry.action}" align="left">    <td width='160px'>&nbsp;{$entry.date}</td>    <td width='40px' >&nbsp;{$entry.user_name}</td>    <td width='120px' title="{$entry.users_from_ip}">&nbsp;{$entry.ip}</td>    <td width='80px'>&nbsp;{$entry.action}</td>    <td width='*' title="{$entry.file|substr:10}{if $entry.ip eq 'retry'}\n : This file did not pass validation. A request was mailed to the RO to restart the upload.{/if}{if $entry.ip eq 'cleanup'}\n : This file entry was missing all chunks. This entry was removed.{/if}">&nbsp;{$entry.file|substr:10:64}</td>   </tr>{foreachelse}   <tr style="background-color:#C7F09E;" align="center">    <td width='*' colspan="3"><hr></td>    <td width='120px'>Log is empty</td>    <td width='*'><hr></td>   </tr>{/foreach}       </table>        </div>  <div class="spacer"></div>      <div class="bottomimage"></div> <div class="clear"></div>       <div class="spacer"></div>      <div class="footer">&nbsp;</div></div></div>{if $debug}{debug}{/if}</body></html>
\ No newline at end of file
diff --git a/templates/udmin.tpl b/templates/udmin.tpl
new file mode 100644 (file)
index 0000000..a89b9b8
--- /dev/null
@@ -0,0 +1,285 @@
+{literal}<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<title>Squasher</title>
+<style>
+
+body{
+background-color:#E2EBD8;
+text-align:center;
+min-width:1000px;
+}
+
+.wrapper{
+width: 1000px;
+margin: 10px auto;
+}
+
+.container{
+border:5px solid;
+border-color:#FFFFFF;
+color:#003300;
+left:50%;
+background: #FFFFFF;
+}
+
+.control{
+float:right;
+text-align:right;
+}
+
+.menucontainer{
+background-color:#FFFFFF;
+}
+
+.menu{
+text-align:center;
+}
+
+.menuhead{
+float:left;
+background-color:#66CC00;
+color:#003300;
+margin:1px;
+border:1px solid;
+border-color:#66CC00;
+}
+
+.menuitem{
+float:left;
+background-color:#C7F09E;
+color:#003300;
+margin:1px;
+border:1px solid;
+border-color:#E2EBD8;
+}
+
+.menuitem:hover{
+background-color:#339900;
+color:#FFFFFF;
+}
+
+.content{
+float:left;
+padding-right:5px;
+width:600px;
+}
+
+.item, .status1, .status2, .status3{
+position:relative;
+color:#003300;
+width:400px;
+height:36px;
+border:2px solid;
+border-color:#FFFFFF;
+font-size:12px;
+}
+
+.item{
+background-color:#E2EBD8;
+}
+.status1{
+background-color:#FFCCCC;
+}
+.status2{
+background-color:#FFFFCC;
+}
+.status3{
+background-color:#CCFFCC;
+}
+
+.name{
+position:absolute;
+left:1px;
+top:1px;
+padding-left:1px;
+}
+
+.center{
+float:left;
+height:inherit;
+padding-left:1px;
+}
+
+.chunks{
+position:absolute;
+left:1px;
+bottom:1px;
+padding-left:1px;
+}
+
+.size{
+position:absolute;
+left:100px;
+bottom:1px;
+padding-left:1px;
+}
+
+.status{
+position:absolute;
+right:2px;
+top:1px;
+padding-left:1px;
+}
+
+.stream{
+position:absolute;
+float:right;
+bottom:1px;
+padding-left:1px;
+}
+
+.download{
+position:absolute;
+right:2px;
+bottom:1px;
+padding-left:1px;
+}
+
+.clear{
+clear:both;
+height:1px;
+}
+
+.spacer{
+clear:both;
+height:10px;
+}
+
+.videoframe{
+float:left;
+width:500px;
+height:400px;
+padding-left:25px;
+}
+
+.banner{
+background-color:#66CC00;
+text-align:center;
+width:100%;
+height:45px;
+background:#66CC00 url(img/squash.gif) no-repeat 30px 50%;
+}
+
+.titel{
+background-color:#66CC00;
+text-align:center;
+}
+
+.footer{
+background-color:#66CC00;
+text-align:center;
+background:#66CC00 url(img/gplogobottomright.gif) no-repeat 100%;
+}
+
+.bottomimage{
+background: #FFFFFF url(img/gp1.gif) no-repeat 95% 95%;
+float:right;
+width:300px;
+height:146px;
+}
+
+a{
+color:#003300;
+}
+
+a:hover{
+color:#FF6600;
+}
+
+.white_border{
+float:left;
+border-top:0px solid #FFFFFF;
+border-bottom:0px solid #FFFFFF;
+}
+
+.check_all, .check_allow, .check_deny{
+float:right;
+height:20px;
+}
+.sample_all, .sample_allow, .sample_deny{
+float:left;
+height:20px;
+}
+.check_all, .sample_all{
+background-color:#AAEEAA;
+}
+.check_allow, .sample_allow{
+background-color:#EEEEAA;
+}
+.check_deny, .sample_deny{
+background-color:#EEAAAA;
+}
+{/literal}
+
+{foreach item=style_row from=$style}{$style_row}
+{/foreach}
+
+</style>
+<script>
+function confirm_delete(formID) {ldelim}
+       if (confirm("Are you sure you want to delete this user?")) {ldelim}
+       document.getElementById(formID).submit();
+       {rdelim}
+{rdelim}
+</script>
+</head>
+<body align="center" style="min-width:1000px;">
+<div class="wrapper">
+<div class="container">
+
+       <div class="banner">&nbsp;<div class="control">{if $user_level > 99}<a href="?">home</a>&nbsp;|&nbsp;<a href="?tools=access">access</a>&nbsp;|{/if}{if $user_level > 99}&nbsp;<a href="?tools=users">users</a>&nbsp;|&nbsp;<a href="?tools=logs">logs</a>&nbsp;|{/if}&nbsp;<a href="index.php?tools=logout">logout({$user_name})</a>&nbsp;</div></div>
+
+       <div class="spacer"></div>
+
+       <div class="menucontainer">
+
+       <div class="menu">
+
+       {*<div class="menuhead">users</div>
+
+       {foreach item=user key=user_id from=$users}<div class="menuitem" onClick="location.href='?tools=access&user={$user.id}'" style="cursor:pointer" >{$user.name}</div>{/foreach}
+
+       </div>*}
+
+       <div class="clear"></div>
+
+       <div class="menu">
+{*     
+       <div class="menuhead">subfolders</div>
+       
+       {foreach item=folder key=folderpath from=$subfolders}<div class="menuitem" onClick="location.href='?path={$folderpath}'" style="cursor:pointer" >{$folder}</div>{/foreach}
+*}     
+       </div>
+       
+       <div class="clear"></div>
+       
+       </div>
+       
+       <div class="spacer"></div>
+
+       <div class="content">
+
+{foreach item=user key=user_id from=$users}
+<div class="white_border"><form method='post' name='user_{$user.id}' id='user_{$user.id}'><input type='hidden' name='u[user_id]' id='user_id' value='{$user.id}' /><input type='hidden' name='type' id='type' value='' /><input name='u[user_name]' id='user_name' value='{$user.name}' readonly /> | {html_options name='u[user_level]' id='user_level' options=$user_levels selected=$user.level} | {if $user.enabled}<a onClick="document.user_{$user.id}.type.value='disable';document.user_{$user.id}.submit();" style="cursor:pointer" >remove password</a>{else}<input name='u[user_pass]' id='user_pass' /> {/if} | <a onClick="document.user_{$user.id}.type.value='delete';confirm_delete('user_{$user.id}');" style="cursor:pointer" >delete</a> | <a onClick="document.user_{$user.id}.type.value='update';document.user_{$user.id}.submit();" style="cursor:pointer" >update</a></form></div>
+<div class="clear"></div>
+{/foreach}
+<div class="white_border"><form method='post' name='user_new' id='user_new'><input type='hidden' name='type' id='type' value='' /><input name='u[user_name]' value='' /> | {html_options name='u[user_level]' options=$user_levels } | <input name='u[user_pass]' /> | <a onClick="document.user_new.type.value='new';document.user_new.submit();" style="cursor:pointer" >add</a></form></div>
+<div class="clear"></div>
+
+       </div>
+
+       <div class="bottomimage"></div>
+       
+       <div class="clear"></div>
+
+       <div class="spacer"></div>
+
+       <div class="footer">&nbsp;</div>
+
+</div>
+</div>
+{if $debug}{debug}{/if}
+</body>
+</html>
\ No newline at end of file
diff --git a/templates/wip_massdelete.tpl b/templates/wip_massdelete.tpl
new file mode 100644 (file)
index 0000000..0132fbd
--- /dev/null
@@ -0,0 +1,381 @@
+{literal}<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<title>Squasher</title>
+<style>
+
+body{
+background-color:#E2EBD8;
+min-width:1000px;
+font-family:Arial Narrow;
+font-size:16px;
+}
+
+.wrapper{
+width: 1000px;
+margin: 10px auto;
+}
+
+.container{
+border:5px solid;
+border-color:#FFFFFF;
+color:#FFFFFF;
+left:50%;
+background: #FFFFFF;
+}
+
+.control{
+float:right;
+text-align:right;
+}
+
+.menucontainer{
+background-color:#FFFFFF;
+}
+
+.menu{
+text-align:center;
+}
+
+.menuhead{
+float:left;
+background-color:#66CC00;
+color:#003300;
+margin:1px;
+border:1px solid;
+border-color:#66CC00;
+}
+
+.menuitem{
+float:left;
+background-color:#C7F09E;
+color:#003300;
+margin:1px;
+border:1px solid;
+border-color:#E2EBD8;
+}
+
+.menuitem:hover{
+background-color:#339900;
+color:#FFFFFF;
+}
+
+.content{
+float:left;
+padding-right:5px;
+}
+
+.item, .status1, .status2, .status3{
+position:relative;
+color:#003300;
+width:600px;
+border:2px solid;
+border-color:#FFFFFF;
+font-size:12px;
+}
+
+.item{
+background-color:#E2EBD8;
+}
+.status1{
+background-color:#FFCCCC;
+}
+.status2{
+background-color:#FFFFCC;
+}
+.status3{
+background-color:#CCFFCC;
+}
+
+.name{
+float:left;
+left:1px;
+top:1px;
+padding-left:1px;
+z-index:50;
+}
+
+.center{
+float:left;
+height:inherit;
+padding-left:1px;
+}
+
+.chunks{
+float:right;
+padding-left:2px;
+padding-right:3px;
+}
+
+.size{
+float:right;
+padding-left:2px;
+padding-right:3px;
+}
+
+.added{
+float:left;
+padding-left:2px;
+padding-right:3px;
+}
+
+.updated{
+float:left;
+padding-left:2px;
+padding-right:3px;
+}
+
+.status{
+float:right;
+top:1px;
+padding-right:2px;
+text-align:right;
+z-index:10;
+}
+
+.stream{
+float:right;
+padding-left:1px;
+padding-right:2px;
+}
+
+.download{
+float:right;
+padding-left:1px;
+padding-right:2px;
+}
+
+.clear{
+clear:both;
+height:1px;
+font-size: 0;
+}
+
+.spacer{
+clear:both;
+height:10px;
+}
+
+.videoframe{
+float:left;
+width:500px;
+height:400px;
+padding-left:25px;
+}
+
+.banner{
+background-color:#66CC00;
+text-align:center;
+width:100%;
+height:45px;
+background:#66CC00 url(img/squash.gif) no-repeat 30px 50%;
+}
+
+.titel{
+background-color:#66CC00;
+text-align:center;
+}
+
+.footer{
+background-color:#66CC00;
+text-align:center;
+background:#66CC00 url(img/gplogobottomright.gif) no-repeat 100%;
+}
+
+.bottomimage{
+background: #FFFFFF url(img/gp1.gif) no-repeat 95% 95%;
+float:right;
+width:300px;
+height:146px;
+}
+
+.massdelete{
+position:absolute;
+bottom:0;
+float:right;
+width:300px;
+#height:146px;
+}
+
+.deletebox{
+visibility: hidden;
+}
+
+.filler{
+position:relative;
+float:right;
+width:300px;
+height:500px;
+}
+
+a{
+color:#003300;
+}
+
+a:hover{
+color:#FF6600;
+}
+
+</style>
+  <script type="text/javascript" language="JavaScript">
+   function toggle_id(hideshow){
+    if(document.getElementById(hideshow).style.visibility == 'visible') {
+     document.getElementById(hideshow).style.visibility = 'hidden';
+    }else{
+     document.getElementById(hideshow).style.visibility = 'visible';
+    }
+   }
+  </script></head>
+{/literal}
+<body style="min-width:1000px;">
+<div class="wrapper">
+<div class="container">
+
+       <div class="banner">&nbsp;<div class="control">{if $user_level > 99}<a href="?">home</a>&nbsp;|&nbsp;<a href="?tools=access">access</a>&nbsp;|{/if}{if $user_level > 99}&nbsp;<a href="?tools=users">users</a>&nbsp;|{/if}&nbsp;<a href="index.php?tools=logout">logout({$user_name})</a>&nbsp;</div></div>
+
+       <div class="spacer"></div>
+
+       <div class="menucontainer">
+
+       <div class="menu">
+       
+       <div class="menuhead">current folder</div>
+       
+       {foreach item=crumb key=cookie from=$base}<div class="menuitem" onClick="location.href='?path={$cookie}'" style="cursor:pointer" >{$crumb}</div>{/foreach}
+       
+       </div>
+       
+       <div class="clear"></div>
+       
+       <div class="menu">
+       
+       <div class="menuhead">subfolders</div>
+       
+       {foreach item=folder key=folderpath from=$subfolders}<div class="menuitem" onClick="location.href='?path={$folderpath}'" style="cursor:pointer" >{$folder}</div>{/foreach}
+       
+       </div>
+       
+       <div class="clear"></div>
+{*     
+       <div class="menu">
+       
+       {foreach item=dir key=path from=$paths}{if $path!=$currentfolder}<div class="menuitem" onClick="location.href='squasher.php?path={$path}'" style="cursor:pointer" >{$dir}</div>{/if}{/foreach}
+       
+       </div>
+       
+       
+       
+       <div class="clear"></div>*}
+       
+       </div>
+       
+       <div class="spacer"></div>
+
+<div class="content">
+{foreach item=item key=id from=$squashed}
+{counter assign=mass_delete_size print=false}
+{if $item.squashed}{*These items are in chunks / uploaded by the squasher tool*}
+
+{if $item.hidden eq false OR $user_level > 99 }
+               <div class={if $item.finished==true}"status3"{elseif $item.finished!=true && $item.embedable==true}"status2"{elseif $item.finished!=true && $item.embedable!=true}"status1"{else}"item"{/if}>
+
+                               <div class="name">{$item.name} {if $user_level > 99}{if $item.hidden}<font color=red>|<a href='?tools=unhide&h={$id}'>publish</a>|</font>{else}<font color=green>|<a href='?tools=hide&h={$id}'>hide</a>|</font>{/if}{if $user_level > 100}<font color=red>|<a href='?tools=delete&h={$id}' onClick="javascript:return confirm('Are you sure you want to permanently delete {$item.name}?')">delete</a>|</font>{/if}{/if}</div>
+
+                               <div class="status">status: {$item.status}</div>
+
+               <div class="clear"></div>
+
+               <div class="added">added: {$item.date}</div>
+               
+                               <!--div class="chunks"></div-->
+                               <div class="size">size:&nbsp;{if $item.size>(1024*1024)}{math equation="((x / 1024) / 1024) * (y / z)" x=$item.size y=$item.chunks_finished z=$item.chunks format="%.2f"}&nbsp;/&nbsp;{math equation="(x / 1024) / 1024" x=$item.size format="%.2f"}mb{elseif $item.size>(1024)}{math equation="(x / 1024) * (y / z)" x=$item.size y=$item.chunks_finished z=$item.chunks format="%.2f"}&nbsp;/&nbsp;{math equation="(x / 1024)" x=$item.size format="%.2f"}kb{else}{math equation="x * (y / z)" x=$item.size y=$item.chunks_finished z=$item.chunks format="%.0f"}&nbsp;/&nbsp;{$item.size}b{/if}({math equation="(y / x) * 100" x=$item.chunks y=$item.chunks_finished format="%.0f"}%)</div>
+
+               <div class="clear"></div>
+
+               <div class="updated">last updated: {$item.lastchange}</div>
+
+
+{if $item.finished==true}
+                               <div class="download"><a href='?f={$id}'>download</a></div>
+{/if}
+{if $item.embedable eq true and $item.finished eq false}
+       {if $item.mime=='video/mpeg'}
+                               <div class="stream"><a href='?f={$id}'>download ({math equation="(y / x) * 100" x=$item.chunks y=$item.chunks_partial format="%.0f"}%)</a></div>
+       {/if}
+{/if}
+
+               <div class="clear"></div>
+               </div>
+       
+               <div class="clear"></div>
+{/if}
+
+{else}{*These items are plain files / uploaded manually by the user via ftp*}
+
+{if $item.hidden eq false OR $user_level > 99 }
+               <div class={if $item.finished==true}"status3"{elseif $item.finished!=true && $item.embedable==true}"status2"{elseif $item.finished!=true && $item.embedable!=true}"status1"{else}"item"{/if}>
+
+                               <div class="name">{$item.name} {if $user_level > 99}{if $item.hidden}<font color=red>|<a href='?tools=unhide&h={$id}'>publish</a>|</font>{else}<font color=green>|<a href='?tools=hide&h={$id}'>hide</a>|</font>{/if}{if $user_level > 199}<font color=red>|<a href='?tools=delete&h={$id}' onClick="javascript:return confirm('Are you sure you want to permanently delete {$item.name}?')">delete</a>|</font>{/if}{/if}</div>
+
+                               <div class="status">status: {$item.status}</div>
+
+               <div class="clear"></div>
+
+               <div class="added">added: {$item.date}</div>
+
+                               <div class="size">size:&nbsp;{if $item.size>(1024*1024)}{math equation="(x / 1024) / 1024" x=$item.size format="%.2f"}mb{elseif $item.size>(1024)}{math equation="(x / 1024)" x=$item.size format="%.2f"}kb{else}{$item.size}b{/if}</div>
+
+               <div class="clear"></div>
+
+               <div class="updated">last updated: {$item.lastchange}</div>
+
+
+{if $item.finished==true}
+                               <div class="download"><a href='?f={$id}'>download</a></div>
+{/if}
+{if $item.embedable eq true and $item.finished eq false}
+       {if $item.mime=='video/mpeg'}
+                               <div class="stream"><a href='?f={$id}'>download (partial)</a></div>
+       {/if}
+{/if}
+
+
+               <div class="clear"></div>
+               </div>
+       
+               <div class="clear"></div>
+{/if}
+{/if}
+{/foreach}
+
+       </div>
+
+       <div class="filler">
+       <div class="bottomimage"></div>
+{if $user_level > 100 and $mass_delete_size > 0}
+               <div class="massdelete"><input type="button" value="Delete multiple items:" OnClick="toggle_id('deletebox');" ><br>
+<div class="deletebox" id="deletebox">
+       <form action="?tools=delete&h=multiple" method="post">
+               <select multiple="" size="{$mass_delete_size}" id="h" name="h[]">
+{foreach item=item key=id from=$squashed}
+                       <option value="{$id}">{$item.name}</option>
+{/foreach}
+               </select>
+               <input type="submit" value="Delete Selected Items">
+       </form>
+</div>
+       </div>
+{/if}
+       </div>
+       <div class="clear"></div>
+
+       <div class="spacer"></div>
+
+       <div class="footer">&nbsp;</div>
+
+</div>
+</div>
+{if $debug}{debug}{/if}
+</body>
+</html>