<?php
$Nombre_De_Coms_Par_Page = 10;
$fichier_de_stockage = 'Stockage-commentaires';
*/
function supprCom($fileName) {
if(isset($_GET['supprcom'])) {
$stock = recupCom($fileName);
if($stock === false) return false;
elseif($_GET['supprcom'] === 'all') $stock = null;
elseif(isset($stock[$_GET['supprcom']])) {
$stock[$_GET['supprcom']] = null;
$string = null;
foreach($stock as $e) {
$str = strlen($e['pseudo']).':'.$e['pseudo'].strlen($e['com']).':'.$e['com'].strlen($e['date']).':'.$e['date'];
if($str != '0:0:0:') $string .= $str;
}
}
else return false;
$file = fopen($fileName,'w');
fwrite($file,$string);
fclose($file);
header('Location: ?');
}
}
function recupCom($fileName,$page=null,$nbComPage=null,&$nbPage=null) {
$path = './'.$fileName;
if(file_exists($path)) {
$file = fopen($path,'r');
$string = @fread($file,filesize($path));
fclose($file);
if(strlen($string) < 3) return false;
$string = str_split($string,1);
$type = 'pseudo';
$len = null;
$a = 0;
for($i = 0;isset($string[$i]); $i++) {
if($len === null) {
if($i > 0) $i--;
for($i;$string[$i] != ':';$i++) $len .= $string[$i];
$len += $i;
}
else{
for($i;$i <= $len; $i++) {
if(isset($stock[$a][$type])) $stock[$a][$type] .= $string[$i];
else $stock[$a][$type] = $string[$i];
}
$len = null;
switch($type) {
case 'pseudo' : $type = 'com';
break;
case 'com' : $type = 'date';
break;
case 'date' : $type = 'pseudo';
$a++;
break;
}
}
}
if(($page && $nbComPage) != null) {
$nbPage = ceil(count($stock) / $nbComPage);
$stock = array_slice($stock,$nbComPage*($page-1),$nbComPage);
}
return $stock;
}
return false;
}
supprCom($fichier_de_stockage);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml" xml:lang="fr">
<head>
<title>Admin System Com</title>
</head>
<body>
<p><a href="?supprcom=all">Supprimer Tout</a></p>
<?php
$don = recupCom($fichier_de_stockage,(isset($_GET['pagecom']))? $_GET['pagecom'] : 1,$Nombre_De_Coms_Par_Page,$nbPage);
if($don !== false) {
if($nbPage > 1 && $Nombre_De_Coms_Par_Page != null) {
echo '<p>';
for($i = 1; $i <= $nbPage;$i++){ ?>
<a href="?pagecom=<?php echo $i; ?>"><?php echo $i; ?><a/>
<?php }
echo '</p>';
}
?>
<table>
<?php
$i = 0;
foreach($don as $e) {
?>
<tr><td><?php echo $e['pseudo']; ?></td><td><?php echo $e['com']; ?></td><td><?php echo $e['date']; ?></td><td><a href="?supprcom=<?php echo $i; ?>">Supprimer</a></td></tr>
<?php $i++; } ?>
</table>
<?php } ?>
</body>
</html>
bon alors voila ou j'en suis ! oui je sais je prend mon temp :)
déja je fais quoi de ce premier code ? je le place dans quoi au juste ?