To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 90e66ed8 authored by Reto Da Forno's avatar Reto Da Forno

webserver files updated, now compatible with PHP7

parent 1dbf731d
...@@ -197,6 +197,8 @@ def main(argv): ...@@ -197,6 +197,8 @@ def main(argv):
keeptime = config.getint('cleaner', 'keeptime_viz') keeptime = config.getint('cleaner', 'keeptime_viz')
earliest_keeptime = time.time() - (keeptime*86400) earliest_keeptime = time.time() - (keeptime*86400)
imgdir_path = config.get('viz','imgdir') imgdir_path = config.get('viz','imgdir')
if not os.path.isdir(imgdir_path):
os.mkdir(imgdir_path)
for f in os.listdir(imgdir_path): for f in os.listdir(imgdir_path):
path = os.path.join(imgdir_path, f) path = os.path.join(imgdir_path, f)
if os.stat(path).st_mtime < earliest_keeptime: if os.stat(path).st_mtime < earliest_keeptime:
......
...@@ -15,15 +15,15 @@ ...@@ -15,15 +15,15 @@
exit(1); exit(1);
if (isset($_POST['resid'])) { if (isset($_POST['resid'])) {
$db = db_connect(); $db = db_connect();
$sql = "DELETE FROM tbl_serv_reservations where serv_reservation_key=".mysql_real_escape_string($_POST['resid']); $sql = "DELETE FROM tbl_serv_reservations where serv_reservation_key=".mysqli_real_escape_string($db, $_POST['resid']);
$rs = mysql_query($sql) or flocklab_die('Cannot delete reservation in database because: ' . mysql_error()); $rs = mysqli_query($db, $sql) or flocklab_die('Cannot delete reservation in database because: ' . mysqli_error($db));
mysql_close($db); mysqli_close($db);
} }
if (isset($_POST['add_group'])) { if (isset($_POST['add_group'])) {
$db = db_connect(); $db = db_connect();
$sql = 'INSERT INTO tbl_serv_reservations (group_id_fk, time_start, time_end) values ('.mysql_real_escape_string($_POST['add_group']).',FROM_UNIXTIME('.strtotime(mysql_real_escape_string($_POST['add_start_time'])).'),FROM_UNIXTIME('.strtotime(mysql_real_escape_string($_POST['add_end_time'])).'))'; $sql = 'INSERT INTO tbl_serv_reservations (group_id_fk, time_start, time_end) values ('.mysqli_real_escape_string($db, $_POST['add_group']).',FROM_UNIXTIME('.strtotime(mysqli_real_escape_string($db, $_POST['add_start_time'])).'),FROM_UNIXTIME('.strtotime(mysqli_real_escape_string($db, $_POST['add_end_time'])).'))';
$rs = mysql_query($sql) or flocklab_die('Cannot add reservation in database because: ' . mysql_error()); $rs = mysqli_query($db, $sql) or flocklab_die('Cannot add reservation in database because: ' . mysqli_error($db));
mysql_close($db); mysqli_close($db);
} }
?> ?>
<script type="text/javascript" src="scripts/jquery.cookie.js"></script> <script type="text/javascript" src="scripts/jquery.cookie.js"></script>
...@@ -64,18 +64,18 @@ echo '<h1>Admin Group Reservations</h1>'; ...@@ -64,18 +64,18 @@ echo '<h1>Admin Group Reservations</h1>';
/* Get all reservations from the database and display them in the table. */ /* Get all reservations from the database and display them in the table. */
$db = db_connect(); $db = db_connect();
$sql = "SELECT serv_groups_key, groupname, GROUP_CONCAT(username SEPARATOR ', ') as group_list FROM (tbl_serv_groups left join tbl_serv_user_groups on (group_fk=serv_groups_key)) left join tbl_serv_users on (user_fk=tbl_serv_users.serv_users_key) GROUP BY group_fk"; $sql = "SELECT serv_groups_key, groupname, GROUP_CONCAT(username SEPARATOR ', ') as group_list FROM (tbl_serv_groups left join tbl_serv_user_groups on (group_fk=serv_groups_key)) left join tbl_serv_users on (user_fk=tbl_serv_users.serv_users_key) GROUP BY group_fk";
$rs = mysql_query($sql) or flocklab_die('Cannot get reservations from database because: ' . mysql_error()); $rs = mysqli_query($db, $sql) or flocklab_die('Cannot get reservations from database because: ' . mysqli_error($db));
$groups = array(); $groups = array();
while ($row = mysql_fetch_array($rs)) { while ($row = mysqli_fetch_array($rs)) {
$groups[$row['serv_groups_key']]=Array('name' => $row['groupname'], 'users' => $row['group_list']); $groups[$row['serv_groups_key']]=Array('name' => $row['groupname'], 'users' => $row['group_list']);
} }
$sql = "SELECT serv_reservation_key, group_id_fk, time_start, time_end, groupname, group_list $sql = "SELECT serv_reservation_key, group_id_fk, time_start, time_end, groupname, group_list
FROM tbl_serv_reservations LEFT JOIN ( FROM tbl_serv_reservations LEFT JOIN (
SELECT serv_groups_key, groupname, GROUP_CONCAT(username SEPARATOR ', ') as group_list FROM (tbl_serv_groups left join tbl_serv_user_groups on (group_fk=serv_groups_key)) left join tbl_serv_users on (user_fk=tbl_serv_users.serv_users_key) GROUP BY serv_groups_key) as groups on (groups.serv_groups_key = group_id_fk) SELECT serv_groups_key, groupname, GROUP_CONCAT(username SEPARATOR ', ') as group_list FROM (tbl_serv_groups left join tbl_serv_user_groups on (group_fk=serv_groups_key)) left join tbl_serv_users on (user_fk=tbl_serv_users.serv_users_key) GROUP BY serv_groups_key) as groups on (groups.serv_groups_key = group_id_fk)
ORDER BY time_start DESC"; ORDER BY time_start DESC";
$rs = mysql_query($sql) or flocklab_die('Cannot get reservations from database because: ' . mysql_error()); $rs = mysqli_query($db, $sql) or flocklab_die('Cannot get reservations from database because: ' . mysqli_error($db));
$nrows = mysql_num_rows($rs); $nrows = mysqli_num_rows($rs);
mysql_close($db); mysqli_close($db);
?> ?>
<form name="resadd" method="post" action="admin_group_reservation.php"> <form name="resadd" method="post" action="admin_group_reservation.php">
...@@ -92,7 +92,7 @@ ORDER BY time_start DESC"; ...@@ -92,7 +92,7 @@ ORDER BY time_start DESC";
<?php <?php
$i = 0; $i = 0;
$max_len = 30; // maximum length of text before being cut $max_len = 30; // maximum length of text before being cut
while ($row = mysql_fetch_array($rs)) { while ($row = mysqli_fetch_array($rs)) {
$i++; $i++;
if ($i%2 == 1) { if ($i%2 == 1) {
echo "<tr class='even'>"; echo "<tr class='even'>";
......
...@@ -16,20 +16,20 @@ ...@@ -16,20 +16,20 @@
if (isset($_POST['inlist']) && isset($_POST['group'])) { if (isset($_POST['inlist']) && isset($_POST['group'])) {
$db = db_connect(); $db = db_connect();
foreach ($_POST['inlist'] as $user) { foreach ($_POST['inlist'] as $user) {
$sql = "DELETE FROM tbl_serv_user_groups where group_fk=".mysql_real_escape_string($_POST['group'])." and user_fk=".mysql_real_escape_string($user); $sql = "DELETE FROM tbl_serv_user_groups where group_fk=".mysqli_real_escape_string($db, $_POST['group'])." and user_fk=".mysqli_real_escape_string($db, $user);
$rs = mysql_query($sql) or flocklab_die('Cannot remove user from group because: ' . mysql_error()); $rs = mysqli_query($db, $sql) or flocklab_die('Cannot remove user from group because: ' . mysqli_error($db));
echo "remove user ".$user." from group ".$_POST['group']; echo "remove user ".$user." from group ".$_POST['group'];
} }
mysql_close($db); mysqli_close($db);
} }
if (isset($_POST['notinlist']) && isset($_POST['group'])) { if (isset($_POST['notinlist']) && isset($_POST['group'])) {
$db = db_connect(); $db = db_connect();
foreach ($_POST['notinlist'] as $user) { foreach ($_POST['notinlist'] as $user) {
$sql = "insert into tbl_serv_user_groups (group_fk, user_fk) values (".mysql_real_escape_string($_POST['group']).",".mysql_real_escape_string($user).")"; $sql = "insert into tbl_serv_user_groups (group_fk, user_fk) values (".mysqli_real_escape_string($db, $_POST['group']).",".mysqli_real_escape_string($db, $user).")";
$rs = mysql_query($sql) or flocklab_die('Cannot add user to group because: ' . mysql_error()); $rs = mysqli_query($db, $sql) or flocklab_die('Cannot add user to group because: ' . mysqli_error($db));
echo "add user ".$user." to group ".$_POST['group']; echo "add user ".$user." to group ".$_POST['group'];
} }
mysql_close($db); mysqli_close($db);
} }
?> ?>
<script type="text/javascript" src="scripts/jquery.cookie.js"></script> <script type="text/javascript" src="scripts/jquery.cookie.js"></script>
...@@ -46,9 +46,9 @@ echo '<h1>Admin Groups</h1>'; ...@@ -46,9 +46,9 @@ echo '<h1>Admin Groups</h1>';
/* Get groups */ /* Get groups */
$db = db_connect(); $db = db_connect();
$sql = "SELECT serv_groups_key, groupname FROM tbl_serv_groups"; $sql = "SELECT serv_groups_key, groupname FROM tbl_serv_groups";
$rs = mysql_query($sql) or flocklab_die('Cannot get reservations from database because: ' . mysql_error()); $rs = mysqli_query($db, $sql) or flocklab_die('Cannot get reservations from database because: ' . mysqli_error($db));
$groups = array(); $groups = array();
while ($row = mysql_fetch_array($rs)) { while ($row = mysqli_fetch_array($rs)) {
$groups[$row['serv_groups_key']]=$row['groupname']; $groups[$row['serv_groups_key']]=$row['groupname'];
} }
if (empty($_POST['group'])) { if (empty($_POST['group'])) {
...@@ -59,18 +59,18 @@ echo '<h1>Admin Groups</h1>'; ...@@ -59,18 +59,18 @@ echo '<h1>Admin Groups</h1>';
$selgroup = $_POST['group']; $selgroup = $_POST['group'];
} }
$sql = "SELECT group_fk, serv_users_key, username FROM tbl_serv_user_groups left join tbl_serv_users on (user_fk=tbl_serv_users.serv_users_key) where group_fk=".$selgroup." order by username"; $sql = "SELECT group_fk, serv_users_key, username FROM tbl_serv_user_groups left join tbl_serv_users on (user_fk=tbl_serv_users.serv_users_key) where group_fk=".$selgroup." order by username";
$rs = mysql_query($sql) or flocklab_die('Cannot get reservations from database because: ' . mysql_error()); $rs = mysqli_query($db, $sql) or flocklab_die('Cannot get reservations from database because: ' . mysqli_error($db));
$isuser = array(); $isuser = array();
while ($row = mysql_fetch_array($rs)) { while ($row = mysqli_fetch_array($rs)) {
$isuser[$row['serv_users_key']]=$row['username']; $isuser[$row['serv_users_key']]=$row['username'];
} }
$sql = "SELECT sum(group_fk=".$selgroup.") as isgroup, serv_users_key, username FROM tbl_serv_users left join tbl_serv_user_groups on (user_fk=tbl_serv_users.serv_users_key) group by serv_users_key having isgroup is null or isgroup=0 order by username"; $sql = "SELECT sum(group_fk=".$selgroup.") as isgroup, serv_users_key, username FROM tbl_serv_users left join tbl_serv_user_groups on (user_fk=tbl_serv_users.serv_users_key) group by serv_users_key having isgroup is null or isgroup=0 order by username";
$rs = mysql_query($sql) or flocklab_die('Cannot get reservations from database because: ' . mysql_error()); $rs = mysqli_query($db, $sql) or flocklab_die('Cannot get reservations from database because: ' . mysqli_error($db));
$notuser = array(); $notuser = array();
while ($row = mysql_fetch_array($rs)) { while ($row = mysqli_fetch_array($rs)) {
$notuser[$row['serv_users_key']]=$row['username']; $notuser[$row['serv_users_key']]=$row['username'];
} }
mysql_close($db); mysqli_close($db);
$max_len = 50; $max_len = 50;
?> ?>
<form name="resadd" method="post" action="admin_groups.php"> <form name="resadd" method="post" action="admin_groups.php">
......
This diff is collapsed.
...@@ -15,26 +15,26 @@ ...@@ -15,26 +15,26 @@
exit(1); exit(1);
if (isset($_POST['use_daq']) && isset($_POST['user_id'])) { if (isset($_POST['use_daq']) && isset($_POST['user_id'])) {
$db = db_connect(); $db = db_connect();
$sql = "UPDATE tbl_serv_users SET use_daq=".mysql_real_escape_string($_POST['use_daq'])." WHERE serv_users_key=".mysql_real_escape_string($_POST['user_id']); $sql = "UPDATE tbl_serv_users SET use_daq=".mysqli_real_escape_string($db, $_POST['use_daq'])." WHERE serv_users_key=".mysqli_real_escape_string($db, $_POST['user_id']);
$rs = mysql_query($sql) or flocklab_die('Cannot update user propery in database because: ' . mysql_error()); $rs = mysqli_query($db, $sql) or flocklab_die('Cannot update user propery in database because: ' . mysqli_error($db));
mysql_close($db); mysqli_close($db);
} }
if (isset($_POST['is_active']) && isset($_POST['user_id'])) { if (isset($_POST['is_active']) && isset($_POST['user_id'])) {
$db = db_connect(); $db = db_connect();
$sql = "UPDATE tbl_serv_users SET is_active=".mysql_real_escape_string($_POST['is_active'])." WHERE serv_users_key=".mysql_real_escape_string($_POST['user_id']); $sql = "UPDATE tbl_serv_users SET is_active=".mysqli_real_escape_string($db, $_POST['is_active'])." WHERE serv_users_key=".mysqli_real_escape_string($db, $_POST['user_id']);
$rs = mysql_query($sql) or flocklab_die('Cannot update user propery in database because: ' . mysql_error()); $rs = mysqli_query($db, $sql) or flocklab_die('Cannot update user propery in database because: ' . mysqli_error($db));
// send email to the user // send email to the user
if ($_POST['is_active']) { if ($_POST['is_active']) {
// fetch the user email // fetch the user email
$sql = "SELECT email, last_login from tbl_serv_users where serv_users_key=".mysql_real_escape_string($_POST['user_id']); $sql = "SELECT email, last_login from tbl_serv_users where serv_users_key=".mysqli_real_escape_string($db, $_POST['user_id']);
$rs = mysql_query($sql) or flocklab_die('Cannot get user email from database because: ' . mysql_error()); $rs = mysqli_query($db, $sql) or flocklab_die('Cannot get user email from database because: ' . mysqli_error($db));
$row = mysql_fetch_array($rs); $row = mysqli_fetch_array($rs);
if (file_exists("template/newuser_emailtemplate.txt") && $row['last_login'] === NULL) { // only send mail to new users (who have not yet logged in) if (file_exists("template/newuser_emailtemplate.txt") && $row['last_login'] === NULL) { // only send mail to new users (who have not yet logged in)
$msg = file_get_contents("template/newuser_emailtemplate.txt"); $msg = file_get_contents("template/newuser_emailtemplate.txt");
mail($row['email'], "Re: Request for FlockLab user account", $msg, "From: flocklab@tik.ee.ethz.ch\r\nReply-To: flocklab-admin@tik.ee.ethz.ch"); mail($row['email'], "Re: Request for FlockLab user account", $msg, "From: flocklab@tik.ee.ethz.ch\r\nReply-To: flocklab-admin@tik.ee.ethz.ch");
} }
} }
mysql_close($db); mysqli_close($db);
} }
?> ?>
<script type="text/javascript" src="scripts/jquery.cookie.js"></script> <script type="text/javascript" src="scripts/jquery.cookie.js"></script>
...@@ -78,9 +78,9 @@ echo '<h1>Admin User Management</h1>'; ...@@ -78,9 +78,9 @@ echo '<h1>Admin User Management</h1>';
/* Get all users from the database and display them in the table. */ /* Get all users from the database and display them in the table. */
$db = db_connect(); $db = db_connect();
$sql = "SELECT serv_users_key, lastname, firstname, username, email, is_active, use_daq, quota_runtime, quota_tests, role, UNIX_TIMESTAMP(create_time) as create_time_ts, DATE_FORMAT(create_time,'%d.%m.%Y') as create_date, last_login from tbl_serv_users"; $sql = "SELECT serv_users_key, lastname, firstname, username, email, is_active, use_daq, quota_runtime, quota_tests, role, UNIX_TIMESTAMP(create_time) as create_time_ts, DATE_FORMAT(create_time,'%d.%m.%Y') as create_date, last_login from tbl_serv_users";
$rs = mysql_query($sql) or flocklab_die('Cannot get users from database because: ' . mysql_error()); $rs = mysqli_query($db, $sql) or flocklab_die('Cannot get users from database because: ' . mysqli_error($db));
$nrows = mysql_num_rows($rs); $nrows = mysqli_num_rows($rs);
mysql_close($db); mysqli_close($db);
?> ?>
<form name="resadd" method="post" action="#"> <form name="resadd" method="post" action="#">
<table id="res_overview" class="tablesorter" style="display:none"> <table id="res_overview" class="tablesorter" style="display:none">
...@@ -100,7 +100,7 @@ echo '<h1>Admin User Management</h1>'; ...@@ -100,7 +100,7 @@ echo '<h1>Admin User Management</h1>';
<tbody> <tbody>
<?php <?php
$i = 0; $i = 0;
while ($row = mysql_fetch_array($rs)) { while ($row = mysqli_fetch_array($rs)) {
$i++; $i++;
if ($i%2 == 1) { if ($i%2 == 1) {
echo "<tr class='even'>"; echo "<tr class='even'>";
......
...@@ -37,11 +37,11 @@ ...@@ -37,11 +37,11 @@
) )
) ORDER BY `a`.time_start_wish ) ORDER BY `a`.time_start_wish
"; ";
$rs = mysql_query($sql) or flocklab_die('Cannot get calendar data from database because: ' . mysql_error()); $rs = mysqli_query($db, $sql) or flocklab_die('Cannot get calendar data from database because: ' . mysqli_error($db));
// Build the array of events: // Build the array of events:
$events = array(); $events = array();
while ($row = mysql_fetch_array($rs)) { while ($row = mysqli_fetch_array($rs)) {
// Create the event depending on the owner: if it is an event which belongs to the logged-in user, show more info and color it differently. // Create the event depending on the owner: if it is an event which belongs to the logged-in user, show more info and color it differently.
if ($row['owner_fk'] == $_SESSION['serv_users_key']) { if ($row['owner_fk'] == $_SESSION['serv_users_key']) {
if ($row['test_status'] == 'failed' || $row['test_status'] == 'finished' || $row['test_status'] == 'retention expiring' || $row['test_status'] == 'deleted' || $row['test_status'] == 'todelete' ) { if ($row['test_status'] == 'failed' || $row['test_status'] == 'finished' || $row['test_status'] == 'retention expiring' || $row['test_status'] == 'deleted' || $row['test_status'] == 'todelete' ) {
...@@ -133,8 +133,8 @@ ...@@ -133,8 +133,8 @@
`time_end` BETWEEN "' . $mysqlstart . '" AND "' . $mysqlend . '") `time_end` BETWEEN "' . $mysqlstart . '" AND "' . $mysqlend . '")
GROUP BY serv_reservation_key GROUP BY serv_reservation_key
'. ($_SESSION['is_admin'] == true?'':'HAVING `reservation_match` is NULL OR `reservation_match` <> 1'); '. ($_SESSION['is_admin'] == true?'':'HAVING `reservation_match` is NULL OR `reservation_match` <> 1');
$rs = mysql_query($sql) or flocklab_die('Cannot get calendar data from database because: ' . mysql_error()); $rs = mysqli_query($db, $sql) or flocklab_die('Cannot get calendar data from database because: ' . mysqli_error($db));
while ($row = mysql_fetch_array($rs)) { while ($row = mysqli_fetch_array($rs)) {
$event = array( $event = array(
'id' => $row['serv_reservation_key'], 'id' => $row['serv_reservation_key'],
'title' => ($_SESSION['is_admin'] == true?'Reservation for group '.$row['group_id_fk']:'Occupied'), 'title' => ($_SESSION['is_admin'] == true?'Reservation for group '.$row['group_id_fk']:'Occupied'),
...@@ -145,7 +145,7 @@ ...@@ -145,7 +145,7 @@
$event['end'] = $row['time_end']; $event['end'] = $row['time_end'];
array_push($events, $event); array_push($events, $event);
} }
mysql_close($db); mysqli_close($db);
// JSON-encode the array and return it to the calendar: // JSON-encode the array and return it to the calendar:
echo json_encode($events); echo json_encode($events);
......
...@@ -36,14 +36,14 @@ ...@@ -36,14 +36,14 @@
WHERE `a`.test_status <> 'not schedulable' AND `a`.test_status <> 'deleted' AND `a`.test_status <> 'todelete' AND (`a`.time_end_wish >= ADDTIME(NOW(), '-30 0:0:0.0')) WHERE `a`.test_status <> 'not schedulable' AND `a`.test_status <> 'deleted' AND `a`.test_status <> 'todelete' AND (`a`.time_end_wish >= ADDTIME(NOW(), '-30 0:0:0.0'))
ORDER by `a`.time_start_wish ASC LIMIT 1000"; ORDER by `a`.time_start_wish ASC LIMIT 1000";
$rs = mysql_query($sql) or die("Unknown error occurred."); $rs = mysqli_query($db, $sql) or die("Unknown error occurred.");
mysql_close($db); mysqli_close($db);
$config = array( "unique_id" => "flocklab.ethz.ch" ); $config = array( "unique_id" => "flocklab.ethz.ch" );
$vcalendar = new vcalendar( $config ); $vcalendar = new vcalendar( $config );
// Build the events: // Build the events:
while ($row = mysql_fetch_array($rs)) { while ($row = mysqli_fetch_array($rs)) {
$start = date_parse($row['time_start_w_offset']); $start = date_parse($row['time_start_w_offset']);
$end = date_parse($row['time_end_w_offset']); $end = date_parse($row['time_end_w_offset']);
$vevent = & $vcalendar->newComponent( "vevent" ); $vevent = & $vcalendar->newComponent( "vevent" );
......
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
$sql = 'UPDATE `tbl_serv_targetimages` $sql = 'UPDATE `tbl_serv_targetimages`
SET `binary` = NULL, `binary_hash_sha1` = NULL SET `binary` = NULL, `binary_hash_sha1` = NULL
WHERE `owner_fk` = '.$_SESSION['serv_users_key'].' WHERE `owner_fk` = '.$_SESSION['serv_users_key'].'
AND `serv_targetimages_key` = ' .mysql_real_escape_string($_POST['imageid']); AND `serv_targetimages_key` = ' .mysqli_real_escape_string($db, $_POST['imageid']);
mysql_query($sql) or flocklab_die('Cannot remove image: ' . mysql_error()); mysqli_query($db, $sql) or flocklab_die('Cannot remove image: ' . mysqli_error($db));
} }
?> ?>
<?php <?php
...@@ -48,9 +48,9 @@ ...@@ -48,9 +48,9 @@
$sql = 'SELECT `serv_targetimages_key`, `tbl_serv_targetimages`.`name` as `name`, `tbl_serv_targetimages`.`description` as `description`, `tbl_serv_operatingsystems`.`name` as `os_name`, `tbl_serv_platforms`.`name` as `platform_name`, `tbl_serv_targetimages`.`last_changed` $sql = 'SELECT `serv_targetimages_key`, `tbl_serv_targetimages`.`name` as `name`, `tbl_serv_targetimages`.`description` as `description`, `tbl_serv_operatingsystems`.`name` as `os_name`, `tbl_serv_platforms`.`name` as `platform_name`, `tbl_serv_targetimages`.`last_changed`
FROM `tbl_serv_targetimages` FROM `tbl_serv_targetimages`
LEFT JOIN (`tbl_serv_platforms`, `tbl_serv_operatingsystems`) ON (`operatingsystems_fk`=`tbl_serv_operatingsystems`.`serv_operatingsystems_key` AND `platforms_fk` = `tbl_serv_platforms`.`serv_platforms_key`) LEFT JOIN (`tbl_serv_platforms`, `tbl_serv_operatingsystems`) ON (`operatingsystems_fk`=`tbl_serv_operatingsystems`.`serv_operatingsystems_key` AND `platforms_fk` = `tbl_serv_platforms`.`serv_platforms_key`)
WHERE `owner_fk` = '.$_SESSION['serv_users_key'].' AND `serv_targetimages_key` = ' .mysql_real_escape_string($_POST['imageid']); WHERE `owner_fk` = '.$_SESSION['serv_users_key'].' AND `serv_targetimages_key` = ' .mysqli_real_escape_string($db, $_POST['imageid']);
$res = mysql_query($sql) or flocklab_die('Cannot fetch image information: ' . mysql_error()); $res = mysqli_query($db, $sql) or flocklab_die('Cannot fetch image information: ' . mysqli_error($db));
$row = mysql_fetch_assoc($res); $row = mysqli_fetch_assoc($res);
echo ' echo '
<form method="post" action="image_delete.php" enctype="multipart/form-data"> <form method="post" action="image_delete.php" enctype="multipart/form-data">
<fieldset> <fieldset>
......
...@@ -17,10 +17,10 @@ if (isset($_POST['imageid']) && is_numeric($_POST['imageid']) && check_imageid($ ...@@ -17,10 +17,10 @@ if (isset($_POST['imageid']) && is_numeric($_POST['imageid']) && check_imageid($
FROM tbl_serv_targetimages i FROM tbl_serv_targetimages i
left join tbl_serv_platforms p on (i.platforms_fk = p.serv_platforms_key) left join tbl_serv_platforms p on (i.platforms_fk = p.serv_platforms_key)
left join tbl_serv_operatingsystems o on (i.operatingsystems_fk = o.serv_operatingsystems_key) left join tbl_serv_operatingsystems o on (i.operatingsystems_fk = o.serv_operatingsystems_key)
WHERE ".($_SESSION['is_admin']?"":("owner_fk = " . $_SESSION['serv_users_key'] . " AND "))."`serv_targetimages_key`=".mysql_real_escape_string($_POST['imageid']); WHERE ".($_SESSION['is_admin']?"":("owner_fk = " . $_SESSION['serv_users_key'] . " AND "))."`serv_targetimages_key`=".mysqli_real_escape_string($db, $_POST['imageid']);
$res = mysql_query($sql); $res = mysqli_query($db, $sql);
if ($res !== false) { if ($res !== false) {
$row = mysql_fetch_assoc($res); $row = mysqli_fetch_assoc($res);
// Send the file to the user's browser: // Send the file to the user's browser:
header("Content-Type: binary/octet-stream"); header("Content-Type: binary/octet-stream");
header("Content-Disposition: attachment; filename=\"". $_POST['imageid'] .".".$row['platform'].".".$row['operatingsystem'].".exe\""); header("Content-Disposition: attachment; filename=\"". $_POST['imageid'] .".".$row['platform'].".".$row['operatingsystem'].".exe\"");
......
...@@ -44,10 +44,10 @@ ...@@ -44,10 +44,10 @@
/* Platforms with more than one core. */ /* Platforms with more than one core. */
$db = db_connect(); $db = db_connect();
$sql = "select count(core) as corenum, name from tbl_serv_architectures left join tbl_serv_platforms on serv_platforms_key = platforms_fk group by platforms_fk having corenum > 1"; $sql = "select count(core) as corenum, name from tbl_serv_architectures left join tbl_serv_platforms on serv_platforms_key = platforms_fk group by platforms_fk having corenum > 1";
$rs = mysql_query($sql) or flocklab_die('Cannot get test images from database because: ' . mysql_error()); $rs = mysqli_query($db, $sql) or flocklab_die('Cannot get test images from database because: ' . mysqli_error($db));
$nrows = mysql_num_rows($rs); $nrows = mysqli_num_rows($rs);
$multicore = Array(); $multicore = Array();
while ($row = mysql_fetch_assoc($rs)) while ($row = mysqli_fetch_assoc($rs))
array_push($multicore, $row['name']); array_push($multicore, $row['name']);
/* Get all test images of the current user from the database and display them in the table. */ /* Get all test images of the current user from the database and display them in the table. */
$sql = "SELECT `serv_targetimages_key`, `tbl_serv_targetimages`.`name` as `name`, `tbl_serv_targetimages`.`description` as `description`, `tbl_serv_architectures`.`description` as `core_desc`, `tbl_serv_operatingsystems`.`name` as `os_name`, `tbl_serv_platforms`.`name` as `platform_name`, `tbl_serv_targetimages`.`last_changed`, `test_fk`, `tbl_serv_tests`.`test_status` $sql = "SELECT `serv_targetimages_key`, `tbl_serv_targetimages`.`name` as `name`, `tbl_serv_targetimages`.`description` as `description`, `tbl_serv_architectures`.`description` as `core_desc`, `tbl_serv_operatingsystems`.`name` as `os_name`, `tbl_serv_platforms`.`name` as `platform_name`, `tbl_serv_targetimages`.`last_changed`, `test_fk`, `tbl_serv_tests`.`test_status`
...@@ -64,9 +64,9 @@ ...@@ -64,9 +64,9 @@
AND (`tbl_serv_targetimages`.`binary_hash_sha1` is not NULL) AND (`tbl_serv_targetimages`.`binary_hash_sha1` is not NULL)
GROUP BY `serv_targetimages_key` GROUP BY `serv_targetimages_key`
ORDER BY `serv_targetimages_key` DESC"; ORDER BY `serv_targetimages_key` DESC";
$rs = mysql_query($sql) or flocklab_die('Cannot get test images from database because: ' . mysql_error()); $rs = mysqli_query($db, $sql) or flocklab_die('Cannot get test images from database because: ' . mysqli_error($db));
$nrows = mysql_num_rows($rs); $nrows = mysqli_num_rows($rs);
mysql_close($db); mysqli_close($db);
// If there are no tests for this user, display a message instead of the table: // If there are no tests for this user, display a message instead of the table:
if ($nrows == 0) { if ($nrows == 0) {
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
<?php <?php
$i = 0; $i = 0;
$max_len = 16; // maximum length of text before beeing cut $max_len = 16; // maximum length of text before beeing cut
while ($row = mysql_fetch_assoc($rs)) { while ($row = mysqli_fetch_assoc($rs)) {
$i++; $i++;
if ($i%2 == 1) { if ($i%2 == 1) {
echo "<tr class='even'>"; echo "<tr class='even'>";
......
...@@ -14,6 +14,4 @@ ...@@ -14,6 +14,4 @@
//debug(); //debug();
// Set timezone to UTC: // Set timezone to UTC:
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');
// Set style for tooltips //TODO
?> ?>
index.php.normal
\ No newline at end of file
This diff is collapsed.
...@@ -155,9 +155,9 @@ echo '<h1>Manage Tests for '.$_SESSION['firstname'] . ' ' . $_SESSION['lastname' ...@@ -155,9 +155,9 @@ echo '<h1>Manage Tests for '.$_SESSION['firstname'] . ' ' . $_SESSION['lastname'
FROM tbl_serv_tests FROM tbl_serv_tests
WHERE owner_fk = " . $_SESSION['serv_users_key'] . " AND test_status <> 'deleted' AND test_status <> 'todelete' WHERE owner_fk = " . $_SESSION['serv_users_key'] . " AND test_status <> 'deleted' AND test_status <> 'todelete'
ORDER BY serv_tests_key DESC"; ORDER BY serv_tests_key DESC";
$rs = mysql_query($sql) or flocklab_die('Cannot get tests from database because: ' . mysql_error()); $rs = mysqli_query($db, $sql) or flocklab_die('Cannot get tests from database because: ' . mysqli_error($db));
$nrows = mysql_num_rows($rs); $nrows = mysqli_num_rows($rs);
mysql_close($db); mysqli_close($db);
// If there are no tests for this user, display a message instead of the table: // If there are no tests for this user, display a message instead of the table:
if ($nrows == 0) { if ($nrows == 0) {
...@@ -185,7 +185,7 @@ echo '<h1>Manage Tests for '.$_SESSION['firstname'] . ' ' . $_SESSION['lastname' ...@@ -185,7 +185,7 @@ echo '<h1>Manage Tests for '.$_SESSION['firstname'] . ' ' . $_SESSION['lastname'
$js = '';$all = array(); $js = '';$all = array();
$now = new DateTime(); $now = new DateTime();
$now = $now->format('U'); $now = $now->format('U');
while ($row = mysql_fetch_array($rs)) { while ($row = mysqli_fetch_array($rs)) {
// Find out the state of the test: // Find out the state of the test:
$schedulable = true; $schedulable = true;
$planned = false; $planned = false;
......
...@@ -22,18 +22,18 @@ if (isset($_GET['p'])) { ...@@ -22,18 +22,18 @@ if (isset($_GET['p'])) {
$sql = "SELECT serv_link_measurements_key, begin $sql = "SELECT serv_link_measurements_key, begin
FROM `flocklab`.tbl_serv_web_link_measurements FROM `flocklab`.tbl_serv_web_link_measurements
LEFT JOIN tbl_serv_platforms ON (serv_platforms_key = platform_fk) LEFT JOIN tbl_serv_platforms ON (serv_platforms_key = platform_fk)
WHERE LOWER(name)='".mysql_real_escape_string($platform)."' AND ".$radio." AND links is not NULL WHERE LOWER(name)='".mysqli_real_escape_string($db, $platform)."' AND ".$radio." AND links is not NULL
ORDER BY begin ASC ORDER BY begin ASC
"; ";
$rs = mysql_query($sql) or flocklab_die('Error: ' . mysql_error()); $rs = mysqli_query($db, $sql) or flocklab_die('Error: ' . mysqli_error($db));
mysql_close($db); mysqli_close($db);
// Build the array of tests. If possible, append start and/or end time to the message: // Build the array of tests. If possible, append start and/or end time to the message:
$tests = array( $tests = array(
'dateTimeFormat'=>'iso8601', 'dateTimeFormat'=>'iso8601',
'events'=> array (), 'events'=> array (),
); );
while ($row = mysql_fetch_array($rs)) { while ($row = mysqli_fetch_array($rs)) {
$d = new DateTime($row['begin']); $d = new DateTime($row['begin']);
$tests['events'][]=array( $tests['events'][]=array(
...@@ -56,12 +56,12 @@ else if (isset($_GET['q']) and is_numeric($_GET['q'])) { ...@@ -56,12 +56,12 @@ else if (isset($_GET['q']) and is_numeric($_GET['q'])) {
$sql = "SELECT CONVERT(links USING utf8) as links $sql = "SELECT CONVERT(links USING utf8) as links
FROM `flocklab`.tbl_serv_web_link_measurements FROM `flocklab`.tbl_serv_web_link_measurements
WHERE serv_link_measurements_key=".$_GET['q']; WHERE serv_link_measurements_key=".$_GET['q'];
$rs = mysql_query($sql) or flocklab_die('Error: ' . mysql_error()); $rs = mysqli_query($db, $sql) or flocklab_die('Error: ' . mysqli_error($db));
mysql_close($db); mysqli_close($db);
if (mysql_num_rows($rs) == 1) { if (mysqli_num_rows($rs) == 1) {
header('Content-Type: application/xml; charset=utf-8'); header('Content-Type: application/xml; charset=utf-8');
$row = mysql_fetch_array($rs); $row = mysqli_fetch_array($rs);
echo $row['links']; echo $row['links'];
} }
......
...@@ -42,12 +42,12 @@ if (isset($_POST['testid'])) { ...@@ -42,12 +42,12 @@ if (isset($_POST['testid'])) {
$sql = 'SELECT pin_name, tbl_serv_gpio_monitor.pin_number, count(tbl_serv_gpio_monitor.pin_number) as c $sql = 'SELECT pin_name, tbl_serv_gpio_monitor.pin_number, count(tbl_serv_gpio_monitor.pin_number) as c
FROM tbl_serv_gpio_monitor FROM tbl_serv_gpio_monitor
LEFT JOIN tbl_serv_pinmappings ON tbl_serv_gpio_monitor.pin_number = tbl_serv_pinmappings.pin_number LEFT JOIN tbl_serv_pinmappings ON tbl_serv_gpio_monitor.pin_number = tbl_serv_pinmappings.pin_number
where test_fk='.mysql_real_escape_string($_POST['testid']).' group by pin_number order by pin_name'; where test_fk='.mysqli_real_escape_string($db, $_POST['testid']).' group by pin_number order by pin_name';
$rs = mysql_query($sql) or flocklab_die('Cannot get test results from database because: ' . mysql_error()); $rs = mysqli_query($db, $sql) or flocklab_die('Cannot get test results from database because: ' . mysqli_error($db));
if (mysql_num_rows($rs)==0) if (mysqli_num_rows($rs)==0)
echo "No data."; echo "No data.";
else else
while($row = mysql_fetch_array($rs)) { while($row = mysqli_fetch_array($rs)) {
echo $row['pin_name'].' '.$row['c']; echo $row['pin_name'].' '.$row['c'];
} }
echo '</div>'; echo '</div>';
...@@ -56,21 +56,21 @@ if (isset($_POST['testid'])) { ...@@ -56,21 +56,21 @@ if (isset($_POST['testid'])) {
$sql = 'SELECT pin_name, tbl_serv_gpio_setting.pin_number, count(tbl_serv_gpio_setting.pin_number) as c $sql = 'SELECT pin_name, tbl_serv_gpio_setting.pin_number, count(tbl_serv_gpio_setting.pin_number) as c
FROM tbl_serv_gpio_setting FROM tbl_serv_gpio_setting
LEFT JOIN tbl_serv_pinmappings ON tbl_serv_gpio_setting.pin_number = tbl_serv_pinmappings.pin_number LEFT JOIN tbl_serv_pinmappings ON tbl_serv_gpio_setting.pin_number = tbl_serv_pinmappings.pin_number
where test_fk='.mysql_real_escape_string($_POST['testid']).' group by pin_number order by pin_name'; where test_fk='.mysqli_real_escape_string($db, $_POST['testid']).' group by pin_number order by pin_name';
$rs = mysql_query($sql) or flocklab_die('Cannot get test results from database because: ' . mysql_error()); $rs = mysqli_query($db, $sql) or flocklab_die('Cannot get test results from database because: ' . mysqli_error($db));
if (mysql_num_rows($rs)==0) if (mysqli_num_rows($rs)==0)
echo "No data."; echo "No data.";
else else
while($row = mysql_fetch_array($rs)) { while($row = mysqli_fetch_array($rs)) {
echo $row['pin_name'].' '.$row['c']; echo $row['pin_name'].' '.$row['c'];
} }
echo '</div>'; echo '</div>';
// Serial reader // Serial reader
echo "<div><p>Serial Reader</p>"; echo "<div><p>Serial Reader</p>";
$sql = 'SELECT count(*) as c FROM tbl_serv_serial_reader where test_fk='.mysql_real_escape_string($_POST['testid']); $sql = 'SELECT count(*) as c FROM tbl_serv_serial_reader where test_fk='.mysqli_real_escape_string($db, $_POST['testid']);
$rs = mysql_query($sql) or flocklab_die('Cannot get test results from database because: ' . mysql_error()); $rs = mysqli_query($db, $sql) or flocklab_die('Cannot get test results from database because: ' . mysqli_error($db));
$row = mysql_fetch_array($rs); $row = mysqli_fetch_array($rs);
if ($row['c']==0) if ($row['c']==0)
echo "No data."; echo "No data.";
else else
...@@ -78,9 +78,9 @@ if (isset($_POST['testid'])) { ...@@ -78,9 +78,9 @@ if (isset($_POST['testid'])) {
echo '</div>'; echo '</div>';
// Power profiling // Power profiling
echo "<div><p>Power Profiling</p>"; echo "<div><p>Power Profiling</p>";
$sql = 'SELECT count(*) as c FROM tbl_serv_powerprofiling where test_fk='.mysql_real_escape_string($_POST['testid']); $sql = 'SELECT count(*) as c FROM tbl_serv_powerprofiling where test_fk='.mysqli_real_escape_string($db, $_POST['testid']);
$rs = mysql_query($sql) or flocklab_die('Cannot get test results from database because: ' . mysql_error()); $rs = mysqli_query($db, $sql) or flocklab_die('Cannot get test results from database because: ' . mysqli_error($db));
$row = mysql_fetch_array($rs); $row = mysqli_fetch_array($rs);
if ($row['c']==0) if ($row['c']==0)
echo "No data."; echo "No data.";
else else
...@@ -89,9 +89,9 @@ if (isset($_POST['testid'])) { ...@@ -89,9 +89,9 @@ if (isset($_POST['testid'])) {
// error // error
echo "<div><p>Errors</p>"; echo "<div><p>Errors</p>";
$sql = 'SELECT count(*) as c, errormessage, timestamp FROM tbl_serv_errorlog where test_fk='.mysql_real_escape_string($_POST['testid']).' ORDER BY timestamp desc LIMIT 1'; $sql = 'SELECT count(*) as c, errormessage, timestamp FROM tbl_serv_errorlog where test_fk='.mysqli_real_escape_string($db, $_POST['testid']).' ORDER BY timestamp desc LIMIT 1';
$rs = mysql_query($sql) or flocklab_die('Cannot get test results from database because: ' . mysql_error()); $rs = mysqli_query($db, $sql) or flocklab_die('Cannot get test results from database because: ' . mysqli_error($db));
$row = mysql_fetch_array($rs); $row = mysqli_fetch_array($rs);
if ($row['c']==0) if ($row['c']==0)
echo "No data."; echo "No data.";
else { else {
......
...@@ -24,12 +24,12 @@ ...@@ -24,12 +24,12 @@
((UTC_TIMESTAMP() < `time_end`) OR (`time_end` IS NULL)) ((UTC_TIMESTAMP() < `time_end`) OR (`time_end` IS NULL))
ORDER BY `time_start` ASC, `time_end` ASC ORDER BY `time_start` ASC, `time_end` ASC
"; ";
$rs = mysql_query($sql) or flocklab_die('Cannot get status messages from database because: ' . mysql_error()); $rs = mysqli_query($db, $sql) or flocklab_die('Cannot get status messages from database because: ' . mysqli_error($db));
mysql_close($db); mysqli_close($db);
// Build the array of events. If possible, append start and/or end time to the message: // Build the array of events. If possible, append start and/or end time to the message:
$events = array(); $events = array();
while ($row = mysql_fetch_array($rs)) { while ($row = mysqli_fetch_array($rs)) {
$msg = "<i>"; $msg = "<i>";
if ($row['time_start'] != "") { if ($row['time_start'] != "") {
$d = new DateTime($row['time_start']); $d = new DateTime($row['time_start']);
......