[ Index ]

PHP Cross Reference of Yamoon 0.9.0

title

Body

[close]

/ -> probe.php (source)

   1  <?php
   2  require_once ('Yamoon/Global.php');
   3  include ('header.php');
   4  
   5  $probe_id = $_GET['probe_id'];
   6  $company_id = $_GET['company_id'];
   7  
   8  // ============ DELETE
   9  if (isset($_GET['action']) && $_GET['action'] == "delete") {
  10      $probe = new Probe($config, $probe_id);
  11      $probe->delete();
  12      $message = "Probe '".$probe->service->name." on ".$probe->host->name."' deleted!";
  13      $link = "company.php?company_id=".$probe->company->id."&action=edit";
  14      $timeout = $config->redir_timeout;
  15      include ('message.php');
  16  
  17  // ============ INSERT
  18  } else if (isset($_GET['action']) && $_GET['action'] == "insert") {
  19      $message = "";
  20      $timeout = $config->redir_timeout;
  21      if (isset($_GET['company_id']) && $_GET['company_id'] != "" &&
  22          isset($_GET['service']) && $_GET['service'] != "" &&
  23          isset($_GET['host']) && $_GET['host'] != "" &&
  24          isset($_GET['active']) && $_GET['active'] != "") {
  25          $company = $_GET['company_id'];
  26          $service = $_GET['service'];
  27          $host = $_GET['host'];
  28          $active = $_GET['active'];
  29          $probe = new Probe($config);
  30          if ($probe->create($company, $service, $host, $active))
  31              $message = "Probe created!";
  32          else {
  33              $timeout = $config->redir_timeout_error;
  34              $message = "Cannot create duplicated probes!";
  35          }
  36      } else {
  37          $timeout = $config->redir_timeout;
  38          $message = "Cannot create a probe without a company, service and host!";
  39      }
  40      $link = "company.php?action=edit&company_id=".$company_id;
  41      include ('message.php');
  42  
  43  // ============ SAVE
  44  } else if (isset($_GET['action']) && $_GET['action'] == "save") {
  45      $probe = new Probe($config, $probe_id);
  46      $oldService = $probe->service;
  47      $oldHost = $probe->host;
  48      $message = "";
  49      $timeout = $config->redir_timeout;
  50      if (isset($_GET['company_id']) && $_GET['company_id'] != "" &&
  51          isset($_GET['service']) && $_GET['service'] != "" &&
  52          isset($_GET['host']) && $_GET['host'] != "") {
  53          $probe->company = new Company($config, $_GET['company_id']);
  54          $probe->service = new Service($config, $_GET['service']);
  55          $probe->host = new Host($config, $_GET['host']);
  56          $probe->active = $_GET['active'];
  57          if ($oldService->id != $probe->service->id || $oldHost->id != $probe->host->id) {
  58              $probe->clearLogs();
  59              $mrtg = new Mrtg($config, $probe->company->id);
  60              $mrtg->reloadConfig();
  61          }
  62          $probe->update();
  63          $message = "Probe data updated!";
  64      } else {
  65          $timeout = $config->redir_timeout_error;
  66          $message = "Cannot update a probe without a company, service and host!";
  67      }
  68      $link = "company.php?action=edit&company_id=".$probe->company->id;
  69      include ('message.php');
  70  
  71  // ============ EDIT
  72  } else {
  73      $probe = new Probe($config, $probe_id);
  74      $selected = "";
  75  ?>
  76  
  77  <p>
  78  <form action="probe.php">
  79  <input type=hidden name=action value=save>
  80  <input type=hidden name=probe_id value="<?php print $probe->id ?>">
  81  <table>
  82      <tr>
  83          <td class='title'>Company</td>
  84          <td class='field'>
  85              <input type=hidden name=company_id value="<?php print $probe->company->id ?>">
  86              <b><?php print $probe->company->name ?></b>
  87          </td>
  88      </tr>
  89      <tr>
  90          <td class='title'>Service</td>
  91          <td class='field'>
  92              <select name=service>
  93              <?php foreach (getServices() as $service) {
  94                  if ($service->id == $probe->service->id)
  95                      $selected = "selected";
  96                  else
  97                      $selected = "";
  98                  print "<option value=\"$service->id\" $selected>$service->name</option>\n";
  99              } ?>
 100              </select>
 101          </td>
 102      </tr>
 103      <tr>
 104          <td class='title'>Host</td>
 105          <td class='field'>
 106              <select name=host>
 107              <?php foreach ($probe->company->getHosts() as $host) {
 108                  if ($host->id == $probe->host->id)
 109                      $selected = "selected";
 110                  else
 111                      $selected = "";
 112                  print "<option value=\"$host->id\" $selected>$host->name</option>\n";
 113              } ?>
 114              </select>
 115          </td>
 116      </tr>
 117      <tr>
 118          <td class='title'>Active</td>
 119          <td class='field'>
 120              <select name=active>
 121                  <option value='Y' <?php if ($probe->active == 'Y') { print 'selected'; } ?>>Yes</option>
 122                  <option value='N' <?php if ($probe->active == 'N') { print 'selected'; } ?>>No</option>
 123              </select>
 124          </td>
 125      </tr>
 126      <tr>
 127          <td class='field' colspan=2><input type=submit value="Update"></td>
 128      </tr>
 129  </table>
 130  </form>
 131  <p>
 132  
 133  <?php
 134  }
 135  include ('footer.php');
 136  ?>


Generated: Sat Feb 19 17:29:53 2005 Cross-referenced by PHPXref 0.6