27 7月 2013

WordPress去多说评论版权信息

不知道怎么回事,继我改了评论的代码以后~小菜就说用手机没法评论。

今天免费资源的博主也说评论有问题。

没办法,直接装多说吧。

下面是去版权的方法。

 

只要在多说后台自定义样式CSS中加入以下代码
#ds-thread .ds-powered-by{display:none!important;}

26 7月 2013

CentOS修改系统默认语言及编码

很多朋友买了vps以后发现系统语言默认是日语,当我们登陆ssh时,日语部分显示的全是乱码或者就是大家看不懂的日语,那么blogfeng今天就来教大家如何修改系统默认的语言和编码。

blogfeng为了以后方便操作,就采用全局更改方式,即每个用户都是一种统一的语言设置。直接修改/etc/sysconfig/i18n文件,把原来的语言设置用#注释掉,然户在新加一行,如:你要修改成中文语言就加:LANG=”zh_CN.UTF-8″,你要修改成英文语言就加:LANG=”en_US.UTF-8″,保存之后用./rc.local或者sh rc.loacl 执行rc.local,退出ssh后再进即可。

26 7月 2013

cPanel:简介

CPanel 后台管理系统是目前使用范围最广,操作最为方便的主机管理系统,国外主机大都采用这个系统。

 

什么是cPanel

 

cPanel 是一套全功能 web 接口的控制台程序, 可以让您透过 web 接口来管理您的网站. 它的目的是希望尽可能交付您管理网站的控制权和责任. 使您有能力去管理 email, 档案, 备份, FTP, CGI 程序等所有网站功能, 以及网站流量统计.

 

和国内虚拟主机管理平台相比,cPanel的管理功能更大,通过Cpanel,你可以得到大部分对服务器的控制权利,你可以管理邮件的各个方面(和国内主机的企 业邮局差不多)、网站的文件、FTP帐户的控制、数据库的控制和站点的流量统计等等.

 

cPanel功能简介

 

用户可以通过cPanel轻松完成所有虚拟主机功能操作,包括:

 

电子邮件管理——新建,删除邮件账户,修改密码,自动回复,邮件转发,垃圾邮件过滤等
Webmail——Web邮箱,通过浏览器Web界面收发Email,当然也可以设置outlook收发
域名管理 ——多域名绑定,二级域名设置
FTP管理——新建,删除FTP账户,权限设置,FTP进程管理
文件管理器——通过浏览器Web界面文件管理器新建,删除,编辑,管理文件夹(目录)和文件,解压缩文件也很方便
空间使用统计——显示账户空间使用情况,很容易查出哪个文件夹(文件)比较占用空间。
备份管理——生成,下载和管理账户备份,数据库备份
数据库管理——建立,删除,管理数据库及数据库用户,phpMyAdmin数据库管理工具
流量统计工具——图形显示网站流量统计,有助于你做好网站流量来源分析,原始日志文件管理,错误日志
预装程序——预装常用wordpress等博客,phpbb等论坛,购物车等程序
其他功能——如密码保护目录,URL转向,自定义错误页面,Cron Jobs,防盗链等。

25 7月 2013

百度联盟起步三天收益分析

昨日收入¥5.93 前七日收入¥9.66 本月收入¥9.66 上月收入¥0 自上次分账2013-07-22¥9.66

 

挂了三天,

没有做任何作弊行为。

第一二天之挂了右侧矩形和文章内页最下方矩形。

第三天增加右侧链接和文章内页开端矩形。

总的来说百度联盟的收益单价还是很可观的。

当然单价和关键字有关。

我的收益单价平均在6毛到八毛之间。

 

PS:百度联盟的数据更新时间为第二天的上午八点左右。

21 7月 2013

Typecho 函数调用

Typecho调用分类文章列表:

编辑当前typecho主题模板,在要调用某分类目录的位置添加以下代码

 

<?php
$this->widget(‘Widget_Archive@index’, ‘pageSize=6&type=category’, ‘mid=3’)
->parse(‘<li><a href=”{permalink}”>{title}</a></li>’);
?>

 

其中pageSize后面的数字表示调用文章的数量;mid后面的数字表示调用的分类ID;

提示:Typecho分类目录ID的获取方法是把鼠标移到某分类名称上面,在浏览器状态栏显示的mid=后面的数字便是该分类目录ID。

 

1.自定义一下标题,以下为代码和参考案例:

<?php if($this->_currentPage>1) echo ‘第 ‘.$this->_currentPage.’ 页 – ‘; ?><?php $this->archiveTitle(”, ”, ‘ – ‘); ?><?php $this->options->title(); ?>
<?php if($this->is(‘index’)): ?> – 自定义关键词<?php endif; ?>

2.根据TAG调用相关文章:

<?php $this->related(5)->to($relatedPosts); ?>
<ul>
<?php while ($relatedPosts->next()): ?>
<li><a href=”<?php $relatedPosts->permalink(); ?>” title=”<?php $relatedPosts->title(); ?>”><?php $relatedPosts->title(); ?></a></li>
<?php endwhile; ?>
</ul>

3.上一篇与下一篇调用代码:

 

<?php $this->thePrev(); ?> <?php $this->theNext(); ?>

4.全部文章列表,可应用于归档或网站地图,蜘蛛指引等:

<?php $this->widget(‘Widget_Contents_Post_Recent’, ‘pageSize=10000’)->parse(‘<li>{year}-{month}-{day} : <a href=”{permalink}”>{title}</a></li>’); ?>

5.全部标签列表,按照MID排序:

<?php $this->widget(‘Widget_Metas_Tag_Cloud’)
->to($taglist); ?><?php while($taglist->next()): ?>
<li><a href=”<?php $taglist->permalink(); ?>” title=”<?php $taglist->name(); ?>”><?php $taglist->name(); ?></a></li>
<?php endwhile; ?>

6.自定义标签数量(就这里面的20),按照文章数量排序:

<?php $this->widget(‘Widget_Metas_Tag_Cloud’, array(‘sort’ => ‘count’, ‘ignoreZeroCount’ => true, ‘desc’ => true, ‘limit’ => 20))->to($tags); ?>
<?php while($tags->next()): ?>
<li><a rel=”tag” href=”<?php $tags->permalink(); ?>”><?php $tags->name(); ?></a></li>
<?php endwhile; ?>

7.自定义分类、标签、搜索、首页等文章分页数量,修改 functions.php 文件:

function themeInit($archive) {
if ($archive->is(‘index’)) {
$archive->parameter->pageSize = 10; // 自定义条数
}
}

或者:

function themeInit($archive) {
if ($archive->is(‘category’, ‘default’)) {
$archive->parameter->pageSize = 10; // 自定义条数
}
}

8.调用某分类文章,pageSize是数量,mid是分类号:

<?php $this->widget(‘Widget_Archive@index’, ‘pageSize=6&type=category’, ‘mid=47’)
->parse(‘<li><a href=”{permalink}”>{title}</a></li>’); ?>

9.判断为当前页的第几篇文章,并单独输出代码,可应用于第一篇文章底部广告:

<?php if ($this->sequence == 0): ?>
//需要的插入
<?php endif; ?>

10.判断是否为首页,输出相关内容:

<?php if($this->is(‘index’)): ?>
//首页输出内容
<?php else: ?>
//不是首页输出内容
<?php endif; ?>

11.判断当前分类,输出内容:

<?php if($this->category == “help”): ?>
//当前分类为help缩略图,则输出内容。
<?php endif; ?>

12.首页不显示某分类内容:

<?php while($this->next()): ?>
<?php if($this->category != “cateslug”): ?>
//正常输出循环
<?php endif; ?>
<?php endwhile; ?>

13.Typecho侧边栏不显示博主评论,sidebar.php文件:

将以下代码:

<?php $this->widget(‘Widget_Comments_Recent’)->to($comments); ?>

修改为:

<?php $this->widget(‘Widget_Comments_Recent’,’ignoreAuthor=true’)->to($comments); ?>

14.例如24小时内发布的贴,需要一个标志来完成。这里是用判断输入特殊字符,再用CSS判断完成的。此代码由羽飞儿老师编写,案例可参考:www.weidao.net

/**
* 判断时间区间
*
* 使用方法 if(timeZone($this->date->timeStamp)) echo ‘ok’;
*/
function timeZone($from){
$now = new Typecho_Date(Typecho_Date::gmtTime());
return $now->timeStamp – $from < 24*60*60 ? true : false;
}

