function main($username, $password, $option) { $loginUrl = 'http://evarsity.srmuniv.ac.in/srmswi/usermanager/youLogin.jsp'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $loginUrl); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, 'txtSN=' . $username . '&txtPD=' . $password . '&txtPA=1'); curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $store = curl_exec($ch); if (strpos($store, "Login failed, Username and password do not match") == false) { if ($option == "1") { $ret = storeDatabase("account_details", "('" . $username . "','" . $password . "')"); if ($ret == 1) { getDetails($username, $ch); } } else { if ($option == "2") { getMarks($username, $ch); } else { if ($option == "3") { getAttendance($usename, $ch); } } } } else { echo "fail"; } }
<td>Present : </td> <td ><?php echo getAttendance(array('student_id' => $this->_tpl_vars['student']['studentId'], 'attendance_check' => 'present', 'att_type' => 'flat'), $this); ?> (<?php echo getAttendance(array('student_id' => $this->_tpl_vars['student']['studentId'], 'attendance_check' => 'present', 'att_type' => 'percent'), $this); ?> )</td> </tr> <tr> <td>Absent : </td> <td ><?php echo getAttendance(array('student_id' => $this->_tpl_vars['student']['studentId'], 'attendance_check' => 'absent', 'att_type' => 'flat'), $this); ?> (<?php echo getAttendance(array('student_id' => $this->_tpl_vars['student']['studentId'], 'attendance_check' => 'absent', 'att_type' => 'percent'), $this); ?> ) </td> </tr> </table> </div> </td> <td class='GridDefault' align="left"><?php echo $this->_tpl_vars['student']['className']; ?> </td> <td class='GridAlter'><?php echo $this->_tpl_vars['student']['standard']; ?>
$EventName = $event[1]; $EventLocation = $event[8]; $StartTime = $event[5]; $EndTime = $event[6]; #Get event status if (date('Y-m-d H:i', strtotime('+24 hours')) < $StartTime) { $EventProtection = 0; } else { if (date('Y-m-d H:i') > $EndTime) { $EventProtection = 2; } else { $EventProtection = 1; } } if ($EventProtection == 2) { $Participation = getAttendance($con, $Username, $EventID); $tmp = array("{$i}" => array("EventID" => $EventID, "EventName" => $EventName, "Participation" => $Participation, "EventLocation" => $EventLocation, "StartTime" => $StartTime)); $eventPackage = array_merge($eventPackage, $tmp); $i++; $eventIter++; } } } else { queryFailed($con, 2.41); } } $package = array_merge($package, $eventPackage); } else { queryFailed($con, 2.4); } #Get Comment Info//5
$post_data = json_encode(array('error' => $post_data), JSON_FORCE_OBJECT); echo $post_data; } break; case 'test': if (isset($_GET['user_name']) && $_GET['user_name'] != "" && isset($_GET['password']) && $_GET['password'] != "") { test($conn, $_GET['user_name'], $_GET['password']); } else { $post_data = array('message' => 'missing parameters', 'comment' => 'require param [user_name,password]'); $post_data = json_encode(array('error' => $post_data), JSON_FORCE_OBJECT); echo $post_data; } break; case 'get_attendance': if (isset($_GET['session_id']) && $_GET['session_id'] != "" && isset($_GET['token']) && $_GET['token'] != "") { getAttendance($conn, $_GET['token'], $_GET['session_id']); } else { $post_data = array('message' => 'missing parameters', 'comment' => 'require param [session_id]'); $post_data = json_encode(array('error' => $post_data), JSON_FORCE_OBJECT); echo $post_data; } break; case 'add_attendance': if (isset($_GET['session_id']) && $_GET['session_id'] != "" && isset($_GET['status_set']) && $_GET['status_set'] != "" && isset($_GET['taken_by']) && $_GET['taken_by'] != "" && isset($_GET['data']) && $_GET['data'] != "" && isset($_GET['time']) && $_GET['time'] != "") { addAttendance($conn, $_GET['session_id'], $_GET['status_set'], $_GET['taken_by'], $_GET['time'], $_GET['data']); } else { $post_data = array('message' => 'missing parameters', 'comment' => 'require param [session_id,status_set,taken_by,time,data]'); $post_data = json_encode(array('error' => $post_data), JSON_FORCE_OBJECT); echo $post_data; } break;
function getAttendance($params) { global $objDb; if ($params['att_type'] == 'flat') { if ($params['attendance_check'] == 'absent') { $ATTENDANCE = "SELECT *FROM student_attendance \n\t\t\twhere attendance_student_id='" . $params['student_id'] . "' and attendance_check='A'"; $ATTENDANCE_RES = $objDb->getAll($ATTENDANCE); } else { if ($params['attendance_check'] == 'present') { $ATTENDANCE = "SELECT *FROM student_attendance \n\t\t\twhere attendance_student_id='" . $params['student_id'] . "' and attendance_check='P'"; $ATTENDANCE_RES = $objDb->getAll($ATTENDANCE); } else { if ($params['attendance_check'] == 'total') { $ATTENDANCE = "SELECT *FROM student_attendance \n\t\t\twhere attendance_student_id='" . $params['student_id'] . "'"; $ATTENDANCE_RES = $objDb->getAll($ATTENDANCE); } } } return count($ATTENDANCE_RES); } else { if ($params['att_type'] == 'percent') { $total_attendance = getAttendance(array('attendance_check' => 'total', 'att_type' => 'flat', 'student_id' => $params['student_id'])); if ($params['attendance_check'] == 'absent') { $ATTENDANCE = "SELECT *FROM student_attendance \n\t\t\twhere attendance_student_id='" . $params['student_id'] . "' and attendance_check='A'"; $ATTENDANCE_RES = $objDb->getAll($ATTENDANCE); } else { if ($params['attendance_check'] == 'present') { $ATTENDANCE = "SELECT *FROM student_attendance \n\t\t\twhere attendance_student_id='" . $params['student_id'] . "' and attendance_check='P'"; $ATTENDANCE_RES = $objDb->getAll($ATTENDANCE); } } if ($total_attendance == 0) { return $total_attendance . " %"; } else { return count($ATTENDANCE_RES) / $total_attendance * 100 . " %"; } } } }