示例#1
0
function TextToImage($single_line, $font_size, $out_file, $extra_line_space = 0, $linenum = -1)
{
    global $global_tb;
    // show the correct header for the image type
    //header("Content-type: image/jpg");
    $single_line = tab2space($single_line);
    if ($linenum != -1) {
        $string = sprintf("%6d:  %s", $linenum, $single_line);
    } else {
        $string = $single_line;
    }
    /*
    	if ( mb_strlen($single_line, "Big5") != strlen($single_line) )
      		$font = 'msjh.ttf';
    	else
    	  $font = 'consola.ttf';
    */
    $font = 'WenQuanYiMicroHeiMono.ttf';
    // some variables to set
    if ($global_tb == NULL) {
        $global_tb = imagettfbbox($font_size, 0, $font, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWZYX");
    }
    $tb = imagettfbbox($font_size, 0, $font, $string);
    $width = abs($tb[2] - $tb[0]) + 1;
    //$height = abs($tb[1] - $tb[7])+1;
    $height = abs($global_tb[1] - $global_tb[7]) + 1;
    //echo $tb[1] + "\n";
    //$width = 400;
    //$height = 200;
    //$width  = imagefontwidth($font) * strlen($string);
    //$height = imagefontheight($font);
    // lets begin by creating an image
    $im = @imagecreatetruecolor($width, $height + $extra_line_space);
    //white background
    $background_color = imagecolorallocate($im, 255, 255, 255);
    imagefill($im, 0, 0, $background_color);
    //black text
    $text_color = imagecolorallocate($im, 0, 0, 0);
    // put it all together
    imagettftext($im, $font_size, 0, 0, $height - $global_tb[1] - 1, $text_color, $font, $string);
    // and display
    imagepng($im, $out_file, 9);
}
示例#2
0
function record_an_edit($posttype, $set, $postid, $edit_id, $orkTime)
{
    $objSrcUser =& $GLOBALS["objSrcUser"];
    $userid = $objSrcUser->get_userid();
    $sql = "SELECT poster_id,poster_kd,post,title FROM forum ";
    $sql .= "WHERE post_id = {$edit_id}";
    $edit = mysql_fetch_array(mysql_query($sql));
    if ($userid != $edit['poster_id']) {
        echo '<div class="center">' . "Sorry, you can't edit this post." . '</div>';
        include_game_down();
        exit;
    }
    // To prevent script kiddies and accidents from editing closed posts
    $seek = mysql_query("SELECT close_option FROM forum WHERE post_id={$postid}");
    $seek = mysql_fetch_array($seek);
    if ($seek['close_option'] == 1) {
        echo '<div class="center">' . "...Topic closed, no editing..." . '</div>';
        include_game_down();
        exit;
    }
    // secure input
    $title = substr($_POST['title'], 0, 30);
    $title = safeHTML($title);
    $text = $_POST['text'];
    // Not yet secured
    // M: Add formatting wrappers + securing *M: updated with AI's fixes*
    if (isset($_POST['formatted']) && $_POST['formatted'] == "yes") {
        if (get_magic_quotes_gpc()) {
            $text = stripslashes($text);
        }
        $text = tab2space($text);
        $text = htmlspecialchars($text);
        $text = mysql_real_escape_string($text);
        $text = "<code>" . $text . "</code>";
    } else {
        $text = safeHTML($text);
        // Secured
    }
    // update post
    $sql = "UPDATE forum SET title='{$title}', post='{$text}', updated='{$orkTime}' WHERE post_id={$edit_id}";
    $result = mysql_query($sql);
    echo '<div class="center"><br />Your post was edited successfully.' . '<br /><br />' . "<a href=\"main.php?cat=game&amp;page=forums&amp;set={$set}&amp;postid={$postid}&amp;mode=posts&amp;start=0&amp;finish=" . FORUM_POSTS_PER_PAGE . "\">" . "Changes saved, click here to return</a>" . '</div>';
    include_game_down();
    exit;
}
示例#3
0
文件: post_i.php 项目: 68/rep2iphone
/**
 * (設定に応じて)ソースコードがHTML上でもきれいに再現されるように、POSTメッセージを変換する
 *
 * @param   string  $MESSAGE
 * @return  string
 */
function formatCodeToPost($MESSAGE)
{
    if (!empty($_POST['fix_source'])) {
        // タブをスペースに
        $MESSAGE = tab2space($MESSAGE);
        // 特殊文字を実体参照に
        $MESSAGE = htmlspecialchars($MESSAGE, ENT_QUOTES);
        // 自動URLリンク回避
        $MESSAGE = str_replace('tp://', 't&#112;://', $MESSAGE);
        // 行頭のスペースを実体参照に
        $MESSAGE = preg_replace('/^ /m', '&nbsp;', $MESSAGE);
        // 二つ続くスペースの一つ目を実体参照に
        $MESSAGE = preg_replace('/(?<!&nbsp;)  /', '&nbsp; ', $MESSAGE);
        // 奇数回スペースがくり返すときの仕上げ
        $MESSAGE = preg_replace('/(?<=&nbsp;)  /', ' &nbsp;', $MESSAGE);
    }
    return $MESSAGE;
}
示例#4
0
    ${$pk} = isset($_POST[$pk]) ? $_POST[$pk] : '';
}
if (!isset($ttitle)) {
    if ($ttitle_en) {
        $ttitle = UrlSafeBase64::decode($ttitle_en);
    } elseif ($subject) {
        $ttitle = $subject;
    } else {
        $ttitle = '';
    }
}
//$MESSAGE = rtrim($MESSAGE);
// {{{ ソースコードがきれいに再現されるように変換
if (!empty($_POST['fix_source'])) {
    // タブをスペースに
    $MESSAGE = tab2space($MESSAGE);
    // 特殊文字を実体参照に
    $MESSAGE = htmlspecialchars($MESSAGE, ENT_QUOTES, 'Shift_JIS');
    // 自動URLリンク回避
    $MESSAGE = str_replace('tp://', 't&#112;://', $MESSAGE);
    // 行頭のスペースを実体参照に
    $MESSAGE = preg_replace('/^ /m', '&nbsp;', $MESSAGE);
    // 二つ続くスペースの一つ目を実体参照に
    $MESSAGE = preg_replace('/(?<!&nbsp;)  /', '&nbsp; ', $MESSAGE);
    // 奇数回スペースがくり返すときの仕上げ
    $MESSAGE = preg_replace('/(?<=&nbsp;)  /', ' &nbsp;', $MESSAGE);
}
// }}}
// したらばのlivedoor移転に対応。post先をlivedoorとする。
$host = P2Util::adjustHostJbbs($host);
// machibbs、JBBS@したらば なら
示例#5
0
function include_configuration($title, $filename)
{
    $text = '';
    $lines = @file($filename);
    foreach ($lines as $line) {
        $line = wordwrap($line, 120);
        $line = tab2space($line);
        $text .= htmlentities($line);
    }
    output_document($title, '<pre>' . $text . '</pre>');
}