2007-10-14 02:07
qingfeng129
[quote]原帖由 [i]Sai[/i] 于 2007-10-13 17:37 发表 [url=http://orzotl.com/bbs/redirect.php?goto=findpost&pid=438826&ptid=6050][img]http://orzotl.com/bbs/images/common/back.gif[/img][/url]
检查一下$boardurl(论坛路径)的填写 [/quote]
修改plugins 文件夹里的now.inc.php?
本人比较菜,不知道哪里有问题,请sai帮着看看吧,谢谢.
[quote]
<?php
/* Nowhere
* Author: Sai <[email=sai@live.com]sai@live.com[/email]>
* File: /plugins/now/now.inc.php
* Usage: Nowhere Core
* Copyright (C) 2007 Sai <[email=sai@live.com]sai@live.com[/email]>
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$ver = "V0.5.5.070720";
if ($action == "index") {
$navtitle = "大家的此时此刻 - ";
$title = "大家的此时此刻...";
require_once DISCUZ_ROOT.'./forumdata/cache/cache_nowhere.php';
$rsshead = '<link rel="alternate" type="application/rss+xml" title="Nowhere Everyone RSS" href="'.$boardurl.'feed/now" />';
if(preg_match('/(mozilla|opera|m3gate|winwap|openwave)/i', $_SERVER['HTTP_USER_AGENT'])) {
$discuz_action = 174;
include template('now');
} else {
$discuz_action = 178;
include template('now_wap');
}
}
if ($action == "") {
$author = trim($author);
if ($author == $discuz_userss) {
$navtitle = $discuz_userss."的此时此刻 - ";
$title = $discuz_userss." 的此时此刻 ...";
$query = $db->query("SELECT avatar FROM {$tablepre}memberfields WHERE uid = '{$discuz_uid}' LIMIT 1");
$member = $db->fetch_array($query);
$member['avatarbig'] = avRESIZE($member['avatar'],'');
$member['avatar'] = avRESIZE($member['avatar']);
$message_list = array();
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}plugin_now WHERE authorid = '{$discuz_uid}'");
$nowcount = $db->result($query, 0);
$threadmaxpages = 100;
$page = isset($page) ? max(1, intval($page)) : 1;
$page = $threadmaxpages && $page > $threadmaxpages ? 1 : $page;
if(preg_match('/(mozilla|opera|m3gate|winwap|openwave)/i', $_SERVER['HTTP_USER_AGENT'])) {
$start_limit = ($page - 1) * 50;
$multipage = now_multi($nowcount, 50, $page, "{$boardurl}now/".rawurlencode($discuz_userss)."/", $threadmaxpages);
$query = $db->query("SELECT n.*,mf.avatar FROM {$tablepre}plugin_now n LEFT JOIN {$tablepre}memberfields mf ON mf.uid=n.authorid WHERE n.authorid = '{$discuz_uid}' ORDER BY dateline DESC LIMIT {$start_limit},50");
} else {
$start_limit = ($page - 1) * 10;
$multipage = now_wap_multi($nowcount, 10, $page, "{$boardurl}now/".rawurlencode($discuz_userss)."/", $threadmaxpages);
$query = $db->query("SELECT n.*,mf.avatar FROM {$tablepre}plugin_now n LEFT JOIN {$tablepre}memberfields mf ON mf.uid=n.authorid WHERE n.authorid = '{$discuz_uid}' ORDER BY dateline DESC LIMIT {$start_limit},10");
}
$count = mysql_num_rows($query);
if ($count < 4) {
$hack_height = 'height: 240px; ';
} else {
$hack_height = '';
}
while ($message = $db->fetch_array($query)) {
$message['dateline'] = make_descriptive_time($message[dateline]);
$message['content'] = dhtmlspecialchars($message['content']);
$message['background'] = nwFROM($message['background']);
$message['iconshow'] = nwICONS($message['icons']);
$message_list[] = $message;
}
if(preg_match('/(mozilla|opera|m3gate|winwap|openwave)/i', $_SERVER['HTTP_USER_AGENT'])) {
$discuz_action = 175;
include template('now');
} else {
$discuz_action = 178;
include template('now_wap');
}
} else {
$query = $db->query("SELECT m.username, mf.avatar FROM {$tablepre}members m
LEFT JOIN {$tablepre}memberfields mf ON mf.uid=m.uid
WHERE username='".$author."'");
$member = $db->fetch_array($query);
$count = mysql_num_rows($query);
$navtitle = stripslashes($author)."的此时此刻 - ";
$title = stripslashes($author)." 的此时此刻 ...";
if ($count == 0) {
dheader("Location: {$boardurl}now");
} else {
$member['avatarbig'] = avRESIZE($member['avatar'],'');
$member['avatar'] = avRESIZE($member['avatar']);
$message_list = array();
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}plugin_now WHERE author = '{$author}'");
$nowcount = $db->result($query, 0);
$threadmaxpages = 100;
$page = isset($page) ? max(1, intval($page)) : 1;
$page = $threadmaxpages && $page > $threadmaxpages ? 1 : $page;
if(preg_match('/(mozilla|opera|m3gate|winwap|openwave)/i', $_SERVER['HTTP_USER_AGENT'])) {
$start_limit = ($page - 1) * 50;
$multipage = now_multi($nowcount, 50, $page, "{$boardurl}now/".rawurlencode($author)."/", $threadmaxpages);
$query = $db->query("SELECT n.*,mf.avatar FROM {$tablepre}plugin_now n LEFT JOIN {$tablepre}memberfields mf ON mf.uid=n.authorid WHERE n.author = '".$author."' ORDER BY dateline DESC LIMIT {$start_limit},50 ");
} else {
$start_limit = ($page - 1) * 10;
$multipage = now_wap_multi($nowcount, 10, $page, "{$boardurl}now/".rawurlencode($author)."/", $threadmaxpages);
$query = $db->query("SELECT n.*,mf.avatar FROM {$tablepre}plugin_now n LEFT JOIN {$tablepre}memberfields mf ON mf.uid=n.authorid WHERE n.author = '".$author."' ORDER BY dateline DESC LIMIT {$start_limit},10 ");
}
$count = mysql_num_rows($query);
if ($count < 4) {
$hack_height = 'height: 240px; ';
} else {
$hack_height = '';
}
$author = stripslashes($author);
while ($message = $db->fetch_array($query)) {
$message['dateline'] = make_descriptive_time($message[dateline]);
$message['content'] = dhtmlspecialchars($message['content']);
$message['background'] = nwFROM($message['background']);
$message['iconshow'] = nwICONS($message['icons']);
$message_list[] = $message;
}
if(preg_match('/(mozilla|opera|m3gate|winwap|openwave)/i', $_SERVER['HTTP_USER_AGENT'])) {
$discuz_action = 175;
include template('now');
} else {
$discuz_action = 178;
include template('now_wap');
}
}
}
}
if ($action == "friends") {
$discuz_action = 176;
$author = trim($author);
$navtitle = stripslashes($author)."和朋友们的此时此刻 - ";
$title = stripslashes($author)." 和朋友们的此时此刻 ...";
$query = $db->query("SELECT m.uid, mf.avatar FROM {$tablepre}members m LEFT JOIN {$tablepre}memberfields mf ON mf.uid=m.uid WHERE username='{$author}'");
$acount = mysql_num_rows($query);
$member = $db->fetch_array($query);
if ($acount == 0) {
dheader("Location: {$boardurl}now");
} else {
$member['avatarbig'] = avRESIZE($member['avatar'],'');
$member['avatar'] = avRESIZE($member['avatar']);
$message_list = array();
if(preg_match('/(mozilla|opera|m3gate|winwap|openwave)/i', $_SERVER['HTTP_USER_AGENT'])) {
$query = $db->query("SELECT n.*,b.buddyid,b.uid,mf.avatar FROM {$tablepre}plugin_now n
LEFT JOIN {$tablepre}buddys b ON b.buddyid=n.authorid
LEFT JOIN {$tablepre}memberfields mf ON mf.uid=n.authorid
WHERE b.uid = '{$member[uid]}' ORDER BY dateline DESC LIMIT 50");
} else {
$query = $db->query("SELECT n.*,b.buddyid,b.uid,mf.avatar FROM {$tablepre}plugin_now n
LEFT JOIN {$tablepre}buddys b ON b.buddyid=n.authorid
LEFT JOIN {$tablepre}memberfields mf ON mf.uid=n.authorid
WHERE b.uid = '{$member[uid]}' ORDER BY dateline DESC LIMIT 20");
}
$count = mysql_num_rows($query);
if ($count < 4) {
$hack_height = 'height: 240px; ';
} else {
$hack_height = '';
}
$author = stripslashes($author);
while ($message = $db->fetch_array($query)) {
$message['avatar'] = avRESIZE($message['avatar']);
$message['dateline'] = make_descriptive_time($message[dateline]);
$message['content'] = dhtmlspecialchars($message['content']);
$message['background'] = nwFROM($message['background']);
$message['iconshow'] = nwICONS($message['icons']);
$message_list[] = $message;
}
if(preg_match('/(mozilla|opera|m3gate|winwap|openwave)/i', $_SERVER['HTTP_USER_AGENT'])) {
include template('now');
} else {
include template('now_wap');
}
}
}
if ($action == "view") {
if (isset($_GET['now_id'])) {
$now_id = intval($_GET['now_id']);
$query = $db->query("SELECT count(vid) AS num FROM {$tablepre}plugin_now WHERE vid = {$now_id} LIMIT 1");
$rec = mysql_fetch_array($query);
$count = $rec['num'];
if ($count) {
$query = $db->query("SELECT n.*,mf.avatar FROM {$tablepre}plugin_now n LEFT JOIN {$tablepre}memberfields mf ON mf.uid=n.authorid WHERE vid = {$now_id} LIMIT 1");
} else {
dheader("Location: {$boardurl}now");
}
$message = $db->fetch_array($query);
if ($message) {
$navtitle = "$message[author] / ".$navtitle;
$message['avatar'] = avRESIZE($message['avatar']);
$message['dateline'] = make_descriptive_time($message[dateline]);
$message['content'] = dhtmlspecialchars($message['content']);
$message['background'] = nwFROM($message['background']);
}
include template('now_view');
}
}
if ($action == "stats"){
$statscachelife = $statscachelife *120;
$author = trim($author);
$query = $db->query("SELECT m.username, mf.avatar, m.uid FROM {$tablepre}members m LEFT JOIN {$tablepre}memberfields mf ON mf.uid=m.uid WHERE username='".$author."'");
$count = mysql_num_rows($query);
if ($count == 0) {
dheader("Location: {$boardurl}now");
} else {
$member = $db->fetch_array($query);
$navtitle = $member['username']."的状态统计 - ";
$title = $member['username']." 的状态统计 ...";
$member['avatar'] = avRESIZE($member['avatar']);
$innow_query = $db->query("SELECT COUNT(authorid) FROM {$tablepre}plugin_now WHERE authorid = '".$member['uid']."' LIMIT 1");
$innow_count = $db->result($innow_query, 0);
if ($innow_count == 0){
$stats['total'] = $stats['weekly'] = $stats['monthly'] = $stats['daily'] ='N/A';
} else {
$stats_query = $db->query("SELECT * FROM {$tablepre}plugin_now_stats WHERE uid = '".$member['uid']."'");
$count = mysql_num_rows($stats_query);
$stats = $db->fetch_array($stats_query);
if ($count == 0 || $timestamp - $stats['lastupdate'] > $statscachelife ) {
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}plugin_now WHERE authorid = '".$member['uid']."'");
$stats['total'] = $nowcount = $db->result($query, 0);
$now_query = $db->query("SELECT dateline FROM {$tablepre}plugin_now WHERE authorid = '".$member['uid']."'ORDER BY dateline ASC LIMIT 1");
$now =$db->fetch_array($now_query);
$now_first = gmdate('Y-m-d',$now['dateline']);
$now_day = round(make_desc_time($now['dateline'])) ;
$now_month = round($now_day / 30);
if ($now_month == 0) {
$now_month = 1;
}
$now_week = $timestamp - 604800;
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}plugin_now WHERE authorid = '".$member['uid']."' AND dateline > ".$now_week."");
$stats['weekly'] = $now_weekly = $db->result($query, 0);
$stats['monthly'] = $now_monthly = round($nowcount / $now_month);
$stats['daily'] = $now_daily = round($nowcount / make_desc_time($now['dateline']),2);
}
if ($count == 0){
$db->query("INSERT INTO {$tablepre}plugin_now_stats (uid, total, monthly, weekly, daily, firstupdate, lastupdate) VALUES ('".$member['uid']."', '".$nowcount."', '".$now_monthly."', '".$now_weekly."','".$now_daily."','".$now['dateline']."','".$timestamp."')");
} else if ($timestamp - $stats['lastupdate'] > $statscachelife) {
$db->query("REPLACE INTO {$tablepre}plugin_now_stats (uid, total, monthly, weekly, daily, firstupdate,lastupdate) VALUES ('".$member['uid']."', '".$nowcount."', '".$now_monthly."', '".$now_weekly."','".$now_daily."','".$now['dateline']."','".$timestamp."')");
}
$now_first = gmdate('Y-m-d',$stats['firstupdate']);
$lastupdate = gmdate("$dateformat $timeformat", $stats['lastupdate'] + $timeoffset * 3600);
$nextupdate = gmdate("$dateformat $timeformat", $stats['lastupdate'] + $statscachelife + $timeoffset * 3600);
}
}
include template('now_stats');
}
if ($action == "im") {
$discuz_action = 177;
require_once DISCUZ_ROOT.'./forumdata/cache/cache_nowhere.php';
$nowhereloop = $_DCACHE['nowhere'];
include template('now_im');
}
if ($action == "ojs") {
if(!$discuz_uid) {
dheader("Location: {$boardurl}now");
} else {
include template('now_ojs');
}
}
if ($action == "oimg") {
if(!$discuz_uid) {
dheader("Location: {$boardurl}now");
} else {
include template('now_oimg');
}
}
if ($action == "opost") {
include template('now_post');
}
if ($action == "js") {
if (isset($_GET['oe'])) {
$oe = strtolower($_GET['oe']);
if ($oe != 'gbk') {
$oe = 'utf-8';
}
} else {
$oe = "utf-8";
}
if ($oe != 'utf-8') {
header('Content-type: text/javascript; charset=gbk');
} else {
header('Content-type: text/javascript; charset=utf-8');
}
header('Cache-control: no-cache, must-revalidate');
if (isset($_GET['u'])) {
$user_nick = trim($_GET['u']);
if ($user_nick == '') {
$o = "document.writeln('<small style=\"font-size: 11px;\"><a href=\"[url=http://saicn.com/now\]http://saicn.com/now\[/url]" target=\"_blank\">NoNameMag::Nowhere</a></small> 输出失败 - 没有指定会员昵称');";
} else {
$query = $db->query("SELECT count(vid) AS num FROM {$tablepre}plugin_now WHERE author = '{$user_nick}' LIMIT 1");
$rec = mysql_fetch_array($query);
$count = $rec['num'];
if ($count) {
$query = $db->query("SELECT * FROM {$tablepre}plugin_now WHERE author = '{$user_nick}' ORDER BY dateline DESC LIMIT 1");
$message = $db->fetch_array($query);
if ($message) {
$messagen['author'] = rawurlencode($message[author]);
$message['dateline'] = make_descriptive_time($message[dateline]);
$message['content'] = dhtmlspecialchars($message['content']);
$message['background'] = nwFROM($message['background']);
}
$o = "document.writeln(\"<span style='color: \" + nnm_now_color_prefix + \";'>\" + nnm_now_prefix + \"</span> " . $message['content'] . " <small style='font-size: 11px; color: \" + nnm_now_color_time + \";'>at " . $message['dateline'] . " via <a href='http://saicn.com/now/" . $messagen[author] . "' target='_blank'>NoNameMag::Nowhere</a></small>\");";
} else {
$o = "document.writeln('<small style=\"font-size: 11px;\"><a href=\"[url=http://saicn.com/now\]http://saicn.com/now\[/url]" target=\"_blank\">NoNameMag::Nowhere</a></small> 输出失败 - 当前会员没有更新过Nowhere');";
}
}
}
if ($oe == 'uft-8') {
echo $o;
} else {
echo $o;
//echo mb_convert_encoding($o, 'gbk', 'utf-8');
}
}
if ($action == "new") {
if(empty($discuz_uid))
showmessage('not_loggedin', NULL, 'HALTED');
if (!$submit) {
if(preg_match('/(mozilla|opera|m3gate|winwap|openwave)/i', $_SERVER['HTTP_USER_AGENT'])) {
include template('now_new');
} else {
include template('now_new_wap');
}
} else {
if (!$content) {
showmessage('请输入文字内容', NULL, 'HALTED');
}
if (strlen($content) > 200) {
showmessage('您输入的文字超过了100字', NULL, 'HALTED');
}
$dateline = gmdate("y/m/d H:i", $timestamp + $timeoffset * 3600);
if (!$background) {
$background = "0";
}
if (preg_match('/(wii)/i', $_SERVER['HTTP_USER_AGENT'])) {
$background = "3";
}
/*
$query = $db->query("SELECT * FROM {$tablepre}plugin_now WHERE authorid = ".$discuz_uid." ORDER BY dateline DESC LIMIT 1");
$row = $db->fetch_array($query);
if ($row) {
$lastpost = $timestamp - $row['dateline'];
if ($lastpost < 10) {
showmessage('对不起,10秒之内您只能发表一次', NULL, 'HALTED');
}
}*/
$db->query("INSERT INTO {$tablepre}plugin_now (dateline, author, authorid, content, background, icons)
VALUES ('".$timestamp."', '$discuz_user', '$discuz_uid', '".$content."', '$background', '$iconsnew')");
require_once DISCUZ_ROOT.'./include/cache.func.php';
updatecache('nowhere');
#update_timeline();
@nowIMG($discuz_userss,$now_img_select);
/* require_once DISCUZ_ROOT.'./include/cache_nm.func.php';
require_once DISCUZ_ROOT.'./include/Geo.func.php';
$Geo = new Geo($geo, $Geo['map']);
$geo = $geo_user;
$geos_all_children = $Geo->nmGetRecursiveChildrenArray('', true);
$geos_all_children_sql = implode(',', $geos_all_children);
$geo_md5 = $geo_user_md5;
updatenmcache('geo_now_'.$geo_md5);
*/
if(preg_match('/(mozilla|opera|m3gate|winwap|openwave)/i', $_SERVER['HTTP_USER_AGENT'])) {
if ($background=='2') {
dheader("Location: {$boardurl}im");
} else if ($dashboard =='1') {
dheader("Location: {$boardurl}dashboard");
} else {
dheader("Location: {$boardurl}now/".rawurlencode($discuz_userss)."");
}
} else {
dheader("Location: {$boardurl}now/");
}
}
}
if ($action == "del") {
if(empty($discuz_uid))
showmessage('not_loggedin', NULL, 'HALTED');
if (isset($_GET['now_id'])) {
$now_id = intval($_GET['now_id']);
$query = $db->query("SELECT vid, authorid FROM {$tablepre}plugin_now WHERE vid = {$now_id}");
$row = $db->fetch_array($query);
if ($discuz_uid == $row['authorid']) {
$db->query("DELETE FROM {$tablepre}plugin_now WHERE vid = {$now_id} LIMIT 1");
require_once DISCUZ_ROOT.'./include/cache.func.php';
updatecache('nowhere');
@nowIMG($discuz_userss,$now_img_select);
} else {
dheader("Location: {$boardurl}now/".rawurlencode($discuz_userss)."");
}
dheader("Location: {$boardurl}now/".rawurlencode($discuz_userss)."");
}
dheader("Location: {$boardurl}now");
}
if ($action == "img_set") {
if(empty($discuz_uid))
showmessage('not_loggedin', NULL, 'HALTED');
if (isset($_GET['img_id'])) {
$img_id = intval($_GET['img_id']);
if ($discuz_uid) {
$db->query("UPDATE {$tablepre}members SET now_img = '{$img_id}' WHERE uid ={$discuz_uid} LIMIT 1");
@nowIMG($discuz_userss,$img_id);
} else {
dheader("Location: {$boardurl}oimg/now");
}
dheader("Location: {$boardurl}oimg/now");
}
dheader("Location: {$boardurl}now");
}
if ($action == "img") {
if (isset($_GET['u'])) {
$user_nick = trim($_GET['u']);
if ($user_nick == '') {
echo 'There is sth wrong with Nowhere';
} else {
$dir_output = './images/nowimg/'.$user_nick.'.png';
if (file_exists($dir_output)) {
header("Content-type: image/png");
readfile($dir_output);
} else {
header("Content-type: image/png");
readfile('./images/now/noimg.png');
}
}
}
}
function nowIMG($user_nick,$style = 0) {
$query = mysql_query("SELECT n.*,mf.avatar FROM cdb_plugin_now n LEFT JOIN cdb_memberfields mf ON mf.uid=n.authorid WHERE author = '{$user_nick}' ORDER BY dateline DESC LIMIT 1");
$item = mysql_fetch_array($query);
if (mysql_num_rows($query) == 0) {
$now_content = iconv('gbk', 'utf-8', '输出失败::当前用户未更新过Nowhere');
} else {
/* S:特别感谢 Sunyanzi */
$item['content'] = cutstr($item['content'],165);
$clean = array("\n","\r","\n\r");
$before = str_replace($clean,'',$item['content']);
if ($style == '0') {
$step = '28';
} else {
$step = '24';
}
for ($i=0;$i<mb_strlen($before);$i=$i+$step) {
$after .= mb_substr($before,$i,$step,'gbk')."\n\r";
}
/* E:特别感谢 Sunyanzi */
$now_content = iconv('gbk', 'utf-8', $after);
$now_author = iconv('gbk', 'utf-8', $item['author'].' 说:');
$now_date = date('Y-m-d h:m',$item['dateline']).' via '.nwFROM($item['background']);
if($item['icons']=='0'){
$now_icon ='';
} else {
$now_icon ='['.nwxmlICONS($item['icons']).']';
}
}
header("Content-type: image/png");
$avatar ='./'.avRESIZE($item['avatar']);
$date_font = './include/fonts/04b03.ttf';
$font = './include/fonts/MSYH.TTF';
if ($style == '0') {
$fn = './include/wbg/wbg2.jpg';
$image[0] = imagecreatefromjpeg($avatar);
$image[1] = imagecreatefromjpeg($fn);
$now = imagecopymerge($image[1],$image[0],12,16,0,0,32,32,100);
$fg = imagecolorallocate($image[1], 240, 240, 230);
$bg = imagecolorallocate($image[1], 120, 140, 190);
$bbg = imagecolorallocate($image[1], 20, 40, 40);
$fs = 10;
imagettftext($image[1], $fs, 0, 58, 47, $fg, $font, $now_content);
imagettftext($image[1], 10, 0, 55, 29, $bbg, $font, $now_author);
imagettftext($image[1], 10, 0, 55, 28, $fg, $font, $now_author);
imagettftext($image[1], 6, 0, 275, 115, $fg, $date_font, $now_date);
imagettftext($image[1], 8, 0, 10, 115, $fg, $font, $now_icon);
} else {
$fn = './include/wbg/wbg_bubble.gif';
$image[0] = imagecreatefromjpeg($avatar);
$image[1] = imagecreatefromgif($fn);
$now = imagecopymerge($image[1],$image[0],12,16,0,0,32,32,100);
$fs = 10;
imagettftext($image[1], $fs, 0, 58, 47, 0, $font, $now_content);
imagettftext($image[1], 10, 0, 58, 29, 0, $font, $now_author);
imagettftext($image[1], 6, 0, 270, 107, 0, $date_font, $now_date);
imagettftext($image[1], 8, 0, 305, 29, 0, $font, $now_icon);
}
imagepng($image[1],'./images/nowimg/'.$user_nick.'.png');
}
?>
[/quote]