Пример #1
0
    /**
     * Update BBCodes that currently use the LOCAL_URL tag
     *
     * To fix http://tracker.src.com/browse/src3-8319 we changed
     * the second_pass_replace value, so that needs updating for existing ones
     */
    public function update_local_url_bbcode()
    {
        $sql = 'SELECT *
			FROM ' . BBCODES_TABLE . '
			WHERE bbcode_match ' . $this->db->sql_like_expression($this->db->get_any_char() . 'LOCAL_URL' . $this->db->get_any_char());
        $result = $this->db->sql_query($sql);
        while ($row = $this->db->sql_fetchrow($result)) {
            if (!class_exists('acp_bbcodes')) {
                if (function_exists('src_require_updated')) {
                    src_require_updated('includes/acp/acp_bbcodes.' . $this->php_ext);
                } else {
                    require $this->src_root_path . 'includes/acp/acp_bbcodes.' . $this->php_ext;
                }
            }
            $bbcode_match = $row['bbcode_match'];
            $bbcode_tpl = $row['bbcode_tpl'];
            $acp_bbcodes = new \acp_bbcodes();
            $sql_ary = $acp_bbcodes->build_regexp($bbcode_match, $bbcode_tpl);
            $sql = 'UPDATE ' . BBCODES_TABLE . '
				SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . '
				WHERE bbcode_id = ' . (int) $row['bbcode_id'];
            $this->sql_query($sql);
        }
        $this->db->sql_freeresult($result);
    }
    public function update_bbcodes_table()
    {
        if (!class_exists('acp_bbcodes')) {
            include $this->phpbb_root_path . 'includes/acp/acp_bbcodes.' . $this->php_ext;
        }
        $bbcodes = new \acp_bbcodes();
        $sql = 'SELECT bbcode_id, bbcode_match, bbcode_tpl
			FROM ' . BBCODES_TABLE;
        $result = $this->sql_query($sql);
        $sql_ary = array();
        while ($row = $this->db->sql_fetchrow($result)) {
            $data = array();
            if (preg_match('/(URL|LOCAL_URL|RELATIVE_URL)/', $row['bbcode_match'])) {
                $data = $bbcodes->build_regexp($row['bbcode_match'], $row['bbcode_tpl']);
                $sql_ary[$row['bbcode_id']] = array('first_pass_match' => $data['first_pass_match'], 'first_pass_replace' => $data['first_pass_replace'], 'second_pass_match' => $data['second_pass_match'], 'second_pass_replace' => $data['second_pass_replace']);
            }
        }
        $this->db->sql_freeresult($result);
        foreach ($sql_ary as $bbcode_id => $bbcode_data) {
            $sql = 'UPDATE ' . BBCODES_TABLE . '
				SET ' . $this->db->sql_build_array('UPDATE', $bbcode_data) . '
				WHERE bbcode_id = ' . (int) $bbcode_id;
            $this->sql_query($sql);
        }
    }
Пример #3
0
 /**
  * Get regular expression and other data that's normally sent to db when adding a BBCode
  */
 public function get_bbcode_data()
 {
     if (!$this->usage || !$this->replacement) {
         return;
     }
     if (!is_object($this->acp_bbcode)) {
         require $this->phpbb_root_path . 'includes/acp/acp_bbcodes.' . $this->php_ext;
         $this->acp_bbcode = new \acp_bbcodes();
     }
     $this->bbcode_data = $this->acp_bbcode->build_regexp($this->usage, $this->replacement);
     $this->bbcode_data['bbcode_id'] = $this->contrib_id;
     $this->bbcode_data['bbcode_tpl'] = $this->replacement;
 }
Пример #4
0
    public function install_bbcode_yandexmaps()
    {
        // Load the acp_bbcode class
        if (!class_exists('acp_bbcodes')) {
            include $this->phpbb_root_path . 'includes/acp/acp_bbcodes.' . $this->php_ext;
        }
        $ym_tpl = "<script type=\"text/javascript\">\n\t\t\tmap_div_id = (typeof map_div_id == \"undefined\") ? 1 : (map_div_id+1);\n\t\t\tdocument.writeln('<div id=\"map_' + map_div_id + '\" style=\"width:auto;height:400px;\"></div>');\n\n\t\t\t(function(){\n\t\t\t\tvar divID = map_div_id;\n\t\t\t\tymaps.ready(function(){\n\t\t\t\t\t\twindow.myMap = new ymaps.Map('map_' + divID, {\n\t\t\t\t\t\t\tcenter: [{INTTEXT}],\n\t\t\t\t\t\t\tzoom: 10\n\t\t\t\t\t\t});\n\t\t\t\t\t\tvar myPlacemark = new ymaps.Placemark([{INTTEXT}]);\n\t\t\t\t\t\tmyMap.geoObjects.add(myPlacemark);\n\t\t\t\t});\n\t\t\t})();\n\t\t</script>";
        $ym_tpl_full = "<script type=\"text/javascript\">\n\t\t\tmap_div_id = (typeof map_div_id == \"undefined\") ? 1 : (map_div_id+1);\n\t\t\tdocument.writeln('<div id=\"map_' + map_div_id + '\" style=\"width:auto;height:400px;\"></div>');\n\t\t\t(function(){\n\t\t\t\tvar divID = map_div_id;\n\t\t\t\tymaps.ready(function(){\n\t\t\t\t\t\twindow.myMap = new ymaps.Map('map_' + divID, {\n\t\t\t\t\t\t\tcenter: [{INTTEXT}],\n\t\t\t\t\t\t\tzoom: 10\n\t\t\t\t\t\t});\n\t\t\t\t\t\tvar myPlacemark = new ymaps.Placemark([{INTTEXT}], {hintContent: '{TEXT}'});\n\t\t\t\t\t\tmyMap.geoObjects.add(myPlacemark);\n\t\t\t\t});\n\t\t\t})();\n\t\t</script>";
        $bbcode_tool = new \acp_bbcodes();
        $bbcode_data = array('yandexmaps' => array('bbcode_helpline' => '{L_YANDEXMAPSHELP}', 'bbcode_match' => '[yandexmaps]{INTTEXT}[/yandexmaps]', 'bbcode_tpl' => $ym_tpl, 'display_on_posting' => 0), 'yandexmaps=' => array('bbcode_helpline' => '{L_YANDEXMAPSHELP2}', 'bbcode_match' => '[yandexmaps={TEXT}]{INTTEXT}[/yandexmaps]', 'bbcode_tpl' => $ym_tpl_full, 'display_on_posting' => 0));
        foreach ($bbcode_data as $bbcode_name => $bbcode_array) {
            // Build the BBCodes
            $data = $bbcode_tool->build_regexp($bbcode_array['bbcode_match'], $bbcode_array['bbcode_tpl']);
            $bbcode_array += array('bbcode_tag' => $data['bbcode_tag'], 'first_pass_match' => $data['first_pass_match'], 'first_pass_replace' => $data['first_pass_replace'], 'second_pass_match' => $data['second_pass_match'], 'second_pass_replace' => $data['second_pass_replace']);
            $sql = 'SELECT bbcode_id
				FROM ' . $this->table_prefix . "bbcodes\n\t\t\t\tWHERE LOWER(bbcode_tag) = '" . strtolower($bbcode_name) . "'\n\t\t\t\tOR LOWER(bbcode_tag) = '" . strtolower($bbcode_array['bbcode_tag']) . "'";
            $result = $this->db->sql_query($sql);
            $row_exists = $this->db->sql_fetchrow($result);
            $this->db->sql_freeresult($result);
            if ($row_exists) {
                // Update existing BBCode
                $bbcode_id = $row_exists['bbcode_id'];
                $sql = 'UPDATE ' . $this->table_prefix . 'bbcodes
					SET ' . $this->db->sql_build_array('UPDATE', $bbcode_array) . '
					WHERE bbcode_id = ' . $bbcode_id;
                $this->db->sql_query($sql);
            } else {
                // Create new BBCode
                $sql = 'SELECT MAX(bbcode_id) AS max_bbcode_id
					FROM ' . $this->table_prefix . 'bbcodes';
                $result = $this->db->sql_query($sql);
                $row = $this->db->sql_fetchrow($result);
                $this->db->sql_freeresult($result);
                if ($row) {
                    $bbcode_id = $row['max_bbcode_id'] + 1;
                    // Make sure it is greater than the core BBCode ids...
                    if ($bbcode_id <= NUM_CORE_BBCODES) {
                        $bbcode_id = NUM_CORE_BBCODES + 1;
                    }
                } else {
                    $bbcode_id = NUM_CORE_BBCODES + 1;
                }
                if ($bbcode_id <= BBCODE_LIMIT) {
                    $bbcode_array['bbcode_id'] = (int) $bbcode_id;
                    $this->db->sql_query('INSERT INTO ' . $this->table_prefix . 'bbcodes ' . $this->db->sql_build_array('INSERT', $bbcode_array));
                }
            }
        }
    }
Пример #5
0
    public function install_bbcode_for_qr_2()
    {
        // Load the acp_bbcode class
        if (!class_exists('acp_bbcodes')) {
            include $this->phpbb_root_path . 'includes/acp/acp_bbcodes.' . $this->php_ext;
        }
        $bbcode_tool = new \acp_bbcodes();
        $bbcode_data = array('ref' => array('bbcode_helpline' => 'BBCode for QuickReply extension', 'bbcode_match' => '[ref]{TEXT}[/ref]', 'bbcode_tpl' => '<span style="font-weight: bold;">{TEXT}</span>', 'display_on_posting' => 0), 'ref=' => array('bbcode_helpline' => 'BBCode for QuickReply extension', 'bbcode_match' => '[ref={COLOR}]{TEXT}[/ref]', 'bbcode_tpl' => '<span style="font-weight: bold; color: {COLOR};">{TEXT}</span>', 'display_on_posting' => 0));
        foreach ($bbcode_data as $bbcode_name => $bbcode_array) {
            // Build the BBCodes
            $data = $bbcode_tool->build_regexp($bbcode_array['bbcode_match'], $bbcode_array['bbcode_tpl']);
            $bbcode_array += array('bbcode_tag' => $data['bbcode_tag'], 'first_pass_match' => $data['first_pass_match'], 'first_pass_replace' => $data['first_pass_replace'], 'second_pass_match' => $data['second_pass_match'], 'second_pass_replace' => $data['second_pass_replace']);
            $sql = 'SELECT bbcode_id
				FROM ' . $this->table_prefix . "bbcodes\n\t\t\t\tWHERE LOWER(bbcode_tag) = '" . strtolower($bbcode_name) . "'\n\t\t\t\tOR LOWER(bbcode_tag) = '" . strtolower($bbcode_array['bbcode_tag']) . "'";
            $result = $this->db->sql_query($sql);
            $row_exists = $this->db->sql_fetchrow($result);
            $this->db->sql_freeresult($result);
            if ($row_exists) {
                // Update exisiting BBCode
                $bbcode_id = $row_exists['bbcode_id'];
                $sql = 'UPDATE ' . $this->table_prefix . 'bbcodes
					SET ' . $this->db->sql_build_array('UPDATE', $bbcode_array) . '
					WHERE bbcode_id = ' . $bbcode_id;
                $this->db->sql_query($sql);
            } else {
                // Create new BBCode
                $sql = 'SELECT MAX(bbcode_id) AS max_bbcode_id
					FROM ' . $this->table_prefix . 'bbcodes';
                $result = $this->db->sql_query($sql);
                $row = $this->db->sql_fetchrow($result);
                $this->db->sql_freeresult($result);
                if ($row) {
                    $bbcode_id = $row['max_bbcode_id'] + 1;
                    // Make sure it is greater than the core BBCode ids...
                    if ($bbcode_id <= NUM_CORE_BBCODES) {
                        $bbcode_id = NUM_CORE_BBCODES + 1;
                    }
                } else {
                    $bbcode_id = NUM_CORE_BBCODES + 1;
                }
                if ($bbcode_id <= BBCODE_LIMIT) {
                    $bbcode_array['bbcode_id'] = (int) $bbcode_id;
                    //$bbcode_array['display_on_posting'] = 1;
                    $this->db->sql_query('INSERT INTO ' . $this->table_prefix . 'bbcodes ' . $this->db->sql_build_array('INSERT', $bbcode_array));
                }
            }
        }
    }
