tor-android/external/badvpn_dns/blog_generator/blog_functions.php

36 lines
895 B
PHP
Raw Normal View History

2015-01-25 11:08:34 +00:00
<?php
function tokenize ($str, &$out) {
$out = array();
while (strlen($str) > 0) {
if (preg_match('/^\\/\\/.*/', $str, $matches)) {
$str = substr($str, strlen($matches[0]));
}
else if (preg_match('/^\\s+/', $str, $matches)) {
$str = substr($str, strlen($matches[0]));
}
else if (preg_match('/^[0-9]+/', $str, $matches)) {
$out[] = array('number', $matches[0]);
$str = substr($str, strlen($matches[0]));
}
else if (preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*/', $str, $matches)) {
$out[] = array('name', $matches[0]);
$str = substr($str, strlen($matches[0]));
}
else {
return FALSE;
}
}
return TRUE;
}
function fatal_error ($message)
{
fwrite(STDERR, "Fatal error: $message\n");
ob_get_clean();
exit(1);
}