function fm_fileinfo($d) { $path = $GLOBALS['prepath'] . $d; $file = filefrompath($path); if (!fm_exists($d)) { return FALSE; } $size = filesize($path); $modified = filemtime($path); $ext = fext($file); return array('name' => $file, 'bname' => endsWith($file, '/') ? substr($file, 0, -1) : $file, 'id' => file2id($file), 'isdir' => filetype($path) == 'dir', 'size' => $size, 'tsize' => textfilesize($size), 'modified' => $modified, 'tmodified' => date("M j, Y g:i:s A", $modified), 'tdmodified' => date("M j, Y", $modified), 'perms' => substr(sprintf('%o', fileperms($path)), -3), 'owner' => fileowner($path), 'group' => filegroup($path), 'ext' => $ext, 'img' => fticon($ext), 'type' => textfiletype($ext), 'ft' => ft($ext), 'writable' => fm_iswritable($d), 'isvimg' => isvimg($ext), 'imgsize' => (isvimg($ext) || $ext == 'psd' || $ext == 'bmp') && $size <= 5242880 ? @getimagesize($path) : FALSE); }
function draw_tree($tree) { $upload_path_size = strlen($_SESSION['upload_path']); echo '<section><ul class="tree">'; $root = explode('/', $tree[0]); $fork = '├'; $root = array_search(basename($tree[0]), $root) + 1; $level = 0; $tab = str_repeat(' ', 2); for ($i = 0; $i < count($tree); $i++) { $branch = $tree[$i]; if (isset($tree[$i + 1])) { $next = $tree[$i + 1]; } else { $next = false; } if ($link = file2id(substr($branch, $upload_path_size))) { $ext = ''; $level = count(explode('/', $branch)) - $root; if ($next) { $next_level = count(explode('/', $next)) - $root; } else { $next_level = 0; } if ($level < 0) { $level = 0; } if ($next_level < 0) { $next_level = 0; } $ext = strtolower(pathinfo($branch, PATHINFO_EXTENSION)); $folder = ''; $basename = basename($branch); if (is_dir($branch)) { $folder = ' folder'; } if ($level > $next_level || !$next) { $fork = '└'; } else { $fork = '├'; } if ($level < $next_level) { echo '<li>' . str_repeat('<span class="vl">' . $tab . '│' . $tab . '</span>', $level + 1) . '</li>'; } echo '<li><span class="vl">' . str_repeat($tab . '│' . $tab, $level) . $tab . $fork . $tab . '</span><span class="' . $ext . $folder . '"><a href="index.php?f=' . $link . '">' . $basename . '</a></span></li>'; if ($level > $next_level) { echo '<li>' . str_repeat('<span class="vl">' . $tab . '│' . $tab . '</span>', $level) . '</li>'; } } } echo '</ul></section>'; }
$upload_path_size = strlen($_SESSION['upload_path']); foreach ($tree as $branch) { $id_tree[file2id(substr($branch, $upload_path_size))] = $branch; } # burn access ? burned($id); exit(json_encode($id_tree)); } # RSS format of a shared folder (but not for a locked one) if (isset($_GET['rss']) && !empty($tree) && strlen($id) <= 23) { $rss = array('infos' => '', 'items' => ''); $rss['infos'] = array('title' => basename($f), 'description' => e('Rss feed of ', false) . basename($f), 'link' => htmlentities($_SESSION['home'] . '?f=' . $id . '&rss')); include 'core/Array2feed.php'; $upload_path_size = strlen($_SESSION['upload_path']); foreach ($tree as $branch) { $id_branch = file2id(substr($branch, $upload_path_size)); $rss['items'][] = array('title' => basename($branch), 'description' => '', 'pubDate' => makeRSSdate(date("d-m-Y H:i:s.", filemtime($branch))), 'link' => $_SESSION['home'] . '?f=' . $id_branch, 'guid' => $_SESSION['home'] . '?f=' . $id_branch); } array2feed($rss); # burn access ? burned($id); exit; } } } } else { $message = '<div class="error"> <br/> ' . e('This link is no longer available, sorry.', false) . ' <br/> </div>';
function draw_tree($tree) { if (!only_image($tree)) { # file list tree echo '<section><ul class="tree">'; $root = explode('/', $tree[0]); $fork = '├'; $root = array_search(basename($tree[0]), $root) + 1; $level = 0; $tab = str_repeat(' ', 2); for ($i = 0; $i < count($tree); $i++) { $branch = $tree[$i]; if (isset($tree[$i + 1])) { $next = $tree[$i + 1]; } else { $next = false; } if ($link = file2id($branch)) { $ext = ''; $level = count(explode('/', $branch)) - $root; if ($next) { $next_level = count(explode('/', $next)) - $root; } else { $next_level = 0; } if ($level < 0) { $level = 0; } if ($next_level < 0) { $next_level = 0; } $ext = strtolower(pathinfo($branch, PATHINFO_EXTENSION)); $folder = ''; $basename = basename($branch); if (is_dir($branch)) { $folder = ' folder'; } if ($level > $next_level || !$next) { $fork = '└'; } else { $fork = '├'; } if ($level < $next_level) { echo '<li>' . str_repeat('<span class="vl">' . $tab . '│' . $tab . '</span>', $level + 1) . '</li>'; } echo '<li><span class="vl">' . str_repeat($tab . '│' . $tab, $level) . $tab . $fork . $tab . '</span><span class="' . $ext . $folder . '"><a href="index.php?f=' . $link . '">' . $basename . '</a></span></li>'; if ($level > $next_level) { echo '<li>' . str_repeat('<span class="vl">' . $tab . '│' . $tab . '</span>', $level) . '</li>'; } } } echo '</ul></section>'; } else { # image gallery if (!function_exists('auto_thumb')) { include 'core/auto_thumb.php'; } global $gallery_thumbs_width; $title = explode('/', $tree[0]); $title = $title[count($title) - 1]; unset($tree[0]); echo '<section><ul class="gallery"><h1>' . $title . '</h1>'; foreach ($tree as $image) { $link = 'index.php?f=' . file2id($image); $ext = strtolower(pathinfo($image, PATHINFO_EXTENSION)); if ($ext != 'mp4') { $size = getimagesize($image); $size = $size[0] . 'x' . $size[1]; $file = basename($image); auto_thumb($image, $width = $gallery_thumbs_width, $height = $gallery_thumbs_width, $add_to_thumb_filename = '_THUMBGALLERY_', $crop_image = true); echo '<a class="image" href="' . $link . '" ><img src="' . $link . '>humbs" alt="' . $file . '"/><span class="info"><em>' . $file . '</em> ' . $size . '</span></a>'; } else { echo '<a class="image video" href="' . $link . '" ><div class="blank"> </div><span class="info"><em>' . $file . '</em> ' . $size . '</span></a>'; } } echo '</ul></section>'; } }
$upload_path_size = strlen($_SESSION['upload_root_path']); foreach ($tree as $branch) { $id_tree[file2id($branch)] = $branch; } # burn access ? burned($id); exit(json_encode($id_tree)); } # RSS format of a shared folder (but not for a locked one) if (isset($_GET['rss']) && !empty($tree) && strlen($id) <= 23) { $rss = array('infos' => '', 'items' => ''); $rss['infos'] = array('title' => basename($f), 'description' => e('Rss feed of ', false) . basename($f), 'link' => htmlentities($_SESSION['home'] . '?f=' . $id . '&rss')); include 'core/Array2feed.php'; $upload_path_size = strlen($_SESSION['upload_root_path']); foreach ($tree as $branch) { $id_branch = file2id($branch); $rss['items'][] = array('title' => basename($branch), 'description' => '', 'pubDate' => makeRSSdate(date("d-m-Y H:i:s.", filemtime($branch))), 'link' => $_SESSION['home'] . '?f=' . $id_branch, 'guid' => $_SESSION['home'] . '?f=' . $id_branch); } array2feed($rss); # burn access ? burned($id); exit; } } } } else { require THEME_PATH . '/header.php'; echo '<div class="error"> <br/> ' . e('This link is no longer available, sorry.', false) . ' <br/>
$destination = $destination_temp; if (!is_dir(dirname('thumbs/' . $destination))) { mkdir(dirname('thumbs/' . $destination), 0744, true); } @rename(get_thumbs_name($file_with_path), get_thumbs_name($destination)); if (is_file($file_with_path)) { # change path in id $id = file2id($file_with_path); $ids = unstore(); $ids[$id] = $destination; store($ids); rename($file_with_path, $destination); $tree = rename_branch($destination, $file_with_path, $id, $_SESSION['login'], $tree); } elseif (is_dir($file_with_path)) { # change path in id and all files/folders in the moved folder $id = file2id($file_with_path); $ids = unstore(); $ids[$id] = $destination; $destination = $destination . '/'; $file = $file . '/'; foreach ($ids as $id => $path) { if (strpos($path, $file) !== false) { $ids[$id] = str_replace($file, $destination, $path); } } store($ids); rename($file_with_path, $destination); $tree = rename_branch($destination, $file_with_path, $id, $_SESSION['login'], $tree); } } header('location:index.php?p=admin&msg=' . $me . ' ' . e('moved to', false) . ' ' . $to . '&token=' . TOKEN);
// Sidebar //==================== $fileinfo = array(); $files = array(); if ($file) { $fileinfo = fm_fileinfo($d); } else { if ($_GET['mi']) { $files = ids2files($_GET['mi']); if (count($files) == 1) { $fileinfo = fm_fileinfo($presub . $postsub . $files[0]); } } else { if (!fm_readdirect() && endsWith('/' . $d, '/')) { //$fileinfo = fm_fileinfo($d); $fileinfo = array('name' => basename($d) ? basename($d) : '/', 'bname' => basename($d) . '/', 'id' => file2id(basename($d) . '/'), 'isdir' => true, 'size' => 0, 'tsize' => '-', 'modified' => 0, 'tmodified' => '-', 'tdmodified' => '-', 'perms' => 0, 'owner' => '', 'group' => '', 'ext' => '/', 'img' => fticon('/'), 'type' => textfiletype('/'), 'ft' => 1, 'writable' => true, 'isvimg' => false, 'imgsize' => false); } else { $fileinfo = fm_fileinfo($d); } } } $vmode = $_GET['vmode']; if ($vmode == 'dl') { if (fm_contenttype(fext($file))) { header('Content-Type: ' . fm_contenttype(fext($file))); header('Content-Disposition: attachment; filename="' . $file . '"'); } echo fm_contents($file); fm_close(); die; }
if (check_path($file) && check_path($destination)) { if (is_file($_SESSION['upload_path'] . $file) || is_dir($_SESSION['upload_path'] . $file)) { $file = stripslashes($file); $destination = addslash_if_needed($destination) . basename($file); # if file/folder exists in destination folder, change name if (is_file($_SESSION['upload_path'] . $destination) || is_dir($_SESSION['upload_path'] . $destination)) { $destination = addslash_if_needed($destination) . rename_item(basename($file)); } # move file rename($_SESSION['upload_path'] . $file, $_SESSION['upload_path'] . $destination); if (!is_dir(dirname('thumbs/' . $destination))) { mkdir(dirname('thumbs/' . $destination), 0744, true); } rename(get_thumbs_name($file), get_thumbs_name($destination)); # change path in id $id = file2id($file); $ids = unstore(); $ids[$id] = $destination; store(); } } header('location:admin.php'); exit; } # Lock folder with password if (!empty($_POST['password']) && !empty($_POST['id'])) { $id = $_POST['id']; $file = id2file($id); $password = blur_password($_POST['password']); # turn normal share id into password hashed id $ids = unstore();
function fm_fileinfo($d) { global $ftp, $ftp_prepath; if (!$d) { return array('name' => '/', 'bname' => '', 'id' => file2id('/'), 'isdir' => true, 'size' => 0, 'tsize' => '-', 'modified' => 0, 'tmodified' => '-', 'tdmodified' => '-', 'perms' => 0, 'owner' => '', 'group' => '', 'ext' => '/', 'img' => fticon('/'), 'type' => textfiletype('/'), 'ft' => 1, 'writable' => true, 'isvimg' => false, 'imgsize' => false); } $up = upOne($ftp_prepath . $d); if (is_array($filecache[$up]['raw'])) { $cfiles = $filecache[$up]['raw']; } else { if (!fm_ftpconnect()) { return false; } ftp_chdir($ftp, $up); $cfiles = ftp_rawlist($ftp, '.'); ftp_chdir($ftp, '/'); $filecache[$up]['raw'] = $cfiles; } $file = basename($d); foreach ($cfiles as $cfile) { $info = array(); $cinfo = preg_split('/[\\s]+/', $cfile, 9); if ($cinfo[0] !== 'total' && $cinfo[8] != '.' && $cinfo[8] != '..' && $cinfo[8] == $file) { $cfilen = $cinfo[8] . ($cinfo[0][0] == 'd' ? '/' : ''); $ext = fext($cfilen); $info = array('name' => $cfilen, 'bname' => $cinfo[8], 'id' => file2id($cfilen), 'isdir' => $cinfo[0][0] == 'd' ? '/' : '', 'size' => intval($cinfo[4]), 'tsize' => textfilesize(intval($cinfo[4])), 'modified' => 0, 'tmodified' => $cinfo[5] . ' ' . $cinfo[6] . ' ' . $cinfo[7], 'tdmodified' => $cinfo[5] . ' ' . $cinfo[6], 'perms' => permconvert($cinfo[0]), 'owner' => $cinfo[2], 'group' => $cinfo[3], 'ext' => $ext, 'img' => fticon($ext), 'type' => textfiletype($ext), 'ft' => ft($ext), 'writable' => true, 'isvimg' => false, 'imgsize' => false); return $info; } } return false; }
function rename_branch($new = null, $old = null, $id = null, $user = null, $tree = array()) { global $ids; if (empty($new) || empty($old) || $new == $old) { return false; } if (empty($id) && empty($ids)) { return false; } if (empty($id)) { $id = file2id($old); } if (empty($user) && !empty($_SESSION['login'])) { $user = $_SESSION['login']; } if (empty($tree)) { $tree = loadtree($user); } if (isset($tree[$id]) || ($id = array_search($old, $tree))) { $tree[$id] = $new; } return $tree; }