function Send($type, $file, $targetname, $targetthumb = '', $targetthumb_c = '', $checkmime = '', $isreply = false, $handle_errors = false) { $isreply_formatted = $isreply ? '1' : '0'; $ch = curl_init($this->url); $post = array('password' => $this->password, 'type' => $type, 'isreply' => $isreply_formatted, 'file' => $file, 'targetname' => $targetname, 'targetthumb' => $targetthumb, 'targetthumb_c' => $targetthumb_c, 'checkmime' => $checkmime); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); $return = curl_exec($ch); curl_close($ch); if ($handle_errors) { if ($return == 'bad password') { die(_gettext('The passwords of the load balancer password in the board configuration and the load receiver script differ.')); } if ($return == 'unable to thumbnail') { die(_gettext('The load balancer script was unable to create the thumbnail for that image.')); } if ($return == 'file already exists') { die(_gettext('That file already exists on the server.')); } if ($return == 'unable to copy') { die(_gettext('The load balancer script was unable to copy the file you uploaded.')); } if ($return == 'bad mime type') { die(_gettext('That file does not match up with the required mime type for that format.')); } if ($return == '' || $return == 'failure') { die(_gettext('The load balancer script stopped unexpectedly.')); } } return $return; }
public function testGettext() { $this->assertEquals('Typ', _gettext('Type')); $this->assertEquals('Typ', __('Type')); $this->assertEquals('%d sekundy', _ngettext('%d second', '%d seconds', 2)); $this->assertEquals('%d seconds', _npgettext('context', '%d second', '%d seconds', 2)); $this->assertEquals('Tabulka', _pgettext('Display format', 'Table')); }
public function checkFields($postData) { if (!$postData['is_reply']) { if (empty($postData['files'][0])) { kxFunc::showError(_gettext('A file is required for a new thread.')); } } else { if (!$this->postClass->checkEmpty($postData)) { kxFunc::showError(_gettext('An image, or message, is required for a reply.')); } } }
public function checkFields($postData) { if ($postData['is_reply']) { if (!$postClass->checkEmpty($postData)) { kxFunc::showError(_gettext('A message is required for a reply.')); } } else { $result = $this->db->select("posts")->countQuery()->condition("post_board", $this->board->board_id)->condition("post_deleted", 0)->condition("post_subject", substr($postData['subject'], 0, 74))->condition("post_parent", 0)->execute()->fetchField(); if ($result > 0) { kxFunc::showError(_gettext('Duplicate thread subject'), _gettext('Text boards may have only one thread with a unique subject. Please pick another.')); } } }
function ev_gettext($string) { if (func_num_args() > 1) { $arg = array(); for ($i = 1; $i < func_num_args(); $i++) { $arg[] = func_get_arg($i); } $string = _gettext($string); return vsprintf($string, $arg); } else { return _gettext($string); } }
function modules_list() { $modules = array(); if ($modules_handle = opendir(KU_ROOTDIR . 'inc/modules')) { while (false !== ($file = readdir($modules_handle))) { /* We don't want hidden files, nor . or .. */ if ($file != '.' && $file != '..' && !is_dir($file) && strpos($file, '.php') != false) { $modules[] = substr($file, 0, -4); } } } else { echo _gettext('Unable to open the modules directory!'); } return $modules; }
/** * get text translation. * * @param string $text text message. * @param string $domain text domain. * @return string return translated text. */ function _t($text, $domain = 'messages') { if ($domain == null) { $domain = 'messages'; } if (function_exists('_textdomain')) { _textdomain($domain); } if (function_exists('_gettext')) { return _gettext($text); } else { \System\Libraries\Log::write('language', 'warning', 'Unable to find _gettext function. Please check php-gettext component.'); return $text; } }
function timeDiff($timestamp, $detailed = false, $max_detail_levels = 8, $precision_level = 'second') { $now = time(); #If the difference is positive "ago" - negative "away" $timestamp >= $now ? $action = '' : ($action = 'ago'); # Set the periods of time $periods = array(_gettext('second'), _gettext('minute'), _gettext('hour'), _gettext('day'), _gettext('week'), _gettext('month'), _gettext('year'), _gettext('decade')); $lengths = array(1, 60, 3600, 86400, 604800, 2630880, 31570560, 315705600); $diff = $action == '' ? $timestamp - $now : $now - $timestamp; $prec_key = array_search($precision_level, $periods); # round diff to the precision_level $diff = round($diff / $lengths[$prec_key]) * $lengths[$prec_key]; # if the diff is very small, display for ex "just seconds ago" if ($diff <= 10) { $periodago = max(0, $prec_key - 1); $agotxt = $periods[$periodago] . 's'; return "{$agotxt} {$action}"; } # Go from decades backwards to seconds $time = ""; for ($i = sizeof($lengths) - 1; $i >= 0; $i--) { if ($i > 0) { if ($diff > $lengths[$i - 1] && $max_detail_levels > 0) { # if the difference is greater than the length we are checking... continue $val = floor($diff / $lengths[$i - 1]); # 65 / 60 = 1. That means one minute. 130 / 60 = 2. Two minutes.. etc $time .= $val . " " . $periods[$i - 1] . ($val > 1 ? 's ' : ' '); # The value, then the name associated, then add 's' if plural $diff -= $val * $lengths[$i - 1]; # subtract the values we just used from the overall diff so we can find the rest of the information if (!$detailed) { $i = 0; } # if detailed is turn off (default) only show the first set found, else show all information $max_detail_levels--; } } } # Basic error checking. if ($time == "") { return "Error-- Unable to calculate time."; } else { if ($action != '') { return $time . $action; } return $time; } }
public function checkFields($postData) { if (!$postData['is_reply']) { if (empty($postData['files'][0]) && !$postData['is_oekaki'] && (!isset($this->request['nofile']) && $this->board->board_enable_no_file == 1 || $this->board->board_enable_no_file)) { kxFunc::showError(_gettext('A file is required for a new thread.')); } } else { if (!$postData['is_oekaki'] && !$this->postClass->checkEmpty($postData)) { kxFunc::showError(_gettext('An image, or message, is required for a reply.')); } } if (isset($this->request['nofile']) && $this->board->board_enable_no_file == 1) { if (!$this->postClass->checkNoFile) { kxFunc::showError('A message is required to post without a file.'); } } }
private function _del() { // Basic check kxForm::addRule('id', 'numeric')->check(); try { $this->db->delete("filetypes")->condition("type_id", $this->request['id'])->execute(); $this->db->delete("board_filetypes")->condition("type_id", $this->request['id'])->execute(); } catch (Exception $e) { $this->twigData['notice']['type'] = 'error'; $this->twigData['notice']['message'] = _gettext('An error occured: ') . $e->getMessage(); } if (!isset($this->twigData['notice'])) { $this->twigData['notice']['type'] = 'success'; $this->twigData['notice']['message'] = _gettext('Filetype deleted successfully!'); } // Need to update the cache $this->recacheFiletypes(); }
function BanCheck($ip, $board = '', $force_display = false) { global $tc_db; if (!isset($_COOKIE['tc_previousip'])) { $_COOKIE['tc_previousip'] = ''; } $bans = array(); $results = $tc_db->GetAll("SELECT * FROM `" . KU_DBPREFIX . "banlist` WHERE ((`type` = '0' AND ( `ipmd5` = '" . md5($ip) . "' OR `ipmd5` = '" . md5($_COOKIE['tc_previousip']) . "' )) OR `type` = '1') AND (`expired` = 0)"); if (count($results) > 0) { foreach ($results as $line) { if ($line['type'] == 1 && strpos($ip, md5_decrypt($line['ip'], KU_RANDOMSEED)) === 0 || $line['type'] == 0) { if ($line['until'] != 0 && $line['until'] < time()) { $tc_db->Execute("UPDATE `" . KU_DBPREFIX . "banlist` SET `expired` = 1 WHERE `id` = " . $line['id']); $line['expired'] = 1; $this->UpdateHtaccess(); } if ($line['globalban'] != 1) { if (in_array($board, explode('|', $line['boards'])) || $board == '') { $line['appealin'] = substr(timeDiff($line['appealat'], true, 2), 0, -1); $bans[] = $line; } } else { $line['appealin'] = substr(timeDiff($line['appealat'], true, 2), 0, -1); $bans[] = $line; } } } } if (count($bans) > 0) { $tc_db->Execute("END TRANSACTION"); echo $this->DisplayBannedMessage($bans); die; } if ($force_display) { /* Instructed to display a page whether banned or not, so we will inform them today is their rucky day */ echo '<title>' . _gettext('YOU ARE NOT BANNED!') . '</title><div align="center"><img src="' . KU_WEBFOLDER . 'youarenotbanned.jpg"><br /><br />' . _gettext('Unable to find record of your IP being banned.') . '</div>'; } else { return true; } }
function do_redirect($url, $ispost = false, $file = '') { global $board_class; $headermethod = true; if ($headermethod) { if ($ispost) { header('Location: ' . $url); } else { die('<meta http-equiv="refresh" content="1;url=' . $url . '">'); } } else { if ($ispost && $file != '') { echo sprintf(_gettext('%s uploaded.'), $file) . ' ' . _gettext('Updating pages.'); } elseif ($ispost) { echo _gettext('Post added.') . ' ' . _gettext('Updating pages.'); # TEE COME BACK } else { echo '---> ---> --->'; } die('<meta http-equiv="refresh" content="1;url=' . $url . '">'); } }
/** * Remove a board * * @param string $dir Directory to remove * @return boolean Result */ function removeBoard($dir) { global $tc_db; if (!isset($GLOBALS['remerror'])) { $GLOBALS['remerror'] = false; } if ($handle = opendir(KU_BOARDSDIR . $dir)) { /* If the folder exploration is sucsessful, continue */ while (false !== ($file = readdir($handle))) { /* As long as storing the next file to $file is successful, continue */ $path = $dir . '/' . $file; if (is_file(KU_BOARDSDIR . $path)) { if (!unlink(KU_BOARDSDIR . $path)) { echo '<u><font color="red">' . sprintf(_gettext('"%s" could not be deleted. This may be due to a permissions problem.</u><br />Directory cannot be deleted until all files are deleted.'), $path) . '</font><br />'; $GLOBALS['remerror'] = true; return false; } } else { if (is_dir(KU_BOARDSDIR . $path) && substr($file, 0, 1) != '.') { removeBoard($path); @rmdir(KU_BOARDSDIR . $path); } } } closedir($handle); /* Close the folder exploration */ } if (!$GLOBALS['remerror']) { /* If no errors occured, delete the now empty directory */ if (!rmdir(KU_BOARDSDIR . $dir)) { echo '<strong><font color="red">' . sprintf(_gettext('Could not remove directory "%s". This may be due to a permissions problem.'), $dir) . '</font></strong><br />' . $GLOBALS['remerror']; return false; } else { return true; } } return false; }
public function checkFields($postData) { if (!$postData['is_reply']) { if (($this->board->board_upload_type == 1 || $this->board->board_upload_type == 2) && !empty($this->board->board_embeds_allowed)) { if ($this->postClass->checkEmbed($postData)) { kxFunc::showError(_gettext('Please enter an embed ID.')); } } if (empty($postData['files'][0]) && (!isset($this->request['nofile']) && $this->board->board_enable_no_file == 1 || $this->board->board_enable_no_file == 0)) { if ($this->board->board_upload_type != 0 && empty($this->request['embed']) || $this->board->board_upload_type == 0) { kxFunc::showError(_gettext('A file is required for a new thread. If embedding is allowed, either a file or embed ID is required.')); } } } else { if (!$this->postClass->checkEmpty($postData)) { kxFunc::showError(_gettext('An image, or message, is required for a reply.')); } } if (isset($this->request['nofile']) && $this->board->board_enable_no_file == 1) { if (!$this->postClass->checkNoFile) { kxFunc::showError('A message is required to post without a file.'); } } }
/** * Wrapper function for translating. * * @param string $str the string * @param mixed $param the parameters * * @return string */ function translate($str, $param = null) { $string = _gettext(Advisor::escapePercent($str)); if (!is_null($param)) { $params = $this->ruleExprEvaluate('array(' . $param . ')'); } else { $params = array(); } return vsprintf($string, $params); }
$page .= $board_class->dwoo->get(KU_TEMPLATEDIR . '/txt_thread.tpl', $board_class->dwoo_data); } } else { $results = $tc_db->GetAll("SELECT * FROM `" . KU_DBPREFIX . "posts` WHERE `boardid` = " . $board_class->board['id'] . " AND ((`parentid` = 0 AND `id` = " . $tc_db->qstr($thread) . ") OR (`parentid` = " . $tc_db->qstr($thread) . ")) AND `IS_DELETED` = 0 ORDER BY `id` ASC"); $ids_found = count($results); if (count($results) > 0) { $results[0]['replies'] = count($results) - 1; foreach ($results as $key => $post) { $results[$key]['message'] = stripslashes(formatLongMessage($results[$key]['message'], $board_class->board['name'], $results[$key][parentid], false)); } $board_class->dwoo_data->assign('posts', $results); $page .= $board_class->dwoo->get(KU_TEMPLATEDIR . '/txt_thread.tpl', $board_class->dwoo_data); } } if ($ids_found == 0) { $page .= _gettext('Unable to find records of any posts matching that quote syntax.'); } } else { if (!$singlepost) { $page .= '<br />' . "\n"; } $results = $tc_db->GetAll("SELECT * FROM `" . KU_DBPREFIX . "posts` WHERE `boardid` = " . $board_class->board['id'] . " AND (" . $postidquery . ") AND `IS_DELETED` = 0 ORDER BY `id` ASC"); if ($board_class->board['type'] == 0) { $embeds = $tc_db->GetAll("SELECT filetype FROM `" . KU_DBPREFIX . "embeds`"); foreach ($embeds as $embed) { $board_class->board['filetypes'][] .= $embed['filetype']; } $board_class->dwoo_data->assign('filetypes', $board_class->board['filetypes']); } foreach ($results as $key => $post) { $results[$key] = $board_class->BuildPost($post, false);
function gettext($msgid) { return _gettext($msgid); }
/** * Alias for gettext. * * @param string $msgid The message. * @param string $domain Gettext domain. * * @throws Exception If $domain is an array. */ function __($msgid, $domain = null) { if (is_array($domain)) { throw new Exception(__('$domain cannot be an array.')); } return isset($domain) ? _dgettext($domain, $msgid) : _gettext($msgid); }
/** * Alias for gettext. * * @param string $msgid The message. * @param string $domain Gettext domain. * * @return string * @throws Exception If $domain is an array. */ function __($msgid, $domain = null) { return isset($domain) ? _dgettext($domain, $msgid) : _gettext($msgid); }
} else { echo _gettext('Your post already doesn\'t have an image!') . '<br />'; } } else { if ($post_class->Delete()) { if ($post_class->post_parentid != '0') { $board_class->RegenerateThreads($post_class->post['parentid']); } $board_class->RegeneratePages(); echo _gettext('Post successfully deleted.') . '<br />'; } else { echo _gettext('There was an error in trying to delete your post') . '<br />'; } } } else { echo _gettext('Incorrect password.') . '<br />'; } } else { do_redirect(KU_BOARDSPATH . '/' . $board_class->board['name'] . '/'); } } } do_redirect(KU_BOARDSPATH . '/' . $board_class->board['name'] . '/'); die; } elseif (isset($_GET['postoek'])) { $board_class->OekakiHeader($_GET['replyto'], $_GET['postoek']); die; } else { do_redirect(KU_BOARDSPATH . '/' . $board_class->board['name'] . '/'); } if (KU_RSS) {
public function loginValidate() { // Remove old login attempts $this->db->delete("loginattempts")->condition("attempt_time", time() - 1200, "<")->execute(); // Are we locked out still? $results = $this->db->select("loginattempts")->fields("loginattempts", array("attempt_ip"))->condition("attempt_ip", $_SERVER['REMOTE_ADDR'])->execute()->fetchAll(); if (count($results) > 5) { kxFunc::showError(_gettext('System lockout'), _gettext('Sorry, because of your numerous failed logins, you have been locked out from logging in for 20 minutes. Please wait and then try again.')); } else { // Find users with the username supplied to us $results = $this->db->select("staff")->fields("staff", array("user_id", "user_name", "user_password", "user_salt"))->condition("user_name", $this->request['username'])->execute()->fetchAll(); if (count($results) > 0) { if (md5($this->request['password'] . $results[0]->user_salt) == $results[0]->user_password) { // Let's make our session $session_id = md5(uniqid(microtime())); $this->request['sid'] = $session_id; // Delete any sessions that already exist for this user $this->db->delete("manage_sessions")->condition("session_staff_id", $results[0]->user_id)->execute(); // Insert our new values $this->db->insert("manage_sessions")->fields(array('session_id' => $session_id, 'session_ip' => $_SERVER['REMOTE_ADDR'], 'session_staff_id' => $results[0]->user_id, 'session_location' => "index", 'session_log_in_time' => time(), 'session_last_action' => time(), 'session_url' => ""))->execute(); // Set the cookies so ajax functions will load $this->SetModerationCookies(); //$this->environment->get('kx:classes:core:logging:id')->manageLog(_gettext('Logged in'), 1); // Let's figure out where we need to go $whereto = ""; // Unfiltered on purpose if ($_POST['qstring']) { $whereto = stripslashes($_POST['qstring']); $whereto = str_replace(kxEnv::Get('kx:paths:script:path'), "", $whereto); $whereto = str_ireplace("?manage.php", "", $whereto); $whereto = ltrim($whereto, '?'); $whereto = preg_replace("/sid=(\\w){32}/", "", $whereto); $whereto = str_replace(array('old_&', 'old_&'), "", $whereto); $whereto = str_replace("module=login", "", $whereto); $whereto = str_replace("do=login-validate", "", $whereto); $whereto = str_replace('&', '&', $whereto); $whereto = preg_replace("/&{1,}/", "&", $whereto); } $url = kxEnv::Get('kx:paths:script:path') . kxEnv::Get('kx:paths:script:folder') . '/manage.php?sid=' . $session_id . '&' . $whereto; if (!empty($_COOKIE['use_frames'])) { $twigData['url'] = $url; kxTemplate::output("manage/frames", $twigData); } else { kxFunc::doRedirect($url, true); } exit; } else { $this->db->insert("loginattempts")->fields(array('attempt_name' => $this->request['username'], 'attempt_ip' => $_SERVER['REMOTE_ADDR'], 'attempt_time' => time()))->execute(); $this->showForm(_gettext('Incorrect username/password.')); } } else { $this->db->insert("loginattempts")->fields(array('attempt_name' => $this->request['username'], 'attempt_ip' => $_SERVER['REMOTE_ADDR'], 'attempt_time' => time()))->execute(); $this->showForm(_gettext('Incorrect username/password.')); } } }
/** * Smarty block function, provides gettext support for smarty. * * The block content is the text that should be translated. * * Any parameter that is sent to the function will be represented as %n in the translation text, * where n is 1 for the first parameter. The following parameters are reserved: * - escape - sets escape mode: * - 'html' for HTML escaping, this is the default. * - 'js' for javascript escaping. * - 'url' for url escaping. * - 'no'/'off'/0 - turns off escaping * - plural - The plural version of the text (2nd parameter of ngettext()) * - count - The item count for plural mode (3rd parameter of ngettext()) */ function smarty_block_t($params, $text, &$smarty) { $text = stripslashes($text); // set escape mode if (isset($params['escape'])) { $escape = $params['escape']; unset($params['escape']); } // set plural version if (isset($params['plural'])) { $plural = $params['plural']; unset($params['plural']); // set count if (isset($params['count'])) { $count = $params['count']; unset($params['count']); } } // use plural if required parameters are set if (isset($count) && isset($plural)) { $text = _ngettext($text, $plural, $count); } else { // use normal $text = _gettext($text); } // run strarg if there are parameters if (count($params)) { $text = smarty_gettext_strarg($text, $params); } if (!isset($escape) || $escape == 'html') { // html escape, default $text = nl2br(htmlspecialchars($text)); } elseif (isset($escape)) { switch ($escape) { case 'javascript': case 'js': // javascript escape $text = str_replace('\'', '\\\'', stripslashes($text)); break; case 'url': // url escape $text = urlencode($text); break; } } return $text; }
function manage_page($action = 'announcements') { global $manage_class, $tpl_page; $manage_class->Header(); if (is_callable(array($manage_class, $action))) { $manage_class->{$action}(); } else { $tpl_page .= sprintf(_gettext('%s not implemented.'), $action); } $manage_class->Footer(); }
function section_html($section, $abbreviation, $show = true) { return '<h2> <span class="plus" onclick="toggle(this, \'' . $abbreviation . '\');" title="' . _gettext('Click to show/hide') . '">' . ($show ? '−' : '+') . ' </span> ' . $section . ' </h2> <div id="' . $abbreviation . '" style="' . ($show ? '' : 'display:none') . '">'; }
function _($message) { return _gettext($message); }
/** * 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 */ public function formatLongMessage($message, $board, $threadid, $page) { $output = ''; if ((strlen($message) > kxEnv::Get('kx:limits:linelength') || count(explode('<br />', $message)) > 15) && $page) { $message_exploded = explode('<br />', $message); $message_shortened = ''; for ($i = 0; $i <= 14; $i++) { if (isset($message_exploded[$i])) { $message_shortened .= $message_exploded[$i] . '<br />'; } } if (strlen($message_shortened) > kxEnv::Get('kx:limits:linelength')) { $message_shortened = substr($message_shortened, 0, kxEnv::Get('kx:limits: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 . '<div class="abbrev">' . "\n" . ' ' . sprintf(_gettext('Message too long. Click %shere%s to view the full text.'), '<a href="' . kxEnv::Get('kx:paths:boards:folder') . $board . '/res/' . $threadid . '.html">', '</a>') . "\n" . '</div>' . "\n"; } else { $output .= $message . "\n"; } return $output; }
/** * * Override normal translate * @param string $string to translate * @param string $lang does nothing, legacy */ public static function get($string, $lang = NULL) { //using the gettext dropin forced if (self::$dropin === TRUE) { return _gettext($string); } else { return _($string); } }
/** * Wrapper function for translating. * * @param string $str * @param mixed $param * * @return string */ function translate($str, $param = null) { if (is_null($param)) { return sprintf(_gettext(Advisor::escapePercent($str))); } else { $printf = 'sprintf("' . _gettext(Advisor::escapePercent($str)) . '",'; return $this->ruleExprEvaluate($printf . $param . ')', strlen($printf)); } }
/** * Create a thumbnail * * @param string $name File to be thumbnailed * @param string $filename Path to place the thumbnail * @param integer $new_w Maximum width * @param integer $new_h Maximum height * @return boolean Success/fail */ function createThumbnail($name, $filename, $new_w, $new_h) { if (KU_THUMBMETHOD == 'imagemagick') { $convert = 'convert ' . escapeshellarg($name); if (!KU_ANIMATEDTHUMBS) { $convert .= '[0] '; } $convert .= ' -resize ' . $new_w . 'x' . $new_h . ' -quality '; if (substr($filename, 0, -3) != 'gif') { $convert .= '70'; } else { $convert .= '90'; } $convert .= ' ' . escapeshellarg($filename); exec($convert); if (is_file($filename)) { return true; } else { return false; } } elseif (KU_THUMBMETHOD == 'gd') { $system = explode(".", $filename); $system = array_reverse($system); if (preg_match("/jpg|jpeg/", $system[0])) { $src_img = imagecreatefromjpeg($name); } else { if (preg_match("/png/", $system[0])) { $src_img = imagecreatefrompng($name); } else { if (preg_match("/gif/", $system[0])) { $src_img = imagecreatefromgif($name); } else { return false; } } } if (!$src_img) { exitWithErrorPage(_gettext('Unable to read uploaded file during thumbnailing.'), _gettext('A common cause for this is an incorrect extension when the file is actually of a different type.')); } $old_x = imageSX($src_img); $old_y = imageSY($src_img); if ($old_x > $old_y) { $percent = $new_w / $old_x; } else { $percent = $new_h / $old_y; } $thumb_w = round($old_x * $percent); $thumb_h = round($old_y * $percent); $dst_img = ImageCreateTrueColor($thumb_w, $thumb_h); fastImageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y, $system); if (preg_match("/png/", $system[0])) { if (!imagepng($dst_img, $filename, 0, PNG_ALL_FILTERS)) { echo 'unable to imagepng.'; return false; } } else { if (preg_match("/jpg|jpeg/", $system[0])) { if (!imagejpeg($dst_img, $filename, 70)) { echo 'unable to imagejpg.'; return false; } } else { if (preg_match("/gif/", $system[0])) { if (!imagegif($dst_img, $filename)) { echo 'unable to imagegif.'; return false; } } } } imagedestroy($dst_img); imagedestroy($src_img); return true; } return false; }
/** * 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('<br />', $message)) > 15) && $page) { $message_exploded = explode('<br />', $message); $message_shortened = ''; for ($i = 0; $i <= 14; $i++) { if (isset($message_exploded[$i])) { $message_shortened .= $message_exploded[$i] . '<br />'; } } 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 . '<div class="abbrev">' . "\n" . ' ' . sprintf(_gettext('Пост чересчур длинный. Нажмите %sсюда%s для просмотра его полностью.'), '<a href="' . KU_BOARDSFOLDER . $board . '/res/' . $threadid . '.html">', '</a>') . "\n" . '</div>' . "\n"; } else { $output .= $message . "\n"; } return $output; }