PHP rocks! wünscht allen Mitgliedern einen guten Rutsch ins neue Jahr 2017 !!!
Hinweis: Das Forum zieht um! Um keine Datenverluste zu haben, schalten wir zwecks Übernahme der Daten das Forum am Sonntag, den 24.04.2016 um ca. 21:00 Uhr offline und passen anschliessend die DNS-Einträge an.
www.php-rocks.de wird euch dann nach den Aktualisierungen der DNS-Server wieder wie gewohnt uneingeschränkt zur Verfügung stehen.
Danke für euer Verständnis!

Hallo, Gast
Du musst dich registrieren bevor du auf unserer Seite Beiträge schreiben kannst.

Benutzername/E-Mail:
  

Passwort
  





Durchsuche Foren

(Erweiterte Suche)

Foren-Statistiken
» Mitglieder: 290
» Neuestes Mitglied: zacharymurphy
» Foren-Themen: 169
» Foren-Beiträge: 899

Komplettstatistiken

Aktive Themen
PHPMailer Pfad wird nicht...
Forum: PHP Basics
Letzter Beitrag: Arne Drews
23.08.2022, 21:07
» Antworten: 5
» Ansichten: 2.718
PHP 8.1: Endlich Enums in...
Forum: PHP Basics
Letzter Beitrag: Arne Drews
22.04.2021, 16:55
» Antworten: 1
» Ansichten: 2.619
Einfache Template Engine
Forum: PHP Template Engines
Letzter Beitrag: Arne Drews
22.04.2021, 16:49
» Antworten: 4
» Ansichten: 10.913
OAuth - Should I "scrambl...
Forum: Off Topic
Letzter Beitrag: Till
05.01.2020, 04:55
» Antworten: 0
» Ansichten: 7.747
"Invisible" Captcha
Forum: PHP Basics
Letzter Beitrag: Arne Drews
11.12.2019, 15:00
» Antworten: 5
» Ansichten: 10.289
Projektvorstellung - Test...
Forum: Off Topic
Letzter Beitrag: Till
22.11.2019, 20:03
» Antworten: 3
» Ansichten: 5.570
POST/GET routes deklarier...
Forum: PHP Basics
Letzter Beitrag: Till
14.11.2019, 19:44
» Antworten: 2
» Ansichten: 4.604
PHPMailer
Forum: PreComposed
Letzter Beitrag: Arne Drews
20.10.2019, 12:44
» Antworten: 6
» Ansichten: 8.447
Twig TemplateEngine
Forum: PreComposed
Letzter Beitrag: Arne Drews
29.08.2019, 14:21
» Antworten: 0
» Ansichten: 3.279
SwiftMailer
Forum: PreComposed
Letzter Beitrag: Arne Drews
28.08.2019, 10:19
» Antworten: 0
» Ansichten: 3.454

 
  Fehler in script/module loader
Geschrieben von: Till - 19.03.2017, 20:25 - Forum: JavaScript / JavaScript Frameworks / Ajax - Antworten (1)

Hallo,
ich habe ein kleines Problem, ich versuche es so gut es geht zu erklären.

Ich habe einen module loader https://github.com/frdl/-Flow/blob/master/api-d/4/js-api/library.js/core/plugin.core.js#L13675 dieser funktioniert soweit auch bisher wunderprächtig, bis auf diese eine Datei:

http://cdn.frdl.webfan.de/cdn/frdl/flow/components/webfan/workspace/js/win.js bzw. http://cdn.frdl.webfan.de/cdn/frdl/flow/components/webfan/workspace/js/win.js?minify=no

Ohne diesen Hack:
https://github.com/frdl/-Flow/blob/master/api-d/4/js-api/library.js/core/plugin.core.js#L13865
https://github.com/frdl/-Flow/blob/master/api-d/4/js-api/library.js/core/plugin.core.js#L14039
wird die datei win.js nicht richtig geladen, wenn ich die seite ein zweites mal(!) öffne.

Nach dem ersten Aufruf wird das javascript gespeichert: https://github.com/frdl/-Flow/blob/master/api-d/4/js-api/library.js/core/plugin.core.js#L14970
Wenn die Seite wieder geladen wird sollte win.js aus dem cache kommen: https://github.com/frdl/-Flow/blob/master/api-d/4/js-api/library.js/core/plugin.core.js#L14896
Dabei tritt der Fehler auf.

Ich bekomme derzeit noch keine debug Meldung, ich merke nur das der Seitenaufbau nicht weiter geht.

Hat jemand einen Tipp?

mfg
Till

P.S.: $.frdlWin sollte eigentlich über $.lazy Plugin geladen werden https://github.com/frdl/-Flow/blob/master/api-d/4/js-api/library.js/core/plugin.core.js#L15603
ich habe es aber auch ohne $.lazy ausprobiert, und es scheint so, als wenn beim deserialisieren des win.js ein Fehler auftritt?

P.S.: Hab datei und header explizit auf utf-8 gesetzt, leider ohne Erfolg.

Drucke diesen Beitrag

  <select> Dropdown fehlerhaft im IE
Geschrieben von: elysium - 15.03.2017, 22:58 - Forum: HTML & CSS - Antworten (3)

Hallo zusammen,

da ich ja gerade brav HTML/CSS lerne, hab ich wieder Ärger mit der Darstellung.

Ich habe, den ganzen Abend über, dieses Formular gebaut:
Formular zum rechnen

Im Chrome und im Firefox schaut alles gleich aus, genau wie ich es möchte.

Der IE11 verschiebt den Button unten leicht nach rechts und das Dropdown-Menü öffnet sich nicht schön nach unten sondern hüpft irgendwie mittig nach oben (schwer zu beschreiben) Huh .

Weiß jemand wie ich das im IE vernünftig anpassen kann?

Gruß,

elysium

Drucke diesen Beitrag

  Gehackter Webspace
Geschrieben von: Lupus_III - 04.03.2017, 18:06 - Forum: Webserver - Antworten (2)

Hallo Arne,

ich möchte Deine Aufforderung gerne annehmen und hier bin ich.

Mein Text im Forum für Webmaster war folgender:

Zum besseren Verständnis muss ich jetzt doch etwas mehr ausführen.

Ich habe die Webseite zur Betreuung Ende Oktober 2016 übernommen, nachdem, wie erwähnt, der Hoster sie gesperrt hatte. Zu dieser Zeit lief auf dem Webserver eine Joomla-Website. Die Software war jahrelang nicht upgedated worden! In den Dateien waren u.a. etwa 500 Troyaner!!

Ich habe eine neue Webseite selbst in HTML und CSS gebaut und mit deiner Hilfe, Arne, auch das Webcam-Problem gelöst. Diese Website ist aktuell auf dem Webserver installiert. Sie beinhaltet neben dem von mir erstellten HTML- und CSS-Code zwei Formulare von http://www.gratis-kontaktformular.de und ein Suchformular von Google und die folgenden Scripte
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.menubutton').click(function() {
$('nav').slideToggle('slow');
});
});
</script>

Der neuerliche Angriff ist für mich überraschend, weil jetzt PHP-Dateien mit Datum 16.10.2016 zum Vorschein kommen, obwohl ich Ende Oktober 2016 alles aufgeräumt habe.

Ich benutze für die Übertragung der Dateien auf den Webserver die Software PSFtp.

Zitat von Arne: Generell solltest Du - wie bereits getan - alle FTP-Passwörter neu setzen ( "sichere" Passwörter! ) und je nachdem, welche Serversoftware Du einsetzt etwas wie die Postausganskontrolle ( Plesk ) einsetzen. Damit kannst Du auf Domain und Postfach Ebene eingrenzen, wie viele Mails stdl. versendet werden dürfen. Wird die Grenze überschritten, bekommst Du eine Meldung und kannst weitere ausgehende Mails für den Verursacher ( Domain oder Postfach ) autom. sperren.

