WordPress.org

Plugin Directory

Changeset 617985


Ignore:
Timestamp:
10/27/12 09:15:09 (18 months ago)
Author:
SteveAtty
Message:

Version 2.1.23 minor bug fixes

Location:
wordbooker
Files:
4 deleted
7 edited
27 copied

Legend:

Unmodified
Added
Removed
  • wordbooker/tags/2.1.23/includes/wordbooker_comments.php

    r548667 r617985  
    55Author: Stephen Atty 
    66Author URI: http://wordbooker.tty.org.uk 
    7 Version: 2.1.1 
     7Version: 2.1.22 
    88*/ 
    99 
    1010function wordbooker_poll_comments($userid=0) { 
    11     wordbooker_debugger("Comment handling starting "," ",-2,9) ;  
    12     global  $wpdb, $user_ID,$table_prefix,$blog_id,$comment_user;    
    13     $wordbooker_settings=get_option('wordbooker_settings');  
    14         $result = $wpdb->query('DELETE FROM ' . WORDBOOKER_ERRORLOGS . ' WHERE timestamp < DATE_SUB(CURDATE(), INTERVAL '.( $wordbooker_settings['wordbooker_comment_cron'] * 3 ) .' MINUTE)  and blog_id ='.$blog_id.' and post_id=-2'); 
     11    global  $wpdb, $user_ID,$table_prefix,$blog_id,$comment_user; 
     12    $comment_user=1;     
     13    wordbooker_debugger("Comment handling starting "," ",-3,9) ; 
     14    $wordbooker_settings=get_option('wordbooker_settings');      
     15    $result = $wpdb->query('DELETE FROM ' . WORDBOOKER_ERRORLOGS . ' WHERE timestamp < DATE_SUB(CURDATE(), INTERVAL '.( $wordbooker_settings['wordbooker_comment_cron'] * 3 ) .' MINUTE)  and blog_id ='.$blog_id.' and post_id=-2'); 
    1516    if (! $wordbooker_settings['wordbooker_comment_handling']) { 
    16         wordbooker_debugger("Comment handling disabled "," ",-2,9) ; 
     17        wordbooker_debugger("Comment handling disabled "," ",-3,9) ; 
    1718        return; 
    1819     } 
     
    2223    $rows = $wpdb->get_results($sql); 
    2324    foreach ($rows as $comment_row) { 
    24     $comment_user=$comment_row->user_ID;  
    25     wordbooker_debugger("Processing comments for ".$comment_row->name," ",-2,9) ; 
    26     wordbooker_debugger("Processing your comments "," ",-3,9) ;  
    27     if (!isset($wordbooker_settings['wordbooker_comment_pull']) ) {  
    28         wordbooker_debugger("Starting Incoming comment handling"," ",-2,9); 
    29         $incoming=wordbooker_get_comments_from_facebook($comment_row->user_ID); 
    30         wordbooker_debugger("Incoming comment handling completed"," ",-2,9); 
    31      }   
    32     else {wordbooker_debugger("Incoming comment handling disabled "," ",-2,9) ; } 
    33     $outgoing=0; 
    34     if (!isset($wordbooker_settings['wordbooker_comment_push']) ) {  
    35     wordbooker_debugger("Starting Outgoing comment handling"," ",-2,9); 
    36     $outgoing=wordbooker_post_comments_to_facebook($comment_row->user_ID); 
    37     wordbooker_debugger("Outgoing comment handling completed"," ",-2,9); 
     25        $comment_user=$comment_row->user_ID;  
     26        wordbooker_debugger("Processing comments for ".$comment_row->name," ",-3,9) ; 
     27        wordbooker_debugger("Processing your comments "," ",-3,9) ;  
     28        if (!isset($wordbooker_settings['wordbooker_comment_pull']) ) {  
     29            wordbooker_debugger("Starting Incoming comment handling"," ",-3,9); 
     30            $incoming=wordbooker_get_comments_from_facebook($comment_row->user_ID); 
     31            wordbooker_debugger("Incoming comment handling completed"," ",-3,9); 
     32         }   
     33        else {wordbooker_debugger("Incoming comment handling disabled "," ",-3,9) ; } 
     34        $outgoing=0; 
     35        if (!isset($wordbooker_settings['wordbooker_comment_push']) ) {  
     36            wordbooker_debugger("Starting Outgoing comment handling"," ",-3,9); 
     37            $outgoing=wordbooker_post_comments_to_facebook($comment_row->user_ID); 
     38            wordbooker_debugger("Outgoing comment handling completed"," ",-3,9); 
     39        }    
     40        else {wordbooker_debugger("Outgoing comment handling disabled "," ",-3,9) ; } 
     41        wordbooker_debugger("Completed comment processing for ".$comment_row->name," In : ".$incoming." - Out : ".$outgoing,-3,9) ;  
     42        wordbooker_debugger("Completed your comment processing "," In : ".$incoming." - Out : ".$outgoing,-3,9) ;  
    3843    }    
    39     else {wordbooker_debugger("Outgoing comment handling disabled "," ",-2,9) ; } 
    40     wordbooker_debugger("Completed comment processing for ".$comment_row->name," In : ".$incoming." - Out : ".$outgoing,-2,9) ;  
    41     wordbooker_debugger("Completed your comment processing "," In : ".$incoming." - Out : ".$outgoing,-3,9) ;  
    42 #   $sql="insert into ".WORDBOOKER_POSTCOMMENTS." (user_id,blog_id,comment_timestamp,fb_post_id,wp_post_id,in_out) values (".$userid.",".$blog_id.",'".$processed_time."','".$incoming."','".$outgoing."','stat')"; 
    43 #   $wpdb->query($sql); 
    44     }    
    45     wordbooker_debugger("Comment handling completed "," ",-2,9) ;  
     44    wordbooker_debugger("Comment handling completed "," ",-3,9) ;  
    4645} 
    4746 
     
    4948    global  $wpdb, $user_ID,$table_prefix,$blog_id,$comment_user;    
    5049    $processed_posts=0; 
     50    $comment_user=$user_id; 
     51    $wbuser = wordbooker_get_userdata($user_id); 
     52    if (strlen($wbuser->access_token)<20) { 
     53        wordbooker_debugger("No user session for comment handling "," ",-3,9) ; 
     54        return 0;  
     55    } 
     56    $wordbooker_settings=wordbooker_options(); 
    5157    $close_comments=get_option('close_comments_for_old_posts'); 
    5258    $close_days_old=get_option('close_comments_days_old'); 
    53     $wbuser = wordbooker_get_userdata($user_id); 
    54     if (strlen($wbuser->access_token)<20) { 
    55     wordbooker_debugger("No user session for comment handling "," ",-2,9) ; 
    56     return 0; } 
    57     $wordbooker_settings=wordbooker_options(); 
    5859    $comment_structure=$wordbooker_settings['wordbooker_comment_post_format']; 
    5960    $comment_tag=$wordbooker_settings['wordbooker_comment_attribute']; 
    60     wordbooker_debugger("Auto close comments ".$close_comments,$close_days_old,-2,98); 
     61    $wordbooker_close=$wordbooker_settings['wordbooker_close_comment']; 
     62    wordbooker_debugger("Auto close comments ".$close_comments,$close_days_old,-3,98); 
    6163    $sql="select distinct wp_post_id,fb_post_id from ".WORDBOOKER_POSTCOMMENTS." where fb_comment_id is null and blog_id=".$blog_id." and user_id=".$user_id." and in_out is null"; 
    6264    if ($close_comments==1) {$sql.=" and comment_timestamp  > DATE_SUB( CURDATE( ) , INTERVAL ".$close_days_old." DAY )";} 
     65    if ($wordbooker_close>0) {$sql.=" and comment_timestamp > DATE_SUB( CURDATE( ) , INTERVAL ".$wordbooker_close." DAY )";} 
    6366    $rows = $wpdb->get_results($sql); 
    6467 
    65     wordbooker_debugger("Blog posts for comment handling : ".$sql,count($rows),-2,98); 
     68    wordbooker_debugger("Blog posts for comment handling : ".$sql,count($rows),-3,98); 
    6669    foreach($rows as $row) { 
    67     wordbooker_debugger("Starting comment handling for WP post ".$row->wp_post_id,$row->fb_post_id,-2,9); 
    68     wordbooker_debugger("Starting comment handling for WP post ".$row->wp_post_id,$row->fb_post_id,-3,9); 
    69     $wordbooker_post_options = get_post_meta($row->wp_post_id, '_wordbooker_options', true); 
    70     if (!isset($wordbooker_post_options['wordbooker_comment_put'])) { 
    71         wordbooker_debugger("Outgoing comment disabled for WP post ".$row->wp_post_id,$row->fb_post_id,-2,9); 
    72         wordbooker_debugger("Outgoing comment disabled for WP post ".$row->wp_post_id,$row->fb_post_id,-3,9);    
    73         continue ; 
    74     } 
    75     $sql="select comment_ID from ".$wpdb->comments." where comment_post_id=".$row->wp_post_id." and comment_approved=1 and comment_id not in (select wp_comment_id from ".WORDBOOKER_POSTCOMMENTS." where  wp_post_id=".$row->wp_post_id." and fb_post_id='".$row->fb_post_id."' and user_id=".$user_id." and comment_post_id in (select ID from ".$wpdb->posts." WHERE comment_status='open'))"; 
    76     if ($close_comments==1) { $sql.="and comment_post_id in (select ID from ".$wpdb->posts." WHERE post_date > DATE_SUB( CURDATE( ) , INTERVAL ".$close_days_old."  
    77 DAY ))";} 
     70        wordbooker_debugger("Starting comment handling for WP post ".$row->wp_post_id,$row->fb_post_id,-3,9); 
     71        $wordbooker_post_options = get_post_meta($row->wp_post_id, '_wordbooker_options', true); 
     72        if (!isset($wordbooker_post_options['wordbooker_comment_put'])) { 
     73            wordbooker_debugger("Outgoing comment disabled for WP post ".$row->wp_post_id,$row->fb_post_id,-3,9);;   
     74            continue ; 
     75        } 
     76            $andlogic=""; 
     77        if ($wordbooker_close>0) { $andlogic=" and wpposts2.post_date > DATE_SUB( CURDATE( ) , INTERVAL ".$wordbooker_close." DAY )";} 
     78        $sql="select distinct comment_ID,comment_date from ".$wpdb->comments." wpcom, ".$wpdb->posts." wpposts2, ".WORDBOOKER_POSTCOMMENTS." wbcom2 where wpcom.comment_post_id=".$row->wp_post_id." and wpcom.comment_approved=1 and wpcom.comment_post_id = wpposts2.ID  and wbcom2.wp_post_id=wpposts2.ID and wbcom2.user_id=".$user_id." and wbcom2.blog_id=".$blog_id." and wbcom2.fb_post_id='".$row->fb_post_id."' and wpcom.comment_id not in (select distinct wp_comment_id from ".WORDBOOKER_POSTCOMMENTS." wbcom, ".$wpdb->posts." wpposts where wbcom.wp_post_id=".$row->wp_post_id." and wbcom.fb_post_id='".$row->fb_post_id."' and wbcom.user_id=".$user_id." and wbcom.wp_post_id = wpposts.ID and  wpposts.comment_status='open')".$andlogic; 
    7879        $results = $wpdb->get_results($sql); 
    79         wordbooker_debugger("Comments for processing : ".$sql,count($results),-2,98); 
    80         foreach($results as $result){            
     80        wordbooker_debugger("Comments for processing : ".$sql,count($results),-3,98); 
     81        foreach($results as $result){    
    8182            $x=0; 
    8283            $comment_content=parse_wordbooker_comment_attributes($result->comment_ID,$comment_structure,$comment_tag); 
     
    8889                $error_msg = $e->getMessage(); 
    8990                $err_no=(integer) substr($error_msg,2,3); 
    90                 wordbooker_debugger("Failed to post comment to Facebook : ".$error_msg,$row->fb_post_id,-2,9); 
    9191                wordbooker_debugger("Failed to post comment to Facebook : ".$error_msg,$row->fb_post_id,-3,9); 
    9292                if ($err_no=100) { 
     
    9696            } 
    9797            if (strlen($x->id)>2){ 
    98             $sql="insert into ".WORDBOOKER_POSTCOMMENTS." (wp_post_id,fb_post_id,wp_comment_id,fb_comment_id,user_id,blog_id,comment_timestamp,in_out) values (".$row->wp_post_id.",'".$row->fb_post_id."','".$result->comment_ID."','".$x->id."',".$user_id.",".$blog_id.",'".strtotime($result->comment_date)."','out')"; 
    99             $wpdb->query($sql); 
    100             wordbooker_debugger("Posting comment to Facebook Post : ".$row->fb_post_id." returns",$x->id,-2,9) ; 
    101             wordbooker_debugger("Posting comment to Facebook Post : ".$row->fb_post_id." returns",$x->id,-3,9) ; 
    102             $processed_posts=$processed_posts+1; 
    103             } 
    104         } 
    105         wordbooker_debugger("Finished comment handling for WP post ".$row->wp_post_id,$row->fb_post_id,-2,9); 
     98                $sql="insert into ".WORDBOOKER_POSTCOMMENTS." (wp_post_id,fb_post_id,wp_comment_id,fb_comment_id,user_id,blog_id,comment_timestamp,in_out) values (".$row->wp_post_id.",'".$row->fb_post_id."',".$result->comment_ID.",'".$x->id."',".$user_id.",".$blog_id.",'".strtotime($result->comment_date)."','out')"; 
     99                $wpdb->query($sql); 
     100                wordbooker_debugger("Posting comment to Facebook Post : ".$row->fb_post_id." returns",$x->id,-3,9) ; 
     101                $processed_posts=$processed_posts+1; 
     102            } 
     103        } 
    106104        wordbooker_debugger("Finished comment handling for WP post ".$row->wp_post_id,$row->fb_post_id,-3,9); 
    107105    } 
     
    112110    global $wpdb,$blog_id,$comment_user; 
    113111    $processed_posts=0; 
     112    $comment_user=$user_id; 
    114113    $wbuser = wordbooker_get_userdata($user_id); 
    115114    if (strlen($wbuser->access_token)<20) { 
    116     wordbooker_debugger("No user session for comment handling "," ",-2,9) ; 
    117     return 0; } 
     115        wordbooker_debugger("No user session for comment handling "," ",-3,9) ; 
     116        return 0;  
     117    } 
     118    $close_comments=get_option('close_comments_for_old_posts'); 
     119    $close_days_old=get_option('close_comments_days_old'); 
    118120    $wordbooker_settings=get_option('wordbooker_settings');  
     121    $wordbooker_close=$wordbooker_settings['wordbooker_close_comment']; 
    119122    $comment_approve=0; 
    120123    if (isset($wordbooker_settings['wordbooker_comment_approve'])) {$comment_approve=1;} 
    121124    $sql='Select distinct fb_post_id from '.WORDBOOKER_POSTCOMMENTS.' where fb_comment_id is null and user_id='.$user_id.' and blog_id='.$blog_id. " and in_out is null "; 
     125    if ($close_comments==1) { $sql.=" and comment_timestamp  > DATE_SUB( CURDATE( ) , INTERVAL ".$close_days_old." DAY )";} 
     126    if ($wordbooker_close>0) {$sql.=" and comment_timestamp  > DATE_SUB( CURDATE( ) , INTERVAL ".$wordbooker_close." DAY )";} 
    122127    $rows = $wpdb->get_results($sql); 
    123     wordbooker_debugger("Blog posts with FB Posts against them : ".$sql,count($rows),-2,98); 
     128    wordbooker_debugger("Blog posts with FB Posts against them : ".$sql,count($rows),-3,98); 
    124129    foreach ($rows as $fb_comment) { 
    125         wordbooker_debugger("Starting comment handling for FB post ".$fb_comment->fb_post_id,"",-2,9); 
    126130        wordbooker_debugger("Starting comment handling for FB post ".$fb_comment->fb_post_id,"",-3,9); 
    127     #   $sql="select fb_comment_id from ".WORDBOOKER_POSTCOMMENTS." where fb_post_id='".$fb_comment->fb_post_id."' and in_out!='out' and in_out!='stat' order by comment_timestamp desc"; 
    128     #   $from_comment=$wpdb->get_row($sql); 
    129131        try { 
    130132            $all_comments=wordbooker_fb_get_comments($fb_comment->fb_post_id,$wbuser->access_token); 
    131             wordbooker_debugger("Comments pulled from Facebook",count($all_comments->data),-2,9); 
     133            wordbooker_debugger("Comments pulled from Facebook",count($all_comments->data),-3,9); 
    132134        } 
    133135        catch (Exception $e)  
     
    135137            $error_msg = $e->getMessage(); 
    136138            $err_no=(integer) substr($error_msg,2,3); 
    137             wordbooker_debugger("Failed to get comment from Facebook : ".$error_msg,$row->fb_post_id,-2,9); 
    138139            wordbooker_debugger("Failed to get comment from Facebook : ".$error_msg,$row->fb_post_id,-3,9); 
    139140        } 
     
    143144                $sql="Select fb_comment_id from ".WORDBOOKER_POSTCOMMENTS." where fb_comment_id='".$single_comment->id."'"; 
    144145                $commq=$wpdb->query($sql); 
    145             #   wordbooker_debugger("running  ".$sql," Returns ".$commq,-2,8); 
    146             #   wordbooker_debugger("running  ".$sql," Returns ".$commq,-3,8); 
    147146                if(!$commq) { 
    148                     wordbooker_debugger("Found new comment for FB post ".$fb_comment->fb_post_id,"from : ".$single_comment->from->name,-2,9); 
    149147                    wordbooker_debugger("Found new comment for FB post ".$fb_comment->fb_post_id,"from : ".$single_comment->from->name,-3,9); 
    150148                    $commemail=$wordbooker_settings['wordbooker_comment_email']; 
     
    154152                    $sql="select distinct wp_post_id from ".WORDBOOKER_POSTCOMMENTS." where fb_post_id='".$fb_comment->fb_post_id."'"; 
    155153                    $wp_post_rows = $wpdb->get_results($sql); 
    156                     wordbooker_debugger("Blogs posts to send comment to : ".$sql,count($wp_post_rows),-2,98); 
     154                    wordbooker_debugger("Blogs posts to send comment to : ".$sql,count($wp_post_rows),-3,98); 
    157155                    foreach ($wp_post_rows as $wp_post_row) { 
    158156                        $wordbooker_post_options = get_post_meta($wp_post_row->wp_post_id, '_wordbooker_options', true); 
    159157                        if (!isset($wordbooker_post_options['wordbooker_comment_get'])) { 
    160                             wordbooker_debugger("Incoming comments disabled for WP post ".$wp_post_row->wp_post_id,' ',-2,9); 
    161158                            wordbooker_debugger("Incoming comments disabled for WP post ".$wp_post_row->wp_post_id,' ',-3,9);    
    162159                            continue ; 
     
    183180                        update_comment_meta($newComment, "fb_uid", $single_comment->from->id); 
    184181                        update_comment_meta($newComment, “akismet_result”, true); 
    185                         #wordbooker_debugger("Inserted comment from ".$single_comment->from->name." into ".$wp_post_row->wp_post_id,"",-2,9); 
    186182                        wordbooker_debugger("Inserted comment from ".$single_comment->from->name." into ".$wp_post_row->wp_post_id." as ".$newComment,"",-3,9); 
    187183                        $sql="Insert into ".WORDBOOKER_POSTCOMMENTS." (fb_post_id,user_id,comment_timestamp,wp_post_id,blog_id,wp_comment_id,fb_comment_id,in_out) values ('".$fb_comment->fb_post_id."',".$user_id.",".strtotime($single_comment->created_time).",".$wp_post_row->wp_post_id.",".$blog_id.",".$newComment.",'".$single_comment->id."','in' )"; 
    188184                        $commq2=$wpdb->query($sql); 
    189                     #   wordbooker_debugger("Updating Comments table - running  ".$sql," Returns ".$commq2,-2,9); 
    190                     #   wordbooker_debugger("Updating Comments table - running  ".$sql," Returns ".$commq2,-3,9); 
    191185                        $processed_posts=$processed_posts+1; 
    192186                    } 
    193                     wordbooker_debugger("Finished comment inserts for FB post ".$fb_comment->fb_post_id,"",-2,9); 
    194187                    wordbooker_debugger("Finished comment inserts for FB post ".$fb_comment->fb_post_id,"",-3,9); 
    195188                } 
    196189               else { 
    197                     wordbooker_debugger("Found existing comment for FB post ".$fb_comment->fb_post_id,"from : ".$single_comment->from->name,-2,9); 
    198                     wordbooker_debugger("Found existing comment for FB post ".$fb_comment->fb_post_id,"from : ".$single_comment->from->name,-3,9);   
     190                    wordbooker_debugger("Found existing comment for FB post ".$fb_comment->fb_post_id,"from : ".$single_comment->from->name,-3,9); 
    199191                } 
    200192            } 
    201193        } 
    202         wordbooker_debugger("Finished comment handling for FB post ".$fb_comment->fb_post_id,"",-2,9); 
    203194        wordbooker_debugger("Finished comment handling for FB post ".$fb_comment->fb_post_id,"",-3,9); 
    204195    } 
  • wordbooker/tags/2.1.23/includes/wordbooker_cron.php

    r609159 r617985  
    1212    global $blog_id,$wpdb,$table_prefix,$wordbooker_user_settings_id,$wbooker_user_id; 
    1313    $wbooker_user_id=$user_id; 
    14     //wordbooker_renew_access_token($user_id); 
    1514    $result = $wpdb->query(' DELETE FROM ' . WORDBOOKER_ERRORLOGS . ' WHERE   blog_id ='.$blog_id.' and (user_ID='.$user_id.' or user_ID=0 ) and post_id<=1'); 
    1615    wordbooker_debugger("Cache Refresh Commence ",$user_id,-1,9) ;  
     
    4443        if($ret->error->message)  { 
    4544        wordbooker_append_to_errorlogs("Your Facebook Session is invalid", "99", $ret->error->message,'',$user_id); 
    46         #wordbooker_delete_user($user_id,1); 
    4745        return; 
    4846        } 
     
    186184        $all_pages_groups=@array_merge($all_pages,$all_groups); 
    187185        $encoded_names=str_replace('\\','\\\\',serialize($all_pages_groups)); 
    188 /* 
    189  
    190         try { 
    191             $query="SELECT flid, owner, name FROM friendlist WHERE owner=$uid"; 
    192             $fb_friend_lists= wordbooker_fql_query($query,$wbuser2->access_token); 
    193         if (is_array($fb_friend_lists)) { 
    194         $sql="Delete from ".WORDBOOKER_FB_FRIEND_LISTS." where user_id=".$user_id; 
    195         $result = $wpdb->get_results($sql); 
    196         foreach ($fb_friend_lists as $friend_list) { 
    197             if (function_exists('mb_convert_encoding')) { 
    198                 $friend_list->name=mb_convert_encoding($friend_list->name,'UTF-8'); 
    199             } 
    200         $sql="replace into ".WORDBOOKER_FB_FRIEND_LISTS." (user_id, flid,  owner, name) values (".$user_id.",'".$friend_list->flid."','".$friend_list->owner."','".$friend_list->name."')"; 
    201         $result = $wpdb->get_results($sql); 
    202         } 
    203         }    
    204  
    205         } 
    206         catch (Exception $e)  
    207         { 
    208             $error_msg = $e->getMessage(); 
    209             wordbooker_debugger("Failed to get friend lists : ",$error_msg,-1,9); 
    210         } 
    211  
    212   
    213         try { 
    214             $query="Select name,uid from user where uid in (Select uid from friendlist_member where flid='10150839623220195')"; 
    215             $fb_friends_info = wordbooker_fql_query($query,$wbuser2->access_token); 
    216         }  
    217         catch (Exception $e)  
    218         { 
    219             $error_msg = $e->getMessage(); 
    220             wordbooker_debugger("Failed to get friends : ",$error_msg,-1,9); 
    221         } 
    222             if (is_array($fb_friends_info) ) { 
    223             $sql="delete from ".WORDBOOKER_FB_FRIENDS." where user_id=".$user_id; 
    224             $result = $wpdb->get_results($sql); 
    225             foreach ($fb_friends_info as $friend_info) { 
    226                 if (function_exists('mb_convert_encoding')) { 
    227                     $friend_info->name=mb_convert_encoding($friend_info->name,'UTF-8'); 
    228                 } 
    229             $sql="insert into ".WORDBOOKER_FB_FRIENDS." (user_id, facebook_id, name, blog_id) values (".$user_id.",'".$friend_info->uid."','".$friend_info->name."',".$blog_id.")"; 
    230             $result = $wpdb->get_results($sql); 
    231             } 
    232         } 
    233 */ 
     186 
    234187        $fb_status_info=wordbooker_status_feed($suid,$wbuser2->access_token); 
    235         # put in check for not being an array and skip... 
    236         #var_dump($fb_status_info); 
    237         foreach($fb_status_info->data as $fbstat) { 
    238             if(!is_null($fbstat->message)){ 
    239                 //      var_dump($fbstat->to->data[0]->id); 
    240                 //      var_dump("XXXX".$fbstat->from->id); 
    241         //      var_dump($fbstat->message); 
    242             //  echo "<br />"; 
    243         //      var_dump($fbstat->from->id); 
    244         //      echo "<br />"; 
    245         //      var_dump($fbstat->to->data[0]->id); 
    246         //      echo "<br /><br />"; 
    247                 if (($suid==$fbstat->from->id) && (is_null($fbstat->to->data[0]->id ) )) { 
    248                     $status_message=$fbstat->message; 
    249                     $status_time=$fbstat->created_time; 
    250                     break;  
    251                 } 
    252              } 
     188        if (!is_null($fb_status_info)) { 
     189            foreach($fb_status_info->data as $fbstat) { 
     190                if(!is_null($fbstat->message)){ 
     191                //      var_dump($fbstat->message); 
     192            //      echo "<br />"; 
     193            //      var_dump($suid); 
     194            //      echo "<br />"; 
     195            //      var_dump($fbstat->from->id); 
     196            //      echo "<br />"; 
     197            //      var_dump($fbstat->to->data[0]->id); 
     198            //      echo "<br /><br />"; 
     199                    if (($suid==$fbstat->from->id) && (is_null($fbstat->to->data[0]->id ) )) { 
     200                        $status_message=$fbstat->message; 
     201                        $status_time=$fbstat->created_time; 
     202                        break;  
     203                    } 
     204                 } 
     205            } 
    253206        } 
    254207        $picture = 'https://graph.facebook.com/'.$suid.'/picture?type=normal'; 
     
    302255        $result = $wpdb->get_results($sql); 
    303256    } 
    304 #fclose($fp); 
    305257    wordbooker_debugger("Cache Refresh Complete for user",$uid,-1,90) ;  
    306258} 
     
    330282} 
    331283 
    332  
    333284?> 
  • wordbooker/tags/2.1.23/includes/wordbooker_facebook_curl.php

    r609159 r617985  
    8282    #   $url='http://ccgi.pemmaquid.plus.com/cgi-bin/refresh.cgi?oldie='.$access_token.'&version='.$version[0]; 
    8383    $url='https://wordbooker.tty.org.uk/refresh_curl.cgi?oldie='.$access_token.'&version='.$version[0]; 
    84     //var_dump($url); 
     84    var_dump($url); 
    8585    $x=wordbooker_make_curl_call2($url); 
    8686    wordbooker_debugger("Access token returns ",print_r($x,true),-5,98) ; 
  • wordbooker/tags/2.1.23/includes/wordbooker_options.php

    r605697 r617985  
    1616function worbooker_validate_options($options) { 
    1717    global $user_ID; 
     18    if ($options["wordbooker_close_comment"]<0) {$options["wordbooker_close_comment"]=0;} 
     19    if (!is_numeric($options["wordbooker_close_comment"])) {$options["wordbooker_close_comment"]=0;} 
    1820    # Do they want to reset? If so we reset the options and let WordPress do the business for us! 
    1921    if (isset( $_POST["mcp"] )) { 
     
    314316 
    315317        echo '<br /><label for="wb_action_link">'.__("Action Link Option ", 'wordbooker'). ': </label><select id="wordbooker_actionlink" name="wordbooker_settings[wordbooker_actionlink]"  >';  
    316              $arr = array(100=> "None ",  200=> __("Share Link ", 'wordbooker'), 300=>__("Read Full Article", 'wordbooker')); 
     318            if($wordbooker_settings['wordbooker_actionlink']==200) {$wordbooker_settings['wordbooker_actionlink']=100;} 
     319             $arr = array(100=> __("Share Link ", 'wordbooker'), 300=>__("Read Full Article", 'wordbooker')); 
    317320                foreach ($arr as $i => $value) { 
    318321                        if ($i==$wordbooker_settings['wordbooker_actionlink']){ print '<option selected="yes" value="'.$i.'" >'.$arr[$i].'</option>';} 
     
    486489        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_comment_handling]" '.$checked_flag[$wordbooker_settings["wordbooker_comment_handling"]].' /><br />'; 
    487490        echo '<label for="wb_import_comment">&nbsp;&nbsp;'.__("Disable Comment Importing", 'wordbooker'). ': </label>'; 
    488         echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_comment_pul]" '.$checked_flag[$wordbooker_settings["wordbooker_comment_pull"]]. '/> <br />'; 
     491        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_comment_pull]" '.$checked_flag[$wordbooker_settings["wordbooker_comment_pull"]]. '/> <br />'; 
    489492        echo '<label for="wb_import_comment">&nbsp;&nbsp;'.__("Disable Comment Exporting", 'wordbooker'). ': </label>'; 
    490493        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_comment_push]" '.$checked_flag[$wordbooker_settings["wordbooker_comment_push"]]. '/> <br />'; 
     
    505508        echo '<label for="wb_publish_comment_approve">'.__("Auto Approve imported comments", 'wordbooker'). ' :</label> '; 
    506509        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_comment_approve]" '.$checked_flag[$wordbooker_settings["wordbooker_comment_approve"]].' /><br />'; 
     510        echo '<label for="wb_attribute">'.__('Comment Cut off (days) ', 'wordbooker').' : </label>'; 
     511        if ($wordbooker_settings["wordbooker_close_comment"]<0) {$wordbooker_settings["wordbooker_close_comment"]=0;} 
     512        if (!is_numeric($wordbooker_settings["wordbooker_close_comment"])) {$wordbooker_settings["wordbooker_close_comment"]=0;} 
     513        $close_comments=get_option('close_comments_for_old_posts'); 
     514        $close_days_old=get_option('close_comments_days_old'); 
     515        echo '<INPUT NAME="wordbooker_settings[wordbooker_close_comment]" size=4 maxlength=4 value="'.stripslashes($wordbooker_settings["wordbooker_close_comment"]).'"> '.__('0 = Use blog settings', 'wordbooker'); 
     516        if ($close_comments) {$cdostring=sprintf(__("(Currently set to %s days)",'wordbooker'),$close_days_old); 
     517    } else {$cdostring=__("(Currently not set)",'wordbooker'); } 
     518        echo " ".$cdostring.'<br />'; 
    507519        if ($wordbooker_settings['wordbooker_comment_cron']!='Never') { 
    508520        echo '<br /><input type="submit" value="'.__("Run Comment Handling Now", 'wordbooker').'" name="mcp" class="button-primary"  />'; 
     
    751763    echo '<label for="wb_status_update">'.__('Facebook Status Text', 'wordbooker').'  : </label> '; 
    752764        echo '<INPUT NAME="wordbooker_status_update_text" size=60 maxlength=60 value="'.stripslashes($wordbookeruser_settings["wordbooker_status_update_text"]).'"> '; 
    753         echo '</select><br />'; 
     765        //echo '</select><br />'; 
    754766 
    755767        echo '<label for="wb_attribute">'.__('Post Attribute', 'wordbooker').' : </label>'; 
     
    757769 
    758770        echo '<label for="wb_action_link">'.__('Action Link Option', 'wordbooker').' : </label><select id="wordbooker_actionlink" name="wordbooker_actionlink"  >';  
    759             $arr = array(0=> __("Same as Blog", 'wordbooker'), 100=> __("None", 'wordbooker'),  200=> __("Share Link", 'wordbooker'), 300=>__("Read Full Article", 'wordbooker')); 
     771        if($wordbookeruser_settings['wordbooker_actionlink']==200) {$wordbookeruser_settings['wordbooker_actionlink']=100;} 
     772            $arr = array(0=> __("Same as Blog", 'wordbooker'), 100=> __("Share Link", 'wordbooker'), 300=>__("Read Full Article", 'wordbooker')); 
    760773                foreach ($arr as $i => $value) { 
    761774                        if ($i==$wordbookeruser_settings['wordbooker_actionlink']){ echo '<option selected="yes" value="'.$i.'" >'.$arr[$i].'</option>';} 
  • wordbooker/tags/2.1.23/includes/wordbooker_posting_options.php

    r605697 r617985  
    160160        } 
    161161            echo "</select><br />"; 
    162  
     162        if($wordbooker_settings['wordbooker_actionlink']==200) {$wordbooker_settings['wordbooker_actionlink']=100;} 
    163163        echo __('Action Link Option', 'wordbooker').' :<select id="wordbooker_actionlink" name="wordbooker_actionlink"  >';  
    164            $arr = array(100=> "None ",  200=> __("Share Link", 'wordbooker'), 300=>__("Read Full Article", 'wordbooker')); 
     164           $arr = array(100=> __("Share Link", 'wordbooker'), 300=>__("Read Full Article", 'wordbooker')); 
    165165                foreach ($arr as $i => $value) { 
    166166                        if ($i==$wordbooker_settings['wordbooker_actionlink']){ print '<option selected="yes" value="'.$i.'" >'.$arr[$i].'</option>';}  
     
    223223*/ 
    224224        } 
    225  
    226  
    227225        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_comment_put" '.$checked_flag[$wordbooker_settings["wordbooker_comment_put"]].' > '.__('Push Comments from this post to Facebook', 'wordbooker').'<br />'; 
    228226        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_comment_get" '.$checked_flag[$wordbooker_settings["wordbooker_comment_get"]].' > '.__('Pull Comments from Facebook for this post', 'wordbooker').'<br />'; 
    229227        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_use_facebook_comments" '.$checked_flag[$wordbooker_settings["wordbooker_use_facebook_comments"]].' > '.__('Enable Facebook Comments for this post', 'wordbooker').'<br />'; 
     228        echo '<input type="hidden" name="crabstick" value="fruitbat" />'; 
    230229    }  else { 
    231230echo "<p>".__('Wordbooker Blog level settings are in force','wordbooker')."<br /></p>"; 
    232  
     231echo '<input type="hidden" name="crabstick" value="stairwell" />'; 
    233232if ( isset($wordbooker_settings['wordbooker_allow_publish_select'])) {  
    234 echo '<input type="hidden" name="crabstick" value="stairwell" />'; 
    235233echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_publish_default" '.$checked_flag[$wordbooker_settings["wordbooker_publish_default"]].' > '.__('Publish This Post to Facebook', 'wordbooker').'<br />'; 
    236234#echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_publish_override" '.$checked_flag[$wordbooker_settings["wordbooker_publish_override"]].' >'.__('Force Re-Publish Post to Facebook on Edit (overrides republish window)').'<br />'; 
  • wordbooker/tags/2.1.23/readme.txt

    r609159 r617985  
    66Requires at least: 2.9 
    77Tested up to: 3.4.2 
    8 Stable tag: 2.1.22 
     8Stable tag: 2.1.23 
    99 
    1010This plugin allows you to cross-post your blog posts to your Facebook Wall and to any Facebook Fan Page / Group that you are an administrator for.  
     
    116116== Changelog == 
    117117 
     118= Version 2.1.23 27/10/2012 = 
     119- Fix problem with Editors publishing where designated wordbooker settings were being lost. 
     120- Minor change to refresh_token call again. 
     121- Add index on post_comments table. 
     122- Fix problem in DB upgrade process so changes roll forward properly. 
     123- Added option to control comment pulling pushing cut off dates rather than relying on the blog setting. 
     124- Recoded a couple of the comment handling queries to make things tighter. 
     125- Fixed a bug in the comment handling process which produced odd results on some installations. 
     126- Removed a pile of redundant diagnostic messages. 
     127- Fixed a problem with a couple of diagnostic messages during comment handling erroring. 
     128- Fix a missing function relating to comment deletion. 
     129- Fix an obscure problem with some installs failing with a unexpected T_VARIABLE error 
     130- Removed the "None" Option from the Action Links. Changed "Share" to use the built in FB Share option 
     131 
     132 
    118133= Version 2.1.22  05/10/2012 = 
    119134- Changes to refresh_token calls to reduce load on server. 
    120 - Add wrapper round curl_version to stop errors blowing things up. 
     135- Add wrapper round curl_version to stop errors blowing things up 
    121136- Added new image size for og:tags so all new images will have a specific image for wordbooker og tags.  
    122137- Change og image code to use the new size, or fail back to large if missing. 
     
    124139 
    125140= Version 2.1.21  03/10/2012 = 
    126 - Two new fields that should have been NULL weren't so data failed to get inserted into a table 
     141- Two new fields that should have been NULL weren't so data failed to get inserted into a table. 
     142 
    127143 
    128144= Version 2.1.20  02/10/2012 = 
    129 - DB changes needed to support new feature not included in create script so new installs would mis-behave 
     145- DB changes needed to support new feature not included in create script so new installs would mis-behave. 
    130146- Remove a totally obsolete function. 
     147 
    131148 
    132149= Version 2.1.19  29/09/2012 = 
     
    138155- Added code to delete records from Wordbooker Comments table when a comment is deleted from the blog. 
    139156- Changes to the Status Fetch to reduce incidents of incorrect status messages being posted. 
    140 - Added option to Comment Admin page to remove a comment entry from the Wordbooker Comments table 
     157- Added option to Comment Admin page to remove a comment entry from the Wordbooker Comments table. 
     158 
    141159 
    142160= Version 2.1.18  03/09/2012 = 
    143161- Rollback some changes in the curl include file which were from 2.2  
     162 
    144163 
    145164= Version 2.1.17  02/09/2012 = 
     
    149168- Changed minimum number of FB comments from 2 to 0. 
    150169 
     170 
    151171= Version 2.1.16  02/09/2012 = 
    152172- Lost in SVN. 
     173 
    153174 
    154175= Version 2.1.15 25/08/2012 = 
     
    164185= Version 2.1.14 30/07/2012 = 
    165186- Fixes a problem with Curl detection caused by FB changing things without telling people. 
     187 
    166188 
    167189= Version 2.1.13 09/06/2012 = 
  • wordbooker/tags/2.1.23/wordbooker.php

    r609159 r617985  
    66Author: Steve Atty  
    77Author URI: http://wordbooker.tty.org.uk 
    8 Version: 2.1.22 
     8Version: 2.1.23 
    99*/ 
    1010 
     
    3939    define('WORDBOOKER_DEBUG', false); 
    4040    define('WORDBOOKER_TESTING', false); 
    41     define('WORDBOOKER_CODE_RELEASE',"2.1.22 R00 - A Wish For Something More"); 
     41    define('WORDBOOKER_CODE_RELEASE',"2.1.23 R00 - Under The Sun"); 
    4242 
    4343    # For Troubleshooting  
     
    7474    define('WORDBOOKER_OPTION_SCHEMAVERS', 'schema_vers'); 
    7575    define('WORDBOOKER_USER_AGENT','WordPress/' . $wp_version . '; Wordbooker-' .WORDBOOKER_CODE_RELEASE ); 
    76     define('WORDBOOKER_SCHEMA_VERSION', '5.5'); 
     76    define('WORDBOOKER_SCHEMA_VERSION', '5.6'); 
    7777 
    7878    $new_wb_table_prefix=$wpdb->base_prefix; 
     
    272272    $result = $wpdb->query(' 
    273273        CREATE TABLE IF NOT EXISTS ' . WORDBOOKER_POSTCOMMENTS . ' ( 
    274           `fb_post_id` varchar(240) NOT NULL, 
    275           `user_id` bigint(20) NOT NULL, 
    276           `comment_timestamp` int(20) NOT NULL, 
    277           `wp_post_id` int(11) NOT NULL, 
    278           `blog_id` bigint(20) NOT NULL, 
    279           `wp_comment_id` int(20) NOT NULL, 
    280           `fb_comment_id` varchar(240) default NULL, 
    281           `in_out` varchar(20) default NULL, 
    282             `FB_USER_ID` varchar(120)  NULL, 
    283            `FB_TARGET_ID` varchar(120)  NULL, 
    284           UNIQUE KEY `fb_comment_id_idx` (`fb_comment_id`), 
    285           KEY `in_out_idx` (`in_out`), 
    286           KEY `main_index` (`blog_id`,`wp_post_id`,`fb_post_id`,`wp_comment_id`) 
     274              `fb_post_id` varchar(240) default NULL, 
     275              `user_id` bigint(20) NOT NULL, 
     276              `comment_timestamp` int(20) NOT NULL, 
     277              `wp_post_id` int(11) NOT NULL, 
     278              `blog_id` bigint(20) NOT NULL, 
     279              `wp_comment_id` int(20) NOT NULL, 
     280              `fb_comment_id` varchar(240) default NULL, 
     281              `in_out` varchar(20) default NULL, 
     282              `FB_USER_ID` varchar(120) NOT NULL, 
     283              `FB_TARGET_ID` varchar(120) NOT NULL, 
     284              UNIQUE KEY `fb_comment_id_idx` (`fb_comment_id`), 
     285              KEY `in_out_idx` (`in_out`), 
     286              KEY `main_index` (`blog_id`,`wp_post_id`,`fb_post_id`,`wp_comment_id`), 
     287              KEY `timestamp` (`comment_timestamp`) 
    287288            )  DEFAULT CHARSET=utf8; 
    288289        '); 
     
    409410        '); 
    410411        wordbooker_set_option('schema_vers', "2.1"); 
     412        $wordbooker_settings['schema_vers']='2.1'; 
    411413    } 
    412414 
    413415    if ($wordbooker_settings['schema_vers']=='2.1') { 
    414         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `user_id` BIGINT( 20 ) NOT NULL  '); 
     416        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `user_id` BIGINT( 20 ) NOT NULL  '); 
    415417        wordbooker_set_option('schema_vers', "2.2"); 
     418        $wordbooker_settings['schema_vers']='2.2'; 
    416419    } 
    417420 
    418421    if ($wordbooker_settings['schema_vers']=='2.2') { 
    419         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `sequence_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT , ADD `diag_level` INT(4) NULL, ADD PRIMARY KEY ( `sequence_id` ) '); 
     422        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `sequence_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT , ADD `diag_level` INT(4) NULL, ADD PRIMARY KEY ( `sequence_id` ) '); 
    420423        wordbooker_set_option('schema_vers', "2.3"); 
     424        $wordbooker_settings['schema_vers']='2.3'; 
    421425    } 
    422426 
    423427    if ($wordbooker_settings['schema_vers']=='2.3') { 
    424         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `sequence_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT , ADD `diag_level` INT(4) NULL, ADD PRIMARY KEY ( `sequence_id` ) '); 
     428        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `sequence_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT , ADD `diag_level` INT(4) NULL, ADD PRIMARY KEY ( `sequence_id` ) '); 
    425429        wordbooker_set_option('schema_vers', "2.4"); 
     430        $wordbooker_settings['schema_vers']='2.4'; 
    426431    } 
    427432 
    428433    if ($wordbooker_settings['schema_vers']=='2.4') { 
    429         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `fb_comment_id` VARCHAR( 40 ) NULL ');     
    430         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' DROP PRIMARY KEY,ADD PRIMARY KEY ( `blog_id` , `wp_post_id` , `fb_post_id` , `wp_comment_id` ) ');      
    431         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `diag_level` INT(4) NULL ');  
     434        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `fb_comment_id` VARCHAR( 40 ) NULL ');    
     435        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' DROP PRIMARY KEY,ADD PRIMARY KEY ( `blog_id` , `wp_post_id` , `fb_post_id` , `wp_comment_id` ) ');     
     436        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `diag_level` INT(4) NULL ');     
    432437        wordbooker_set_option('schema_vers', "2.5"); 
     438        $wordbooker_settings['schema_vers']='2.5'; 
    433439    } 
    434440 
    435441    if ($wordbooker_settings['schema_vers']=='2.5') { 
    436         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  DROP PRIMARY KEY , ADD INDEX `main_index` ( `blog_id` , `wp_post_id` , `fb_post_id` , `wp_comment_id` ) '); 
    437         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `in_out` VARCHAR( 20 ) NULL ');    
    438         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD INDEX `in_out_idx` ( `in_out` ) '); 
    439         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD INDEX `fb_comment_id_idx` (`fb_comment_id`) ');  
     442        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  DROP PRIMARY KEY , ADD INDEX `main_index` ( `blog_id` , `wp_post_id` , `fb_post_id` , `wp_comment_id` ) '); 
     443        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `in_out` VARCHAR( 20 ) NULL ');   
     444        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD INDEX `in_out_idx` ( `in_out` ) '); 
     445        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD INDEX `fb_comment_id_idx` (`fb_comment_id`) ');  
    440446        $result = $wpdb->query('DELETE FROM '. WORDBOOKER_POSTCOMMENTS. '  where user_id=0'); 
    441447        $result = $wpdb->query('DELETE FROM '. WORDBOOKER_POSTCOMMENTS. '  where wp_post_id=0'); 
    442         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `diag_level` INT(4) NULL ');  
     448        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `diag_level` INT(4) NULL ');     
    443449        wordbooker_set_option('schema_vers', "2.6"); 
     450        $wordbooker_settings['schema_vers']='2.6'; 
    444451    } 
    445452 
    446453    if ($wordbooker_settings['schema_vers']=='2.6') { 
    447         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' DROP PRIMARY KEY , DROP INDEX fb_comment_id, ADD PRIMARY KEY ( `blog_id` , `wp_post_id` , `fb_post_id` , `wp_comment_id` ) '); 
    448         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `user_id` BIGINT( 20 ) NOT NULL  '); 
    449         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `sequence_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT , ADD `diag_level` INT(4) NULL, ADD PRIMARY KEY ( `sequence_id` ) '); 
    450         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `fb_comment_id` VARCHAR( 40 ) NULL ');     
    451         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `diag_level` INT(4) NULL ');  
    452         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  DROP PRIMARY KEY , ADD INDEX `main_index` ( `blog_id` , `wp_post_id` , `fb_post_id` , `wp_comment_id` ) '); 
    453         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `in_out` VARCHAR( 20 ) NULL ');    
    454         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD INDEX `in_out_idx` ( `in_out` ) '); 
    455         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD INDEX `fb_comment_id_idx` (`fb_comment_id`) ');  
     454        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' DROP PRIMARY KEY , DROP INDEX fb_comment_id, ADD PRIMARY KEY ( `blog_id` , `wp_post_id` , `fb_post_id` , `wp_comment_id` ) '); 
     455        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `user_id` BIGINT( 20 ) NOT NULL  '); 
     456        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `sequence_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT , ADD `diag_level` INT(4) NULL, ADD PRIMARY KEY ( `sequence_id` ) '); 
     457        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `fb_comment_id` VARCHAR( 40 ) NULL ');    
     458        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `diag_level` INT(4) NULL ');     
     459        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  DROP PRIMARY KEY , ADD INDEX `main_index` ( `blog_id` , `wp_post_id` , `fb_post_id` , `wp_comment_id` ) '); 
     460        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `in_out` VARCHAR( 20 ) NULL ');   
     461        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD INDEX `in_out_idx` ( `in_out` ) '); 
     462        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD INDEX `fb_comment_id_idx` (`fb_comment_id`) ');  
    456463        $result = $wpdb->query('DELETE FROM '. WORDBOOKER_POSTCOMMENTS. '  where user_id=0'); 
    457464        $result = $wpdb->query('DELETE FROM '. WORDBOOKER_POSTCOMMENTS. '  where wp_post_id=0'); 
    458         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `diag_level` INT(4) NULL '); 
     465        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `diag_level` INT(4) NULL '); 
    459466        wordbooker_set_option('schema_vers', "3"); 
     467        $wordbooker_settings['schema_vers']='3'; 
    460468    }    
    461469 
    462470    if ($wordbooker_settings['schema_vers']=='3') { 
    463         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' DROP PRIMARY KEY '); 
    464         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' DROP INDEX fb_comment_id,'); 
    465         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD PRIMARY KEY ( `blog_id` , `wp_post_id` , `fb_post_id` , `wp_comment_id` ) '); 
    466         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `user_id` BIGINT( 20 ) NOT NULL  '); 
    467         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. '  ADD `sequence_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT '); 
    468         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. '  ADD PRIMARY KEY ( `sequence_id` ) '); 
    469         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '   ADD `fb_comment_id` VARCHAR( 40 ) NULL ');   
    470         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  DROP PRIMARY KEY '); 
    471         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD INDEX `main_index` ( `blog_id` , `wp_post_id` , `fb_post_id` , `wp_comment_id` ) '); 
    472         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD `in_out` VARCHAR( 20 ) NULL ');   
    473         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD INDEX `in_out_idx` ( `in_out` ) '); 
    474         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD INDEX `fb_comment_id_idx` (`fb_comment_id`) ');  
    475         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `diag_level` INT(4) NULL '); 
     471        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' DROP PRIMARY KEY '); 
     472        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' DROP INDEX fb_comment_id,'); 
     473        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD PRIMARY KEY ( `blog_id` , `wp_post_id` , `fb_post_id` , `wp_comment_id` ) '); 
     474        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `user_id` BIGINT( 20 ) NOT NULL  '); 
     475        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. '  ADD `sequence_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT '); 
     476        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. '  ADD PRIMARY KEY ( `sequence_id` ) '); 
     477        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '   ADD `fb_comment_id` VARCHAR( 40 ) NULL ');  
     478        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  DROP PRIMARY KEY '); 
     479        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD INDEX `main_index` ( `blog_id` , `wp_post_id` , `fb_post_id` , `wp_comment_id` ) '); 
     480        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD `in_out` VARCHAR( 20 ) NULL ');  
     481        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD INDEX `in_out_idx` ( `in_out` ) '); 
     482        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD INDEX `fb_comment_id_idx` (`fb_comment_id`) ');  
     483        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `diag_level` INT(4) NULL '); 
    476484        wordbooker_set_option('schema_vers', "4"); 
     485        $wordbooker_settings['schema_vers']='4'; 
    477486    } 
    478487 
    479488    if ($wordbooker_settings['schema_vers']=='4') { 
    480489 
    481         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  change  `fb_comment_id` `fb_comment_id` VARCHAR( 240 ) ');    
    482         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  change  `fb_post_id` `fb_post_id` VARCHAR( 240 ) ');  
     490        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  change  `fb_comment_id` `fb_comment_id` VARCHAR( 240 ) ');   
     491        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  change  `fb_post_id` `fb_post_id` VARCHAR( 240 ) ');     
    483492        $result = $wpdb->query('TRUNCATE TABLE '.WORDBOOKER_ERRORLOGS ); 
    484         $result = $wpdb->query('ALTER TABLE '.WORDBOOKER_ERRORLOGS.' CHANGE `sequence_id` `sequence_id` BIGINT( 20 ) NOT NULL'); 
    485         $result = $wpdb->query('ALTER TABLE '.WORDBOOKER_ERRORLOGS.' drop primary key'); 
     493        $result = @$wpdb->query('ALTER TABLE '.WORDBOOKER_ERRORLOGS.' CHANGE `sequence_id` `sequence_id` BIGINT( 20 ) NOT NULL'); 
     494        $result = @$wpdb->query('ALTER TABLE '.WORDBOOKER_ERRORLOGS.' drop primary key'); 
    486495        $result = $wpdb->query('TRUNCATE TABLE '.WORDBOOKER_ERRORLOGS ); 
    487         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD PRIMARY KEY ( `sequence_id` ) '); 
    488         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' change `sequence_id` `sequence_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT '); 
     496        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD PRIMARY KEY ( `sequence_id` ) '); 
     497        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' change `sequence_id` `sequence_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT '); 
    489498        wordbooker_set_option('schema_vers', "5"); 
     499        $wordbooker_settings['schema_vers']='5'; 
    490500    } 
    491501    # I know this is the same as above - brain cramp in my logic meant some changes got wiped out by accident. 
    492502    if ($wordbooker_settings['schema_vers']=='5') { 
    493503 
    494         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  change  `fb_comment_id` `fb_comment_id` VARCHAR( 240 ) ');    
    495         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  change  `fb_post_id` `fb_post_id` VARCHAR( 240 ) ');  
     504        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  change  `fb_comment_id` `fb_comment_id` VARCHAR( 240 ) ');   
     505        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  change  `fb_post_id` `fb_post_id` VARCHAR( 240 ) ');     
    496506        $result = $wpdb->query('TRUNCATE TABLE '.WORDBOOKER_ERRORLOGS ); 
    497         $result = $wpdb->query('ALTER TABLE '.WORDBOOKER_ERRORLOGS.' CHANGE `sequence_id` `sequence_id` BIGINT( 20 ) NOT NULL'); 
    498         $result = $wpdb->query('ALTER TABLE '.WORDBOOKER_ERRORLOGS.' drop primary key'); 
     507        $result = @$wpdb->query('ALTER TABLE '.WORDBOOKER_ERRORLOGS.' CHANGE `sequence_id` `sequence_id` BIGINT( 20 ) NOT NULL'); 
     508        $result = @$wpdb->query('ALTER TABLE '.WORDBOOKER_ERRORLOGS.' drop primary key'); 
    499509        $result = $wpdb->query('TRUNCATE TABLE '.WORDBOOKER_ERRORLOGS ); 
    500         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD PRIMARY KEY ( `sequence_id` ) '); 
    501         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' change `sequence_id` `sequence_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT '); 
     510        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD PRIMARY KEY ( `sequence_id` ) '); 
     511        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' change `sequence_id` `sequence_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT '); 
    502512        wordbooker_set_option('schema_vers', "5.1"); 
     513        $wordbooker_settings['schema_vers']='5.1'; 
    503514    } 
    504515     
    505          
    506516        if ($wordbooker_settings['schema_vers']=='5.1') { 
    507517 
    508         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_FB_FRIENDS. ' ADD FULLTEXT `name_idx` (`name`)');  
     518        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_FB_FRIENDS. ' ADD FULLTEXT `name_idx` (`name`)');     
    509519        wordbooker_set_option('schema_vers', "5.2"); 
     520        $wordbooker_settings['schema_vers']='5.2'; 
    510521    } 
    511522     
    512523        if ($wordbooker_settings['schema_vers']=='5.2') { 
    513524 
    514         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_USERDATA. '  DROP PRIMARY KEY , ADD PRIMARY KEY ( `user_ID` , `blog_id` ) ');  
    515         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD `FB_USER_ID` VARCHAR( 120 ) NOT NULL '); 
    516         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `FB_TARGET_ID` VARCHAR( 120 ) NOT NULL '); 
     525        $result = @$wpdb->query('ALTER TABLE '.WORDBOOKER_USERDATA.'  DROP PRIMARY KEY , ADD PRIMARY KEY ( `user_ID` , `blog_id` ) ');   
     526        $result = @$wpdb->query('ALTER TABLE '.WORDBOOKER_POSTCOMMENTS.'  ADD `FB_USER_ID` VARCHAR( 120 ) NOT NULL '); 
     527        $result = @$wpdb->query('ALTER TABLE '.WORDBOOKER_POSTCOMMENTS.' ADD `FB_TARGET_ID` VARCHAR( 120 ) NOT NULL '); 
    517528        wordbooker_set_option('schema_vers', "5.3"); 
     529        $wordbooker_settings['schema_vers']='5.3'; 
    518530    } 
    519531     
    520532    if ($wordbooker_settings['schema_vers']=='5.3') { 
    521533 
    522         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_USERDATA. '  DROP PRIMARY KEY , ADD PRIMARY KEY ( `user_ID` , `blog_id` ) ');  
    523         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD `FB_USER_ID` VARCHAR( 120 ) NOT NULL '); 
    524         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `FB_TARGET_ID` VARCHAR( 120 ) NOT NULL '); 
     534        $result = @$wpdb->query('ALTER TABLE '.WORDBOOKER_USERDATA.'  DROP PRIMARY KEY , ADD PRIMARY KEY ( `user_ID` , `blog_id` ) ');   
     535        $result = @$wpdb->query('ALTER TABLE '.WORDBOOKER_POSTCOMMENTS.'  ADD `FB_USER_ID` VARCHAR( 120 ) NOT NULL '); 
     536        $result = @$wpdb->query('ALTER TABLE '.WORDBOOKER_POSTCOMMENTS.' ADD `FB_TARGET_ID` VARCHAR( 120 ) NOT NULL '); 
    525537        wordbooker_set_option('schema_vers', "5.4"); 
     538        $wordbooker_settings['schema_vers']='5.4'; 
    526539    } 
    527540     
    528541    if ($wordbooker_settings['schema_vers']=='5.4') { 
    529         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  CHANGE `FB_USER_ID` `FB_USER_ID` VARCHAR( 120 )  NULL  '); 
    530         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' CHANGE `FB_TARGET_ID` `FB_TARGET_ID` VARCHAR( 120 )  NULL  '); 
     542        $result = @$wpdb->query('ALTER TABLE '.WORDBOOKER_POSTCOMMENTS.'  CHANGE `FB_USER_ID` `FB_USER_ID` VARCHAR( 120 )  NULL  '); 
     543        $result = @$wpdb->query('ALTER TABLE '.WORDBOOKER_POSTCOMMENTS.' CHANGE `FB_TARGET_ID` `FB_TARGET_ID` VARCHAR( 120 )  NULL  '); 
    531544        wordbooker_set_option('schema_vers', "5.5"); 
    532     } 
    533          
     545        $wordbooker_settings['schema_vers']='5.5'; 
     546    } 
     547     
     548    if ($wordbooker_settings['schema_vers']=='5.5') { 
     549        $result = @$wpdb->query('ALTER TABLE '.WORDBOOKER_POSTCOMMENTS.'  ADD INDEX `timestamp` ( `comment_timestamp` ) '); 
     550        wordbooker_set_option('schema_vers', "5.6"); 
     551        $wordbooker_settings['schema_vers']='5.6'; 
     552    } 
     553    $result = $wpdb->query('DELETE FROM ' .WORDBOOKER_POSTCOMMENTS .' where wp_comment_Id=0 and fb_comment_id is not null'); 
     554     
    534555    $dummy=wp_clear_scheduled_hook('wb_cron_job'); 
    535556    $dummy=wp_schedule_event(current_time( 'timestamp' ), 'hourly', 'wb_cron_job'); 
    536     #wordbooker_set_option('schema_vers', WORDBOOKER_SCHEMA_VERSION ); 
    537557    wp_cache_flush(); 
    538558} 
     
    14401460    if ( function_exists( 'get_the_post_thumbnail' ) ) {  
    14411461        preg_match_all('/<img \s+ ([^>]*\s+)? src \s* = \s* [\'"](.*?)[\'"]/ix',get_the_post_thumbnail($post_id), $matches_tn);  
    1442         if ($flag==1) {wordbooker_debugger("Getting the thumnail image",$matches_tn[2][0],$post->ID,80) ;} 
     1462        if ($flag==1) {wordbooker_debugger("Getting the thumnail image",$matches_tn[2][0],$postid,80) ;} 
    14431463        #var_dump($matches_tn[2][0]); 
    14441464    } 
     
    16261646    if ($wordbooker_post_options['wordbooker_actionlink']==100) { 
    16271647        // No action link 
    1628         wordbooker_debugger("No action link being used","",$post_id,80) ; 
     1648        wordbooker_debugger("Share Link being used"," ",$post_id,80) ; 
    16291649    } 
    16301650    if ($wordbooker_post_options['wordbooker_actionlink']==200) { 
    16311651        // Share This 
    16321652        wordbooker_debugger("Share Link being used"," ",$post_id,80) ; 
    1633         $action_links = array('name' => __('Share', 'wordbooker'),'link' => 'https://www.facebook.com/share.php?u='.urlencode($post_data['post_link_share'])); 
    1634         $wordbooker_fb_post['actions']=json_encode($action_links); 
     1653        //$action_links = array('name' => __('Share', 'wordbooker'),'link' => 'https://www.facebook.com/share.php?u='.urlencode($post_data['post_link_share'])); 
     1654    //  $action_links= array('name' => __('Share', 'wordbooker'),'link' => 'http://www.facebook.com/ajax/sharer/?s=39&appid='.WORDBOOKER_FB_ID.'&p%5B0%5D=WPTARGETID&u='.urlencode($post_data['post_link_share'])); 
     1655    //  $wordbooker_fb_post['actions']=json_encode($action_links); 
    16351656    } 
    16361657    if ($wordbooker_post_options['wordbooker_actionlink']==300) { 
     
    23842405    # Now lets strip any tags which dont have balanced ends 
    23852406    #  Need to put NGgallery tags in there - there are a lot of them and they are all different. 
    2386     $open_tags="[simage,[[CP,[gallery,[imagebrowser,[slideshow,[tags,[albumtags,[singlepic,[album"; 
    2387     $close_tags="],]],],],],],],],]"; 
     2407    $open_tags="[simage,[[CP,[gallery,[imagebrowser,[slideshow,[tags,[albumtags,[singlepic,[album,[contact-form,[contact-field,[/contact-form,<strong>Google+:"; 
     2408    $close_tags="],]],],],],],],],],],],],Daniel Treadwell</a>.</i>"; 
    23882409    $open_tag=explode(",",$open_tags); 
    23892410    $close_tag=explode(",",$close_tags); 
    23902411    foreach (array_keys($open_tag) as $key) { 
    2391         if (preg_match_all('/' . preg_quote($open_tag[$key]) . '(.*?)' . preg_quote($close_tag[$key]) .'/i',$excerpt,$matches)) { 
     2412        if (preg_match_all('#' . preg_quote($open_tag[$key]) . '(.*?)' . preg_quote($close_tag[$key]) .'#i',$excerpt,$matches)) { 
    23922413            $excerpt=str_replace($matches[0],"" , $excerpt); 
    23932414         } 
     
    24042425    if (strlen($excerpt) > $maxlength) { 
    24052426        # If we've got multibyte support then we need to make sure we get the right length - Thanks to Kensuke Akai for the fix 
    2406         if(function_exists('mb_strimwidth')){$excerpt=mb_strimwidth($excerpt, 0, $maxlength, " ...");} 
    2407         else { $excerpt=current(explode("SJA26666AJS", wordwrap($excerpt, $maxlength, "SJA26666AJS")))." ...";} 
    2408     } 
    2409      
     2427        if(function_exists('mb_strimwidth')){ 
     2428            $excerpt=mb_strimwidth($excerpt, 0, $maxlength); 
     2429            $arr=preg_split("/\s+(?=\S*+$)/",$excerpt); 
     2430            $excerpt=$arr[0]." ..."; 
     2431        } 
     2432        else {  
     2433            $excerpt=current(explode("SJA26666AJS", wordwrap($excerpt, $maxlength, "SJA26666AJS")))." ..."; 
     2434        } 
     2435    } 
    24102436    return $excerpt; 
    24112437} 
     2438 
     2439 
    24122440 
    24132441function wordbooker_translate($text) { 
     
    24932521} 
    24942522 
     2523function wordbooker_delete_comment($comment_id) {    
     2524    global $blog_id; 
     2525    wordbooker_delete_comment_from_commentlogs($comment_id,$blog_id); 
     2526} 
     2527 
    24952528function wordbooker_process_post_queue($post_id) { 
    24962529    global $wpdb,$blog_id; 
     
    25102543    if ($_POST['action']=='autosave') { return;} 
    25112544    wordbooker_update_post_meta($post); 
    2512     //var_dump($_POST); 
    2513     if ($_POST['action']=='editpost') {  
     2545    # Don't save the options if we're publishing using other settings. 
     2546    if ( ($_POST['action']=='editpost') && ($_POST['crabstick']!='stairwell')){  
    25142547        foreach (array_keys($_POST) as $key ) { 
    25152548            if (substr($key,0,8)=='wordbook') { 
    25162549                $wordbooker_sets[$key]= html_entity_decode($_POST[$key],ENT_QUOTES); 
    2517             //  $wordbooker_sets[$key]=str_replace( array('&amp;','&quot;','&#039;','&lt;','&gt;','&nbsp;&nbsp;'),array('&','"','\'','<','>',"\t"),$_POST[$key]); 
    2518              
    25192550            } 
    25202551        } 
     
    25232554    if (!$newstatus=="publish") { return;} 
    25242555    # Check for non public custom post types. 
    2525     #var_dump($post->post_type); 
    25262556    if ( $post->post_status == 'publish' ) { 
    25272557        $post_type_info = get_post_type_object( $post->post_type ); 
     
    25332563    $wb_params = get_post_meta($post->ID, '_wordbooker_options', true); 
    25342564    $wb_user_id=$post->post_author;  
    2535     #var_dump($fred);var_dump($fred); var_dump($wb_params);var_dump($fred);var_dump($fred); 
    2536     # Put a check in here so that we can allow the EDIT user's preferences to over-ride the AUTHOR settings 
     2565 
    25372566    if (wordbooker_get_userdata($user_ID) && (isset($wordbooker_settings["wordbooker_override_author"]))) {  
    25382567    $wb_user_id=$user_ID;} else { 
     
    25422571    $wordbooker_settings["wordbooker_override_id"]=$wb_user_id; 
    25432572    $_POST['wordbooker_override_id']=$wb_user_id; 
     2573    if ($_POST['crabstick']=='stairwell') { 
     2574        # If we have settings on the post then use those rather than the user defaults 
     2575        if (count($wb_params)> 10 ) {$wordbooker_settings=$wb_params;}  
     2576        else { 
     2577            $wordbooker_user_settings_id="wordbookuser".$blog_id; 
     2578            $wordbookuser=get_usermeta($wb_user_id,$wordbooker_user_settings_id); 
     2579            if(is_array($wordbookuser)) { 
     2580                foreach (array_keys($wordbookuser) as $key) { 
     2581                    if ((strlen($wordbookuser[$key])>0) && ($wordbookuser[$key]!="0") ) { 
     2582                        $wordbooker_settings[$key]=$wordbookuser[$key]; 
     2583                    }  
     2584                } 
     2585            } 
     2586        } 
     2587        foreach (array_keys($wordbooker_settings) as $key ) { 
     2588                if (substr($key,0,8)=='wordbook') { 
     2589                    if (!isset($_POST[$key])){$_POST[$key]=str_replace( array('&amp;','&quot;','&#039;','&lt;','&gt;','&nbsp;&nbsp;'),array('&','"','\'','<','>',"\t"),$wordbooker_settings[$key]);} 
     2590                } 
     2591        } 
     2592        update_post_meta($post->ID, '_wordbooker_options',$wordbooker_settings); 
     2593    } 
    25442594    if ( (!is_array($wb_params)) &&((stripos($_POST["_wp_http_referer"],'press-this')) || ( stripos($_POST["_wp_http_referer"],'index.php')) || (!isset($_POST['wordbooker_post_edited']) )) ) { 
    25452595        wordbooker_debugger("Inside the press this / quick press / remote client block "," ",$post->ID) ; 
     
    25512601            $publish=$wordbooker_settings["wordbooker_publish_post_default"]; 
    25522602        } 
    2553         # New get the user level settings from the DB 
    2554  
    25552603        $wordbooker_global_settings=wordbooker_options();  
    25562604        $wordbooker_settings=$wordbooker_global_settings; 
     
    26032651    foreach (array_keys($_POST) as $key ) { 
    26042652        if (substr($key,0,8)=='wordbook') { 
    2605         #   wordbooker_debugger(" 2nd replacing  ".$key." - ".$wb_params[$key]." with ",$_POST[$key],$post->ID) ; 
    26062653            $wb_params[$key]=str_replace(array('&','"','\'','<','>',"\t",), array('&amp;','&quot;','&#039;','&lt;','&gt;','&nbsp;&nbsp;'),$_POST[$key]); 
    26072654        } 
     
    26262673    global $user_ID, $user_identity, $user_login, $wpdb, $blog_id,$wordbooker_settings,$wb_user_id; 
    26272674    $post = get_post($post_id); 
    2628     #var_dump($wordbooker_settings); 
    26292675    if ((isset($user_ID) && $user_ID>0) &&  (!current_user_can(WORDBOOKER_MINIMUM_ADMIN_LEVEL))) { wordbooker_debugger("This user doesn't have enough rights"," ",$post_id,99) ; return; } 
    26302676    wordbooker_debugger("Commence Publish "," ",$post_id,99) ;  
    2631     #$wb_params = get_post_meta($post_id, '_wordbooker_options', true);  
    26322677    $wordbooker_settings = wordbooker_options(); 
    26332678    # If there is no user row for this user then set the user id to the default author. If the default author is set to 0 (i.e current logged in user) then only blog level settings apply. 
     
    26362681    if (wordbooker_get_userdata($user_ID) && (isset($wordbooker_settings["wordbooker_override_author"]))) {  
    26372682    $wb_user_id=$user_ID;} 
    2638     #var_dump($wb_user_id); 
    26392683    if (! wordbooker_get_userdata($wb_user_id)) { $wb_user_id=$wordbooker_settings["wordbooker_default_author"];} 
    26402684    if  ($wordbooker_settings["wordbooker_default_author"] == 0 ) {$wb_user_id=$wb_user_id;} else {$wb_user_id=$wordbooker_settings["wordbooker_default_author"];} 
     
    26672711        #we dont want to record anything if its an draft of any kind 
    26682712        if (stristr($p->post_status,'draft')) {return;} 
    2669     //  $x = get_post_meta($post->ID, '_wordbooker_options', true);  
    2670         #echo "<br />"; 
    26712713        $usid=$p->post_author; 
    2672     //  if(isset($x['wordbooker_override_author'])) {$usid=$user_ID;} 
    26732714    } 
    26742715    $admin_id=wordbooker_get_option('wordbooker_diagnostic_admin'); 
     
    27272768} 
    27282769 
    2729  
    27302770register_activation_hook(__FILE__, 'wordbooker_activate'); 
    27312771add_action ('init', 'wordbooker_init'); 
     
    27402780 
    27412781function wordbooker_schema($attr) { 
    2742        # $attr .= " xmlns:fb=\"http://www.facebook.com/2008/fbml\" xmlns:og=\"http://ogp.me/ns#\" "; 
     2782   # $attr .= " xmlns:fb=\"http://www.facebook.com/2008/fbml\" xmlns:og=\"http://ogp.me/ns#\" "; 
    27432783  if (preg_match('/(prefix\s*=\s*[\"|\'])/i', $attr)) { 
    27442784    $attr = preg_replace('/(prefix\s*=\s*[\"|\'])/i', '${1}" og: http://ogp.me/ns#"', $attr); 
     
    28102850          $nonce = wp_create_nonce("wordbooker_comment_nonce"); 
    28112851        $link = admin_url('admin-ajax.php?action=wordbookercommentflip&id='.$comment->comment_ID.'&_wbnonce='.$nonce); 
    2812         $actions['wordbooker'] = '<a href="' . $link . '">' . __( 'Remove Wordbooker Record', 'wordbooker' ) . '</a>'; 
     2852        $actions['wordbooker'] = '<a href="'.$link . '">'. __( 'Remove Wordbooker Record', 'wordbooker' ).'</a>'; 
    28132853    } 
    28142854    return $actions; 
     
    28732913} 
    28742914 
    2875 # This is for support for alternative posting processes. Only Curl is supported right now 
    2876 #if (wordbooker_get_option('wordbooker_fopen_curl')=='fopen'){ 
    2877     #   include("includes/wordbooker_facebook_fopen.php"); 
    2878     #}   
    2879 #   else { 
    2880     include("includes/wordbooker_facebook_curl.php"); 
    2881 #   } 
     2915include("includes/wordbooker_facebook_curl.php"); 
    28822916 
    28832917?> 
  • wordbooker/trunk/includes/wordbooker_comments.php

    r548667 r617985  
    55Author: Stephen Atty 
    66Author URI: http://wordbooker.tty.org.uk 
    7 Version: 2.1.1 
     7Version: 2.1.22 
    88*/ 
    99 
    1010function wordbooker_poll_comments($userid=0) { 
    11     wordbooker_debugger("Comment handling starting "," ",-2,9) ;  
    12     global  $wpdb, $user_ID,$table_prefix,$blog_id,$comment_user;    
    13     $wordbooker_settings=get_option('wordbooker_settings');  
    14         $result = $wpdb->query('DELETE FROM ' . WORDBOOKER_ERRORLOGS . ' WHERE timestamp < DATE_SUB(CURDATE(), INTERVAL '.( $wordbooker_settings['wordbooker_comment_cron'] * 3 ) .' MINUTE)  and blog_id ='.$blog_id.' and post_id=-2'); 
     11    global  $wpdb, $user_ID,$table_prefix,$blog_id,$comment_user; 
     12    $comment_user=1;     
     13    wordbooker_debugger("Comment handling starting "," ",-3,9) ; 
     14    $wordbooker_settings=get_option('wordbooker_settings');      
     15    $result = $wpdb->query('DELETE FROM ' . WORDBOOKER_ERRORLOGS . ' WHERE timestamp < DATE_SUB(CURDATE(), INTERVAL '.( $wordbooker_settings['wordbooker_comment_cron'] * 3 ) .' MINUTE)  and blog_id ='.$blog_id.' and post_id=-2'); 
    1516    if (! $wordbooker_settings['wordbooker_comment_handling']) { 
    16         wordbooker_debugger("Comment handling disabled "," ",-2,9) ; 
     17        wordbooker_debugger("Comment handling disabled "," ",-3,9) ; 
    1718        return; 
    1819     } 
     
    2223    $rows = $wpdb->get_results($sql); 
    2324    foreach ($rows as $comment_row) { 
    24     $comment_user=$comment_row->user_ID;  
    25     wordbooker_debugger("Processing comments for ".$comment_row->name," ",-2,9) ; 
    26     wordbooker_debugger("Processing your comments "," ",-3,9) ;  
    27     if (!isset($wordbooker_settings['wordbooker_comment_pull']) ) {  
    28         wordbooker_debugger("Starting Incoming comment handling"," ",-2,9); 
    29         $incoming=wordbooker_get_comments_from_facebook($comment_row->user_ID); 
    30         wordbooker_debugger("Incoming comment handling completed"," ",-2,9); 
    31      }   
    32     else {wordbooker_debugger("Incoming comment handling disabled "," ",-2,9) ; } 
    33     $outgoing=0; 
    34     if (!isset($wordbooker_settings['wordbooker_comment_push']) ) {  
    35     wordbooker_debugger("Starting Outgoing comment handling"," ",-2,9); 
    36     $outgoing=wordbooker_post_comments_to_facebook($comment_row->user_ID); 
    37     wordbooker_debugger("Outgoing comment handling completed"," ",-2,9); 
     25        $comment_user=$comment_row->user_ID;  
     26        wordbooker_debugger("Processing comments for ".$comment_row->name," ",-3,9) ; 
     27        wordbooker_debugger("Processing your comments "," ",-3,9) ;  
     28        if (!isset($wordbooker_settings['wordbooker_comment_pull']) ) {  
     29            wordbooker_debugger("Starting Incoming comment handling"," ",-3,9); 
     30            $incoming=wordbooker_get_comments_from_facebook($comment_row->user_ID); 
     31            wordbooker_debugger("Incoming comment handling completed"," ",-3,9); 
     32         }   
     33        else {wordbooker_debugger("Incoming comment handling disabled "," ",-3,9) ; } 
     34        $outgoing=0; 
     35        if (!isset($wordbooker_settings['wordbooker_comment_push']) ) {  
     36            wordbooker_debugger("Starting Outgoing comment handling"," ",-3,9); 
     37            $outgoing=wordbooker_post_comments_to_facebook($comment_row->user_ID); 
     38            wordbooker_debugger("Outgoing comment handling completed"," ",-3,9); 
     39        }    
     40        else {wordbooker_debugger("Outgoing comment handling disabled "," ",-3,9) ; } 
     41        wordbooker_debugger("Completed comment processing for ".$comment_row->name," In : ".$incoming." - Out : ".$outgoing,-3,9) ;  
     42        wordbooker_debugger("Completed your comment processing "," In : ".$incoming." - Out : ".$outgoing,-3,9) ;  
    3843    }    
    39     else {wordbooker_debugger("Outgoing comment handling disabled "," ",-2,9) ; } 
    40     wordbooker_debugger("Completed comment processing for ".$comment_row->name," In : ".$incoming." - Out : ".$outgoing,-2,9) ;  
    41     wordbooker_debugger("Completed your comment processing "," In : ".$incoming." - Out : ".$outgoing,-3,9) ;  
    42 #   $sql="insert into ".WORDBOOKER_POSTCOMMENTS." (user_id,blog_id,comment_timestamp,fb_post_id,wp_post_id,in_out) values (".$userid.",".$blog_id.",'".$processed_time."','".$incoming."','".$outgoing."','stat')"; 
    43 #   $wpdb->query($sql); 
    44     }    
    45     wordbooker_debugger("Comment handling completed "," ",-2,9) ;  
     44    wordbooker_debugger("Comment handling completed "," ",-3,9) ;  
    4645} 
    4746 
     
    4948    global  $wpdb, $user_ID,$table_prefix,$blog_id,$comment_user;    
    5049    $processed_posts=0; 
     50    $comment_user=$user_id; 
     51    $wbuser = wordbooker_get_userdata($user_id); 
     52    if (strlen($wbuser->access_token)<20) { 
     53        wordbooker_debugger("No user session for comment handling "," ",-3,9) ; 
     54        return 0;  
     55    } 
     56    $wordbooker_settings=wordbooker_options(); 
    5157    $close_comments=get_option('close_comments_for_old_posts'); 
    5258    $close_days_old=get_option('close_comments_days_old'); 
    53     $wbuser = wordbooker_get_userdata($user_id); 
    54     if (strlen($wbuser->access_token)<20) { 
    55     wordbooker_debugger("No user session for comment handling "," ",-2,9) ; 
    56     return 0; } 
    57     $wordbooker_settings=wordbooker_options(); 
    5859    $comment_structure=$wordbooker_settings['wordbooker_comment_post_format']; 
    5960    $comment_tag=$wordbooker_settings['wordbooker_comment_attribute']; 
    60     wordbooker_debugger("Auto close comments ".$close_comments,$close_days_old,-2,98); 
     61    $wordbooker_close=$wordbooker_settings['wordbooker_close_comment']; 
     62    wordbooker_debugger("Auto close comments ".$close_comments,$close_days_old,-3,98); 
    6163    $sql="select distinct wp_post_id,fb_post_id from ".WORDBOOKER_POSTCOMMENTS." where fb_comment_id is null and blog_id=".$blog_id." and user_id=".$user_id." and in_out is null"; 
    6264    if ($close_comments==1) {$sql.=" and comment_timestamp  > DATE_SUB( CURDATE( ) , INTERVAL ".$close_days_old." DAY )";} 
     65    if ($wordbooker_close>0) {$sql.=" and comment_timestamp > DATE_SUB( CURDATE( ) , INTERVAL ".$wordbooker_close." DAY )";} 
    6366    $rows = $wpdb->get_results($sql); 
    6467 
    65     wordbooker_debugger("Blog posts for comment handling : ".$sql,count($rows),-2,98); 
     68    wordbooker_debugger("Blog posts for comment handling : ".$sql,count($rows),-3,98); 
    6669    foreach($rows as $row) { 
    67     wordbooker_debugger("Starting comment handling for WP post ".$row->wp_post_id,$row->fb_post_id,-2,9); 
    68     wordbooker_debugger("Starting comment handling for WP post ".$row->wp_post_id,$row->fb_post_id,-3,9); 
    69     $wordbooker_post_options = get_post_meta($row->wp_post_id, '_wordbooker_options', true); 
    70     if (!isset($wordbooker_post_options['wordbooker_comment_put'])) { 
    71         wordbooker_debugger("Outgoing comment disabled for WP post ".$row->wp_post_id,$row->fb_post_id,-2,9); 
    72         wordbooker_debugger("Outgoing comment disabled for WP post ".$row->wp_post_id,$row->fb_post_id,-3,9);    
    73         continue ; 
    74     } 
    75     $sql="select comment_ID from ".$wpdb->comments." where comment_post_id=".$row->wp_post_id." and comment_approved=1 and comment_id not in (select wp_comment_id from ".WORDBOOKER_POSTCOMMENTS." where  wp_post_id=".$row->wp_post_id." and fb_post_id='".$row->fb_post_id."' and user_id=".$user_id." and comment_post_id in (select ID from ".$wpdb->posts." WHERE comment_status='open'))"; 
    76     if ($close_comments==1) { $sql.="and comment_post_id in (select ID from ".$wpdb->posts." WHERE post_date > DATE_SUB( CURDATE( ) , INTERVAL ".$close_days_old."  
    77 DAY ))";} 
     70        wordbooker_debugger("Starting comment handling for WP post ".$row->wp_post_id,$row->fb_post_id,-3,9); 
     71        $wordbooker_post_options = get_post_meta($row->wp_post_id, '_wordbooker_options', true); 
     72        if (!isset($wordbooker_post_options['wordbooker_comment_put'])) { 
     73            wordbooker_debugger("Outgoing comment disabled for WP post ".$row->wp_post_id,$row->fb_post_id,-3,9);;   
     74            continue ; 
     75        } 
     76            $andlogic=""; 
     77        if ($wordbooker_close>0) { $andlogic=" and wpposts2.post_date > DATE_SUB( CURDATE( ) , INTERVAL ".$wordbooker_close." DAY )";} 
     78        $sql="select distinct comment_ID,comment_date from ".$wpdb->comments." wpcom, ".$wpdb->posts." wpposts2, ".WORDBOOKER_POSTCOMMENTS." wbcom2 where wpcom.comment_post_id=".$row->wp_post_id." and wpcom.comment_approved=1 and wpcom.comment_post_id = wpposts2.ID  and wbcom2.wp_post_id=wpposts2.ID and wbcom2.user_id=".$user_id." and wbcom2.blog_id=".$blog_id." and wbcom2.fb_post_id='".$row->fb_post_id."' and wpcom.comment_id not in (select distinct wp_comment_id from ".WORDBOOKER_POSTCOMMENTS." wbcom, ".$wpdb->posts." wpposts where wbcom.wp_post_id=".$row->wp_post_id." and wbcom.fb_post_id='".$row->fb_post_id."' and wbcom.user_id=".$user_id." and wbcom.wp_post_id = wpposts.ID and  wpposts.comment_status='open')".$andlogic; 
    7879        $results = $wpdb->get_results($sql); 
    79         wordbooker_debugger("Comments for processing : ".$sql,count($results),-2,98); 
    80         foreach($results as $result){            
     80        wordbooker_debugger("Comments for processing : ".$sql,count($results),-3,98); 
     81        foreach($results as $result){    
    8182            $x=0; 
    8283            $comment_content=parse_wordbooker_comment_attributes($result->comment_ID,$comment_structure,$comment_tag); 
     
    8889                $error_msg = $e->getMessage(); 
    8990                $err_no=(integer) substr($error_msg,2,3); 
    90                 wordbooker_debugger("Failed to post comment to Facebook : ".$error_msg,$row->fb_post_id,-2,9); 
    9191                wordbooker_debugger("Failed to post comment to Facebook : ".$error_msg,$row->fb_post_id,-3,9); 
    9292                if ($err_no=100) { 
     
    9696            } 
    9797            if (strlen($x->id)>2){ 
    98             $sql="insert into ".WORDBOOKER_POSTCOMMENTS." (wp_post_id,fb_post_id,wp_comment_id,fb_comment_id,user_id,blog_id,comment_timestamp,in_out) values (".$row->wp_post_id.",'".$row->fb_post_id."','".$result->comment_ID."','".$x->id."',".$user_id.",".$blog_id.",'".strtotime($result->comment_date)."','out')"; 
    99             $wpdb->query($sql); 
    100             wordbooker_debugger("Posting comment to Facebook Post : ".$row->fb_post_id." returns",$x->id,-2,9) ; 
    101             wordbooker_debugger("Posting comment to Facebook Post : ".$row->fb_post_id." returns",$x->id,-3,9) ; 
    102             $processed_posts=$processed_posts+1; 
    103             } 
    104         } 
    105         wordbooker_debugger("Finished comment handling for WP post ".$row->wp_post_id,$row->fb_post_id,-2,9); 
     98                $sql="insert into ".WORDBOOKER_POSTCOMMENTS." (wp_post_id,fb_post_id,wp_comment_id,fb_comment_id,user_id,blog_id,comment_timestamp,in_out) values (".$row->wp_post_id.",'".$row->fb_post_id."',".$result->comment_ID.",'".$x->id."',".$user_id.",".$blog_id.",'".strtotime($result->comment_date)."','out')"; 
     99                $wpdb->query($sql); 
     100                wordbooker_debugger("Posting comment to Facebook Post : ".$row->fb_post_id." returns",$x->id,-3,9) ; 
     101                $processed_posts=$processed_posts+1; 
     102            } 
     103        } 
    106104        wordbooker_debugger("Finished comment handling for WP post ".$row->wp_post_id,$row->fb_post_id,-3,9); 
    107105    } 
     
    112110    global $wpdb,$blog_id,$comment_user; 
    113111    $processed_posts=0; 
     112    $comment_user=$user_id; 
    114113    $wbuser = wordbooker_get_userdata($user_id); 
    115114    if (strlen($wbuser->access_token)<20) { 
    116     wordbooker_debugger("No user session for comment handling "," ",-2,9) ; 
    117     return 0; } 
     115        wordbooker_debugger("No user session for comment handling "," ",-3,9) ; 
     116        return 0;  
     117    } 
     118    $close_comments=get_option('close_comments_for_old_posts'); 
     119    $close_days_old=get_option('close_comments_days_old'); 
    118120    $wordbooker_settings=get_option('wordbooker_settings');  
     121    $wordbooker_close=$wordbooker_settings['wordbooker_close_comment']; 
    119122    $comment_approve=0; 
    120123    if (isset($wordbooker_settings['wordbooker_comment_approve'])) {$comment_approve=1;} 
    121124    $sql='Select distinct fb_post_id from '.WORDBOOKER_POSTCOMMENTS.' where fb_comment_id is null and user_id='.$user_id.' and blog_id='.$blog_id. " and in_out is null "; 
     125    if ($close_comments==1) { $sql.=" and comment_timestamp  > DATE_SUB( CURDATE( ) , INTERVAL ".$close_days_old." DAY )";} 
     126    if ($wordbooker_close>0) {$sql.=" and comment_timestamp  > DATE_SUB( CURDATE( ) , INTERVAL ".$wordbooker_close." DAY )";} 
    122127    $rows = $wpdb->get_results($sql); 
    123     wordbooker_debugger("Blog posts with FB Posts against them : ".$sql,count($rows),-2,98); 
     128    wordbooker_debugger("Blog posts with FB Posts against them : ".$sql,count($rows),-3,98); 
    124129    foreach ($rows as $fb_comment) { 
    125         wordbooker_debugger("Starting comment handling for FB post ".$fb_comment->fb_post_id,"",-2,9); 
    126130        wordbooker_debugger("Starting comment handling for FB post ".$fb_comment->fb_post_id,"",-3,9); 
    127     #   $sql="select fb_comment_id from ".WORDBOOKER_POSTCOMMENTS." where fb_post_id='".$fb_comment->fb_post_id."' and in_out!='out' and in_out!='stat' order by comment_timestamp desc"; 
    128     #   $from_comment=$wpdb->get_row($sql); 
    129131        try { 
    130132            $all_comments=wordbooker_fb_get_comments($fb_comment->fb_post_id,$wbuser->access_token); 
    131             wordbooker_debugger("Comments pulled from Facebook",count($all_comments->data),-2,9); 
     133            wordbooker_debugger("Comments pulled from Facebook",count($all_comments->data),-3,9); 
    132134        } 
    133135        catch (Exception $e)  
     
    135137            $error_msg = $e->getMessage(); 
    136138            $err_no=(integer) substr($error_msg,2,3); 
    137             wordbooker_debugger("Failed to get comment from Facebook : ".$error_msg,$row->fb_post_id,-2,9); 
    138139            wordbooker_debugger("Failed to get comment from Facebook : ".$error_msg,$row->fb_post_id,-3,9); 
    139140        } 
     
    143144                $sql="Select fb_comment_id from ".WORDBOOKER_POSTCOMMENTS." where fb_comment_id='".$single_comment->id."'"; 
    144145                $commq=$wpdb->query($sql); 
    145             #   wordbooker_debugger("running  ".$sql," Returns ".$commq,-2,8); 
    146             #   wordbooker_debugger("running  ".$sql," Returns ".$commq,-3,8); 
    147146                if(!$commq) { 
    148                     wordbooker_debugger("Found new comment for FB post ".$fb_comment->fb_post_id,"from : ".$single_comment->from->name,-2,9); 
    149147                    wordbooker_debugger("Found new comment for FB post ".$fb_comment->fb_post_id,"from : ".$single_comment->from->name,-3,9); 
    150148                    $commemail=$wordbooker_settings['wordbooker_comment_email']; 
     
    154152                    $sql="select distinct wp_post_id from ".WORDBOOKER_POSTCOMMENTS." where fb_post_id='".$fb_comment->fb_post_id."'"; 
    155153                    $wp_post_rows = $wpdb->get_results($sql); 
    156                     wordbooker_debugger("Blogs posts to send comment to : ".$sql,count($wp_post_rows),-2,98); 
     154                    wordbooker_debugger("Blogs posts to send comment to : ".$sql,count($wp_post_rows),-3,98); 
    157155                    foreach ($wp_post_rows as $wp_post_row) { 
    158156                        $wordbooker_post_options = get_post_meta($wp_post_row->wp_post_id, '_wordbooker_options', true); 
    159157                        if (!isset($wordbooker_post_options['wordbooker_comment_get'])) { 
    160                             wordbooker_debugger("Incoming comments disabled for WP post ".$wp_post_row->wp_post_id,' ',-2,9); 
    161158                            wordbooker_debugger("Incoming comments disabled for WP post ".$wp_post_row->wp_post_id,' ',-3,9);    
    162159                            continue ; 
     
    183180                        update_comment_meta($newComment, "fb_uid", $single_comment->from->id); 
    184181                        update_comment_meta($newComment, “akismet_result”, true); 
    185                         #wordbooker_debugger("Inserted comment from ".$single_comment->from->name." into ".$wp_post_row->wp_post_id,"",-2,9); 
    186182                        wordbooker_debugger("Inserted comment from ".$single_comment->from->name." into ".$wp_post_row->wp_post_id." as ".$newComment,"",-3,9); 
    187183                        $sql="Insert into ".WORDBOOKER_POSTCOMMENTS." (fb_post_id,user_id,comment_timestamp,wp_post_id,blog_id,wp_comment_id,fb_comment_id,in_out) values ('".$fb_comment->fb_post_id."',".$user_id.",".strtotime($single_comment->created_time).",".$wp_post_row->wp_post_id.",".$blog_id.",".$newComment.",'".$single_comment->id."','in' )"; 
    188184                        $commq2=$wpdb->query($sql); 
    189                     #   wordbooker_debugger("Updating Comments table - running  ".$sql," Returns ".$commq2,-2,9); 
    190                     #   wordbooker_debugger("Updating Comments table - running  ".$sql," Returns ".$commq2,-3,9); 
    191185                        $processed_posts=$processed_posts+1; 
    192186                    } 
    193                     wordbooker_debugger("Finished comment inserts for FB post ".$fb_comment->fb_post_id,"",-2,9); 
    194187                    wordbooker_debugger("Finished comment inserts for FB post ".$fb_comment->fb_post_id,"",-3,9); 
    195188                } 
    196189               else { 
    197                     wordbooker_debugger("Found existing comment for FB post ".$fb_comment->fb_post_id,"from : ".$single_comment->from->name,-2,9); 
    198                     wordbooker_debugger("Found existing comment for FB post ".$fb_comment->fb_post_id,"from : ".$single_comment->from->name,-3,9);   
     190                    wordbooker_debugger("Found existing comment for FB post ".$fb_comment->fb_post_id,"from : ".$single_comment->from->name,-3,9); 
    199191                } 
    200192            } 
    201193        } 
    202         wordbooker_debugger("Finished comment handling for FB post ".$fb_comment->fb_post_id,"",-2,9); 
    203194        wordbooker_debugger("Finished comment handling for FB post ".$fb_comment->fb_post_id,"",-3,9); 
    204195    } 
  • wordbooker/trunk/includes/wordbooker_cron.php

    r609159 r617985  
    1212    global $blog_id,$wpdb,$table_prefix,$wordbooker_user_settings_id,$wbooker_user_id; 
    1313    $wbooker_user_id=$user_id; 
    14     //wordbooker_renew_access_token($user_id); 
    1514    $result = $wpdb->query(' DELETE FROM ' . WORDBOOKER_ERRORLOGS . ' WHERE   blog_id ='.$blog_id.' and (user_ID='.$user_id.' or user_ID=0 ) and post_id<=1'); 
    1615    wordbooker_debugger("Cache Refresh Commence ",$user_id,-1,9) ;  
     
    4443        if($ret->error->message)  { 
    4544        wordbooker_append_to_errorlogs("Your Facebook Session is invalid", "99", $ret->error->message,'',$user_id); 
    46         #wordbooker_delete_user($user_id,1); 
    4745        return; 
    4846        } 
     
    186184        $all_pages_groups=@array_merge($all_pages,$all_groups); 
    187185        $encoded_names=str_replace('\\','\\\\',serialize($all_pages_groups)); 
    188 /* 
    189  
    190         try { 
    191             $query="SELECT flid, owner, name FROM friendlist WHERE owner=$uid"; 
    192             $fb_friend_lists= wordbooker_fql_query($query,$wbuser2->access_token); 
    193         if (is_array($fb_friend_lists)) { 
    194         $sql="Delete from ".WORDBOOKER_FB_FRIEND_LISTS." where user_id=".$user_id; 
    195         $result = $wpdb->get_results($sql); 
    196         foreach ($fb_friend_lists as $friend_list) { 
    197             if (function_exists('mb_convert_encoding')) { 
    198                 $friend_list->name=mb_convert_encoding($friend_list->name,'UTF-8'); 
    199             } 
    200         $sql="replace into ".WORDBOOKER_FB_FRIEND_LISTS." (user_id, flid,  owner, name) values (".$user_id.",'".$friend_list->flid."','".$friend_list->owner."','".$friend_list->name."')"; 
    201         $result = $wpdb->get_results($sql); 
    202         } 
    203         }    
    204  
    205         } 
    206         catch (Exception $e)  
    207         { 
    208             $error_msg = $e->getMessage(); 
    209             wordbooker_debugger("Failed to get friend lists : ",$error_msg,-1,9); 
    210         } 
    211  
    212   
    213         try { 
    214             $query="Select name,uid from user where uid in (Select uid from friendlist_member where flid='10150839623220195')"; 
    215             $fb_friends_info = wordbooker_fql_query($query,$wbuser2->access_token); 
    216         }  
    217         catch (Exception $e)  
    218         { 
    219             $error_msg = $e->getMessage(); 
    220             wordbooker_debugger("Failed to get friends : ",$error_msg,-1,9); 
    221         } 
    222             if (is_array($fb_friends_info) ) { 
    223             $sql="delete from ".WORDBOOKER_FB_FRIENDS." where user_id=".$user_id; 
    224             $result = $wpdb->get_results($sql); 
    225             foreach ($fb_friends_info as $friend_info) { 
    226                 if (function_exists('mb_convert_encoding')) { 
    227                     $friend_info->name=mb_convert_encoding($friend_info->name,'UTF-8'); 
    228                 } 
    229             $sql="insert into ".WORDBOOKER_FB_FRIENDS." (user_id, facebook_id, name, blog_id) values (".$user_id.",'".$friend_info->uid."','".$friend_info->name."',".$blog_id.")"; 
    230             $result = $wpdb->get_results($sql); 
    231             } 
    232         } 
    233 */ 
     186 
    234187        $fb_status_info=wordbooker_status_feed($suid,$wbuser2->access_token); 
    235         # put in check for not being an array and skip... 
    236         #var_dump($fb_status_info); 
    237         foreach($fb_status_info->data as $fbstat) { 
    238             if(!is_null($fbstat->message)){ 
    239                 //      var_dump($fbstat->to->data[0]->id); 
    240                 //      var_dump("XXXX".$fbstat->from->id); 
    241         //      var_dump($fbstat->message); 
    242             //  echo "<br />"; 
    243         //      var_dump($fbstat->from->id); 
    244         //      echo "<br />"; 
    245         //      var_dump($fbstat->to->data[0]->id); 
    246         //      echo "<br /><br />"; 
    247                 if (($suid==$fbstat->from->id) && (is_null($fbstat->to->data[0]->id ) )) { 
    248                     $status_message=$fbstat->message; 
    249                     $status_time=$fbstat->created_time; 
    250                     break;  
    251                 } 
    252              } 
     188        if (!is_null($fb_status_info)) { 
     189            foreach($fb_status_info->data as $fbstat) { 
     190                if(!is_null($fbstat->message)){ 
     191                //      var_dump($fbstat->message); 
     192            //      echo "<br />"; 
     193            //      var_dump($suid); 
     194            //      echo "<br />"; 
     195            //      var_dump($fbstat->from->id); 
     196            //      echo "<br />"; 
     197            //      var_dump($fbstat->to->data[0]->id); 
     198            //      echo "<br /><br />"; 
     199                    if (($suid==$fbstat->from->id) && (is_null($fbstat->to->data[0]->id ) )) { 
     200                        $status_message=$fbstat->message; 
     201                        $status_time=$fbstat->created_time; 
     202                        break;  
     203                    } 
     204                 } 
     205            } 
    253206        } 
    254207        $picture = 'https://graph.facebook.com/'.$suid.'/picture?type=normal'; 
     
    302255        $result = $wpdb->get_results($sql); 
    303256    } 
    304 #fclose($fp); 
    305257    wordbooker_debugger("Cache Refresh Complete for user",$uid,-1,90) ;  
    306258} 
     
    330282} 
    331283 
    332  
    333284?> 
  • wordbooker/trunk/includes/wordbooker_facebook_curl.php

    r609159 r617985  
    8282    #   $url='http://ccgi.pemmaquid.plus.com/cgi-bin/refresh.cgi?oldie='.$access_token.'&version='.$version[0]; 
    8383    $url='https://wordbooker.tty.org.uk/refresh_curl.cgi?oldie='.$access_token.'&version='.$version[0]; 
    84     //var_dump($url); 
     84    var_dump($url); 
    8585    $x=wordbooker_make_curl_call2($url); 
    8686    wordbooker_debugger("Access token returns ",print_r($x,true),-5,98) ; 
  • wordbooker/trunk/includes/wordbooker_options.php

    r605697 r617985  
    1616function worbooker_validate_options($options) { 
    1717    global $user_ID; 
     18    if ($options["wordbooker_close_comment"]<0) {$options["wordbooker_close_comment"]=0;} 
     19    if (!is_numeric($options["wordbooker_close_comment"])) {$options["wordbooker_close_comment"]=0;} 
    1820    # Do they want to reset? If so we reset the options and let WordPress do the business for us! 
    1921    if (isset( $_POST["mcp"] )) { 
     
    314316 
    315317        echo '<br /><label for="wb_action_link">'.__("Action Link Option ", 'wordbooker'). ': </label><select id="wordbooker_actionlink" name="wordbooker_settings[wordbooker_actionlink]"  >';  
    316              $arr = array(100=> "None ",  200=> __("Share Link ", 'wordbooker'), 300=>__("Read Full Article", 'wordbooker')); 
     318            if($wordbooker_settings['wordbooker_actionlink']==200) {$wordbooker_settings['wordbooker_actionlink']=100;} 
     319             $arr = array(100=> __("Share Link ", 'wordbooker'), 300=>__("Read Full Article", 'wordbooker')); 
    317320                foreach ($arr as $i => $value) { 
    318321                        if ($i==$wordbooker_settings['wordbooker_actionlink']){ print '<option selected="yes" value="'.$i.'" >'.$arr[$i].'</option>';} 
     
    486489        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_comment_handling]" '.$checked_flag[$wordbooker_settings["wordbooker_comment_handling"]].' /><br />'; 
    487490        echo '<label for="wb_import_comment">&nbsp;&nbsp;'.__("Disable Comment Importing", 'wordbooker'). ': </label>'; 
    488         echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_comment_pul]" '.$checked_flag[$wordbooker_settings["wordbooker_comment_pull"]]. '/> <br />'; 
     491        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_comment_pull]" '.$checked_flag[$wordbooker_settings["wordbooker_comment_pull"]]. '/> <br />'; 
    489492        echo '<label for="wb_import_comment">&nbsp;&nbsp;'.__("Disable Comment Exporting", 'wordbooker'). ': </label>'; 
    490493        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_comment_push]" '.$checked_flag[$wordbooker_settings["wordbooker_comment_push"]]. '/> <br />'; 
     
    505508        echo '<label for="wb_publish_comment_approve">'.__("Auto Approve imported comments", 'wordbooker'). ' :</label> '; 
    506509        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_comment_approve]" '.$checked_flag[$wordbooker_settings["wordbooker_comment_approve"]].' /><br />'; 
     510        echo '<label for="wb_attribute">'.__('Comment Cut off (days) ', 'wordbooker').' : </label>'; 
     511        if ($wordbooker_settings["wordbooker_close_comment"]<0) {$wordbooker_settings["wordbooker_close_comment"]=0;} 
     512        if (!is_numeric($wordbooker_settings["wordbooker_close_comment"])) {$wordbooker_settings["wordbooker_close_comment"]=0;} 
     513        $close_comments=get_option('close_comments_for_old_posts'); 
     514        $close_days_old=get_option('close_comments_days_old'); 
     515        echo '<INPUT NAME="wordbooker_settings[wordbooker_close_comment]" size=4 maxlength=4 value="'.stripslashes($wordbooker_settings["wordbooker_close_comment"]).'"> '.__('0 = Use blog settings', 'wordbooker'); 
     516        if ($close_comments) {$cdostring=sprintf(__("(Currently set to %s days)",'wordbooker'),$close_days_old); 
     517    } else {$cdostring=__("(Currently not set)",'wordbooker'); } 
     518        echo " ".$cdostring.'<br />'; 
    507519        if ($wordbooker_settings['wordbooker_comment_cron']!='Never') { 
    508520        echo '<br /><input type="submit" value="'.__("Run Comment Handling Now", 'wordbooker').'" name="mcp" class="button-primary"  />'; 
     
    751763    echo '<label for="wb_status_update">'.__('Facebook Status Text', 'wordbooker').'  : </label> '; 
    752764        echo '<INPUT NAME="wordbooker_status_update_text" size=60 maxlength=60 value="'.stripslashes($wordbookeruser_settings["wordbooker_status_update_text"]).'"> '; 
    753         echo '</select><br />'; 
     765        //echo '</select><br />'; 
    754766 
    755767        echo '<label for="wb_attribute">'.__('Post Attribute', 'wordbooker').' : </label>'; 
     
    757769 
    758770        echo '<label for="wb_action_link">'.__('Action Link Option', 'wordbooker').' : </label><select id="wordbooker_actionlink" name="wordbooker_actionlink"  >';  
    759             $arr = array(0=> __("Same as Blog", 'wordbooker'), 100=> __("None", 'wordbooker'),  200=> __("Share Link", 'wordbooker'), 300=>__("Read Full Article", 'wordbooker')); 
     771        if($wordbookeruser_settings['wordbooker_actionlink']==200) {$wordbookeruser_settings['wordbooker_actionlink']=100;} 
     772            $arr = array(0=> __("Same as Blog", 'wordbooker'), 100=> __("Share Link", 'wordbooker'), 300=>__("Read Full Article", 'wordbooker')); 
    760773                foreach ($arr as $i => $value) { 
    761774                        if ($i==$wordbookeruser_settings['wordbooker_actionlink']){ echo '<option selected="yes" value="'.$i.'" >'.$arr[$i].'</option>';} 
  • wordbooker/trunk/includes/wordbooker_posting_options.php

    r605697 r617985  
    160160        } 
    161161            echo "</select><br />"; 
    162  
     162        if($wordbooker_settings['wordbooker_actionlink']==200) {$wordbooker_settings['wordbooker_actionlink']=100;} 
    163163        echo __('Action Link Option', 'wordbooker').' :<select id="wordbooker_actionlink" name="wordbooker_actionlink"  >';  
    164            $arr = array(100=> "None ",  200=> __("Share Link", 'wordbooker'), 300=>__("Read Full Article", 'wordbooker')); 
     164           $arr = array(100=> __("Share Link", 'wordbooker'), 300=>__("Read Full Article", 'wordbooker')); 
    165165                foreach ($arr as $i => $value) { 
    166166                        if ($i==$wordbooker_settings['wordbooker_actionlink']){ print '<option selected="yes" value="'.$i.'" >'.$arr[$i].'</option>';}  
     
    223223*/ 
    224224        } 
    225  
    226  
    227225        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_comment_put" '.$checked_flag[$wordbooker_settings["wordbooker_comment_put"]].' > '.__('Push Comments from this post to Facebook', 'wordbooker').'<br />'; 
    228226        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_comment_get" '.$checked_flag[$wordbooker_settings["wordbooker_comment_get"]].' > '.__('Pull Comments from Facebook for this post', 'wordbooker').'<br />'; 
    229227        echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_use_facebook_comments" '.$checked_flag[$wordbooker_settings["wordbooker_use_facebook_comments"]].' > '.__('Enable Facebook Comments for this post', 'wordbooker').'<br />'; 
     228        echo '<input type="hidden" name="crabstick" value="fruitbat" />'; 
    230229    }  else { 
    231230echo "<p>".__('Wordbooker Blog level settings are in force','wordbooker')."<br /></p>"; 
    232  
     231echo '<input type="hidden" name="crabstick" value="stairwell" />'; 
    233232if ( isset($wordbooker_settings['wordbooker_allow_publish_select'])) {  
    234 echo '<input type="hidden" name="crabstick" value="stairwell" />'; 
    235233echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_publish_default" '.$checked_flag[$wordbooker_settings["wordbooker_publish_default"]].' > '.__('Publish This Post to Facebook', 'wordbooker').'<br />'; 
    236234#echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_publish_override" '.$checked_flag[$wordbooker_settings["wordbooker_publish_override"]].' >'.__('Force Re-Publish Post to Facebook on Edit (overrides republish window)').'<br />'; 
  • wordbooker/trunk/readme.txt

    r609159 r617985  
    66Requires at least: 2.9 
    77Tested up to: 3.4.2 
    8 Stable tag: 2.1.22 
     8Stable tag: 2.1.23 
    99 
    1010This plugin allows you to cross-post your blog posts to your Facebook Wall and to any Facebook Fan Page / Group that you are an administrator for.  
     
    116116== Changelog == 
    117117 
     118= Version 2.1.23 27/10/2012 = 
     119- Fix problem with Editors publishing where designated wordbooker settings were being lost. 
     120- Minor change to refresh_token call again. 
     121- Add index on post_comments table. 
     122- Fix problem in DB upgrade process so changes roll forward properly. 
     123- Added option to control comment pulling pushing cut off dates rather than relying on the blog setting. 
     124- Recoded a couple of the comment handling queries to make things tighter. 
     125- Fixed a bug in the comment handling process which produced odd results on some installations. 
     126- Removed a pile of redundant diagnostic messages. 
     127- Fixed a problem with a couple of diagnostic messages during comment handling erroring. 
     128- Fix a missing function relating to comment deletion. 
     129- Fix an obscure problem with some installs failing with a unexpected T_VARIABLE error 
     130- Removed the "None" Option from the Action Links. Changed "Share" to use the built in FB Share option 
     131 
     132 
    118133= Version 2.1.22  05/10/2012 = 
    119134- Changes to refresh_token calls to reduce load on server. 
    120 - Add wrapper round curl_version to stop errors blowing things up. 
     135- Add wrapper round curl_version to stop errors blowing things up 
    121136- Added new image size for og:tags so all new images will have a specific image for wordbooker og tags.  
    122137- Change og image code to use the new size, or fail back to large if missing. 
     
    124139 
    125140= Version 2.1.21  03/10/2012 = 
    126 - Two new fields that should have been NULL weren't so data failed to get inserted into a table 
     141- Two new fields that should have been NULL weren't so data failed to get inserted into a table. 
     142 
    127143 
    128144= Version 2.1.20  02/10/2012 = 
    129 - DB changes needed to support new feature not included in create script so new installs would mis-behave 
     145- DB changes needed to support new feature not included in create script so new installs would mis-behave. 
    130146- Remove a totally obsolete function. 
     147 
    131148 
    132149= Version 2.1.19  29/09/2012 = 
     
    138155- Added code to delete records from Wordbooker Comments table when a comment is deleted from the blog. 
    139156- Changes to the Status Fetch to reduce incidents of incorrect status messages being posted. 
    140 - Added option to Comment Admin page to remove a comment entry from the Wordbooker Comments table 
     157- Added option to Comment Admin page to remove a comment entry from the Wordbooker Comments table. 
     158 
    141159 
    142160= Version 2.1.18  03/09/2012 = 
    143161- Rollback some changes in the curl include file which were from 2.2  
     162 
    144163 
    145164= Version 2.1.17  02/09/2012 = 
     
    149168- Changed minimum number of FB comments from 2 to 0. 
    150169 
     170 
    151171= Version 2.1.16  02/09/2012 = 
    152172- Lost in SVN. 
     173 
    153174 
    154175= Version 2.1.15 25/08/2012 = 
     
    164185= Version 2.1.14 30/07/2012 = 
    165186- Fixes a problem with Curl detection caused by FB changing things without telling people. 
     187 
    166188 
    167189= Version 2.1.13 09/06/2012 = 
  • wordbooker/trunk/wordbooker.php

    r609159 r617985  
    66Author: Steve Atty  
    77Author URI: http://wordbooker.tty.org.uk 
    8 Version: 2.1.22 
     8Version: 2.1.23 
    99*/ 
    1010 
     
    3939    define('WORDBOOKER_DEBUG', false); 
    4040    define('WORDBOOKER_TESTING', false); 
    41     define('WORDBOOKER_CODE_RELEASE',"2.1.22 R00 - A Wish For Something More"); 
     41    define('WORDBOOKER_CODE_RELEASE',"2.1.23 R00 - Under The Sun"); 
    4242 
    4343    # For Troubleshooting  
     
    7474    define('WORDBOOKER_OPTION_SCHEMAVERS', 'schema_vers'); 
    7575    define('WORDBOOKER_USER_AGENT','WordPress/' . $wp_version . '; Wordbooker-' .WORDBOOKER_CODE_RELEASE ); 
    76     define('WORDBOOKER_SCHEMA_VERSION', '5.5'); 
     76    define('WORDBOOKER_SCHEMA_VERSION', '5.6'); 
    7777 
    7878    $new_wb_table_prefix=$wpdb->base_prefix; 
     
    272272    $result = $wpdb->query(' 
    273273        CREATE TABLE IF NOT EXISTS ' . WORDBOOKER_POSTCOMMENTS . ' ( 
    274           `fb_post_id` varchar(240) NOT NULL, 
    275           `user_id` bigint(20) NOT NULL, 
    276           `comment_timestamp` int(20) NOT NULL, 
    277           `wp_post_id` int(11) NOT NULL, 
    278           `blog_id` bigint(20) NOT NULL, 
    279           `wp_comment_id` int(20) NOT NULL, 
    280           `fb_comment_id` varchar(240) default NULL, 
    281           `in_out` varchar(20) default NULL, 
    282             `FB_USER_ID` varchar(120)  NULL, 
    283            `FB_TARGET_ID` varchar(120)  NULL, 
    284           UNIQUE KEY `fb_comment_id_idx` (`fb_comment_id`), 
    285           KEY `in_out_idx` (`in_out`), 
    286           KEY `main_index` (`blog_id`,`wp_post_id`,`fb_post_id`,`wp_comment_id`) 
     274              `fb_post_id` varchar(240) default NULL, 
     275              `user_id` bigint(20) NOT NULL, 
     276              `comment_timestamp` int(20) NOT NULL, 
     277              `wp_post_id` int(11) NOT NULL, 
     278              `blog_id` bigint(20) NOT NULL, 
     279              `wp_comment_id` int(20) NOT NULL, 
     280              `fb_comment_id` varchar(240) default NULL, 
     281              `in_out` varchar(20) default NULL, 
     282              `FB_USER_ID` varchar(120) NOT NULL, 
     283              `FB_TARGET_ID` varchar(120) NOT NULL, 
     284              UNIQUE KEY `fb_comment_id_idx` (`fb_comment_id`), 
     285              KEY `in_out_idx` (`in_out`), 
     286              KEY `main_index` (`blog_id`,`wp_post_id`,`fb_post_id`,`wp_comment_id`), 
     287              KEY `timestamp` (`comment_timestamp`) 
    287288            )  DEFAULT CHARSET=utf8; 
    288289        '); 
     
    409410        '); 
    410411        wordbooker_set_option('schema_vers', "2.1"); 
     412        $wordbooker_settings['schema_vers']='2.1'; 
    411413    } 
    412414 
    413415    if ($wordbooker_settings['schema_vers']=='2.1') { 
    414         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `user_id` BIGINT( 20 ) NOT NULL  '); 
     416        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `user_id` BIGINT( 20 ) NOT NULL  '); 
    415417        wordbooker_set_option('schema_vers', "2.2"); 
     418        $wordbooker_settings['schema_vers']='2.2'; 
    416419    } 
    417420 
    418421    if ($wordbooker_settings['schema_vers']=='2.2') { 
    419         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `sequence_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT , ADD `diag_level` INT(4) NULL, ADD PRIMARY KEY ( `sequence_id` ) '); 
     422        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `sequence_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT , ADD `diag_level` INT(4) NULL, ADD PRIMARY KEY ( `sequence_id` ) '); 
    420423        wordbooker_set_option('schema_vers', "2.3"); 
     424        $wordbooker_settings['schema_vers']='2.3'; 
    421425    } 
    422426 
    423427    if ($wordbooker_settings['schema_vers']=='2.3') { 
    424         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `sequence_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT , ADD `diag_level` INT(4) NULL, ADD PRIMARY KEY ( `sequence_id` ) '); 
     428        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `sequence_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT , ADD `diag_level` INT(4) NULL, ADD PRIMARY KEY ( `sequence_id` ) '); 
    425429        wordbooker_set_option('schema_vers', "2.4"); 
     430        $wordbooker_settings['schema_vers']='2.4'; 
    426431    } 
    427432 
    428433    if ($wordbooker_settings['schema_vers']=='2.4') { 
    429         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `fb_comment_id` VARCHAR( 40 ) NULL ');     
    430         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' DROP PRIMARY KEY,ADD PRIMARY KEY ( `blog_id` , `wp_post_id` , `fb_post_id` , `wp_comment_id` ) ');      
    431         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `diag_level` INT(4) NULL ');  
     434        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `fb_comment_id` VARCHAR( 40 ) NULL ');    
     435        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' DROP PRIMARY KEY,ADD PRIMARY KEY ( `blog_id` , `wp_post_id` , `fb_post_id` , `wp_comment_id` ) ');     
     436        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `diag_level` INT(4) NULL ');     
    432437        wordbooker_set_option('schema_vers', "2.5"); 
     438        $wordbooker_settings['schema_vers']='2.5'; 
    433439    } 
    434440 
    435441    if ($wordbooker_settings['schema_vers']=='2.5') { 
    436         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  DROP PRIMARY KEY , ADD INDEX `main_index` ( `blog_id` , `wp_post_id` , `fb_post_id` , `wp_comment_id` ) '); 
    437         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `in_out` VARCHAR( 20 ) NULL ');    
    438         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD INDEX `in_out_idx` ( `in_out` ) '); 
    439         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD INDEX `fb_comment_id_idx` (`fb_comment_id`) ');  
     442        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  DROP PRIMARY KEY , ADD INDEX `main_index` ( `blog_id` , `wp_post_id` , `fb_post_id` , `wp_comment_id` ) '); 
     443        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `in_out` VARCHAR( 20 ) NULL ');   
     444        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD INDEX `in_out_idx` ( `in_out` ) '); 
     445        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD INDEX `fb_comment_id_idx` (`fb_comment_id`) ');  
    440446        $result = $wpdb->query('DELETE FROM '. WORDBOOKER_POSTCOMMENTS. '  where user_id=0'); 
    441447        $result = $wpdb->query('DELETE FROM '. WORDBOOKER_POSTCOMMENTS. '  where wp_post_id=0'); 
    442         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `diag_level` INT(4) NULL ');  
     448        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `diag_level` INT(4) NULL ');     
    443449        wordbooker_set_option('schema_vers', "2.6"); 
     450        $wordbooker_settings['schema_vers']='2.6'; 
    444451    } 
    445452 
    446453    if ($wordbooker_settings['schema_vers']=='2.6') { 
    447         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' DROP PRIMARY KEY , DROP INDEX fb_comment_id, ADD PRIMARY KEY ( `blog_id` , `wp_post_id` , `fb_post_id` , `wp_comment_id` ) '); 
    448         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `user_id` BIGINT( 20 ) NOT NULL  '); 
    449         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `sequence_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT , ADD `diag_level` INT(4) NULL, ADD PRIMARY KEY ( `sequence_id` ) '); 
    450         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `fb_comment_id` VARCHAR( 40 ) NULL ');     
    451         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `diag_level` INT(4) NULL ');  
    452         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  DROP PRIMARY KEY , ADD INDEX `main_index` ( `blog_id` , `wp_post_id` , `fb_post_id` , `wp_comment_id` ) '); 
    453         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `in_out` VARCHAR( 20 ) NULL ');    
    454         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD INDEX `in_out_idx` ( `in_out` ) '); 
    455         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD INDEX `fb_comment_id_idx` (`fb_comment_id`) ');  
     454        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' DROP PRIMARY KEY , DROP INDEX fb_comment_id, ADD PRIMARY KEY ( `blog_id` , `wp_post_id` , `fb_post_id` , `wp_comment_id` ) '); 
     455        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `user_id` BIGINT( 20 ) NOT NULL  '); 
     456        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `sequence_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT , ADD `diag_level` INT(4) NULL, ADD PRIMARY KEY ( `sequence_id` ) '); 
     457        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `fb_comment_id` VARCHAR( 40 ) NULL ');    
     458        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `diag_level` INT(4) NULL ');     
     459        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  DROP PRIMARY KEY , ADD INDEX `main_index` ( `blog_id` , `wp_post_id` , `fb_post_id` , `wp_comment_id` ) '); 
     460        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `in_out` VARCHAR( 20 ) NULL ');   
     461        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD INDEX `in_out_idx` ( `in_out` ) '); 
     462        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD INDEX `fb_comment_id_idx` (`fb_comment_id`) ');  
    456463        $result = $wpdb->query('DELETE FROM '. WORDBOOKER_POSTCOMMENTS. '  where user_id=0'); 
    457464        $result = $wpdb->query('DELETE FROM '. WORDBOOKER_POSTCOMMENTS. '  where wp_post_id=0'); 
    458         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `diag_level` INT(4) NULL '); 
     465        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `diag_level` INT(4) NULL '); 
    459466        wordbooker_set_option('schema_vers', "3"); 
     467        $wordbooker_settings['schema_vers']='3'; 
    460468    }    
    461469 
    462470    if ($wordbooker_settings['schema_vers']=='3') { 
    463         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' DROP PRIMARY KEY '); 
    464         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' DROP INDEX fb_comment_id,'); 
    465         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD PRIMARY KEY ( `blog_id` , `wp_post_id` , `fb_post_id` , `wp_comment_id` ) '); 
    466         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `user_id` BIGINT( 20 ) NOT NULL  '); 
    467         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. '  ADD `sequence_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT '); 
    468         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. '  ADD PRIMARY KEY ( `sequence_id` ) '); 
    469         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '   ADD `fb_comment_id` VARCHAR( 40 ) NULL ');   
    470         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  DROP PRIMARY KEY '); 
    471         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD INDEX `main_index` ( `blog_id` , `wp_post_id` , `fb_post_id` , `wp_comment_id` ) '); 
    472         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD `in_out` VARCHAR( 20 ) NULL ');   
    473         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD INDEX `in_out_idx` ( `in_out` ) '); 
    474         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD INDEX `fb_comment_id_idx` (`fb_comment_id`) ');  
    475         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `diag_level` INT(4) NULL '); 
     471        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' DROP PRIMARY KEY '); 
     472        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' DROP INDEX fb_comment_id,'); 
     473        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD PRIMARY KEY ( `blog_id` , `wp_post_id` , `fb_post_id` , `wp_comment_id` ) '); 
     474        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `user_id` BIGINT( 20 ) NOT NULL  '); 
     475        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. '  ADD `sequence_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT '); 
     476        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. '  ADD PRIMARY KEY ( `sequence_id` ) '); 
     477        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '   ADD `fb_comment_id` VARCHAR( 40 ) NULL ');  
     478        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  DROP PRIMARY KEY '); 
     479        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD INDEX `main_index` ( `blog_id` , `wp_post_id` , `fb_post_id` , `wp_comment_id` ) '); 
     480        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD `in_out` VARCHAR( 20 ) NULL ');  
     481        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD INDEX `in_out_idx` ( `in_out` ) '); 
     482        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD INDEX `fb_comment_id_idx` (`fb_comment_id`) ');  
     483        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD `diag_level` INT(4) NULL '); 
    476484        wordbooker_set_option('schema_vers', "4"); 
     485        $wordbooker_settings['schema_vers']='4'; 
    477486    } 
    478487 
    479488    if ($wordbooker_settings['schema_vers']=='4') { 
    480489 
    481         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  change  `fb_comment_id` `fb_comment_id` VARCHAR( 240 ) ');    
    482         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  change  `fb_post_id` `fb_post_id` VARCHAR( 240 ) ');  
     490        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  change  `fb_comment_id` `fb_comment_id` VARCHAR( 240 ) ');   
     491        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  change  `fb_post_id` `fb_post_id` VARCHAR( 240 ) ');     
    483492        $result = $wpdb->query('TRUNCATE TABLE '.WORDBOOKER_ERRORLOGS ); 
    484         $result = $wpdb->query('ALTER TABLE '.WORDBOOKER_ERRORLOGS.' CHANGE `sequence_id` `sequence_id` BIGINT( 20 ) NOT NULL'); 
    485         $result = $wpdb->query('ALTER TABLE '.WORDBOOKER_ERRORLOGS.' drop primary key'); 
     493        $result = @$wpdb->query('ALTER TABLE '.WORDBOOKER_ERRORLOGS.' CHANGE `sequence_id` `sequence_id` BIGINT( 20 ) NOT NULL'); 
     494        $result = @$wpdb->query('ALTER TABLE '.WORDBOOKER_ERRORLOGS.' drop primary key'); 
    486495        $result = $wpdb->query('TRUNCATE TABLE '.WORDBOOKER_ERRORLOGS ); 
    487         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD PRIMARY KEY ( `sequence_id` ) '); 
    488         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' change `sequence_id` `sequence_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT '); 
     496        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD PRIMARY KEY ( `sequence_id` ) '); 
     497        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' change `sequence_id` `sequence_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT '); 
    489498        wordbooker_set_option('schema_vers', "5"); 
     499        $wordbooker_settings['schema_vers']='5'; 
    490500    } 
    491501    # I know this is the same as above - brain cramp in my logic meant some changes got wiped out by accident. 
    492502    if ($wordbooker_settings['schema_vers']=='5') { 
    493503 
    494         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  change  `fb_comment_id` `fb_comment_id` VARCHAR( 240 ) ');    
    495         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  change  `fb_post_id` `fb_post_id` VARCHAR( 240 ) ');  
     504        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  change  `fb_comment_id` `fb_comment_id` VARCHAR( 240 ) ');   
     505        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  change  `fb_post_id` `fb_post_id` VARCHAR( 240 ) ');     
    496506        $result = $wpdb->query('TRUNCATE TABLE '.WORDBOOKER_ERRORLOGS ); 
    497         $result = $wpdb->query('ALTER TABLE '.WORDBOOKER_ERRORLOGS.' CHANGE `sequence_id` `sequence_id` BIGINT( 20 ) NOT NULL'); 
    498         $result = $wpdb->query('ALTER TABLE '.WORDBOOKER_ERRORLOGS.' drop primary key'); 
     507        $result = @$wpdb->query('ALTER TABLE '.WORDBOOKER_ERRORLOGS.' CHANGE `sequence_id` `sequence_id` BIGINT( 20 ) NOT NULL'); 
     508        $result = @$wpdb->query('ALTER TABLE '.WORDBOOKER_ERRORLOGS.' drop primary key'); 
    499509        $result = $wpdb->query('TRUNCATE TABLE '.WORDBOOKER_ERRORLOGS ); 
    500         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD PRIMARY KEY ( `sequence_id` ) '); 
    501         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' change `sequence_id` `sequence_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT '); 
     510        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' ADD PRIMARY KEY ( `sequence_id` ) '); 
     511        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_ERRORLOGS. ' change `sequence_id` `sequence_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT '); 
    502512        wordbooker_set_option('schema_vers', "5.1"); 
     513        $wordbooker_settings['schema_vers']='5.1'; 
    503514    } 
    504515     
    505          
    506516        if ($wordbooker_settings['schema_vers']=='5.1') { 
    507517 
    508         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_FB_FRIENDS. ' ADD FULLTEXT `name_idx` (`name`)');  
     518        $result = @$wpdb->query('ALTER TABLE '. WORDBOOKER_FB_FRIENDS. ' ADD FULLTEXT `name_idx` (`name`)');     
    509519        wordbooker_set_option('schema_vers', "5.2"); 
     520        $wordbooker_settings['schema_vers']='5.2'; 
    510521    } 
    511522     
    512523        if ($wordbooker_settings['schema_vers']=='5.2') { 
    513524 
    514         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_USERDATA. '  DROP PRIMARY KEY , ADD PRIMARY KEY ( `user_ID` , `blog_id` ) ');  
    515         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD `FB_USER_ID` VARCHAR( 120 ) NOT NULL '); 
    516         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `FB_TARGET_ID` VARCHAR( 120 ) NOT NULL '); 
     525        $result = @$wpdb->query('ALTER TABLE '.WORDBOOKER_USERDATA.'  DROP PRIMARY KEY , ADD PRIMARY KEY ( `user_ID` , `blog_id` ) ');   
     526        $result = @$wpdb->query('ALTER TABLE '.WORDBOOKER_POSTCOMMENTS.'  ADD `FB_USER_ID` VARCHAR( 120 ) NOT NULL '); 
     527        $result = @$wpdb->query('ALTER TABLE '.WORDBOOKER_POSTCOMMENTS.' ADD `FB_TARGET_ID` VARCHAR( 120 ) NOT NULL '); 
    517528        wordbooker_set_option('schema_vers', "5.3"); 
     529        $wordbooker_settings['schema_vers']='5.3'; 
    518530    } 
    519531     
    520532    if ($wordbooker_settings['schema_vers']=='5.3') { 
    521533 
    522         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_USERDATA. '  DROP PRIMARY KEY , ADD PRIMARY KEY ( `user_ID` , `blog_id` ) ');  
    523         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD `FB_USER_ID` VARCHAR( 120 ) NOT NULL '); 
    524         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `FB_TARGET_ID` VARCHAR( 120 ) NOT NULL '); 
     534        $result = @$wpdb->query('ALTER TABLE '.WORDBOOKER_USERDATA.'  DROP PRIMARY KEY , ADD PRIMARY KEY ( `user_ID` , `blog_id` ) ');   
     535        $result = @$wpdb->query('ALTER TABLE '.WORDBOOKER_POSTCOMMENTS.'  ADD `FB_USER_ID` VARCHAR( 120 ) NOT NULL '); 
     536        $result = @$wpdb->query('ALTER TABLE '.WORDBOOKER_POSTCOMMENTS.' ADD `FB_TARGET_ID` VARCHAR( 120 ) NOT NULL '); 
    525537        wordbooker_set_option('schema_vers', "5.4"); 
     538        $wordbooker_settings['schema_vers']='5.4'; 
    526539    } 
    527540     
    528541    if ($wordbooker_settings['schema_vers']=='5.4') { 
    529         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  CHANGE `FB_USER_ID` `FB_USER_ID` VARCHAR( 120 )  NULL  '); 
    530         $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' CHANGE `FB_TARGET_ID` `FB_TARGET_ID` VARCHAR( 120 )  NULL  '); 
     542        $result = @$wpdb->query('ALTER TABLE '.WORDBOOKER_POSTCOMMENTS.'  CHANGE `FB_USER_ID` `FB_USER_ID` VARCHAR( 120 )  NULL  '); 
     543        $result = @$wpdb->query('ALTER TABLE '.WORDBOOKER_POSTCOMMENTS.' CHANGE `FB_TARGET_ID` `FB_TARGET_ID` VARCHAR( 120 )  NULL  '); 
    531544        wordbooker_set_option('schema_vers', "5.5"); 
    532     } 
    533          
     545        $wordbooker_settings['schema_vers']='5.5'; 
     546    } 
     547     
     548    if ($wordbooker_settings['schema_vers']=='5.5') { 
     549        $result = @$wpdb->query('ALTER TABLE '.WORDBOOKER_POSTCOMMENTS.'  ADD INDEX `timestamp` ( `comment_timestamp` ) '); 
     550        wordbooker_set_option('schema_vers', "5.6"); 
     551        $wordbooker_settings['schema_vers']='5.6'; 
     552    } 
     553    $result = $wpdb->query('DELETE FROM ' .WORDBOOKER_POSTCOMMENTS .' where wp_comment_Id=0 and fb_comment_id is not null'); 
     554     
    534555    $dummy=wp_clear_scheduled_hook('wb_cron_job'); 
    535556    $dummy=wp_schedule_event(current_time( 'timestamp' ), 'hourly', 'wb_cron_job'); 
    536     #wordbooker_set_option('schema_vers', WORDBOOKER_SCHEMA_VERSION ); 
    537557    wp_cache_flush(); 
    538558} 
     
    14401460    if ( function_exists( 'get_the_post_thumbnail' ) ) {  
    14411461        preg_match_all('/<img \s+ ([^>]*\s+)? src \s* = \s* [\'"](.*?)[\'"]/ix',get_the_post_thumbnail($post_id), $matches_tn);  
    1442         if ($flag==1) {wordbooker_debugger("Getting the thumnail image",$matches_tn[2][0],$post->ID,80) ;} 
     1462        if ($flag==1) {wordbooker_debugger("Getting the thumnail image",$matches_tn[2][0],$postid,80) ;} 
    14431463        #var_dump($matches_tn[2][0]); 
    14441464    } 
     
    16261646    if ($wordbooker_post_options['wordbooker_actionlink']==100) { 
    16271647        // No action link 
    1628         wordbooker_debugger("No action link being used","",$post_id,80) ; 
     1648        wordbooker_debugger("Share Link being used"," ",$post_id,80) ; 
    16291649    } 
    16301650    if ($wordbooker_post_options['wordbooker_actionlink']==200) { 
    16311651        // Share This 
    16321652        wordbooker_debugger("Share Link being used"," ",$post_id,80) ; 
    1633         $action_links = array('name' => __('Share', 'wordbooker'),'link' => 'https://www.facebook.com/share.php?u='.urlencode($post_data['post_link_share'])); 
    1634         $wordbooker_fb_post['actions']=json_encode($action_links); 
     1653        //$action_links = array('name' => __('Share', 'wordbooker'),'link' => 'https://www.facebook.com/share.php?u='.urlencode($post_data['post_link_share'])); 
     1654    //  $action_links= array('name' => __('Share', 'wordbooker'),'link' => 'http://www.facebook.com/ajax/sharer/?s=39&appid='.WORDBOOKER_FB_ID.'&p%5B0%5D=WPTARGETID&u='.urlencode($post_data['post_link_share'])); 
     1655    //  $wordbooker_fb_post['actions']=json_encode($action_links); 
    16351656    } 
    16361657    if ($wordbooker_post_options['wordbooker_actionlink']==300) { 
     
    23842405    # Now lets strip any tags which dont have balanced ends 
    23852406    #  Need to put NGgallery tags in there - there are a lot of them and they are all different. 
    2386     $open_tags="[simage,[[CP,[gallery,[imagebrowser,[slideshow,[tags,[albumtags,[singlepic,[album"; 
    2387     $close_tags="],]],],],],],],],]"; 
     2407    $open_tags="[simage,[[CP,[gallery,[imagebrowser,[slideshow,[tags,[albumtags,[singlepic,[album,[contact-form,[contact-field,[/contact-form,<strong>Google+:"; 
     2408    $close_tags="],]],],],],],],],],],],],Daniel Treadwell</a>.</i>"; 
    23882409    $open_tag=explode(",",$open_tags); 
    23892410    $close_tag=explode(",",$close_tags); 
    23902411    foreach (array_keys($open_tag) as $key) { 
    2391         if (preg_match_all('/' . preg_quote($open_tag[$key]) . '(.*?)' . preg_quote($close_tag[$key]) .'/i',$excerpt,$matches)) { 
     2412        if (preg_match_all('#' . preg_quote($open_tag[$key]) . '(.*?)' . preg_quote($close_tag[$key]) .'#i',$excerpt,$matches)) { 
    23922413            $excerpt=str_replace($matches[0],"" , $excerpt); 
    23932414         } 
     
    24042425    if (strlen($excerpt) > $maxlength) { 
    24052426        # If we've got multibyte support then we need to make sure we get the right length - Thanks to Kensuke Akai for the fix 
    2406         if(function_exists('mb_strimwidth')){$excerpt=mb_strimwidth($excerpt, 0, $maxlength, " ...");} 
    2407         else { $excerpt=current(explode("SJA26666AJS", wordwrap($excerpt, $maxlength, "SJA26666AJS")))." ...";} 
    2408     } 
    2409      
     2427        if(function_exists('mb_strimwidth')){ 
     2428            $excerpt=mb_strimwidth($excerpt, 0, $maxlength); 
     2429            $arr=preg_split("/\s+(?=\S*+$)/",$excerpt); 
     2430            $excerpt=$arr[0]." ..."; 
     2431        } 
     2432        else {  
     2433            $excerpt=current(explode("SJA26666AJS", wordwrap($excerpt, $maxlength, "SJA26666AJS")))." ..."; 
     2434        } 
     2435    } 
    24102436    return $excerpt; 
    24112437} 
     2438 
     2439 
    24122440 
    24132441function wordbooker_translate($text) { 
     
    24932521} 
    24942522 
     2523function wordbooker_delete_comment($comment_id) {    
     2524    global $blog_id; 
     2525    wordbooker_delete_comment_from_commentlogs($comment_id,$blog_id); 
     2526} 
     2527 
    24952528function wordbooker_process_post_queue($post_id) { 
    24962529    global $wpdb,$blog_id; 
     
    25102543    if ($_POST['action']=='autosave') { return;} 
    25112544    wordbooker_update_post_meta($post); 
    2512     //var_dump($_POST); 
    2513     if ($_POST['action']=='editpost') {  
     2545    # Don't save the options if we're publishing using other settings. 
     2546    if ( ($_POST['action']=='editpost') && ($_POST['crabstick']!='stairwell')){  
    25142547        foreach (array_keys($_POST) as $key ) { 
    25152548            if (substr($key,0,8)=='wordbook') { 
    25162549                $wordbooker_sets[$key]= html_entity_decode($_POST[$key],ENT_QUOTES); 
    2517             //  $wordbooker_sets[$key]=str_replace( array('&amp;','&quot;','&#039;','&lt;','&gt;','&nbsp;&nbsp;'),array('&','"','\'','<','>',"\t"),$_POST[$key]); 
    2518              
    25192550            } 
    25202551        } 
     
    25232554    if (!$newstatus=="publish") { return;} 
    25242555    # Check for non public custom post types. 
    2525     #var_dump($post->post_type); 
    25262556    if ( $post->post_status == 'publish' ) { 
    25272557        $post_type_info = get_post_type_object( $post->post_type ); 
     
    25332563    $wb_params = get_post_meta($post->ID, '_wordbooker_options', true); 
    25342564    $wb_user_id=$post->post_author;  
    2535     #var_dump($fred);var_dump($fred); var_dump($wb_params);var_dump($fred);var_dump($fred); 
    2536     # Put a check in here so that we can allow the EDIT user's preferences to over-ride the AUTHOR settings 
     2565 
    25372566    if (wordbooker_get_userdata($user_ID) && (isset($wordbooker_settings["wordbooker_override_author"]))) {  
    25382567    $wb_user_id=$user_ID;} else { 
     
    25422571    $wordbooker_settings["wordbooker_override_id"]=$wb_user_id; 
    25432572    $_POST['wordbooker_override_id']=$wb_user_id; 
     2573    if ($_POST['crabstick']=='stairwell') { 
     2574        # If we have settings on the post then use those rather than the user defaults 
     2575        if (count($wb_params)> 10 ) {$wordbooker_settings=$wb_params;}  
     2576        else { 
     2577            $wordbooker_user_settings_id="wordbookuser".$blog_id; 
     2578            $wordbookuser=get_usermeta($wb_user_id,$wordbooker_user_settings_id); 
     2579            if(is_array($wordbookuser)) { 
     2580                foreach (array_keys($wordbookuser) as $key) { 
     2581                    if ((strlen($wordbookuser[$key])>0) && ($wordbookuser[$key]!="0") ) { 
     2582                        $wordbooker_settings[$key]=$wordbookuser[$key]; 
     2583                    }  
     2584                } 
     2585            } 
     2586        } 
     2587        foreach (array_keys($wordbooker_settings) as $key ) { 
     2588                if (substr($key,0,8)=='wordbook') { 
     2589                    if (!isset($_POST[$key])){$_POST[$key]=str_replace( array('&amp;','&quot;','&#039;','&lt;','&gt;','&nbsp;&nbsp;'),array('&','"','\'','<','>',"\t"),$wordbooker_settings[$key]);} 
     2590                } 
     2591        } 
     2592        update_post_meta($post->ID, '_wordbooker_options',$wordbooker_settings); 
     2593    } 
    25442594    if ( (!is_array($wb_params)) &&((stripos($_POST["_wp_http_referer"],'press-this')) || ( stripos($_POST["_wp_http_referer"],'index.php')) || (!isset($_POST['wordbooker_post_edited']) )) ) { 
    25452595        wordbooker_debugger("Inside the press this / quick press / remote client block "," ",$post->ID) ; 
     
    25512601            $publish=$wordbooker_settings["wordbooker_publish_post_default"]; 
    25522602        } 
    2553         # New get the user level settings from the DB 
    2554  
    25552603        $wordbooker_global_settings=wordbooker_options();  
    25562604        $wordbooker_settings=$wordbooker_global_settings; 
     
    26032651    foreach (array_keys($_POST) as $key ) { 
    26042652        if (substr($key,0,8)=='wordbook') { 
    2605         #   wordbooker_debugger(" 2nd replacing  ".$key." - ".$wb_params[$key]." with ",$_POST[$key],$post->ID) ; 
    26062653            $wb_params[$key]=str_replace(array('&','"','\'','<','>',"\t",), array('&amp;','&quot;','&#039;','&lt;','&gt;','&nbsp;&nbsp;'),$_POST[$key]); 
    26072654        } 
     
    26262673    global $user_ID, $user_identity, $user_login, $wpdb, $blog_id,$wordbooker_settings,$wb_user_id; 
    26272674    $post = get_post($post_id); 
    2628     #var_dump($wordbooker_settings); 
    26292675    if ((isset($user_ID) && $user_ID>0) &&  (!current_user_can(WORDBOOKER_MINIMUM_ADMIN_LEVEL))) { wordbooker_debugger("This user doesn't have enough rights"," ",$post_id,99) ; return; } 
    26302676    wordbooker_debugger("Commence Publish "," ",$post_id,99) ;  
    2631     #$wb_params = get_post_meta($post_id, '_wordbooker_options', true);  
    26322677    $wordbooker_settings = wordbooker_options(); 
    26332678    # If there is no user row for this user then set the user id to the default author. If the default author is set to 0 (i.e current logged in user) then only blog level settings apply. 
     
    26362681    if (wordbooker_get_userdata($user_ID) && (isset($wordbooker_settings["wordbooker_override_author"]))) {  
    26372682    $wb_user_id=$user_ID;} 
    2638     #var_dump($wb_user_id); 
    26392683    if (! wordbooker_get_userdata($wb_user_id)) { $wb_user_id=$wordbooker_settings["wordbooker_default_author"];} 
    26402684    if  ($wordbooker_settings["wordbooker_default_author"] == 0 ) {$wb_user_id=$wb_user_id;} else {$wb_user_id=$wordbooker_settings["wordbooker_default_author"];} 
     
    26672711        #we dont want to record anything if its an draft of any kind 
    26682712        if (stristr($p->post_status,'draft')) {return;} 
    2669     //  $x = get_post_meta($post->ID, '_wordbooker_options', true);  
    2670         #echo "<br />"; 
    26712713        $usid=$p->post_author; 
    2672     //  if(isset($x['wordbooker_override_author'])) {$usid=$user_ID;} 
    26732714    } 
    26742715    $admin_id=wordbooker_get_option('wordbooker_diagnostic_admin'); 
     
    27272768} 
    27282769 
    2729  
    27302770register_activation_hook(__FILE__, 'wordbooker_activate'); 
    27312771add_action ('init', 'wordbooker_init'); 
     
    27402780 
    27412781function wordbooker_schema($attr) { 
    2742        # $attr .= " xmlns:fb=\"http://www.facebook.com/2008/fbml\" xmlns:og=\"http://ogp.me/ns#\" "; 
     2782   # $attr .= " xmlns:fb=\"http://www.facebook.com/2008/fbml\" xmlns:og=\"http://ogp.me/ns#\" "; 
    27432783  if (preg_match('/(prefix\s*=\s*[\"|\'])/i', $attr)) { 
    27442784    $attr = preg_replace('/(prefix\s*=\s*[\"|\'])/i', '${1}" og: http://ogp.me/ns#"', $attr); 
     
    28102850          $nonce = wp_create_nonce("wordbooker_comment_nonce"); 
    28112851        $link = admin_url('admin-ajax.php?action=wordbookercommentflip&id='.$comment->comment_ID.'&_wbnonce='.$nonce); 
    2812         $actions['wordbooker'] = '<a href="' . $link . '">' . __( 'Remove Wordbooker Record', 'wordbooker' ) . '</a>'; 
     2852        $actions['wordbooker'] = '<a href="'.$link . '">'. __( 'Remove Wordbooker Record', 'wordbooker' ).'</a>'; 
    28132853    } 
    28142854    return $actions; 
     
    28732913} 
    28742914 
    2875 # This is for support for alternative posting processes. Only Curl is supported right now 
    2876 #if (wordbooker_get_option('wordbooker_fopen_curl')=='fopen'){ 
    2877     #   include("includes/wordbooker_facebook_fopen.php"); 
    2878     #}   
    2879 #   else { 
    2880     include("includes/wordbooker_facebook_curl.php"); 
    2881 #   } 
     2915include("includes/wordbooker_facebook_curl.php"); 
    28822916 
    28832917?> 
Note: See TracChangeset for help on using the changeset viewer.