Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->user->session_begin();
     $this->user->setup('common');
     if ($this->config['email_enable']) {
         include $this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext;
         // functions_messenger.php uses config to determine language paths
         // Remove when able
         global $config;
         $config = $this->config;
         $messenger = new \messenger(false);
         $messenger->template('installed', $this->install_config->get('user_language', 'en'));
         $messenger->to($this->config['board_email'], $this->install_config->get('admin_name'));
         $messenger->anti_abuse_headers($this->config, $this->user);
         $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode($this->install_config->get('admin_name')), 'PASSWORD' => htmlspecialchars_decode($this->install_config->get('admin_passwd'))));
         $messenger->send(NOTIFY_EMAIL);
     }
     // Login admin
     // Ugly but works
     $this->auth->login($this->install_config->get('admin_name'), $this->install_config->get('admin_passwd'), false, true, true);
     $this->iohandler->set_cookie($this->config['cookie_name'] . '_sid', $this->user->session_id);
     $this->iohandler->set_cookie($this->config['cookie_name'] . '_u', $this->user->cookie_data['u']);
     $this->iohandler->set_cookie($this->config['cookie_name'] . '_k', $this->user->cookie_data['k']);
     // Create log
     $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_INSTALL_INSTALLED', false, array($this->config['version']));
     // Remove install_lock
     @unlink($this->phpbb_root_path . 'cache/install_lock');
 }
Exemplo n.º 2
0
    public function file($attach_id)
    {
        $this->user->setup('viewtopic');
        $sql_attach = 'SELECT a.*, u.username, u.user_colour, p.post_id, p.topic_id, p.forum_id, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid
			FROM ' . ATTACHMENTS_TABLE . ' a, ' . USERS_TABLE . ' u, ' . POSTS_TABLE . " p\n\t\t\tWHERE a.attach_id = " . (int) $attach_id . "\n\t\t\t\tAND p.post_id = a.post_msg_id\n\t\t\t\tAND a.poster_id = u.user_id\n\t\t\t\tAND a.is_orphan = 0";
        $result = $this->db->sql_query($sql_attach);
        $row = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        // Start auth check
        if (!$this->auth->acl_get('u_download') || !$this->auth->acl_get('f_read', $row['forum_id'])) {
            trigger_error('LINKAGE_FORBIDDEN');
        }
        $attachments = $update_count = array();
        $sql_attach = 'SELECT * FROM ' . ATTACHMENTS_TABLE . "\n\t\t\tWHERE post_msg_id = " . (int) $row['post_id'] . "\n\t\t\t\tAND is_orphan = 0";
        $result_attach = $this->db->sql_query($sql_attach);
        while ($attach_row = $this->db->sql_fetchrow($result_attach)) {
            $attachments[] = $attach_row;
        }
        $this->db->sql_freeresult($result_attach);
        // Parse the message and subject
        $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES;
        $message = generate_text_for_display($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, true);
        // Parse attachments
        parse_attachments($row['forum_id'], $message, $attachments, $update_count);
        // Replace naughty words such as farty pants
        $row['post_subject'] = censor_text($row['post_subject']);
        $view_post = append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", "t={$row['topic_id']}&p={$row['post_id']}") . "#p{$row['post_id']}";
        $this->template->assign_vars(array('POST_AUTHOR_FULL' => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour']), 'POST_DATE' => $this->user->format_date($row['filetime'], false, false), 'POST_TITLE' => $row['post_subject'], 'DESCRIPTION' => $row['post_subject'], 'MESSAGE' => $message, 'U_VIEW_POST' => $view_post, 'U_ATTACHMENTS_TOPIC' => $this->helper->route("bb3mobi_attach_cat", array('t' => $row['topic_id'])), 'ATTACHMENTS_BY' => $this->user->lang('ATTACHMENTS_BY', '<a href="http://bb3.mobi/forum/viewtopic.php?t=226">Download by</a>'), 'S_HAS_ATTACHMENTS' => !empty($attachments) ? true : false));
        foreach ($attachments as $attachment) {
            $this->template->assign_block_vars('attachment', array('DISPLAY_ATTACHMENT' => $attachment));
        }
        return $row['real_filename'];
    }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->user->session_begin();
     $this->user->setup(array('common', 'acp/common', 'cli'));
     $install_extensions = $this->iohandler->get_input('install-extensions', array());
     $all_available_extensions = $this->extension_manager->all_available();
     $i = $this->install_config->get('install_extensions_index', 0);
     $available_extensions = array_slice($all_available_extensions, $i);
     // Install extensions
     foreach ($available_extensions as $ext_name => $ext_path) {
         if (!empty($install_extensions) && $install_extensions !== ['all'] && !in_array($ext_name, $install_extensions)) {
             continue;
         }
         try {
             $this->extension_manager->enable($ext_name);
             $extensions = $this->get_extensions();
             if (isset($extensions[$ext_name]) && $extensions[$ext_name]['ext_active']) {
                 // Create log
                 $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($ext_name));
                 $this->iohandler->add_success_message(array('CLI_EXTENSION_ENABLE_SUCCESS', $ext_name));
             } else {
                 $this->iohandler->add_log_message(array('CLI_EXTENSION_ENABLE_FAILURE', $ext_name));
             }
         } catch (\Exception $e) {
             // Add fail log and continue
             $this->iohandler->add_log_message(array('CLI_EXTENSION_ENABLE_FAILURE', $ext_name));
         }
         $i++;
         // Stop execution if resource limit is reached
         if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) {
             break;
         }
     }
     $this->install_config->set('install_extensions_index', $i);
     if ($i < sizeof($all_available_extensions)) {
         throw new resource_limit_reached_exception();
     }
 }
