<?php
/**
* AbyssWS Pattern Matching
* Function: abyss_pattern_match()
*
* Created by: Joshua H. (TRUSTAbyss)
*/
function abyss_pattern_match($pattern, $string)
{
// Create an array with the characters to be converted.
$replace =
array('\\' =>
'\\\\',
'/' =>
'\/',
'\/' =>
'\/',
'.' =>
'\.',
'\.' =>
'\.',
'+' =>
'\+',
'\+' =>
'\+',
'\*' =>
'\*',
'*' =>
'.*',
'\?' =>
'\?',
'?' =>
'.',
'$' =>
'\$',
'\$' =>
'\$',
'(' =>
'\(',
'\(' =>
'\(',
')' =>
'\)',
'\)' =>
'\)',
'{' =>
'\{',
'\{' =>
'\{',
'}' =>
'\}',
'\}' =>
'\}',
'=' =>
'\=',
'\=' =>
'\=',
'!' =>
'\!',
'\\!' =>
'\!',
'<' =>
'\<',
'\<' =>
'\<',
'>' =>
'\>',
'\>' =>
'\>',
'|' =>
'\|',
'\|' =>
'\|',
':' =>
'\:',
'\:' =>
'\:',
'\-' =>
'\-',
'[!' =>
'[^',
'^' =>
'\^',
'\\^' =>
'\^',
'[^' =>
'[^',
'\[' =>
'\[',
'\]' =>
'\]');
// Return TRUE or FALSE based on the response of the preg_match() function.
}
// Here's a short example of this function. It's just like using the eregi() function
// but instead you get to match Abyss Web Server's patterns.
// This pattern will match sub folders containing mp2, mp3, or mp4 files.
$pattern = "/*/*.mp[2-4]";
// Here's a sample string to be compared.
$string = "/folder/file.mp3";
if (abyss_pattern_match($pattern, $string)) // A match was found.
{
echo "Congratulations! This pattern was successfully found within the string";
}
else // No pattern match.
{
echo "Looks like the pattern didn't match.";
}
?>