'reverted' old-style update-process; removed billing-classes, -functions and -templates; some sql-fixes;
57 lines
1.6 KiB
PHP
57 lines
1.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* This file is part of the SysCP project.
|
|
* Copyright (c) 2003-2009 the SysCP Team (see authors).
|
|
*
|
|
* For the full copyright and license information, please view the COPYING
|
|
* file that was distributed with this source code. You can also view the
|
|
* COPYING file online at http://files.syscp.org/misc/COPYING.txt
|
|
*
|
|
* @copyright (c) the authors
|
|
* @author Florian Lippert <flo@syscp.org>
|
|
* @license GPLv2 http://files.syscp.org/misc/COPYING.txt
|
|
* @package Functions
|
|
* @version $Id: function.replace_variables.php 2724 2009-06-07 14:18:02Z flo $
|
|
*/
|
|
|
|
/**
|
|
* Replaces all occurences of variables defined in the second argument
|
|
* in the first argument with their values.
|
|
*
|
|
* @param string The string that should be searched for variables
|
|
* @param array The array containing the variables with their values
|
|
* @return string The submitted string with the variables replaced.
|
|
* @author Michael Duergner
|
|
*/
|
|
|
|
function replace_variables($text, $vars)
|
|
{
|
|
$pattern = "/\{([a-zA-Z0-9\-_]+)\}/";
|
|
|
|
// --- martin @ 08.08.2005 -------------------------------------------------------
|
|
// fixing usage of uninitialised variable
|
|
|
|
$matches = array();
|
|
|
|
// -------------------------------------------------------------------------------
|
|
|
|
if(count($vars) > 0
|
|
&& preg_match_all($pattern, $text, $matches))
|
|
{
|
|
for ($i = 0;$i < count($matches[1]);$i++)
|
|
{
|
|
$current = $matches[1][$i];
|
|
|
|
if(isset($vars[$current]))
|
|
{
|
|
$var = $vars[$current];
|
|
$text = str_replace("{" . $current . "}", $var, $text);
|
|
}
|
|
}
|
|
}
|
|
|
|
$text = str_replace('\n', "\n", $text);
|
|
return $text;
|
|
}
|