|\(.*?\))/', '', $text);
$text = preg_replace('/\'s/', '', $text);
$text = strtolower(trim($text));
$poss_id = preg_replace('/\s+/', '_', $text);
$id = $poss_id;
$counter = 1;
while (isset($seen_ids[$id]))
{
$id = $poss_id . '_' . $counter;
$counter++;
}
$seen_ids[$id] = true;
return $id;
}
/** generateID($text) **/
function mkAllDir($destination_dir, $mode)
{
echo '
* Make all directories: ' . $destination_dir . '
' . "\n";
$dirs_to_create = array();
$dir = $destination_dir;
while (!empty($dir) && !file_exists($dir))
{
echo 'Does not exist - create...
';
array_unshift($dirs_to_create, $dir);
$dir = substr($dir, 0, strrpos($dir, '/'));
echo 'Testing for the existance of: ' . $dir . '
';
}
foreach ($dirs_to_create as $dir)
{
if (!file_exists($dir))
{
mkdir($dir, 0755);
}
}
if (!file_exists($destination_dir))
{
printError('Failed to create directory: ' . $destination_dir);
}
}
/**
*/
function parseCLIArguments()
{
if (isset($_SERVER['argc']) && $_SERVER['argc'] > 0)
{
for ($i = 1; $i < $_SERVER['argc'] && !$unknown_argument; $i++)
{
if (preg_match('/^\-+(l|m)/i', $_SERVER['argv'][$i], $matches))
{
$i++;
$_REQUEST[$matches[1]] = $_SERVER['argv'][$i];
}
else
{
return false;
}
}
}
return true;
}
/** parseCLIArguments() **/
/**
*/
function printError($message, $is_fatal=true)
{
if ($is_fatal)
{
exit('Error! ' . $message . "
\n");
}
else
{
echo 'Error! ' . $message . "
\n";
}
}
/** printError($message) **/
?>