11月 2014

PHP利用showmycode在线解密Zend加密的文件

PHP利用showmycode在线解密Zend加密的文件

 

 /**
     * 在线解密Zend加密
     * @author jakehu
     * @date   2014-06-10
     */
header("Content-Type: text/html; charset=utf-8");
if (@$_REQUEST['action']=='bomp') {
    if ($_FILES["file"]){      
        move_uploaded_file($_FILES["file"]["tmp_name"],"temp/" . $_FILES["file"]["name"]);
        $path = "temp/" . $_FILES["file"]["name"];
    }
 
    $decodingurl = $_REQUEST['decodingurl'];
    $captcha = $_REQUEST['captcha'];
    $cookies = $_REQUEST['cookies'];
    $query['MAX_FILE_SIZE'] = 2097152;
    $query['decodingurl'] = $decodingurl;
    $query['upload'] = '@'.dirname(__FILE__).'/'.$path;
    $query['captcha'] = $captcha;
    
    $url = 'http://www.showmycode.com/';
    $ch = curl_init ();
    curl_setopt ( $ch, CURLOPT_URL, $url );
    curl_setopt ( $ch, CURLOPT_HEADER, 0 );
    curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
    curl_setopt(  $ch, CURLOPT_REFERER, "http://www.showmycode.com");
    curl_setopt ( $ch, CURLOPT_POST, 1 );
    curl_setopt ( $ch, CURLOPT_POSTFIELDS, $query );
    curl_setopt ( $ch, CURLOPT_COOKIE, $cookies );
    $result = curl_exec ( $ch ); // 
    curl_close ( $ch );
    
    $result = explode('', $result);
    $result = explode('', $result[1]);   
    
    echo $result[0].', Here is the result:';
      
    $url = 'http://www.showmycode.com/?download';
    $ch = curl_init ();
    curl_setopt ( $ch, CURLOPT_URL, $url );
    curl_setopt ( $ch, CURLOPT_HEADER, 0 );
    curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
    curl_setopt(  $ch, CURLOPT_REFERER, "http://www.showmycode.com");
    curl_setopt ( $ch, CURLOPT_COOKIE, $cookies );
    $result = curl_exec ( $ch ); //
    curl_close ( $ch );
 
    echo "";
    //因博客代码高亮问题注释显示(使用时请打开上面注释)
    exit();
}
$url = "http://www.showmycode.com/?c";
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $url );
curl_setopt ( $ch, CURLOPT_HEADER, 1 );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt(  $ch, CURLOPT_REFERER, "http://www.showmycode.com");
curl_setopt ( $ch, CURLOPT_POST, 0 );
$result = curl_exec ( $ch ); // 
curl_close ( $ch );
 
list ( $header1, $body ) = explode ( "rnrn", $result );
preg_match_all ( '/set-cookie:([^;]*)/i', $header1, $matches );
echo "";
//因博客代码高亮问题注释显示(使用时请打开上面注释)
$cookies = trim($matches[1][1]);
echo "";
echo "action:";
echo "cookies:";
echo "file:";
echo "decodingurl:";
echo "captcha:";
echo "";
echo "";
echo "";

利用PHP获取Google PR值代码片段

用php的方法取谷歌的PR值。事实上我已经很久没关注PR值了,PR值 也不像以前那样备受关注,影响力有所下降。

function pagerank($domain)
{
$StartURL = "http://toolbarqueries.google.com/tbr?client=navclient-auto&features=Rank&q=info:";
$GoogleURL = $StartURL.$domain. '&ch='.HashURL($domain);
$fcontents = file_get_contents("$GoogleURL");
$pagerank = substr($fcontents,9);
if (!$pagerank) return "0";else return $pagerank;
}
 
function HashURL($url)
{
$SEED = "Mining PageRank is AGAINST GOOGLE’S TERMS OF SERVICE.";
$Result = 0x01020345;
for ($i=0; $i<strlen($url); $i++) { $Result ^= ord($SEED{$i%87}) ^ ord($url{$i}); $Result = (($Result >> 23) & 0x1FF) | $Result << 9;
}
return sprintf("8%x", $Result);
}
 
echo pagerank("saycn.net");

如果是64位的系统,上面的代码运行不了,HashURL的函数换为下面的。

function HashURL($url)
{
$SEED = "Mining PageRank is AGAINST GOOGLE’S TERMS OF SERVICE.";
$Result = 0x01020345;
for ($i=0; $i<strlen($url); $i++) { $Result ^= ord($SEED{$i%87}) ^ ord($url{$i}); $Result = (($Result >> 23) & 0x1FF) | $Result << 9 & 0xFFFFFFFF;
}
return sprintf("8%x", $Result);
}

如何使用Php实现Google /Baidu Ping服务快速收录

