PHP Coding Standards fixes

This commit is contained in:
n 2024-02-12 20:46:07 +01:00
parent 9fc0ef62d5
commit 0a3c559a59
45 changed files with 938 additions and 958 deletions

View file

@ -1,6 +1,6 @@
<?php
$titlepage = "Accès refusé";
include "include/head.inc.php";
<?php
$titlepage = "Accès refusé";
include "include/head.inc.php";
include "include/theme.inc.php";
include "themes/default/theme.php";

View file

@ -1,4 +1,4 @@
<?php
<?php
$titlepage = "Fichier non trouvé";
include "include/head.inc.php";
include "include/theme.inc.php";

View file

@ -1,5 +1,5 @@
<?php
$titlepage="Erreur interne";
$titlepage = "Erreur interne";
include "include/head.inc.php";
include "include/theme.inc.php";

View file

@ -1,17 +1,16 @@
<?php
define("IFPP_PATH","http://$HTTP_HOST/ifpp");
define("IFPP_PATH", "http://$HTTP_HOST/ifpp");
define("PAGES_PATH",IFPP_PATH."/pages");
define("INCLUDE_PATH",IFPP_PATH."/include");
define("IMAGES_PATH",IFPP_PATH."/images");
define("MODULES_PATH",IFPP_PATH."/modules");
define("PAGES_PATH", IFPP_PATH."/pages");
define("INCLUDE_PATH", IFPP_PATH."/include");
define("IMAGES_PATH", IFPP_PATH."/images");
define("MODULES_PATH", IFPP_PATH."/modules");
define("MODULES_FORTUNE_PATH",IFPP_PATH.MODULES_PATH."/fortunes");
define("MODULES_SONDAGE_PATH",IFPP_PATH.MODULES_PATH."/sondages");
define("MODULES_LIENSDIRECTS_PATH",IFPP_PATH.MODULES_PATH."/liensdirects");
define("MODULES_TRIBUNE_PATH",IFPP_PATH.MODULES_PATH."/tribune");
define("MODULES_FORTUNE_PATH", IFPP_PATH.MODULES_PATH."/fortunes");
define("MODULES_SONDAGE_PATH", IFPP_PATH.MODULES_PATH."/sondages");
define("MODULES_LIENSDIRECTS_PATH", IFPP_PATH.MODULES_PATH."/liensdirects");
define("MODULES_TRIBUNE_PATH", IFPP_PATH.MODULES_PATH."/tribune");
include INCLUDE_PATH."/body.inc.php";
echo INCLUDE_PATH;
?>

View file

@ -1,15 +1,18 @@
<?php
echo "<img src='images/li_lgn1_animated.gif' width=100%><div align=center>
<table border=0 width='100%' valign=bottom><tr>
<td align =center>\n<a href='http://fr.php.net/' target='_blank'>\n<img src='images/";
if (date("n")!="4")
echo "elephpant.gif";
else
echo "phpoisson_davril.gif";
if (date("n") != "4") {
echo "elephpant.gif";
} else {
echo "phpoisson_davril.gif";
}
echo "' alt='Ce site utilise PHP5' title='Ce site utilise PHP5' border=0></a>\n</td>\n";
if ($HTTP_GET_VARS["IFRANCE"] =="1")
echo "<td align=center>{=compt_puce_b}</td>\n";
if ($HTTP_GET_VARS["IFRANCE"] == "1") {
echo "<td align=center>{=compt_puce_b}</td>\n";
}
echo "
<td align=center>\n<a href='http://www.ifrance.com/phpinfo/index.php?section=pages/pip&page=index&theme=$theme' target='_blank'>\n<img src='images/mercipip.jpg' height=45 width=102 alt='Powered by PIP' title='Powered by PIP' border=0></a>\n</td>
@ -20,4 +23,3 @@ echo "
</tr></table></div></div>\n";
// echo "<br><a href=\"index.php\">retour au menu</a><br></div>";
?>

View file

@ -1,18 +1,18 @@
<div align=right>
<?php
setlocale (LC_ALL, 'fr_FR');
//$link = mysql_connect("localhost", "", "")
// or die("Could not connect");
//$hits = mysql_query("SELECT COUNT(*) FROM visit.visiteurs",$link)
// or die("Invalid query");
//echo strftime("%A %e %B %G | %R");
//if ($hits)
// echo mysql_result($hits,0)."<a href='visit/'> Hits</a><hr>";
//mysql_close($link);
//echo rand(10,10000000);
//echo "<a href='visit/' title=\"Vous y croyez, vous ?\"> Hits</a><hr>";
setlocale(LC_ALL, 'fr_FR');
//$link = mysql_connect("localhost", "", "")
// or die("Could not connect");
//$hits = mysql_query("SELECT COUNT(*) FROM visit.visiteurs",$link)
// or die("Invalid query");
//echo strftime("%A %e %B %G | %R");
//if ($hits)
// echo mysql_result($hits,0)."<a href='visit/'> Hits</a><hr>";
//mysql_close($link);
//echo rand(10,10000000);
//echo "<a href='visit/' title=\"Vous y croyez, vous ?\"> Hits</a><hr>";
?>
</div>

View file

@ -18,4 +18,3 @@ $noir = "#000000";
$blanc = "#FFFFFF";
*/
echo "<body onload=\"initLightbox(); useStyleAgain('styleTestStore');\" onunload=\"rememberStyle('styleTestStore');\">";
?>

View file

@ -2,10 +2,11 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
if ($titlepage == "")
$titlepage = "Train Miniature Avallonnais";
else
$titlepage = "Train Miniature Avallonnais : $titlepage";
if ($titlepage == "") {
$titlepage = "Train Miniature Avallonnais";
} else {
$titlepage = "Train Miniature Avallonnais : $titlepage";
}
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"fr\">
<head>

View file

