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'];
- $base_url = "https://studentportal.unpar.ac.id/";
- $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);
- $home = str_get_html($output);
- if($home->find("p[class=student-npm]") == null){
- header("Location: index.php");
- exit;
- }
- $npm = $home->find("p[class=student-npm]", 0)->text();
- $npm = str_replace(" / AKTIF", "", $npm);
- $name = $home->find("p[class=student-name]", 0)->text();
- $semester = $home->find(".main-info-semester", 0)->text();
- $semester = str_replace(" : KULIAH", "", $semester);
- $photo_url = $home->find("img", 0)->src;
- //ambil table jadwal yang sedang diambil semester tersebut
- $jadwal = $home->find("table[class=portal-full-table]", 0)->find("tr");
- $jadwal_kuliah = [];
- $countJadwal = 0;
- for ($i=2; $i < count($jadwal); $i++) {
- $jadwal_kuliah[$countJadwal] = [
- "kode" => $jadwal[$i]->find("td", 1)->text(),
- "matkul" => $jadwal[$i]->find("td", 2)->text(),
- "sks" => $jadwal[$i]->find("td", 3)->text(),
- ];
- $countJadwal++;
- }
- /** 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");
- $senin = [];
- $selasa = [];
- $rabu = [];
- $kamis = [];
- $jumat = [];
- $sabtu = [];
- $ctsenin = 0;
- $ctselasa = 0;
- $ctrabu = 0;
- $ctkamis = 0;
- $ctjumat = 0;
- $ctsabtu = 0;
- for($i = 0; $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);
- if ($kuliah_html[$i]->find("td", 7)->text() == "Senin") {
- $senin[$ctsenin] = [
- "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(),
- ];
- $ctsenin++;
- }
- }
- }
- 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);
- if ($kuliah_html[$i]->find("td", 7)->text() == "Selasa") {
- $selasa[$ctselasa] = [
- "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(),
- ];
- $ctselasa++;
- }
- }
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title></title>
- <link rel="stylesheet" href="bootstrap.css" charset="utf-8">
- <link rel="stylesheet" href="custom.css" charset="utf-8">
- <link rel="stylesheet" href="http://fullcalendar.io/js/fullcalendar-2.6.0/fullcalendar.css">
- </head>
- <body>
- <div class="container-fluid content">
- <div class="row">
- <div class="img-student col-xs-4">
- <?php echo "<img src=$base_url" . "$photo_url>"; ?>
- </div>
- <div class="col-xs-8">
- <?php
- echo "<h3>" . $name . "</h3>";
- echo "<h4>" . $npm . "</h4>";
- echo "<h5>" . $semester . "</h5>";
- ?>
- </div>
- </div>
- <div class="row">
- <div class="col-xs-12">
- <br>
- <?php
- echo "<table class='table table-striped table-condensed text-center'>";
- echo "<thead>";
- echo "<th class='text-center'>Kode Matakuliah</th>";
- echo "<th class='text-center'>Nama Matakuliah</th>";
- echo "<th class='text-center'>Sks</th>";
- echo "</thead>";
- echo "<tbody>";
- for ($i=0; $i < count($jadwal_kuliah); $i++) {
- echo "<tr>";
- echo "<td>";
- echo $jadwal_kuliah[$i]['kode'];
- echo "</td>";
- echo "<td>";
- echo $jadwal_kuliah[$i]['matkul'];
- echo "</td>";
- echo "<td>";
- echo $jadwal_kuliah[$i]['sks'];
- echo "</td>";
- echo "</tr>";
- }
- echo "</tbody>";
- echo "</table>";
- ?>
- </div>
- </div>
- <div class="row">
- <div class="col-xs-12">
- <?php
- echo $selasa;
- echo '<h3>Jadwal Kuliah</h3>';
- echo '<h5>Senin</h5>';
- echo "<table class='table table-striped table-condensed text-center'>";
- echo "<tbody>";
- for ($i=0; $i < count($senin); $i++) {
- echo "<tr>";
- echo "<td>";
- echo $senin[$i]['kode'];
- echo "</td>";
- echo "<td>";
- echo $senin[$i]['matkul'];
- echo "</td>";
- echo "</tr>";
- }
- echo "</tbody>";
- echo "</table>";
- echo '<h5>Selasa</h5>';
- echo "<table class='table table-striped table-condensed text-center'>";
- echo "<tbody>";
- for ($i=0; $i < count($selasa); $i++) {
- echo "<tr>";
- echo "<td>";
- echo $selasa[$i]['kode'];
- echo "</td>";
- echo "<td>";
- echo $selasa[$i]['matkul'];
- echo "</td>";
- echo "<td>";
- echo $selasa[$i]['sks'];
- echo "</td>";
- echo "</tr>";
- }
- echo "</tbody>";
- echo "</table>";
- ?>
- </div>
- </div>
- </div>
- </body>
- <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.1/fullcalendar.min.js"></script> -->
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement