当前位置: 首页>>代码示例>>PHP>>正文


PHP utf8tohtml函数代码示例

本文整理汇总了PHP中utf8tohtml函数的典型用法代码示例。如果您正苦于以下问题:PHP utf8tohtml函数的具体用法?PHP utf8tohtml怎么用?PHP utf8tohtml使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了utf8tohtml函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Element

function Element($templateFile, array $options)
{
    global $config, $debug, $loader;
    if (function_exists('create_pm_header') && (isset($options['mod']) && $options['mod'] || isset($options['__mod']))) {
        $options['pm'] = create_pm_header();
    }
    if (isset($options['body']) && $config['debug']) {
        if (isset($debug['start'])) {
            $debug['time'] = '~' . round((microtime(true) - $debug['start']) * 1000, 2) . 'ms';
            unset($debug['start']);
        }
        $options['body'] .= '<h3>Debug</h3><pre style="white-space: pre-wrap;font-size: 10px;">' . str_replace("\n", '<br/>', utf8tohtml(print_r($debug, true))) . '</pre>';
    }
    $loader->setPaths($config['dir']['template']);
    $twig = new Twig_Environment($loader, array('autoescape' => false, 'cache' => "{$config['dir']['template']}/cache", 'debug' => $config['debug'] ? true : false));
    $twig->addExtension(new Twig_Extensions_Extension_Tinyboard());
    $twig->addExtension(new Twig_Extensions_Extension_I18n());
    // Read the template file
    if (@file_get_contents("{$config['dir']['template']}/{$templateFile}")) {
        $body = $twig->render($templateFile, $options);
        if ($config['minify_html'] && preg_match('/\\.html$/', $templateFile)) {
            $body = trim(preg_replace("/[\t\r\n]/", '', $body));
        }
        return $body;
    } else {
        throw new Exception("Template file '{$templateFile}' does not exist or is empty in '{$config['dir']['template']}'!");
    }
}
开发者ID:nabm,项目名称:Tinyboard,代码行数:28,代码来源:template.php

示例2: Element

function Element($templateFile, array $options)
{
    global $config, $debug, $twig;
    if (!$twig) {
        load_twig();
    }
    if (function_exists('create_pm_header') && (isset($options['mod']) && $options['mod'] || isset($options['__mod']))) {
        $options['pm'] = create_pm_header();
    }
    if (isset($options['body']) && $config['debug']) {
        if (isset($debug['start'])) {
            $debug['time'] = '~' . round((microtime(true) - $debug['start']) * 1000, 2) . 'ms';
            unset($debug['start']);
        }
        $debug['included'] = get_included_files();
        $debug['memory'] = round(memory_get_usage(true) / (1024 * 1024), 2) . ' MiB';
        $options['body'] .= '<h3>Debug</h3><pre style="white-space: pre-wrap;font-size: 10px;">' . str_replace("\n", '<br/>', utf8tohtml(print_r($debug, true))) . '</pre>';
    }
    // Read the template file
    if (@file_get_contents("{$config['dir']['template']}/{$templateFile}")) {
        $body = $twig->render($templateFile, $options);
        if ($config['minify_html'] && preg_match('/\\.html$/', $templateFile)) {
            $body = trim(preg_replace("/[\t\r\n]/", '', $body));
        }
        return $body;
    } else {
        throw new Exception("Template file '{$templateFile}' does not exist or is empty in '{$config['dir']['template']}'!");
    }
}
开发者ID:niksfish,项目名称:Tinyboard,代码行数:29,代码来源:template.php

示例3: ban

function ban($mask, $reason, $length, $board)
{
    global $mod, $pdo;
    $query = prepare("INSERT INTO `bans` VALUES (NULL, :ip, :mod, :time, :expires, :reason, :board)");
    $query->bindValue(':ip', $mask);
    $query->bindValue(':mod', $mod['id']);
    $query->bindValue(':time', time());
    if ($reason !== '') {
        markup($reason);
        $query->bindValue(':reason', $reason);
    } else {
        $query->bindValue(':reason', null, PDO::PARAM_NULL);
    }
    if ($length > 0) {
        $query->bindValue(':expires', $length);
    } else {
        $query->bindValue(':expires', null, PDO::PARAM_NULL);
    }
    if ($board) {
        $query->bindValue(':board', $board);
    } else {
        $query->bindValue(':board', null, PDO::PARAM_NULL);
    }
    $query->execute() or error(db_error($query));
    modLog('Created a new ' . ($length > 0 ? preg_replace('/^(\\d+) (\\w+?)s?$/', '$1-$2', until($length)) : 'permanent') . ' ban (<small>#' . $pdo->lastInsertId() . '</small>) for ' . (filter_var($mask, FILTER_VALIDATE_IP) !== false ? "<a href=\"?/IP/{$mask}\">{$mask}</a>" : utf8tohtml($mask)) . ' with ' . ($reason ? 'reason: ' . utf8tohtml($reason) . '' : 'no reason'));
}
开发者ID:npfriday,项目名称:Tinyboard,代码行数:26,代码来源:ban.php

示例4: recentposts_install

 function recentposts_install($settings)
 {
     if (!is_numeric($settings['limit_images']) || $settings['limit_images'] < 0) {
         return array(false, '<strong>' . utf8tohtml($settings['limit_images']) . '</strong> is not a non-negative integer.');
     }
     if (!is_numeric($settings['limit_posts']) || $settings['limit_posts'] < 0) {
         return array(false, '<strong>' . utf8tohtml($settings['limit_posts']) . '</strong> is not a non-negative integer.');
     }
 }
开发者ID:0151n,项目名称:vichan,代码行数:9,代码来源:info.php

示例5: gd_text_script

/**
 * Script to make a nice textual image, vertical writing.
 */
function gd_text_script()
{
    if (!function_exists('imagefontwidth')) {
        return;
    }
    $text = get_param('text');
    if (get_magic_quotes_gpc()) {
        $text = stripslashes($text);
    }
    $font_size = array_key_exists('size', $_GET) ? intval($_GET['size']) : 8;
    $font = get_param('font', get_file_base() . '/data/fonts/' . filter_naughty(get_param('font', 'FreeMonoBoldOblique')) . '.ttf');
    if (!function_exists('imagettftext') || !array_key_exists('FreeType Support', gd_info()) || @imagettfbbox(26.0, 0.0, get_file_base() . '/data/fonts/Vera.ttf', 'test') === false || strlen($text) == 0) {
        $pfont = 4;
        $height = intval(imagefontwidth($pfont) * strlen($text) * 1.05);
        $width = imagefontheight($pfont);
        $baseline_offset = 0;
    } else {
        $scale = 4;
        list(, , $height, , , , , $width) = imagettfbbox(floatval($font_size * $scale), 0.0, $font, $text);
        $baseline_offset = 8 * intval(ceil(floatval($font_size) / 8.0));
        $width = max($width, -$width);
        $width += $baseline_offset;
        $height += $font_size * $scale;
        // This is just due to inaccuracy in imagettfbbox, possibly due to italics not being computed correctly
        list(, , $real_height, , , , , $real_width) = imagettfbbox(floatval($font_size), 0.0, $font, $text);
        $real_width = max($real_width, -$real_width);
        $real_width += $baseline_offset / $scale;
        $real_height += 2;
    }
    if ($width == 0) {
        $width = 1;
    }
    if ($height == 0) {
        $height = 1;
    }
    $trans_color = array_key_exists('color', $_GET) ? $_GET['color'] : 'FF00FF';
    $img = imagecreatetruecolor($width, $height + $baseline_offset);
    imagealphablending($img, false);
    $black_color = array_key_exists('fgcolor', $_GET) ? $_GET['fgcolor'] : '000000';
    $black = imagecolorallocate($img, hexdec(substr($black_color, 0, 2)), hexdec(substr($black_color, 2, 2)), hexdec(substr($black_color, 4, 2)));
    if (!function_exists('imagettftext') || !array_key_exists('FreeType Support', gd_info()) || @imagettfbbox(26.0, 0.0, get_file_base() . '/data/fonts/Vera.ttf', 'test') === false || strlen($text) == 0) {
        $trans = imagecolorallocate($img, hexdec(substr($trans_color, 0, 2)), hexdec(substr($trans_color, 2, 2)), hexdec(substr($trans_color, 4, 2)));
        imagefill($img, 0, 0, $trans);
        imagecolortransparent($img, $trans);
        imagestringup($img, $pfont, 0, $height - 1 - intval($height * 0.02), $text, $black);
    } else {
        if (function_exists('imagecolorallocatealpha')) {
            $trans = imagecolorallocatealpha($img, hexdec(substr($trans_color, 0, 2)), hexdec(substr($trans_color, 2, 2)), hexdec(substr($trans_color, 4, 2)), 127);
        } else {
            $trans = imagecolorallocate($img, hexdec(substr($trans_color, 0, 2)), hexdec(substr($trans_color, 2, 2)), hexdec(substr($trans_color, 4, 2)));
        }
        imagefilledrectangle($img, 0, 0, $width, $height, $trans);
        if (@$_GET['angle'] != 90) {
            require_code('character_sets');
            $text = utf8tohtml(convert_to_internal_encoding($text, strtolower(get_param('charset', get_charset())), 'utf-8'));
            if (strpos($text, '&#') === false) {
                $previous = mixed();
                $nxpos = 0;
                for ($i = 0; $i < strlen($text); $i++) {
                    if (!is_null($previous)) {
                        list(, , $rx1, , $rx2) = imagettfbbox(floatval($font_size * $scale), 0.0, $font, $previous);
                        $nxpos += max($rx1, $rx2) + 3;
                    }
                    imagettftext($img, floatval($font_size * $scale), 270.0, $baseline_offset, $nxpos, $black, $font, $text[$i]);
                    $previous = $text[$i];
                }
            } else {
                imagettftext($img, floatval($font_size * $scale), 270.0, 4, 0, $black, $font, $text);
            }
        } else {
            imagettftext($img, floatval($font_size * $scale), 90.0, $width - $baseline_offset, $height, $black, $font, $text);
        }
        $dest_img = imagecreatetruecolor($real_width + intval(ceil(floatval($baseline_offset) / floatval($scale))), $real_height);
        imagealphablending($dest_img, false);
        imagecopyresampled($dest_img, $img, 0, 0, 0, 0, $real_width + intval(ceil(floatval($baseline_offset) / floatval($scale))), $real_height, $width, $height);
        // Sizes down, for simple antialiasing-like effect
        imagedestroy($img);
        $img = $dest_img;
        if (function_exists('imagesavealpha')) {
            imagesavealpha($img, true);
        }
    }
    header('Content-Type: image/png');
    imagepng($img);
    imagedestroy($img);
}
开发者ID:erico-deh,项目名称:ocPortal,代码行数:89,代码来源:misc_scripts.php

示例6: mod_edit_page

function mod_edit_page($id)
{
    global $config, $mod, $board;
    $query = prepare('SELECT * FROM ``pages`` WHERE `id` = :id');
    $query->bindValue(':id', $id);
    $query->execute() or error(db_error($query));
    $page = $query->fetch();
    if (!$page) {
        error(_('Could not find the page you are trying to edit.'));
    }
    if (!$page['board'] && $mod['boards'][0] !== '*') {
        error($config['error']['noaccess']);
    }
    if (!hasPermission($config['mod']['edit_pages'], $page['board'])) {
        error($config['error']['noaccess']);
    }
    if ($page['board'] && !openBoard($page['board'])) {
        error($config['error']['noboard']);
    }
    if (isset($_POST['method'], $_POST['content'])) {
        $content = $_POST['content'];
        $method = $_POST['method'];
        $page['type'] = $method;
        if (!in_array($method, array('markdown', 'html', 'infinity'))) {
            error(_('Unrecognized page markup method.'));
        }
        switch ($method) {
            case 'markdown':
                $write = purify_html(markdown($content));
                break;
            case 'html':
                if (hasPermission($config['mod']['rawhtml'])) {
                    $write = $content;
                } else {
                    $write = purify_html($content);
                }
                break;
            case 'infinity':
                $c = $content;
                markup($content);
                $write = $content;
                $content = $c;
        }
        if (!isset($write) or !$write) {
            error(_('Failed to mark up your input for some reason...'));
        }
        $query = prepare('UPDATE ``pages`` SET `type` = :method, `content` = :content WHERE `id` = :id');
        $query->bindValue(':method', $method);
        $query->bindValue(':content', $content);
        $query->bindValue(':id', $id);
        $query->execute() or error(db_error($query));
        $fn = ($board['uri'] ? $board['uri'] . '/' : '') . $page['name'] . '.html';
        $body = "<div class='ban'>{$write}</div>";
        $html = Element('page.html', array('config' => $config, 'body' => $body, 'title' => utf8tohtml($page['title'])));
        file_write($fn, $html);
        modLog("Edited page {$page['name']} <span class='unimportant'>(#{$page['id']})</span>");
    }
    if (!isset($content)) {
        $query = prepare('SELECT `content` FROM ``pages`` WHERE `id` = :id');
        $query->bindValue(':id', $id);
        $query->execute() or error(db_error($query));
        $content = $query->fetchColumn();
    }
    mod_page(sprintf(_('Editing static page: %s'), $page['name']), 'mod/edit_page.html', array('page' => $page, 'token' => make_secure_link_token("edit_page/{$id}"), 'content' => prettify_textarea($content), 'board' => $board));
}
开发者ID:ringtech,项目名称:infinity,代码行数:65,代码来源:pages.php

示例7: foreach

if ($langSwitch) {
    $thLang = $_GET['lang'] ? $_GET['lang'] : $_COOKIE['cookie_lang'];
    echo '<div id="lang-switch" style="text-align: right; /*margin-top: 0px; float: right*/ position:absolute; right:0; top:0px;">
  <form name="languages" action="#" style="font-size: 14px;">
  Language: <select name="langSelect" onchange="location.href=\'' . $_SERVER["PHP_SELF"] . '?lang=\'+document.languages.langSelect.value;">';
    include './wxwugraphs/languages/langlist.php';
    foreach ($langList as $key => $val) {
        $selectedL = $thLang == $key ? ' selected' : '';
        echo '<option value="' . $key . '"' . $selectedL . '>' . utf8tohtml($val) . '</option>';
    }
    echo '</select>
  </form>
  </div>';
}
echo '      <ul style="/*height:25px;*/">
        ' . $hrTab . '
        <li><a href="./wxwugraphs/WUG-tabsd.php?lang=' . $scLang . '"><span>' . utf8tohtml($Tdaily) . '</span></a></li>
        <li><a href="./wxwugraphs/WUG-tabsm.php?lang=' . $scLang . '"><span>' . utf8tohtml($Tmonthly) . '</span></a></li>
        <li><a href="./wxwugraphs/WUG-tabsy.php?lang=' . $scLang . '"><span>' . utf8tohtml($Tyearly) . '</span></a></li>  		
     </ul>
    </div>
    </td></tr>
    <tr><td style="vertical-align:bottom;"><div id="WUG-foot">
';
require_once './wxwugraphs/WUG-ver.php';
echo '
    </div></td></tr>
  </table>
</div>';
echo $errWUGlang;
#chdir ('./weather2/');
开发者ID:shakaran,项目名称:weatherpro,代码行数:31,代码来源:wsWuGraphs.php

示例8: mod_config