Пример #6
0
    /**
     * Installs BBCodes, used by migrations to perform add/updates
     *
     * @param array $bbcode_data Array of BBCode data to install
     * @return null
     * @access public
     */
    public function install_bbcodes($bbcode_data)
    {
        // Load the acp_bbcode class
        if (!class_exists('acp_bbcodes')) {
            include $this->phpbb_root_path . 'includes/acp/acp_bbcodes.' . $this->php_ext;
        }
        $bbcode_tool = new \acp_bbcodes();
        foreach ($bbcode_data as $bbcode_name => $bbcode_array) {
            // Build the BBCodes
            $data = $bbcode_tool->build_regexp($bbcode_array['bbcode_match'], $bbcode_array['bbcode_tpl']);
            $bbcode_array += array('bbcode_tag' => $data['bbcode_tag'], 'first_pass_match' => $data['first_pass_match'], 'first_pass_replace' => $data['first_pass_replace'], 'second_pass_match' => $data['second_pass_match'], 'second_pass_replace' => $data['second_pass_replace']);
            $sql = 'SELECT bbcode_id
				FROM ' . BBCODES_TABLE . "\n\t\t\t\tWHERE LOWER(bbcode_tag) = '" . strtolower($bbcode_name) . "'\n\t\t\t\tOR LOWER(bbcode_tag) = '" . strtolower($bbcode_array['bbcode_tag']) . "'";
            $result = $this->db->sql_query($sql);
            $row_exists = $this->db->sql_fetchrow($result);
            $this->db->sql_freeresult($result);
            if ($row_exists) {
                // Update existing BBCode
                $bbcode_id = $row_exists['bbcode_id'];
                $sql = 'UPDATE ' . BBCODES_TABLE . '
					SET ' . $this->db->sql_build_array('UPDATE', $bbcode_array) . '
					WHERE bbcode_id = ' . $bbcode_id;
                $this->db->sql_query($sql);
            } else {
                // Create new BBCode
                $sql = 'SELECT MAX(bbcode_id) AS max_bbcode_id
					FROM ' . BBCODES_TABLE;
                $result = $this->db->sql_query($sql);
                $row = $this->db->sql_fetchrow($result);
                $this->db->sql_freeresult($result);
                if ($row) {
                    $bbcode_id = $row['max_bbcode_id'] + 1;
                    // Make sure it is greater than the core BBCode ids...
                    if ($bbcode_id <= NUM_CORE_BBCODES) {
                        $bbcode_id = NUM_CORE_BBCODES + 1;
                    }
                } else {
                    $bbcode_id = NUM_CORE_BBCODES + 1;
                }
                if ($bbcode_id <= BBCODE_LIMIT) {
                    $bbcode_array['bbcode_id'] = (int) $bbcode_id;
                    $bbcode_array['display_on_posting'] = 0;
                    $this->db->sql_query('INSERT INTO ' . BBCODES_TABLE . ' ' . $this->db->sql_build_array('INSERT', $bbcode_array));
                }
            }
        }
    }
Пример #7
0
    public function install_bbcode_for_qr()
    {
        // Load the acp_bbcode class
        if (!class_exists('acp_bbcodes')) {
            include $this->phpbb_root_path . 'includes/acp/acp_bbcodes.' . $this->php_ext;
        }
        $bbcode_tool = new \acp_bbcodes();
        $bbcode_name = 'post';
        $bbcode_array = array('bbcode_helpline' => 'BBCode for QuickReply extension', 'bbcode_match' => '[post]{NUMBER}[/post]', 'bbcode_tpl' => '<a href="./viewtopic.php?p={NUMBER}#p{NUMBER}"><span class="imageset icon_topic_latest" title="{L_QR_BBPOST}">{L_QR_BBPOST}</span></a>', 'display_on_posting' => 0);
        // Build the BBCodes
        $data = $bbcode_tool->build_regexp($bbcode_array['bbcode_match'], $bbcode_array['bbcode_tpl']);
        $bbcode_array += array('bbcode_tag' => $data['bbcode_tag'], 'first_pass_match' => $data['first_pass_match'], 'first_pass_replace' => $data['first_pass_replace'], 'second_pass_match' => $data['second_pass_match'], 'second_pass_replace' => $data['second_pass_replace']);
        $sql = 'SELECT bbcode_id
			FROM ' . $this->table_prefix . "bbcodes\n\t\t\tWHERE LOWER(bbcode_tag) = '" . strtolower($bbcode_name) . "'\n\t\t\tOR LOWER(bbcode_tag) = '" . strtolower($bbcode_array['bbcode_tag']) . "'";
        $result = $this->db->sql_query($sql);
        $row_exists = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        if ($row_exists) {
            // Update exisiting BBCode
            $bbcode_id = $row_exists['bbcode_id'];
            $sql = 'UPDATE ' . $this->table_prefix . 'bbcodes
				SET ' . $this->db->sql_build_array('UPDATE', $bbcode_array) . '
				WHERE bbcode_id = ' . $bbcode_id;
            $this->db->sql_query($sql);
        } else {
            // Create new BBCode
            $sql = 'SELECT MAX(bbcode_id) AS max_bbcode_id
				FROM ' . $this->table_prefix . 'bbcodes';
            $result = $this->db->sql_query($sql);
            $row = $this->db->sql_fetchrow($result);
            $this->db->sql_freeresult($result);
            if ($row) {
                $bbcode_id = $row['max_bbcode_id'] + 1;
                // Make sure it is greater than the core BBCode ids...
                if ($bbcode_id <= NUM_CORE_BBCODES) {
                    $bbcode_id = NUM_CORE_BBCODES + 1;
                }
            } else {
                $bbcode_id = NUM_CORE_BBCODES + 1;
            }
            if ($bbcode_id <= BBCODE_LIMIT) {
                $bbcode_array['bbcode_id'] = (int) $bbcode_id;
                //$bbcode_array['display_on_posting'] = 1;
                $this->db->sql_query('INSERT INTO ' . $this->table_prefix . 'bbcodes ' . $this->db->sql_build_array('INSERT', $bbcode_array));
            }
        }
    }
Пример #8
0
    public function install_bbcode_for_travisbbcode()
    {
        if (!class_exists('acp_bbcodes')) {
            include $this->phpbb_root_path . 'includes/acp/acp_bbcodes.' . $this->php_ext;
        }
        $bbcode_tool = new \acp_bbcodes();
        $bbcode_name = 'travis';
        $bbcode_array = array('bbcode_match' => '[travis]{IDENTIFIER1}/{IDENTIFIER2}[/travis]', 'bbcode_tpl' => '<a href="https://travis-ci.org/{IDENTIFIER1}/{IDENTIFIER2}" title="{IDENTIFIER1}/{IDENTIFIER2}"><img src="https://travis-ci.org/{IDENTIFIER1}/{IDENTIFIER2}.svg?branch=master" alt="" style="margin-bottom: -5px;" /></a>', 'bbcode_helpline' => '[travis]yourvendor/yourextension[/travis]', 'display_on_posting' => 1);
        $data = $bbcode_tool->build_regexp($bbcode_array['bbcode_match'], $bbcode_array['bbcode_tpl'], $bbcode_array['bbcode_helpline']);
        $bbcode_array += array('bbcode_tag' => $data['bbcode_tag'], 'first_pass_match' => $data['first_pass_match'], 'first_pass_replace' => $data['first_pass_replace'], 'second_pass_match' => $data['second_pass_match'], 'second_pass_replace' => $data['second_pass_replace']);
        $sql = 'SELECT bbcode_id
			FROM ' . $this->table_prefix . "bbcodes\n\t\t\tWHERE LOWER(bbcode_tag) = '" . strtolower($bbcode_name) . "'\n\t\t\tOR LOWER(bbcode_tag) = '" . strtolower($bbcode_array['bbcode_tag']) . "'";
        $result = $this->db->sql_query($sql);
        $row_exists = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        if ($row_exists) {
            $bbcode_id = $row_exists['bbcode_id'];
            $sql = 'UPDATE ' . $this->table_prefix . 'bbcodes
				SET ' . $this->db->sql_build_array('UPDATE', $bbcode_array) . '
				WHERE bbcode_id = ' . $bbcode_id;
            $this->db->sql_query($sql);
        } else {
            $sql = 'SELECT MAX(bbcode_id) AS max_bbcode_id
				FROM ' . $this->table_prefix . 'bbcodes';
            $result = $this->db->sql_query($sql);
            $row = $this->db->sql_fetchrow($result);
            $this->db->sql_freeresult($result);
            if ($row) {
                $bbcode_id = $row['max_bbcode_id'] + 1;
                if ($bbcode_id <= NUM_CORE_BBCODES) {
                    $bbcode_id = NUM_CORE_BBCODES + 1;
                }
            } else {
                $bbcode_id = NUM_CORE_BBCODES + 1;
            }
            if ($bbcode_id <= BBCODE_LIMIT) {
                $bbcode_array['bbcode_id'] = (int) $bbcode_id;
                $this->db->sql_query('INSERT INTO ' . $this->table_prefix . 'bbcodes ' . $this->db->sql_build_array('INSERT', $bbcode_array));
            }
        }
    }
