function del_line_id($file, $id_to_del) { $last_line = get_nb_last_line($file); $nb_champ = 1; $nb_ligne_boucle = 0; // array lines $array[$last_line]; while (($ligne = fgets($file, 4096)) != false) { $nb_ligne_boucle++; $array[$nb_ligne_boucle] = $ligne; } $champ = get_champ_line($array[$nb_ligne_boucle], $nb_champ); if ($champ == $id_to_del) { $array[$nb_ligne_boucle] = ' '; } for ($i; $i <= $nb_ligne_boucle; $i++) { if ($array[$i] == ' ') { $array[$i] = $array[$i + 1]; } } }
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <h1>categories</h1> <?php require 'bdd.php'; $champ1 = 1; $champ2 = 2; $rep_id_categorie_nom = '../' . $id_categorie_nom; $last_line_categories = get_nb_last_line($rep_id_categorie_nom); $tab_categories[$last_line_categories][2] = 0; for ($i = 1; $i <= $last_line_categories; $i++) { $categorie_line = get_line($rep_id_categorie_nom, $i); $tab_categories[$i][$champ1] = get_champ_line($categorie_line, $champ1); $tab_categories[$i][$champ2] = get_champ_line($categorie_line, $champ2); } $j = 1; for ($i = 1; $i <= $last_line_categories; $i++) { if ($j == 1) { echo '<div style="color:green;background-color:D8D8D8;float:left;width:72%;height:45px;">'; $j++; } else { echo '<div style="color:green;float:left;width:72%;height:45px;">'; $j = 1; } echo '<strong>' . $tab_categories[$i][$champ2] . '</strong><br />'; echo '</div>'; echo '<div style="float:left;width:28%;height:45px;">'; echo '<img onclick="edit_categorie();" width="45px" height="45px" src="../bdd/images/icones/edit.png">'; echo '<img onclick="delete_categorie();" width="45px" height="45px" src="../bdd/images/icones/delete.png">'; echo '</div>'; }
$last_line_relations = get_nb_last_line($id_page_id_categorie_nom_page); // tableaux fini $tab_categories[$last_line_categories][2] = 0; $tab_relations[$last_line_relations][3] = 0; // tab categories fini for ($i = 1; $i <= $last_line_categories; $i++) { $categorie_line = get_line($id_categorie_nom, $i); $tab_categories[$i][$champ1] = get_champ_line($categorie_line, $champ1); $tab_categories[$i][$champ2] = get_champ_line($categorie_line, $champ2); } // tab avec lignes relations fini for ($j = 1; $j <= $last_line_relations; $j++) { $relation = get_line($id_page_id_categorie_nom_page, $j); $tab_relations[$j][$champ1] = get_champ_line($relation, $champ1); $tab_relations[$j][$champ2] = get_champ_line($relation, $champ2); $tab_relations[$j][$champ3] = get_champ_line($relation, $champ3); } // affichage des categories et ses pages for ($i = 1; $i <= $last_line_categories; $i++) { echo '<div style="margin-bottom:4px;margin-top:4px;font-size:150%;background-color:grey;color:white;"><strong>' . $tab_categories[$i][$champ2] . '</strong></div>'; //echo '<h2>'.$tab_categories[$i][$champ2].'</h2>'; for ($j = 1; $j <= $last_line_relations; $j++) { if ($tab_categories[$i][$champ1] == $tab_relations[$j][$champ2]) { echo '<div style="background-color:D8D8D8;font-size:120%;margin-top:4px;"><a href="core/print_page.php?id_page=' . $tab_relations[$j][$champ1] . '">' . $tab_relations[$j][$champ3] . '</a></div>'; } } } //echo '<ul>'; ?> <br/> <br/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <?php require 'bdd.php'; require 'get.php'; $line_relation = get_line('../' . $id_page_id_categorie_nom_page, $id_page); $nom_page = get_champ_line($line_relation, 3); echo '<div id="titre">' . $nom_page . '</div>'; $file_id_page = read('../bdd/pages/' . $id_page . '.txt'); echo $file_id_page; ?> <style type="text/css"> footer { text-align: center; background: #100; color: #dedcb9; padding: 0.5em 0; position: fixed; bottom: 0; left: 0; width: 100%; height:47px;} </style> <footer> <a href="../index.php"> <img src="../bdd/images/icones/acceuil.png" style="float:left" width="47px" height="47px" /></a> <a href="edit_page.php?id_page=<?php echo $id_page; ?> "> <img src="../bdd/images/icones/edit.png" style="margin-left:4px;float:left" width="47px" height="47px" /></a> <img src="../bdd/images/icones/delete.png" style="float:left;" width="47px" height="47px" /> <a href="#titre"><img src="../bdd/images/icones/fleche_haut.jpeg" style="float:right;" width="47px" height="47px" /></a> </footer>
<?php $rep_id_categorie_nom = '../' . $id_categorie_nom; $champ1 = 1; $champ2 = 2; $last_line_categories = get_nb_last_line($rep_id_categorie_nom); $tab_categories[$last_line_categories][2] = 0; // categories -> tab for ($i = 1; $i <= $last_line_categories; $i++) { $categorie_line = get_line($rep_id_categorie_nom, $i); $tab_categories[$i][$champ1] = get_champ_line($categorie_line, $champ1); $tab_categories[$i][$champ2] = get_champ_line($categorie_line, $champ2); } // print options categories if ($get_page_exist == 1) { $line_relation = get_line('../' . $id_page_id_categorie_nom_page, $id_page); $id_categorie = get_champ_line($line_relation, 2); } for ($i = 1; $i <= $last_line_categories; $i++) { if ($id_categorie == $i) { echo '<option value="' . $tab_categories[$i][$champ1] . '" selected>' . $tab_categories[$i][$champ2] . '</option>'; } else { echo '<option value="' . $tab_categories[$i][$champ1] . '">' . $tab_categories[$i][$champ2] . '</option>'; } } ?> </select> </p> <div id="page-wrapper" style="border:solid;overflow:scroll;word-wrap: break-word;"> <div id="editor" style="height:200px;width:100%;word-wrap: break-word;"contenteditable="true"> Click here<h1> to edit the text.</h1>