Update of /cvsroot/php-blog/serendipity/include
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3575/include
Modified Files:
functions.inc.php plugin_api.inc.php
Log Message:
* allow unlimited ammount of nested directories inside plugin directory(see mailinglist)
* unify "get current url" for plugins: karma, templatedropdown, shoutbox
Index: plugin_api.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/plugin_api.inc.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- plugin_api.inc.php 6 Dec 2004 10:46:32 -0000 1.7
+++ plugin_api.inc.php 6 Dec 2004 12:45:42 -0000 1.8
@@ -65,8 +65,9 @@
$key = $plugin_class_id . ':' . $id;
- // Secure Plugin path. Only one directory level allowed.
- $pluginPath = str_replace('/', '', serendipity_db_escape_string($pluginPath));
+ // Secure Plugin path. No leading slashes, no backslashes, no "up" directories
+ $pluginPath = preg_replace('@^(/)@', '', $pluginPath);
+ $pluginPath = str_replace(array('..', "\\"), array('', '/'), serendipity_db_escape_string($pluginPath));
$rs = serendipity_db_query("SELECT MAX(sort_order) as sort_order_max FROM {$serendipity['dbPrefix']}plugins WHERE placement = '$default_placement'", true, 'num');
@@ -164,7 +165,7 @@
return $classes;
}
- function traverse_plugin_dir($ppath, &$classes, $event_only) {
+ function traverse_plugin_dir($ppath, &$classes, $event_only, $maindir = '') {
$d = @opendir($ppath);
if ($d) {
while (($f = readdir($d)) !== false) {
@@ -177,8 +178,17 @@
continue;
}
- // Instead of only looking for directories, search for whiles within subdirectories
+ // Instead of only looking for directories, search for files within subdirectories
while (($subf = readdir($subd)) !== false) {
+ if ($subf{0} == '.' || $subf == 'CVS') {
+ continue;
+ }
+
+ if (is_dir($ppath . '/' . $f . '/' . $subf) && $maindir != $ppath . '/' . $f) {
+ // Search for another level of subdirectories
+ serendipity_plugin_api::traverse_plugin_dir($ppath . '/' . $f, $classes, $event_only, $f . '/');
+ }
+
if (!preg_match('@^[^_]+_(event|plugin)_.+\.php$@i', $subf)) {
continue;
}
@@ -203,7 +213,7 @@
$class_name = str_replace('.php', '', $subf);
$classes[$class_name] = array('name' => $class_name,
- 'pluginPath' => $f);
+ 'pluginPath' => $maindir . $f);
}
}
}
Index: functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/functions.inc.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- functions.inc.php 2 Dec 2004 14:11:27 -0000 1.9
+++ functions.inc.php 6 Dec 2004 12:45:30 -0000 1.10
@@ -574,6 +574,25 @@
return (strpos($d, "\r") === false && strpos($d, "\n") === false);
}
+function serendipity_currentURL() {
+ global $serendipity;
+
+ // All that URL getting humpty-dumpty is necessary to allow a user to change the template in the
+ // articles view. POSTing data to that page only works with mod_rewrite and not the ErrorDocument
+ // redirection, so we need to generate the ErrorDocument-URI here.
+
+ $uri = parse_url($_SERVER['REQUEST_URI']);
+ $qst = '';
+ if (!empty($uri['query'])) {
+ $qst = '&' . str_replace('&', '&', $uri['query']);
+ }
+ $uri['path'] = str_replace($serendipity['serendipityHTTPPath'], '', $uri['path']);
+ $url = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?' . $uri['path'] . $qst;
+ $url = str_replace($serendipity['indexFile'] . '&', '', $url); // Kill possible looped repitions which could occur
+
+ return $url;
+}
+
define("serendipity_FUNCTIONS_LOADED", true);
/* vim: set sts=4 ts=4 expandtab : */
?>
|