コード例 #1
0
ファイル: diff.php プロジェクト: Sajaki/customisation-db
 /**
  * constructor
  *
  * @param string $renderer_type Classname of the renderer to use
  */
 public function __construct($renderer_type = 'diff_renderer_unified')
 {
     $this->renderer_type = $renderer_type;
     $this->ext_root_path = \titania::$root_path;
     phpbb::_include('diff/diff', false, 'diff');
     phpbb::_include('diff/engine', false, 'diff');
     phpbb::_include('diff/renderer', false, 'diff');
     phpbb::_include('functions_compress', false, 'compress');
 }
コード例 #2
0
/**
* Generate text for display
* Returns the result of generate_text_for_display() from phpBB's functions_content.php file, but has hacks in place to let us use our own bbcode.html file
*
* @param mixed $text
* @param mixed $uid
* @param mixed $bitfield
* @param mixed $flags
* @return mixed
*/
function titania_generate_text_for_display($text, $uid, $bitfield, $flags)
{
    if (titania::$hook->call_hook(__FUNCTION__, $text, $uid, $bitfield, $flags)) {
        if (titania::$hook->hook_return(__FUNCTION__)) {
            return titania::$hook->hook_return_result(__FUNCTION__);
        }
    }
    global $phpbb_root_path;
    phpbb::_include('bbcode', false, 'bbcode');
    // HAX
    $phpbb_root_path = TITANIA_ROOT;
    $return = generate_text_for_display($text, $uid, $bitfield, $flags);
    // UnHAX
    $phpbb_root_path = PHPBB_ROOT_PATH;
    return $return;
}
コード例 #3
0
    /**
     * Send Notifications
     *
     * Using this function:
     * Call this function when you know the Object type, object id, and the email
     * template name.
     * Sample usage:
     *
     * <code>
     *
     * $object_type = SOME_OBJECT_CONSTANT_TYPE;
     * $obhect)id = 242974;
     *
     * titania_subscriptions::send_notifications($object_type, $object_id, 'mod_subscribe', array(
     * 		'OBJECT_NAME'	=> 'Some MOD',
     * ));
     *
     * </code>
     *
     * The vars parameter will be used in the messanger assign vars, which will act
     * as the common vars when sending out the notifications. Data such as the MOD's
     * or Style's name should go here, what action was taken, etc. The usernaeme and
     * emails of the recepiants will be personalised by the function. Ensure the
     * email template has the {USERNAME} var present.
     *
     * @param $exclude_user User_id of the one who posted the item to exclude them from the sending
     *
     */
    public static function send_notifications($object_type, $object_id, $email_tpl, $vars, $exclude_user = false)
    {
        $sql = 'SELECT w.watch_user_id, w.watch_type, u.user_id, u.username, u.user_email
				FROM ' . TITANIA_WATCH_TABLE . ' w, ' . USERS_TABLE . ' u
				WHERE w.watch_user_id = u.user_id ';
        if (is_array($object_type) || is_array($object_id)) {
            // Both needs to be arrays if one is and they need to have the same number of elements.
            if (!is_array($object_type) || !is_array($object_id) || sizeof($object_type) != sizeof($object_id)) {
                return;
            }
            $sql_objects = '';
            foreach ($object_type as $key => $value) {
                $sql_objects .= ($sql_objects == '' ? '' : ' OR ') . '(w.watch_object_type = ' . (int) $value . '
							AND w.watch_object_id = ' . (int) $object_id[$key] . ')';
            }
            $sql .= 'AND (' . $sql_objects . ')';
            unset($sql_objects);
        } else {
            $sql .= 'AND w.watch_object_type = ' . (int) $object_type . '
						AND w.watch_object_id = ' . (int) $object_id;
        }
        $sql .= $exclude_user ? ' AND w.watch_user_id <> ' . (int) $exclude_user : '';
        $result = phpbb::$db->sql_query($sql);
        // Throw everything here
        $user_data = array();
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            // Use user_id for the keys to not send duplicates.
            $user_data[$row['user_id']] = array('username' => $row['username'], 'user_email' => $row['user_email'], 'watch_type' => $row['watch_type']);
        }
        // No one subscribed? We're done.
        if (!sizeof($user_data)) {
            return;
        }
        // You wanted the email template parsed? Well here you go.
        $template = file_get_contents(TITANIA_ROOT . 'language/en/email/' . $email_tpl);
        foreach ($vars as $var => $replace) {
            if (strtoupper($var) == 'SUBJECT') {
                continue;
            }
            $template = str_replace('{' . strtoupper($var) . '}', $replace, $template);
        }
        // Steal the subject if it exists
        $subject = '';
        if (($subject_start = strpos($template, 'Subject:')) !== false) {
            $subject_length = strpos($template, "\n", $subject_start) - $subject_start;
            $subject = substr($template, $subject_start, $subject_length);
            $template = substr($template, 0, $subject_start) . substr($template, $subject_start + $subject_length);
        }
        $subject = isset($vars['SUBJECT']) ? $vars['SUBJECT'] : $subject;
        $subject = $subject ? $subject : phpbb::$user->lang['SUBSCRIPTION_NOTIFICATION'];
        // Send to each user
        // Add a new case statment for each subscription type
        foreach ($user_data as $data) {
            // Generic messages that will be sent to each module individually
            $message = str_replace('{USERNAME}', $data['username'], $template);
            /*
             * Switch between the types.
             * ------------------------------------------
             * When adding a type, the final message will
             * be stored in $message, and the subject is
             * stored in $vars['SUBJECT'].
             */
            switch ($data['watch_type']) {
                case SUBSCRIPTION_EMAIL:
                    // Only make the object if we need it
                    phpbb::_include('functions_messenger', false, 'messenger');
                    $messenger = new messenger();
                    $messenger->headers('X-AntiAbuse: Board servername - ' . phpbb::$config['server_name']);
                    $messenger->headers('X-AntiAbuse: User_id - ' . phpbb::$user->data['user_id']);
                    $messenger->headers('X-AntiAbuse: Username - ' . phpbb::$user->data['username']);
                    // HAX
                    $user_lang_path = phpbb::$user->lang_path;
                    phpbb::$user->lang_path = TITANIA_ROOT . 'language/';
                    $messenger->template('subscribe_generic');
                    // Reverse HAX
                    phpbb::$user->lang_path = $user_lang_path;
                    $messenger->to($data['user_email'], $data['username']);
                    $messenger->assign_vars(array_merge($vars, array('SUBJECT' => $subject, 'MESSAGE' => $message)));
                    $messenger->send();
                    $messenger->save_queue();
                    break;
            }
        }
        return;
    }
コード例 #4
0
ファイル: hook.php プロジェクト: Sajaki/customisation-db
* This file is part of the phpBB Customisation Database package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
/**
 * @ignore
 */
