Archive for the ‘ blog设计 ’ Category

micolog反向代理后IP的获取

总所周知GAE的博客是需要反向代理的,否则只能翻墙访问了。

但是反向代理之后评论等等地方显示的ip都全部是反向代理服务器的ip了。

开工:

需要改两个文件:

blog.py

第一处:

self.remote_ip = ”
try:
    if self.remote_ip == ”:
        self.remote_ip = self.request.headers['x-forwarded-for']
    if self.remote_ip == ”:
        self.remote_ip = self.request.headers['Proxy-Client-IP']
    if self.remote_ip == ”:
        self.remote_ip = self.request.headers['WL-Proxy-Client-IP']
except:
    if self.remote_ip == ”:
        self.remote_ip = self.request.remote_addr

image

 

第二处:

image

第三处:

image

第四处:

image

第二个文件是rpc编辑的时候用的,可以不用修改。

api_rpc.py

image

注意:一定要小心空格或者是tab,micolog是采用的tab,如果采用空格来分隔会报错的。

为discuz帖子列表页面增加ajax更新

先看效果吧:

image

目的就是使用户能够不用刷新就能获得帖子更新。

第一步:修改模板文件forumdisplay,htm

1、在文件开头添加ajax请求的判断

<!–{if !$inajax}–>

如图:

image

2、在文件结尾加上else

