<?php
// --------------------
// Entry Format Parsing
// --------------------
function blog_to_html( $str, $comment_mode=false, $strip_all_tags=false, $add_no_follow = true ) {
global $site;
$str = stripslashes($str);
// Convert Simple Blog tags to HTML.
//
// Search and replace simple tags. These tags don't have any
// special attributes so we can do a str_replace() on them.
//
// ( Could use str_ireplace() but it's only supported in PHP 5. )
$tag_arr = array('i', 'b', 'blockquote', 'strong', 'em', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'del', 'ins', 'strike', 'pre', 'code' );
// Build search and replace arrays.
$search_arr = array();
$replace_arr = array();
for ( $i = 0; $i < count( $tag_arr ); $i++ ) {
$tag = $tag_arr[$i];
array_push( $search_arr, '[' . strtolower( $tag ) . ']', '[' . strtoupper( $tag ) . ']' );
if ( $strip_all_tags ) {
array_push( $replace_arr, '', '' );
} else {
array_push( $replace_arr, '<' . strtolower( $tag ) . '>', '<' . strtoupper( $tag ) . '>' );
}
array_push( $search_arr, '[/' . strtolower( $tag ) . ']', '[/' . strtoupper( $tag ) . ']' );
if ( $strip_all_tags ) {
array_push( $replace_arr, '', '' );
} else {
array_push( $replace_arr, '</' . strtolower( $tag ) . '>', '</' . strtoupper( $tag ) . '>' );
}
}
// Do str_replace() replacement.
$str = str_replace( $search_arr, $replace_arr, $str);
/*//oneoo
$handle=opendir('smiles/');
while ($file = readdir($handle)) {
if(substr($file,-4)=='.gif' || substr($file,-4)=='.jpg' || substr($file,-4)=='.png'){
$fs = substr($file,0,strlen($file)-4);
$str = str_replace( '['.$fs.']', ' <img src="smiles/'.$file.'" align=absMiddle> ', $str);
// echo "<A href=\"javascript:paste_smiles('[".substr($file,0,strlen($file)-4)."]','text')\"><IMG class=ib title=rolleyes alt=rolleyes src=\"smiles/".$file."\" align=absMiddle></A>\n";
}
}
closedir($handle);
// Do str_replace() replacement.
$str = str_replace( $search_arr, $replace_arr, $str);
*/
// Replace [url] Tags:
// The [url] tag has an optional "new" attribute. The "new"
// attribute determines whether to open the link in the
// same window or a new window.
// new - (true/false)
//
// [url=http://xxx]xxx[/url]
// [url=http://xxx new=true]xxx[/url]
if ( $strip_all_tags ) {
$str = replace_url_tag( $str, '[url=', ']', '[/url]', true, $add_no_follow );
$str = replace_url_tag( $str, '[URL=', ']', '[/URL]', true, $add_no_follow );
} else {
$str = replace_url_tag( $str, '[url=', ']', '[/url]', false, $add_no_follow );
$str = replace_url_tag( $str, '[URL=', ']', '[/URL]', false, $add_no_follow );
}
// Replace [img] Tags:
// The [img] tag has an number of optional attributes -
// width - width of image in pixels
// height - height of image in pixels
// popup - (true/false)
// float - (left/right)
//
// [img=http://xxx]
// [img=http://xxx width=xxx height=xxx popup=true float=left]
$str = replaceImgTag($str);
// Selectively replace line breaks and/or decode html entities.
if ( $comment_mode ) {
{
$str = replace_html_tag( $str, true );
}
} else {
if ( $strip_all_tags ) {
$str = replace_html_tag( $str, true );
} else {
$str = replace_html_tag( $str, false );
}
}
// Emoticons
$smile_arr = array();
array_push( $smile_arr, array( ':)', 'smile_regular.gif') );
array_push( $smile_arr, array( ':-)', 'smile_regular.gif') );
array_push( $smile_arr, array( ':(', 'smile_sad.gif') );
array_push( $smile_arr, array( ':-(', 'smile_sad.gif') );
// array_push( $smile_arr, array( ':o', 'smile_omg.gif') );
array_push( $smile_arr, array( ':-o', 'smile_omg.gif') );
array_push( $smile_arr, array( ':O', 'smile_omg.gif') );
array_push( $smile_arr, array( ':-O', 'smile_omg.gif') );
array_push( $smile_arr, array( ':p', 'smile_tongue.gif') );
array_push( $smile_arr, array( ':-p', 'smile_tongue.gif') );
array_push( $smile_arr, array( ':P', 'smile_tongue.gif') );
array_push( $smile_arr, array( ':-P', 'smile_tongue.gif') );
array_push( $smile_arr, array( ':D', 'smile_teeth.gif') );
array_push( $smile_arr, array( ':-D', 'smile_teeth.gif') );
array_push( $smile_arr, array( '(ci)', 'smoking.gif') );
array_push( $smile_arr, array( '(ci)', 'smoking.gif') );
array_push( $smile_arr, array( '(ci)', 'smoking.gif') );
array_push( $smile_arr, array( ':-@', 'smile_angry.gif') );
array_push( $smile_arr, array( ':@', 'smile_angry.gif') );
array_push( $smile_arr, array( ':-S', 'smile_confused.gif') );
array_push( $smile_arr, array( ':S', 'smile_confused.gif') );
array_push( $smile_arr, array( '8-)', 'smile_shades.gif') );
for ( $i = 0; $i < count( $smile_arr ); $i++ ) {
$str = str_replace( $smile_arr[$i][0], '<img src="'.$site['link'].'/images/smiles/'.$smile_arr[$i][1].'" alt="'.$smile_arr[$i][0].'" align="absMiddle">', $str );
}
return autolink(replace_poll_tag(replace_song_tag( $str )));
}
function replace_html_tag( $str, $strip_tags ) {
// Replacements for HTML tags. Sub-function of blog_to_html.
//
// This function decodes HTML entities that are located between
// HTML tags. Also, inserts <br />'s for new lines only if blocks
// are outside the HTML tags.
global $lang_string;
$str_out = NULL;
$tag_begin = '[html]';
$tag_end = '[/html]';
// Search for the openning HTML tag. Tag could be either upper or
// lower case so we want to find the nearest one.
//
// Get initial $str_offset value.
$temp_lower = strpos( $str, strtolower( $tag_begin ) );
$temp_upper = strpos( $str, strtoupper( $tag_begin ) );
if ( $temp_lower === false ) {
if ( $temp_upper === false ) {
$str_offset = false;
} else {
$str_offset = $temp_upper;
}
} else {
if ( $temp_upper === false ) {
$str_offset = $temp_lower;
} else {
$str_offset = min( $temp_upper, $temp_lower );
}
}
while ( $str_offset !== false ) {
// Store all the text BEFORE the openning HTML tag.
//
// Also, replace hard returns with '<br />' tags.
$temp_str = substr( $str, 0, $str_offset );
$temp_str = str_replace( chr(10), '<br />', $temp_str );
$str_out = $str_out . $temp_str;
// Store all text AFTER the tag
$str = substr( $str, $str_offset + strlen( $tag_begin ) );
// Search for the closing HTML tag. Find the nearest one.
$temp_lower = strpos( $str, strtolower( $tag_end ) );
$temp_upper = strpos( $str, strtoupper( $tag_end ) );
if ( $temp_lower === false ) {
if ( $temp_upper === false ) {
$str_offset = false;
} else {
$str_offset = $temp_upper;
}
} else {
if ( $temp_upper === false ) {
$str_offset = $temp_lower;
} else {
$str_offset = min( $temp_upper, $temp_lower );
}
}
if ( $str_offset !== false ) {
// Store all the text BETWEEN the HTML tags.
//
// Also, decode HTML entities between the tags.
$temp_str = substr( $str, 0, $str_offset );
if ( $strip_tags === false ) {
$temp_str = html_entity_decode( $temp_str, ENT_QUOTES, $lang_string[ 'php_charset' ] );
}
$str_out = $str_out . $temp_str;
// Store sub_string after the tag.
$str = substr( $str, $str_offset + strlen( $tag_end ) );
// Search for openning HTML tag again.
$temp_lower = strpos( $str, strtolower( $tag_begin ) );
$temp_upper = strpos( $str, strtoupper( $tag_begin ) );
if ( $temp_lower === false ) {
if ( $temp_upper === false ) {
$str_offset = false;
} else {
$str_offset = $temp_upper;
}
} else {
if ( $temp_upper === false ) {
$str_offset = $temp_lower;
} else {
$str_offset = min( $temp_upper, $temp_lower );
}
没有合适的资源?快使用搜索试试~ 我知道了~
基于PHP实现的yo2blog v0.9.1_yo2blog091_博客论坛(源代码+html).zip
共37个文件
gif:20个
php:11个
png:3个
0 下载量 109 浏览量
2024-04-26
00:43:32
上传
评论
收藏 50KB ZIP 举报
温馨提示
【项目资源】:包含前端、后端、移动开发、操作系统、人工智能、物联网、信息化管理、数据库、硬件开发、大数据、课程资源、音视频、网站开发等各种技术项目的源码。包括STM32、ESP8266、PHP、QT、Linux、iOS、C++、Java、python、web、C#、EDA、proteus、RTOS等项目的源码。【项目质量】:所有源码都经过严格测试,可以直接运行。功能在确认正常工作后才上传。【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。【附加价值】:项目具有较高的学习借鉴价值,也可直接拿来修改复刻。对于有一定基础或热衷于研究的人来说,可以在这些基础代码上进行修改和扩展,实现其他功能。【沟通交流】:有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。鼓励下载和使用,并欢迎大家互相学习,共同进步。
资源推荐
资源详情
资源评论
收起资源包目录
基于PHP实现的yo2blog v0.9.1_yo2blog091_博客论坛(源代码+html).zip (37个子文件)
[博客空间]yo2blog v0.9.1_yo2blog091
yo2blog v0.9.1
login.php 1KB
images.php 4KB
yo2blog_0.9.1_sql.sql 1KB
logo.gif 4KB
lib.js 4KB
rss.php 2KB
trackback.php 5KB
entry.php 10KB
setup.php 16KB
style.php 2KB
theme.php 4KB
favicon.ico 1KB
index.php 14KB
lib.php 5KB
formatting.php 22KB
images
ll.gif 538B
smiles
smile_shades.gif 339B
smile_teeth.gif 328B
smile_omg.gif 351B
smile_sad.gif 339B
smoking.gif 600B
smile_confused.gif 343B
smile_tongue.gif 343B
smile_regular.gif 346B
smile_angry.gif 331B
stop.gif 385B
play_o.gif 390B
top.gif 3KB
poll_1.gif 67B
play.gif 392B
load.gif 1KB
s.gif 49B
poll_0.gif 67B
stars
no_star.png 1KB
full_star.png 1KB
half_star.png 1KB
yo2blog.gif 716B
共 37 条
- 1
资源评论
大黄鸭duck.
- 粉丝: 3087
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功