if (!defined('IN_PHPBB')) {
    exit;
}
phpbb::_include('hooks/index', false, 'phpbb_hook');
/**
* Titania Hook Class
*
* Same as phpBB's hook class, but not requiring the hooks to be registered at class construction time
*/
class titania_hook extends phpbb_hook
{
    /**
     * Initialize hook class.
     */
    public function titania_hook()
    {
        if (function_exists('phpbb_hook_register')) {
            phpbb_hook_register($this);
        }
コード例 #5
0
ファイル: email.php プロジェクト: Gfksx/customisation-db
    /**
     * Ignore this for now!
     * Moving it to the side for later...
     */
    public function email_friend()
    {
        phpbb::$user->add_lang('memberlist');
        if (!phpbb::$config['email_enable']) {
            titania::error_box('ERROR', 'EMAIL_DISABLED', TITANIA_ERROR, HEADER_SERVICE_UNAVAILABLE);
            return false;
        }
        if (!phpbb::$user->data['is_registered'] || phpbb::$user->data['is_bot'] || !phpbb::$auth->acl_get('u_sendemail')) {
            if (phpbb::$user->data['user_id'] == ANONYMOUS) {
                login_box(titania::$page, phpbb::$user->lang['ERROR_CONTRIB_EMAIL_FRIEND']);
            }
            titania::error_box('ERROR', 'ERROR_CONTRIB_EMAIL_FRIEND', TITANIA_ERROR, HEADER_FORBIDDEN);
            return false;
        }
        // Are we trying to abuse the facility?
        if (titania::$time - phpbb::$user->data['user_emailtime'] < phpbb::$config['flood_interval']) {
            trigger_error('FLOOD_EMAIL_LIMIT', E_USER_NOTICE);
        }
        $name = utf8_normalize_nfc(request_var('name', '', true));
        $email = request_var('email', '');
        $email_lang = request_var('lang', phpbb::$config['default_lang']);
        $message = utf8_normalize_nfc(request_var('message', '', true));
        $cc = isset($_POST['cc_email']) ? true : false;
        $submit = isset($_POST['submit']) ? true : false;
        add_form_key('contrib_email');
        phpbb::$template->assign_vars(array('S_LANG_OPTIONS' => language_select($email_lang), 'S_POST_ACTION' => phpbb::append_sid(titania::$page, array('id' => 'email', 'contrib_id' => $this->contrib_id))));
        $error = array();
        if ($submit) {
            if (!check_form_key('contrib_email')) {
                $error[] = 'FORM_INVALID';
            }
            if (!$email || !preg_match('/^' . get_preg_expression('email') . '$/i', $email)) {
                $error[] = 'EMPTY_ADDRESS_EMAIL';
            }
            if (!$name) {
                $error[] = 'EMPTY_NAME_EMAIL';
            }
            if (!empty($error)) {
                titania::error_box('ERROR', $error, TITANIA_ERROR);
                return false;
            }
            phpbb::_include('functions_messenger', false, 'messenger');
            $sql = 'UPDATE ' . USERS_TABLE . '
				SET user_emailtime = ' . titania::$time . '
				WHERE user_id = ' . (int) phpbb::$user->data['user_id'];
            $result = phpbb::$db->sql_query($sql);
            $mail_to_users = array();
            $mail_to_users[] = array('email_lang' => $email_lang, 'email' => $email, 'name' => $name);
            // Ok, now the same email if CC specified, but without exposing the users email address
            if ($cc) {
                $mail_to_users[] = array('email_lang' => phpbb::$user->data['user_lang'], 'email' => phpbb::$user->data['user_email'], 'name' => phpbb::$user->data['username']);
            }
            $lang_path = phpbb::$user->lang_path;
            phpbb::$user->set_custom_lang_path(titania::$config->language_path);
            $messenger = new messenger(false);
            foreach ($mail_to_users as $row) {
                $messenger->template('contrib_recommend', $row['email_lang']);
                $messenger->replyto(phpbb::$user->data['user_email']);
                $messenger->to($row['email'], $row['name']);
                $messenger->headers('X-AntiAbuse: Board servername - ' . phpbb::$config['server_name']);
                $messenger->headers('X-AntiAbuse: User_id - ' . (int) phpbb::$user->data['user_id']);
                $messenger->headers('X-AntiAbuse: Username - ' . phpbb::$user->data['username']);
                $messenger->headers('X-AntiAbuse: User IP - ' . phpbb::$user->ip);
                $messenger->assign_vars(array('BOARD_CONTACT' => phpbb::$config['board_contact'], 'TO_USERNAME' => htmlspecialchars_decode($name), 'FROM_USERNAME' => htmlspecialchars_decode(phpbb::$user->data['username']), 'MESSAGE' => htmlspecialchars_decode($message), 'CONTRIB_NAME' => htmlspecialchars_decode($this->contrib_name), 'U_CONTRIB' => phpbb::append_sid(titania::$page, array('contrib_id' => $this->contrib_id, 'id' => 'details'), true, '')));
                $messenger->send(NOTIFY_EMAIL);
            }
            phpbb::$user->set_custom_lang_path($lang_path);
            titania::error_box('SUCCESS', 'EMAIL_SENT', TITANIA_SUCCESS);
            return true;
        }
        return false;
    }
コード例 #6
0
ファイル: topic.php プロジェクト: Noxwizard/customisation-db
 /**
  * Assign details
  *
  * A little different from those in other classes, this one only returns the info ready for output
  */
 public function assign_details()
 {
     // Tracking check
     $last_read_mark = titania_tracking::get_track(TITANIA_TOPIC, $this->topic_id, true);
     $last_read_mark = max($last_read_mark, titania_tracking::find_last_read_mark($this->additional_unread_fields, $this->topic_type, $this->parent_id));
     $this->unread = $this->topic_last_post_time > $last_read_mark ? true : false;
     $folder_img = $folder_alt = '';
     $this->topic_folder_img($folder_img, $folder_alt);
     phpbb::_include('functions_display', 'topic_generate_pagination');
     // To find out if we have any posts that need approval
     $approved = titania_count::from_db($this->topic_posts, titania_count::get_flags(TITANIA_ACCESS_PUBLIC, false, false));
     $total = titania_count::from_db($this->topic_posts, titania_count::get_flags(TITANIA_ACCESS_PUBLIC, false, true));
     $details = array('TOPIC_ID' => $this->topic_id, 'TOPIC_TYPE' => $this->topic_type, 'TOPIC_ACCESS' => $this->topic_access, 'TOPIC_STATUS' => $this->topic_status, 'TOPIC_STICKY' => $this->topic_sticky, 'TOPIC_LOCKED' => $this->topic_locked, 'POSTS_APPROVED' => phpbb::$auth->acl_get('u_titania_mod_post_mod') && $total > $approved ? false : true, 'TOPIC_APPROVED' => phpbb::$auth->acl_get('u_titania_mod_post_mod') ? $this->topic_approved : true, 'TOPIC_REPORTED' => phpbb::$auth->acl_get('u_titania_mod_post_mod') ? $this->topic_reported : false, 'TOPIC_ASSIGNED' => $this->topic_assigned, 'TOPIC_REPLIES' => $this->get_postcount() - 1, 'TOPIC_VIEWS' => $this->topic_views, 'TOPIC_SUBJECT' => censor_text($this->topic_subject), 'TOPIC_FIRST_POST_ID' => $this->topic_first_post_id, 'TOPIC_FIRST_POST_USER_ID' => $this->topic_first_post_user_id, 'TOPIC_FIRST_POST_USER_COLOUR' => $this->topic_first_post_user_colour, 'TOPIC_FIRST_POST_USER_FULL' => get_username_string('full', $this->topic_first_post_user_id, $this->topic_first_post_username, $this->topic_first_post_user_colour, false, phpbb::append_sid('memberlist', 'mode=viewprofile')), 'TOPIC_FIRST_POST_TIME' => phpbb::$user->format_date($this->topic_first_post_time), 'TOPIC_LAST_POST_ID' => $this->topic_last_post_id, 'TOPIC_LAST_POST_USER_ID' => $this->topic_last_post_user_id, 'TOPIC_LAST_POST_USER_COLOUR' => $this->topic_last_post_user_colour, 'TOPIC_LAST_POST_USER_FULL' => get_username_string('full', $this->topic_last_post_user_id, $this->topic_last_post_username, $this->topic_last_post_user_colour, false, phpbb::append_sid('memberlist', 'mode=viewprofile')), 'TOPIC_LAST_POST_TIME' => phpbb::$user->format_date($this->topic_last_post_time), 'TOPIC_LAST_POST_SUBJECT' => censor_text($this->topic_last_post_subject), 'PAGINATION' => topic_generate_pagination($this->get_postcount() - 1, titania_url::append_url($this->get_url())), 'U_NEWEST_POST' => $this->unread ? titania_url::append_url($this->get_url(), array('view' => 'unread', '#' => 'unread')) : '', 'U_VIEW_TOPIC' => $this->get_url(), 'U_VIEW_LAST_POST' => titania_url::append_url($this->get_url(), array('p' => $this->topic_last_post_id, '#p' => $this->topic_last_post_id)), 'S_UNREAD_TOPIC' => $this->unread ? true : false, 'S_ACCESS_TEAMS' => $this->topic_access == TITANIA_ACCESS_TEAMS ? true : false, 'S_ACCESS_AUTHORS' => $this->topic_access == TITANIA_ACCESS_AUTHORS ? true : false, 'FOLDER_IMG' => phpbb::$user->img($folder_img, $folder_alt), 'FOLDER_IMG_SRC' => phpbb::$user->img($folder_img, $folder_alt, false, '', 'src'), 'FOLDER_IMG_ALT' => phpbb::$user->lang[$folder_alt], 'FOLDER_IMG_WIDTH' => phpbb::$user->img($folder_img, '', false, '', 'width'), 'FOLDER_IMG_HEIGHT' => phpbb::$user->img($folder_img, '', false, '', 'height'));
     // Hooks
     titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $details, $this);
     return $details;
 }
コード例 #7
0
    /**
     * Install a style on the demo board.
     *
     * @param string $phpbb_root_path
     * @param mixed contrib object
     */
    public function install_demo_style($phpbb_root_path, $contrib)
    {
        phpbb::$user->add_lang('acp/styles');
        if ($phpbb_root_path[strlen($phpbb_root_path) - 1] != '/') {
            $phpbb_root_path .= '/';
        }
        if (!is_dir($phpbb_root_path) || !file_exists($phpbb_root_path . 'config.' . PHP_EXT)) {
            $this->error[] = 'PATH_INVALID';
            return false;
        }
        include $phpbb_root_path . 'config.' . PHP_EXT;
        $sql_db = !empty($dbms) ? 'dbal_' . basename($dbms) : 'dbal';
        // Is this DBAL loaded?
        phpbb::_include('db/' . $dbms, false, $sql_db);
        // Instantiate DBAL class
        $db = new $sql_db();
        // Connect to demo board DB
        $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport);
        // We do not need this any longer, unset for safety purposes
        unset($dbpasswd);
        if (empty($this->unzip_dir)) {
            // Extract zip.
            $this->unzip_dir = titania::$config->contrib_temp_path . basename($this->original_zip, 'zip') . '/';
            // Clear out old stuff if there is anything here...
            $this->rmdir_recursive($this->unzip_dir);
            // Unzip to our temp directory
            $this->extract($this->original_zip, $this->unzip_dir);
        }
        $package_root = $this->find_root(false, 'style.cfg');
        $stylecfg = parse_cfg_file($this->unzip_dir . $package_root . '/style.cfg');
        $style_root = $phpbb_root_path . 'styles/' . $contrib->contrib_id . '/';
        $this->mvdir_recursive($this->unzip_dir . $package_root, $style_root, false);
        $this->rmdir_recursive($this->unzip_dir);
        $variables = array('db', 'phpbb_root_path');
        // Let's get lazy.
        foreach ($variables as $variable) {
            ${'_' . $variable} = $GLOBALS[$variable];
            $GLOBALS[$variable] = ${$variable};
        }
        // Get the acp_styles class.
        phpbb::_include('acp/acp_styles', false, 'acp_styles');
        if (!defined('TEMPLATE_BITFIELD')) {
            // Hardcoded template bitfield to add for new templates
            $bitfield = new bitfield();
            $bitfield->set(0);
            $bitfield->set(1);
            $bitfield->set(2);
            $bitfield->set(3);
            $bitfield->set(4);
            $bitfield->set(8);
            $bitfield->set(9);
            $bitfield->set(11);
            $bitfield->set(12);
            define('TEMPLATE_BITFIELD', $bitfield->get_base64());
            unset($bitfield);
        }
        $styles = new acp_styles();
        // Fill the configuration variables
        $styles->style_cfg = $styles->template_cfg = $styles->theme_cfg = $styles->imageset_cfg = '
#
# phpBB {MODE} configuration file
#
# @package phpBB3
# @copyright (c) 2005 phpBB Group
# @license http://opensource.org/licenses/gpl-license.php GNU Public License
#
#
# At the left is the name, please do not change this
# At the right the value is entered
# For on/off options the valid values are on, off, 1, 0, true and false
#
# Values get trimmed, if you want to add a space in front or at the end of
# the value, then enclose the value with single or double quotes.
# Single and double quotes do not need to be escaped.
#
#

# General Information about this {MODE}
name = {NAME}
copyright = {COPYRIGHT}
version = {VERSION}
';
        $styles->theme_cfg .= '
# Some configuration options

#
# You have to turn this option on if you want to use the
# path template variables ({T_IMAGESET_PATH} for example) within
# your css file.
# This is mostly the case if you want to use language specific
# images within your css file.
#
parse_css_file = {PARSE_CSS_FILE}
';
        $styles->template_cfg .= '
# Some configuration options

#
# You can use this function to inherit templates from another template.
# The template of the given name has to be installed.
# Templates cannot inherit from inheriting templates.
#';
        $styles->imageset_keys = array('logos' => array('site_logo'), 'buttons' => array('icon_back_top', 'icon_contact_aim', 'icon_contact_email', 'icon_contact_icq', 'icon_contact_jabber', 'icon_contact_msnm', 'icon_contact_pm', 'icon_contact_yahoo', 'icon_contact_www', 'icon_post_delete', 'icon_post_edit', 'icon_post_info', 'icon_post_quote', 'icon_post_report', 'icon_user_online', 'icon_user_offline', 'icon_user_profile', 'icon_user_search', 'icon_user_warn', 'button_pm_forward', 'button_pm_new', 'button_pm_reply', 'button_topic_locked', 'button_topic_new', 'button_topic_reply'), 'icons' => array('icon_post_target', 'icon_post_target_unread', 'icon_topic_attach', 'icon_topic_latest', 'icon_topic_newest', 'icon_topic_reported', 'icon_topic_unapproved', 'icon_friend', 'icon_foe'), 'forums' => array('forum_link', 'forum_read', 'forum_read_locked', 'forum_read_subforum', 'forum_unread', 'forum_unread_locked', 'forum_unread_subforum', 'subforum_read', 'subforum_unread'), 'folders' => array('topic_moved', 'topic_read', 'topic_read_mine', 'topic_read_hot', 'topic_read_hot_mine', 'topic_read_locked', 'topic_read_locked_mine', 'topic_unread', 'topic_unread_mine', 'topic_unread_hot', 'topic_unread_hot_mine', 'topic_unread_locked', 'topic_unread_locked_mine', 'sticky_read', 'sticky_read_mine', 'sticky_read_locked', 'sticky_read_locked_mine', 'sticky_unread', 'sticky_unread_mine', 'sticky_unread_locked', 'sticky_unread_locked_mine', 'announce_read', 'announce_read_mine', 'announce_read_locked', 'announce_read_locked_mine', 'announce_unread', 'announce_unread_mine', 'announce_unread_locked', 'announce_unread_locked_mine', 'global_read', 'global_read_mine', 'global_read_locked', 'global_read_locked_mine', 'global_unread', 'global_unread_mine', 'global_unread_locked', 'global_unread_locked_mine', 'pm_read', 'pm_unread'), 'polls' => array('poll_left', 'poll_center', 'poll_right'), 'ui' => array('upload_bar'), 'user' => array('user_icon1', 'user_icon2', 'user_icon3', 'user_icon4', 'user_icon5', 'user_icon6', 'user_icon7', 'user_icon8', 'user_icon9', 'user_icon10'));
        // Define references.
        $error = array();
        $style_id = 0;
        $style_row = array('install_name' => $stylecfg['name'], 'install_copyright' => $stylecfg['copyright'], 'template_id' => 0, 'template_name' => $stylecfg['name'], 'template_copyright' => $stylecfg['copyright'], 'theme_id' => 0, 'theme_name' => $stylecfg['name'], 'theme_copyright' => $stylecfg['copyright'], 'imageset_id' => 0, 'imageset_name' => $stylecfg['name'], 'imageset_copyright' => $stylecfg['copyright'], 'store_db' => 0, 'style_active' => 1, 'style_default' => 0);
        // Install the style.
        // (&$error, $action, $root_path, &$id, $name, $path, $copyright, $active, $default, &$style_row, $template_root_path = false, $template_path = false, $theme_root_path = false, $theme_path = false, $imageset_root_path = false, $imageset_path = false)
        if (!$styles->install_style($error, 'install', $style_root, $style_id, $stylecfg['name'], $contrib->contrib_id, $stylecfg['copyright'], true, false, $style_row)) {
            if ($error != array(phpbb::$user->lang['STYLE_ERR_NAME_EXIST'])) {
                $this->error = array_merge($this->error, $error);
            } else {
                $sql = 'SELECT style_id
					FROM ' . STYLES_TABLE . "\n\t\t\t\t\tWHERE style_name = '" . $db->sql_escape(basename($stylecfg['name'])) . "'";
                $db->sql_query($sql);
                $style_id = $db->sql_fetchfield('style_id');
                $db->sql_freeresult();
            }
        }
        // Have UMIL refresh the template, theme, imageset
        phpbb::_include('../umil/umil', false, 'umil');
        $umil = new umil(true, $db);
        $umil->cache_purge('template', $style_id);
        $umil->cache_purge('theme', $style_id);
        $umil->cache_purge('imageset', $style_id);
        foreach ($variables as $variable) {
            $GLOBALS[$variable] = ${'_' . $variable};
        }
        return $style_id;
    }
