批量删除MYSQL里前缀相同的表

mysql_connect('localhost','username','password');
mysql_select_db('dbname');
$rs=mysql_query('show tables');
while($arr=mysql_fetch_array($rs))
{
$TF=strpos($arr[0],'bf_');
if($TF===0)
{
$FT=mysql_query("drop table $arr[0]");
if($FT)
{
echo "$arr[0] 删除成功!
“;
}
}
}
?>

dedecms(织梦)完美实现伪静态的方法

dedecms(织梦)完美实现伪静态的方法

测试版本:Dedecms V5.6版本

测试平台:Windows 7

测试环境:IIS 7.5

成功。其他条件下大同小异。

需要的条件:

1、服务器必须支持URL重写。

2、后台开启伪静态。

3、栏目设置使用动态。

4、添加文档时选择使用动态浏览。

5、修改php文件include/channelunit.func.php。

6、修改include/arc.listview.class.php。

7、编写rewrite规则。

操作步骤:

1、加载Rewrite模块(过程略)。

参考:http://hi.baidu.com/elsand/blog/item/96d417264b078a08908f9dcf.html

2、dedecms后台-系统-系统基本参数-核心设置-是否使用伪静态,选“是”。

3、把栏目和文档设置成为动态浏览。可以手动,用sql语句更快。

dedecms后台-SQL命令行工具,执行以下语句

将所有文档设置为“仅动态浏览”:update dede_archives set ismake=-1

将所有栏目设置为“使用动态页”:update dede_arctype set isdefault=-1

改成1就是静态。动态转换为静态后需要重新生成HTML。

添加栏目和文章默认为动态的一劳永逸的方法:

http://hi.baidu.com/elsand/blog/item/cd9fb8be6ae69e0618d81f5f.html

4、修改php文件include/channelunit.func.php

查找

return $GLOBALS["cfg_plus_dir"]."/view-".$aid.'-1.html';

修改为

return "/view-".$aid.'-1.html';

查找

return $GLOBALS['cfg_phpurl']."/view.php?aid=$aid";

修改为

return "/view.php?aid=$aid";

其实页可以不修改,就是URL地址会长一点。这个是文章页的。

查找

$reurl = $GLOBALS['cfg_phpurl']."/list.php?tid=".$typeid;

修改为

$reurl = "/list-".$typeid.".html";

这个必须修改,是栏目页的。

其实不修改也可以,但是URL地址会长一点。这个是文章的。

5、打开include/arc.listview.class.php

找到

$plist = str_replace('.php?tid=', '-', $plist);

(大约在第964行)

在其前面面添加一行

$plist = str_replace('plus/list', 'list', $plist);

这个是列表页分页rewrite的url格式的。

默认是http://www.xxx.com/plus/list-1-2-3.html

现在是http://www.xxx.com/list-1-2-3.html

6、 设置重写规则,在httpd.ini里面写上:

[ISAPI_Rewrite]

# 缓存3600秒 = 1 小时(hour)
CacheClockRate 3600

RepeatLimit 32

#dedecms Rewrite规则
RewriteRule ^(.*)/index\.html $1/index\.php
RewriteRule ^(.*)/list-([0-9]+)\.html $1/plus/list\.php\?tid=$2
RewriteRule ^(.*)/list-([0-9]+)-([0-9]+)-([0-9]+)\.html $1/plus/list\.php\?tid=$2&TotalResult=$3&PageNo=$4
RewriteRule ^(.*)/view-([0-9]+)-([0-9]+)\.html $1/plus/view\.php\?arcID=$2&pageno=$3

7、如果不使用动态首页

把rewrite规则中的

RewriteRule ^(.*)/index\.html $1/index\.php

去掉,或改为

RewriteRule ^(.*)/index\.html $1/index\.html

否则打开http://www.xxx.com/index.html时会陷入死循环。

说明:
1、
RewriteRule ^view-([0-9]+)-([0-9]+)\.html$ /plus/view.php?aid=$1&pageno=$2

此为文章分页重写命令。

2、如果view替换成自己设置的其他词,则需要把include/arc.archives.class.php文件中的view同时替换掉。

3、重写后的URL如下:

文章页:http://www.xxx.com/view-1-1.html

列表页:http://www.xxx.com/list-1.html

如果需要改成如下格式:

文章页:http://www.xxx.com/abc/view-1-1.html

列表页:http://www.xxx.com/abc/list-1.html

include/channelunit.func.php中

return $GLOBALS["cfg_plus_dir"]."/view-".$aid.'-1.html';

改为 return "/abc/view-".$aid.'-1.html';

return $GLOBALS['cfg_phpurl']."/view.php?aid=$aid";

改为 return "/abc/view.php?aid=$aid";

$reurl = $GLOBALS['cfg_phpurl']."/list.php?tid=".$typeid;

改为 $reurl = "/abc/list-".$typeid.".html";

重写规则改为:

