index.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. $class = 'wiki-import';
  3. $page = (isset($_GET['page']) && $_GET['page']) ? $_GET['page'] : 'SLOODLE'; // todo
  4. $redirects = array(
  5. 'Download_Sloodle' => '/download',
  6. 'Repository_checkout_for_SLOODLE_2.x' => 'Repository_checkout_for_SLOODLE_2x',
  7. 'Repository_checkout_for_SLOODLE_1.x' => 'Repository_checkout_for_SLOODLE_1x',
  8. 'Quickstart_Sloodle_1.0' => 'Quickstart_Sloodle_10'
  9. );
  10. if (isset($redirects[$page])) {
  11. header('Location: '.$redirects[$page]);
  12. exit;
  13. }
  14. $dir = '';
  15. if (!preg_match('/^[A-Za-z0-9_-]+$/', $page) ) {
  16. header("HTTP/1.0 404 Not Found");
  17. exit;
  18. }
  19. if (preg_match('/^(.)(.)(.)/', $page, $matches)) {
  20. $dir = '/'.strtolower($matches[1]).'/'.strtolower($matches[2]).'/'.strtolower($matches[3]);
  21. }
  22. $title = 'SLOODLE Documentation';
  23. $file = dirname(__FILE__).'/wiki/articles'.$dir.'/'.$page.'.html';
  24. if (!file_exists($file)) {
  25. header("HTTP/1.0 404 Not Found");
  26. exit;
  27. }
  28. $contents = file_get_contents($file);
  29. if (preg_match('/\<title\>(.*?)\<\/title\>/s', $contents, $matches)) {
  30. $title = $matches[1];
  31. }
  32. $contents = preg_replace('/^.*?\<div id="mw-content-text.*?\>/s', '', $contents);
  33. $contents = preg_replace('/<div class="printfooter.*$/s', '', $contents);
  34. $contents = str_replace('../../../../images/', 'wiki/images/', $contents);
  35. $contents = preg_replace('#../../../../articles/\w/\w/\w/([A-Za-z0-9_-]+)\.html#', '${1}', $contents);
  36. $contents = str_replace('http://slisweb.sjsu.edu/sl/index.php/', '', $contents);
  37. $contents = str_replace('Wiki Frontpage', 'Document Top', $contents);
  38. $contents = preg_replace('/<table style="background-color:#ffffff; border:solid 1px #cccccc;">/', '<table style="background-color:light-gray; margin-left:0px; margin-top:10px; margin-bottom:10px;">', $contents);
  39. $contents = preg_replace('/<td style="background-color:#dddddd; font-weight:bold;"> Language Menu:/', '<td>Languages:', $contents);
  40. $sidebar = '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;';
  41. if (preg_match('/(\<table id="toc" class="toc"\>.*?\<\/table\>)/s', $contents, $matches)) {
  42. if (preg_match('/(\<ul\>.*\<\/ul\>)/s', $matches[1], $morematches)) {
  43. $sidebar = $morematches[1];
  44. $contents = preg_replace('/(\<table id="toc" class="toc"\>.*?\<\/table\>)/s', '', $contents);
  45. }
  46. }
  47. ?>
  48. <?php include(dirname(__FILE__).'/../include/header.php'); ?>
  49. <?php
  50. $contents = preg_replace('/SL_DISTRIBUTION_LOCATION/s', $sl_distribution_location, $contents);
  51. ?>
  52. <table id="content_table"><tr><td class="main">
  53. <div class="post" id="" style="width:100%">
  54. <?php print $contents; ?>
  55. <td style="vertical-align:top; padding:10px;">
  56. <?php print $sidebar; ?>
  57. </td>
  58. </td></tr></table>
  59. <?php include(dirname(__FILE__).'/../include/footer.php'); ?>