コード例 #8
0
ファイル: queue.php プロジェクト: Sajaki/customisation-db
    /**
     * Send the approve/deny notification
     */
    private function send_approve_deny_notification($approve = true)
    {
        $this->user->add_lang_ext('phpbb/titania', 'manage');
        phpbb::_include('functions_privmsgs', 'submit_pm');
        // Need some stuff
        $contrib = new titania_contribution();
        $contrib->load((int) $this->contrib_id);
        $revision = new titania_revision($contrib, $this->revision_id);
        $revision->load();
        // Generate the authors list to send it to
        $authors = array($contrib->contrib_user_id => 'to');
        $sql = 'SELECT user_id FROM ' . TITANIA_CONTRIB_COAUTHORS_TABLE . '
			WHERE contrib_id = ' . (int) $this->contrib_id . '
				AND active = 1';
        $result = phpbb::$db->sql_query($sql);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            $authors[$row['user_id']] = 'to';
        }
        phpbb::$db->sql_freeresult($result);
        // Subject
        $subject = sprintf(phpbb::$user->lang[$contrib->type->validation_subject], $contrib->contrib_name, $revision->revision_version);
        // Message
        $notes = $this->validation_notes;
        message::decode($notes, $this->validation_notes_uid);
        if ($approve) {
            $message = $contrib->type->validation_message_approve;
        } else {
            $message = $contrib->type->validation_message_deny;
        }
        $message = sprintf(phpbb::$user->lang[$message], $notes);
        // Replace empty quotes if there are no notes
        if (!$notes) {
            $message = str_replace('[quote][/quote]', phpbb::$user->lang['NO_NOTES'], $message);
        }
        // Parse the message
        $message_uid = $message_bitfield = $message_options = false;
        generate_text_for_storage($message, $message_uid, $message_bitfield, $message_options, true, true, true);
        $data = array('address_list' => array('u' => $authors), 'from_user_id' => phpbb::$user->data['user_id'], 'from_username' => phpbb::$user->data['username'], 'icon_id' => 0, 'from_user_ip' => phpbb::$user->ip, 'enable_bbcode' => true, 'enable_smilies' => true, 'enable_urls' => true, 'enable_sig' => true, 'message' => $message, 'bbcode_bitfield' => $message_bitfield, 'bbcode_uid' => $message_uid);
        // Hooks
        titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $data, $this);
        // Submit Plz
        submit_pm('post', $subject, $data, true);
    }
