summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--main.php98
1 files changed, 57 insertions, 41 deletions
diff --git a/main.php b/main.php
index bcb1c3f..645be30 100644
--- a/main.php
+++ b/main.php
@@ -46,7 +46,7 @@ function get_string_between($string, $start, $end){
Errors:
-1 no login info
-2 not logged in
- -3 bad username or password
+ -3 bad password but user exists
-4 not written yet
-5 unable to create cookie dir
-6 non existing user
@@ -54,7 +54,7 @@ Errors:
class gimsisextClient {
private $username;
private $password;
- public $version = array(0, 7, 7);
+ public $version = array(0, 8, 0);
private $programname = "gimsisextclient";
private $programdomain = 'gimsisextclient.gimb.tk';
private $cookiedir; // set at runtime, ker je get_curerent_user, v login()
@@ -73,6 +73,7 @@ Errors:
private $gimsisextizbrisisporocilo = "https://zgimsis.gimb.org/gse/Page_Gim/Uporabnik/Sporocila.aspx/DeleteMessage";
private $gimsisextizostanki = "https://zgimsis.gimb.org/gse/Page_Gim/Ucenec/IzostankiUcenec.aspx";
private $gimsisextresetgeslo = "https://zgimsis.gimb.org/gse/ResetPassword.aspx";
+ private $gimsisextmodsporocilo = "https://zgimsis.gimb.org/gse/Page_Gim/Uporabnik/modSporocilo.aspx";
public function setusername($value) {
$this->username = $value;
}
@@ -495,54 +496,69 @@ Errors:
}
return $msgkat;
}
- public function fetchsporocilo($id) { // id formata ddddd|ddddd|d
+ public function fetchsporocilo($id) { // id formata ddddd|ddddd|d ali samo 1. sklop
$ch = $this->login();
if(!curl_getinfo($ch)) {
if(!empty($ch)){return $ch;}else{return -2;}
}
- curl_setopt($ch, CURLOPT_URL, $this->gimsisextsporocila);
+ curl_setopt($ch, CURLOPT_URL, $this->gimsisextmodsporocilo."?params=IdMsg%3D".explode("|", $id)[0]);
curl_setopt($ch, CURLOPT_POST, 0);
- $sporocilo_init_output = curl_exec($ch);
- $xmlDoc = new DOMDocument($sporocilo_init_output);
- $xmlDoc->loadHTML( $sporocilo_init_output );
- $searchNode = $xmlDoc->getElementsByTagName( "input" );
- foreach( $searchNode as $sn ) {
- if($sn->getAttribute('name') != 'ctl00$ContentPlaceHolder1$hfIdSporocilo') {
- $postvars .= urlencode($sn->getAttribute('name'))."=".urlencode($sn->getAttribute('value'))."&";
- }
- }
- curl_setopt($ch, CURLOPT_POST, 1);
- $postbody = $postvars . urlencode('ctl00$ContentPlaceHolder1$hfIdSporocilo') . '=' . urlencode($id);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $postbody);
$sporocilo_output = curl_exec($ch);
+ file_put_contents("/tmp/as.txt", $sporocilo_output);
$xmlDoc = new DOMDocument();
$xmlDoc->loadHTML( $sporocilo_output );
- $tabelaNode = $xmlDoc->getElementsByTagName( "table" );
- foreach($tabelaNode as $tn) {
- if ($tn->getAttribute("id") == "ctl00_ContentPlaceHolder1_gvwSporociloVrsta") {
- $msg = array();
- foreach ($tn->getElementsByTagName("tbody")[0]->getElementsByTagName("td") as $dn) {
- foreach($dn->getElementsByTagName('div') as $sn) {
- switch($sn->getAttribute("class")) {
- case "msgSubjectS":
- $msg['zadeva'] = str_replace("\n", null, str_replace("\r", null, str_replace(" ", null, str_replace("\t", null, DOMinnerHTML($sn)))));
- break;
- }
- }
- $msg['id'] = $id;
- foreach($dn->getElementsByTagName('div') as $divn) {
- if ($divn->getAttribute("class") == "msgInfo") {
- $msg['posiljatelj'] = explode(" (", DOMinnerHTML($divn->getElementsByTagName('span')[0]))[0];
- $msg['datum'] = explode(" ", get_string_between(DOMinnerHTML($divn->getElementsByTagName('span')[0]), "(", ")"))[0];
- $msg['ura'] = explode(" ", get_string_between(DOMinnerHTML($divn->getElementsByTagName('span')[0]), "(", ")"))[1];
- $msg['prejemnik'] = DOMinnerHTML($divn->getElementsByTagName('span')[1]);
- } elseif ($divn->getAttribute("class") == "gCursorAuto") {
- $msg['telo'] = explode("<hr>", DOMinnerHTML($divn))[0];
- }
- }
- }
- }
+ $textarea = DOMinnerHTML($xmlDoc->getElementById( "ctl00_ModalMasterBody_edtBesediloExt" ));
+ $zadeva = get_string_between($sporocilo_output, '<input name="ctl00$ModalMasterBody$edtZadeva" type="text" value="', '" id="ctl00_ModalMasterBody_edtZadeva" />');
+ $telo = get_string_between($textarea, "&lt;/span&gt;&lt;/p&gt;&lt;p&gt;", "&lt;/p&gt;\n");
+ $posiljatelj = get_string_between($textarea, "&gt;&lt;b&gt;Od&lt;/b&gt;: ", "&lt;br /&gt;&lt;b&gt;Poslano&lt;/b&gt;: "); // ne trudi se za prejemnika, gimsisglitch(C)12
+ $datumincas = get_string_between($textarea, "&lt;br /&gt;&lt;b&gt;Poslano&lt;/b&gt;: ", "&lt;br /&gt;&lt;b&gt;Za&lt;/b&gt;: "); // pazi, tale je za ljudi
+ $cas = explode(":", end(explode(" ", $datumincas)));
+ $datum['dan'] = intval(substr(explode(" ", $datumincas)[0], 0, -1)); // da ni .
+ $datum['mesecbeseda'] = explode(" ", $datumincas)[1];
+ $datum['leto'] = explode(" ", $datumincas)[2];
+ switch ($datum['mesecbeseda']) {
+ case "jan":
+ $datum['jsmesec'] = 0;
+ break;
+ case "feb":
+ $datum['jsmesec'] = 1;
+ break;
+ case "mar":
+ $datum['jsmesec'] = 2;
+ break;
+ case "apr":
+ $datum['jsmesec'] = 3;
+ break;
+ case "maj":
+ $datum['jsmesec'] = 4;
+ break;
+ case "jun":
+ $datum['jsmesec'] = 5;
+ break;
+ case "jul":
+ $datum['jsmesec'] = 6;
+ break;
+ case "avg":
+ $datum['jsmesec'] = 7;
+ break;
+ case "sep":
+ $datum['jsmesec'] = 8;
+ break;
+ case "okt":
+ $datum['jsmesec'] = 9;
+ break;
+ case "nov":
+ $datum['jsmesec'] = 10;
+ break;
+ case "dec":
+ $datum['jsmesec'] = 11;
+ break;
+ case "šubidubi":
+ $datum['jsmesec'] = 69; // yey, another easteregg!
+ break;
}
+ $datum['mesec'] = $datum['jsmesec']+1;
+ $msg = array("telo" => $telo, "zadeva" => $zadeva, "posiljatelj" => $posiljatelj, "datumincas" => array("opis" => $datumincas, "cas" => array("ura" => $cas[0], "minuta" => $cas[1]), "datum" => $datum));
return $msg;
}
public function posljisporocilo($prejemnikst, $zadeva, $telo) { // prejemnikst je zajeban dobit (za zdej)