Commit 8cdcf852 authored by Stefan's avatar Stefan

add special via url and fix delete bug

parent e96b3d01
<?php
$gesamt = mysql_num_rows(mysql_query("SELECT * FROM routers"));
$online = mysql_num_rows(mysql_query("SELECT * FROM routers WHERE status = 'online'"));
$offline = mysql_num_rows(mysql_query("SELECT * FROM routers WHERE status = 'offline'"));
$clientsnw = file_get_contents('tmp/stat/clients.json');
if($clientsnw == "") {
$clientsnw = '-';
}
/**
* Network Monitoring Freifunk
*
* @author Stefan <stefan@osnabrueck.freifunk.net>
* @version 0.1
* @file router_special.php
*/
/* get mysql */
$gesamt = mysql_num_rows(mysql_query("SELECT * FROM routers"));
$online = mysql_num_rows(mysql_query("SELECT * FROM routers WHERE status = 'online'"));
$offline = mysql_num_rows(mysql_query("SELECT * FROM routers WHERE status = 'offline'"));
$clientsnw = file_get_contents('tmp/stat/clients.json');
if($clientsnw == "") {
$clientsnw = '-';
}
if($_GET['action']=="add") {
$sql = mysql_query("INSERT INTO router_special SET user = '".$_SESSION['userid']."', router = '".$_GET['id']."'");
}
if($_GET['action']=="delete") {
$sql = mysql_query("DELETE FROM router_special WHERE user = '".$_SESSION['userid']."' AND router = '".$_GET['id']."'");
}
/* add special router */
if($_GET['action']=="add") {
$sql = mysql_query("INSERT INTO router_special SET user = '".$_SESSION['userid']."', router = '".$_GET['id']."'");
}
/* delete special router */
if($_GET['action']=="delete") {
$sql = mysql_query("DELETE FROM router_special WHERE user = '".$_SESSION['userid']."' AND router = '".$_GET['id']."'");
}
?>
<!-- ROUTER MODAL -->
......@@ -61,27 +73,35 @@
</thead>
<tbody>
<?php
$sql2 = mysql_query("SELECT * FROM router_special WHERE user = '".$_SESSION['userid']."'");
while($row3 = mysql_fetch_assoc($sql2)) {
$row = mysql_fetch_assoc(mysql_query("SELECT * FROM routers WHERE id = '".$row3['router']."'"));
if($row['status']=="online") {
$status = '<img src="https://cdn1.iconfinder.com/data/icons/fs-icons-ubuntu-by-franksouza-dark/16/tray-online.png">';
/* return special id */
if($_GET['special']) {
$special_id = $_GET['special'];
$delete = '';
} else {
$status = '<img src="https://cdn1.iconfinder.com/data/icons/fs-icons-ubuntu-by-franksouza-dark/16/tray-offline.png">';
$special_id = $_SESSION['userid'];
$delete = '<a style="float: right;" href="index.php?section=routerlist_special&action=delete&id='.$row['id'].'"><img src="https://cdn3.iconfinder.com/data/icons/musthave/16/Cancel.png"></a>';
}
/* select routers */
$sql2 = mysql_query("SELECT * FROM router_special WHERE user = '".$special_id."'");
while($row3 = mysql_fetch_assoc($sql2)) {
$row = mysql_fetch_assoc(mysql_query("SELECT * FROM routers WHERE id = '".$row3['router']."'"));
if($row['status']=="online") {
$status = '<img src="https://cdn1.iconfinder.com/data/icons/fs-icons-ubuntu-by-franksouza-dark/16/tray-online.png">';
} else {
$status = '<img src="https://cdn1.iconfinder.com/data/icons/fs-icons-ubuntu-by-franksouza-dark/16/tray-offline.png">';
}
echo '<tr>
<td width="60%"><a href="#router1" onClick="$(\'#routerdetail\').load(\'pages/router_detail.php?id='.$row['id'].'&time='.time().'\');" class="modal-opener">'.$row['hostname'].'</a></td>
<td width="20%" align="center">'.$status.'</td>
<td width="20%" align="center">'.$row['clients'].' '.$delete.'</td>
</tr>';
}
echo '<tr>
<td width="60%"><a href="#router1" onClick="$(\'#routerdetail\').load(\'pages/router_detail.php?id='.$row['id'].'&time='.time().'\');" class="modal-opener">'.$row['hostname'].'</a></td>
<td width="20%" align="center">'.$status.'</td>
<td width="20%" align="center">'.$row['clients'].' <a style="float: right;" href="index.php?section=routerlist_special&action=delete&id='.$row['id'].'"><img src="https://cdn3.iconfinder.com/data/icons/musthave/16/Cancel.png"></a></td>
</tr>';
}
?>
</tbody>
</table>
<br /><br />
<script>
$(function(){
$("#nodes").tablesorter();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment