Plugin Directory

Changeset 873445


Ignore:
Timestamp:
03/11/2014 02:59:57 PM (12 years ago)
Author:
Bartko.co.uk
Message:

Issue - plugin downgrade

Location:
wpguards/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • wpguards/trunk/modules/manager/addons/post_links/post.class.php

    r872784 r873445  
    110110            $attachments  = array();
    111111            $post_content = $post_data['post_content'];
    112            
    113             if(!empty($get_urls) && is_array($get_urls)){
    114                 foreach ($get_urls as $get_url_k => $get_url) {
    115                     // unset url in attachment array
    116                     if(!empty($post_atta_img) && is_array($post_atta_img)){
    117                         foreach ($post_atta_img as $atta_url_k => $atta_url_v) {
    118                             $match_patt_url = '/' . str_replace($rep, $with, substr($atta_url_v['src'], 0, strrpos($atta_url_v['src'], '.'))) . '/';
    119                             if (preg_match($match_patt_url, $get_url[4])) {
    120                                 unset($post_atta_img[$atta_url_k]);
    121                             }
    122                         }
    123                     }
    124                     $pic_from_other_site = $get_urls[$get_url_k][4];
    125                    /* if(strpos($pic_from_other_site,'exammple.com') === false){
    126                        continue;
    127                     }*/
    128                    
    129                     if (isset($get_urls[$get_url_k][6])) { // url have parent, don't download this url
    130                         if ($get_url[1] != '') {
    131                             // change src url
    132                             $s_mmb_mp = '/' . str_replace($rep, $with, $get_url[4]) . '/';
    133                            
    134                             $s_img_atta   = wp_get_attachment_image_src($get_urls[$get_url_k][6]);
    135                             $s_mmb_rp     = $s_img_atta[0];
    136                             $post_content = preg_replace($s_mmb_mp, $s_mmb_rp, $post_content);
    137                             // change attachment url
    138                             if (preg_match('/attachment_id/i', $get_url[2])) {
    139                                 $iwp_mmb_mp       = '/' . str_replace($rep, $with, $get_url[2]) . '/';
    140                                 $iwp_mmb_rp       = get_bloginfo('wpurl') . '/?attachment_id=' . $get_urls[$get_url_k][6];
    141                                 $post_content = preg_replace($iwp_mmb_mp, $iwp_mmb_rp, $post_content);
    142                             }
    143                         }
    144                         continue;
    145                     }
    146                    
    147                     $no_thumb = '';
    148                     if (preg_match('/-\d{3}x\d{3}\.[a-zA-Z0-9]{3,4}$/', $get_url[4])) {
    149                         $no_thumb = preg_replace('/-\d{3}x\d{3}\.[a-zA-Z0-9]{3,4}$/', '.' . $get_url[5], $get_url[4]);
    150                     } else {
    151                         $no_thumb = $get_url[4];
    152                     }
    153                    
    154                     if(isset($upload['error']) && !empty($upload['error'])){
    155                         return array('error' => $upload['error']);
    156                     }
    157                     $file_name = basename($no_thumb);
    158                     $tmp_file  = download_url($no_thumb);
    159                    
    160                     if(is_wp_error($tmp_file)){
    161                         return array('error' => $tmp_file->get_error_message());
    162                     }
    163                    
    164                     $attach_upload['url']  = $upload['url'] . '/' . $file_name;
    165                     $attach_upload['path'] = $upload['path'] . '/' . $file_name;
    166                     $renamed               = @rename($tmp_file, $attach_upload['path']);
    167                     if ($renamed === true) {
    168                         $match_pattern   = '/' . str_replace($rep, $with, $get_url[4]) . '/';
    169                         $replace_pattern = $attach_upload['url'];
    170                         $post_content    = preg_replace($match_pattern, $replace_pattern, $post_content);
    171                         if (preg_match('/-\d{3}x\d{3}\.[a-zA-Z0-9]{3,4}$/', $get_url[4])) {
    172                             $match_pattern = '/' . str_replace($rep, $with, preg_replace('/-\d{3}x\d{3}\.[a-zA-Z0-9]{3,4}$/', '.' . $get_url[5], $get_url[4])) . '/';
    173                             $post_content  = preg_replace($match_pattern, $replace_pattern, $post_content);
    174                         }
    175                        
    176                         $attachment = array(
    177                             'post_title' => $file_name,
    178                             'post_content' => '',
    179                             'post_type' => 'attachment',
    180                             //'post_parent' => $post_id,
    181                             'post_mime_type' => 'image/' . $get_url[5],
    182                             'guid' => $attach_upload['url']
    183                         );
    184                        
    185                         // Save the data
    186                        
    187                         $attach_id = wp_insert_attachment($attachment, $attach_upload['path']);
    188                        
    189                         $attachments[$attach_id] = 0;
    190                        
    191                         // featured image
    192                         if ($post_featured_img != '') {
    193                             $feat_img_url = '';
    194                             if (preg_match('/-\d{3}x\d{3}\.[a-zA-Z0-9]{3,4}$/', $post_featured_img)) {
    195                                 $feat_img_url = substr($post_featured_img, 0, strrpos($post_featured_img, '.') - 8);
    196                             } else {
    197                                 $feat_img_url = substr($post_featured_img, 0, strrpos($post_featured_img, '.'));
    198                             }
    199                             $m_feat_url = '/' . str_replace($rep, $with, $feat_img_url) . '/';
    200                             if (preg_match($m_feat_url, $get_url[4])) {
    201                                 $post_featured_img       = '';
    202                                 $attachments[$attach_id] = $attach_id;
    203                             }
    204                         }
    205                        
    206                         // set $get_urls value[6] - parent atta_id
    207                         foreach ($get_urls as $url_k => $url_v) {
    208                             if ($get_url_k != $url_k) {
    209                                 $s_get_url = '';
    210                                 if (preg_match('/-\d{3}x\d{3}\.[a-zA-Z0-9]{3,4}$/', $url_v[4])) {
    211                                     $s_get_url = substr($url_v[4], 0, strrpos($url_v[4], '.') - 8);
    212                                 } else {
    213                                     $s_get_url = substr($url_v[4], 0, strrpos($url_v[4], '.'));
    214                                 }
    215                                 $m_patt_url = '/' . str_replace($rep, $with, $s_get_url) . '/';
    216                                 if (preg_match($m_patt_url, $get_url[4])) {
    217                                     array_push($get_urls[$url_k], $attach_id);
    218                                 }
    219                             }
    220                         }
    221                        
    222                        
    223                         $some_data = wp_generate_attachment_metadata($attach_id, $attach_upload['path']);
    224                         wp_update_attachment_metadata($attach_id, $some_data);
    225                        
    226                        
    227                         //changing href of a tag
    228                         if ($get_url[1] != '') {
    229                             $iwp_mmb_mp = '/' . str_replace($rep, $with, $get_url[2]) . '/';
    230                             if (preg_match('/attachment_id/i', $get_url[2])) {
    231                                 $iwp_mmb_rp       = get_bloginfo('wpurl') . '/?attachment_id=' . $attach_id;
    232                                 $post_content = preg_replace($iwp_mmb_mp, $iwp_mmb_rp, $post_content);
    233                             }
    234                         }
    235                     } else {
    236                         @unlink($tmp_file);
    237                         return array('error' => "Cannot create attachment file in ".$attach_upload['path']." Please set correct permissions.");
    238                        
    239                     }
    240                     @unlink($tmp_file);
    241                 }
    242             }
     112               
     113            foreach ($get_urls as $get_url_k => $get_url) {
     114                // unset url in attachment array
     115                foreach ($post_atta_img as $atta_url_k => $atta_url_v) {
     116                    $match_patt_url = '/' . str_replace($rep, $with, substr($atta_url_v['src'], 0, strrpos($atta_url_v['src'], '.'))) . '/';
     117                    if (preg_match($match_patt_url, $get_url[4])) {
     118                        unset($post_atta_img[$atta_url_k]);
     119                    }
     120                }
     121                $pic_from_other_site = $get_urls[$get_url_k][4];
     122               /* if(strpos($pic_from_other_site,'exammple.com') === false){
     123                   continue;
     124                }*/
     125               
     126                if (isset($get_urls[$get_url_k][6])) { // url have parent, don't download this url
     127                    if ($get_url[1] != '') {
     128                        // change src url
     129                        $s_mmb_mp = '/' . str_replace($rep, $with, $get_url[4]) . '/';
     130                       
     131                        $s_img_atta   = wp_get_attachment_image_src($get_urls[$get_url_k][6]);
     132                        $s_mmb_rp     = $s_img_atta[0];
     133                        $post_content = preg_replace($s_mmb_mp, $s_mmb_rp, $post_content);
     134                        // change attachment url
     135                        if (preg_match('/attachment_id/i', $get_url[2])) {
     136                            $iwp_mmb_mp       = '/' . str_replace($rep, $with, $get_url[2]) . '/';
     137                            $iwp_mmb_rp       = get_bloginfo('wpurl') . '/?attachment_id=' . $get_urls[$get_url_k][6];
     138                            $post_content = preg_replace($iwp_mmb_mp, $iwp_mmb_rp, $post_content);
     139                        }
     140                    }
     141                    continue;
     142                }
     143               
     144                $no_thumb = '';
     145                if (preg_match('/-\d{3}x\d{3}\.[a-zA-Z0-9]{3,4}$/', $get_url[4])) {
     146                    $no_thumb = preg_replace('/-\d{3}x\d{3}\.[a-zA-Z0-9]{3,4}$/', '.' . $get_url[5], $get_url[4]);
     147                } else {
     148                    $no_thumb = $get_url[4];
     149                }
     150               
     151                if(isset($upload['error']) && !empty($upload['error'])){
     152                    return array('error' => $upload['error']);
     153                }
     154                $file_name = basename($no_thumb);
     155                $tmp_file  = download_url($no_thumb);
     156               
     157                if(is_wp_error($tmp_file)){
     158                    return array('error' => $tmp_file->get_error_message());
     159                }
     160               
     161                $attach_upload['url']  = $upload['url'] . '/' . $file_name;
     162                $attach_upload['path'] = $upload['path'] . '/' . $file_name;
     163                $renamed               = @rename($tmp_file, $attach_upload['path']);
     164                if ($renamed === true) {
     165                    $match_pattern   = '/' . str_replace($rep, $with, $get_url[4]) . '/';
     166                    $replace_pattern = $attach_upload['url'];
     167                    $post_content    = preg_replace($match_pattern, $replace_pattern, $post_content);
     168                    if (preg_match('/-\d{3}x\d{3}\.[a-zA-Z0-9]{3,4}$/', $get_url[4])) {
     169                        $match_pattern = '/' . str_replace($rep, $with, preg_replace('/-\d{3}x\d{3}\.[a-zA-Z0-9]{3,4}$/', '.' . $get_url[5], $get_url[4])) . '/';
     170                        $post_content  = preg_replace($match_pattern, $replace_pattern, $post_content);
     171                    }
     172                   
     173                    $attachment = array(
     174                        'post_title' => $file_name,
     175                        'post_content' => '',
     176                        'post_type' => 'attachment',
     177                        //'post_parent' => $post_id,
     178                        'post_mime_type' => 'image/' . $get_url[5],
     179                        'guid' => $attach_upload['url']
     180                    );
     181                   
     182                    // Save the data
     183                   
     184                    $attach_id = wp_insert_attachment($attachment, $attach_upload['path']);
     185                   
     186                    $attachments[$attach_id] = 0;
     187                   
     188                    // featured image
     189                    if ($post_featured_img != '') {
     190                        $feat_img_url = '';
     191                        if (preg_match('/-\d{3}x\d{3}\.[a-zA-Z0-9]{3,4}$/', $post_featured_img)) {
     192                            $feat_img_url = substr($post_featured_img, 0, strrpos($post_featured_img, '.') - 8);
     193                        } else {
     194                            $feat_img_url = substr($post_featured_img, 0, strrpos($post_featured_img, '.'));
     195                        }
     196                        $m_feat_url = '/' . str_replace($rep, $with, $feat_img_url) . '/';
     197                        if (preg_match($m_feat_url, $get_url[4])) {
     198                            $post_featured_img       = '';
     199                            $attachments[$attach_id] = $attach_id;
     200                        }
     201                    }
     202                   
     203                    // set $get_urls value[6] - parent atta_id
     204                    foreach ($get_urls as $url_k => $url_v) {
     205                        if ($get_url_k != $url_k) {
     206                            $s_get_url = '';
     207                            if (preg_match('/-\d{3}x\d{3}\.[a-zA-Z0-9]{3,4}$/', $url_v[4])) {
     208                                $s_get_url = substr($url_v[4], 0, strrpos($url_v[4], '.') - 8);
     209                            } else {
     210                                $s_get_url = substr($url_v[4], 0, strrpos($url_v[4], '.'));
     211                            }
     212                            $m_patt_url = '/' . str_replace($rep, $with, $s_get_url) . '/';
     213                            if (preg_match($m_patt_url, $get_url[4])) {
     214                                array_push($get_urls[$url_k], $attach_id);
     215                            }
     216                        }
     217                    }
     218                   
     219                   
     220                    $some_data = wp_generate_attachment_metadata($attach_id, $attach_upload['path']);
     221                    wp_update_attachment_metadata($attach_id, $some_data);
     222                   
     223                   
     224                    //changing href of a tag
     225                    if ($get_url[1] != '') {
     226                        $iwp_mmb_mp = '/' . str_replace($rep, $with, $get_url[2]) . '/';
     227                        if (preg_match('/attachment_id/i', $get_url[2])) {
     228                            $iwp_mmb_rp       = get_bloginfo('wpurl') . '/?attachment_id=' . $attach_id;
     229                            $post_content = preg_replace($iwp_mmb_mp, $iwp_mmb_rp, $post_content);
     230                        }
     231                    }
     232                } else {
     233                    @unlink($tmp_file);
     234                    return array('error' => "Cannot create attachment file in ".$attach_upload['path']." Please set correct permissions.");
     235                   
     236                }
     237                @unlink($tmp_file);
     238            }
    243239           
    244240           
  • wpguards/trunk/modules/manager/backup.class.php

    r872784 r873445  
    110110      //WPguards modify!!!!!!
    111111      if ( (int) @ini_get('max_execution_time') < 7200 ) {
    112             @ini_set('max_execution_time', 7200);//two hours
    113             @set_time_limit(7200);
    114             $changed['execution_time'] = 1;
    115         }
     112            @ini_set('max_execution_time', 7200);//two hours
     113            @set_time_limit(7200);
     114            $changed['execution_time'] = 1;
     115        }
    116116       
    117117        return $changed;
     
    178178                    $before[$task_name]['task_results'] = array_values($before[$task_name]['task_results']);
    179179                }
    180                 //$before[$task_name]['task_results'][count($before[$task_name]['task_results'])]['time'] = (isset($time) && $time) ? $time : time();
     180                $before[$task_name]['task_results'][count($before[$task_name]['task_results'])]['time'] = (isset($time) && $time) ? $time : time();
    181181            //}
    182             if (isset($time) && $time) { //This will occur for schedule runtask.
    183                 $before[$task_name]['task_results'][count($before[$task_name]['task_results'])]['time'] = $time;
    184             }else{
    185                 if($task_name == 'Backup Now')
    186                  $before[$task_name]['task_results'][count($before[$task_name]['task_results'])]['time'] = time();
    187             }
     182           
    188183           
    189184            $this->update_tasks($before);
     
    326321        if (!$args || empty($args))
    327322            return false;
    328        
     323       
    329324        extract($args); //extract settings
    330325       
     
    562557       
    563558        $this->update_status($task_name,'finished',true);
    564 
     559        do_action( 'iwp_after_backup', $backup_url, $backup_settings[$task_name], $paths, $task_name );
     560       
    565561        return $backup_url; //Return url to backup file
    566562    }
     
    12981294    function restore($args)
    12991295    {
     1296        $args = apply_filters('before_backup', $args, $this->tasks );
    13001297       
    13011298        global $wpdb, $wp_filesystem;
    13021299        if (empty($args)) {
    1303             return false;
    1304         }
     1300            return false; 
     1301        } 
    13051302       
    13061303        extract($args);
    13071304        $this->set_memory();
    13081305       
    1309         $unlink_file = true; //Delete file after restore
     1306        $unlink_file = false; //Delete file after restore
    13101307       
    13111308        include_once ABSPATH . 'wp-admin/includes/file.php';
     
    13271324            if (isset($task['task_results'][$result_id]['server'])) {
    13281325                $backup_file = $task['task_results'][$result_id]['server']['file_path'];
    1329                 $unlink_file = false; //Don't delete file if stored on server
     1326                $unlink_file = true; //Don't delete file if stored on server
    13301327               
    13311328            } elseif (isset($task['task_results'][$result_id]['ftp'])) {
     
    14981495                iwp_mmb_print_flush('ZIP Extract PCL: Start');
    14991496                $archive = new IWPPclZip($backup_file);
    1500                 $result  = $archive->extract(PCLZIP_OPT_PATH, $new_temp_folder, PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1);
     1497                $result  = $archive->extract(PCLZIP_OPT_PATH, $new_temp_folder, PCLZIP_OPT_REPLACE_NEWER);
    15011498                iwp_mmb_print_flush('ZIP Extract PCL: End');
    15021499            }
     
    15041501           
    15051502            if ($unlink_file) {
    1506                 @unlink($backup_file);
     1503                //@unlink($backup_file);
    15071504            }
    15081505           
     
    21022099            require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/dropbox.php';
    21032100           
    2104            
    2105             $dropbox = new IWP_Dropbox($consumer_key, $consumer_secret);
    2106            
     2101            $dropbox = new Dropbox($consumer_key, $consumer_secret);
    21072102            $dropbox->setOAuthTokens($oauth_token, $oauth_token_secret);
    21082103           
     
    21382133        require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/dropbox.php';
    21392134       
    2140        
    2141         $dropbox = new IWP_Dropbox($consumer_key, $consumer_secret);
    2142        
    2143        
     2135        $dropbox = new Dropbox($consumer_key, $consumer_secret);
    21442136        $dropbox->setOAuthTokens($oauth_token, $oauth_token_secret);
    21452137       
     
    21662158        require_once $GLOBALS['iwp_mmb_plugin_dir']  . '/lib/dropbox.php';
    21672159       
    2168        
    2169         $dropbox = new IWP_Dropbox($consumer_key, $consumer_secret);
    2170        
    2171        
     2160        $dropbox = new Dropbox($consumer_key, $consumer_secret);
    21722161        $dropbox->setOAuthTokens($oauth_token, $oauth_token_secret);
    21732162       
  • wpguards/trunk/modules/manager/core.class.php

    r872784 r873445  
    11<?php
     2
    23/************************************************************
     4
    35 * This plugin was modified by Revmakx                      *
     6
    47 * Copyright (c) 2012 Revmakx                               *
     8
    59 * www.revmakx.com                                          *
     10
    611 *                                                          *
     12
    713 ************************************************************/
     14
    815/*************************************************************
     16
    917 *
     18
    1019 * core.class.php
     20
    1121 *
     22
    1223 * Upgrade Plugins
     24
    1325 *
     26
    1427 *
     28
    1529 * Copyright (c) 2011 Prelovac Media
     30
    1631 * www.prelovac.com
     32
    1733 **************************************************************/
     34
    1835 
     36
    1937class IWP_MMB_Core extends IWP_MMB_Helper
     38
    2039{
     40
    2141    var $name;
     42
    2243    var $slug;
     44
    2345    var $settings;
     46
    2447    var $remote_client;
     48
    2549    var $comment_instance;
     50
    2651    var $plugin_instance;
     52
    2753    var $theme_instance;
     54
    2855    var $wp_instance;
     56
    2957    var $post_instance;
     58
    3059    var $stats_instance;
     60
    3161    var $search_instance;
     62
    3263    var $links_instance;
     64
    3365    var $user_instance;
     66
    3467    var $backup_instance;
     68
    3569    var $installer_instance;
     70
    3671    var $iwp_mmb_multisite;
     72
    3773    var $network_admin_install;
     74
    3875   
     76
    3977    var $backup_repository_instance;
     78
    4079    var $optimize_instance;
     80
    4181   
     82
    4283    private $action_call;
     84
    4385    private $action_params;
     86
    4487    private $iwp_mmb_pre_init_actions;
     88
    4589    private $iwp_mmb_pre_init_filters;
     90
    4691    private $iwp_mmb_init_actions;
    47    
    48    
     92
     93   
     94
     95   
     96
    4997    function __construct()
    50     {
     98
     99    {
     100
    51101        global $iwp_mmb_plugin_dir, $wpmu_version, $blog_id, $_iwp_mmb_plugin_actions, $_iwp_mmb_item_filter;
    52        
     102
     103       
     104
    53105        $_iwp_mmb_plugin_actions = array();
     106
    54107        $this->name     = 'Manage Multiple Blogs';
     108
    55109        $this->slug     = 'manage-multiple-blogs';
     110
    56111        $this->action_call = null;
     112
    57113        $this->action_params = null;
    58        
    59        
     114
     115       
     116
     117       
     118
    60119        $this->settings = get_option($this->slug);
     120
    61121        if (!$this->settings) {
     122
    62123            $this->settings = array(
     124
    63125                'blogs' => array(),
     126
    64127                'current_blog' => array(
     128
    65129                    'type' => null
     130
    66131                )
     132
    67133            );
     134
    68135            $this->save_options();
    69         }
     136
     137        }
     138
    70139        if ( function_exists('is_multisite') ) {
     140
    71141            if ( is_multisite() ) {
     142
    72143                $this->iwp_mmb_multisite = $blog_id;
     144
    73145                $this->network_admin_install = get_option('iwp_client_network_admin_install');
     146
    74147            }
     148
    75149        } else if (!empty($wpmu_version)) {
     150
    76151            $this->iwp_mmb_multisite = $blog_id;
     152
    77153            $this->network_admin_install = get_option('iwp_client_network_admin_install');
     154
    78155        } else {
     156
    79157            $this->iwp_mmb_multisite = false;
     158
    80159            $this->network_admin_install = null;
     160
    81161        }
    82        
     162
     163       
     164
    83165        // admin notices
     166
    84167        if ( !get_option('iwp_client_public_key') ){
     168
    85169            if( $this->iwp_mmb_multisite ){
     170
    86171                if( is_network_admin() && $this->network_admin_install == '1'){
     172
    87173                    add_action('network_admin_notices', array( &$this, 'network_admin_notice' ));
     174
    88175                } else if( $this->network_admin_install != '1' ){
     176
    89177                    //$parent_key = $this->get_parent_blog_option('iwp_client_public_key');//IWP commented to show notice to all subsites of network
     178
    90179                    //if(empty($parent_key))//IWP commented to show notice to all subsites of network
     180
    91181                        add_action('admin_notices', array( &$this, 'admin_notice' ));
     182
    92183                }
     184
    93185            } else {
     186
    94187                add_action('admin_notices', array( &$this, 'admin_notice' ));
     188
    95189            }
     190
    96191        }
    97        
     192
     193       
     194
    98195        // default filters
     196
    99197        //$this->iwp_mmb_pre_init_filters['get_stats']['iwp_mmb_stats_filter'][] = array('IWP_MMB_Stats', 'pre_init_stats'); // called with class name, use global $iwp_mmb_core inside the function instead of $this
     198
    100199        $this->iwp_mmb_pre_init_filters['get_stats']['iwp_mmb_stats_filter'][] = 'iwp_mmb_pre_init_stats';
    101        
     200
     201       
     202
    102203        $_iwp_mmb_item_filter['pre_init_stats'] = array( 'core_update', 'hit_counter', 'comments', 'backups', 'posts', 'drafts', 'scheduled' );
     204
    103205        $_iwp_mmb_item_filter['get'] = array( 'updates', 'errors' );
    104        
     206
     207       
     208
    105209        $this->iwp_mmb_pre_init_actions = array(
     210
    106211            'backup_req' => 'iwp_mmb_get_backup_req',
     212
    107213        );
    108        
     214
     215       
     216
    109217        $this->iwp_mmb_init_actions = array(
     218
    110219            'do_upgrade' => 'iwp_mmb_do_upgrade',
     220
    111221            'get_stats' => 'iwp_mmb_stats_get',
     222
    112223            'remove_site' => 'iwp_mmb_remove_site',
     224
    113225            'backup_clone' => 'iwp_mmb_backup_now',
     226
    114227            'restore' => 'iwp_mmb_restore_now',
     228
    115229            'optimize_tables' => 'iwp_mmb_optimize_tables',
     230
    116231            'check_wp_version' => 'iwp_mmb_wp_checkversion',
     232
    117233            'create_post' => 'iwp_mmb_post_create',
     234
    118235            'update_client' => 'iwp_mmb_update_client_plugin',
     236
    119237           
     238
    120239            'change_comment_status' => 'iwp_mmb_change_comment_status',
     240
    121241            'change_post_status' => 'iwp_mmb_change_post_status',
     242
    122243            'get_comment_stats' => 'iwp_mmb_comment_stats_get',
     244
    123245           
     246
    124247            'get_links' => 'iwp_mmb_get_links',
     248
    125249            'add_link' => 'iwp_mmb_add_link',
     250
    126251            'delete_link' => 'iwp_mmb_delete_link',
     252
    127253            'delete_links' => 'iwp_mmb_delete_links',
     254
    128255           
     256
    129257            'create_post' => 'iwp_mmb_post_create',
     258
    130259            'change_post_status' => 'iwp_mmb_change_post_status',
     260
    131261            'get_posts' => 'iwp_mmb_get_posts',
     262
    132263            'delete_post' => 'iwp_mmb_delete_post',
     264
    133265            'delete_posts' => 'iwp_mmb_delete_posts',
     266
    134267            'edit_posts' => 'iwp_mmb_edit_posts',
     268
    135269            'get_pages' => 'iwp_mmb_get_pages',
     270
    136271            'delete_page' => 'iwp_mmb_delete_page',
     272
    137273           
     274
    138275            'install_addon' => 'iwp_mmb_install_addon',
     276
    139277            'add_link' => 'iwp_mmb_add_link',
     278
    140279            'add_user' => 'iwp_mmb_add_user',
     280
    141281            'email_backup' => 'iwp_mmb_email_backup',
     282
    142283            'check_backup_compat' => 'iwp_mmb_check_backup_compat',
     284
    143285            'scheduled_backup' => 'iwp_mmb_scheduled_backup',
     286
    144287            'run_task' => 'iwp_mmb_run_task_now',
     288
    145289            'delete_schedule_task' => 'iwp_mmb_delete_task_now',
     290
    146291            'execute_php_code' => 'iwp_mmb_execute_php_code',
     292
    147293            'delete_backup' => 'iwp_mmb_delete_backup',
     294
    148295            'remote_backup_now' => 'iwp_mmb_remote_backup_now',
     296
    149297            'set_notifications' => 'iwp_mmb_set_notifications',
     298
    150299            'clean_orphan_backups' => 'iwp_mmb_clean_orphan_backups',
     300
    151301            'get_users' => 'iwp_mmb_get_users',
     302
    152303            'edit_users' => 'iwp_mmb_edit_users',
     304
    153305            'get_plugins_themes' => 'iwp_mmb_get_plugins_themes',
     306
    154307            'edit_plugins_themes' => 'iwp_mmb_edit_plugins_themes',
     308
    155309            'get_comments' => 'iwp_mmb_get_comments',
     310
    156311            'action_comment' => 'iwp_mmb_action_comment',
     312
    157313            'bulk_action_comments' => 'iwp_mmb_bulk_action_comments',
     314
    158315            'replyto_comment' => 'iwp_mmb_reply_comment',
     316
    159317            'client_brand' => 'iwp_mmb_client_brand',
     318
    160319            'set_alerts' => 'iwp_mmb_set_alerts',
     320
    161321            'maintenance' => 'iwp_mmb_maintenance_mode',
     322
    162323           
     324
    163325            'wp_optimize' => 'iwp_mmb_wp_optimize',
     326
    164327           
     328
    165329            'backup_repository' => 'iwp_mmb_backup_repository'
     330
    166331        );
    167        
     332
     333       
     334
    168335        add_action('rightnow_end', array( &$this, 'add_right_now_info' ));       
     336
    169337        add_action('admin_init', array(&$this,'admin_actions'));   
     338
    170339        add_action('init', array( &$this, 'iwp_mmb_remote_action'), 9999);
     340
    171341        add_action('setup_theme', 'iwp_mmb_parse_request');
     342
    172343        add_action('set_auth_cookie', array( &$this, 'iwp_mmb_set_auth_cookie'));
     344
    173345        add_action('set_logged_in_cookie', array( &$this, 'iwp_mmb_set_logged_in_cookie'));
    174        
    175     }
    176    
     346
     347       
     348
     349    }
     350
     351   
     352
    177353    function iwp_mmb_remote_action(){
     354
    178355        if($this->action_call != null){
     356
    179357            $params = isset($this->action_params) && $this->action_params != null ? $this->action_params : array();
     358
    180359            call_user_func($this->action_call, $params);
     360
    181361        }
     362
    182363    }
     364
    183365   
     366
    184367    function register_action_params( $action = false, $params = array() ){
    185        
     368
     369       
     370
    186371        if(isset($this->iwp_mmb_pre_init_actions[$action]) && function_exists($this->iwp_mmb_pre_init_actions[$action])){
     372
    187373            call_user_func($this->iwp_mmb_pre_init_actions[$action], $params);
     374
    188375        }
    189        
     376
     377       
     378
    190379        if(isset($this->iwp_mmb_init_actions[$action]) && function_exists($this->iwp_mmb_init_actions[$action])){
     380
    191381            $this->action_call = $this->iwp_mmb_init_actions[$action];
     382
    192383            $this->action_params = $params;
     384
    193385           
     386
    194387            if( isset($this->iwp_mmb_pre_init_filters[$action]) && !empty($this->iwp_mmb_pre_init_filters[$action])){
     388
    195389                global $iwp_mmb_filters;
     390
    196391               
     392
    197393                foreach($this->iwp_mmb_pre_init_filters[$action] as $_name => $_functions){
     394
    198395                    if(!empty($_functions)){
     396
    199397                        $data = array();
     398
    200399                       
     400
    201401                        foreach($_functions as $_k => $_callback){
     402
    202403                            if(is_array($_callback) && method_exists($_callback[0], $_callback[1]) ){
     404
    203405                                $data = call_user_func( $_callback, $params );
     406
    204407                            } elseif (is_string($_callback) && function_exists( $_callback )){
     408
    205409                                $data = call_user_func( $_callback, $params );
     410
    206411                            }
     412
    207413                            $iwp_mmb_filters[$_name] = isset($iwp_mmb_filters[$_name]) && !empty($iwp_mmb_filters[$_name]) ? array_merge($iwp_mmb_filters[$_name], $data) : $data;
     414
    208415                            add_filter( $_name, create_function( '$a' , 'global $iwp_mmb_filters; return array_merge($a, $iwp_mmb_filters["'.$_name.'"]);') );
     416
    209417                        }
     418
    210419                    }
     420
    211421                   
     422
    212423                }
     424
    213425            }
     426
    214427            return true;
     428
    215429        }
     430
    216431        return false;
     432
    217433    }
     434
    218435   
    219     /**
     436
     437    /**
     438
    220439     * Add notice to network admin dashboard for security reasons   
    221      *
    222      */
     440
     441     *
     442
     443     */
     444
    223445    function network_admin_notice()
    224     {
     446
     447    {
     448
    225449        echo '<div class="error" style="text-align: center;"><p style="font-size: 14px; font-weight: bold; color:#c00;">Attention !</p>
     450
    226451        <p>The InfiniteWP client plugin has to be activated on individual sites. Kindly deactivate the plugin from the network admin dashboard and activate them from the individual dashboards.</p></div>';
    227     }
     452
     453    }
     454
    228455   
    229        
     456
     457       
     458
    230459    /**
     460
    231461     * Add notice to admin dashboard for security reasons   
    232      *
    233      */
     462
     463     *
     464
     465     */
     466
    234467    function admin_notice()
    235     {
     468
     469    {
     470
    236471       /* IWP */
    237         if(defined('MULTISITE') && MULTISITE == true){ 
     472       /* We don't need that notices anymore */
     473
     474        /*if(defined('MULTISITE') && MULTISITE == true){   
     475
    238476            global $blog_id;           
     477
    239478            $user_id_from_email = get_user_id_from_string( get_blog_option($blog_id, 'admin_email'));
     479
    240480            $details = get_userdata($user_id_from_email);
     481
    241482            $username = $details->user_login;           
     483
    242484        }
     485
    243486        else{
     487
    244488            $current_user = wp_get_current_user();
     489
    245490            $username = $current_user->data->user_login;
     491
    246492        }   
    247        
     493
     494       
     495
    248496        $iwp_client_activate_key = get_option('iwp_client_activate_key');
    249        
     497
     498       
     499
    250500        //check BWP
     501
    251502        $bwp = get_option("bit51_bwps");
     503
    252504        $notice_display_URL=admin_url();
     505
    253506        if(!empty($bwp))
     507
    254508        {
     509
    255510            //$bwpArray = @unserialize($bwp);
     511
    256512            if($bwp['hb_enabled']==1)
     513
    257514            $notice_display_URL = get_option('home');
     515
    258516        }
    259        
     517
     518       
     519
    260520        $notice_display_URL = rtrim($notice_display_URL, '/').'/';
    261        
    262        
     521
     522       
     523
     524       
     525
    263526        echo '<div class="updated" style="text-align: center;"><p style="color: green; font-size: 14px; font-weight: bold;">Add this site to IWP Admin panel</p><p>
     527
    264528        <table border="0" align="center">';
     529
    265530        if(!empty($iwp_client_activate_key)){
     531
    266532            echo '<tr><td align="right">WP-ADMIN URL:</td><td align="left"><strong>'.$notice_display_URL.'</strong></td></tr>
     533
    267534            <tr><td align="right">ADMIN USERNAME:</td><td align="left"><strong>'.$username.'</strong> (or any admin id)</td></tr>
     535
    268536            <tr><td align="right">ACTIVATION KEY:</td><td align="left"><strong>'.$iwp_client_activate_key.'</strong></td></tr>';
     537
    269538        }
     539
    270540        else{
     541
    271542            echo '<tr><td align="center">Please deactivate and then activate InfiniteWP Client plugin.</td></tr>';
     543
    272544        }       
    273        
     545
     546       
     547
    274548        echo '</table>
    275         </p></div>';       
    276        
    277     }
    278    
    279     /**
     549
     550        </p></div>';    */ 
     551
     552       
     553
     554    }
     555
     556   
     557
     558    /**
     559
    280560     * Add an item into the Right Now Dashboard widget
     561
    281562     * to inform that the blog can be managed remotely
    282      *
    283      */
     563
     564     *
     565
     566     */
     567
    284568    function add_right_now_info()
    285     {
     569
     570    {
     571
    286572        echo '<div class="iwp_mmb-slave-info">
     573
    287574            <p>This site can be managed remotely.</p>
     575
    288576        </div>';
    289     }
    290    
    291     /**
     577
     578    }
     579
     580   
     581
     582    /**
     583
    292584     * Get parent blog options
    293      *
    294      */
     585
     586     *
     587
     588     */
     589
    295590    private function get_parent_blog_option( $option_name = '' )
    296     {
     591
     592    {
     593
    297594        global $wpdb;
     595
    298596        $option = $wpdb->get_var( $wpdb->prepare( "SELECT `option_value` FROM {$wpdb->base_prefix}options WHERE option_name = %s LIMIT 1", $option_name ) );
     597
    299598        return $option;
    300     }
    301    
     599
     600    }
     601
     602   
     603
    302604   
     605
    303606    /**
     607
    304608     * Gets an instance of the WP_Optimize class
    305      *
    306      */
     609
     610     *
     611
     612     */
     613
    307614    function wp_optimize_instance()
    308     {
     615
     616    {
     617
    309618        if (!isset($this->optimize_instance)) {
     619
    310620            $this->optimize_instance = new IWP_MMB_Optimize();
    311         }
    312        
     621
     622        }
     623
     624       
     625
    313626        return $this->optimize_instance;
    314     }
    315    
    316     /**
     627
     628    }
     629
     630   
     631
     632    /**
     633
    317634     * Gets an instance of the Comment class
    318      *
    319      */
     635
     636     *
     637
     638     */
     639
    320640    function get_comment_instance()
    321     {
     641
     642    {
     643
    322644        if (!isset($this->comment_instance)) {
     645
    323646            $this->comment_instance = new IWP_MMB_Comment();
    324         }
    325        
     647
     648        }
     649
     650       
     651
    326652        return $this->comment_instance;
    327     }
    328    
    329     /**
     653
     654    }
     655
     656   
     657
     658    /**
     659
    330660     * Gets an instance of the Plugin class
    331      *
    332      */
     661
     662     *
     663
     664     */
     665
    333666    function get_plugin_instance()
    334     {
     667
     668    {
     669
    335670        if (!isset($this->plugin_instance)) {
     671
    336672            $this->plugin_instance = new IWP_MMB_Plugin();
    337         }
    338        
     673
     674        }
     675
     676       
     677
    339678        return $this->plugin_instance;
    340     }
    341    
    342     /**
     679
     680    }
     681
     682   
     683
     684    /**
     685
    343686     * Gets an instance of the Theme class
    344      *
    345      */
     687
     688     *
     689
     690     */
     691
    346692    function get_theme_instance()
    347     {
     693
     694    {
     695
    348696        if (!isset($this->theme_instance)) {
     697
    349698            $this->theme_instance = new IWP_MMB_Theme();
    350         }
    351        
     699
     700        }
     701
     702       
     703
    352704        return $this->theme_instance;
    353     }
    354    
    355    
    356     /**
     705
     706    }
     707
     708   
     709
     710   
     711
     712    /**
     713
    357714     * Gets an instance of IWP_MMB_Post class
    358      *
    359      */
     715
     716     *
     717
     718     */
     719
    360720    function get_post_instance()
    361     {
     721
     722    {
     723
    362724        if (!isset($this->post_instance)) {
     725
    363726            $this->post_instance = new IWP_MMB_Post();
    364         }
    365        
     727
     728        }
     729
     730       
     731
    366732        return $this->post_instance;
    367     }
    368    
    369     /**
     733
     734    }
     735
     736   
     737
     738    /**
     739
    370740     * Gets an instance of Blogroll class
    371      *
    372      */
     741
     742     *
     743
     744     */
     745
    373746    function get_blogroll_instance()
    374     {
     747
     748    {
     749
    375750        if (!isset($this->blogroll_instance)) {
     751
    376752            $this->blogroll_instance = new IWP_MMB_Blogroll();
    377         }
    378        
     753
     754        }
     755
     756       
     757
    379758        return $this->blogroll_instance;
    380     }
    381    
    382    
    383    
    384     /**
     759
     760    }
     761
     762   
     763
     764   
     765
     766   
     767
     768    /**
     769
    385770     * Gets an instance of the WP class
    386      *
    387      */
     771
     772     *
     773
     774     */
     775
    388776    function get_wp_instance()
    389     {
     777
     778    {
     779
    390780        if (!isset($this->wp_instance)) {
     781
    391782            $this->wp_instance = new IWP_MMB_WP();
    392         }
    393        
     783
     784        }
     785
     786       
     787
    394788        return $this->wp_instance;
    395     }
    396    
    397     /**
     789
     790    }
     791
     792   
     793
     794    /**
     795
    398796     * Gets an instance of User
    399      *
    400      */
     797
     798     *
     799
     800     */
     801
    401802    function get_user_instance()
    402     {
     803
     804    {
     805
    403806        if (!isset($this->user_instance)) {
     807
    404808            $this->user_instance = new IWP_MMB_User();
    405         }
    406        
     809
     810        }
     811
     812       
     813
    407814        return $this->user_instance;
    408     }
    409    
    410     /**
     815
     816    }
     817
     818   
     819
     820    /**
     821
    411822     * Gets an instance of stats class
    412      *
    413      */
     823
     824     *
     825
     826     */
     827
    414828    function get_stats_instance()
    415     {
     829
     830    {
     831
    416832        if (!isset($this->stats_instance)) {
     833
    417834            $this->stats_instance = new IWP_MMB_Stats();
    418         }
     835
     836        }
     837
    419838        return $this->stats_instance;
    420     }
    421     /**
     839
     840    }
     841
     842    /**
     843
    422844     * Gets an instance of search class
    423      *
    424      */
     845
     846     *
     847
     848     */
     849
    425850    function get_search_instance()
    426     {
     851
     852    {
     853
    427854        if (!isset($this->search_instance)) {
     855
    428856            $this->search_instance = new IWP_MMB_Search();
    429         }
     857
     858        }
     859
    430860        //return $this->search_instance;
     861
    431862        return $this->search_instance;
    432     }
    433     /**
     863
     864    }
     865
     866    /**
     867
    434868     * Gets an instance of stats class
     869
    435870     *
    436      */
     871
     872     */
     873
    437874    function get_backup_instance()
    438     {
     875
     876    {
     877
    439878        if (!isset($this->backup_instance)) {
     879
    440880            $this->backup_instance = new IWP_MMB_Backup();
    441         }
    442        
     881
     882        }
     883
     884       
     885
    443886        return $this->backup_instance;
    444     }
    445    
     887
     888    }
     889
     890   
     891
    446892    function get_backup_repository_instance()
    447     {
     893
     894    {
     895
    448896        if (!isset($this->backup_repository_instance)) {
     897
    449898            $this->backup_repository_instance = new IWP_MMB_Backup_Repository();
    450         }
    451        
     899
     900        }
     901
     902       
     903
    452904        return $this->backup_repository_instance;
    453     }
    454    
    455     /**
     905
     906    }
     907
     908   
     909
     910    /**
     911
    456912     * Gets an instance of links class
     913
    457914     *
    458      */
     915
     916     */
     917
    459918    function get_link_instance()
    460     {
     919
     920    {
     921
    461922        if (!isset($this->link_instance)) {
     923
    462924            $this->link_instance = new IWP_MMB_Link();
    463         }
    464        
     925
     926        }
     927
     928       
     929
    465930        return $this->link_instance;
    466     }
    467    
     931
     932    }
     933
     934   
     935
    468936    function get_installer_instance()
    469     {
     937
     938    {
     939
    470940        if (!isset($this->installer_instance)) {
     941
    471942            $this->installer_instance = new IWP_MMB_Installer();
    472         }
     943
     944        }
     945
    473946        return $this->installer_instance;
    474     }
     947
     948    }
     949
    475950   
    476     /**
     951
     952    /**
     953
    477954     * Plugin install callback function
     955
    478956     * Check PHP version
    479      */
     957
     958     */
     959
    480960    function install() {
    481        
     961
     962       
     963
    482964        global $wpdb, $_wp_using_ext_object_cache, $current_user;
     965
    483966        $_wp_using_ext_object_cache = false;
    484967
     968
     969
    485970        //delete plugin options, just in case
     971
    486972        if ($this->iwp_mmb_multisite != false) {
     973
    487974            $network_blogs = $wpdb->get_results("select `blog_id`, `site_id` from `{$wpdb->blogs}`");
     975
    488976            if(!empty($network_blogs)){
     977
    489978                if( is_network_admin() ){
     979
    490980                    update_option('iwp_client_network_admin_install', 1);
     981
    491982                    foreach($network_blogs as $details){
     983
    492984                        if($details->site_id == $details->blog_id)
     985
    493986                            update_blog_option($details->blog_id, 'iwp_client_network_admin_install', 1);
     987
    494988                        else
     989
    495990                            update_blog_option($details->blog_id, 'iwp_client_network_admin_install', -1);
     991
    496992                           
     993
    497994                        delete_blog_option($blog_id, 'iwp_client_nossl_key');
     995
    498996                        delete_blog_option($blog_id, 'iwp_client_public_key');
     997
    499998                        delete_blog_option($blog_id, 'iwp_client_action_message_id');
     999
    5001000                    }
     1001
    5011002                } else {
     1003
    5021004                    update_option('iwp_client_network_admin_install', -1);
     1005
    5031006                    delete_option('iwp_client_nossl_key');
     1007
    5041008                    delete_option('iwp_client_public_key');
     1009
    5051010                    delete_option('iwp_client_action_message_id');
     1011
    5061012                }
     1013
    5071014            }
     1015
    5081016        } else {
     1017
    5091018            delete_option('iwp_client_nossl_key');
     1019
    5101020            delete_option('iwp_client_public_key');
     1021
    5111022            delete_option('iwp_client_action_message_id');
    512         }
    513        
     1023
     1024        }
     1025
     1026       
     1027
    5141028        //delete_option('iwp_client_backup_tasks');
     1029
    5151030        delete_option('iwp_client_notifications');
     1031
    5161032        delete_option('iwp_client_brand');
     1033
    5171034        delete_option('iwp_client_pageview_alerts');
    5181035       
     1036       
     1037
    5191038        add_option('iwp_client_activate_key', sha1( rand(1, 99999). uniqid('', true) . get_option('siteurl') ) );
    520        
    521     }
    522    
    523     /**
     1039
     1040       
     1041
     1042    }
     1043
     1044   
     1045
     1046    /**
     1047
    5241048     * Saves the (modified) options into the database
    525      *
    526      */
     1049
     1050     *
     1051
     1052     */
     1053
    5271054    function save_options()
    528     {
     1055
     1056    {
     1057
    5291058        if (get_option($this->slug)) {
     1059
    5301060            update_option($this->slug, $this->settings);
     1061
    5311062        } else {
     1063
    5321064            add_option($this->slug, $this->settings);
    533         }
    534     }
    535    
    536     /**
     1065
     1066        }
     1067
     1068    }
     1069
     1070   
     1071
     1072    /**
     1073
    5371074     * Deletes options for communication with IWP Admin panel
    538      *
    539      */
     1075
     1076     *
     1077
     1078     */
     1079
    5401080    function uninstall( $deactivate = false )
    541     {
     1081
     1082    {
     1083
    5421084        global $current_user, $wpdb, $_wp_using_ext_object_cache;
     1085
    5431086        $_wp_using_ext_object_cache = false;
    544        
     1087
     1088       
     1089
    5451090        if ($this->iwp_mmb_multisite != false) {
     1091
    5461092            $network_blogs = $wpdb->get_col("select `blog_id` from `{$wpdb->blogs}`");
     1093
    5471094            if(!empty($network_blogs)){
     1095
    5481096                if( is_network_admin() ){
     1097
    5491098                    if( $deactivate ) {
     1099
    5501100                        delete_option('iwp_client_network_admin_install');
     1101
    5511102                        foreach($network_blogs as $blog_id){
     1103
    5521104                            delete_blog_option($blog_id, 'iwp_client_network_admin_install');
     1105
    5531106                            delete_blog_option($blog_id, 'iwp_client_nossl_key');
     1107
    5541108                            delete_blog_option($blog_id, 'iwp_client_public_key');
     1109
    5551110                            delete_blog_option($blog_id, 'iwp_client_action_message_id');
     1111
    5561112                            delete_blog_option($blog_id, 'iwp_client_maintenace_mode');
     1113
    5571114                        }
     1115
    5581116                    }
     1117
    5591118                } else {
     1119
    5601120                    if( $deactivate )
     1121
    5611122                        delete_option('iwp_client_network_admin_install');
     1123
    5621124                       
     1125
    5631126                    delete_option('iwp_client_nossl_key');
     1127
    5641128                    delete_option('iwp_client_public_key');
     1129
    5651130                    delete_option('iwp_client_action_message_id');
     1131
    5661132                }
     1133
    5671134            }
     1135
    5681136        } else {
     1137
    5691138            delete_option('iwp_client_nossl_key');
     1139
    5701140            delete_option('iwp_client_public_key');
     1141
    5711142            delete_option('iwp_client_action_message_id');
    572         }
    573        
     1143
     1144        }
     1145
     1146       
     1147
    5741148        //Delete options
     1149
    5751150        delete_option('iwp_client_maintenace_mode');
     1151
    5761152        //delete_option('iwp_client_backup_tasks');
     1153
    5771154        wp_clear_scheduled_hook('iwp_client_backup_tasks');
     1155
    5781156        delete_option('iwp_client_notifications');
     1157
    5791158        wp_clear_scheduled_hook('iwp_client_notifications');       
     1159
    5801160        delete_option('iwp_client_brand');
     1161
    5811162        delete_option('iwp_client_pageview_alerts');
    582        
     1163
     1164       
     1165
    5831166        delete_option('iwp_client_activate_key');
    584     }
    585    
    586    
    587     /**
     1167
     1168    }
     1169
     1170   
     1171
     1172   
     1173
     1174    /**
     1175
    5881176     * Constructs a url (for ajax purpose)
    589      *
     1177
     1178     *
     1179
    5901180     * @param mixed $base_page
    591      */
     1181
     1182     */
     1183
    5921184    function construct_url($params = array(), $base_page = 'index.php')
    593     {
     1185
     1186    {
     1187
    5941188        $url = "$base_page?_wpnonce=" . wp_create_nonce($this->slug);
     1189
    5951190        foreach ($params as $key => $value) {
     1191
    5961192            $url .= "&$key=$value";
    597         }
    598        
     1193
     1194        }
     1195
     1196       
     1197
    5991198        return $url;
    600     }
    601    
    602     /**
     1199
     1200    }
     1201
     1202   
     1203
     1204    /**
     1205
    6031206     * Client update
    604      *
    605      */
     1207
     1208     *
     1209
     1210     */
     1211
    6061212    function update_client_plugin($params)
    607     {
     1213
     1214    {
     1215
    6081216        extract($params);
     1217
    6091218        if ($download_url) {
     1219
    6101220            @include_once ABSPATH . 'wp-admin/includes/file.php';
     1221
    6111222            @include_once ABSPATH . 'wp-admin/includes/misc.php';
     1223
    6121224            @include_once ABSPATH . 'wp-admin/includes/template.php';
     1225
    6131226            @include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     1227
    6141228            @include_once ABSPATH . 'wp-admin/includes/screen.php';
     1229
    6151230           
     1231
    6161232            if (!$this->is_server_writable()) {
     1233
    6171234                return array(
     1235
    6181236                    'error' => 'Failed. please add FTP details for automatic upgrades.'
     1237
    6191238                );
     1239
    6201240            }
     1241
    6211242           
     1243
    6221244            ob_start();
     1245
    6231246            @unlink(dirname(__FILE__));
     1247
    6241248            $upgrader = new Plugin_Upgrader();
     1249
    6251250            $result   = $upgrader->run(array(
     1251
    6261252                'package' => $download_url,
     1253
    6271254                'destination' => WP_PLUGIN_DIR,
     1255
    6281256                'clear_destination' => true,
     1257
    6291258                'clear_working' => true,
     1259
    6301260                'hook_extra' => array(
     1261
    6311262                    'plugin' => 'iwp-client/init.php'
     1263
    6321264                )
     1265
    6331266            ));
     1267
    6341268            ob_end_clean();
     1269
    6351270            @wp_update_plugins();
     1271
    6361272           
     1273
    6371274            if (is_wp_error($result) || !$result) {
     1275
    6381276                return array(
     1277
    6391278                    'error' => 'InfiniteWP Client plugin could not be updated.'
     1279
    6401280                );
     1281
    6411282            } else {
     1283
    6421284                return array(
     1285
    6431286                    'success' => 'InfiniteWP Client plugin successfully updated.'
     1287
    6441288                );
     1289
    6451290            }
    646         }
     1291
     1292        }
     1293
    6471294        return array(
     1295
    6481296            'error' => 'Bad download path for client installation file.'
     1297
    6491298        );
    650     }
    651    
    652     /**
     1299
     1300    }
     1301
     1302   
     1303
     1304    /**
     1305
    6531306     * Automatically logs in when called from IWP Admin panel
    654      *
    655      */
     1307
     1308     *
     1309
     1310     */
     1311
    6561312    function automatic_login()
    657     {
     1313
     1314    {
     1315
    6581316        $where      = isset($_GET['iwp_goto']) ? $_GET['iwp_goto'] : false;
     1317
    6591318        $username   = isset($_GET['username']) ? $_GET['username'] : '';
     1319
    6601320        $auto_login = isset($_GET['auto_login']) ? $_GET['auto_login'] : 0;
     1321
    6611322        $_SERVER['HTTP_REFERER']='';
     1323
    6621324        if( !function_exists('is_user_logged_in') )
     1325
    6631326            include_once( ABSPATH.'wp-includes/pluggable.php' );
    664        
     1327
     1328       
     1329
    6651330        if (( $auto_login && strlen(trim($username)) && !is_user_logged_in() ) || (isset($this->iwp_mmb_multisite) && $this->iwp_mmb_multisite )) {
     1331
    6661332            $signature  = base64_decode($_GET['signature']);
     1333
    6671334            $message_id = trim($_GET['message_id']);
     1335
    6681336           
     1337
    6691338            $auth = $this->authenticate_message($where . $message_id, $signature, $message_id);
     1339
    6701340            if ($auth === true) {
     1341
    6711342               
     1343
    6721344                if (!headers_sent())
     1345
    6731346                    header('P3P: CP="CAO PSA OUR"');
     1347
    6741348               
     1349
    6751350                if(!defined('IWP_MMB_USER_LOGIN'))
     1351
    6761352                    define('IWP_MMB_USER_LOGIN', true);
     1353
    6771354               
     1355
    6781356                $siteurl = function_exists('get_site_option') ? get_site_option( 'siteurl' ) : get_option('siteurl');
     1357
    6791358                $user = $this->iwp_mmb_get_user_info($username);
     1359
    6801360                wp_set_current_user($user->ID);
     1361
    6811362               
     1363
    6821364                if(!defined('COOKIEHASH') || (isset($this->iwp_mmb_multisite) && $this->iwp_mmb_multisite) )
     1365
    6831366                    wp_cookie_constants();
     1367
    6841368               
     1369
    6851370                wp_set_auth_cookie($user->ID);
     1371
    6861372                @iwp_mmb_client_header();
     1373
    6871374               
     1375
    6881376                if((isset($this->iwp_mmb_multisite) && $this->iwp_mmb_multisite ) || isset($_REQUEST['iwpredirect'])){
     1377
    6891378                    if(function_exists('wp_safe_redirect') && function_exists('admin_url')){
     1379
    6901380                        wp_safe_redirect(admin_url($where));
     1381
    6911382                        exit();
     1383
    6921384                    }
     1385
    6931386                }
     1387
    6941388            } else {
     1389
    6951390                wp_die($auth['error']);
     1391
    6961392            }
     1393
    6971394        } elseif( is_user_logged_in() ) {
     1395
    6981396            @iwp_mmb_client_header();
     1397
    6991398            if(isset($_REQUEST['iwpredirect'])){
     1399
    7001400                if(function_exists('wp_safe_redirect') && function_exists('admin_url')){
     1401
    7011402                    wp_safe_redirect(admin_url($where));
     1403
    7021404                    exit();
     1405
    7031406                }
     1407
    7041408            }
     1409
    7051410        }
    706     }
    707    
     1411
     1412    }
     1413
     1414   
     1415
    7081416    function iwp_mmb_set_auth_cookie( $auth_cookie ){
     1417
    7091418        if(!defined('IWP_MMB_USER_LOGIN'))
     1419
    7101420            return false;
    711        
     1421
     1422       
     1423
    7121424        if( !defined('COOKIEHASH') )
     1425
    7131426            wp_cookie_constants();
     1427
    7141428           
     1429
    7151430        $_COOKIE['wordpress_'.COOKIEHASH] = $auth_cookie;
    716        
     1431
     1432       
     1433
    7171434    }
     1435
    7181436    function iwp_mmb_set_logged_in_cookie( $logged_in_cookie ){
     1437
    7191438        if(!defined('IWP_MMB_USER_LOGIN'))
     1439
    7201440            return false;
     1441
    7211442   
     1443
    7221444        if( !defined('COOKIEHASH') )
     1445
    7231446            wp_cookie_constants();
     1447
    7241448           
     1449
    7251450        $_COOKIE['wordpress_logged_in_'.COOKIEHASH] = $logged_in_cookie;
     1451
    7261452    }
    727        
     1453
     1454       
     1455
    7281456    function admin_actions(){
    729         add_filter('all_plugins', array($this, 'client_replace'));
    730     }
    731    
     1457
     1458        //add_filter('all_plugins', array($this, 'client_replace'));
     1459
     1460    }
     1461
     1462   
     1463
    7321464    function client_replace($all_plugins){
     1465
    7331466        $replace = get_option("iwp_client_brand");
     1467
    7341468        if(is_array($replace)){
     1469
    7351470            if($replace['name'] || $replace['desc'] || $replace['author'] || $replace['author_url']){
     1471
    7361472                $all_plugins['iwp-client/init.php']['Name'] = $replace['name'];
     1473
    7371474                $all_plugins['iwp-client/init.php']['Title'] = $replace['name'];
     1475
    7381476                $all_plugins['iwp-client/init.php']['Description'] = $replace['desc'];
     1477
    7391478                $all_plugins['iwp-client/init.php']['AuthorURI'] = $replace['author_url'];
     1479
    7401480                $all_plugins['iwp-client/init.php']['Author'] = $replace['author'];
     1481
    7411482                $all_plugins['iwp-client/init.php']['AuthorName'] = $replace['author'];
     1483
    7421484                $all_plugins['iwp-client/init.php']['PluginURI'] = '';
     1485
    7431486            }
     1487
    7441488           
     1489
    7451490            if($replace['hide']){
     1491
    7461492                if (!function_exists('get_plugins')) {
     1493
    7471494            include_once(ABSPATH . 'wp-admin/includes/plugin.php');
     1495
    7481496            }
     1497
    7491498          $activated_plugins = get_option('active_plugins');
     1499
    7501500          if (!$activated_plugins)
     1501
    7511502                $activated_plugins = array();
     1503
    7521504          if(in_array('iwp-client/init.php',$activated_plugins))
     1505
    7531506            unset($all_plugins['iwp-client/init.php']);     
     1507
    7541508            }
     1509
    7551510        }
     1511
    7561512                   
     1513
    7571514        return $all_plugins;
    758     }
    759    
     1515
     1516    }
     1517
     1518   
     1519
    7601520   
     1521
    7611522}
     1523
    7621524?>
  • wpguards/trunk/modules/manager/helper.class.php

    r872784 r873445  
    349349        $current_message = $this->get_client_message_id();
    350350       
    351         if(isset($_GET['auto_login'])){//temp fix for stopping reuse of open admin url
    352             if ((int) $current_message >= (int) $message_id)
    353                 return array(
    354                     'error' => 'Invalid message recieved.'
    355                 );
    356         }
    357        
     351        /*if ((int) $current_message > (int) $message_id)
     352            return array(
     353                'error' => 'Invalid message recieved. Deactivate and activate the InfiniteWP Client plugin on this site, then remove the website from your InfiniteWP account and add it again.'
     354            );*/
     355       
    358356        $pl_key = $this->get_admin_panel_public_key();
    359357        if (!$pl_key) {
  • wpguards/trunk/modules/manager/init.php

    r872784 r873445  
    11<?php
    2 /*
    3 Plugin Name: InfiniteWP - Client
    4 Plugin URI: http://infinitewp.com/
    5 Description: This is the client plugin of InfiniteWP that communicates with the InfiniteWP Admin panel.
    6 Author: Revmakx
    7 Version: 1.2.8
    8 Author URI: http://www.revmakx.com
    9 */
     2/************************************************************
     3 * This plugin was modified by Wordpressgeeks               *
     4 * Copyright (c) 2013 Wordpressgeeks                        *
     5 * www.revmakx.com                                          *
     6 *                                                          *
     7 ************************************************************/
    108/************************************************************
    119 * This plugin was modified by Revmakx                      *
     
    2725
    2826if(!defined('IWP_MMB_CLIENT_VERSION'))
    29     define('IWP_MMB_CLIENT_VERSION', '1.2.8');
     27    define('IWP_MMB_CLIENT_VERSION', '1.2.3');
    3028
    3129
     
    4038
    4139$iwp_mmb_wp_version = $wp_version;
     40//WPGUARDS MODYFICATION
     41$iwp_mmb_plugin_dir = WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__));
     42$iwp_mmb_plugin_url = WP_PLUGIN_URL . '/' . basename(dirname(__FILE__));
     43//New Value
    4244$iwp_mmb_plugin_dir = WPGUARDS_MODULES_PATH.'/' . basename(dirname(__FILE__));
    4345$iwp_mmb_plugin_url = WPGUARDS_DIR . '/modules/' . basename(dirname(__FILE__));
     
    8991        if (!isset($HTTP_RAW_POST_DATA)) {
    9092            $HTTP_RAW_POST_DATA = file_get_contents('php://input');
    91         }
    92        
     93           
     94        }
     95        /*$fp = fopen('/home/wpguards//test/public_html/wp-content/plugins/wpguards/iwp-client/activate.txt', 'a');
     96        fwrite($fp, print_r($params, TRUE));
     97        fwrite($fp, print_r($_REQUEST, true));
     98        //fwrite($fp, print_r($_SERVER, true));
     99        fwrite($fp, print_r(unserialize(base64_decode(file_get_contents('php://input'))),true));
     100        fclose($fp); */
    93101        ob_start();
    94102       
     
    220228        global $iwp_mmb_core;
    221229        $num = extract($params);
    222        
     230
    223231        if ($num) {
    224232            if (!get_option('iwp_client_action_message_id') && !get_option('iwp_client_public_key')) {
    225233                $public_key = base64_decode($public_key);
    226234               
     235                fwrite($fp, $public_key);
    227236               
    228237                if(trim($activation_key) != get_option('iwp_client_activate_key')){ //iwp
     
    233242                if (checkOpenSSL() && !$user_random_key_signing) {
    234243                    $verify = openssl_verify($action . $id, base64_decode($signature), $public_key);
     244                    //fwrite($fp, '<----Weryfy: '.$verify.'-'.$action.$id);
     245                    ///fclose($fp);
    235246                    if ($verify == 1) {
    236247                        $iwp_mmb_core->set_admin_panel_public_key($public_key);
     
    281292        }
    282293    }
     294
     295
    283296}
    284297
     
    347360    {
    348361        global $iwp_mmb_core;
    349        
     362        die();
    350363        $iwp_mmb_core->get_backup_instance();
    351         $return = $iwp_mmb_core->backup_instance->backup($params);
     364        do_action( 'iwp_before_backup', $params );
     365       
     366        $return = $iwp_mmb_core->backup_instance->backup($params);
     367        //Custom Add action
    352368       
    353369        if (is_array($return) && array_key_exists('error', $return))
     
    11701186}
    11711187
     1188
     1189global $iwp_mmb_core;
    11721190$iwp_mmb_core = new IWP_MMB_Core();
    11731191$mmb_core = 1;
    1174 
     1192//$iwp_mmb_core->install(true);
    11751193if(isset($_GET['auto_login']))
    11761194    $iwp_mmb_core->automatic_login();   
    11771195
    1178 if (function_exists('register_activation_hook'))
    1179     register_activation_hook( __FILE__ , array( $iwp_mmb_core, 'install' ));
    1180 
    1181 if (function_exists('register_deactivation_hook'))
    1182     register_deactivation_hook(__FILE__, array( $iwp_mmb_core, 'uninstall' ));
     1196
    11831197
    11841198if (function_exists('add_action'))
     
    11921206    remove_action( 'login_init', 'send_frame_options_header');
    11931207}
    1194 
     1208//iwp_mmb_add_site(array('activation_key'))
    11951209?>
  • wpguards/trunk/modules/manager/installer.class.php

    r872784 r873445  
    5252    function install_remote_file($params)
    5353    {
    54                
    5554        global $wp_filesystem;
    5655        extract($params);
     
    9291            ));
    9392        }
    94                
     93       
    9594        if ($activate) {
    9695            if ($type == 'plugins') {
    9796                include_once(ABSPATH . 'wp-admin/includes/plugin.php');
    98                  
    99                  wp_cache_delete( 'plugins', 'plugins' );
    100                  
    101                 $all_plugins = get_plugins();
    102                 foreach ($all_plugins as $plugin_slug => $plugin) {
     97                $all_plugins = get_plugins();
     98                foreach ($all_plugins as $plugin_slug => $plugin) {
    10399                    $plugin_dir = preg_split('/\//', $plugin_slug);
    104100                    foreach ($install_info as $key => $install) {
     
    227223    {
    228224        ob_start();
    229         if (!function_exists('wp_version_check') || !function_exists('get_core_checksums'))
     225        if (!function_exists('wp_version_check'))
    230226            include_once(ABSPATH . '/wp-admin/includes/update.php');
    231227       
     
    757753                   
    758754                    if (!in_array($path, $activated_plugins)) {
    759                         $plugins['inactive'][$br_i]['path'] = $path;
    760                         $plugins['inactive'][$br_i]['name'] = strip_tags($plugin['Name']);
     755                       $plugins['inactive'][$br_i]['path'] = $path;
     756                       $plugins['inactive'][$br_i]['name'] = strip_tags($plugin['Name']);
    761757                        $plugins['inactive'][$br_i]['version'] = $plugin['Version'];
    762758                        $br_i++;
  • wpguards/trunk/modules/manager/lib/dropbox.php

    r872784 r873445  
    11<?php
    2 class IWP_Dropbox {
     2class Dropbox {
    33    const API_URL = 'https://api.dropbox.com/';
    44    const API_CONTENT_URL = 'https://api-content.dropbox.com/';
     
    4343        $file = str_replace("\\", "/",$file);
    4444        if (!is_readable($file) or !is_file($file))
    45             throw new IWP_DropboxException("Error: File \"$file\" is not readable or doesn't exist.");
     45            throw new DropboxException("Error: File \"$file\" is not readable or doesn't exist.");
    4646        $filesize=filesize($file);
    4747        if ($filesize < (1024*1024*50)) {  //chunk transfer on bigger uploads <50MB
     
    5959        $file = str_replace("\\", "/",$file);
    6060        if (!is_readable($file) or !is_file($file))
    61             throw new IWP_DropboxException("Error: File \"$file\" is not readable or doesn't exist.");
     61            throw new DropboxException("Error: File \"$file\" is not readable or doesn't exist.");
    6262        $file_handle=fopen($file,'r');
    6363        $uploadid=null;
     
    106106    public function search($path = '', $query , $fileLimit = 1000){
    107107        if (strlen($query)>=3)
    108             throw new IWP_DropboxException("Error: Query \"$query\" must three characters long.");
     108            throw new DropboxException("Error: Query \"$query\" must three characters long.");
    109109        $url = self::API_URL.self::API_VERSION_URL.'search/'.$this->root.'/'.trim($path,'/');
    110110        return $this->request($url, array('query' => $query, 'file_limit' => $fileLimit));
     
    155155            elseif (0!=curl_errno($ch)) $message = '('.curl_errno($ch).') '.curl_error($ch);
    156156            else $message = '('.$status.') Invalid response.';
    157             throw new IWP_DropboxException($message);
     157            throw new DropboxException($message);
    158158        }
    159159        curl_close($ch);
     
    189189            elseif (0!=curl_errno($ch)) $message = '('.curl_errno($ch).') '.curl_error($ch);
    190190            else $message = '('.$status.') Invalid response.';
    191             throw new IWP_DropboxException($message);
     191            throw new DropboxException($message);
    192192        }
    193193    }
     
    258258            elseif ($status['http_code']==507) $message = '(507) User is over Dropbox storage quota.';
    259259            else $message = '('.$status['http_code'].') Invalid response.';
    260             throw new IWP_DropboxException($message);
     260            throw new DropboxException($message);
    261261        } else {
    262262            curl_close($ch);
     
    281281}
    282282
    283 class IWP_DropboxException extends Exception {
     283class DropboxException extends Exception {
    284284}
    285285?>
  • wpguards/trunk/modules/manager/pclzip.class.php

    r872784 r873445  
    57165716  // --------------------------------------------------------------------------------
    57175717
     5718
    57185719?>
  • wpguards/trunk/readme.txt

    r873298 r873445  
    55Requires at least: 3.6
    66Tested up to: 3.8.1
    7 Stable tag: 1.2.0
     7Stable tag: 1.1.1
    88License: GPLv2
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    8383== Changelog ==
    8484
    85 = 1.2.0 - 10.3.2014 =
    86 * Updated IWP Client
    87 
    8885= 1.1.1 - 9.3.2014 =
    8986* Forked IWP client
     
    9289== Upgrade Notice ==
    9390
    94 = 1.2.0 =
    95 Improved security
    96 
    9791= 1.1.1 =
    9892Better integration with IWP and improved unistallation security
  • wpguards/trunk/wpguards.php

    r872784 r873445  
    44 * Plugin URI: http://wpguards.com
    55 * Description: WordPress Support and Maintenance on Autopilot
    6  * Version: 1.2.0
     6 * Version: 1.1.1
    77 * Author: WordPressGeeks
    88 * Author URI: http://wordpressgeeks.co.uk
Note: See TracChangeset for help on using the changeset viewer.