function create_files_list_full($dir, $extensions = '') { $directory = @opendir($dir); $files_list = array(); while (@($file = readdir($directory))) { if (!in_array($file, array('.', '..'))) { $is_dir = is_dir($dir . '/' . $file) ? true : false; $temp_path = str_replace('//', '/', $dir . '/' . $file); $file_details = get_file_details($temp_path); $file_title = $file_details['name']; $file_type = strtolower($file_details['ext']); $process_file = false; if ($extensions == '') { //$file_exclusions_array = array(); $file_exclusions_array = array('ace', 'bak', 'bmp', 'css', 'gif', 'hl', 'htc', 'htm', 'html', 'ico', 'jar', 'jpeg', 'jpg', 'js', 'pak', 'png', 'rar', 'sql', 'swf', 'tpl', 'ttf', 'txt', 'wmv', 'zip'); if (!in_array($file_type, $file_exclusions_array)) { $process_file = true; } } else { if ($file_type == $extensions) { $process_file = true; } } if ($process_file == true) { $files_list[] = $temp_path; } // Directory found, so recall this function if ($is_dir) { $files_list = array_merge($files_list, create_files_list_full($dir . '/' . $file, $extensions)); } } // if } // while @closedir($directory); return $files_list; }
require '../includes/admin_config.php'; $userquery->admin_login_check(); $userquery->login_check('web_config_access'); /* Assigning page and subpage */ if (!defined('MAIN_PAGE')) { define('MAIN_PAGE', 'Tool Box'); } if (!defined('SUB_PAGE')) { define('SUB_PAGE', 'Repair video duration'); } $params = array('duration' => '1', 'duration_op' => '<=', 'status' => 'Successful'); $videos = get_videos($params); $fixed_array = array(); if ($_POST['fix_duration'] || $_POST['mark_failed'] || $_POST['mark_delete']) { foreach ($videos as $video) { $log = get_file_details($video['file_name']); if ($log && $_POST['fix_duration']) { //$duration = $log['output_duration']; //if(!$duration) // $duration = $log['duration']; $duration = parse_duration(LOGS_DIR . '/' . $video['file_name'] . '.log'); if (!$duration) { e("Can't do anything about \"" . $video['title'] . "\""); } else { $db->update(tbl('video'), array('duration'), array($duration), "videoid='" . $video['videoid'] . "'"); $fixed_array[$video['file_name']] = 'yes'; e("Succesfully updated duration of \"" . $video['title'] . "\" to " . SetTime($duration), 'm'); } } if (!$log && $_POST['mark_failed']) { $db->update(tbl("video"), array("status", "failed_reason"), array('Failed', "Unable to get video duration"), " file_name='" . $video['file_name'] . "'");
$filename = $_GET['filename']; } } // a single attachment if (!empty($attachment_id)) { $attachment = get_attachment($attachment_id); // file usage $usage = attachment_usage($attachment_id); // default to list if requested attachment not found if (empty($attachment)) { $attachments = get_attachments(); } } elseif (isset($_GET['filename'])) { // this is a rogue file $rogue_path = WW_ROOT . '/ww_files/attachments/' . $_GET['ext'] . '/' . $_GET['filename']; $attachment = get_file_details($rogue_path); $attachment['src'] = WW_WEB_ROOT . '/ww_files/attachments/' . $_GET['ext'] . '/' . $_GET['filename']; // file usage $usage = attachment_usage($attachment_id); } else { // if no single attachment is found/requested we return a list $attachments = get_attachments(); // get total attachments and total pages $total_files = !empty($attachments) ? $attachments[0]['total_files'] : 0; $total_pages = !empty($attachments) ? $attachments[0]['total_pages'] : 0; // check for rogues and orphans if (isset($_GET['ext'])) { $orphans = get_attachment_orphans($_GET['ext']); } else { $rogue = get_files(WW_ROOT . '/ww_files/attachments/'); if (!empty($rogue)) {
/** * Function used to get file details from database */ function file_details($file_name) { global $db; return get_file_details($file_name); /* $results = $db->select("video_files","*"," src_name='$file_name'"); if($db->num_rows==0) return false; else { return $results[0]; } */ }
function parse_duration($log) { $duration = false; $log_details = get_file_details($log); if (isset($log['output_duration'])) { $duration = $log['output_duration']; } if ((!$duration || !is_numeric($duration)) && isset($log['duration'])) { $duration = $log['duration']; } if (!$duration || !is_numeric($duration)) { if (file_exists($log)) { $log_content = file_get_contents($log); } //Parse duration.. preg_match_all('/Duration: ([0-9]{1,2}):([0-9]{1,2}):([0-9.]{1,5})/i', $log_content, $matches); unset($log_content); //Now we will multiple hours, minutes accordingly and then add up with seconds to //make a single variable of duration $hours = $matches[1][0]; $minutes = $matches[2][0]; $seconds = $matches[3][0]; $hours = $hours * 60 * 60; $minutes = $minutes * 60; $duration = $hours + $minutes + $seconds; $duration; } return $duration; }
header('Location: ' . WW_WEB_ROOT . '/ww_edit/index.php?page_name=images&image_id=' . $image_id); } // get image details or list of images $image_id = isset($_GET['image_id']) ? (int) $_GET['image_id'] : 0; if (isset($_GET['filename'])) { $filepath = WW_ROOT . '/ww_files/images/' . $_GET['filename']; if (file_exists($filepath)) { $filename = $_GET['filename']; } } if (!empty($image_id)) { $image = get_image($_GET['image_id']); // file usage $usage = file_usage($image['filename']); } elseif (isset($filename)) { $image = get_file_details($filepath); // file usage $usage = file_usage($image['filename']); } else { $images = get_images($images_per_page); $orphans = get_image_orphans(); $total_images = !empty($images) ? $images[0]['total_images'] : 0; $total_pages = !empty($images) ? $images[0]['total_pages'] : 0; } // construct page header $left_text = '<a href="' . $_SERVER["PHP_SELF"] . '?page_name=files">files</a>'; $left_text .= isset($image) ? ': <a href="' . $_SERVER["PHP_SELF"] . '?page_name=images">images</a>' : ': images'; $right_text = isset($image) ? $image['filename'] : $total_images . ' found'; $page_header = show_page_header($left_text, $right_text); // output main content $main_content = $page_header;
//sometimes video is inserted after video conversion so in this case, video can get lost $in_bg_cron = true; include dirname(__FILE__) . "/../includes/config.inc.php"; cb_call_functions('verify_converted_videos_cron'); if ($argv[1]) { $fileName = $argv[1]; } else { $fileName = false; } if (isset($_GET['filename'])) { $fileName = $_GET['filename']; } $files = get_video_being_processed($fileName); if (is_array($files)) { foreach ($files as $file) { $file_details = get_file_details($file['cqueue_name'], true); //Thanks to pandusetiawan @ forums.clip-bucket.com if ($file_details['conversion_status'] == 'failed' or strpos($file_details['conversion_log'], 'conversion_status : failed') > 0) { update_processed_video($file, 'Failed', $ffmpeg->failed_reason); $db->update(tbl("conversion_queue"), array("cqueue_conversion"), array("yes"), " cqueue_id = '" . $file['cqueue_id'] . "'"); /** * Calling Functions after converting Video */ if (get_functions('after_convert_functions')) { foreach (get_functions('after_convert_functions') as $func) { if (@function_exists($func)) { $func($file_details); } } } } elseif ($file_details['conversion_status'] == 'completed' or strpos($file_details['conversion_log'], 'conversion_status : completed') > 0 or $file_details['conversion_status'] == 'Successful' or strpos($file_details['conversion_log'], 'conversion_status : Successful') > 0) {
if (!empty($custom_folders)) { $main_content .= '<ul>'; foreach ($custom_folders as $custom_folder) { $main_content .= ' <li> <a href="' . $custom_folder['link'] . '">' . $custom_folder['title'] . '</a> </li>'; } $main_content .= '</ul>'; } else { $main_content .= '<p>No custom folders have been created</p>'; } } else { // get single files details if filename set via url if (isset($_GET['filename'])) { $file_details = get_file_details(WW_ROOT . '/ww_files/' . $_GET['folder'] . '/' . $_GET['filename']); if (isset($_GET['action']) && $_GET['action'] == 'delete') { $main_content .= ' <h2>Are you sure you want to delete this file?</h2> <form action="' . $action_url . '" method="post" name="confirm_delete_file_form"> <input name="filename" type="hidden" value="' . $file_details['filename'] . '"/> <input name="folder" type="hidden" value="' . $_GET['folder'] . '"/> <input name="confirm_delete_file" type="submit" value="Yes"/> <input name="cancel_delete_file" type="submit" value="No" /> </form> '; } $main_content .= "\r\n\t\t\t\t<hr />\r\n\t\t\t\t<h4>file details</h4>\r\n\t\t\t\t\r\n\t\t\t\t<ul>\r\n\t\t\t\t\t<li><strong>filename: </strong><a href=\"" . $file_details['path'] . "\">" . $file_details['filename'] . "</a></li>\r\n\t\t\t\t\t<li><strong>size: </strong>" . get_kb_size($file_details['size']) . "</li>\r\n\t\t\t\t\t<li><strong>date uploaded: </strong>" . date('d F Y', $file_details['date_uploaded']) . "</li>\r\n\t\t\t\t</ul>"; // get file listing if a folder name is set via url } elseif (isset($_GET['folder'])) { if (!empty($files)) {
/** * Function used to get file details from database */ function file_details($file_name) { global $db; return get_file_details($file_name); }