Advertisement
Guest User

Untitled

a guest
May 22nd, 2015
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 22.86 KB | None | 0 0
  1. <?php
  2. function DisplayMyWikis(){
  3.     include'functions/connect.php';
  4.  
  5.         if(isset($_SESSION['profilLevel'])){
  6.             $userId = $_SESSION['userid'];
  7.             $userLevel = $_SESSION['profilLevel'];
  8.         } else {
  9.             $userId = 0;
  10.             $userLevel = 0;
  11.         }
  12.  
  13.         $sqlDisplayTopics = ("SELECT * FROM tbsujet where authorId = $userId ");
  14.    
  15.         $sqlDisplayTopicsResult = mysqli_query($db_connexion, $sqlDisplayTopics);
  16.    
  17.         echo"<form method=post action=#>";
  18.         echo "<table>  
  19.                <tr>
  20.                    <th>id du sujet</th>
  21.                    <th>id de l'auteur</th>
  22.                    <th>titre</th>
  23.                    <th>description</th>
  24.                    <th>date de création</th>
  25.                     <th>éditer sujet</th>
  26.                     <th>éditer page(s)</th>
  27.                     <th>afficher</th>
  28.                     <th>supprimer sujet</th>
  29.                </tr>";
  30.         while($row = mysqli_fetch_array($sqlDisplayTopicsResult)){
  31.             if(empty($row['visibilityAdminChoice'])){
  32.                 $adminLevelChoice  = "NULLL";
  33.             } else {
  34.                 $adminLevelChoice = $row['visibilityAdminChoice'];
  35.             }
  36.  
  37.             if(empty($row['visibilityModoChoice'])){
  38.                 $adminModoChoice  = "NULLL";
  39.             } else {
  40.                 $adminModoChoice = $row['visibilityModoChoice'];
  41.             }
  42.            
  43.             if(empty($row['visibilityAuthorChoice'])){
  44.                 $adminAuthorChoice  = "NULLL";
  45.             } else {
  46.                 $adminAuthorChoice = $row['visibilityAuthorChoice'];
  47.             }
  48.  
  49.             $topicLevel;
  50.            
  51.             if($adminLevelChoice == "NULLL"){
  52.                 if($adminModoChoice == "NULLL"){
  53.                     if($adminAuthorChoice == "NULLL"){
  54.                         $topicLevel = 0;
  55.                     } else {
  56.                         $topicLevel = $adminAuthorChoice;
  57.                     }
  58.                 } else {
  59.                     $topicLevel = $adminModoChoice;
  60.                 }
  61.             } else {
  62.                 $topicLevel = $adminLevelChoice;
  63.             }
  64.            
  65.            
  66.             if($userLevel < $topicLevel){
  67.                 echo "
  68.                     <tr>
  69.                         <td> vous n'avez pas les droit recquis</td>
  70.                         <td> vous n'avez pas les droit recquis</td>
  71.                         <td> vous n'avez pas les droit recquis</td>
  72.                         <td> vous n'avez pas les droit recquis</td>
  73.                         <td> vous n'avez pas les droit recquis</td>
  74.                         <td> vous n'avez pas les droit recquis</td>
  75.                         <td> vous n'avez pas les droit recquis</td>
  76.                         <td> vous n'avez pas les droit recquis, enregistrez vous</td>
  77.                     </tr>";
  78.             } else {
  79.                 $sujetIdToEdit = $row['sujetId'];
  80.                 $authorSql = ("SELECT authorId from tbsujet where sujetId = $sujetIdToEdit");
  81.                 $authorSqlQuery = mysqli_query($db_connexion, $authorSql);
  82.                 $authorSqlFetch = mysqli_fetch_array($authorSqlQuery);
  83.                 $author = $authorSqlFetch['authorId'];
  84.                 echo "
  85.                     <tr>
  86.                         <td>" . $row['sujetId'] . "</td>
  87.                         <td>" . $row['authorId'] . "</td>
  88.                         <td>" . $row['sujetTitle'] . "</td>
  89.                         <td>" . $row['sujetDesc'] . "</td>
  90.                         <td>" . $row['sujetDateCrea'] . "</td>";
  91.                 if($userId != $author){
  92.                     echo"<td>seul l'auteur peut éditer</td>";
  93.                 }else if(($userId == $author) || ($userId = 1)){
  94.                     echo"<td><input type=submit name=IdToEdit value=$sujetIdToEdit id=inputSmall >éditer topic</input></td>";
  95.                         }
  96.  
  97.                 if($userId != $author){
  98.                     echo"<td>seul l'auteur peut éditer</td>";
  99.                 }else if($userId == $author) {
  100.                     echo"<td><input type=submit name=sujetIdToEdit value=$sujetIdToEdit id=inputSmall >éditer page(s)</input></td>";
  101.                         }
  102.                 echo"   <td><input type=submit name=displayTopic value=$sujetIdToEdit id=inputSmall >afficher</input></td>";
  103.                 if($sujetIdToEdit == 1){
  104.                     echo "<td>ce sujet ne peut pas être éffacé</td>";
  105.                 } else {
  106.                     echo"<td><input type=submit name=DeleteTopic value=$sujetIdToEdit id=inputSmall >Supprimer le sujet</input></td>";
  107.                 }
  108.                 echo "</tr>";
  109.             }
  110.         }
  111.         echo "</table>";
  112.         echo"</form>";
  113.  
  114.         if(isset($_POST['DeleteTopic'])){
  115.             $topicToDelete = $_POST['DeleteTopic'];
  116.             if(isset($_POST['deleteTheTopic'])){
  117.                 $deleteTheTopic = $_POST['deleteTheTopic'];
  118.                 $sqlDelete = (" DELETE FROM tbpage WHERE sujetId = $deleteTheTopic ");
  119.                 $sqlDeleteQuery = mysqli_query($db_connexion, $sqlDelete);
  120.                 if(mysqli_query($db_connexion, $sqlDelete)){
  121.                     echo "1/2 : les pages ont été correctement éffacées";
  122.                 } else {
  123.                     echo "erreur". mysqli_error($db_connexion);
  124.                 }
  125.                 $sqlDelete2 = (" DELETE FROM tbsujet WHERE sujetId = $deleteTheTopic ");
  126.                 $sqlDelete2Query = mysqli_query($db_connexion, $sqlDelete2);
  127.                 if(mysqli_query($db_connexion, $sqlDelete2)){
  128.                     echo "2/2 : les sujets ont été correctement éffacées";
  129.                 } else {
  130.                     echo "erreur". mysqli_error($db_connexion);
  131.                 }
  132.             } else {
  133.  
  134. ?>         
  135.             <h3>Suppresion du sujet</h3>
  136.  
  137.             <button onclick="myFunction()" id="button1">Continuer</button>
  138.             <button onclick="myFunction2()" id="button2">Continuer quand même</button>
  139.             <form action="index.php?page=wiki&subPage=espaceMembre&a=DisplayMyWikis" id="annuler1">
  140.                 <input type="submit" id="annuler" value="annuler">
  141.             </form>
  142.  
  143.             <form action="#" method="post" id="deleteTheTopic">
  144.                 <input type="text" name="deleteTheTopic" value="<?php echo $topicToDelete ?>" readonly="true">
  145.                 <input type="hidden" name="DeleteTopic" value="<?php echo $topicToDelete ?>" readonly="true">
  146.                 <input type="submit" id="submit" value="effacer le sujet">
  147.             </form>
  148.  
  149.             <script>
  150.             window.onload=function(){
  151.                 document.getElementById("button1").style.display='block';
  152.                 document.getElementById("button2").style.display='none';
  153.                 document.getElementById("annuler").style.display='none';
  154.                 document.getElementById("annuler1").style.display='none';
  155.                 document.getElementById("deleteTheTopic").style.display='none';
  156.             }
  157.             function myFunction() {
  158.                 var txt;
  159.                 var r = confirm("Etes-vous sur de vouloir continuer?");
  160.                 if (r == true) {
  161.                     document.getElementById("button1").style.display='none';
  162.                     document.getElementById("button2").style.display='block';
  163.                     document.getElementById("annuler").style.display='none';
  164.                     document.getElementById("annuler1").style.display='none';
  165.                 } else {
  166.                     document.getElementById("button1").style.display='none';
  167.                     document.getElementById("button2").style.display='none';
  168.                     document.getElementById("annuler").style.display='block';
  169.                 }
  170.             }
  171.             function myFunction2() {
  172.                 var txt;
  173.                 var r = confirm("Attention, toutes les pages vont également être supprimées. Etes-vous sur de vouloir continuer?");
  174.                 if (r == true) {
  175.                     document.getElementById("button1").style.display='none';
  176.                     document.getElementById("button2").style.display='none';
  177.                     document.getElementById("deleteTheTopic").style.display='block';
  178.                 } else {
  179.                     document.getElementById("button1").style.display='none';
  180.                     document.getElementById("button2").style.display='none';
  181.                     document.getElementById("annuler").style.display='block';
  182.                     document.getElementById("annuler1").style.display='block';
  183.                 }
  184.             }
  185.            
  186.             </script>
  187.  
  188.             </body>
  189.             </html>
  190. <?php
  191.             }
  192.         }
  193.        
  194.         if(isset($_POST['sujetIdToEdit'])){
  195.             $sujetIdToEdit = $_POST['sujetIdToEdit'];
  196.             $sql = "SELECT pageId, pageKeyword FROM tbpage where sujetId= $sujetIdToEdit order by pageId ";
  197.             if(isset($_POST['pageToEdit'])){
  198.                 $pageToEdit = $_POST['pageToEdit'];
  199.                 $sqlPageContent = ("SELECT * from tbpage where pageId = $pageToEdit");
  200.                 $sqlPageContentQuery = mysqli_query($db_connexion, $sqlPageContent);
  201.                 $fetchPageContent = mysqli_fetch_array($sqlPageContentQuery);
  202.  
  203.                 $pageContent= $fetchPageContent['pageContent'];
  204.  
  205.                 echo "
  206.                     <h3>Veuillez insérer le nouveau contenu</h3>
  207.                     <form method=post action=index.php?page=wiki&wikiAction=editPage>
  208.                     <label>Contenu:</br></label>
  209.                     <textarea name=pageContentNew id=pageContentNew value='$pageContent' cols=30 rows=30 required></textarea></br>
  210.                     <input type=hidden name=pageToEdit id=pageToEdit value='$pageToEdit' required</br>
  211.                     <input type=submit name=edit value='editer la page' />
  212.                 ";
  213.             } else {
  214.                 echo'<hr class="fancy-line"></hr>';
  215.                 echo'<h3>Modificiation des pages pour le sujet selectionné</h3>';
  216.                 echo'<p>Choisisez la page à éditer:</p>';
  217.                 echo '<form action="#" method="POST">';
  218.                 echo '<select name=pageToEdit id=pageToEdit>Page</option>';
  219.                 foreach($db_connexion->query($sql) as $row)
  220.                 {
  221.                     echo '<option value="' . $row['pageId'] . '">' . $row['pageKeyword'] . '</option>';
  222.                 }
  223.    
  224.                 echo "      
  225.                     <input type=hidden name=sujetIdToEdit id=sujetIdToEdit value=$sujetIdToEdit required>
  226.                     <input type=submit name=edit value=editer id=inputSmall />
  227.                     </select>
  228.                 </form>";
  229.                 $toEdit = $row['pageId'];
  230.             }
  231.  
  232.         }
  233.  
  234.         if(isset($_POST['displayTopic'])){
  235.             $displayTopic = $_POST['displayTopic'];
  236.             $sqlTopic = "SELECT * FROM tbsujet where sujetId= $displayTopic ";
  237.  
  238.             foreach($db_connexion->query($sqlTopic) as $row)
  239.                 {
  240.                     $authorId = $row['authorId'];
  241.                     $authorName = get_user_name_fromId($authorId);
  242. ?>
  243.                     <div style="background-color: #243464; color: #fff; padding: 10px 10px 10px 10px; margin-top: 20px;">
  244.                     <h1><?php echo $row['sujetTitle'] ?></h1>
  245.                     <h2><?php echo $row['sujetDesc'] ?></h2>
  246.                     <p><?php echo "auteur: " .$authorName . " | "; echo "date de création: " .$row['sujetDateCrea'];?></p></div>
  247. <?php              
  248.                     $sqlPage = "SELECT * FROM tbpage where sujetId = $displayTopic";
  249.                     $i = 0;
  250.                     $y = 1;
  251.                     foreach($db_connexion->query($sqlPage) as $row){
  252.                         $pageId =  $row['pageId'];
  253.                         $regexText = $row['pageContent'];
  254.                         $htmlText = regex_to_html_copy($regexText, $displayTopic);            
  255. ?>
  256.                        
  257.                         <div style="background-color: #808080; padding: 10px 10px 10px 10px; margin-top: 20px;">
  258.                             <h3>Mot clé : <?php echo $row['pageKeyword'] ?> (page: <?php echo $i ?>)</h3><a href="index.php?page=pageSignal&pageSignalID=<?php echo $pageId?>&pageSignalTopicID=<?php echo $displayTopic?>">signaler la page</a></p>
  259.                         </div>
  260.                         <div style="background-color: #c9c9c9; padding: 10px 10px 10px 10px; margin-top: 20px;">
  261.                             <p>Contenu: </p><br>
  262.                             <p><?php echo  $htmlText?></p>
  263.                             <hr>
  264.                             <p><?php echo "auteur: " .$authorName . " | "; echo "date de création: " .$row['pageDateCrea'];?></p>
  265.                         </div>
  266. <?php                  
  267.                         $i = $i + $y;        
  268.                     }
  269.  
  270.                 }
  271.  
  272.         }
  273.  
  274.  
  275.     if(isset($_POST['IdToEdit'])){
  276.            
  277.             if(isset($_POST['editTopicValid'])){
  278.                 include'fx_visibility.php';
  279.                 $sujetTitleNew = $_POST['sujetTitleNew'];
  280.                 $sujetDescNew = $_POST['sujetDescNew'];
  281.                 $newVisi = $_POST['newVisi'];
  282.                 $IdToEdit = $_POST['IdToEdit'];
  283.                 $newVisi = get_vis_lev_fromChoice($newVisi);
  284.  
  285.                 $sqlUpdate = ("UPDATE tbsujet SET sujetTitle = '$sujetTitleNew', sujetDesc = '$sujetDescNew', sujetDerModif = NOW(), visibilityAuthorChoice = '$newVisi' WHERE sujetId = '$IdToEdit' ");
  286.                 if(mysqli_query($db_connexion, $sqlUpdate)){
  287.                     echo "Le sujet a été correctement modifié";
  288.                 } else {
  289.                     echo "erreur lors de l'édition" . mysqli_error($db_connexion);
  290.                 }
  291.             } else {
  292.                 $editTopicId = $_POST['IdToEdit'];
  293.             $sqlTopic = "SELECT * FROM tbsujet where sujetId= $editTopicId ";
  294.  
  295.             foreach($db_connexion->query($sqlTopic) as $row)
  296.                 {
  297.                     $sujetTitleOld = $row['sujetTitle'];
  298.                     $sujetDescOld = $row['sujetDesc'];
  299. ?>
  300.                         <form action="" method="post">
  301.                         <label>Titre</label><br>
  302.                         <input type=text name=sujetTitleNew id=sujetTitleNew value=<?php echo "'$sujetTitleOld'" ?> required><br>
  303.                         <label>Description</label><br>
  304.                         <input type=text name=sujetDescNew id=sujetDescNew value=<?php echo "'$sujetDescOld'"?> required><br>
  305.                 <?php   if($userLevel == 7) {      
  306.                             echo "<label>Visibilité</label><br>
  307.                             <input list=visi name=newVisi required>
  308.                             <datalist id=visi>
  309.                                 <option value=visiteur>
  310.                                 <option value=normal>
  311.                             </datalist>";
  312.                         } else if($userLevel == 8){
  313.                             echo "<label>Visibilité</label><br>
  314.                             <input list=visi name=newVisi required>
  315.                             <datalist id=visi>
  316.                                 <option value=visiteur>
  317.                                 <option value=normal>
  318.                                 <option value=modo>
  319.                             </datalist>";
  320.                         } else if($userLevel == 9){
  321.                             echo "<label>Visibilité</label><br>
  322.                             <input list=visi name=newVisi required>
  323.                             <datalist id=visi>
  324.                                 <option value=visiteur>
  325.                                 <option value=normal>
  326.                                 <option value=modo>
  327.                                 <option value=admin>
  328.                             </datalist>";
  329.                         }
  330.                 ?>
  331.                         <input type=hidden name=IdToEdit id=IdToEdit value=<?php echo "'$editTopicId'" ?> required><br>
  332.                         <input type=submit name=editTopicValid value="editer le sujet" />
  333.                     </form>
  334. <?php
  335.                 }
  336.             }
  337.  
  338.     }
  339.         mysqli_close($db_connexion);
  340.     }
  341.  
  342.  
  343. function FindMyWikisTitle(){
  344.     include'functions/connect.php';
  345.  
  346.         if (!isset($_POST['wikiToFind'])){
  347.             echo'<form action="#" method="post">
  348.                <div>
  349.                    <label for="wikiToFind">Trouver le wiki à partir de son titre*</label><br/>
  350.                    <input type="text" name="wikiToFind" id="wikiToFind" required/><br />
  351.                </div>
  352.            </form>';
  353.    
  354.        } else {
  355.             if(isset($_SESSION['userid'])){
  356.                 $userId = $_SESSION['userid'];
  357.                 $userLevel = user_level_fromId($userId);
  358.             } else {
  359.                 $userLevel = 0;
  360.                 $userId = 0;
  361.             }
  362.  
  363.             $wikiToFind;
  364.             $wikiToFind = $_POST['wikiToFind'];
  365.    
  366.             $sql = ("SELECT * from tbsujet
  367.                    WHERE sujetTitle like '%$wikiToFind%' AND authorId = '$userId' ");
  368.  
  369.             $result = mysqli_query($db_connexion, $sql) or die("Selection Query Failed !!!");
  370.             if(mysqli_num_rows($result) > 0){
  371.                 echo "<table>  
  372.                        <tr>
  373.                             <th>id du sujet</th>
  374.                             <th>id de l'auteur</th>
  375.                             <th>titre</th>
  376.                             <th>description</th>
  377.                             <th>date de création</th>
  378.                             <th>éditer sujet</th>
  379.                             <th>éditer page(s)</th>
  380.                             <th>afficher</th>
  381.                        </tr>";
  382.         while($row = mysqli_fetch_array($result)){
  383.             if(empty($row['visibilityAdminChoice'])){
  384.                 $adminLevelChoice  = "NULLL";
  385.             } else {
  386.                 $adminLevelChoice = $row['visibilityAdminChoice'];
  387.             }
  388.  
  389.             if(empty($row['visibilityModoChoice'])){
  390.                 $adminModoChoice  = "NULLL";
  391.             } else {
  392.                 $adminModoChoice = $row['visibilityModoChoice'];
  393.             }
  394.            
  395.             if(empty($row['visibilityAuthorChoice'])){
  396.                 $adminAuthorChoice  = "NULLL";
  397.             } else {
  398.                 $adminAuthorChoice = $row['visibilityAuthorChoice'];
  399.             }
  400.  
  401.             $topicLevel;
  402.            
  403.             if($adminLevelChoice == "NULLL"){
  404.                 if($adminModoChoice == "NULLL"){
  405.                     if($adminAuthorChoice == "NULLL"){
  406.                         $topicLevel = 0;
  407.                     } else {
  408.                         $topicLevel = $adminAuthorChoice;
  409.                     }
  410.                 } else {
  411.                     $topicLevel = $adminModoChoice;
  412.                 }
  413.             } else {
  414.                 $topicLevel = $adminLevelChoice;
  415.             }
  416.                 if ($userLevel < $topicLevel){
  417.                     echo "
  418.                         <tr>
  419.                                 <td> vous n'avez pas les droit recquis</td>
  420.                                 <td> vous n'avez pas les droit recquis</td>
  421.                                 <td> vous n'avez pas les droit recquis</td>
  422.                                 <td> vous n'avez pas les droit recquis</td>
  423.                                 <td> vous n'avez pas les droit recquis</td>
  424.                                 <td> vous n'avez pas les droit recquis</td>
  425.                                 <td> vous n'avez pas les droit recquis</td>
  426.                                 <td> vous n'avez pas les droit recquis, enregistrez vous</td>
  427.                         </tr>";
  428.                 } else {
  429.                     $sujetIdToEdit = $row['sujetId'];
  430.                     $authorSql = ("SELECT authorId from tbsujet where sujetId = $sujetIdToEdit");
  431.                     $authorSqlQuery = mysqli_query($db_connexion, $authorSql);
  432.                     $authorSqlFetch = mysqli_fetch_array($authorSqlQuery);
  433.                     $author = $authorSqlFetch['authorId'];
  434.                     echo "
  435.                             <tr>
  436.                                 <td>" . $row['sujetId'] . "</td>
  437.                                 <td>" . $row['authorId'] . "</td>
  438.                                 <td>" . $row['sujetTitle'] . "</td>
  439.                                 <td>" . $row['sujetDesc'] . "</td>
  440.                                 <td>" . $row['sujetDateCrea'] . "</td>";  
  441.                             if($userId != $author){
  442.                                 echo"<td>seul l'auteur peut éditer</td>";
  443.                             }else if(($userId == $author) || ($userId = 1)){
  444.                                 echo"<td><p>via la page 'Les sujets'</p></td>";
  445.                                     }
  446.  
  447.                             if($userId != $author){
  448.                                 echo"<td>seul l'auteur peut éditer</td>";
  449.                             }else if($userId == $author) {
  450.                                 echo"<td><p>via la page 'Les sujets'</p></td>";
  451.                                     }
  452.                             echo"   <td><p>via la page 'Les sujets'</p></td>
  453.                                 </tr>";
  454.                        
  455.                         }
  456.                 }
  457.                 echo "</table>";
  458.                 echo "</form>";
  459.                 mysqli_close($db_connexion);
  460.             } else {
  461.                 echo "<div id=notifications>Aucune correspondance trouvée dans les wikis pour : $wikiToFind</div>";   
  462.             }
  463.    
  464.         }
  465.  }
  466.  
  467.  function FindMyWikisDesc(){
  468.      include'functions/connect.php';
  469.  
  470.         if (!isset($_POST['wiki_description'])){
  471.             echo'<form action="#" method="post">
  472.                <div>
  473.                    <label for="wiki_description">Trouver le wiki à partir de sa description*</label><br/>
  474.                    <input type="text" name="wiki_description" id="wikiToFind" required/><br />
  475.                </div>
  476.            </form>';
  477.    
  478.        } else {
  479.             if(isset($_SESSION['userid'])){
  480.                 $userId = $_SESSION['userid'];
  481.                 $userLevel = user_level_fromId($userId);
  482.             } else {
  483.                 $userLevel = 0;
  484.                 $userId = 0;
  485.             }
  486.  
  487.             $wiki_description;
  488.             $wiki_description = $_POST['wiki_description'];
  489.    
  490.             $sqlDesc = ("SELECT * from tbsujet
  491.                    WHERE sujetDesc like '%$wiki_description%' AND authorId = '$userId' ");
  492.  
  493.             $result = mysqli_query($db_connexion, $sqlDesc) or die("Selection Query Failed !!!" . mysqli_error($db_connexion));
  494.             if(mysqli_num_rows($result) > 0){
  495.                 echo "<table>  
  496.                        <tr>
  497.                             <th>id du sujet</th>
  498.                             <th>id de l'auteur</th>
  499.                             <th>titre</th>
  500.                             <th>description</th>
  501.                             <th>date de création</th>
  502.                             <th>éditer sujet</th>
  503.                             <th>éditer page(s)</th>
  504.                             <th>afficher</th>
  505.                        </tr>";
  506.         while($row = mysqli_fetch_array($result)){
  507.             if(empty($row['visibilityAdminChoice'])){
  508.                 $adminLevelChoice  = "NULLL";
  509.             } else {
  510.                 $adminLevelChoice = $row['visibilityAdminChoice'];
  511.             }
  512.  
  513.             if(empty($row['visibilityModoChoice'])){
  514.                 $adminModoChoice  = "NULLL";
  515.             } else {
  516.                 $adminModoChoice = $row['visibilityModoChoice'];
  517.             }
  518.            
  519.             if(empty($row['visibilityAuthorChoice'])){
  520.                 $adminAuthorChoice  = "NULLL";
  521.             } else {
  522.                 $adminAuthorChoice = $row['visibilityAuthorChoice'];
  523.             }
  524.  
  525.             $topicLevel;
  526.            
  527.             if($adminLevelChoice == "NULLL"){
  528.                 if($adminModoChoice == "NULLL"){
  529.                     if($adminAuthorChoice == "NULLL"){
  530.                         $topicLevel = 0;
  531.                     } else {
  532.                         $topicLevel = $adminAuthorChoice;
  533.                     }
  534.                 } else {
  535.                     $topicLevel = $adminModoChoice;
  536.                 }
  537.             } else {
  538.                 $topicLevel = $adminLevelChoice;
  539.             }
  540.                 if ($userLevel < $topicLevel){
  541.                     echo "
  542.                         <tr>
  543.                         <td> vous n'avez pas les droit recquis</td>
  544.                         <td> vous n'avez pas les droit recquis</td>
  545.                         <td> vous n'avez pas les droit recquis</td>
  546.                         <td> vous n'avez pas les droit recquis</td>
  547.                         <td> vous n'avez pas les droit recquis</td>
  548.                         <td> vous n'avez pas les droit recquis</td>
  549.                         <td> vous n'avez pas les droit recquis</td>
  550.                         <td> vous n'avez pas les droit recquis, enregistrez vous</td>
  551.                         </tr>";
  552.                 } else {
  553.                     $sujetIdToEdit = $row['sujetId'];
  554.                     $authorSql = ("SELECT authorId from tbsujet where sujetId = $sujetIdToEdit");
  555.                     $authorSqlQuery = mysqli_query($db_connexion, $authorSql);
  556.                     $authorSqlFetch = mysqli_fetch_array($authorSqlQuery);
  557.                     $author = $authorSqlFetch['authorId'];
  558.                     echo "
  559.                             <tr>
  560.                                 <td>" . $row['sujetId'] . "</td>
  561.                                 <td>" . $row['authorId'] . "</td>
  562.                                 <td>" . $row['sujetTitle'] . "</td>
  563.                                 <td>" . $row['sujetDesc'] . "</td>
  564.                                 <td>" . $row['sujetDateCrea'] . "</td>";
  565.                                 if($userId != $author){
  566.                                 echo"<td>seul l'auteur peut éditer</td>";
  567.                             }else if(($userId == $author) || ($userId = 1)){
  568.                                 echo"<td><p>via la page 'Les sujets'</p></td>";
  569.                                     }
  570.  
  571.                             if($userId != $author){
  572.                                 echo"<td>seul l'auteur peut éditer</td>";
  573.                             }else if($userId == $author) {
  574.                                 echo"<td><p>via la page 'Les sujets'</p></td>";
  575.                                     }
  576.                             echo"   <td><p>via la page 'Les sujets'</p></td>
  577.                                 </tr>";                    
  578.                         }
  579.                 }
  580.                 echo "</table>";
  581.                 echo"</form>";
  582.                 mysqli_close($db_connexion);
  583.             } else {
  584.                 echo "<div id=notifications>Aucune correspondance trouvée dans les wikis pour : $wiki_description</div>"; 
  585.             }
  586.    
  587.         }
  588.        
  589.         }
  590.  
  591. function DisplayMyPages(){
  592.         include'functions/connect.php';
  593.  
  594.         if(isset($_SESSION['profilLevel'])){
  595.             $userId = $_SESSION['userid'];
  596.             $userLevel = $_SESSION['profilLevel'];
  597.         } else {
  598.             $userId = 0;
  599.             $userLevel = 0;
  600.         }
  601.  
  602.         $PostSujetId = $_POST[''];
  603.        
  604.         $sqlDisplayTopics = ("SELECT * FROM tbpage where sujetId = $userId ");
  605.    
  606.         $sqlDisplayTopicsResult = mysqli_query($db_connexion, $sqlDisplayTopics);
  607. }
  608.  
  609.  
  610. ?>
  611.  
  612. <?php
  613.  
  614. function regex_to_html_copy($text, $topicId)
  615. {
  616.     $text = trim($text);
  617.     $text = htmlspecialchars($text);
  618.     $text = nl2br($text);
  619.     $text = stripslashes($text);
  620.  
  621.     $regexCode = array(
  622.          "/\[\s*!\s*\|\s*([^\]\[\|]*)\s*\]/si",
  623.         "/\[\s*1\s*\|\s*([^\]\[\|]*)\s*\]/si",
  624.          "/\[\s*2\s*\|\s*([^\]\[\|]*)\s*\]/si",
  625.         "/\[\s*3\s*\|\s*([^\]\[\|]*)\s*\]/si",
  626.         "/\[\s*d\s*\|\s*([^\]\[\|]*)\s*\]/si",
  627.    
  628.         "/\[\s*n\s*([^\]\[\|]*)\s*\]/si",
  629.         "/\[\s*h\s*([^\]\[\|]*)\s*\]/si",
  630.  
  631.         "/\[\s*i\s*\|\s*([^\]^\[^\|]*)\s*\]/si",
  632.         "/\[\s*b\s*\|\s*([^\]\[\|]*)\s*\]/si",
  633.         "/\[\s*s\s*\|\s*([^\]\[\|]*)\s*\]/si",
  634.         "/\[\s*p\s*\|\s*([^\]\[\|]*)\s*\]/si",
  635.         "/\[\s*u\s*\|\s*([^\]\[\|]*)\s*\]/si",
  636.                  
  637.          "/\[\s*a\s*\|\s*([^\]\[\|]*)\s*\|([^\]\[\|]*)\s*\]/si",
  638.         "/\[\s*img\s*\|\s*([^\]\[\|]*)\s*\|([^\]\[\|]*)\s*\]/si",
  639.  
  640.         "/\[\[\s*(.*?)\s*\]\]/",
  641.                    
  642.     );
  643.  
  644.     $htmlCode = array(
  645.         "<!--$1-->\n",
  646.         "<h1>$1</h1>\n",
  647.         "<h2>$1</h2>\n",
  648.         "<h3>$1</h3>\n",
  649.         "<div>$1</div>\n",
  650.    
  651.         "<br />\n$1",
  652.         "<hr>\n$1",
  653.  
  654.         "<i>$1</i>",
  655.         "<b>$1</b>",
  656.         "<s>$1</s>",
  657.         "<p>$1</p>\n",
  658.         "<u>$1</u>",
  659.  
  660.         "<a href=\"$1\">$2</a>",
  661.         "<img src=\"$1\" alt=\"$2\"/>",
  662.         "<a href=index.php?page=wiki&wikiAction=pageKey&keyword=" .'$1'. "&topicId=$topicId style='color:blue'>$1</a>",
  663.        
  664.     );
  665.     while (($isTreaded = preg_replace($regexCode, $htmlCode, $text)) != $text) {
  666.         $text = $isTreaded;
  667.     }
  668.     return ($text);
  669. }
  670.  
  671. function keyWord_get2($text)
  672. {
  673.     $text = trim($text);
  674.     $text = htmlspecialchars($text);
  675.     $regexCodeKeyWord = array(
  676.         "/\[\[\s*(.*?)\s*\]\]/",
  677.     );
  678.     $textCodeKeyWord = array(
  679.         "<a href=index.php?page=wiki&keyword=" .'$1'. ">$1</a>",
  680.     );
  681.     $textCodeKeyWord2 = array(
  682.         "$1",
  683.     );
  684.     while (($isTreaded = preg_replace($regexCodeKeyWord, $textCodeKeyWord, $text)) != $text) {
  685.         $Word = preg_replace($regexCodeKeyWord, $textCodeKeyWord2, $text);
  686.         $text = $isTreaded;
  687.     }
  688.  
  689.     return ($text);
  690. }
  691.  
  692.     ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement