. // Utility functions for user file sandbox feature require_once("../inc/util.inc"); require_once("../inc/dir_hier.inc"); // Return path of sandbox directory for the given user. // Create dir if not present. // function sandbox_dir($user) { if (!is_dir("../../sandbox")) { mkdir("../../sandbox"); } $d = "../../sandbox/$user->id"; if (!is_dir($d)) { mkdir($d); } return $d; } function sandbox_write_link_file($path, $size, $md5) { file_put_contents($path, "sb $size $md5"); } // parse a link file and return // (error, size, md5) // function sandbox_parse_link_file($path) { $x = file_get_contents($path); $n = sscanf($x, "%s %d %s", $s, $size, $md5); if ($n != 3) return array(true, null, null); if ($s != 'sb') return array(true, null, null); return array(false, $size, $md5); } $fanout = parse_config(get_config(), ""); // return the path of the file in the download directory // function sandbox_physical_path($user, $md5) { global $fanout; $f = "sb_".$user->id.$md5; return dir_hier_path($f, "../../download", $fanout); } ?>