Guest User

Untitled

a guest
Apr 26th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.82 KB | None | 0 0
  1. login.php
  2. <?php
  3. session_start();
  4. session_destroy();
  5. ?>
  6.  
  7. <html>
  8. <body>
  9. <form action="intro.php" method="post">
  10.     loginname:<br>
  11.     <input type="text" name="name"><br>
  12.     password:<br>
  13.     <input type="text" name="passw"><br>
  14.     <input type="submit" value="login"><br>
  15. </form>
  16. </body>
  17. </html>
  18.  
  19. intro.php
  20. <?php
  21. session_start();
  22. $user = 'foo';
  23. $pass = 'bar';
  24. if($_POST['name'])
  25. {
  26.     if($_POST['name'] == $user && $_POST['passw'] == $pass)
  27.     {  
  28.         $_SESSION['name'] = $_POST['name'];
  29.         $_SESSION['passw'] = $_POST['passw'];
  30.     }  
  31. }
  32. include "session_check.php";
  33. ?>
  34. <html>
  35. <body>
  36. <?php
  37. if(!isset($_POST['add']) && empty($_POST['add']))
  38. {
  39. echo "Hallo " . $_SESSION['name'] .".<br>";
  40. echo "what do you whant to do?<br><br>";
  41. ?>
  42. <form action="" method="post">
  43.  
  44. <table>
  45. <tr><td>create new cluster:</td><td><input type="radio" name="add" value="add_cluster"></td></tr>
  46. <tr><td>add new host/master/slave</td><td><input type="radio" name="add" value="add_host"></td></tr>
  47. <tr><td>add new group of hosts</td><td><input type="radio" name="add" value="add_hostgroup"></td></tr>
  48. <tr><td>add Application</td><td><input type="radio" name="add" value="add_app"></td></tr>
  49. <tr><td>add Resource</td><td><input type="radio" name="add" value="add_res"></td></tr>
  50. <tr><td>add User</td><td><input type="radio" name="add" value="add_user"></td></tr>
  51. <tr><td>add Group of Users</td><td><input type="radio" name="add" value="add_usergroup"></td></tr>
  52. <tr><td></td><td><input type="submit" name="go" value="send"></td></tr>
  53. </form>
  54. </body>
  55. </html>
  56. <?php
  57. }
  58. else
  59. {
  60.     $_SESSION['exec'] = $_POST['add'];
  61.     header("Location:".$_SESSION['exec'].".php");
  62. }
  63. ?>
  64.  
  65. session_check.php
  66. <?php
  67. if(!isset($_SESSION['name']))
  68. {
  69.     header('Location: login.php');
  70. }
  71. ?>
  72.  
  73.  
  74.  
  75. add_cluster.php
  76. <?php
  77. session_start();
  78.  
  79. $clusters = array('bre_a','bre_m','tco_v');
  80. $cluster_ok;
  81.  
  82. include "session_check.php";
  83.  
  84. if($_POST['go'])
  85. {
  86.     if(($_POST['name'] && isset($_POST['name'])) &&
  87.     (isset($_POST['dns_sufix']) && $_POST['dns_sufix']) &&
  88.     (isset($_POST['person']) && $_POST['person']))
  89.     {
  90.         $cluster = trim($_POST['name']);
  91.         $cluster_ok = check_cluster($cluster, $clusters);
  92.  
  93.         if($cluster_ok)
  94.         {
  95.             $_SESSION['cluster'] = array('name' => $cluster, 'dns_sufix' => $_POST['dns_sufix'], 'person' => $_POST['person']);
  96.             header("Location:add_host.php");
  97.         }
  98.         else
  99.         {
  100.             echo "ERROR: cluster $cluster already exist, please choose another name<br>";
  101.         }
  102.     }
  103.     else
  104.     {
  105.         echo "Please fill in all fields<br>";
  106.     }
  107. }
  108. ?>
  109.  
  110. <html>
  111. <body>
  112. <form method='post'>
  113. <table>
  114. <tr>
  115.     <td><b>cluster:</b></td>
  116.     <td><input type='text' name='name'><td>
  117. </tr>
  118. <tr>
  119.     <td><b>dns sufix:</b></td>
  120.     <td><input type='text' name='dns_sufix'><td>
  121. </tr>
  122. <tr>
  123.     <td><b>responsable person:</b></td>
  124.     <td><input type='text' name='person'><td>
  125. </tr>
  126. <tr>
  127.     <td></td>
  128.     <td><input type='submit' name="go" value="send"></td>
  129. </tr>
  130. </table>
  131. </body>
  132. </html>
  133.  
  134. <?php
  135. function check_cluster($cluster, $clusters)
  136. {
  137. #    $query = "SELECT id, name FROM clusters WHERE name='".$cluster."'";
  138. #    $result = mysql_query($query);
  139.  
  140.      return (in_array($cluster, $clusters)) ? "0" : "1";
  141. }
  142. ?>
  143.  
  144.  
  145. add_hosts.php
  146.  
  147.  <?php
  148. session_start();
  149.  
  150. $host_ok;
  151.  
  152. include "session_check.php";
  153. ?>
  154.  
  155. <html>
  156. <body>
  157. <form method='post'>
  158. <table>
  159. <?php
  160. if($_SESSION['exec'] == 'add_cluster')
  161. {
  162.     foreach($_SESSION['cluster'] as $key => $value)
  163.     {  
  164.         echo "<tr><td><b>$key: </b></td><td>$value<td></tr>";
  165.     }  
  166. }
  167. ?>
  168. <tr>
  169.     <td><b>cluster:</b></td>
  170.     <td><select name='name'>
  171.             <option value="bre_a">bre_a</option>
  172.         </select>
  173.     </td>
  174. </tr>
  175. <tr>
  176.     <td><b>host:</b></td>
  177.     <td><input type='text' name='dns_sufix'><td>
  178. </tr>
  179. <tr>
  180.     <td><b>role:</b></td>
  181.     <td>
  182.     <table>
  183.     <tr>
  184.         <td>
  185.             <select name="role">
  186.               <option value="node">node</option>
  187.               <option value="master" selected>master</option>
  188.               <option value="slave">slave</option>
  189.               <option value="client">client</option>
  190.             </select>
  191.         </td>
  192.         <td><input type='checkbox' name="server" value="1" checked>server</td>
  193.     </tr>
  194.     </table>
  195. </tr>
  196. <tr>
  197.     <td><b>type:</b></td>
  198.     <td><input type='text' name='type' value="!"><td>
  199. </tr>
  200. <tr>
  201.     <td><b>model:</b></td>
  202.     <td><input type='text' name='model' value="!"><td>
  203. </tr>
  204. <tr>
  205.     <td><b>architecture:</b></td>
  206.     <td><input type='text' name='arch'><td>
  207. </tr>
  208. <tr>
  209.     <td></td><td><input type='submit'></td>
  210. </tr>
  211. </table>
  212. </form>
  213. </body>
  214. </html>
  215.  
  216. <?php
  217. function check_host($cluster, $clusters)
  218. {
  219.        return (in_array($host, $hosts)) ? "0" : "1";
  220. }
  221. ?>
Add Comment
Please, Sign In to add comment