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 c7aba1f0 authored by Reto Da Forno's avatar Reto Da Forno

minor improvements to previously added changes

git-svn-id: svn://svn.ee.ethz.ch/flocklab/trunk/shared@3337 613144d5-4475-0410-9df3-888732ad2c88
parent aaee2cfb
......@@ -4,15 +4,41 @@ __author__ = "Reto Da Forno <reto.daforno@tik.ee.ethz.ch>"
__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
try:
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"
cur.close()
cn.close()
sys.exit()
for elem in ret:
r.append(elem[0])
cur.close()
cn.close()
except Exception as e:
print "could not connect to database: " + sys.exc_info()[1][0]
sys.exit()
elif len(sys.argv) != 3:
print "Usage: ./%s [subject] [recipients] < [filename]" % scriptname
sys.exit()
msg = sys.stdin.read()
......
......@@ -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: flocklab@tik.ee.ethz.ch\r\nReply-To: flocklab-admin@tik.ee.ethz.ch");
}
......
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