Plugin Directory

Changeset 567376


Ignore:
Timestamp:
07/04/2012 02:19:17 PM (14 years ago)
Author:
siteheart
Message:
 
Location:
hypercomments/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • hypercomments/trunk/comments.php

    r508796 r567376  
    11<div id="HyperComments_Box">
    2 <?php echo hc_show_script();?>
     2<?php if(!hc_searchbot_detect($_SERVER['HTTP_USER_AGENT'])):?>
     3    <?php echo hc_show_script();?> 
     4<?php else:?>   
     5    <?php $comments = hc_get_comments_post();?>     
     6    <?php for($i=0;$i<count($comments);$i++):?>
     7    <div style='position:relative;padding:5px;font-size:12px;'>
     8        <div  style='position:absolute;'><?php echo get_avatar($comments[$i]->user_id)?></div>
     9        <div style='margin-left:50px;'>
     10            <div style='float:left;margin-right:5px;color:#3B5998;font-size: 11px;font-family: tahoma,verdana,arial,sans-serif;font-weight: bold;'><?php echo $comments[$i]->comment_author;?></div>
     11            <div style='color: gray;font-size:10px;'><?php echo $comments[$i]->comment_date;?></div>
     12            <div style='padding:5px;'><?php echo $comments[$i]->comment_content;?></div>
     13        </div>
     14    </div>
     15    <?php endfor;?>
     16<?php endif;?>
    317</div>
  • hypercomments/trunk/hypercomments.php

    r561105 r567376  
    44Plugin URI: http://hypercomments.com/
    55Description: HyperComments - New dimension of comments. Hypercomments technology allows commenting a specific word or a piece of text.
    6 Version: 1.0.7
     6Version: 1.0.8
    77Author:  Alexandr Bazik, Dmitry Goncharov, Inna Goncharova
    88Author URI: http://hypercomments.com/
     
    4040    global $wpdb;
    4141   
    42     if (function_exists('load_plugin_textdomain')) {
    43          load_plugin_textdomain('hypercomments', 'wp-content/plugins/hypercomments/locales');
     42    if(function_exists('load_plugin_textdomain')) {
     43        load_plugin_textdomain('hypercomments', 'wp-content/plugins/hypercomments/locales');
    4444    }
    4545
     
    102102                         if($signature == md5(get_option('hc_secret_key').$data_sign.$time)){
    103103                             $data_decode = json_decode($data_sign);                                   
    104                              foreach($data_decode as $cmd){
    105                                  
     104                             foreach($data_decode as $cmd){                                 
    106105                                 switch($cmd->cmd){
    107106                                     case 'streamMessage':                                       
    108                                          $post_id_mas = explode('?', $cmd->xid);
    109                                          $pos = strpos($cmd->xid,'=');                                         
    110                                          $post_id = substr($cmd->xid, $pos+1);
    111                                          $data = array(
     107                                        $post_id_mas = explode('?', $cmd->xid);
     108                                        $pos = strpos($cmd->xid,'=');                                         
     109                                        $post_id = substr($cmd->xid, $pos+1);
     110                                        $data = array(
    112111                                            'comment_post_ID' => $post_id,
    113112                                            'comment_author' => $cmd->nick,                                         
     
    150149        }
    151150    }
    152 
    153151}
    154152/**
     
    175173 */
    176174function hc_delete(){ 
    177      delete_option('hc_wid');
    178      delete_option('hc_access');
    179      delete_option('hc_selector');
    180      delete_option('hc_title_widget');
    181      delete_option('hc_secret_key');
    182      delete_option('hc_synch');
     175    delete_option('hc_wid');
     176    delete_option('hc_access');
     177    delete_option('hc_selector');
     178    delete_option('hc_title_widget');
     179    delete_option('hc_secret_key');
     180    delete_option('hc_synch');
    183181}
    184182/**
     
    255253?>
    256254<?php
    257       if(hc_enableParams()){
    258             echo '_hcp.enableParams=true;';
    259        }
     255    if(hc_enableParams()){
     256        echo '_hcp.enableParams=true;';
     257    }
    260258 ?>
    261259(function() {
     
    272270 */
    273271function hc_options_page() {
    274      if( $_POST['hc_form_counter_sub'] == 'Y' ) {
    275          update_option( 'hc_selector',  $_POST['hc_form_selector'] );
    276          if(isset($_POST['hc_title_widget'])){
     272    if( $_POST['hc_form_counter_sub'] == 'Y' ) {
     273        update_option( 'hc_selector',  $_POST['hc_form_selector'] );
     274        if(isset($_POST['hc_title_widget'])){
    277275            update_option( 'hc_title_widget',  $_POST['hc_title_widget'] );
    278          }else{
    279              delete_option('hc_title_widget');
    280          }
    281          if(isset($_POST['hc_synch'])){
     276        }else{
     277            delete_option('hc_title_widget');
     278        }
     279        if(isset($_POST['hc_synch'])){
    282280            update_option( 'hc_synch',  $_POST['hc_synch'] );
    283          }else{
    284              delete_option('hc_synch');
    285          }
    286          if(isset($_POST['hc_secret_key'])){
     281        }else{
     282            delete_option('hc_synch');
     283        }
     284        if(isset($_POST['hc_secret_key'])){
    287285            update_option( 'hc_secret_key',  $_POST['hc_secret_key'] );
    288          }else{
    289              delete_option('hc_secret_key');
    290          }
    291          echo '<div class="updated"><p><strong>'.__('Options saved', 'hypercomments').'</strong></p></div>';
    292      }
    293      include_once(dirname(__FILE__) . '/manage.php');
     286        }else{
     287            delete_option('hc_secret_key');
     288        }
     289        echo '<div class="updated"><p><strong>'.__('Options saved', 'hypercomments').'</strong></p></div>';
     290    }
     291    include_once(dirname(__FILE__) . '/manage.php');
    294292}
    295293/**
     
    297295 */
    298296function hc_add_pages() {
    299      add_submenu_page(
    300          'edit-comments.php',
    301          'HyperComments',
    302          'HyperComments',
    303          'moderate_comments',
    304          'hypercomments',
    305          'hc_options_page'
    306      );
     297    add_submenu_page(
     298        'edit-comments.php',
     299        'HyperComments',
     300        'HyperComments',
     301        'moderate_comments',
     302        'hypercomments',
     303        'hc_options_page'
     304    );
    307305}
    308306/**
     
    345343 * @return string
    346344 */
    347 function hc_the_content_filter( $content ) {
     345function hc_the_content_filter( $content ){
    348346    global $post;     
    349347    global $is_append;   
    350348    global $user;
    351     $parse = parse_url($post->guid);
    352     $url = str_replace('https://','',str_replace('http://','',str_replace('www.','',str_replace($parse['host'], get_option('home'), $post->guid)))); 
    353     if(get_option('hc_title_widget')){
    354         if($post->comment_status == 'open'){ 
    355             if ( !is_singular()){         
    356                 $content = sprintf(
    357                     '%s<div class="hc_content_comments" data-xid="'.$url.'"></div>',
    358                   $content         
    359                 );
     349
     350    if(!hc_searchbot_detect($_SERVER['HTTP_USER_AGENT'])){
     351        $parse = parse_url($post->guid);
     352        $url = str_replace('https://','',str_replace('http://','',str_replace('www.','',str_replace($parse['host'], get_option('home'), $post->guid)))); 
     353        if(get_option('hc_title_widget')){
     354            if($post->comment_status == 'open'){ 
     355                if ( !is_singular()){         
     356                    $content = sprintf(
     357                        '%s<div class="hc_content_comments" data-xid="'.$url.'"></div>',
     358                      $content         
     359                    );
     360                }
    360361            }
    361         }
    362     }   
    363    
    364    if( is_singular()){   
    365        if($post->comment_status == 'open'){   
    366            $is_append = true;
    367          
    368            $wid = '<div id="hypercomments_widget"></div>
    369            <script type="text/javascript">         
    370            var _hcp = _hcp || {};_hcp.widget_id = '.get_option('hc_wid').';_hcp.widget = "Stream";_hcp.platform="wordpress";
    371            _hcp.language = "'.hc_get_language().'";_hcp.xid = "'.$url.'";'.hc_get_auth().'         
    372            (function() {
    373             var hcc = document.createElement("script"); hcc.type = "text/javascript"; hcc.async = true;
    374             hcc.src = ("https:" == document.location.protocol ? "https" : "http")+"://widget.hypercomments.com/apps/js/hc.js";
    375             var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hcc, s.nextSibling);
    376             })();
    377             </script>';
    378             $content = $content.$wid;     
    379        }
    380    }
     362        }   
     363       
     364        if(is_singular()){   
     365            if($post->comment_status == 'open'){   
     366                $is_append = true;         
     367                $wid = '<div id="hypercomments_widget"></div>
     368                <script type="text/javascript">                       
     369                var _hcp = _hcp || {};_hcp.widget_id = '.get_option('hc_wid').';_hcp.widget = "Stream";_hcp.platform="wordpress";
     370                _hcp.language = "'.hc_get_language().'";_hcp.xid = "'.$url.'";'.hc_get_auth().'         
     371                (function() {
     372                var hcc = document.createElement("script"); hcc.type = "text/javascript"; hcc.async = true;
     373                hcc.src = ("https:" == document.location.protocol ? "https" : "http")+"://widget.hypercomments.com/apps/js/hc.js";
     374                var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hcc, s.nextSibling);
     375                })();
     376                </script>';
     377                $content = $content.$wid;     
     378            }
     379        }
     380    }else{
     381        $is_append = true;
     382    }
    381383    return $content;
    382384}
     
    390392    get_currentuserinfo();
    391393    if(is_user_logged_in() && get_option('hc_synch')){
    392          $user = array(
    393                 'nick'   => $current_user->user_nicename,
    394                 'avatar' => hc_parse_avatar($current_user->ID, 36),
    395                 'id'     => $current_user->ID,
    396                 'email'  => $current_user->user_email
    397           );
    398           $secret = get_option('hc_secret_key');
    399           $time   = time();   
    400           $base64 = base64_encode(json_encode($user));   
    401           $sign   = md5($secret . $base64 . $time);
    402           $auth = $base64 . "_" . $time . "_" . $sign;
    403           $hcp = '_hcp.auth="'.$auth.'";';             
     394        $user = array(
     395            'nick'   => $current_user->user_nicename,
     396            'avatar' => hc_parse_avatar($current_user->ID, 36),
     397            'id'     => $current_user->ID,
     398            'email'  => $current_user->user_email
     399        );
     400        $secret = get_option('hc_secret_key');
     401        $time   = time();   
     402        $base64 = base64_encode(json_encode($user));   
     403        $sign   = md5($secret . $base64 . $time);
     404        $auth = $base64 . "_" . $time . "_" . $sign;
     405        $hcp = '_hcp.auth="'.$auth.'";';             
    404406    }else{
    405           $hcp = '';
     407        $hcp = '';
    406408    }
    407409    return $hcp;
     
    422424    return $avatar_src;
    423425}
    424 ?>
     426/**
     427 * Detect Search Bot
     428 * @param type $user_agent
     429 * @return boolean
     430 */
     431function hc_searchbot_detect($user_agent)
     432{
     433    $engines = array(
     434            'Aport','Google','msnbot','Rambler','Yahoo','AbachoBOT',
     435            'accoona','AcoiRobot','ASPSeek','CrocCrawler','Dumbot',
     436            'FAST-WebCrawler','GeonaBot','Gigabot','Lycos','MSRBOT',
     437            'Scooter','AltaVista','WebAlta','IDBot','eStyle','Mail.Ru',
     438            'Scrubby','Yandex','YaDirectBot'
     439        );
     440    foreach ($engines as $engine) {
     441        if(strstr(strtolower($user_agent), strtolower($engine))){
     442            return true;
     443        }
     444    }
     445    return false;
     446}
     447/**
     448 * Return all post comments
     449 * @global type $wpdb
     450 * @global type $post
     451 * @return boolean array
     452 */
     453function hc_get_comments_post()
     454{
     455    global $wpdb;
     456    global $post;
     457    $commentQ = "SELECT * FROM $wpdb->comments WHERE comment_post_ID=".$post->ID ;
     458    $comments = $wpdb->get_results( $wpdb->prepare($commentQ));
     459    return $comments;
     460}
     461?>
  • hypercomments/trunk/readme.txt

    r561105 r567376  
    44Donate link: http://hypercomments.com/
    55Tags: hyperComments, comments, threaded, email, notification, spam, avatars, community, profile, widget
    6 Requires at least: 1.0.7
    7 Tested up to: 1.0.7
    8 Stable tag: 1.0.7
     6Requires at least: 1.0.8
     7Tested up to: 1.0.8
     8Stable tag: 1.0.8
    99
    1010The HyperComments technology replaces your WordPress comment system with your comments hosted and powered by HyperComments
     
    9595
    9696== Changelog ==
     97**1.0.8**
     98
     99Improved the search engine optimization
     100
    97101**1.0.7**
    98102
Note: See TracChangeset for help on using the changeset viewer.