玩过WORDPRESS的朋友应该都知道ping服务吧,通俗点讲它可以在更新文章的时候向Google、baidu及其他支持ping的搜索引擎发送指令然后招呼它们过来,不用傻等他们过来收录了,化被动为主动了。直接贴代码了,很简单的。

/**
  +------------------------------------------------------------------------------
 * 通知搜索引擎过来抓去最新发布的内容。秒收不是梦
 * 目前仅支持Google和Baidu
  +------------------------------------------------------------------------------
 */
class Ping {
 
    public $method, $callback;
 
    public function method($site_name, $site_url, $update_url, $update_rss) {
        $this->method = '
    < ?xml version="1.0" encoding="UTF-8"?>
    
      weblogUpdates.extendedPing
      
     {$site_name}
     {$site_url}
     {$update_url}
     {$update_rss}
      
    ';
        return $this->method;
    }
 
    public function _post($url, $postvar) {
        $ch = curl_init();
        $headers = array(
            "POST " . $url . " HTTP/1.0",
            'Content-type: text/xml;charset="utf-8"',
            "Accept: text/xml",
            "Content-length: " . strlen($postvar)
        );
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $postvar);
        $res = curl_exec($ch);
        curl_close($ch);
        return $res;
    }
 
    public function google() {
        $this->callback = $this->_post('http://blogsearch.google.com/ping/RPC2', $this->method);
        return strpos($this->callback, "0") ? true : false;
    }
 
    public function baidu() {
        $this->callback = $this->_post('http://ping.baidu.com/ping/RPC2', $this->method);
        return strpos($this->callback, "0") ? true : false;
    }
     
}


下面演示一下如何调用

$Ping=new Ping();
$Ping->method('xxx博客', 'https://saycn.net/', 'https://saycn.net/xxx', 'https://saycn.net/feed');
$Ping->baidu();
$Ping->google();

PHP去除Html所有标签、空格以及空白

笔者在前几天做微信自定义分享网页的时候,自定义内容的时候需要去除内容的标签并截取部分内容作为简介便用到了下面了的函数,现在笔者把他分享出来,希望能够帮到大家

function cutstr_html($string, $sublen)    
 {
      $string = strip_tags($string);
      $string = trim($string);
      $string = ereg_replace("t","",$string);
      $string = ereg_replace("rn","",$string);
      $string = ereg_replace("r","",$string);
      $string = ereg_replace("n","",$string);
      $string = ereg_replace("    ","",$string);
      return trim($string);
}

微信(weixin)分享网页自定义缩略图、链接、标题和摘要

由于微信分享是通过WeixinJSBridge实现的。所以用户只需要将下面这段Js代码复制到网页中,定义好对应的参数即可

  var imgUrl = 'https://saycn.net/xxx.jpg';
        var lineLink = 'https://saycn.net/904';
        var descContent = "这是xxx的博客";
        var shareTitle = 'xxx';
        var appid = '';
        
        function shareFriend() {
            WeixinJSBridge.invoke('sendAppMessage',{
                "appid": appid,
                "img_url": imgUrl,
                "img_width": "200",
                "img_height": "200",
                "link": lineLink,
                "desc": descContent,
                "title": shareTitle
            }, function(res) {
                //_report('send_msg', res.err_msg);
            })
        }
        function shareTimeline() {
            WeixinJSBridge.invoke('shareTimeline',{
                "img_url": imgUrl,
                "img_width": "200",
                "img_height": "200",
                "link": lineLink,
                "desc": descContent,
                "title": shareTitle
            }, function(res) {
                   //_report('timeline', res.err_msg);
            });
        }
        function shareWeibo() {
            WeixinJSBridge.invoke('shareWeibo',{
                "content": descContent,
                "url": lineLink,
            }, function(res) {
                //_report('weibo', res.err_msg);
            });
        }
        // 当微信内置浏览器完成内部初始化后会触发WeixinJSBridgeReady事件。
        document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
            // 发送给好友
            WeixinJSBridge.on('menu:share:appmessage', function(argv){
                shareFriend();
            });
            // 分享到朋友圈
            WeixinJSBridge.on('menu:share:timeline', function(argv){
                shareTimeline();
            });
            // 分享到微博
            WeixinJSBridge.on('menu:share:weibo', function(argv){
                shareWeibo();
            });
        }, false);

zbp已有模块内容的更新(重建)的两种方法

都是以插件的形式实现,以侧栏标签云模块为例

一、对原有模块内容的重写。

(1)首先挂接接口 

 Add_Filter_Plugin('Filter_Plugin_Zbp_Load','BuildModule_Populartags');

(2)接口函数的编写

//热门标签模块重建(开始)
function BuildModule_Populartags()
{
    global $zbp;
    $zbp->RegBuildModule('tags', 'BuildModule_Populartags');
    $s = '';
    $i = $zbp->modulesbyfilename['tags']->MaxLi;
    if ($i == 0)
        $i = 25;
    $array  = $zbp->GetTagList('*', '', array(
        'tag_Count' => 'DESC'
    ), $i, null);
    $array2 = array();
    foreach ($array as $tag) {
        $array2[$tag->ID] = $tag;
    }
    ksort($array2);
     
    foreach ($array2 as $tag) {
        $s .= ' <a href="' . $tag->Url . '" title="' . $tag->Count . '个话题" style="font-size:12px"> ' . $tag->Name . ' </a>';
    }
     
    return $s;
}
//重建热门标签模块结束

启用方法:进入模块管理的tags列表,点击提交就可以移到侧栏使用了。

二、对原有模块内容的直接替换。

(1)挂接接口:

Add_Filter_Plugin('Filter_Plugin_Index_Begin','Tblogpublished');
Add_Filter_Plugin('Filter_Plugin_Search_Begin','Tblogpublisheds');

(2)替换函数的编写:

function Tblogpublished(){
    global $zbp;
    if(isset($zbp->modulesbyfilename['tags'])){
    $zbp->modulesbyfilename['tags']->Content =Tblog_Get_tags();
    }
}
function Tblogpublisheds(){
    global $zbp;
    if(isset($zbp->modulesbyfilename['tags'])){
    $zbp->modulesbyfilename['tags']->Content =Tblog_Get_tags();
    }  
}

(3)新的标签云内容的编写:

function Tblog_Get_tags(){
global $zbp;
$zbp->header .='<script src="'.$zbp->host.'zb_users/plugin/ttyb_newlypublished/js/3D-Tags.js" type="text/javascript"></script>';
$zbp->header .= "<link rel="stylesheet" href="{$zbp->host}zb_users/plugin/ttyb_newlypublished/css/3dstyle.css" type="text/css" />rn";
$s = '';
$s.= '<div id="div1">';
    $i = $zbp->modulesbyfilename['tags']->MaxLi;
    if ($i == 0) $i = 25;
    $array = $zbp->GetTagList('*', '', array('tag_Count' => 'DESC'), $i, null);
    $array2 = array();
    foreach ($array as $tag) {
        $array2[$tag->ID] = $tag;
    }
    ksort($array2);
    $clor123=array("tblogred","tblogblack","tblogblue","tblogorange","tblogpink","tblogpurple");
    foreach ($array2 as $tag) {
        $s .= '<a href="' . $tag->Url . '"  class="'.$clor123[rand(0,5)].'" >' . $tag->Name . '(' . $tag->Count . ')</a>';
    }
$s.= '</div>';  
    return $s;
}

+-比较前面两个方法:

到这里已经全部介绍完两种方法,在这里来比较下两个方法:

相同点:

(1)都是可以实现模块内容的更新。

(2)显示数量等可以到模块管理面设置。

不同点:

(1)第一种方法:可以实现启用的时候必须要到模块管理里面管理重写提交下或者新建的tag的时候才能使用(相对tags来说,别的类似),第二种方法可以。

(2)第二种方法的动态内容的实现比较灵活。比如对于新建的模块内容是动态的,要实现动态的更换就会很麻烦。需要来回重写模块。那就费事了。(有点过了。要是介绍新建模块就好了。呵呵,以后介绍。)(可以忽略第二条。)

IE下实现placeholder效果的jquery插件

发现ie11都不支持placeholder,这是相当悲剧的。下面贴出一段简单的解决方法:

$(document).ready(
  function () {
    var doc = document,
      inputs = doc
        .getElementsByTagName('input'),
      supportPlaceholder = 'placeholder' in doc
        .createElement('input'),
      placeholder = function (
        input) {
        var text = input.getAttribute('placeholder'),
          defaultValue = input.defaultValue;
        if (defaultValue == '') {
          input.value = text
          input.setAttribute("old_color", input.style.color);
          input.style.color = "#c0c0c0";
        }
        input.onfocus = function () {
          this.style.color = this.getAttribute("old_color");
          if (input.value === text) {
            this.value = ''
          }
        };
        input.onblur = function () {
          if (input.value === '') {
            this.style.color = "#c0c0c0";
            this.value = text
          }
        }
      };
    if (!supportPlaceholder) {
      for (var i = 0, len = inputs.length; i < len; i++) {
        var input = inputs[i],
          text = input
            .getAttribute('placeholder');
        if (input.type === 'text' && text) {
          placeholder(input)
        }
      }
    }
  }
);

直接引用这段js就可以了。

原理

就是通过js获取表单的title,然后把title写入到表单中,当表单激活的时候,再清空表单内容就可以了。