';
}
if ($type == 'post') {
if ($locale == 'ja') {
/* Format the timestamp japanese style */
$fulldate = strftime ("%Yy%mm%dd(DAYOFWEEK) %HH%MM%SS", $timestamp);
$dayofweek = strftime('%a', $timestamp);
/* I don't like this method, but I can't rely on PHP's locale settings to do it for me... */
switch ($dayofweek) {
case 'Sun':
$dayofweek = '日';
break;
case 'Mon':
$dayofweek = '月';
break;
case 'Tue':
$dayofweek = '火';
break;
case 'Wed':
$dayofweek = '水';
break;
case 'Thu':
$dayofweek = '木';
break;
case 'Fri':
$dayofweek = '金';
break;
case 'Sat':
$dayofweek = '土';
break;
default:
// The date must be in the correct language already, so let's convert it to unicode if it isn't already.
$dayofweek = mb_convert_encoding($dayofweek, "UTF-8", "JIS, eucjp-win, sjis-win");
break;
}
$fulldate = formatJapaneseNumbers($fulldate);
//Convert the symbols for year, month, etc to unicode equivalents. We couldn't do this above beause the numbers would be formatted to japanese.
$fulldate = str_replace(array("y","m","d","H","M","S"), array("年","月","日","時","分","秒"), $fulldate);
$fulldate = str_replace('DAYOFWEEK', $dayofweek, $fulldate);
return $output.$fulldate.(($email != '') ? ('') : (""));
} else {
/* Format the timestamp english style */
return $output.date('y/m/d(D)H:i', $timestamp).(($email != '') ? ('') : (""));
}
}
return $output.date('y/m/d(D)H:i', $timestamp).(($email != '') ? ('') : (""));
}
/**
* Format the provided input into a reflink, which follows the Japanese locale if it is set.
*/
function formatReflink($post_board, $post_thread_start_id, $post_id, $locale = 'en') {
$return = ' ';
$reflink_noquote = '';
$reflink_quote = '';
if ($locale == 'ja') {
$return .= $reflink_quote . formatJapaneseNumbers($post_id) . '' . $reflink_noquote . '番';
} else {
$return .= $reflink_noquote . 'No. ' . '' . $reflink_quote . $post_id . '';
}
return $return . "\n";
}
/**
* Calculate the different name and tripcode for the name field provided
*
* @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)){
$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);
return array($name, $tripcode);
}
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);
if (strrpos($message_shortened,"<") > strrpos($message_shortened,">")) {
//We have a partially opened tag we need to get rid of.
$message_shortened = substr($message_shortened, 0, strrpos($message_shortened,"<"));
}
$output = $message_shortened . '