[b0cbbf]: index.php Maximize Restore History

Download this file

index.php    145 lines (126 with data), 6.2 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?
function formatDocs($filename, $title='') {
$content = file_get_contents($filename);
$content = str_replace("\n",'[\n]', $content);
// Fix links to man pages.
$content = preg_replace('/<a href="([\/\w]+)\.html(\#?\w*)">([^<]+)<\/a>/',
'<a href="?docs=$1&amp;title=$3$2">$3</a>', $content);
$content = preg_replace('/<a href="(PP-Inline)\.html(\#?\w*)">([^<]+)<\/a>/',
'<a href="?docs=$1&amp;title=$3$2">$3</a>',$content);
// External modules -- link to search.cpan.org: they WILL have it!
// Note that this is not perfect. There's some complication because we don't know how many / to replace with ::. My REGEX-fu is probably not up to snuff.
// It assumes that starting the URL with ../ means that it is out of the PDL namespace, and therefore an external module. But if the current doc is (say) PDL::IO::FITS and we want to link to PDL::Core, then there will be some leading ../ but still within the namespace. There's only so much DAL can do with PHP--I think the problem is with pod2html, honestly. Anyway, it's no worse than the previous solution (kept, but commented, below). Note that this way there is no way to specifically go to any anchored section on the page, because of the CPAN redirect, so we just drop it. Ultimately we should just link to metacpan, but they have no docs for modules that come from .pd files, so we're stuck for now.
if (preg_match_all('/<a href="..\/([\/\w]+)\.html(\#?\w*)">/',$content,$matches,PREG_SET_ORDER)) {
// print "<pre>I matched " . count($matches) . " times!\n";
for ($i=0; $i<count($matches);$i++){
$string = $matches[$i][1];
$pkg_delim = preg_replace('|/|','::',$string);
//print "replacing $string with $pkg_delim\n";
$content = preg_replace("|<a href=\"..\/($string)\.html(\#?\w*)\">([^<]+)<\/a>|",
"<a href=\"http://search.cpan.org/perldoc?$pkg_delim\">$3</a>",$content);
}
} //else {
//print "I didn't match!\n";
//}
//print "</pre>";
// This was the original version, which was also not perfect.
// External modules -- link to perldoc.perl.org and hope they have it.
// $content = preg_replace('/<a href="..\/([\/\w]+)\.html(\#?\w*)">/',
// '<a href="http://perldoc.perl.org/$1.html$2">', $content);
// Remove body tags.
$content = preg_replace('/^.*<body[^>]*>/', '', $content);
$content = preg_replace('/<\/body>.*$/', '', $content);
// Finished.
$content = str_replace('[\n]', "\n", $content);
$content = preg_replace('/\n+/', "\n", $content);
return "
<b>See also:</b> <a href='?page=function-ref'>How do I search for a function?</a>
<h1 class='title'>$title</h1>
<div class='pod'>$content</div>
";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head profile="http://www.w3.org/2005/10/profile">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Perl Data Language</title>
<link rel="shortcut icon" href="images/favicon.ico"
type="image/vnd.microsoft.icon" />
<link rel="stylesheet" type="text/css"
href="http://www.google.com/cse/style/look/espresso.css" />
<link rel='stylesheet' type='text/css' href='google-search.css' />
<link rel="stylesheet" type="text/css"
href="css/jquery-ui-1.8.2.custom.css" />
<link rel='stylesheet' type='text/css' href='pdl.css' />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"
type="text/javascript"></script>
<script type="text/javascript" src="js/jquery.cycle.all.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.2.custom.min.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-17388934-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script');
ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<!-- BANNER -->
<div class="banner">
<a href="index.php?page=home">
<img src="images/icons/pdl.png" alt="PDL" height="79px" width="146px"/>
</a>
<img src="images/banners/pos-1-opt-<?=rand(0,2)?>.jpg" alt="Banner image1" height="79px" width="278px"/>
<img src="images/banners/pos-2-opt-<?=rand(0,2)?>.jpg" alt="Banner image2" height="79px" width="93px"/>
<img src="images/banners/pos-4-opt-<?=rand(0,1)?>.jpg" alt="Banner image3" height="79px" width="110px" style="margin-left: 25px"/>
<div id="cse-search-form" style="position: absolute; top: 20px; left: 700px">Loading</div>
</div>
<!-- END BANNER -->
<!-- SIDE BAR -->
<div class="sidebar-container">
<? include "content/sidebar.html" ?>
</div>
<!-- END SIDE BAR -->
<!-- END GOOGLE SEARCH -->
<table id="cse-container">
<tr>
<td id="cse"></td>
</tr>
</table>
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
google.load('search', '1', {language : 'en'});
google.setOnLoadCallback(function() {
var customSearchControl = new google.search.CustomSearchControl('005624475199589227813:0cr_qvao0qc');
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
var options = new google.search.DrawOptions();
options.setSearchFormRoot('cse-search-form');
options.setAutoComplete(true);
customSearchControl.draw('cse', options);
}, true);
</script>
<!-- END GOOGLE SEARCH -->
<!-- MAIN CONTENT -->
<div class="main">
<?
function issane($string) {
return preg_match('/^[-_a-zA-Z0-9\/]+$/',$string);
}
if (isset($_GET['page']) && issane($_GET['page'])) {
require_once "content/".$_GET['page'].".html";
} elseif (isset($_GET['docs']) && issane($_GET['docs'])) {
echo formatDocs("PDLdocs/".$_GET['docs'].".html",$_GET['title']);
} else {
require_once "content/home.html";
}
?>
</div>
<!-- END CONTENT -->
</body>
</html>