PEAK XOOPS - お手軽高速化!:-) updated in englishin japanese

Archive | RSS |
XOOPS
XOOPS : お手軽高速化!:-) updated
Poster : GIJOE on 2005-11-14 18:00:24 (41371 reads)

in englishin japanese
リダイレクトメッセージは、時間がかかって邪魔だと思いませんか?
実際、あのリダイレクトメッセージは、無駄なサーバ負荷にもなっています。

とうわけで、okuhikiさんの書込をヒントに、メッセージをじっくり読みたい人にも、さくさく作業したい人にも最善と思われるHackを施してみました。

このサイトで投稿などしてみればお判りいただけると思いますが、リダイレクトメッセージがリダイレクト後のページに、左ブロックとして表示されます。

また、リロードすれば消えるようにも作っています。ただし、このサイトには、FCH(ページ全体のキャッシュ)がかかっているので、リロードではたぶん消えません。

Hack方法はきわめて簡単です。
include/functions.php の redirect_header() 関数をちょっといじって、あとは、テーマを書き換えるだけです。

コアバージョンによって、結構違うのが面倒といえば面倒ですね。

2.0.13a では、include/functions.phpが書き変わって行数が違っていたので、そこを修正しました。また、HTTPレスポンス分割攻撃の可能性も0ではないため、一応対策コードも追加しておきました。


全バージョンでの共通処理: theme.html
この8行をお使いのテーマのtheme.htmlの一番上に挿入します


<{php}>
if( ! empty( $_SESSION['redirect_message'] ) ) {
	if( empty( $this->_tpl_vars['xoops_lblocks'] ) ) $this->_tpl_vars['xoops_lblocks'] = array() ;
	array_unshift( $this->_tpl_vars['xoops_lblocks'] , array( 'title' => 'Message' , 'content' => $_SESSION['redirect_message'] , 'weight' => 0 ) ) ;
	$this->_tpl_vars['xoops_showlblock'] = 1 ;
	unset( $_SESSION['redirect_message'] ) ;
}
<{/php}>

If you use XOOPS 2.2.x, also insert them into themeadmin.html


XOOPS 2.0.13a-JP
line 423 in include/functions.php

        $xoopsTpl->assign('url', $url);
        $message = trim($message) != '' ? $message : _TAKINGBACK;
        $xoopsTpl->assign('message', $message);
        $xoopsTpl->assign('lang_ifnotreload', sprintf(_IFNOTRELOAD, $url));
        $GLOBALS['xoopsModuleUpdate'] = 1;

        // GIJ start
        if( ! headers_sent() ) {
            $_SESSION['redirect_message'] = $message ;
            header( "Location: ".strtr(preg_replace('/[&]amp;/i','&',$url),"\r\n\0","   ") ) ;
            exit ;
        }
        // GIJ end

        $xoopsTpl->display('db:system_redirect.html');
        exit();
    } else {
        $url = preg_replace("/& amp;/i", '&', htmlspecialchars($url, ENT_QUOTES));

        // GIJ start
        if( ! headers_sent() ) {
            $_SESSION['redirect_message'] = $message ;
            header( "Location: ".strtr(preg_replace('/[&]amp;/i','&',$url),"\r\n\0","   ") ) ;
            exit ;
        }
        // GIJ end

        echo '
        <html>
        <head>

line 128 in include/cp_functions.php
最新版altsysの管理画面テーマを利用するなら、このHackは不要です

        <table border='0' cellpadding='0' cellspacing='0' width='100%'>
          <tr>
            <td width='2%' valign='top' class='bg5'  background='".XOOPS_URL."/modules/system/images/bg_menu.gif' align='center'></td>
            <td width='15%' valign='top' class='bg5' align='center'><img src='".XOOPS_URL."/modules/system/images/menu.gif' /><br />
              <table border='0' cellpadding='4' cellspacing='0' width='100%'>";

        // GIJ start
        if( ! empty( $_SESSION['redirect_message'] ) ) {
            echo "<tr><td>".htmlspecialchars($_SESSION['redirect_message'],ENT_QUOTES)."</td></tr>\n" ;
            unset( $_SESSION['redirect_message'] ) ;
        }
        // GIJ end

        foreach ( $admin_mids as $adm ) {
            if ( !empty($xoops_admin_menu_ft[$adm]) ) {
                echo "<tr><td align='center'>".$xoops_admin_menu_ft[$adm]."</td></tr>";
            }
        }




XOOPS 2.0.13.2
line 404 in include/functions.php

    $xoopsTpl->assign('url', $url);
    $message = trim($message) != '' ? $message : _TAKINGBACK;
    $xoopsTpl->assign('message', $message);
    $xoopsTpl->assign('lang_ifnotreload', sprintf(_IFNOTRELOAD, $url));

        // GIJ start
        if( ! headers_sent() ) {
            $_SESSION['redirect_message'] = $message ;
            header( "Location: ".strtr(preg_replace('/[&]amp;/i','&',$url),"\r\n\0","   ") ) ;
            exit ;
        }
        // GIJ end

    $xoopsTpl->display('db:system_redirect.html');
    exit();
}



