Documente Academic
Documente Profesional
Documente Cultură
php
################################################################################
# GraphViz Site Map Generator
# Author: Michael Angeles (http://urlgreyhot.com/)
# Copyright (c) 2002-2003, Michael Angeles
# http://urlgreyhot.com/graphviz/
#
# This script sends UNIX shell commands to graphviz in order to generate
# site maps from tab-delimmited files. To get this to work, you will need
# to have GraphViz (dot, neato) installed on your server. For details about
# AT&T Labs' GraphViz application, see http://graphviz.org
#
# I'd be happy to know if you are able to use this script somewhere. Send me
# email (michael@studioid.com) if you do.
#
# GraphViz Site Map Generator comes with ABSOLUTELY NO WARRANTY.
# This is free software, and you are welcome to redistribute it
# under certain conditions. See http://urlgreyhot.com/graphviz/LICENSE
# for details.
###############################################################################
################################################################################
# INSTALLATION
################################################################################
################################################################################
# CONFIGURATION
################################################################################
# 1. The 2 following variables refer to the SAME directory where your script
# is located/installed
# 1a. Server path (without trailing slash)
$base = "/usr/www/users/jibjab/graphviz";
# 1b. URL (without trailing slash)
$baseurl = "http://urlgreyhot.com/graphviz";
function page_footer() {
global $baseurl;
global $vers;
echo "
<div id=\"Footer\"><p><a href=\"http://urlgreyhot.com\">UrlGreyHot</a> | <a
href=\"$baseurl\">GraphViz Sitemap Generator</a></p></div>
</body></html>";
}
################################################################################
# do stuff
################################################################################
page_header();
global $baseurl;
global $filedir;
// execute modules
if ($q) {
$a1 = sanitize($a1,SYSTEM);
$a2 = sanitize($a2,SYSTEM);
$a3 = sanitize($a3,SYSTEM);
$mod = sanitize($q,SYSTEM);
module_invoke($mod, $a1, $a2, $a3);
} else {
}
// error checking
elseif ( ($submit=="Submit") && (($fname=='') || ($fupload=='')) ){
echo '<h1><a href=\"$baseurl\">GraphViz sitemap generator</a> / Error</h1><p
class="error">The following errors were detected:</p><blockquote>';
if ($fname=='') {
echo '<p>You need to enter a name for your diagram.</p>';
}
if ($fupload=='') {
echo '<p>You need to select a tab delimmited file to submit.</p>';
}
echo '</blockquote><p><a href="javascript:history.go(-1);">« Go back and
try again.</a></p>';
} else {
// process file
if (
(is_uploaded_file( $file_array['tmp_name'] ))
// && (!eregi("application", $file_array['type']))
// && (!eregi("image", $file_array['type']))
&& (!eregi(" ", $fname))
)
{
// link to image
view($fname);
} else {
error("Sorry. Your diagram cannot be processed. Likely cause may be
that you have a space in your project name or your file is not in ASCII (plain
text) format");
} // end process file
} // submit form
}
page_footer();
################################################################################
# modules
################################################################################
// create svg
passthru("$dotbase/$layout -o $base/output/$a1.svg -Tsvg $base/input/$a1.dot");
/* open file, remove comment and rewrite file */
function view($a1)
{
global $baseurl;
echo "<h1><a href=\"$baseurl\">GraphViz sitemap generator</a> / $a1</h1>
<a href=\"$baseurl/output/$a1.map\"><img src=\"$baseurl/output/$a1.gif\"
ismap=\"ismap\" border=\"0\" ></a><br /><br />
<small>
<b>Please note</b>. All files generated by this application are removed DAILY at
midnight, Eastern Time. You must save your work locally. No files will be
archived.<br /><br />
GIF: <a href=\"$baseurl/output/$a1.gif\">$baseurl/output/$a1.gif</a><br />
SVG: <a href=\"$baseurl/output/$a1.svg\">$baseurl/output/$a1.svg</a><br />
Image Map: <a href=\"$baseurl/output/$a1.txt\">$baseurl/output/$a1.map</a><br />
</small>";
}
function viewsitemap($a1)
{
global $baseurl;
echo "<a href=\"$baseurl/output/$a1.map\"><img src=\"$baseurl/output/$a1.gif\"
ismap=\"ismap\" border=\"0\" ></a><br /><br />";
}
// version info
function vers(){
global $baseurl;
echo "
<h1><a href=\"$baseurl\">GraphViz sitemap generator</a> / Version info</h1>
<b>0.1</b><br />
First version released with minimal configuration options.<br />
<br />
<b>0.1.1</b><br />
Fixed bug caused by single and double quotes in upload files.<br />
<br />
<b>0.2</b><br />
Added layout, shape and style attributes.<br />
<br />
<b>0.3</b><br />
Fixed bug that was producing unusable SVG output. SVG files should now work, but
font size is rather large.<br />
<br />
<b>0.4</b><br />
Added minor feature to break up labels by using a newline marker <nl> in tab
delimmited file.<br />
<br />
<b>0.5</b><br />
Added error recovery messages.<br />
<br />
<b>0.5.1</b><br />
Added direct links to view a) image map, b) gif and c) sitemap without
navigation links. Set SVG files with smaller fonts to make more readable. Released
under GPL.<br />
<br />
<b>0.5.2</b><br />
Added some installation documentation and import_request_variables('GPC'); per
Gilbert Grosdidier's suggestion.<br />
<br />
<b>0.5.3</b><br />
Fixed bug when using tab character instead of \t in replacement string.<br />
<br />
";
}
// error messages
function error($msg) {
echo "<h1>Error</h1><p>$msg</p>";
}
################################################################################
?>