From 60e2f0dfc8dd291991f2e6183819d33d249c85e8 Mon Sep 17 00:00:00 2001 From: franzz Date: Tue, 28 Oct 2014 01:03:01 +0100 Subject: [PATCH] trying getting note through pdf --- inc/note.php | 23 ++++++++++++++++++----- masks/note.html | 2 +- 2 files changed, 19 insertions(+), 6 deletions(-) mode change 100644 => 100755 inc/note.php mode change 100644 => 100755 masks/note.html diff --git a/inc/note.php b/inc/note.php old mode 100644 new mode 100755 index a6b143d..0386132 --- a/inc/note.php +++ b/inc/note.php @@ -19,6 +19,19 @@ class Note extends PhpObject $sContent = ''; if($this->sNote!='') { + $this->sUrl = 'http://service.sap.com/sap/support/notes/convert2pdf/000'.$this->sNote.'?sap-language=EN'; + $sContent = $this->getPageRecursive(); + + header('Content-Description: File Transfer'); + header('Content-type: application/pdf'); + header('Content-Disposition: inline; filename="note_'.$this->sNote.'.pdf"'); + header('Content-Transfer-Encoding: binary'); + header('Expires: 0'); + header('Content-Length: '.strlen($sContent)); + header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); + header('Pragma: public'); + + /* $this->sUrl = 'http://service.sap.com/sap/support/notes/'.$this->sNote; $this->getPageRecursive(); $sSapPath = substr($this->sUrl, 0, strpos($this->sUrl, '/bc/bsp/sno/ui_entry/entry.htm')); @@ -47,7 +60,7 @@ class Note extends PhpObject //Deleting auto resize //$sContent = str_replace('lv_diff = 210','lv_diff = 0', $sContent); $sContent = str_replace(array('setHeight();', 'window.onresize = setHeight; '), '', $sContent); - + */ } else $this->addError('Empty note number'); @@ -71,8 +84,8 @@ class Note extends PhpObject private function getPageRecursive() { - $sheader = $this->getPage(true); - $asLines = explode("\n", $sheader); + $sHeader = $this->getPage(true); + $asLines = array_filter(explode("\n", $sHeader)); foreach($asLines as $sLine) $asInfo[strtolower(strstr($sLine, ':', true))] = trim(substr(strstr($sLine, ':'), 1)); if(array_key_exists('set-cookie', $asInfo)) $this->parseSetCookie($asInfo['set-cookie']); @@ -83,7 +96,7 @@ class Note extends PhpObject $this->sUrl = ((substr($asInfo['location'], 0, 4)!='http')?self::getDomain($this->sUrl):'').$asInfo['location']; return $this->getPageRecursive(); } - else return substr($sheader, strpos($sheader, '')); + else return implode("\n", $asLines); } private function parseSetCookie($sCookie) @@ -94,7 +107,7 @@ class Note extends PhpObject //Parse FIXME $asCookieInfo = explode('; ', $sCookie); foreach($asCookieInfo as $sCookieInfo) $asCookie[strstr($sCookieInfo, '=', true)] = substr(strstr($sCookieInfo, '='), 1); - setcookie('sap-appcontext', $asCookie['sap-appcontext'], time()+3600, $asCookie['path']); + if(array_key_exists('sap-appcontext', $asCookie)) setcookie('sap-appcontext', $asCookie['sap-appcontext'], time()+3600, $asCookie['path']); } private function getCredentials() diff --git a/masks/note.html b/masks/note.html old mode 100644 new mode 100755 index e909b04..82dd882 --- a/masks/note.html +++ b/masks/note.html @@ -23,7 +23,7 @@ databap.pageInit = function() if(isNumeric(iNote) && iNote > 0 && iNote!=databap.tmp('note')) { $('#note_id').val(iNote).focus(); - self.addBufferIcon(); + //self.addBufferIcon(); $('#note_frame').attr('src', 'index.php?a=note&id='+iNote); databap.tmp('note', iNote); }