| 1 | <html>
|
|---|
| 2 | <head>
|
|---|
| 3 | <meta name="Author" content="The FACT Group" />
|
|---|
| 4 | <meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
|---|
| 5 | <title>FACT Project</title>
|
|---|
| 6 | <link rel="StyleSheet" type="text/css" href="../style.css" />
|
|---|
| 7 | </head>
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 | <body>
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 | <a href='https://www.fact-project.org/smartfact'>Is FACT taking data?</a><br><br>
|
|---|
| 14 | Who is on shift?
|
|---|
| 15 | (from <a href='https://www.fact-project.org/shift'>FACT shift plan<a>
|
|---|
| 16 | and <a href='https://www.fact-project.org/logbook/memberlist.php'>FACT logbook<a>)
|
|---|
| 17 |
|
|---|
| 18 | <?php
|
|---|
| 19 |
|
|---|
| 20 | if ($argv)
|
|---|
| 21 | parse_str(implode('&', array_slice($argv, 1)), $_GET);
|
|---|
| 22 |
|
|---|
| 23 | if (isset($_GET['date']))
|
|---|
| 24 | $today=date("Ymd", strtotime($_GET["date"]));
|
|---|
| 25 | else
|
|---|
| 26 | {
|
|---|
| 27 | if (date("H")>8)
|
|---|
| 28 | $today=date("Ymd", mktime(0,0,0,date("m"), date("d"), date("Y")));
|
|---|
| 29 | else
|
|---|
| 30 | $today=date("Ymd",strtotime(date("Y-m-d", mktime(0,0,0,date("m"), date("d"), date("Y")))." -1 day"));
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 | function send_email($date, $msg_part)
|
|---|
| 35 | {
|
|---|
| 36 | $to = "fact-online@lists.phys.ethz.ch";
|
|---|
| 37 | $subject = $date.": shifter-info missing";
|
|---|
| 38 | $msg = "WARNING: No shifter-info available for ".$date."\n\n";
|
|---|
| 39 | $msg .= $msg_part;
|
|---|
| 40 |
|
|---|
| 41 | if (!mail($to, $subject, $msg, 'From:observations@fact-project.org'))
|
|---|
| 42 | echo "Sending warning email failed.<br>\n\n";
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | function get_userinfo($db, $username)
|
|---|
| 46 | {
|
|---|
| 47 | // this is getting exactly one entry from the DB, since we get only
|
|---|
| 48 | // one username, which is unique in the DB.
|
|---|
| 49 | $query="SELECT username as login, usertitle as name, email, fid5 as mobile, fid7 as skype
|
|---|
| 50 | FROM logbook.userfields
|
|---|
| 51 | LEFT JOIN logbook.users
|
|---|
| 52 | ON (uid=ufid)
|
|---|
| 53 | WHERE username='".$username."'";
|
|---|
| 54 | $result = $db->query($query);
|
|---|
| 55 | $all = $result->fetch_assoc();
|
|---|
| 56 | $result->free();
|
|---|
| 57 | return $all;
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 | function get_expertinfo($db)
|
|---|
| 62 | {
|
|---|
| 63 |
|
|---|
| 64 | $query="SELECT username as login, usertitle as name, email, fid5 as mobile, fid7 as skype
|
|---|
| 65 | FROM logbook.userfields
|
|---|
| 66 | LEFT JOIN logbook.users ON (uid=ufid)
|
|---|
| 67 | LEFT JOIN memberlist.experts
|
|---|
| 68 | ON (ufid=userid)
|
|---|
| 69 | WHERE now() < stop and now() > start";
|
|---|
| 70 | $result = $db->query($query);
|
|---|
| 71 | $all = $result->fetch_all(MYSQLI_ASSOC);
|
|---|
| 72 | $result->free();
|
|---|
| 73 | return $all;
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | function userinfo_to_string($userinfo){
|
|---|
| 77 | $s = $userinfo['name'] . "[" .$userinfo['login']."]" . ": <br>";
|
|---|
| 78 | $s .= " email:" . $userinfo['email'] . "<br>";
|
|---|
| 79 | $s .= " mobile:" . $userinfo['mobile'] . "<br>";
|
|---|
| 80 | $s .= " skype:" . $userinfo['skype'] . "<br>";
|
|---|
| 81 | return $s;
|
|---|
| 82 | }
|
|---|
| 83 |
|
|---|
| 84 | function send_warning_mail_to_user($userinfo){
|
|---|
| 85 | $msg = "Dear " . $userinfo['name'] . "[".$userinfo['login']."]" ."\n\n";
|
|---|
| 86 | $msg .= ", please insert your 'Shifthelper Mobile Phone Number' in ";
|
|---|
| 87 | $msg .= ' https://www.fact-project.org/logbook/usercp.php?action=profile';
|
|---|
| 88 | send_email($today, $msg);
|
|---|
| 89 |
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | echo "<br> Night: ".$today." (date of sunset) <br>";
|
|---|
| 93 | $query="SELECT u FROM calendar.Data WHERE CONCAT(y, LPAD(m+1, 2, 0), LPAD(d,2,0))='".$today."'";
|
|---|
| 94 | $query.=" AND NOT x=1 AND u NOT in('ISDC','ETHZ','TUDO','UNIWUE')";
|
|---|
| 95 | include ("db.php");
|
|---|
| 96 | $db = new mysqli($host, $user, $pw, $database);
|
|---|
| 97 | $db->set_charset("utf8");
|
|---|
| 98 | $result = $db->query($query);
|
|---|
| 99 | $numrows=mysqli_num_rows($result);
|
|---|
| 100 | if ($numrows==0)
|
|---|
| 101 | send_email($today, "Whoever is on shift, please insert your name to the shift calendar!\n");
|
|---|
| 102 | else
|
|---|
| 103 | echo " Contact Info Shiftcrew: <br>\n ";
|
|---|
| 104 | echo "<ul>\n";
|
|---|
| 105 | while ($row = $result->fetch_assoc())
|
|---|
| 106 | {
|
|---|
| 107 |
|
|---|
| 108 | $userinfo = get_userinfo($db, $row['u']);
|
|---|
| 109 | if ($userinfo['name']){
|
|---|
| 110 | echo "<li>".userinfo_to_string($userinfo)."</li>\n";
|
|---|
| 111 | if (!$userinfo['mobile'])
|
|---|
| 112 | send_warning_mail_to_user($userinfo);
|
|---|
| 113 | }
|
|---|
| 114 | }
|
|---|
| 115 | echo "</ul>\n <br>\n <br>\n ";
|
|---|
| 116 | $result->free();
|
|---|
| 117 |
|
|---|
| 118 | echo "Expert-On-Call Contact Info: <br>\n <ul>\n";
|
|---|
| 119 |
|
|---|
| 120 | foreach (get_expertinfo($db) as $expertinfo) {
|
|---|
| 121 | echo "<li>".userinfo_to_string($expertinfo)."</li><br>\n";
|
|---|
| 122 |
|
|---|
| 123 | }
|
|---|
| 124 | echo "</ul>\n";
|
|---|
| 125 | ?>
|
|---|
| 126 |
|
|---|
| 127 | </body>
|
|---|
| 128 | </html>
|
|---|