session_begin(); $auth->acl($user->data); $user->setup('mods/tube'); // Setup specific vars $mode = request_var('mode',''); $submode = request_var('submode',''); $type = request_var('type',''); $id = request_var('id',''); $start = request_var('start',0); $submit = (isset($_POST['submit'])) ? true : false; $deny = (isset($_POST['deny'])) ? true : false; $item_id = request_var('item_id',0); $sort_order = request_var('sort_order','DESC'); $error = $message = NULL; $comment = $comment_username = ''; $template->assign_vars(array( 'S_TUBE_ADD' => ($auth->acl_get('u_tube_add') && (($config['tube_upload'] == true && $config['tube_ffmpeg'] != '' && is_executable($config['tube_ffmpeg'])) || $config['tube_youtube'] == true)) ? true : false, 'S_ITEM_VIEW' => true, 'U_TUBE_ADD' => append_sid("{$tube_path}video_add.$phpEx", "mode=addvideo"), 'U_TUBE' => append_sid("{$tube_path}index.$phpEx"), 'ERROR' => $error, )); if ($config['tube_disabled'] == false) { if (!isset($user->lang['TUBE_COPYRIGHT']) || (trim($user->lang['TUBE_COPYRIGHT']) == '') || $user->lang['TUBE_COPYRIGHT'] != $user->lang['TUBE_COPYRIGHT_CHECK']) { trigger_error($user->lang['TUBE_REPLACE_COPYRIGHT'], E_USER_NOTICE); exit; } switch($mode) { default: if (!$auth->acl_get('u_tube_view')) { login_box(append_sid("./tube/index.$phpEx"), $user->lang['LOGIN_EXPLAIN_TUBE']); } if ($user->data['is_bot']) { redirect(append_sid("{$phpbb_root_path}index.$phpEx")); } $x = $y = 0; $result = get_catitems_order('title'); while ($cat_item = $db->sql_fetchrow($result)) { $x++; $y++; $total_items = countItems($cat_item['category_id']); $template->assign_block_vars('category', array( 'S_ROW' => $x % 3, 'S_COL' => $y, 'U_CATEGORY' => append_sid("{$tube_path}video_category.$phpEx", "mode=category&id=" . $cat_item['category_id']), 'CATEGORY' => $cat_item['title'], 'COUNT' => $total_items, 'DESCRIPTION' => (strlen($cat_item['description']) > 150) ? substr($cat_item['description'], 0, 150) . '...' : $cat_item['description'], 'THUMB' => ($cat_item['thumb'] != '') ? (($cat_item['thumb'] != '') ? $cat_item['thumb'] : append_sid($cat_item['thumb'])) : '', )); } $db->sql_freeresult($result); make_tabs(); $total24hours = countdateItems(86400); $total7days = countdateItems(604800); $total30days = countdateItems(2592000); $totaltotal = countdateItems(time()); $template->assign_vars(array( '24_HOURS' => sprintf($user->lang['TUBE_TOTAL_24_HOURS'], $total24hours), '7_DAYS' => sprintf($user->lang['TUBE_TOTAL_7_DAYS'], $total7days), '30_DAYS' => sprintf($user->lang['TUBE_TOTAL_30_DAYS'], $total30days), 'TOTAL' => sprintf($user->lang['TUBE_TOTAL'], $totaltotal), )); $template->assign_block_vars('navlinks', array( 'U_VIEW_FORUM' => append_sid("{$tube_path}index.$phpEx"), 'FORUM_NAME' => $user->lang['TUBE'], )); $template->set_filenames(array( 'body' => 'tube/tube_main.html' )); $page_title = $user->lang['TUBE']; break; } } else { $template->assign_block_vars('navlinks', array( 'U_VIEW_FORUM' => append_sid("{$tube_path}index.$phpEx"), 'FORUM_NAME' => $user->lang['TUBE'], )); $template->set_filenames(array( 'body' => 'tube/tube_disable.html' )); $page_title = $user->lang['TUBE']; } // Output the page page_header($page_title); page_footer(); // Get the ordered items of a category function get_catitems_order($sort_order) { global $db; $sql = 'SELECT * FROM ' . TUBE_CATEGORIES_TABLE . " WHERE 1 ORDER BY $sort_order"; return $result = $db->sql_query($sql); } function get_rating($id, $votes = FALSE, $link = FALSE) { global $phpbb_root_path, $user, $db, $phpEx; $sql = 'SELECT COUNT(item_id), SUM(rating) FROM ' . TUBE_RATINGS_TABLE . " WHERE item_id = '" . $db->sql_escape($id) . "'"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if ($row['COUNT(item_id)'] == 0) { $value = 0; $count = 0; } else { $value = $row['SUM(rating)'] / $row['COUNT(item_id)']; $count = $row['COUNT(item_id)']; } $rating = ''; for ($i = 1; $i <= 5; $i++) { global $tube_path; $prepend = ($link == TRUE && $user->data['user_id'] != ANONYMOUS) ? '' : ''; if ($value >= 1) { $append = ($link == TRUE && $user->data['user_id'] != ANONYMOUS) ? 'onmouseover="this.src=\'images/ratings/on.gif\'" onmouseout="this.src=\'images/ratings/full.gif\'" />' : '/>'; $rating .= $prepend . '' . $i . '= 0.5) { $append = ($link == TRUE && $user->data['user_id'] != ANONYMOUS) ? 'onmouseover="this.src=\'images/ratings/on.gif\'" onmouseout="this.src=\'images/ratings/half.gif\'" />' : '/>'; $rating .= $prepend . '' . number_format($i + $value,2) . 'data['user_id'] != ANONYMOUS) ? 'onmouseover="this.src=\'images/ratings/on.gif\'" onmouseout="this.src=\'images/ratings/off.gif\'" />' : '/>'; $rating .= $prepend . '' . (($value > 0) ? number_format($i + $value,2) : '-') . 'lang['TUBE_RATING_INFO'], $count) : ''; return $rating; } //Count the items of a category in time function countdateItems($time) { global $db; $sql = 'SELECT COUNT(*) as num_items FROM ' . TUBE_ITEMS_TABLE . ' WHERE date >= ' . (time()-$time) . ' AND date <= ' . time(); $result = $db->sql_query($sql); $total_time_items = $db->sql_fetchfield('num_items'); $db->sql_freeresult($result); return $total_time_items; } ?>