forked from pus2inbo2ts/mmubee-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmsAttendance.php
executable file
·82 lines (63 loc) · 3.07 KB
/
cmsAttendance.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
include 'config.php';
checkActive();
//https://cms.mmu.edu.my/psc/csprd/EMPLOYEE/HRMS/c/N_SELF_SERVICE.N_SM_EXAMSLIP_PNL.GBL
$arr = loginCms($sid, $cpw);
$cookie = implode(';', $arr['cookie']);
$html = get('https://cms.mmu.edu.my/psc/csprd/EMPLOYEE/HRMS/c/N_SR_STUDENT_RECORDS.N_SR_SS_ATTEND_PCT.GBL?FolderPath=PORTAL_ROOT_OBJECT.CO_EMPLOYEE_SELF_SERVICE.HCCC_ACADEMIC_RECORDS.HC_SSS_ATTENDANCE_PERCENT_GBL&IsFolder=false&IgnoreParamTempl=FolderPath%2cIsFolder', $cookie);
//get item sum.
preg_match_all("/<span class='PSGRIDCOUNTER' >.*of (.*)<\/span>/Us", $html, $content);
if(!isset($content[1][0])){
//get error
preg_match_all("/<DIV id='win0div\\\$ICField\\\$112\\\$'>(.*)<\/DIV>/Us", $html, $error);
//print_r($error);
$html = <<<html
<div class="card" style="margin-top:20px;">
<div class="item item-text-wrap item-body">
<div class="icon ion-sad" style="font-size:50px; text-align:center;"></div>
<br />
{$error[1][0]}
</div>
</div>
html;
ok(array('html'=>$html));
exit();
}
$sum = $content[1][0];
//get subject code
//<span class='PSEDITBOX_DISPONLY' id='N_STN_ENRL_SSVW_CATALOG_NBR$0'>2133</span>
preg_match_all("/<span class='PSEDITBOX_DISPONLY' id='N_STN_ENRL_SSVW_CATALOG_NBR\\\$\d*'>(.*)<\/span>/Us", $html, $code);
//<span class='PSEDITBOX_DISPONLY' id='N_STN_ENRL_SSVW_SUBJECT$0'>MPW</span>
preg_match_all("/<span class='PSEDITBOX_DISPONLY' id='N_STN_ENRL_SSVW_SUBJECT\\\$\d*'>(.*)<\/span>/Us", $html, $area);
$subjectCode = array();
foreach ($code[1] as $key => $value) {
$subjectCode[] = $area[1][$key].$value;
}
//<span class='PSEDITBOX_DISPONLY' id='N_SR_AT_PCT_WRK_DESCR1$0'>Lecture</span>
preg_match_all("/<span class='PSEDITBOX_DISPONLY' id='SSF_SS_CHRG_ACT_SSF_POSTED_DATE\\\$\d*'>(.*)<\/span>/Us", $html, $postDate);
preg_match_all("/<span class='PSEDITBOX_DISPONLY' id='N_SR_AT_PCT_WRK_DESCR\\\$\d*'>(.*)<\/span>/Us", $html, $name);
preg_match_all("/<span class='PSEDITBOX_DISPONLY' id='N_SR_AT_PCT_WRK_N_CURR_ATTND\\\$\d*'>(.*)<\/span>/Us", $html, $attendance);
preg_match_all("/<span class='PSEDITBOX_DISPONLY' id='N_SR_AT_PCT_WRK_N_ATTND_PERC\\\$\d*'>(.*)<\/span>/Us", $html, $barring);
preg_match_all("/<span class='PSEDITBOX_DISPONLY' id='N_SR_AT_PCT_WRK_DESCR1\\\$\d*'>(.*)<\/span>/Us", $html, $component);
/*
if(!isset($content[0][0])){
$debug = array('title'=>'MMUbee error: examtimetable #1', 'body'=>"ID: {$sid}\r\nPW: {$pw}\r\nMPW: {$mpw}\r\nCPW: {$cpw}\r\n");
err('Unable to processing raw data.', $debug);
exit();
}
*/
$html = '<style type="text/css">.item-body h2{ margin-top: 0px; margin-bottom: 7px; } .card .item{ min-height:0; }</style>';
for($i = 0; $i<$sum; $i++){
$html.="
<li class='item'>
<h2>".$name[1][$i]."</h2><br />
<p style='margin-top:-25px; color:rgb(52, 152, 219);'>
<span style='color:#4a6b82;'>".$subjectCode[$i]." - ".$component[1][$i]."</span><br />
Attendance ".$attendance[1][$i]."% <br />
Barring ".$barring[1][$i]."%
</p></li>
";
}
//print_r($subjectCode);
ok(array('html'=>$html));
?>