index.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?PHP
  2. $shell = array();
  3. $base = '../';
  4. $shell['title2'] = 'Examples';
  5. $shell['link2'] = '../';
  6. include 'config.php';
  7. ob_start();
  8. ?>
  9. <div id="donate">
  10. <p>Your generous donation allows me to continue developing and updating my code!</p>
  11. <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
  12. <input type="hidden" name="cmd" value="_s-xclick">
  13. <input type="hidden" name="hosted_button_id" value="5791421">
  14. <input class="submit" type="image" src="../donate.gif" name="submit" alt="PayPal - The safer, easier way to pay online!">
  15. <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
  16. </form>
  17. <div class="clear"></div>
  18. </div>
  19. <?
  20. $shell['donate'] = ob_get_contents();
  21. ob_end_clean();
  22. function draw_shell() {
  23. global $shell, $base;
  24. ?><!DOCTYPE html>
  25. <html lang="en">
  26. <head>
  27. <meta http-equiv="content-type" content="text/html; charset=utf-8">
  28. <title>Ben Alman &raquo; <?= $shell['title1'] ?><? if ( $shell['title2'] ) { print ' &raquo; ' . $shell['title2']; } ?><? if ( $shell['title3'] ) { print ' &raquo; ' . $shell['title3']; } ?></title>
  29. <script type="text/javascript" src="<?= $base ?>../shared/ba-debug.js"></script>
  30. <?
  31. if ( $shell['jquery'] ) {
  32. ?><script type="text/javascript" src="<?= $base ?>../shared/<?= $shell['jquery'] ?>"></script><?
  33. }
  34. ?><script type="text/javascript" src="<?= $base ?>../shared/SyntaxHighlighter/scripts/shCore.js"></script><?
  35. if ( $shell['shBrush'] ) {
  36. foreach ( $shell['shBrush'] as $brush ) {
  37. ?><script type="text/javascript" src="<?= $base ?>../shared/SyntaxHighlighter/scripts/shBrush<?= $brush ?>.js"></script><?
  38. }
  39. }
  40. ?>
  41. <link rel="stylesheet" type="text/css" href="<?= $base ?>../shared/SyntaxHighlighter/styles/shCore.css">
  42. <link rel="stylesheet" type="text/css" href="<?= $base ?>../shared/SyntaxHighlighter/styles/shThemeDefault.css">
  43. <link rel="stylesheet" type="text/css" href="<?= $base ?>index.css">
  44. <?= $shell['html_head'] ?>
  45. </head>
  46. <body>
  47. <div id="page">
  48. <div id="header">
  49. <h1>
  50. <a href="http://benalman.com/" class="title"><b>Ben</b> Alman</a>
  51. <?
  52. $i = 1;
  53. while ( $shell["title$i"] ) {
  54. print ' &raquo; ';
  55. if ( $shell["link$i"] ) {
  56. print '<a href="' . $shell["link$i"] . '">' . $shell["title$i"] . '</a>';
  57. } else {
  58. print $shell["title$i"];
  59. }
  60. $i++;
  61. }
  62. ?>
  63. </h1>
  64. <?
  65. $i = 2;
  66. while ( $shell["h$i"] ) {
  67. print "<h$i>" . $shell["h$i"] . "</h$i>";
  68. $i++;
  69. }
  70. ?>
  71. <?= $shell['html_header'] ?>
  72. </div>
  73. <div id="content">
  74. <?= $shell['html_body'] ?>
  75. </div>
  76. <div id="footer">
  77. <p>
  78. If console output is mentioned, but your browser has no console, this example is using <a href="http://benalman.com/projects/javascript-debug-console-log/">JavaScript Debug</a>. Click this bookmarklet: <a href="javascript:if(!window.firebug){window.firebug=document.createElement(&quot;script&quot;);firebug.setAttribute(&quot;src&quot;,&quot;http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js&quot;);document.body.appendChild(firebug);(function(){if(window.firebug.version){firebug.init()}else{setTimeout(arguments.callee)}})();void (firebug);if(window.debug&&debug.setCallback){(function(){if(window.firebug&&window.firebug.version){debug.setCallback(function(b){var a=Array.prototype.slice.call(arguments,1);firebug.d.console.cmd[b].apply(window,a)},true)}else{setTimeout(arguments.callee,100)}})()}};">Debug + Firebug Lite</a> to add the Firebug lite console to the current page. Syntax highlighting is handled by <a href="http://alexgorbatchev.com/">SyntaxHighlighter</a>.
  79. </p>
  80. <p>
  81. All original code is Copyright &copy; 2010 "Cowboy" Ben Alman and dual licensed under the MIT and GPL licenses. View the <a href="http://benalman.com/about/license/">license page</a> for more details.
  82. </p>
  83. </div>
  84. </div>
  85. </body>
  86. </html><?
  87. }
  88. if ( count( get_included_files() ) == 2 ) {
  89. $shell['link2'] = '';
  90. $shell['h2'] = 'Select an example:';
  91. $shell['h3'] = '';
  92. $shell['html_body'] = '';
  93. $files = scandir( '.' );
  94. foreach ( $files as $file ) {
  95. if ( $file != '.' && $file != '..' && file_exists( "$file/index.php" ) ) {
  96. $file_contents = file_get_contents( "$file/index.php" );
  97. $title = preg_replace( '/^.*\$shell\[\'title3\'\]\s*=\s*"(.*?)";.*$/s', '$1', $file_contents );
  98. $title = $title == $file_contents ? $file : stripcslashes( $title );
  99. $shell['html_body'] .= "<a href=\"$file/\">$title</a><br>";
  100. }
  101. }
  102. $base = '';
  103. draw_shell();
  104. }
  105. ?>