<!–{else}–>
{template header_ajax}
<table>
                <!–{loop $threadlist $key $thread}–>

                <tbody id=”$thread[id]“>
                    <tr>
                        <td class=”folder”>
                            <a href=”viewthread.php?tid=$thread[tid]&amp;extra=$extra” title=”{lang target_blank}” target=”_blank”>
                            <!–{if $thread[folder] == ‘lock’}–>
                                <img src=”{IMGDIR}/folder_lock.gif” /></a>
                            <!–{elseif in_array($thread['displayorder'], array(1, 2, 3, 4))}–>
                                <img src=”{IMGDIR}/pin_$thread[displayorder].gif” alt=”$threadsticky[3-$thread[displayorder]]” /></a>
                            <!–{else}–>
                                <img src=”{IMGDIR}/folder_$thread[folder].gif” /></a>
                            <!–{/if}–>
                        </td>
                        <td class=”icon”>
                        <!–{if $thread['special'] == 1}–>
                            <a href=”forumdisplay.php?fid=$fid&amp;filter=poll”><img src=”{IMGDIR}/pollsmall.gif” alt=”{lang thread_poll}” /></a>
                        <!–{elseif $thread['special'] == 2}–>
                            <a href=”forumdisplay.php?fid=$fid&amp;filter=trade”><img src=”{IMGDIR}/tradesmall.gif” alt=”{lang thread_trade}” /></a>
                        <!–{elseif $thread['special'] == 3}–>
                            <a href=”forumdisplay.php?fid=$fid&amp;filter=reward”><img src=”{IMGDIR}/rewardsmall.gif” alt=”{lang thread_reward}” <!–{if $thread['price'] < 0}–>class=”solved”<!–{/if}–> /></a>
                        <!–{elseif $thread['special'] == 4}–>
                            <a href=”forumdisplay.php?fid=$fid&amp;filter=activity”><img src=”{IMGDIR}/activitysmall.gif” alt=”{lang thread_activity}” /></a>
                        <!–{elseif $thread['special'] == 5}–>
                            <a href=”forumdisplay.php?fid=$fid&amp;filter=debate”><img src=”{IMGDIR}/debatesmall.gif” alt=”{lang thread_debate}” /></a>
                        <!–{else}–>
                            $thread['icon']
                        <!–{/if}–>
                        </td>
                        <!–{if $forum['ismoderator']}–>
                        <td class=”icon”>
                            <!–{if $thread['fid'] == $fid && $thread['digest'] >= 0}–>
                                <!–{if $thread['displayorder'] <= 3 || $adminid == 1}–>
                                    <input onclick=”tmodclick(this)” class=”checkbox” type=”checkbox” name=”moderate[]” value=”$thread[tid]” />
                                <!–{else}–>
                                    <input class=”checkbox” type=”checkbox” disabled=”disabled” />
                                <!–{/if}–>
                            <!–{else}–>
                                <input class=”checkbox” type=”checkbox” disabled=”disabled” />
                            <!–{/if}–>
                        </td>
                        <!–{/if}–>
                        <th class=”subject $thread[folder]“>
                            <label>{$pluginhooks[forumdisplay_thread][$key]}&nbsp;</label>
                            <!–{if $thread['moved']}–>
                                <!–{if $forum['ismoderator']}–>
                                    <a href=”topicadmin.php?action=moderate&optgroup=3&operation=delete&tid=$thread[moved]” onclick=”showWindow(‘mods’, this.href);return false”>{lang thread_moved}:</a>
                                <!–{else}–>
                                    {lang thread_moved}:
                                <!–{/if}–>
                            <!–{/if}–>
                            $thread[sortid] $thread[typeid]
                            <span id=”thread_$thread[tid]“><a href=”viewthread.php?tid=$thread[tid]&amp;extra=$extra”$thread[highlight]>$thread[subject]</a></span>
                            <!–{if $thread['readperm']}–> – [{lang readperm} <span class="bold">$thread[readperm]</span>]<!–{/if}–>
                            <!–{if $thread['price'] > 0}–>
                                <!–{if $thread['special'] == ’3′}–>
                                – <span style=”color: #C60″>[{lang thread_reward}{$extcredits[$creditstransextra[2]][title]} <span class=”bold”>$thread[price]</span> {$extcredits[$creditstransextra[2]][unit]}]</span>
                                <!–{else}–>
                                – [{lang price} {$extcredits[$creditstransextra[1]][title]} <span class=”bold”>$thread[price]</span> {$extcredits[$creditstransextra[1]][unit]}]
                                <!–{/if}–>
                            <!–{elseif $thread['special'] == ’3′ && $thread['price'] < 0}–>
                                – <span style=”color: #269F11″>[{lang reward_solved}]</span>
                            <!–{/if}–>
                            <!–{if $thread['attachment'] == 2}–>
                                <img src=”images/attachicons/image_s.gif” alt=”{lang attach_img}” class=”attach” />
                            <!–{elseif $thread['attachment'] == 1}–>
                                <img src=”images/attachicons/common.gif” alt=”{lang attachment}” class=”attach” />
                            <!–{/if}–>
                            <!–{if $thread['displayorder'] == 0}–>
                                <!–{if $thread[recommendicon]}–>
                                    <img src=”{IMGDIR}/recommend_$thread[recommendicon].gif” class=”attach” alt=”{lang thread_recommend}” title=”{lang thread_recommend}” />
                                <!–{/if}–>
                                <!–{if $thread[heatlevel]}–>
                                    <img src=”{IMGDIR}/hot_$thread[heatlevel].gif” class=”attach” alt=”$thread[heatlevel] {lang heats}” title=”$thread[heatlevel] {lang heats}” />
                                <!–{/if}–>
                                <!–{if $thread['digest'] > 0}–>
                                    <img src=”{IMGDIR}/digest_$thread[digest].gif” class=”attach” alt=”{lang thread_digest} $thread[digest]” title=”{lang thread_digest} $thread[digest]” />
                                <!–{/if}–>
                                <!–{if $thread['rate'] > 0}–>
                                    <img src=”{IMGDIR}/agree.gif” class=”attach” alt=”{lang rate_credit_add}” title=”{lang rate_credit_add}” />
                                <!–{/if}–>
                            <!–{/if}–>
                            <!–{if $thread[multipage]}–>
                                <span class=”threadpages”>$thread[multipage]</span>
                            <!–{/if}–>
                        </th>
                        <td class=”author”>
                            <cite>
                            <!–{if $thread['authorid'] && $thread['author']}–>
                                <a href=”space.php?uid=$thread[authorid]“>$thread[author]</a>
                            <!–{else}–>
                                <!–{if $forum['ismoderator']}–>
                                    <a href=”space.php?uid=$thread[authorid]“>{lang anonymous}</a>
                                <!–{else}–>
                                    {lang anonymous}
                                <!–{/if}–>
                            <!–{/if}–>
                            </cite>
                            <em>$thread[dateline]</em>
                        </td>
                        <td class=”nums”><strong>$thread[replies]</strong>/<em>$thread[views]</em></td>
                        <td class=”lastpost”>
                            <cite><!–{if $thread['lastposter']}–><a href=”{if $thread[digest] != -2}space.php?username=$thread[lastposterenc]{else}viewthread.php?tid=$thread[tid]&amp;page={echo max(1, $thread[pages]);}{/if}”>$thread[lastposter]</a><!–{else}–>{lang anonymous}<!–{/if}–></cite>
                            <em><a href=”{if $thread[digest] != -2}redirect.php?tid=$thread[tid]&amp;goto=lastpost$highlight#lastpost{else}viewthread.php?tid=$thread[tid]&amp;page={echo max(1, $thread[pages]);}{/if}”>$thread[lastpost]</a></em>
                        </td>
                    </tr>
                </tbody>
                <!–{/loop}–>
