Plugin Directory

Changeset 477926


Ignore:
Timestamp:
12/20/2011 11:35:44 AM (14 years ago)
Author:
allarem
Message:

update to 0.3

Location:
qq-avatar
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • qq-avatar/tags/0.3/qq-avatar.php

    r477817 r477926  
    22/*
    33Plugin Name: QQ Avatar
     4Plugin URI: http://wordpress.org/extend/plugins/qq-avatar/
    45Author: Meng Zhuo
    56Author URI: http://mengzhuo.org
    6 Version: 0.2
     7Version: 0.3
    78License: GPLv2 or later
    8 Description: Replace Gravatar while commenter use QQ numeric email address.如果用户使用数字QQ邮箱留言且公开空间头像,就替换成QQ头像。
     9Description: Replace Gravatar while commenter use QQ numeric email address.如果用户使用数字QQ邮箱留言且公开空间头像,就<strong>将Gravatar替换成QQ头像</strong> | <strong><a href="http://me.alipay.com/mengzhuo">捐助</a></strong> | <a title="使用本插件即表示您知晓并接受本条款" href="http://mengzhuo.org/lab/qq-avatar/agreement.htm">条款</a>
    910*/
    1011/*
     
    4041function qq_avatar($original_img,$comment_info){
    4142    if (is_object($comment_info)){
    42    
    43         if ( !is_dir(CACHE) ){
    44             mkdir( CACHE );
     43        $cache = get_home_path().CACHE;
     44        if ( !is_dir($cache) ){
     45            mkdir( $cache );
    4546        }
    46         if ( isset($comment_info->comment_author_email) && preg_match('/^\[email protected]/',$comment_info->comment_author_email) ){
     47       
     48        if ( isset($comment_info->comment_author_email) && preg_match('/^\d+@(vip\.)?qq.com$/',$comment_info->comment_author_email) ){
    4749            //Thank FSM, It's an QQ number
    4850            $qq_uin = explode("@", $comment_info->comment_author_email);
     
    5052            $qq_uin_md5 = md5($qq_uin);
    5153           
    52             if (file_exists(CACHE.'/'.$qq_uin_md5.'.jpg')){
     54            $file_url = "$cache/$qq_uin_md5.jpg";
     55
     56            if (file_exists("$cache/$qq_uin_md5.jpg")){
     57               
    5358                $original_img = preg_replace("/src='[^']*'/",
    5459                      "src='".get_home_url().'/'.CACHE."/$qq_uin_md5.jpg'",
     
    5863           
    5964            $response = wp_remote_get( QQ_REQUEST.$qq_uin,
    60                                         array('user-agent'=>QQ_REQUEST_UA)
     65                                        array('user-agent'=>QQ_REQUEST_UA,
     66                                               'timeout'=>1
     67                                        )
    6168                                     );
    6269           
     
    6875                                                $response['body']
    6976                                                ));
    70                                                
     77                if (!is_numeric($qq_info->uin)){
     78                    //how the hell you get through this...                     
     79                    return $original_img;
     80                }
    7181               
    72                 $pic_url = CACHE.'/'.md5($qq_info->uin).'.jpg';
     82                $qq_uin_md5 = md5($qq_info->uin);//yes, it's recheck.
     83                $pic_path = "$cache/$qq_uin_md5.jpg";
    7384               
    74                 if (isset($qq_info->avatarUrl) && !file_exists($pic_url)){
     85                if (isset($qq_info->avatarUrl) && !file_exists($pic_path)){
    7586               
    76                     $pic_handle = wp_remote_get($qq_info->avatarUrl);
     87                    $pic_handle = wp_remote_get($qq_info->avatarUrl,
     88                                                 array('user-agent'=>QQ_REQUEST_UA,
     89                                                'timeout'=>1
     90                                        ));
     91                    if ($pic_handle['response']['code'] != 200){
     92                        return $original_img;
     93                    }                   
     94                   
    7795                    $pic_handle = $pic_handle['body'];
    7896                   
    79                     $temp_pic = fopen( $pic_url,'wb+');
    80                     fwrite($temp_pic,$pic_handle);
     97                    $temp_pic = fopen( $pic_path,'wb+');
     98                   
     99                    if (fwrite($temp_pic,$pic_handle)){
     100                          $original_img = preg_replace("/src='[^']*'/",
     101                                  "src='".get_home_url().'/'.CACHE."/$qq_uin_md5.jpg'",
     102                                   $original_img);
     103                    }
     104                   
    81105                    fclose($temp_pic);
    82106                }
    83                
    84                 $original_img = preg_replace("/src='[^']*'/",
    85                                   "src='".get_home_url()."/$pic_url'",
    86                                    $original_img);
    87107            }
    88108        }
  • qq-avatar/tags/0.3/readme.txt

    r477817 r477926  
    11=== QQ Avatar ===
    22Contributors: allarem
    3 Tags: avatar,qq
     3Tags: avatar,qq,头像
    44Requires at least: 3.1
    55Tested up to: 3.3
    6 Stable tag: 0.2
     6Stable tag: 0.3
    77License: GPLv2 or later
    88
    9 Replace Gravatar while commenter use QQ numeric email address.
     9Replace Gravatar while commenter use QQ numeric email address.如果用户使用数字QQ邮箱留言且公开空间头像,就替换成QQ头像。
    1010
    1111== Description ==
     
    1717You've done it !
    1818
     19== MD5 ==
     20If you find out that your php-file's md5 doesn't match in the changlog, please reinstall to reassure safty.
     21如果您的文件MD5散列值与Changlog里的不符,请重新下载并安装以保证安全
     22
    1923== Changelog ==
     24
     25= 0.3 =
     26b53efa6c4e95783e59b8376c35dfa304  qq-avatar.php
     27*FIXED:avatar won't show while in wp-admin panel
     28*IMPROVE:Set 1 sencond as timeout to improve performance.
    2029
    2130= 0.2 =
  • qq-avatar/trunk/qq-avatar.php

    r477817 r477926  
    22/*
    33Plugin Name: QQ Avatar
     4Plugin URI: http://wordpress.org/extend/plugins/qq-avatar/
    45Author: Meng Zhuo
    56Author URI: http://mengzhuo.org
    6 Version: 0.2
     7Version: 0.3
    78License: GPLv2 or later
    8 Description: Replace Gravatar while commenter use QQ numeric email address.如果用户使用数字QQ邮箱留言且公开空间头像,就替换成QQ头像。
     9Description: Replace Gravatar while commenter use QQ numeric email address.如果用户使用数字QQ邮箱留言且公开空间头像,就<strong>将Gravatar替换成QQ头像</strong> | <strong><a href="http://me.alipay.com/mengzhuo">捐助</a></strong> | <a title="使用本插件即表示您知晓并接受本条款" href="http://mengzhuo.org/lab/qq-avatar/agreement.htm">条款</a>
    910*/
    1011/*
     
    4041function qq_avatar($original_img,$comment_info){
    4142    if (is_object($comment_info)){
    42    
    43         if ( !is_dir(CACHE) ){
    44             mkdir( CACHE );
     43        $cache = get_home_path().CACHE;
     44        if ( !is_dir($cache) ){
     45            mkdir( $cache );
    4546        }
    46         if ( isset($comment_info->comment_author_email) && preg_match('/^\[email protected]/',$comment_info->comment_author_email) ){
     47       
     48        if ( isset($comment_info->comment_author_email) && preg_match('/^\d+@(vip\.)?qq.com$/',$comment_info->comment_author_email) ){
    4749            //Thank FSM, It's an QQ number
    4850            $qq_uin = explode("@", $comment_info->comment_author_email);
     
    5052            $qq_uin_md5 = md5($qq_uin);
    5153           
    52             if (file_exists(CACHE.'/'.$qq_uin_md5.'.jpg')){
     54            $file_url = "$cache/$qq_uin_md5.jpg";
     55
     56            if (file_exists("$cache/$qq_uin_md5.jpg")){
     57               
    5358                $original_img = preg_replace("/src='[^']*'/",
    5459                      "src='".get_home_url().'/'.CACHE."/$qq_uin_md5.jpg'",
     
    5863           
    5964            $response = wp_remote_get( QQ_REQUEST.$qq_uin,
    60                                         array('user-agent'=>QQ_REQUEST_UA)
     65                                        array('user-agent'=>QQ_REQUEST_UA,
     66                                               'timeout'=>1
     67                                        )
    6168                                     );
    6269           
     
    6875                                                $response['body']
    6976                                                ));
    70                                                
     77                if (!is_numeric($qq_info->uin)){
     78                    //how the hell you get through this...                     
     79                    return $original_img;
     80                }
    7181               
    72                 $pic_url = CACHE.'/'.md5($qq_info->uin).'.jpg';
     82                $qq_uin_md5 = md5($qq_info->uin);//yes, it's recheck.
     83                $pic_path = "$cache/$qq_uin_md5.jpg";
    7384               
    74                 if (isset($qq_info->avatarUrl) && !file_exists($pic_url)){
     85                if (isset($qq_info->avatarUrl) && !file_exists($pic_path)){
    7586               
    76                     $pic_handle = wp_remote_get($qq_info->avatarUrl);
     87                    $pic_handle = wp_remote_get($qq_info->avatarUrl,
     88                                                 array('user-agent'=>QQ_REQUEST_UA,
     89                                                'timeout'=>1
     90                                        ));
     91                    if ($pic_handle['response']['code'] != 200){
     92                        return $original_img;
     93                    }                   
     94                   
    7795                    $pic_handle = $pic_handle['body'];
    7896                   
    79                     $temp_pic = fopen( $pic_url,'wb+');
    80                     fwrite($temp_pic,$pic_handle);
     97                    $temp_pic = fopen( $pic_path,'wb+');
     98                   
     99                    if (fwrite($temp_pic,$pic_handle)){
     100                          $original_img = preg_replace("/src='[^']*'/",
     101                                  "src='".get_home_url().'/'.CACHE."/$qq_uin_md5.jpg'",
     102                                   $original_img);
     103                    }
     104                   
    81105                    fclose($temp_pic);
    82106                }
    83                
    84                 $original_img = preg_replace("/src='[^']*'/",
    85                                   "src='".get_home_url()."/$pic_url'",
    86                                    $original_img);
    87107            }
    88108        }
  • qq-avatar/trunk/readme.txt

    r477817 r477926  
    11=== QQ Avatar ===
    22Contributors: allarem
    3 Tags: avatar,qq
     3Tags: avatar,qq,头像
    44Requires at least: 3.1
    55Tested up to: 3.3
    6 Stable tag: 0.2
     6Stable tag: 0.3
    77License: GPLv2 or later
    88
    9 Replace Gravatar while commenter use QQ numeric email address.
     9Replace Gravatar while commenter use QQ numeric email address.如果用户使用数字QQ邮箱留言且公开空间头像,就替换成QQ头像。
    1010
    1111== Description ==
     
    1717You've done it !
    1818
     19== MD5 ==
     20If you find out that your php-file's md5 doesn't match in the changlog, please reinstall to reassure safty.
     21如果您的文件MD5散列值与Changlog里的不符,请重新下载并安装以保证安全
     22
    1923== Changelog ==
     24
     25= 0.3 =
     26b53efa6c4e95783e59b8376c35dfa304  qq-avatar.php
     27*FIXED:avatar won't show while in wp-admin panel
     28*IMPROVE:Set 1 sencond as timeout to improve performance.
    2029
    2130= 0.2 =
Note: See TracChangeset for help on using the changeset viewer.