[ Index ] |
PHP Cross Reference of Yamoon 0.9.0 |
[Summary view] [Print] [Text view]
1 <?php 2 3 require_once ('Yamoon/Global.php'); 4 include ('header.php'); 5 6 $company_id = $_GET['company_id']; 7 8 // ============ DELETE 9 if (isset($_GET['action']) && $_GET['action'] == "delete") { 10 $company = new Company($config, $company_id); 11 $company->delete(); 12 $message = "Company '$company->name' and all it's hosts and probes deleted!"; 13 $link = "index.php"; 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['companyname']) && $_GET['companyname'] != "") { 22 $name = $_GET['companyname']; 23 $contact = $_GET['companycontact']; 24 $company = new Company($config); 25 if ($company->create($name, $contact)) 26 $message = "Company '$name' created!"; 27 else { 28 $timeout = $config->redir_timeout_error; 29 $message = "Cannot create duplicated companies!"; 30 } 31 } else { 32 $timeout = $config->redir_timeout_error; 33 $message = "Cannot create company without a name!"; 34 } 35 $link = "index.php"; 36 include ('message.php'); 37 38 // ============ CLONE 39 } else if (isset($_GET['action']) && $_GET['action'] == "clone") { 40 $timeout = $config->redir_timeout; 41 $company = new Company($config, $company_id); 42 if ($newCompany = $company->clone()) 43 $message = "Company '".$newCompany->name."' created!"; 44 else { 45 $timeout = $config->redir_timeout_error; 46 $message = "Cannot create duplicated companies!"; 47 } 48 $link = "index.php"; 49 include ('message.php'); 50 51 // ============ SAVE 52 } else if (isset($_GET['action']) && $_GET['action'] == "save") { 53 $company = new Company($config, $company_id); 54 $message = ""; 55 $timeout = $config->redir_timeout; 56 if (isset($_GET['companyname']) && $_GET['companyname'] != "") { 57 $company->name = $_GET['companyname']; 58 $company->contact = $_GET['companycontact']; 59 $company->update(); 60 $message = "Company data updated!"; 61 } else { 62 $timeout = $config->redir_timeout_error; 63 $message = "Cannot update a company without a name!"; 64 } 65 $link = "company.php?action=edit&company_id=$company_id"; 66 include ('message.php'); 67 68 // ============ EXECUTE 69 } else if (isset($_GET['action']) && $_GET['action'] == "execute") { 70 $company = new Company($config, $company_id); 71 foreach ($company->getProbes() as $probe) { 72 $probe->run(); 73 } 74 $link = "company.php?company_id=".$company->id; 75 $message = "All probes from company '".$company->name."' runned successfully"; 76 $timeout = $config->redir_timeout; 77 include ('message.php'); 78 79 // ============ EDIT 80 } else if (isset($_GET['action']) && $_GET['action'] == "edit") { 81 $company = new Company($config, $company_id); 82 83 ?> 84 85 <!-- COMPANY DATA --> 86 <p> 87 <form action="company.php"> 88 <input type=hidden name=action value=save> 89 <input type=hidden name=company_id value="<?php print $company->id ?>"> 90 <table> 91 <tr><td><b>Name:</b> <input name=companyname value="<?php print $company->name ?>"></td></tr> 92 <tr><td><b>Contact:</b> <input name=companycontact value="<?php print $company->contact ?>"></td></tr> 93 <tr><td><input type=submit value="Update"> 94 </table> 95 </form> 96 97 <!-- PROBE LIST --> 98 <p> 99 <table> 100 <tr><th>Service</th><th>Host</th><th>Active</th><th>Actions</th></tr> 101 <?php 102 foreach ($company->getProbes() as $probe) { 103 ?> 104 <tr> 105 <td class='prop'><a href="service.php?service_id=<?php print $probe->service->id ?>"><?php print $probe->service->name ?></a></td> 106 <td class='prop'><a href="host.php?host_id=<?php print $probe->host->id ?>&company_id=<?php print $probe->company->id ?>&action=edit"><?php print $probe->host->name ?></a></td> 107 <td class='prop'><?php print $probe->active ?></td> 108 <td class='link'> 109 <a href="probe.php?probe_id=<?php print $probe->id ?>">Edit</a> 110 <a href="probe.php?action=delete&probe_id=<?php print $probe->id ?>" onClick="return confirmDelete('probe','<?php print $probe->service->name." on ".$probe->host->name ?>')">Delete</a> 111 </td> 112 </tr> 113 <?php 114 } 115 ?> 116 <tr> 117 <form action="probe.php"> 118 <input type=hidden name=action value=insert> 119 <input type=hidden name=company_id value="<?php print $company->id ?>"> 120 <td class='prop'> 121 <select name=service> 122 <?php foreach (getServices() as $service) { 123 print "<option value=$service->id>$service->name</option>\n"; 124 } ?> 125 </select> 126 </td> 127 <td class='prop'> 128 <select name=host> 129 <?php foreach ($company->getHosts() as $host) { 130 print "<option value=$host->id>$host->name</option>\n"; 131 } ?> 132 </select> 133 </td> 134 <td class='prop'> 135 <select name=active> 136 <option value='Y'>Yes</option> 137 <option value='N'>No</option> 138 </select> 139 </td> 140 <td class='link'> 141 <input type=submit value="Create Probe"> 142 </td> 143 </form> 144 </tr> 145 </table> 146 147 <!-- HOST LIST --> 148 <p> 149 <table> 150 <tr><th>Host</th><th>IP</th><th>Actions</th></tr> 151 <?php 152 foreach ($company->getHosts() as $host) { 153 ?> 154 <tr> 155 <td class='prop'> 156 <?php print $host->name ?> 157 </td> 158 <td class='prop'> 159 <?php print $host->ip ?> 160 </td> 161 <td class='link'> 162 <a href="host.php?action=edit&company_id=<?php print $company_id ?>&host_id=<?php print $host->id ?>">Edit</a> 163 <a href="host.php?action=delete&company_id=<?php print $company_id ?>&host_id=<?php print $host->id ?>" onClick="return confirmDelete('host','<?php print $host->name?>')">Delete</a> 164 </td> 165 </tr> 166 <?php 167 } 168 ?> 169 <tr> 170 <form action="host.php"> 171 <input type=hidden name=action value=insert> 172 <input type=hidden name=company_id value="<?php print $company->id ?>"> 173 <td class='prop'> 174 <input name=hostname> 175 </td> 176 <td class='prop'> 177 <input name=hostip> 178 </td> 179 <td class='link'> 180 <input type=submit value="Create Host"> 181 </td> 182 </tr> 183 </form> 184 </table> 185 186 <?php 187 // ============ VIEW 188 } else { 189 $company = new Company($config, $company_id); 190 ?> 191 192 <table> 193 <tr> 194 <th>Service</th><th>Host</th><th>Active</th><th>Status</th><th>Quality</th><th>Delay</th><th>Actions</th> 195 </tr> 196 <?php 197 foreach ($company->getProbes() as $probe) { 198 ?> 199 200 <tr> 201 <td class='<?php print $probe->status ?>'><?php print $probe->service->name ?></td> 202 <td class='<?php print $probe->status ?>'><?php print $probe->host->name ?></td> 203 <td class='<?php print $probe->status ?>'><?php print $probe->active ?></td> 204 <td class='<?php print $probe->status ?>'><?php print strtoupper($probe->status) ?></td> 205 <td class='<?php print $probe->status ?>'><?php print $probe->quality ?></td> 206 <td class='<?php print $probe->status ?>'><?php print $probe->delay ?></td> 207 <td class='<?php print $probe->status ?>'> 208 <a href="stats.php?probe_id=<?php print $probe->id ?>">Stats</a> 209 <a href="/mrtg/<?php print $probe->service->name ?>_on_<?php print $probe->host->name ?>.html">MRTG</a> 210 </td> 211 </tr> 212 213 <?php 214 } 215 ?> 216 217 </table> 218 219 <?php 220 } 221 include ('footer.php'); 222 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sat Feb 19 17:29:53 2005 | Cross-referenced by PHPXref 0.6 |