function forceDirectories($path) { if (strlen($path) == 0) { return 0; } if (strlen($path) < 3) { return 1; // avoid 'xyz:\' problem. } elseif (is_dir($path)) { return 1; // avoid 'xyz:\' problem. } elseif (dirname($path) == $path) { return 1; // avoid 'xyz:\' problem. } return (ForceDirectories(dirname($path))and mkdir($path, 0775)); }
$frame_rate = $ThisFileInfo['video']["frame_rate"]; $small_frame_width = isset($config['small_frame_width']) ? $config['small_frame_width'] : 80; $command = "{$config['mencoder']} -frames 1 -ovc lavc -lavcopts vcodec={$config['vcodec']} -nosound -o {$tmpdir}/tmp.avi "; for ($j = 0; $j < $count; $j++) { $res = array(); $ss = floor(rand(300, $playtime_seconds - 600)); $nfilename = escapeshellarg($storages->decode_path($filename)); $command .= " {$nfilename} -ss {$ss} "; } echo "{$command}<br>\n"; exec($command, $output); echo implode("<br>\n", $output); $smallframes = array(); $frames = array(); if (is_file("{$tmpdir}/tmp.avi")) { ForceDirectories($this_path . "/" . $directory); $command = "{$config['mplayer']} -vo jpeg -speed 100 {$tmpdir}/tmp.avi"; echo "{$command}<br>\n"; exec($command, $output); echo implode("<br>\n", $output); for ($i = 0; $i < $count; $i++) { $fn = sprintf("{$tmpdir}/%08s.jpg", $i + 1); if (is_file($fn)) { $to_path = $directory . "/f{$i}.jpg"; @unlink($this_path . "/" . $to_path); if (rename($fn, $this_path . "/" . $to_path)) { $frames[] = $to_path; } } } $imageinfo = getimagesize($this_path . "/" . $to_path);
function urename($from_path, $to_path) { ForceDirectories($to_path); $this_path = getcwd(); if (is_dir($from_path)) { chdir($from_path); $handle = opendir('.'); while (($file = readdir($handle)) !== false) { if ($file != "." && $file != "..") { if (is_dir($file)) { urename($from_path . $file . "/", $to_path . $file . "/"); chdir($from_path); } if (is_file($file)) { rename($from_path . $file, $to_path . $file); chmod($to_path . $file, isset($config['folder_rights']) ? $config['folder_rights'] : 0644); } } } closedir($handle); } else { rename($from_path, $to_path); } $res = rmdir($from_path); @rmdir(dirname($from_path)); return $res; }
function ForceDirectories($path, $umask) { if (strlen($path) == 0) { return 0; } // if (strlen($path) < 3) { return 1; // avoid 'xyz:\' problem. } elseif (is_dir($path)) { return 1; // avoid 'xyz:\' problem. } elseif (dirname($path) == $path) { return 1; // avoid 'xyz:\' problem. } return ForceDirectories(dirname($path), $umask) and mkdir($path, $umask); }