function action_look_file($id_file) { $data = Sql::selectOne('files, extensions', 'files.id = ? and files.id_ext = extensions.id', $id_file, 'files.name, files.uid, files.size, files.id_ext, extensions.name as name_ext, content, extensions.status'); if (!$data) { return; } if ($data['status'] == 1) { header('Content-Type: ' . getmime($data['name_ext'])); header('Content-Length: ' . $data['size']); header('Pragma: public'); header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); header('Expires: 0'); header('Connection:Close'); echo $data['content']; } else { if ($data['name_ext'] == 'png' or $data['name_ext'] == 'jpg' or $data['name_ext'] == 'jpeg' or $data['name_ext'] == 'gif') { header('Content-Type: image/jpeg'); if (file_exists('../upload/min/' . $data['uid'])) { readfile('../upload/min/' . $data['uid']); } } else { if ($data['name_ext'] == "mp3") { header('Content-Type: ' . getmime($data['name_ext'])); header('Content-Length: ' . $data['size']); header('Cache-Control: public, must-revalidate, max-age=0'); header('Content-Transfer-Encoding: binary'); header('Pragma: no-cache'); header('Content-Disposition: inline; filename=' . $data['name'] . ''); header('Accept-Ranges: bytes'); header('Content-Range: bytes 0-' . ($data['size'] - 1) . '/' . $data['size']); if (file_exists('../upload/' . $data['uid'])) { readfile('../upload/' . $data['uid']); } } else { if ($data['name_ext'] == "pdf") { header('Content-Type: ' . getmime($data['name_ext'])); header('Content-Length: ' . $data['size']); header('Content-Disposition: inline; filename=' . $data['name'] . ''); if (file_exists('../upload/' . $data['uid'])) { readfile('../upload/' . $data['uid']); } } } } } exit; }
function listdir($directory) { global $dirlink, $basedir; $handle = opendir($basedir . $directory); while ($file = readdir($handle)) { $filelist[] = $file; } $count = 1; natcasesort($filelist); while (list($key, $file) = each($filelist)) { if ($GLOBALS['CONFIG']['PROCESS_INDEX'] && in_array($file, $GLOBALS['CONFIG']['INDEX_FILES'])) { header('Location: ' . substr($directory, 1) . '/' . $file); } if (($GLOBALS['CONFIG']['DISPLAY_HIDDEN'] || !$GLOBALS['CONFIG']['DISPLAY_HIDDEN'] && $file[0] != ".") && $file != '.' && $file != '..' && (!is_array($GLOBALS['CONFIG']['HIDE_FILES']) || is_array($GLOBALS['CONFIG']['HIDE_FILES']) && !in_array($basedir . $directory . '/' . $file, $GLOBALS['CONFIG']['HIDE_FILES']))) { $stats = stat($basedir . $directory . '/' . $file); if ($basedir . $directory . '/' == './') { $dirlink = ''; } else { $dirlink = $basedir . $directory . '/'; } if (is_dir($basedir . $directory . '/' . $file)) { $dirc[] = '<td width="100%"><table cellpadding="0" cellspacing="0" width="100%"><tr><td width="18">' . '<img src="' . $_SERVER['SCRIPT_NAME'] . '?p=mime&type=' . getmime($directory . '/' . $file) . '" border="0" alt=""><td align="left"><a href="' . $_SERVER['SCRIPT_NAME'] . '?dir=' . $dirlink . $file . '">' . $file . '</a></table>' . '<td nowrap>' . date('F jS Y', $stats['9']) . '<td nowrap> - '; } elseif (iswebtype($file)) { $filec[] = '<td width="100%"><table cellpadding="0" cellspacing="0" width="100%"><tr><td width="18"><a href="' . $dirlink . url_encode($file) . '"><img src="' . $_SERVER['SCRIPT_NAME'] . '?p=mime&type=' . getmime($directory . '/' . $file) . '" border="0" alt=""></a></td>' . '<td align="left"><a href="' . $_SERVER['SCRIPT_NAME'] . '?p=source&file=' . url_encode($dirlink . $file) . '">' . $file . '</a></table>' . '<td nowrap>' . date('F jS Y', $stats['9']) . '<td nowrap>' . getsize($stats['7']); } elseif (isimgtype($file)) { $filec[] = '<td width="100%"><table cellpadding="0" cellspacing="0" width="100%"><tr><td width="18"><a href="' . $dirlink . url_encode($file) . '"><img src="' . $_SERVER['SCRIPT_NAME'] . '?p=thumb&file=' . base64_encode($directory . '/' . $file) . '" border="0" alt=""></a></td>' . '<td align="left"><a href="' . $dirlink . url_encode($file) . '">' . $file . '</a></table>' . '<td nowrap>' . date('F jS Y', $stats['9']) . '<td nowrap>' . getsize($stats['7']); } else { $filec[] = '<td width="100%"><table cellpadding="0" cellspacing="0" width="100%"><tr><td width="18"><a href="' . $dirlink . url_encode($file) . '"><img src="' . $_SERVER['SCRIPT_NAME'] . '?p=mime&type=' . getmime($directory . '/' . $file) . '" border="0" alt=""></a></td>' . '<td align="left"><a href="' . $dirlink . url_encode($file) . '">' . $file . '</a></table>' . '<td nowrap>' . date('F jS Y', $stats['9']) . '<td nowrap>' . getsize($stats['7']); } } } pagehead($directory); $dirdis = '.' . $directory . '/'; echo '<tr><td colspan="3" nowrap><b>Current Directory: '; while ($basepos = strpos($dirdis, '/')) { if ($dirlist[$t - 1] == '') { $dirlist[$t] = substr($dirdis, 0, $basepos); } else { $dirlist[$t] = $dirlist[$t - 1] . '/' . substr($dirdis, 0, $basepos); } echo '/<a href="' . $_SERVER['SCRIPT_NAME'] . '?dir=' . $dirlist[$t] . '">' . substr($dirdis, 0, $basepos) . '</a>'; $dirdis = substr($dirdis, $basepos + 1, strlen($dirdis)); $t++; } echo '</b><tr class="head"><td width="100%" bgcolor="' . $GLOBALS['CONFIG']['TB_COLOR_4'] . '">Name<td nowrap bgcolor="' . $GLOBALS['CONFIG']['TB_COLOR_4'] . '">Last Modified<td nowrap bgcolor="' . $GLOBALS['CONFIG']['TB_COLOR_4'] . '">Size'; if ($dirc) { asort($dirc); foreach ($dirc as $dir) { $tcoloring = $a % 2 ? $GLOBALS['CONFIG']['TB_COLOR_2'] : $GLOBALS['CONFIG']['TB_COLOR_3']; echo '<tr bgcolor="' . $tcoloring . '">' . $dir; $a++; } } if ($filec) { asort($filec); foreach ($filec as $file) { $tcoloring = $a % 2 ? $GLOBALS['CONFIG']['TB_COLOR_2'] : $GLOBALS['CONFIG']['TB_COLOR_3']; echo '<tr bgcolor="' . $tcoloring . '">' . $file; $a++; } } $dir = $directory; if (!$dir) { $dir = './'; } else { $dir = '.' . $directory; } $count = countdir($dir); echo '<tr bgcolor="' . $GLOBALS['CONFIG']['TB_COLOR_4'] . '"><td><b>' . number_format($count[1]) . '</b> lines of code in <b>' . number_format($count[2]) . '</b> files within <b>' . number_format($count[3]) . '</b> directories.' . '<td> <td nowrap><b>' . getsize($count[0]) . '</b>'; pagefoot(); }