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):
keeptime = config.getint('cleaner', 'keeptime_viz')
earliest_keeptime = time.time() - (keeptime*86400)
imgdir_path = config.get('viz','imgdir')
if not os.path.isdir(imgdir_path):
os.mkdir(imgdir_path)
for f in os.listdir(imgdir_path):
path = os.path.join(imgdir_path, f)
if os.stat(path).st_mtime < earliest_keeptime:
......
......@@ -15,15 +15,15 @@
exit(1);
if (isset($_POST['resid'])) {
$db = db_connect();
$sql = "DELETE FROM tbl_serv_reservations where serv_reservation_key=".mysql_real_escape_string($_POST['resid']);
$rs = mysql_query($sql) or flocklab_die('Cannot delete reservation in database because: ' . mysql_error());
mysql_close($db);
$sql = "DELETE FROM tbl_serv_reservations where serv_reservation_key=".mysqli_real_escape_string($db, $_POST['resid']);
$rs = mysqli_query($db, $sql) or flocklab_die('Cannot delete reservation in database because: ' . mysqli_error($db));
mysqli_close($db);
}
if (isset($_POST['add_group'])) {
$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'])).'))';
$rs = mysql_query($sql) or flocklab_die('Cannot add reservation in database because: ' . mysql_error());
mysql_close($db);
$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 = mysqli_query($db, $sql) or flocklab_die('Cannot add reservation in database because: ' . mysqli_error($db));
mysqli_close($db);
}
?>
<script type="text/javascript" src="scripts/jquery.cookie.js"></script>
......@@ -64,18 +64,18 @@ echo '<h1>Admin Group Reservations</h1>';
/* Get all reservations from the database and display them in the table. */
$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";
$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();
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']);
}
$sql = "SELECT serv_reservation_key, group_id_fk, time_start, time_end, groupname, group_list
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)
ORDER BY time_start DESC";
$rs = mysql_query($sql) or flocklab_die('Cannot get reservations from database because: ' . mysql_error());
$nrows = mysql_num_rows($rs);
mysql_close($db);
$rs = mysqli_query($db, $sql) or flocklab_die('Cannot get reservations from database because: ' . mysqli_error($db));
$nrows = mysqli_num_rows($rs);
mysqli_close($db);
?>
<form name="resadd" method="post" action="admin_group_reservation.php">
......@@ -92,7 +92,7 @@ ORDER BY time_start DESC";
<?php
$i = 0;
$max_len = 30; // maximum length of text before being cut
while ($row = mysql_fetch_array($rs)) {
while ($row = mysqli_fetch_array($rs)) {
$i++;
if ($i%2 == 1) {
echo "<tr class='even'>";
......
......@@ -16,20 +16,20 @@
if (isset($_POST['inlist']) && isset($_POST['group'])) {
$db = db_connect();
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);
$rs = mysql_query($sql) or flocklab_die('Cannot remove user from group because: ' . mysql_error());
$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 = mysqli_query($db, $sql) or flocklab_die('Cannot remove user from group because: ' . mysqli_error($db));
echo "remove user ".$user." from group ".$_POST['group'];
}
mysql_close($db);
mysqli_close($db);
}
if (isset($_POST['notinlist']) && isset($_POST['group'])) {
$db = db_connect();
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).")";
$rs = mysql_query($sql) or flocklab_die('Cannot add user to group because: ' . mysql_error());
$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 = mysqli_query($db, $sql) or flocklab_die('Cannot add user to group because: ' . mysqli_error($db));
echo "add user ".$user." to group ".$_POST['group'];
}
mysql_close($db);
mysqli_close($db);
}
?>
<script type="text/javascript" src="scripts/jquery.cookie.js"></script>
......@@ -46,9 +46,9 @@ echo '<h1>Admin Groups</h1>';
/* Get groups */
$db = db_connect();
$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();
while ($row = mysql_fetch_array($rs)) {
while ($row = mysqli_fetch_array($rs)) {
$groups[$row['serv_groups_key']]=$row['groupname'];
}
if (empty($_POST['group'])) {
......@@ -59,18 +59,18 @@ echo '<h1>Admin Groups</h1>';
$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";
$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();
while ($row = mysql_fetch_array($rs)) {
while ($row = mysqli_fetch_array($rs)) {
$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";
$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();
while ($row = mysql_fetch_array($rs)) {
while ($row = mysqli_fetch_array($rs)) {
$notuser[$row['serv_users_key']]=$row['username'];
}
mysql_close($db);
mysqli_close($db);
$max_len = 50;
?>
<form name="resadd" method="post" action="admin_groups.php">
......
This diff is collapsed.
......@@ -15,26 +15,26 @@
exit(1);
if (isset($_POST['use_daq']) && isset($_POST['user_id'])) {
$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']);
$rs = mysql_query($sql) or flocklab_die('Cannot update user propery in database because: ' . mysql_error());
mysql_close($db);
$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 = mysqli_query($db, $sql) or flocklab_die('Cannot update user propery in database because: ' . mysqli_error($db));
mysqli_close($db);
}
if (isset($_POST['is_active']) && isset($_POST['user_id'])) {
$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']);
$rs = mysql_query($sql) or flocklab_die('Cannot update user propery in database because: ' . mysql_error());
$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 = mysqli_query($db, $sql) or flocklab_die('Cannot update user propery in database because: ' . mysqli_error($db));
// send email to the user
if ($_POST['is_active']) {
// fetch the user email
$sql = "SELECT email, last_login from tbl_serv_users where serv_users_key=".mysql_real_escape_string($_POST['user_id']);
$rs = mysql_query($sql) or flocklab_die('Cannot get user email from database because: ' . mysql_error());
$row = mysql_fetch_array($rs);
$sql = "SELECT email, last_login from tbl_serv_users where serv_users_key=".mysqli_real_escape_string($db, $_POST['user_id']);
$rs = mysqli_query($db, $sql) or flocklab_die('Cannot get user email from database because: ' . mysqli_error($db));
$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)
$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");
}
}
mysql_close($db);
mysqli_close($db);
}
?>
<script type="text/javascript" src="scripts/jquery.cookie.js"></script>
......@@ -78,9 +78,9 @@ echo '<h1>Admin User Management</h1>';
/* Get all users from the database and display them in the table. */
$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";
$rs = mysql_query($sql) or flocklab_die('Cannot get users from database because: ' . mysql_error());
$nrows = mysql_num_rows($rs);
mysql_close($db);
$rs = mysqli_query($db, $sql) or flocklab_die('Cannot get users from database because: ' . mysqli_error($db));
$nrows = mysqli_num_rows($rs);
mysqli_close($db);
?>
<form name="resadd" method="post" action="#">
<table id="res_overview" class="tablesorter" style="display:none">
......@@ -100,7 +100,7 @@ echo '<h1>Admin User Management</h1>';
<tbody>
<?php
$i = 0;
while ($row = mysql_fetch_array($rs)) {
while ($row = mysqli_fetch_array($rs)) {
$i++;
if ($i%2 == 1) {
echo "<tr class='even'>";
......
......@@ -37,11 +37,11 @@
)
) 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:
$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.
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' ) {
......@@ -133,8 +133,8 @@
`time_end` BETWEEN "' . $mysqlstart . '" AND "' . $mysqlend . '")
GROUP BY serv_reservation_key
'. ($_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());
while ($row = mysql_fetch_array($rs)) {
$rs = mysqli_query($db, $sql) or flocklab_die('Cannot get calendar data from database because: ' . mysqli_error($db));
while ($row = mysqli_fetch_array($rs)) {
$event = array(
'id' => $row['serv_reservation_key'],
'title' => ($_SESSION['is_admin'] == true?'Reservation for group '.$row['group_id_fk']:'Occupied'),
......@@ -145,7 +145,7 @@
$event['end'] = $row['time_end'];
array_push($events, $event);
}
mysql_close($db);
mysqli_close($db);
// JSON-encode the array and return it to the calendar:
echo json_encode($events);
......
......@@ -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'))
ORDER by `a`.time_start_wish ASC LIMIT 1000";
$rs = mysql_query($sql) or die("Unknown error occurred.");
mysql_close($db);
$rs = mysqli_query($db, $sql) or die("Unknown error occurred.");
mysqli_close($db);
$config = array( "unique_id" => "flocklab.ethz.ch" );
$vcalendar = new vcalendar( $config );
// Build the events:
while ($row = mysql_fetch_array($rs)) {
while ($row = mysqli_fetch_array($rs)) {
$start = date_parse($row['time_start_w_offset']);
$end = date_parse($row['time_end_w_offset']);
$vevent = & $vcalendar->newComponent( "vevent" );
......
......@@ -19,8 +19,8 @@
$sql = 'UPDATE `tbl_serv_targetimages`
SET `binary` = NULL, `binary_hash_sha1` = NULL
WHERE `owner_fk` = '.$_SESSION['serv_users_key'].'
AND `serv_targetimages_key` = ' .mysql_real_escape_string($_POST['imageid']);
mysql_query($sql) or flocklab_die('Cannot remove image: ' . mysql_error());
AND `serv_targetimages_key` = ' .mysqli_real_escape_string($db, $_POST['imageid']);
mysqli_query($db, $sql) or flocklab_die('Cannot remove image: ' . mysqli_error($db));
}
?>
<?php
......@@ -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`
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`)
WHERE `owner_fk` = '.$_SESSION['serv_users_key'].' AND `serv_targetimages_key` = ' .mysql_real_escape_string($_POST['imageid']);
$res = mysql_query($sql) or flocklab_die('Cannot fetch image information: ' . mysql_error());
$row = mysql_fetch_assoc($res);
WHERE `owner_fk` = '.$_SESSION['serv_users_key'].' AND `serv_targetimages_key` = ' .mysqli_real_escape_string($db, $_POST['imageid']);
$res = mysqli_query($db, $sql) or flocklab_die('Cannot fetch image information: ' . mysqli_error($db));
$row = mysqli_fetch_assoc($res);
echo '
<form method="post" action="image_delete.php" enctype="multipart/form-data">
<fieldset>
......
......@@ -17,10 +17,10 @@ if (isset($_POST['imageid']) && is_numeric($_POST['imageid']) && check_imageid($
FROM tbl_serv_targetimages i
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)
WHERE ".($_SESSION['is_admin']?"":("owner_fk = " . $_SESSION['serv_users_key'] . " AND "))."`serv_targetimages_key`=".mysql_real_escape_string($_POST['imageid']);
$res = mysql_query($sql);
WHERE ".($_SESSION['is_admin']?"":("owner_fk = " . $_SESSION['serv_users_key'] . " AND "))."`serv_targetimages_key`=".mysqli_real_escape_string($db, $_POST['imageid']);
$res = mysqli_query($db, $sql);
if ($res !== false) {
$row = mysql_fetch_assoc($res);
$row = mysqli_fetch_assoc($res);
// Send the file to the user's browser:
header("Content-Type: binary/octet-stream");
header("Content-Disposition: attachment; filename=\"". $_POST['imageid'] .".".$row['platform'].".".$row['operatingsystem'].".exe\"");
......
......@@ -44,10 +44,10 @@
/* Platforms with more than one core. */
$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";
$rs = mysql_query($sql) or flocklab_die('Cannot get test images from database because: ' . mysql_error());
$nrows = mysql_num_rows($rs);
$rs = mysqli_query($db, $sql) or flocklab_die('Cannot get test images from database because: ' . mysqli_error($db));
$nrows = mysqli_num_rows($rs);
$multicore = Array();
while ($row = mysql_fetch_assoc($rs))
while ($row = mysqli_fetch_assoc($rs))
array_push($multicore, $row['name']);
/* 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`
......@@ -64,9 +64,9 @@
AND (`tbl_serv_targetimages`.`binary_hash_sha1` is not NULL)
GROUP BY `serv_targetimages_key`
ORDER BY `serv_targetimages_key` DESC";
$rs = mysql_query($sql) or flocklab_die('Cannot get test images from database because: ' . mysql_error());
$nrows = mysql_num_rows($rs);
mysql_close($db);
$rs = mysqli_query($db, $sql) or flocklab_die('Cannot get test images from database because: ' . mysqli_error($db));
$nrows = mysqli_num_rows($rs);
mysqli_close($db);
// If there are no tests for this user, display a message instead of the table:
if ($nrows == 0) {
......@@ -91,7 +91,7 @@
<?php
$i = 0;
$max_len = 16; // maximum length of text before beeing cut
while ($row = mysql_fetch_assoc($rs)) {
while ($row = mysqli_fetch_assoc($rs)) {
$i++;
if ($i%2 == 1) {
echo "<tr class='even'>";
......
......@@ -14,6 +14,4 @@
//debug();
// Set timezone to 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'
FROM tbl_serv_tests
WHERE owner_fk = " . $_SESSION['serv_users_key'] . " AND test_status <> 'deleted' AND test_status <> 'todelete'
ORDER BY serv_tests_key DESC";
$rs = mysql_query($sql) or flocklab_die('Cannot get tests from database because: ' . mysql_error());
$nrows = mysql_num_rows($rs);
mysql_close($db);
$rs = mysqli_query($db, $sql) or flocklab_die('Cannot get tests from database because: ' . mysqli_error($db));
$nrows = mysqli_num_rows($rs);
mysqli_close($db);
// If there are no tests for this user, display a message instead of the table:
if ($nrows == 0) {
......@@ -185,7 +185,7 @@ echo '<h1>Manage Tests for '.$_SESSION['firstname'] . ' ' . $_SESSION['lastname'
$js = '';$all = array();
$now = new DateTime();
$now = $now->format('U');
while ($row = mysql_fetch_array($rs)) {
while ($row = mysqli_fetch_array($rs)) {
// Find out the state of the test:
$schedulable = true;
$planned = false;
......
......@@ -22,18 +22,18 @@ if (isset($_GET['p'])) {
$sql = "SELECT serv_link_measurements_key, begin
FROM `flocklab`.tbl_serv_web_link_measurements
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
";
$rs = mysql_query($sql) or flocklab_die('Error: ' . mysql_error());
mysql_close($db);
$rs = mysqli_query($db, $sql) or flocklab_die('Error: ' . mysqli_error($db));
mysqli_close($db);
// Build the array of tests. If possible, append start and/or end time to the message:
$tests = array(
'dateTimeFormat'=>'iso8601',
'events'=> array (),
);
while ($row = mysql_fetch_array($rs)) {
while ($row = mysqli_fetch_array($rs)) {
$d = new DateTime($row['begin']);
$tests['events'][]=array(
......@@ -56,12 +56,12 @@ else if (isset($_GET['q']) and is_numeric($_GET['q'])) {
$sql = "SELECT CONVERT(links USING utf8) as links
FROM `flocklab`.tbl_serv_web_link_measurements
WHERE serv_link_measurements_key=".$_GET['q'];
$rs = mysql_query($sql) or flocklab_die('Error: ' . mysql_error());
mysql_close($db);
$rs = mysqli_query($db, $sql) or flocklab_die('Error: ' . mysqli_error($db));
mysqli_close($db);
if (mysql_num_rows($rs) == 1) {
if (mysqli_num_rows($rs) == 1) {
header('Content-Type: application/xml; charset=utf-8');
$row = mysql_fetch_array($rs);
$row = mysqli_fetch_array($rs);
echo $row['links'];
}
......
......@@ -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
FROM tbl_serv_gpio_monitor
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';
$rs = mysql_query($sql) or flocklab_die('Cannot get test results from database because: ' . mysql_error());
if (mysql_num_rows($rs)==0)
where test_fk='.mysqli_real_escape_string($db, $_POST['testid']).' group by pin_number order by pin_name';
$rs = mysqli_query($db, $sql) or flocklab_die('Cannot get test results from database because: ' . mysqli_error($db));
if (mysqli_num_rows($rs)==0)
echo "No data.";
else
while($row = mysql_fetch_array($rs)) {
while($row = mysqli_fetch_array($rs)) {
echo $row['pin_name'].' '.$row['c'];
}
echo '</div>';
......@@ -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
FROM tbl_serv_gpio_setting
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';
$rs = mysql_query($sql) or flocklab_die('Cannot get test results from database because: ' . mysql_error());
if (mysql_num_rows($rs)==0)
where test_fk='.mysqli_real_escape_string($db, $_POST['testid']).' group by pin_number order by pin_name';
$rs = mysqli_query($db, $sql) or flocklab_die('Cannot get test results from database because: ' . mysqli_error($db));
if (mysqli_num_rows($rs)==0)
echo "No data.";
else
while($row = mysql_fetch_array($rs)) {
while($row = mysqli_fetch_array($rs)) {
echo $row['pin_name'].' '.$row['c'];
}
echo '</div>';
// Serial reader
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']);
$rs = mysql_query($sql) or flocklab_die('Cannot get test results from database because: ' . mysql_error());
$row = mysql_fetch_array($rs);
$sql = 'SELECT count(*) as c FROM tbl_serv_serial_reader where test_fk='.mysqli_real_escape_string($db, $_POST['testid']);
$rs = mysqli_query($db, $sql) or flocklab_die('Cannot get test results from database because: ' . mysqli_error($db));
$row = mysqli_fetch_array($rs);
if ($row['c']==0)
echo "No data.";
else
......@@ -78,9 +78,9 @@ if (isset($_POST['testid'])) {
echo '</div>';
// Power profiling
echo "<div><p>Power Profiling</p>";
$sql = 'SELECT count(*) as c FROM tbl_serv_powerprofiling where test_fk='.mysql_real_escape_string($_POST['testid']);
$rs = mysql_query($sql) or flocklab_die('Cannot get test results from database because: ' . mysql_error());
$row = mysql_fetch_array($rs);
$sql = 'SELECT count(*) as c FROM tbl_serv_powerprofiling where test_fk='.mysqli_real_escape_string($db, $_POST['testid']);
$rs = mysqli_query($db, $sql) or flocklab_die('Cannot get test results from database because: ' . mysqli_error($db));
$row = mysqli_fetch_array($rs);
if ($row['c']==0)
echo "No data.";
else
......@@ -89,9 +89,9 @@ if (isset($_POST['testid'])) {
// error
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';
$rs = mysql_query($sql) or flocklab_die('Cannot get test results from database because: ' . mysql_error());
$row = mysql_fetch_array($rs);
$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 = mysqli_query($db, $sql) or flocklab_die('Cannot get test results from database because: ' . mysqli_error($db));
$row = mysqli_fetch_array($rs);
if ($row['c']==0)
echo "No data.";
else {
......
......@@ -24,12 +24,12 @@
((UTC_TIMESTAMP() < `time_end`) OR (`time_end` IS NULL))
ORDER BY `time_start` ASC, `time_end` ASC
";
$rs = mysql_query($sql) or flocklab_die('Cannot get status messages from database because: ' . mysql_error());
mysql_close($db);
$rs = mysqli_query($db, $sql) or flocklab_die('Cannot get status messages from database because: ' . mysqli_error($db));
mysqli_close($db);
// Build the array of events. If possible, append start and/or end time to the message:
$events = array();
while ($row = mysql_fetch_array($rs)) {
while ($row = mysqli_fetch_array($rs)) {
$msg = "<i>";
if ($row['time_start'] != "") {
$d = new DateTime($row['time_start']);
......
......@@ -53,10 +53,10 @@
$db = db_connect();
$sql = "SELECT serv_tests_key, title, description, time_start_act, time_start_wish, time_end_act, time_end_wish, test_status, `targetimage_fk`
FROM tbl_serv_tests LEFT JOIN tbl_serv_map_test_observer_targetimages ON (serv_tests_key = test_fk)
WHERE owner_fk = " . $_SESSION['serv_users_key'] . " AND serv_tests_key = ".mysql_real_escape_string($_POST['testid'])."
WHERE owner_fk = " . $_SESSION['serv_users_key'] . " AND serv_tests_key = ".mysqli_real_escape_string($db, $_POST['testid'])."
GROUP BY `targetimage_fk`";
$res = mysql_query($sql) or flocklab_die('Cannot fetch test information: ' . mysql_error());
$row = mysql_fetch_assoc($res);
$res = mysqli_query($db, $sql) or flocklab_die('Cannot fetch test information: ' . mysqli_error($db));
$row = mysqli_fetch_assoc($res);
// Find out the state of the test:
$schedulable = true;
$planned = false;
......@@ -154,9 +154,9 @@
<tr><td>Images used</td><td><ul>';
if (isset($row['targetimage_fk']))
echo '<li>'.$row['targetimage_fk'].'</li>';
$num = mysql_num_rows($res) - 1;
$num = mysqli_num_rows($res) - 1;
while ($num-- > 0) {
$row = mysql_fetch_assoc($res);
$row = mysqli_fetch_assoc($res);
echo '<li>'.$row['targetimage_fk'].'</li>';
}
echo '</ul></td><tr>
......
......@@ -26,37 +26,37 @@
SELECT targetimage_fk, serv_tests_key
FROM
tbl_serv_tests LEFT JOIN tbl_serv_map_test_observer_targetimages ON (serv_tests_key = test_fk)
WHERE owner_fk = '.$_SESSION['serv_users_key'].' AND serv_tests_key = '.mysql_real_escape_string($_POST['testid']).'
WHERE owner_fk = '.$_SESSION['serv_users_key'].' AND serv_tests_key = '.mysqli_real_escape_string($db, $_POST['testid']).'
GROUP BY `targetimage_fk`
) as a
LEFT JOIN tbl_serv_map_test_observer_targetimages as b ON (a.targetimage_fk = b.targetimage_fk)
GROUP BY targetimage_fk
HAVING DC=1';
$res = mysql_query($sql) or flocklab_die('Cannot remove test: ' . mysql_error());
$num = mysql_num_rows($res);
$res = mysqli_query($db, $sql) or flocklab_die('Cannot remove test: ' . mysqli_error($db));
$num = mysqli_num_rows($res);
while ($num-- > 0) {
$row = mysql_fetch_assoc($res);
$row = mysqli_fetch_assoc($res);
array_push($rmimages, $row['targetimage_fk']);
}
}
mysql_close($db);
mysqli_close($db);
// delete related image binaries (keep metadata for statistics)
$db = db_connect();
foreach($rmimages as $imid) {
$sql = 'UPDATE `tbl_serv_targetimages`
SET `binary` = NULL
WHERE `serv_targetimages_key` = '.$imid;
mysql_query($sql) or flocklab_die('Cannot remove test: ' . mysql_error());
mysqli_query($db, $sql) or flocklab_die('Cannot remove test: ' . mysqli_error($db));
}
// mark test to be deleted
$sql = 'UPDATE tbl_serv_tests SET test_status="todelete"
WHERE `owner_fk` = '.$_SESSION['serv_users_key'].' AND `serv_tests_key` = ' .mysql_real_escape_string($_POST['testid']);
mysql_query($sql) or flocklab_die('Cannot remove test: ' . mysql_error());
WHERE `owner_fk` = '.$_SESSION['serv_users_key'].' AND `serv_tests_key` = ' .mysqli_real_escape_string($db, $_POST['testid']);
mysqli_query($db, $sql) or flocklab_die('Cannot remove test: ' . mysqli_error($db));
// remove resource allocations
$sql = 'DELETE from tbl_serv_resource_allocation
WHERE `test_fk` = ' .mysql_real_escape_string($_POST['testid']);
mysql_query($sql) or flocklab_die('Cannot remove test: ' . mysql_error());
mysql_close($db);
WHERE `test_fk` = ' .mysqli_real_escape_string($db, $_POST['testid']);
mysqli_query($db, $sql) or flocklab_die('Cannot remove test: ' . mysqli_error($db));
mysqli_close($db);
}
else
array_push($errors, "Test does not belong to you.");
......@@ -93,10 +93,10 @@
$db = db_connect();
$sql = "SELECT serv_tests_key, title, description, time_start_act, time_start_wish, time_end_act, time_end_wish, test_status, `targetimage_fk`
FROM tbl_serv_tests LEFT JOIN tbl_serv_map_test_observer_targetimages ON (serv_tests_key = test_fk)
WHERE owner_fk = " . $_SESSION['serv_users_key'] . " AND serv_tests_key = ".mysql_real_escape_string($_POST['testid'])." AND test_status <> 'deleted' AND test_status <> 'todelete'
WHERE owner_fk = " . $_SESSION['serv_users_key'] . " AND serv_tests_key = ".mysqli_real_escape_string($db, $_POST['testid'])." AND test_status <> 'deleted' AND test_status <> 'todelete'
GROUP BY `targetimage_fk`";
$res = mysql_query($sql) or flocklab_die('Cannot fetch test information: ' . mysql_error());
$row = mysql_fetch_assoc($res);
$res = mysqli_query($db, $sql) or flocklab_die('Cannot fetch test information: ' . mysqli_error($db));
$row = mysqli_fetch_assoc($res);
// Find out the state of the test:
$schedulable = true;
$planned = false;
......@@ -202,9 +202,9 @@
<tr><td>Images used</td><td><ul>';
if (isset($row['targetimage_fk']))
echo '<li>'.$row['targetimage_fk'].'</li>';
$num = mysql_num_rows($res) - 1;
$num = mysqli_num_rows($res) - 1;
while ($num-- > 0) {
$row = mysql_fetch_assoc($res);
$row = mysqli_fetch_assoc($res);
echo '<li>'.$row['targetimage_fk'].'</li>';
}
echo '</ul></td><tr>
......
......@@ -20,11 +20,11 @@
$sql = "SELECT serv_tests_key as testid, title, description, time_start_act, time_start_wish, time_end_act, time_end_wish, test_status
FROM tbl_serv_tests
WHERE owner_fk = " . $_SESSION['serv_users_key'] . " AND test_status <> 'deleted' AND test_status <> 'todelete' AND ".(isset($_GET['testid'])?"serv_tests_key = ".$_GET['testid']:"last_changed >= '".date( 'Y-m-d H:i:s T', $_GET['updatesince'])."'");
$rs = mysql_query($sql) or flocklab_die('Cannot get test data from database because: ' . mysql_error());
mysql_close($db);
$rs = mysqli_query($db, $sql) or flocklab_die('Cannot get test data from database because: ' . mysqli_error($db));
mysqli_close($db);
$all = array();
while ($row = mysql_fetch_array($rs, MYSQL_ASSOC)) {
while ($row = mysqli_fetch_array($rs, MYSQL_ASSOC)) {
$all[]=$row;
}
// JSON-encode test info
......
......@@ -129,8 +129,8 @@ $javascript = '<link rel="stylesheet" href="css/ui-lightness/jquery-ui-1.8.20.cu
WHERE obs.status!='disabled' AND obs.status!='develop'
ORDER BY obs.observer_id
;";
$rs = mysql_query($sql) or flocklab_die('Cannot get observer information from database because: ' . mysql_error());
mysql_close($db);
$rs = mysqli_query($db, $sql) or flocklab_die('Cannot get observer information from database because: ' . mysqli_error($db));
mysqli_close($db);
?>
<div><table id="statustable" class="tablesorter" style="width:885px">
<thead>
......@@ -148,7 +148,7 @@ $javascript = '<link rel="stylesheet" href="css/ui-lightness/jquery-ui-1.8.20.cu
<?php
$i = 0;
$js = '';
while ($row = mysql_fetch_array($rs)) {
while ($row = mysqli_fetch_array($rs)) {
$i++;
echo ($i%2 == 1) ? "<tr class='even'>" : "<tr class='odd'>";
if ($row['observer_id'] < 10 )
......
This diff is collapsed.
......@@ -46,21 +46,21 @@
$db = db_connect();
$sql = "UPDATE `tbl_serv_users`
SET
`lastname` = '" . mysql_real_escape_string($lastname) . "',
`firstname` = '" . mysql_real_escape_string($firstname) . "',
`country` = '" . mysql_real_escape_string($country) . "',
`email` = '" . mysql_real_escape_string($email) . "',
`institution_type` = '" . mysql_real_escape_string($institutiontype) . "',
`institution` = '" . mysql_real_escape_string($institution) . "',
`disable_infomails` = '" . mysql_real_escape_string($disable_infomails) . "'
`lastname` = '" . mysqli_real_escape_string($db, $lastname) . "',
`firstname` = '" . mysqli_real_escape_string($db, $firstname) . "',
`country` = '" . mysqli_real_escape_string($db, $country) . "',
`email` = '" . mysqli_real_escape_string($db, $email) . "',
`institution_type` = '" . mysqli_real_escape_string($db, $institutiontype) . "',
`institution` = '" . mysqli_real_escape_string($db, $institution) . "',
`disable_infomails` = '" . mysqli_real_escape_string($db, $disable_infomails) . "'
WHERE serv_users_key = " . $_SESSION['serv_users_key'];
mysql_query($sql) or flocklab_die('Cannot update user information in database because: ' . mysql_error());
mysqli_query($db, $sql) or flocklab_die('Cannot update user information in database because: ' . mysqli_error($db));
// If the password was changed, reflect that also in the database:
if ($passwd != sha1("")) {
$sql = "UPDATE `tbl_serv_users` SET `password` = '" . mysql_real_escape_string($passwd) . "' WHERE serv_users_key = " . $_SESSION['serv_users_key'];
mysql_query($sql) or flocklab_die('Cannot update user password in database because: ' . mysql_error());
$sql = "UPDATE `tbl_serv_users` SET `password` = '" . mysqli_real_escape_string($db, $passwd) . "' WHERE serv_users_key = " . $_SESSION['serv_users_key'];
mysqli_query($db, $sql) or flocklab_die('Cannot update user password in database because: ' . mysqli_error($db));
}
mysql_close($db);
mysqli_close($db);
}
} else {
// Get the values from the database:
......