Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require ("cijfercheck_pass.php");
- include ("postmessage.php");
- include 'vendor/autoload.php';
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, 'https://rapid.deltion.nl/user/login/');
- curl_setopt($ch, CURLOPT_POSTFIELDS,'username='.urlencode($login_email).'&password='.urlencode($login_pass).'&login=Login');
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/my_cookies.txt");
- curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/my_cookies.txt");
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
- curl_setopt($ch, CURLOPT_REFERER, "https://rapid.deltion.nl/student/info/");
- $page = curl_exec($ch);
- curl_setopt($ch, CURLOPT_URL,'https://rapid.deltion.nl/student/pdfresultaten/id/97041344/Luuk%20Wuijster.pdf');
- curl_setopt($ch, CURLOPT_POSTFIELDS,'btnresultatenpdf='.urlencode('pdf resultaten'));
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/my_cookies.txt");
- $result = curl_exec($ch);
- curl_close($ch);
- $destination = dirname(__FILE__) . '/pdf/temp.pdf';
- $file = fopen($destination, "w+");
- fputs($file, $result);
- fclose($file);
- function logdata($body){
- $time = date("d-m-Y H:i:s");
- $file = 'cijfercheck.log';
- $current = file_get_contents($file);
- $current .= "[${time}] ${body} \n";
- file_put_contents($file, $current);
- }
- if (file_exists('pdf/temp.pdf')) {
- logdata("temp.pdf gedownload van rapid.deltion.nl");
- } else {
- logdata("ERROR: kon temp.pdf niet downloaden van rapid.deltion.nl");
- die();
- }
- $parser = new \Smalot\PdfParser\Parser();
- $pdf1 = $parser->parseFile('pdf/cijferlijst.pdf');
- $pdf2 = $parser->parseFile('pdf/temp.pdf');
- $string1 = $pdf1->getText();
- $string2 = $pdf2->getText();
- $nospace1 = str_replace(' ', '', $string1);
- $nospace2 = str_replace(' ', '', $string2);
- $arr1 = explode(':', $nospace1);
- $arr2 = explode(':', $nospace2);
- $check = $arr1[5];
- $temp = $arr2[5];
- if (!empty($temp) OR !empty($check)) {
- logdata("pdf omgezet naar een array");
- } else {
- logdata("ERROR: was niet mogelijk om pdf om te zetten naar array");
- die();
- }
- if($check == $temp){
- if(unlink('pdf/temp.pdf')){
- logdata("temp.pdf is verwijderd");
- } else {
- logdata("ERROR: kon temp.pdf niet verwijderen");
- die();
- }
- } else {
- if(unlink('pdf/cijferlijst.pdf') && rename('pdf/temp.pdf', 'pdf/cijferlijst.pdf')){
- logdata("cijferlijst.pdf is verwijderd en temp.pdf is hernoemt naar cijferlijst.pdf");
- PostToSlack();
- } else {
- logdata("ERROR: kon cijferlijst.pdf niet verwijderen en/of kon temp.pdf niet hernoemen naar cijferlijst.pdf");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement