function show_figlet($str, $font) { $cv = caca_create_canvas(0, 0); if (!caca_canvas_set_figfont($cv, $font)) { return false; } $chars = unistr_to_ords($str); $color = 0; foreach ($chars as $c) { caca_set_color_ansi($cv, 1 + ($color += 1) % 13, CACA_WHITE); caca_put_figchar($cv, $c); } echo caca_export_string($cv, "html3"); }
} $modpost_message .= '.html#' . $post_id . '">' . $post_id . '</a> in /' . $_POST['board'] . '/ with flags: ' . $flags . '.'; management_addlogentry($modpost_message, 1, md5_decrypt($_POST['modpassword'], KU_RANDOMSEED)); } if ($post['name_save'] && isset($_POST['name'])) { setcookie('name', urldecode($_POST['name']), time() + 31556926, '/', KU_DOMAIN); } if ($post['email_save']) { setcookie('email', urldecode($post['email']), time() + 31556926, '/', KU_DOMAIN); } setcookie('postpassword', urldecode($_POST['postpassword']), time() + 31556926, '/'); } else { exitWithErrorPage(_gettext('Could not copy uploaded image.')); } // If the user replied to a thread, and they weren't sage-ing it... if ($thread_replyto != '0' && strtolower($_POST['em']) != 'sage' && unistr_to_ords($_POST['em']) != array(19979, 12370)) { // And if the number of replies already in the thread are less than the maximum thread replies before perma-sage... if ($thread_replies <= $board_class->board['maxreplies']) { // Bump the thread $tc_db->Execute("UPDATE `" . KU_DBPREFIX . "posts` SET `bumped` = '" . time() . "' WHERE `boardid` = " . $board_class->board['id'] . " AND `id` = '" . $thread_replyto . "'"); } } // If the user replied to a thread he is watching, update it so it doesn't count his reply as unread if (KU_WATCHTHREADS && $thread_replyto != '0') { $viewing_thread_is_watched = $tc_db->GetOne("SELECT COUNT(*) FROM `" . KU_DBPREFIX . "watchedthreads` WHERE `ip` = '" . $_SERVER['REMOTE_ADDR'] . "' AND `board` = '" . $board_class->board['name'] . "' AND `threadid` = '" . $thread_replyto . "'"); if ($viewing_thread_is_watched > 0) { $newestreplyid = $tc_db->GetOne('SELECT `id` FROM `' . KU_DBPREFIX . 'posts` WHERE `boardid` = ' . $board_class->board['id'] . ' AND `IS_DELETED` = 0 AND `parentid` = ' . $thread_replyto . ' ORDER BY `id` DESC LIMIT 1'); $tc_db->Execute("UPDATE `" . KU_DBPREFIX . "watchedthreads` SET `lastsawreplyid` = " . $newestreplyid . " WHERE `ip` = '" . $_SERVER['REMOTE_ADDR'] . "' AND `board` = '" . $board_class->board['name'] . "' AND `threadid` = '" . $thread_replyto . "'"); } } $tc_db->Execute("COMMIT");
function CheckBadUnicode($post_name, $post_email, $post_subject, $post_message) { /* Check for bad characters which can cause the page to deform (right-to-left markers, etc) */ $bad_ords = array(8235, 8238); $ords_name = unistr_to_ords($post_name); $ords_email = unistr_to_ords($post_email); $ords_subject = unistr_to_ords($post_subject); $ords_message = unistr_to_ords($post_message); $ords_filename = isset($_FILES['imagefile']) ? unistr_to_ords($_FILES['imagefile']['name']) : ''; foreach ($bad_ords as $bad_ord) { if ($ords_name != '') { if (in_array($bad_ord, $ords_name)) { exitWithErrorPage(_gettext('Your post contains one or more illegal characters.')); } } if ($ords_email != '') { if (in_array($bad_ord, $ords_email)) { exitWithErrorPage(_gettext('Your post contains one or more illegal characters.')); } } if ($ords_subject != '') { if (in_array($bad_ord, $ords_subject)) { exitWithErrorPage(_gettext('Your post contains one or more illegal characters.')); } } if ($ords_message != '') { if (in_array($bad_ord, $ords_message)) { exitWithErrorPage(_gettext('Your post contains one or more illegal characters.')); } } if ($ords_filename != '') { if (in_array($bad_ord, $ords_filename)) { exitWithErrorPage(_gettext('Your post contains one or more illegal characters.')); } } } }
* to Public License, Version 2, as published by Sam Hocevar. See * http://www.wtfpl.net/ for more details. */ function unistr_to_ords($str, $encoding = 'UTF-8') { $str = mb_convert_encoding($str, "UCS-4BE", $encoding); $result = array(); for ($i = 0; $i < mb_strlen($str, "UCS-4BE"); $i++) { $c = mb_substr($str, $i, 1, "UCS-4BE"); $val = unpack("N", $c); $result[] = $val[1]; } return $result; } if (php_sapi_name() != "cli") { die("You have to run this program with php-cli!\n"); } if ($argc < 3) { die("Too few arguments.\nUsage: cmd <path of font> <utf8 string>\n"); } $cv = caca_create_canvas(0, 0); if (!caca_canvas_set_figfont($cv, $argv[1])) { die("Could not open font\n"); } $chars = unistr_to_ords($argv[2]); $color = 0; foreach ($chars as $c) { caca_set_color_ansi($cv, 1 + ($color += 4) % 15, CACA_TRANSPARENT); caca_put_figchar($cv, $c); } echo caca_export_string($cv, "utf8");
function CheckBadUnicode($post_name, $post_email, $post_subject, $post_message) { /* Check for bad characters which can cause the page to deform (right-to-left markers, etc) */ $bad_ords = array(8235, 8238); $ords_name = unistr_to_ords($post_name); $ords_email = unistr_to_ords($post_email); $ords_subject = unistr_to_ords($post_subject); $ords_message = unistr_to_ords($post_message); $ords_filename = isset($_FILES['imagefile']) ? unistr_to_ords($_FILES['imagefile']['name']) : ''; foreach ($bad_ords as $bad_ord) { if ($ords_name != '') { if (in_array($bad_ord, $ords_name)) { exitWithErrorPage(_gettext('В вашем посте присутствуют неугодные системе символы. Потрудитесь их убрать.')); } } if ($ords_email != '') { if (in_array($bad_ord, $ords_email)) { exitWithErrorPage(_gettext('В вашем посте присутствуют неугодные системе символы. Потрудитесь их убрать.')); } } if ($ords_subject != '') { if (in_array($bad_ord, $ords_subject)) { exitWithErrorPage(_gettext('В вашем посте присутствуют неугодные системе символы. Потрудитесь их убрать.')); } } if ($ords_message != '') { if (in_array($bad_ord, $ords_message)) { exitWithErrorPage(_gettext('В вашем посте присутствуют неугодные системе символы. Потрудитесь их убрать.')); } } if ($ords_filename != '') { if (in_array($bad_ord, $ords_filename)) { exitWithErrorPage(_gettext('В вашем посте присутствуют неугодные системе символы. Потрудитесь их убрать.')); } } } }