Skip to content

Instantly share code, notes, and snippets.

@Johnbug
Johnbug / disabledMouseWheel.js
Created September 27, 2013 02:35
Javascript禁止鼠标的滚轮事件
function disabledMouseWheel() {
if (document.addEventListener) {
document.addEventListener('DOMMouseScroll', scrollFunc, false);
}//W3C
window.onmousewheel = document.onmousewheel = scrollFunc;//IE/Opera/Chrome
}
function scrollFunc(evt) {
evt = evt || window.event;
if(evt.preventDefault) {
@Johnbug
Johnbug / UserAgent.js
Created September 7, 2013 08:42
XSS--UserAgent
/**
* Created with JetBrains WebStorm.
* User: jonbug
* Date: 13-9-7
* Time: 下午4:11
* To change this template use File | Settings | File Templates.
*/
function getUserAgent(){
if(window.ActiveXObject){
if(document.documentElement && typeof document.documentElement.style.maxHeight!="undefined"){
@Johnbug
Johnbug / UserAgent.js
Created September 7, 2013 08:42
XSS--获取userAgent
/**
* Created with JetBrains WebStorm.
* User: jonbug
* Date: 13-9-7
* Time: 下午4:11
* To change this template use File | Settings | File Templates.
*/
function getUserAgent(){
if(window.ActiveXObject){
if(document.documentElement && typeof document.documentElement.style.maxHeight!="undefined"){
@Johnbug
Johnbug / Ajax.js
Created September 6, 2013 13:09
Ajax的具体实现
function ajax(method,url,fnSuc,fnFailed){
var oAjax;
if(window.XMLHttpRequest){
oAjax = new XMLHttpRequest();
}else {
oAjax = new ActiveXObject("Microsoft.XMLHTTP");
}
oAjax.open(method,url,true);
oAjax.send();
oAjax.onreadystatechange = function(){
@Johnbug
Johnbug / function.setCookie.js
Created September 5, 2013 05:34
原生JavaScript设置cookie值
function setCookie(name, value, Hours) {
var d = new Date();
var offset = 8;
var utc = d.getTime() + (d.getTimezoneOffset() * 60000);
var nd = utc + (3600000 * offset);
var exp = new Date(nd);
exp.setTime(exp.getTime() + Hours * 60 * 60 * 1000);
document.cookie = name + "=" + escape(value) + ";path=/;expires=" + exp.toGMTString() + ";domain=360doc.com;"
}
@Johnbug
Johnbug / function.AuthCode.php
Last active December 22, 2015 08:38
Discuz! 经典加密解密函数(带详解)
<?php
// $string: 明文 或 密文
// $operation:DECODE表示解密,其它表示加密
// $key: 密匙
// $expiry:密文有效期
function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) {
// 动态密匙长度,相同的明文会生成不同密文就是依靠动态密匙
$ckey_length = 4;
// 密匙
@Johnbug
Johnbug / function.eventclass_cache.php
Created September 3, 2013 04:21
php缓存机制的相关代码!一段来自uchome的代码,可以学习!
<?php
#活动类别函数
function eventclass_cache(){
global $_SGLOBAL;
$_SGLOBAL['eventclass'] = array();
#同时写入全局
$query = $_SGLOBAL['db']->query("SELECT * FROM " . tname("eventclass") . " ORDER BY displayorder");
while($value = $_SGLOBAL['db']->fetch_array($query)){
if($value['poster']) {
@Johnbug
Johnbug / beautify-gist.html
Created August 30, 2013 07:00
一点小小的美化gist嵌入
<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
.center{margin-left: auto;margin-right: auto;}
.cold-shadow{-webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;-moz-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;-ms-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;-o-box-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px 0;}
.cold-font{font-size: 12px;font-family: "consolas";}
#gist-box{width: 900px;}
.gist-title{height: 30px;line-height: 30px;background-color: #ececec;padding-left: 20px;font-size: 15px;border: 1px solid #ddd;}
</style>
@Johnbug
Johnbug / function.getCurrentURI.php
Last active December 21, 2015 23:59
关于获取当前URI的php代码片段
<?php
function getCurrentURI(){
#较通用的写法
if (isset($_SERVER['REQUEST_URI'])){
$uri = $_SERVER['REQUEST_URI'];
}else{
if (isset($_SERVER['argv'])){
$uri = $_SERVER['PHP_SELF'] .'?'. $_SERVER['argv'][0];
}else{
$uri = $_SERVER['PHP_SELF'] .'?'. $_SERVER['QUERY_STRING'];