This commit is contained in:
2013-04-02 01:03:29 +08:00
parent 5b5e2c4d66
commit 0a2903e20d
5 changed files with 230 additions and 230 deletions

View File

@@ -1,6 +1,6 @@
emlog 读者墙插件
====================
貌似没什么好介绍的了最初模仿的是wordpress的读者墙其实就是模仿wordpress的根据emlog的特殊性移植过来。有周读者墙月读者墙总读者墙取决于你怎么调用。
emlog 读者墙插件
====================
貌似没什么好介绍的了最初模仿的是wordpress的读者墙其实就是模仿wordpress的根据emlog的特殊性移植过来。有周读者墙月读者墙总读者墙取决于你怎么调用。
[插件主页](http://xiaosong.org/share/emlog-readers-wall-plug-reloaded)

View File

@@ -1,109 +1,109 @@
<?php
/*
Plugin Name: 读者墙
Version: 4.2.3
Plugin URL: http://xiaosong.org/share/emlog-readers-wall-plug-reloaded
Description: 页面或文章正文,侧边栏显示读者墙
ForEmlog: 4.1.0以上
Author: 小松
Author Email: sahala_2007@126.com
Author URL: http://xiaosong.org
*/
!defined('EMLOG_ROOT') && exit('access deined!');
require_once('reader_wall_config.php');
function reader_wall(){
global $imgnum_week,$imgnum_month,$imgnum_all,$imgsize_week,$imgsize_month,$imgsize_all,$tip;
$CACHE = Cache::getInstance();
$user_cache = $CACHE->readCache('user');
$content = ob_get_clean();
if (Option::get('isgzipenable') == 'y' && function_exists('ob_gzhandler')){
ob_start('ob_gzhandler');
} else {
ob_start();
}
$content = explode("<body",$content);
$log_content = $content[1];
if(strpos($log_content, '[READERWALL-WEEK]') > -1) {
$cur_time_span = strtotime('last Monday',strtotime('Sunday'));
$option = 0;
$imgnums = $imgnum_week;
$imgsize = $imgsize_week;
}
elseif(strpos($log_content, '[READERWALL-MONTH]') > -1){
$cur_time_span = strtotime('this month',strtotime(date('m/01/y')));
$option = 1;
$imgnums = $imgnum_month;
$imgsize = $imgsize_month;
}
else{$cur_time_span = 0;$option = 2;$imgnums = $imgnum_all;$imgsize = $imgsize_all;}
if(empty($imgsize)){$imgsize = 32;}
$DB = MySql::getInstance();
$userName = $user_cache[1]['name'];
$userMail = $user_cache[1]['mail'];
$sql = "SELECT count(1) AS comment_nums,poster,mail,url FROM ".DB_PREFIX."comment where date > $cur_time_span and mail != '' and mail != '$userMail' and poster != '$userName' and hide = 'n' group by mail order by comment_nums DESC limit 0,$imgnums";
$result = $DB->query($sql);
while($row = $DB->fetch_array($result)){
$img = "<img width='".$imgsize."' height='".$imgsize."' title='".$row['poster']." (".$row['comment_nums'].")' alt='' src='".getGravatar($row['mail'],$imgsize)."' />";
if($row['url']){
$tmp = "<a href='".$row['url']."' target='_blank'>".$img."</a>";
}else{$tmp = $img;}
$output .= $tmp;
}
if(empty($output)){
$output = "<p style='text-align:center'>".$tip."</p>";
}else{
$output = "<div id='readerswall'>".$output."</div>";}
if($option == 0)
$log_content = preg_replace("'\[READERWALL-WEEK\]'i", $output, $log_content, 1);
elseif($option == 1)
$log_content = preg_replace("'\[READERWALL-MONTH\]'i", $output, $log_content, 1);
else
$log_content = preg_replace("'\[READERWALL\]'i", $output, $log_content, 1);
echo $content[0].'<body'.$log_content;
unset($content);
unset($log_content);
}
addAction('index_footer', 'reader_wall');
function reader_wall_side(){
global $imgsize_side,$imgnum_side,$type_wall,$tip,$open;
$CACHE = Cache::getInstance();
$user_cache = $CACHE->readCache('user');
if($type_wall == 'week'){
$time_side = strtotime('last Monday',strtotime('Sunday'));
}elseif($type_wall == 'month'){
$time_side = strtotime('this month',strtotime(date('m/01/y')));
}else{
$time_side = 0;
}
if(empty($imgsize_side)){
$imgsize_side = 32;
}
$DB = MySql::getInstance();
$userName = $user_cache[1]['name'];
$sql_side = "SELECT count(1) AS comment_nums,poster,mail,url FROM ".DB_PREFIX."comment where date > $time_side and mail != '' and poster != '$userName' and hide ='n' group by mail order by comment_nums DESC limit 0,$imgnum_side";
$result_side = $DB->query($sql_side);
while($row_side = $DB->fetch_array($result_side)){
$img_side = "<img width='".$imgsize_side."' height='".$imgsize_side."' title='".$row_side['poster']." (".$row_side['comment_nums'].")' alt='' src='".getGravatar($row_side['mail'],$imgsize_side)."' />";
if($row_side['url']){
$tmp_side = "<a href='".$row_side['url']."' target='_blank'>".$img_side."</a>";
}else{
$tmp_side = $img_side;
}
$output_side .= $tmp_side;
}
if(empty($output_side)){
$output_side = "<p style='text-align:center'>".$tip."</p>";
}else{
$output_side = "<div id='readerswall_side'>".$output_side."</div>";
}
return $output_side;
}
if(isset($_GET['reader_wall_widgets'])){
echo 'document.write("'.reader_wall_side().'")';
exit;
}
function reader_wall_menu(){
echo '<div class="sidebarsubmenu" id="reader_wall"><a href="./plugin.php?plugin=reader_wall">读者墙设置</a></div>';
}
addAction('adm_sidebar_ext', 'reader_wall_menu');
<?php
/*
Plugin Name: 读者墙
Version: 4.2.3
Plugin URL: http://xiaosong.org/share/emlog-readers-wall-plug-reloaded
Description: 页面或文章正文,侧边栏显示读者墙
ForEmlog: 4.1.0以上
Author: 小松
Author Email: sahala_2007@126.com
Author URL: http://xiaosong.org
*/
!defined('EMLOG_ROOT') && exit('access deined!');
require_once('reader_wall_config.php');
function reader_wall(){
global $imgnum_week,$imgnum_month,$imgnum_all,$imgsize_week,$imgsize_month,$imgsize_all,$tip;
$CACHE = Cache::getInstance();
$user_cache = $CACHE->readCache('user');
$content = ob_get_clean();
if (Option::get('isgzipenable') == 'y' && function_exists('ob_gzhandler')){
ob_start('ob_gzhandler');
} else {
ob_start();
}
$content = explode("<body",$content);
$log_content = $content[1];
if(strpos($log_content, '[READERWALL-WEEK]') > -1) {
$cur_time_span = strtotime('last Monday',strtotime('Sunday'));
$option = 0;
$imgnums = $imgnum_week;
$imgsize = $imgsize_week;
}
elseif(strpos($log_content, '[READERWALL-MONTH]') > -1){
$cur_time_span = strtotime('this month',strtotime(date('m/01/y')));
$option = 1;
$imgnums = $imgnum_month;
$imgsize = $imgsize_month;
}
else{$cur_time_span = 0;$option = 2;$imgnums = $imgnum_all;$imgsize = $imgsize_all;}
if(empty($imgsize)){$imgsize = 32;}
$DB = MySql::getInstance();
$userName = $user_cache[1]['name'];
$userMail = $user_cache[1]['mail'];
$sql = "SELECT count(1) AS comment_nums,poster,mail,url FROM ".DB_PREFIX."comment where date > $cur_time_span and mail != '' and mail != '$userMail' and poster != '$userName' and hide = 'n' group by mail order by comment_nums DESC limit 0,$imgnums";
$result = $DB->query($sql);
while($row = $DB->fetch_array($result)){
$img = "<img width='".$imgsize."' height='".$imgsize."' title='".$row['poster']." (".$row['comment_nums'].")' alt='' src='".getGravatar($row['mail'],$imgsize)."' />";
if($row['url']){
$tmp = "<a href='".$row['url']."' target='_blank'>".$img."</a>";
}else{$tmp = $img;}
$output .= $tmp;
}
if(empty($output)){
$output = "<p style='text-align:center'>".$tip."</p>";
}else{
$output = "<div id='readerswall'>".$output."</div>";}
if($option == 0)
$log_content = preg_replace("'\[READERWALL-WEEK\]'i", $output, $log_content, 1);
elseif($option == 1)
$log_content = preg_replace("'\[READERWALL-MONTH\]'i", $output, $log_content, 1);
else
$log_content = preg_replace("'\[READERWALL\]'i", $output, $log_content, 1);
echo $content[0].'<body'.$log_content;
unset($content);
unset($log_content);
}
addAction('index_footer', 'reader_wall');
function reader_wall_side(){
global $imgsize_side,$imgnum_side,$type_wall,$tip,$open;
$CACHE = Cache::getInstance();
$user_cache = $CACHE->readCache('user');
if($type_wall == 'week'){
$time_side = strtotime('last Monday',strtotime('Sunday'));
}elseif($type_wall == 'month'){
$time_side = strtotime('this month',strtotime(date('m/01/y')));
}else{
$time_side = 0;
}
if(empty($imgsize_side)){
$imgsize_side = 32;
}
$DB = MySql::getInstance();
$userName = $user_cache[1]['name'];
$sql_side = "SELECT count(1) AS comment_nums,poster,mail,url FROM ".DB_PREFIX."comment where date > $time_side and mail != '' and poster != '$userName' and hide ='n' group by mail order by comment_nums DESC limit 0,$imgnum_side";
$result_side = $DB->query($sql_side);
while($row_side = $DB->fetch_array($result_side)){
$img_side = "<img width='".$imgsize_side."' height='".$imgsize_side."' title='".$row_side['poster']." (".$row_side['comment_nums'].")' alt='' src='".getGravatar($row_side['mail'],$imgsize_side)."' />";
if($row_side['url']){
$tmp_side = "<a href='".$row_side['url']."' target='_blank'>".$img_side."</a>";
}else{
$tmp_side = $img_side;
}
$output_side .= $tmp_side;
}
if(empty($output_side)){
$output_side = "<p style='text-align:center'>".$tip."</p>";
}else{
$output_side = "<div id='readerswall_side'>".$output_side."</div>";
}
return $output_side;
}
if(isset($_GET['reader_wall_widgets'])){
echo 'document.write("'.reader_wall_side().'")';
exit;
}
function reader_wall_menu(){
echo '<div class="sidebarsubmenu" id="reader_wall"><a href="./plugin.php?plugin=reader_wall">读者墙设置</a></div>';
}
addAction('adm_sidebar_ext', 'reader_wall_menu');
?>

View File

@@ -1,28 +1,28 @@
<?php
if(!defined('EMLOG_ROOT')) {exit('error!');}
function callback_init(){
$CACHE = Cache::getInstance();
$DB = MySql::getInstance();
$options_cache = $CACHE->readCache('options');
//写入widgest
$custom_widget = $options_cache['custom_widget'] ? @unserialize($options_cache['custom_widget']) : array();
$reader_wall_widgets_content = '<script type="text/javascript" src="'.BLOG_URL.'index.php?reader_wall_widgets"></script>';
if(is_array($custom_widget))
{
if(!in_array('custom_wg_reader_wall',array_keys($custom_widget)))
{
//添加
$custom_wg_index = 'custom_wg_reader_wall';
$custom_widget[$custom_wg_index] = array('title'=>"读者墙",'content'=>$reader_wall_widgets_content);
$custom_widget_str = addslashes(serialize($custom_widget));
$DB->query("update ".DB_PREFIX."options set option_value='$custom_widget_str' where option_name='custom_widget'");
//启用
$widgets = !empty($options_cache['widgets1']) ? unserialize($options_cache['widgets1']) : array();
$widgets[] = "custom_wg_reader_wall";
$widgets = serialize($widgets);
$DB->query("update ".DB_PREFIX."options set option_value='$widgets' where option_name='widgets1'");
$CACHE->updateCache('options');
}
}
}
<?php
if(!defined('EMLOG_ROOT')) {exit('error!');}
function callback_init(){
$CACHE = Cache::getInstance();
$DB = MySql::getInstance();
$options_cache = $CACHE->readCache('options');
//写入widgest
$custom_widget = $options_cache['custom_widget'] ? @unserialize($options_cache['custom_widget']) : array();
$reader_wall_widgets_content = '<script type="text/javascript" src="'.BLOG_URL.'index.php?reader_wall_widgets"></script>';
if(is_array($custom_widget))
{
if(!in_array('custom_wg_reader_wall',array_keys($custom_widget)))
{
//添加
$custom_wg_index = 'custom_wg_reader_wall';
$custom_widget[$custom_wg_index] = array('title'=>"读者墙",'content'=>$reader_wall_widgets_content);
$custom_widget_str = addslashes(serialize($custom_widget));
$DB->query("update ".DB_PREFIX."options set option_value='$custom_widget_str' where option_name='custom_widget'");
//启用
$widgets = !empty($options_cache['widgets1']) ? unserialize($options_cache['widgets1']) : array();
$widgets[] = "custom_wg_reader_wall";
$widgets = serialize($widgets);
$DB->query("update ".DB_PREFIX."options set option_value='$widgets' where option_name='widgets1'");
$CACHE->updateCache('options');
}
}
}
?>

View File

@@ -1,12 +1,12 @@
<?php
$imgnum_week = 20;
$imgsize_week = 32;
$imgnum_month = 30;
$imgsize_month = 32;
$imgnum_all = 40;
$imgsize_all = 32;
$imgnum_side = 8;
$imgsize_side = 32;
$type_wall = 'all';
$tip = '墙上还没人,快抢沙发啦~';
<?php
$imgnum_week = 20;
$imgsize_week = 32;
$imgnum_month = 30;
$imgsize_month = 32;
$imgnum_all = 40;
$imgsize_all = 32;
$imgnum_side = 8;
$imgsize_side = 32;
$type_wall = 'all';
$tip = '墙上还没人,快抢沙发啦~';
?>

View File

@@ -1,80 +1,80 @@
<?php
/*
* 读者墙插件
* design by 小松
*/
function plugin_setting_view(){
require_once('reader_wall_config.php');
}
?>
<script type="text/javascript">
$("#reader_wall").addClass('sidebarsubmenu1');
</script>
<div class="containertitle"><b>读者墙设置</b>
<?php if(isset($_GET['setting'])):?><span class="actived">插件设置完成</span><?php endif;?>
</div>
<div class="line"></div>
<form action="plugin.php?plugin=reader_wall&action=setting" method="post">
<div>
<p>①、一周评论排行显示头像数:
<input size="3" name="imgnum_week" type="text" value="<?php echo $imgnum_week; ?>" />
&nbsp;&nbsp;头像大小单位为px
<input size="3" name="imgsize_week" type="text" value="<?php echo $imgsize_week; ?>" />
</p>
<p>②、一月评论排行显示头像数:
<input size="3" name="imgnum_month" type="text" value="<?php echo $imgnum_month; ?>" />
&nbsp;&nbsp;头像大小单位为px
<input size="3" name="imgsize_month" type="text" value="<?php echo $imgsize_month; ?>" />
</p>
<p>③、开博至今评论排行显示头像数:
<input size="3" name="imgnum_all" type="text" value="<?php echo $imgnum_all; ?>" />
&nbsp;&nbsp;头像大小单位为px
<input size="3" name="imgsize_all" type="text" value="<?php echo $imgsize_all; ?>" />
</p>
<p>④、侧边栏评论排行显示头像数:
<input size="3" name="imgnum_side" type="text" value="<?php echo $imgnum_side; ?>" />
&nbsp;&nbsp;头像大小单位为px
<input size="3" name="imgsize_side" type="text" value="<?php echo $imgsize_side; ?>" />
&nbsp;&nbsp;统计区间:
<select name="type_wall">
<option value="week"<?php if($type_wall == 'week'):?> selected<?php endif;?>>week</option>
<option value="month"<?php if($type_wall == 'month'):?> selected<?php endif;?>>month</option>
<option value="all"<?php if($type_wall == 'all'):?> selected<?php endif;?>>all</option>
</select>
</p>
<p>⑤、如果统计区间内数据为空,则显示如下:
<input size="50" name="tip" type="text" value="<?php echo $tip; ?>" />
</p>
<p><input type="submit" value="保 存" class="submit" /></p>
</div>
</form>
<?php
function plugin_setting(){
$imgnum_week = isset($_POST['imgnum_week']) ? intval($_POST['imgnum_week']) : 20;
$imgsize_week = isset($_POST['imgsize_week']) ? intval($_POST['imgsize_week']) : 32;
$imgnum_month = isset($_POST['imgnum_month']) ? intval($_POST['imgnum_month']) : 30;
$imgsize_month = isset($_POST['imgsize_month']) ? intval($_POST['imgsize_month']) : 32;
$imgnum_all = isset($_POST['imgnum_all']) ? intval($_POST['imgnum_all']) : 40;
$imgsize_all = isset($_POST['imgsize_all']) ? intval($_POST['imgsize_all']) : 32;
$imgnum_side = isset($_POST['imgnum_side']) ? intval($_POST['imgnum_side']) : 8;
$imgsize_side = isset($_POST['imgsize_side']) ? intval($_POST['imgsize_side']) : 32;
$type_wall = isset($_POST['type_wall']) ? addslashes(trim($_POST['type_wall'])) : '';
$tip = isset($_POST['tip']) ? addslashes(trim($_POST['tip'])) : '';
$data = "<?php
\$imgnum_week = ".$imgnum_week.";
\$imgsize_week = ".$imgsize_week.";
\$imgnum_month = ".$imgnum_month.";
\$imgsize_month = ".$imgsize_month.";
\$imgnum_all = ".$imgnum_all.";
\$imgsize_all = ".$imgsize_all.";
\$imgnum_side = ".$imgnum_side.";
\$imgsize_side = ".$imgsize_side.";
\$type_wall = '".$type_wall."';
\$tip = '".$tip."';
?>";
$file = EMLOG_ROOT.'/content/plugins/reader_wall/reader_wall_config.php';
@ $fp = fopen($file, 'wb') OR emMsg('读取文件失败如果您使用的是Unix/Linux主机请修改文件/content/plugins/reader_wall/reader_wall_config.php的权限为777。如果您使用的是Windows主机请联系管理员将该文件设为everyone可写');
@ $fw = fwrite($fp,$data) OR emMsg('写入文件失败如果您使用的是Unix/Linux主机请修改文件/content/plugins/reader_wall/reader_wall_config.php的权限为777。如果您使用的是Windows主机请联系管理员将该文件设为everyone可写');
fclose($fp);
}
<?php
/*
* 读者墙插件
* design by 小松
*/
function plugin_setting_view(){
require_once('reader_wall_config.php');
}
?>
<script type="text/javascript">
$("#reader_wall").addClass('sidebarsubmenu1');
</script>
<div class="containertitle"><b>读者墙设置</b>
<?php if(isset($_GET['setting'])):?><span class="actived">插件设置完成</span><?php endif;?>
</div>
<div class="line"></div>
<form action="plugin.php?plugin=reader_wall&action=setting" method="post">
<div>
<p>①、一周评论排行显示头像数:
<input size="3" name="imgnum_week" type="text" value="<?php echo $imgnum_week; ?>" />
&nbsp;&nbsp;头像大小单位为px
<input size="3" name="imgsize_week" type="text" value="<?php echo $imgsize_week; ?>" />
</p>
<p>②、一月评论排行显示头像数:
<input size="3" name="imgnum_month" type="text" value="<?php echo $imgnum_month; ?>" />
&nbsp;&nbsp;头像大小单位为px
<input size="3" name="imgsize_month" type="text" value="<?php echo $imgsize_month; ?>" />
</p>
<p>③、开博至今评论排行显示头像数:
<input size="3" name="imgnum_all" type="text" value="<?php echo $imgnum_all; ?>" />
&nbsp;&nbsp;头像大小单位为px
<input size="3" name="imgsize_all" type="text" value="<?php echo $imgsize_all; ?>" />
</p>
<p>④、侧边栏评论排行显示头像数:
<input size="3" name="imgnum_side" type="text" value="<?php echo $imgnum_side; ?>" />
&nbsp;&nbsp;头像大小单位为px
<input size="3" name="imgsize_side" type="text" value="<?php echo $imgsize_side; ?>" />
&nbsp;&nbsp;统计区间:
<select name="type_wall">
<option value="week"<?php if($type_wall == 'week'):?> selected<?php endif;?>>week</option>
<option value="month"<?php if($type_wall == 'month'):?> selected<?php endif;?>>month</option>
<option value="all"<?php if($type_wall == 'all'):?> selected<?php endif;?>>all</option>
</select>
</p>
<p>⑤、如果统计区间内数据为空,则显示如下:
<input size="50" name="tip" type="text" value="<?php echo $tip; ?>" />
</p>
<p><input type="submit" value="保 存" class="submit" /></p>
</div>
</form>
<?php
function plugin_setting(){
$imgnum_week = isset($_POST['imgnum_week']) ? intval($_POST['imgnum_week']) : 20;
$imgsize_week = isset($_POST['imgsize_week']) ? intval($_POST['imgsize_week']) : 32;
$imgnum_month = isset($_POST['imgnum_month']) ? intval($_POST['imgnum_month']) : 30;
$imgsize_month = isset($_POST['imgsize_month']) ? intval($_POST['imgsize_month']) : 32;
$imgnum_all = isset($_POST['imgnum_all']) ? intval($_POST['imgnum_all']) : 40;
$imgsize_all = isset($_POST['imgsize_all']) ? intval($_POST['imgsize_all']) : 32;
$imgnum_side = isset($_POST['imgnum_side']) ? intval($_POST['imgnum_side']) : 8;
$imgsize_side = isset($_POST['imgsize_side']) ? intval($_POST['imgsize_side']) : 32;
$type_wall = isset($_POST['type_wall']) ? addslashes(trim($_POST['type_wall'])) : '';
$tip = isset($_POST['tip']) ? addslashes(trim($_POST['tip'])) : '';
$data = "<?php
\$imgnum_week = ".$imgnum_week.";
\$imgsize_week = ".$imgsize_week.";
\$imgnum_month = ".$imgnum_month.";
\$imgsize_month = ".$imgsize_month.";
\$imgnum_all = ".$imgnum_all.";
\$imgsize_all = ".$imgsize_all.";
\$imgnum_side = ".$imgnum_side.";
\$imgsize_side = ".$imgsize_side.";
\$type_wall = '".$type_wall."';
\$tip = '".$tip."';
?>";
$file = EMLOG_ROOT.'/content/plugins/reader_wall/reader_wall_config.php';
@ $fp = fopen($file, 'wb') OR emMsg('读取文件失败如果您使用的是Unix/Linux主机请修改文件/content/plugins/reader_wall/reader_wall_config.php的权限为777。如果您使用的是Windows主机请联系管理员将该文件设为everyone可写');
@ $fw = fwrite($fp,$data) OR emMsg('写入文件失败如果您使用的是Unix/Linux主机请修改文件/content/plugins/reader_wall/reader_wall_config.php的权限为777。如果您使用的是Windows主机请联系管理员将该文件设为everyone可写');
fclose($fp);
}
?>