コード例 #9
0
ファイル: uploader.php プロジェクト: Gfksx/customisation-db
/**
*
* @package Titania
* @version $Id$
* @copyright (c) 2008 phpBB Customisation Database Team
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_TITANIA')) {
    exit;
}
phpbb::_include('functions_upload', false, 'fileupload');
/**
 * Handles uploading attachments for Titania.
 */
class titania_uploader extends fileupload
{
    /**
     * Some vars we need
     *
     * @var mix
     */
    public $form_name = '';
    public $ext_group = '';
    /**
     * Array of data holding informatiom about the file being uploaded.
     *
コード例 #10
0
/**
 * Allow to create a new topic, to reply to a topic, to edit a post or the first_post of a topic in database
 * @param $mode post/reply/edit/edit_first_post/edit_last_post
 * @param $options array Array with post data, see our documentation for exact required items
 * @param $poll array Array with poll options.
 *
 * @return mixed false if there was an error, else topic_id when $mode is post, post_id when $mode is reply, true when mode is edit
 */
function phpbb_posting($mode, &$options, $poll = array())
{
    if (!in_array($mode, array('post', 'reply', 'edit', 'edit_first_post', 'edit_last_post'))) {
        return false;
    }
    phpbb::_include('bbcode', false, 'bbcode');
    phpbb::_include('message_parser', false, 'parse_message');
    phpbb::_include('functions_posting', 'submit_post', false);
    // Set some defaults
    $options = array_merge($options, array('enable_bbcode' => true, 'enable_urls' => true, 'enable_smilies' => true, 'topic_type' => POST_NORMAL));
    $message_parser = new parse_message($options['post_text']);
    // Get the data we need
    if ($mode == 'reply') {
        $sql = 'SELECT f.*, t.*
			FROM ' . FORUMS_TABLE . ' f, ' . TOPICS_TABLE . ' t
			WHERE t.topic_id = ' . (int) $options['topic_id'] . '
				AND f.forum_id = t.forum_id';
        $result = phpbb::$db->sql_query($sql);
        $post_data = phpbb::$db->sql_fetchrow($result);
        phpbb::$db->sql_freeresult($result);
    } else {
        if ($mode == 'edit') {
            $sql = 'SELECT f.*, t.*, p.*
			FROM ' . FORUMS_TABLE . ' f, ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p
			WHERE p.post_id = ' . (int) $options['post_id'] . '
				AND t.topic_id = p.topic_id
				AND f.forum_id = t.forum_id';
            $result = phpbb::$db->sql_query($sql);
            $post_data = phpbb::$db->sql_fetchrow($result);
            phpbb::$db->sql_freeresult($result);
        } else {
            if ($mode == 'edit_first_post') {
                $sql = 'SELECT f.*, t.*, p.*
			FROM ' . FORUMS_TABLE . ' f, ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p
			WHERE t.topic_id = ' . (int) $options['topic_id'] . '
				AND p.post_id = t.topic_first_post_id
				AND f.forum_id = t.forum_id';
                $result = phpbb::$db->sql_query($sql);
                $post_data = phpbb::$db->sql_fetchrow($result);
                phpbb::$db->sql_freeresult($result);
                //http://tracker.phpbb.com/browse/PHPBB3-9644
                $mode = 'edit';
            } else {
                if ($mode == 'edit_last_post') {
                    $sql = 'SELECT f.*, t.*, p.*
			FROM ' . FORUMS_TABLE . ' f, ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p
			WHERE t.topic_id = ' . (int) $options['topic_id'] . '
				AND p.post_id = t.topic_last_post_id
				AND f.forum_id = t.forum_id';
                    $result = phpbb::$db->sql_query($sql);
                    $post_data = phpbb::$db->sql_fetchrow($result);
                    phpbb::$db->sql_freeresult($result);
                    //http://tracker.phpbb.com/browse/PHPBB3-9644
                    $mode = 'edit';
                } else {
                    $sql = 'SELECT *
			FROM ' . FORUMS_TABLE . '
			WHERE forum_id = ' . (int) $options['forum_id'];
                    $result = phpbb::$db->sql_query($sql);
                    $post_data = phpbb::$db->sql_fetchrow($result);
                    phpbb::$db->sql_freeresult($result);
                }
            }
        }
    }
    if (!$post_data) {
        return false;
    }
    // If we need to post the message as a different user other than the one logged in
    if (isset($options['poster_id']) && $options['poster_id']) {
        // Some data for the ugly fix below :P
        $sql = 'SELECT username, user_colour, user_permissions, user_type
			FROM ' . USERS_TABLE . '
			WHERE user_id = ' . (int) $options['poster_id'];
        $result = phpbb::$db->sql_query($sql);
        $user_data = phpbb::$db->sql_fetchrow($result);
        phpbb::$db->sql_freeresult($result);
        if (!$user_data) {
            return false;
        }
        // Ugly fix, to be sure it is posted for the right user ;)
        $old_user_data = phpbb::$user->data;
        phpbb::$user->data['user_id'] = $options['poster_id'];
        phpbb::$user->data['username'] = $user_data['username'];
        phpbb::$user->data['user_colour'] = $user_data['user_colour'];
        phpbb::$user->data['user_permissions'] = $user_data['user_permissions'];
        phpbb::$user->data['user_type'] = $user_data['user_type'];
        // Same for auth, be sure its posted with correct permissions :)
        $old_auth = phpbb::$auth;
        phpbb::$auth = new auth();
        phpbb::$auth->acl(phpbb::$user->data);
    }
    // When editing a post, submit post does not update the bbcode uid, we have to specify the old one.
    if (in_array($mode, array('edit', 'edit_first_post', 'edit_last_post'))) {
        $message_parser->bbcode_uid = $post_data['bbcode_uid'];
    }
    // Parse the BBCode
    if ($options['enable_bbcode']) {
        $message_parser->parse($options['enable_bbcode'], $options['enable_urls'], $options['enable_smilies'], (bool) phpbb::$auth->acl_get('f_img', $post_data['forum_id']), (bool) phpbb::$auth->acl_get('f_flash', $post_data['forum_id']), true, phpbb::$config['allow_post_links']);
    }
    // Setup the settings we need to send to submit_post
    $data = array('topic_title' => $options['topic_title'], 'enable_bbcode' => (bool) $options['enable_bbcode'], 'enable_smilies' => (bool) $options['enable_smilies'], 'enable_urls' => (bool) $options['enable_urls'], 'message_md5' => (string) md5($message_parser->message), 'bbcode_bitfield' => $message_parser->bbcode_bitfield, 'bbcode_uid' => $message_parser->bbcode_uid, 'message' => $message_parser->message, 'force_approved_state' => true, 'post_time' => time(), 'notify_set' => false, 'notify' => false);
    switch ($mode) {
        case 'post':
            $data = array_merge(array('icon_id' => isset($options['icon_id']) ? $options['icon_id'] : 0, 'poster_id' => isset($options['poster_id']) && $options['poster_id'] ? (int) $options['poster_id'] : phpbb::$user->data['user_id'], 'enable_sig' => isset($options['enable_sig']) ? (bool) $options['enable_sig'] : true, 'post_edit_locked' => isset($options['post_edit_locked']) ? $options['post_edit_locked'] : false), $data);
            break;
        case 'reply':
            $data = array_merge(array('poster_id' => isset($options['poster_id']) && $options['poster_id'] ? (int) $options['poster_id'] : phpbb::$user->data['user_id'], 'enable_sig' => isset($options['enable_sig']) ? (bool) $options['enable_sig'] : true, 'post_edit_locked' => isset($options['post_edit_locked']) ? $options['post_edit_locked'] : false), $data);
            break;
    }
    // Merge the data we grabbed from the forums/topics/posts tables
    $data = array_merge($data, $post_data);
    // Aaaand, submit it.
    switch ($mode) {
        case 'post':
        case 'reply':
            submit_post($mode, $options['topic_title'], isset($options['poster_id']) && $options['poster_id'] ? $user_data['username'] : phpbb::$user->data['username'], $options['topic_type'], $poll, $data);
            break;
        default:
            submit_post($mode, $options['topic_title'], phpbb::$user->data['username'], $options['topic_type'], $poll, $data);
            break;
    }
    // Change the status?  submit_post does not support setting this
    if (isset($options['topic_status'])) {
        $sql = 'UPDATE ' . TOPICS_TABLE . '
			SET topic_status = ' . (int) $options['topic_status'] . '
			WHERE topic_id = ' . $data['topic_id'] . '
				AND topic_moved_id = 0';
        phpbb::$db->sql_query($sql);
    }
    // Restore the user data
    if (isset($options['poster_id']) && $options['poster_id']) {
        phpbb::$user->data = $old_user_data;
        $auth = $old_auth;
    }
    // Add the new data to the options (to grab post/topic id/etc if we want it later)
    $options = array_merge($data, $options);
    if ($mode == 'post') {
        return $data['topic_id'];
    } else {
        if ($mode == 'reply') {
            return $data['post_id'];
        }
    }
    return true;
}
コード例 #11
0
    /**
     * Delete this contribution
     */
    public function delete()
    {
        // Delete Revisions
        $revision = new titania_revision($this);
        $sql = 'SELECT * FROM ' . TITANIA_REVISIONS_TABLE . '
			WHERE contrib_id = ' . $this->contrib_id;
        $result = phpbb::$db->sql_query($sql);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            $revision->__set_array($row);
            $revision->delete();
        }
        phpbb::$db->sql_freeresult($result);
        // Delete Support/Discussion/Queue Discussion Topics
        $topic = new titania_topic();
        $sql = 'SELECT * FROM ' . TITANIA_TOPICS_TABLE . '
			WHERE ' . phpbb::$db->sql_in_set('topic_type', array(TITANIA_SUPPORT, TITANIA_QUEUE_DISCUSSION)) . '
				AND parent_id = ' . $this->contrib_id;
        $result = phpbb::$db->sql_query($sql);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            $topic->__set_array($row);
            $topic->delete();
        }
        phpbb::$db->sql_freeresult($result);
        // Change the status to new (handles resetting counts)
        $this->change_status(TITANIA_CONTRIB_NEW);
        // Remove any attention items
        $sql = 'DELETE FROM ' . TITANIA_ATTENTION_TABLE . '
			WHERE attention_object_type = ' . TITANIA_CONTRIB . '
				AND attention_object_id = ' . $this->contrib_id;
        phpbb::$db->sql_query($sql);
        // Delete the release topic
        if ($this->contrib_release_topic_id) {
            phpbb::_include('functions_admin', 'delete_topics');
            delete_topics('topic_id', $this->contrib_release_topic_id);
        }
        // Delete from categories
        $this->update_category_count('-');
        $sql = ' DELETE FROM ' . TITANIA_CONTRIB_IN_CATEGORIES_TABLE . '
			WHERE contrib_id = ' . $this->contrib_id;
        phpbb::$db->sql_query($sql);
        repository::trigger_cron($this->config);
        // Self delete
        parent::delete();
    }
