xoops forums

playsome

Not too shy to talk
Posted on: 2012/10/24 12:54
playsome
playsome (Show more)
Not too shy to talk
Posts: 197
Since: 2009/4/15
#1

xoRewriteModule hack not working after upgrade to php 5.3.17

Hi all,

my host(surpass) has upgraded php to 5.3.17 and it seems to have made the xorewriteModule hack not work.

It seems to be the rewriting of the urls to remove the /modules/ part that is not working e.g <{$xoAppUrl /modules/article/}> in the theme should point to sitename.com/news/ but it points to sitename.com/modules/article/.

I can still manually type in sitename.com/news/ and it will work fine, but the rewriting has stopped working.

I have turned on xoops debug and i get the following 6 errors:

Warningsyntax errorunexpected END_OF_LINEexpecting '=' in /configs/xoRewriteModule.ini.php on line 14 in file /Frameworks/smarty/xoSmartyFunctions.php line 32
Warning
array_key_exists() expects parameter 2 to be array, boolean given in file /Frameworks/smarty/xoSmartyFunctions.php line 34
Warning
XoSmartyPlugin section [xoRewriteModuledoes not exist in /configs/xoRewriteModule.ini.php in file /Frameworks/smarty/xoSmartyFunctions.php line 42
Warning
syntax errorunexpected END_OF_LINEexpecting '=' in /configs/xoRewriteModule.ini.php on line 14 in file /Frameworks/smarty/xoSmartyFunctions.php line 32
Warning
array_key_exists() expects parameter 2 to be array, boolean given in file /Frameworks/smarty/xoSmartyFunctions.php line 34
Warning
XoSmartyPlugin section [xoRewriteModuledoes not exist in /configs/xoRewriteModule.ini.php in file /Frameworks/smarty/xoSmartyFunctions.php line 42


this is the code in xoRewriteModule.ini.php
<?php
/**
 * -------------------------------------------------------------------------------------
 * Smarty plugin for xoops
 * xoRewriteModule configuration file
 *
 * Author:                : DuGris <http://www.dugris.info>
 * -------------------------------------------------------------------------------------
 * xoRewriteModule    : Url rewritting for modules/dirname
 * -------------------------------------------------------------------------------------
 */
 
 
[xoRewriteModule]
 
article="news"
 
xcgal="photo-gallery"
 
qpages="whats-on"
 
smartpartner="partners"
 
extcal="calendar"
 
content="services"
 
room-hire="room-hire"
 
wfchannel="about-us"
 
mastop_go2="spotlight"
 
mysearch="wcrcsearch"
 
g-teas-cafe="g-teas-cafe"
 
sitemap="sitemap"
 
docs="docs"
 
tag="tags"
 
links="links"
 
profile="profile"
 
pm="pm"
 
contact="contactform"
 
newbb="forums"
 
tips-for-saving-energy="top-tips-for-saving-energy"
 
weblog="blogs"
 
outofschoolcare="bonusballoutofschoolcare"
 

?>


this is the code in Frameworks/smarty/xoSmartyFunctions.php

<?php
/**
 * -------------------------------------------------------------------------------------
 * Common functions for Xoops's smarty plugins : xoSmartyFunctions.php
 *
 * Type            : common functions
 * Author:        : DuGris <http://www.dugris.info>
 * Purpose        : Common functions for Xoops's smarty plugins
 * -------------------------------------------------------------------------------------
**/

define("XOSMARTY_FILENOTFOUND""XoSmartyPlugin : %s does not exist");
define("XOSMARTY_SECTIONNOTFOUND""XoSmartyPlugin : section [%s] does not exist in %s");
define("XOSMARTY_GDNOTINSTALLED""XoSmartyPlugin : GD Librairy is not installed");
define("XOSMARTY_DEFAULTVALUE""XoSmartyPlugin : %s use the default values");

/**
 * -------------------------------------------------------------------------------------
 * get the contents of the section of ini file :
 *
 * @param        String        $section            name of the section of ini file
 *
 * @return        Array
 * -------------------------------------------------------------------------------------
**/
function XoSmartyPluginGetSection$section '' ) {
    
$config_file 'xoSmartyPlugin';
    if ( 
file_existsXOOPS_ROOT_PATH "/configs/$section.ini.php" ) ) {
        
$config_file $section;
    }
    if ( 
file_existsXOOPS_ROOT_PATH "/configs/$config_file.ini.php" ) ) {
        
$IniContent parse_ini_fileXOOPS_ROOT_PATH "/configs/$config_file.ini.php"true);
        if ( !empty(
$section) ) {
            if ( 
array_key_exists$section$IniContent) ) {
                if ( 
count($IniContent[$section]) == ) {
                     
XoopsErrorHandler_HandleErrorE_USER_WARNINGsprintf(XOSMARTY_SECTIONNOTFOUND$section"/configs/$config_file.ini.php"), __FILE____LINE__ );
                    return array();
                }
                return 
$IniContent[$section];
            }
        }
         
