武汉17中迅雷下载(转)

2011-08-23 留下评论

好像这几天武汉17中很火,唉,现在的孩子啊,是不是太open了点,直接在教室就xxoo。中国的教育水平真是越来越低了。
想了解这件事的,可以点下面的博客进去。

武汉17中迅雷在线视频下载地址

[110822]国外主流被屏蔽网盘的国内下载方法附免费filesonic网盘高级账号一个

2011-08-22 留下评论

分享一个可用的filesonic网盘账号,不要问我干什么用的。
需要的尽快拿走咯,这种东西都很短命的。
争取每天都有新的出来,请大家关注我的博客。

另外废话一句,用JDownloader外加filesonic的会员账号,
就可以突破防火墙屏蔽高速下载了。

另外补充一下, wupload的链接没有屏蔽, 可以用JDownloader下载,
没有会员账号的话, 限速大约40k~100k, 一次只能下载1个文件,
并且下载完一个文件后, 要等待一段时间才能下载第二个文件.
当然, 如果是用会员账号的话则不限制.

而hotfile的网盘, 需要将资源链接地址修改为 https://开头的才能打开下载.
JDownloader 目前暂时无法支持hotfile文件, 大家可以用浏览器下载.

Username: KingThor110@yahoo.com
Password: premiumvn.com

已失效,请关注每日更新,或者订阅本博客.

有图为证

Javascript刷新全集

2012-04-21 留下评论

一:刷新本页面

前台:<script>window.location.href=window.location.href;</script>

后台:Response.Write(“<script>window.location.href=window.location.href;</script>”)

二:刷新父页面

前台:opener.location.href=opener.location.href;</script>

后台:Response.Write(“<script>opener.location.href=opener.location.href;</script>”)

三:链接到指定网页

前台:<script>window.location.href=’http://www.cnblogs.com/yooolonet/‘;</script>

  MSDN说的window.navigate(sURL)方法是针对IE的,不适用于FF,在HTML DOM Window Object中,根本没有列出window.navigate方法。

后台:Response.Write(“<script>window.location.href=’yourpage.aspx’;</script>”)

  或者: Response.Write(“NewUrl”);

四:刷新Iframe

前台:<script>iframe名字或者ID.location.reload(true);</script>

五:定时刷新