コード例 #12
0
ファイル: users.php プロジェクト: Sajaki/customisation-db
 /**
  * Assign user details
  *
  * @param int $user_id
  * @param string $prefix Prefix to assign to the user details
  * @param bool $output_to_template True to output the data to the template
  */
 public static function assign_details($user_id, $prefix = '', $output_to_template = false)
 {
     $row = self::get_user($user_id);
     $user_id = $row['user_id'];
     // Re-assign properly...in case it gives us the anonymous user
     phpbb::_include('functions_display', 'phpbb_get_user_rank');
     phpbb::$user->add_lang('memberlist');
     // Get user rank
     $rank = phpbb_get_user_rank($row, $row['user_posts']);
     $output = array($prefix . 'USER_FULL' => self::get_user($user_id, '_full'), $prefix . 'USER_COLOUR' => self::get_user($user_id, '_colour'), $prefix . 'USERNAME' => self::get_user($user_id, '_username'), $prefix . 'RANK_TITLE' => $rank['title'], $prefix . 'RANK_IMG' => $rank['img'], $prefix . 'RANK_IMG_SRC' => $rank['img_src'], $prefix . 'USER_JOINED' => phpbb::$user->format_date($row['user_regdate']), $prefix . 'USER_POSTS' => $row['user_posts'], $prefix . 'USER_AVATAR' => self::get_user($user_id, '_avatar'), $prefix . 'USER_WARNINGS' => $row['user_warnings'], $prefix . 'USER_SIG' => self::get_user($user_id, '_signature'), $prefix . 'ONLINE_IMG' => $user_id != ANONYMOUS && isset(self::$status[$user_id]) ? self::$status[$user_id] ? phpbb::$user->img('icon_user_online', 'ONLINE') : phpbb::$user->img('icon_user_offline', 'OFFLINE') : '', $prefix . 'S_ONLINE' => $user_id != ANONYMOUS && isset(self::$status[$user_id]) ? self::$status[$user_id] : false, $prefix . 'S_FRIEND' => isset($row['friend']) ? true : false, $prefix . 'S_FOE' => isset($row['foe']) ? true : false, $prefix . 'U_USER_BOARD_PROFILE' => self::get_user($user_id, '_profile'), $prefix . 'U_SEARCH' => phpbb::$auth->acl_get('u_search') ? phpbb::append_sid('search', "author_id={$user_id}&amp;sr=posts") : '', $prefix . 'U_PM' => self::get_user($user_id, '_u_pm'), $prefix . 'U_EMAIL' => self::get_user($user_id, '_u_email'), $prefix . 'U_JABBER' => self::get_user($user_id, '_jabber'), $prefix . 'S_JABBER_ENABLED' => phpbb::$config['jab_enable'] ? true : false, $prefix . 'SEND_EMAIL_USER' => phpbb::$user->lang('SEND_EMAIL_USER', self::get_user($user_id, '_username')));
     if ($output_to_template) {
         phpbb::$template->assign_vars($output);
     }
     return $output;
 }
