Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include('simple_html_dom.php');
- $username = $_POST['username'];
- $password = $_POST['password'];
- $login_url = "https://studentportal.unpar.ac.id/home/index.login.submit.php";
- $cas_login_url = "https://cas.unpar.ac.id/login?service=https%3A%2F%2Fstudentportal.unpar.ac.id%2Flogin.submit.php";
- $cas_url = "https://cas.unpar.ac.id";
- $ch = curl_init();
- /** GET TOKEN **/
- curl_setopt($ch, CURLOPT_URL, $login_url);
- curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.103 Safari/537.36");
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLINFO_HEADER_OUT, true);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, "Submit=Login");
- curl_setopt($ch, CURLOPT_COOKIEFILE, dirname( __FILE__ ) . '/cookie');
- curl_setopt($ch, CURLOPT_COOKIEJAR, dirname( __FILE__ ) . '/cookiejar');
- $output = curl_exec($ch);
- $html = str_get_html($output);
- /** LOGIN CAS **/
- $action_url = $html->find("form", 0)->attr["action"];
- $lt = $html->find("input[name=lt]", 0)->attr["value"];
- $execution = $html->find("input[name=execution]", 0)->attr["value"];
- $eventId = $html->find("input[name=_eventId]", 0)->attr["value"];
- $data = ("username=$username&password=$password<=$lt&execution=$execution&_eventId=$eventId");
- // $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $cas_url . $action_url);
- curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.103 Safari/537.36");
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_COOKIEFILE, dirname( __FILE__ ) . '/cookie');
- curl_setopt($ch, CURLOPT_COOKIEJAR, dirname( __FILE__ ) . '/cookiejar');
- $output = curl_exec($ch);
- $html = str_get_html($output);
- if($html->find("p[class=student-npm]") == null){
- header("Location: index.php");
- exit;
- }
- $npm = $html->find("p[class=student-npm]", 0)->text();
- $npm = str_replace(" / AKTIF", "", $npm); //20123730007 / AKTIF
- /** LOAD JADWAL **/
- // curl_setopt($ch, CURLOPT_URL, "https://studentportal.unpar.ac.id/includes/jadwal.aktif.php");
- // curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.103 Safari/537.36");
- // $output = curl_exec($ch);
- // $html = str_get_html($output);
- //POST https://studentportal.unpar.ac.id/includes/jadwal.kuliah.php
- //data: npm, thn_akd, sem_akd
- // $thn_akd_html = $html->find("select[id=tahun_akd_sec]");
- // $thn_akds = [];
- // foreach($thn_akd_html as $thn_akd_data){
- // $thn_akds[] = [
- // 'thn_akd' => '',
- // 'sem_akd' => '',
- // ];
- // }
- /** GET URL SEMESTER LALU **/
- $data = "npm=$npm&thn_akd=2015&sem_akd=2";
- curl_setopt($ch, CURLOPT_URL, "https://studentportal.unpar.ac.id/includes/jadwal.kuliah.php");
- curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.103 Safari/537.36");
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_COOKIEFILE, dirname( __FILE__ ) . '/cookie');
- curl_setopt($ch, CURLOPT_COOKIEJAR, dirname( __FILE__ ) . '/cookiejar');
- $output = curl_exec($ch);
- $html = str_get_html($output);
- $kuliah_html = $html->find("table[class=portal-full-table]", 0)->find("tr");
- $kuliah = [];
- $ct = 0;
- for($i = 2; $i < count($kuliah_html)-1; $i++){
- if($kuliah_html[$i]->find("td") != null){
- $date = str_replace(".", ":", $kuliah_html[$i]->find("td", 8)->text());
- $date = explode("-", $date);
- $kuliah[$ct] = [
- "kode" => $kuliah_html[$i]->find("td", 1)->text(),
- "matkul" => $kuliah_html[$i]->find("td", 2)->text(),
- "sks" => $kuliah_html[$i]->find("td", 3)->text(),
- "kelas" => $kuliah_html[$i]->find("td", 4)->text(),
- "dosen" => $kuliah_html[$i]->find("td", 5)->text(),
- "hari" => $kuliah_html[$i]->find("td", 7)->text(),
- "waktu" => $kuliah_html[$i]->find("td", 8)->text(),
- "ruang" => $kuliah_html[$i]->find("td", 9)->text(),
- ];
- if($kuliah[$ct]["kode"] == ""){
- $kuliah[$ct]["kode"] = $kuliah[$ct - 1]["kode"];
- }
- if($kuliah[$ct]["matkul"] == ""){
- $kuliah[$ct]["matkul"] = $kuliah[$ct - 1]["matkul"];
- }
- $kuliah[$ct]["title"] = $kuliah[$ct]["matkul"];
- switch($kuliah_html[$i]->find("td", 7)->text()){
- case "Senin":
- $kuliah[$ct]["start"] = "2016-02-08T$date[0]:00";
- $kuliah[$ct]["end"] = "2016-02-08T$date[1]:00";
- break;
- case "Selasa":
- $kuliah[$ct]["start"] = "2016-02-09T$date[0]:00";
- $kuliah[$ct]["end"] = "2016-02-09T$date[1]:00";
- break;
- case "Rabu":
- $kuliah[$ct]["start"] = "2016-02-10T$date[0]:00";
- $kuliah[$ct]["end"] = "2016-02-10T$date[1]:00";
- break;
- case "Kamis":
- $kuliah[$ct]["start"] = "2016-02-11T$date[0]:00";
- $kuliah[$ct]["end"] = "2016-02-11T$date[1]:00";
- break;
- case "Jumat":
- $kuliah[$ct]["start"] = "2016-02-12T$date[0]:00";
- $kuliah[$ct]["end"] = "2016-02-12T$date[1]:00";
- break;
- case "Sabtu":
- $kuliah[$ct]["start"] = "2016-02-13T$date[0]:00";
- $kuliah[$ct]["end"] = "2016-02-13T$date[1]:00";
- break;
- case "":
- $kuliah[$ct]["start"] = "2016-02-08T$date[0]:00";
- $kuliah[$ct]["end"] = "2016-02-08T$date[1]:00";
- break;
- }
- $ct++;
- }
- }
- $kuliah = json_encode($kuliah);
- ?>
- <!DOCTYPE>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title></title>
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
- <script type="text/javascript" src="http://fullcalendar.io/js/fullcalendar-2.6.0/lib/moment.min.js"></script>
- <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.6.0/fullcalendar.min.js"></script>
- <script type="text/javascript">
- $(document).ready(function(){
- $("#calendar").fullCalendar({
- defaultView: "agendaWeek",
- minTime: "07:00:00",
- maxTime: "19:00:00",
- events: <?php echo $kuliah ?>
- });
- })
- </script>
- <link rel="stylesheet" href="http://fullcalendar.io/js/fullcalendar-2.6.0/fullcalendar.css">
- </head>
- <body>
- <div class="" id="calendar">
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement