Skip to content

Instantly share code, notes, and snippets.

<script>
function isEmail(strEmail)
{
if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
return false;
else
return true;
}
function isMobel(value)
{
@zsmynl
zsmynl / gist:ad3084fec08aa8568365
Created August 12, 2014 09:00
我发誓要做一个好用的在线编辑器,真的,我不骗你!!!
我发誓要做一个好用的在线编辑器,真的,我不骗你!!!
@zsmynl
zsmynl / .htaccess
Created February 25, 2014 07:59
重定向学习;
[ISAPI_Rewrite] / RewriteEngine on
RewriteRule ^/(login|register|user)$ /index.php?do=$1 [L]
#register
RewriteRule ^/register/(.*?)$ /index.php?do=register&key=$1 [L]
RewriteRule ^/register-validate/(.*?)$ /index.php?do=register&act=validate&key=$1 [L]
#for Nginx
rewrite ^/(login|register|user)$ /index.php?do=$1 last;
rewrite ^/register/(.*?)$ /index.php?do=register&key=$1 last;
@zsmynl
zsmynl / localimg.php
Created February 24, 2014 09:53
php图片采集后按原路径保存图片
<?php
$domain ='http://www.xxxx.com';
$url = '/newskin/images/v4/logo.jpg';
$pats = pathinfo($url);
$dir = '.'.$pats['dirname'].'/';
if(!is_dir($dir))
{
@mkdirs($dir, 0777);
@fclose(fopen($dir.'/index.htm', 'w'));
}
@zsmynl
zsmynl / .htaccess
Created February 22, 2014 11:22
记一次htaccess伪静态
RewriteEngine on
RewriteRule ^discover$ index.php?do=discover
RewriteRule ^content/([a-zA-Z0-9_-]+)$ index.php?do=content&workid=$1
RewriteRule ^discover/([a-zA-Z0-9_-]+)$ index.php?do=discover&id=$1
RewriteRule ^content/([a-zA-Z0-9_-]+)/id/([a-zA-Z0-9_-]+)$ index.php?do=content&workid=$1&contentId=$2
RewriteRule ^home/([a-zA-Z0-9_-]+)$ index.php?do=home&id=$1
RewriteRule ^works/([a-zA-Z0-9_-]+)$ index.php?do=home&act=works&id=$1
@zsmynl
zsmynl / randomkeys.php
Created February 14, 2014 03:50
php简单的声称随机字符串/
<?php
/* 生成随机字母与数字混合验证码 */
function randomkeys($length) {
$returnStr='';
$pattern='23456789abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ';
for($i=0;$i<$length;$i ++) {
$returnStr.=$pattern{mt_rand(0,strlen($pattern)-1)}; //生成php随机数
}
return $returnStr;
}
@zsmynl
zsmynl / localStorage.js
Created February 10, 2014 08:39
使用localStorage保存页面内容。
/* 保存填写内容 begin */
<script type="text/javascript">
function saveMyContent(){
if(window.localStorage){
var items=["bugtitle","description","editor_content","editor_content1","editor_content2","usertags"];
$.each(items,function(k,v){
var inputValue=$("#"+v).val();
if (inputValue==null ||inputValue==""){
inputValue="";
}else{
@zsmynl
zsmynl / curl_post.php
Created February 7, 2014 21:50
php使用curl进行post数据;
<?php
function request($url,$data='',$headers=array()) {
if(empty($headers['UserAgent'])) $headers['UserAgent']='Mozilla/5.0';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
if($data){
curl_setopt($ch, CURLOPT_POST, 1);
@zsmynl
zsmynl / test.php
Created February 6, 2014 20:25
调试服务器环境常用测试
<?php
error_reporting(E_ALL);
$con=mysql_connect('localhost','root','')or die('数据库连接失败');
$db=mysql_select_db('test',$con);
$sql="SELECT name FROM user";
$query=mysql_query($sql,$con);
while ($row=mysql_fetch_assoc($query)) {
$list[]=$row;
}
foreach ($list as $k => $v) {
@zsmynl
zsmynl / wrap.php
Created January 20, 2014 10:26
php过滤换行符的方法;
<?php
//php 不同系统的换行
//不同系统之间换行的实现是不一样的
//linux 与unix中用 /n
//MAC 用 /r
//window 为了体现与linux不同 则是 /r/n
//所以在不同平台上 实现方法就不一样
//php 有三种方法来解决
//1、使用str_replace 来替换换行