Пример #9
0
    public function install_bbcode_for_modxcommands()
    {
        if (!class_exists('acp_bbcodes')) {
            include $this->phpbb_root_path . 'includes/acp/acp_bbcodes.' . $this->php_ext;
        }
        $bbcode_tool = new \acp_bbcodes();
        $bbcode_name = 'install';
        $bbcode_array = array('bbcode_match' => '[install]{TEXT}[/install]', 'bbcode_tpl' => '<div class="inst-wrapper"><div class="inst-content">{TEXT}</div></div>', 'bbcode_helpline' => '', 'display_on_posting' => 0);
        $data = $bbcode_tool->build_regexp($bbcode_array['bbcode_match'], $bbcode_array['bbcode_tpl'], $bbcode_array['bbcode_helpline']);
        $bbcode_array += array('bbcode_tag' => $data['bbcode_tag'], 'first_pass_match' => $data['first_pass_match'], 'first_pass_replace' => $data['first_pass_replace'], 'second_pass_match' => $data['second_pass_match'], 'second_pass_replace' => $data['second_pass_replace']);
        $sql = 'SELECT bbcode_id
			FROM ' . $this->table_prefix . "bbcodes\n\t\t\tWHERE LOWER(bbcode_tag) = '" . strtolower($bbcode_name) . "'\n\t\t\tOR LOWER(bbcode_tag) = '" . strtolower($bbcode_array['bbcode_tag']) . "'";
        $result = $this->db->sql_query($sql);
        $row_exists = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        if ($row_exists) {
            $bbcode_id = $row_exists['bbcode_id'];
            $sql = 'UPDATE ' . $this->table_prefix . 'bbcodes
			SET ' . $this->db->sql_build_array('UPDATE', $bbcode_array) . '
			WHERE bbcode_id = ' . $bbcode_id;
            $this->db->sql_query($sql);
        } else {
            $sql = 'SELECT MAX(bbcode_id) AS max_bbcode_id
				FROM ' . $this->table_prefix . 'bbcodes';
            $result = $this->db->sql_query($sql);
            $row = $this->db->sql_fetchrow($result);
            $this->db->sql_freeresult($result);
            if ($row) {
                $bbcode_id = $row['max_bbcode_id'] + 1;
                if ($bbcode_id <= NUM_CORE_BBCODES) {
                    $bbcode_id = NUM_CORE_BBCODES + 1;
                }
            } else {
                $bbcode_id = NUM_CORE_BBCODES + 1;
            }
            if ($bbcode_id <= BBCODE_LIMIT) {
                $bbcode_array['bbcode_id'] = (int) $bbcode_id;
                $this->db->sql_query('INSERT INTO ' . $this->table_prefix . 'bbcodes ' . $this->db->sql_build_array('INSERT', $bbcode_array));
            }
        }
    }
