To receive notifications about scheduled maintenance, please subscribe to the mailing-list You can subscribe to the mailing-list at

Commit c7aba1f0 authored by Reto Da Forno's avatar Reto Da Forno

minor improvements to previously added changes

git-svn-id: svn:// 613144d5-4475-0410-9df3-888732ad2c88
parent aaee2cfb
......@@ -4,15 +4,41 @@ __author__ = "Reto Da Forno <>"
__copyright__ = "Copyright 2018, ETH Zurich, Switzerland"
__license__ = "GPL"
import sys, os, __main__, time, re
scriptpath = '/home/flocklab/flocklab_bin/testmanagementserver'
sys.path.append(scriptpath + '/lib')
import flocklab # local library
scriptname = os.path.basename(__main__.__file__)
if __name__ == "__main__":
if len(sys.argv) != 3:
print "Usage: ./%s [subject] [recipients] < [filename]" % os.path.basename(__main__.__file__)
r = []
if len(sys.argv) == 2:
# no email provided -> extract all addresses from the database
config = flocklab.get_config(configpath=scriptpath)
logger = flocklab.get_logger(loggername=scriptname, loggerpath=scriptpath)
(cn, cur) = flocklab.connect_to_db(config, logger)
cur.execute("""SELECT email FROM `tbl_serv_users` WHERE is_active=1;""")
ret = cur.fetchall()
if not ret:
print "failed to get user emails from database"
for elem in ret:
except Exception as e:
print "could not connect to database: " + sys.exc_info()[1][0]
elif len(sys.argv) != 3:
print "Usage: ./%s [subject] [recipients] < [filename]" % scriptname
msg =
......@@ -26,10 +26,10 @@
// send email to the user
if ($_POST['is_active']) {
// fetch the user email
$sql = "SELECT email 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=".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);
if (file_exists("template/newuser_emailtemplate.txt")) {
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:\r\nReply-To:");
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