RewriteRule ^(.*)/index\.html $1/index\.php
RewriteRule ^(.*)/abc/list-([0-9]+)\.html $1/plus/list\.php\?tid=$2
RewriteRule ^(.*)/abc/list-([0-9]+)-([0-9]+)-([0-9]+)\.html $1/plus/list\.php\?tid=$2&TotalResult=$3&PageNo=$4
RewriteRule ^(.*)/abc/view-([0-9]+)-([0-9]+)\.html $1/plus/view\.php\?arcID=$2&pageno=$3

4、伪静态可能会出现多个url都是指向相同页面,如果看重SEO效果,则可用robots.txt屏蔽多余url。

Yahoo Media Player(很好的网页播放器)使用方法

相关网址:http://mediaplayer.yahoo.com/
使用帮助:http://yahoomediaplayer.wikia.com/


1、基础使用:
1、1:将代码 <script src=”http://mediaplayer.yahoo.com/js” type=”text/javascript”></script> 放到“博客设置–自定义Header”中保存。
1、2:发布方式:
最简样式:<a href=”http://example.com/mysong.mp3″> My Favorite Tune</a>
高级样式:<a href=”http://example.com/mp3/song” tabindex=”1″
   title=”Movin’ Right Along” type=”audio/mpeg”>my favorite song</a> Continue reading ‘Yahoo Media Player(很好的网页播放器)使用方法’ »

PHP和JS 字符串BASE64加密及解密

在PHP中我们可以直接使用PHP自带的函数 base64_encode() 和 base64_decode() 进行加密和解密,废话不说了,我们直接进入正题:

例子 1. base64_encode() 示例

$str = 'This is an encoded string';
echo base64_encode($str);

此示例将显示:

VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==

Continue reading ‘PHP和JS 字符串BASE64加密及解密’ »

DEDE调试时出现Safe Alert: Request Error step 2!解决办法

原因:DEDE的数据库类是禁子使用子查询的
找到sql语句 $dsql->Execute(‘me’,$query);

在上面加一句:$dsql->safeCheck = false;

DEDE5.6自定义模型调用定义联动类别的方法

先修改 include\taglib\infolink.lib.php 文件

require_once(DEDEROOT.'/data/enums/infotype.php');
下面添加
require_once(DEDEROOT.'/data/enums/自定义联动类别字段名.php');
function lib_infolink(&$ctag,&$refObj)
{
global $dsql,$nativeplace,$infotype,$自定义联动类别字段名,$hasSetEnumJs,$cfg_cmspath,$cfg_mainsite;
global $em_nativeplaces,$em_infotypes,$em_自定义联动类别字段名s; //看清楚,这里后面的个S Continue reading ‘DEDE5.6自定义模型调用定义联动类别的方法’ »

PHP获取远程文件的四种方法

1. fopen, fread

view plainprint?1 if($file = fopen(“http://www.example.com/“, “r”)) { 

2     while(!feof ($file)) 

3         $data .= fread($file, 1024); 

4 }  Continue reading ‘PHP获取远程文件的四种方法’ »

dedeCMS V5.5的一些高级标签应用方法

首先我简单的介绍下自己,我是织梦官方团队的天涯,接触织梦也有2年多时间了,之前一直在论坛上做斑竹,认识了很多喜爱织梦的朋友,后来便加入了织梦团队,发现这是一个充满朝气、有激情和学习力的地方,这次受站长网的邀请来给大家做一次DedeCMS程序方面的讲座。
  因为这次主要是讲座,缺乏体系的培训内容,本次讲座我将织梦技术论坛较为常见的问题加以整理,并结合一些其他方面的应用内容进行补充,让大家更了解DedeCMS程序的使用。 Continue reading ‘dedeCMS V5.5的一些高级标签应用方法’ »

PHP正则表达式替换和普通替换实例

{dede:field name='aid' runphp='yes'} $tsql = new DedeSql(false);
$tsql->SetQuery("select * from #@__addonmusic as b left join #@__archives a on a.id = b.aid where aid='@me'");
$tsql->Execute('t');
while($row = $tsql->GetArray('t',MYSQL_ASSOC)){

$url=”http://www.qqzer.com/plus/lrc.php?title=”.urlencode($row['title']).”&artist=”.urlencode($row['music_author']);
$str=file_get_contents($url);

}
$str=preg_replace(‘/\[(.*?)\]/i’,”
“, $str);
$str=str_replace(“\n”,”",$str);
$str=str_replace(“\t”,”",$str);
$str=str_replace(“\r”,”",$str);
$str=str_replace(”

“,”
“,$str);
$str=str_replace(”

“,”
“,$str);
@me=$str;
{/dede:field}

百度第一天收录的文章第二天就K掉分析

原因:
    一、你发布的新闻有人转载,而且转载你新闻的站点权重比你的高(比如一个权重稍低的网站发布一篇原创的文章,且被百度收录,但这篇原创的文章经一个权重较高的网站转载后,百度也会收录,一篇一样的软文经多方转载后百度可能收录很多,但经过百度系统分析后(也就一天时间左右),百度会K掉一些权重低的网站,就算软文是你的原创,权重高的网站转载后,百度一但收录,就会误判为软文原创者是权重高的网站,原因只有一个就是人家网站权重高。 Continue reading ‘百度第一天收录的文章第二天就K掉分析’ »