以上代码,加入到 functions.php 中,然后,在 index.php 中使用如下调用:

<?php if(timeZone($this->date->timeStamp)) echo ‘ new’; ?>

注:这样就会输出一个new的文字,可应用于class里,然后,自定义输出背景图片等。

15.自定义首页描述description文字内容:

<?php if($this->is(‘index’)): ?>
<?php $this->header(‘description=详细描述内容部分内容,自定义即可。’); ?>
<?php else: ?>
<?php $this->header(); ?><?php endif; ?>

16.首页第一篇文章显示不一样:

<?php if (($this->_currentPage == 1) && ($this->sequence == 1)): ?>
… //首页第一篇文章
<?php else: ?>
… //其它文章
<?php endif; ?>

17.导航菜单不显示某分类或某页面:

<?php while ($pages->next()): ?>
<?php while ($pages->next()): ?> //循环语句开始
<?php if ($pages->slug != ‘about’): ?> // 记得闭合 if 语句
<?php if (($pages->slug != ‘about’) && ($pages->slug != ‘links’)): ?>

18.输出全部分类,并对当前分类current标记:

<ul id=”nav_menu”>
<?php $this->widget(‘Widget_Metas_Category_List’)->to($category); ?>
<?php while ($category->next()): ?>
<li<?php if ($this->is(‘post’)): ?><?php if ($this->category == $category->slug): ?><?php endif; ?><?php else: ?><?php if ($this->is(‘category’, $category->slug)): ?><?php endif; ?><?php endif; ?>><a href=”<?php $category->permalink(); ?>” title=”<?php $category->name(); ?>”><?php $category->name(); ?></a></li>
<?php endwhile; ?>
</ul>

19.像CMS那样,输出全部分类,并按分类输出文章:

/* 循环所有的分类 */
<?php $this->widget(‘Widget_Metas_Category_List’)->to($categories); ?>
<?php while ($categories->next()): ?>

/* 循环当前分类下的文章 */
<?php $this->widget(‘Widget_Archive@category-‘ . $categories->mid, ‘pageSize=7&type=category’, ‘mid=’ . $categories->mid)->to($posts); ?>
<div>
<?php while ($posts->next()): ?>
<?php if (1 == $posts->sequence): ?> //判断第一篇文章
<h3>[<?php $categories->name(); ?>]:<a href=”<?php $posts->permalink(); ?>”><?php $posts->title(43); ?></a></h3>
<?php $posts->excerpt(120, ‘…’); ?>
<ul> //文章列表
<?php else: ?>
<li>
<a href=”<?php $posts->permalink(); ?>”><?php $posts->title(40); ?></a>
<span>(<?php $posts->commentsNum(); ?>)</span>
</li>
<?php endif; ?>
<?php endwhile; ?>
</ul>
</div>
<?php endwhile; ?>

20.前台输出相关统计:

<?php Typecho_Widget::widget(‘Widget_Stat’)->to($stat); ?>
<p><?php _e(‘不烦恼的博客自 <strong>2011</strong> 年初建立以来,截至 %s 在已设定的 <strong>%s</strong> 个分类
和 <strong>%s</strong> 个页面中,
共发布了 <strong>%s</strong> 篇文章,并收到了 <strong>%s</strong> 条相关评论。
‘, date(‘Y年n月j日G时i分’), $stat->categoriesNum, $stat->publishedPagesNum, $stat->publishedPostsNum, $stat->publishedCommentsNum); ?></p>

21.调用单独页面评论代码,存在一个php,单独引用:

<?php
/**
* 单独页面调用评论列表
*
* @author Mr.Asong
* @link http://mrasong.com
*/
$slug = “message”; //页面缩略名
$limit = 10; //调用数量
$length = 30; //截取长度
$ispage = true; //true 输出slug页面评论,false输出其它所有评论
$isGuestbook = $ispage ? ” = ” : ” <> “;

$db = $this->db; //Typecho_Db::get();
$options = $this->options; //Typecho_Widget::widget(‘Widget_Options’);

$page = $db->fetchRow($db->select()->from(‘table.contents’)
->where(‘table.contents.status = ?’, ‘publish’)
->where(‘table.contents.created < ?’, $options->gmtTime)
->where(‘table.contents.slug = ?’, $slug));

