Page 1 sur 1

Lister les fonctions disponibles

Posté : 21 mai 2005, 15:36
par Cyrano
Salut,
J'ai un jour récupéré un script que je trouve particulièrment pratique. J'ai quelque peu arrangé le code d'origine à ma sauce pour établir la liste des librairies disponibles et par librairie, la liste des fonctions PHP. Chaque fonction indiquée pointe vers la page du manuel en ligne (version française). Vous pouvez voir pour l'exemple ce que ça donne sur free.fr ICI.

Petit détail, si vous installez au même niveau que cette page un fichier phpinfo.php avec un simple phpinfo(), un lien sera en outre affiché près du logo de PHP.

Le code de ce script :
<?php
echo("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
<!-- Date de création: 29-10-03 -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Librairies disponibles et commandes sous PHP <?php echo(phpversion()); ?></title>
<style type="text/css">
<!--
body {background-color: #ffffff; color: #000000; padding: 0px}
body, td, h2, h3 {font-family: sans-serif;}
a {color: #000099; text-decoration: none; background-color: transparent;}
a:hover {text-decoration: underline;}
a.retour{color: #000099; text-decoration: none; background-color: transparent; border: 1px solid #000000; font-size: 12px; font-weight: bold}
a.retour:hover {color:#000099; background-color: #cccccc; text-decoration: none; font-size: 12px; font-weight: bold}
a:visited {color:#000099}
table {border-collapse: collapse; width: 70%; margin-left: 14%}
td { border: 1px solid #000000; font-size: 12px; vertical-align: baseline;}
h2 {font-size: 22px; text-align: center}
h3 {font-size: 18px; margin-left: 20px; margin-bottom: 0px}
.p {text-align: left;}
.e {background-color: #ccccff; font-weight: bold; color: #000000; text-align: left}
.h {background-color: #9999cc; font-weight: bold; color: #000000;}
.v {background-color: #cccccc; color: #000000;}
i {color: #666666; background-color: #cccccc;}
img {float: right; border: none}
hr {width: 600px; background-color: #cccccc; border: 0px; height: 1px; color: #000000;}
#menu {background-color: #9999cc; text-align: left; font-weight: bold; color: #000000; border: 1px solid #000000; width: 70%; margin-left: 14%; padding-top: 10px; padding-left: 25px}
#logo {float: right; width: 160px; margin-top: 20px; padding-right: 5px}
//-->
</style>
<script language="JavaScript" type="text/javascript">
<!--
function ouvre(nomFonction)
{
    // var description = window.open("http://localhost/Documentations/Manuel_PHP.php/function." + nomFonction + ".php","descriptionFonction","scrollbars=no,width=800,height=600,scrollbars,resizable");
    var description = window.open("http://www.php.net/manual/fr//function." + nomFonction + ".php","descriptionFonction","location=yes,scrollbars=no,width=800,height=600,scrollbars,resizable");
    description.document.close();
    description.focus();
}
// -->
</script>
</head>
<body>
<a name="top"></a>
<h2>Liste des librairies installées:</h2>
<div id="menu">
  <div id="logo">
  <p><a href="http://www.php.net/"><img src="http://static.php.net/www.php.net/images/php.gif" alt="PHP.net, le site officiel" title="PHP.net, le site officiel" /></a></p>
  </div>
  <p><span style="text-align: right; float: right">Version installée : <?php echo(phpversion()); ?><br />
<?php
if(file_exists("./phpinfo.php"))
{
?>
  <a href="#" onclick="window.open('./phpinfo.php')" title="Information de configuration du serveur de Cyrano.">PHP Info.</a></span></p>
<?php
}
?>
<ol start="1" style="list-style-type: upper-roman"> 
<?php 
$listModule = get_loaded_extensions();
foreach ($listModule as $key => $module)
{
    $nom_module = str_replace(" ","_",$module);
    echo "<li>Librairie : <b><a href=\"#". $nom_module ."\">". $module ."</a></b></li>\n";
}
?> 
</ol>
</div>
<div style="text-align:center; padding: 0px; margin: 0px">
<h2>Detail des fonctions par librairie:</h2> 
<?php 
foreach ($listModule as $modulKey => $module)
{
    $nom_module = str_replace(" ","_",$module);
    ?>
<a name="<?php echo($nom_module); ?>"></a>
<table class="tableaux_lib" summary="">
  <tr class="h">
    <td>
      <h3>Librairie : <span><?php echo($module); ?></span></h3>
    </td>
  </tr>
  <tr>
    <td class="e">
    <?php
    $listfonctions = get_extension_funcs(strtolower($module));
    if($listfonctions)
    {
        sort($listfonctions);
        ?>
      <ol type="1">
        <?php
        foreach ($listfonctions as $fonctionKey => $fonctions)
        {
            $nomFonctions = str_replace("_","-",$fonctions);
?>
        <li>Fonction supportée : <a href="#" onclick="ouvre('<?php echo($nomFonctions); ?>'); return false;"><?php echo($fonctions); ?></a></li>
<?php
        }
?>
      </ol>
<?php
    }
    else
    {
?>
        <p>Liste des fonctions non disponibles.</p>
<?php
    }
?>
    </td>
  </tr>
</table>
<p><a href="#top" class="retour">&nbsp;revenir en haut de la page </a></p>
<?php
}
?> 
</div>
</body>
</html>
Bon code :)

Posté : 21 mai 2005, 15:39
par fab
Très simpa, je garde et si un jour je dois changer d'hébergeur et prendre un mutualisé je lui demanderé surement de le mettre pour voir :)

Posté : 21 mai 2005, 16:00
par rami
Ouais plutôt sympa effectivement ;)
Je garde ce code sous la main.

Posté : 21 sept. 2005, 22:34
par Gibsostrat
8) Mis en application, nickel

Merci

Posté : 22 sept. 2005, 09:08
par PhilFree
Bonjour à tous !

Super script, très utile, merci Cyrano !

Petite question, l'affichage chez moi est incorrect avec IE et Firefox sous Windows XP Home et Pro. Où dois-je agir sur le script pour que la mise en page soit correcte ?

Ce qui me semble bizarre, c'est que la mise en page sur le lien que donne Cyrano est impeccable.

Voici ce que j'obtiens avec FireFox (c'est pire avec IE):

Image

Posté : 22 sept. 2005, 09:14
par Cyrano
Ça sent la boulette en CSS ça, faudrait que je vérifie, je n'ai jamais vu cette forme et j,ai pourtant testé avec plusieurs navigateurs... :-k

Posté : 22 sept. 2005, 11:24
par naholyr
L'affichage des librairies je l'ai corrigé comme ça (attention, tu avais un <ol> dans un <span>) :
<div id="menu">
  <div id="logo">
  <p><a href="http://www.php.net/"><img src="fonctions_fichiers/php.gif" alt="PHP.net, le site officiel" title="PHP.net, le site officiel"></a></p>
  </div>
  <p style="text-align: right;">Version installée : 5.1.0RC1</p>
<ol start="1" style="list-style-type: upper-roman;">
<li>Librairie : <b><a href="#bcmath">bcmath</a></b></li>
...
</ol>
</div>
Ensuite il suffit de fermer la balise meta, et la balise img, et on a une page valide selon son doctype (xhtml) ;)

Posté : 22 sept. 2005, 15:24
par PhilFree
Merci Naholyr,

Le résultat est PARFAIT :wink:

Posté : 23 sept. 2005, 12:35
par Grummfy
pour corriger (dans le code ....)
remplacer

Code : Tout sélectionner

if(file_exists("./phpinfo.php")) { ?> <a href="#" onclick="window.open('./phpinfo.php')" title="Information de configuration du serveur de Cyrano.">PHP Info.</a></span></p> <?php } ?>
par

Code : Tout sélectionner

if(file_exists("./phpinfo.php")) { ?> <a href="#" onclick="window.open('./phpinfo.php')" title="Information de configuration du serveur de Cyrano.">PHP Info.</a> <?php } ?> </span></p>