</table>
{template footer_ajax}
<!–{/if}–>

如图:

image

3、增加模板调用forumdisplay_ajax

                <!–用于ajax自动更新页面 start–>
                {template forumdisplay_ajax}   
                <!–用于ajax自动更新页面 end—>

如图:

image

第二步:添加模板文件forumdisplay_ajax.htm到模板default目录

文件内容:

                <style type=”text/css”>
                    .newnotice{
                        font-size:13px;display:block;padding:5px 1px;margin:2px 0px 2px 0px;cursor:pointer;background:#E3F1FA;border:1px solid #C6E4F2;text-align:center;text-shadow:0 1px 0 #fff;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;z-index:2;
                    }
                    .newnotice:hover{
                        background-color:rgba(0,132,180,0.2);border-color:rgba(0,132,180,0.25);
                    }
                </style>
                <tbody style=”display:none;”>
                    <tr>
                        <td colspan=”7″><div id=”newnotice1″ class=”newnotice” onclick=”shownewthread();”>&nbsp;</div></td>
                    </tr>
                </tbody>
                <script type=”text/javascript”>
                var now=new Date();
                var timeline=Math.floor(now.getTime()/1000);
                var div_unread1=document.createElement(‘div’);
                div_unread1.id=”unread1″;
                div_unread1.style.display=”none”;
                var div_unread2=document.createElement(‘div’);
                div_unread2.id=”unread2″;
                div_unread2.style.display=”none”;
                _attachEvent(window, ‘load’,ajax_forum, document);
               
                function ajax_forum(){
                                document.body.appendChild(div_unread1);
                                document.body.appendChild(div_unread2);
                                setInterval(checknewthread,60000);
                }
                function shownewthread(){
                    var noticetbody=$(‘newnotice1′).parentNode.parentNode.parentNode;
                    noticetbody.style.display=”none”;
                    var newthreads=div_unread1.getElementsByTagName(‘tbody’);
                    var newcount=newthreads.length;
                    document.title=document.title.replace(/(.+)/g,”);
                    for(i=0;i<newcount;i++){
                        noticetbody.parentNode.insertBefore(newthreads[0],noticetbody.nextSibling);
                    }
                }
                function storenewthread(){
                    var newthreads=div_unread2.getElementsByTagName(‘tbody’);
                    var newcount=newthreads.length;
                    if(BROWSER.ie){
                        //如果是ie还要继续判断一下,ie回自动为table添加tbody
                        if(div_unread2.innerHTML.length<=32){
                            newcount=0;
                        }
                    }
                    for(i=0;i<newcount;i++){
                        //div_unread1.insertBefore(newthreads[0],div_unread1.getElementsByTagName(‘tbody’)[0]);
                        div_unread1.appendChild(newthreads[0]);
                    }
                    var newcount=div_unread1.getElementsByTagName(‘tbody’).length;
                    var newtitle=document.title;
                    if(newcount){
                        $(‘newnotice1′).innerHTML=newcount+” new threads”;
                        $(‘newnotice1′).parentNode.parentNode.parentNode.style.display=”table-header-group”;
                        if(newtitle.indexOf(‘(‘)!=-1){
                            document.title=newtitle.replace(/(.+)/g,’(‘+newcount+’)');
                        }else{
                            document.title=’(‘+newcount+’) ‘+document.title;
                        }
                    }else{
                        $(‘newnotice1′).parentNode.parentNode.parentNode.style.display=”none”;
                    }
                }
                function checknewthread(){
                    ajaxget(“forumdisplay.php?checknewthread=” + Math.random() +”&fid=”+fid+”&dateline=”+timeline,”unread2″,”,”,’none’,storenewthread);
                    now=new Date();
                    timeline=Math.floor(now.getTime()/1000);
                }
                </script>

第三步:修改forumdisplay.php(位于根目录)

1、增加数据库查询限制语句

/*用于ajax自动更新页面 start*/
$ajaxunread=false;
$ajaxunread=$inajax && $dateline && $ajaxtarget==’unread2′;
if($ajaxunread)
{
    $filteraddajax=”AND dateline>=’$dateline’”;
}
/*用于ajax自动更新页面 end*/

位置在这里:

image

2、添加到查询中,如图的三个位置

image

第四步:修补一些小的细节

1、这样请求会照成对在线时间统计的混乱,相当于用户可以“挂机”了,所以对于这些请求不能计算在在线时间里

在forumdisplay.php文件里面做修改

updatesession()

修改成

if(!$ajaxunread)updatesession();

不过效果还没有测试。

2、本来在帖子浏览页面(viewthread.php)也是可以增加ajax请求的,样式和方法都类似,但是一般用户关注的帖子都会有短消息提示,所以我们只需要不断请求短消息就可以了(其实是我偷懒了,(^o^)/~)

discuz本身会在页面载入完成后请求一次短消息:

在include/js/common.js文件里面:

_attachEvent(window, ‘load’, pmchecknew, document);

其中的pmcheckmew是ajax请求短消息更新,

所以我们在其下面添加一段:

_attachEvent(window, ‘load’, function(){setInterval(pmchecknew,30000)}, document);

image

为了能够及时的更新短消息,采取的是重新再绑定函数的方法,如果直接替换掉以前的那么页面就需要在等待30s才会检查短消息。

最好更新缓存,生效!

补充:经测试ie5.5以上以及FF、chorme通过!

discuz7.2 在iis下配置php sendmail功能

本文不是将怎样配置IIS下面的SMTP的,详情请看php的mail函数在WinXP+IIS环境下的应用/设置这篇文章。

注意在

虚拟服务器->属性->访问->中继
将那个复选框选好,然后再添加了*.*.*.*(一定要填写服务器的公网ip,稍后解释)的本地地址

但是这样之后我们在discuz的后台如下配置:

image

接着进行测试:

image

这样测试是完全可以成功的,但是如果发件人或者收件人是username user@domain.com这样的格式就不能发送了,也许是iis的服务器不能个支持这样的格式(本人不才,如果高人看到请指教具体原因)

对于论坛上面说到的情况就是这样,后台测试成功,但是在注册或者找回密码或者邀请码发送时候就发送不出去了。

找到原因就好办了,打开sendmail.inc.php文件,修改两处代码:

第一处:

$email_from = $email_from == ” ? ‘=?’.$charset.’?B?’.base64_encode($bbname)."?= <$adminemail>" : (preg_match(‘/^(.+?) <(.+?)>$/’,$email_from, $from) ? ‘=?’.$charset.’?B?’.base64_encode($from[1])."?= <$from[2]>" : $email_from);

改为

$email_from = $email_from == ” ? $adminemail : preg_match(‘/^(.+?) <(.+?)>$/’,$email_from, $from) ? $from[2] : $email_from;

第二处:

$tousers[] = preg_match(‘/^(.+?) <(.+?)>$/’,$touser, $to) ? ($mailusername ? ‘=?’.$charset.’?B?’.base64_encode($to[1])."?= <$to[2]>" : $to[2]) : $touser;

改为

$tousers[] = preg_match(‘/^(.+?) <(.+?)>$/’,$touser, $to) ? $to[2] : $touser;

再测试邮件就成功发送了。以上希望对大家有帮助

同时刚才说到中继要填写服务器真实IP,这是由于如果不设置这些就会使收到的邮件被判定为垃圾邮件。但是只是这样设置也是不够的,还需要在php.ini配置的时候也填写真是IP,而不是填写127.0.0.1 。

接下来你还需要绑定你自己的域名到刚才的IP,比如我的bt.sicau.org,那么发送邮件时候设置发件人为XXX@bt.sicau.org 那么邮件就不会再直接进入QQ,gmail等的垃圾箱了。

以上初步解决RDNS的问题。

所有的ghs IP全部挂掉了,紧急转向appspot

昨天晚上在强大的GFW的作用下,已知的所有ghs IP全部挂掉,在搜索半天后没有发现新的可用IP,转向到Appspot了

现在也暂时不管搜索引擎了,先能访问再说!

 

 

感谢http://www.jmj.hk/的帮助,现在终于可以像以前一样访问了~~

micolog 模板的制作-illacrimo-plus-2(完结)

micolog 模板的制作-illacrimo-plus-1

这篇文章写了一部分很久都没有更新,现在终于把这部分完善了。各位看官请接着看~~

base.html
{{ blog.title}}:          博客标题
{{ blog.feedurl }}:      RSS地址
/static/wlwmanifest.xml
{{ blog.theme_name }}     当前主题名称
{{blog.baseurl}}          根域名
{{self.m_list_pages}}     自定义页面列表
{{self.logouturl}}        用户退出
{{ blog.author }}         blog作者
{{ self.login_user.email }} 当前用户email
{{ self.login_user.nickname }} 当前用户名

{% block title %} {{ blog.title}}{% endblock %}     标题块
{% block head_block %}{% endblock %}                头部文件块
{%if ishome%}current_page_item{%else%}page_item{%endif%} 判断是否当前页为首页
{% block topmenu %}{% endblock %}         顶部菜单(生成)
{%if self.is_admin%}{%endif%}             判断是否是admin
{%if self.is_login%}{%endif%}             判断是否是登录用户

{%block content %}{%endblock%}            通用页面中间内容部分

index.html
{% extends “base.html” %}   继承自base.html
{% block content%}{% endblock %}  定义content块替换base.html中的此块
循环中
{{entry.key}}       文章ID
{{entry.title}}     文章名字
{{entry.author}}    文章作者
/{{ entry.link }}   文章URL
{{entry.edit_url}}   文章编辑地址
{{entry.date|datetz:”F jS, Y”}}  文章时间(具体参数可以参照php语言的时间格式化)
{{entry.content_excerpt}}  文章简介
{{entry.commentcount}}  评论数量
{% if entry.strtags %}Tags: {%for tag in entry.tags%}{{tag}} {%endfor%}{%endif%}   文章tags循环(附加判断是否有tags)
{% if show_next %}Older Posts »{%endif%}    下一页
{% if show_prev %}« Newer Posts{%endif%}   上一页

siderbar.html
{% for comment in recent_comments %}

  • {{comment.author}}:{{comment.shortcontent}}… {%endfor%}       最近评论(循环列表)
    {%for next in entry.next%}
    {{next.title}}?
    {%endfor%}                        下一篇文章
    {%for prev in entry.prev%}
    ?{{prev.title}}
    {%endfor%}                        上一篇文章
    {{ entry.content }}               文章正文

    comments.html
    {{entry.comments.count}}          文章评论数量
    {%cycle alt1,alt %}               文章评论间隔(奇数编号的评论为alt1,偶数为alt)
     

    123

    category.html
    {{category.name}}                 分类名字

大家可以看到还有几个模板文件没有替换,比如:tag.html,error404.html,这些文件大家可以自己看着办,因为这些文件都几乎没有什么标签了。

大家可以参照这个标签列表来替换你喜欢的wordpress主题,按照上面的文件顺序查找替换所有php的标签(类似这样的“”的内容)就可以完成了,如果你喜欢这个主题也可以用我做的这个。

用法:将其解压到micologthemes目录下,修改script.js替换QQ号码还有msn号码就可以了。

具体介绍请参看:http://www.cbmland.com/post/767/illacrimo-plus-theme-204-for-wordpress-27.html

下载:

illacrimo Plus Theme 2.04 for wordpress 2.7 for micolog

p.s. 由于没有更好的文件上传空间了,所以麻烦大家到纳米盘下载了哈。

http://d.namipan.com/d/e20d20d71abe8253674dd4dbfd73021d65537c94ec410500

这是微软的下载点:

http://cid-c02be930ae8e85a2.skydrive.live.com/self.aspx/.Public/illacrimo-plus.rar

对不起,忘记把Google广告去掉了,请大家打开sing.html把两处广告和base.html的一处广告去掉。