';
if ($email != '') {
$output .= '';
}
if ($name == '' && $tripcode == '') {
$output .= $anonymous;
} else if ($name == '' && $tripcode != '') {
/* Just display the tripcode, no added html */
} else {
$output .= $name;
}
if ($email != '') {
$output .= '';
}
$output .= '';
if ($tripcode != '') {
$output .= '!' . $tripcode . '';
}
$output .= "\n";
return $output;
}
/**
* Will check if there is already a cached version of the name string in the database, and if so, get it, instead of recalculating it
*
* @param string $post_name Text entered in the Name field
* @return array Name and tripcode
*/
function calculateNameAndTripcode($post_name) {
global $tc_db;
if(ereg("(#|!)(.*)", $post_name, $regs)){
$results = $tc_db->GetAll("SELECT `name`, `tripcode` FROM `".KU_DBPREFIX."passcache` WHERE `md5` = '".md5($post_name)."' LIMIT 1");
if (isset($results[0])) {
return array($results[0][0], $results[0][1]);
} else {
$cap = $regs[2];
$cap_full = '#' . $regs[2];
// {{{ Special tripcode check
$trips = unserialize(KU_TRIPS);
if (count($trips) > 0) {
if (isset($trips[$cap_full])) {
$forcedtrip = $trips[$cap_full];
return array(ereg_replace("(#)(.*)", "", $post_name), $forcedtrip);
}
}
// }}}
if (function_exists('mb_convert_encoding')) {
$recoded_cap = mb_convert_encoding($cap, 'SJIS', 'UTF-8');
if ($recoded_cap != '') {
$cap = $recoded_cap;
}
}
if (strpos($post_name, '#') === false) {
$cap_delimiter = '!';
} elseif (strpos($post_name, '!') === false) {
$cap_delimiter = '#';
} else {
$cap_delimiter = (strpos($post_name, '#') < strpos($post_name, '!')) ? '#' : '!';
}
if (ereg("(.*)(" . $cap_delimiter . ")(.*)", $cap, $regs_secure)) {
$cap = $regs_secure[1];
$cap_secure = $regs_secure[3];
$is_secure_trip = true;
} else {
$is_secure_trip = false;
}
$tripcode = '';
if ($cap != '') {
/* From Futabally */
$cap = strtr($cap, "&", "&");
$cap = strtr($cap, ",", ", ");
$salt = substr($cap."H.", 1, 2);
$salt = ereg_replace("[^\.-z]", ".", $salt);
$salt = strtr($salt, ":;<=>?@[\\]^_`", "ABCDEFGabcdef");
$tripcode = substr(crypt($cap, $salt), -10);
}
if ($is_secure_trip) {
if ($cap != '') {
$tripcode .= '!';
}
$secure_tripcode = md5($cap_secure . KU_RANDOMSEED);
if (function_exists('base64_encode')) {
$secure_tripcode = base64_encode($secure_tripcode);
}
if (function_exists('str_rot13')) {
$secure_tripcode = str_rot13($secure_tripcode);
}
$secure_tripcode = substr($secure_tripcode, 2, 10);
$tripcode .= '!' . $secure_tripcode;
}
$name = ereg_replace("(" . $cap_delimiter . ")(.*)", "", $post_name);
$tc_db->Execute("INSERT INTO `".KU_DBPREFIX."passcache` ( `md5` , `name` , `tripcode` ) VALUES ( '" . md5($post_name) . "' , '" . $name . "' , '" . $tripcode . "' )");
return array($name, $tripcode);
}
} else {
return $post_name;
}
}
/**
* Format a long message to be shortened if it exceeds the allowed length on a page
*
* @param string $message Post message
* @param string $board Board directory
* @param integer $threadid Thread ID
* @param boolean $page Is rendering for a page
* @return string The formatted message
*/
function formatLongMessage($message, $board, $threadid, $page) {
$output = '';
if ((strlen($message) > KU_LINELENGTH || count(explode('
', $message)) > 15) && $page) {
$message_exploded = explode('
', $message);
$message_shortened = '';
for ($i = 0; $i <= 14; $i++) {
if (isset($message_exploded[$i])) {
$message_shortened .= $message_exploded[$i] . '
';
}
}
if (strlen($message_shortened) > KU_LINELENGTH) {
$message_shortened = substr($message_shortened, 0, KU_LINELENGTH);
}
$message_shortened = closeOpenTags($message_shortened);
$output = $message_shortened . '