|
—
本帖被 云天河 执行取消置顶操作(2011-11-18)
—
1)修改的文件require/common.php 添加三个function - /**
- * add by hexiang
- *
- * @param unknown_type $key
- * @return unknown
- */
- function sessionSet($cookieName, $cookieValue, $expireTime = 'F', $needPrefix = true) {
- global $timestamp;
- $needPrefix && $cookieName = CookiePre() . '_' . $cookieName;
- if ($expireTime == 'F') {
- $expireTime = $timestamp + 31536000;
- } elseif ($cookieValue == '' && $expireTime == 0) {
- $expireTime = $timestamp - 31536000;
- }
- ini_set('session.gc_probability', 2);
- ini_set('session.gc_divisor', 100);
- ini_set('session.gc_maxlifetime', $expireTime);
- ini_set('session.cache_expire', $expireTime);
- session_set_cookie_params($expireTime);
- if ($GLOBALS['sessionid']) {
- session_id($GLOBALS['sessionid']);
- }
- session_start();
- $_SESSION[$cookieName] = $cookieValue;
- return TRUE;
- }
- /**
- * add by hexiang
- *
- * @param unknown_type $key
- * @return unknown
- */
- function sessionGet($key) {
- session_start();
- return $_SESSION[CookiePre() . '_' . $key];
- }
- /**
- * 随机字母
- *
- * @param unknown_type $length
- * @param unknown_type $mode
- * @return unknown
- */
- function getCode($length = 32, $mode = 2) {
- switch ($mode) {
- case '1' :
- $str = '1234567890';
- break;
- case '2' :
- $str = 'abcdefghijklmnopqrstuvwxyz';
- break;
- case '3' :
- $str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
- break;
- default :
- $str = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
- break;
- }
-
- $result = '';
- $l = strlen($str) - 1;
- $num = 0;
-
- for ($i = 0; $i < $length; $i++) {
- $num = rand(0, $l);
- $a = $str[$num];
- $result = $result . $a;
- }
- return $result;
- }
2)require/postnew.php 在 if (empty($_POST['step'])) {;下面添加 - /**
- * add by yanghexiang
- */
- $randnum = rand(10, 50);
- $htmlNameTokenS = getCode(1);
- $htmlNameToken = $htmlNameTokenS . md5($timestamp);
- $totkenName = 'token';
- $numa = rand(10, 30);
- $numb = rand(30, 50);
- $numc = rand(50, 70);
- //$token = $htmlNameTokenS . md5($GLOBALS['db_hash'] . $timestamp);
- $scret = strtolower(md5($GLOBALS['db_hash'] . $timestamp));
- $token = $htmlNameTokenS . $scret;
- sessionSet($totkenName, $token, 3600);
-
- $mouseValue = encode($scret, $timestamp, $numa, $numb, $numc);
- sessionSet('mouseValue', $mouseValue, 3600);
- require_once 'class.JavaScriptPacker.php';
- $scriptAdd = $scriptAddAfter = '';
- for ($i = 1; $i < $randnum; $i++) {
- $scriptAddHead .= 'var ' . $htmlNameTokenS . md5($i . 'H') . '="' . $htmlNameTokenS . md5($i . 'Head') . '";';
- $scriptAddAfter .= 'var ' . $htmlNameTokenS . md5($i . 'A') . '="' . $htmlNameTokenS . md5($i . 'After') . '";';
- }
- $script = 'var mouseValue = "";
- function setMouseValue(){
- mouseValue = encodesgg("' . $scret . '",' . $timestamp .');
- }
- function ' . $htmlNameToken . '(){
- var ' . $htmlNameToken . '=document.createElement("input");
- ' . $htmlNameToken . '.type="hidden";' . $scriptAddHead . '
- ' . $htmlNameToken . '.name="' . $token . '";
- ' . $htmlNameToken . '.value=mouseValue;
- ' . $scriptAddAfter . '
- return ' . $htmlNameToken . ';
- }
- function encodesgg(F,D) {
- var D = D,
- J = 0;
- var F = F;
- var M = "",
- C = "";
- var I = [],
- E = [];
- function L(Q, N, O) {
- for (var P = Q; P <= N; P++) {
- I[P] = P + O;
- E[P + O] = P
- }
- }
- L(0, 9, 48);
- L(10, 35, 55);
- L(36, 61, 61);
- var K = D % 26;
- K = K ? K : 1;
- function A(O) {
- var N = O.length;
- var Q = "";
- for (var P = 0; P < N; P++) {
- var R = O.charAt(P);
- if (/[A-Za-z0-9]/.test(R)) {
- var S = E[O.charCodeAt(P)] - K;
- if (S < 0) {
- S += 62
- }
- R = String.fromCharCode(I[S])
- }
- Q += R
- }
- return Q
- }
- M = A(F);
- return M;
- }';
- $packer = new JavaScriptPacker($script);
- $packed = $packer->pack();
- //$packed = $script;
- //end by yanghexiang
在S::gp(array('iscontinue'), 'P');下面添加 - /**
- * add by yanghexiang
- */
- S::gp(array('ifpostcheck'), 'G');
- if (!procLock($winduid)) {
- Showmsg('并发错误');
- }
- procUnLock($winduid);
- $totkenName = 'token';
- $token = sessionGet($totkenName);
- $mouseValue = (sessionGet('mouseValue'));
- S::gp(array($token), 'P', 0);
- if (empty($token) || empty($mouseValue) || $$token != $mouseValue) {
- Showmsg('非法请求');
- }
在 refreshto($j_p, $pinfo);前面加 - //add by yanghexiang
- sessionSet($totkenName, FALSE, 3600);
- sessionSet($totkenName, FALSE, 3600);
- //add by yanghexiang
顶下添加函数 - /**
- * add by yanghexiang
- *
- * @param unknown_type $url
- * @param unknown_type $sertim
- * @param unknown_type $numa
- * @param unknown_type $numb
- * @param unknown_type $numc
- * @return unknown
- */
- function encode($url, $sertim, $numa, $numb, $numc) {
- $len = strlen($url);
- $decurl = "";
- $asc_arr1 = array();
- $asc_arr2 = array();
-
- $key = $sertim % 26;
-
- $key = $key ? $key : 1;
- for ($i = 0; $i <= 9; $i++) {
- $asc_arr1[$i] = $i + 48;
- $asc_arr2[$i + 48] = $i;
- }
- for ($i = 10; $i <= 35; $i++) {
- $asc_arr1[$i] = $i + 55;
- $asc_arr2[$i + 55] = $i;
- }
- for ($i = 36; $i <= 61; $i++) {
- $asc_arr1[$i] = $i + 61;
- $asc_arr2[$i + 61] = $i;
- }
- for ($i = 0; $i < $len; $i++) {
- $word = substr($url, $i, 1);
-
- if (preg_match("/[A-Za-z0-9]/", $word)) {
- $pos = $asc_arr2[ord(substr($url, $i, 1))] - $key;
- if ($pos < 0) {
- $pos += 62;
- }
- $word = chr($asc_arr1[$pos]);
- }
- $decurl .= $word;
- }
-
- return $decurl;
- }
模板里面添加 template/wind/post.html (也许在你自定义的模板里面) 找到 function ajaxSubmit(obj){ 在前面添加 {$packed} 在下面添加 - <!--
- EOT;
- if($htmlNameToken){
- print <<<EOT
- -->
- $htmlNameToken = {$htmlNameToken}();
- obj.appendChild($htmlNameToken);
- <!--
- EOT;
- }
- print <<<EOT
- -->
把 <button type="submit" name="Submit"> 发 布 </button> 变成 <button type="submit" name="Submit" onmousemove="setMouseValue()" > 发 布 </button> 3)添加文件 require/class.JavaScriptPacker.php 内容: class.JavaScriptPacker.rar (7 K) 下载次数:82
|