2 if (!$_SESSION['creds']['validated'] && !isset($_GET['f']))
5 require_once("squasher.class.php");
7 $squashweb = new squashweb();
9 $squashweb->update_history();
12 $basedir = "../uploads";
13 if (isset($_GET['path']) && $_GET['path']!=NULL && strlen($_GET['path'])!=1) {
14 $subf = $_GET['path'];
15 $path = $basedir . $subf;
20 $squashweb->set_root($basedir);
22 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') {
30 //update folder rights if form is submitted
31 if ($submitted['edited_user'] > 0 && $submitted['formtype'] == 'folderrights')
32 $squashweb->update_rights($submitted,$_SESSION['creds']['user_level']);
35 if (isset($_GET['f']) && $_GET['f']!=NULL) {
36 $squashweb->give_rights(2);
38 $squashweb->give_rights($_SESSION['creds']['user_id']);
41 if (isset($_GET['f']) && $_GET['f']!=NULL) {
42 $f_q = "SELECT * FROM file_hash WHERE md5_hash = '".$_GET['f']."'";
43 $f_r = mysql_query($f_q);
44 $f_o = mysql_fetch_object($f_r);
47 @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())");
49 $_hpath_arr=explode("/", $f_o->file);
50 $file=array_pop($_hpath_arr); //Remove filename
51 $path=implode("/", $_hpath_arr);
52 $squashweb->read_single_file($path, $file);
53 #$squashweb->read_directory($path, false, true, false, false);
55 //parse folders for readable files
56 $squashweb->read_directory($path, true, true, $getdeepfiles, $populate);
59 //check if a file is requested
60 if (isset($_GET['f']) && $_GET['f']!=NULL) {
61 //get the config of requested file
62 $request = $squashweb->get_config($_GET['f']);
64 //------------------------------------
65 //-check-file-and-request-type--start-
66 //------------------------------------
67 if (strpos($request['mime'],'ideo') && isset($_GET['d'])) { //embed video
68 $squashweb->embed_video($_GET['f']);
70 elseif (strpos($request['mime'],'ideo') && isset($_GET['x'])) { //show stream playlist
71 $squashweb->create_playlist($_GET['f'],$_GET['x'],$request[2]);
73 else { //show requested file
74 # header('Cache-control: private');
75 header('Content-Disposition: attachment; filename="'.$request[2].'"');
76 header("Content-Type: ".$request['mime']);
77 if ($request[3])header('Content-Length: '.$request[3]);
80 $squashweb->print_files($request['path'], $request[2]);
82 //---------------------------------
83 //-check-file-and-request-type-end-
84 //---------------------------------
86 } elseif ($tools=="hide" && isset($_GET['h'])) {
87 if ($_SESSION['creds']['user_level'] > 99) {
88 $request = $squashweb->get_config($_GET['h']);
89 $handle = fopen($request['path'].'/'.$request[2].'.hidden', 'x');
90 fwrite($handle, 'hidden by '.$_SESSION['creds']['user_name']);
92 $path=substr($request['path'], strlen($basedir));
93 header( 'Location: '.$_SERVER['PHP_SELF'].'?path='.$path) ;
95 } elseif ($tools=="unhide" && isset($_GET['h'])) {
96 if ($_SESSION['creds']['user_level'] > 99) {
97 $request = $squashweb->get_config($_GET['h']);
98 @unlink($request['path'].'/'.$request[2].'.hidden');
99 $path=substr($request['path'], strlen($basedir));
100 header( 'Location: '.$_SERVER['PHP_SELF'].'?path='.$path) ;
102 } elseif ($tools=="delete" && isset($_GET['h'])) {
103 if ($_SESSION['creds']['user_level'] > 99) {
104 if ($_GET['h'] == "multiple") {
105 $h_post = $_POST['h'];
106 foreach ($h_post as $h_key => $h) {
107 $request = $squashweb->get_config($h);
108 $squashweb->delete_file($h, $_SESSION['creds']);
112 $request = $squashweb->get_config($h);
113 $squashweb->delete_file($h, $_SESSION['creds']);
115 $path=substr($request['path'], strlen($basedir));
116 header( 'Location: '.$_SERVER['PHP_SELF'].'?path='.$path);
118 } elseif (@$_GET['tools']=='access' && $_SESSION['creds']['user_level'] > 100) {
120 require_once("smarty/Smarty.class.php");
122 $smarty = new Smarty;
124 $smarty->assign('user_level', $_SESSION['creds']['user_level']);
125 $smarty->assign('user_name', $_SESSION['creds']['user_name']);
126 $smarty->assign('users', $squashweb->get_users($_SESSION['creds']['user_level']));
128 $smarty->assign('edited_user', $_GET['user']);
130 $tree = $squashweb->show_rights_tree($path, 0, $_GET['user']);
132 $smarty->assign('style', $tree['style']);
133 $smarty->assign('layout', $tree['layout']);
135 $smarty->assign('debug', $vars['debug']);
136 $smarty->assign('folderrights', $squashweb->folderrights());
137 $smarty->assign('userrights', $squashweb->userrights());
138 $smarty->display('admin.tpl');
140 } elseif (@$_GET['tools']=='users' && $_SESSION['creds']['user_level'] > 100) {
142 if ($submitted['type']=="update")
143 $squashweb->update_users($submitted);
144 if ($submitted['type']=="disable")
145 $squashweb->disable_users($submitted);
146 if ($submitted['type']=="delete")
147 $squashweb->remove_users($submitted);
148 if ($submitted['type']=="new")
149 $squashweb->insert_users($submitted, $_SESSION['creds']['user_level']);
150 require_once("smarty/Smarty.class.php");
152 $smarty = new Smarty;
154 $smarty->assign('user_level', $_SESSION['creds']['user_level']);
155 $smarty->assign('user_name', $_SESSION['creds']['user_name']);
156 $smarty->assign('users', $squashweb->get_users($_SESSION['creds']['user_level']));
158 if ($_SESSION['creds']['user_level'] > 199) {
159 $smarty->assign('user_levels', array(155 => 'admin' , 55 => 'user' ) );
161 $smarty->assign('user_levels', array(55 => 'user' ) );
163 $smarty->assign('debug',$vars['debug']);
165 $smarty->display('udmin.tpl');
167 } elseif ($_GET['tools']=='logs' && $_SESSION['creds']['user_level'] > 100) {
168 $logtype=($_GET['logtype']) ? $_GET['logtype'] : 'all';
169 require_once("smarty/Smarty.class.php");
171 $smarty = new Smarty;
173 $smarty->assign('user_level', $_SESSION['creds']['user_level']);
174 $smarty->assign('user_name', $_SESSION['creds']['user_name']);
175 $smarty->assign('logtype', $logtype);
176 $smarty->assign('logs', $squashweb->get_logs($logtype));
178 $smarty->display('logs.tpl');
183 require_once("smarty/Smarty.class.php");
185 $smarty = new Smarty;
195 * [6] -> CRC32 checksum
198 $configs_num = $squashweb->get_configs();
200 $configs_sorted = named_records_sort($configs_num, 'lastchange', true);
202 foreach ($configs_sorted as $key => $value) {
203 $configs[$key]['squashed'] = $value['squashed'];
204 $configs[$key]['version'] = $value[0];
205 //$configs[$key]['date'] = $value[1]; //removed because user local creation date is irrelevant
206 $configs[$key]['name'] = $value[2];
207 $configs[$key]['size'] = $value[3];
208 $configs[$key]['chunk_size'] = $value[4];
209 $configs[$key]['chunks'] = $value[5];
210 $configs[$key]['crc'] = $value[6];
211 $paths[substr($value['path'], strlen($basedir))]=array_pop(explode('/',$value['path']));
212 (strpos($value['mime'],'ideo')) ? $embedable=true : $embedable=false;
213 (@array_sum($value['stats']) == $value[5]) ? $finished=true : $finished=false;
215 $configs[$key]['embedable'] = $embedable;
216 $configs[$key]['finished'] = $finished;
217 $configs[$key]['mime'] = $value['mime'];
218 $configs[$key]['status'] = $value['status'];
219 $configs[$key]['hidden'] = $value['hidden'];
220 $configs[$key]['chunks_finished'] = @array_sum($value['stats']);
222 $configs[$key]['chunks_partial'] = $configs[$key]['chunks_finished'];
225 foreach($value['stats'] as $sk => $sv) {
227 $configs[$key]['chunks_partial'] = $configs[$key]['chunks_partial']+$sv;
228 if ($sv != '1.00') $continue=false;
232 $configs[$key]['date'] = date('d.m.y - H:i:s - T', $value['added']);
233 $configs[$key]['lastchange'] = date('d.m.y - H:i:s - T', $value['lastchange']);
238 $basepath['/'] = ' top ';
239 foreach (explode('/',$subf) as $key => $value) {
241 $bpath .= '/'.$value;
242 $basepath[$bpath] = $value;
245 $smarty->assign('debug', $vars['debug']);
246 $smarty->assign('user_level', $_SESSION['creds']['user_level']);
247 $smarty->assign('user_name', $_SESSION['creds']['user_name']);
248 $smarty->assign('folderrights', $squashweb->folderrights());
250 $smarty->assign('squashed', $configs);
251 $smarty->assign('paths', $paths);
252 $smarty->assign('base', $basepath);
253 $smarty->assign('currentfolder', $subf);
254 $subs = $squashweb->subfolders();
256 $smarty->assign('subfolders', $subs);
258 //if($vars[debug])print_r($configs);
259 if (!$vars['newtpl'])
260 $smarty->display('index.tpl'); //Display normal template
262 $smarty->display('wip_massdelete.tpl'); //Display Work In Progress template
265 // vim: syntax=php ts=4 sw=4 sts=4 sr noet