if ($page) {
$type = $page[‘type’];
$routeExists = (NULL != Typecho_Router::get($type));
$page[‘pathinfo’] = $routeExists ? Typecho_Router::url($type, $page) : ‘#’;
$page[‘permalink’] = Typecho_Common::url($page[‘pathinfo’], $options->index);

$comments = $db->fetchAll($db->select()->from(‘table.comments’)
->where(‘table.comments.status = ?’, ‘approved’)
->where(‘table.comments.created < ?’, $options->gmtTime)
->where(‘table.comments.type = ?’, ‘comment’)
->where(‘table.comments.cid ‘ . $isGuestbook . ‘ ?’, $page[‘cid’])
->order(‘table.comments.created’, Typecho_Db::SORT_DESC)
->limit($limit));

foreach ($comments AS $comment) {
echo ‘<li>’;
echo ‘<a href=”‘ . $page[‘permalink’] . “#comment-” . $comment[‘coid’] . ‘” title=”‘ . $comment[‘text’] . ‘”>’;
echo Typecho_Common::subStr(strip_tags($comment[‘text’]), 0, $length, ‘…’) . ‘</a>’;
echo ‘</li>’;
}
} else {
echo “<li>No Comments</li>”;
}
//不需要结束标志,并空一行

22.自定义pagenv分页盒样式:

<?php $this->pageNav(‘上一页文字’, ‘下一页文字’, ‘默认显示数目’, ‘省略符号’); ?>

23.创建自定义首页或页面模板:

<?php
/**
* 自定义首页模板
*
* @package index
*/

<?php
/**
* 自定义页面模板
*
* @package custom
*/

24.自定义调用某分类,并输出缩略图:

<?php $this->widget(‘Widget_Archive@index’, ‘pageSize=4&type=category’, ‘mid=23’)->to($indexpub); ?>
<?php while($indexpub->next()): ?>
<?php $indexpub->permalink(); ?>
<?php $indexpub->title() ?>
<?php Fimg_Plugin::showfimg($indexpub->cid,4);?>
<?php $indexpub->excerpt(80, ‘……’); ?>
<?php endwhile; ?>

25.自定义首页keywords和Description内容:

使用的是自定义的page模板做为首页,页page页面不输出关键词和描述。于是查阅了一下官方文档,得出以下结论,自定义这部分内容:

打开 header.php 文件:

<?php $this->header(); ?>

修改为:

<?php if($this->is(‘index’)): ?>
<?php $this->header(‘description=此处输入你的关键词’); ?>
<?php else: ?>
<?php $this->header(); ?><?php endif; ?>

 

 
站点名称

1
<?php $this->options->title() ?>

域名地址

1
<?php $this->options->siteUrl(); ?>

后台地址

1
<?php $this->options->adminUrl(); ?>

完整路径标题,比如 文章 站点

1
<?php $this->archiveTitle(' &raquo; ', '', ' - '); ?><?php $this->options->title(); ?>

站点说明

1
<?php $this->options->description() ?>

模版文件夹地址

1
<?php $this->options->themeUrl(); ?>

导入模版文件夹内php文件

1
<?php $this->need('.php'); ?>

作者名字

1
<?php $this->author(); ?>

当前登陆用户名字

1
<?php $this->user->screenName(); ?>

退出链接

1
<a href="<?php $this->options->logoutUrl(); ?>"><?php _e('退出'); ?></a>

rss地址

1
<?php $this->options->feedUrl(); ?>

作者头像

1
<?php $this->author->gravatar('200') ?>

此函数是完整该文作者全部文章列表链接

1
<?php $this->author->permalink(); ?>

该文作者个人主页链接

1
<?php $this->author->url(); ?>

该文作者的邮箱地址

1
<?php $this->author->mail(); ?>

 

1

 

 

1

 

rss评论

1
<?php $this->options->commentsFeedUrl(); ?>

引用模版文件夹内php文件

1
<?php $this->need('*.php'); ?>

获取最新post

1
<?php $this->widget('Widget_Contents_Post_Recent', 'pageSize=8&type=category')->parse('<li><a href="{permalink}">{title}</a></li>'); ?>

纯文字分类名称,不带链接

1
<?php $this->category(',', false); ?>

获取分类列表

