|
From: Florin C B. <ory...@us...> - 2012-02-09 10:52:06
|
Update of /cvsroot/mxbb/core/includes/sessions/phpbb3
In directory vz-cvs-4.sog:/tmp/cvs-serv3978/sessions/phpbb3
Modified Files:
session.php
Log Message:
Added Support for Styles Demo Mod
Index: session.php
===================================================================
RCS file: /cvsroot/mxbb/core/includes/sessions/phpbb3/session.php,v
retrieving revision 1.44
retrieving revision 1.45
diff -C2 -d -r1.44 -r1.45
*** session.php 27 Jul 2011 19:44:58 -0000 1.44
--- session.php 9 Feb 2012 10:52:04 -0000 1.45
***************
*** 1347,1355 ****
$style = $this->style; // From main style init. Should be correct and valid.
! /*
if(!$board_config['override_user_style'] && ($this->data['user_id'] != ANONYMOUS))
{
// Set up style
! $style = $this->data['user_style'] ? $this->data['user_style'] : $board_config['default_style'];
}
else
--- 1347,1355 ----
$style = $this->style; // From main style init. Should be correct and valid.
! /* */
if(!$board_config['override_user_style'] && ($this->data['user_id'] != ANONYMOUS))
{
// Set up style
! $style = $this->data['user_style'] ? $this->data['user_style'] : $this->phpbb_style['style_id'];
}
else
***************
*** 1359,1363 ****
//Anonymouse users should see all block graphic corect
//Query phpBB style_id corepondent to mxp themes_id
! $sql = "SELECT s.style_id
FROM " . MX_THEMES_TABLE . " AS m, " . STYLES_TABLE . " AS s, " . STYLES_TEMPLATE_TABLE . " AS t
WHERE m.themes_id = " . (int) $default_style . "
--- 1359,1363 ----
//Anonymouse users should see all block graphic corect
//Query phpBB style_id corepondent to mxp themes_id
! $sql = "SELECT s.style_id, s.style_name
FROM " . MX_THEMES_TABLE . " AS m, " . STYLES_TABLE . " AS s, " . STYLES_TEMPLATE_TABLE . " AS t
WHERE m.themes_id = " . (int) $default_style . "
***************
*** 1374,1407 ****
}
}
! */
// Set up style Temp code should be removed after bugtraking
! $style = ($style) ? $style : ((!$board_config['override_user_style'] && $this->data['user_id'] != ANONYMOUS) ? $this->data['user_style'] : $this->phpbb_style['style_id']);
}
!
! $sql = "SELECT s.style_id, t.template_storedb, t.template_path, t.template_id, t.bbcode_bitfield, c.theme_path, c.theme_name, c.theme_storedb, c.theme_id, i.imageset_path, i.imageset_id, i.imageset_name
! FROM " . STYLES_TABLE . " AS s, " . STYLES_TEMPLATE_TABLE . " AS t, " . STYLES_THEME_TABLE . " AS c, " . STYLES_IMAGESET_TABLE . " i
! WHERE s.style_id = " . (int) $style . "
! AND t.template_id = s.template_id
! AND c.theme_id = s.theme_id
! AND i.imageset_id = s.imageset_id";
!
! if ( !($result = $db->sql_query($sql, 3600)) )
{
! mx_message_die(CRITICAL_ERROR, "Could not query database for imageset_id info style_id [$style]", "", __LINE__, __FILE__, $sql);
}
$this->theme = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
!
// User has wrong style
if (!$this->theme && $style == $this->data['user_style'])
{
$style = $this->data['user_style'] = $board_config['default_style'];
!
$sql = 'UPDATE ' . USERS_TABLE . "
SET user_style = $style
WHERE user_id = {$this->data['user_id']}";
$db->sql_query($sql);
!
$sql = 'SELECT s.style_id, t.template_storedb, t.template_path, t.template_id, t.bbcode_bitfield, c.theme_path, c.theme_name, c.theme_storedb, c.theme_id, i.imageset_path, i.imageset_id, i.imageset_name
FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . ' c, ' . STYLES_IMAGESET_TABLE . " i
--- 1374,1491 ----
}
}
! /* */
// Set up style Temp code should be removed after bugtraking
! //$style = ($style) ? $style : ((!$board_config['override_user_style'] && $this->data['user_id'] != ANONYMOUS) ? $this->data['user_style'] : $this->phpbb_style['style_id']);
}
!
! // BEGIN Styles_Demo MOD for phpBB Block
! $style_value = '';
! if (isset($_GET['demostyle']))
{
! $style_value = phpBB3::request_var('demostyle', '');
! if (intval($style_value) == 0)
! {
! //Query phpBB style_id corepondent to mxp style_name
! //Any Demo Style here should work also for portal and forums
! //Any Demo Style Name should be supported using same guild lines for portal as for forums for e.g. with spaces etc.
! $sql = "SELECT s.style_id, s.style_name
! FROM " . MX_THEMES_TABLE . " AS m, " . STYLES_TABLE . " AS s, " . STYLES_TEMPLATE_TABLE . " AS t
! WHERE s.style_active = 1 AND s.style_name = '$style_value'
! AND s.style_name = m.style_name
! AND t.template_id = s.template_id";
! if(!$row = @$db->sql_fetchrow(@$db->sql_query($sql)))
! {
! die('Could not find style name '. $style_value . '!');
! }
! else
! {
! $style_value = $row['style_id'];
! }
! }
! else
! {
! //Query phpBB style_id corepondent to mxp themes_id
! //Any Demo Style here should work also for portal and forums
! //Any Demo Style Name should be supported using same guild lines for portal as for forums for e.g. with spaces etc.
! $sql = "SELECT s.style_id, s.style_name
! FROM " . MX_THEMES_TABLE . " AS m, " . STYLES_TABLE . " AS s, " . STYLES_TEMPLATE_TABLE . " AS t
! WHERE s.style_id = " . (int) $style_value . "
! AND s.style_name = m.style_name
! AND t.template_id = s.template_id";
! if(!$row = $db->sql_fetchrow($db->sql_query($sql)))
! {
! die('style_id ' . $style_value . ' not found');
! }
! }
! $this->set_cookie('change_style', $style_value, time() + 31536000);
! }
! elseif (isset($_COOKIE[$config['cookie_name'] . '_change_style']))
! {
! $style_value = $_COOKIE[$config['cookie_name'] . '_change_style'];
! }
!
! //Change the value before query
! if (!empty($style_value))
! {
! $style = $style_value;
! }
!
! //We should never get this, temp fix for GoogleBot-2.1 crawler
! //Remove this Deguging Code after solved
! if ((intval($style) == 0) && empty($style_value))
! {
! $style_value = 'prosilver';
! }
!
! // END Styles_Demo MOD
! if (intval($style) == 0)
! {
! //Query phpBB style_name
! $sql = "SELECT s.style_id, t.template_storedb, t.template_path, t.template_id, t.bbcode_bitfield, c.theme_path, c.theme_name, c.theme_storedb, c.theme_id, i.imageset_path, i.imageset_id, i.imageset_name
! FROM " . STYLES_TABLE . " AS s, " . STYLES_TEMPLATE_TABLE . " AS t, " . STYLES_THEME_TABLE . " AS c, " . STYLES_IMAGESET_TABLE . " i
! WHERE s.style_active = 1 AND s.style_name = '$style_value'
! AND t.template_id = s.template_id
! AND c.theme_id = s.theme_id
! AND i.imageset_id = s.imageset_id";
!
! if(($result = $db->sql_query($sql)) && ($row = $db->sql_fetchrow($result)))
! {
! $style = $row['style_id'];
! }
! else
! {
! mx_message_die(CRITICAL_ERROR, "Could not query database for imageset_id info style_name [$style]", "", __LINE__, __FILE__, $sql);
! }
}
+ else
+ {
+ //Query phpBB style_id
+ $sql = "SELECT s.style_id, t.template_storedb, t.template_path, t.template_id, t.bbcode_bitfield, c.theme_path, c.theme_name, c.theme_storedb, c.theme_id, i.imageset_path, i.imageset_id, i.imageset_name
+ FROM " . STYLES_TABLE . " AS s, " . STYLES_TEMPLATE_TABLE . " AS t, " . STYLES_THEME_TABLE . " AS c, " . STYLES_IMAGESET_TABLE . " i
+ WHERE s.style_id = " . (int) $style . "
+ AND t.template_id = s.template_id
+ AND c.theme_id = s.theme_id
+ AND i.imageset_id = s.imageset_id";
+
+ if (!$result = $db->sql_query_limit($sql, 1))
+ {
+ mx_message_die(CRITICAL_ERROR, "Could not query database for imageset_id info style_id [$style]", "", __LINE__, __FILE__, $sql);
+ }
+ }
+
$this->theme = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
!
// User has wrong style
if (!$this->theme && $style == $this->data['user_style'])
{
$style = $this->data['user_style'] = $board_config['default_style'];
!
$sql = 'UPDATE ' . USERS_TABLE . "
SET user_style = $style
WHERE user_id = {$this->data['user_id']}";
$db->sql_query($sql);
!
$sql = 'SELECT s.style_id, t.template_storedb, t.template_path, t.template_id, t.bbcode_bitfield, c.theme_path, c.theme_name, c.theme_storedb, c.theme_id, i.imageset_path, i.imageset_id, i.imageset_name
FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . ' c, ' . STYLES_IMAGESET_TABLE . " i
***************
*** 1414,1439 ****
$db->sql_freeresult($result);
}
!
if (!$this->theme)
{
trigger_error('Could not get style data', E_USER_ERROR);
}
!
// Now parse the cfg file and cache it
$parsed_items = $mx_backend->obtain_cfg_items($this->theme);
!
// We are only interested in the theme configuration for now
$parsed_items = $parsed_items['theme'];
!
$check_for = array(
'parse_css_file' => (int) 0,
'pagination_sep' => (string) ', '
);
!
foreach ($check_for as $key => $default_value)
{
$this->theme[$key] = (isset($parsed_items[$key])) ? $parsed_items[$key] : $default_value;
settype($this->theme[$key], gettype($default_value));
!
if (is_string($default_value))
{
--- 1498,1523 ----
$db->sql_freeresult($result);
}
!
if (!$this->theme)
{
trigger_error('Could not get style data', E_USER_ERROR);
}
!
// Now parse the cfg file and cache it
$parsed_items = $mx_backend->obtain_cfg_items($this->theme);
!
// We are only interested in the theme configuration for now
$parsed_items = $parsed_items['theme'];
!
$check_for = array(
'parse_css_file' => (int) 0,
'pagination_sep' => (string) ', '
);
!
foreach ($check_for as $key => $default_value)
{
$this->theme[$key] = (isset($parsed_items[$key])) ? $parsed_items[$key] : $default_value;
settype($this->theme[$key], gettype($default_value));
!
if (is_string($default_value))
{
***************
*** 1441,1445 ****
}
}
!
// If the style author specified the theme needs to be cached
// (because of the used paths and variables) than make sure it is the case.
--- 1525,1529 ----
}
}
!
// If the style author specified the theme needs to be cached
// (because of the used paths and variables) than make sure it is the case.
***************
*** 1448,1457 ****
{
$this->theme['theme_storedb'] = 1;
!
$stylesheet = file_get_contents("{$phpbb_root_path}styles/{$this->theme['theme_path']}/theme/stylesheet.css");
// Match CSS imports
$matches = array();
preg_match_all('/@import url\(["\'](.*)["\']\);/i', $stylesheet, $matches);
!
if (sizeof($matches))
{
--- 1532,1541 ----
{
$this->theme['theme_storedb'] = 1;
!
$stylesheet = file_get_contents("{$phpbb_root_path}styles/{$this->theme['theme_path']}/theme/stylesheet.css");
// Match CSS imports
$matches = array();
preg_match_all('/@import url\(["\'](.*)["\']\);/i', $stylesheet, $matches);
!
if (sizeof($matches))
{
***************
*** 1471,1477 ****
unset($content);
}
!
! $stylesheet = str_replace('./', 'styles/' . $this->theme['theme_path'] . '/theme/', $stylesheet);
!
$sql_ary = array(
'theme_data' => $stylesheet,
--- 1555,1561 ----
unset($content);
}
!
! $stylesheet = str_replace('./', 'styles/' . $this->theme['theme_path'] . '/theme/', $stylesheet);
!
$sql_ary = array(
'theme_data' => $stylesheet,
***************
*** 1479,1495 ****
'theme_storedb' => 1
);
!
$sql = 'UPDATE ' . STYLES_THEME_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
WHERE theme_id = ' . $this->theme['theme_id'];
$db->sql_query($sql);
!
unset($sql_ary);
}
!
$template->set_template();
!
$this->img_lang = (file_exists($phpbb_root_path . 'styles/' . $this->theme['imageset_path'] . '/imageset/' . $this->lang_name)) ? $this->lang_name : $board_config['default_lang'];
!
$sql = 'SELECT image_name, image_filename, image_lang, image_height, image_width
FROM ' . STYLES_IMAGESET_DATA_TABLE . '
--- 1563,1579 ----
'theme_storedb' => 1
);
!
$sql = 'UPDATE ' . STYLES_THEME_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
WHERE theme_id = ' . $this->theme['theme_id'];
$db->sql_query($sql);
!
unset($sql_ary);
}
!
$template->set_template();
!
$this->img_lang = (file_exists($phpbb_root_path . 'styles/' . $this->theme['imageset_path'] . '/imageset/' . $this->lang_name)) ? $this->lang_name : $board_config['default_lang'];
!
$sql = 'SELECT image_name, image_filename, image_lang, image_height, image_width
FROM ' . STYLES_IMAGESET_DATA_TABLE . '
|