mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-11-29 08:56:03 +00:00
Kinda working with both Lightning & Evolution now. About to restructure to
add TODO items and make certain queries easier.
This commit is contained in:
1 parent
acc28c0faa
commit
a57d690167
27 files changed
+2879
-2107
No files matched your search
@@ -52,4 +52,35 @@ if ( !function_exists("session_validate_password") ) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( !function_exists("replace_uri_params") ) {
|
||||
/**
|
||||
* Given a URL (presumably the current one) and a parameter, replace the value of parameter,
|
||||
* extending the URL as necessary if the parameter is not already there.
|
||||
* @param string $uri The URI we will be replacing parameters in.
|
||||
* @param array $replacements An array of replacement pairs array( "replace_this" => "with this" )
|
||||
* @return string The URI with the replacements done.
|
||||
*/
|
||||
function replace_uri_params( $uri, $replacements ) {
|
||||
$replaced = $uri;
|
||||
foreach( $replacements AS $param => $new_value ) {
|
||||
$rxp = preg_replace( '/([\[\]])/', '\\\\$1', $param ); // Some parameters may be arrays.
|
||||
$regex = "/([&?])($rxp)=([^&]+)/";
|
||||
dbg_error_log("core", "Looking for [%s] to replace with [%s] regex is %s and searching [%s]", $param, $new_value, $regex, $replaced );
|
||||
if ( preg_match( $regex, $replaced ) )
|
||||
$replaced = preg_replace( $regex, "\$1$param=$new_value", $replaced);
|
||||
else
|
||||
$replaced .= "&$param=$new_value";
|
||||
}
|
||||
if ( ! preg_match( '/\?/', $replaced ) ) {
|
||||
$replaced = preg_replace("/&(.+)$/", "?\$1", $replaced);
|
||||
}
|
||||
$replaced = str_replace("&", "--AmPeRsAnD--", $replaced);
|
||||
$replaced = str_replace("&", "&", $replaced);
|
||||
$replaced = str_replace("--AmPeRsAnD--", "&", $replaced);
|
||||
dbg_error_log("core", "URI <<$uri>> morphed to <<$replaced>>");
|
||||
return $replaced;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in new issue
Block a user