function flash(){window.location.href=”http://www.cnblogs.com/yooolonet/”;setTimeout(“flash()”,1000);} //1000为一秒

<script>setTimeout(“location.href=http://www.cnblogs.com/yooolonet/“,2000)</script>

<script>setTimeout(“self.location.reload();”,1000);<script>一秒一次

分类:Other

最全的开源电子商务网店平台介绍

2012-04-18 留下评论

The moment you decide to run an online store selling your favorite stuff, you are immediately thrown with dozens of questions and obstacles. For starters, you’ll need to decide between clean inventory/excess stock, then comes the resource for products. Ultimately, when it comes to open an e-commerce site, the biggest decision is Which platform should I use?

open source shopping cart Open Source E Commerce Shopping Carts Best Of

The software you’ve decided upon will be the foundation of your entire e-commerce site and will not likely be changed in the future, therefore it’s utmost important that you know all of the best one before you choose and regret later. In this post, we want to bring to your attention some of the best (free) open-source shopping carts available on the Internet. Do check them out, test of the demo, play around with it to know if the functionality suits your business before deciding on one.

Full list after jump.

Best of the pack

OsCommerce (PHP/MySQL)

OsCommerce Online Merchant is an open source online shop e-commerce solution that is available for free under the GNU General Public License. It features a rich set of out-of-the-box online shopping cart functionality that allows store owners to setup, run, and maintain online stores with minimum effort and with no costs, fees, or limitations involved.

oscommerce Open Source E Commerce Shopping Carts Best Of

Zen Cart (PHP/MySQL)

Zen Cart truly is the art of e-commerce; free, user-friendly, open source shopping cart software. The ecommerce web site design program is being developed by a group of like-minded shop owners, programmers, designers, and consultants that think ecommerce web design could be and should be done differently.

zen cart Open Source E Commerce Shopping Carts Best Of

PrestaShop (PHP/MySQL)

PrestaShop is a professional e-Commerce shopping cart software that you can download and use for free. Having a very powerful back-end, store admins can manage the inventory, orders, customers & payments easily. System never limits you as it supports unlimited categories, sub-categories & image pictures.

prestashop Open Source E Commerce Shopping Carts Best Of

CubeCart (PHP/MySQL)

CubeCart is written to run on servers that have PHP & MySQL support. With CubeCart you can quickly setup a powerful online store which can be used to sell digital or tangible products to new and existing customers all over the world.

cubecart Open Source E Commerce Shopping Carts Best Of

Magento Commerce (PHP/MySQL)

Magento is a feature-rich eCommerce platform built on open-source technology that provides online merchants with unprecedented flexibility and control over the look, content and functionality of their eCommerce store. Magento’s intuitive administration interface features powerful marketing, search engine optimization and catalog-management tools to give merchants the power to create sites that are tailored to their unique business needs. Magento also comes with a much more powerful Enterprise version.

magentocommerce Open Source E Commerce Shopping Carts Best Of

Digistore (PHP/MySQL)

Digistore Ecommerce 4.0 is a fully featured open source ecommerce solution based on the popular osCommerce engine. Boasting improvements both to the administration and the end user experience Digistore has quickly become a popular choice for people wishing to market products online.

digistore Open Source E Commerce Shopping Carts Best Of

Opencart (PHP/MySQL)

A robust e-commerce solution for Internet merchants with the ability to create their own online business and participate in e-commerce at a minimal cost. OpenCart is designed feature rich, easy to use, search engine friendly and with a visually appealing interface.

opencart Open Source E Commerce Shopping Carts Best Of

Spree Commerce (Ruby on Rails/MySQL)

Spree capitalizes on the dynamic nature of the Ruby progamming language to provide the most flexible commerce platform available. Spree has been designed from the ground up to be as open and extensible as possible. You no longer have to be frustrated with the limited set of choices provided by most platforms.

spreecommerce Open Source E Commerce Shopping Carts Best Of

CREloaded (PHP/MySQL)

CRE Loaded is much more than your average shopping cart. It’s the industry’s first downloadable e-commerce system that makes your store fully compliant with all Payment Card Industry (PCI) security rules. Organize, manage and ship your products from your online store. Accept credit card transactions safely.

creloaded Open Source E Commerce Shopping Carts Best Of

Zeuscart (PHP/MySQL)

The Zeuscart shopping cart is based on PHP application and it is used as scripting language which facilitates developer in making dynamically driven websites. It is very facile to learn and understand. To be precise, application of PHP is most popular because of its functionality which can be changed as per ones requirements.

zeuscart Open Source E Commerce Shopping Carts Best Of

Agoracart (Perl/MySQL)

Offers a very wide range of features that allow you to setup an online storefront or shop ranging from a simple template based store for novices to the integration of complex web design concepts created by your web designer.

agoracart Open Source E Commerce Shopping Carts Best Of

Afcommerce (PHP/MySQL)

AFCommerce is a full and complete online store with both a store front and administration area directly Out-Of-The-Box, which can be easily installed, configured, and maintained over a web-based interface. AFCommerce now includes our Ecommerce Website Building Software, AFBuilder, included completely Free.

afcommerce Open Source E Commerce Shopping Carts Best Of

RapidShop (PHP/without MySQL)

Very fast and easy to use, without MySQL (and can without PHP), direct from MS Excel. For 1000-2000 item of products. RapidShop is integrated with PayPal, EGold and any payment system. You can link your shopping cart to any credit card merchant account or payment gateway. Search Engine Optimized.

rapidshop Open Source E Commerce Shopping Carts Best Of

Designers & Photographers’s Favorite

These following shopping carts are light, simple and utmost useful for those who wish to sell stock photos, video and print graphics online.

Cmsaccount Photo Store Script (PHP/MySQL)

Photo store software for selling your photos, images, artwork, audio, videos, vector illustrations and prints online.

cmsaccount Open Source E Commerce Shopping Carts Best Of

Ktools Photostore (PHP/MySQL)

PhotoStore allows you to setup a complete photo selling website on your server or hosting space in just minutes. Perfect for professional photographers looking to sell their images or prints to their customers online.

photostore Open Source E Commerce Shopping Carts Best Of

Xpoze (PHP/MySQL)

Complete and easy to use solution for selling images and other media files such as videos, vectors or 3D graphics. As everyone tends for something unique Xpoze have worked had to provide you with the best flexibility to customize the look and the features you want to use without much fuss and programming knowledge.

xpoze Open Source E Commerce Shopping Carts Best Of

Shopping Carts: Joomla

VirtueMart (PHP/MySQL)

The complete e-Commerce shopping cart solution for Joomla! used by thousands of store owners. It can be run in Store- and Catalog-Mode. With its powerful Administration Tool you can handle an unlimited Number of Categories, Products, Orders, Discounts, Shopper Groups and Customers. VirtueMart works for both />Joomla and />Mambo.

virtuemart Open Source E Commerce Shopping Carts Best Of

RokQuickCart (PHP/MySQL)

RokQuickCart is a simple shopping cart for Joomla. It takes a simple, yet elegant, shopping cart script and integrates directly into Joomla. It allows you to showcase products, inclusive of images, descriptions and additional options, and purchase these items, with support for shipping and tax calculation.

rokquickcart Open Source E Commerce Shopping Carts Best Of

Seber Cart (PHP/MySQL)

Small, fast and easy to use shopping cart for Joomla.

seber Open Source E Commerce Shopping Carts Best Of

SimpleCaddy (PHP/MySQL)

Integrate a simple shopping cart into your content. No need to set up a complete system like VirtueMart if you are only selling a few items or you don’t want to setup a complete shop.

simplecaddy Open Source E Commerce Shopping Carts Best Of

Shopping Carts: WordPress

ShopperPress (PHP/MySQL)

ShopperPress is a fully featured shopping cart plugin for wordpress, suitable for selling any types of products, services, and digital downloads online. ShopperPress has built in support for multiple payment gateways allowing you to accept product payments online.

shopperpress Open Source E Commerce Shopping Carts Best Of

Fat Free Cart (PHP/MySQL)

With FatFreeCart Plugin you do not have to generate or paste any code in CSS or HTML of WordPress theme. The plugin is designed to work within your WordPress post editor.

fatfreecart Open Source E Commerce Shopping Carts Best Of

WordPress e-Commerce (PHP/MySQL)

WordPress e-Commerce is a WordPress Shopping Cart Plugin that is truly an industrial strength elegant easy to use and fully featured shopping cart solution suitable for selling your products, services, and or fees online.

instinct Open Source E Commerce Shopping Carts Best Of

Premium Shopping Carts Worth Knowing

Last but not least, we throw in some shooping cart that comes with a price tag. For those who have budgets for their online business, these following shopping carts are worth knowing too.

CS-Cart (PHP/MySQL)

CS-Cart is an “out of the box” ecommerce software solution with easy-to-use functionality that allows to start selling online immediately. Its feature set fits into businesses of any size, from a small single-product shop to a fully-featured online storefront. Designed for ease of use along with flexibility, CS-Cart is equipped with the latest ecommerce innovations (like one-page checkout, AJAX-based web interface, block manager and others) built into a highly configurable and modifiable sales and promotion engine.

cs cart Open Source E Commerce Shopping Carts Best Of

Fortune3 Ecommerce Software

Fortune3′s Shopping Cart software is a completely customizable and professional shopping cart, that includes thousands of features and tools to make managing your online store easy and fast. Their powerful Windows software, the Fortune3 Wizard, stands out from the rest, it includes a built-in HTML WYSIWYG editor and a superb Product Management interface that cannot be compared to any web-based ecommerce software. You can download a 30 day trial of the full version of Fortune3, and build your ecommerce site for free for 30 days.

f3 cart Open Source E Commerce Shopping Carts Best Of

Bosscart (PHP/MySQL)

Boss Cart is an eCommerce shopping basket application, specifically developed to meet the needs of small to medium sized retailers. Boss Cart has been created using the latest technology and runs on Windows, Linux and all other Web platforms. Boss Cart has been tested with over 20,000 items to ensure maximum speed and efficiency.

bosscart Open Source E Commerce Shopping Carts Best Of

Avactis (PHP/MySQL)

Avactis shopping cart is a software package that allows you to open an online store on the Internet. It comprises two parts a client side and an administrator side. The client side is your website as seen by visitors. The Avactis’s client side allows the visitors to your site to browse products in the online store, select products and put them into the shopping cart, as in a conventional supermarket, and then pay for the selected products using a credit card or other payment options.

avactis Open Source E Commerce Shopping Carts Best Of

Lite Commerce (PHP/MySQL)

LiteCommerce is a lightweight high-tech ecommerce solution devoted to make an internet store launching process as easy as surfing the Web. LiteCommerce is more than just a shopping cart. It is a multipurpose ecommerce store platform. Numerous built-in features will make your online store and your business successful: inventory management, credit card processing, SEO tools, special offers, discount coupons and others.

litecommerce Open Source E Commerce Shopping Carts Best Of

X-cart (PHP/MySQL)

X-Cart shopping cart software is based on PHP Smarty templates, this makes it very flexible and easy to modify. The data is stored in MySQL database. X-Cart is a turnkey package. Installation is handled by web-based step-by-step wizard to make the system running immediately after receiving it. X-Cart is search engine friendly. A merchant can specify meta tags and define custom URLs for product and category pages that results in higher search engine rankings.

x cart Open Source E Commerce Shopping Carts Best Of

Instantestore (Hosting not required)

InstanteStore provides a variety of SEO, marketing, and promotional tools that you can make use of to bring in traffic and customers. These features will help you reach your potential customer market and get them buying at your store.

instantestore Open Source E Commerce Shopping Carts Best Of

Interspire (PHP/MySQL)

From complete SEO optimization to single page checkout, track-able coupon codes and business intelligence reports no other shopping cart software increases your online sales like Interspire Shopping Cart. Guaranteed, or your money back. We offer both a PHP-based shopping cart and also a hosted, fully-managed ecommerce solution called BigCommerce.

interspire Open Source E Commerce Shopping Carts Best Of

Sunshop (PHP/MySQL)

SunShop shopping cart is search engine friendly shopping cart system. A complete ecommerce solution packed with and extensive feature list. SunShop offers all of the standard features you would find in any off the shelf shopping cart software plus much more. What makes SunShop shopping cart stand above the rest is the ease of use.

sunshop Open Source E Commerce Shopping Carts Best Of

Squirrel Cart (PHP/MySQL)

Squirrelcart PHP Shopping Cart software is a fully customizable, robust php shopping cart, designed with the advanced developer and web novice in mind. If you are a web novice, you will appreciate its ease of use, and the fact that Squirrelcart will generate the HTML for all of your store’s pages based on the built in templates provided. If you have a strong knowledge of HTML, you will appreciate the ability to make Squirrelcart look and work the way YOU want it to.

squirrelcart Open Source E Commerce Shopping Carts Best Of

Shopfactory (PHP/MySQL)

ShopFactory 8 all-in-one shopping cart software allows anyone to quickly create and manage their own professional Internet shop — despite being one of the most powerful and feature rich eCommerce solutions on the market. Now you can update your own website and products to sell securely online without professional help.

shopfactory Open Source E Commerce Shopping Carts Best Of

3dcart (Hosting not required)

Shopping Carts from 3dCart are complete e-commerce storefront solutions for your new or existing web site. Easily build, edit, and maintain your online shop, and collect orders without any programming or HTML knowledge!

3dcart Open Source E Commerce Shopping Carts Best Of

Viart (PHP/MySQL)

The Viart range of software provides the tools you need to make full use of the Internet in your business. Now anyone can set up a secure online store without the need for any programming knowledge. The Viart suite of products is designed by Viart in-house team of e-commerce software developers. Together team has over thirty years of experience in this arena.

viart Open Source E Commerce Shopping Carts Best Of

Pinnacle Cart (PHP/MySQL)

Pinnacle Cart is an extremely powerful php shopping cart and website builder application. Designed from marketing perspective, this eCommerce application is feature-packed, robust, scalable and easy to use. Pinnacle Cart is the clear choice for serious merchants focused on rapidly and cost effectively deploying, managing and growing a successful web-based business.

pinnaclecart Open Source E Commerce Shopping Carts Best Of

分类:Other

威盾PHP加密专家解密算法

2012-02-28 留下评论
  1. <?php
  2. /***********************************
  3. *威盾PHP加密专家解密算法 By:Neeao
  4. *http://Neeao.com
  5. *2009-09-10
  6. ***********************************/
  7. $filename=”install.php”;//要解密的文件
  8. $lines = file($filename);//0,1,2行
  9. //第一次base64解密
  10. $content=””;
  11. if(preg_match(“/O0O0000O0(‘.*’)/”,$lines[1],$y))
  12. {
  13. $content=str_replace(“O0O0000O0(‘”,””,$y[0]);
  14. $content=str_replace(“‘)”,””,$content);
  15. $content=base64_decode($content);
  16. }
  17. //第一次base64解密后的内容中查找密钥
  18. $decode_key=””;
  19. if(preg_match(“/),’.*’,/”,$content,$k))
  20. {
  21. $decode_key=str_replace(“),'”,””,$k[0]);
  22. $decode_key=str_replace(“‘,”,””,$decode_key);
  23. }
  24. //截取文件加密后的密文
  25. $Secret=substr($lines[2],380);
  26. //echo $Secret;
  27. //直接还原密文输出
  28. echo “<?php “.base64_decode(strtr($Secret,$decode_key,’ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/’)).”?>”;
  29. ?>
分类:Other

Access在线解密 PHP源码

2012-02-28 留下评论

<?
/*site:http://www.t00ls.net */
/*如果转载请保留本信息 */
/*by:7jdg QQ:7259561 */
$file=$_FILES[‘uploadfile’][‘tmp_name’];
$oldname =$_FILES[‘uploadfile’][‘name’];
$ext =strtolower(substr(strrchr($oldname, ‘.’), 1));
if ($file)
{
if ($ext !== “mdb”)
{
echo “你传的是MDB文件吗?大学生是你这样吗?<br>”;
echo “您知道啥是MDB么?\t<font color=red>” . $oldname . “</font>是MDB后缀吗?后缀是啥知道不?”;
}
else
{
//为Access2000异或的源码
$PassSource2k=array(0xa1,0xec,0x7a,0x9c,0xe1,0x28,0x34,0x8a,0x73,0x7b,0xd2,0xdf,0x50);
//Access97的异或源码
$PassSource97=array(0x86,0xfb,0xec,0x37,0x5d,0x44,0x9c,0xfa,0xc6,0x5e,0x28,0xe6,0x13);

//$file = ‘Level5555.mdb’;

$ver = file_get_contents($file,1,null,0x14,1);//版本
$ver = hexdec(bin2hex($ver));
$EncrypFlag= file_get_contents($file,1,null,0x62,1);//加密标志
$EncrypFlag = hexdec(bin2hex($EncrypFlag));
for($i=66;$i < 92; $i++){
$temp = file_get_contents($file,1,null,$i,1);//加密标志
$pass[].=hexdec(bin2hex($temp));
}

if ($ver < 1){
$MdbVersion=”Access 97″;
if(($pass[0] ^ $PassSource97[0])==0)
$MdbPassword=”密码为空!”;
else{
$MdbPassword=””;
for($i=0;$i < 13; $i++)
$MdbPassword .=chr($pass[$i*2] ^ $PassSource2k[$i]);
}
}else{
$MdbVersion=”Access 2000 or 2002″;
for($i=0;$i < 13; $i++){
if(($i % 2)==0)
$t1 = chr(0x13 ^ $EncrypFlag ^ $pass[$i*2] ^ $PassSource2k[$i]);
else
$t1 = chr($pass[$i*2] ^ $PassSource2k[$i]);

$MdbPassword .=$t1;
}
}
if(ord($MdbPassword[1]) < 0x20 || ord($MdbPassword[1]) > 0x7e)
$MdbPassword=”密码为空!”;
}
}
?>

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<HTML>
<HEAD>
<TITLE>Access在线解密</TITLE>
<META http-equiv = Content-Type content = “text/html; charset=gb2312”>
<META content = “MSHTML 6.00.2800.1479” name = GENERATOR>
</HEAD>
<link href = “style.css” rel = “stylesheet” type = “text/css”>
<BODY>
<br>
<br>
<form action = “” method = “POST” enctype = “multipart/form-data”>
MDB文件:
<INPUT class=”input” type = “file” name = “uploadfile” size = “21”>
<INPUT class=”input” name = “” value = “解密” type = “submit” size = “30”><br><br>
Access版本: <input name=”ver” value=”<?= $MdbVersion ?>” type=”text” class=”input” size=”39″ ><br>
文件名: <input name=”Encode” value=”<?= $oldname ?>” type=”text” class=”input” size=”39″ ><br>
密码: <input name=”Decode” value=”<?= $MdbPassword?>” type=”text” class=”input” size=”39″ >
</FORM>
<br>

分类:Other

将PHP错误发送到指定邮箱

2012-02-02 留下评论

有些时候你不想显示PHP错误,而给你发送一个email,下面代码可以帮助你实现:
<?php
// Our custom error handler
function nettuts_error_handler($number, $message, $file, $line, $vars){
$email = ”
<p>An error ($number) occurred on line
<strong>$line</strong> and in the <strong>file: $file.</strong>
<p> $message </p>”;
$email .= “<pre>” . print_r($vars, 1) . “</pre>”;
$headers = ‘Content-type: text/html; charset=iso-8859-1’ . “\r\n”;
// Email the error to someone…
error_log($email, 1, ‘you, $headers);
// Make sure that you decide how to respond to errors (on the user’s side)
// Either echo an error message, or kill the entire project. Up to you…
// The code below ensures that we only “die” if the error was more than
// just a NOTICE.
if ( ($number !== E_NOTICE) && ($number < 2048) ) {
die(“There was an error. Please try again later.”);
}
}
// We should use our custom function to handle errors.
set_error_handler(‘nettuts_error_handler’);
// Trigger an error… (var doesn’t exist)
echo $somevarthatdoesnotexist;

分类:Other

使用gzcompress()来压缩数据

2012-02-02 留下评论

当使用string时,往往会非常的长。使用gzcompress()方法,strings可以被压缩,解压缩使用gzuncompress()即可,如下:
$string =
“Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Nunc ut elit id mi ultricies
adipiscing. Nulla facilisi. Praesent pulvinar,
sapien vel feugiat vestibulum, nulla dui pretium orci,
non ultricies elit lacus quis ante. Lorem ipsum dolor
sit amet, consectetur adipiscing elit. Aliquam
pretium ullamcorper urna quis iaculis. Etiam ac massa
sed turpis tempor luctus. Curabitur sed nibh eu elit
mollis congue. Praesent ipsum diam, consectetur vitae
ornare a, aliquam a nunc. In id magna pellentesque
tellus posuere adipiscing. Sed non mi metus, at lacinia
augue. Sed magna nisi, ornare in mollis in, mollis
sed nunc. Etiam at justo in leo congue mollis.
Nullam in neque eget metus hendrerit scelerisque
eu non enim. Ut malesuada lacus eu nulla bibendum
id euismod urna sodales. “;
$compressed = gzcompress($string);
echo “Original size: “. strlen($string).”\n”;
/* prints
Original size: 800
*/
echo “Compressed size: “. strlen($compressed).”\n”;
/* prints
Compressed size: 418
*/
// getting it back
$original = gzuncompress($compressed);

分类:Other

百度分词技术

2012-01-24 留下评论

百度分为大体分为3中方法

1.字符串匹配的分词方法
2.词义分词法。
3.统计分此法。

一、字符串匹配的分词方法是最常用的分词法,百度就是用此种分词。字符串匹

配的分词方法又分为3中分词方法:

1.正向最大匹配法

什么意思呢?就是把一个词从左至右来分词。举个例子:“不知道你在说什么”

,这句话采用正向最大匹配法是如何分的呢?“不知道,你,在,说什么”与正

向最大匹配法相对应的是反向最大匹配发。

2.反向最大匹配法

上面我举的例子是如何分的呢 “不知道你在说什么”。反向最大匹配法来分上面这

段是如何分的:“不,知道,你在,说,什么”,这个就分的比较多了,反向最

大匹配法就是从右至左。

3.就是最短路径分词法

这个怎么理解呢 ,就是说,我一段话里面要求切出的词数是最少的。

还是上面哪句话:“不知道你在说什么” 最短路径分词法就是指,我把上面哪句

话分成的词要是最少的。不知道,你在,说什么,这就是最短路径分词法,分出

来就只有3个词了 。好了,当然还有上面三种可以相互结合组成一些分词方法。

比如正向最大匹配法和反向最大匹配法组合起来就可以叫做双向最大匹配法。好

了,第一种说完了,

二、词义分词法

这种其实就是一种机器语音判断的分词
方法。很简单,进行句法、语义分析,利用句法信息和语义信息来处理歧义现象

来分词,这种分词方法,现在还不成熟。处在测试阶段。

三、统计的分词方法

这个很简单,就是根据词组的统计,就会发现两个相邻的字出现的频率最多,那

么这个词就很重要。就可以作为用户提供字符串中的分隔符。这样来分词。比如

,“我的,你的,许多的,这里,这一,那里”。等等,这些词出现的比较多,就

从这些词里面分开来。好了,分词技术讲完了。

那么我们刚刚学了分词技术,又如何来运用他们为我们的站点获得流量呢

我们可以利用分词技术来增加我们站点长尾词,这样就可以获取流量排名。

不但这些分出来的长尾词能够获取一定的排名,也能够推动站点的目标关键词获

取很好的排名。这个原理就是内链原理,这里不再讲了。讲了这么多,我们举个

例子。

例如:外贸网站优化,如何来分呢?

正向最大匹配,反向最大匹配,双向最大匹配,最短链接匹配。
1、正向最大匹配:“外贸,网站优化”
2、反向最大匹配:“外贸网站,优化”
3、双向最大匹配:“外贸,网站,优化”
4、最短路径最大匹配。:“外贸网站优化”

好了,我们分了词为“外贸,网站优化,优化,外贸网站,网站 ,外贸网站优化

。”

这些词每个都可以做一个主题页为目标关键词

这些分出来的词,把他们都作为你站点的主题页,一旦导入链接权重上来了,竞

争力就大了,因为这些页面把他内链起来。用锚链接,指向主页的目标关键词。

呵呵,这就是分词的好处。他能够提升目标关键词的排名的竞争力也同时给站点

带来一定流量。

分词还有一种好处,那就是提升内页的排名。好的,这个我就不详细讲了。大家

可以去看一下。就是关于百度,捕获描述的文章。如果你的内页不做描述,那么

百度就会给你定义一个描述或者从你的页面捕获一个描述。在捕获描述的时候,

如果你的知道他会捕获哪一段,那么你说,你的排名会不会上升。你就刻意写哪

一段。

分类:Other

seo谷歌高级搜索命令

2012-01-24 留下评论

每天查询反链,搜索footprint、profile资源的命令大家肯定用的得心应手,

但是大家肯定不知道有多少谷歌搜索命令,下面转来一起学习

很多不常用的,但是说不定哪天用到了 标记一下

一、allintitle:
当我们用allintitle提交查询的时候,Google会限制搜索结果仅是那些在网页标题里边包含了我们所有查询关键词的网页。例 [allintitle: detect plagiarism],提交这个查询,Google仅会返回在网页标题里边包含了”detect”和”plagiarism”这两个关键词的网页。

二、bphonebook:
用bphonebook进行查询的时候,返回结果将是那些商务电话资料。

三、allinanchor:
anchor是一处说明性的文字,它标注说明了这个链接可能跳转到其它的网页或跳转到当前网页的不同地方。当我们用allinanchor提交查询的时 候,Google会限制搜索结果必须是那些在anchor文字里包含了我们所有查询关键词的网页。例[ allinanchor: best museums
Sydney ] ,提交这个查询,Google仅仅会返回在网页anchor说明文字里边包含了关键词”best” “museums” 和”Sydney”的网面。

四、allinurl:
当我们用allinurl提交查询的时候,Google会限制搜索结果仅是那些在URL(网址)里边包含了我们所有查询关键词的网页。例 [allinurl: google faq],提交这个查询,Google仅会返回在URL里边包含了关键词”google”和”faq”的网页,象www.google.com/help /faq.html等的网页。

五、cache:
提交cache:url ,Google会显示当前网页的快照信息,从而替换网页的当前信息。例[cache:www.friendgolf.com],提交这个查询,Google会返回所有抓取的关于www.friendgolf.com的网页快照信息。在显示的网页快照信息里边,Google会高亮显示查询关键词。(在cache:和URL之间不能有空格)

六、allintext:
当我们用allintext提交查询的时候,Google会限制搜索结果仅仅是在网页正文里边包含了我们所有查询关键词的网页。例[allintext: travel packing list],提交这个查询,Google仅仅会返回在一个网页包含了三个关键词”travel” “packing”和”list”的网页。

分类:Other

压缩你的PHP、JS、CSS等文本类型代码

2012-01-23 留下评论

众所周知,减小代码在传输中的大小,就能提高页面的传输速度,打开网页也就快 了,这是基于带宽瓶颈的理论,当然服务器速度受到其他很多因素的影响, 有PHP代码执行速度,数据库访问速度,磁盘读写IO速度等,无论怎样,带宽影响是非常大,而受中国电信抑或是中国网通还有其他的一些电信公司的制约,在 服务器网络带宽并不很充裕的条件下,压缩代码传输将会大大节省带宽!

本文讲述通过使用Gzip压缩方式自动压缩相应的代码,在访问者浏览器端会自动还原成代码以便浏览器执行,至于编写代码时的良好风格节省空间的方法不在本文之列。

GZIP 最早由Jean-loup Gailly和Mark Adler创建,用于UNIX系统的文件压缩。我们在 LINUX中经常会用到后缀为.gz的文件,它们就是GZIP格式的。现今已经成为Internet 上使用非常普遍的一种数据压缩格式,或者说一种文件格式。HTTP协议上的GZIP编码是一种用来改进WEB应用程序性能的技术。大流量的WEB站点常常 使用GZIP压缩技术来让用户感受更快的速度。

首先测试一下你的网站各个页面是否采用了Gzip压缩,这里有个测试工具

目前,有两种主流方法实现Gzip压缩。
一、mod_deflate模块

mod_deflate 模块提供了DEFLATE输出过滤器,允许服务器在将输出内容发送到客户端以前进行压缩(应该也是采用gzip数据格式压缩,deflate是一种压缩算 法)以节约带宽。Apache 1.3.x时代使用mod_gzip模块来实现,Apache2已经内置了mod_deflate模块。

这种方法要求安装了Apache的http服务器软件,并且加载了deflate模块。

使用方法:

在网页发布目录的.htaccess文件中加入:

  1. <ifmodule mod_deflate.c>
  2. AddOutputFilter DEFLATE html htm xml php js css
  3. </ifmodule>

这样就会使得Apache在发布html,xml,php,js,css这样的文件时会采用Gzip方式传输数据,这个方法简单,一劳永逸,但一般使用的虚拟主机并没有安装deflate模块,也不一定是Apache的,不过我们还有办法:

二、ob_gzhandler函数
主机要求:支持PHP,PHP版本在4.0.4以上,安装有zlib库

对于PHP文件传输中压缩,只需在原来的 PHP 文件首行加上

  1. <?php if(extension_loaded(‘zlib‘)){ob_start(‘ob_gzhandler‘);}?>

并且在结尾加上

  1. <?php if(extension_loaded(‘zlib‘)){ob_end_flush();}?>

复制时还原为正规的PHP格式。

对于js文件,则在原来js文件的首行加上

  1. <?php if(extension_loaded(‘zlib‘)){ob_start(‘ob_gzhandler‘);} header(“Content-Type: text/javascript“); ?>

末尾同样加上

  1. <?php if(extension_loaded(‘zlib‘)){ob_end_flush();}?>

然后存为abc.js.PHP这样的文件,并且修改指向这个所有html,PHP等文件。

  1. <script type=“text/javascript“ src=“abc.js“ charset=“utf-8“></script>

  1. <script type=“text/javascript“ src=“abc.js.php“ charset=“utf-8“></script>

对于a.html文件就直接改成a.PHP访问好了,如果要保留原来的URL就 修改.htaccess 伪URL或者建立一个网页跳转吧,而其他的CSS等文本也就依此推算出该怎么改了。

压缩效能说明:jQuery库源代码为50k左右,先写代码时优化,去除空格组合函数等使其减小至26k,再使用GZIP压缩至14k!
再附一张其他网站的压缩效能比较图,图中三种方式都是GZIP,只是执行的方法不同而已。
gzip.png

分类:Other

PHP句法规则详解

2012-01-23 留下评论

1.简单句法规则(用花括号界定变量名,适用于PHP所有版本):
$a = ‘flower’;
echo “She received some $as”;
// 无效;字母s会被当成有效的变量名组成元素,但是这里的变量是$a
echo “She received some ${a}s”; // 有效
echo “She received some {$a}s”; // 有效;推荐的使用方法
我们希望表达的是”她收到一些花“,语境中的flower应该采用复数形式(也就是说应该在后面加上S),但是如果不对变量做任何界定的话,就会出现第一个echo的情况。显然我们希望输出的是$a而不是$as。那么我们通常是怎么来处理这个输出的呢?
echo “She received some $a”.”s”;
echo “She received some “.$a.”s”;
// 这两种习惯性的写法应该没有加花括号的写法简洁明了吧?
注意:不管{是出现在$前面还是后面,只有两者紧挨着时花括号才会被当成是界定符号。不要在之间加空格,要不然就会被当作普通的花括号处理
echo “She received some { $a}s”;
// 输出的结果为:She received some { flower}s
2.复杂句法规则(用花括号界定表达式等,使用与PHP4+):
echo “有效的写法: {$arr[4][3]}”;
// 有效;界定多维数组
echo “有效的写法: {$arr[‘foo’][3]}”;
// 有效;当在字符串中使用多维数组时,一定要用括号将它括起来
echo “有效的写法: {$this->width}00”;
// 有效;如果不界定的话,就会变成 $this->width00
echo “有效的写法: {$this->value[3]->name}”;
// 有效;该例演示了界定链式调用
echo “有效的写法: $name: {${$name}}”;
// 有效;该例演示的效果实际上是一个可变变量
echo “有效的写法: {${getName()}}”;
// 有效;该例演示了将函数的返回值作为变量名
echo “有效的下发: {${$this->getName()}}”;
// 有效;该例演示了将函数的返回值作为变量名
注意1:echo “这样写有效吗: {getName()}”;输出结果为:’这样写有效吗:
{getName()}’。因为里面不含$,所以花括号不会被当作界定符
注意2:echo “这样写有效吗:{$arr[foo][3]}”; 在回答这个问题前我们先来进行一个实验:
error_reporting(E_ALL);
$arr = array(‘a’, ‘b’, ‘c’, ‘d’=>’e’);
echo “This is $arr[d]”;
// 我们发现这样写是没有问题的,那么我们像下面这样写呢?
echo $arr[d];
产生了这样的错误:
Notice: Use of undefined constant d – assumed ‘d’
注意:采用了未定义的常量d,可能应该为’d’
那么如果我们像下面这样修改一下代码的话
error_reporting(E_ALL);
$arr = array(‘a’, ‘b’, ‘c’, ‘d’=>’e’);
define(‘f’, ‘d’);
echo $arr[f];
我们发现这次没有问题了。可以看出在字符串中数组的索引不加单引号是没有问题的,但是如果这种写法不是出现在字符串当中就会报错,而对于字符串中{$arr[foo][3]}的解析就是按照非字符串的方式解析的。所以说在字符串当中对数组只加花括号界定而不对索引加单引号的写法是错误的。因为程序会把不加单引号的索引当作是常量来进行解析,这就产生了错误。正确的写法应该是:
echo “有效的写法: {$arr[‘foo’][3]}”;
特别提醒一点:echo “This is $arr[d]”;这种写法虽然能够被程序解析,但这也仅限于数组是一维数组的情况。严谨的写法应该是:echo “This is {$arr[‘d’]}”;我的学生曾经在这一点上和我争论过,他说:既然前面一种写法能出结果,为什么一定要用后面一种写法呢?那么,我们再继续修改一下前面的代码
error_reporting(E_ALL);
$arr = array(‘a’, ‘b’, ‘c’,
‘d’=>array(‘e’=>’f’)
);
echo “This is $arr[d][e]”;
这样还能够被正确解析吗?我只想告诉你,加花括号是严谨的必要的。当然,如果你不是我的学生那么我管不了那么多……
注意3:
error_reporting(E_ALL);
$arr = array(‘a’, ‘b’, ‘c’, ‘d’);
echo “This is {$arr[2]}
“;
echo “This is {$arr[‘2’]}
“;
执行上面的代码。结果是一样的,为什么会这样呢?我只能告诉你PHP是弱类型语言,至于什么叫弱类型语言我就不在这里多说了。自己去Google一下吧。说了这么多,那么最能体现这些句法规则优势的具体应用在什么地方呢?—-SQL语句
// 示例一:
$SQL1 = “select * from table where id={$_GET[‘id’]}”;
// 示例二:
$SQL2 = “select * from table where id={$this->id}”;

分类:Other

Kloxo开启Gzip

2012-01-23 留下评论

原来默认的Kloxo配置里面,没有开启Gzip

Kloxo开启Gzip方法:

进入 PHP Config 里面,给 Output Compression 前面打上钩就可以了

记得重启httpd服务喔

分类:Other

Linux入门

2012-01-23 留下评论

在网上搜罗的一些资料,给自己日后部署更多VPS的时候,可以更快速的部署,省去一些麻烦

一、基础:

首先是3个比较好用的软件:

Putty http://www.putty.org/ SSH命令行,用于远程管理服务器

Filezilla http://filezilla-project.org/ 开源的FTP软件

WinSCP http://winscp.net 这个我也不知道叫啥,可以说是FTP和SSH的结合体吧,挺好用的,不过千万不要只用这个而不用Putty

然后是一系列的Linux常用命令:

目录操作:
rm -rf mydir /*删除mydir目录*/
cd mydir /*进入mydir目录*/
cd /*回上一级目录*/
cd .. /*回父目录,中间有空格*/
cd ~ /*回根目录*/
mv tools tool /*把tools目录改名为tool */
ln -s tool bac /*给tool目录创建名为bac的符号链接,最熟悉的应该就是FTP中www链接到public_html目录了*/
cp -a tool /home/vpser/www /*把tool目录下所有文件复制到www目录下 */

文件操作:
rm go.tar /* 删除go.tar文件 */
find mt.cgi /* 查找文件名为mt.cgi的文件 */
df h /* 查看磁盘剩余空间,好像没这个必要,除非你太那个了 */

解压缩:
tar xvf wordpress.tar /* 解压tar格式的文件 */
tar -tvf myfile.tar /* 查看tar文件中包含的文件 */

tar cf toole.tar tool /* 把tool目录打包为toole.tar文件 */
tar cfz vpser.tar.gz tool /* 把tool目录打包且压缩为vpser.tar.gz文件,因为.tar文件几乎是没有压缩过的,MT的.tar.gz文件解压成.tar文件后差不多是10MB */

tar jcvf /var/bak/www.tar.bz2 /var/www/ /*创建.tar.bz2文件,压缩率高*/
tar xjf http://www.tar.bz2 /*解压tar.bz2格式*/

gzip -d ge.tar.gz /* 解压.tar.gz文件为.tar文件 */
unzip phpbb.zip /* 解压zip文件,windows下要压缩出一个.tar.gz格式的文件还是有点麻烦的 */

下载:
wget http://soft.vpser.net/web/nginx/nginx-0.8.0.tar.gz
/*下载远程服务器上的文件到自己的服务器,连上传都省了,服务器不是100M就是1000M的带宽,下载一个2-3兆的MT还不是几十秒的事 */
wget -c http://soft.vpser.net/web/nginx/nginx-0.8.0.tar.gz
/* 继续下载上次未下载完的文件 */

进程管理:
ps -aux /*ps 进程状态查询命令*/

ps命令输出字段的含义:
[list]
[*]USER,进程所有者的用户名。
[*]PID,进程号,可以唯一标识该进程。
[*]%CPU,进程自最近一次刷新以来所占用的CPU时间和总时间的百分比。
[*]%MEM,进程使用内存的百分比。
[*]VSZ,进程使用的虚拟内存大小,以K为单位。
[*]RSS,进程占用的物理内存的总数量,以K为单位。
[*]TTY,进程相关的终端名。
[*]STAT,进程状态,用(R运行或准备运行;S睡眠状态;I空闲;Z冻结;D不间断睡眠;W-进程没有驻留页;T停止或跟踪。)这些字母来表示。
[*]START,进程开始运行时间。
[*]TIME,进程使用的总CPU时间。
[*]COMMAND,被执行的命令行。
[/list]

ps -aux | grep nginx /*在所有进程中,查找nginx的进程*/
kill 1234 /*1234为进程ID,即ps -aux 中的PID*/
killall nginx /*killall 通过程序的名字,直接杀死所有进程,nginx为进程名*/

Vim操作:

移动类的:
h/j/k/l: 左/下/上/右 移一格
w : 向后词移动 (前面加数字移动多少个词)
b : 向前词移动 (前面加数字移动多少个词)
e : 向后移到词末
ge : 向前移到词末
$ <End> : 行末
0 <Home> : 行首
tx : 向右查找本行的x并移到那儿(大写时向左)
33G : 移到文件的第33行
gg : 文件首行
G : 文件尾行
33% : 文件的33%处
H/M/L : 屏幕的首/中/尾行
zt/zz/zb : 当前行移到屏幕的首/中/底部

跳转:
“ : 回到跳转来的地方
CTRL-O : 跳到一个 “较老” 的地方
CTRL-I <Tab> : 则跳到一个 “较新” 的地方

查找:
/ : 向下查找(后加关键字)
? : 向上查找(后加关键字)
n : 下一条符合的记录

编辑:
i : 转换到插入模式
x : 删除当前字符
. : 重复最后一次的修改操作(同PS里ctrl+f执行滤镜)
u : 撤销操作
CTRL-R : 重做
p : 将删除的字符插入到当前位置(put)

退出保存:
:q : 退出
:q! : 不保存退出
ZZ : 保存后退出
:e! : 放弃修改重新编辑

转载自:VPS侦探 原文链接地址:http://www.vpser.net/build/linux-vps-ssh-command.html

二、Web服务器环境搭建:

# 下面是抄录 www.ctohome.com 的kloxo一键安装模块

# disable selinux 关闭防火墙
setenforce 0

# Remove exists softs 删掉默认软件
yum -y remove php mysql httpd;

# Create new soft download dir 新建文件夹并进入
mkdir -p /backup/www.ctohome.com;
cd /backup/www.ctohome.com;

# Install kloxo 下载安装kloxo
wget http://download.lxlabs.com/download/kloxo/production/kloxo-install-master.sh;
sh ./kloxo-install-master.sh;

# Install the Chinese language package 下载安装kloxo汉化模块
cd /usr/local/lxlabs/kloxo/httpdocs/lang;
wget http://www.ctohome.com/linux-vps-pack/kloxo_cn_www.ctohome.com.zip;
unzip kloxo_cn_www.ctohome.com.zip;

# Change the default charset from UTF-8 to off 修改Apache字符模块,关闭默认UTF-8限制
sed -i ‘s/UTF-8/Off/g’ /etc/httpd/conf/httpd.conf

# Install the php-mbstring for phpMyAdmin and other php scripts 安装一些附带组件
yum -y install php-mbstring php-bcmath php-mhash nmap
echo ‘extension=mbstring.so’ >> /usr/local/lxlabs/ext/php/etc/php.ini

# Change localtime to Shanghai time 修改服务器时区
rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

# Configure some services for security eg. lx,ftp,mail 编译安装安全服务组件
php /usr/local/lxlabs/kloxo/bin/common/misc/reset-mysql-root-password.phps;
cd /backup/www.ctohome.com;
wget http://www.ctohome.com/linux-vps-pack/kloxo_cn_www.ctohome.com.sql;
mysql -uroot kloxo< /backup/www.ctohome.com/kloxo_cn_www.ctohome.com.sql;

# Restart kloxo 重启kloxo
service kloxo restart

# skip-innodb and skip-bdb for mysql, if you don’t want skip them, delete this line 跳过某些MySQL模块安装,有助于减少内存消耗,但是会影响到某些程序的运行效率
sed -i “s/# Disabling symbolic-links/skip-innodb\nskip-bdb\n#Disabling symbolic-links/g” /etc/my.cnf
service mysqld restart

# Stop not necessary servces to release memory and avoid email spam: 关闭一些不必要的服务

service named stop
service qmail stop
service courier-imap stop

chkconfig named off
chkconfig qmail off
chkconfig courier-imap off

# Install unrar 安装RAR解压软件
wget http://dag.wieers.com/rpm/packages/unrar/unrar-3.6.8-1.el5.rf.i386.rpm;
rpm -Uvh unrar-3.6.8-1.el5.rf.i386.rpm;

# Check runing services and ports 检查服务器开发端口
nmap localhost

YOURIP=`hostname -i`;

至此,服务器上面的Web环境就安装完成了,LAMP平台搭建好,登录Kloxo后台地址为:http://youdomain.com:7778 默认帐号密码:admin

分类:Other

网站开启Gzip压缩的方法

2012-01-23 留下评论

网站要快除了虚拟主机需越接近自己的区域外,当然主机上也要开启一些系统功能来加速自己的网站,最常见的就是开启网页封包压缩Gzip。通常程序包内都有方便你启用的按钮,点一下就可以启用了。不过要注意的是主机本身若已经有启用,如果你再透过程序后台启用的话,很可能会相冲,造成网站出问题。因此在启用前请先利用Gzip检测工具帮自己网站检查一下吧!

网站启用了Gzip确实会替网站减肥不少,主要就是在输出时透过网站主机系统内部压缩输出大小,然后传给读取者,利用读取者端的计算机进行解压缩并读取,不然网络带宽太小,若是一直传输肥大的网页,看网页应该也会很吃力。

网站名称:网页gzip压缩检测

网站网址:http://gzip.zzbaike.com/

首先来到检测网站然后将网址输入在网页上的字段并点击提交,接着请耐心等候一下系统检测,最后画面就会秀出检测结果,从检测结果中可以很清楚的看到网页是否有开启Gzip封包压缩。如果没开启,这时你就可以赶快利用程序后端开启Gzip封包压缩,如果主机本身已经有启用了,那千万别再启用了,因为很可能会发生两者相冲,最后导致网页空白喔!

从上面可以很清楚的看到Gzip压缩后,网页大大减肥了,相信每个人看到这数字应该都想要开启这项功能吧?

不过要注意的是这种功能会加重服务器的负担,如果你的虚拟主机有限制CPU TIME,那很可能要稍微注意一下,不过压缩开过头导致网站CPU TIME冲高。当然有时候可能因为某些因素您可能启用Gzip后会造成网页空白或是出意外,或是主机不支持开启Gzip,这时请您还是关闭Gzip功能吧!

开启Gzip功能可以用插件,也可以用代码。插件网上有很多,自己可以搜搜;用代码可以利用.htaccess启动Gzip网页压缩

这方法是通过Apache的「Enabling Compression」来达到。请透过FTP软件将您的.htaccess下载回来,如果没有请用笔记本建立一个,储存时类型请选择所有档案,然后档名输入「.htaccess」即可。在.htaccess中请加入以下语法,然后储存上传覆盖即可。

<IfModule mod_deflate.c>
# Insert filters
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE image/svg+xml

# Drop problematic browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

# Make sure proxies don’t deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>

另外一个方法就是通过PHP函式的方式来启动网页压缩,但前提是您的系统必须有支持「Zlib Compression Functions」才有办法启动,您可以丢个网页探针到服务器上查询看看就知道了。语法加入方式很简单,透过FTP软件连到WordPress根目录,然后下载其中的「index.php」并使用笔记本软件开启,在「<?php」之后加入以下语法,然后上传覆盖即可。请注意,不是下载布景档案的 index.php,而是WordPress主程序。修改完后请上传覆盖掉原本的就可以了。不过这样的方式比较麻烦,当WordPress版本更新时,您必须重新加入语法。

ob_start(’ob_gzhandler’);

以上两种方法请选择一种使用,大家可以自己试试看,以上两种方法和小经验提供给大家参考。

分类:Other

MySQL 当记录不存在时插入insert if not exists

2011-12-12 留下评论

在 MySQL 中,插入(insert)一条记录很简单,但是一些特殊应用,在插入记录前,需要检查这条记录是否已经存在,只有当记录不存在时才执行插入操作,本文介绍的就是这个问题的解决方案。

问题:我创建了一个表来存放客户信息,我知道可以用 insert 语句插入信息到表中,但是怎么样才能保证不会插入重复的记录呢?

答案:可以通过使用 EXISTS 条件句防止插入重复记录。

示例一:插入多条记录

假设有一个主键为 client_id 的 clients 表,可以使用下面的语句:

Code:

INSERT INTO clients
(client_id, client_name, client_type)
SELECT supplier_id, supplier_name, ‘advertising’
FROM suppliers
WHERE not exists (select * from clients
where clients.client_id = suppliers.supplier_id);

示例一:插入单条记录

Code:

INSERT INTO clients
(client_id, client_name, client_type)
SELECT 10345, ‘IBM’, ‘advertising’
FROM dual
WHERE not exists (select * from clients
where clients.client_id = 10345);

使用 dual 做表名可以让你在 select 语句后面直接跟上要插入字段的值,即使这些值还不存在当前表中。

分类:Other

Robots.txt 知识汇总

2011-11-19 留下评论

robots.txt文件是seo中不可忽略的一个细节,他的作用非常之大,最近在研究细节,搜了相关Robots.txt的文章记录下

一、定义:
robots.txt 是存放在站点根目录下的一个纯文本文件,让搜索蜘蛛读取的txt文件,文件名必须是小写的”robots.txt”。
二、作用:
通过robots.txt可以控制SE收录内容,告诉蜘蛛哪些文件和目录可以收录,哪些不可以收录。
三、语法:
User-agent:搜索引擎的蜘蛛名
Disallow:禁止搜的内容
Allow:允许搜的内容
四、实例:
1.User-agent: * //禁止所有搜索引擎搜目录1、目录2、目录3
Disallow: /目录名1/
Disallow: /目录名2/
Disallow: /目录名3/
2.
User-agent: Baiduspider //禁止百度搜索secret目录下的内容
Disallow: /secret/
3.
User-agent: * //禁止所有搜索引擎搜索cgi目录,但是允许slurp搜索所有
Disallow: /cgi/
User-agent: slurp
Disallow:
4. User-agent: * //禁止所有搜索引擎搜索haha目录,但是允许搜索haha目录下test目录
Disallow: /haha/
Allow:/haha/test/
五、常见搜索引擎蜘蛛的代码
#搜索引擎User-Agent代码对照表########################
# 搜索引擎 User-Agent代码
# AltaVista Scooter
# Infoseek Infoseek
# Hotbot Slurp
# AOL Search Slurp
# Excite ArchitextSpider
# Google Googlebot
# Goto Slurp
# Lycos Lycos

分类:Other

PHP 限制HTML内容中的图片必须是本站的

2011-11-13 留下评论

当用户发帖或者写博客的时候,使用的所见即所得的编辑器允许用户插入图片,服务器接收到这个内容后对 html 进行检查,只允许是站内的图片,否则不予显示

php

<?php
$dom = new DOMDocument;
$dom->loadHTML(file_get_contents(‘input.html’));
$xpath = new DOMXpath($dom);
$img = $xpath->query(‘//img’);
foreach($img as $i) {
$url = parse_url($i->getAttribute(‘src’));
if(isset($url[‘host’]) && in_array($url[‘host’], array(‘yourdomain.com’, ‘www.yourdomain.com’)) == false) {
// show an error
//

分类:Other

swfupload 批量上传源码

2011-11-13 留下评论

win下的提升用户体验的图片批量上传处理 基于swfupload的上传工具

//首先 准备 swfupload 包
//前端用户体验页面
<!DOCTYPE html>
<html>
<head>
<title>SWFUpload Demos – Application Demo</title>
<link href=”./default.css” rel=”stylesheet” type=”text/css” />
<script type=”text/javascript” src=”./swfupload/swfupload.js”></script>
<script type=”text/javascript” src=”./swfupload/jquery-1.4.js”></script>
<script type=”text/javascript” src=”js/handlers.js”></script>
<script type=”text/javascript”>
$(function(){
$(‘#btn’).bind(‘click’,path);
});
function path()
{
var url=”;
$(‘#thumbnails img’).each(function(){
url=$(this).attr(‘id’)+'{#@T@#}’+url;
})
alert(url);
}
var swfu;
window.onload = function () {
swfu = new SWFUpload({
// Backend Settings
upload_url: “upload.php”,
post_params: {“PHPSESSID”: “<?php echo session_id(); ?>”},
// File Upload Settings
file_size_limit : “800”, // 2MB 最大容量限制
file_types : “*.jpg”,
file_types_description : “JPG Images”,
file_upload_limit : 5,//上传数量限制
// Event Handler Settings – these functions as defined in Handlers.js
// The handlers are not part of SWFUpload but are part of my website and control how
// my website reacts to the SWFUpload events.
swfupload_preload_handler : preLoad,
swfupload_load_failed_handler : loadFailed,
file_queue_error_handler : fileQueueError,
file_dialog_complete_handler : fileDialogComplete,
upload_progress_handler : uploadProgress,
upload_error_handler : uploadError,
upload_success_handler : uploadSuccess,
upload_complete_handler : uploadComplete,
// Button Settings
button_image_url : “images/SmallSpyGlassWithTransperancy_17x18.png”,
button_placeholder_id : “spanButtonPlaceholder”,
button_width: 200,
button_height: 18,
button_text : ‘<span class=”button”>Select Images <span class=”buttonSmall”>(800 k Max)[*.jpeg]</span></span>’,
button_text_style : ‘.button { font-family: Helvetica, Arial, sans-serif; font-size: 12pt; } .buttonSmall { font-size: 10pt; }’,
button_text_top_padding: 0,
button_text_left_padding: 18,
button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
button_cursor: SWFUpload.CURSOR.HAND,

// Flash Settings
flash_url : “./swfupload/swfupload.swf”,
flash9_url : “./swfupload/swfupload_FP9.swf”,
custom_settings : {
upload_target : “divFileProgressContainer”
},

// Debug Settings
debug: false
});
};
</script>
</head>
<body>
<h2>最多上传5张图片<h2>
<form>
<div style=”width: 200px; height: 18px; border: solid 1px #7FAAFF; background-color: #C5D9FF; padding: 2px;”>
<span id=”spanButtonPlaceholder”></span>
</div>
</form>
<div id=”divFileProgressContainer” style=”height: 75px;”></div>
<div id=”thumbnails” style=’width:500px;border:1px solid lime;padding-left:20px’></div>
</div>
<button id=’btn’>提交</button>
</body>
</html>
//后台处理页面 upload.php
<?php

if (isset($_POST[“PHPSESSID”])) {
session_id($_POST[“PHPSESSID”]);
}
session_start();
ini_set(“html_errors”, “0”);
// Check the upload
if (!isset($_FILES[“Filedata”]) || !is_uploaded_file($_FILES[“Filedata”][“tmp_name”]) || $_FILES[“Filedata”][“error”] != 0) {
echo “ERROR:invalid upload”;
exit(0);
}
// Get the image and create a thumbnail
$img = imagecreatefromjpeg($_FILES[“Filedata”][“tmp_name”]);
if (!$img) {
echo “ERROR:could not create image handle “. $_FILES[“Filedata”][“tmp_name”];
exit(0);
}
$width = imageSX($img);
$height = imageSY($img);
if (!$width || !$height) {
echo “ERROR:Invalid width or height”;
exit(0);
}
// Build the thumbnail
$target_width = 100;
$target_height = 100;
$target_ratio = $target_width / $target_height;
$img_ratio = $width / $height;
if ($target_ratio > $img_ratio) {
$new_height = $target_height;
$new_width = $img_ratio * $target_height;
} else {
$new_height = $target_width / $img_ratio;
$new_width = $target_width;
}
if ($new_height > $target_height) {
$new_height = $target_height;
}
if ($new_width > $target_width) {
$new_height = $target_width;
}
$new_img = ImageCreateTrueColor(100, 100);
if (!, 0, 0, $target_width-1, $target_height-1, 0)) { // Fill the image black
echo “ERROR:Could not fill new image”;
exit(0);
}
if (!, $img, ($target_width-$new_width)/2, ($target_height-$new_height)/2, 0, 0, $new_width, $new_height, $width, $height)) {
echo “ERROR:Could not resize image”;
exit(0);
}
if (!isset($_SESSION[“file_info”])) {
$_SESSION[“file_info”] = array();
}
// Use a output buffering to load the image into a variable
ob_start();
imagejpeg($new_img);
$imagevariable = ob_get_contents();
ob_end_clean();
$file_id = md5($_FILES[“Filedata”][“tmp_name”] + rand()*100000);
$_SESSION[“file_info”][$file_id] = $imagevariable;
//上传图片处理
if(!is_dir(“uploadimage”))
{
mkdir(“uploadimage”);
}
$pre_fix=md5(‘120ask120’);
move_uploaded_file($_FILES[“Filedata”][“tmp_name”],trim(“./uploadimage/”.$pre_fix.$file_id.”.jpg”));
/*图片处理结束*/
echo “FILEID:” . $file_id; // Return the file id to the script

?>

分类:Other

CSS:解决跨浏览器兼容性

2011-11-13 留下评论

**** Selector Hacks ******/

/* IE6 and below */
* html #uno { color: red }

/* IE7 */
*:first-child+html #dos { color: red }

/* IE7, FF, Saf, Opera */
html>body #tres { color: red }

/* IE8, FF, Saf, Opera (Everything but IE 6,7) */
html>/**/body #cuatro { color: red }

/* Opera 9.27 and below, safari 2 */
html:first-child #cinco { color: red }

/* Safari 2-3 */
html[xmlns*=””] body:last-child #seis { color: red }

/* safari 3+, chrome 1+, opera9+, ff 3.5+ */
body:nth-of-type(1) #siete { color: red }

/* safari 3+, chrome 1+, opera9+, ff 3.5+ */
body:first-of-type #ocho { color: red }

/* saf3+, chrome1+ */
@media screen and (-webkit-min-device-pixel-ratio:0) {
#diez { color: red }
}

/* iPhone / mobile webkit */
@media screen and (max-device-width: 480px) {
#veintiseis { color: red }
}

/* Safari 2 – 3.1 */
html[xmlns*=””]:root #trece { color: red }

/* Safari 2 – 3.1, Opera 9.25 */
*|html[xmlns*=””] #catorce { color: red }

/* Everything but IE6-8 */
:root *> #quince { color: red }

/* IE7 */
*+html #dieciocho { color: red }

/* Firefox only. 1+ */
#veinticuatro, x:-moz-any-link { color: red }

/* Firefox 3.0+ */
#veinticinco, x:-moz-any-link, x:default { color: red }

/***** Attribute Hacks ******/

/* IE6 */
#once { _color: blue }

/* IE6, IE7 */
#doce { *color: blue; /* or #color: blue */ }

/* Everything but IE6 */
#diecisiete { color/**/: blue }

/* IE6, IE7, IE8 */
#diecinueve { color: blue\9; }

/* IE7, IE8 */
#veinte { color/*\**/: blue\9; }

/* IE6, IE7 — acts as an !important */
#veintesiete { color: blue !ie; } /* string after ! can be anything */

分类:Other

CSS跨浏览器透明度 & 跨浏览器最小高度

2011-11-13 留下评论

CSS跨浏览器透明度
selector {
filter: alpha(opacity=50); /* internet explorer */
-khtml-opacity: 0.5; /* khtml, old safari */
-moz-opacity: 0.5; /* mozilla, netscape */
opacity: 0.5; /* fx, safari, opera */
}

跨浏览器最小高度 #div {
min-height : 500px ;
height : auto !important ;
height : 500px ;
}

分类:Other

最简单的xml2array

2011-11-13 留下评论

$xml = simplexml_load_string($result);
$_result = json_decode(json_encode($xml), true);

or

$xml = simplexml_load_string($result);
$_result = (array)$xml->children();

分类:Other

配置文件操作.如config.php文件的读取修改等操作

2011-11-13 留下评论

对形如config.php文件的读取,修改等操作
<?php
$name=”admin”;//kkkk
$bb=’234′;
$db=4561321;
$kkk=”admin”;
?>

函数定义:
配置文件数据值获取:function getconfig($file, $ini, $type=”string”)
配置文件数据项更新:function updateconfig($file, $ini, $value,$type=”string”)

调用方式:
getconfig(“./2.php”, “bb”);//
updateconfig(“./2.php”, “kkk”, “admin”);

<?php
//配置文件数据值获取。
//默认没有第三个参数时,按照字符串读取提取”中或””中的内容
//如果有第三个参数时为int时按照数字int处理。
function getconfig($file, $ini, $type=”string”)
{
if ($type==”int”)
{
$str = file_get_contents($file);
$config = preg_match(“/” . $ini . “=(.*);/”, $str, $res);
Return $res[1];
}
else
{
$str = file_get_contents($file);
$config = preg_match(“/” . $ini . “=\”(.*)\”;/”, $str, $res);
if($res[1]==null)
{
$config = preg_match(“/” . $ini . “='(.*)’;/”, $str, $res);
}
Return $res[1];
}
}
//配置文件数据项更新
//默认没有第四个参数时,按照字符串读取提取”中或””中的内容
//如果有第四个参数时为int时按照数字int处理。
function updateconfig($file, $ini, $value,$type=”string”)
{
$str = file_get_contents($file);
$str2=””;
if($type==”int”)
{
$str2 = preg_replace(“/” . $ini . “=(.*);/”, $ini . “=” . $value . “;”, $str);
}
else
{
$str2 = preg_replace(“/” . $ini . “=(.*);/”, $ini . “=\”” . $value . “\”;”, $str);
}
file_put_contents($file, $str2);
}

//echo getconfig(“./2.php”, “bb”, “string”);
getconfig(“./2.php”, “bb”);//
updateconfig(“./2.php”, “kkk”, “admin”);
//echo “<br/>”.getconfig(“./2.php”, “name”,”string”);
?>

分类:Other

PHP通用alert函数

2011-11-13 留下评论

//函数:通用提示
//参数:提示息,型或址,窗口名或函得延时毫秒Alert(“”,”function”,”close2″,300);

//函数:通用提示
//参数:提示息,型或址,窗口名或函得延时毫秒Alert(“”,”function”,”close2″,300);
Function Alert($Str,$Typ=”back”,$TopWindow=””,$Tim=100){
Echo “<script>”.Chr(10);
If(!Empty($Str)){
Echo “alert(\”Warning:\\n\\n{$Str}\\n\\n\”);”.Chr(10);
}

Echo “function _r_r_(){“;
$WinName=(!Empty($TopWindow))?”top”:”self”;
Switch (StrToLower($Typ)){
Case “#”:
Break;
Case “back”:
Echo $WinName.”.history.go(-1);”.Chr(10);
Break;
Case “reload”:
Echo $WinName.”.window.location.reload();”.Chr(10);
Break;
Case “close”:
Echo “window.opener=null;window.close();”.Chr(10);
Break;
Case “function”:
Echo “var _T=new Function(‘return {$TopWindow}’)();_T();”.Chr(10);
Break;
//Die();
Default:
If($Typ!=””){
//Echo “window.{$WinName}.location.href='{$Typ}’;”;
Echo “window.{$WinName}.location=(‘{$Typ}’);”;
}
}

Echo “}”.Chr(10);

//榉乐irefox不绦etTimeout
Echo “if(setTimeout(\”_r_r_()\”,”.$Tim.”)==2){_r_r_();}”;
IF($Tim==100){
Echo “_r_r_();”.Chr(10);
}Else{
Echo “setTimeout(\”_r_r_()\”,”.$Tim.”);”.Chr(10);
}
Echo “</script>”.Chr(10);
Exit();
}

分类:Other

php文件分割组合源代码

2011-11-13 留下评论

<?php
$orgFile = ‘VirtualBox.exe’;
$cacheFileName = ‘vbcache’;

cutFile($orgFile, 10 * pow(2,20)); //10 * pow(2,20) 就等于 10M
mergeFile(‘cache2vb.exe’);

function cutFile($fileName,$block) {
global $cacheFileName;

if (!file_exists($fileName)) return false;

$num = 1;
$file = fopen($fileName, ‘rb’);
while ($content = fread($file,$block)) {
$cacheFile = $cacheFileName . $num++ . ‘.dat’;
$cfile = fopen($cacheFile, ‘wb’);
fwrite($cfile, $content);
fclose($cfile);
}
fclose($file);
}

function mergeFile($targetFile) {
global $cacheFileName;

$num = 1;
$file = fopen($targetFile, ‘wb’);
while ($num > 0) {
$cacheFile = $cacheFileName . $num++ . ‘.dat’;
if (file_exists($cacheFile)) {
$cfile = fopen($cacheFile, ‘rb’);
$content = fread($cfile, filesize($cacheFile));
fclose($cfile);
fwrite($file, $content);
} else {
$num = -1;
}
}
fclose($file);
}

分类:Other

JavaScript Cookie操作

2011-11-13 留下评论

function setCookie(NameOfCookie, value, expiredays)
{
var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
document.cookie = NameOfCookie + “=” + escape(value) +
((expiredays == null) ? “” : “; expires=” + ExpireDate.toGMTString());
}

function getCookie(NameOfCookie)
{
if (document.cookie.length > 0)
{
begin = document.cookie.indexOf(NameOfCookie+”=”);
if (begin != -1)
{
begin += NameOfCookie.length+1;//cookie值的初始位置
end = document.cookie.indexOf(“;”, begin);//结束位置
if (end == -1) end = document.cookie.length;//没有;则end为字符串结束位置
document.write(document.cookie.substring(begin, end));
return unescape(document.cookie.substring(begin, end));
}
}
return null;
}

function delCookie (NameOfCookie)
{
if (getCookie(NameOfCookie))
{
document.cookie = NameOfCookie+”=”+”;expires=Thu, 01-Jan-70 00:00:01 GMT”;
}
}

分类:Other

php cookie加密

2011-11-13 留下评论

<?php
class Cookie
{
/**
* 解密已经加密了的cookie
*
* @param string $encryptedText
* @return string
*/
private static function _decrypt($encryptedText)
{
$key = Config::get(‘secret_key’);
$cryptText = base64_decode($encryptedText);
$ivSize = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($ivSize, MCRYPT_RAND);
$decryptText = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $cryptText, MCRYPT_MODE_ECB, $iv);
return trim($decryptText);
}

/**
* 加密cookie
*
* @param string $plainText
* @return string
*/
private static function _encrypt($plainText)
{
$key = Config::get(‘secret_key’);
$ivSize = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
$iv = mcrypt_create_iv($ivSize, MCRYPT_RAND);
$encryptText = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $plainText, MCRYPT_MODE_ECB, $iv);
return trim(base64_encode($encryptText));
}

/**
* 删除cookie
*
* @param array $args
* @return boolean
*/
public static function del($args)
{
$name = $args[‘name’];
$domain = isset($args[‘domain’]) ? $args[‘domain’] : null;
return isset($_COOKIE[$name]) ? setcookie($name, ”, time() – 86400, ‘/’, $domain) : true;
}

/**
* 得到指定cookie的值
*
* @param string $name
*/
public static function get($name)
{
return isset($_COOKIE[$name]) ? self::_decrypt($_COOKIE[$name]) : null;
}

/**
* 设置cookie
*
* @param array $args
* @return boolean
*/
public static function set($args)
{
$name = $args[‘name’];
$value= self::_encrypt($args[‘value’]);
$expire = isset($args[‘expire’]) ? $args[‘expire’] : null;
$path = isset($args[‘path’]) ? $args[‘path’] : ‘/’;
$domain = isset($args[‘domain’]) ? $args[‘domain’] : null;
$secure = isset($args[‘secure’]) ? $args[‘secure’] : 0;
return setcookie($name, $value, $expire, $path, $domain, $secure);
}
}

分类:Other

PHP利用shell后台运行PHP脚本,并获取该脚本的Process ID

2011-11-13 留下评论

$command = ‘/usr/bin/php /pub/www/u111/job/Crondo/auto_collector.php &’;
$process = proc_open($command, array(),$pipes);
$var = proc_get_status($process);
proc_close($process);

//pid就是进程ID,至于为什么要加1,我现在也没有搞懂,经过多次的测试,发现$var[‘pid’]得到的ID比实际的少1
$pid = intval($var[‘pid’])+1;

//杀死进程
proc_close(proc_open(‘kill -9 ‘.$pid, array(), $pipes));

分类:Other

PHP将相对路径URL转换为绝对路径URL

2011-11-13 留下评论

在采集程序或者蜘蛛程序中经常会遇到一类问题,就是将网页中相对路径形式的URL转换为绝对路径形式的URL。例如在http://www.msphome.cn/blog/1/这个页面中,有一个URL链接为../index.php,那么我们要将它转换为http://www.msphome.cn/blog /index.php。下面给出了解决这类问题的代码。该程序能够成功处理各种URL,将其变成绝对形式。

方法一:

<?php
/**
* 将一个URL转换为完整URL
*
*/
function format_url($srcurl, $baseurl) {
$srcinfo = parse_url($srcurl);
if(isset($srcinfo[‘scheme’])) {
return $srcurl;
}
$baseinfo = parse_url($baseurl);
$url = $baseinfo[‘scheme’].’://’.$baseinfo[‘host’];
if(substr($srcinfo[‘path’], 0, 1) == ‘/’) {
$path = $srcinfo[‘path’];
}else{
$path = dirname($baseinfo[‘path’]).’/’.$srcinfo[‘path’];
}
$rst = array();
$path_array = explode(‘/’, $path);
if(!$path_array[0]) {
$rst[] = ”;
}
foreach ($path_array AS $key => $dir) {
if ($dir == ‘..’) {
if (end($rst) == ‘..’) {
$rst[] = ‘..’;
}elseif(!array_pop($rst)) {
$rst[] = ‘..’;
}
}elseif($dir && $dir != ‘.’) {
$rst[] = $dir;
}
}
if(!end($path_array)) {
$rst[] = ”;
}
$url .= implode(‘/’, $rst);
return str_replace(‘\\’, ‘/’, $url);
}

$srcurl = ‘/guestbook.php’;
$baseurl = ‘http://www.msphome.cn/index.php/ddd.html‘;
echo format_url($srcurl, $baseurl);

?>

方法二

//相对路径转化成绝对路径
<?
function relative_to_absolute($content, $feed_url) {
preg_match(‘/(http|https|ftp):///’, $feed_url, $protocol);
$server_url = preg_replace(“/(http|https|ftp|news):///”, “”, $feed_url);
$server_url = preg_replace(“//.*/”, “”, $server_url);
if ($server_url == ”) {
return $content;
}
if (isset($protocol[0])) {
$new_content = preg_replace(‘/href=”//’, ‘href=”‘.$protocol[0].$server_url.’/’, $content);
$new_content = preg_replace(‘/src=”//’, ‘src=”‘.$protocol[0].$server_url.’/’, $new_content); //开源OSPhP.COM.CN
} else {
$new_content = $content;
}
return $new_content;
}
?>

分类:Other

PHP获取远程web服务器时间的代码

2011-11-13 留下评论

<?php
function get_time($server){
$data = “HEAD / HTTP/1.1\r\n”;
$data .= “Host: $server\r\n”;
$data .= “Connection: Close\r\n\r\n”;
$fp = fsockopen($server, 80);
fputs($fp, $data);
$resp = ”;
while ($fp && !feof($fp))
$resp .= fread($fp, 1024);
preg_match(‘/^Date: (.*)$/mi’,$resp,$matches);
return strtotime($matches[1]);
}
echo date(‘Y-m-d H:i:s’,get_time(“www.163.com“));
?>

分类:Other

根据用户时区显示当地时间 javascript+php

2011-11-13 留下评论

在跨时区应用中会用到下面代码,这是以前写的一段代码。

服务器保存相关时间配置,保存形式为GMT时间,客户端需要根据客户所在时区做相应显示,以符合客户习惯。

JavaScript代码

window.onload = function() {
//TODO begin 处理登陆用户时区
//获得登陆用户时区与GMT时区的差值
var exp = new Date();
var gmtHours = -(exp.getTimezoneOffset()/60);
setCookie(‘customer_timezone’,gmtHours,1);
//判断是否为夏令时
date = exp.format(‘yyyy-MM-dd HH:mm:ss’);
if(inDaylightTime(date)){
setCookie(‘inDaylightTime’,1,1);
}
}
//设置Cookie
function setCookie(c_name,value,expiredays){
var exdate=new Date()
exdate.setDate(exdate.getDate()+expiredays)
document.cookie=c_name+ “=” +escape(value)+
((expiredays==null) ? “” : “; expires=”+exdate.toGMTString())
}
//判断时间是东半球还是西半球
function isEastEarthTime(newDate)
{
var dj= newDate.getGMTOffset(false);
if (dj.indexOf(“-“) == -1){
return true;
} else {
return false;
}
}
//是否是夏令时
function inDaylightTime(date){
var start = new Date(date.getTime());
start.setMonth(0);
start.setDate(1);
start.setHours(0);
start.setMinutes(0);
start.setSeconds(0);
var middle = new Date(start.getTime());
middle.setMonth(6);
// 如果年始和年中时差相同,则认为此国家没有夏令时
if ((middle.getTimezoneOffset() – start.getTimezoneOffset()) == 0) {
return false;
}

var margin = 0;
if (this.isEastEarthTime(date)) {
margin = middle.getTimezoneOffset();
} else {
margin = start.getTimezoneOffset();
}
if (date.getTimezoneOffset() == margin) {
return true;
}
return false;
}
//DONE end

服务器端php代码

//24小时内 GMT到本地时间的转换
function gmt_to_local($time = ”, $dst = FALSE){
//JavaScript设置Cookie,PHP取值
if (isset($_COOKIE[“customer_timezone”])){
$timezone = $_COOKIE[“customer_timezone”];
}else{
$timezone = 0;
}
if ($time == ”){
return now();
}
//时间处理
$time += $timezone * 3600;

//是否为夏令时
if(isset($_COOKIE[“inDaylightTime”]) && $_COOKIE[“inDaylightTime”] == 1){
$dst = TRUE;
}

if ($dst == TRUE){
$time += 3600;
}
return date(“H:i”,$time);
}

分类:Other

最新CSS兼容方案

2011-11-13 留下评论

浏览器在不断更新,可使用的hack也需要更新下了,继上一篇《 最新CSS兼容方案 》之后,Opera和Safari都已经更新了版本,IE8也出来了,还有一个Chrome。新版本的Opera 9.6 和Safari 3.2.3分别有一个hack不能使用了,具体为:

Opear:

*+html .e{
background-color:#0000FF;/* OP */
}

Safai:

@media all and (min-width:0){ select{ … }}

还好发现了另一个Safari可以用的hack,Chrome和Safari的hack一样,还无法单独区分。另外“[; …
]”中的内容只有Opera读不到,注意“[]”要成对出现,不然Opera下会导致后面的样式无法读取。重新整理的hack如下:

.e{
color:#FFF;/* FF,OP,IE8 */
[;color:#0F0;]/* SF,CH */
*color:#FF0;/* IE7 */
_color:#F00;/* IE6 */
}
.e{
background-color:#332200;/* FF*/
}
html* .e{
background-color:#FF00FF;/* Sa IE7 CH */
}
*+html .e{
*background-color:#0000FF;/* IE7 */
}
* html .e{
background-color:#00FFFF;/* IE6 */
}
html*~/**/body .e{
background-color:#055000;/* IE8 */
}
@media all and(min-width:0){
.e{
background-color:#FF5500;/* OP */
}
}经FF3、OP9.64、OP9.5.0、Sa3.2.3(pc)、Ch1.0.154.65、Ch2.0.172.28、IE7、IE6、IE8测试通过

分类:Other