line 141 in include/cp_functions.php
最新版altsysの管理画面テーマを利用するなら、このHackは不要です

        <table border='0' cellpadding='0' cellspacing='0' width='100%'>
          <tr>
            <td width='2%' valign='top' class='bg5'  background='".XOOPS_URL."/m
odules/system/images/bg_menu.gif' align='center'></td>
            <td width='15%' valign='top' class='bg5' align='center'><img src='".
XOOPS_URL."/modules/system/images/menu.gif' /><br />
              <table border='0' cellpadding='4' cellspacing='0' width='100%'>";

        // GIJ start
        if( ! empty( $_SESSION['redirect_message'] ) ) {
            echo "<tr><td>".htmlspecialchars($_SESSION['redirect_message'],ENT_QUOTES)."</td></tr>\n" ;
            unset( $_SESSION['redirect_message'] ) ;
        }
        // GIJ end

        foreach ( array_keys($xoops_admin_menu_ft) as $adm ) {
            if ( in_array($adm, $admin_mids) ) {
                echo "<tr><td align='center'>".$xoops_admin_menu_ft[$adm]."</td>
</tr>";
            }
        }





XOOPS 2.2.3 final
line 424 in include/functions.php

    $xTheme->tplEngine->assign('url', $url);
    $message = trim($message) != '' ? $message : _TAKINGBACK;
    $xTheme->tplEngine->assign('message', $message);
    $xTheme->tplEngine->assign('lang_ifnotreload', sprintf(_IFNOTRELOAD, $url));
    $xTheme->tplEngine->assign('xoops_module_header', '<meta http-equiv="Refresh" content="2; url='.$url.'" />');
    $xoopsOption['template_main'] = 'system_redirect.html';

        // GIJ start
        if( ! headers_sent() ) {
            $_SESSION['redirect_message'] = $message ;
            header( "Location: ".strtr(preg_replace('/[&]amp;/i','&',$url),"\r\n\0","   ") ) ;
            exit ;
        }
        // GIJ end

    include XOOPS_ROOT_PATH."/footer.php";
    exit();
}


----
2005/8/15 fixed

from:
- header( "Location: $url" ) ;
to:
- header( "Location: ".preg_replace("/& amp;/i",'&',$url) ) ;


----
2005/11/14 modified (for the security reason)

from:
- header( "Location: ".preg_replace("/& amp;/i",'&',$url) ) ;
to:
- header( "Location: ".strtr(preg_replace("/& amp;/i",'&',$url),"\r\n\0"," ") ) ;

----
2005/11/17 modified (it is not necessary to convert & ) and added 2.2.3final

from:
- header( "Location: ".strtr(preg_replace("/& amp;/i",'&',$url),"\r\n\0"," ") ) ;
to:
- header( "Location: ".strtr($url,array("\r"=>'',"\n"=>'') ) ) ;

----
2006/4/11 reverted (it is necessary to convert & )