Пример #10
0
function change_database_data(&$no_updates, $version)
{
    global $db, $db_tools, $errored, $error_ary, $config, $table_prefix, $phpbb_root_path, $phpEx;
    switch ($version) {
        case '3.0.0':
            $sql = 'UPDATE ' . TOPICS_TABLE . "\n\t\t\t\tSET topic_last_view_time = topic_last_post_time\n\t\t\t\tWHERE topic_last_view_time = 0";
            _sql($sql, $errored, $error_ary);
            // Update smiley sizes
            $smileys = array('icon_e_surprised.gif', 'icon_eek.gif', 'icon_cool.gif', 'icon_lol.gif', 'icon_mad.gif', 'icon_razz.gif', 'icon_redface.gif', 'icon_cry.gif', 'icon_evil.gif', 'icon_twisted.gif', 'icon_rolleyes.gif', 'icon_exclaim.gif', 'icon_question.gif', 'icon_idea.gif', 'icon_arrow.gif', 'icon_neutral.gif', 'icon_mrgreen.gif', 'icon_e_ugeek.gif');
            foreach ($smileys as $smiley) {
                if (file_exists($phpbb_root_path . 'images/smilies/' . $smiley)) {
                    list($width, $height) = getimagesize($phpbb_root_path . 'images/smilies/' . $smiley);
                    $sql = 'UPDATE ' . SMILIES_TABLE . '
						SET smiley_width = ' . $width . ', smiley_height = ' . $height . "\n\t\t\t\t\t\tWHERE smiley_url = '" . $db->sql_escape($smiley) . "'";
                    _sql($sql, $errored, $error_ary);
                }
            }
            $no_updates = false;
            break;
            // No changes from 3.0.1-RC1 to 3.0.1
        // No changes from 3.0.1-RC1 to 3.0.1
        case '3.0.1-RC1':
            break;
            // changes from 3.0.1 to 3.0.2-RC1
        // changes from 3.0.1 to 3.0.2-RC1
        case '3.0.1':
            set_config('referer_validation', '1');
            set_config('check_attachment_content', '1');
            set_config('mime_triggers', 'body|head|html|img|plaintext|a href|pre|script|table|title');
            $no_updates = false;
            break;
            // No changes from 3.0.2-RC1 to 3.0.2-RC2
        // No changes from 3.0.2-RC1 to 3.0.2-RC2
        case '3.0.2-RC1':
            break;
            // No changes from 3.0.2-RC2 to 3.0.2
        // No changes from 3.0.2-RC2 to 3.0.2
        case '3.0.2-RC2':
            break;
            // Changes from 3.0.2 to 3.0.3-RC1
        // Changes from 3.0.2 to 3.0.3-RC1
        case '3.0.2':
            set_config('enable_queue_trigger', '0');
            set_config('queue_trigger_posts', '3');
            set_config('pm_max_recipients', '0');
            // Set maximum number of recipients for the registered users, bots, guests group
            $sql = 'UPDATE ' . GROUPS_TABLE . ' SET group_max_recipients = 5
				WHERE ' . $db->sql_in_set('group_name', array('GUESTS', 'REGISTERED', 'REGISTERED_COPPA', 'BOTS'));
            _sql($sql, $errored, $error_ary);
            // Not prefilling yet
            set_config('dbms_version', '');
            // Add new permission u_masspm_group and duplicate settings from u_masspm
            include_once $phpbb_root_path . 'includes/acp/auth.' . $phpEx;
            $auth_admin = new auth_admin();
            // Only add the new permission if it does not already exist
            if (empty($auth_admin->acl_options['id']['u_masspm_group'])) {
                $auth_admin->acl_add_option(array('global' => array('u_masspm_group')));
                // Now the tricky part, filling the permission
                $old_id = $auth_admin->acl_options['id']['u_masspm'];
                $new_id = $auth_admin->acl_options['id']['u_masspm_group'];
                $tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE);
                foreach ($tables as $table) {
                    $sql = 'SELECT *
						FROM ' . $table . '
						WHERE auth_option_id = ' . $old_id;
                    $result = _sql($sql, $errored, $error_ary);
                    $sql_ary = array();
                    while ($row = $db->sql_fetchrow($result)) {
                        $row['auth_option_id'] = $new_id;
                        $sql_ary[] = $row;
                    }
                    $db->sql_freeresult($result);
                    if (sizeof($sql_ary)) {
                        $db->sql_multi_insert($table, $sql_ary);
                    }
                }
                // Remove any old permission entries
                $auth_admin->acl_clear_prefetch();
            }
            /**
            * Do not resync post counts here. An admin may do this later from the ACP
            $start = 0;
            $step = ($config['num_posts']) ? (max((int) ($config['num_posts'] / 5), 20000)) : 20000;
            
            $sql = 'UPDATE ' . USERS_TABLE . ' SET user_posts = 0';
            _sql($sql, $errored, $error_ary);
            
            do
            {
            	$sql = 'SELECT COUNT(post_id) AS num_posts, poster_id
            		FROM ' . POSTS_TABLE . '
            		WHERE post_id BETWEEN ' . ($start + 1) . ' AND ' . ($start + $step) . '
            			AND post_postcount = 1 AND post_approved = 1
            		GROUP BY poster_id';
            	$result = _sql($sql, $errored, $error_ary);
            
            	if ($row = $db->sql_fetchrow($result))
            	{
            		do
            		{
            			$sql = 'UPDATE ' . USERS_TABLE . " SET user_posts = user_posts + {$row['num_posts']} WHERE user_id = {$row['poster_id']}";
            			_sql($sql, $errored, $error_ary);
            		}
            		while ($row = $db->sql_fetchrow($result));
            
            		$start += $step;
            	}
            	else
            	{
            		$start = 0;
            	}
            	$db->sql_freeresult($result);
            }
            while ($start);
            */
            $sql = 'UPDATE ' . MODULES_TABLE . '
				SET module_auth = \'acl_a_email && cfg_email_enable\'
				WHERE module_class = \'acp\'
					AND module_basename = \'email\'';
            _sql($sql, $errored, $error_ary);
            $no_updates = false;
            break;
            // Changes from 3.0.3-RC1 to 3.0.3
        // Changes from 3.0.3-RC1 to 3.0.3
        case '3.0.3-RC1':
            if ($db->sql_layer == 'oracle') {
                // log_operation is CLOB - but we can change this later
                $sql = 'UPDATE ' . LOG_TABLE . "\n\t\t\t\t\tSET log_operation = 'LOG_DELETE_TOPIC'\n\t\t\t\t\tWHERE log_operation LIKE 'LOG_TOPIC_DELETED'";
                _sql($sql, $errored, $error_ary);
            } else {
                $sql = 'UPDATE ' . LOG_TABLE . "\n\t\t\t\t\tSET log_operation = 'LOG_DELETE_TOPIC'\n\t\t\t\t\tWHERE log_operation = 'LOG_TOPIC_DELETED'";
                _sql($sql, $errored, $error_ary);
            }
            $no_updates = false;
            break;
            // Changes from 3.0.3 to 3.0.4-RC1
        // Changes from 3.0.3 to 3.0.4-RC1
        case '3.0.3':
            // Update the Custom Profile Fields based on previous settings to the new format
            $sql = 'SELECT field_id, field_required, field_show_on_reg, field_hide
					FROM ' . PROFILE_FIELDS_TABLE;
            $result = _sql($sql, $errored, $error_ary);
            while ($row = $db->sql_fetchrow($result)) {
                $sql_ary = array('field_required' => 0, 'field_show_on_reg' => 0, 'field_hide' => 0, 'field_show_profile' => 0);
                if ($row['field_required']) {
                    $sql_ary['field_required'] = $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1;
                } else {
                    if ($row['field_show_on_reg']) {
                        $sql_ary['field_show_on_reg'] = $sql_ary['field_show_profile'] = 1;
                    } else {
                        if ($row['field_hide']) {
                            // Only administrators and moderators can see this CPF, if the view is enabled, they can see it, otherwise just admins in the acp_users module
                            $sql_ary['field_hide'] = 1;
                        } else {
                            // equivelant to "none", which is the "Display in user control panel" option
                            $sql_ary['field_show_profile'] = 1;
                        }
                    }
                }
                _sql('UPDATE ' . PROFILE_FIELDS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE field_id = ' . $row['field_id'], $errored, $error_ary);
            }
            $no_updates = false;
            break;
            // Changes from 3.0.4-RC1 to 3.0.4
        // Changes from 3.0.4-RC1 to 3.0.4
        case '3.0.4-RC1':
            break;
            // Changes from 3.0.4 to 3.0.5-RC1
        // Changes from 3.0.4 to 3.0.5-RC1
        case '3.0.4':
            // Captcha config variables
            set_config('captcha_gd_wave', 0);
            set_config('captcha_gd_3d_noise', 1);
            set_config('captcha_gd_fonts', 1);
            set_config('confirm_refresh', 1);
            // Maximum number of keywords
            set_config('max_num_search_keywords', 10);
            // Remove static config var and put it back as dynamic variable
            $sql = 'UPDATE ' . CONFIG_TABLE . "\n\t\t\t\tSET is_dynamic = 1\n\t\t\t\tWHERE config_name = 'search_indexing_state'";
            _sql($sql, $errored, $error_ary);
            // Hash old MD5 passwords
            $sql = 'SELECT user_id, user_password
					FROM ' . USERS_TABLE . '
					WHERE user_pass_convert = 1';
            $result = _sql($sql, $errored, $error_ary);
            while ($row = $db->sql_fetchrow($result)) {
                if (strlen($row['user_password']) == 32) {
                    $sql_ary = array('user_password' => phpbb_hash($row['user_password']));
                    _sql('UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE user_id = ' . $row['user_id'], $errored, $error_ary);
                }
            }
            $db->sql_freeresult($result);
            // Adjust bot entry
            $sql = 'UPDATE ' . BOTS_TABLE . "\n\t\t\t\tSET bot_agent = 'ichiro/'\n\t\t\t\tWHERE bot_agent = 'ichiro/2'";
            _sql($sql, $errored, $error_ary);
            // Before we are able to add a unique key to auth_option, we need to remove duplicate entries
            // We get duplicate entries first
            $sql = 'SELECT auth_option
				FROM ' . ACL_OPTIONS_TABLE . '
				GROUP BY auth_option
				HAVING COUNT(*) >= 2';
            $result = $db->sql_query($sql);
            $auth_options = array();
            while ($row = $db->sql_fetchrow($result)) {
                $auth_options[] = $row['auth_option'];
            }
            $db->sql_freeresult($result);
            // Remove specific auth options
            if (!empty($auth_options)) {
                foreach ($auth_options as $option) {
                    // Select auth_option_ids... the largest id will be preserved
                    $sql = 'SELECT auth_option_id
						FROM ' . ACL_OPTIONS_TABLE . "\n\t\t\t\t\t\tWHERE auth_option = '" . $db->sql_escape($option) . "'\n\t\t\t\t\t\tORDER BY auth_option_id DESC";
                    // sql_query_limit not possible here, due to bug in postgresql layer
                    $result = $db->sql_query($sql);
                    // Skip first row, this is our original auth option we want to preserve
                    $row = $db->sql_fetchrow($result);
                    while ($row = $db->sql_fetchrow($result)) {
                        // Ok, remove this auth option...
                        _sql('DELETE FROM ' . ACL_OPTIONS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary);
                        _sql('DELETE FROM ' . ACL_ROLES_DATA_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary);
                        _sql('DELETE FROM ' . ACL_GROUPS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary);
                        _sql('DELETE FROM ' . ACL_USERS_TABLE . ' WHERE auth_option_id = ' . $row['auth_option_id'], $errored, $error_ary);
                    }
                    $db->sql_freeresult($result);
                }
            }
            // Now make auth_option UNIQUE, by dropping the old index and adding a UNIQUE one.
            $changes = array('drop_keys' => array(ACL_OPTIONS_TABLE => array('auth_option')));
            $statements = $db_tools->perform_schema_changes($changes);
            foreach ($statements as $sql) {
                _sql($sql, $errored, $error_ary);
            }
            $changes = array('add_unique_index' => array(ACL_OPTIONS_TABLE => array('auth_option' => array('auth_option'))));
            $statements = $db_tools->perform_schema_changes($changes);
            foreach ($statements as $sql) {
                _sql($sql, $errored, $error_ary);
            }
            $no_updates = false;
            break;
            // No changes from 3.0.5-RC1 to 3.0.5
        // No changes from 3.0.5-RC1 to 3.0.5
        case '3.0.5-RC1':
            break;
            // Changes from 3.0.5 to 3.0.6-RC1
        // Changes from 3.0.5 to 3.0.6-RC1
        case '3.0.5':
            // Let's see if the GD Captcha can be enabled... we simply look for what *is* enabled...
            if (!empty($config['captcha_gd']) && !isset($config['captcha_plugin'])) {
                set_config('captcha_plugin', 'phpbb_captcha_gd');
            } else {
                if (!isset($config['captcha_plugin'])) {
                    set_config('captcha_plugin', 'phpbb_captcha_nogd');
                }
            }
            // Entries for the Feed Feature
            set_config('feed_enable', '0');
            set_config('feed_limit', '10');
            set_config('feed_overall_forums', '1');
            set_config('feed_overall_forums_limit', '15');
            set_config('feed_overall_topics', '0');
            set_config('feed_overall_topics_limit', '15');
            set_config('feed_forum', '1');
            set_config('feed_topic', '1');
            set_config('feed_item_statistics', '1');
            // Entries for smiley pagination
            set_config('smilies_per_page', '50');
            // Entry for reporting PMs
            set_config('allow_pm_report', '1');
            // Install modules
            $modules_to_install = array('feed' => array('base' => 'board', 'class' => 'acp', 'title' => 'ACP_FEED_SETTINGS', 'auth' => 'acl_a_board', 'cat' => 'ACP_BOARD_CONFIGURATION', 'after' => array('signature', 'ACP_SIGNATURE_SETTINGS')), 'warnings' => array('base' => 'users', 'class' => 'acp', 'title' => 'ACP_USER_WARNINGS', 'auth' => 'acl_a_user', 'display' => 0, 'cat' => 'ACP_CAT_USERS', 'after' => array('feedback', 'ACP_USER_FEEDBACK')), 'send_statistics' => array('base' => 'send_statistics', 'class' => 'acp', 'title' => 'ACP_SEND_STATISTICS', 'auth' => 'acl_a_server', 'cat' => 'ACP_SERVER_CONFIGURATION'), 'setting_forum_copy' => array('base' => 'permissions', 'class' => 'acp', 'title' => 'ACP_FORUM_PERMISSIONS_COPY', 'auth' => 'acl_a_fauth && acl_a_authusers && acl_a_authgroups && acl_a_mauth', 'cat' => 'ACP_FORUM_BASED_PERMISSIONS', 'after' => array('setting_forum_local', 'ACP_FORUM_PERMISSIONS')), 'pm_reports' => array('base' => 'pm_reports', 'class' => 'mcp', 'title' => 'MCP_PM_REPORTS_OPEN', 'auth' => 'aclf_m_report', 'cat' => 'MCP_REPORTS'), 'pm_reports_closed' => array('base' => 'pm_reports', 'class' => 'mcp', 'title' => 'MCP_PM_REPORTS_CLOSED', 'auth' => 'aclf_m_report', 'cat' => 'MCP_REPORTS'), 'pm_report_details' => array('base' => 'pm_reports', 'class' => 'mcp', 'title' => 'MCP_PM_REPORT_DETAILS', 'auth' => 'aclf_m_report', 'cat' => 'MCP_REPORTS'));
            _add_modules($modules_to_install);
            // Add newly_registered group... but check if it already exists (we always supported running the updater on any schema)
            $sql = 'SELECT group_id
				FROM ' . GROUPS_TABLE . "\n\t\t\t\tWHERE group_name = 'NEWLY_REGISTERED'";
            $result = $db->sql_query($sql);
            $group_id = (int) $db->sql_fetchfield('group_id');
            $db->sql_freeresult($result);
            if (!$group_id) {
                $sql = 'INSERT INTO ' . GROUPS_TABLE . " (group_name, group_type, group_founder_manage, group_colour, group_legend, group_avatar, group_desc, group_desc_uid, group_max_recipients) VALUES ('NEWLY_REGISTERED', 3, 0, '', 0, '', '', '', 5)";
                _sql($sql, $errored, $error_ary);
                $group_id = $db->sql_nextid();
            }
            // Insert new user role... at the end of the chain
            $sql = 'SELECT role_id
				FROM ' . ACL_ROLES_TABLE . "\n\t\t\t\tWHERE role_name = 'ROLE_USER_NEW_MEMBER'\n\t\t\t\t\tAND role_type = 'u_'";
            $result = $db->sql_query($sql);
            $u_role = (int) $db->sql_fetchfield('role_id');
            $db->sql_freeresult($result);
            if (!$u_role) {
                $sql = 'SELECT MAX(role_order) as max_order_id
					FROM ' . ACL_ROLES_TABLE . "\n\t\t\t\t\tWHERE role_type = 'u_'";
                $result = $db->sql_query($sql);
                $next_order_id = (int) $db->sql_fetchfield('max_order_id');
                $db->sql_freeresult($result);
                $next_order_id++;
                $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES ('ROLE_USER_NEW_MEMBER', 'ROLE_DESCRIPTION_USER_NEW_MEMBER', 'u_', {$next_order_id})";
                _sql($sql, $errored, $error_ary);
                $u_role = $db->sql_nextid();
                if (!$errored) {
                    // Now add the correct data to the roles...
                    // The standard role says that new users are not able to send a PM, Mass PM, are not able to PM groups
                    $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT {$u_role}, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'u_%' AND auth_option IN ('u_sendpm', 'u_masspm', 'u_masspm_group')";
                    _sql($sql, $errored, $error_ary);
                    // Add user role to group
                    $sql = 'INSERT INTO ' . ACL_GROUPS_TABLE . " (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES ({$group_id}, 0, 0, {$u_role}, 0)";
                    _sql($sql, $errored, $error_ary);
                }
            }
            // Insert new forum role
            $sql = 'SELECT role_id
				FROM ' . ACL_ROLES_TABLE . "\n\t\t\t\tWHERE role_name = 'ROLE_FORUM_NEW_MEMBER'\n\t\t\t\t\tAND role_type = 'f_'";
            $result = $db->sql_query($sql);
            $f_role = (int) $db->sql_fetchfield('role_id');
            $db->sql_freeresult($result);
            if (!$f_role) {
                $sql = 'SELECT MAX(role_order) as max_order_id
					FROM ' . ACL_ROLES_TABLE . "\n\t\t\t\t\tWHERE role_type = 'f_'";
                $result = $db->sql_query($sql);
                $next_order_id = (int) $db->sql_fetchfield('max_order_id');
                $db->sql_freeresult($result);
                $next_order_id++;
                $sql = 'INSERT INTO ' . ACL_ROLES_TABLE . " (role_name, role_description, role_type, role_order) VALUES  ('ROLE_FORUM_NEW_MEMBER', 'ROLE_DESCRIPTION_FORUM_NEW_MEMBER', 'f_', {$next_order_id})";
                _sql($sql, $errored, $error_ary);
                $f_role = $db->sql_nextid();
                if (!$errored) {
                    $sql = 'INSERT INTO ' . ACL_ROLES_DATA_TABLE . " (role_id, auth_option_id, auth_setting) SELECT {$f_role}, auth_option_id, 0 FROM " . ACL_OPTIONS_TABLE . " WHERE auth_option LIKE 'f_%' AND auth_option IN ('f_noapprove')";
                    _sql($sql, $errored, $error_ary);
                }
            }
            // Set every members user_new column to 0 (old users) only if there is no one yet (this makes sure we do not execute this more than once)
            $sql = 'SELECT 1
				FROM ' . USERS_TABLE . '
				WHERE user_new = 0';
            $result = $db->sql_query_limit($sql, 1);
            $row = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            if (!$row) {
                $sql = 'UPDATE ' . USERS_TABLE . ' SET user_new = 0';
                _sql($sql, $errored, $error_ary);
            }
            // Newly registered users limit
            if (!isset($config['new_member_post_limit'])) {
                set_config('new_member_post_limit', !empty($config['enable_queue_trigger']) ? $config['queue_trigger_posts'] : 0);
            }
            if (!isset($config['new_member_group_default'])) {
                set_config('new_member_group_default', 0);
            }
            // To mimick the old "feature" we will assign the forum role to every forum, regardless of the setting (this makes sure there are no "this does not work!!!! YUO!!!" posts...
            // Check if the role is already assigned...
            $sql = 'SELECT forum_id
				FROM ' . ACL_GROUPS_TABLE . '
				WHERE group_id = ' . $group_id . '
					AND auth_role_id = ' . $f_role;
            $result = $db->sql_query($sql);
            $is_options = (int) $db->sql_fetchfield('forum_id');
            $db->sql_freeresult($result);
            // Not assigned at all... :/
            if (!$is_options) {
                // Get postable forums
                $sql = 'SELECT forum_id
					FROM ' . FORUMS_TABLE . '
					WHERE forum_type != ' . FORUM_LINK;
                $result = $db->sql_query($sql);
                while ($row = $db->sql_fetchrow($result)) {
                    _sql('INSERT INTO ' . ACL_GROUPS_TABLE . ' (group_id, forum_id, auth_option_id, auth_role_id, auth_setting) VALUES (' . $group_id . ', ' . (int) $row['forum_id'] . ', 0, ' . $f_role . ', 0)', $errored, $error_ary);
                }
                $db->sql_freeresult($result);
            }
            // Clear permissions...
            include_once $phpbb_root_path . 'includes/acp/auth.' . $phpEx;
            $auth_admin = new auth_admin();
            $auth_admin->acl_clear_prefetch();
            if (!isset($config['allow_avatar'])) {
                if ($config['allow_avatar_upload'] || $config['allow_avatar_local'] || $config['allow_avatar_remote']) {
                    set_config('allow_avatar', '1');
                } else {
                    set_config('allow_avatar', '0');
                }
            }
            if (!isset($config['allow_avatar_remote_upload'])) {
                if ($config['allow_avatar_remote'] && $config['allow_avatar_upload']) {
                    set_config('allow_avatar_remote_upload', '1');
                } else {
                    set_config('allow_avatar_remote_upload', '0');
                }
            }
            // Minimum number of characters
            if (!isset($config['min_post_chars'])) {
                set_config('min_post_chars', '1');
            }
            if (!isset($config['allow_quick_reply'])) {
                set_config('allow_quick_reply', '1');
            }
            // Set every members user_options column to enable
            // bbcode, smilies and URLs for signatures by default
            $sql = 'SELECT user_options
				FROM ' . USERS_TABLE . '
				WHERE user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ')';
            $result = $db->sql_query_limit($sql, 1);
            $user_option = (int) $db->sql_fetchfield('user_options');
            $db->sql_freeresult($result);
            // Check if we already updated the database by checking bit 15 which we used to store the sig_bbcode option
            if (!($user_option & 1 << 15)) {
                // 229376 is the added value to enable all three signature options
                $sql = 'UPDATE ' . USERS_TABLE . ' SET user_options = user_options + 229376';
                _sql($sql, $errored, $error_ary);
            }
            if (!isset($config['delete_time'])) {
                set_config('delete_time', $config['edit_time']);
            }
            $no_updates = false;
            break;
            // No changes from 3.0.6-RC1 to 3.0.6-RC2
        // No changes from 3.0.6-RC1 to 3.0.6-RC2
        case '3.0.6-RC1':
            break;
            // Changes from 3.0.6-RC2 to 3.0.6-RC3
        // Changes from 3.0.6-RC2 to 3.0.6-RC3
        case '3.0.6-RC2':
            // Update the Custom Profile Fields based on previous settings to the new format
            $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . '
				SET field_show_on_vt = 1
				WHERE field_hide = 0
					AND (field_required = 1 OR field_show_on_reg = 1 OR field_show_profile = 1)';
            _sql($sql, $errored, $error_ary);
            $no_updates = false;
            break;
            // No changes from 3.0.6-RC3 to 3.0.6-RC4
        // No changes from 3.0.6-RC3 to 3.0.6-RC4
        case '3.0.6-RC3':
            break;
            // No changes from 3.0.6-RC4 to 3.0.6
        // No changes from 3.0.6-RC4 to 3.0.6
        case '3.0.6-RC4':
            break;
            // Changes from 3.0.6 to 3.0.7-RC1
        // Changes from 3.0.6 to 3.0.7-RC1
        case '3.0.6':
            // ATOM Feeds
            set_config('feed_overall', '1');
            set_config('feed_http_auth', '0');
            set_config('feed_limit_post', (string) (isset($config['feed_limit']) ? (int) $config['feed_limit'] : 15));
            set_config('feed_limit_topic', (string) (isset($config['feed_overall_topics_limit']) ? (int) $config['feed_overall_topics_limit'] : 10));
            set_config('feed_topics_new', !empty($config['feed_overall_topics']) ? '1' : '0');
            set_config('feed_topics_active', !empty($config['feed_overall_topics']) ? '1' : '0');
            // Delete all text-templates from the template_data
            $sql = 'DELETE FROM ' . STYLES_TEMPLATE_DATA_TABLE . '
				WHERE template_filename ' . $db->sql_like_expression($db->any_char . '.txt');
            _sql($sql, $errored, $error_ary);
            $no_updates = false;
            break;
            // Changes from 3.0.7-RC1 to 3.0.7-RC2
        // Changes from 3.0.7-RC1 to 3.0.7-RC2
        case '3.0.7-RC1':
            $sql = 'SELECT user_id, user_email, user_email_hash
				FROM ' . USERS_TABLE . '
				WHERE user_type <> ' . USER_IGNORE . "\n\t\t\t\t\tAND user_email <> ''";
            $result = $db->sql_query($sql);
            $i = 0;
            while ($row = $db->sql_fetchrow($result)) {
                // Snapshot of the phpbb_email_hash() function
                // We cannot call it directly because the auto updater updates the DB first. :/
                $user_email_hash = sprintf('%u', crc32(strtolower($row['user_email']))) . strlen($row['user_email']);
                if ($user_email_hash != $row['user_email_hash']) {
                    $sql_ary = array('user_email_hash' => $user_email_hash);
                    $sql = 'UPDATE ' . USERS_TABLE . '
						SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
						WHERE user_id = ' . (int) $row['user_id'];
                    _sql($sql, $errored, $error_ary, $i % 100 == 0);
                    ++$i;
                }
            }
            $db->sql_freeresult($result);
            $no_updates = false;
            break;
            // No changes from 3.0.7-RC2 to 3.0.7
        // No changes from 3.0.7-RC2 to 3.0.7
        case '3.0.7-RC2':
            break;
            // No changes from 3.0.7 to 3.0.7-PL1
        // No changes from 3.0.7 to 3.0.7-PL1
        case '3.0.7':
            break;
            // Changes from 3.0.7-PL1 to 3.0.8-RC1
        // Changes from 3.0.7-PL1 to 3.0.8-RC1
        case '3.0.7-PL1':
            // Update file extension group names to use language strings.
            $sql = 'SELECT lang_dir
				FROM ' . LANG_TABLE;
            $result = $db->sql_query($sql);
            $extension_groups_updated = array();
            while ($lang_dir = $db->sql_fetchfield('lang_dir')) {
                $lang_dir = basename($lang_dir);
                // The language strings we need are either in language/.../acp/attachments.php
                // in the update package if we're updating to 3.0.8-RC1 or later,
                // or they are in language/.../install.php when we're updating from 3.0.7-PL1 or earlier.
                // On an already updated board, they can also already be in language/.../acp/attachments.php
                // in the board root.
                $lang_files = array("{$phpbb_root_path}install/update/new/language/{$lang_dir}/acp/attachments.{$phpEx}", "{$phpbb_root_path}language/{$lang_dir}/install.{$phpEx}", "{$phpbb_root_path}language/{$lang_dir}/acp/attachments.{$phpEx}");
                foreach ($lang_files as $lang_file) {
                    if (!file_exists($lang_file)) {
                        continue;
                    }
                    $lang = array();
                    include $lang_file;
                    foreach ($lang as $lang_key => $lang_val) {
                        if (isset($extension_groups_updated[$lang_key]) || strpos($lang_key, 'EXT_GROUP_') !== 0) {
                            continue;
                        }
                        $sql_ary = array('group_name' => substr($lang_key, 10));
                        $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . '
							SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\t\t\t\tWHERE group_name = '" . $db->sql_escape($lang_val) . "'";
                        _sql($sql, $errored, $error_ary);
                        $extension_groups_updated[$lang_key] = true;
                    }
                }
            }
            $db->sql_freeresult($result);
            // Install modules
            $modules_to_install = array('post' => array('base' => 'board', 'class' => 'acp', 'title' => 'ACP_POST_SETTINGS', 'auth' => 'acl_a_board', 'cat' => 'ACP_MESSAGES', 'after' => array('message', 'ACP_MESSAGE_SETTINGS')));
            _add_modules($modules_to_install);
            // update
            $sql = 'UPDATE ' . MODULES_TABLE . '
				SET module_auth = \'cfg_allow_avatar && (cfg_allow_avatar_local || cfg_allow_avatar_remote || cfg_allow_avatar_upload || cfg_allow_avatar_remote_upload)\'
				WHERE module_class = \'ucp\'
					AND module_basename = \'profile\'
					AND module_mode = \'avatar\'';
            _sql($sql, $errored, $error_ary);
            // add Bing Bot
            $bot_name = 'Bing [Bot]';
            $bot_name_clean = utf8_clean_string($bot_name);
            $sql = 'SELECT user_id
				FROM ' . USERS_TABLE . "\n\t\t\t\tWHERE username_clean = '" . $db->sql_escape($bot_name_clean) . "'";
            $result = $db->sql_query($sql);
            $bing_already_added = (bool) $db->sql_fetchfield('user_id');
            $db->sql_freeresult($result);
            if (!$bing_already_added) {
                $bot_agent = 'bingbot/';
                $bot_ip = '';
                $sql = 'SELECT group_id, group_colour
					FROM ' . GROUPS_TABLE . "\n\t\t\t\t\tWHERE group_name = 'BOTS'";
                $result = $db->sql_query($sql);
                $group_row = $db->sql_fetchrow($result);
                $db->sql_freeresult($result);
                if (!$group_row) {
                    // default fallback, should never get here
                    $group_row['group_id'] = 6;
                    $group_row['group_colour'] = '9E8DA7';
                }
                if (!function_exists('user_add')) {
                    include $phpbb_root_path . 'includes/functions_user.' . $phpEx;
                }
                $user_row = array('user_type' => USER_IGNORE, 'group_id' => $group_row['group_id'], 'username' => $bot_name, 'user_regdate' => time(), 'user_password' => '', 'user_colour' => $group_row['group_colour'], 'user_email' => '', 'user_lang' => $config['default_lang'], 'user_style' => $config['default_style'], 'user_timezone' => 0, 'user_dateformat' => $config['default_dateformat'], 'user_allow_massemail' => 0);
                $user_id = user_add($user_row);
                $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $db->sql_build_array('INSERT', array('bot_active' => 1, 'bot_name' => (string) $bot_name, 'user_id' => (int) $user_id, 'bot_agent' => (string) $bot_agent, 'bot_ip' => (string) $bot_ip));
                _sql($sql, $errored, $error_ary);
            }
            // end Bing Bot addition
            // Delete shadow topics pointing to not existing topics
            $batch_size = 500;
            // Set of affected forums we have to resync
            $sync_forum_ids = array();
            do {
                $sql_array = array('SELECT' => 't1.topic_id, t1.forum_id', 'FROM' => array(TOPICS_TABLE => 't1'), 'LEFT_JOIN' => array(array('FROM' => array(TOPICS_TABLE => 't2'), 'ON' => 't1.topic_moved_id = t2.topic_id')), 'WHERE' => 't1.topic_moved_id <> 0
								AND t2.topic_id IS NULL');
                $sql = $db->sql_build_query('SELECT', $sql_array);
                $result = $db->sql_query_limit($sql, $batch_size);
                $topic_ids = array();
                while ($row = $db->sql_fetchrow($result)) {
                    $topic_ids[] = (int) $row['topic_id'];
                    $sync_forum_ids[(int) $row['forum_id']] = (int) $row['forum_id'];
                }
                $db->sql_freeresult($result);
                if (!empty($topic_ids)) {
                    $sql = 'DELETE FROM ' . TOPICS_TABLE . '
						WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
                    $db->sql_query($sql);
                }
            } while (sizeof($topic_ids) == $batch_size);
            // Sync the forums we have deleted shadow topics from.
            sync('forum', 'forum_id', $sync_forum_ids, true, true);
            // Unread posts search load switch
            set_config('load_unreads_search', '1');
            // Reduce queue interval to 60 seconds, email package size to 20
            if ($config['queue_interval'] == 600) {
                set_config('queue_interval', '60');
            }
            if ($config['email_package_size'] == 50) {
                set_config('email_package_size', '20');
            }
            $no_updates = false;
            break;
            // No changes from 3.0.8-RC1 to 3.0.8
        // No changes from 3.0.8-RC1 to 3.0.8
        case '3.0.8-RC1':
            break;
            // Changes from 3.0.8 to 3.0.9-RC1
        // Changes from 3.0.8 to 3.0.9-RC1
        case '3.0.8':
            set_config('ip_login_limit_max', '50');
            set_config('ip_login_limit_time', '21600');
            set_config('ip_login_limit_use_forwarded', '0');
            // Update file extension group names to use language strings, again.
            $sql = 'SELECT group_id, group_name
				FROM ' . EXTENSION_GROUPS_TABLE . '
				WHERE group_name ' . $db->sql_like_expression('EXT_GROUP_' . $db->any_char);
            $result = $db->sql_query($sql);
            while ($row = $db->sql_fetchrow($result)) {
                $sql_ary = array('group_name' => substr($row['group_name'], 10));
                $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . '
					SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
					WHERE group_id = ' . $row['group_id'];
                _sql($sql, $errored, $error_ary);
            }
            $db->sql_freeresult($result);
            /*
            * Due to a bug, vanilla phpbb could not create captcha tables
            * in 3.0.8 on firebird. It was possible for board administrators
            * to adjust the code to work. If code was manually adjusted by
            * board administrators, index names would not be the same as
            * what 3.0.9 and newer expect. This code fragment drops captcha
            * tables, destroying all entered Q&A captcha configuration, such
            * that when Q&A is configured next the respective tables will be
            * created with correct index names.
            *
            * If you wish to preserve your Q&A captcha configuration, you can
            * manually rename indexes to the currently expected name:
            * 	phpbb_captcha_questions_lang_iso	=> phpbb_captcha_questions_lang
            * 	phpbb_captcha_answers_question_id	=> phpbb_captcha_answers_qid
            *
            * Again, this needs to be done only if a board was manually modified
            * to fix broken captcha code.
            *
            if ($db_tools->sql_layer == 'firebird')
            {
            	$changes = array(
            		'drop_tables'	=> array(
            			$table_prefix . 'captcha_questions',
            			$table_prefix . 'captcha_answers',
            			$table_prefix . 'qa_confirm',
            		),
            	);
            	$statements = $db_tools->perform_schema_changes($changes);
            
            	foreach ($statements as $sql)
            	{
            		_sql($sql, $errored, $error_ary);
            	}
            }
            */
            $no_updates = false;
            break;
            // No changes from 3.0.9-RC1 to 3.0.9-RC2
        // No changes from 3.0.9-RC1 to 3.0.9-RC2
        case '3.0.9-RC1':
            break;
            // No changes from 3.0.9-RC2 to 3.0.9-RC3
        // No changes from 3.0.9-RC2 to 3.0.9-RC3
        case '3.0.9-RC2':
            break;
            // No changes from 3.0.9-RC3 to 3.0.9-RC4
        // No changes from 3.0.9-RC3 to 3.0.9-RC4
        case '3.0.9-RC3':
            break;
            // No changes from 3.0.9-RC4 to 3.0.9
        // No changes from 3.0.9-RC4 to 3.0.9
        case '3.0.9-RC4':
            break;
            // Changes from 3.0.9 to 3.0.10-RC1
        // Changes from 3.0.9 to 3.0.10-RC1
        case '3.0.9':
            if (!isset($config['email_max_chunk_size'])) {
                set_config('email_max_chunk_size', '50');
            }
            $no_updates = false;
            break;
            // No changes from 3.0.10-RC1 to 3.0.10-RC2
        // No changes from 3.0.10-RC1 to 3.0.10-RC2
        case '3.0.10-RC1':
            break;
            // No changes from 3.0.10-RC2 to 3.0.10-RC3
        // No changes from 3.0.10-RC2 to 3.0.10-RC3
        case '3.0.10-RC2':
            break;
            // No changes from 3.0.10-RC3 to 3.0.10
        // No changes from 3.0.10-RC3 to 3.0.10
        case '3.0.10-RC3':
            break;
            // Changes from 3.0.10 to 3.0.11-RC1
        // Changes from 3.0.10 to 3.0.11-RC1
        case '3.0.10':
            // Updates users having current style a deactivated one
            $sql = 'SELECT style_id
				FROM ' . STYLES_TABLE . '
				WHERE style_active = 0';
            $result = $db->sql_query($sql);
            $deactivated_style_ids = array();
            while ($style_id = $db->sql_fetchfield('style_id', false, $result)) {
                $deactivated_style_ids[] = (int) $style_id;
            }
            $db->sql_freeresult($result);
            if (!empty($deactivated_style_ids)) {
                $sql = 'UPDATE ' . USERS_TABLE . '
					SET user_style = ' . (int) $config['default_style'] . '
					WHERE ' . $db->sql_in_set('user_style', $deactivated_style_ids);
                _sql($sql, $errored, $error_ary);
            }
            // Delete orphan private messages
            $batch_size = 500;
            $sql_array = array('SELECT' => 'p.msg_id', 'FROM' => array(PRIVMSGS_TABLE => 'p'), 'LEFT_JOIN' => array(array('FROM' => array(PRIVMSGS_TO_TABLE => 't'), 'ON' => 'p.msg_id = t.msg_id')), 'WHERE' => 't.user_id IS NULL');
            $sql = $db->sql_build_query('SELECT', $sql_array);
            do {
                $result = $db->sql_query_limit($sql, $batch_size);
                $delete_pms = array();
                while ($row = $db->sql_fetchrow($result)) {
                    $delete_pms[] = (int) $row['msg_id'];
                }
                $db->sql_freeresult($result);
                if (!empty($delete_pms)) {
                    $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . '
						WHERE ' . $db->sql_in_set('msg_id', $delete_pms);
                    _sql($sql, $errored, $error_ary);
                }
            } while (sizeof($delete_pms) == $batch_size);
            $no_updates = false;
            break;
            // No changes from 3.0.11-RC1 to 3.0.11-RC2
        // No changes from 3.0.11-RC1 to 3.0.11-RC2
        case '3.0.11-RC1':
            break;
            // No changes from 3.0.11-RC2 to 3.0.11
        // No changes from 3.0.11-RC2 to 3.0.11
        case '3.0.11-RC2':
            break;
            // Changes from 3.0.11 to 3.0.12-RC1
        // Changes from 3.0.11 to 3.0.12-RC1
        case '3.0.11':
            $sql = 'UPDATE ' . MODULES_TABLE . '
				SET module_auth = \'acl_u_sig\'
				WHERE module_class = \'ucp\'
					AND module_basename = \'profile\'
					AND module_mode = \'signature\'';
            _sql($sql, $errored, $error_ary);
            // Update bots
            if (!function_exists('user_delete')) {
                include $phpbb_root_path . 'includes/functions_user.' . $phpEx;
            }
            $bots_updates = array('NG-Search [Bot]' => false, 'Nutch/CVS [Bot]' => false, 'OmniExplorer [Bot]' => false, 'Seekport [Bot]' => false, 'Synoo [Bot]' => false, 'WiseNut [Bot]' => false, 'Baidu [Spider]' => 'Baiduspider', 'Exabot [Bot]' => 'Exabot', 'Voyager [Bot]' => 'voyager/', 'W3C [Validator]' => 'W3C_Validator');
            foreach ($bots_updates as $bot_name => $bot_agent) {
                $sql = 'SELECT user_id
					FROM ' . USERS_TABLE . '
					WHERE user_type = ' . USER_IGNORE . "\n\t\t\t\t\t\tAND username_clean = '" . $db->sql_escape(utf8_clean_string($bot_name)) . "'";
                $result = $db->sql_query($sql);
                $bot_user_id = (int) $db->sql_fetchfield('user_id');
                $db->sql_freeresult($result);
                if ($bot_user_id) {
                    if ($bot_agent === false) {
                        $sql = 'DELETE FROM ' . BOTS_TABLE . "\n\t\t\t\t\t\t\tWHERE user_id = {$bot_user_id}";
                        _sql($sql, $errored, $error_ary);
                        user_delete('remove', $bot_user_id);
                    } else {
                        $sql = 'UPDATE ' . BOTS_TABLE . "\n\t\t\t\t\t\t\tSET bot_agent = '" . $db->sql_escape($bot_agent) . "'\n\t\t\t\t\t\t\tWHERE user_id = {$bot_user_id}";
                        _sql($sql, $errored, $error_ary);
                    }
                }
            }
            // Disable receiving pms for bots
            $sql = 'SELECT user_id
				FROM ' . BOTS_TABLE;
            $result = $db->sql_query($sql);
            $bot_user_ids = array();
            while ($row = $db->sql_fetchrow($result)) {
                $bot_user_ids[] = (int) $row['user_id'];
            }
            $db->sql_freeresult($result);
            if (!empty($bot_user_ids)) {
                $sql = 'UPDATE ' . USERS_TABLE . '
					SET user_allow_pm = 0
					WHERE ' . $db->sql_in_set('user_id', $bot_user_ids);
                _sql($sql, $errored, $error_ary);
            }
            /**
             * Update BBCodes that currently use the LOCAL_URL tag
             *
             * To fix http://tracker.phpbb.com/browse/PHPBB3-8319 we changed
             * the second_pass_replace value, so that needs updating for existing ones
             */
            $sql = 'SELECT *
				FROM ' . BBCODES_TABLE . '
				WHERE bbcode_match ' . $db->sql_like_expression($db->any_char . 'LOCAL_URL' . $db->any_char);
            $result = $db->sql_query($sql);
            while ($row = $db->sql_fetchrow($result)) {
                if (!class_exists('acp_bbcodes')) {
                    phpbb_require_updated('includes/acp/acp_bbcodes.' . $phpEx);
                }
                $bbcode_match = $row['bbcode_match'];
                $bbcode_tpl = $row['bbcode_tpl'];
                $acp_bbcodes = new acp_bbcodes();
                $sql_ary = $acp_bbcodes->build_regexp($bbcode_match, $bbcode_tpl);
                $sql = 'UPDATE ' . BBCODES_TABLE . '
					SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
					WHERE bbcode_id = ' . (int) $row['bbcode_id'];
                $db->sql_query($sql);
            }
            $db->sql_freeresult($result);
            $no_updates = false;
            break;
            // No changes from 3.0.12-RC1 to 3.0.12-RC2
        // No changes from 3.0.12-RC1 to 3.0.12-RC2
        case '3.0.12-RC1':
            break;
            // No changes from 3.0.12-RC2 to 3.0.12-RC3
        // No changes from 3.0.12-RC2 to 3.0.12-RC3
        case '3.0.12-RC2':
            break;
            // No changes from 3.0.12-RC3 to 3.0.12
        // No changes from 3.0.12-RC3 to 3.0.12
        case '3.0.12-RC3':
            break;
            // No changes from 3.0.12 to 3.0.13-RC1
        // No changes from 3.0.12 to 3.0.13-RC1
        case '3.0.12':
            break;
            // No changes from 3.0.13-RC1 to 3.0.13
        // No changes from 3.0.13-RC1 to 3.0.13
        case '3.0.13-RC1':
            break;
            // No changes from 3.0.13 to 3.0.13-PL1
        // No changes from 3.0.13 to 3.0.13-PL1
        case '3.0.13':
            break;
            // No changes from 3.0.13-PL1 to 3.0.14-RC1
        // No changes from 3.0.13-PL1 to 3.0.14-RC1
        case '3.0.13-PL1':
            break;
            // No changes from 3.0.14-RC1 to 3.0.14
        // No changes from 3.0.14-RC1 to 3.0.14
        case '3.0.14-RC1':
            break;
    }
}
function add_bbcode($album_bbcode)
{
    global $cache, $config, $db, $phpbb_root_path, $phpEx;
    if (!class_exists('acp_bbcodes')) {
        include $phpbb_root_path . 'includes/acp/acp_bbcodes.' . $phpEx;
    }
    $acp_bbcodes = new acp_bbcodes();
    $gallery_url = generate_board_url() . '/' . GALLERY_ROOT_PATH;
    $bbcode_match = '[' . $album_bbcode . ']{NUMBER}[/' . $album_bbcode . ']';
    $bbcode_tpl = '<a href="' . $gallery_url . 'image.php?image_id={NUMBER}"><img src="' . $gallery_url . 'image.php?mode=thumbnail&amp;image_id={NUMBER}" alt="{NUMBER}" /></a>';
    $sql_ary = $acp_bbcodes->build_regexp($bbcode_match, $bbcode_tpl);
    $sql_ary = array_merge($sql_ary, array('bbcode_match' => $bbcode_match, 'bbcode_tpl' => $bbcode_tpl, 'display_on_posting' => true, 'bbcode_helpline' => 'GALLERY_HELPLINE_ALBUM'));
    $sql = 'UPDATE ' . BBCODES_TABLE . '
		SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\tWHERE bbcode_tag = '" . $db->sql_escape($sql_ary['bbcode_tag']) . "'";
    $db->sql_query($sql);
    if ($db->sql_affectedrows() <= 1) {
        $sql = 'SELECT bbcode_id
			FROM ' . BBCODES_TABLE . "\n\t\t\tWHERE bbcode_tag = '" . $db->sql_escape($sql_ary['bbcode_tag']) . "'";
        $result = $db->sql_query($sql);
        $bbcode_id = (int) $db->sql_fetchfield('bbcode_id');
        $db->sql_freeresult($result);
        if (!$bbcode_id) {
            $sql = 'SELECT bbcode_id
				FROM ' . BBCODES_TABLE . "\n\t\t\t\tORDER BY bbcode_id DESC";
            $result = $db->sql_query_limit($sql, 1);
            $max_bbcode_id = (int) $db->sql_fetchfield('bbcode_id') + 1;
            $db->sql_freeresult($result);
            if ($max_bbcode_id <= NUM_CORE_BBCODES) {
                $max_bbcode_id = NUM_CORE_BBCODES + 1;
            }
            // The table does NOT have autoincrement because of the core-bbcodes, so we need to add it here.
            $sql_ary['bbcode_id'] = $max_bbcode_id;
            $sql = 'INSERT INTO ' . BBCODES_TABLE . '
				' . $db->sql_build_array('INSERT', $sql_ary);
            $db->sql_query($sql);
        }
    }
    $cache->destroy('sql', BBCODES_TABLE);
}
Пример #12
0
/**
 * inserts bbcodes into database
 *
 * @param string $action
 * @param string $version
 */
function insert_bbcodes($action, $version, $tag, $helpline)
{
    global $db, $user, $template, $cache;
    global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
    // Set up mode-specific vars
    // build each field for the sql query
    $bbcode_match = "[{$tag}]{SIMPLETEXT}[/{$tag}]";
    $bbcode_tpl = $bbcode_match;
    // same as match
    $sql = 'SELECT count(*) as checkcount FROM ' . BBCODES_TABLE . " WHERE LOWER(bbcode_tag) = '" . $db->sql_escape(strtolower($tag)) . "'";
    $result = $db->sql_query($sql);
    $checkcount = (int) $db->sql_fetchfield('checkcount');
    if ($checkcount >= 1) {
        return;
    }
    $db->sql_freeresult($result);
    // Include the bbcode class
    if (!class_exists('acp_bbcodes')) {
        require "{$phpbb_root_path}includes/acp/acp_bbcodes.{$phpEx}";
    }
    $acp_bbcodes = new acp_bbcodes();
    $data = $acp_bbcodes->build_regexp($bbcode_match, $bbcode_tpl);
    // assign the other variables
    $sql_ary = array('bbcode_tag' => $tag, 'bbcode_match' => $bbcode_match, 'bbcode_tpl' => $bbcode_tpl, 'display_on_posting' => 1, 'bbcode_helpline' => $helpline, 'first_pass_match' => $data['first_pass_match'], 'first_pass_replace' => $data['first_pass_replace'], 'second_pass_match' => $data['second_pass_match'], 'second_pass_replace' => $data['second_pass_replace']);
    // get max bbcodeid
    $sql = 'SELECT MAX(bbcode_id) as max_bbcode_id
			FROM ' . BBCODES_TABLE;
    $result = $db->sql_query($sql);
    $row = $db->sql_fetchrow($result);
    $db->sql_freeresult($result);
    if ($row) {
        $bbcode_id = $row['max_bbcode_id'] + 1;
        // Make sure it is greater than the core bbcode ids...
        if ($bbcode_id <= NUM_CORE_BBCODES) {
            $bbcode_id = NUM_CORE_BBCODES + 1;
        }
    } else {
        $bbcode_id = NUM_CORE_BBCODES + 1;
    }
    if ($bbcode_id > 1511) {
        trigger_error($user->lang['TOO_MANY_BBCODES'] . adm_back_link($this->u_action), E_USER_WARNING);
    }
    $sql_ary['bbcode_id'] = (int) $bbcode_id;
    $db->sql_query('INSERT INTO ' . BBCODES_TABLE . $db->sql_build_array('INSERT', $sql_ary));
    $cache->destroy('sql', BBCODES_TABLE);
    $lang = 'BBCODE_ADDED';
    $log_action = 'LOG_BBCODE_ADD';
    add_log('admin', $log_action, $data['bbcode_tag']);
}
Пример #13
0
    /**
     * This function is called, when the main() function is called.
     * You can use this function to add your language files, check for a valid mode, unset config options and more.
     *
     * @param	int		$id		The ID of the module
     * @param	string	$mode	The name of the mode we want to display
     * @return	void
     */
    public function main($id, $mode)
    {
        // Check whether the mode is allowed.
        if (!isset($this->display_vars[$mode])) {
            trigger_error('NO_MODE', E_USER_ERROR);
        }
        global $config, $db, $user, $template, $cache, $phpbb_container, $phpbb_root_path, $phpEx, $phpbb_gallery_url;
        global $request, $config;
        $phpbb_gallery_url = $phpbb_container->get('phpbbgallery.core.url');
        $user->add_lang_ext('phpbbgallery/core', array('gallery', 'gallery_acp'));
        $submit = isset($_POST['submit']) ? true : false;
        $form_key = 'acp_time';
        add_form_key($form_key);
        // Create the toolio config object
        //$this->toolio_config = new phpbb_ext_gallery_core_config($config, $db, CONFIG_TABLE);
        switch ($mode) {
            case 'main':
                $vars = $this->get_display_vars('main');
                break;
        }
        // Init gallery block class
        $phpbb_ext_gallery_core_constants = new \phpbbgallery\core\block();
        // Init gallery configs class
        $phpbb_gallery_configs = new \phpbbgallery\core\config($config);
        $this->new_config = $phpbb_gallery_configs->get_all();
        $cfg_array = isset($_REQUEST['config']) ? utf8_normalize_nfc($request->variable('config', array('' => ''), true)) : $this->new_config;
        $error = array();
        // We validate the complete config if whished
        validate_config_vars($vars['vars'], $cfg_array, $error);
        if ($submit && !check_form_key($form_key)) {
            $error[] = $user->lang['FORM_INVALID'];
        }
        // Do not write values if there is an error
        if (sizeof($error)) {
            $submit = false;
        }
        //now we display the variables
        foreach ($vars['vars'] as $config_name => $null) {
            if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) {
                continue;
            }
            $this->new_config[$config_name] = $config_value = $cfg_array[$config_name];
            if ($submit) {
                // Check for RRC-display-options
                if (isset($null['method']) && ($null['method'] == 'rrc_display' || $null['method'] == 'rrc_modes')) {
                    // Changing the value, casted by int to not mess up anything
                    $config_value = (int) array_sum($request->variable($config_name, array(0)));
                }
                // Recalculate the Watermark-position
                if (isset($null['method']) && $null['method'] == 'watermark_position') {
                    // Changing the value, casted by int to not mess up anything
                    $config_value = $request->variable('watermark_position_x', 0) + $request->variable('watermark_position_y', 0);
                }
                if ($config_name == 'link_thumbnail') {
                    $update_bbcode = $request->variable('update_bbcode', '');
                    // Update the BBCode
                    if ($update_bbcode) {
                        if (!class_exists('acp_bbcodes')) {
                            $phpbb_gallery_url->_include('acp/acp_bbcodes', 'phpbb');
                            //include_once($phpbb_root_path . 'includes/acp/acp_bbcodes.' . $phpEx);
                        }
                        $acp_bbcodes = new \acp_bbcodes();
                        $bbcode_match = '[image]{NUMBER}[/image]';
                        $bbcode_tpl = $this->bbcode_tpl($config_value);
                        $sql_ary = $acp_bbcodes->build_regexp($bbcode_match, $bbcode_tpl);
                        $sql_ary = array_merge($sql_ary, array('bbcode_match' => $bbcode_match, 'bbcode_tpl' => $bbcode_tpl, 'display_on_posting' => true, 'bbcode_helpline' => 'GALLERY_HELPLINE_ALBUM'));
                        $sql = 'UPDATE ' . BBCODES_TABLE . '
							SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\t\t\t\tWHERE bbcode_tag = '" . $sql_ary['bbcode_tag'] . "'";
                        $db->sql_query($sql);
                        $cache->destroy('sql', BBCODES_TABLE);
                    }
                }
                if (strpos($config_name, 'watermark') !== false && $phpbb_gallery_configs->get($config_name) != $config_value) {
                    $phpbb_gallery_configs->set('watermark_changed', time());
                }
                $phpbb_gallery_configs->set($config_name, $config_value);
            }
        }
        if ($submit) {
            $cache->destroy('sql', CONFIG_TABLE);
            trigger_error($user->lang['GALLERY_CONFIG_UPDATED'] . adm_back_link($this->u_action));
        }
        $this->tpl_name = 'acp_board';
        $this->page_title = $vars['title'];
        $template->assign_vars(array('L_TITLE' => $user->lang[$vars['title']], 'L_TITLE_EXPLAIN' => $user->lang[$vars['title'] . '_EXPLAIN'], 'S_ERROR' => sizeof($error) ? true : false, 'ERROR_MSG' => implode('<br />', $error), 'U_ACTION' => $this->u_action));
        // Output relevant page
        foreach ($vars['vars'] as $config_key => $vars) {
            if (!is_array($vars) && strpos($config_key, 'legend') === false) {
                continue;
            }
            if (strpos($config_key, 'legend') !== false) {
                $template->assign_block_vars('options', array('S_LEGEND' => true, 'LEGEND' => isset($user->lang[$vars]) ? $user->lang[$vars] : $vars));
                continue;
            }
            if (isset($vars['append'])) {
                $vars['append'] = isset($user->lang[$vars['append']]) ? ' ' . $user->lang[$vars['append']] : $vars['append'];
            }
            $this->new_config[$config_key] = $phpbb_gallery_configs->get($config_key);
            $type = explode(':', $vars['type']);
            $l_explain = '';
            //$this->var_display($vars);
            if (isset($vars['explain'])) {
                $l_explain = isset($user->lang[$vars['lang'] . '_EXP']) ? $user->lang[$vars['lang'] . '_EXP'] : '';
            }
            $content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars);
            if (empty($content)) {
                continue;
            }
            $template->assign_block_vars('options', array('KEY' => $config_key, 'TITLE' => isset($user->lang[$vars['lang']]) ? $user->lang[$vars['lang']] : $vars['lang'], 'S_EXPLAIN' => isset($vars['explain']) ? $vars['explain'] : '', 'TITLE_EXPLAIN' => $l_explain, 'CONTENT' => $content));
            unset($this->display_vars['vars'][$config_key]);
        }
    }