コード例 #13
0
ファイル: users.php プロジェクト: Gfksx/customisation-db
 /**
  * Assign user details
  *
  * @param int $user_id
  * @param string $prefix Prefix to assign to the user details
  * @param bool $output_to_template True to output the data to the template
  */
 public static function assign_details($user_id, $prefix = '', $output_to_template = false)
 {
     $row = self::get_user($user_id);
     $user_id = $row['user_id'];
     // Re-assign properly...in case it gives us the anonymous user
     phpbb::_include('functions_display', 'get_user_rank');
     // IT'S A HACK!
     global $phpbb_root_path;
     $phpbb_root_path = titania::$absolute_board;
     // Get user rank and avatar (need hacks for this)
     get_user_rank($row['user_rank'], $row['user_posts'], $row['rank_title'], $row['rank_image'], $row['rank_image_src']);
     // Undo
     $phpbb_root_path = PHPBB_ROOT_PATH;
     $output = array($prefix . 'USER_FULL' => self::get_user($user_id, '_full'), $prefix . 'USER_COLOUR' => self::get_user($user_id, '_colour'), $prefix . 'USERNAME' => self::get_user($user_id, '_username'), $prefix . 'RANK_TITLE' => $row['rank_title'], $prefix . 'RANK_IMG' => $row['rank_image'], $prefix . 'RANK_IMG_SRC' => $row['rank_image_src'], $prefix . 'USER_JOINED' => phpbb::$user->format_date($row['user_regdate']), $prefix . 'USER_POSTS' => $row['user_posts'], $prefix . 'USER_FROM' => $row['user_from'], $prefix . 'USER_AVATAR' => self::get_user($user_id, '_avatar'), $prefix . 'USER_WARNINGS' => $row['user_warnings'], $prefix . 'USER_SIG' => self::get_user($user_id, '_signature'), $prefix . 'ICQ_STATUS_IMG' => self::get_user($user_id, '_icq_status'), $prefix . 'ONLINE_IMG' => $user_id != ANONYMOUS && isset(self::$status[$user_id]) ? self::$status[$user_id] ? phpbb::$user->img('icon_user_online', 'ONLINE') : phpbb::$user->img('icon_user_offline', 'OFFLINE') : '', $prefix . 'S_ONLINE' => $user_id != ANONYMOUS && isset(self::$status[$user_id]) ? self::$status[$user_id] : false, $prefix . 'S_FRIEND' => isset($row['friend']) ? true : false, $prefix . 'S_FOE' => isset($row['foe']) ? true : false, $prefix . 'U_USER_PROFILE' => self::get_user($user_id, '_profile'), $prefix . 'U_SEARCH' => phpbb::$auth->acl_get('u_search') ? phpbb::append_sid('search', "author_id={$user_id}&amp;sr=posts") : '', $prefix . 'U_PM' => self::get_user($user_id, '_u_pm'), $prefix . 'U_EMAIL' => self::get_user($user_id, '_u_email'), $prefix . 'U_WWW' => $row['user_website'], $prefix . 'U_ICQ' => self::get_user($user_id, '_icq'), $prefix . 'U_AIM' => self::get_user($user_id, '_aim'), $prefix . 'U_MSN' => self::get_user($user_id, '_msnm'), $prefix . 'U_YIM' => self::get_user($user_id, '_yim'), $prefix . 'U_JABBER' => self::get_user($user_id, '_jabber'));
     if ($output_to_template) {
         phpbb::$template->assign_vars($output);
     }
     return $output;
 }
コード例 #14
0
ファイル: attention.php プロジェクト: Sajaki/customisation-db
 /**
  * Disapprove action.
  *
  * @return null
  */
 protected function disapprove()
 {
     if (!$this->attention->is_open() || $this->attention->is_report()) {
         redirect($this->helper->route('phpbb.titania.manage.attention'));
     }
     $disapprove_reason = $this->request->variable('disapprove_reason', 0);
     $disapprove_explain = $this->request->variable('disapprove_explain', '', true);
     $result = false;
     if (confirm_box(true)) {
         $result = $this->attention->disapprove($disapprove_reason, $disapprove_explain);
     }
     if (!$result || $result === 'reason_empty') {
         if ($result) {
             $this->template->assign_var('ADDITIONAL_MSG', $this->user->lang['NO_REASON_DISAPPROVAL']);
             // Make sure we can reuse the confirm box
             $this->request->overwrite('confirm_key', null, \phpbb\request\request_interface::REQUEST);
             $this->request->overwrite('confirm_key', null, \phpbb\request\request_interface::POST);
             $this->request->overwrite('confirm', null, \phpbb\request\request_interface::POST);
         }
         \phpbb::_include('functions_display', 'display_reasons');
         display_reasons($disapprove_reason);
         confirm_box(false, 'DISAPPROVE_ITEM', build_hidden_fields(array('disapprove' => true)), 'manage/disapprove_body.html');
     }
     redirect($this->helper->route('phpbb.titania.manage.attention'));
 }
コード例 #15
0
 /**
  * Private function strings have to pass before entering the database.
  * Ensures string length et cetera.
  *
  * @param	string	$value		The string we want to validate
  * @param	array	$config		The configuration array we're validating against
  *
  * @return	string				The validated string
  */
 private function validate_string($value, $config)
 {
     if (empty($value)) {
         return '';
     }
     // Check if multibyte characters are disallowed
     if (isset($config['multibyte']) && $config['multibyte'] === false) {
         // No multibyte, only allow ASCII (0-127)
         $value = preg_replace('/[\\x80-\\xFF]/', '', $value);
     } else {
         // Make sure multibyte characters are wellformed
         if (!preg_match('/^./u', $value)) {
             return '';
         }
     }
     // Truncate to the maximum length
     if (isset($config['max']) && $config['max']) {
         phpbb::_include('functions_content', 'truncate_string');
         truncate_string($value, $config['max']);
     }
     return $value;
 }
