inc/debug/relay/.htaccess -text
inc/debug/request_ -text
inc/debug/server/.htaccess -text
+inc/expression-functions.php -text
inc/extensions-functions.php -text
inc/extensions/.htaccess -text
inc/extensions/ext- -text
./inc/extensions/ext-yoomedia.php:55:// @TODO Only deprecated when 'network' is ready! setExtensionDeprecated('Y');
./inc/extensions-functions.php:379:// @TODO Change from ext_id to ext_name (not just even the variable! ;-) )
./inc/extensions-functions.php:492: // @TODO Extension is loaded, what next?
-./inc/filters.php:472: // @TODO This whole switch-block is very static
-./inc/filters.php:543: case 'config': // @TODO FILTER_COMPILE_CONFIG does not handle call-back functions so we handle it here again
./inc/functions.php:1010:// @TODO $simple is deprecated
./inc/functions.php:1045: // @TODO Do only use $content and deprecate $GLOBALS and $DATA in templates
./inc/functions.php:2521:// @TODO Please describe this function
--- /dev/null
+<?php
+/************************************************************************
+ * Mailer v0.2.1-FINAL Start: 04/12/2009 *
+ * =================== Last change: 04/12/2009 *
+ * *
+ * -------------------------------------------------------------------- *
+ * File : expression-functions.php *
+ * -------------------------------------------------------------------- *
+ * Short description : Expression callback functions *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung : Expression-Callback-Funktionen *
+ * -------------------------------------------------------------------- *
+ * $Revision:: $ *
+ * $Date:: $ *
+ * $Tag:: 0.2.1-FINAL $ *
+ * $Author:: $ *
+ * Needs to be in all Files and every File needs "svn propset *
+ * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2009 by Roland Haeder *
+ * For more information visit: http://www.mxchange.org *
+ * *
+ * 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. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
+ * MA 02110-1301 USA *
+ ************************************************************************/
+
+// Some security stuff...
+if (!defined('__SECURITY')) {
+ die();
+} // END - if
+
+// Expression call-back function for getCode() calls
+function doExpressionCode ($data) {
+ // Replace the code
+ $code = str_replace($data['matches'][0][$data['key']], "\" . getCode('" . $data['matches'][4][$data['key']] . "') . \"", $data['code']);
+
+ // Return replaced code
+ return $code;
+}
+
+// Expression call-back function for URLs
+function doExpressionUrl ($data) {
+ // Do we have JS-mode?
+ if ($data['callback'] == 'js') $data['mode'] = 1;
+
+ // Handle an URL here
+ $replacer = "\" . encodeUrl(\"" . $data['matches'][4][$data['key']] . "\", " . $data['mode'] . ") . \"";
+
+ // Replace it
+ $code = str_replace($data['matches'][0][$data['key']], $replacer, $data['code']);
+
+ // Return replaced code
+ return $code;
+}
+
+// Expression call-back function for reading data from $_SERVER
+function doExpressionServer ($data) {
+ // This will make 'foo_bar' to detectFooBar()
+ $functionName = "'detect' . implode('', array_map('ucfirst', explode('_', '" . $data['callback'] . "')))";
+
+ // Replace it
+ $code = str_replace($data['matches'][0][$data['key']], "\" . call_user_func(" . $functionName . ") . \"", $data['code']);
+
+ // Return replaced code
+ return $code;
+}
+
+// Expression call-back function for fetching user data
+function doExpressionUser ($data) {
+ // Use current userid by default
+ $functionName = 'getMemberId()';
+
+ // User-related data, so is there a userid?
+ if (!empty($data['matches'][4][$data['key']])) {
+ // Do we have a userid or $userid?
+ if ($data['matches'][4][$data['key']] == '$userid') {
+ // Use dynamic call
+ $functionName = "getFetchedUserData('userid', \$userid, '" . $data['callback'] . "')";
+ } elseif ($data['matches'][4][$data['key']] > 0) {
+ // User data found
+ $functionName = "getFetchedUserData('userid', " . $data['matches'][4][$data['key']] . ", " . $data['callback'] . "')";
+ }
+ } elseif ((!empty($data['callback'])) && (isUserDataValid())) {
+ // "Call-back" alias column for current logged in user's data
+ $functionName = "getUserData('" . $data['callback'] . "')";
+ }
+
+ // Do we have another function to run (e.g. translations)
+ if (!empty($extraFunction)) {
+ // Surround the original function call with it
+ $functionName = $extraFunction . '(' . $functionName . ')';
+ } // END - if
+
+ // Now replace the code
+ $code = str_replace($data['matches'][0][$data['key']], "\" . " . $functionName . " . \"", $data['code']);
+
+ // Return replaced code
+ return $code;
+}
+
+// Expression call-back function for getting extension data
+function doExpressionExt ($data) {
+ // Not installed is default
+ $replacer = 'false';
+
+ // Is the extension installed?
+ if (isExtensionInstalled($data['matches'][4][$data['key']])) {
+ // Construct call-back function name
+ $functionName = 'getExtension' . ucfirst(strtolower($data['callback']));
+
+ // Construct call of the function
+ $replacer = "\" . call_user_func_array('" . $functionName . "', array('" . $data['matches'][4][$data['key']] . "', true)) . \"";
+ } // END - if
+
+ // Replace it and insert parameter for GET request
+ $code = str_replace($data['matches'][0][$data['key']], sprintf("&ext=%s&ver=%s&rev=\" . getConfig('CURR_SVN_REVISION') . \"", $data['matches'][4][$data['key']], $replacer), $data['code']);
+
+ // Return replaced code
+ return $code;
+}
+
+// Expression call-back function for getting configuration data
+function doExpressionConfig ($data) {
+ // Read configuration
+ $configValue = getConfig($data['matches'][4][$data['key']]);
+
+ // Do we have a call-back?
+ if (!empty($data['callback'])) {
+ // Parse it through this function
+ $configValue = call_user_func_array($data['callback'], array($configValue));
+ } // END - if
+
+ // Replace the config entry
+ $code = str_replace($data['matches'][0][$data['key']], $configValue, $data['code']);
+
+ // Return replaced code
+ return $code;
+}
+
+// Expression call-back function for calling filters
+function doExpressionFilter ($data) {
+ // Construct replacement
+ $replacer = "\" . runFilterChain('" . $data['matches'][4][$data['key']] . "') . \"";
+
+ // Run the filter and insert result
+ $code = str_replace($data['matches'][0][$data['key']], $replacer, $data['code']);
+
+ // Return replaced code
+ return $code;
+}
+
+// [EOF]
+?>
// Filter for compiling expression code
function FILTER_COMPILE_EXPRESSION_CODE ($code) {
- // Compile {%cmd=some_value%} to get expression code snippets
+ // Compile {%cmd,callback,extraFunction=some_value%} to get expression code snippets
// See switch() command below for supported commands
preg_match_all('/\{%(([a-zA-Z0-9-_,]+)(=([^\}]+)){0,1})*%\}/', $code, $matches);
//* DEBUG: */ print('<pre>'.print_r($matches, true).'</pre>');
// Extract command and call-back
$cmdArray = explode(',', $cmd);
$cmd = $cmdArray[0];
- if (isset($cmdArray[1])) $callback = $cmdArray[1];
+ if (isset($cmdArray[1])) $callback = $cmdArray[1];
if (isset($cmdArray[2])) $extraFunction = $cmdArray[2];
- // Is the extension installed or code provided?
- // @TODO This whole switch-block is very static
- switch ($cmd) {
- case 'code': // Code asked for
- $code = str_replace($matches[0][$key], "\" . getCode('" . $matches[4][$key] . "') . \"", $code);
- break;
-
- case 'url':
- // Do we have JS-mode?
- if (substr($cmd, -2, 2) == 'js') $outputMode = 1;
-
- // Handle an URL here
- $replacer = "\" . encodeUrl(\"" . $matches[4][$key] . "\", " . $outputMode . ") . \"";
-
- // Replace it
- $code = str_replace($matches[0][$key], $replacer, $code);
- break;
-
- case 'server':
- // This will make 'foo_bar' to detectFooBar()
- $functionName = "'detect' . implode('', array_map('ucfirst', explode('_', '" . $callback . "')))";
-
- // Replace it
- $code = str_replace($matches[0][$key], "\" . call_user_func(" . $functionName . ") . \"", $code);
- break;
-
- case 'user':
- // Use current userid by default
- $functionName = 'getMemberId()';
-
- // User-related data, so is there a userid?
- if (!empty($matches[4][$key])) {
- // Do we have a userid or $userid?
- if ($matches[4][$key] == '$userid') {
- // Use dynamic call
- $functionName = "getFetchedUserData('userid', \$userid, '" . $callback . "')";
- } elseif ($matches[4][$key] > 0) {
- // User data found
- $functionName = "getFetchedUserData('userid', " . $matches[4][$key] . ", " . $callback . "')";
- } // END - if
- } elseif ((!empty($callback)) && (isUserDataValid())) {
- // "Call-back" alias column for current logged in user's data
- $functionName = "getUserData('" . $callback . "')";
- }
-
- // Do we have another function to run (e.g. translations)
- if (!empty($extraFunction)) {
- // Surround the original function call with it
- $functionName = $extraFunction . '(' . $functionName . ')';
- } // END - if
-
- // Now replace the code
- $code = str_replace($matches[0][$key], "\" . " . $functionName . " . \"", $code);
- break;
-
- case 'ext':
- // Not installed is default
- $replacer = 'false';
-
- // Is the extension installed?
- if (isExtensionInstalled($matches[4][$key])) {
- // Construct call-back function name
- $functionName = 'getExtension' . ucfirst(strtolower($callback));
-
- // Construct call of the function
- $replacer = "\" . call_user_func_array('" . $functionName . "', array('" . $matches[4][$key] . "', true)) . \"";
- } // END - if
-
- // Replace it and insert parameter for GET request
- $code = str_replace($matches[0][$key], sprintf("&ext=%s&ver=%s&rev=\" . getConfig('CURR_SVN_REVISION') . \"", $matches[4][$key], $replacer), $code);
- break;
-
- case 'config': // @TODO FILTER_COMPILE_CONFIG does not handle call-back functions so we handle it here again
- // Read configuration
- $configValue = getConfig($matches[4][$key]);
-
- // Do we have a call-back?
- if (!empty($callback)) {
- // Parse it through this function
- $configValue = call_user_func_array($callback, array($configValue));
- } // END - if
-
- // Replace the config entry
- $code = str_replace($matches[0][$key], $configValue, $code);
- break;
-
- case 'filter':
- // Construct replacement
- $replacer = "\" . runFilterChain('" . $matches[4][$key] . "') . \"";
-
- // Run the filter and insert result
- $code = str_replace($matches[0][$key], $replacer, $code);
- break;
-
- default:
- // Unsupported command detected
- debug_report_bug('Command=' . $cmd . ', callback=' . $callback . ', extra=' . $extraFunction . ' is unsupported.');
- break;
- } // END - switch
+ // Construct call-back function name for the command
+ $commandFunction = 'doExpression' . ucfirst(strtolower($cmd));
+
+ // Is this function there?
+ if (function_exists($commandFunction)) {
+ // Prepare $matches, $key, $outputMode, etc.
+ $data = array(
+ 'matches' => $matches,
+ 'key' => $key,
+ 'mode' => $outputMode,
+ 'code' => $code,
+ 'callback' => $callback
+ );
+
+ // Call it
+ $code = call_user_func($commandFunction, $data);
+ } else {
+ // Unsupported command detected
+ debug_report_bug('Command=' . $cmd . ', callback=' . $callback . ', extra=' . $extraFunction . ' is unsupported.');
+ }
} // END - foreach
} // END - if
} // END - if
// Three different ways to debug...
- /* DEBUG: */ debug_report_bug(sprintf("%s[%s:] URL=%s", __FUNCTION__, __LINE__, $URL));
+ //* DEBUG: */ debug_report_bug(sprintf("%s[%s:] URL=%s", __FUNCTION__, __LINE__, $URL));
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'URL=' . $URL);
//* DEBUG: */ die($URL);
} // END - if
// Load more function libraries or includes
-foreach (array('functions', 'request-functions', 'session-functions', 'code-functions', 'language-functions', 'sql-functions', 'filter-functions', 'filters', 'mysql-manager', 'extensions-functions', 'handler') as $lib) {
+foreach (array('functions', 'request-functions', 'session-functions', 'code-functions', 'language-functions', 'sql-functions', 'expression-functions', 'filter-functions', 'filters', 'mysql-manager', 'extensions-functions', 'handler') as $lib) {
// Load special functions
loadIncludeOnce('inc/' . $lib . '.php');
} // END - foreach