Kannst du das Thema Postausgangskontrolle etwas näher beschreiben?

Zitat von Arne: Dazu könnte ich Dir ein kleines Script zur Verfügung stellen, mit dem Du alle vhosts ( sollte es mehrere geben ) auf dem Server scannen kannst und erhältst eine Liste mit allen Verzeichnissen und Dateien, die aktuell vorhanden sind. Ich habe das für mich erweitert, so dass ich alle zwei Stunden eine Meldung bekommen würde, wenn Dateien dazu gekommen sind. Bestimmte Dateiendungen kann ich dabei ausschliessen, um nicht permanent mich nur um Warnungen kümmern zu müssen.

Das würde ich gerne einsetzen.

Drucke diesen Beitrag

  DIV zentrieren
Geschrieben von: elysium - 28.02.2017, 20:53 - Forum: HTML & CSS - Antworten (5)

Hallo zusammen,

nun ist es soweit, ich hänge fest  Confused  .

Ich soll mir 3 "Layouts" ausdenken in denen ich DIVs verschachteln soll.
Nun habe ich mir wohl etwas zu schweres ausgedacht  Big Grin  .

Ich wollte eine umgedrehte Pyramide mit DIVs bauen in denen jeweils 2 weitere DIVs ineinander verschachtelt sind.
Das habe ich sogar hinbekommen  Cool  .

Der innerste DIV (im Code .container8) reagiert aber leider auf keine vertikalen Margin-Befehle.
Ich möchte den schön mittig haben, wie der DIV in dem er steckt (.container7).

Hab alle möglichen Schreibweisen versucht, sogar mit padding bei Container7 habe ich es versucht (da sprengt es das Layout).

Ich weiß nicht mehr weiter  Huh  .

Anbei der Code:

Code:
<!DOCTYPE html>
<html lang="de">
   
   <head>
       <meta charset="utf-8">
       <title>Aufgabe 01</title>
       <style type="text/css">
           #wrapper{
               width: 700px;
               height: 400px;
               margin: 0 auto;
           }
           /* Oben - Links - Blau */
           #container1{
               background: blue;
               width: 200px;
               height: 100px;
               margin-right: 50px;
               float: left;
           }
           /* Oben - Mitte - Grün */
           #container2{
               background: green;
               width: 200px;
               height: 100px;
               float: left;
           }
           /* Oben - Rechts - Gelb */
           #container3{
               background: yellow;
               width: 200px;
               height: 100px;
               margin-left: 50px;
               float: left;
           }
           /* Mitte - Links - Grau */
           #container4{
               background: gray;
               width: 200px;
               height: 100px;
               margin: 50px 25px 50px 125px;
               float: left;
           }
           /* Mitte - Rechts - Gold */
           #container5{
               background: gold;
               width: 200px;
               height: 100px;
               margin: 50px 125px 50px 25px;
               float: left;
           }
           /* Unten - Links - Violet */
           #container6{
               background: blueviolet;
               width: 200px;
               height: 100px;
               margin: 0 250px;
               float: left;
           }
           /* Überall - Innen - Dunkelrot */
           .container7{
               background: darkred;
               width: 100px;
               height: 50px;
               margin: 25px auto;
           }
           /* Überall - Innen - Schwarz */
           .container8{
               background: black;
               width: 50px;
               height: 30px;
               margin-top: 10px;
               margin-left: 25px;
           }
       </style>
   </head>

   <body>
       <div id="wrapper">
           <div id="container1">
               <div class="container7">
                   <div class="container8"></div>
               </div><!-- Ende container7 -->
           </div><!-- Ende container1 -->
           <div id="container2">
               <div class="container7">
                   <div class="container8"></div>
               </div><!-- Ende container7 -->
           </div><!-- Ende container2 -->
           <div id="container3">
               <div class="container7">
                   <div class="container8"></div>
               </div><!-- Ende container7 -->
           </div><!-- Ende container3 -->
           <div id="container4">
               <div class="container7">
                   <div class="container8"></div>
               </div><!-- Ende container7 -->
           </div><!-- Ende container4 -->
           <div id="container5">
               <div class="container7">
                   <div class="container8"></div>
               </div><!-- Ende container7 -->
           </div><!-- Ende container5 -->
           <div id="container6">
               <div class="container7">
                   <div class="container8"></div>
               </div><!-- Ende container7 -->
           </div><!-- Ende container6 -->
       </div><!-- Ende wrapper -->
   </body>

</html>

Drucke diesen Beitrag

  Self-executing php without Phar
Geschrieben von: Till - 12.02.2017, 19:58 - Forum: Code Goodies - Antworten (6)

Hallo @all,
the common way to create self-executing php scripts is to use Phar.

Auf manchen shared-hosts oder älteren compilationen steht dieses nicht zur Verfügung.
Deshalb möchte ich meine Alternative präsentieren, sie basiert auf dem MIME 1.0 protokoll bzw. dem multipart/mixed Content-Type.

Das Script ist auch als gist verfügbar und befindet sich auch im Anhang dieses Postings.
Das frdl/webfan package dient als Live Example Beispiel: http://www.webfan.de/install/


Anmerkung: Wer sich für den "common way" mit phar entscheidet, für den ist vielleicht dieses package interessant: https://packagist.org/packages/phine/phar



Wie das .phar Format auch, macht das script Gebrauch von der Anweisung

PHP-Code:
 __halt_compiler 


Wenn dieser Token in einer Datei vorkommt, wird alles nachfolgende vom php-compiler ignoriert.
Dies erlaubt uns an eine .php Datei beliebiege Daten anzuhägen ohne einen parse error zu verursachen.

Die php Constant
PHP-Code:
__COMPILER_HALT_OFFSET__ 
hilft uns dabei die Daten, bzw. die Position der angehängten Daten in der php Datei zu finden.


Unser script speichert die Daten im Anhang als MIME mutlipart/mixed Format.
Die Dateien im ersten multipart mit dem Content-Type

PHP-Code:
        'application/vnd.frdl.script.php' => '_run_php_1',
 
        'application/php' => '_run_php_1',
 
        'text/php' => '_run_php_1',
 
        'php' => '_run_php_1',
 
        'multipart/mixed' => '_run_multipart',
 
        'multipart/serial' => '_run_multipart',
 
        'multipart/related' => '_run_multipart',
 
        'application/x-httpd-php' => '_run_php_1'

werden entsprechend als php ausgeführt.




In der Vorlage-Datei bootstrap.php befindet sich die Passage

PHP-Code:
spl_autoload_register(array($this,'Autoload'), truetrue); 

Dies installiert einen Autolader welcher Klassen nach einem vorgegebenen Schema direkt aus der Mime Datei lädt.
Siehe script und method Autolad Wink .



Create the script

Um ein self-executing script zu erstellen lade eine Instanz der MIME-VM z.B. per autoloader oder vorherigem include in eine Variable z.B. $vm:

PHP-Code:
    $vm = \webfan\MimeStubAPC::vm(); 

Get a file within $vm

