?> /** * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * Public License for more details. */ /** * Poseidon PHP Content Document * Author: Torben Jensen * Contact: Torben@GreyStork.com * * Automatic Site Map generation script for use as an * active PHP document in Poseidon content management system. * * Requirements: PCRE (Perl Compatible Regular Expressions) Support * * February 6, 2004: V1.1.2 * - Fixed a bug that prevented unregistered users from seeing anything but * menu items. * February 2, 2004: V1.1.1 * ! Modified the parseLinkTree function to use regular expressions. * January 31, 2004: V1.1.0 * + As it turned out, the overhead associated with regenerating the sitemap * every time the page is viewed is in fact negligible. Hence, I've added * an option that will make the manual update a thing of the past, unless * your server is really slow and you have a really complex site map tree. * It should be noted that generating the site map on-the-fly is safer, * since every single link is then checked against the user's credentials * instead of simply inheriting the credentials check for its menu item. * January 31, 2004: V1.0.0 * ! Admins will be able to update the site map at the click of a button. * ! When generating the site map, the script will parse HTML content and * search for links to other content items, i.e. URLs in the form * content.php?title=... or content.php?id=... * ! PHP content items will not be parsed - hence, links inside this type of * document will not show up in the site map. * ! Any identified link will only be followed once, thus preventing circular * recursive linking from resulting in infinite loops. */ /** * Set AutoGenerateSiteMap to false if your server can't handle the load * associated with generating a new sitemap every time it is viewed. */ $AutoGenerateSiteMap = true; $SiteMapVersion = "1.1.2"; $MenuSection = "Location"; $MenuItemText = "Site Map"; $MenuItemTooltip = "A bird''s eye view of this whole pile of spaghetti"; $MenuErrorText = "Failed to create menu item"; $UpdateButtonText = "Update"; $nl = chr(13) . chr(10); if (POSEIDON_VERSION >= "0.6" && !getPluginByName("SiteMap")) { $SiteMapCode = "\$sitemap = new plugin();" . $nl; $SiteMapCode .= "\$sitemap->name = \"SiteMap\";" . $nl; $SiteMapCode .= "\$sitemap->version = \"" . $SiteMapVersion."\";" . $nl; $SiteMapCode .= "\$sitemap->createMenuItem(\"" . $MenuSection . "\", \"" . $MenuItemText . "\", \"content.php?title=" . urlencode($item->title) . "\", \"" . $MenuItemTooltip . ".\", 0);" . $nl; if (!installPlugin ("SiteMap", $SiteMapVersion, "", $SiteMapCode, 1)) { print "
" . $MenuErrorText . ".
" . $nl; } } print "" . $nl; print "" . $nl; } print "" . $nl; /** * Function: parseLinkTree * * Parses linked HTML content items and returns a link tree * in an unordered list. * * Parameters: * * link - The link to follow. * parentlink - An array of links not to follow. * * Returns: * * String containing the link tree list. */ function parseLinkTree($link, &$parentlink) { global $userinfo; $nl = chr(13) . chr(10); $linkmatch = array(); if (array_search($link, $parentlink) === false) $parentlink[] = $link; else return ""; if (preg_match("/([^:]+?|)content\.php\?.*?(title|id)=([^\s]*)/i", $link, $linkmatch)) { if ($linkmatch[2] = "title") { $contentItem = getContentByTitle(urldecode($linkmatch[3])); if (count($contentItem) > 1) return ""; } else $contentItem = getContentById($linkmatch[3]); if ($contentItem === false || ($contentItem->userlevel && $userinfo->userlevel < $contentItem->userlevel)) return ""; } else return ""; $list = "