1
playsome
xoRewriteModule hack not working after upgrade to php 5.3.17
  • 2012/10/24 12:54

  • playsome

  • Not too shy to talk

  • Posts: 197

  • Since: 2009/4/15


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
/**
 * -------------------------------------------------------------------------------------
 * Smarty plugin for xoops
 * xoRewriteModule configuration file
 *
 * Author:                : DuGris 
 * -------------------------------------------------------------------------------------
 * 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

/**
 * -------------------------------------------------------------------------------------
 * Common functions for Xoops's smarty plugins : xoSmartyFunctions.php
 *
 * Type            : common functions
 * Author:        : DuGris 
 * 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"") == -) {
        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.

2
playsome
[SOLVED]xoRewriteModule hack not working after upgrade to php 5.3.17
  • 2012/10/24 13:13

  • playsome

  • Not too shy to talk

  • Posts: 197

  • Since: 2009/4/15


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.


3
irmtfan
Re: [SOLVED]xoRewriteModule hack not working after upgrade to php 5.3.17
  • 2012/10/27 5:27

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


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

4
Dedale
Re: [SOLVED]xoRewriteModule hack not working after upgrade to php 5.3.17
  • 2012/10/30 17:02

  • Dedale

  • Friend of XOOPS

  • Posts: 68

  • Since: 2007/1/12


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"
...

Login

Who's Online

272 user(s) are online (161 user(s) are browsing Support Forums)


Members: 0


Guests: 272


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits