完美

[学习|工作|博客|交流平台|完美起航]

作者头像admin2017.06.01 11:47 

js实现左右移动的图片

左右移动的图片[修改图片名称即可][共2步]====1、将以下代码加入到HEML的<head></head>之间:<scriptLANGUAGE="JavaScript"> <!-- step=0; obj=newImage(); functionanim(xp,xk,smer)//smer=direction { obj.style.left=x; x+=step*smer; if(x>=(xk+xp)/2){ if(smer==1) step--; else step++; }else{ if(smer==1) step++; else step--; } if(x>=xk){ x=xk; smer=-1; } if(x<=xp){ x=xp; smer=1; } //if(smer>2)smer=3; setTimeout('anim('+xp+','+xk+','+smer+')',50); } functionmoveLR(objID,movingarea_width,c){ if(navigator.appName=="Netscape") window_width=window.innerWidth; else window_width=document.body.offsetWidth; obj=document.images[objID]; image_width=obj.width; x1=obj.style.left; x=Number(x1.substring(0,x1.length-2));//30px->30 if(c==0){ if(movingarea_width==0){ right_margin=window_width-image_width; anim(x,right_margin,1); }else{ right_margin=x+movingarea_width-image_width; if(movingarea_width<x+image_width) window.alert("Nospaceformoving!"); else anim(x,right_margin,1); } }else{ if(movingarea_width==0) right_margin=window_width-image_width; else{ x=Math.round((window_width-movingarea_width)/2); right_margin=Math.round((window_width+movingarea_width)/2)-image_width; } anim(x,right_margin,1); } } //--> </script>====2、将以下代码加入到HEML的<body></body>之间:<img src="要显示的图片名称.gif" name=&q

左右移动的图片 3398 1

作者头像admin2017.05.26 15:25 

UEditor如何防止xss注入

现在的富文本编辑器,都有xss注入漏洞,想请教一下,如何防止xss注入?markdown编辑器先不考虑服务器端清除xss攻击stringhtmlentities(string$string[,int$flags=ENT_COMPAT|ENT_HTML401[,string$encoding="UTF-8"[,bool$double_encode=true]]])例子:<?php $str="A'quote'is<b>bold</b>"; //Outputs:A'quote'is&lt;b&gt;bold&lt;/b&gt; echohtmlentities($str); //Outputs:A&#039;quote&#039;is&lt;b&gt;bold&lt;/b&gt; echohtmlentities($str,ENT_QUOTES); ?><?php $str="\x8F!!!"; //Outputsanemptystring echohtmlentities($str,ENT_QUOTES,"UTF-8"); //Outputs"!!!" echohtmlentities($str,ENT_QUOTES|ENT_IGNORE,"UTF-8"); ?>stringhtmlspecialchars(string$string[,int$flags=ENT_COMPAT|ENT_HTML401[,string$encoding="UTF-8"[,bool$double_encode=true]]])<?php $new=htmlspecialchars("<ahref='test'>Test</a>",ENT_QUOTES); echo$new;//&lt;ahref=&#039;test&#039;&gt;Test&lt;/a&gt; ?>还原显示可以使用htmlspecialchars_decode、html_entity_decodestringhtmlspecialchars_decode(string$string[,int$flags=ENT_COMPAT|ENT_HTML401])<?php $str="<p>this-&gt;&quot;</p>\n"; echohtmlspecialchars_decode($str); //注意,这里的引号不会被转换 echohtmlspecialchars_decode($str,ENT_NOQUOTES); ?>以上过程会输出<p>this->"</p> <p>this->&quot;</p>stringhtml_entity_decode

UEditor 3927 4

作者头像admin2017.06.01 11:47 

PHP unpack() 函数

PHP unpack() 函数定义和用法unpack() 函数从二进制字符串对数据进行解包。语法unpack(format,data)参数描述format必需。规定在解包数据时所使用的格式。data可选。规定被解包的二进制数据。format 参数的可能值:a - NUL-padded stringA - SPACE-padded stringh - Hex string, low nibble firstH - Hex string, high nibble firstc - signed charC - unsigned chars - signed short (always 16 bit, machine byte order)S - unsigned short (always 16 bit, machine byte order)n - unsigned short (always 16 bit, big endian byte order)v - unsigned short (always 16 bit, little endian byte order)i - signed integer (machine dependent size and byte order)I - unsigned integer (machine dependent size and byte order)l - signed long (always 32 bit, machine byte order)L - unsigned long (always 32 bit, machine byte order)N - unsigned long (always 32 bit, big endian byte order)V - unsigned long (always 32 bit, little endian byte order)f - float (machine dependent size and representation)d - double (machine dependent size and representation)x - NUL byteX - Back up one byte@ - NUL-fill to absolute position例子例子 1<?php $data="PHP"; print_r(unpack("C*",$data)); ?>输出:Array ( [1]=>80 [2]=>72 [3]=>80 )例子 2<?php $data="PHP"; print_r(unpack("C*myint",$data)); ?>输出:Array ( [myint1]=>80 [myint2]=>72 [myint3]=>80 )例子 3<?php $bin=pack("c2n2",0x1234,0x5678,65,66); print_r(unpack("c2chars/n2int",$bin)); ?>输出:Array ( [chars1]=>52 [

unpack 2956 1

作者头像admin2017.06.01 11:47 

PHP usleep() 函数

PHP usleep() 函数定义和用法usleep() 函数延迟代码执行若干微秒。语法usleep(microseconds)参数描述microseconds必需。以微秒计的暂停时间。返回值无返回值。提示和注释注释:在 PHP 5 之前,该函数无法工作于 Windows 系统上。注释:一微秒等于百万分之一秒。例子<?php echodate(h:i:s)."<br/>"; //延迟10描述usleep(10000000);//再次开始 echodate(h:i:s); ?>输出:09:23:14 09:23:24

usleep 3058 2

作者头像admin2017.05.24 23:28 

php删除文件夹及文件夹下所有文件

php删除文件夹及文件夹下所有文件,代码如下<? functiondeldir($dir){ //先删除目录下的文件: $dh=opendir($dir); while($file=readdir($dh)){ if($file!="."&&$file!=".."){ $fullpath=$dir."/".$file; if(!is_dir($fullpath)){ unlink($fullpath); }else{ deldir($fullpath); } } } closedir($dh); //删除当前文件夹: if(rmdir($dir)){ returntrue; }else{ returnfalse; } } ?>

PHP 67788 9

a6bfb44cbd5549740eb36647f36ef83a