Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- login.php
- <?php
- session_start();
- session_destroy();
- ?>
- <html>
- <body>
- <form action="intro.php" method="post">
- loginname:<br>
- <input type="text" name="name"><br>
- password:<br>
- <input type="text" name="passw"><br>
- <input type="submit" value="login"><br>
- </form>
- </body>
- </html>
- intro.php
- <?php
- session_start();
- $user = 'foo';
- $pass = 'bar';
- if($_POST['name'])
- {
- if($_POST['name'] == $user && $_POST['passw'] == $pass)
- {
- $_SESSION['name'] = $_POST['name'];
- $_SESSION['passw'] = $_POST['passw'];
- }
- }
- include "session_check.php";
- ?>
- <html>
- <body>
- <?php
- if(!isset($_POST['add']) && empty($_POST['add']))
- {
- echo "Hallo " . $_SESSION['name'] .".<br>";
- echo "what do you whant to do?<br><br>";
- ?>
- <form action="" method="post">
- <table>
- <tr><td>create new cluster:</td><td><input type="radio" name="add" value="add_cluster"></td></tr>
- <tr><td>add new host/master/slave</td><td><input type="radio" name="add" value="add_host"></td></tr>
- <tr><td>add new group of hosts</td><td><input type="radio" name="add" value="add_hostgroup"></td></tr>
- <tr><td>add Application</td><td><input type="radio" name="add" value="add_app"></td></tr>
- <tr><td>add Resource</td><td><input type="radio" name="add" value="add_res"></td></tr>
- <tr><td>add User</td><td><input type="radio" name="add" value="add_user"></td></tr>
- <tr><td>add Group of Users</td><td><input type="radio" name="add" value="add_usergroup"></td></tr>
- <tr><td></td><td><input type="submit" name="go" value="send"></td></tr>
- </form>
- </body>
- </html>
- <?php
- }
- else
- {
- $_SESSION['exec'] = $_POST['add'];
- header("Location:".$_SESSION['exec'].".php");
- }
- ?>
- session_check.php
- <?php
- if(!isset($_SESSION['name']))
- {
- header('Location: login.php');
- }
- ?>
- add_cluster.php
- <?php
- session_start();
- $clusters = array('bre_a','bre_m','tco_v');
- $cluster_ok;
- include "session_check.php";
- if($_POST['go'])
- {
- if(($_POST['name'] && isset($_POST['name'])) &&
- (isset($_POST['dns_sufix']) && $_POST['dns_sufix']) &&
- (isset($_POST['person']) && $_POST['person']))
- {
- $cluster = trim($_POST['name']);
- $cluster_ok = check_cluster($cluster, $clusters);
- if($cluster_ok)
- {
- $_SESSION['cluster'] = array('name' => $cluster, 'dns_sufix' => $_POST['dns_sufix'], 'person' => $_POST['person']);
- header("Location:add_host.php");
- }
- else
- {
- echo "ERROR: cluster $cluster already exist, please choose another name<br>";
- }
- }
- else
- {
- echo "Please fill in all fields<br>";
- }
- }
- ?>
- <html>
- <body>
- <form method='post'>
- <table>
- <tr>
- <td><b>cluster:</b></td>
- <td><input type='text' name='name'><td>
- </tr>
- <tr>
- <td><b>dns sufix:</b></td>
- <td><input type='text' name='dns_sufix'><td>
- </tr>
- <tr>
- <td><b>responsable person:</b></td>
- <td><input type='text' name='person'><td>
- </tr>
- <tr>
- <td></td>
- <td><input type='submit' name="go" value="send"></td>
- </tr>
- </table>
- </body>
- </html>
- <?php
- function check_cluster($cluster, $clusters)
- {
- # $query = "SELECT id, name FROM clusters WHERE name='".$cluster."'";
- # $result = mysql_query($query);
- return (in_array($cluster, $clusters)) ? "0" : "1";
- }
- ?>
- add_hosts.php
- <?php
- session_start();
- $host_ok;
- include "session_check.php";
- ?>
- <html>
- <body>
- <form method='post'>
- <table>
- <?php
- if($_SESSION['exec'] == 'add_cluster')
- {
- foreach($_SESSION['cluster'] as $key => $value)
- {
- echo "<tr><td><b>$key: </b></td><td>$value<td></tr>";
- }
- }
- ?>
- <tr>
- <td><b>cluster:</b></td>
- <td><select name='name'>
- <option value="bre_a">bre_a</option>
- </select>
- </td>
- </tr>
- <tr>
- <td><b>host:</b></td>
- <td><input type='text' name='dns_sufix'><td>
- </tr>
- <tr>
- <td><b>role:</b></td>
- <td>
- <table>
- <tr>
- <td>
- <select name="role">
- <option value="node">node</option>
- <option value="master" selected>master</option>
- <option value="slave">slave</option>
- <option value="client">client</option>
- </select>
- </td>
- <td><input type='checkbox' name="server" value="1" checked>server</td>
- </tr>
- </table>
- </tr>
- <tr>
- <td><b>type:</b></td>
- <td><input type='text' name='type' value="!"><td>
- </tr>
- <tr>
- <td><b>model:</b></td>
- <td><input type='text' name='model' value="!"><td>
- </tr>
- <tr>
- <td><b>architecture:</b></td>
- <td><input type='text' name='arch'><td>
- </tr>
- <tr>
- <td></td><td><input type='submit'></td>
- </tr>
- </table>
- </form>
- </body>
- </html>
- <?php
- function check_host($cluster, $clusters)
- {
- return (in_array($host, $hosts)) ? "0" : "1";
- }
- ?>
Add Comment
Please, Sign In to add comment