@ -1,4 +1,5 @@
<?php
require_once "include/standard.inc.php";
require_once "include/timer.inc.php";
require_once "include/random.inc.php";
@ -6,16 +7,13 @@ require_once "include/random.inc.php";
// modèle = YYYY mm dd hh MM ss
// masque = 0000 00 00 00 10 00
// valeur = 24h.
$Logo = timer("logo",240000);
$Logo = timer("logo", 240000);
if ($Logo == FALSE)
{
while (($RandomLogo = RandomFile("images/logos/")) == $Logo);
settimer("logo","$RandomLogo");
$Logo = $RandomLogo;
if ($Logo == false) {
while (($RandomLogo = RandomFile("images/logos/")) == $Logo);
settimer("logo", "$RandomLogo");
$Logo = $RandomLogo;
}
echo "<a href='leclub.html' title='TMA'><img src='images/logos/$Logo' alt='TMA' width='147' height='82' class='border2' /></a>";
unset($Logo);
unset($RandomLogo);
?>

View file

@ -1,11 +1,11 @@
<?php
function openimg($source,$lien,$titre,$target='_blank')
function openimg($source, $lien, $titre, $target = '_blank')
{
echo "<a href=\"$lien\" title=\"$titre\" onclick=\"window.open(this,'$target','location=0,statusbar=0,menubar=0,width=720,height=500'); return false\"><img src=\"$source\" alt=\"$titre\" title=\"$titre\" /></a>";
echo "<a href=\"$lien\" title=\"$titre\" onclick=\"window.open(this,'$target','location=0,statusbar=0,menubar=0,width=720,height=500'); return false\"><img src=\"$source\" alt=\"$titre\" title=\"$titre\" /></a>";
}
function litebox($source,$lien,$titre,$target='_blank')
function litebox($source, $lien, $titre, $target = '_blank')
{
echo "<a href=\"$lien\" title=\"$titre\" rel=\"lightbox[exemple]\"><img src=\"$source\" alt=\"$titre\" title=\"$titre\" /></a>";
echo "<a href=\"$lien\" title=\"$titre\" rel=\"lightbox[exemple]\"><img src=\"$source\" alt=\"$titre\" title=\"$titre\" /></a>";
}
?>
<br />

View file

@ -1,41 +1,42 @@
<?php
// plante la graine...
@mt_srand ((double) microtime() * 1000000);
@mt_srand((float) microtime() * 1000000);
function RandomColors()
{
$colors = array("ccccff","cceecc","ffcccc","eeccee","ffccff","cceeee","cceeff");
$color[0] = $color[1] = "000000";
$colors = array("ccccff","cceecc","ffcccc","eeccee","ffccff","cceeee","cceeff");
$color[0] = $color[1] = "000000";
while ($color[0] == $color[1])
{
$color[0] = $colors[mt_rand(0, count($colors)-1)];
$color[1] = $colors[mt_rand(0, count($colors)-1)];
}
while ($color[0] == $color[1]) {
$color[0] = $colors[mt_rand(0, count($colors) - 1)];
$color[1] = $colors[mt_rand(0, count($colors) - 1)];
}
@array_splice($colors,0);
@array_splice($colors, 0);
return $color;
return $color;
}
function RandomFile($dirname)
{
$i = 0;
$d = opendir($dirname);
$i = 0;
$d = opendir($dirname);
while (false!==($rfile = readdir($d)))
if (($rfile[0] != ".") && is_file($dirname."/".$rfile))
$listfiles[++$i] = $rfile;
closedir($d);
while (false !== ($rfile = readdir($d))) {
if (($rfile[0] != ".") && is_file($dirname."/".$rfile)) {
$listfiles[++$i] = $rfile;
}
}
closedir($d);
if (count($listfiles) > 1)
$rfile = $listfiles[mt_rand(1, count($listfiles))];
else
$rfile =$listfiles[1];
if (count($listfiles) > 1) {
$rfile = $listfiles[mt_rand(1, count($listfiles))];
} else {
$rfile = $listfiles[1];
}
@array_splice($listfiles,0);
@array_splice($listfiles, 0);
return $rfile;
return $rfile;
}
?>

View file

@ -1,232 +1,241 @@
<?php
// extract($themeset, EXTR_OVERWRITE);
// fonctions & icones par nitro skateboarding
// http://www.multimania.com/nskate
$souriez = array(
array("|:-)", "lunettes.gif"),
array(";-)", "clin.gif"),
array(";)", "clin.gif"),
array(";o)", "clin.gif"),
array(":-))", "dents.gif"),
array(":))", "dents.gif"),
array(":-)", "content.gif"),
array(":)", "content.gif"),
array(":-o", "couteau.gif"),
array(":o)", "debile.gif"),
array(":-((", "enerve.gif"),
array(":((", "enerve.gif"),
array(":-(", "decu.gif"),
array(":(", "decu.gif"),
array("8-)", "hallucine.gif"),
array(":-p", "langue.gif"),
array(";-(", "pleure.gif"),
array(";(", "pleure.gif"),
array(";o(", "pleure.gif")
array("|:-)", "lunettes.gif"),
array(";-)", "clin.gif"),
array(";)", "clin.gif"),
array(";o)", "clin.gif"),
array(":-))", "dents.gif"),
array(":))", "dents.gif"),
array(":-)", "content.gif"),
array(":)", "content.gif"),
array(":-o", "couteau.gif"),
array(":o)", "debile.gif"),
array(":-((", "enerve.gif"),
array(":((", "enerve.gif"),
array(":-(", "decu.gif"),
array(":(", "decu.gif"),
array("8-)", "hallucine.gif"),
array(":-p", "langue.gif"),
array(";-(", "pleure.gif"),
array(";(", "pleure.gif"),
array(";o(", "pleure.gif")
);
// traitement des chaines - transformation des caractères
function parse_string($chaine)
{
include "include/theme.inc.php";
include "include/theme.inc.php";
// smileys
global $souriez;
$traite = str_replace($souriez[0][0], "<img src='modules/share/".$souriez[0][1]."' border='0' alt='|:-&#41;' />", $chaine);
$traite = str_replace($souriez[1][0], "<img src='modules/share/".$souriez[1][1]."' border='0' alt=';-&#41;' />", $traite);
$traite = str_replace($souriez[2][0], "<img src='modules/share/".$souriez[2][1]."' border='0' alt=';&#41;' />", $traite);
$traite = str_replace($souriez[3][0], "<img src='modules/share/".$souriez[3][1]."' border='0' alt=';o&#41;' />", $traite);
$traite = str_replace($souriez[4][0], "<img src='modules/share/".$souriez[4][1]."' border='0' alt=':-&#41;&#41; /'>", $traite);
$traite = str_replace($souriez[5][0], "<img src='modules/share/".$souriez[5][1]."' border='0' alt=':&#41;&#41' />", $traite);
$traite = str_replace($souriez[6][0], "<img src='modules/share/".$souriez[6][1]."' border='0' alt=':-&#41;' />", $traite);
$traite = str_replace($souriez[7][0], "<img src='modules/share/".$souriez[7][1]."' border='0' alt=':&#41;' />", $traite);
$traite = str_replace($souriez[8][0], "<img src='modules/share/".$souriez[8][1]."' border='0' alt=':-o' />", $traite);
$traite = str_replace($souriez[9][0], "<img src='modules/share/".$souriez[9][1]."' border='0' alt=':o&#40; /'>", $traite);
$traite = str_replace($souriez[10][0], "<img src='modules/share/".$souriez[10][1]."' border='0' alt=':o&#40;&#40; /'>", $traite);
$traite = str_replace($souriez[11][0], "<img src='modules/share/".$souriez[11][1]."' border='0' alt=':&#40;&#40;' />", $traite);
$traite = str_replace($souriez[12][0], "<img src='modules/share/".$souriez[12][1]."' border='0' alt=':-&#40;' />", $traite);
$traite = str_replace($souriez[13][0], "<img src='modules/share/".$souriez[13][1]."' border='0' alt=':&#40;' />", $traite);
$traite = str_replace($souriez[14][0], "<img src='modules/share/".$souriez[14][1]."' border='0' alt='8-&#41' />", $traite);
$traite = str_replace($souriez[15][0], "<img src='modules/share/".$souriez[15][1]."' border='0' alt=':-p' />", $traite);
$traite = str_replace($souriez[16][0], "<img src='modules/share/".$souriez[16][1]."' border='0' alt=';-&#40;' />", $traite);
$traite = str_replace($souriez[17][0], "<img src='modules/share/".$souriez[17][1]."' border='0' alt=';-&#40;' />", $traite);
$traite = str_replace($souriez[18][0], "<img src='modules/share/".$souriez[18][1]."' border='0' alt=';-&#40;' />", $traite);
// smileys
global $souriez;
$traite = str_replace($souriez[0][0], "<img src='modules/share/".$souriez[0][1]."' border='0' alt='|:-&#41;' />", $chaine);
$traite = str_replace($souriez[1][0], "<img src='modules/share/".$souriez[1][1]."' border='0' alt=';-&#41;' />", $traite);
$traite = str_replace($souriez[2][0], "<img src='modules/share/".$souriez[2][1]."' border='0' alt=';&#41;' />", $traite);
$traite = str_replace($souriez[3][0], "<img src='modules/share/".$souriez[3][1]."' border='0' alt=';o&#41;' />", $traite);
$traite = str_replace($souriez[4][0], "<img src='modules/share/".$souriez[4][1]."' border='0' alt=':-&#41;&#41; /'>", $traite);
$traite = str_replace($souriez[5][0], "<img src='modules/share/".$souriez[5][1]."' border='0' alt=':&#41;&#41' />", $traite);
$traite = str_replace($souriez[6][0], "<img src='modules/share/".$souriez[6][1]."' border='0' alt=':-&#41;' />", $traite);
$traite = str_replace($souriez[7][0], "<img src='modules/share/".$souriez[7][1]."' border='0' alt=':&#41;' />", $traite);
$traite = str_replace($souriez[8][0], "<img src='modules/share/".$souriez[8][1]."' border='0' alt=':-o' />", $traite);
$traite = str_replace($souriez[9][0], "<img src='modules/share/".$souriez[9][1]."' border='0' alt=':o&#40; /'>", $traite);
$traite = str_replace($souriez[10][0], "<img src='modules/share/".$souriez[10][1]."' border='0' alt=':o&#40;&#40; /'>", $traite);
$traite = str_replace($souriez[11][0], "<img src='modules/share/".$souriez[11][1]."' border='0' alt=':&#40;&#40;' />", $traite);
$traite = str_replace($souriez[12][0], "<img src='modules/share/".$souriez[12][1]."' border='0' alt=':-&#40;' />", $traite);
$traite = str_replace($souriez[13][0], "<img src='modules/share/".$souriez[13][1]."' border='0' alt=':&#40;' />", $traite);
$traite = str_replace($souriez[14][0], "<img src='modules/share/".$souriez[14][1]."' border='0' alt='8-&#41' />", $traite);
$traite = str_replace($souriez[15][0], "<img src='modules/share/".$souriez[15][1]."' border='0' alt=':-p' />", $traite);
$traite = str_replace($souriez[16][0], "<img src='modules/share/".$souriez[16][1]."' border='0' alt=';-&#40;' />", $traite);
$traite = str_replace($souriez[17][0], "<img src='modules/share/".$souriez[17][1]."' border='0' alt=';-&#40;' />", $traite);
$traite = str_replace($souriez[18][0], "<img src='modules/share/".$souriez[18][1]."' border='0' alt=';-&#40;' />", $traite);
// liens
//$traite = ereg_replace("\n","<br />",$traite);
//$traite = ereg_replace("<url>","<a href=\"",$traite);
//$traite = ereg_replace("</url>","\">[Lien]</a>",$traite);
// themes
global $theme;
$traite = ereg_replace("THEME_COURANT",$theme,$traite);
return $traite;
// liens
//$traite = ereg_replace("\n","<br />",$traite);
//$traite = ereg_replace("<url>","<a href=\"",$traite);
//$traite = ereg_replace("</url>","\">[Lien]</a>",$traite);
// themes
global $theme;
$traite = ereg_replace("THEME_COURANT", $theme, $traite);
return $traite;
}
// renvoie la page ou le module en cours
// (nécessaire car netscape ne reconnait pas la constante __SELF__)
function caller()
{
include "include/theme.inc.php";
global $section;
global $page;
global $modulepage;
global $theme;
include "include/theme.inc.php";
global $section;
global $page;
global $modulepage;
global $theme;
if (($section != "") && ($page != ""))
$liencaller = "index.php?section=$section&page=$page&theme=$theme";
else if ($modulepage != "")
$liencaller = "index.php?modulepage=$modulepage&theme=$theme";
else
$liencaller = "index.php?theme=$theme";
if (($section != "") && ($page != "")) {
$liencaller = "index.php?section=$section&page=$page&theme=$theme";
} elseif ($modulepage != "") {
$liencaller = "index.php?modulepage=$modulepage&theme=$theme";
} else {
$liencaller = "index.php?theme=$theme";
}
return $liencaller;
return $liencaller;
}
// renvoie la page ou le module en cours, à ajouter dans un formulaire
// (pour le passage de paramètres par méthode get)
function formcaller()
{
require_once "include/theme.inc.php";
global $section;
global $page;
global $modulepage;
global $theme;
require_once "include/theme.inc.php";
global $section;
global $page;
global $modulepage;
global $theme;
if (($section != "") && ($page != ""))
$formcaller = "<input name='theme' value='$theme' type=hidden>
if (($section != "") && ($page != "")) {
$formcaller = "<input name='theme' value='$theme' type=hidden>
<input name='section' value='$section' type=hidden>
<input name='page' value='$page' type=hidden>";
else if ($modulepage != "")
$formcaller = "<input name='theme' value='$theme' type=hidden>
} elseif ($modulepage != "") {
$formcaller = "<input name='theme' value='$theme' type=hidden>
<input name='modulepage' value='$modulepage' type=hidden>";
else
$formcaller = "<input name='theme' value='$theme' type=hidden>";
} else {
$formcaller = "<input name='theme' value='$theme' type=hidden>";
}
return $formcaller;
return $formcaller;
}
// formate un nombre pour stockage dans un fichier d'index
function splitchar($Number)
{
$byte = strval(dechex($Number));
switch(strlen($byte))
{
case 1:
$byte0=$byte;
$byte1=$byte2=$byte3=0;
break;
case 2:
$byte0="$byte[0]$byte[1]";
$byte1=$byte2=$byte3=0;
break;
case 3:
$byte0="$byte[1]$byte[2]";
$byte1=$byte[0];
$byte2=$byte3=0;
break;
case 4:
$byte0="$byte[2]$byte[3]";
$byte1="$byte[0]$byte[1]";
$byte2=$byte3=0;
break;
case 5:
$byte0="$byte[3]$byte[4]";
$byte1="$byte[1]$byte[2]";
$byte2=$byte[0];
$byte3=0;
break;
case 6:
$byte0="$byte[4]$byte[5]";
$byte1="$byte[2]$byte[3]";
$byte2="$byte[0]$byte[1]";
$byte3=0;
case 7:
$byte0="$byte[5]$byte[6]";
$byte1="$byte[3]$byte[4]";
$byte2="$byte[1]$byte[2]";
$byte3=$byte[0];
break;
case 8:
$byte0="$byte[6]$byte[7]";
$byte1="$byte[4]$byte[5]";
$byte2="$byte[2]$byte[3]";
$byte3="$byte[0]$byte[1]";
break;
default:
echo "depassement !!!!!!";
}
$byte = strval(dechex($Number));
switch(strlen($byte)) {
case 1:
$byte0 = $byte;
$byte1 = $byte2 = $byte3 = 0;
break;
case 2:
$byte0 = "$byte[0]$byte[1]";
$byte1 = $byte2 = $byte3 = 0;
break;
case 3:
$byte0 = "$byte[1]$byte[2]";
$byte1 = $byte[0];
$byte2 = $byte3 = 0;
break;
case 4:
$byte0 = "$byte[2]$byte[3]";
$byte1 = "$byte[0]$byte[1]";
$byte2 = $byte3 = 0;
break;
case 5:
$byte0 = "$byte[3]$byte[4]";
$byte1 = "$byte[1]$byte[2]";
$byte2 = $byte[0];
$byte3 = 0;
break;
case 6:
$byte0 = "$byte[4]$byte[5]";
$byte1 = "$byte[2]$byte[3]";
$byte2 = "$byte[0]$byte[1]";
$byte3 = 0;
// no break
case 7:
$byte0 = "$byte[5]$byte[6]";
$byte1 = "$byte[3]$byte[4]";
$byte2 = "$byte[1]$byte[2]";
$byte3 = $byte[0];
break;
case 8:
$byte0 = "$byte[6]$byte[7]";
$byte1 = "$byte[4]$byte[5]";
$byte2 = "$byte[2]$byte[3]";
$byte3 = "$byte[0]$byte[1]";
break;
default:
echo "depassement !!!!!!";
}
$string = sprintf("%c%c%c%c",hexdec($byte3),hexdec($byte2),hexdec($byte1),hexdec($byte0));
$string = sprintf("%c%c%c%c", hexdec($byte3), hexdec($byte2), hexdec($byte1), hexdec($byte0));
return $string;
return $string;
}
// créé un fichier d'index
function strfile($FileName)
{
$Nb = 0;
$index[$Nb++] = "0";
$input = fopen("$FileName.csv","r");
while ($data = fgetcsv($input, 10000, ","))
$index[$Nb++] = ftell($input);
fclose($input);
$index[--$Nb] = 0;
$output = fopen("$FileName.dat","w");
fwrite($output,splitchar($Nb));
for ($i = 0 ; $i < $Nb ; $i++)
fwrite($output,splitchar($index[$i]));
fclose($output);
$Nb = 0;
$index[$Nb++] = "0";
$input = fopen("$FileName.csv", "r");
while ($data = fgetcsv($input, 10000, ",")) {
$index[$Nb++] = ftell($input);
}
fclose($input);
$index[--$Nb] = 0;
$output = fopen("$FileName.dat", "w");
fwrite($output, splitchar($Nb));
for ($i = 0 ; $i < $Nb ; $i++) {
fwrite($output, splitchar($index[$i]));
}
fclose($output);
}
// lit un fichier d'index et renvoie l'index correspondant au numéro d'enregistrement
function unstr($FileName,$Num)
function unstr($FileName, $Num)
{
if (!file_exists("$FileName.dat"))
strfile($FileName);
if (!file_exists("$FileName.dat")) {
strfile($FileName);
}
$indexfile = fopen("$FileName.dat","r");
$total = hexdec(bin2hex(fread($indexfile,4)));
// echo $total;
if ($Num > $total)
$indexfile = fopen("$FileName.dat", "r");
$total = hexdec(bin2hex(fread($indexfile, 4)));
// echo $total;
if ($Num > $total) {
$Num = $total;
fseek($indexfile,($Num*4)+4);
$pos = hexdec(bin2hex(fread($indexfile,4)));
fclose($indexfile);
return $pos;
}
fseek($indexfile, ($Num * 4) + 4);
$pos = hexdec(bin2hex(fread($indexfile, 4)));
fclose($indexfile);
return $pos;
}
// retourne le nombre d'enregistrement d'après le fichier d'index
function gettotal($FileName)
{
if (!file_exists("$FileName.dat"))
strfile($FileName);
$indexfile = fopen("$FileName.dat","r");
return hexdec(bin2hex(fread($indexfile,4)));
if (!file_exists("$FileName.dat")) {
strfile($FileName);
}
$indexfile = fopen("$FileName.dat", "r");
return hexdec(bin2hex(fread($indexfile, 4)));
}
// compte le nombre d'enregistrement d'un fichier csv
function countcsv($File)
{
$max = 0;
$fd = fopen("$File.csv","r");
while (fgetcsv($fd,10000 , ","))
$max = 0;
$fd = fopen("$File.csv", "r");
while (fgetcsv($fd, 10000, ",")) {
$max++;
fclose($fd);
return $max;
}
fclose($fd);
return $max;
}
// créé un fichier
function createfile($FileName)
{
$fp = fopen($FileName,"w+");
fclose($fp);
$fp = fopen($FileName, "w+");
fclose($fp);
}
// affiche une erreur 401
function err401($msg_err)
{
echo "
echo "
<html>
<head>
<meta http-equiv='Content-Type' content='HTTP/1.0 401 Unauthorized' />
@ -240,92 +249,86 @@ function err401($msg_err)
</body>
</html>";
exit();
exit();
}
// affiche une demande de mot de passe suivant le fichier password.txt
function password($folder)
{
//************** indentification de l'utilisateur *************
//************** indentification de l'utilisateur *************
$fd = fopen("$folder/password.txt","r");
$titre = fgetcsv($fd, 10000, ",");
$fd = fopen("$folder/password.txt", "r");
$titre = fgetcsv($fd, 10000, ",");
while($fd)
{
$data = fgetcsv($fd, 10000, ",");
$login[$i] = $data[0];
$mdp[$i] = $data[1];
$bienvenue[$i] = parse_string(stripcslashes($data[2]));
}
fclose($fd);
while($fd) {
$data = fgetcsv($fd, 10000, ",");
$login[$i] = $data[0];
$mdp[$i] = $data[1];
$bienvenue[$i] = parse_string(stripcslashes($data[2]));
}
fclose($fd);
// vide le cache
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date du passé
// vide le cache
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date du passé
if (!isset($PHP_AUTH_USER))
{
header("WWW-Authenticate: Basic realm=\"iphp\" ");
err401("Action annulée");
}
else
{
if ($login[0] == $PHP_AUTH_USER)
{
echo "bienvenue superuser !";
}
else
{
while (($login[$Cpt++] != $PHP_AUTH_USER) && ($mdp[$Cpt++] != $PHP_AUTH_PW));
echo "bienvenue user !";
}
if (!isset($PHP_AUTH_USER)) {
header("WWW-Authenticate: Basic realm=\"iphp\" ");
err401("Action annulée");
} else {
if ($login[0] == $PHP_AUTH_USER) {
echo "bienvenue superuser !";
} else {
while (($login[$Cpt++] != $PHP_AUTH_USER) && ($mdp[$Cpt++] != $PHP_AUTH_PW));
echo "bienvenue user !";
}
}
}
// créé un fichier de log
function addlog($url)
{
$File = "/logs/".str_replace("/","_",$url).".log";
// si le fichier n'existe pas, on le crée:
if (!file_exists("$File.csv") )
createfile("$File.csv");
$File = "/logs/".str_replace("/", "_", $url).".log";
// si le fichier n'existe pas, on le crée:
if (!file_exists("$File.csv")) {
createfile("$File.csv");
}
$date = strftime ("%d/%m/%Y", time());
$date = strftime("%d/%m/%Y", time());
$string = sprintf("\"".$date."\",\"".iheure()."\",\"".$_SERVER["REMOTE_ADDR"]."\",\"".$_SERVER["HTTP_REFERER"]."\",\"".$_SERVER["HTTP_USER_AGENT"]."\"\n");
$string = sprintf("\"".$date."\",\"".iheure()."\",\"".$_SERVER["REMOTE_ADDR"]."\",\"".$_SERVER["HTTP_REFERER"]."\",\"".$_SERVER["HTTP_USER_AGENT"]."\"\n");
$fp = fopen("$File.csv","a");
fwrite($fp,$string);
fclose($fp);
strfile($File);
$fp = fopen("$File.csv", "a");
fwrite($fp, $string);
fclose($fp);
strfile($File);
}
// convertit les entités HTML en charactères spéciaux
function html2ascii($inputstring)
{
$outputstring = eregi_replace("&eacute;","é",$inputstring);
$outputstring = eregi_replace("&egrave;","è",$outputstring);
$outputstring = eregi_replace("&agrave;","à",$outputstring);
$outputstring = eregi_replace("&ugrave;","ù",$outputstring);
$outputstring = eregi_replace("&eacute;", "é", $inputstring);
$outputstring = eregi_replace("&egrave;", "è", $outputstring);
$outputstring = eregi_replace("&agrave;", "à", $outputstring);
$outputstring = eregi_replace("&ugrave;", "ù", $outputstring);
$outputstring = eregi_replace("&ocirc;","ô",$outputstring);
$outputstring = eregi_replace("&ecirc;","ê",$outputstring);
$outputstring = eregi_replace("&icirc;","î",$outputstring);
$outputstring = eregi_replace("&acirc;","â",$outputstring);
$outputstring = eregi_replace("&ucirc;","û",$outputstring);
$outputstring = eregi_replace("&ocirc;", "ô", $outputstring);
$outputstring = eregi_replace("&ecirc;", "ê", $outputstring);
$outputstring = eregi_replace("&icirc;", "î", $outputstring);
$outputstring = eregi_replace("&acirc;", "â", $outputstring);
$outputstring = eregi_replace("&ucirc;", "û", $outputstring);
$outputstring = eregi_replace("&iuml;","ï",$outputstring);
$outputstring = eregi_replace("&euml;","ë",$outputstring);
$outputstring = eregi_replace("&ccedil;","ç",$outputstring);
$outputstring = eregi_replace("&iuml;", "ï", $outputstring);
$outputstring = eregi_replace("&euml;", "ë", $outputstring);
$outputstring = eregi_replace("&ccedil;", "ç", $outputstring);
$outputstring = eregi_replace("&nbsp;"," ",$outputstring);
$outputstring = eregi_replace("&quot;","\"",$outputstring);
$outputstring = eregi_replace("&amp;","&",$outputstring);
$outputstring = eregi_replace("&nbsp;", " ", $outputstring);
$outputstring = eregi_replace("&quot;", "\"", $outputstring);
$outputstring = eregi_replace("&amp;", "&", $outputstring);
return $outputstring;
return $outputstring;
}
// ------------------------------------------------------------------------- //
@ -349,28 +352,24 @@ fichier .dat
// $filename est le nom du fichier créé pour stocker les informations
function nb_visiteurs_connecte($time,$filename="/tmp/nbweb.dat")
function nb_visiteurs_connecte($time, $filename = "/tmp/nbweb.dat")
{
$ip = getenv("REMOTE_ADDR");
$date=time();
$date = time();
$i=0;
$ii=0;
$bool=0;
$i = 0;
$ii = 0;
$bool = 0;
if(file_exists($filename))
{
if($fichier=fopen($filename,"r"))
{
while(!feof($fichier))
{
$ligne=fgets($fichier,4096);
$tab=explode("|",$ligne);
if(file_exists($filename)) {
if($fichier = fopen($filename, "r")) {
while(!feof($fichier)) {
$ligne = fgets($fichier, 4096);
$tab = explode("|", $ligne);
if($tab[1]>0)
{
$tab_de_tab[$i][0]=$tab[0];
$tab_de_tab[$i][1]=$tab[1];
if($tab[1] > 0) {
$tab_de_tab[$i][0] = $tab[0];
$tab_de_tab[$i][1] = $tab[1];
$i++;
}
@ -379,43 +378,34 @@ function nb_visiteurs_connecte($time,$filename="/tmp/nbweb.dat")
}
}
for($j=0;$j<$i;$j++)
{
if(($date-chop($tab_de_tab[$j][1]))>$time)
{
for($j = 0;$j < $i;$j++) {
if(($date - chop($tab_de_tab[$j][1])) > $time) {
//on ne fait rien
}
else
{
$tab_de_tab_actualise[$ii][0]=$tab_de_tab[$j][0];
$tab_de_tab_actualise[$ii][1]=chop($tab_de_tab[$j][1]);
} else {
$tab_de_tab_actualise[$ii][0] = $tab_de_tab[$j][0];
$tab_de_tab_actualise[$ii][1] = chop($tab_de_tab[$j][1]);
$ii++;
}
}
for($j=0;$j<$ii;$j++)
{
if($tab_de_tab_actualise[$j][0]==$ip)
{
$bool=1;
for($j = 0;$j < $ii;$j++) {
if($tab_de_tab_actualise[$j][0] == $ip) {
$bool = 1;
}
}
if($bool==0)
{
$tab_de_tab_actualise[$ii][0]=$ip;
$tab_de_tab_actualise[$ii][1]=$date;
if($bool == 0) {
$tab_de_tab_actualise[$ii][0] = $ip;
$tab_de_tab_actualise[$ii][1] = $date;
$ii++;
}
if($fichier=fopen($filename,"w"))
{
for($j=0;$j<$ii;$j++)
{
fputs($fichier,chop($tab_de_tab_actualise[$j][0]));
fputs($fichier,"|");
fputs($fichier,chop($tab_de_tab_actualise[$j][1]));
fputs($fichier,"\n");
if($fichier = fopen($filename, "w")) {
for($j = 0;$j < $ii;$j++) {
fputs($fichier, chop($tab_de_tab_actualise[$j][0]));
fputs($fichier, "|");
fputs($fichier, chop($tab_de_tab_actualise[$j][1]));
fputs($fichier, "\n");
}
fclose($fichier);
@ -423,7 +413,3 @@ function nb_visiteurs_connecte($time,$filename="/tmp/nbweb.dat")
return $ii;
}
?>

View file

@ -1,5 +1,5 @@
<?php
if (!isset($theme))
$theme = "default";
?>
if (!isset($theme)) {
$theme = "default";
}

View file

@ -1,73 +1,69 @@
<?php
/* fixe un timer */
function settimer($TimerName,$String)
function settimer($TimerName, $String)
{
$FileTimerName = "modules/timers/$TimerName.csv";
$FileTimerName = "modules/timers/$TimerName.csv";
if (strftime("%m", time()) < 10)
$Date = strftime ("%Y%0m%d%H%M%S", time());
else
$Date = strftime ("%Y%m%d%H%M%S", time());
if (strftime("%m", time()) < 10) {
$Date = strftime("%Y%0m%d%H%M%S", time());
} else {
$Date = strftime("%Y%m%d%H%M%S", time());
}
$fp = fopen("$FileTimerName","w+");
$Ligne = sprintf("\"".$Date."\",\"".$String."\"\n");
fwrite($fp,$Ligne);
fclose($fp);
// echo "fichier créé<br>";
$fp = fopen("$FileTimerName", "w+");
$Ligne = sprintf("\"".$Date."\",\"".$String."\"\n");
fwrite($fp, $Ligne);
fclose($fp);
// echo "fichier créé<br>";
}
/* renvoie $string si le temps n'est pas écoulé, ou FALSE sinon */
function timer($TimerName,$TimerNb)
function timer($TimerName, $TimerNb)
{
$FileTimerN = "modules/timers/$TimerName.csv";
$FileTimerN = "modules/timers/$TimerName.csv";
if (strftime("%m", time()) < 10)
$Date = strftime ("%Y%0m%d%H%M%S", time());
else
$Date = strftime ("%Y%m%d%H%M%S", time());
if (strftime("%m", time()) < 10) {
$Date = strftime("%Y%0m%d%H%M%S", time());
} else {
$Date = strftime("%Y%m%d%H%M%S", time());
}
if (!file_exists("$FileTimerN"))
{
$timer = FALSE;
if (!file_exists("$FileTimerN")) {
$timer = false;
} else {
// lecture de la date stockée dans le fichier
$fp = fopen("$FileTimerN", "r");
$data = fgetcsv($fp, 1000, ",");
fclose($fp);
$FileDate = $data[0];
$Date = strftime("%Y%m%d%H%M%S", time());
$String = $data[1];
if ($Date >= ($FileDate + $TimerNb)) {
// echo "date dépassée:".$Date." >= ".($FileDate+$TimerNb)."<br>";
$timer = false;
} else {
$timer = $String;
}
else
{
// lecture de la date stockée dans le fichier
$fp = fopen("$FileTimerN","r");
$data = fgetcsv($fp, 1000, ",");
fclose($fp);
}
$FileDate = $data[0];
$Date = strftime ("%Y%m%d%H%M%S", time());
$String = $data[1];
if ($Date >= ($FileDate+$TimerNb))
{
// echo "date dépassée:".$Date." >= ".($FileDate+$TimerNb)."<br>";
$timer = FALSE;
}
else
{
$timer = $String;
}
}
return $timer;
return $timer;
}
/* renvoie l'heure française (format HH:MM) */
function iheure()
{
if ($HTTP_GET_VARS["IFRANCE"] =="1")
$iheure=$I_HEURE_UK;
else
$iheure= date("H:i");
return $iheure;
if ($HTTP_GET_VARS["IFRANCE"] == "1") {
$iheure = $I_HEURE_UK;
} else {
$iheure = date("H:i");
}
return $iheure;
}
?>

453
index.php
View file

@ -1,13 +1,14 @@
<?php
$page=$_GET["page"];
$modulepage=$_GET["modulepage"];
$page = $_GET["page"];
$modulepage = $_GET["modulepage"];
function getmicrotime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
$startgen = getmicrotime ();
function getmicrotime()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
$startgen = getmicrotime();
// visites
//$lvc_include_dir = 'visit/include/';
//include($lvc_include_dir.'new-visitor.inc.php3');
@ -23,19 +24,23 @@ $couleur = RandomColors(); */
include "include/theme.inc.php";
if (file_exists("themes/$theme/theme.php"))
include "themes/$theme/theme.php";
else
include "themes/e/theme.php";
if (file_exists("themes/$theme/theme.php")) {
include "themes/$theme/theme.php";
} else {
include "themes/e/theme.php";
}
if (!isset($section) || $section == "")
$section="pages";
if (!isset($section) || $section == "") {
$section = "pages";
}
if ($page == "index")
$page="menu";
if ($page == "index") {
$page = "menu";
}
if (isset($File))
$FileNews = $File;
if (isset($File)) {
$FileNews = $File;
}
// if (!isset($FileNews))
// $FileNews = "modules/news/news";
@ -54,225 +59,225 @@ include "include/body.inc.php";
echo "<table border='0' width='100%'><tr>\n"; // tableau principal
// *************** gauche *****************
if (!isset($left) || ($left ==1))
{
//echo "<div class='ltop'>";
$cachefile = "tmp/left.cache.html";
if (!file_exists($cachefile) || (filemtime($cachefile) < filemtime("modules/liens")))
{
$cachecontent=file_get_contents("http://tma.tourmentine.com/left.php");
$fp = fopen($cachefile,"w");
fwrite($fp,$cachecontent);
fclose($fp);
}
echo "\n\n<!-- Partie mise en cache (".date("d/m/Y@H:i:s", filemtime($cachefile)).")-->\n\n";
echo "<td valign='top' class='colonne'>\n";
include $cachefile;
echo "</td>\n";
echo "\n<!-- fin Partie mise en cache -->\n\n";
// echo "</div>";
if (!isset($left) || ($left == 1)) {
//echo "<div class='ltop'>";
$cachefile = "tmp/left.cache.html";
if (!file_exists($cachefile) || (filemtime($cachefile) < filemtime("modules/liens"))) {
$cachecontent = file_get_contents("http://tma.tourmentine.com/left.php");
$fp = fopen($cachefile, "w");
fwrite($fp, $cachecontent);
fclose($fp);
}
echo "\n\n<!-- Partie mise en cache (".date("d/m/Y@H:i:s", filemtime($cachefile)).")-->\n\n";
echo "<td valign='top' class='colonne'>\n";
include $cachefile;
echo "</td>\n";
echo "\n<!-- fin Partie mise en cache -->\n\n";
// echo "</div>";
}
// ************** centre ****************
echo "<td class='pageseparator'><img src='/modules/share/trans.gif' alt='' title='' width='20' class='border0' /></td><td valign='top'>\n";
// --- gestion des modules ---
if (isset($modulepage))
{
if (isset($modulepage)) {
//include "include/logo.inc.php";
switch($modulepage) {
case "sondage":
extract($themeset, EXTR_OVERWRITE);
$headstartcode = "<font name='verdana' size='3' class='centerhead'>";
$headendcode = "</font>";
$bodyclass = "centerbody";
$module = "sondage";
$titre = "Résultats du sondage";
include "modules/magicbox.php";
break;
case "goldbook":
unset($NbMaxPost);
extract($themeset, EXTR_OVERWRITE);
$headstartcode = "<font size='3' class='centerhead'>";
$headendcode = "</font>";
$bodyclass = "centerbody";
$module = "goldbook";
$titre = "Livre d'or";
$GoldbookFile = "goldbook";
echo "<br /><br /><br />\n<div align='center'><h1>Laissez-nous un message...</h1></div><br />\n";
include "modules/magicbox.php";
unset($bodyclass);
break;
case "addnews":
extract($themeset, EXTR_OVERWRITE);
if (isset($File)) {
$FileNews = $File;
}
// fichier de news par défaut
if (!isset($FileNews)) {
$FileNews = "modules/news/news";
}
$headstartcode = "<font name='verdana' size='3' class='centerhead'>";
$headendcode = "</font>";
$bodyclass = "centerbody";
$module = "admin/addnews";
$titre = "Ajout d'une nouvelle";
include "modules/magicbox.php";
unset($bodyclass);
// unset($NewsFile);
// unset($File);
break;
case "affnews":
if (isset($File)) {
$FileNews = $File;
}
if (!isset($FileNews)) {
$FileNews = "modules/news/pipnews";
}
// appel direct du module affnews ; magicbox est appelé par ce dernier
include "modules/affnews.php";
unset($NewsFile);
// unset($newsnb);
//unset($File);
break;
case "commentnews":
if (isset($File)) {
$FileNews = $File;
}
if (!isset($FileNews)) {
$FileNews = "modules/news/news";
}
$modulepage = "affnews";
$start = $idnews;
$NbMaxNews = 1;
include "modules/affnews.php";
$headstartcode = "<font name='verdana' size='3' class='centerhead'>";
$headendcode = "</font>";
$bodyclass = "centerbody";
$module = "forum";
$titre = "Commentaires";
//$goldbooktype = "comment";
$forumfile = "$FileNews.$idnews.forum.csv";
include "modules/magicbox.php";
//$modulepage = "commentbook";
// unset($goldbooktype);
// unset($NewsFile);
// unset($File);
break;
case "print":
if (isset($File)) {
$FileNews = $File;
}
if (!isset($FileNews)) {
$FileNews = "modules/news/news";
}
include "modules/print.php";
break;
case "backend":
if (isset($File)) {
$FileNews = $File;
}
if (!isset($FileNews)) {
$FileNews = "modules/news/news";
}
include "modules/genbackend.php";
break;
case "chatlogin":
extract($themeset, EXTR_OVERWRITE);
$bodyclass = "centerbody";
$module = "kikchat/login";
$headstartcode = "<font name='verdana' size='3' class='centerhead'>";
$headendcode = "</font>";
$titre = "Bienvenue sur le chat";
$bodystartcode = "<div align=center>";
$bodyendcode = "</div>";
$footerbox = 1;
$footerboxtext = "Retour au menu";
$footerlien = "/";
include "modules/magicbox.php";
unset($bodyclass);
break;
case "kikchat":
extract($themeset, EXTR_OVERWRITE);
$bodyclass = "centerbody";
$module = "kikchat/post";
$titre = "Kik it Productions' Live Chat";
$headlien = "http://www.kik-it.com";
$footerbox = 1;
$footerboxtext = "Retour au menu";
$footerlien = "/";
include "modules/magicbox.php";
unset($bodyclass);
break;
case "affimage":
extract($themeset, EXTR_OVERWRITE);
// $headstartcode = "<font name='verdana' size=4 class='centerhead'>";
// $headendcode ="</font>";
$bodyclass = "centerbody";
$module = "affimages";
$titre = $image;
$footerbox = 1;
$footerboxtext = "Retour au menu";
$footerlien = "/";
include "modules/magicbox.php";
unset($bodyclass);
break;
default:
include "pages/menu.php";
}
} else {
// ---- affichage des pages ----
//echo "<div align='center'>";
if (isset($section) && isset($page) && $page != "menu") {
// si url éronnée, affiche la page d'acceuil
if (file_exists("$section/$page.php")) {
/* echo "<div id='left'>"; */
include_once "$section/$page.php";
/* echo "</div>";*/
} else {
include_once "pages/menu.php";
}
echo "<div class='center'><a href='/'>&gt;Retour à la page d'accueil&lt;</a><br /></div>";
} else {
//include "include/logo.inc.php";
switch($modulepage)
{
case "sondage":
extract($themeset, EXTR_OVERWRITE);
$headstartcode = "<font name='verdana' size='3' class='centerhead'>";
$headendcode ="</font>";
$bodyclass="centerbody";
$module = "sondage";
$titre = "Résultats du sondage";
include "modules/magicbox.php";
break;
case "goldbook":
unset($NbMaxPost);
extract($themeset, EXTR_OVERWRITE);
$headstartcode = "<font size='3' class='centerhead'>";
$headendcode ="</font>";