当前位置: 首页>>代码示例>>PHP>>正文


PHP user::setup方法代码示例

本文整理汇总了PHP中phpbb\user::setup方法的典型用法代码示例。如果您正苦于以下问题:PHP user::setup方法的具体用法?PHP user::setup怎么用?PHP user::setup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在phpbb\user的用法示例。


在下文中一共展示了user::setup方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  * {@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');
 }
开发者ID:007durgesh219,项目名称:phpbb,代码行数:31,代码来源:notify_user.php

示例2: file

    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'];
    }
开发者ID:bb3mobi,项目名称:attachments,代码行数:33,代码来源:route.php

示例3: run

 /**
  * {@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();
     }
 }
开发者ID:phpbb,项目名称:phpbb,代码行数:41,代码来源:install_extensions.php

示例4: avatar_crop

    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();
    }
开发者ID:bb3mobi,项目名称:AvatarUpload,代码行数:65,代码来源:crop.php

示例5: handle_video


//.........这里部分代码省略.........
                            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);
开发者ID:newbeetle,项目名称:youtubegallery,代码行数:67,代码来源:youtubegallery.php

示例6: run

 /**
  * {@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);
 }
开发者ID:phpbb,项目名称:phpbb,代码行数:67,代码来源:update_extensions.php


注:本文中的phpbb\user::setup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。