Oct 14

在文章页模版<body>和</body>之间粘贴一段代码如下:

<script type=”text/javascript”>
document.body.oncopy = function () { setTimeout( function () { var text = clipboardData.getData(”text”); if (text) { text = text + “\r\n本篇文章来源于 中国SEO之家|www.chinaseohome.com 原文链接:”+location.href; clipboardData.setData(”text”, text); } }, 100 ) }
</script>

written by Toby \\ tags:

Aug 20

关于UCH中安装了投票后首页的FEED动态显示出现”feed_comment_”问题解决方案:

先下重新下载插件

送礼1.5版 下载地址: uch_gift_115_gbk (586.93 KB)

投票1.5版 下载地址: uch_vote_115 (21.12 KB)

问答1.5版 下载地址: uch_ask_115_gbk (14.05 KB)

然后复制下下面代码生成cp_comment.php文件 ,覆盖到source/cp_comment.php下即可

或直接下载  cp_comment (3.13KB)  直接覆盖。

演示地址:www.mdjlove.com

<?php
/*
 [UCenter Home] (C) 2007-2008 Comsenz Inc.
 $Id: cp_comment.php 8338 2008-08-04 06:09:51Z liguode $
*/

if(!defined(’IN_UCHOME’)) {
 exit(’Access Denied’);
}

include_once(S_ROOT.’./source/function_bbcode.php’);

//共用变量
$tospace = $pic = $blog = $album = $vote = array();

