原贴地址:https://discuz.dismall.com/thread-792441-1-1.html
说明:我的手动修改方法估计不是很完善,权为参考,愿意与大家一道学习讨论,你完全可以不用按照我的方法修改!
如果你采取我的方法修改.建议你在修改前备份原文件再做修动
注意:修改文件为9月4日版本的!请确认你的版本
奇虎组图服务插件Beta版发布
组图服务插件经过一段时间的开发和测试,今天正式和大家见面了!
在组图服务插件中我们提供了如下的功能,希望组图服务能提供给广大站长更多的帮助!
组图服务插件功能简介:
开启此项服务后,上传组图和播放组图flash所需的存储及带宽由奇虎网承担,而不占用您的任何存储空间及带宽。奇虎网作为 Discuz! 的核心合作伙伴,共同助力社区网站发展,为中国互联网企业及中小网站提供稳定、可靠的图片存储解决方案。
组图播放功能,在不影响现有附件方式上传图片的情况下,将帖子(主贴和跟帖)中的图片自动生成flash播放,方便用户快速阅读有大量图片的帖子,减轻站长服务器的存储和带宽压力。此功能也支持帖子中从外站引用过来的图片。
组图上传功能,将组图上传与其他附件上传分开,支持断点续传,解决用户上传多张图片容易失败、不方便管理等诸多问题,而且,组图的存储和带宽完全由奇虎提供,大大减轻了站长服务器的存储和带宽压力,用户打开有多个图片的帖子的速度也将明显提升。
一.打开:admin.php
找到- } elseif($action == 'videoconfig' || $action == 'video' || $action == 'videobind' || $action == 'videoclass') {
- $cpscript = 'video';
复制代码 在下面添加:- } elseif($action == 'imageconfig' || $action == 'image' || $action == 'imagebind') {
- $cpscript = 'image';
复制代码 保存.退出
=====================================
二.topicadmin.php
1.找到:- $query = $db->query("SELECT pid,
复制代码 在其后面(注意"'"号后面有一空格)加上整段为这样显示:- $query = $db->query("SELECT pid, tid, authorid, dateline, message, first FROM {$tablepre}posts WHERE pid IN ($deletepids) AND tid='$tid'");
复制代码 保存.退出;
==========================
三.继续找:- $pids .= ','.$post['pid'];
复制代码 下面加:- updateimaget($post['pid'], $post['tid'], 3, 0);
复制代码 保存,退出;
================================
四.viewthread.php
找到:- $newpostanchor = $postcount = $ratelogpids = 0;
复制代码 在前面(注意是前面)添加- $issetthid = $qihoothid =
复制代码 继续找后面加上(注意前后空格)再找在后面紧跟加上最后找到- $post['ratings'] = karmaimg($post['rate'], $post['ratetimes']);
复制代码 在下面加上- $issetthid = $post['qipid'] && empty($post['phid']) ? 1 : $issetthid;
- $qihoothid = $post['thid'] ? $post['thid'] : $qihoothid;
复制代码 保存退出;
=========================
五.admin\menu.inc.php
找- showmenu($lang['menu_qihoo'], array(array('name' => $lang['menu_qihoo_config'], 'url' => 'admincp.php?action=qihoo_config'),
- array('name' => $lang['menu_qihoo_topics'], 'url' => 'admincp.php?action=qihoo_topics'),
- array('name' => $lang['menu_qihoo_relatedthreads'], 'url' => 'admincp.php?action=qihoo_relatedthreads')));
复制代码 下面加- showmenu('组图功能',array(array('name' => '参数设置', 'url' => 'admincp.php?action=imageconfig'),
- array('name' => '绑定组图帐户', 'url' => 'admincp.php?action=imagebind')));
复制代码 保存.退出
=====================================
六.include\common.inc.php
找- $charset = $dbcharset = $forumfounders = $metakeywords = $extrahead = $seodescription =
复制代码 后面加上(注意前面有一空格)修改后整段代码显示为:- $charset = $dbcharset = $forumfounders = $metakeywords = $extrahead = $seodescription = $updatetoqihoo = '';
复制代码 保存,退出
====================================
七.include\cache.func.php
找在上面加上- $data['isiteid'] = $data['ikey'] = $data['ipassword'] = $data['iemail'] = $data['isiteurl'] = $data['qihoo_image_opent'] = $data['qihoo_image_openp'] = '';
- if($data['qihoo_image'] = unserialize($data['qihoo_image'])) {
- $data['isiteid'] = $data['qihoo_image']['isiteid'];
- $data['ikey'] = $data['qihoo_image']['ikey'];
- $data['iemail'] = $data['qihoo_image']['iemail'];
- $data['ipassword'] = $data['qihoo_image']['ipassword'];
- $data['isiteurl'] = $data['qihoo_image']['isiteurl'];
- $data['qihoo_image_opent'] = $data['qihoo_image']['qihoo_image_opent'];
- $data['qihoo_image_openp'] = $data['qihoo_image']['qihoo_image_openp'];
- }
- unset($data['qihoo_image']);
复制代码 保存,退出
========================================
八.include\discuzcode.func.php
1.找- "/\[img=(\d{1,4})[x|\,](\d{1,4})\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/ies"
复制代码 在下面加上- "/\[img=([^\[\<\r\n]+?)\]\s*([^\[\<\r\n]+?)\s*\[\/img\]/ies"
复制代码 2.再找- ), $allowimgcode ? array(
- ($parsetype != 1 ? "bbcodeurl('\\1', ' <img src="images/attachicons/flash.gif" align="absmiddle" alt="" /> <a href="%s" target="_blank">Flash: %s</a> ')" : ""),
- "bbcodeurl('\\1', '<img src="%s" border="0" onclick="zoom(this, this.src)" onload="attachimg(this, \'load\')" alt="" />')",
- "bbcodeurl('\\3', '<img width="\\1" height="\\2" src="%s" border="0" alt="" />')",
复制代码 下面加上- "bbcodeurl('\\1', '<img src="%s" border="0" alt="\\2" />')"
复制代码 3.继续找- ) : array(
- ($parsetype != 1 ? "bbcodeurl('\\1', ' <img src="images/attachicons/flash.gif" align="absmiddle" alt="" /> <a href="%s" target="_blank">Flash: %s</a> ')" : ""),
- "bbcodeurl('\\1', '<a href="%s" target="_blank">%s</a>')",
- "bbcodeurl('\\3', '<a href="%s" target="_blank">%s</a>')",
复制代码 下面加上- "bbcodeurl('\\1', '<a href="%s" target="_blank">\\2</a>')"
复制代码 4.继续找到- foreach(explode('+', $highlight) as $ret) {
- if($ret) {
- $message = preg_replace("/(^|>)([^><]*?)(".preg_quote($ret, '/').")([^><]*?)(<|$)/siU", "\\1\\2<u><strong><font color="#FF0000">\\3</font></strong></u>\\4\\5", $message);
- }
- }
复制代码 替换为- $highlightarray = explode('+', $highlight);
- $message = preg_replace('#(^|>)([^<]+)(?=<|$)#sUe', "highlight('\\2', \$highlightarray, '\\1', 0)", $message);
复制代码 5.在文件的最后加上- function highlight($text, $words, $prepend, $type = 1) {
- $text = str_replace('"', '"', $text);
- foreach($words AS $key => $replaceword) {
- if($type) {
- global $_DCACHE;
- if($_DCACHE['tags'][$key] && @strexists($text, $replaceword)) {
- $text = str_replace($replaceword, '<span href="tag.php?name='.rawurlencode($replaceword).'" onclick="tagshow(event)" class="t_tag">'.$replaceword.'</span>', $text);
- unset($_DCACHE['tags'][$key]);
- }
- } else {
- $text = str_replace($replaceword, '<strong><font color="#FF0000">'.$replaceword.'</font></strong>', $text);
- }
- }
- return "$prepend$text";
复制代码 保存,退出
============================================
九.include\editpost.inc.php
找- $query = $db->query("SELECT * FROM {$tablepre}posts WHERE pid='$pid' AND tid='$tid' AND fid='$fid'");
- $postinfo = $db->fetch_array($query);
复制代码 下面加上- if($qihoo_image_openp) {
- $qihoophid = $db->fetch_array($db->query("SELECT phid FROM {$tablepre}qihooimages WHERE pid='$pid' AND tid='$tid' LIMIT 1"));
- $postinfo['phid'] = empty($qihoophid['phid']) ? 0 : $qihoophid['phid'];
- }
复制代码 保存.退出
=============================================
十一.include\global.func.php
找- function dexit($message = '') {
- echo $message;
- output();
- exit();
- }
复制代码 在下面加入- function dfopen($url, $limit = 500000, $post = '', $cookie = '', $bysocket = FALSE, $ip = '', $timeout = 20, $block = TRUE) {
- global $version, $boardurl;
- if(ini_get('allow_url_fopen') && !$bysocket && !$post) {
- $fp = @fopen($url, 'r');
- $s = @fread($fp, $limit);
- @fclose($fp);
- return $s;
- }
- $return = '';
- $matches = parse_url($url);
- $host = $matches['host'];
- $script = substr($url, strlen($host) + 7);
- $script = $script ? $script : '/';
- $port = !empty($matches['port']) ? $matches['port'] : 80;
- if($post) {
- $out = "POST $script HTTP/1.0\r\n";
- $out .= "Accept: *\r\n";
- $out .= "Referer: $boardurl\r\n";
- $out .= "Accept-Language: zh-cn\r\n";
- $out .= "Content-Type: application/x-www-form-urlencoded\r\n";
- $out .= "User-Agent: Comsenz/1.0 ($version)\r\n";
- $out .= "Host: $host\r\n";
- $out .= 'Content-Length: '.strlen($post)."\r\n";
- $out .= "Connection: Close\r\n";
- $out .= "Cache-Control: no-cache\r\n";
- $out .= "Cookie: $cookie\r\n\r\n";
- $out .= $post;
- } else {
- $out = "GET $script HTTP/1.0\r\n";
- $out .= "Accept: */*\r\n";
- $out .= "Referer: $boardurl\r\n";
- $out .= "Accept-Language: zh-cn\r\n";
- $out .= "User-Agent: Comsenz/1.0 ($version)\r\n";
- $out .= "Host: $host\r\n";
- $out .= "Connection: Close\r\n";
- $out .= "Cookie: $cookie\r\n\r\n";
- }
- $fp = @fsockopen(($ip ? $ip : $host), $port, $errno, $errstr, $timeout);
- if(!$fp) {
- return '';//note $errstr : $errno \r\n
- } else {
- stream_set_blocking($fp, $block);
- stream_set_timeout($fp, $timeout);
- @fwrite($fp, $out);
- $status = stream_get_meta_data($fp);
- if($status['timed_out']) {
- return '';
- }
- while(!feof($fp) && $limit > -1) {
- $limit -= 524;
- $return .= @fread($fp, 524);
- }
- @fclose($fp);
- $return = preg_replace("/\r\n\r\n/", "\n\n", $return, 1);
- $strpos = strpos($return, "\n\n");
- $strpos = $strpos !== FALSE ? $strpos + 2 : 0;
- $return = substr($return, $strpos);
- return $return;
- }
- }
复制代码 再找- global $authkey, $ftp, $attachdir
复制代码 后面加上继续找- @unlink($attachdir.'/'.$filename);
- $havethumb && @unlink($attachdir.'/'.$filename.'.thumb.jpg');
复制代码 在下面加上- }
- if($qihoo_image_opent && in_array(strtolower(fileext($filename)), array('jpg', 'jpeg', 'gif', 'png', 'swf', 'bmp'))) {
- updatetoqihoo('2');
复制代码 保存,退出
=========================================================
十二.include\newreply.inc.php
找- $replymessage = 'post_reply_succeed';
复制代码 在上面加上- //note qihoo主题图打开的情况下,并且是楼主本人、有上传图片附件、帖子内容有[img]调用updateimaget函数。
- if($qihoo_image_opent && ($thread['authorid'] == $discuz_uid) && (strpos($message, '[/hide]') === FALSE) && (isattachmentimage($pid) || strpos($message, '[/img]') !== FALSE)) {
- updateimaget($pid, $tid, 1, intval(strpos($message, '[/img]') !== FALSE));
- }
- if($qihoo_image_openp && $phid) {
- updateimagep($pid, $tid, $phid);
-
- if(empty($subject)) {
- $threadsubject = $db->fetch_array($db->query("SELECT subject FROM {$tablepre}threads WHERE tid='$tid'"));
- $subject = $threadsubject['subject'];
- }
- dfopen($isiteurl."/discuz/update.php?sid=$isiteid&code=".urlencode(authcode("spassword=$ipassword&phid=$phid&tid=$tid&pid=$pid&uid=".$postinfo['authorid']."&ctime=".$postinfo['dateline']."&mtime=$timestamp", '', $ikey))."&title=".urlencode($subject)."&content=".urlencode(spacecutstr($message, 500)), 10000, '', '', TRUE, '', 20, FALSE);
- }
复制代码 保存,退出
==========================================
十三.include\newthread.inc.php
找- if($iscircle && $sgid) {
- supe_dbconnect();
- $query = $supe['db']->query("UPDATE {$supe[tablepre]}groups SET lastpost='$timestamp' WHERE gid='$sgid'", 'SILENT');
- }
复制代码 在上面添加上- //note qihoo主题图打开的情况下,有上传图片附件、帖子内容有[img]调用updateimaget函数。
- if($qihoo_image_opent && (strpos($message, '[/hide]') === FALSE) && (isattachmentimage($pid) || strpos($message, '[/img]') !== FALSE)) {
- updateimaget($pid, $tid, 1, intval(strpos($message, '[/img]') !== FALSE));
- }
- if($qihoo_image_openp && $phid) {
- updateimagep($pid, $tid, $phid);
- dfopen($isiteurl."/discuz/update.php?sid=$isiteid&code=".urlencode(authcode("spassword=$ipassword&phid=$phid&tid=$tid&pid=$pid&uid=".$postinfo['authorid']."&ctime=".$postinfo['dateline']."&mtime=$timestamp", '', $ikey))."&title=".urlencode($subject)."&content=".urlencode(spacecutstr($message, 500)), 10000, '', '', TRUE, '', 20, FALSE);
- }
复制代码 保存,退出
=====================================
十四.include\post.func.php
找- function arrayslice($array, $offset, $length) {
- if(PHP_VERSION >= '5.0.2') {
- return array_slice($array, $offset, $length, TRUE);
- } else {
- $array = array_chunk($array, $length, TRUE);
- return $array[$offset / $length];
- }
- }
复制代码 在下面加上- function isattachmentimage($pid) {
- global $db, $tablepre;
- $isattachmentimage = 0;
- $query = $db->query("SELECT isimage FROM {$tablepre}attachments WHERE pid='$pid'");
- while($imageinfo = $db->fetch_array($query)) {
- $isattachmentimage = empty($imageinfo['isimage']) ? $isattachmentimage : $imageinfo['isimage'];
- }
- return $isattachmentimage;
- }
- function isubbimage($pid) {
- global $db, $tablepre;
- $isubbimage = 0;
- $query = $db->query("SELECT hasimage FROM {$tablepre}qihooimages WHERE pid='$pid'");
- while($imageinfo = $db->fetch_array($query)) {
- $isubbimage = empty($imageinfo['hasimage']) ? $isubbimage : $imageinfo['hasimage'];
- }
- return $isubbimage;
- }
- function updateimaget($pid, $tid, $type, $hasimage) {
- global $db, $tablepre, $timestamp;
- $hasimage = $hasimage ? '1' : '0';
- if($type == 2 || $type == 1) {
- $postimageurl = $db->fetch_array($db->query("SELECT * FROM {$tablepre}qihooimages WHERE pid='$pid'"));
- if($postimageurl['pid']) {
- $sqlmode = 'UPDATE';
- $sqltype = $postimageurl['type'] == '1' && $postimageurl['status'] == '1' ? '1' : '2';
- $sqlconditions = "WHERE pid='$pid'";
- } else {
- $sqlmode = 'INSERT INTO';
- $sqltype = '1';
- $sqlconditions = '';
- }
- $sql = "$sqlmode {$tablepre}qihooimages SET pid='$pid', tid='$tid', dateline='$timestamp', hasimage='$hasimage', type='$sqltype', status='1' $sqlconditions";
- } elseif($type == 3) {
- $sql = "UPDATE {$tablepre}qihooimages SET dateline='$timestamp', hasimage='$hasimage', type='3', status='1' WHERE pid='$pid'";
- }
- //echo $sql; exit;
- if(!empty($sql)) {
- $db->query($sql);
- updatetoqihoo();
- }
- }
- function updateimagep($pid, $tid, $phid) {
- global $db, $tablepre;
- $postimagep = $db->fetch_array($db->query("SELECT pid FROM {$tablepre}qihooimages WHERE pid='$pid'"));
- if($postimagep['pid']) {
- $sqlmode = 'UPDATE';
- $sqlconditions = "WHERE pid='$pid'";
- } else {
- $sqlmode = 'INSERT INTO';
- $sqlconditions = '';
- }
- $db->query("$sqlmode {$tablepre}qihooimages SET pid='$pid', tid='$tid', phid='$phid' $sqlconditions");
- }
- function updatetoqihoo ($type = '0') {
- global $db, $tablepre, $isiteid, $ikey, $ipassword,$updatetoqihoo, $pid, $tid,$timestamp,$isiteurl;
-
- if(empty($updatetoqihoo)) {
- $returninfo = dfopen($isiteurl."/discuz/notify.php?sid=$isiteid&code=".urlencode(authcode('spassword='.$ipassword, '', $ikey)), 10000, '', '', TRUE, '', 20, FALSE);
- $updatetoqihoo = '1';
- }
- if($type == '2') {
- $db->query("UPDATE {$tablepre}qihooimages SET type='2', dateline='$timestamp',status='1' WHERE pid='$pid'");
- }
- }
- function spacecutstr($str, $length) {
- global $_DCACHE;
- include_once DISCUZ_ROOT.'./forumdata/cache/cache_post.php';
- $bbcodes = 'b|i|u|color|size|font|align|list|indent|url|email|code|free|table|tr|td|img|swf|payto|float'.($_DCACHE['bbcodes_display'] ? '|'.implode('|', array_keys($_DCACHE['bbcodes_display'])) : '');
- $str = dhtmlspecialchars(cutstr(strip_tags(preg_replace(array(
- "/\[hide=?\d*\](.+?)\[\/hide\]/is",
- "/\[quote](.*)\[\/quote]/siU",
- "/\[($bbcodes)=?.*\]/iU",
- "/\[\/($bbcodes)\]/i",
- "/\[attach\](\d+)\[\/attach\]/i",
- "/\[media=(\w{1,4}),(\d{1,4}),(\d{1,4}),(\d)\]\s*([^\[\<\r\n]+?)\s*\[\/media\]/i",
- ), array(
- '',
- '',
- '',
- '',
- '',
- "\\5"
- ), $str)), $length));
- $find = array("/http:\/\/[a-z0-9\/\-_+=.~!%@?#%&;:$\\()|]+?\.(jpg|gif|png|bmp)/is", "/(\n|\r|\r\n){2,}/", "/\s{2,}/");
- $replace = array("<img onload="if(this.width>320) {this.resized=true;this.width=320;}" src="\\0">", "\r\n", '');
- $str = preg_replace($find, $replace, $str);
- return trim(nl2br($str));
- }
复制代码 保存,退出
============================================
十五.\templates\default\post_editor.htm
找- <!--{if $forum['allowmediacode']}-->
- <div class="popupmenu_popup" id="{$editorid}_popup_media_menu" style="width: 240px;display: none">
- <input type="hidden" id="{$editorid}_mediatype" value="ra">
- <input type="hidden" id="{$editorid}_mediaautostart" value="0">
- <table cellpadding="4" cellspacing="0" border="0" unselectable="on">
- <tr class="popupmenu_option">
复制代码 在上面加上- <div class="popupmenu_popup" id="{$editorid}_popup_image_menu" style="width: 240px;display: none" unselectable="on">
- {lang post_discuzcode_imageurl}:
- <input id="{$editorid}_imageurl" size="40" value=""/>
- 图片描述:
- <input id="{$editorid}_imagedescription" size="40" value=""/>
- <center><input type="button" size="8" value="{lang submit}" onclick="setimagecode('$editorid')"> <input type="button" onclick="hideMenu()" value="{lang cancel}" /></center>
- </div>
复制代码 继续找- <!--{if $allowpostattach}-->
- <table class="box" summary="Upload" cellspacing="0" cellpadding="0">
- <thead>
复制代码 在上面添加上- <!--{if $qihoo_image_openp}-->
- <script type="text/javascript">
- var qihoo_image_openp = 1;
- lang['phidstatus'] = '请先完成Flash的保存,否则会丢失数据!';
- function setImageInfo(phid, phidstatus) {
- $('phid').value = phid;
- $('phidstatus').value = phidstatus;
- }
- </script>
- <!--{eval $phidstring = empty($postinfo[phid]) ? '' : '&phid='.$postinfo[phid];}-->
- <!--{eval $code = "&spassword=$ipassword&tid=$tid&pid=$pid".$phidstring;}-->
- <!--{eval $code = urlencode(authcode($code,"",$ikey))}-->
- <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" id="uploadimages" width="750" height="240" align="middle">
- <param name="allowScriptAccess" value="always" />
- <param name="FlashVars" value="sid=$isiteid&code=$code{$phidstring}">
- <param name="movie" value="http://p.qihoo.com/flash/upload.swf" />
- <param name="quality" value="high" />
- <param name="bgcolor" value="#FFFFFF" />
- <embed src="http://p.qihoo.com/flash/upload.swf" quality="high" bgcolor="#FFFFFF" width="750" height="240" swLiveConnect=true id="uploadimages" name="uploadimages" align="middle" allowScriptAccess="always" FlashVars="sid=$isiteid&code=$code{$phidstring}" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
- </object>
- <input type="hidden" name="phid" id="phid" value="$postinfo[phid]" />
- <input type="hidden" name="phidstatus" id="phidstatus" value="0" />
- <!--{/if}-->
复制代码 保存,退出
==============================================
十六.templates\default\viewthread.htm
找到- <div id="postmessage_$post[pid]" class="t_msgfont">$post[message]</div>
复制代码 注意:分两步添加
1.在上面添加- <!--{if $post['first'] == 1 && $qihoo_image_opent && !$post['attachment']}-->
- <!--{if $issetthid && empty($qihoothid)}-->
- <div class="qihooimage" style="float:right;"><a href="viewimages.php?tid=$post[tid]&pid=$post[pid]" target="_blank"><img src="images/common/viewimage.gif"></a></div>
- <!--{elseif $qihoothid}-->
- <!--{eval $thidstring = $qihoothid;}-->
- <!--{eval $code = "&spassword=$ipassword&thid=$thidstring&ctime=$timestamp";}-->
- <!--{eval $code = urlencode(authcode($code,"",$ikey))}-->
- <div class="qihooimage" style="float:right;">
- <script type="text/javascript" src="include/javascript/qihooimage.js"></script>
- <script language="javascript" type="text/javascript">
- //<![CDATA[
- flashTagIns.setNew("http://p.qihoo.com/flash/miniature.swf?sid=$isiteid&code=$code", 215, 60);
- flashTagIns.setVersion("7,0,19,0");
- flashTagIns.write(document);
- //]]>
- </script>
- </div>
- <!--{/if}-->
- <!--{/if}-->
复制代码 2.在下面添加- <!--{if $post['qipid'] && $post['phid']}-->
- <!--{eval $phidtemp = $post[phid];}-->
- <!--{eval $code = "&spassword=$ipassword&phid=$phidtemp&ctime=$timestamp";}-->
- <!--{eval $code = urlencode(authcode($code,"",$ikey))}-->
- <script type="text/javascript" src="include/javascript/qihooimage.js"></script>
- <div class="swf">
- <script language="javascript" type="text/javascript">
- //<![CDATA[
- flashTagIns.setNew("http://p.qihoo.com/flash/pic_view.swf?sid=$isiteid&code=$code&auto={$post['first']}", 575, 475);
- flashTagIns.setVersion("7,0,19,0");
- flashTagIns.write(document);
- //]]>
- </script>
- </div>
- <!--{/if}-->
复制代码 保存,退出
=======================================
其余文件平时涉及修改较少,直接覆盖即可
[ 本帖最后由 lqng 于 2007-11-23 10:33 编辑 ] |