Help with finding versions of modules?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Peter
Forum Commoner
Posts: 28
Joined: Mon Jun 10, 2002 12:40 am
Location: Brisbane, Australia

Help with finding versions of modules?

Post 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.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Try this: extension_loaded()

Hope it helps,
Mac
Peter
Forum Commoner
Posts: 28
Joined: Mon Jun 10, 2002 12:40 am
Location: Brisbane, Australia

Post 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. :)
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Peter
Forum Commoner
Posts: 28
Joined: Mon Jun 10, 2002 12:40 am
Location: Brisbane, Australia

Post 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. :)
Peter
Forum Commoner
Posts: 28
Joined: Mon Jun 10, 2002 12:40 am
Location: Brisbane, Australia

Post 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;
?>
Post Reply