Пример #1
0
function strip_combining_chars($str)
{
    $chars = preg_split('//u', $str, -1, PREG_SPLIT_NO_EMPTY);
    $str = '';
    foreach ($chars as $char) {
        $o = 0;
        $ord = ordutf8($char, $o);
        if ($ord >= 768 && $ord <= 879 || $ord >= 1536 && $ord <= 1791 || $ord >= 3655 && $ord <= 3659 || $ord >= 7616 && $ord <= 7679 || $ord >= 8400 && $ord <= 8447 || $ord >= 65056 && $ord <= 65071) {
            continue;
        }
        $str .= $char;
    }
    return $str;
}
Пример #2
0
     }
 }
 if ($config['allowed_tags'] && $post['op'] && isset($_POST['tag']) && $_POST['tag'] && isset($config['allowed_tags'][$_POST['tag']])) {
     $post['body'] .= "\n<tinyboard tag>" . $_POST['tag'] . "</tinyboard>";
 }
 if (mysql_version() >= 50503) {
     $post['body_nomarkup'] = $post['body'];
     // Assume we're using the utf8mb4 charset
 } else {
     // MySQL's `utf8` charset only supports up to 3-byte symbols
     // Remove anything >= 0x010000
     $chars = preg_split('//u', $post['body'], -1, PREG_SPLIT_NO_EMPTY);
     $post['body_nomarkup'] = '';
     foreach ($chars as $char) {
         $o = 0;
         $ord = ordutf8($char, $o);
         if ($ord >= 0x10000) {
             continue;
         }
         $post['body_nomarkup'] .= $char;
     }
 }
 $post['tracked_cites'] = markup($post['body'], true, $post['op']);
 if ($post['has_file']) {
     $allhashes = '';
     foreach ($post['files'] as $key => &$file) {
         if ($post['op'] && $config['allowed_ext_op']) {
             if (!in_array($file['extension'], $config['allowed_ext_op'])) {
                 error($config['error']['unknownext']);
             }
         } elseif (!in_array($file['extension'], $config['allowed_ext']) && !in_array($file['extension'], $config['allowed_ext_files'])) {
Пример #3
0
function mod_new_board()
{
    global $config, $board;
    if (!hasPermission($config['mod']['newboard'])) {
        error($config['error']['noaccess']);
    }
    if (isset($_POST['uri'], $_POST['title'], $_POST['subtitle'])) {
        if ($_POST['uri'] == '') {
            error(sprintf($config['error']['required'], 'URI'));
        }
        if ($_POST['title'] == '') {
            error(sprintf($config['error']['required'], 'title'));
        }
        if (!preg_match('/^' . $config['board_regex'] . '$/u', $_POST['uri'])) {
            error(sprintf($config['error']['invalidfield'], 'URI'));
        }
        $bytes = 0;
        $chars = preg_split('//u', $_POST['uri'], -1, PREG_SPLIT_NO_EMPTY);
        foreach ($chars as $char) {
            $o = 0;
            $ord = ordutf8($char, $o);
            if ($ord > 0x80) {
                $bytes += 5;
            } else {
                $bytes++;
            }
        }
        $bytes + strlen('posts_.frm');
        if ($bytes > 255) {
            error('Your filesystem cannot handle a board URI of that length (' . $bytes . '/255 bytes)');
            exit;
        }
        if (openBoard($_POST['uri'])) {
            error(sprintf($config['error']['boardexists'], $board['url']));
        }
        $query = prepare('INSERT INTO ``boards`` VALUES (:uri, :title, :subtitle)');
        $query->bindValue(':uri', $_POST['uri']);
        $query->bindValue(':title', $_POST['title']);
        $query->bindValue(':subtitle', $_POST['subtitle']);
        $query->execute() or error(db_error($query));
        modLog('Created a new board: ' . sprintf($config['board_abbreviation'], $_POST['uri']));
        if (!openBoard($_POST['uri'])) {
            error(_("Couldn't open board after creation."));
        }
        $query = Element('posts.sql', array('board' => $board['uri']));
        if (mysql_version() < 50503) {
            $query = preg_replace('/(CHARSET=|CHARACTER SET )utf8mb4/', '$1utf8', $query);
        }
        query($query) or error(db_error());
        if ($config['cache']['enabled']) {
            cache::delete('all_boards');
        }
        // Build the board
        buildIndex();
        rebuildThemes('boards');
        header('Location: ?/' . $board['uri'] . '/' . $config['file_index'], true, $config['redirect_http']);
    }
    mod_page(_('New board'), 'mod/board.html', array('new' => true, 'token' => make_secure_link_token('new-board')));
}
Пример #4
0
</script>
</head>
<body onLoad='init()'>

<table class='rmenuobj' cellpadding=0 cellspacing=0 width=100%>
<?php 
function ordutf8($s)
{
    if (function_exists("mb_convert_encoding")) {
        list(, $ret) = unpack('N', mb_convert_encoding(mb_strtolower($s), 'UCS-4BE', 'UTF-8'));
    } else {
        $ret = ord(strtolower($s));
    }
    return $ret;
}
foreach ($files as $key => $data) {
    $key = trim($key);
    $chr = ordutf8($key);
    if ($key === '.') {
        echo "<tr><td code='" . rawurlencode($data) . "' id='root' class='rmenuitemselected' nowrap onclick='menuClick(this); return false;' ondblclick='menuDblClickAndExit(this); return false;'>";
    } else {
        echo "<tr><td code='" . rawurlencode($data) . "' class='rmenuitem' id='i" . $chr . "' nowrap onclick='menuClick(this); return false;' ondblclick='menuDblClick(this); return false;'>";
    }
    echo "&nbsp;&nbsp;";
    echo $key;
    echo "</td></tr>";
}
?>
</table>
</body>
Пример #5
0
function trimhousenumbers($housenumber)
{
    echo "Input: " . $housenumber . PHP_EOL;
    $numbers = preg_split('/;/', $housenumber, -1, PREG_SPLIT_NO_EMPTY);
    asort($numbers);
    natsort($numbers);
    $numbers = array_values($numbers);
    print_r($numbers);
    $hexes = array();
    $output = array();
    $alfa = array();
    $nume = array();
    $first = $last = null;
    foreach ($numbers as $this_number) {
        // filter out numbers with dot in
        $pos = strpos($this_number, '.');
        if ($pos !== false) {
            continue;
        }
        // filter out numbers with / in
        $pos = strpos($this_number, '/');
        if ($pos !== false) {
            continue;
        }
        if (ctype_digit($this_number)) {
            $nume[] = $this_number;
        } elseif (ctype_alnum($this_number)) {
            $alfa[] = $this_number;
        } else {
            // drop whatever else
        }
    }
    // echo "NUME\n";
    // print_r($nume);
    foreach ($nume as $this_number) {
        if ($first === null) {
            $first = $last = $this_number;
        }
        if ($last < $this_number - 1) {
            if (is_numeric($this_number)) {
                $output[] = $first == $last ? $first : $first . '-' . $last;
            }
            $first = $last = $this_number;
        } else {
            $last = $this_number;
        }
    }
    //if (count($output)) {
    $output[] = $first == $last ? $first : $first . '-' . $last;
    //}
    //echo "OUTPUT" . PHP_EOL;
    //print_r($output);
    foreach ($alfa as $this_number) {
        if (!is_integer($this_number)) {
            $this_number = trim($this_number);
            if (preg_match("/([0-9]+)([A-Z+])/ui", $this_number, $match)) {
                // if (preg_match("/[^[:alnum:]]/u", $this_number))
                // print_r($match);
                if (isset($match[1])) {
                    if (!isset($hexes[$match[1]], $hexes)) {
                        $hexes[$match[1]] = $match[2];
                    } else {
                        $hexes[$match[1]] .= ';' . $match[2];
                    }
                }
            }
        }
    }
    //echo "HEXES" . PHP_EOL;
    //print_r($hexes);
    //exit;
    $res = array();
    foreach ($hexes as $k => $v) {
        $ranges = array();
        $chars = preg_split('/;/', $v, -1, PREG_SPLIT_NO_EMPTY);
        $first = $last = null;
        foreach ($chars as $char) {
            // echo "ORD : (".$char .  ") -> ". ordutf8(strtoupper($char)) . " / " . utf8chr(ordutf8(strtoupper($char)))  . PHP_EOL;
            $this_char = ordutf8(strtoupper($char));
            if ($first === null) {
                $first = $last = $this_char;
            }
            if ($last < $this_char - 1) {
                $ranges[] = $first == $last ? $first : $first . '-' . $last;
                $first = $last = $this_char;
            } else {
                $last = $this_char;
            }
        }
        $ranges[] = $first == $last ? $first : $first . '-' . $last;
        $res[$k] = $ranges;
    }
    $numstr = "";
    $nnum = array();
    foreach ($res as $number => $ranges) {
        foreach ($ranges as $k => $range) {
            $newnumbers = array();
            $srange = preg_split('/-/', $range, -1, PREG_SPLIT_NO_EMPTY);
            $str_range = array();
            foreach ($srange as $kk => $vv) {
                $str_range[] = utf8chr($vv);
            }
            foreach ($str_range as $val) {
                $newnumbers[] = sprintf('%s%s', $number, $val);
            }
            $num = join('-', $newnumbers);
            $nnum[] = $num;
        }
    }
    if (is_array($nnum) && is_array($output)) {
        $nn = array_merge($output, $nnum);
        $numstr = join(';', $nn);
        return $numstr;
    } elseif (is_array($output)) {
        return $output;
    } else {
        return array();
    }
}
Пример #6
0
</script>
</head>
<body onLoad='init()'>

<table class='rmenuobj' cellpadding=0 cellspacing=0 width=100%>
<?php 
function ordutf8($s, $offset)
{
    if (function_exists("mb_convert_encoding")) {
        list(, $ret) = unpack('N', mb_convert_encoding(mb_strtolower(mb_substr($s, $offset, 1)), 'UCS-4BE', 'UTF-8'));
    } else {
        $ret = ord(strtolower($s[$offset]));
    }
    return $ret;
}
foreach ($files as $key => $data) {
    $chr = ordutf8($key, 0);
    if ($key == '/.' || $key[0] != '/') {
        echo "<tr><td code='" . rawurlencode($data) . "' id='" . bin2hex($key) . "' name='i" . $chr . "' class='rmenuitem' nowrap onclick='menuClick(this); return false;' ondblclick='menuDblClickAndExit(this); return false;'>";
    } else {
        $chr = ordutf8($key, 1);
        echo "<tr><td code='" . rawurlencode($data) . "' id='" . bin2hex($key) . "' name='i" . $chr . "' class='rmenuitem' nowrap onclick='menuClick(this); return false;' ondblclick='menuDblClick(this); return false;'>";
    }
    echo "&nbsp;&nbsp;";
    echo $key;
    echo "</td></tr>";
}
?>
</table>
</body>