Example #1
0
}
?>
<div id="center">
<div id="home_container">
<div class="container_box1"><div class="header">Submit Videos</div>
<?php 
if (isset($_POST['add'])) {
    $title = yasDB_clean($_POST['title']);
    $desc = yasDB_clean($_POST['description']);
    $thumb = $_POST['thumbnail'];
    $file = 'http://www.youtube.com/watch?v=' . get_youtube_data($_POST['file'], true);
    $height = intval($_POST['height']);
    $width = intval($_POST['width']);
    $keywords = yasDB_clean($_POST['keywords']);
    if ($_POST['type'] == 'YOUTUBE') {
        $data = get_youtube_data($_POST['file']);
        $tn = $data['thumbnail'];
        $title = yasDB_clean($data['title']);
        $desc = yasDB_clean($data['description']);
        $keywords = yasDB_clean($data['keywords']);
        if (isset($_POST['name'])) {
            $name = yasDB_clean($_POST['name']);
        } else {
            if (isset($_SESSION['user'])) {
                $name = $_SESSION['user'];
            } else {
                $name = '';
            }
        }
        if (remoteFileExists($tn) === true) {
            $thumb = 'img/' . preg_replace('#\\W#', '', $title) . rand(0, pow(10, 5)) . '.' . get_file_extension($tn);
    function main($video_id, $mode)
    {
        global $db, $user, $auth, $template, $cache;
        global $config, $SID, $phpbb_root_path, $phpbb_admin_path, $phpEx;
        include $phpbb_root_path . 'includes/sgp_functions.' . $phpEx;
        $user->add_lang('acp/k_youtube');
        $this->tpl_name = 'acp_k_youtube';
        $this->page_title = 'ACP_YOUTUBE';
        $form_key = 'acp_k_youtube';
        add_form_key($form_key);
        //$s_hidden_fields = '';
        $mode = request_var('mode', '');
        $video_id = request_var('video_id', '');
        $action = request_var('config', '');
        $submit = isset($_POST['submit']) ? true : false;
        $action = isset($_POST['add_video']) ? 'add' : (isset($_POST['save']) ? 'save' : (isset($_POST['config']) ? 'config' : $action));
        switch ($action) {
            case 'config':
                $template->assign_var('MESSAGE', $user->lang['SWITCHING']);
                meta_refresh(1, "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_vars&amp;mode=config&amp;switch=k_youtube");
                break;
            case 'add':
                $mode = '';
                meta_refresh(0, "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_youtube&amp;mode=add");
                break;
            default:
                break;
        }
        if ($submit && !check_form_key($form_key)) {
            $submit = false;
            $mode = '';
            trigger_error('Error! ' . $user->lang['FORM_INVALID'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
        }
        $template->assign_vars(array('U_BACK' => "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_youtube", 'U_ADD' => "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_youtube&amp;mode=add", 'U_EDIT' => "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_youtube&amp;mode=edit" . '&amp;video_id=' . $video_id, 'U_DELETE' => "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_youtube&amp;mode=delete" . '&amp;video_id=' . $video_id, 'U_BROWSE' => "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_youtube&amp;mode=browse", 'S_OPT' => 'browse'));
        switch ($mode) {
            case 'edit':
                if ($submit) {
                    $video_id = request_var('video_id', 0);
                    $video_link = request_var('video_link', '');
                    $video_rating = request_var('video_rating', '');
                    $video_category = utf8_normalize_nfc(request_var('video_category', '', true));
                    $video_who = utf8_normalize_nfc(request_var('video_who', '', true));
                    $video_title = utf8_normalize_nfc(request_var('video_title', '', true));
                    $video_comment = utf8_normalize_nfc(request_var('video_comment', ''));
                    $video_poster_id = request_var('video_poster_id', '');
                    $sql_ary = array('video_link' => $video_link, 'video_category' => $video_category, 'video_who' => $video_who, 'video_rating' => $video_rating, 'video_title' => $video_title, 'video_comment' => $video_comment);
                    $sql = 'UPDATE ' . K_YOUTUBE_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " WHERE video_id = " . (int) $video_id;
                    if (!($result = $db->sql_query($sql))) {
                        trigger_error($user->lang['ERROR_PORTAL_VIDEO'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
                    }
                    $template->assign_vars(array('MESSAGE' => $user->lang['DATA_IS_BEING_SAVED'] . '</font><br />', 'S_OPT' => 'saving'));
                    meta_refresh(0, "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_youtube&amp;mode=browse");
                }
                get_video_item($video_id);
                $template->assign_var('S_OPTION', 'edit');
                break;
            case 'delete':
                //get the title of the video to make delete clearer to the user...
                $video_name = get_video_item($video_id);
                if (confirm_box(true)) {
                    $sql = 'DELETE FROM ' . K_YOUTUBE_TABLE . '
						WHERE video_id = ' . (int) $video_id;
                    if (!($result = $db->sql_query($sql))) {
                        trigger_error($user->lang['ERROR_PORTAL_VIDEO'] . basename(dirname(__FILE__)) . '/' . basename(__FILE__) . ', line ' . __LINE__);
                    }
                    $template->assign_vars(array('MESSAGE' => $user->lang['DELETING'] . $video_id . '<br />', 'S_OPT' => 'delete'));
                    $cache->destroy('sql', K_YOUTUBE_TABLE);
                    meta_refresh(1, "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_youtube&amp;mode=browse");
                    break;
                } else {
                    confirm_box(false, sprintf($user->lang['CONFIRM_OPERATION_YOUTUBE'], $video_name), build_hidden_fields(array('id' => $video_id, 'mode' => $mode, 'action' => 'delete')));
                }
                $template->assign_var('MESSAGE', $user->lang['ACTION_CANCELLED']);
                meta_refresh(1, "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_youtube&amp;mode=browse");
                break;
            case 'add':
                if ($submit) {
                    //$video_id		 = request_var('video_id', '');
                    $video_link = request_var('video_link', '');
                    $video_rating = request_var('video_rating', '');
                    $video_category = utf8_normalize_nfc(request_var('video_category', '', true));
                    $video_who = utf8_normalize_nfc(request_var('video_who', '', true));
                    $video_title = utf8_normalize_nfc(request_var('video_title', '', true));
                    $video_comment = utf8_normalize_nfc(request_var('video_comment', '', true));
                    $video_poster_id = request_var('video_poster_id', '');
                    if (strstr($video_link, 'None')) {
                        $video_link = '';
                    }
                    $sql_array = array('video_category' => $video_category, 'video_who' => $video_who, 'video_link' => $video_link, 'video_title' => $video_title, 'video_rating' => $video_rating, 'video_comment' => $video_comment, 'video_poster_id' => $user->data['user_id']);
                    $db->sql_query('INSERT INTO ' . K_YOUTUBE_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_array));
                    meta_refresh(0, "{$phpbb_root_path}adm/index.{$phpEx}{$SID}&amp;i=k_youtube&amp;mode=browse");
                    $template->assign_var('L_MENU_REPORT', $user->lang['VIDEO_CREATED']);
                    $cache->destroy('sql', K_YOUTUBE_TABLE);
                    break;
                } else {
                    get_video_item(0);
                    $template->assign_vars(array('S_OPTION' => 'add', 'MESSAGE' => $user->lang['UTUBE_SAMPLE_DATA'] . '<br />'));
                    $mode = 'add';
                }
                break;
            case 'config':
                break;
            case 'browse':
                get_youtube_data();
                break;
            case 'default':
                break;
        }
        $template->assign_var('U_ACTION', $this->u_action);
    }