if(submitcheck(’commentsubmit’)) {

 if(!checkperm(’allowcomment’)) {
  showmessage(’no_privilege’);
 }
 //实名认证
 ckrealname(’comment’);

 //判断是否发布太快
 $waittime = interval_check(’post’);
 if($waittime > 0) {
  showmessage(’operating_too_fast’,”,1,array($waittime));
 }

 $message = getstr($_POST['message'], 0, 1, 1, 1, 2);
 if(strlen($message) < 2) {
  showmessage(’content_is_too_short’);
 }

 //摘要
 $summay = getstr($message, 150, 1, 1, 0, 0, -1);

 $id = intval($_POST['id']);

 //引用评论
 $cid = empty($_POST['cid'])?0:intval($_POST['cid']);
 $comment = array();
 if($cid) {
  $query = $_SGLOBAL['db']->query(”SELECT * FROM “.tname(’comment’).” WHERE cid=’$cid’ AND id=’$id’ AND idtype=’$_POST[idtype]‘”);
  $comment = $_SGLOBAL['db']->fetch_array($query);
  if($comment && $comment['authorid'] != $_SGLOBAL['supe_uid']) {
   //实名
   realname_set($comment['authorid'], $comment['author']);
   realname_get();
   
   $comment['message'] = preg_replace(”/\<div class=\”quote\”\>\<span class=\”q\”\>.*?\<\/span\>\<\/div\>/is”, ”, $comment['message']);
   //bbcode转换
   $comment['message'] = html2bbcode($comment['message']);
   $message = addslashes(”<div class=\”quote\”><span class=\”q\”><b>”.$_SN[$comment['authorid']].”</b>: “.getstr($comment['message'], 150, 0, 0, 0, 2).’</span></div>’).$message;
   if($comment['idtype']==’uid’) {
    $id = $comment['authorid'];
   }
  } else {
   $comment = array();
  }
 }

 //对输入的id、idtype进行检查
 checkcomment($id, $_POST['idtype']);

 //事件
 $fs = array();
 $fs['icon'] = ‘comment’;
 $fs['target_ids'] = $fs['friend'] = ”;

 switch ($_POST['idtype']) {
  case ‘uid’:
   //事件
   $fs['icon'] = ‘wall’;
   $fs['title_template'] = cplang(’feed_comment_space’);
   $fs['title_data'] = array(’touser’=>”<a href=\”space.php?uid=$tospace[uid]\”>”.$_SN[$tospace['uid']].”</a>”);
   $fs['body_template'] = ”;
   $fs['body_data'] = array();
   $fs['body_general'] = ”;
   $fs['images'] = array();
   $fs['image_links'] = array();
   break;
  case ‘picid’:
   //事件
   $fs['title_template'] = cplang(’feed_comment_image’);
   $fs['title_data'] = array(’touser’=>”<a href=\”space.php?uid=$tospace[uid]\”>”.$_SN[$tospace['uid']].”</a>”);
   $fs['body_template'] = ‘{pic_title}’;
   $fs['body_data'] = array(’pic_title’=>$pic['title']);
   $fs['body_general'] = $summay;
   $fs['images'] = array(mkpicurl($pic));
   $fs['image_links'] = array(”space.php?uid=$tospace[uid]&do=album&picid=$pic[picid]“);
   $fs['target_ids'] = $album['target_ids'];
   $fs['friend'] = $album['friend'];
   break;
  case ‘blogid’:
   //更新评论统计
   $_SGLOBAL['db']->query(”UPDATE “.tname(’blog’).” SET replynum=replynum+1 WHERE blogid=’$id’”);
   //事件
   $fs['title_template'] = cplang(’feed_comment_blog’);
   $fs['title_data'] = array(’touser’=>”<a href=\”space.php?uid=$tospace[uid]\”>”.$_SN[$tospace['uid']].”</a>”, ‘blog’=>”<a href=\”space.php?uid=$tospace[uid]&do=blog&id=$id\”>$blog[subject]</a>”);
   $fs['body_template'] = ”;
   $fs['body_data'] = array();
   $fs['body_general'] = ”;
   $fs['target_ids'] = $blog['target_ids'];
   $fs['friend'] = $blog['friend'];
   break;
  case ’sid’:
   //事件
   $fs['title_template'] = cplang(’feed_comment_share’);
   $fs['title_data'] = array(’touser’=>”<a href=\”space.php?uid=$tospace[uid]\”>”.$_SN[$tospace['uid']].”</a>”, ’share’=>”<a href=\”space.php?uid=$tospace[uid]&do=share&id=$id\”>”.cplang(’share’).”</a>”);
   $fs['body_template'] = ”;
   $fs['body_data'] = array();
   $fs['body_general'] = ”;
   break;
  //为了投票能使用系统评论而添加 1
  case ‘app_vote_id’: 
   //事件
   $fs['title_template'] = “{actor} 评论了”.$_POST['app_name'].” {touser}”;
   $fs['title_data'] = array(’touser’=>”<a href=\”".$_POST['refer'].”\”>{$_POST['app_title']}</a>”);
   $fs['body_template'] = ”;
   $fs['body_data'] = array();
   //$fs['body_general'] = ”;
   break; 
 }

 $setarr = array(
  ’uid’ => $tospace['uid'],
  ’id’ => $id,
  ’idtype’ => $_POST['idtype'],
  ’authorid’ => $_SGLOBAL['supe_uid'],
  ’author’ => $_SGLOBAL['supe_username'],
  ’dateline’ => $_SGLOBAL['timestamp'],
  ’message’ => $message,
  ’ip’ => getonlineip()
 );
 //入库
 $cid = inserttable(’comment’, $setarr, 1);

 switch ($_POST['idtype']) {
  case ‘uid’:
   $n_url = “space.php?uid=$tospace[uid]&do=wall&cid=$cid”;
   $note_type = ‘wall’;
   $note = cplang(’note_wall’, array($n_url));
   $q_note = cplang(’note_wall_reply’, array($n_url));
   if($comment) {
    $msg = ‘note_wall_reply_success’;
    $magvalues = array($_SN[$tospace['uid']]);
   } else {
    $msg = ‘do_success’;
    $magvalues = array();
   }
   $msgtype = ‘comment_friend’;
   break;
  case ‘picid’:
   $n_url = “space.php?uid=$tospace[uid]&do=album&picid=$id&cid=$cid”;
   $note_type = ‘piccomment’;
   $note = cplang(’note_pic_comment’, array($n_url));
   $q_note = cplang(’note_pic_comment_reply’, array($n_url));
   $msg = ‘do_success’;
   $magvalues = array();
   $msgtype = ‘photo_comment’;
   break;
  case ‘blogid’:
   //通知
   $n_url = “space.php?uid=$tospace[uid]&do=blog&id=$id&cid=$cid”;
   $note_type = ‘blogcomment’;
   $note = cplang(’note_blog_comment’, array($n_url, $blog['subject']));
   $q_note = cplang(’note_blog_comment_reply’, array($n_url));
   $msg = ‘do_success’;
   $magvalues = array();
   $msgtype = ‘blog_comment’;
   break;
  case ’sid’:
   //分享
   $n_url = “space.php?uid=$tospace[uid]&do=share&id=$id&cid=$cid”;
   $note_type = ’sharecomment’;
   $note = cplang(’note_share_comment’, array($n_url));
   $q_note = cplang(’note_share_comment_reply’, array($n_url));
   $msg = ‘do_success’;
   $magvalues = array();
   $msgtype = ’share_comment’;
   break;
  //为了投票能使用系统评论而添加 2
  case ‘app_vote_id’:
   $n_url = “app.php?do=vote&ac=view&id=$id&uid=$tospace[uid]“;
   $note_type = ‘app_comment’;
   $note = “评论了你的投票 <a href=’{$n_url}’ target=’_blank’>”.addslashes($_POST['app_title']).”</a>”;
   $q_note = “回复了你的投票 <a href=’{$n_url}’ target=’_blank’>”.addslashes($_POST['app_title']).”</a>”;
   $msg = ‘do_success’;
   $magvalues = array();
   $msgtype = ‘app_comment’;
   break; 
 }

 //发送邮件通知
 $msgtype = empty($comment)?$msgtype:$msgtype.’_reply’;
 $touid = empty($comment['authorid']) ? $tospace['uid'] : $comment['authorid'];
 addmailcron($touid, ”, cplang($msgtype, array($_SGLOBAL['supe_username'])), ”, $msgtype);

 if(empty($comment)) {
  //非引用评论
  if($tospace['uid'] != $_SGLOBAL['supe_uid']) {
   //事件发布
   if(ckprivacy(’comment’, 1)) {
    feed_add($fs['icon'], $fs['title_template'], $fs['title_data'], $fs['body_template'], $fs['body_data'], $fs['body_general'],$fs['images'], $fs['image_links'], $fs['target_ids'], $fs['friend']);
   }
   //发送通知
   notification_add($tospace['uid'], $note_type, $note);
   //留言发送短消息
   if($_POST['idtype'] == ‘uid’ && $tospace['updatetime'] == $tospace['dateline']) {
    include_once S_ROOT.’./uc_client/client.php’;
    uc_pm_send($_SGLOBAL['supe_uid'], $tospace['uid'], cplang(’wall_pm_subject’), cplang(’wall_pm_message’, array(addslashes(getsiteurl().$n_url))), 1, 0, 0);
   }
  }
 } elseif($comment['authorid'] != $_SGLOBAL['supe_uid']) {
  notification_add($comment['authorid'], $note_type, $q_note);
 }

 //积分
 if($tospace['uid'] != $_SGLOBAL['supe_uid']) {
  updatespacestatus(’get’, ‘comment’);
 }

 showmessage($msg, $_POST['refer'], 0, $magvalues);
}

$cid = empty($_GET['cid'])?0:intval($_GET['cid']);

//编辑
if($_GET['op'] == ‘edit’) {

 $query = $_SGLOBAL['db']->query(”SELECT * FROM “.tname(’comment’).” WHERE cid=’$cid’ AND authorid=’$_SGLOBAL[supe_uid]‘”);
 if(!$comment = $_SGLOBAL['db']->fetch_array($query)) {
  showmessage(’no_privilege’);
 }

 //提交编辑
 if(submitcheck(’editsubmit’)) {

  $message = getstr($_POST['message'], 0, 1, 1, 1, 2);
  if(strlen($message) < 2) showmessage(’content_is_too_short’);

  updatetable(’comment’, array(’message’=>$message), array(’cid’=>$comment['cid']));

  showmessage(’do_success’, $_POST['refer'], 0);
 }

 //bbcode转换
 $comment['message'] = html2bbcode($comment['message']);//显示用

} elseif($_GET['op'] == ‘delete’) {

 if(submitcheck(’deletesubmit’)) {
  include_once(S_ROOT.’./source/function_delete.php’);
  if(deletecomments(array($cid))) {
   showmessage(’do_success’, $_POST['refer'], 0);
  } else {
   showmessage(’no_privilege’);
  }
 }

} elseif($_GET['op'] == ‘reply’) {

 $query = $_SGLOBAL['db']->query(”SELECT * FROM “.tname(’comment’).” WHERE cid=’$cid’”);
 if(!$comment = $_SGLOBAL['db']->fetch_array($query)) {
  showmessage(’comments_do_not_exist’);
 }

} else {

 showmessage(’no_privilege’);
}

include template(’cp_comment’);

//检查
function checkcomment($id, $idtype) {
 global $_SGLOBAL;
 global $tospace, $pic, $blog, $album;

 switch ($idtype) {
  case ‘uid’:
   //检索空间
   $tospace = getspace($id);
   break;
  case ‘picid’:
   //检索图片
   $query = $_SGLOBAL['db']->query(”SELECT * FROM “.tname(’pic’).” WHERE picid=’$id’ LIMIT 1″);
   $pic = $_SGLOBAL['db']->fetch_array($query);
   //图片不存在
   if(empty($pic)) {
    showmessage(’view_images_do_not_exist’);
   }

   //检索空间
   $tospace = getspace($pic['uid']);

   //获取相册
   $album = array();
   if($pic['albumid']) {
    $query = $_SGLOBAL['db']->query(”SELECT * FROM “.tname(’album’).” WHERE albumid=’$pic[albumid]‘”);
    if(!$album = $_SGLOBAL['db']->fetch_array($query)) {
     updatetable(’pic’, array(’albumid’=>0), array(’albumid’=>$pic['albumid']));//相册丢失
    } else {
     if($album['target_ids']) {
      $album['target_ids'] .= “,$album[uid]“;
     }
    }
   }
   break;
  case ‘blogid’:
   //读取日志
   $query = $_SGLOBAL['db']->query(”SELECT b.*, bf.target_ids
    FROM “.tname(’blog’).” b
    LEFT JOIN “.tname(’blogfield’).” bf ON bf.blogid=b.blogid
    WHERE b.blogid=’$id’”);
   $blog = $_SGLOBAL['db']->fetch_array($query);
   //日志不存在
   if(empty($blog)) {
    showmessage(’view_to_info_did_not_exist’);
   }

   //是否允许评论
   if(!empty($blog['noreply'])) {
    showmessage(’do_not_accept_comments’);
   }
   if($blog['target_ids']) {
    $blog['target_ids'] .= “,$blog[uid]“;
   }
   //检索空间
   $tospace = getspace($blog['uid']);
   break;
  case ’sid’:
   //读取日志
   $query = $_SGLOBAL['db']->query(”SELECT * FROM “.tname(’share’).” WHERE sid=’$id’”);
   $share = $_SGLOBAL['db']->fetch_array($query);
   //日志不存在
   if(empty($share)) {
    showmessage(’sharing_does_not_exist’);
   }

   //检索空间
   $tospace = getspace($share['uid']);
   break;
  case ‘app_vote_id’:
   $cspace = array(’uid’=>$_POST['app_uid'], ‘username’=>$_POST['app_username'], ‘app_title’=>$_POST['app_title'], ‘app_link’ => $_POST['refer'], ‘app_name’ =>$_POST['app_name']);
   //检索空间
   $tospace = getspace($_POST['app_uid']);
   break;
  default:
   showmessage(’non_normal_operation’);
   break;
 }
 if(empty($tospace)) {
  showmessage(’space_does_not_exist’);
 }
 //黑名单
 if(isblacklist($tospace['uid'])) {
  showmessage(’is_blacklist’);
 }
}

?>

written by Toby \\ tags:

Jul 23

牡丹江站长不知道有多少,想找哪个站长也很麻烦

今天跟朋友商量一下,建个群,把牡丹江的站长都邀请进来一起交流

群号:24602385

欢迎牡丹江的各位站长加入! 

written by Toby \\ tags: ,

Jun 14

本文地址:  http://blog.youxibo.com/2008/06/13/php-jichu-jiaocheng/

Apache Php5 Mysql5 图文安装教程

不管哪个版本。安装方法都差不多。以下以 Apache 2.0.52 PHP5.2.5版为例
注:相关图片请看本空间相册
先安装 apache 默认安装就行
服务器名 localhost
服务器IP localhost
管理员邮箱 my#localhost(#换@)

接下来安装PHP

打开 PHP5目录
查找目录下所有 dll 文件。包括子目录
大约为65个文件。

复制到 C:\windows\system32 目录下 2000系统为 C:\winnt\system32 目录
重命名 php.ini-dist 为 php.ini
把 php.exe  和 php.ini 复制到 C:\windows 目录下 2000系统为 C:\winnt

接下来就是配置服务器
先建立一个目录做为服务器的主目录,例如 D:\web

 

打开 C:\windows\php.ini 文件修改以下几个地方

440行 magic_quotes_gpc = Off
472行 include_path = “.;D:\web”
486行 extension_dir = “C:\windows\system32\”
625行 extension=php_mysql.dll
991行 session.save_path = D:/web/tmp  要保证目录存在,如果没有自己建一个

打开 apache 配置文件,文件位置在
D:\Program Files\Apache Group\Apache2\conf\httpd.conf
视你的安装目录决定

修改以下几个地方
228行 DocumentRoot “d:/web”
321行 DirectoryIndex index.html index.htm index.php
701行 AddDefaultCharset GB2312

文件最后加上以下代码加载PHP

ScriptAlias /php/ “c:/windows/”
AddType application/x-httpd-php .php
Action application/x-httpd-php “/php/php.exe”
LoadModule php5_module C:/windows/system32/php5apache2.dll
AddOutputFilter PHP .php
AddInputFilter PHP .php

重启 apache 完成配置

 

安装 Zend
基本上默认安装就可以了

测试一下吧。

<?php//文件名 index.phpphpinfo();?>

 

 

 

安装 MYSQL5
先默认安装并配置结束。配置方法看图10-图12

 

要进命令行重设一个密码,不然好头疼。。照着输入就可以了。只要你也是安装在这个目录。。
那个密码。就是图11里设置的密码。不设不让装。。NND
D:\>cd mysql
D:\MySQL>cd mysql server 5.0
D:\MySQL\MySQL Server 5.0>cd bin
D:\MySQL\MySQL Server 5.0\bin>mysql -u root -p mysql
Enter password: ******
mysql> update user set Password=PASSWORD(”) where user=’root’;
mysql> flush privileges;
mysql> quit

我是单机测试用的,所以密码为空就行了。方便一点。^_^
用一个简单的代码。测试一下。


<?PHP//文件名 mysql.phpif(function_exists(‘mysql_connect’))“MYSQL 函数库已经加载!\n”;//MYSQL连接$rt=@mysql_connect(‘localhost’,‘root’,);$rt)‘已经可以使用 MYSQL 了.’;‘<br>\n MYSQL 工作异常!无法连接。<br>’;

{

     echo

  

  

     if(

       echo

     else

       echo

      echo mysql_error();

}else{

     echo “MYSQL 函数库没有加载,请重设 php.ini!”;

}

?>

完成了

 

written by Toby

Jun 12

很久前的一天,我想使用这个东西,然后看了下,GooGle的Translate工具目前没有公开API,还是一个逐渐完善的过程,另一方面,利用一段很小的程序就可以得到我们想要的效果。
   在这篇,我就利用C#写一个小程序,翻译:
   思路是这样的:
   
   1:发送POST(或者GET)
   2:获取POST(或者GET)的响应
   3:正则匹配我们想要的值。

   发生POST(或者GET)的函数:

public static string GetGetRequest(string urlP,string encode){
        if(null==urlP) return null;
        string StrRetP = null;
        Stream dataStream = null;
        try{

            HttpWebRequest myHttpWebRequest=(HttpWebRequest)WebRequest.Create(urlP);

            myHttpWebRequest.Timeout = 10000;     // 10 secs
            HttpWebResponse Objresponse =(HttpWebResponse)myHttpWebRequest.GetResponse();
            //Encoding enc = Encoding.GetEncoding(1252);  // Windows default Code Page
            if(Objresponse.StatusDescription == ”OK”){//HttpStatusCode.OK
                dataStream = Objresponse.GetResponseStream ();
                Encoding objE = String.IsNullOrEmpty(encode)?Encoding.GetEncoding(0):Encoding.GetEncoding(encode);
                StreamReader r = new StreamReader(dataStream,objE);
                StrRetP= r.ReadToEnd();
            }
        }catch(Exception e){
            StrRetP =e.Message;
        }finally{
            if(null!=dataStream) dataStream.Close();
        }
        return StrRetP;
    }

这个我在前面的一些文章中有所介绍。

   然后正则匹配的函数:

public static string GetMatchString(string text,string pattern,int point){
        if(String.IsNullOrEmpty(text)||String.IsNullOrEmpty(pattern))return String.Empty;
        Regex rx = new Regex(pattern,RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Multiline);
        Match match = rx.Match(text);
        string word=”";
        if (match.Success)    word = match.Groups[point].Value;
        return word.Trim();
    }
这个数根据一个正则表达数,返回匹配的值。

直接进入Main主体:

  public static void Main(string[] args){
            string mess =”我们”;
            Console.WriteLine(HttpUtility.UrlEncode(”我们”));
            mess = GetGetRequest(”http://translate.google.com/translate_t?langpair=”+HttpUtility.UrlEncode(”zh-CN|en”)+ ”&text=”+HttpUtility.UrlEncode(mess,System.Text.UnicodeEncoding.GetEncoding( ”Gb2312″)),”utf-8″);
            //Console.WriteLine(mess);
            mess = GetMatchString(mess,@”(<div id=result_box dir=”"ltr”">)([?:\s\S]*?)(</div>)”,2);
            Console.WriteLine(mess);
        }

注意的是

HttpUtility.UrlEncode(mess,System.Text.UnicodeEncoding.GetEncoding( ”Gb2312″))

这句,无法识别UrlEncode的字符编码,这里需要指明。

OK,然后csc了,编译一下,下载一下吧。

C# 使用Google的Translate API

然后再搞个PHP的。

本文转自老农博客

原地址:http://www.5do8.com/blog/doc/627/index.aspx

written by Toby

Apr 14

一夜下来,新博客已经弄的差不多了。天亮了,看到太阳心情也好了很多。

这个博客注定会是Toby的私人BLOG,主要是一些时光刻录和作品以及不断进步的过程。

第一个博客是和讯的,地址早已经记不清了。

第二个博客是初学SEO时实验用的www.seosos.net.cn 后来改成静态的页,挂排名去liao~失败

第三个博客准备定为私人博客的,结果后来改成竞争关键词了.地址是www.toby.org.cn(惭愧,已经3个多月没更新了,写的东西也乱七八糟 - -!)

第四个也是最后一个,就是现在的www.seobasic.com了,不想做词,不想实验,只想安心的写一些心里所想的东西。

其实每天都有很多想写下来的东西,只是人比较懒不愿意动手,想着写下来,结果过几天就忘光啦,哈哈哈

现在好了,在这里安营、驻留、扎寨、生根、发芽、成长、进步…生活、生存、繁衍…乱~

写给自己的回忆 - Toby’s Blog

written by Toby