Source de toolbox.inc
<?
define("SCRIPTS_DIR","/scripts/");
define("SOURCES_DIR","/./");
define("JS_DIR","js/");
define("FORUM_DIR","forums/");
define("NO_VIEW_LINK_PATTERN","^display_|of_");
define("LOGIN_FILE","private.php");
function getScriptsArray(&$scripts_array)
{
$script_dir = dir($_SERVER["DOCUMENT_ROOT"].SCRIPTS_DIR);
$scripts_count = 0;
while ($filename = $script_dir->read())
{
if (!ereg("^\.|~$|^index",$filename))
{
$scripts_array[$scripts_count]=$filename;
$scripts_count++;
}
}
$script_dir->close();
sort($scripts_array);
return $scripts_count;
}
function getScriptsTopics()
{
$scripts_count = getScriptsArray($scripts_array);
$topics = array("Sources du site" => "/site_sources.php",
"GCfilms" => "/gcfilms/",
"LCDApi" => "/lcdapi.php",
"CPC MozBar" => "/cpcmozbar/",
"Karmix" => "/karmix.php",
"KarDevices" => "/kardevices.php");
for ($index=0; $index<$scripts_count; $index++)
{
$script_name = $scripts_array[$index];
$topics[$script_name] = "/affiche_script.php?script=$script_name";
}
return $topics;
}
function getSourcesArray(&$sources_array, &$themes_array, &$forums_array, &$js_array)
{
$sources_dir = dir($_SERVER["DOCUMENT_ROOT"].SOURCES_DIR);
$sources_count = 0;
while ($filename = $sources_dir->read())
{
if (ereg("\.php$|\.inc$",$filename))
{
$sources_array[$sources_count]=$filename;
$sources_count++;
}
}
$sources_dir->close();
sort($sources_array);
$lessons_dir = dir($_SERVER["DOCUMENT_ROOT"].'/cours/');
$lessons_count = 0;
while ($filename = $lessons_dir->read())
{
if (ereg("\.php$|\.inc$",$filename))
{
$lessons_array[$lessons_count] = 'cours/'.$filename;
$lessons_count++;
}
}
$lessons_dir->close();
sort($lessons_array);
$sources_array = array_merge($sources_array,$lessons_array);
$themes_dir = dir($_SERVER["DOCUMENT_ROOT"].THEMES_DIR);
$themes_count = 0;
while ($filename = $themes_dir->read())
{
if (ereg("\.css$",$filename))
{
$themes_array[$themes_count]=$filename;
$themes_count++;
}
}
$themes_dir->close();
sort($themes_array);
$forums_dir = dir($_SERVER["DOCUMENT_ROOT"]."/".FORUM_DIR);
$forums_count = 0;
while ($filename = $forums_dir->read())
{
if (ereg("\.php$",$filename) && ($filename != LOGIN_FILE))
{
$forums_array[$forums_count]=$filename;
$forums_count++;
}
}
$forums_dir->close();
sort($forums_array);
$js_dir = dir($_SERVER["DOCUMENT_ROOT"]."/".JS_DIR);
$js_count = 0;
while ($filename = $js_dir->read())
{
if (ereg("\.js$",$filename))
{
$js_array[$js_count]=$filename;
$js_count++;
}
}
$js_dir->close();
sort($js_array);
}
define("SCRIPTS_DIR","/scripts/");
define("SOURCES_DIR","/./");
define("JS_DIR","js/");
define("FORUM_DIR","forums/");
define("NO_VIEW_LINK_PATTERN","^display_|of_");
define("LOGIN_FILE","private.php");
function getScriptsArray(&$scripts_array)
{
$script_dir = dir($_SERVER["DOCUMENT_ROOT"].SCRIPTS_DIR);
$scripts_count = 0;
while ($filename = $script_dir->read())
{
if (!ereg("^\.|~$|^index",$filename))
{
$scripts_array[$scripts_count]=$filename;
$scripts_count++;
}
}
$script_dir->close();
sort($scripts_array);
return $scripts_count;
}
function getScriptsTopics()
{
$scripts_count = getScriptsArray($scripts_array);
$topics = array("Sources du site" => "/site_sources.php",
"GCfilms" => "/gcfilms/",
"LCDApi" => "/lcdapi.php",
"CPC MozBar" => "/cpcmozbar/",
"Karmix" => "/karmix.php",
"KarDevices" => "/kardevices.php");
for ($index=0; $index<$scripts_count; $index++)
{
$script_name = $scripts_array[$index];
$topics[$script_name] = "/affiche_script.php?script=$script_name";
}
return $topics;
}
function getSourcesArray(&$sources_array, &$themes_array, &$forums_array, &$js_array)
{
$sources_dir = dir($_SERVER["DOCUMENT_ROOT"].SOURCES_DIR);
$sources_count = 0;
while ($filename = $sources_dir->read())
{
if (ereg("\.php$|\.inc$",$filename))
{
$sources_array[$sources_count]=$filename;
$sources_count++;
}
}
$sources_dir->close();
sort($sources_array);
$lessons_dir = dir($_SERVER["DOCUMENT_ROOT"].'/cours/');
$lessons_count = 0;
while ($filename = $lessons_dir->read())
{
if (ereg("\.php$|\.inc$",$filename))
{
$lessons_array[$lessons_count] = 'cours/'.$filename;
$lessons_count++;
}
}
$lessons_dir->close();
sort($lessons_array);
$sources_array = array_merge($sources_array,$lessons_array);
$themes_dir = dir($_SERVER["DOCUMENT_ROOT"].THEMES_DIR);
$themes_count = 0;
while ($filename = $themes_dir->read())
{
if (ereg("\.css$",$filename))
{
$themes_array[$themes_count]=$filename;
$themes_count++;
}
}
$themes_dir->close();
sort($themes_array);
$forums_dir = dir($_SERVER["DOCUMENT_ROOT"]."/".FORUM_DIR);
$forums_count = 0;
while ($filename = $forums_dir->read())
{
if (ereg("\.php$",$filename) && ($filename != LOGIN_FILE))
{
$forums_array[$forums_count]=$filename;
$forums_count++;
}
}
$forums_dir->close();
sort($forums_array);
$js_dir = dir($_SERVER["DOCUMENT_ROOT"]."/".JS_DIR);
$js_count = 0;
while ($filename = $js_dir->read())
{
if (ereg("\.js$",$filename))
{
$js_array[$js_count]=$filename;
$js_count++;
}
}
$js_dir->close();
sort($js_array);
}
Si avez des problèmes ou des questions concernant ce fichier source, vous pouvez utiliser le Forum Sources du site