@@ -30,13 +30,13 @@ function icalFormatTime($time) {
3030
3131function generateIcal ($ schedule ) {
3232 // Globals
33- global $ HTTPROOTADDRESS ;
33+ global $ HTTPROOTADDRESS , $ dbConn ;
3434
3535 // We need to lookup the information about the quarter
36- $ term = mysql_real_escape_string ($ schedule ['term ' ]);
36+ $ term = $ dbConn -> real_escape_string ($ schedule ['term ' ]);
3737 $ query = "SELECT start, end, breakstart, breakend FROM quarters WHERE quarter=' {$ term }' " ;
38- $ result = mysql_query ($ query );
39- $ term = mysql_fetch_assoc ( $ result );
38+ $ result = $ dbConn -> query ($ query );
39+ $ term = $ result-> fetch_assoc ( );
4040 $ termStart = strtotime ($ term ['start ' ]);
4141 $ termEnd = date ("Ymd " , strtotime ($ term ['end ' ]));
4242
@@ -106,15 +106,15 @@ function getScheduleFromId($id) {
106106 // Query to see if the id exists, if we can update the last accessed time,
107107 // then the id most definitely exists.
108108 $ query = "UPDATE schedules SET datelastaccessed = NOW() WHERE id= {$ id }" ;
109- $ result = mysql_query ($ query );
109+ $ result = $ dbConn -> query ($ query );
110110
111111 $ query = "SELECT startday, endday, starttime, endtime, building, `quarter`, CAST(`image` AS unsigned int) AS `image` FROM schedules WHERE id= {$ id }" ;
112112
113- $ result = mysql_query ($ query );
113+ $ result = $ dbConn -> query ($ query );
114114 if (!$ result ) {
115115 return NULL ;
116116 }
117- $ scheduleInfo = mysql_fetch_assoc ( $ result );
117+ $ scheduleInfo = $ result-> fetch_assoc ( );
118118 if (!$ scheduleInfo ) {
119119 return NULL ;
120120 }
@@ -133,18 +133,18 @@ function getScheduleFromId($id) {
133133
134134 // It exists, so grab all the courses that exist for this schedule
135135 $ query = "SELECT section FROM schedulecourses WHERE schedule = {$ id }" ;
136- $ result = mysql_query ($ query );
137- while ($ course = mysql_fetch_assoc ( $ result )) {
136+ $ result = $ dbConn -> query ($ query );
137+ while ($ course = $ result-> fetch_assoc ( )) {
138138 $ schedule [] = getCourseBySectionId ($ course ['section ' ]);
139139 }
140140
141141 // Grab all the non courses that exist for this schedule
142142 $ query = "SELECT * FROM schedulenoncourses WHERE schedule = $ id " ;
143- $ result = mysql_query ($ query );
143+ $ result = $ dbConn -> query ($ query );
144144 if (!$ result ) {
145- echo mysql_error ();
145+ echo $ dbConn -> error ();
146146 }
147- while ($ nonCourseInfo = mysql_fetch_assoc ( $ result )) {
147+ while ($ nonCourseInfo = $ result-> fetch_assoc ( )) {
148148 $ schedule [] = array (
149149 "title " => $ nonCourseInfo ['title ' ],
150150 "courseNum " => "non " ,
@@ -171,11 +171,11 @@ function getScheduleFromId($id) {
171171
172172function getScheduleFromOldId ($ id ) {
173173 $ query = "SELECT id FROM schedules WHERE oldid = ' {$ id }' " ;
174- $ result = mysql_query ($ query );
175- if (!$ result || mysql_num_rows ( $ result) != 1 ) {
174+ $ result = $ dbConn -> query ($ query );
175+ if (!$ result || $ result-> num_rows != 1 ) {
176176 return NULL ;
177177 } else {
178- $ newId = mysql_fetch_assoc ( $ result );
178+ $ newId = $ result-> fetch_assoc ( );
179179 $ newId = $ newId ['id ' ];
180180 $ schedule = getScheduleFromId ($ newId );
181181 $ schedule ['id ' ] = $ newId ;
@@ -337,19 +337,19 @@ function renderSvg($svg, $id) {
337337 $ query = "INSERT INTO schedules (oldid, startday, endday, starttime, endtime, building, quarter) " .
338338 " VALUES('', ' {$ json ['startday ' ]}', ' {$ json ['endday ' ]}', ' {$ json ['starttime ' ]}', ' {$ json ['endtime ' ]}', ' {$ json ['building ' ]}', " .
339339 " ' {$ json ['term ' ]}') " ;
340- $ result = mysql_query ($ query );
340+ $ result = $ dbConn -> query ($ query );
341341 if (!$ result ) {
342- die (json_encode (array ("error " => "mysql " , "msg " => "Failed to store the schedule: " . mysql_error ( $ dbConn) )));
342+ die (json_encode (array ("error " => "mysql " , "msg " => "Failed to store the schedule: " . $ dbConn-> error )));
343343 }
344344
345345 // Grab the latest id for the schedule
346- $ schedId = mysql_insert_id () ;
346+ $ schedId = $ dbConn -> insert_id ;
347347
348348 // Optionally process the svg for the schedule
349349 $ image = false ;
350350 if (!empty ($ _POST ['svg ' ]) && renderSvg ($ _POST ['svg ' ], $ schedId )) {
351351 $ query = "UPDATE schedules SET image = ((1)) WHERE id = ' {$ schedId }' " ;
352- mysql_query ($ query ); // We don't particularly care if this fails
352+ $ dbConn -> query ($ query ); // We don't particularly care if this fails
353353 }
354354
355355 // Now iterate through the schedule
@@ -360,18 +360,18 @@ function renderSvg($svg, $id) {
360360 foreach ($ item ['times ' ] as $ time ) {
361361 $ query = "INSERT INTO schedulenoncourses (title, day, start, end, schedule) " .
362362 " VALUES(' {$ item ['title ' ]}', ' {$ time ['day ' ]}', ' {$ time ['start ' ]}', ' {$ time ['end ' ]}', ' {$ schedId }') " ;
363- $ result = mysql_query ($ query );
363+ $ result = $ dbConn -> query ($ query );
364364 if (!$ result ) {
365- die (json_encode (array ("error " => "mysql " , "msg " => "Storing non-course item ' {$ item ['title ' ]}' failed: " . mysql_error ( $ dbConn) )));
365+ die (json_encode (array ("error " => "mysql " , "msg " => "Storing non-course item ' {$ item ['title ' ]}' failed: " . $ dbConn-> error )));
366366 }
367367 }
368368 } else {
369369 // Process each course. It's crazy simple now.
370370 $ query = "INSERT INTO schedulecourses (schedule, section) " .
371371 " VALUES(' {$ schedId }', ' {$ item ['id ' ]}') " ;
372- $ result = mysql_query ($ query );
372+ $ result = $ dbConn -> query ($ query );
373373 if (!$ result ) {
374- die (json_encode (array ("error " => "mysql " , "msg " => "Storing a course ' {$ item ['courseNum ' ]}' failed: " . mysql_error ( $ dbConn) )));
374+ die (json_encode (array ("error " => "mysql " , "msg " => "Storing a course ' {$ item ['courseNum ' ]}' failed: " . $ dbConn-> erorr )));
375375 }
376376 }
377377 }
0 commit comments