Пример #14
0
/**
* Create additional needed bbcodes so we can correctly transfer post formats
*/
function mybb_create_bbcodes()
{
	global $db, $phpbb_root_path, $phpEx;

	$templates = array(
		'[align={SIMPLETEXT}]{TEXT}[/align]'	=> '<div style="text-align: {SIMPLETEXT};">{TEXT}</div>',
		'[font={SIMPLETEXT}]{TEXT}[/font]'		=> '<span style="font-family: {SIMPLETEXT};">{TEXT}</span>',
		'[hr][/hr]'								=> '<hr />',
	);

	if (!class_exists('acp_bbcodes'))
	{
		include($phpbb_root_path . 'includes/acp/acp_bbcodes.' . $phpEx);
	}

	$bbcode = new acp_bbcodes();
	$bbcode_settings = array();

	// Get the bbcode regex
	foreach ($templates as $match => $tpl)
	{
		$settings = $bbcode->build_regexp($match, $tpl);

		$bbcode_settings[$settings['bbcode_tag']] = array_merge($settings, array(
			'bbcode_match'			=> $match,
			'bbcode_tpl'			=> $tpl,
			'display_on_posting'	=> 1,
			'bbcode_helpline'		=> '',
		));
	}

	$sql = 'SELECT MAX(bbcode_id) AS max_bbcode_id
		FROM ' . BBCODES_TABLE;
	$result = $db->sql_query($sql);
	$max_bbcode_id = (int) $db->sql_fetchfield('max_bbcode_id');
	$db->sql_freeresult($result);

	if ($max_bbcode_id)
	{
		$sql = 'SELECT bbcode_tag
			FROM ' . BBCODES_TABLE . '
			WHERE ' . $db->sql_in_set('bbcode_tag', array_keys($bbcode_settings));
		$result = $db->sql_query($sql);

		while ($row = $db->sql_fetchrow($result))
		{
			unset($bbcode_settings[$row['bbcode_tag']]);
		}
		$db->sql_freeresult($result);
	}
	else
	{
		$max_bbcode_id = NUM_CORE_BBCODES;
	}

	if (!empty($bbcode_settings))
	{
		// Reset the keys so that sql_multi_insert works...
		$bbcode_settings = array_values($bbcode_settings);

		foreach ($bbcode_settings as $index => $bbcode)
		{
			$bbcode_settings[$index]['bbcode_id'] = ++$max_bbcode_id;
		}
		$db->sql_multi_insert(BBCODES_TABLE, $bbcode_settings);
	}
}
    function main($id, $mode)
    {
        global $db, $user, $auth, $cache, $template;
        phpbb_gallery::init();
        $user->add_lang(array('mods/gallery_acp', 'mods/gallery'));
        $submit = isset($_POST['submit']) ? true : false;
        $form_key = 'acp_time';
        add_form_key($form_key);
        switch ($mode) {
            case 'main':
                // Disable some Options if they can not be used
                if (!function_exists('exif_read_data')) {
                    $this->display_vars['vars']['exif_data']['type'] = 'custom';
                    $this->display_vars['vars']['exif_data']['explain'] = true;
                    $this->display_vars['vars']['exif_data']['method'] = 'disabled_boolean';
                }
                if (!function_exists('imagerotate')) {
                    $this->display_vars['vars']['allow_rotate_images']['type'] = 'custom';
                    $this->display_vars['vars']['allow_rotate_images']['explain'] = true;
                    $this->display_vars['vars']['allow_rotate_images']['method'] = 'disabled_boolean';
                }
                break;
            default:
                trigger_error('NO_MODE', E_USER_ERROR);
                break;
        }
        phpbb_gallery_config::load(true);
        $this->new_config = phpbb_gallery_config::get_array();
        $cfg_array = isset($_REQUEST['config']) ? utf8_normalize_nfc(request_var('config', array('' => ''), true)) : $this->new_config;
        $error = array();
        // We validate the complete config if whished
        validate_config_vars($this->display_vars['vars'], $cfg_array, $error);
        if ($submit && !check_form_key($form_key)) {
            $error[] = $user->lang['FORM_INVALID'];
        }
        // Do not write values if there is an error
        if (sizeof($error)) {
            $submit = false;
        }
        // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
        foreach ($this->display_vars['vars'] as $config_name => $null) {
            if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) {
                continue;
            }
            $this->new_config[$config_name] = $config_value = $cfg_array[$config_name];
            if ($submit) {
                // Check for RRC-display-options
                if (isset($null['method']) && ($null['method'] == 'rrc_display' || $null['method'] == 'rrc_modes')) {
                    // Changing the value, casted by int to not mess up anything
                    $config_value = (int) array_sum(request_var($config_name, array(0)));
                }
                // Recalculate the Watermark-position
                if (isset($null['method']) && $null['method'] == 'watermark_position') {
                    // Changing the value, casted by int to not mess up anything
                    $config_value = request_var('watermark_position_x', 0) + request_var('watermark_position_y', 0);
                }
                if ($config_name == 'link_thumbnail') {
                    $update_bbcode = request_var('update_bbcode', '');
                    // Update the BBCode
                    if ($update_bbcode) {
                        if (!class_exists('acp_bbcodes')) {
                            phpbb_gallery_url::_include('acp/acp_bbcodes', 'phpbb');
                        }
                        $acp_bbcodes = new acp_bbcodes();
                        $bbcode_match = '[album]{NUMBER}[/album]';
                        $bbcode_tpl = $this->bbcode_tpl($config_value);
                        $sql_ary = $acp_bbcodes->build_regexp($bbcode_match, $bbcode_tpl);
                        $sql_ary = array_merge($sql_ary, array('bbcode_match' => $bbcode_match, 'bbcode_tpl' => $bbcode_tpl, 'display_on_posting' => true, 'bbcode_helpline' => 'GALLERY_HELPLINE_ALBUM'));
                        $sql = 'UPDATE ' . BBCODES_TABLE . '
							SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "\n\t\t\t\t\t\t\tWHERE bbcode_tag = '" . $sql_ary['bbcode_tag'] . "'";
                        $db->sql_query($sql);
                        $cache->destroy('sql', BBCODES_TABLE);
                    }
                }
                phpbb_gallery_config::set($config_name, $config_value);
            }
        }
        if ($submit) {
            $cache->destroy('sql', CONFIG_TABLE);
            trigger_error($user->lang['GALLERY_CONFIG_UPDATED'] . adm_back_link($this->u_action));
        }
        $this->tpl_name = 'acp_board';
        $this->page_title = $this->display_vars['title'];
        $template->assign_vars(array('L_TITLE' => $user->lang[$this->display_vars['title']], 'L_TITLE_EXPLAIN' => $user->lang[$this->display_vars['title'] . '_EXPLAIN'], 'S_ERROR' => sizeof($error) ? true : false, 'ERROR_MSG' => implode('<br />', $error), 'U_ACTION' => $this->u_action));
        // Output relevant page
        foreach ($this->display_vars['vars'] as $config_key => $vars) {
            if (!is_array($vars) && strpos($config_key, 'legend') === false) {
                continue;
            }
            if (strpos($config_key, 'legend') !== false) {
                $template->assign_block_vars('options', array('S_LEGEND' => true, 'LEGEND' => isset($user->lang[$vars]) ? $user->lang[$vars] : $vars));
                continue;
            }
            $this->new_config[$config_key] = phpbb_gallery_config::get($config_key);
            $type = explode(':', $vars['type']);
            $l_explain = '';
            if ($vars['explain']) {
                $l_explain = isset($user->lang[$vars['lang'] . '_EXP']) ? $user->lang[$vars['lang'] . '_EXP'] : '';
            }
            $content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars);
            if (empty($content)) {
                continue;
            }
            $template->assign_block_vars('options', array('KEY' => $config_key, 'TITLE' => isset($user->lang[$vars['lang']]) ? $user->lang[$vars['lang']] : $vars['lang'], 'S_EXPLAIN' => $vars['explain'], 'TITLE_EXPLAIN' => $l_explain, 'CONTENT' => $content));
            unset($this->display_vars['vars'][$config_key]);
        }
    }