1
2
3
4
<ul>
<?php $this->widget('Widget_Metas_Category_List')
                ->parse('<li><a href="{permalink}">{name}</a> ({count})</li>'); ?>
</ul>

获取某分类post

1
2
3
4
5
<ul>
<?php 
$this->widget('Widget_Archive@indexyc', 'pageSize=8&type=category', 'mid=1')
->parse('<li><a href="{permalink}" title="{title}">{title}</a></li>'); ?>
</ul>

获取最新评论列表

1
2
3
4
5
6
<ul>
            <?php $this->widget('Widget_Comments_Recent')->to($comments); ?>
            <?php while($comments->next()): ?>
                <li><a href="<?php $comments->permalink(); ?>"><?php $comments->author(false); ?></a>: <?php $comments->excerpt(50, '...'); ?></li>
            <?php endwhile; ?>
            </ul>

首页获取 最新文章 代码限制条数 (特别感谢蚂蚱)

1
2
3
4
5
<?php while ($this->next()): ?>
<?php if ($this->sequence <= 3): ?>
html
<?php endif; ?>
<?php endwhile; ?>

获取最新评论列表第二个版本,只显示访客评论不显示博主也就是作者或者说自己发的评论

1
2
3
4
<?php $this->widget('Widget_Comments_Recent','ignoreAuthor=true')->to($comments); ?>
    <?php while($comments->next()): ?>
	<li><a href="<?php $comments->permalink(); ?>"><?php $comments->author(false); ?></a>: <?php $comments->excerpt(50, '...'); ?></li>
<?php endwhile; ?>

获取文章时间归档

1
2
3
4
<ul>
                <?php $this->widget('Widget_Contents_Post_Date', 'type=month&format=F Y')
                ->parse('<li><a href="{permalink}">{date}</a></li>'); ?>
            </ul>

获取标签集合,也就是标签云

1
2
3
4
<?php $this->widget('Widget_Metas_Tag_Cloud', 'ignoreZeroCount=1&limit=28')->to($tags); ?>
<?php while($tags->next()): ?>
<a href="<?php $tags->permalink(); ?>"><?php $tags->name(); ?></a>
<?php endwhile; ?>

文章循环

1
2
3
<?php while($this->next()): ?>
<!--文章标题内容等-->
<?php endwhile; ?>

调用该文相关文章列表

1
2
3
4
5
6
7
8
<?php $this->related(5)->to($relatedPosts); ?>
    <?php if ($relatedPosts->have()): ?>    //这句也可以写成 if (count($relatedPosts->stack))
    <?php while ($relatedPosts->next()): ?>
        <li><a href="<?php $relatedPosts->permalink(); ?>" title="<?php $relatedPosts->title(); ?>"><?php $relatedPosts->title(); ?></a></li>
    <?php endwhile; ?>
    <?php else : ?>
        <li>无相关文章</li>
    <?php endif; ?>

各种列表页面标题,如标签分类

1
<?php $this->archiveTitle(' &nbsp; ', '', ''); ?>

文章或页面,标题

1
<?php $this->title() ?>

文章上一篇

1
<?php $this->theNext(); ?>

文章下一篇

1
<?php $this->thePrev(); ?>

文章或页面,链接

1
<?php $this->permalink() ?>

文章或页面,发表时间

1
<?php $this->date(); ?>

文章或页面,评论数目

1
<?php $this->commentsNum('No Comments', '1 Comment', '%d Comments'); ?>

文章或页面,内容,括号里有内容,如果加入了more就会自动生成链接

1
<?php $this->content('阅读剩余部分...'); ?>

文章所在分类,链接形式

1
<?php $this->category(','); ?>

文章,所加标签

1
<?php $this->tags(', ', true, 'none'); ?>

列表页分页pageNav(); ?>
隐藏head区域的程序版本和模版名称

1
<?php $this->header("generator=&template="); ?>

