@@ -15,7 +15,7 @@ class PWI
15
15
* Alpha Release
16
16
* @version 1.1
17
17
*
18
- * @contributor(s): Ashwanth Kumar <ashwanth.kumar@gmail.com>
18
+ * @contributor(s): Ashwanth Kumar <ashwanth.kumar@gmail.com>, Adithya Parthasarathy <adithya91@gmail.com>
19
19
*/
20
20
21
21
const VERSION = 1.1 ;
@@ -43,30 +43,31 @@ public function __construct($params) {
43
43
/**
44
44
* Set the Params.
45
45
*/
46
- private function setRegNo ($ regno ){
46
+ private function setRegNo ($ regno ) {
47
47
$ this ->regno = $ regno ;
48
48
return $ this ;
49
49
}
50
50
51
- private function setPass ($ pass ){
51
+ private function setPass ($ pass ) {
52
52
$ this ->pass = $ pass ;
53
53
return $ this ;
54
54
}
55
55
56
56
/**
57
57
* Set the required CURL Behaviour.
58
58
*/
59
- private function setCurlBehaviour (){
59
+ private function setCurlBehaviour () {
60
60
$ options = array (CURLOPT_POST => true ,
61
- CURLOPT_FOLLOWLOCATION => true ,
62
- CURLOPT_COOKIEJAR => "cookies.txt " ,
63
- CURLOPT_COOKIEFILE => "cookies.txt " ,
64
- CURLOPT_RETURNTRANSFER => true ,
61
+ CURLOPT_FOLLOWLOCATION => true ,
62
+ CURLOPT_COOKIEJAR => "cookies.txt " ,
63
+ CURLOPT_COOKIEFILE => "cookies.txt " ,
64
+ CURLOPT_RETURNTRANSFER => true ,
65
65
CURLOPT_HEADER => false
66
66
);
67
- $ this ->ch = curl_init ();
68
- curl_setopt_array ($ this ->ch , $ options );
69
- return $ this ;
67
+
68
+ $ this ->ch = curl_init ();
69
+ curl_setopt_array ($ this ->ch , $ options );
70
+ return $ this ;
70
71
}
71
72
72
73
/**
@@ -94,22 +95,22 @@ private function loginToPWI() {
94
95
}
95
96
96
97
/**
97
- * Get the login status of the current user
98
- ** /
98
+ * Get the login status of the current user
99
+ */
99
100
public function getAuthStatus () {
100
101
return $ this ->isAuthenticated ;
101
102
}
102
103
103
104
/**
104
- * Get which campus does the student belong. Well useful, as certain operations are not available for SRC campus students on PWI.
105
- ** /
105
+ * Get which campus does the student belong. Well useful, as certain operations are not available for SRC campus students on PWI.
106
+ */
106
107
public function getIsMainCampus () {
107
108
return $ this ->isMainCampus ;
108
109
}
109
110
110
111
/**
111
112
* Throw error when user is not authenticated properly
112
- ** /
113
+ */
113
114
public function authError () {
114
115
return json_encode (array ("status " => "false " , "error " => "User not authenticated " ));
115
116
}
@@ -138,6 +139,7 @@ public function getInfo() {
138
139
public function getAttendance () {
139
140
if (isset ($ this ->regno ) && isset ($ this ->pass )) {
140
141
if ($ this ->getAuthStatus ()) {
142
+
141
143
/**
142
144
* Fetch the Attendance from PWI
143
145
*/
@@ -245,16 +247,7 @@ public function getInternalMarks() {
245
247
}
246
248
247
249
/**
248
- * Fetch Grades.
249
- *
250
- * Update - The papers are grouped by Semester.
251
- * Usage -
252
- * $grades = json_decode($student->getGrades());
253
- * // To get the semester 2 paper details
254
- * foreach($grades[2] as $paper) {
255
- * echo $paper->SUBNAME; // Get the subject name
256
- * echo $paper->GRADE; // Get the grade in that paper
257
- * }
250
+ * Fetch Grades
258
251
*/
259
252
public function getGrades () {
260
253
if (isset ($ this ->regno ) && isset ($ this ->pass )) {
@@ -654,9 +647,14 @@ public function getCourses($sem = NULL) {
654
647
} else die ("Register Number or Password not set. " );
655
648
}
656
649
650
+ /**
651
+ * Get Fee Dues
652
+ */
653
+
657
654
public function getFeeDue () {
658
655
if (isset ($ this ->regno ) && isset ($ this ->pass )) {
659
656
if ($ this ->getAuthStatus ()) {
657
+
660
658
/**
661
659
* Get the Fee Due details from PWI.
662
660
*/
@@ -665,7 +663,10 @@ public function getFeeDue() {
665
663
curl_setopt ($ ch , CURLOPT_REFERER , "http://webstream.sastra.edu/sastrapwi/usermanager/home.jsp " );
666
664
$ html = curl_exec ($ ch );
667
665
668
- phpQuery::newDocument ($ html );
666
+ /**
667
+ * Parse the content
668
+ */
669
+ phpQuery::newDocument ($ html );
669
670
pq ('tr:first ' )->remove ();
670
671
pq ('tr:first ' )->remove ();
671
672
@@ -687,10 +688,6 @@ public function getFeeDue() {
687
688
} else {
688
689
return $ this ->authError ();
689
690
}
690
- } else
691
- die ("Register Number or Password not set. " );
691
+ } else die ("Register Number or Password not set. " );
692
692
}
693
-
694
693
}
695
-
696
- ?>
0 commit comments