Malcolm Beck´s: Aus einer Funktion eine Klasse machen

Beitrag lesen

مرحبا

Ausgabe (das ist alles, insgesamt um die 400 Zeilen)

  /**  
 * Ausgabe  
 */  
  print <<<EOT  
<!DOCTYPE html>  
<html>  
<head>  
<meta charset="utf-8">  
<title>APES - Awesome Path Enumeration Script</title>  
<style>  

~~~~~~css
body {  
  padding:0 10px 40px;  
  color:#666;  
  font: .9em/150% Geneva,Helvetica,sans-serif,Verdana;  
  letter-spacing:1px;  
}  
h1, h2, h3, h4, h5, h6 {  
  margin-top:30px;  
  font-size:1.3em;  
}  
h2, h3 {  
  margin-top:100px;  
}  
ul {  
  margin-left:25px;  
  padding:0;  
}  
li span { /* in diesem Fall der Aktive "Link" */  
  color:#F00;  
}  
a {  
  color:#336699;  
}  
a:focus, a:hover, a:active {  
  color:#DD4B39;  
}  
abbr {  
  border:0 none;  
}  
.got_childs:after {  
  content:' »';  
  color:#b0c4de;  
}  
#navigation {  
  width:14em;  
}  
#navigation li:hover {  
  position:relative;  
  z-index:1;  
}  
.got_childs:hover:after,  
#navigation li:hover > .got_childs:after {  
  color:#F00;  
}  
#navigation li:hover #ajax_request {  
  display:block;  
}  
#ajax_request {  
  display:none;  
  padding:20px 15px 15px 5px;  
  position:absolute;  
  z-index:10;  
  left:9em;  
  top:-20px;  
  border:2px solid #999;  
  min-width:300px;  
  min-height:200px;  
  border-radius:10px;  
  box-shadow:5px 5px 5px #AAA;  
  background: #FFF;  
}  
#ajax_request a {  
  display:block;  
}  
li.active_tree > a,  
li.active_tree > a.got_childs:after {  
  color:#6495ed;  
  text-decoration:none;  
}  
li.active_tree > a.got_childs:after {  
  color:#3CF;  
}  
.active_tree a:hover,  
.active_tree a:hover:after {  
  color:#F00 !important;  
}  
#footer {  
  margin:40px 0 0;  
  padding:10px 0 0;  
  border-top:1px solid #8BA5BF;  
}  
#footer li {  
  margin-right:5px;  
  font-size:.95em;  
  list-style:none;  
  display:inline;  
}  
header {  
  margin:-8px -17px;  
  padding:0;  
  background: #cedce7; /* Old browsers */  /* http://www.colorzilla.com/gradient-editor/ */  
  background: -moz-linear-gradient(top,  #cedce7 0%, #ffffff 100%); /* FF3.6+ */  
  background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#cedce7), color-stop(100%,#ffffff)); /* Chrome,Safari4+ */  
  background: -webkit-linear-gradient(top,  #cedce7 0%,#ffffff 100%); /* Chrome10+,Safari5.1+ */  
  background: -o-linear-gradient(top,  #cedce7 0%,#ffffff 100%); /* Opera 11.10+ */  
  background: -ms-linear-gradient(top,  #cedce7 0%,#ffffff 100%); /* IE10+ */  
  background: linear-gradient(top,  #cedce7 0%,#ffffff 100%); /* W3C */  
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cedce7', endColorstr='#ffffff',GradientType=0 ); /* IE6-9 */  
}  
pre {  
  margin:0;  
  padding:0 10px 15px;  
  font-weight:bold;  
  font-size:1.1em;  
  line-height:140%;  
  white-space:pre;  
}  
pre a {  
  text-decoration:none;  
  display:inline-block;  
}  
pre span {  
  font-size:1.2em;  
  letter-spacing:2px;  
}
</style>  
</head>  
<body>  
<header><pre><a href="/">  
       _____ _____________________ _________  
      /  _  \\______   \_   _____//   _____/  
     /  /_\  \|     ___/|    __)_ \_____  \  
    /    |    \    |    |        \/        \  
    \____|__  /____|   /_______  /_______  /  
            \/                 \/        \/  
     <span>Awesome Path Enumeration Script</span></a></pre>  
</header>  
EOT;  
  
  if (MenuList (0, 'test')) // Wenn es Menus gibt  
  {  
      // Menu  
      print '<h1>Navigation</h1>';  
      print MenuList (0, 'navigation');  
      // Teilzweig  
      print '<h2>Teilzweig mit allen Kindern von <a href="/computer/software">Software</a></h2>';  
      print MenuList (7, 'software', '/computer/software', true);  
      // Ausgeklapptes Menu  
      print '<h3>Ausgeklapptes Menu</h3>';  
      print MenuList (0, 'navigation-expanded', false, true);  
  }  
  else {  
      printf ('<p>Keine Daten gefunden.</p><p>Jetzt welche erstellen: <a href="?create-table=true">Create Table</a></p><pre style="margin:40px 0 50px;">%s</pre>', htmlspecialchars($create, ENT_QUOTES));  
  }  
  // Für JQuery den RequestPath in einer Variable speichern  
  $JQRP = sprintf ('var RequestPath = "%1$s";', urlencode(RequestPath));  
  
  print <<<EOT  
<ul id="footer">  
<li><a href="?create-table=true">Create Table</a></li>  
<li><a href="?drop-table=true">Drop Table</a></li>  
</ul>  
<!-- Und noch ein bisschen Voodoo -->  
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>  
<script type="text/javascript">  
$(function() {  
    $JQRP  
    $("#navigation a,#navigation span").hover(  
      function () { // On  
        var itemId = $(this).data('itemid');  
        var mhref  = $(this).attr('href') ? $(this).attr('href') : $(this).data('href');  
        $('#ajax_sub_tree').remove();  
        $(this).after('<div id="ajax_sub_tree"></div>');  //  
        $('#ajax_sub_tree').load('/?rpath='+RequestPath+';itemid='+itemId+';linkto='+mhref, function() {  
            $(this).hide().fadeIn(250);  
        });  
      }, // On ends  
      function () { // Off  
          $(this).animate({opacity:1},0,"",  
               function(){  
                    $("#ajax_sub_tree").hover(  
                        function () {}, // Keine Ahnung, wie es ohne diesen Sinnlosen Funktionsaufruf funktioniert  
                        function () {  
                          $('#ajax_sub_tree').fadeOut(0);  
                        }  
                    );  
                })  
      } // Off ends  
    );  
});  
</script>  
</body>  
</html>  
EOT;

mfg