Page 1 of 1

Help with finding versions of modules?

Posted: Mon Jun 10, 2002 12:40 am
by Peter
Hello!

I trying to find out how you can get the versions of modules and whether they're enabled. Is there a function or variable, or is there only to grab it from phpinfo()?

I was writting a script to grab it from phpinfo() but then I got a mindblock. :P Here's what I've currently written...

Code: Select all

<?
/* Test for GD */
$line = file("test.php"); // contents of test.php: phpinfo(8);
foreach($line as $cfg_var)&#123;
if(eregi("GD Support",$cfg_var) || eregi("GD Version",$cfg_var))&#123;
$cfg_var = strip_tags($cfg_var,"<b>");
echo $cfg_var . "<br>";
&#125;
&#125;
?>
Thanks.

Posted: Mon Jun 10, 2002 2:01 am
by twigletmac
Try this: extension_loaded()

Hope it helps,
Mac

Posted: Mon Jun 10, 2002 2:36 am
by Peter
Thank You.

Unfortunately that would only find whether the module is installed, whereas I want to find the version of the module and whether it is enabled. :)

Posted: Mon Jun 10, 2002 3:34 am
by twigletmac
Nope, the function tests to see if the module is available - not if it is installed. There doesn't appear to be any obvious way of determining the version of an extension but you could check to see if the function you want to use is supported by using a combination of extension_loaded() and get_extension_funcs().

Mac

Posted: Mon Jun 10, 2002 4:17 am
by Peter
twigletmac wrote:Nope, the function tests to see if the module is available - not if it is installed. There doesn't appear to be any obvious way of determining the version of an extension but you could check to see if the function you want to use is supported by using a combination of extension_loaded() and get_extension_funcs().

Mac
Okay, that takes care of the availability, but I still need to find the exact version number because I'm not trying to find the existance of a function, but rather echo out the version to the user. :)

Posted: Mon Jun 10, 2002 5:28 am
by Peter
Okay, I got off my lazy arse, fixed my head..... and then fixed the script.... :D

Code: Select all

<?

/* Test for GD */

// start output buffer
ob_start();
        
// set phpinfo() as output
phpinfo(8);
       
// get contents of output buffer and insert into string
$var_phpinfo = ob_get_contents();
                
// end output buffer
ob_end_clean();

// split up phpinfo variable into array
$var_phpinfo = explode("\n",$var_phpinfo);

foreach($var_phpinfo as $line)&#123;
if(eregi("GD Support",$line) || eregi("GD Version",$line))&#123;
$line = strip_tags($line,"<b>");
echo $line . "<br>";
/*
$module = explode("</b>",$line);
switch($module&#1111;0])&#123;
case "GD Support":
$gd_support = $module&#1111;1];
break;
case "GD Version":
$gd_version = $module&#1111;1];
break;
&#125;
*/
&#125;

if($gd_support == "enabled")&#123;
echo "GD Version: $gd_version";
&#125;

&#125;
?>