Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.80 KB | None | 0 0
  1. <?php
  2.             $db = mysql_connect('localhost', 'root', 'TURLUTUTUSAMERLAPUUUUUUUUUTE');
  3.             if (!$db)
  4.             {
  5.                 die('Could not connect: ' . mysql_error());
  6.             }
  7.             mysql_select_db('PCA_PRA',$db);
  8.         ?>
  9.         <html>
  10.         <link rel="stylesheet" media="screen" type="text/css" title="Design" href="./design.css" />
  11.         <?php
  12.             if(!isset($_GET['recherche']) &&  !isset($_GET['Ressources']) && !isset($_GET['Serveur']) && !isset($_GET['Application']))
  13.             {
  14.                 $req = mysql_query('SELECT numRes,nomRes FROM Ressources');
  15.                 if(mysql_num_rows($req) != 0)
  16.                 {
  17.             ?> 
  18.             <table>
  19.             <tr>
  20.                 <td>Ressources</td>
  21.                 <td>Serveur</td>
  22.                 <td>Application</td>
  23.             </tr>
  24.             <tr>
  25.                 <td>
  26.                 <form method="GET" action="#">
  27.                 <select name="Ressources">
  28.                 <option value"blank"></option>
  29.                 <?php
  30.                     while($ligne = mysql_fetch_array($req))
  31.                     {
  32.                                     echo '<option value="'. $ligne['numRes'] . '">' .$ligne['nomRes'] . '</option>';
  33.                     }
  34.                 }
  35.                 else
  36.                 {
  37.                     echo 'Problème lors de la création de la liste de serveurs';
  38.                 }
  39.            
  40.                 ?>
  41.                 </select>
  42.                 <input type="submit" value="Afficher"></form>
  43.                 </td>
  44.         <?php
  45.         }
  46.         else
  47.         {
  48.             if(is_numeric(mysql_real_escape_string($_GET['Ressources']))==true)
  49.             {
  50.                 $numRes = mysql_real_escape_string($_GET['Ressources']);
  51.                 if($numRes != "blank" && $numRes != NULL)
  52.                 {
  53.                     $req = mysql_query('SELECT * FROM Ressources where numRes ='.$numRes );
  54.                     if(mysql_num_rows($req) != 0)
  55.                     {
  56.                         $ligne = mysql_fetch_assoc($req);
  57.                         afficherRessource($ligne,"0",false);
  58.                         $serv = getServByID($ligne['kSrv']);
  59.                         if($serv !=false)
  60.                         {
  61.                             afficherServeur(getServByID($ligne['kSrv']),"0",true);
  62.                         }
  63.                     }
  64.                     else
  65.                     {
  66.                         echo 'Ressource non trouvée';
  67.                     }
  68.                 }
  69.             }
  70.         }
  71.         if(!isset($_GET['recherche']) &&  !isset($_GET['Serveur']) && !isset($_GET['Ressources']) && !isset($_GET['Application']))
  72.         {
  73.             ?>
  74.             <td>
  75.             <form method="GET" action="#">
  76.             <select name="Serveur">
  77.             <option value"blank"></option>
  78.             <?php
  79.             $req = mysql_query('SELECT numSrv,nomSrv FROM Serveurs');
  80.             if(mysql_num_rows($req) != 0)
  81.             {
  82.                 while($ligne = mysql_fetch_array($req))
  83.                 {
  84.                     echo '<option value="'. $ligne['numSrv'] . '">' .$ligne['nomSrv'] . '</option>';
  85.                 }
  86.             }
  87.             else
  88.             {
  89.                 echo 'Serveur non trouvé';
  90.             }  
  91.             ?>
  92.             </select>
  93.             <input type="submit" value="Afficher"></form>
  94.             </td>
  95.             <?php
  96.         }
  97.         else
  98.         {
  99.             if(is_numeric(mysql_real_escape_string($_GET['Serveur']))==true)
  100.             {
  101.                 $numSrv = mysql_real_escape_string($_GET['Serveur']);
  102.                 if($numSrv != "blank" && $numSrv != NULL)
  103.                 {
  104.                     $req2 = mysql_query('SELECT * FROM Serveurs where numSrv ='.$numSrv );
  105.                     if(mysql_num_rows($req2) != 0)
  106.                     {
  107.                         $ligne2 = mysql_fetch_assoc($req2);
  108.                         if($ligne2 != false)
  109.                         {
  110.                             afficherServeur($ligne2,"0",false);
  111.                             $mat = getMatByID($ligne2['numMat']);
  112.                             if($mat != false)
  113.                             {
  114.                                 afficherMateriel($mat,"0",true);
  115.                                 $req3 = mysql_query('SELECT * FROM Ressources where kSrv ='.$numSrv);
  116.                                 while($ligne = mysql_fetch_array($req3))
  117.                                 {
  118.                                     afficherRessource($ligne,"100",true);
  119.                                 }
  120.                             }
  121.                         }
  122.                     }
  123.                     else
  124.                     {
  125.                         echo 'Serveur non trouvé';
  126.                     }
  127.                 }
  128.             }
  129.         }
  130.         if(!isset($_GET['recherche']) && !isset($_GET['Ressources']) && !isset($_GET['Serveur']) && !isset($_GET['Application']))
  131.         {
  132.             ?>
  133.             <form name="input" action="resrecherche.php" method="GET">
  134.             <input type="text" name="recherche" />
  135.             <input type="submit" value="Rechercher" />
  136.             </form>
  137.             <?php
  138.         }
  139.         if(!isset($_GET['recherche']) &&  !isset($_GET['Serveur']) && !isset($_GET['Ressources']) && !isset($_GET['Application']))
  140.         {
  141.             ?>
  142.             <td>
  143.             <form method="GET" action="#">
  144.             <select name="Application">
  145.             <option value"blank"></option>
  146.             <?php
  147.             $req = mysql_query('SELECT numApp,nomApp FROM Applications');
  148.             if(mysql_num_rows($req) != 0)
  149.             {
  150.                 while($ligne = mysql_fetch_array($req))
  151.                 {
  152.                                 echo '<option value="'. $ligne['numApp'] . '">' .$ligne['nomApp'] . '</option>';
  153.                 }
  154.             }
  155.             ?>
  156.             </select>
  157.             <input type="submit" value="Afficher"></form>
  158.             </td>
  159.             <?php
  160.         }
  161.         else
  162.         {
  163.             if(is_numeric(mysql_real_escape_string($_GET['Application']))==true)
  164.             {
  165.                 $numApp = mysql_real_escape_string($_GET['Application']);
  166.                 if($numApp != "blank" && $numApp != NULL)
  167.                 {
  168.                     $req2 = mysql_query('SELECT * FROM Applications where numApp ='.$numApp );
  169.                     if(mysql_num_rows($req2) != 0)
  170.                     {
  171.                         $ligne2 = mysql_fetch_assoc($req2);
  172.                         afficherApplication($ligne2,"0",false);
  173.                         $res = GetRessourceByApp($ligne2['numApp']);
  174.                         if($res != false)
  175.                         {
  176.                             afficherRessource($res, "0", true);
  177.                             $serv=getServByID($res['kSrv']);
  178.                             if($serv!=false)
  179.                             {
  180.                                 afficherServeur($serv,"100", true);
  181.                                 $mat = getMatByID($serv['numMat']);
  182.                                 if ($mat !=false)
  183.                                 {
  184.                                     afficherMateriel($mat,"200",true);
  185.                                 }
  186.                             }
  187.                         }
  188.                     }
  189.                     else
  190.                     {
  191.                         echo 'Application non trouvée';
  192.                     }
  193.                 }  
  194.             }
  195.         }
  196.         mysql_close($db);  // 6
  197.         ?>
  198.         </tr>
  199.         </table>
  200.         </html>
  201.         <?php
  202.  
  203.         function getNomTypeSrvByID($kTypeSrv)
  204.         {
  205.                 $req=mysql_query('SELECT nomTypeSrv FROM Types_Serveurs where num ='. $kTypeSrv );
  206.                 if(mysql_num_rows($req) != 0)
  207.                 {              
  208.                     $ligne = mysql_fetch_assoc($req);
  209.                     return $ligne['nomTypeSrv'];
  210.                 }
  211.                 else
  212.                 {
  213.                     echo 'Type de serveur non trouvé';
  214.                     return false;
  215.                 }
  216.         }
  217.  
  218.         function getNomCatSrvByID($kCategorieSrv)
  219.         {
  220.                 $req=mysql_query('SELECT nomCategorieSrv FROM Categories_Serveurs where num ='. $kCategorieSrv );
  221.                 if(mysql_num_rows($req) != 0)
  222.                 {
  223.                     $ligne = mysql_fetch_assoc($req);
  224.                     return $ligne['nomCategorieSrv'];
  225.                 }
  226.                 else
  227.                 {
  228.                     echo 'Catégorie Serveur non trouvée';
  229.                     return false;
  230.                 }
  231.         }
  232.        
  233.         function getMatByID($numMat)
  234.         {
  235.                 $req=mysql_query('SELECT * FROM Materiels where num ='. $numMat );
  236.                 if(mysql_num_rows($req) != 0)
  237.                 {              
  238.                     $ligne = mysql_fetch_assoc($req);
  239.                     return $ligne;
  240.                 }
  241.                 else
  242.                 {
  243.                     echo 'Materiel non trouvé';
  244.                     return false;
  245.                 }
  246.         }
  247.        
  248.         function getServByID($numSrv)
  249.         {
  250.             $req=mysql_query('SELECT * FROM Serveurs where numSrv ='. $numSrv );
  251.             if(mysql_num_rows($req) != 0)
  252.             {
  253.                 $ligne = mysql_fetch_assoc($req);
  254.                 return $ligne;
  255.             }
  256.             else
  257.             {
  258.                 echo 'Serveur non trouvé';
  259.                 return false;
  260.             }
  261.         }
  262.    
  263.         function GetRessourceByApp ($kApp)
  264.         {
  265.             $req=mysql_query('SELECT kSvc FROM App_Svc where kApp ='. $kApp );
  266.             if(mysql_num_rows($req) != 0)
  267.             {
  268.                 $kSvc = mysql_fetch_assoc($req);
  269.                 //echo $kSvc['kSvc'];
  270.                 $req2=mysql_query('SELECT kRes FROM Svc_Res where kSvc ='. $kSvc['kSvc'] );
  271.                 if(mysql_num_rows($req2) != 0)
  272.                 {
  273.                     $kRes = mysql_fetch_assoc($req2);
  274.                     $ligne = GetRessouceById($kRes['kRes']);
  275.                     return $ligne;
  276.                 }
  277.                 else
  278.                 {
  279.                     echo 'Shit just Happened';
  280.                     return false;
  281.                 }
  282.             }
  283.             else
  284.             {
  285.                 echo 'Ressource non trouvée';
  286.                 return false;
  287.             }
  288.         }
  289.        
  290.         function GetRessouceById ($numRes)
  291.         {
  292.             $req=mysql_query('SELECT * FROM Ressources where numRes ='. $numRes );
  293.             if(mysql_num_rows($req) != 0)
  294.             {
  295.                 $ligne = mysql_fetch_assoc($req);
  296.                 return $ligne;
  297.             }
  298.             else
  299.             {
  300.                 echo 'Ressource non trouvée, 2';
  301.                 return false;
  302.             }
  303.         }
  304.                
  305.         function getTypeAppByID($kTypeApp)
  306.         {
  307.                 $req=mysql_query('SELECT nomTypeApp FROM Types_Applications where num ='. $kTypeApp );
  308.                 if(mysql_num_rows($req) != 0)
  309.                 {
  310.                     $ligne = mysql_fetch_assoc($req);
  311.                     return $ligne['nomTypeApp'];
  312.                 }
  313.                 else
  314.                 {
  315.                     echo 'Type d\'application non trouvé';
  316.                     return false;
  317.                 }
  318.         }
  319.        
  320.         function getTypeResByID($kTypeRes)
  321.         {
  322.                 $req=mysql_query('SELECT nomTypeRes FROM Types_Ressources where num ='. $kTypeRes );
  323.                 if(mysql_num_rows($req) != 0)
  324.                 {
  325.                     $ligne = mysql_fetch_assoc($req);
  326.                     return $ligne['nomTypeRes'];
  327.                 }
  328.                 else
  329.                 {
  330.                     echo 'Type de ressource non trouvé';
  331.                     return false;
  332.                 }
  333.         }
  334.        
  335.         function afficherServeur($ligne, $margin,$link)
  336.         {
  337.             echo '<table id="serveur" style="margin-left:'. $margin .'px;">';
  338.             echo '<tr>';
  339.                 if($link == true)
  340.                 {
  341.                     echo '<td>';
  342.                         echo '<img src="./link.png" />';
  343.                     echo '</td>';
  344.                 }
  345.                     echo '<td>';
  346.                         echo '<a href="./index.php?Serveur='.$ligne[numSrv].'"><img src="./serveur.png"/></a>';
  347.                     echo '</td>';
  348.  
  349.                     echo '<td style="vertical-align:middle">';
  350.                         echo '<p>';
  351.                         echo 'Nom du Serveur : '.$ligne['nomSrv'];
  352.                         echo '</br>';
  353.                         echo 'Fonction du Serveur : '.$ligne['fonctionSrv'];
  354.                         echo '</br>';
  355.                         echo 'Responsable du Serveur : '.$ligne['responsable'];
  356.                         echo '</br>';
  357.                         echo 'Type du Serveur : '.getNomTypeSrvByID($ligne['kTypeSrv']);
  358.                         echo '</br>';
  359.                         echo 'Categorie du Serveur : '.getNomCatSrvByID($ligne['kCategorieSrv']);
  360.                         echo '</br>';
  361.                         echo '</p>';
  362.                     echo '</td>';
  363.             echo '</tr>';
  364.             echo '</table>';
  365.         }
  366.        
  367.         function afficherMateriel($ligne,$margin, $link)
  368.         {
  369.             echo '<table style="margin-left:'.$margin.'px;">';
  370.             echo '<tr>';
  371.                 if($link == true)
  372.                 {
  373.                     echo '<td>';
  374.                         echo '<img src="./link.png" />';
  375.                     echo '</td>';
  376.                 }
  377.                 echo '<td>';
  378.                     echo '<img src="./materiel.png"/>';
  379.                 echo '</td>';
  380.  
  381.                 echo '<td style="vertical-align:middle">';
  382.                     echo '<p>';
  383.                     echo 'Fabriquant matériel : '.$ligne['marqueMat'];
  384.                     echo '</br>';
  385.                     echo 'Modèle du matériel : '.$ligne['nomMat'];
  386.                     echo '</br>';
  387.                     echo 'Numéro de série matériel : '.$ligne['serialMat'];
  388.                     echo '</br>';
  389.                     echo 'Processeur : '.$ligne['processeurMat'];
  390.                     echo '</br>';
  391.                     echo 'Memoire : '.$ligne['memoireMat'];
  392.                     echo '</br>';
  393.                     echo '</p>';
  394.                 echo '</td>';
  395.             echo '</tr>';
  396.             echo '</table>';
  397.         }
  398.        
  399.         function afficherRessource($ligne,$margin,$link)
  400.         {
  401.             echo '<table style="margin-left:'.$margin.'px;">';
  402.             echo '<tr>';
  403.                 if($link == true)
  404.                 {
  405.                     echo '<td>';
  406.                         echo '<img src="./link.png" />';
  407.                     echo '</td>';
  408.                 }
  409.                 echo '<td>';
  410.                     echo '<a href="./index.php?Ressources='.$ligne[numRes].'"><img src="./database.png"/></a>';
  411.                 echo '</td>';
  412.  
  413.                 echo '<td style="vertical-align:middle;">';
  414.                     echo '<p>';
  415.                     echo 'Nom Ressource: '.$ligne['nomRes'];
  416.                     echo '</br>';
  417.                     echo 'Description Ressource : '.$ligne['descriptionRes'];
  418.                     echo '</br>';
  419.                     echo 'Type de Ressource : '.getTypeResByID($ligne['kTypeRes']);
  420.                     echo '</br>';
  421.                     echo 'Responsable : '.$ligne['responsable'];
  422.                     echo '</br>';
  423.                     echo '</p>';
  424.                 echo '</td>';
  425.             echo '</tr>';
  426.             echo '</table>';
  427.         }
  428.        
  429.         function afficherApplication($ligne,$margin,$link)
  430.         {
  431.             echo '<table style="margin-left:'.$margin.'px;">';
  432.             echo '<tr>';
  433.                 if($link == true)
  434.                 {
  435.                     echo '<td>';
  436.                     echo '<img src="./link.png" />';
  437.                     echo '</td>';
  438.                 }
  439.                 echo '<td>';
  440.                     echo '<a href="./index.php?Application='.$ligne[numApp].'"><img src="./appli.png"/></a>';
  441.                 echo '</td>';
  442.  
  443.                 echo '<td style="vertical-align:middle;">';
  444.                     echo '<p>';
  445.                     echo 'Nom Application: '.$ligne['nomApp'];
  446.                     echo '</br>';
  447.                     echo 'Description Application : '.$ligne['descriptionApp'];
  448.                     echo '</br>';
  449.                     echo 'Type de Application : '.getTypeAppByID($ligne['kTypeApp']);
  450.                     echo '</br>';
  451.                     echo 'Responsable : '.$ligne['responsable'];
  452.                     echo '</br>';
  453.                     echo '</p>';
  454.                 echo '</td>';
  455.             echo '</tr>';
  456.             echo '</table>';
  457.         }
  458. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement