|\(.*?\))/', '', $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) { ///cho '

* Make all directories: ' . $destination_dir . '

' . "\n"; $dirs_to_create = array(); $dir = $destination_dir; while (!empty($dir) && !file_exists($dir)) { array_unshift($dirs_to_create, $dir); $dir = substr($dir, 0, strrpos($dir, '/')); } foreach ($dirs_to_create as $dir) { mkdir($dir, 0755); } if (!file_exists($destination_dir)) { printError('Failed to create directory: ' . $destination_dir); } } /** */ function parseCLIArguments() { if ($_SERVER['argc']) { for ($i = 1; $i < $_SERVER['argc'] && !$unknown_argument; $i++) { if (preg_match('/^\-+m/i', $_SERVER['argv'][$i])) { $i++; $_REQUEST['m'] = $_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) **/ ?>