diff options
author | Anton Luka Šijanec <sijanecantonluka@gmail.com> | 2020-03-01 00:50:46 +0100 |
---|---|---|
committer | Anton Luka Šijanec <sijanecantonluka@gmail.com> | 2020-03-01 00:50:46 +0100 |
commit | 81d7453d4c5b15f8ccc03b0f8ec668ca31b367f7 (patch) | |
tree | fc4d602c83057c87da245c103e39d75e41c350cb /main.php | |
parent | added spremenigeslo (diff) | |
download | gimsisextclient-81d7453d4c5b15f8ccc03b0f8ec668ca31b367f7.tar gimsisextclient-81d7453d4c5b15f8ccc03b0f8ec668ca31b367f7.tar.gz gimsisextclient-81d7453d4c5b15f8ccc03b0f8ec668ca31b367f7.tar.bz2 gimsisextclient-81d7453d4c5b15f8ccc03b0f8ec668ca31b367f7.tar.lz gimsisextclient-81d7453d4c5b15f8ccc03b0f8ec668ca31b367f7.tar.xz gimsisextclient-81d7453d4c5b15f8ccc03b0f8ec668ca31b367f7.tar.zst gimsisextclient-81d7453d4c5b15f8ccc03b0f8ec668ca31b367f7.zip |
Diffstat (limited to 'main.php')
-rw-r--r-- | main.php | 68 |
1 files changed, 67 insertions, 1 deletions
@@ -1,4 +1,24 @@ <?php +function build_data_files($boundary, $fields, $files){ + $data = ''; + $eol = "\r\n"; + $delimiter = '-------------' . $boundary; + foreach ($fields as $name => $content) { + $data .= "--" . $delimiter . $eol + . 'Content-Disposition: form-data; name="' . $name . "\"".$eol.$eol + . $content . $eol; + } + foreach ($files as $name => $content) { + $data .= "--" . $delimiter . $eol + . 'Content-Disposition: form-data; name="undefined"; filename="' . $name . '"' . $eol + . 'Content-Type: '.$content[1].$eol + ; + $data .= $eol; + $data .= $content[0] . $eol; + } + $data .= "--" . $delimiter . "--".$eol; + return $data; +} function strip_tags_content($text, $tags = '', $invert = FALSE) { preg_match_all('/<(.+?)[\s]*\/?[\s]*>/si', trim($tags), $tags); $tags = array_unique($tags[1]); @@ -504,7 +524,7 @@ Errors: curl_setopt($ch, CURLOPT_POST, 0); $sporocilo_output = curl_exec($ch); $zadeva = html_entity_decode(get_string_between($sporocilo_output, '<input name="ctl00$ModalMasterBody$edtZadeva" type="text" value="', '" id="ctl00_ModalMasterBody_edtZadeva" />')); - $telo = html_entity_decode(html_entity_decode(get_string_between($sporocilo_output, "</span></p>", "</textarea>"))); + $telo = html_entity_decode(html_entity_decode(html_entity_decode(get_string_between($sporocilo_output, "</span></p>", "</textarea>")))); $posiljatelj = html_entity_decode(html_entity_decode(get_string_between($sporocilo_output, "><b>Od</b>: ", "<br /><b>Poslano</b>: "))); // ne trudi se za prejemnika, gimsisglitch(C)12 $datumincas = get_string_between($sporocilo_output, "<br /><b>Poslano</b>: ", "<br /><b>Za</b>: "); // pazi, tale je za ljudi $cas = explode(":", end(explode(" ", $datumincas))); @@ -580,6 +600,52 @@ Errors: $posljisporocilo_output = curl_exec($ch); return; } + public function posljisporocilonov($prejemnikst, $zadeva, $telo, $file = null, $filemime = null, $filename = null) { // prejemnikst je zajeban dobit (za zdej) + $ch = $this->login(); + if(!curl_getinfo($ch)) { + if(!empty($ch)){return $ch;}else{return -2;} + } + curl_setopt($ch, CURLOPT_POST, 0); + curl_setopt($ch, CURLOPT_URL, $this->gimsisextposljisporocilo); + $posljisporocilo_init_output = curl_exec($ch); + $xmlDoc = new DOMDocument($posljisporocilo_init_output); + $xmlDoc->loadHTML( $posljisporocilo_init_output ); + $searchNode = $xmlDoc->getElementsByTagName( "input" ); + $postfields = array(); + foreach( $searchNode as $sn ) { + if($sn->getAttribute("name") == 'ctl00$ModalMasterBody$edtPrejemniki') { + } else if($sn->getAttribute("name") == 'ctl00$ModalMasterBody$edtZadeva') { + } else if($sn->getAttribute("name") == 'ctl00$ModalMasterBody$edtBesediloExt'){ + } else if ($sn->getAttribute("name") == 'ctl00$ModalMasterBody$hfPrejemniki') { + } else { + $postfields[urlencode($sn->getAttribute("name"))] = urlencode($sn->getAttribute('value')); + } + } + $postfields['ctl00$ModalMasterBody$edtBesediloExt'] = $telo; + $postfields['ctl00$ModalMasterBody$hfPrejemniki'] = $prejemnikst; + $postfields['ctl00$ModalMasterBody$edtZadeva'] = $zadeva; + $postfields['ctl00$ModalMasterBody$edtPrejemniki'] = ""; + if(!empty($file) && !empty($filemime) && !empty($filename)) { + $files = array($filename => array($file, $filemime)); + } else { + $files = array(); + } + $postfields["__EVENTTARGET"] = "ctl00%24ModalMasterBody%24btnDogodekShrani"; + $postfields["__EVENTARGUMENT"] = ""; + $boundary = time(); + $delimiter = '-------------' . $boundary; + $post_data = build_data_files($boundary, $postfields, $files); + curl_setopt($ch, CURLOPT_POST, 1); + curl_setopt($ch, CURLOPT_HEADER, array( + "Content-Type: multipart/form-data; boundary=".$delimiter + )); + curl_setopt($ch, CURLOPT_URL, $this->gimsisextposljisporocilo); + curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); + $posljisporocilo_output = curl_exec($ch); + file_put_contents("/tmp/12.html", $posljisporocilo_output); + file_put_contents("/tmp/12.txt", $post_data); + return; + } public function setgeslo($geslo, $spremenigeslovobjektu = true) { // geslo $ch = $this->login(); if(!curl_getinfo($ch)) { |