Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Living up to the facts, get GS to work under PHP 5.2 again!
#1
GetSimple has always stated to run on PHP 5.1.3 and up. Apparently, as of some version, this has no longer been true.

fstieglitz pointed out an installation problem which was easily traced back to a single function not being available below PHP version 5.2.0. I guess with all us developers* running on higher versions of PHP we never noticed. The solution is simple, we define the function when your version of PHP doesn’t!

I did not feel like we had any need for a complete JSON interpreter. Instead the below function is specially made to only read the two possible replies from the GetSimple API server. I’m throwing it up here and not on the SVN because I’ll leave the call to Chris whether we will just make GetSimple 5.2.0+ only or want to define this function in the core.

The fix, put the following code at the bottom of /admin/inc/basic.php:
Code:
/*******************************************************
* @function json_decode
* @returns the API response in the form of an object
* @about - This is to temporarily fix issues with PHP versions < 5.2.0
*
*/
if(!function_exists('json_decode')) {
    function json_decode($api_data) {
        preg_match('/(?P<status>[^"]+)","((api_key":"(?P<api_key>[^"]+))|(latest":"(?P<latest>[^"]+)))/',$api_data,$api_data);
        return (object)$api_data;
    }
}
/******************************************************/

* I partly made this fix because, to keep my fancy title, I feel like I should keep offering support here on the forum ;-)
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#2
r156 has been committed to the SVN, thanks for this Zegnat - i had no idea how this slipped our radar for almost a full year.
- Chris
Thanks for using GetSimple! - Download

Please do not email me directly for help regarding GetSimple. Please post all your questions/problems in the forum!
Reply
#3
Hello,

I have an other error wifth a php version < 5.2 width :
$pathName= pathinfo($fi,PATHINFO_FILENAME )

> admin\inc\plugin_functions.php
Convert to comment the ligne 26
$pathName= pathinfo($fi,PATHINFO_FILENAME );

admin\plugins.php
> Convert to comment the ligne 28
and add after :

Code:
if(version_compare(phpversion(), "5.2.0", "<")) {
function pathinfo_filename($path) {
$temp = pathinfo($path);
if($temp['extension'])
$temp['filename'] = substr($temp['basename'],0 ,strlen($temp['basename'])-strlen($temp['extension'])-1);
return $temp;
}
} else {
function pathinfo_filename($path) {
return pathinfo($path, PATHINFO_FILENAME);
}
}
$pathName = pathinfo_filename($fi);
Reply
#4
Corection on my precedent post :

admin\plugins.php :
Code:
<?php
/****************************************************
*
* @File:     plugins.php
* @Package:    GetSimple
* @Action:    Displays all installed plugins.    
*
*****************************************************/

// Setup inclusions
$load['plugin'] = true;

// Relative
$relative = '../';

// Include common.php
include('inc/common.php');

// Variable settings
login_cookie_check();
$counter = '0';
$table = '';

$pluginfiles = getFiles(GSPLUGINPATH);

    if(version_compare(phpversion(), "5.2.0", "<")) {
        function pathinfo_filename($path) {
            $temp = pathinfo($path);
            if($temp['extension']){
                $temp['filename'] = substr($temp['basename'],0 ,strlen($temp['basename'])-strlen($temp['extension'])-1);
                return $temp['filename'];
            }
            return false;
        }
    } else {
        function pathinfo_filename($path) {
            return pathinfo($path, PATHINFO_FILENAME);
        }
    }

foreach ($pluginfiles as $fi)
{
    $pathExt = pathinfo($fi,PATHINFO_EXTENSION );
    //$pathName= pathinfo($fi,PATHINFO_FILENAME );
    $pathName = pathinfo_filename($fi);

    if ($pathExt=="php")
    {
        $table .= '<tr id="tr-'.$counter.'" >';
        $table .= '<td width="25%" ><b>'.$plugin_info[$pathName]['name'] .'</b></td>';
        $table .= '<td><span>'.$plugin_info[$pathName]['description'] .'<br />';
        $table .= $i18n['PLUGIN_VER'] .' '. $plugin_info[$pathName]['version'].' &nbsp;|&nbsp; By <a href="'.$plugin_info[$pathName]['author_url'].'" target="_blank">'.$plugin_info[$pathName]['author'].'</a></span></td>';
        $table .= "</tr>\n";
        $counter++;
    }    
}    
?>

<?php exec_action('plugin-hook');?>

<?php get_template('header', cl($SITENAME).' &raquo; '.$i18n['PLUGINS_MANAGEMENT']); ?>
    
    <h1><a href="<?php echo $SITEURL; ?>" target="_blank" ><?php echo cl($SITENAME); ?></a> <span>&raquo;</span> <?php echo $i18n['PLUGINS_MANAGEMENT']; ?></h1>
    
    <?php include('template/include-nav.php'); ?>
    <?php include('template/error_checking.php'); ?>
    
    <div class="bodycontent">
    
    <div id="maincontent">
        <div class="main" >
            
        <h3><?php echo $i18n['PLUGINS_MANAGEMENT']; ?></h3>
        
        <table class="edittable highlight paginate">
            <?php echo $table; ?>
        </table>
        <div id="page_counter" class="qc_pager"></div>
        <p><em><b><span id="pg_counter"><?php echo $counter; ?></span></b> <?php echo $i18n['PLUGINS_INSTALLED']; ?></em></p>
            
        </div>
    </div>
    
    <div id="sidebar" >
        <?php include('template/sidebar-plugins.php'); ?>
    </div>
    
    <div class="clear"></div>
    </div>

<?php get_template('footer'); ?>
Reply




Users browsing this thread: 1 Guest(s)