Example #1
0
/**
 * Validates regular expression
 *
 * @param string $path
 * @param array  $values
 *
 * @return array
 */
function validate_regex($path, $values)
{
    $result = array($path => '');
    if ($values[$path] == '') {
        return $result;
    }
    test_php_errormsg();
    $matches = array();
    // in libraries/List_Database.class.php _checkHideDatabase(),
    // a '/' is used as the delimiter for hide_db
    preg_match('/' . $values[$path] . '/', '', $matches);
    test_php_errormsg(false);
    if (isset($php_errormsg)) {
        $error = preg_replace('/^preg_match\\(\\): /', '', $php_errormsg);
        return array($path => $error);
    }
    return $result;
}
Example #2
0
/**
 * Validates regular expression
 *
 * @param string $path
 * @param array  $values
 * @return array
 */
function validate_regex($path, $values)
{
    $result = array($path => '');
    if ($values[$path] == '') {
        return $result;
    }
    test_php_errormsg();
    $matches = array();
    preg_match($values[$path], '', $matches);
    ob_end_clean();
    test_php_errormsg(false);
    if (isset($php_errormsg)) {
        $error = preg_replace('/^preg_match\\(\\): /', '', $php_errormsg);
        return array($path => $error);
    }
    return $result;
}