Пример #1
0
function display_message_start($using_cli, $level)
{
    $background_color = '';
    $tag = '';
    switch ($level) {
        case 'error':
            $background_color = '#D02733';
            $tag = 'div';
            break;
        case 'warning':
            $background_color = '#FF8110';
            $tag = 'div';
            break;
        case 'system':
            $background_color = '#000000';
            $tag = 'div';
            break;
        case 'normal':
            $background_color = '#000000';
            $tag = 'pre';
            break;
        default:
            $background_color = '#F2F2F2';
            break;
    }
    $output = $using_cli ? '' : "<" . $tag . " style='" . create_css($background_color) . "'>";
    echo $output;
}
Пример #2
0
function setup_style($style)
{
    // Begin PNphpBB2 Module
    //	global $db, $board_config, $template, $images, $phpbb_root_path;
    global $db, $board_config, $template, $images, $phpbb_root_path, $phpEx;
    // End PNphpBB2 Module
    $sql = 'SELECT *
		FROM ' . THEMES_TABLE . '
		WHERE themes_id = ' . (int) $style;
    if (!($result = $db->sql_query($sql))) {
        message_die(CRITICAL_ERROR, 'Could not query database for theme info');
    }
    if (!($row = $db->sql_fetchrow($result))) {
        // We are trying to setup a style which does not exist in the database
        // Try to fallback to the board default (if the user had a custom style)
        // and then any users using this style to the default if it succeeds
        if ($style != $board_config['default_style']) {
            $sql = 'SELECT *
				FROM ' . THEMES_TABLE . '
				WHERE themes_id = ' . (int) $board_config['default_style'];
            if (!($result = $db->sql_query($sql))) {
                message_die(CRITICAL_ERROR, 'Could not query database for theme info');
            }
            if ($row = $db->sql_fetchrow($result)) {
                $db->sql_freeresult($result);
                $sql = 'UPDATE ' . USERS_TABLE . '
					SET user_style = ' . (int) $board_config['default_style'] . "\n\t\t\t\t\tWHERE user_style = {$style}";
                if (!($result = $db->sql_query($sql))) {
                    message_die(CRITICAL_ERROR, 'Could not update user theme info');
                }
            } else {
                message_die(CRITICAL_ERROR, "Could not get theme data for themes_id [{$style}]");
            }
        } else {
            message_die(CRITICAL_ERROR, "Could not get theme data for themes_id [{$style}]");
        }
    }
    // Begin PNphpBB2 Module
    //	$template_path = 'templates/' ;
    $template_path = $phpbb_root_path . 'templates/';
    $template_name = $row['template_name'];
    $board_config['template_path'] = $template_path . $template_name;
    // Get the Postnuke theme name
    $theme_name = UserUtil::isLoggedIn() && System::getVar('theme_change') != 1 ? UserUtil::getTheme() : System::getVar('Default_Theme');
    $board_config['theme_name'] = $theme_name;
    // Image path (Non-Language dependant)
    $imagedir = $template_path . $template_name . "/images";
    if (@is_dir(@phpbb_realpath($imagedir . "/" . $theme_name))) {
        $board_config['path_images'] = $imagedir . "/" . $theme_name;
        $board_config['image_sub_path'] = $theme_name . '/';
    } else {
        $board_config['path_images'] = $imagedir;
        $board_config['image_sub_path'] = '';
    }
    $current_template_path = $board_config['path_images'];
    // Image language path
    // Postnuke language files or regualr images for secific language
    $imagedir = $board_config['path_images'] . "/lang_" . $board_config['default_lang'];
    if (@is_dir(@phpbb_realpath($imagedir))) {
        // Ok cool lets use it
        $board_config['path_images_lang'] = $imagedir;
        $board_config['image_lang'] = $board_config['default_lang'];
    } else {
        $imagedir = $template_path . $template_name . "/images/lang_" . $board_config['default_lang'];
        if (@is_dir(@phpbb_realpath($imagedir))) {
            $board_config['path_images_lang'] = $imagedir;
            $board_config['image_lang'] = $board_config['default_lang'];
        } else {
            $imagedir = $board_config['path_images'] . "/lang_english";
            $board_config['path_images_lang'] = @is_dir(@phpbb_realpath($imagedir)) ? $imagedir : $template_path . $template_name . '/images/lang_english';
            $board_config['image_lang'] = "english";
        }
    }
    // Image post icons
    $imagedir = $template_path . $template_name . "/posticons/" . $theme_name;
    $board_config['path_posticons'] = @is_dir(@phpbb_realpath($imagedir)) ? $imagedir : $phpbb_root_path . "images/posticons";
    // Get a default Post Icon size
    $board_config['posticons_size'] = 'width="15" height="15"';
    if (@is_file($board_config['path_posticons'] . "/posticons_size." . $phpEx)) {
        @(include $board_config['path_posticons'] . "/posticons_size." . $phpEx);
    }
    //	$dir = @opendir($board_config['path_posticons']);
    //  $temp_w_size = 15;
    //  $temp_h_size = 15;
    //	while( $file = @readdir($dir) )
    //	{
    //	  if ( preg_match('/image_(\d+)\.gif$/is', $file, $num) )
    //		{
    //			 if ($num[1] > 0 and $num[1] < 256)
    //			 {
    //	 	 	 		$post_images[$num_post_images] = $num[1];
    //					$postimagesize = getimagesize($board_config['path_posticons'] . '/' . $file);
    //         if ( $postimagesize[0] > $temp_w_size )
    //          {
    //           $temp_w_size = $postimagesize[0];
    //          }
    //          if ( $postimagesize[1] > $temp_h_size )
    //          {
    //            $temp_h_size = $postimagesize[1];
    //          }
    //          // $board_config['posticons_size'] = $postimagesize[3];
    //          // echo $postimagesize[3];
    //		 	 }
    //		}
    //	}
    //	@closedir($dir);
    //	$board_config['posticons_size'] = 'width="' . $temp_w_size . '" height="' . $temp_h_size . '"';
    // Rank images
    // Postnuke language files or regualr images for secific language
    $imagedir = $template_path . $template_name . "/ranks/" . $theme_name . "/lang_" . $board_config['default_lang'];
    if (@is_dir(@phpbb_realpath($imagedir))) {
        // Ok cool lets use it
        $board_config['path_ranks'] = $imagedir;
    } else {
        $imagedir = $template_path . $template_name . "/ranks/lang_" . $board_config['default_lang'];
        if (@is_dir(@phpbb_realpath($imagedir))) {
            $board_config['path_ranks'] = $imagedir;
        } else {
            $imagedir = $template_path . $template_name . "/ranks/lang_english";
            $board_config['path_ranks'] = @is_dir(@phpbb_realpath($imagedir)) ? $imagedir : $phpbb_root_path . 'images/ranks';
        }
    }
    // Stylename & cellpic path
    $style_name = $template_path . $template_name . "/styles/" . $theme_name . ".css";
    $cellpics_path = $template_path . $template_name . "/cellpics/" . $theme_name;
    // Here we will switch gears and if the style sheet does not exist for the current PN theme, we will create it!
    // However if the admin has not turned the theme matching function on we will try and find a style sheet
    // based on the current theme, and use it. If not then we will use the defualt style sheet and cellpics.
    if ($board_config['theme_matching']) {
        if (@(!is_file($style_name))) {
            // Could not find the style sheet for this theme soooo.....
            // Create a temparary template container to build the style sheet
            // $board_config['style_name'] = $template_path . $template_name . "/styles/default.css";
            $stylesheet = new Template($template_path . $template_name);
            include_once $phpbb_root_path . 'includes/functions_styles.' . $phpEx;
            $succ = create_css($stylesheet, $theme_name);
            if (!$succ) {
                $board_config['style_name'] = $template_path . $template_name . "/styles/default.css";
                $board_config['path_cellpics'] = $template_path . $template_name . "/cellpics/default";
            }
        }
    }
    // Find the style sheet for the current theme no style sheet then use defualt.
    $board_config['style_name'] = @is_readable($style_name) ? $style_name : $template_path . $template_name . "/styles/default.css";
    // Find the cell pics for the current theme no cell pics then use defualt ones.
    $board_config['path_cellpics'] = @is_readable($cellpics_path) ? $cellpics_path : $template_path . $template_name . "/cellpics/default";
    $template = new Template($template_path . $template_name);
    // End PNphpBB2 Module
    if ($template) {
        $current_template_path = $template_path . $template_name;
        // Begin PNphpBB2 Module
        //		$img_lang = ( file_exists(@phpbb_realpath($current_template_path . '/images/lang_' . $board_config['default_lang'])) ) ? $board_config['default_lang'] : 'english';
        //		$img_lang = ( file_exists(@phpbb_realpath($phpbb_root_path . $current_template_path . '/images/lang_' . $board_config['default_lang'])) ) ? $board_config['default_lang'] : 'english';
        $img_lang = $board_config['image_lang'];
        // End PNphpBB2 Module
        // Begin PNphpBB2 Module
        include $template_path . $template_name . '/' . $template_name . '.cfg';
        // End PNphpBB2 Module
        if (!defined('TEMPLATE_CONFIG')) {
            message_die(CRITICAL_ERROR, "Could not open {$template_name} template config file", '', __LINE__, __FILE__);
        }
        // Begin PNphpBB2 Module
        //		$img_lang = ( file_exists(@phpbb_realpath($phpbb_root_path . $current_template_path . '/images/lang_' . $board_config['default_lang'])) ) ? $board_config['default_lang'] : 'english';
        // End PNphpBB2 Module
        while (list($key, $value) = @each($images)) {
            if (!is_array($value)) {
                // Begin PNphpBB2 Module
                //				$images[$key] = $phpbb_root_path . str_replace('{LANG}', 'lang_' . $img_lang, $value);
                $images[$key] = str_replace('{LANG}', 'lang_' . $board_config['image_lang'], $value);
                // End PNphpBB2 Module
            }
        }
    }
    return $row;
}