from:
- header( "Location: ".strtr($url,array("\r"=>'',"\n"=>'') ) ) ;
to:
- header( "Location: ".strtr(preg_replace('/[&]amp;/i','&',$url),"\r\n\0"," ") ) ;

Printer friendly page Send this story to a friend

Comments list

GIJOE  Posted on 2007/9/9 6:24
With XCL 2.1, you need not hack include/functions.php.

Just edit the template "legacy_redirect.html".

Insert it into the top of the template.
<{php}>
  if( ! headers_sent() ) {
    $_SESSION["redirect_message"] = $this->_tpl_vars["message"];
    header("Location: ".html_entity_decode($this->_tpl_vars["url"],ENT_QUOTES));
    exit;
  }
<{/php}>

You also have to edit theme.html like the hack for X2.
marco  Posted on 2007/9/7 4:32
hello,

is this nice improvement already integrated in XC/XCL?
how manages XC/XCL the redirect page, or dos it user another nicest way?
thx for your explanation
marco
slyss79  Posted on 2006/12/9 8:41
in your theme.html delete this:

[code]
<{php}>
if( ! empty( $_SESSION['redirect_message'] ) ) {
if( empty( $this->_tpl_vars['xoops_lblocks'] ) ) $this->_tpl_vars['xoops_lblocks'] = array() ;
array_unshift( $this->_tpl_vars['xoops_lblocks'] , array( 'title' => 'Message' , 'content' => $_SESSION['redirect_message'] , 'weight' => 0 ) ) ;
$this->_tpl_vars['xoops_showlblock'] = 1 ;
unset( $_SESSION['redirect_message'] ) ;
}
<{/php}>
[/code]

and insert this:

[code]
<{php}>
if( ! empty( $_SESSION['redirect_message'] ) ) {
$this->_tpl_vars['xoops_msg'] = $_SESSION['redirect_message'];
unset( $_SESSION['redirect_message'] ) ;
}
<{/php}>
[/code]

Now you can use the smarty's variable [b]<{$xoops_msg}>[/b] and you can put the redirect messagge where you want in the theme.html

i hope this feature is appreciated....

thanks to dead from xoopsitalia.

sly

[url=http://www.xoopsitalia.org/modules/newbb/viewtopic.php?post_id=38114#forumpost38114]originale message[/url]
avtx30  Posted on 2006/8/1 23:14 | Last modified
GIJOEさん、

どうもありがとうございました。やってみます。

<3分後>
ありがとうございました。出来ました ↓

http://www.nhatban.net (ベトナム語ですが)
GIJOE  Posted on 2006/8/1 6:52
本家2.0.14は本家2.0.13.2とほぼ同じですよ。

include/functions.php は行数も同じ。
include/cp_functions.php は、127行目に挿入。

いずれも、前後の行はほとんど違わないので挿入ポイントも迷わないはずです。
3lr0n  Posted on 2006/7/29 18:35 | Last modified
Hi, if i can el somebody here is the code to apply a css style to the left block with the message:

'content' => '<div class=info_message>'.$_SESSION['redirect_message'].'</div>'

The all u have to do is create a class .info_message (or whatever u want) and apply the css style.

regards.
3lr0n  Posted on 2006/7/29 9:07
btw.. can i assign a style to the block to fit my theme?

i want white font with some padding and red bg .. where can i apply the style in the code?

ta in advance
3lr0n  Posted on 2006/7/29 9:04
Lol, i forget to load the templates to the database.. all fixed

:)
3lr0n  Posted on 2006/7/29 8:51
Hi, i just hack as u mention above but i cant see the left block.. i only hack the part referring to xoops 2.0.13.2 (not the XOOPS 2.0.13a-JP) as i use it on my site.

i did something wrong? u can c my site at www.overclocking.es

ta in advance
avtx30  Posted on 2006/7/25 21:46
本家2.0.14に是非「お手軽高速化」したいのです。

どうかやり方を教えていただけませんでしょうか。
Login
Username or e-mail:

Password:

Remember Me

Lost Password?

Register now!