通过JS打开图片另存为对话框,提示用户保存文件<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title> New Document </title> <……继续阅读 » 水墨上仙 5年前 (2021-03-12) 2918浏览 457个赞
JavaScript判断浏览器的类型var request = false;var btype=getinternet(); function getinternet() { if(navigator.useragent.indexof("msie")>0) { ret……继续阅读 » 水墨上仙 5年前 (2021-03-12) 3414浏览 2357个赞
node.js log模块日期格式化 在node.js开发过程中使用了npm install log默认下载的模块,日期时间很不符合习惯。[Tue Dec 25 2012 21……继续阅读 » 水墨上仙 5年前 (2021-03-12) 1909浏览 1410个赞
本代码首先通过head进行301转向,如果失败,则通过http-equiv=”Refresh”转向,如果不行再通过js进行转向,再不行直接在页面上输出链接地址让用户自己点击链接转向function safe_redirect($url, $exit=true) { // Only use the header red……继续阅读 » 水墨上仙 5年前 (2021-03-12) 1478浏览 2528个赞
javascript获取当前鼠标的坐标位置<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ht……继续阅读 » 水墨上仙 5年前 (2021-03-12) 3229浏览 909个赞
一个伦敦奥运会倒计时的JS代码,简单的修改一下就可以用作其它倒计时<SCRIPT LANGUAGE="JavaScript"> //作者:www.tongqiong.com<!-- var urodz= new Date("July 28,2012"); var s="伦敦奥……继续阅读 » 水墨上仙 5年前 (2021-03-12) 1430浏览 1691个赞
JS解析json数据并将json字符串转化为数组的实现方法,json数据在ajax实现异步交互时起到了很重要的作用,他可以返回请求的数据,然后利用客户端的js进行解析,这一点体现出js的强大,本文介绍JS解析json数据并将json字符串转化为数组的实现方法。<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML……继续阅读 » 水墨上仙 5年前 (2021-03-12) 2478浏览 2146个赞
html5 canvas制作的简单时钟效果<html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <style type="text/css&……继续阅读 » 水墨上仙 5年前 (2021-03-12) 1880浏览 912个赞
JS redirect转向方法<script type="text/javascript"><!-- window.location = "http://www.google.com/"//--></script>……继续阅读 » 水墨上仙 5年前 (2021-03-12) 3762浏览 361个赞
jquery限制textarea的字数长度并显示已输入字符长度<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">……继续阅读 » 水墨上仙 5年前 (2021-03-12) 3402浏览 616个赞
Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'a' available at org.springframework.beans.factory……继续阅读 » 开心洋葱 5年前 (2021-03-12) 2162浏览 0评论243个赞
修改一下第二行的url地址即可获得你想要的网页的html代码<?php // display source code $lines = file('http://google.com/'); foreach ($lines as $line_num => $line) { // loop thru e……继续阅读 » 水墨上仙 5年前 (2021-03-10) 1575浏览 0评论1607个赞
php版快速排序代码function quicksort($seq){ if(!count($seq)) return $seq; $k = $seq[0]; $x = $y = array(); for($i=count($seq); --$i;) { if($seq[$i] <= $k) { $x[] = $……继续阅读 » 水墨上仙 5年前 (2021-03-10) 1678浏览 0评论1608个赞
jQuery读写操作cookie的代码演示,可以对cookie进行读写操作,可以设置域名和过期时间 插件代码/*! * jQuery Cookie Plugin v1.3 * https://github.com/carhartl/jquery-cookie * * Cop……继续阅读 » 水墨上仙 5年前 (2021-03-10) 3377浏览 0评论2083个赞
这段代码可以帮助你判断任意图片的主色调,使用了简单的统计算法实现$i = imagecreatefromjpeg("image.jpg"); for ($x=0;$x<imagesx($i);$x++) { for ($y=0;$y<imagesy($i);$y++) { $rg……继续阅读 » 水墨上仙 5年前 (2021-03-10) 2439浏览 0评论1021个赞
需要判断代码运行环境是否是HTTPS服务器,只需要判断_SERVER[‘HTTPS’]是否打开即可if ($_SERVER['HTTPS'] != "on") { echo "This is not HTTPS"; }else{ echo &……继续阅读 » 水墨上仙 5年前 (2021-03-10) 2363浏览 0评论946个赞
php实现二分查找算法// $low and $high have to be integersfunction BinarySearch( $array, $key, $low, $high ){ if( $low > $high ) // termination case { return -1; ……继续阅读 » 水墨上仙 5年前 (2021-03-10) 3348浏览 0评论2326个赞
php检查日期是否合法function check_date($date) { //检查日期是否合法日期 $dateArr = explode("-", $date); if (is_numeric($dateArr[0]) && is_numeric($dateArr[1]) &&……继续阅读 » 水墨上仙 5年前 (2021-03-10) 2489浏览 0评论1311个赞
php自己实现memcached的队列类<?php/* * memcache队列类 * 支持多进程并发写入、读取 * 边写边读,AB面轮值替换 * @author lkk/lianq.net * @create on 9:25 2012-9-28 * * * @example: * $obj = new memcacheQu……继续阅读 » 水墨上仙 5年前 (2021-03-10) 1506浏览 0评论624个赞
php无限分类获得当前位置的函数<?php/* * @name pcb_article_position * @access public * @param int $id * @param string $split * @return string */function pcb_article_position ……继续阅读 » 水墨上仙 5年前 (2021-03-10) 2033浏览 0评论352个赞
php获取访问者浏览器<? function browse_infor() { $browser="";$browserver=""; $Browsers =array("Lynx","MOSAIC","AOL","Opera&q……继续阅读 » 水墨上仙 5年前 (2021-03-10) 2823浏览 0评论722个赞
php检查时间是否合法function check_time($time) { //检查时间是否合法时间 $timeArr = explode(":", $time); if (is_numeric($timeArr[0]) && is_numeric($timeArr[1]) &&am……继续阅读 » 水墨上仙 5年前 (2021-03-10) 2690浏览 0评论793个赞
php时间比较函数,返回两个日期相差几秒、几分钟、几小时或几天 function DateDiff($date1, $date2, $unit = "") { //时间比较函数,返回两个日期相差几秒、几分钟、几小时或几天 switch ($unit) { case 's': ……继续阅读 » 水墨上仙 5年前 (2021-03-10) 2750浏览 0评论1477个赞
php把全角数字转换为半角数字<? function GetAlabNum($fnum){ $nums = array("0","1","2","3","4","5","6","……继续阅读 » 水墨上仙 5年前 (2021-03-10) 2918浏览 0评论2212个赞
php重定向的三种方法<? 方法一:header("Location: index.php"); 方法二:echo "<scrīpt>window.location ="$PHP_SELF";</scrīpt>"; //OSPHP.COm.CN 方法三:ec……继续阅读 » 水墨上仙 5年前 (2021-03-10) 3302浏览 0评论570个赞
php写入文件函数<? function writetofile($file_name,$data,$method="w") { $filenum=fopen($file_name,$method); //OSPHP.COM.Cn开源 flock($filenum,LOCK_EX); $file_data=fwrite……继续阅读 » 水墨上仙 5年前 (2021-03-10) 1662浏览 0评论1545个赞
php相对路径转换成绝对路径<? function relative_to_absolute($content, $feed_url) { preg_match('/(http|https|ftp):///', $feed_url, $protocol); $server_url = preg_rep……继续阅读 » 水墨上仙 5年前 (2021-03-10) 2664浏览 0评论570个赞
php取得网页上的所有链接<? function get_all_url($code){ preg_match_all('/<as+href=["|']?([^>"' ]+)["|']?s*[^>]*>([^>]+)</……继续阅读 » 水墨上仙 5年前 (2021-03-10) 2799浏览 0评论1866个赞
php去除html标记<? function Text2Html($txt){ $txt = str_replace(" "," ",$txt); $txt = str_replace("<","<",$txt); ……继续阅读 » 水墨上仙 5年前 (2021-03-10) 1960浏览 0评论1590个赞
php生成excel文档<? header("Content-type:application/vnd.ms-excel"); header("Content-Disposition:filename=test.xls"); echo "test1t"; echo "t……继续阅读 » 水墨上仙 5年前 (2021-03-10) 2257浏览 0评论589个赞
php获取访问者的操作系统信息<? function osinfo() { $os=""; $Agent = $GLOBALS["HTTP_USER_AGENT"]; if (eregi('win',$Agent) && strpos($Agent, '……继续阅读 » 水墨上仙 5年前 (2021-03-10) 2183浏览 0评论585个赞
php删除指定的目录,本代码会递归删除子目录<?php/** * Delete a file, or a folder and its contents (recursive algorithm) * * @author Aidan Lister <aidan@php.net> * @version 1.0……继续阅读 » 水墨上仙 5年前 (2021-03-10) 1539浏览 0评论2738个赞
这段代码可以自动根据post数组的键值创建同名变量,这个功能使用非常方便,不用提前声明变量<?php$expected=array('username','age','city','street');foreach($expected as $key){ ……继续阅读 » 水墨上仙 5年前 (2021-03-10) 2895浏览 0评论1500个赞
php简单截断字符串函数,如果截断在字符串后自动加上省略号function short($txt,$size){ $short = $size - 3; if(strlen($txt) > $size){ $data = substr( $txt, 0, $short )."..."; ……继续阅读 » 水墨上仙 5年前 (2021-03-10) 2170浏览 0评论1005个赞
将HTML表格的每行每列转为数组,采集表格数据<? function get_td_array($table) { $table = preg_replace("'<table[^>]*?>'si","",$table); //oSPHP.COM.C……继续阅读 » 水墨上仙 5年前 (2021-03-10) 2023浏览 0评论648个赞
php获取当前urlfunction curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; i……继续阅读 » 水墨上仙 5年前 (2021-03-10) 1766浏览 0评论1294个赞
返回字符串中的所有单词 $distinct=true 去除重复<? function split_en_str($str,$distinct=true) { preg_match_all('/([a-zA-Z]+)/',$str,$match); if ($distinct == true……继续阅读 » 水墨上仙 5年前 (2021-03-10) 1758浏览 0评论721个赞
php将12小时制转换成24小时制,输入格式为:02:30:00 pm 转换成:14:30:00<?phpfunction to_24_hour($hours,$minutes,$seconds,$meridiem){ $hours = sprintf('%02d',(int) $hours); $minut……继续阅读 » 水墨上仙 5年前 (2021-03-10) 1627浏览 0评论2415个赞
javascriipt通过当前时间解决GET和POST的缓存问题在postUrl后面添加当前时间为参数,可以有效的解决缓存问题因为每次提交的url地址都是不同的var currentTime = new Date();var n = currentTime.getTime();postUrl = "http://www.example.c……继续阅读 » 水墨上仙 5年前 (2021-03-10) 1909浏览 0评论367个赞
Sum all elements of a bidimensional or multi-dimensional array with an assigned key/** * sum values in array * * @param array $arr * @param string [optional]$index * @retur……继续阅读 » 水墨上仙 5年前 (2021-03-10) 1719浏览 0评论211个赞
简单的PHP框架,实现antoload,viewEngine,有兴趣学写MVC框架的可以看看这篇文章: http://my.oschina.net/u/131802/blog/82016 这个很适合初学者对框架的认识 index.php 入口文件<?php……继续阅读 » 水墨上仙 5年前 (2021-03-10) 2573浏览 0评论727个赞
360提供的php防注入代码<?php //Code By Safe3 function customError($errno, $errstr, $errfile, $errline) { echo "<b>Error number:</b> [$errno],error on line $……继续阅读 » 水墨上仙 5年前 (2021-03-10) 3438浏览 0评论1155个赞
根据给定的数字查找其因数的高效C++代码//Algorithm derived from the method described here://http://mathschallenge.net/index.php?section=faq&ref=number/number_of_divisorsint mathTools::numFac……继续阅读 » 水墨上仙 5年前 (2021-03-10) 1707浏览 0评论2187个赞
php实现的ssh api类,主要用来通过ssh传输文件class SshApi extends BaseObject{ public $session = null; public $authenticated = false; public function __construct(){ } p……继续阅读 » 水墨上仙 5年前 (2021-03-10) 2713浏览 0评论1660个赞
php遍历目录的代码<?php function myscandir($pathname){ foreach( glob($pathname) as $filename ){ if(is_dir($filename)){ myscandir($filename.……继续阅读 » 水墨上仙 5年前 (2021-03-10) 2766浏览 0评论1199个赞