コード例 #16
0
                    phpbb::update_user_postcount($post->post_user_id);
                }
                $post->submit();
                // Load z topic
                $post->topic->topic_id = $post->topic_id;
                $post->topic->load();
                // Update first/last post?
                if ($post->topic->topic_first_post_time > $post->post_time) {
                    $post->topic->sync_first_post();
                }
                if ($post->topic->topic_last_post_time < $post->post_time) {
                    $post->topic->sync_last_post();
                }
                // Subscriptions?
                if ($post->topic->topic_last_post_id == $post->post_id) {
                    phpbb::_include('functions_messenger', false, 'messenger');
                    $email_vars = array('NAME' => $post->topic->topic_subject, 'U_VIEW' => titania_url::append_url($post->topic->get_url(), array('view' => 'unread', '#' => 'unread')));
                    titania_subscriptions::send_notifications(TITANIA_TOPIC, $post->topic_id, 'subscribe_notify.txt', $email_vars, $post->post_user_id);
                }
                $sql = 'SELECT COUNT(post_id) AS cnt FROM ' . TITANIA_POSTS_TABLE . '
					WHERE topic_id = ' . $post->topic_id . '
						AND post_approved = 0';
                phpbb::$db->sql_query($sql);
                $cnt = phpbb::$db->sql_fetchfield('cnt');
                if (!$cnt) {
                    $sql = 'UPDATE ' . TITANIA_TOPICS_TABLE . '
						SET topic_approved = 1
						WHERE topic_id = ' . $post->topic_id;
                    phpbb::$db->sql_query($sql);
                    // Subscriptions
                    if ($post->topic->topic_last_post_id == $post->post_id) {
コード例 #17
0
ファイル: diff.php プロジェクト: Gfksx/customisation-db
* @package Titania
* @version $Id$
* @copyright (c) 2008 phpBB Customisation Database Team
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_TITANIA')) {
    exit;
}
phpbb::_include('diff/diff', false, 'diff');
phpbb::_include('diff/engine', false, 'diff');
phpbb::_include('diff/renderer', false, 'diff');
phpbb::_include('functions_compress', false, 'compress');
/**
* Class to create diffs for updated versions
* @package Titania
*/
class titania_diff
{
    /**
     * Classname of the diff renderer to use
     *
     * @var string
     */
    private $renderer_type;
    /**
     * Identification for old and new
     * This is used by from_dir to add an identification to the diff file
コード例 #18
0
if (!defined('TITANIA_ROOT')) {
    define('TITANIA_ROOT', './');
}
if (!defined('PHP_EXT')) {
    define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
}
require TITANIA_ROOT . 'common.' . PHP_EXT;
titania::add_lang('manage');
// Give founders access to run this
if (phpbb::$user->data['user_type'] != USER_FOUNDER) {
    titania::needs_auth();
}
// Hopefully this helps
@set_time_limit(0);
if (!isset(phpbb::$config['titania_hook_phpbb_com'])) {
    phpbb::_include('../umil/umil', false, 'umil');
    $umil = new umil(true, phpbb::$db);
    $umil->run_actions('update', array('1.0.0' => array('table_column_add' => array(array(TITANIA_TOPICS_TABLE, 'phpbb_topic_id', array('UINT', 0))))), 'titania_hook_phpbb_com');
    unset($umil);
}
// Hack for local
phpbb::$config['site_upload_dir'] = !isset(phpbb::$config['site_upload_dir']) ? '../phpBB3_titania/files/contribdb' : '../../' . phpbb::$config['site_upload_dir'];
$screenshots_dir = phpbb::$config['site_upload_dir'] . '/demo/';
// Table prefix
$ariel_prefix = 'community_site_';
$limit = 1000;
$mod_validation_trash_forum = 28;
$style_validation_trash_forum = 83;
$step = request_var('step', 0);
$start = request_var('start', 0);
// Populated later
コード例 #19
0
ファイル: posts.php プロジェクト: Noxwizard/customisation-db
    /**
     * Display topic section for support/tracker/etc
     *
     * @param object $topic The topic object
     * @param titania_sort $sort The sort object (includes/tools/sort.php)
     */
    public static function display_topic($topic, $sort = false)
    {
        if ($sort === false) {
            // Setup the sort tool
            $sort = self::build_sort();
        }
        $sort->request();
        $sql_ary = array('SELECT' => 'p.*', 'FROM' => array(TITANIA_POSTS_TABLE => 'p'), 'WHERE' => 'p.topic_id = ' . (int) $topic->topic_id . self::sql_permissions('p.'), 'ORDER_BY' => $sort->get_order_by());
        // Main SQL Query
        $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
        // Handle pagination
        if (!$sort->sql_count($sql_ary, 'p.post_id')) {
            // No results...no need to query more...
            return;
        }
        $sort->build_pagination($topic->get_url());
        // Get the data
        $post_ids = $user_ids = array();
        $last_post_time = 0;
        // tracking
        $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            self::$posts[$row['post_id']] = $row;
            self::$posts[$row['post_id']]['attachments'] = array();
            $post_ids[] = $row['post_id'];
            $user_ids[] = $row['post_user_id'];
            $user_ids[] = $row['post_edit_user'];
            $user_ids[] = $row['post_delete_user'];
            $last_post_time = $row['post_time'];
            // to set tracking
        }
        phpbb::$db->sql_freeresult($result);
        // Grab the tracking data
        $last_mark_time = titania_tracking::get_track(TITANIA_TOPIC, $topic->topic_id);
        // Store tracking data
        titania_tracking::track(TITANIA_TOPIC, $topic->topic_id, $last_post_time);
        // load the user data
        users_overlord::load($user_ids);
        phpbb::_include('functions_profile_fields', false, 'custom_profile');
        $cp = new custom_profile();
        $post = new titania_post($topic->topic_type, $topic);
        $attachments = new titania_attachment($topic->topic_type, false);
        // Grab all attachments
        $attachments_set = $attachments->load_attachments_set($post_ids);
        // Loop de loop
        $prev_post_time = 0;
        foreach ($post_ids as $post_id) {
            $post->__set_array(self::$posts[$post_id]);
            $attachments->clear_attachments();
            if (isset($attachments_set[$post_id])) {
                $attachments->store_attachments($attachments_set[$post_id]);
            }
            // Parse attachments before outputting the message
            $message = $post->generate_text_for_display();
            $parsed_attachments = $attachments->parse_attachments($message);
            // Prepare message text for use in javascript
            $message_decoded = censor_text($post->post_text);
            titania_decode_message($message_decoded, $post->post_text_uid);
            $message_decoded = bbcode_nl2br($message_decoded);
            // Build CP Fields
            $cp_row = array();
            if (isset(users_overlord::$cp_fields[$post->post_user_id])) {
                $cp_row = $cp->generate_profile_fields_template('show', false, users_overlord::$cp_fields[$post->post_user_id]);
            }
            $cp_row['row'] = isset($cp_row['row']) && sizeof($cp_row['row']) ? $cp_row['row'] : array();
            // Display edit info
            $display_username = get_username_string('full', $post->post_user_id, users_overlord::get_user($post->post_user_id, 'username'), users_overlord::get_user($post->post_user_id, 'user_colour'), false, phpbb::append_sid('memberlist', 'mode=viewprofile'));
            $l_edited_by = $post->post_edit_time ? sprintf(phpbb::$user->lang['EDITED_MESSAGE'], $display_username, phpbb::$user->format_date($post->post_edit_time)) : '';
            phpbb::$template->assign_block_vars('posts', array_merge($post->assign_details(false), users_overlord::assign_details($post->post_user_id), $cp_row['row'], array('POST_TEXT' => $message, 'POST_TEXT_DECODED' => $message_decoded, 'EDITED_MESSAGE' => $l_edited_by, 'U_MINI_POST' => titania_url::append_url($topic->get_url(), array('p' => $post_id, '#p' => $post_id)), 'MINI_POST_IMG' => $post->post_time > $last_mark_time ? phpbb::$user->img('icon_post_target_unread', 'NEW_POST') : phpbb::$user->img('icon_post_target', 'POST'), 'S_FIRST_UNREAD' => $post->post_time > $last_mark_time && $prev_post_time <= $last_mark_time ? true : false)));
            // Output CP Fields
            if (!empty($cp_row['blockrow'])) {
                foreach ($cp_row['blockrow'] as $field_data) {
                    phpbb::$template->assign_block_vars('posts.custom_fields', $field_data);
                }
            }
            //S_IGNORE_POST
            //POST_ICON_IMG
            //MINI_POST_IMG
            foreach ($parsed_attachments as $attachment) {
                phpbb::$template->assign_block_vars('posts.attachment', array('DISPLAY_ATTACHMENT' => $attachment));
            }
            $prev_post_time = $post->post_time;
        }
        unset($post, $attachments);
        // Increment the topic view count
        $sql = 'UPDATE ' . TITANIA_TOPICS_TABLE . '
			SET topic_views = topic_views + 1
			WHERE topic_id = ' . (int) $topic->topic_id;
        phpbb::$db->sql_query($sql);
    }
コード例 #20
0
function phpbb_com_move_queue_topic($queue_object)
{
    $sql = 'SELECT phpbb_topic_id, topic_category FROM ' . TITANIA_TOPICS_TABLE . '
		WHERE topic_id = ' . (int) $queue_object->queue_topic_id;
    $result = phpbb::$db->sql_query($sql);
    $row = phpbb::$db->sql_fetchrow($result);
    phpbb::$db->sql_freeresult($result);
    if (!$row['phpbb_topic_id']) {
        return;
    }
    phpbb::_include('functions_admin', 'move_topics');
    move_topics($row['phpbb_topic_id'], phpbb_com_forum_id($row['topic_category'], 'trash'));
}
コード例 #21
0
ファイル: attachment.php プロジェクト: Gfksx/customisation-db
    /**
     * Upload any files we attempted to attach
     *
     * @param bool|int $max_thumbnail_width The maximum thumbnail width (if we create one)
     */
    public function upload($max_thumbnail_width = false)
    {
        // First, we shall handle the items already attached
        $attached_ids = request_var($this->form_name . '_attachments', array(0));
        // Query the ones we must
        $to_query = array_diff($attached_ids, array_keys($this->attachments));
        if (sizeof($to_query)) {
            $sql = 'SELECT * FROM ' . $this->sql_table . '
				WHERE ' . phpbb::$db->sql_in_set('attachment_id', array_map('intval', $to_query)) . '
					AND object_type = ' . (int) $this->object_type . '
					AND object_id = ' . (int) $this->object_id;
            // Don't let them be messin with us
            $result = phpbb::$db->sql_query($sql);
            while ($row = phpbb::$db->sql_fetchrow($result)) {
                $this->attachments[$row['attachment_id']] = $row;
            }
            phpbb::$db->sql_freeresult($result);
        }
        // Next, delete those requested
        $delete = request_var('delete_file', array(0));
        foreach ($delete as $attach_id => $null) {
            $this->delete($attach_id);
            $this->deleted = true;
            // Sometime I'll look into this again; having it setup to only delete attachments after the form is submitted
            /*if (isset($this->attachments[$attach_id]))
            		{
            			$this->attachments[$attach_id]['deleted'] = true;
            		}*/
        }
        // And undelete any
        /*$undelete = request_var('undelete_file', array(0));
        		foreach ($delete as $attach_id => $null)
        		{
        			if (isset($this->attachments[$attach_id]))
        			{
        				$this->attachments[$attach_id]['deleted'] = false;
        			}
        		}*/
        if (isset($_FILES[$this->form_name])) {
            // In order to save ourselves from rewriting the phpBB uploader to support multi-uploads, we have to do some hacking
            $uploaded_files = array();
            if (is_array($_FILES[$this->form_name]['name'])) {
                // Store the files in our own data array
                foreach ($_FILES[$this->form_name]['name'] as $id => $name) {
                    $uploaded_files[] = array('name' => $name, 'type' => $_FILES[$this->form_name]['type'][$id], 'tmp_name' => $_FILES[$this->form_name]['tmp_name'][$id], 'error' => $_FILES[$this->form_name]['error'][$id], 'size' => $_FILES[$this->form_name]['size'][$id]);
                }
            } else {
                // Compatibility with non-multi-upload forms
                $uploaded_files[] = $_FILES[$this->form_name];
            }
            // Finally upload new items if required
            foreach ($uploaded_files as $uploaded_file) {
                // Hack time
                $_FILES[$this->form_name] = $uploaded_file;
                if ($_FILES[$this->form_name]['name'] != 'none' && trim($_FILES[$this->form_name]['name'])) {
                    // Setup uploader tool.
                    $this->uploader = new titania_uploader($this->form_name, $this->object_type);
                    // Try uploading the file.
                    $this->uploader->upload_file();
                    // Store for easier access
                    $this->error = array_merge($this->error, $this->uploader->filedata['error']);
                    // If we had no problems we can submit the data to the database.
                    if (!sizeof($this->uploader->filedata['error'])) {
                        // Create thumbnail
                        $has_thumbnail = false;
                        if ($this->uploader->filedata['is_image']) {
                            phpbb::_include('functions_posting', 'create_thumbnail');
                            $src = titania::$config->upload_path . utf8_basename($this->uploader->filedata['attachment_directory']) . '/' . utf8_basename($this->uploader->filedata['physical_filename']);
                            $dst = titania::$config->upload_path . utf8_basename($this->uploader->filedata['attachment_directory']) . '/thumb_' . utf8_basename($this->uploader->filedata['physical_filename']);
                            $has_thumbnail = $this->create_thumbnail($src, $dst, $this->uploader->filedata['mimetype'], $max_thumbnail_width, $max_thumbnail_width === false ? false : 0);
                        }
                        $this->__set_array(array('attachment_id' => 0, 'physical_filename' => $this->uploader->filedata['physical_filename'], 'attachment_directory' => $this->uploader->filedata['attachment_directory'], 'real_filename' => $this->uploader->filedata['real_filename'], 'extension' => $this->uploader->filedata['extension'], 'mimetype' => $this->uploader->filedata['mimetype'], 'filesize' => $this->uploader->filedata['filesize'], 'filetime' => $this->uploader->filedata['filetime'], 'hash' => $this->uploader->filedata['md5_checksum'], 'thumbnail' => $has_thumbnail, 'attachment_comment' => utf8_normalize_nfc(request_var('filecomment', '', true))));
                        parent::submit();
                        // Store in $this->attachments[]
                        $this->attachments[$this->attachment_id] = $this->__get_array();
                        // Additional fields
                        foreach ($this->additional_fields as $output_key => $row_key) {
                            $this->attachments[$this->attachment_id][$row_key] = utf8_normalize_nfc(request_var($row_key, '', true));
                        }
                    }
                    $this->uploaded = true;
                }
            }
            // We do not want to upload it again if this function is called again.
            unset($_FILES[$this->form_name]);
        }
    }
コード例 #22
0
ファイル: message.php プロジェクト: kairion/customisation-db
 /**
  * If you display the captcha, run this function to check if they entered the correct captcha setting
  *
  * @return mixed $captcha->validate(); results (false on success, error string on failure)
  */
 public function validate_captcha()
 {
     phpbb::_include('captcha/captcha_factory', false, 'phpbb_captcha_factory');
     $captcha =& phpbb_captcha_factory::get_instance(phpbb::$config['captcha_plugin']);
     $captcha->init(CONFIRM_POST);
     return $captcha->validate($this->request_data());
 }
コード例 #23
0
ファイル: attention.php プロジェクト: Sajaki/customisation-db
 /**
  * Send an individual a notification.
  * @todo This should probably be moved somewhere else so it can be reused.
  *
  * @param int $user_id
  * @param string $email_template
  * @param array $message_vars Additional variables for email message.
  */
 public function notify_user($user_id, $email_template, $message_vars)
 {
     if ($user_id == ANONYMOUS) {
         return;
     }
     phpbb::_include('functions_messenger', false, 'messenger');
     $lang_path = phpbb::$user->lang_path;
     phpbb::$user->set_custom_lang_path(titania::$config->language_path);
     $messenger = new messenger(false);
     users_overlord::load_users(array($user_id));
     $messenger->template($email_template, users_overlord::get_user($user_id, 'user_lang'));
     $messenger->to(users_overlord::get_user($user_id, 'user_email'), users_overlord::get_user($user_id, '_username'));
     $messenger->assign_vars(array_merge($message_vars, array('USERNAME' => htmlspecialchars_decode(users_overlord::get_user($user_id, '_username')))));
     $messenger->send();
     phpbb::$user->set_custom_lang_path($lang_path);
     // This gets reset when $template->_tpl_load() gets called
     phpbb::$user->theme['template_inherits_id'] = 1;
 }