XoopsErrorHandler_HandleErrorE_USER_WARNINGsprintf(XOSMARTY_SECTIONNOTFOUND$section"/configs/$config_file.ini.php"), __FILE____LINE__ );
        return 
$IniContent;
    }
    
XoopsErrorHandler_HandleErrorE_USER_WARNINGsprintf(XOSMARTY_FILENOTFOUND"/configs/$section.ini.php") , __FILE____LINE__ );
    return array();
}

/**
 * -------------------------------------------------------------------------------------
 * Check if the GD Librairy is installed
 *
 * @return        Boolean        TRUE if GD Librairy is installed, FALSE otherwise
 * -------------------------------------------------------------------------------------
**/
function XoSmartyPluginLoadGD() {
    if (
extension_loaded('gd')) {
        
$required_functions = array("imagecreate""imagecreatetruecolor""imagecolorallocate""imagefilledrectangle""ImagePNG""imagedestroy""imageftbbox""ImageColorTransparent");
        foreach(
$required_functions as $func) {
            if( !
function_exists($func) ) {
                
XoopsErrorHandler_HandleErrorE_USER_WARNINGXOSMARTY_GDNOTINSTALLED __FILE____LINE__ );
                return 
false;
            }
        }
    }
    return 
true;
}

/**
 * -------------------------------------------------------------------------------------
 * Convert Hexacimal color in RGB color
 *
 * @param        String        $color        hexacimal color
 *
 * @return        Array            {0 => red color value, 1 => green color value, 2 => blue color value)
 * -------------------------------------------------------------------------------------
**/

function XoSmartyPluginHTML2RGB$color '#000000' ) {
    if (
substr($color,0,1)=="#"$color=substr($color,1,6);

    
$ret[0] = hexdec(substr($color02));
    
$ret[1] = hexdec(substr($color22));
    
$ret[2] = hexdec(substr($color42));
    return 
$ret;
}

/**
 * -------------------------------------------------------------------------------------
 * Truncate string
 *
 * @param        string        $string            string to truncate
 * @param        int            $length            determines how many characters to truncate to.
 * @param        string        $etc                replace the truncated text
 * @param        boolean        $break_words    determines whether or not to truncate at a word boundary
 * @param        boolean        $middle            determines whether the truncation happens at the end of the string
 *
 * @return        String
 * -------------------------------------------------------------------------------------
**/
function XoSmartyPlugin_truncate($string$length 80$etc '...'$break_words false$middle false) {
    if ( 
$length == ) {
        return 
'';
    }

    if ( 
strlen($string) > $length ) {
        
$length -= min($lengthstrlen($etc));
        if ( !
$break_words && !$middle ) {
            
$string preg_replace('/s+?(S+)?$/'''substr($string0$length+1));
        }
        if ( !
$middle ) {
            return 
substr($string0$length) . $etc;
        } else {
            return 
substr($string0$length/2) . $etc substr($string, -$length/2);
        }
    } else {
        return 
$string;
    }
}

function 
XoSmartyPlugin_write_index_file$path '') {
    if ( empty(
$path) ) { return false; }

    
$path substr($path, -1) == "/" substr($path0, -1) : $path;
    
$filename $path '/index.html';

    if ( 
file_exists($filename) ) { return true; }

    if ( !
$file fopen($filename"w") ) {
        echo 
'failed open file';
        return 
false;
    }
    if ( 
fwrite($file"<script>history.go(-1);</script>") == -) {
        echo 
'failed write file';
        return 
false;
    }
    
fclose($file);
    return 
true;
}
?>


Any ideas to what has changed in php 5.3.17 that could be casuing these errors and the rewrite hack not to work?

Thanks for your help.

playsome

Not too shy to talk
Posted on: 2012/10/24 13:13
playsome
playsome (Show more)
Not too shy to talk
Posts: 197
Since: 2009/4/15
#2

[SOLVED]xoRewriteModule hack not working after upgrade to php 5.3.17

easiest fix ever. After a quick search of google it seems that indentation can sometimes casue the end of line errors. So in xoRewriteModule.ini.php line 13 where it has
[xoRewriteModule]
there was a indentation of one space, simply deleted that space and everything seems tio work now, no errors at all.

Not sure how it works but it works, hope this can help anyone else with similar problems.

irmtfan

Module Developer
Posted on: 2012/10/27 5:27
irmtfan
irmtfan (Show more)
Module Developer
Posts: 3419
Since: 2003/12/7
#3

Re: [SOLVED]xoRewriteModule hack not working after upgrade to php 5.3.17

nice finding.
Im in the surpass too.
I think many xoops modules need to be compatible with php 5.3

Dedale

Friend of XOOPS
Posted on: 2012/10/30 17:02
Dedale
Dedale (Show more)
Friend of XOOPS
Posts: 68
Since: 2007/1/12
#4

Re: [SOLVED]xoRewriteModule hack not working after upgrade to php 5.3.17

It didn't work for me. But I found another fix.

I read that php ini parser cannot parse a php file. So I removed the php tags and comments.

Now the file looks like:

[xoRewriteModule]
modulename="newname"
...