PHP-Code:
$vm->get_file($vm->document'$HOME/index.php''stub index.php'

Clear its contents

PHP-Code:
$vm->get_file($vm->document'$HOME/index.php''stub index.php')
 
 ->clear() 

Clear its contents and then append something

PHP-Code:
$vm->get_file($vm->document'$HOME/index.php''stub index.php')
 
 ->clear()
 
 ->append(file_get_contents($SDIR.'stub'.DIRECTORY_SEPARATOR.'HOME'DIRECTORY_SEPARATOR .'index.php' ))


Wenn man die $vm fertig bearbeitet hat kann man das resultierende self-executing php script ganz einfach abspeichern mit

PHP-Code:
$vm->location __DIR__DIRECTORY_SEPARATOR'newscript.php'



@ToDo: Der MIME-Parser ist derzeit nicht memory optimiert und es kann bei größeren Anhängen das memory limit überschritten werden. Es sollten zunächst nur die Datei-Header eingelesen werden um dies zu vermeiden.





PHP-Code:
<?php
/**
 * Copyright  (c) 2017, Till Wehowski
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of frdl/webfan nor the
 *    names of its contributors may be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY frdl/webfan ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL frdl/webfan BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * 
 */
namespace webfan;
use 
frdl;
define('___BLOCK_WEBFAN_MIME_VM_RUNNING_STUB___'true);



 
$run = function($file null){
     
$args func_get_args();
     
header_remove();
     
$MimeVM = new MimeVM($args[0]);
     
$MimeVM('run');
     return 
$MimeVM;
 };
 
 
$included_files get_included_files();  
if(!___BLOCK_WEBFAN_MIME_VM_RUNNING_STUB___ && !in_array(__FILE__$included_files) || __FILE__===$included_files[0]) {
 
   $run(__FILE__);


 
 

class Context
{
    
}


class 
Env
{
    
}


class 
Response
{
    
}





 class 
MimeVM
 
{
     
     
     public 
$e_level E_USER_ERROR;
     
     protected 
$Request false;
 
     protected $Response false;    
     
     protected 
$raw false;
     protected 
$MIME false;
     
     protected 
$__FILE__ false;
     protected 
$buf;
     
     
//stream
     
protected $IO false;
     protected 
$file false;
     protected 
$host false;
     protected 
$mode false;
     protected 
$offset false;
     
     
     protected 
$Context false;     
     protected 
$Env false;
     
     protected 
$initial_offset 0;
     
     protected 
$php = array();

 
 
   protected $mimes_engine = array(
 
        'application/vnd.frdl.script.php' => '_run_php_1',
 
        'application/php' => '_run_php_1',
 
        'text/php' => '_run_php_1',
 
        'php' => '_run_php_1',
 
        'multipart/mixed' => '_run_multipart',
 
        'multipart/serial' => '_run_multipart',
 
        'multipart/related' => '_run_multipart',
 
        'application/x-httpd-php' => '_run_php_1',
 
   );

    protected function 
_run_multipart($_Part){

             foreach( 
$_Part->getParts() as $pos => $part){
                 if(isset(
$this->mimes_engine[$part->getMimeType()])){
                    
call_user_func_array(array($this$this->mimes_engine[$part->getMimeType()]), array($part));
                }
 
           }

    }

 
     protected function runStubs(){
        
//echo $this->document;
    //    return;
     
 foreach$this->document->getParts() as $rootPos => $rootPart){
 
         if($rootPart->isMultiPart())    {
             foreach( 
$rootPart->getParts() as $pos => $part){
                 if(isset(
$this->mimes_engine[$part->getMimeType()])){
                    
call_user_func_array(array($this$this->mimes_engine[$part->getMimeType()]), array($part));
                }
 
           }
         
 }
         
 break;
 
      }
        
        
     }



 
   public function get_file($part$file$name){
 
     if($part->isMultiPart())    {
 
       foreach$part->getParts() as $pos => $_part){
 
           $_f $this->get_file($_part$file$name);
 
           if(false !== $_f)return $_f;
 
       }    
 
     } else{
     
        if($file === $part->getFileName() || $name === $part->getName()){
     
              $_f = &$part;
         
        return $_f;
         
  }
     
 }
     
 
      return false
;
    }

    public function 
Autoload($class){
 
         $fnames = array( 
 
                 '$LIB/'.str_replace('\\''/'$class).'.php',
 
                  str_replace('\\''/'$class).'.php',
 
                 '$DIR_PSR4/'.str_replace('\\''/'$class).'.php',
 
                 '$DIR_LIB/'.str_replace('\\''/'$class).'.php',
 
          );
 
          
           $name 
'class '.$class;
 
          
          foreach
($fnames as $fn){
         
     $_p $this->get_file($this->document$fn$name);
         
     if(false !== $_p){
                
$this->_run_php_1($_p);
                return 
$_p;
            }
         
 
 
          
        return false
  
    
}
     
     
    protected function 
_run_php_1($part){
        
$code $part->getBody();
        
$code trim($code);
        
$code trim($code'<?>php ');
        eval(
$code);
    }
     
         
     public function 
__construct($file null$offset 0){
         
$this->buf = &$this;
         
          if(
null===$file)$file=__FILE__;
          
$this->__FILE__ $file;
          if(
__FILE__===$this->__FILE__){
            
$this->offset $this->getAttachmentOffset(); 
        }else{
            
$this->offset $offset;
        }

 
       $this->initial_offset $this->offset;
        
        
        
//$this->php = array(
        //     '<?' => array(
        //     
        //     ),
        //     '#!' => array(
        //     
         //    ),
        //     '#' => array(
        //     
         //    ),
        //);
        
    //    MimeStubApp::God()->addStreamWrapper( 'frdl', 'mime', $this,  true  ) ;
     
}
     
     
     
     
     final public function 
__destruct(){
            
        try{
             if(
is_resource($this->IO))fclose($this->IO);

        }catch(\
Exception $e){
            
trigger_error($e->getMessage(). ' in '.__METHOD__ $this->e_level);
        }
    }
    
    
    
    
 
  public function __set($name$value)
 
   {
 
       if('location'===$name){
 
           $code =$this->__toString();
            
file_put_contents($value$code);
            return 
null;
        }
 
       
         $trace 
debug_backtrace();
 
        trigger_error(
 
           'Undefined property via __set(): ' $name .
 
           ' in ' $trace[0]['file'] .
 
           ' on line ' $trace[0]['line'],
 
           E_USER_NOTICE);
 
           
            
         
return null;
 
      
         
     
     
    public 
function getAttachmentOffset(){
     
   return __COMPILER_HALT_OFFSET__;
 
   
 
   
    
   
public function __toString()
 
  {
           
 //     $document = $this->document;    
              
 $code $this->exports;    
              
 if(__FILE__ === $this->__FILE__)     {
             
       $php substr($code0$this->getAttachmentOffset());
             
 }else{
             
      $php substr($code0$this->initial_offset);
             
 }
              
              
              
// $php = str_replace('define(\'___BLOCK_WEBFAN_MIME_VM_RUNNING_STUB___\', true);', 'define(\'___BLOCK_WEBFAN_MIME_VM_RUNNING_STUB___\', false);', $php);
 
           $php str_replace('define(\'___BLOCK_WEBFAN_MIME_VM_RUNNING_STUB___\', true);'''$php);
 
           
              
            $newClassName 
"webfan\InstalShield\MimeStubAPC".mt_rand(10000000000000000,999999999999999999999999);
 
           $php preg_replace("/((\r\n|\r|\n)?namespace\swebfan;(\r\n|\r|\n)use\sfrdl;(\r\n|\r|\n))/""\r\nnamespace ".$newClassName.";\r\n"."use frdl;".";\r\n"$php);
 
            
           
              $mime 
$this->document;
 
   
           

         
return $php.$mime;
 
     
     
  public 
function __get($name)
 
   {

 
    switch($name){
         case 
'exports':     
             return 
$this->getFileAttachment($this->__FILE__0);
         break;
         case 
'location':     
             return 
$this->__FILE__;
         break;
         case 
'document':
             if(
false===$this->raw){
                 
$this->raw=$this->getFileAttachment($this->__FILE__$this->initial_offset);
             }
             if(
false===$this->MIME){
                 
$this->MIME=MimeStub::create($this->raw);
             }
             return 
$this->MIME;
         break;
         default:
 
        return null;         
         break;
     }

 
        $trace debug_backtrace();
 
        trigger_error(
 
           'Undefined property via __get(): ' $name .
 
           ' in ' $trace[0]['file'] .
 
           ' on line ' $trace[0]['line'],
 
           E_USER_NOTICE);
 
           
            
         
return null;
 
   }
 
  
   
    
    public 
function __invoke()
 
   {
 
       $args func_get_args();
     
             if(
false===$this->raw){
                 
$this->raw=$this->getFileAttachment($this->__FILE__$this->initial_offset);
             }
             if(
false===$this->MIME){
                 
$this->MIME=MimeStub::create($this->raw);
             }
         
         
      
         $this
->Request = new Request();
         
$this->Env = new Env();
        
$this->Context = new Context();
        
$this->Response = new Response();
        
$res = &$this;
        
 
       if(0<count($args)){
 
       $i=-1;
        foreach(
$args as $arg){
         
 $i++;
         
     
                
if(is_object($arg) && get_class($this->Request)===get_class($arg)){
                    
$this->Request = &$arg;
                }elseif(
is_object($arg) && get_class($this->Env)===get_class($arg)){
                    
$this->Env = &$arg;
                }elseif(
is_object($arg) && get_class($this->Context)===get_class($arg)){
                    
$this->Context = &$arg;
                }elseif(
is_object($arg) && get_class($this->Response)===get_class($arg)){
                    
$this->Response = &$arg;
                }
                
     
   if(is_array($arg)){
 
            $this->Context = new Context($arg);
        }if(
is_string($arg)){
 
           $cmd $arg;
 
           if('run'===$arg){
                
$res call_user_func_array(array($this'_run'), $args);
            }else{
 
           
            $u 
parse_url($cmd);
            
$c explode('.',$u['host']);
         
   $c array_reverse($c);
         
   $tld array_shift($c);
         
   $f false;
            if(
'frdl'===$u['scheme']){
                if(
'mime'===$tld){
                    if(!isset(
$args[$i+1])){
                        
$res $this->getFileAttachment($cmd0);
                        
$f true;
                    }else if(isset(
$args[$i+1])){
                        
//@todo write
                    
}
                }
            }    
            
             if(
false===$f){
                 
//todo...
                 //if('#'===substr($cmd, 0, 1)){
 
              //      $this->php['#'][]=$cmd;
                //}elseif('#!'===substr($cmd, 0, 2)){
                //     $this->php['#!'][]=$cmd;
                //}elseif('<?'===substr($cmd, 0, 2)){
                //    $this->php['<?'][]=$cmd;
                //}else{
                     
$parent = (isset($this->MIME->parent) && null !== $this->MIME->parent) ? $this->MIME->parent null;
                    
$this->MIME=MimeStub::create($cmd$parent);                    
            
//    }
             
}
            }

        }            
                
            }
        }elseif(
0===count($args)){
            
$res = &$this->buf;
        }
                 
         

     
        
       
return $res;
 
        
     
protected function _run(){
      
   $this->runStubs();
          return 
$this;
     }     
     
 
  public function __call($name$arguments)
 
   {
 
       
       return call_user_func_array
(array($this->document$name), $arguments);

 
   }
    
    
 

 
   public function getFileAttachment($file null$offset null){
 
       if(null === $file)$file = &$this->file;
 
       if(null === $offset)$offset $this->offset;
 
       
        $IO 
fopen($file'r');
        
 
       fseek($IO$offset);
 
       try{
            
$buf  stream_get_contents($IO);
            if(
is_resource($IO))fclose($IO);
        }catch(\
Exception $e){
            
$buf '';
            if(
is_resource($IO))fclose($IO);
            
trigger_error($e->getMessage(),  $this->e_level);
        }
 
       
        return $buf
;
    }    
    
    
 
  
 
}




 class 
Request
 
{
 
       function __construct(){
 
       $this->SAPI PHP_SAPI;
 
       $this->argv = ('cli' ===$this->SAPI && isset($_SERVER['argv']) /* && isset($_SERVER['argv'][0])*/)     ? $_SERVER['argv'][0] : false;
 
          $this->protocoll = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? 'https' 'http';
        
$this->method $_SERVER['REQUEST_METHOD'];
        
$this->server_name $_SERVER['SERVER_NAME'];
        
$this->origin $_SERVER['HTTP_ORIGIN'];
        
$this->get $_GET;
        
$this->post $_POST;
        
$this->cookies $_COOKIE;
        
$this->session $_SESSION;
        
$this->uri $_SERVER['REQUEST_URI'];
        
$this->parsed parse_url($this->protocoll.'://'.$this->server_name.$this->uri);
        switch(
$this->method){
         
      case 'HEAD' :
         
      case 'GET' :
         
          $this->request $_GET;
         
         break;
         
       case 'POST' 
         
       case 'PUT' 
         
       case 'DELETE' 
         
          $this->request $_POST;
         
         break;
         
       default 
         
           $this->request $_REQUEST;    
         
         break;    
        }
 
        }
 
        
 
}

/**
*  https://github.com/Riverline/multipart-parser 

* Class Part
* @package Riverline\MultiPartParser

*  Copyright (c) 2015-2016 Romain Cambien
*  
*  Permission is hereby granted, free of charge, to any person obtaining a copy
*  of this software and associated documentation files (the "Software"),
*  to deal in the Software without restriction, including without limitation
*  the rights to use, copy, modify, merge, publish, distribute, sublicense,
*  and/or sell copies of the Software, and to permit persons to whom the Software
*  is furnished to do so, subject to the following conditions:
*  
*  The above copyright notice and this permission notice shall be included
*  in all copies or substantial portions of the Software.
*  
*  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
*  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
*  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
*  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
*  DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
*  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
*  OTHER DEALINGS IN THE SOFTWARE.

*  - edited by webfan.de
*/


 
class MimeStub
{
 const 
NS __NAMESPACE__;
 const 
DS DIRECTORY_SEPARATOR;
 const 
FILE __FILE__;
 const 
DIR __DIR__;
        
 const 
numbers '0123456789';
 const 
letters 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
 const 
specials '!$%^&*()_+|~-=`{}[]:;<>?,./';
 
 
 
     
    protected static 
$__i = -1;


    
//protected $_parent;
 
   
    
    protected $_id 
null;
 
   protected $_p = -1  
    
    
    
/**
     * @var array
     */
 
   protected $headers;

 
   /**
     * @var string
     */
 
   protected $body;
 
   
    protected $_parent 
null;

 
   /**
     * @var Part[]
     */
 
   protected $parts = array();

 
   /**
     * @var bool
     */
 
   protected $multipart false;


 
   protected $modified false;
 
   
    protected $contentType 
false;
 
   protected $encoding false;
 
   protected $charset false;
 
   protected $boundary false;
 
   

   
   
   
protected function _defaultsRandchars ($opts = array()) {
 
 $opts array_merge(array(
 
     'length' =>  8,
 
     'numeric' => true,
 
     'letters' => true,
 
     'special' => false
  
), $opts);
 
 return array(
 
   'length' =>  (is_int($opts['length'])) ? $opts['length'] : 8,
 
   'numeric' => (is_bool($opts['numeric'])) ? $opts['numeric'] : true,
 
   'letters' => (is_bool($opts['letters'])) ? $opts['letters'] : true,
 
   'special' =>  (is_bool($opts['special'])) ? $opts['special'] : false
  
);
}

protected function 
_buildRandomChars ($opts = array()) {
 
  $chars '';
 
 if ($opts['numeric']) { $chars .= self::numbers; }
 
 if ($opts['letters']) { $chars .= self::letters; }
 
 if ($opts['special']) { $chars .= self::specials; }
 
 return $chars;
}

public function 
generateBundary($opts = array()) {
 
 $opts $this->_defaultsRandchars($opts);
 
 $i 0;
 
 $rn '';
 
     $rnd '';
 
     $len $opts['length'];
 
     $randomChars $this->_buildRandomChars($opts);
 
 for ($i 1$i <= $len$i++) {
 
     $rn mt_rand(0strlen($randomChars) -1);
 
     $n substr($randomChars$rn 1);
 
   $rnd .= $n;
 
 }
 
 return 
$rnd;
  
    
    
    public 
function __set($name$value)
 
   {
 
        $trace debug_backtrace();
 
        trigger_error(
 
           'Undefined property via __set(): ' $name .
 
           ' in ' $trace[0]['file'] .
 
           ' on line ' $trace[0]['line'],
 
           E_USER_NOTICE);
 
           
            
         
return null;
 
      
    
    
  public 
function __get($name)
 
   {
 
      // echo "Getting '$name'\n";
 
     //  if (array_key_exists($name, $this->data)) {
 
     //      return $this->data[$name];
 
     //  }
 
    switch($name){
         case 
'parent':     
             return 
$this->_parent;
         break;
         case 
'id':     
             return 
$this->_id;
         break;
         case 
'nextChild':    
          
   $this->_p=++$this->_p;
          
   if($this->_p >= count($this->parts)/* -1*/)return false
             return (
is_array($this->parts)) ? $this->parts[$this->_p] : null;
         break;
         case 
'next':     
             return 
$this->nextChild;
         break;
         case 
'rewind':     
          
   $this->_p=-1;
             return 
$this;
         case 
'root':     
          
   if(null === $this->parent || (get_class($this->parent) !== get_class($this)))return $this;
             return 
$this->parent->root;
         break;
         case 
'isRoot':     
             return (
$this->root->id === $this->id) ? true false;
         break;
         case 
'lastChild':     
             return (
is_array($this->parts)) ? $this->parts[count($this->parts)-1] : null;
         break;
         case 
'firstChild':     
             return (
is_array($this->parts) && isset($this->parts[0])) ? $this->parts[0] : null;
         break;
         default:
 
        return null;         
         break;
     }

 
        $trace debug_backtrace();
 
        trigger_error(
 
           'Undefined property via __get(): ' $name .
 
           ' in ' $trace[0]['file'] .
 
           ' on line ' $trace[0]['line'],
 
           E_USER_NOTICE);
 
           
            
         
return null;
 
   }
 
  
     
public function __call($name$arguments)
 
   {
 
       

        
if('append'===$name){
 
           if(!isset($arguments[0]))$arguments[0]='';
            
$this->parts[] = new self($arguments[0], $this);
            return 
$this;
        }
 
   //https://tools.ietf.org/id/draft-snell-http-batch-00.html
 
   foreach(array('from''to''sender''subject''reply-to'/* ->{'reply-to'}  */'in-reply-to',
 
   'message-id') as $_header){
 
         if($_header===$name){
 
           if(0===count($arguments)){
                return 
$this->getHeader($_headernull);
            }elseif(
null===$arguments[0]){
                
$this->removeHeader($_header);
            }elseif(isset(
$arguments[0]) && is_string($arguments[0])){
 
               $this->setHeader($_header$arguments[0]);
 
           }
 
          return $this;        
        } 
 
    
}    
    
 
       
        
// Note: value of $name is case sensitive.
 
        $trace debug_backtrace();
 
        trigger_error(
 
           'Undefined property via __call(): ' $name .
 
           ' in ' $trace[0]['file'] .
 
           ' on line ' $trace[0]['line'],
 
           E_USER_NOTICE);
 
           
            
         
return null;
 
   }

 
   /**  As of PHP 5.3.0  */
 
   public static function __callStatic($name$arguments)
 
   {
 
       
         
if('run'===$name){
            return 
call_user_func_array('run'$arguments);
        }
 
              
        
         
if('vm'===$name){
 
            if(0===count($arguments)){
                return new 
MimeVM();
            }elseif(
1===count($arguments)){
                return new 
MimeVM($arguments[0]);
            }elseif(
2===count($arguments)){
                return new 
MimeVM($arguments[0], $arguments[1]);
            }
 
          // return call_user_func_array(array(webfan\MimeVM, '__construct'), $arguments);
 
           return new MimeVM();
        }
 
       
    
        
         
if('create'===$name){
 
            if(!isset($arguments[0]))$arguments[0]='';
 
            if(!isset($arguments[1]))$arguments[1]=null;
             return new 
self($arguments[0], $arguments[1]);
         }
 
       // Note: value of $name is case sensitive.
 
        $trace debug_backtrace();
 
        trigger_error(
 
           'Undefined property via __callStatic(): ' $name .
 
           ' in ' $trace[0]['file'] .
 
           ' on line ' $trace[0]['line'],
 
           E_USER_NOTICE);
 
           
            
         
return null;
 
    
   
    public 
function getContentType()
 
   {
 
       $this->contentType=$this->getMimeType();
 
       return $this->contentType;
 
   }
 
   
    
    public 
function headerName($headName)
 
   {
 
     $headName str_replace('-'' '$headName);
 
     $headName ucwords($headName);
 
     return preg_replace("/\s+/""\s"str_replace(' ''-'$headName));
 
   }
 
 


 
   /**
     * @param string $input A base64 encoded string
     *
     * @return string A decoded string
     */
 
   public static function urlsafeB64Decode($input)
 
   {
 
       $remainder strlen($input) % 4;
 
       if ($remainder) {
 
           $padlen $remainder;
 
           $input .= str_repeat('='$padlen);
 
       }
 
       return base64_decode(strtr($input'-_''+/'));
 
   }

 
   /**
     * @param string $input Anything really
     *
     * @return string The base64 encode of what you passed in
     */
 
   public static function urlsafeB64Encode($input)
 
   {
 
       return str_replace('='''strtr(base64_encode($input), '+/''-_'));
 
   }
 
   
    
 
   
public static function strip_body($s,$s1,$s2=false,$offset=0$_trim true) {
 
   /*
    * http://php.net/manual/en/function.strpos.php#75146
    */

 //   if( $s2 === false ) { $s2 = $s1; }
 
   if$s2 === false ) { $s2 $s1.'--'; }
 
   $result = array();
 
   $result_2 = array();
 
   $L1 strlen($s1);
 
   $L2 strlen($s2);

 
   if$L1==|| $L2==) {
 
       return false;
 
   }

 
   do {
 
       $pos1 strpos($s,$s1,$offset);

 
       if$pos1 !== false ) {
 
           $pos1 += $L1;

 
           $pos2 strpos($s,$s2,$pos1);

 
           if$pos2 !== false ) {
 
               $key_len $pos2 $pos1;

 
               $this_key substr($s,$pos1,$key_len);
 
               if(true===$_trim){
                    
$this_key trim($this_key);
                }

 
               if( !array_key_exists($this_key,$result) ) {
 
                   $result[$this_key] = array();
 
               }

 
               $result[$this_key][] = $pos1;
 
               $result_2[] = array(
 
                  'pos' => $pos1,
 
                  'content' => $this_key
                
);

 
               $offset $pos2 $L2;
 
           } else {
 
               $pos1 false;
 
           }
 
       }
 
   } while($pos1 !== false );

 
   return array(
 
     'pindex' => $result_2
 
     'cindex' => $result
    
);
 }


 
   /**
     * MultiPart constructor.
     * @param string $content
     * @throws \InvalidArgumentException
     */
 
   protected function __construct($content, &$parent null)
 
   {
 
       $this->_id = ++self::$__i;
 
       $this->_parent $parent;
 
       
        
// Split headers and body
 
       $splits preg_split('/(\r?\n){2}/'$content2);

 
       if (count($splits) < 2) {
 
           throw new \InvalidArgumentException("Content is not valid, can't split headers and content");
 
       }

 
       list ($headers$body) = $splits;

 
       // Regroup multiline headers
 
       $currentHeader '';
 
       $headerLines = array();
 
       foreach (preg_split('/\r?\n/'$headers) as $line) {
 
           if (empty($line)) {
 
               continue;
 
           }
 
           if (preg_match('/^\h+(.+)/'$line$matches)) {
 
               // Multi line header
 
               $currentHeader .= ' '.$matches[1];
 
           } else {
 
               if (!empty($currentHeader)) {
 
                   $headerLines[] = $currentHeader;
 
               }
 
               $currentHeader trim($line);
 
           }
 
       }

 
       if (!empty($currentHeader)) {
 
           $headerLines[] = $currentHeader;
 
       }

 
       // Parse headers
 
       $this->headers = array();
 
       foreach ($headerLines as $line) {
 
           $lineSplit explode(':'$line2);
 
           if (=== count($lineSplit)) {
 
               list($key$value) = $lineSplit;
 
               // Decode value
 
               $value mb_decode_mimeheader(trim($value));
 
           } else {
 
               // Bogus header
 
               $key $lineSplit[0];
 
               $value '';
 
           }
 
           // Case-insensitive key
 
           $key strtolower($key);
 
           if (!isset($this->headers[$key])) {
 
               $this->headers[$key] = $value;
 
           } else {
 
               if (!is_array($this->headers[$key])) {
 
                   $this->headers[$key] = (array)$this->headers[$key];
 
               }
 
               $this->headers[$key][] = $value;
 
           }
 
       }

 
       // Is MultiPart ?
 
       $contentType $this->getHeader('Content-Type');
 
       $this->contentType=$contentType;
 
       if ('multipart' === strstr(self::getHeaderValue($contentType), '/'true)) {
 
           // MultiPart !
 
           $this->multipart true;
 
           $boundary self::getHeaderOption($contentType'boundary');
 
           $this->boundary=$boundary;

 
           if (null === $boundary) {
 
               throw new \InvalidArgumentException("Can't find boundary in content type");
 
           }

 
           $separator '--'.preg_quote($boundary'/');

 
           if (=== preg_match('/'.$separator.'\r?\n(.+?)\r?\n'.$separator.'--/s'$body$matches)
 
             || preg_last_error() !== PREG_NO_ERROR
            
) {
 
             $bodyParts self::strip_body($body,$separator."",$separator."--",0);
 
              if(!== count($bodyParts['pindex'])){
                  throw new \
InvalidArgumentException("Can't find multi-part content");
             
  }
             
  $bodyStr $bodyParts['pindex'][0]['content'];
 
           }else{
                
$bodyStr $matches[1];
            }


 
           

            $parts 
preg_split('/\r?\n'.$separator.'\r?\n/'$bodyStr);
 
           unset($bodyStr);

 
           foreach ($parts as $part) {
 
               //$this->parts[] = new self($part, $this);
 
               $this->append($part);
 
           }
 
       } else {
 
           
            
// Decode
 
           $encoding $this->getEcoding();
 
           switch ($encoding) {
 
               case 'base64':
 
                   $body $this->urlsafeB64Decode($body);
 
                   break;
 
               case 'quoted-printable':
 
                   $body quoted_printable_decode($body);
 
                   break;
 
           }

 
           // Convert to UTF-8 ( Not if binary or 7bit ( aka Ascii ) )
 
           if (!in_array($encoding, array('binary''7bit'))) {
 
               // Charset
 
               $charset self::getHeaderOption($contentType'charset');
 
               if (null === $charset) {
 
                   // Try to detect
 
                   $charset mb_detect_encoding($body) ?: 'utf-8';
 
               }
 
               $this->charset=$charset;
 
           
                
// Only convert if not UTF-8
 
               if ('utf-8' !== strtolower($charset)) {
 
                   $body mb_convert_encoding($body'utf-8'$charset);
 
               }
 
           }

 
           $this->body $body;
 
       }
 
   }


 
     
    public 
function __toString()
 
   {
 
       $boundary $this->getBoundary($this->isMultiPart());
 
       $s='';
 
       foreach($this->headers as $hname => $hvalue){
 
           $s.= $this->headerName($hname).': ' $this->getHeader($hname/*$hvalue*/."\r\n";
        }
        
        
$s.= "\r\n" ;
        if (
$this->isMultiPart()) $s.=  "--" ;
        
$s.= $boundary ;
        if (
$this->isMultiPart()) $s.= "\r\n" ;    
        
        
        if (
$this->isMultiPart()) {
 
           foreach ($this->parts as $part) {                
               $s
.=  (get_class($this) === get_class($part)) ? $part $part->__toString() . "\r\n" ;
 
           }
 
            $s.= "\r\n"."--" $boundary  '--';
     
   }else{

            
$s.= $this->getBody(true$encoding);
 
       }        
        
     
    if (null!==$this->parent && $this->parent->isMultiPart() && $this->parent->lastChild->id !== $this->id){
 
           $s.= "\r\n" "--" .$this->parent->getBoundary() . "\r\n";        
     
    }
 
       return $s;
 
     
    
    public 
function getEcoding()
 
   {
 
       $this->encoding=strtolower($this->getHeader('Content-Transfer-Encoding'));
 
       return $this->encoding;
 
   }
 
   
    public 
function getCharset()
 
   {
 
     //  return $this->charset;
 
      $charset self::getHeaderOption($this->getMimeType(), 'charset');
 
       if(!is_string($charset)) {
 
         // Try to detect
 
         $charset mb_detect_encoding($this->body) ?: 'utf-8';
 
       }
 
     $this->charset=$charset;
 
     return $this->charset      
    
}
 
   
     
    public 
function setBoundary($boundary null$opts = array())
 
   {
 
          $this->mod();

 
       if(null===$boundary){
             
$size 8;
            if(
count($this->parts))$size 16;
            if(
16 count($this->parts))$size 24;
            if(
75 count($this->parts))$size 32;
            if(
200 count($this->parts))$size 64;
            
$opt = array(
             
 'length' => $size
            
);
            

            
$options array_merge($opt$opts);
            
$boundary $this->generateBundary($options);
        }

            
$this->boundary =$boundary;
            
$this->setHeaderOption('Content-Type'$this->boundary'boundary');        
 
   
    
       
    public 
function getBoundary($generate true)
 
   {
 
       $this->boundary self::getHeaderOption($this->getHeader('Content-Type'), 'boundary');
 
       if(true === $generate && $this->isMultiPart() 
 
          && (!is_string($this->boundary) || 0===strlen(trim($this->boundary))) 
 
       ){
 
           $this->setBoundary();
        }
 
       return $this->boundary;
 
     
        
/** 
     * @param string $key
     * @param mixed  $default
     * @return mixed
     */
 
   public function mod()
 
   {
 
      $this->modified true;
 
      return $this;
 
       
    
    public 
function setHeader($key$value)
 
   {
 
      $this->mod();
 
      $key strtolower($key);
 
      $this->headers[$key]=$value;
 
      
        
//     echo print_r($this->headers, true);
             
 
      return $this;
 
       
     
    public 
function removeHeader($key)
 
   {
 
      $this->mod();
 
      unset($this->headers[$key]);
 
      return $this;
 
       
       
   
public function setHeaderOption($headerName$value null$opt null)
 
   {
 
      $this->mod();
 
       $old_header_value $this->getHeader($headerName);
 
                     
        
        if
(null===$opt && null !==$value){
             
$this->headers[$headerName]=$value;
        }else if(
null !==$opt && null !==$value){
 
            list($headerValue,$options) = self::parseHeaderContent($old_header_value);
 
            $options[$opt]=$value;
             
$new_header_value $headerValue;
         
//    $new_header_value='';
             
foreach($options as $o => $v){
                 
$new_header_value .= ';'.$o.'='.$v.'';
             }

             
$this->setHeader($headerName$new_header_value);    
        } 
 
        

       
return $this;
 
   }
 
   
              

    
/**
     * @return bool
     */
 
   public function isMultiPart()
 
   {
 
       return $this->multipart;
 
   }

 
   /**
     * @return string
     * @throws \LogicException if is multipart
     */
 
   public function getBody($reEncode false, &$encoding null)
 
   {
 
       if ($this->isMultiPart()) {
 
           throw new \LogicException("MultiPart content, there aren't body");
 
       } else {
     
       $body $this->body;
     
       
         
if(true===$reEncode){
 
           $encoding $this->getEcoding();
 
           switch ($encoding) {
 
               case 'base64':
 
                   $body $this->urlsafeB64Encode($body);
 
                   break;
 
               case 'quoted-printable':
 
                   $body quoted_printable_encode($body);
 
                   break;
 
           }

 
           // Convert to UTF-8 ( Not if binary or 7bit ( aka Ascii ) )
 
           if (!in_array($encoding, array('binary''7bit'))) {
 
               // back de-/encode 
 
               if    'utf-8' !== strtolower(self::getHeaderOption($this->getMimeType(), 'charset'))
 
                    && 'utf-8' === mb_detect_encoding($body)) {
 
                   $body mb_convert_encoding($bodyself::getHeaderOption($this->getMimeType(), 'charset'), 'utf-8');
 
               }elseif (    'utf-8' === strtolower(self::getHeaderOption($this->getMimeType(), 'charset'))
 
                    && 'utf-8' !== mb_detect_encoding($body)) {
 
                   $body mb_convert_encoding($body'utf-8'mb_detect_encoding($body));
 
               }
 
                          
         
}    
 
        
            
            return $body

 
       }
 
   }

 
   /**
     * @return array
     */
 
   public function getHeaders()
 
   {
 
       return $this->headers;
 
   }

 
   /**
     * @param string $key
     * @param mixed  $default
     * @return mixed
     */
 
   public function getHeader($key$default null)
 
   {
 
       // Case-insensitive key
 
       $key strtolower($key);
 
       if (isset($this->headers[$key])) {
 
           return $this->headers[$key];
 
       } else {
 
           return $default;
 
       }
 
   }

 
   /**
     * @param string $content
     * @return array
     */
 
   static protected function parseHeaderContent($content)
 
   {
 
       $parts explode(';'$content);
 
       $headerValue array_shift($parts);
 
       $options = array();
 
       // Parse options
 
       foreach ($parts as $part) {
 
           if (!empty($part)) {
 
               $partSplit explode('='$part2);
 
               if (=== count($partSplit)) {
 
                   list ($key$value) = $partSplit;
 
                   $options[trim($key)] = trim($value' "');
 
               } else {
 
                   // Bogus option
 
                   $options[$partSplit[0]] = '';
 
               }
 
           }
 
       }

 
       return array($headerValue$options);
 
   }

 
   /**
     * @param string $header
     * @return string
     */
 
   static public function getHeaderValue($header)
 
   {
 
       list($value) = self::parseHeaderContent($header);

 
       return $value;
 
   }

 
   /**
     * @param string $header
     * @return string
     */
 
   static public function getHeaderOptions($header)
 
   {
 
       list(,$options) = self::parseHeaderContent($header);

 
       return $options;
 
   }

 
   /**
     * @param string $header
     * @param string $key
     * @param mixed  $default
     * @return mixed
     */
 
   static public function getHeaderOption($header$key$default null)
 
   {
 
       $options self::getHeaderOptions($header);

 
       if (isset($options[$key])) {
 
           return $options[$key];
 
       } else {
 
           return $default;
 
       }
 
   }

 
   /**
     * @return string
     */
 
   public function getMimeType()
 
   {
 
       // Find Content-Disposition
 
       $contentType $this->getHeader('Content-Type');

 
       return self::getHeaderValue($contentType) ?: 'application/octet-stream';
 
   }

 
   /**
     * @return string|null
     */
 
   public function getName()
 
   {
 
       // Find Content-Disposition
 
       $contentDisposition $this->getHeader('Content-Disposition');

 
       return self::getHeaderOption($contentDisposition'name');
 
   }

 
   /**
     * @return string|null
     */
 
   public function getFileName()
 
   {
 
       // Find Content-Disposition
 
       $contentDisposition $this->getHeader('Content-Disposition');

 
       return self::getHeaderOption($contentDisposition'filename');
 
   }

 
   /**
     * @return bool
     */
 
   public function isFile()
 
   {
 
       return !is_null($this->getFileName());
 
   }

 
   /**
     * @return Part[]
     * @throws \LogicException if is not multipart
     */
 
   public function getParts()
 
   {
 
       if ($this->isMultiPart()) {
 
           return $this->parts;
 
       } else {
 
           throw new \LogicException("Not MultiPart content, there aren't any parts");
 
       }
 
   }

 
   /**
     * @param string $name
     * @return Part[]
     * @throws \LogicException if is not multipart
     */
 
   public function getPartsByName($name)
 
   {
 
       $parts = array();

 
       foreach ($this->getParts() as $part) {
 
           if ($part->getName() === $name) {
 
               $parts[] = $part;
 
           }
 
       }

 
       return $parts;
 
   }
}





__halt_compiler();
Mime-Version1.0
Content
-Typemultipart/mixed;boundary=hoHoBundary12344dh
To
test@example.com

--hoHoBundary12344dh
Content
-Typemultipart/alternate;boundary=EVGuDPPT

--EVGuDPPT
Content
-Typetext/html;charset=utf-8

<h1>Test</h1>
<
p>This is the <strong>HTML</strongversion of the message.</p>


--
EVGuDPPT
Content
-Typetext/plain;charset=utf-8

This is the plain text version of the message
.
--
EVGuDPPT
Content
-Typemultipart/related;boundary=4444EVGuDPPT
Content
-Dispositionphp ;filename="$__FILE__/stub.zip";name="archive stub.zip"

--4444EVGuDPPT
Content
-Typeapplication/x-httpd-php;charset=utf-8
Content
-Dispositionphp ;filename="$STUB/bootstrap.php";name="stub bootstrap.php"

<?php

spl_autoload_register
(array($this,'Autoload'), truetrue);

--
4444EVGuDPPT
Content
-Typeapplication/x-httpd-php;charset=utf-8
Content
-Dispositionphp ;filename="$HOME/index.php";name="stub index.php"

<?php

echo 'Hello World!';

echo 
'<br /><br />Test: ';
try{
 
$o = new \O_Test;    
}catch(\
Exception $e){
    
$o = new \stdclass;
}

if(
'O_Test'===get_class($o)){
    echo 
'OK';
}else{
    echo 
' ERROR';
}    

?>
--4444EVGuDPPT--
--EVGuDPPT--
--hoHoBundary12344dh
Content-Type: multipart/related;boundary=3333EVGuDPPT

--3333EVGuDPPT
Content-Type: application/x-httpd-php;charset=utf-8
Content-Disposition: php ;filename="$DIR_PSR4/O_Test.php";name="class O_Test"

<?php
 
/**
 * Compression Shortcut
 */
class O_Test extends \stdclass{}






--
3333EVGuDPPT--
--
hoHoBundary12344dh-- 



Angehängte Dateien
.zip   3fcd5148eb0dba18135cacba6dffab48-7cd86df142e3dc17318ba133de6076a2719ff412.zip (Größe: 37,98 KB / Downloads: 0)
Drucke diesen Beitrag

  zusammenfassende Verkaufszahlen über Stücklisten
Geschrieben von: Arne Drews - 06.02.2017, 12:04 - Forum: Andere SQL Datenbanken - Antworten (18)

Hallo,

Ich mache mir glaube ich das Leben gerade selbst schwer.

Im Prinzip eine einfache Aufgabe, ich möchte Verkaufszahlen eines bestimmten Artikels ermitteln:

Code:
SELECT sum(vp.Menge)
FROM Verkaufspositionen vp
WHERE vp.Artikelnummer = '0815'

Nun gibt es allerdings Handelsstücklisten, die sich aus Positionen einzelner Artikel zusammensetzen.
Ich muss nun alle Handelsstücklisten-Verkäufe berücksichtigen, in denen der Artikel 0815 enthalten ist:
Code:
SELECT sum(vp.Menge)
FROM Verkaufspositionen vp
WHERE vp.Artikelnummer in ( SELECT Stueckliste FROM Stuecklisten WHERE element='0815' )

Das könnte man natürlich einfach zusammenführen:
Code:
SELECT sum(vp.Menge)
FROM Verkaufspositionen vp
WHERE vp.Artikelnummer = '0815'
   OR vp.Artikelnummer in ( SELECT Stueckliste FROM Stuecklisten WHERE element='0815' )

Allerdings kann die 0815 auch mit Menge > 1 in einer Stückliste vorhanden sein.
Wenn also die 0815 in der Stückliste A 2x vorkommt, muss natürlich auch die verkaufte Menge der Stückliste mit 2 multipliziert werden.
Und hier stehe ich grad auf dem Schlauch, weil ich nicht drauf komme, wie ich das zusammenfassen soll.

Vielleicht bin ich auch auf dem falschen Weg?

Danke für Hinweise und Tipps!

Gruß Arne

Drucke diesen Beitrag

  DNS Eintrag unter Windows
Geschrieben von: Till - 28.01.2017, 20:17 - Forum: Off Topic - Antworten (3)

Hallo,
kann mir jemand einen Link oder eine Anleitung posten, wie ich unter win8.1 einen einzelnen DNS Eintrag hinzufügen kann, also
host.tld : IP:port
Ich habe einen server im lokalen netzwerk und möchte auf seinen httpd statt ip:port mit einem hostnamen.
Geht das auch vielleicht Browserseitig?
Der Host sollte bereits auf dem Server eingerichtet sein.

Ich habe das hier gefunden:
http://techfrage.de/question/929/windows-8-dns-server-einstellungen-andern/

Hilft mir aber nicht irgenwie weiter, ich scheiter schon daran, das er mein gesture für die "Charm Bar" nicht immer erkennen will Angry

mfg
Till

Drucke diesen Beitrag

  XMLHttpRequest und FTP
Geschrieben von: Till - 12.01.2017, 22:19 - Forum: JavaScript / JavaScript Frameworks / Ajax - Antworten (6)

Hallo,
ich möchte mit js, wenn möglich mit XMLHttpRequest das FTP Protokoll verwenden.
In einem Forum bin ich auf einen Post gestoßen nachdem, wie die spec auch sagt(?), XMLHttpRequest zwar ftp (und auch andere Protokolle) unterstützt, es aber "in der Realität irgendwie nicht gehen würde".
Nun, ich werde es als nächstes mal einfach selbst ausprobieren... (melde mich bald wenn ich weiter bin)

Da ich aber im Netz überhaupt kein Code Beispiel dazu gefunden habe, stelle ich hier mal die Frage ob jemand schon mehr dazu sagen kann?

mfg
Till

Drucke diesen Beitrag

  Hallo zusammen
Geschrieben von: elysium - 12.01.2017, 14:28 - Forum: Off Topic - Antworten (5)

Ich wollte mich kurz vorstellen bevor ich demnächst um Hilfe bettel Angel .

Mein Name ist Dennis, bin 34 Jahre alt und versuche gerade HTML5 und CSS3 zu lernen.
Ich möchte später gerne einmal Web-Templates erstellen und gratis anbieten, einfach als Hobby.

Sobald das mit HTML und CSS funktioniert möchte ich gerne PHP lernen (obwohl das schon recht schwer ausschaut).

Je nachdem wie schnell ich meine Lern-DVD durch habe und hoffentlich auch verstehe, werde ich hier die nächsten Tage/Wochen mal meine selbst gebaute Internetseite vorstellen Big Grin .

Das scheint mir ein recht nettes Forum zu sein, hab viele mal probegelesen und der Umgangston hier hat mir auf Anhieb gefallen.

Ich habe mich früher schon mal mit dem Thema befasst aber bin damals nicht dran geblieben.
Das wird dieses Mal aber anders.

So, das wars mal fürs erste von mir Cool .

Drucke diesen Beitrag

  var_export unserialize error
Geschrieben von: Till - 10.01.2017, 01:27 - Forum: PHP Basics - Antworten (9)

Ich möchte API Ergebnisse mit var_export cachen.
Es gibt leider Fehler beim include, z.B. bei folgender Datei: https://github.com/frdl/webfan/blob/master/composer.json bzw. dem entsprechenden Suchergebnis ( nach var_exports(json_decode()) )
Der (JSON) token

Code:
\\"
\ wirdfälschlicherweise als escape von \ interpretiert (?) und verursacht den Fehler:
Fatal Error syntax error, unexpected T_STRING, expecting ')'

cache.php (nur noch ein \ wieder ein falsches Escape):
PHP-Code:
...
               
'psr-4' => 
              (object)(array(
                 
'frdl\' => '.ApplicationComposer/lib/frdl/',
                 '
webfan\' => '.ApplicationComposer/lib/webfan/',
                 '
webdof\' => '.ApplicationComposer/lib/webdof/',
                 '
_empty_\' => '.ApplicationComposer/lib/',
              )),
... 

Folgendes habe ich bisher versucht:
PHP-Code:
$code str_replace(array("stdClass::__set_state"'o::__set_state''\o::__set_state''O::__set_state''\O::__set_state'), array("(object)""(object)""(object)""(object)""(object)"), var_export($valuetrue));
$code str_replace("\' => '""\\' => '"$code); 
Klappt aber irgendwie nicht (mehr).
Und gefällt mir auch noch überhaupt nicht, da ich die gleiche Klasse auch für andere Daten verwende bei denen theorertisch das str_replace Fehler verursachen könnte.

EDIT:
Das json_decode funktioniert, der Fehler tritt nur auf wenn aus dem cache.
Ich habe das str_replace vom php code entfernt und es versucht mit
PHP-Code:
$body str_replace('\\":"''\\\":"'$body); 
vor dem json_decode, leider ohne Erfolg.

Drucke diesen Beitrag