Changeset 567376
- Timestamp:
- 07/04/2012 02:19:17 PM (14 years ago)
- Location:
- hypercomments/trunk
- Files:
-
- 3 edited
-
comments.php (modified) (1 diff)
-
hypercomments.php (modified) (11 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
hypercomments/trunk/comments.php
r508796 r567376 1 1 <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;?> 3 17 </div> -
hypercomments/trunk/hypercomments.php
r561105 r567376 4 4 Plugin URI: http://hypercomments.com/ 5 5 Description: HyperComments - New dimension of comments. Hypercomments technology allows commenting a specific word or a piece of text. 6 Version: 1.0. 76 Version: 1.0.8 7 7 Author: Alexandr Bazik, Dmitry Goncharov, Inna Goncharova 8 8 Author URI: http://hypercomments.com/ … … 40 40 global $wpdb; 41 41 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'); 44 44 } 45 45 … … 102 102 if($signature == md5(get_option('hc_secret_key').$data_sign.$time)){ 103 103 $data_decode = json_decode($data_sign); 104 foreach($data_decode as $cmd){ 105 104 foreach($data_decode as $cmd){ 106 105 switch($cmd->cmd){ 107 106 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( 112 111 'comment_post_ID' => $post_id, 113 112 'comment_author' => $cmd->nick, … … 150 149 } 151 150 } 152 153 151 } 154 152 /** … … 175 173 */ 176 174 function 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'); 183 181 } 184 182 /** … … 255 253 ?> 256 254 <?php 257 if(hc_enableParams()){258 echo '_hcp.enableParams=true;';259 }255 if(hc_enableParams()){ 256 echo '_hcp.enableParams=true;'; 257 } 260 258 ?> 261 259 (function() { … … 272 270 */ 273 271 function 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'])){ 277 275 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'])){ 282 280 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'])){ 287 285 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'); 294 292 } 295 293 /** … … 297 295 */ 298 296 function 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 ); 307 305 } 308 306 /** … … 345 343 * @return string 346 344 */ 347 function hc_the_content_filter( $content ) {345 function hc_the_content_filter( $content ){ 348 346 global $post; 349 347 global $is_append; 350 348 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 } 360 361 } 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 } 381 383 return $content; 382 384 } … … 390 392 get_currentuserinfo(); 391 393 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_email397 );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.'";'; 404 406 }else{ 405 $hcp = '';407 $hcp = ''; 406 408 } 407 409 return $hcp; … … 422 424 return $avatar_src; 423 425 } 424 ?> 426 /** 427 * Detect Search Bot 428 * @param type $user_agent 429 * @return boolean 430 */ 431 function 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 */ 453 function 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 4 4 Donate link: http://hypercomments.com/ 5 5 Tags: hyperComments, comments, threaded, email, notification, spam, avatars, community, profile, widget 6 Requires at least: 1.0. 77 Tested up to: 1.0. 78 Stable tag: 1.0. 76 Requires at least: 1.0.8 7 Tested up to: 1.0.8 8 Stable tag: 1.0.8 9 9 10 10 The HyperComments technology replaces your WordPress comment system with your comments hosted and powered by HyperComments … … 95 95 96 96 == Changelog == 97 **1.0.8** 98 99 Improved the search engine optimization 100 97 101 **1.0.7** 98 102
Note: See TracChangeset
for help on using the changeset viewer.