Changeset 1108929
- Timestamp:
- 03/09/2015 05:53:51 PM (11 years ago)
- Location:
- raspberry-weather/trunk
- Files:
-
- 2 edited
-
functions.php (modified) (5 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
raspberry-weather/trunk/functions.php
r1056360 r1108929 52 52 //use global variables 53 53 global $graph_ids; 54 54 global $wpdb; 55 //setup of table name 56 $tablename = "temperatures"; 57 //make it convertable for blog switching 58 $wpdb->tables[] = $tablename; 59 //prepare it for use in actual blog 60 $wpdb->$tablename = $tablename; //$wpdb->get_blog_prefix() . $tablename; 55 61 $options = shortcode_atts(array( 56 62 'width' => "400px", … … 83 89 84 90 //Create the graph 85 $options[day] = mysql_real_escape_string($options[day]);86 $dateChosen = date('Y-m-d', mysql_real_escape_string(strtotime($options[day]))); //what day needs to be displayed?87 $temperatureMeasurement = mysql_real_escape_string($options[temperatureMeasurement]); //celsius or fahrenheit?88 $display = mysql_real_escape_string($options[display]); //do we show only temp, only humidity or both?89 $displayMeasurement = mysql_real_escape_string($options[scale]);91 $options[day] = esc_sql($options[day]); 92 $dateChosen = date('Y-m-d', esc_sql(strtotime($options[day]))); //what day needs to be displayed? 93 $temperatureMeasurement = esc_sql($options[temperatureMeasurement]); //celsius or fahrenheit? 94 $display = esc_sql($options[display]); //do we show only temp, only humidity or both? 95 $displayMeasurement = esc_sql($options[scale]); 90 96 91 97 //check for all types of temperature … … 105 111 $displayMeasurement = "F"; 106 112 107 $resultSet = mysql_query("SELECT " . $display . " FROM temperatures WHERE dateMeasured='" . $dateChosen . "'");113 $resultSet = $wpdb->get_results("SELECT " . $display . " FROM temperatures WHERE dateMeasured='" . $dateChosen . "'", ARRAY_A); 108 114 109 115 110 116 $graph_draw_js .= 'var graph = new google.visualization.LineChart(document.getElementById(\'' . $options['id'] . '\'));'; 111 117 112 if ( mysql_num_rows($resultSet) == 0) //nothing in table118 if (($wpdb->num_rows) == 0) //nothing in table 113 119 { 114 120 $content = "['Sample Time','Sample Temperature [" . $displayMeasurement . "]','Sample Humidity [%]'],"; //tell the user he has empty table … … 186 192 } 187 193 188 while ($row = mysql_fetch_assoc($resultSet)) {194 foreach ($resultSet as $row) { 189 195 $hourMeasured = $row['hourMeasured']; 190 196 if (strcmp($displayMeasurement, "C") == 0) … … 224 230 if (!empty($options['v_title'])) 225 231 { 226 $resultSet = mysql_query("SELECT temperature FROM temperatures WHERE dateMeasured='" . $dateChosen . "' ORDER BY temmperature ASC LIMIT 1");//get lowest temperature for chosen date232 $resultSet =$wpdb->get_results("SELECT temperature FROM temperatures WHERE dateMeasured='" . $dateChosen . "' ORDER BY temmperature ASC LIMIT 1");//get lowest temperature for chosen date 227 233 $graph_draw_js .= 'vAxis: {title: "' . $options['v_title'] . '", viewWindow: {min:".$resultSet."}}'; 228 234 -
raspberry-weather/trunk/readme.txt
r1056360 r1108929 53 53 == Changelog == 54 54 55 = 1.2 = 56 Thanks to Stefan Mayer for removing deprecated functions and adding some improvements! Graph now works on newest PHP versions! 57 55 58 = 1.1 = 56 59 Fixed bug for negative values, thank you Simon P.
Note: See TracChangeset
for help on using the changeset viewer.