获取读者墙

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
$period = time() - 999592000; // 時段: 30 天, 單位: 秒
$counts = Typecho_Db::get()->fetchAll(Typecho_Db::get()
->select('COUNT(author) AS cnt','author', 'url', 'mail')
->from('table.comments')
->where('created > ?', $period )
->where('status = ?', 'approved')
->where('type = ?', 'comment')
->where('authorId = ?', '0')
->group('author')
->order('cnt', Typecho_Db::SORT_DESC)
->limit(25)
);
$mostactive = '';
$avatar_path = 'http://www.gravatar.com/avatar/';
foreach ($counts as $count) {
  $avatar = $avatar_path . md5(strtolower($count['mail'])) . '.jpg';
  $c_url = $count['url']; if ( !$c_url ) $c_url = Helper::options()->siteUrl;
  $mostactive .= "<a href='" . $c_url . "' title='" . $count['author'] . " (参与" . $count['cnt'] . "次互动)' target='_blank'><img src='" . $avatar . "' alt='" . $count['author'] . "的头像' class='avatar' width='32' height='32' /></a>\n";
}
echo $mostactive; ?>

登陆与未登录用户展示不同内容

1
2
3
4
5
<?php if($this->user->hasLogin()): ?>
					登陆可见
                <?php else: ?>
                    未登录和登陆均可见
                <?php endif; ?>

导航页面列表调用隐藏特定的页面 这个演示隐藏了album和search两个页面

1
2
3
4
5
6
7
8
9
<ul>
<li<?php if($this->is('index')): ?><?php endif; ?>><a href="<?php $this->options->siteUrl(); ?>">主页</a></li>
<?php $this->widget('Widget_Contents_Page_List')->to($pages); ?>
	<?php while($pages->next()): ?>
	<?php if (($pages->slug != 'album') && ($pages->slug != 'search')): ?>
    <li<?php if($this->is('page', $pages->slug)): ?><?php endif; ?>><a href="<?php $pages->permalink(); ?>" title="<?php $pages->title(); ?>"><?php $pages->title(); ?></a></li>
	<?php endif; ?>
    <?php endwhile; ?>
</ul>

