Changeset 18681 for trunk/www/dch/shiftinfo.php
- Timestamp:
- 12/13/16 06:18:42 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/dch/shiftinfo.php
r18208 r18681 12 12 13 13 <a href='https://www.fact-project.org/smartfact'>Is FACT taking data?</a><br><br> 14 Who is on shift? 14 Who is on shift? 15 15 (from <a href='https://www.fact-project.org/shift'>FACT shift plan<a> 16 16 and <a href='https://www.fact-project.org/logbook/memberlist.php'>FACT logbook<a>) 17 17 18 <!--#!/usr/bin/php-->19 18 <?php 20 19 … … 32 31 } 33 32 33 34 34 function send_email($date, $msg_part) 35 35 { 36 //echo "WARNING: no shift crew found -> need to send email.<br>\n";37 36 $to = "fact-online@lists.phys.ethz.ch"; 38 //$to = "dorner@astro.uni-wuerzburg.de";39 37 $subject = $date.": shifter-info missing"; 40 38 $msg = "WARNING: No shifter-info available for ".$date."\n\n"; … … 45 43 } 46 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 } 47 91 48 92 echo "<br> Night: ".$today." (date of sunset) <br>"; 49 93 $query="SELECT u FROM calendar.Data WHERE CONCAT(y, LPAD(m+1, 2, 0), LPAD(d,2,0))='".$today."'"; 50 //excluding experts and institutes (apart from 'moon')51 94 $query.=" AND NOT x=1 AND u NOT in('ISDC','ETHZ','TUDO','UNIWUE')"; 52 95 include ("db.php"); 53 $db_id = mysql_connect($host, $user, $pw); 54 $result = mysql_query($query); 55 $numrows=mysql_num_rows($result); 96 $db = new mysqli($host, $user, $pw, $database); 97 $db->set_charset("utf8"); 98 $result = $db->query($query); 99 $numrows=mysqli_num_rows($result); 56 100 if ($numrows==0) 57 101 send_email($today, "Whoever is on shift, please insert your name to the shift calendar!\n"); … … 59 103 echo " Contact Info Shiftcrew: <br>\n "; 60 104 echo "<ul>\n"; 61 while ($row = mysql_fetch_row($result))105 while ($row = $result->fetch_assoc()) 62 106 { 63 $query2="SELECT usertitle, fid8 FROM logbook.userfields LEFT JOIN logbook.users ON (uid=ufid) WHERE username='".$row[0]."'"; 64 $result2 = mysql_query($query2); 65 while ($row2 = mysql_fetch_row($result2)) 66 { 67 echo "<li>".$row2[0].": ".$row2[1]."</li>\n"; 68 if (!$row2[1]) 69 send_email($today, "Dear ".$row2[0].", please insert your 'Contact Info' in your logbook user-profile!"); 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); 70 113 } 71 mysql_free_result($result2);72 114 } 73 115 echo "</ul>\n <br>\n <br>\n "; 74 mysql_free_result($result);116 $result->free(); 75 117 76 118 echo "Expert-On-Call Contact Info: <br>\n <ul>\n"; 77 $query3="SELECT usertitle, fid8 FROM logbook.userfields LEFT JOIN logbook.users ON (uid=ufid) LEFT JOIN memberlist.experts ON (ufid=userid) WHERE now() < stop and now() > start"; 78 $result3 = mysql_query($query3); 79 while ($row3 = mysql_fetch_row($result3)) 80 { 81 echo "<li>".$row3[0].": ".$row3[1]."</li>\n"; 119 120 foreach (get_expertinfo($db) as $expertinfo) { 121 echo "<li>".userinfo_to_string($expertinfo)."</li><br>\n"; 122 82 123 } 83 mysql_free_result($result3);84 124 echo "</ul>\n"; 85 86 /*87 echo "General Contact Info: <br>\n <ul>\n";88 $query4="SELECT usertitle, fid8 FROM logbook.userfields LEFT JOIN logbook.users ON (uid=ufid) WHERE username='dorner'";89 $result4 = mysql_query($query4);90 while ($row4 = mysql_fetch_row($result4))91 {92 echo "<li>".$row4[0].": ".$row4[1]."</li>\n";93 }94 mysql_free_result($result4);95 echo "</ul>\n";96 */97 98 125 ?> 99 126
Note:
See TracChangeset
for help on using the changeset viewer.