Exemplo n.º 4
0
    public function avatar_crop($avatar_id)
    {
        $extension = $this->request->variable('ext', '');
        $submit = $this->request->is_set_post('submit');
        $prefix = $this->config['avatar_salt'] . '_';
        // Calculate new destination
        $destination = $this->config['avatar_path'];
        // Adjust destination path (no trailing slash)
        if (substr($destination, -1, 1) == '/' || substr($destination, -1, 1) == '\\') {
            $destination = substr($destination, 0, -1);
        }
        $destination = str_replace(array('../', '..\\', './', '.\\'), '', $destination);
        if ($destination && ($destination[0] == '/' || $destination[0] == "\\")) {
            $destination = '';
        }
        $destination_file = $this->phpbb_root_path . $destination . '/' . $prefix . $avatar_id . '.' . $extension;
        $destination_old_file = $this->phpbb_root_path . $this->d_edit . '/' . $avatar_id . '.' . $extension;
        $this->user->setup('ucp');
        $this->user->add_lang_ext('bb3mobi/AvatarUpload', 'avatar_upload');
        $error = array();
        if ($this->user->data['user_id'] != $avatar_id) {
            trigger_error('NO_AVATAR_USER');
        }
        if (!$extension || !file_exists($destination_old_file)) {
            trigger_error('NO_AVATAR_FILES');
        }
        if (($image_info = @getimagesize($destination_old_file)) == false) {
            trigger_error('NO_AVATAR_FILES');
        }
        $avatar_width = $image_info[0];
        $avatar_height = $image_info[1];
        $params_size = array('x1' => $this->request->variable('x1', 0), 'y1' => $this->request->variable('y1', 0), 'x2' => ceil($this->request->variable('x2', $image_info[0])), 'y2' => ceil($this->request->variable('y2', $image_info[1])), 'w' => floor($this->request->variable('w', $image_info[0])), 'h' => floor($this->request->variable('h', $image_info[1])), 'ext' => (string) $extension);
        if ($submit) {
            if ($params_size['w'] < $this->config['avatar_min_width'] || $params_size['x1'] > $avatar_width - $this->config['avatar_max_width']) {
                $error[] = $this->user->lang['ERROR_AVATAR_W'];
            }
            if ($params_size['h'] < $this->config['avatar_min_height'] || $params_size['y1'] > $avatar_height - $this->config['avatar_max_height']) {
                $error[] = $this->user->lang['ERROR_AVATAR_H'];
            }
            if ($params_size['x2'] > $avatar_width || $params_size['x2'] < $this->config['avatar_min_width']) {
                $error[] = $this->user->lang['ERROR_AVATAR_X2'];
            }
            if ($params_size['y2'] > $avatar_height || $params_size['y2'] < $this->config['avatar_min_height']) {
                $error[] = $this->user->lang['ERROR_AVATAR_Y2'];
            }
        }
        if (!sizeof($error) && $submit) {
            if ($result = $this->resize($params_size, $this->d_edit, $destination_old_file)) {
                rename($destination_old_file, $destination_file);
                // Success! Lets save the result in the database
                $result = array('user_avatar_type' => AVATAR_UPLOAD, 'user_avatar' => $avatar_id . '_' . time() . '.' . $extension, 'user_avatar_width' => $result['avatar_width'], 'user_avatar_height' => $result['avatar_height']);
                $sql = 'UPDATE ' . USERS_TABLE . '
					SET ' . $this->db->sql_build_array('UPDATE', $result) . '
					WHERE user_id = ' . (int) $this->user->data['user_id'];
                $this->db->sql_query($sql);
                meta_refresh(3, generate_board_url(), true);
                $message = $this->user->lang['PROFILE_UPDATED'] . '<br /><br />' . sprintf($this->user->lang['RETURN_INDEX'], '<a href="' . generate_board_url() . '">', '</a>');
                trigger_error($message);
            }
        }
        $this->template->assign_vars(array('ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'AVATAR_FILE' => generate_board_url() . '/' . $this->d_edit . '/' . $avatar_id . '.' . $extension, 'IMG_WIDTH' => $image_info[0], 'IMG_HEIGHT' => $image_info[1], 'SIZE_X1' => $params_size['x1'], 'SIZE_X2' => $params_size['x2'], 'SIZE_Y1' => $params_size['y1'], 'SIZE_Y2' => $params_size['y2'], 'SIZE_WIDTH' => $params_size['w'], 'SIZE_HEIGHT' => $params_size['h'], 'S_HIDDEN_FIELDS' => build_hidden_fields(array('ext' => $extension)), 'S_CROP_ACTION' => $this->helper->route("bb3mobi_AvatarUpload_crop", array('avatar_id' => $avatar_id))));
        page_header('Avatar crop');
        $this->template->set_filenames(array('body' => '@bb3mobi_AvatarUpload/crop_body.html'));
        page_footer();
    }
Exemplo n.º 5
0
    public function handle_video()
    {
        if (!$this->auth->acl_get('u_video_view_full')) {
            trigger_error($this->user->lang['UNAUTHED']);
        }
        // Initial var setup
        $video_id = $this->request->variable('id', 0);
        $video_url = $this->request->variable('video_url', '', true);
        $video_title = $this->request->variable('video_title', '', true);
        $video_cat_id = $this->request->variable('cid', 0);
        $video_cat_ids = $this->request->variable('id', 0);
        $username = $this->request->variable('username', '', true);
        $user_id = $this->request->variable('user_id', 0);
        $youtube_id = $this->request->variable('youtube_id', '', true);
        $create_time = $this->request->variable('create_time', '');
        $video_views = $this->request->variable('video_views', 0);
        $sql_start = $this->request->variable('start', 0);
        $sql_limit = $this->request->variable('limit', 10);
        $sql_limits = $this->request->variable('limit', $this->config['comments_per_page']);
        //comments
        // Comments
        $cmnt_id = $this->request->variable('cmntid', 0);
        $cmnt_video_id = $this->request->variable('v', 0);
        $cmnt_text = utf8_normalize_nfc($this->request->variable('cmnt_text', '', true));
        $mode = $this->request->variable('mode', '');
        $submit = isset($_POST['submit']) ? true : false;
        // Determine board url - we may need it later
        $board_url = generate_board_url() . '/';
        $web_path = defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH ? $board_url : $this->phpbb_root_path;
        if (!$this->config['google_api_key']) {
            if ($this->auth->acl_get('a_')) {
                trigger_error($this->user->lang['NO_KEY_ADMIN']);
            } else {
                trigger_error($this->user->lang['NO_KEY_USER']);
            }
        }
        /**
         * Get youtube video ID from URL
         * From: http://halgatewood.com/php-get-the-youtube-video-id-from-a-youtube-url/
         */
        function getYouTubeIdFromURL($url)
        {
            $pattern = '/(?:youtube\\.com\\/(?:[^\\/]+\\/.+\\/|(?:v|e(?:mbed)?)\\/|.*[?&]v=)|youtu\\.be\\/)([^"&?\\/ ]{11})/i';
            preg_match($pattern, $url, $matches);
            return isset($matches[1]) ? $matches[1] : false;
        }
        $youtube_id = getYouTubeIdFromURL($video_url);
        $jsonURL = file_get_contents("https://www.googleapis.com/youtube/v3/videos?id={$youtube_id}&key={$this->config['google_api_key']}&type=video&part=snippet");
        $json = json_decode($jsonURL);
        if (isset($json->items[0]->snippet)) {
            $video_title = $json->items[0]->snippet->title;
        }
        $sql_ary = array('video_id' => $video_id, 'video_url' => $video_url, 'video_title' => $video_title, 'video_cat_id' => $video_cat_id, 'username' => $username, 'user_id' => $user_id, 'youtube_id' => $youtube_id, 'create_time' => (int) time(), 'video_views' => $video_views);
        $error = $row = array();
        $current_time = time();
        $this->template->assign_vars(array('S_NEW_VIDEO' => $this->auth->acl_get('u_video_post') ? true : false, 'SCRIPT_NAME' => 'video', 'U_VIDEO' => $this->helper->route('dmzx_youtubegallery_controller')));
        $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $this->user->lang['VIDEO_INDEX'], 'U_VIEW_FORUM' => $this->helper->route('dmzx_youtubegallery_controller')));
        switch ($mode) {
            case 'submit':
                // User is a bot?!
                if ($this->user->data['is_bot']) {
                    redirect(append_sid("{$this->phpbb_root_path}index.{$this->phpEx}"));
                }
                $redirect_url = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'submit'));
                // Is a guest?!
                if ($this->user->data['user_id'] == ANONYMOUS) {
                    login_box($redirect_url);
                }
                // Can post?!
                if (!$this->auth->acl_get('u_video_post')) {
                    trigger_error($this->user->lang['UNAUTHED']);
                }
                $l_title = $this->user->lang['VIDEO_SUBMIT'];
                $template_html = 'video_editor.html';
                $s_action = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'submit'));
                $s_hidden_fields = '';
                $form_enctype = '';
                add_form_key('postform');
                // List of categories
                $sql = 'SELECT *
					FROM ' . $this->video_cat_table . '
					ORDER BY video_cat_id DESC';
                $result = $this->db->sql_query($sql);
                while ($row = $this->db->sql_fetchrow($result)) {
                    $this->template->assign_block_vars('cat', array('VIDEO_CAT_ID' => censor_text($row['video_cat_id']), 'VIDEO_CAT_TITLE' => censor_text($row['video_cat_title'])));
                }
                // Start assigning vars for main posting page ...
                $this->template->assign_vars(array('S_USER_ID' => $this->user->data['user_id'], 'S_USERNAME' => $this->user->data['username'], 'S_FORM_ENCTYPE' => $form_enctype, 'S_POST_ACTION' => $s_action, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'ERROR' => sizeof($error) ? implode('<br />', $error) : ''));
                $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $this->user->lang['VIDEO_SUBMIT']));
                add_form_key('postform');
                if ($submit) {
                    if (!check_form_key('postform')) {
                        trigger_error('FORM_INVALID');
                    }
                }
                switch ($submit) {
                    case 'add':
                        if ($video_url == '') {
                            $meta_info = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'submit'));
                            $message = $this->user->lang['NEED_VIDEO_URL'];
                            meta_refresh(3, $meta_info);
                            $message .= '<br /><br />' . sprintf($this->user->lang['PAGE_RETURN'], '<a href="' . $meta_info . '">', '</a>');
                            trigger_error($message);
                        } else {
                            $this->db->sql_query('INSERT INTO ' . $this->video_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary));
                            $u_action = $this->helper->route('dmzx_youtubegallery_controller');
                            $meta_info = $this->helper->route('dmzx_youtubegallery_controller');
                            $message = $this->user->lang['VIDEO_CREATED'];
                            meta_refresh(3, $meta_info);
                            $message .= '<br /><br />' . sprintf($this->user->lang['PAGE_RETURN'], '<a href="' . $meta_info . '">', '</a>');
                            trigger_error($message);
                        }
                        break;
                }
                break;
            case 'comment':
                $l_title = $this->user->lang['VIDEO_CMNT_SUBMIT'];
                $template_html = '@dmzx_youtubegallery/video_cmnt_editor.html';
                if (!$this->config['enable_comments']) {
                    trigger_error($this->user->lang['COMMENTS_DISABLED']);
                }
                // User is a bot?!
                if ($this->user->data['is_bot']) {
                    redirect(append_sid("{$this->phpbb_root_path}index.{$this->phpEx}"));
                }
                // Can post?!
                if (!$this->auth->acl_get('u_video_comment')) {
                    trigger_error($this->user->lang['UNAUTHED']);
                }
                $redirect_url = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'comment', 'v' => (int) $video_id));
                // Is a guest?!
                if ($this->user->data['user_id'] == ANONYMOUS) {
                    login_box($redirect_url);
                }
                if (!function_exists('generate_smilies')) {
                    include $this->phpbb_root_path . 'includes/functions_posting.' . $this->phpEx;
                }
                if (!function_exists('display_custom_bbcodes')) {
                    include $this->phpbb_root_path . 'includes/functions_display.' . $this->phpEx;
                }
                //Settings for comments
                $this->user->setup('posting');
                display_custom_bbcodes();
                generate_smilies('inline', 0);
                $bbcode_status = $this->config['allow_bbcode'] ? true : false;
                $smilies_status = $this->config['allow_smilies'] ? true : false;
                $img_status = $bbcode_status ? true : false;
                $url_status = $this->config['allow_post_links'] ? true : false;
                $flash_status = $bbcode_status && $this->config['allow_post_flash'] ? true : false;
                $quote_status = true;
                $video_id = $this->request->variable('v', 0);
                $uid = $bitfield = $options = '';
                $allow_bbcode = $allow_urls = $allow_smilies = true;
                $s_action = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'comment', 'v' => (int) $video_id));
                $s_hidden_fields = '';
                $form_enctype = '';
                add_form_key('postform');
                // Start assigning vars for main posting page ...
                $this->template->assign_vars(array('VIDEO_ID' => (int) $video_id, 'S_FORM_ENCTYPE' => $form_enctype, 'S_POST_ACTION' => $s_action, 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'ERROR' => sizeof($error) ? implode('<br />', $error) : '', 'S_BBCODE_ALLOWED' => $bbcode_status ? 1 : 0, 'S_SMILIES_ALLOWED' => $smilies_status, 'S_BBCODE_IMG' => $img_status, 'S_BBCODE_URL' => $url_status, 'S_LINKS_ALLOWED' => $url_status, 'S_BBCODE_QUOTE' => $quote_status));
                if (isset($_POST['submit'])) {
                    if (!check_form_key('postform')) {
                        trigger_error('FORM_INVALID');
                    }
                    $video_id = $this->request->variable('v', 0);
                    // Get video to redirect :D
                    $message = $this->request->variable('cmnt_text', '', true);
                    generate_text_for_storage($message, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies);
                    $data = array('cmnt_video_id' => $this->request->variable('cmnt_video_id', 0), 'cmnt_poster_id' => $this->user->data['user_id'], 'cmnt_text' => $message, 'create_time' => time(), 'bbcode_uid' => $uid, 'bbcode_bitfield' => $bitfield, 'bbcode_options' => $options);
                    if ($message == '') {
                        $meta_info = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'comment', 'v' => (int) $video_id));
                        $message = $this->user->lang['NEED_VIDEO_MESSAGE'];
                        meta_refresh(3, $meta_info);
                        $message .= '<br /><br />' . sprintf($this->user->lang['PAGE_RETURN'], '<a href="' . $meta_info . '">', '</a>');
                        trigger_error($message);
                    } else {
                        $this->db->sql_query('INSERT INTO ' . $this->video_cmnts_table . ' ' . $this->db->sql_build_array('INSERT', $data));
                        $meta_info = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'view', 'id' => (int) $video_id));
                        $message = $this->user->lang['COMMENT_CREATED'];
                        meta_refresh(3, $meta_info);
                        $message .= '<br /><br />' . sprintf($this->user->lang['PAGE_RETURN'], '<a href="' . $meta_info . '">', '</a>');
                        trigger_error($message);
                    }
                }
                $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $this->user->lang['VIDEO_CMNT_SUBMIT']));
                break;
            case 'delcmnt':
                if (!$this->auth->acl_get('u_video_comment_delete')) {
                    trigger_error($this->user->lang['UNAUTHED']);
                }
                $video_id = $this->request->variable('v', 0);
                // Get video to redirect :D
                if (confirm_box(true)) {
                    $sql = 'DELETE FROM ' . $this->video_cmnts_table . '
						WHERE cmnt_id = ' . (int) $cmnt_id;
                    $this->db->sql_query($sql);
                    $meta_info = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'view', 'id' => (int) $video_id));
                    $message = $this->user->lang['COMMENT_DELETED_SUCCESS'];
                    meta_refresh(1, $meta_info);
                    $message .= '<br /><br />' . sprintf($this->user->lang['PAGE_RETURN'], '<a href="' . $meta_info . '">', '</a>');
                    trigger_error($message);
                } else {
                    $s_hidden_fields = build_hidden_fields(array('id' => $cmnt_id, 'mode' => 'delcmnt'));
                    confirm_box(false, $this->user->lang['DELETE_COMMENT_CONFIRM'], $s_hidden_fields);
                    $meta_info = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'view', 'id' => (int) $video_id));
                    meta_refresh(1, $meta_info);
                }
                break;
            case 'delete':
                if (!$this->auth->acl_get('u_video_delete')) {
                    trigger_error($this->user->lang['UNAUTHED']);
                }
                $l_title = $this->user->lang['DELETE_VIDEO'];
                if (confirm_box(true)) {
                    $sql = 'DELETE FROM ' . $this->video_table . '
						WHERE video_id = ' . $video_id;
                    $this->db->sql_query($sql);
                    $meta_info = $this->helper->route('dmzx_youtubegallery_controller');
                    $message = $this->user->lang['VIDEO_DELETED'];
                    meta_refresh(3, $meta_info);
                    $message .= '<br /><br />' . sprintf($this->user->lang['PAGE_RETURN'], '<a href="' . $meta_info . '">', '</a>');
                    trigger_error($message);
                } else {
                    $s_hidden_fields = build_hidden_fields(array('mode' => 'delete', 'submit' => true, 'video_id' => $video_id));
                    confirm_box(false, $this->user->lang['DELETE_VIDEO'], $s_hidden_fields);
                    $meta_info = $this->helper->route('dmzx_youtubegallery_controller');
                    $message = $this->user->lang['RETURN_TO_VIDEO_INDEX'];
                    meta_refresh(3, $meta_info);
                    $message .= '<br /><br />' . sprintf($this->user->lang['PAGE_RETURN'], '<a href="' . $meta_info . '">', '</a>');
                    trigger_error($message);
                }
                break;
            case 'view':
                if (!$this->auth->acl_get('u_video_view')) {
                    trigger_error($this->user->lang['VIDEO_UNAUTHED']);
                }
                // Update video view... but only for humans
                if (isset($this->user->data['session_page']) && !$this->user->data['is_bot']) {
                    $sql = 'UPDATE ' . $this->video_table . '
					SET video_views = video_views + 1
					WHERE video_id = ' . $video_id;
                    $this->db->sql_query($sql);
                }
                $sql_ary = array('SELECT' => 'v.*, u.*', 'FROM' => array($this->video_table => 'v', USERS_TABLE => 'u'), 'WHERE' => 'v.video_id = ' . (int) $video_id . ' and u.user_id = v.user_id', 'ORDER_BY' => 'v.video_id DESC');
                $sql = $this->db->sql_build_query('SELECT', $sql_ary);
                $result = $this->db->sql_query($sql);
                $row = $this->db->sql_fetchrow($result);
                $this->db->sql_freeresult($result);
                $page_title = $row['video_title'];
                $user_id = $row['user_id'];
                $flash_status = $this->config['allow_post_flash'] ? true : false;
                $delete_allowed = ($this->auth->acl_get('a_') or $this->auth->acl_get('m_') || $this->user->data['is_registered'] && $this->user->data['user_id'] == $row['user_id'] && $this->auth->acl_get('u_video_delete'));
                $this->template->assign_vars(array('VIDEO_ID' => censor_text($row['video_id']), 'VIDEO_TITLE' => censor_text($row['video_title']), 'VIDEO_VIEWS' => $row['video_views'], 'USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'YOUTUBE_ID' => censor_text($row['youtube_id']), 'VIDEO_TIME' => $this->user->format_date($row['create_time']), 'YOUTUBE_VIDEO' => 'http://www.youtube.com/watch?v=' . $row['youtube_id'], 'VIDEO_LINK' => generate_board_url() . $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'view', 'id' => $row['video_id'])), 'VIDEO_LINK_FLASH' => 'http://www.youtube.com/v/' . $row['youtube_id'], 'U_USER_VIDEOS' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'user_videos', 'user_id' => $this->user->data['user_id'])), 'U_DELETE' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'delete', 'id' => $row['video_id'])), 'DELETE_ALLOW' => $delete_allowed, 'S_BBCODE_FLASH' => $flash_status, 'FLASH_STATUS' => $flash_status ? $this->user->lang['FLASH_IS_ON'] : $this->user->lang['FLASH_IS_OFF'], 'S_VIDEO_WIDTH' => $this->config['video_width'], 'S_VIDEO_HEIGHT' => $this->config['video_height'], 'U_POST_COMMENT' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'comment', 'v' => $row['video_id'])), 'S_ENABLE_COMMENTS' => $this->config['enable_comments'], 'S_POST_COMMENT' => $this->auth->acl_get('u_video_comment')));
                // Comments
                $pagination_url = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'view', 'id' => $video_id));
                $sql_ary = array('SELECT' => 'v.*, cmnt.*, u.username,u.user_colour,u.user_id', 'FROM' => array($this->video_table => 'v', $this->video_cmnts_table => 'cmnt', USERS_TABLE => 'u'), 'WHERE' => 'v.video_id = ' . (int) $video_id . '
						AND cmnt.cmnt_video_id = v.video_id
						AND u.user_id = cmnt.cmnt_poster_id', 'ORDER_BY' => 'cmnt.cmnt_id DESC');
                $sql = $this->db->sql_build_query('SELECT', $sql_ary);
                $result = $this->db->sql_query_limit($sql, $sql_limits, $sql_start);
                while ($row = $this->db->sql_fetchrow($result)) {
                    $delete_cmnt_allowed = ($this->auth->acl_get('a_') or $this->auth->acl_get('m_') || $this->user->data['is_registered'] && $this->user->data['user_id'] == $row['user_id'] && $this->auth->acl_get('u_video_comment_delete'));
                    $text = generate_text_for_display($row['cmnt_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']);
                    $this->template->assign_block_vars('commentrow', array('COMMENT_ID' => $row['cmnt_id'], 'COMMENT_TEXT' => $text, 'COMMENT_TIME' => $this->user->format_date($row['create_time']), 'USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'S_DELETE_ALLOWED' => $delete_cmnt_allowed, 'U_DELETE' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'delcmnt', 'cmntid' => (int) $row['cmnt_id'], 'v' => (int) $row['cmnt_video_id']))));
                }
                $this->db->sql_freeresult($result);
                // We need another query for the video count
                $sql = 'SELECT COUNT(*) as comment_count
				FROM ' . $this->video_cmnts_table . '
				WHERE cmnt_video_id = ' . (int) $video_id;
                $result = $this->db->sql_query($sql);
                $videorow['comment_count'] = $this->db->sql_fetchfield('comment_count');
                $this->db->sql_freeresult($result);
                //Start pagination
                $start = $this->request->variable('start', 0);
                $this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $videorow['comment_count'], $sql_limits, $sql_start);
                $this->template->assign_vars(array('TOTAL_COMMENTS' => $videorow['comment_count'] == 1 ? $this->user->lang['LIST_COMMENT'] : sprintf($this->user->lang['LIST_COMMENTS'], $videorow['comment_count'])));
                //End pagination
                // Count the videos user video ...
                $sql = 'SELECT COUNT(video_id) AS total_videos
				FROM ' . $this->video_table . '
				WHERE user_id = ' . (int) $user_id;
                $result = $this->db->sql_query($sql);
                $total_videos = (int) $this->db->sql_fetchfield('total_videos');
                $this->db->sql_freeresult($result);
                $this->template->assign_vars(array('TOTAL_VIDEOS' => $total_videos));
                // Count the video comments ...
                $sql_cmnts = 'SELECT COUNT(cmnt_id) AS total_comments
				FROM ' . $this->video_cmnts_table . '
				WHERE cmnt_video_id = ' . (int) $video_id;
                $result = $this->db->sql_query($sql_cmnts);
                $total_comments = (int) $this->db->sql_fetchfield('total_comments');
                $this->db->sql_freeresult($result);
                $this->template->assign_vars(array('TOTAL_COMMENTS_TITLE' => $total_comments));
                $l_title = $page_title;
                $template_html = 'video_view.html';
                $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $page_title));
                break;
            case 'cat':
                $sql_limit = $sql_limit > 10 ? 10 : $sql_limit;
                $pagination_url = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'cat', 'id' => $video_cat_ids));
                $sql_ary = array('SELECT' => 'v.*,
				ct.video_cat_title,ct.video_cat_id,
				u.username,u.user_colour,u.user_id', 'FROM' => array($this->video_table => 'v', $this->video_cat_table => 'ct', USERS_TABLE => 'u'), 'WHERE' => 'v.video_cat_id = ' . $video_cat_ids . '
					AND ct.video_cat_id = ' . $video_cat_ids . '
					AND v.user_id = u.user_id', 'ORDER_BY' => 'v.video_id DESC');
                $sql = $this->db->sql_build_query('SELECT', $sql_ary);
                $result = $this->db->sql_query_limit($sql, $sql_limit, $sql_start);
                while ($row = $this->db->sql_fetchrow($result)) {
                    $this->template->assign_block_vars('video', array('VIDEO_TITLE' => $row['video_title'], 'VIDEO_CAT_ID' => $row['video_cat_id'], 'VIDEO_CAT_TITLE' => $row['video_cat_title'], 'VIDEO_VIEWS' => $row['video_views'], 'U_CAT' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'cat', 'id' => $row['video_cat_id'])), 'VIDEO_TIME' => $this->user->format_date($row['create_time']), 'VIDEO_ID' => censor_text($row['video_id']), 'U_VIEW_VIDEO' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'view', 'id' => $row['video_id'])), 'U_POSTER' => append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", array('mode' => 'viewprofile', 'u' => $row['user_id'])), 'USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'S_VIDEO_THUMBNAIL' => 'http://img.youtube.com/vi/' . censor_text($row['youtube_id']) . '/default.jpg'));
                }
                $this->db->sql_freeresult($result);
                // We need another query for the video count
                $sql = 'SELECT COUNT(*) as video_count
				FROM ' . $this->video_table . '
				WHERE video_cat_id = ' . (int) $video_cat_ids;
                $result = $this->db->sql_query($sql);
                $videorow['video_count'] = $this->db->sql_fetchfield('video_count');
                $this->db->sql_freeresult($result);
                $start = $this->request->variable('start', 0);
                $this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $videorow['video_count'], $sql_limit, $sql_start);
                $this->template->assign_vars(array('TOTAL_VIDEOS' => $videorow['video_count'] == 1 ? $this->user->lang['LIST_VIDEO'] : sprintf($this->user->lang['LIST_VIDEOS'], $videorow['video_count'])));
                $sql = 'SELECT *
				FROM ' . $this->video_cat_table . '
				WHERE video_cat_id = ' . (int) $video_cat_ids;
                $result = $this->db->sql_query($sql);
                $row = $this->db->sql_fetchrow($result);
                $this->db->sql_freeresult($result);
                $this->template->assign_vars(array('CAT_NAME' => $row['video_cat_title']));
                $l_title = $row['video_cat_title'];
                $template_html = 'video_cat.html';
                $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $row['video_cat_title']));
                break;
            case 'user_videos':
                $this->template->assign_vars(array('S_SEARCH_USER_VIDEO' => true));
                $sql_limit = $sql_limit > 10 ? 10 : $sql_limit;
                $pagination_url = $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'user_videos', 'user_id' => $user_id));
                $sql_ary = array('SELECT' => 'v.*,
				ct.video_cat_title,ct.video_cat_id,
				u.username,u.user_colour,u.user_id', 'FROM' => array($this->video_table => 'v', $this->video_cat_table => 'ct', USERS_TABLE => 'u'), 'WHERE' => 'u.user_id = v.user_id
					AND ct.video_cat_id = v.video_cat_id
					AND u.user_id = ' . $user_id, 'ORDER_BY' => 'v.video_id DESC');
                $sql = $this->db->sql_build_query('SELECT', $sql_ary);
                $result = $this->db->sql_query_limit($sql, $sql_limit, $sql_start);
                while ($row = $this->db->sql_fetchrow($result)) {
                    $this->template->assign_block_vars('video', array('VIDEO_TITLE' => $row['video_title'], 'VIDEO_CAT_ID' => $row['video_cat_id'], 'VIDEO_CAT_TITLE' => $row['video_cat_title'], 'VIDEO_VIEWS' => $row['video_views'], 'U_CAT' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'cat', 'id' => $row['video_cat_id'])), 'VIDEO_TIME' => $this->user->format_date($row['create_time']), 'VIDEO_ID' => censor_text($row['video_id']), 'U_VIEW_VIDEO' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'view', 'id' => $row['video_id'])), 'U_POSTER' => append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", array('mode' => 'viewprofile', 'u' => $row['user_id'])), 'USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'S_VIDEO_THUMBNAIL' => 'http://img.youtube.com/vi/' . censor_text($row['youtube_id']) . '/default.jpg'));
                }
                $this->db->sql_freeresult($result);
                // We need another query for the video count
                $sql = 'SELECT COUNT(*) as video_count
				FROM ' . $this->video_table . '
				WHERE user_id = ' . $user_id;
                $result = $this->db->sql_query($sql);
                $videorow['video_count'] = $this->db->sql_fetchfield('video_count');
                $this->db->sql_freeresult($result);
                $start = $this->request->variable('start', 0);
                $this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $videorow['video_count'], $sql_limit, $sql_start);
                $this->template->assign_vars(array('TOTAL_VIDEOS' => $videorow['video_count'] == 1 ? $this->user->lang['LIST_VIDEO'] : sprintf($this->user->lang['LIST_VIDEOS'], $videorow['video_count'])));
                $l_title = $this->user->lang['USER_VIDEOS'];
                $template_html = 'video_search.html';
                break;
            default:
                //Listing categories
                $sql = 'SELECT *
				FROM ' . $this->video_cat_table . "\n\t\t\t\tORDER BY video_cat_id";
                $res = $this->db->sql_query($sql);
                while ($row = $this->db->sql_fetchrow($res)) {
                    $this->template->assign_block_vars('videocat', array('VIDEO_CAT_ID' => $row['video_cat_id'], 'VIDEO_CAT_TITLE' => $row['video_cat_title'], 'U_CAT' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'cat', 'id' => $row['video_cat_id']))));
                }
                // Count the videos ...
                $sql = 'SELECT COUNT(video_id) AS total_videos
				FROM ' . $this->video_table;
                $result = $this->db->sql_query($sql);
                $total_videos = (int) $this->db->sql_fetchfield('total_videos');
                $this->db->sql_freeresult($result);
                // Count the videos categories ...
                $sql = 'SELECT COUNT(video_cat_id) AS total_categories
				FROM ' . $this->video_cat_table . '';
                $result = $this->db->sql_query($sql);
                $total_categories = (int) $this->db->sql_fetchfield('total_categories');
                $this->db->sql_freeresult($result);
                // Count the videos views ...
                $sql = 'SELECT SUM(video_views) AS total_views
				FROM ' . $this->video_table;
                $result = $this->db->sql_query($sql);
                $total_views = (int) $this->db->sql_fetchfield('total_views');
                $this->db->sql_freeresult($result);
                $total_videos;
                // Count the videos comments ...
                $sql = 'SELECT COUNT(cmnt_id) AS total_comments
				FROM ' . $this->video_cmnts_table;
                $result = $this->db->sql_query($sql);
                $total_comments = (int) $this->db->sql_fetchfield('total_comments');
                $this->db->sql_freeresult($result);
                $l_title = $this->user->lang['VIDEO_INDEX'];
                $template_html = 'video_body.html';
                $l_total_video_s = $total_videos == 0 ? 'TOTAL_VIDEO_ZERO' : 'TOTAL_VIDEOS_OTHER';
                $l_total_category_s = $total_categories == 0 ? 'TOTAL_CATEGORY_ZERO' : 'TOTAL_CATEGORIES_OTHER';
                $l_total_view_s = $total_views == 0 ? 'TOTAL_VIEW_ZERO' : 'TOTAL_VIEWS_OTHER';
                $l_total_comment_s = $total_comments == 0 ? 'TOTAL_COMMENT_ZERO' : 'TOTAL_COMMENTS_OTHER';
                $this->template->assign_vars(array('U_VIDEO_SUBMIT' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'submit')), 'VIDEOSUBMIT' => $this->auth->acl_get('u_video_post'), 'U_MY_VIDEOS' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'user_videos', 'user_id' => $this->user->data['user_id'])), 'BUTTON_VIDEO_NEW' => "{$web_path}styles/" . $this->user->lang_name . '/button_video_new.gif', 'TOTAL_VIDEOS_INDEX' => sprintf($this->user->lang[$l_total_video_s], $total_videos), 'TOTAL_CATEGORIES' => sprintf($this->user->lang[$l_total_category_s], $total_categories), 'TOTAL_VIEWS' => sprintf($this->user->lang[$l_total_view_s], $total_views), 'TOTAL_COMMENTS' => sprintf($this->user->lang[$l_total_comment_s], $total_comments)));
                $sql_limit = $sql_limit > 10 ? 10 : $sql_limit;
                $pagination_url = $this->helper->route('dmzx_youtubegallery_controller');
                $sql_ary = array('SELECT' => 'v.*,
				ct.video_cat_title,ct.video_cat_id,
				u.username,u.user_colour,u.user_id', 'FROM' => array($this->video_table => 'v', $this->video_cat_table => 'ct', USERS_TABLE => 'u'), 'WHERE' => 'ct.video_cat_id = v.video_cat_id AND u.user_id = v.user_id', 'ORDER_BY' => 'v.video_id DESC');
                $sql = $this->db->sql_build_query('SELECT', $sql_ary);
                $result = $this->db->sql_query_limit($sql, $sql_limit, $sql_start);
                while ($row = $this->db->sql_fetchrow($result)) {
                    $this->template->assign_block_vars('video', array('VIDEO_TITLE' => $row['video_title'], 'VIDEO_CAT_ID' => $row['video_cat_id'], 'VIDEO_CAT_TITLE' => $row['video_cat_title'], 'VIDEO_VIEWS' => $row['video_views'], 'U_CAT' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'cat', 'id' => $row['video_cat_id'])), 'VIDEO_TIME' => $this->user->format_date($row['create_time']), 'VIDEO_ID' => censor_text($row['video_id']), 'U_VIEW_VIDEO' => $this->helper->route('dmzx_youtubegallery_controller', array('mode' => 'view', 'id' => $row['video_id'])), 'U_POSTER' => append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", array('mode' => 'viewprofile', 'u' => $row['user_id'])), 'USERNAME' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']), 'YOUTUBE_ID' => censor_text($row['youtube_id'])));
                }
                $this->db->sql_freeresult($result);
                // We need another query for the video count
                $sql = 'SELECT COUNT(*) as video_count
				FROM ' . $this->video_table;
                $result = $this->db->sql_query($sql);
                $videorow['video_count'] = $this->db->sql_fetchfield('video_count');
                $this->db->sql_freeresult($result);
                $start = $this->request->variable('start', 0);
                $this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $videorow['video_count'], $sql_limit, $sql_start);
                $this->template->assign_vars(array('TOTAL_VIDEOS' => $videorow['video_count'] == 1 ? $this->user->lang['LIST_VIDEO'] : sprintf($this->user->lang['LIST_VIDEOS'], $videorow['video_count'])));
                break;
        }
        if (!$row) {
            $this->template->assign_vars(array('NO_ENTRY' => $this->user->lang['NO_VIDEOS']));
        }
        // Output page
        page_header($l_title, false);
        $this->template->set_filenames(array('body' => $template_html));
        make_jumpbox(append_sid("{$this->phpbb_root_path}viewforum.{$this->phpEx}"));
        page_footer();
    }
Exemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->user->session_begin();
     $this->user->setup(array('common', 'acp/common', 'cli'));
     $update_info = $this->install_config->get('update_info_unprocessed', []);
     $version_from = !empty($update_info) ? $update_info['version']['from'] : $this->config['version_update_from'];
     if (!empty($version_from)) {
         $update_extensions = $this->iohandler->get_input('update-extensions', []);
         // Create list of default extensions that need to be enabled in update
         $default_update_extensions = [];
         foreach (self::$default_extensions_update as $version => $extensions) {
             if ($this->update_helper->phpbb_version_compare($version_from, $version, '<=')) {
                 $default_update_extensions = array_merge($default_update_extensions, $extensions);
             }
         }
         $all_available_extensions = $this->extension_manager->all_available();
         $i = $this->install_config->get('update_extensions_index', 0);
         $available_extensions = array_slice($all_available_extensions, $i);
         // Update available extensions
         foreach ($available_extensions as $ext_name => $ext_path) {
             // Update extensions if:
             //	1) Extension is currently enabled
             //	2) Extension was implicitly defined as needing an update
             //	3) Extension was newly added as default phpBB extension in
             //		this update and should be enabled by default.
             if ($this->extension_manager->is_enabled($ext_name) || in_array($ext_name, $update_extensions) || in_array($ext_name, $default_update_extensions)) {
                 try {
                     $extension_enabled = $this->extension_manager->is_enabled($ext_name);
                     if ($extension_enabled) {
                         $this->extension_manager->disable($ext_name);
                     }
                     $this->extension_manager->enable($ext_name);
                     $extensions = $this->get_extensions();
                     if (isset($extensions[$ext_name]) && $extensions[$ext_name]['ext_active']) {
                         // Create log
                         $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_UPDATE', time(), array($ext_name));
                         $this->iohandler->add_success_message(array('CLI_EXTENSION_UPDATE_SUCCESS', $ext_name));
                     } else {
                         $this->iohandler->add_log_message('CLI_EXTENSION_UPDATE_FAILURE', array($ext_name));
                     }
                     // Disable extensions if it was disabled by the admin before
                     if (!$extension_enabled && !in_array($ext_name, $default_update_extensions)) {
                         $this->extension_manager->disable($ext_name);
                     }
                 } catch (\Exception $e) {
                     // Add fail log and continue
                     $this->iohandler->add_log_message('CLI_EXTENSION_UPDATE_FAILURE', array($ext_name));
                 }
             }
             $i++;
             // Stop execution if resource limit is reached
             if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) {
                 break;
             }
         }
         $this->install_config->set('update_extensions_index', $i);
         if ($i < sizeof($all_available_extensions)) {
             throw new resource_limit_reached_exception();
         }
     }
     $this->config->delete('version_update_from');
     $this->cache->purge();
     $this->config->increment('assets_version', 1);
 }