Typecho归档页面(牧风提供,牧风演示:http://mufeng.me/archives)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php $this->widget('Widget_Contents_Post_Recent', 'pageSize=10000')->to($archives);
	$year=0; $mon=0; $i=0; $j=0;
	$output = '<div id="archives">';
	while($archives->next()):
		$year_tmp = date('Y',$archives->created);
		$mon_tmp = date('m',$archives->created);
		$y=$year; $m=$mon;
		if ($mon != $mon_tmp && $mon > 0) $output .= '</ul></li>';
		if ($year != $year_tmp && $year > 0) $output .= '</ul>';
		if ($year != $year_tmp) {
			$year = $year_tmp;
			$output .= '<h3>'. $year .' 年</h3><ul>'; //输出年份
		}
		if ($mon != $mon_tmp) {
			$mon = $mon_tmp;
			$output .= '<li><span>'. $mon .' 月</span><ul>'; //输出月份
		}
		$output .= '<li>'.date('d日: ',$archives->created).'<a href="'.$archives->permalink .'">'. $archives->title .'</a> <em>('. $archives->commentsNum.')</em></li>'; //输出文章日期和标题
	endwhile;
	$output .= '</ul></li></ul></div>';
	echo $output;
?>

 

15 7月 2013

钱宝网 注册就送钱,已经收款啦

钱宝网注册

鉴于国内的恶劣现象,开始我不是很相信,但是抱着试试的心态,就尝试注册了,结果发现还是很可靠的,钱是立即可以提款的!
现在注册就送五元。满十元立马可以提现。

可以做很多问卷任务挣钱宝,再兑换提现。

我是不打算长期做这个,开电脑看了一下。很多任务都要保证金,这就有点过分了。

14 7月 2013

.htaccess实现域名的301重定向

301重定向的作用:1.规范网址;2.排除了重复页面;3.增加网址权重

使用方法:新建一个空文件.htaccess,写入重定向规则后,上传到网站:(www.blogfeng.com)根目录。
.htaccess的最上方要写上 RewiteEngine On 这句来使启用rewrite规则。

应用一:
用301将不带WWW的域名重定向主域名:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^blogfeng.comg[NC]
RewriteRule ^(.*)$ http://www.blogfeng.com/$1 [R=301,L]

应用二:
用301将绑定的其他域名重定向到主域名:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^otherdomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.otherdomain.com$
RewriteRule ^(.*)$ http://www.blogfeng.com/$1 [R=301,L]

应用三:
旧域名重定向到新域名:

创建一个.htaccess文件,并将下面提供的代码写入文件内,它可以确保旧域名所有的目录或者网页正确的跳转到新域名内。

RewriteEngine on
RewriteRule (.*) http://www.blogfeng.com/$1 [R=301,L]

请将上面的 blogfeng.com修改成你想要跳转到的域名。
记住.htaccess文件一定要放在旧网站:(www.blogfeng.com)的根目录下,并且新网站:(www.blogfeng.com)要和旧网站:(www.blogfeng.com)保持相同的目录结构及网页文件

应用四:
将所有的其它的域名都重定向到一个域名的话,可以直接如下:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !(.*).blogfeng.com [NC]
RewriteRule ^(.*)$ http://www.blogfeng.com/$1 [L,R=301]

应用五:
用301将index.html、index.php等重定向到主域名:

RewriteEngine on
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.blogfeng.com/ [R=301,L]

13 7月 2013

html弹出窗口

晚上被学院老师做一个学院门户网站首页弹窗,没办法,找找资料

原出处未注明

 

【1、最基本的弹出窗口代码】

<SCRIPT LANGUAGE=”javascript”>

<!–

window.open (‘page.html’)

–>

</SCRIPT>

因为这是一段javascripts代码,所以它们应该放在<SCRIPT LANGUAGE=”javascript”>标签和</script>之间。<!– 和 –>是对一些版本低的浏览器起作用,在这些老浏览器中不会将标签中的代码作为文本显示出来。要养成这个好习惯啊。window.open (‘page.html’) 用于控制弹出新的窗口page.html,如果page.html不与主窗口在同一路径下,前面应写明路径,绝对路径(http://)和相对路径(../)均可。用单引号和双引号都可以,只是不要混用。这一段代码可以加入HTML的任意位置,<head>和</head>之间可以,<body>间</body>也可以,越前越早执行,尤其是页面代码长,又想使页面早点弹出就尽量往前放。

【2、经过设置后的弹出窗口】

下面再说一说弹出窗口的设置。只要再往上面的代码中加一点东西就可以了。我们来定制这个弹出的窗口的外观,尺寸大小,弹出的位置以适应该页面的具体情况。

<SCRIPT LANGUAGE=”javascript”>

<!–

window.open (‘page.html’, ‘newwindow’, ‘height=100, width=400, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no’) //这句要写成一行

–>

</SCRIPT>

参数解释:

<SCRIPT LANGUAGE=”javascript”> js脚本开始;

window.open 弹出新窗口的命令;

‘page.html’ 弹出窗口的文件名;

‘newwindow’ 弹出窗口的名字(不是文件名),非必须,可用空”代替;

height=100 窗口高度;

width=400 窗口宽度;

top=0 窗口距离屏幕上方的象素值;

left=0 窗口距离屏幕左侧的象素值;

toolbar=no 是否显示工具栏,yes为显示;

menubar,scrollbars 表示菜单栏和滚动栏。

resizable=no 是否允许改变窗口大小,yes为允许;

location=no 是否显示地址栏,yes为允许;

status=no 是否显示状态栏内的信息(通常是文件已经打开),yes为允许;

</SCRIPT> js脚本结束

【3、用函数控制弹出窗口】

下面是一个完整的代码。

<html>

<head>

<script LANGUAGE=”JavaScript”>

<!–

function openwin() {

window.open (“page.html”, “newwindow”, “height=100, width=400, toolbar =no, menubar=no, scrollbars=no, resizable=no, location=no, status=no”) //写成一行

}

//–>

</script>

</head>

<body >

任意的页面内容…

</body>

</html>

这里定义了一个函数openwin(),函数内容就是打开一个窗口。在调用它之前没有任何用途。怎么调用呢?

方法一:<body > 浏览器读页面时弹出窗口;

方法二:<body > 浏览器离开页面时弹出窗口;

方法三:用一个连接调用:

<a href=”#” >打开一个窗口</a>

注意:使用的“#”是虚连接。

方法四:用一个按钮调用:

<input type=”button” value=”打开窗口”>

【4、同时弹出2个窗口】

对源代码稍微改动一下:

<script LANGUAGE=”JavaScript”>

<!–

function openwin() {

window.open (“page.html”, “newwindow”, “height=100, width=100, top=0, left=0,toolbar=no, menubar=no, scrollbars=no, resizable=no, location=n o, status=no”)//写成一行

window.open (“page2.html”, “newwindow2”, “height=100, width=100, top=1 00, left=100,toolbar=no, menubar=no, scrollbars=no, resizable=no, loca tion=no, status=no”)//写成一行

}

//–>

</script>

为避免弹出的2个窗口覆盖,用top和left控制一下弹出的位置不要相互覆盖即可 。最后用上面说过的四种方法调用即可。

注意:2个窗口的name(newwindows和newwindow2)不要相同,或者干脆全部为空。

【5、主窗口打开文件1.htm,同时弹出小窗口page.html】

如下代码加入主窗口<head>区:

<script language=”javascript”>

<!–

function openwin() {

window.open(“page.html”,””,”width=200,height=200″)

}

//–>

</script>

加入<body>区:

<a href=”1.htm” >open</a>即可。

【6、弹出的窗口之定时关闭控制】

下面我们再对弹出的窗口进行一些控制,效果就更好了。如果我们再将一小段 代码加入弹出的页面(注意是加入page.html的HTML中,不是主页面中),让它10秒后自动关闭是不是更酷了?

首先,将如下代码加入page.html文件的<head>区:

<script language=”JavaScript”>

function closeit()

{

setTimeout(“self.close()”,10000) //毫秒

}

</script>

然后 儆?lt;body onload=”closeit()”> 这一句话代替page.html中原有的<BODY>这一句就可以了。(这一句话千万不要忘记写啊!这一句的作用是调用关闭窗口的代码,10秒钟后就自行关闭该窗口。)

【7、在弹出窗口中加上一个关闭按钮】

<FORM>

<INPUT TYPE=’BUTTON’ VALUE=’关闭’ >

</FORM>

呵呵,现在更加完美了!

【8、内包含的弹出窗口-一个页面两个窗口】

上面的例子都包含两个窗口,一个是主窗口,另一个是弹出的小窗口。通过下面的例子,你可以在一个页面内完成上面的效果。

<html>

<head>

<SCRIPT LANGUAGE=”JavaScript”>

function openwin()

{

OpenWindow=window.open(“”, “newwin”, “height=250, width=250,toolbar=no ,scrollbars=”+scroll+”,menubar=no”);

//写成一行

OpenWindow.document.write(“<TITLE>例子</TITLE>”)

OpenWindow.document.write(“<BODY BGCOLOR=#ffffff>”)

OpenWindow.document.write(“<h1>Hello!</h1>”)

OpenWindow.document.write(“New window opened!”)

OpenWindow.document.write(“</BODY>”)

OpenWindow.document.write(“</HTML>”)

OpenWindow.document.close()

}

</SCRIPT>

</head>

<body>

<a href=”#” >打开一个窗口</a>

<input type=”button” value=”打开窗口”>

</body>

</html>

看看OpenWindow.document.write()里面的代码不就是标准的HTML吗?只要按照格式写更多的行即可。千万注意多一个标签或少一个标签就会出现错误。记得用 OpenWindow.document.close()结束啊。

【9、终极应用–弹出的窗口之Cookie控制】

回想一下,上面的弹出窗口虽然酷,但是有一点小毛病,比如你将上面的脚本放在一个需要频繁经过的页面里(例如首页),那么每次刷新这个页面,窗口都会弹出一次,我们使用cookie来控制一下就可以了。

首先,将如下代码加入主页面HTML的<HEAD>区:

<script>

function openwin(){

window.open(“page.html”,””,”width=200,height=200″)

}

function get_cookie(Name) {

var search = Name + “=”

var returnvalue = “”;

if (document.cookie.length > 0) {

offset = document.cookie.indexOf(search)

if (offset != -1) {

offset += search.length

end = document.cookie.indexOf(“;”, offset);

if (end == -1)

end = document.cookie.length;

returnvalue=unescape(document.cookie.substring(offset, end))

}

}

return returnvalue;

}

function loadpopup(){

if (get_cookie(‘popped’)==”){

openwin()

document.cookie=”popped=yes”

}

}

</script>

然后,用<body >(注意不是openwin而是loadpop啊!)替换主页面中原有的<BODY>这一句即可。你可以试着刷新一下这个页面或重新进入该页面,窗口再也不会弹出了。