Skip to content

Commit c08e4ea

Browse files
author
Vignesh Rajagopalan
committedAug 13, 2011
Code cleaned.
1 parent dec8497 commit c08e4ea

File tree

1 file changed

+29
-32
lines changed

1 file changed

+29
-32
lines changed
 

‎pwi.php

+29-32
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class PWI
1515
* Alpha Release
1616
* @version 1.1
1717
*
18-
* @contributor(s): Ashwanth Kumar <ashwanth.kumar@gmail.com>
18+
* @contributor(s): Ashwanth Kumar <ashwanth.kumar@gmail.com>, Adithya Parthasarathy <adithya91@gmail.com>
1919
*/
2020

2121
const VERSION = 1.1;
@@ -43,30 +43,31 @@ public function __construct($params) {
4343
/**
4444
* Set the Params.
4545
*/
46-
private function setRegNo($regno){
46+
private function setRegNo($regno) {
4747
$this->regno = $regno;
4848
return $this;
4949
}
5050

51-
private function setPass($pass){
51+
private function setPass($pass) {
5252
$this->pass = $pass;
5353
return $this;
5454
}
5555

5656
/**
5757
* Set the required CURL Behaviour.
5858
*/
59-
private function setCurlBehaviour(){
59+
private function setCurlBehaviour() {
6060
$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,
6565
CURLOPT_HEADER => false
6666
);
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;
7071
}
7172

7273
/**
@@ -94,22 +95,22 @@ private function loginToPWI() {
9495
}
9596

9697
/**
97-
* Get the login status of the current user
98-
**/
98+
* Get the login status of the current user
99+
*/
99100
public function getAuthStatus() {
100101
return $this->isAuthenticated;
101102
}
102103

103104
/**
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+
*/
106107
public function getIsMainCampus() {
107108
return $this->isMainCampus;
108109
}
109110

110111
/**
111112
* Throw error when user is not authenticated properly
112-
**/
113+
*/
113114
public function authError() {
114115
return json_encode(array("status" => "false", "error" => "User not authenticated"));
115116
}
@@ -138,6 +139,7 @@ public function getInfo() {
138139
public function getAttendance() {
139140
if (isset($this->regno) && isset($this->pass)) {
140141
if($this->getAuthStatus()) {
142+
141143
/**
142144
* Fetch the Attendance from PWI
143145
*/
@@ -245,16 +247,7 @@ public function getInternalMarks() {
245247
}
246248

247249
/**
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
258251
*/
259252
public function getGrades() {
260253
if (isset($this->regno) && isset($this->pass)) {
@@ -654,9 +647,14 @@ public function getCourses($sem = NULL) {
654647
} else die("Register Number or Password not set.");
655648
}
656649

650+
/**
651+
* Get Fee Dues
652+
*/
653+
657654
public function getFeeDue() {
658655
if (isset($this->regno) && isset($this->pass)) {
659656
if ($this->getAuthStatus()) {
657+
660658
/**
661659
* Get the Fee Due details from PWI.
662660
*/
@@ -665,7 +663,10 @@ public function getFeeDue() {
665663
curl_setopt($ch, CURLOPT_REFERER, "http://webstream.sastra.edu/sastrapwi/usermanager/home.jsp");
666664
$html = curl_exec($ch);
667665

668-
phpQuery::newDocument($html);
666+
/**
667+
* Parse the content
668+
*/
669+
phpQuery::newDocument($html);
669670
pq('tr:first')->remove();
670671
pq('tr:first')->remove();
671672

@@ -687,10 +688,6 @@ public function getFeeDue() {
687688
} else {
688689
return $this->authError();
689690
}
690-
} else
691-
die("Register Number or Password not set.");
691+
} else die("Register Number or Password not set.");
692692
}
693-
694693
}
695-
696-
?>

0 commit comments

Comments
 (0)
Please sign in to comment.