11 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);