function mod_config($board_config = false)
{
    global $config, $mod, $board;
    if ($board_config && !openBoard($board_config)) {
        error($config['error']['noboard']);
    }
    if (!hasPermission($config['mod']['edit_config'], $board_config)) {
        error($config['error']['noaccess']);
    }
    $config_file = $board_config ? $board['dir'] . 'config.php' : 'inc/instance-config.php';
    if ($config['mod']['config_editor_php']) {
        $readonly = !(is_file($config_file) ? is_writable($config_file) : is_writable(dirname($config_file)));
        if (!$readonly && isset($_POST['code'])) {
            $code = $_POST['code'];
            // Save previous instance_config if php_check_syntax fails
            $old_code = file_get_contents($config_file);
            file_put_contents($config_file, $code);
            $resp = shell_exec_error('php -l ' . $config_file);
            if (preg_match('/No syntax errors detected/', $resp)) {
                header('Location: ?/config' . ($board_config ? '/' . $board_config : ''), true, $config['redirect_http']);
                return;
            } else {
                file_put_contents($config_file, $old_code);
                error($config['error']['badsyntax'] . $resp);
            }
        }
        $instance_config = @file_get_contents($config_file);
        if ($instance_config === false) {
            $instance_config = "<?php\n\n// This file does not exist yet. You are creating it.";
        }
        $instance_config = str_replace("\n", '&#010;', utf8tohtml($instance_config));
        mod_page(_('Config editor'), 'mod/config-editor-php.html', array('php' => $instance_config, 'readonly' => $readonly, 'boards' => listBoards(), 'board' => $board_config, 'file' => $config_file, 'token' => make_secure_link_token('config' . ($board_config ? '/' . $board_config : ''))));
        return;
    }
    require_once 'inc/mod/config-editor.php';
    $conf = config_vars();
    foreach ($conf as &$var) {
        if (is_array($var['name'])) {
            $c =& $config;
            foreach ($var['name'] as $n) {
                $c =& $c[$n];
            }
        } else {
            $c = @$config[$var['name']];
        }
        $var['value'] = $c;
    }
    unset($var);
    if (isset($_POST['save'])) {
        $config_append = '';
        foreach ($conf as $var) {
            $field_name = 'cf_' . (is_array($var['name']) ? implode('/', $var['name']) : $var['name']);
            if ($var['type'] == 'boolean') {
                $value = isset($_POST[$field_name]);
            } elseif (isset($_POST[$field_name])) {
                $value = $_POST[$field_name];
            } else {
                continue;
            }
            // ???
            if (!settype($value, $var['type'])) {
                continue;
            }
            // invalid
            if ($value != $var['value']) {
                // This value has been changed.
                $config_append .= '$config';
                if (is_array($var['name'])) {
                    foreach ($var['name'] as $name) {
                        $config_append .= '[' . var_export($name, true) . ']';
                    }
                } else {
                    $config_append .= '[' . var_export($var['name'], true) . ']';
                }
                $config_append .= ' = ';
                if (@$var['permissions'] && isset($config['mod']['groups'][$value])) {
                    $config_append .= $config['mod']['groups'][$value];
                } else {
                    $config_append .= var_export($value, true);
                }
                $config_append .= ";\n";
            }
        }
        if (!empty($config_append)) {
            $config_append = "\n// Changes made via web editor by \"" . $mod['username'] . "\" @ " . date('r') . ":\n" . $config_append . "\n";
            if (!is_file($config_file)) {
                $config_append = "<?php\n\n{$config_append}";
            }
            if (!@file_put_contents($config_file, $config_append, FILE_APPEND)) {
                $config_append = htmlentities($config_append);
                if ($config['minify_html']) {
                    $config_append = str_replace("\n", '&#010;', $config_append);
                }
                $page = array();
                $page['title'] = 'Cannot write to file!';
                $page['config'] = $config;
                $page['body'] = '
					<p style="text-align:center">Tinyboard could not write to <strong>' . $config_file . '</strong> with the ammended configuration, probably due to a permissions error.</p>
					<p style="text-align:center">You may proceed with these changes manually by copying and pasting the following code to the end of <strong>' . $config_file . '</strong>:</p>
					<textarea style="width:700px;height:370px;margin:auto;display:block;background:white;color:black" readonly>' . $config_append . '</textarea>
//.........这里部分代码省略.........
开发者ID:vicentil,项目名称:vichan,代码行数:101,代码来源:pages.php

示例9: substr

                                $unicode = (15 & $ascii) * 262144 + (63 & $ascii1) * 4096 + (63 & $ascii2) * 64 + (63 & $ascii3);
                                $result .= "&#{$unicode};";
                                $i += 3;
                            }
                        }
                    }
                }
            }
        }
        return $result;
    }
}
// utf-8 convert
$thisPage = substr($_SERVER["SCRIPT_NAME"], strrpos($_SERVER["SCRIPT_NAME"], "/") + 1);
if ($thisPage == 'wxwugraphs.php') {
    $TWUsource = utf8tohtml($TWUsource);
}
if ($dataSource == 'mysql') {
    $sourceString = '';
} else {
    $sourceString = ' ' . $TWUsource . ' <a href="http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=' . $WUID . '" target="_blank" onmouseover="Tip(\'&lt;img src=&#34;' . $mainDir . 'images/wunder-long.png&#34; alt=&#34;Wunderground Logo&#34; width=&#34;230&#34; height=&#34;33&#34; /&gt;\',TITLE,\'Weather Undeground server\')" onmouseout="UnTip()">Wunderground.com (' . $WUID . ')</a>';
}
$uvarg = isset($winFlag) ? $winFlag : false;
if ($uvarg || $tabFlag) {
    echo '
<table style="width: 100%; color: #bbb;" id="WUGcInfo">
<tr><td class="c-lside">
<div>WU-Graphs <span' . $redVer . ' onmouseover="Tip(\'' . $tooltipVer . '\',ABOVE, true)" onmouseout="UnTip()">&nbsp;v ' . VERSION . '</span></div>
&copy; 2010 <a href="http://pocasi.hovnet.cz/wxwug.php?lang=en" target="_blank" onmouseover="Tip(\'Author\\\'s weather Web site with more information about this software.\',TITLE,\'Weather station Hovezi - Czech Republic\')" onmouseout="UnTip()">Radomir Luza</a>. Powered by <a href="http://www.highcharts.com" target="_blank" rel="nofollow" onmouseover="Tip(\'&lt;div style=&quot;width:190px;&quot;>&lt;img src=&#34;' . $mainDir . 'images/higcharts-logo.png&#34; alt=&#34;Highcharts Logo&#34; width=&#34;175&#34; height=&#34;33&#34; /&gt;&lt;/div&gt;\',TITLE,\'JS charts for your webpages\', TEXTALIGN, \'center\')" onmouseout="UnTip()">HighCharts</a> &amp; <a href="http://www.jquery.com" target="_blank" rel="nofollow" onmouseover="Tip(\'&lt;div style=&quot;width:190px;&quot;&gt;&lt;img src=&#34;' . $mainDir . 'images/jquery-logo.png&#34; alt=&#34;jQuery Logo&#34; width=&#34;152&#34; height=&#34;33&#34; /&gt;&lt;/div&gt;\',TITLE,\'jQuery - write less, do more\', TEXTALIGN, \'center\')" onmouseout="UnTip()">jQuery UI</a></td>
<td class="c-rside" style="text-align: right; font-weight: bold; vertical-align: bottom; ">' . $sourceString . '</td></tr>
</table>
开发者ID:shakaran,项目名称:weatherpro,代码行数:31,代码来源:WUG-ver.php

示例10: __construct

 public function __construct($id, $subject, $email, $name, $trip, $capcode, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $sticky, $locked, $bumplocked, $embed, $root = null, $mod = false, $hr = true)
 {
     global $config;
     if (!isset($root)) {
         $root =& $config['root'];
     }
     $this->id = $id;
     $this->subject = utf8tohtml($subject);
     $this->email = $email;
     $this->name = utf8tohtml($name);
     $this->trip = $trip;
     $this->capcode = $capcode;
     $this->body = $body;
     $this->time = $time;
     $this->thumb = $thumb;
     $this->thumbx = $thumbx;
     $this->thumby = $thumby;
     $this->file = $file;
     $this->filex = $filex;
     $this->filey = $filey;
     $this->filesize = $filesize;
     $this->filename = $filename;
     $this->omitted = 0;
     $this->omitted_images = 0;
     $this->posts = array();
     $this->ip = $ip;
     $this->sticky = $sticky;
     $this->locked = $locked;
     $this->bumplocked = $bumplocked;
     $this->embed = $embed;
     $this->root = $root;
     $this->mod = $mod;
     $this->hr = $hr;
     if ($this->mod) {
         // Fix internal links
         // Very complicated regex
         $this->body = preg_replace('/<a(([a-zA-Z]+="[^"]+")|[a-zA-Z]+=[a-zA-Z]+|\\s)*href="' . preg_quote($config['root'], '/') . '(' . sprintf(preg_quote($config['board_path'], '/'), '\\w+') . ')/', '<a href="?/$3', $this->body);
     }
 }
开发者ID:npfriday,项目名称:Tinyboard,代码行数:39,代码来源:display.php

示例11: build_install

 function build_install($settings)
 {
     if (!is_numeric($settings['no_recent']) || $settings['no_recent'] < 0) {
         return array(false, '<strong>' . utf8tohtml($settings['no_recent']) . '</strong> is not a non-negative integer.');
     }
 }
开发者ID:0151n,项目名称:vichan,代码行数:6,代码来源:info.php

示例12: die

<?php

require 'inc/functions.php';
if (!$config['search']['enable']) {
    die(_("Post search is disabled"));
}
$queries_per_minutes = $config['search']['queries_per_minutes'];
$queries_per_minutes_all = $config['search']['queries_per_minutes_all'];
$search_limit = $config['search']['search_limit'];
if (isset($config['search']['boards'])) {
    $boards = $config['search']['boards'];
} else {
    $boards = listBoards(TRUE);
}
$body = Element('search_form.html', array('boards' => $boards, 'b' => isset($_GET['board']) ? $_GET['board'] : false, 'search' => isset($_GET['search']) ? str_replace('"', '&quot;', utf8tohtml($_GET['search'])) : false));
if (isset($_GET['search']) && !empty($_GET['search']) && isset($_GET['board']) && in_array($_GET['board'], $boards)) {
    $phrase = $_GET['search'];
    $_body = '';
    $query = prepare("SELECT COUNT(*) FROM ``search_queries`` WHERE `ip` = :ip AND `time` > :time");
    $query->bindValue(':ip', $_SERVER['REMOTE_ADDR']);
    $query->bindValue(':time', time() - $queries_per_minutes[1] * 60);
    $query->execute() or error(db_error($query));
    if ($query->fetchColumn() > $queries_per_minutes[0]) {
        error(_('Wait a while before searching again, please.'));
    }
    $query = prepare("SELECT COUNT(*) FROM ``search_queries`` WHERE `time` > :time");
    $query->bindValue(':time', time() - $queries_per_minutes_all[1] * 60);
    $query->execute() or error(db_error($query));
    if ($query->fetchColumn() > $queries_per_minutes_all[0]) {
        error(_('Wait a while before searching again, please.'));
    }
开发者ID:0151n,项目名称:vichan,代码行数:31,代码来源:search.php

示例13: error

         }
     } else {
         error(_('Unrecognized file size determination method.'));
     }
     if ($size > $config['max_filesize']) {
         error(sprintf3($config['error']['filesize'], array('sz' => number_format($size), 'filesz' => number_format($size), 'maxsz' => number_format($config['max_filesize']))));
     }
     $post['filesize'] = $size;
 }
 $post['capcode'] = false;
 if ($mod && preg_match('/^((.+) )?## (.+)$/', $post['name'], $matches)) {
     $name = $matches[2] != '' ? $matches[2] : $config['anonymous'];
     $cap = $matches[3];
     if (isset($config['mod']['capcode'][$mod['type']])) {
         if ($config['mod']['capcode'][$mod['type']] === true || is_array($config['mod']['capcode'][$mod['type']]) && in_array($cap, $config['mod']['capcode'][$mod['type']])) {
             $post['capcode'] = utf8tohtml($cap);
             $post['name'] = $name;
         }
     }
 }
 $trip = generate_tripcode($post['name']);
 $post['name'] = $trip[0];
 $post['trip'] = isset($trip[1]) ? $trip[1] : '';
 $noko = false;
 if (strtolower($post['email']) == 'noko') {
     $noko = true;
     $post['email'] = '';
 } elseif (strtolower($post['email']) == 'nonoko') {
     $noko = false;
     $post['email'] = '';
 } else {
开发者ID:0xjove,项目名称:lainchan,代码行数:31,代码来源:post.php

示例14: markup

function markup(&$body, $track_cites = false)
{
    global $board, $config, $markup_urls;
    $modifiers = extract_modifiers($body);
    $body = preg_replace('@<tinyboard (?!escape )([\\w\\s]+)>(.+?)</tinyboard>@us', '', $body);
    $body = preg_replace('@<(tinyboard) escape ([\\w\\s]+)>@i', '<$1 $2>', $body);
    if (isset($modifiers['raw html']) && $modifiers['raw html'] == '1') {
        return array();
    }
    $body = str_replace("\r", '', $body);
    $body = utf8tohtml($body);
    if (mysql_version() < 50503) {
        $body = mb_encode_numericentity($body, array(0x10000, 0xffffff, 0, 0xffffff), 'UTF-8');
    }
    if ($config['markup_code']) {
        $code_markup = array();
        $body = preg_replace_callback($config['markup_code'], function ($matches) use(&$code_markup) {
            $d = count($code_markup);
            $code_markup[] = $matches;
            return "<code {$d}>";
        }, $body);
    }
    foreach ($config['markup'] as $markup) {
        if (is_string($markup[1])) {
            $body = preg_replace($markup[0], $markup[1], $body);
        } elseif (is_callable($markup[1])) {
            $body = preg_replace_callback($markup[0], $markup[1], $body);
        }
    }
    if ($config['markup_urls']) {
        $markup_urls = array();
        $body = preg_replace_callback('/((?:https?:\\/\\/|ftp:\\/\\/|irc:\\/\\/)[^\\s<>()"]+?(?:\\([^\\s<>()"]*?\\)[^\\s<>()"]*?)*)((?:\\s|<|>|"|\\.||\\]|!|\\?|,|&#44;|&quot;)*(?:[\\s<>()"]|$))/', 'markup_url', $body, -1, $num_links);
        if ($num_links > $config['max_links']) {
            error($config['error']['toomanylinks']);
        }
    }
    if ($config['markup_repair_tidy']) {
        $body = str_replace('  ', ' &nbsp;', $body);
    }
    if ($config['auto_unicode']) {
        $body = unicodify($body);
        if ($config['markup_urls']) {
            foreach ($markup_urls as &$url) {
                $body = str_replace(unicodify($url), $url, $body);
            }
        }
    }
    $tracked_cites = array();
    // Cites
    if (isset($board) && preg_match_all('/(^|\\s)&gt;&gt;(\\d+?)([\\s,.)?]|$)/m', $body, $cites, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) {
        if (count($cites[0]) > $config['max_cites']) {
            error($config['error']['toomanycites']);
        }
        $skip_chars = 0;
        $body_tmp = $body;
        $search_cites = array();
        foreach ($cites as $matches) {
            $search_cites[] = '`id` = ' . $matches[2][0];
        }
        $search_cites = array_unique($search_cites);
        $query = query(sprintf('SELECT `thread`, `id` FROM ``posts_%s`` WHERE ' . implode(' OR ', $search_cites), $board['uri'])) or error(db_error());
        $cited_posts = array();
        while ($cited = $query->fetch(PDO::FETCH_ASSOC)) {
            $cited_posts[$cited['id']] = $cited['thread'] ? $cited['thread'] : false;
        }
        foreach ($cites as $matches) {
            $cite = $matches[2][0];
            // preg_match_all is not multibyte-safe
            foreach ($matches as &$match) {
                $match[1] = mb_strlen(substr($body_tmp, 0, $match[1]));
            }
            if (isset($cited_posts[$cite])) {
                $replacement = '<a onclick="highlightReply(\'' . $cite . '\');" href="' . $config['root'] . $board['dir'] . $config['dir']['res'] . link_for(array('id' => $cite, 'thread' => $cited_posts[$cite])) . '#' . $cite . '">' . '&gt;&gt;' . $cite . '</a>';
                $body = mb_substr_replace($body, $matches[1][0] . $replacement . $matches[3][0], $matches[0][1] + $skip_chars, mb_strlen($matches[0][0]));
                $skip_chars += mb_strlen($matches[1][0] . $replacement . $matches[3][0]) - mb_strlen($matches[0][0]);
                if ($track_cites && $config['track_cites']) {
                    $tracked_cites[] = array($board['uri'], $cite);
                }
            }
        }
    }
    // Cross-board linking
    if (preg_match_all('/(^|\\s)&gt;&gt;&gt;\\/(' . $config['board_regex'] . 'f?)\\/(\\d+)?([\\s,.)?]|$)/um', $body, $cites, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) {
        if (count($cites[0]) > $config['max_cites']) {
            error($config['error']['toomanycross']);
        }
        $skip_chars = 0;
        $body_tmp = $body;
        if (isset($cited_posts)) {
            // Carry found posts from local board >>X links
            foreach ($cited_posts as $cite => $thread) {
                $cited_posts[$cite] = $config['root'] . $board['dir'] . $config['dir']['res'] . ($thread ? $thread : $cite) . '.html#' . $cite;
            }
            $cited_posts = array($board['uri'] => $cited_posts);
        } else {
            $cited_posts = array();
        }
        $crossboard_indexes = array();
        $search_cites_boards = array();
        foreach ($cites as $matches) {
//.........这里部分代码省略.........
开发者ID:jejechan,项目名称:jejechan,代码行数:101,代码来源:functions.php

示例15: html

 public function html($count = false)
 {
     global $config;
     $elements = array('<input type="hidden" name="%name%" value="%value%">', '<input type="hidden" value="%value%" name="%name%">', '<input style="display:none" type="text" name="%name%" value="%value%">', '<input style="display:none" type="text" value="%value%" name="%name%">', '<span style="display:none"><input type="text" name="%name%" value="%value%"></span>', '<div style="display:none"><input type="text" name="%name%" value="%value%"></div>', '<div style="display:none"><input type="text" name="%name%" value="%value%"></div>', '<textarea style="display:none" name="%name%">%value%</textarea>', '<textarea name="%name%" style="display:none">%value%</textarea>');
     $html = '';
     if ($count === false) {
         $count = rand(1, count($this->inputs) / 15);
     }
     if ($count === true) {
         // all elements
         $inputs = array_slice($this->inputs, $this->index);
     } else {
         $inputs = array_slice($this->inputs, $this->index, $count);
     }
     $this->index += count($inputs);
     foreach ($inputs as $name => $value) {
         $element = false;
         while (!$element) {
             $element = $elements[array_rand($elements)];
             if (strpos($element, 'textarea') !== false && $value == '') {
                 // There have been some issues with mobile web browsers and empty <textarea>'s.
                 $element = false;
             }
         }
         $element = str_replace('%name%', utf8tohtml($name), $element);
         if (rand(0, 2) == 0) {
             $value = $this->make_confusing($value);
         } else {
             $value = utf8tohtml($value);
         }
         if (strpos($element, 'textarea') === false) {
             $value = str_replace('"', '&quot;', $value);
         }
         $element = str_replace('%value%', $value, $element);
         $html .= $element;
     }
     return $html;
 }
开发者ID:niksfish,项目名称:Tinyboard,代码行数:38,代码来源:anti-bot.php


注:本文中的utf8tohtml函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。