Plugin Directory

Changeset 872784


Ignore:
Timestamp:
03/10/2014 03:13:05 PM (12 years ago)
Author:
Bartko.co.uk
Message:

IWP update, readme.txt improvement

Location:
wpguards/trunk
Files:
10 edited

Legend:

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

    r872536 r872784  
    110110            $attachments  = array();
    111111            $post_content = $post_data['post_content'];
    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             }
     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            }
    239243           
    240244           
  • wpguards/trunk/modules/manager/backup.class.php

    r872536 r872784  
    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            
     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            }
    183188           
    184189            $this->update_tasks($before);
     
    321326        if (!$args || empty($args))
    322327            return false;
    323        
     328       
    324329        extract($args); //extract settings
    325330       
     
    557562       
    558563        $this->update_status($task_name,'finished',true);
    559         do_action( 'iwp_after_backup', $backup_url, $backup_settings[$task_name], $paths, $task_name );
    560        
     564
    561565        return $backup_url; //Return url to backup file
    562566    }
     
    12941298    function restore($args)
    12951299    {
    1296         $args = apply_filters('before_backup', $args, $this->tasks );
    12971300       
    12981301        global $wpdb, $wp_filesystem;
    12991302        if (empty($args)) {
    1300             return false; 
    1301         } 
     1303            return false;
     1304        }
    13021305       
    13031306        extract($args);
    13041307        $this->set_memory();
    13051308       
    1306         $unlink_file = false; //Delete file after restore
     1309        $unlink_file = true; //Delete file after restore
    13071310       
    13081311        include_once ABSPATH . 'wp-admin/includes/file.php';
     
    13241327            if (isset($task['task_results'][$result_id]['server'])) {
    13251328                $backup_file = $task['task_results'][$result_id]['server']['file_path'];
    1326                 $unlink_file = true; //Don't delete file if stored on server
     1329                $unlink_file = false; //Don't delete file if stored on server
    13271330               
    13281331            } elseif (isset($task['task_results'][$result_id]['ftp'])) {
     
    14951498                iwp_mmb_print_flush('ZIP Extract PCL: Start');
    14961499                $archive = new IWPPclZip($backup_file);
    1497                 $result  = $archive->extract(PCLZIP_OPT_PATH, $new_temp_folder, PCLZIP_OPT_REPLACE_NEWER);
     1500                $result  = $archive->extract(PCLZIP_OPT_PATH, $new_temp_folder, PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1);
    14981501                iwp_mmb_print_flush('ZIP Extract PCL: End');
    14991502            }
     
    15011504           
    15021505            if ($unlink_file) {
    1503                 //@unlink($backup_file);
     1506                @unlink($backup_file);
    15041507            }
    15051508           
     
    20992102            require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/dropbox.php';
    21002103           
    2101             $dropbox = new Dropbox($consumer_key, $consumer_secret);
     2104           
     2105            $dropbox = new IWP_Dropbox($consumer_key, $consumer_secret);
     2106           
    21022107            $dropbox->setOAuthTokens($oauth_token, $oauth_token_secret);
    21032108           
     
    21332138        require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/dropbox.php';
    21342139       
    2135         $dropbox = new Dropbox($consumer_key, $consumer_secret);
     2140       
     2141        $dropbox = new IWP_Dropbox($consumer_key, $consumer_secret);
     2142       
     2143       
    21362144        $dropbox->setOAuthTokens($oauth_token, $oauth_token_secret);
    21372145       
     
    21582166        require_once $GLOBALS['iwp_mmb_plugin_dir']  . '/lib/dropbox.php';
    21592167       
    2160         $dropbox = new Dropbox($consumer_key, $consumer_secret);
     2168       
     2169        $dropbox = new IWP_Dropbox($consumer_key, $consumer_secret);
     2170       
     2171       
    21612172        $dropbox->setOAuthTokens($oauth_token, $oauth_token_secret);
    21622173       
  • wpguards/trunk/modules/manager/core.class.php

    r872536 r872784  
    11<?php
    2 
    32/************************************************************
    4 
    53 * This plugin was modified by Revmakx                      *
    6 
    74 * Copyright (c) 2012 Revmakx                               *
    8 
    95 * www.revmakx.com                                          *
    10 
    116 *                                                          *
    12 
    137 ************************************************************/
    14 
    158/*************************************************************
    16 
    179 *
    18 
    1910 * core.class.php
    20 
    2111 *
    22 
    2312 * Upgrade Plugins
    24 
    2513 *
    26 
    2714 *
    28 
    2915 * Copyright (c) 2011 Prelovac Media
    30 
    3116 * www.prelovac.com
    32 
    3317 **************************************************************/
    34 
    3518 
    36 
    3719class IWP_MMB_Core extends IWP_MMB_Helper
    38 
    3920{
    40 
    4121    var $name;
    42 
    4322    var $slug;
    44 
    4523    var $settings;
    46 
    4724    var $remote_client;
    48 
    4925    var $comment_instance;
    50 
    5126    var $plugin_instance;
    52 
    5327    var $theme_instance;
    54 
    5528    var $wp_instance;
    56 
    5729    var $post_instance;
    58 
    5930    var $stats_instance;
    60 
    6131    var $search_instance;
    62 
    6332    var $links_instance;
    64 
    6533    var $user_instance;
    66 
    6734    var $backup_instance;
    68 
    6935    var $installer_instance;
    70 
    7136    var $iwp_mmb_multisite;
    72 
    7337    var $network_admin_install;
    74 
    7538   
    76 
    7739    var $backup_repository_instance;
    78 
    7940    var $optimize_instance;
    80 
    8141   
    82 
    8342    private $action_call;
    84 
    8543    private $action_params;
    86 
    8744    private $iwp_mmb_pre_init_actions;
    88 
    8945    private $iwp_mmb_pre_init_filters;
    90 
    9146    private $iwp_mmb_init_actions;
    92 
    93    
    94 
    95    
    96 
     47   
     48   
    9749    function __construct()
    98 
    99     {
    100 
     50    {
    10151        global $iwp_mmb_plugin_dir, $wpmu_version, $blog_id, $_iwp_mmb_plugin_actions, $_iwp_mmb_item_filter;
    102 
    103        
    104 
     52       
    10553        $_iwp_mmb_plugin_actions = array();
    106 
    10754        $this->name     = 'Manage Multiple Blogs';
    108 
    10955        $this->slug     = 'manage-multiple-blogs';
    110 
    11156        $this->action_call = null;
    112 
    11357        $this->action_params = null;
    114 
    115        
    116 
    117        
    118 
     58       
     59       
    11960        $this->settings = get_option($this->slug);
    120 
    12161        if (!$this->settings) {
    122 
    12362            $this->settings = array(
    124 
    12563                'blogs' => array(),
    126 
    12764                'current_blog' => array(
    128 
    12965                    'type' => null
    130 
    13166                )
    132 
    13367            );
    134 
    13568            $this->save_options();
    136 
    137         }
    138 
     69        }
    13970        if ( function_exists('is_multisite') ) {
    140 
    14171            if ( is_multisite() ) {
    142 
    14372                $this->iwp_mmb_multisite = $blog_id;
    144 
    14573                $this->network_admin_install = get_option('iwp_client_network_admin_install');
    146 
    14774            }
    148 
    14975        } else if (!empty($wpmu_version)) {
    150 
    15176            $this->iwp_mmb_multisite = $blog_id;
    152 
    15377            $this->network_admin_install = get_option('iwp_client_network_admin_install');
    154 
    15578        } else {
    156 
    15779            $this->iwp_mmb_multisite = false;
    158 
    15980            $this->network_admin_install = null;
    160 
    16181        }
    162 
    163        
    164 
     82       
    16583        // admin notices
    166 
    16784        if ( !get_option('iwp_client_public_key') ){
    168 
    16985            if( $this->iwp_mmb_multisite ){
    170 
    17186                if( is_network_admin() && $this->network_admin_install == '1'){
    172 
    17387                    add_action('network_admin_notices', array( &$this, 'network_admin_notice' ));
    174 
    17588                } else if( $this->network_admin_install != '1' ){
    176 
    17789                    //$parent_key = $this->get_parent_blog_option('iwp_client_public_key');//IWP commented to show notice to all subsites of network
    178 
    17990                    //if(empty($parent_key))//IWP commented to show notice to all subsites of network
    180 
    18191                        add_action('admin_notices', array( &$this, 'admin_notice' ));
    182 
    18392                }
    184 
    18593            } else {
    186 
    18794                add_action('admin_notices', array( &$this, 'admin_notice' ));
    188 
    18995            }
    190 
    19196        }
    192 
    193        
    194 
     97       
    19598        // default filters
    196 
    19799        //$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 
    199100        $this->iwp_mmb_pre_init_filters['get_stats']['iwp_mmb_stats_filter'][] = 'iwp_mmb_pre_init_stats';
    200 
    201        
    202 
     101       
    203102        $_iwp_mmb_item_filter['pre_init_stats'] = array( 'core_update', 'hit_counter', 'comments', 'backups', 'posts', 'drafts', 'scheduled' );
    204 
    205103        $_iwp_mmb_item_filter['get'] = array( 'updates', 'errors' );
    206 
    207        
    208 
     104       
    209105        $this->iwp_mmb_pre_init_actions = array(
    210 
    211106            'backup_req' => 'iwp_mmb_get_backup_req',
    212 
    213107        );
    214 
    215        
    216 
     108       
    217109        $this->iwp_mmb_init_actions = array(
    218 
    219110            'do_upgrade' => 'iwp_mmb_do_upgrade',
    220 
    221111            'get_stats' => 'iwp_mmb_stats_get',
    222 
    223112            'remove_site' => 'iwp_mmb_remove_site',
    224 
    225113            'backup_clone' => 'iwp_mmb_backup_now',
    226 
    227114            'restore' => 'iwp_mmb_restore_now',
    228 
    229115            'optimize_tables' => 'iwp_mmb_optimize_tables',
    230 
    231116            'check_wp_version' => 'iwp_mmb_wp_checkversion',
    232 
    233117            'create_post' => 'iwp_mmb_post_create',
    234 
    235118            'update_client' => 'iwp_mmb_update_client_plugin',
    236 
    237            
    238 
     119           
    239120            'change_comment_status' => 'iwp_mmb_change_comment_status',
    240 
    241121            'change_post_status' => 'iwp_mmb_change_post_status',
    242 
    243122            'get_comment_stats' => 'iwp_mmb_comment_stats_get',
    244 
    245            
    246 
     123           
    247124            'get_links' => 'iwp_mmb_get_links',
    248 
    249125            'add_link' => 'iwp_mmb_add_link',
    250 
    251126            'delete_link' => 'iwp_mmb_delete_link',
    252 
    253127            'delete_links' => 'iwp_mmb_delete_links',
    254 
    255            
    256 
     128           
    257129            'create_post' => 'iwp_mmb_post_create',
    258 
    259130            'change_post_status' => 'iwp_mmb_change_post_status',
    260 
    261131            'get_posts' => 'iwp_mmb_get_posts',
    262 
    263132            'delete_post' => 'iwp_mmb_delete_post',
    264 
    265133            'delete_posts' => 'iwp_mmb_delete_posts',
    266 
    267134            'edit_posts' => 'iwp_mmb_edit_posts',
    268 
    269135            'get_pages' => 'iwp_mmb_get_pages',
    270 
    271136            'delete_page' => 'iwp_mmb_delete_page',
    272 
    273            
    274 
     137           
    275138            'install_addon' => 'iwp_mmb_install_addon',
    276 
    277139            'add_link' => 'iwp_mmb_add_link',
    278 
    279140            'add_user' => 'iwp_mmb_add_user',
    280 
    281141            'email_backup' => 'iwp_mmb_email_backup',
    282 
    283142            'check_backup_compat' => 'iwp_mmb_check_backup_compat',
    284 
    285143            'scheduled_backup' => 'iwp_mmb_scheduled_backup',
    286 
    287144            'run_task' => 'iwp_mmb_run_task_now',
    288 
    289145            'delete_schedule_task' => 'iwp_mmb_delete_task_now',
    290 
    291146            'execute_php_code' => 'iwp_mmb_execute_php_code',
    292 
    293147            'delete_backup' => 'iwp_mmb_delete_backup',
    294 
    295148            'remote_backup_now' => 'iwp_mmb_remote_backup_now',
    296 
    297149            'set_notifications' => 'iwp_mmb_set_notifications',
    298 
    299150            'clean_orphan_backups' => 'iwp_mmb_clean_orphan_backups',
    300 
    301151            'get_users' => 'iwp_mmb_get_users',
    302 
    303152            'edit_users' => 'iwp_mmb_edit_users',
    304 
    305153            'get_plugins_themes' => 'iwp_mmb_get_plugins_themes',
    306 
    307154            'edit_plugins_themes' => 'iwp_mmb_edit_plugins_themes',
    308 
    309155            'get_comments' => 'iwp_mmb_get_comments',
    310 
    311156            'action_comment' => 'iwp_mmb_action_comment',
    312 
    313157            'bulk_action_comments' => 'iwp_mmb_bulk_action_comments',
    314 
    315158            'replyto_comment' => 'iwp_mmb_reply_comment',
    316 
    317159            'client_brand' => 'iwp_mmb_client_brand',
    318 
    319160            'set_alerts' => 'iwp_mmb_set_alerts',
    320 
    321161            'maintenance' => 'iwp_mmb_maintenance_mode',
    322 
    323            
    324 
     162           
    325163            'wp_optimize' => 'iwp_mmb_wp_optimize',
    326 
    327            
    328 
     164           
    329165            'backup_repository' => 'iwp_mmb_backup_repository'
    330 
    331166        );
    332 
    333        
    334 
     167       
    335168        add_action('rightnow_end', array( &$this, 'add_right_now_info' ));       
    336 
    337169        add_action('admin_init', array(&$this,'admin_actions'));   
    338 
    339170        add_action('init', array( &$this, 'iwp_mmb_remote_action'), 9999);
    340 
    341171        add_action('setup_theme', 'iwp_mmb_parse_request');
    342 
    343172        add_action('set_auth_cookie', array( &$this, 'iwp_mmb_set_auth_cookie'));
    344 
    345173        add_action('set_logged_in_cookie', array( &$this, 'iwp_mmb_set_logged_in_cookie'));
    346 
    347        
    348 
    349     }
    350 
    351    
    352 
     174       
     175    }
     176   
    353177    function iwp_mmb_remote_action(){
    354 
    355178        if($this->action_call != null){
    356 
    357179            $params = isset($this->action_params) && $this->action_params != null ? $this->action_params : array();
    358 
    359180            call_user_func($this->action_call, $params);
    360 
    361181        }
    362 
    363182    }
    364 
    365183   
    366 
    367184    function register_action_params( $action = false, $params = array() ){
    368 
    369        
    370 
     185       
    371186        if(isset($this->iwp_mmb_pre_init_actions[$action]) && function_exists($this->iwp_mmb_pre_init_actions[$action])){
    372 
    373187            call_user_func($this->iwp_mmb_pre_init_actions[$action], $params);
    374 
    375188        }
    376 
    377        
    378 
     189       
    379190        if(isset($this->iwp_mmb_init_actions[$action]) && function_exists($this->iwp_mmb_init_actions[$action])){
    380 
    381191            $this->action_call = $this->iwp_mmb_init_actions[$action];
    382 
    383192            $this->action_params = $params;
    384 
    385            
    386 
     193           
    387194            if( isset($this->iwp_mmb_pre_init_filters[$action]) && !empty($this->iwp_mmb_pre_init_filters[$action])){
    388 
    389195                global $iwp_mmb_filters;
    390 
    391196               
    392 
    393197                foreach($this->iwp_mmb_pre_init_filters[$action] as $_name => $_functions){
    394 
    395198                    if(!empty($_functions)){
    396 
    397199                        $data = array();
    398 
    399200                       
    400 
    401201                        foreach($_functions as $_k => $_callback){
    402 
    403202                            if(is_array($_callback) && method_exists($_callback[0], $_callback[1]) ){
    404 
    405203                                $data = call_user_func( $_callback, $params );
    406 
    407204                            } elseif (is_string($_callback) && function_exists( $_callback )){
    408 
    409205                                $data = call_user_func( $_callback, $params );
    410 
    411206                            }
    412 
    413207                            $iwp_mmb_filters[$_name] = isset($iwp_mmb_filters[$_name]) && !empty($iwp_mmb_filters[$_name]) ? array_merge($iwp_mmb_filters[$_name], $data) : $data;
    414 
    415208                            add_filter( $_name, create_function( '$a' , 'global $iwp_mmb_filters; return array_merge($a, $iwp_mmb_filters["'.$_name.'"]);') );
    416 
    417209                        }
    418 
    419210                    }
    420 
    421211                   
    422 
    423212                }
    424 
    425213            }
    426 
    427214            return true;
    428 
    429215        }
    430 
    431216        return false;
    432 
    433217    }
    434 
    435218   
    436 
    437     /**
    438 
     219    /**
    439220     * Add notice to network admin dashboard for security reasons   
    440 
    441      *
    442 
    443      */
    444 
     221     *
     222     */
    445223    function network_admin_notice()
    446 
    447     {
    448 
     224    {
    449225        echo '<div class="error" style="text-align: center;"><p style="font-size: 14px; font-weight: bold; color:#c00;">Attention !</p>
    450 
    451226        <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>';
    452 
    453     }
    454 
     227    }
    455228   
    456 
    457        
    458 
     229       
    459230    /**
    460 
    461231     * Add notice to admin dashboard for security reasons   
    462 
    463      *
    464 
    465      */
    466 
     232     *
     233     */
    467234    function admin_notice()
    468 
    469     {
    470 
     235    {
    471236       /* IWP */
    472        /* We don't need that notices anymore */
    473 
    474         /*if(defined('MULTISITE') && MULTISITE == true){   
    475 
     237        if(defined('MULTISITE') && MULTISITE == true){ 
    476238            global $blog_id;           
    477 
    478239            $user_id_from_email = get_user_id_from_string( get_blog_option($blog_id, 'admin_email'));
    479 
    480240            $details = get_userdata($user_id_from_email);
    481 
    482241            $username = $details->user_login;           
    483 
    484242        }
    485 
    486243        else{
    487 
    488244            $current_user = wp_get_current_user();
    489 
    490245            $username = $current_user->data->user_login;
    491 
    492246        }   
    493 
    494        
    495 
     247       
    496248        $iwp_client_activate_key = get_option('iwp_client_activate_key');
    497 
    498        
    499 
     249       
    500250        //check BWP
    501 
    502251        $bwp = get_option("bit51_bwps");
    503 
    504252        $notice_display_URL=admin_url();
    505 
    506253        if(!empty($bwp))
    507 
    508254        {
    509 
    510255            //$bwpArray = @unserialize($bwp);
    511 
    512256            if($bwp['hb_enabled']==1)
    513 
    514257            $notice_display_URL = get_option('home');
    515 
    516258        }
    517 
    518        
    519 
     259       
    520260        $notice_display_URL = rtrim($notice_display_URL, '/').'/';
    521 
    522        
    523 
    524        
    525 
     261       
     262       
    526263        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 
    528264        <table border="0" align="center">';
    529 
    530265        if(!empty($iwp_client_activate_key)){
    531 
    532266            echo '<tr><td align="right">WP-ADMIN URL:</td><td align="left"><strong>'.$notice_display_URL.'</strong></td></tr>
    533 
    534267            <tr><td align="right">ADMIN USERNAME:</td><td align="left"><strong>'.$username.'</strong> (or any admin id)</td></tr>
    535 
    536268            <tr><td align="right">ACTIVATION KEY:</td><td align="left"><strong>'.$iwp_client_activate_key.'</strong></td></tr>';
    537 
    538269        }
    539 
    540270        else{
    541 
    542271            echo '<tr><td align="center">Please deactivate and then activate InfiniteWP Client plugin.</td></tr>';
    543 
    544272        }       
    545 
    546        
    547 
     273       
    548274        echo '</table>
    549 
    550         </p></div>';    */ 
    551 
    552        
    553 
    554     }
    555 
    556    
    557 
    558     /**
    559 
     275        </p></div>';       
     276       
     277    }
     278   
     279    /**
    560280     * Add an item into the Right Now Dashboard widget
    561 
    562281     * to inform that the blog can be managed remotely
    563 
    564      *
    565 
    566      */
    567 
     282     *
     283     */
    568284    function add_right_now_info()
    569 
    570     {
    571 
     285    {
    572286        echo '<div class="iwp_mmb-slave-info">
    573 
    574287            <p>This site can be managed remotely.</p>
    575 
    576288        </div>';
    577 
    578     }
    579 
    580    
    581 
    582     /**
    583 
     289    }
     290   
     291    /**
    584292     * Get parent blog options
    585 
    586      *
    587 
    588      */
    589 
     293     *
     294     */
    590295    private function get_parent_blog_option( $option_name = '' )
    591 
    592     {
    593 
     296    {
    594297        global $wpdb;
    595 
    596298        $option = $wpdb->get_var( $wpdb->prepare( "SELECT `option_value` FROM {$wpdb->base_prefix}options WHERE option_name = %s LIMIT 1", $option_name ) );
    597 
    598299        return $option;
    599 
    600     }
    601 
    602    
    603 
     300    }
     301   
    604302   
    605 
    606303    /**
    607 
    608304     * Gets an instance of the WP_Optimize class
    609 
    610      *
    611 
    612      */
    613 
     305     *
     306     */
    614307    function wp_optimize_instance()
    615 
    616     {
    617 
     308    {
    618309        if (!isset($this->optimize_instance)) {
    619 
    620310            $this->optimize_instance = new IWP_MMB_Optimize();
    621 
    622         }
    623 
    624        
    625 
     311        }
     312       
    626313        return $this->optimize_instance;
    627 
    628     }
    629 
    630    
    631 
    632     /**
    633 
     314    }
     315   
     316    /**
    634317     * Gets an instance of the Comment class
    635 
    636      *
    637 
    638      */
    639 
     318     *
     319     */
    640320    function get_comment_instance()
    641 
    642     {
    643 
     321    {
    644322        if (!isset($this->comment_instance)) {
    645 
    646323            $this->comment_instance = new IWP_MMB_Comment();
    647 
    648         }
    649 
    650        
    651 
     324        }
     325       
    652326        return $this->comment_instance;
    653 
    654     }
    655 
    656    
    657 
    658     /**
    659 
     327    }
     328   
     329    /**
    660330     * Gets an instance of the Plugin class
    661 
    662      *
    663 
    664      */
    665 
     331     *
     332     */
    666333    function get_plugin_instance()
    667 
    668     {
    669 
     334    {
    670335        if (!isset($this->plugin_instance)) {
    671 
    672336            $this->plugin_instance = new IWP_MMB_Plugin();
    673 
    674         }
    675 
    676        
    677 
     337        }
     338       
    678339        return $this->plugin_instance;
    679 
    680     }
    681 
    682    
    683 
    684     /**
    685 
     340    }
     341   
     342    /**
    686343     * Gets an instance of the Theme class
    687 
    688      *
    689 
    690      */
    691 
     344     *
     345     */
    692346    function get_theme_instance()
    693 
    694     {
    695 
     347    {
    696348        if (!isset($this->theme_instance)) {
    697 
    698349            $this->theme_instance = new IWP_MMB_Theme();
    699 
    700         }
    701 
    702        
    703 
     350        }
     351       
    704352        return $this->theme_instance;
    705 
    706     }
    707 
    708    
    709 
    710    
    711 
    712     /**
    713 
     353    }
     354   
     355   
     356    /**
    714357     * Gets an instance of IWP_MMB_Post class
    715 
    716      *
    717 
    718      */
    719 
     358     *
     359     */
    720360    function get_post_instance()
    721 
    722     {
    723 
     361    {
    724362        if (!isset($this->post_instance)) {
    725 
    726363            $this->post_instance = new IWP_MMB_Post();
    727 
    728         }
    729 
    730        
    731 
     364        }
     365       
    732366        return $this->post_instance;
    733 
    734     }
    735 
    736    
    737 
    738     /**
    739 
     367    }
     368   
     369    /**
    740370     * Gets an instance of Blogroll class
    741 
    742      *
    743 
    744      */
    745 
     371     *
     372     */
    746373    function get_blogroll_instance()
    747 
    748     {
    749 
     374    {
    750375        if (!isset($this->blogroll_instance)) {
    751 
    752376            $this->blogroll_instance = new IWP_MMB_Blogroll();
    753 
    754         }
    755 
    756        
    757 
     377        }
     378       
    758379        return $this->blogroll_instance;
    759 
    760     }
    761 
    762    
    763 
    764    
    765 
    766    
    767 
    768     /**
    769 
     380    }
     381   
     382   
     383   
     384    /**
    770385     * Gets an instance of the WP class
    771 
    772      *
    773 
    774      */
    775 
     386     *
     387     */
    776388    function get_wp_instance()
    777 
    778     {
    779 
     389    {
    780390        if (!isset($this->wp_instance)) {
    781 
    782391            $this->wp_instance = new IWP_MMB_WP();
    783 
    784         }
    785 
    786        
    787 
     392        }
     393       
    788394        return $this->wp_instance;
    789 
    790     }
    791 
    792    
    793 
    794     /**
    795 
     395    }
     396   
     397    /**
    796398     * Gets an instance of User
    797 
    798      *
    799 
    800      */
    801 
     399     *
     400     */
    802401    function get_user_instance()
    803 
    804     {
    805 
     402    {
    806403        if (!isset($this->user_instance)) {
    807 
    808404            $this->user_instance = new IWP_MMB_User();
    809 
    810         }
    811 
    812        
    813 
     405        }
     406       
    814407        return $this->user_instance;
    815 
    816     }
    817 
    818    
    819 
    820     /**
    821 
     408    }
     409   
     410    /**
    822411     * Gets an instance of stats class
    823 
    824      *
    825 
    826      */
    827 
     412     *
     413     */
    828414    function get_stats_instance()
    829 
    830     {
    831 
     415    {
    832416        if (!isset($this->stats_instance)) {
    833 
    834417            $this->stats_instance = new IWP_MMB_Stats();
    835 
    836         }
    837 
     418        }
    838419        return $this->stats_instance;
    839 
    840     }
    841 
    842     /**
    843 
     420    }
     421    /**
    844422     * Gets an instance of search class
    845 
    846      *
    847 
    848      */
    849 
     423     *
     424     */
    850425    function get_search_instance()
    851 
    852     {
    853 
     426    {
    854427        if (!isset($this->search_instance)) {
    855 
    856428            $this->search_instance = new IWP_MMB_Search();
    857 
    858         }
    859 
     429        }
    860430        //return $this->search_instance;
    861 
    862431        return $this->search_instance;
    863 
    864     }
    865 
    866     /**
    867 
     432    }
     433    /**
    868434     * Gets an instance of stats class
    869 
    870435     *
    871 
    872      */
    873 
     436     */
    874437    function get_backup_instance()
    875 
    876     {
    877 
     438    {
    878439        if (!isset($this->backup_instance)) {
    879 
    880440            $this->backup_instance = new IWP_MMB_Backup();
    881 
    882         }
    883 
    884        
    885 
     441        }
     442       
    886443        return $this->backup_instance;
    887 
    888     }
    889 
    890    
    891 
     444    }
     445   
    892446    function get_backup_repository_instance()
    893 
    894     {
    895 
     447    {
    896448        if (!isset($this->backup_repository_instance)) {
    897 
    898449            $this->backup_repository_instance = new IWP_MMB_Backup_Repository();
    899 
    900         }
    901 
    902        
    903 
     450        }
     451       
    904452        return $this->backup_repository_instance;
    905 
    906     }
    907 
    908    
    909 
    910     /**
    911 
     453    }
     454   
     455    /**
    912456     * Gets an instance of links class
    913 
    914457     *
    915 
    916      */
    917 
     458     */
    918459    function get_link_instance()
    919 
    920     {
    921 
     460    {
    922461        if (!isset($this->link_instance)) {
    923 
    924462            $this->link_instance = new IWP_MMB_Link();
    925 
    926         }
    927 
    928        
    929 
     463        }
     464       
    930465        return $this->link_instance;
    931 
    932     }
    933 
    934    
    935 
     466    }
     467   
    936468    function get_installer_instance()
    937 
    938     {
    939 
     469    {
    940470        if (!isset($this->installer_instance)) {
    941 
    942471            $this->installer_instance = new IWP_MMB_Installer();
    943 
    944         }
    945 
     472        }
    946473        return $this->installer_instance;
    947 
    948     }
    949 
     474    }
    950475   
    951 
    952     /**
    953 
     476    /**
    954477     * Plugin install callback function
    955 
    956478     * Check PHP version
    957 
    958      */
    959 
     479     */
    960480    function install() {
    961 
    962        
    963 
     481       
    964482        global $wpdb, $_wp_using_ext_object_cache, $current_user;
    965 
    966483        $_wp_using_ext_object_cache = false;
    967484
    968 
    969 
    970485        //delete plugin options, just in case
    971 
    972486        if ($this->iwp_mmb_multisite != false) {
    973 
    974487            $network_blogs = $wpdb->get_results("select `blog_id`, `site_id` from `{$wpdb->blogs}`");
    975 
    976488            if(!empty($network_blogs)){
    977 
    978489                if( is_network_admin() ){
    979 
    980490                    update_option('iwp_client_network_admin_install', 1);
    981 
    982491                    foreach($network_blogs as $details){
    983 
    984492                        if($details->site_id == $details->blog_id)
    985 
    986493                            update_blog_option($details->blog_id, 'iwp_client_network_admin_install', 1);
    987 
    988494                        else
    989 
    990495                            update_blog_option($details->blog_id, 'iwp_client_network_admin_install', -1);
    991 
    992496                           
    993 
    994497                        delete_blog_option($blog_id, 'iwp_client_nossl_key');
    995 
    996498                        delete_blog_option($blog_id, 'iwp_client_public_key');
    997 
    998499                        delete_blog_option($blog_id, 'iwp_client_action_message_id');
    999 
    1000500                    }
    1001 
    1002501                } else {
    1003 
    1004502                    update_option('iwp_client_network_admin_install', -1);
    1005 
    1006503                    delete_option('iwp_client_nossl_key');
    1007 
    1008504                    delete_option('iwp_client_public_key');
    1009 
    1010505                    delete_option('iwp_client_action_message_id');
    1011 
    1012506                }
    1013 
    1014507            }
    1015 
    1016508        } else {
    1017 
    1018509            delete_option('iwp_client_nossl_key');
    1019 
    1020510            delete_option('iwp_client_public_key');
    1021 
    1022511            delete_option('iwp_client_action_message_id');
    1023 
    1024         }
    1025 
    1026        
    1027 
     512        }
     513       
    1028514        //delete_option('iwp_client_backup_tasks');
    1029 
    1030515        delete_option('iwp_client_notifications');
    1031 
    1032516        delete_option('iwp_client_brand');
    1033 
    1034517        delete_option('iwp_client_pageview_alerts');
    1035518       
    1036        
    1037 
    1038519        add_option('iwp_client_activate_key', sha1( rand(1, 99999). uniqid('', true) . get_option('siteurl') ) );
    1039 
    1040        
    1041 
    1042     }
    1043 
    1044    
    1045 
    1046     /**
    1047 
     520       
     521    }
     522   
     523    /**
    1048524     * Saves the (modified) options into the database
    1049 
    1050      *
    1051 
    1052      */
    1053 
     525     *
     526     */
    1054527    function save_options()
    1055 
    1056     {
    1057 
     528    {
    1058529        if (get_option($this->slug)) {
    1059 
    1060530            update_option($this->slug, $this->settings);
    1061 
    1062531        } else {
    1063 
    1064532            add_option($this->slug, $this->settings);
    1065 
    1066         }
    1067 
    1068     }
    1069 
    1070    
    1071 
    1072     /**
    1073 
     533        }
     534    }
     535   
     536    /**
    1074537     * Deletes options for communication with IWP Admin panel
    1075 
    1076      *
    1077 
    1078      */
    1079 
     538     *
     539     */
    1080540    function uninstall( $deactivate = false )
    1081 
    1082     {
    1083 
     541    {
    1084542        global $current_user, $wpdb, $_wp_using_ext_object_cache;
    1085 
    1086543        $_wp_using_ext_object_cache = false;
    1087 
    1088        
    1089 
     544       
    1090545        if ($this->iwp_mmb_multisite != false) {
    1091 
    1092546            $network_blogs = $wpdb->get_col("select `blog_id` from `{$wpdb->blogs}`");
    1093 
    1094547            if(!empty($network_blogs)){
    1095 
    1096548                if( is_network_admin() ){
    1097 
    1098549                    if( $deactivate ) {
    1099 
    1100550                        delete_option('iwp_client_network_admin_install');
    1101 
    1102551                        foreach($network_blogs as $blog_id){
    1103 
    1104552                            delete_blog_option($blog_id, 'iwp_client_network_admin_install');
    1105 
    1106553                            delete_blog_option($blog_id, 'iwp_client_nossl_key');
    1107 
    1108554                            delete_blog_option($blog_id, 'iwp_client_public_key');
    1109 
    1110555                            delete_blog_option($blog_id, 'iwp_client_action_message_id');
    1111 
    1112556                            delete_blog_option($blog_id, 'iwp_client_maintenace_mode');
    1113 
    1114557                        }
    1115 
    1116558                    }
    1117 
    1118559                } else {
    1119 
    1120560                    if( $deactivate )
    1121 
    1122561                        delete_option('iwp_client_network_admin_install');
    1123 
    1124562                       
    1125 
    1126563                    delete_option('iwp_client_nossl_key');
    1127 
    1128564                    delete_option('iwp_client_public_key');
    1129 
    1130565                    delete_option('iwp_client_action_message_id');
    1131 
    1132566                }
    1133 
    1134567            }
    1135 
    1136568        } else {
    1137 
    1138569            delete_option('iwp_client_nossl_key');
    1139 
    1140570            delete_option('iwp_client_public_key');
    1141 
    1142571            delete_option('iwp_client_action_message_id');
    1143 
    1144         }
    1145 
    1146        
    1147 
     572        }
     573       
    1148574        //Delete options
    1149 
    1150575        delete_option('iwp_client_maintenace_mode');
    1151 
    1152576        //delete_option('iwp_client_backup_tasks');
    1153 
    1154577        wp_clear_scheduled_hook('iwp_client_backup_tasks');
    1155 
    1156578        delete_option('iwp_client_notifications');
    1157 
    1158579        wp_clear_scheduled_hook('iwp_client_notifications');       
    1159 
    1160580        delete_option('iwp_client_brand');
    1161 
    1162581        delete_option('iwp_client_pageview_alerts');
    1163 
    1164        
    1165 
     582       
    1166583        delete_option('iwp_client_activate_key');
    1167 
    1168     }
    1169 
    1170    
    1171 
    1172    
    1173 
    1174     /**
    1175 
     584    }
     585   
     586   
     587    /**
    1176588     * Constructs a url (for ajax purpose)
    1177 
    1178      *
    1179 
     589     *
    1180590     * @param mixed $base_page
    1181 
    1182      */
    1183 
     591     */
    1184592    function construct_url($params = array(), $base_page = 'index.php')
    1185 
    1186     {
    1187 
     593    {
    1188594        $url = "$base_page?_wpnonce=" . wp_create_nonce($this->slug);
    1189 
    1190595        foreach ($params as $key => $value) {
    1191 
    1192596            $url .= "&$key=$value";
    1193 
    1194         }
    1195 
    1196        
    1197 
     597        }
     598       
    1198599        return $url;
    1199 
    1200     }
    1201 
    1202    
    1203 
    1204     /**
    1205 
     600    }
     601   
     602    /**
    1206603     * Client update
    1207 
    1208      *
    1209 
    1210      */
    1211 
     604     *
     605     */
    1212606    function update_client_plugin($params)
    1213 
    1214     {
    1215 
     607    {
    1216608        extract($params);
    1217 
    1218609        if ($download_url) {
    1219 
    1220610            @include_once ABSPATH . 'wp-admin/includes/file.php';
    1221 
    1222611            @include_once ABSPATH . 'wp-admin/includes/misc.php';
    1223 
    1224612            @include_once ABSPATH . 'wp-admin/includes/template.php';
    1225 
    1226613            @include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    1227 
    1228614            @include_once ABSPATH . 'wp-admin/includes/screen.php';
    1229 
    1230615           
    1231 
    1232616            if (!$this->is_server_writable()) {
    1233 
    1234617                return array(
    1235 
    1236618                    'error' => 'Failed. please add FTP details for automatic upgrades.'
    1237 
    1238619                );
    1239 
    1240620            }
    1241 
    1242621           
    1243 
    1244622            ob_start();
    1245 
    1246623            @unlink(dirname(__FILE__));
    1247 
    1248624            $upgrader = new Plugin_Upgrader();
    1249 
    1250625            $result   = $upgrader->run(array(
    1251 
    1252626                'package' => $download_url,
    1253 
    1254627                'destination' => WP_PLUGIN_DIR,
    1255 
    1256628                'clear_destination' => true,
    1257 
    1258629                'clear_working' => true,
    1259 
    1260630                'hook_extra' => array(
    1261 
    1262631                    'plugin' => 'iwp-client/init.php'
    1263 
    1264632                )
    1265 
    1266633            ));
    1267 
    1268634            ob_end_clean();
    1269 
    1270635            @wp_update_plugins();
    1271 
    1272            
    1273 
     636           
    1274637            if (is_wp_error($result) || !$result) {
    1275 
    1276638                return array(
    1277 
    1278639                    'error' => 'InfiniteWP Client plugin could not be updated.'
    1279 
    1280640                );
    1281 
    1282641            } else {
    1283 
    1284642                return array(
    1285 
    1286643                    'success' => 'InfiniteWP Client plugin successfully updated.'
    1287 
    1288644                );
    1289 
    1290645            }
    1291 
    1292         }
    1293 
     646        }
    1294647        return array(
    1295 
    1296648            'error' => 'Bad download path for client installation file.'
    1297 
    1298649        );
    1299 
    1300     }
    1301 
    1302    
    1303 
    1304     /**
    1305 
     650    }
     651   
     652    /**
    1306653     * Automatically logs in when called from IWP Admin panel
    1307 
    1308      *
    1309 
    1310      */
    1311 
     654     *
     655     */
    1312656    function automatic_login()
    1313 
    1314     {
    1315 
     657    {
    1316658        $where      = isset($_GET['iwp_goto']) ? $_GET['iwp_goto'] : false;
    1317 
    1318659        $username   = isset($_GET['username']) ? $_GET['username'] : '';
    1319 
    1320660        $auto_login = isset($_GET['auto_login']) ? $_GET['auto_login'] : 0;
    1321 
    1322661        $_SERVER['HTTP_REFERER']='';
    1323 
    1324662        if( !function_exists('is_user_logged_in') )
    1325 
    1326663            include_once( ABSPATH.'wp-includes/pluggable.php' );
    1327 
    1328        
    1329 
     664       
    1330665        if (( $auto_login && strlen(trim($username)) && !is_user_logged_in() ) || (isset($this->iwp_mmb_multisite) && $this->iwp_mmb_multisite )) {
    1331 
    1332666            $signature  = base64_decode($_GET['signature']);
    1333 
    1334667            $message_id = trim($_GET['message_id']);
    1335 
    1336668           
    1337 
    1338669            $auth = $this->authenticate_message($where . $message_id, $signature, $message_id);
    1339 
    1340670            if ($auth === true) {
    1341 
    1342671               
    1343 
    1344672                if (!headers_sent())
    1345 
    1346673                    header('P3P: CP="CAO PSA OUR"');
    1347 
    1348674               
    1349 
    1350675                if(!defined('IWP_MMB_USER_LOGIN'))
    1351 
    1352676                    define('IWP_MMB_USER_LOGIN', true);
    1353 
    1354677               
    1355 
    1356678                $siteurl = function_exists('get_site_option') ? get_site_option( 'siteurl' ) : get_option('siteurl');
    1357 
    1358679                $user = $this->iwp_mmb_get_user_info($username);
    1359 
    1360680                wp_set_current_user($user->ID);
    1361 
    1362681               
    1363 
    1364682                if(!defined('COOKIEHASH') || (isset($this->iwp_mmb_multisite) && $this->iwp_mmb_multisite) )
    1365 
    1366683                    wp_cookie_constants();
    1367 
    1368684               
    1369 
    1370685                wp_set_auth_cookie($user->ID);
    1371 
    1372686                @iwp_mmb_client_header();
    1373 
    1374687               
    1375 
    1376688                if((isset($this->iwp_mmb_multisite) && $this->iwp_mmb_multisite ) || isset($_REQUEST['iwpredirect'])){
    1377 
    1378689                    if(function_exists('wp_safe_redirect') && function_exists('admin_url')){
    1379 
    1380690                        wp_safe_redirect(admin_url($where));
    1381 
    1382691                        exit();
    1383 
    1384692                    }
    1385 
    1386693                }
    1387 
    1388694            } else {
    1389 
    1390695                wp_die($auth['error']);
    1391 
    1392696            }
    1393 
    1394697        } elseif( is_user_logged_in() ) {
    1395 
    1396698            @iwp_mmb_client_header();
    1397 
    1398699            if(isset($_REQUEST['iwpredirect'])){
    1399 
    1400700                if(function_exists('wp_safe_redirect') && function_exists('admin_url')){
    1401 
    1402701                    wp_safe_redirect(admin_url($where));
    1403 
    1404702                    exit();
    1405 
    1406703                }
    1407 
    1408704            }
    1409 
    1410705        }
    1411 
    1412     }
    1413 
    1414    
    1415 
     706    }
     707   
    1416708    function iwp_mmb_set_auth_cookie( $auth_cookie ){
    1417 
    1418709        if(!defined('IWP_MMB_USER_LOGIN'))
    1419 
    1420710            return false;
    1421 
    1422        
    1423 
     711       
    1424712        if( !defined('COOKIEHASH') )
    1425 
    1426713            wp_cookie_constants();
    1427 
    1428            
    1429 
     714           
    1430715        $_COOKIE['wordpress_'.COOKIEHASH] = $auth_cookie;
    1431 
    1432        
    1433 
     716       
    1434717    }
    1435 
    1436718    function iwp_mmb_set_logged_in_cookie( $logged_in_cookie ){
    1437 
    1438719        if(!defined('IWP_MMB_USER_LOGIN'))
    1439 
    1440720            return false;
    1441 
    1442721   
    1443 
    1444722        if( !defined('COOKIEHASH') )
    1445 
    1446723            wp_cookie_constants();
    1447 
    1448            
    1449 
     724           
    1450725        $_COOKIE['wordpress_logged_in_'.COOKIEHASH] = $logged_in_cookie;
    1451 
    1452726    }
    1453 
    1454        
    1455 
     727       
    1456728    function admin_actions(){
    1457 
    1458         //add_filter('all_plugins', array($this, 'client_replace'));
    1459 
    1460     }
    1461 
    1462    
    1463 
     729        add_filter('all_plugins', array($this, 'client_replace'));
     730    }
     731   
    1464732    function client_replace($all_plugins){
    1465 
    1466733        $replace = get_option("iwp_client_brand");
    1467 
    1468734        if(is_array($replace)){
    1469 
    1470735            if($replace['name'] || $replace['desc'] || $replace['author'] || $replace['author_url']){
    1471 
    1472736                $all_plugins['iwp-client/init.php']['Name'] = $replace['name'];
    1473 
    1474737                $all_plugins['iwp-client/init.php']['Title'] = $replace['name'];
    1475 
    1476738                $all_plugins['iwp-client/init.php']['Description'] = $replace['desc'];
    1477 
    1478739                $all_plugins['iwp-client/init.php']['AuthorURI'] = $replace['author_url'];
    1479 
    1480740                $all_plugins['iwp-client/init.php']['Author'] = $replace['author'];
    1481 
    1482741                $all_plugins['iwp-client/init.php']['AuthorName'] = $replace['author'];
    1483 
    1484742                $all_plugins['iwp-client/init.php']['PluginURI'] = '';
    1485 
    1486743            }
    1487 
    1488744           
    1489 
    1490745            if($replace['hide']){
    1491 
    1492746                if (!function_exists('get_plugins')) {
    1493 
    1494747            include_once(ABSPATH . 'wp-admin/includes/plugin.php');
    1495 
    1496748            }
    1497 
    1498749          $activated_plugins = get_option('active_plugins');
    1499 
    1500750          if (!$activated_plugins)
    1501 
    1502751                $activated_plugins = array();
    1503 
    1504752          if(in_array('iwp-client/init.php',$activated_plugins))
    1505 
    1506753            unset($all_plugins['iwp-client/init.php']);     
    1507 
    1508754            }
    1509 
    1510755        }
    1511 
    1512756                   
    1513 
    1514757        return $all_plugins;
    1515 
    1516     }
    1517 
    1518    
    1519 
     758    }
     759   
    1520760   
    1521 
    1522761}
    1523 
    1524762?>
  • wpguards/trunk/modules/manager/helper.class.php

    r872536 r872784  
    349349        $current_message = $this->get_client_message_id();
    350350       
    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        
     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       
    356358        $pl_key = $this->get_admin_panel_public_key();
    357359        if (!$pl_key) {
  • wpguards/trunk/modules/manager/init.php

    r872536 r872784  
    11<?php
    2 /************************************************************
    3  * This plugin was modified by Wordpressgeeks               *
    4  * Copyright (c) 2013 Wordpressgeeks                        *
    5  * www.revmakx.com                                          *
    6  *                                                          *
    7  ************************************************************/
     2/*
     3Plugin Name: InfiniteWP - Client
     4Plugin URI: http://infinitewp.com/
     5Description: This is the client plugin of InfiniteWP that communicates with the InfiniteWP Admin panel.
     6Author: Revmakx
     7Version: 1.2.8
     8Author URI: http://www.revmakx.com
     9*/
    810/************************************************************
    911 * This plugin was modified by Revmakx                      *
     
    2527
    2628if(!defined('IWP_MMB_CLIENT_VERSION'))
    27     define('IWP_MMB_CLIENT_VERSION', '1.2.3');
     29    define('IWP_MMB_CLIENT_VERSION', '1.2.8');
    2830
    2931
     
    3840
    3941$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
    4442$iwp_mmb_plugin_dir = WPGUARDS_MODULES_PATH.'/' . basename(dirname(__FILE__));
    4543$iwp_mmb_plugin_url = WPGUARDS_DIR . '/modules/' . basename(dirname(__FILE__));
     
    9189        if (!isset($HTTP_RAW_POST_DATA)) {
    9290            $HTTP_RAW_POST_DATA = file_get_contents('php://input');
    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); */
     91        }
     92       
    10193        ob_start();
    10294       
     
    228220        global $iwp_mmb_core;
    229221        $num = extract($params);
    230 
     222       
    231223        if ($num) {
    232224            if (!get_option('iwp_client_action_message_id') && !get_option('iwp_client_public_key')) {
    233225                $public_key = base64_decode($public_key);
    234226               
    235                 fwrite($fp, $public_key);
    236227               
    237228                if(trim($activation_key) != get_option('iwp_client_activate_key')){ //iwp
     
    242233                if (checkOpenSSL() && !$user_random_key_signing) {
    243234                    $verify = openssl_verify($action . $id, base64_decode($signature), $public_key);
    244                     //fwrite($fp, '<----Weryfy: '.$verify.'-'.$action.$id);
    245                     ///fclose($fp);
    246235                    if ($verify == 1) {
    247236                        $iwp_mmb_core->set_admin_panel_public_key($public_key);
     
    292281        }
    293282    }
    294 
    295 
    296283}
    297284
     
    360347    {
    361348        global $iwp_mmb_core;
    362         die();
     349       
    363350        $iwp_mmb_core->get_backup_instance();
    364         do_action( 'iwp_before_backup', $params );
    365        
    366         $return = $iwp_mmb_core->backup_instance->backup($params);
    367         //Custom Add action
     351        $return = $iwp_mmb_core->backup_instance->backup($params);
    368352       
    369353        if (is_array($return) && array_key_exists('error', $return))
     
    11861170}
    11871171
    1188 
    1189 global $iwp_mmb_core;
    11901172$iwp_mmb_core = new IWP_MMB_Core();
    11911173$mmb_core = 1;
    1192 //$iwp_mmb_core->install(true);
     1174
    11931175if(isset($_GET['auto_login']))
    11941176    $iwp_mmb_core->automatic_login();   
    11951177
    1196 
     1178if (function_exists('register_activation_hook'))
     1179    register_activation_hook( __FILE__ , array( $iwp_mmb_core, 'install' ));
     1180
     1181if (function_exists('register_deactivation_hook'))
     1182    register_deactivation_hook(__FILE__, array( $iwp_mmb_core, 'uninstall' ));
    11971183
    11981184if (function_exists('add_action'))
     
    12061192    remove_action( 'login_init', 'send_frame_options_header');
    12071193}
    1208 //iwp_mmb_add_site(array('activation_key'))
     1194
    12091195?>
  • wpguards/trunk/modules/manager/installer.class.php

    r872536 r872784  
    5252    function install_remote_file($params)
    5353    {
     54               
    5455        global $wp_filesystem;
    5556        extract($params);
     
    9192            ));
    9293        }
    93        
     94               
    9495        if ($activate) {
    9596            if ($type == 'plugins') {
    9697                include_once(ABSPATH . 'wp-admin/includes/plugin.php');
    97                 $all_plugins = get_plugins();
    98                 foreach ($all_plugins as $plugin_slug => $plugin) {
     98                 
     99                 wp_cache_delete( 'plugins', 'plugins' );
     100                 
     101                $all_plugins = get_plugins();
     102                foreach ($all_plugins as $plugin_slug => $plugin) {
    99103                    $plugin_dir = preg_split('/\//', $plugin_slug);
    100104                    foreach ($install_info as $key => $install) {
     
    223227    {
    224228        ob_start();
    225         if (!function_exists('wp_version_check'))
     229        if (!function_exists('wp_version_check') || !function_exists('get_core_checksums'))
    226230            include_once(ABSPATH . '/wp-admin/includes/update.php');
    227231       
     
    753757                   
    754758                    if (!in_array($path, $activated_plugins)) {
    755                        $plugins['inactive'][$br_i]['path'] = $path;
    756                        $plugins['inactive'][$br_i]['name'] = strip_tags($plugin['Name']);
     759                        $plugins['inactive'][$br_i]['path'] = $path;
     760                        $plugins['inactive'][$br_i]['name'] = strip_tags($plugin['Name']);
    757761                        $plugins['inactive'][$br_i]['version'] = $plugin['Version'];
    758762                        $br_i++;
  • wpguards/trunk/modules/manager/lib/dropbox.php

    r872536 r872784  
    11<?php
    2 class Dropbox {
     2class IWP_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 DropboxException("Error: File \"$file\" is not readable or doesn't exist.");
     45            throw new IWP_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 DropboxException("Error: File \"$file\" is not readable or doesn't exist.");
     61            throw new IWP_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 DropboxException("Error: Query \"$query\" must three characters long.");
     108            throw new IWP_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 DropboxException($message);
     157            throw new IWP_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 DropboxException($message);
     191            throw new IWP_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 DropboxException($message);
     260            throw new IWP_DropboxException($message);
    261261        } else {
    262262            curl_close($ch);
     
    281281}
    282282
    283 class DropboxException extends Exception {
     283class IWP_DropboxException extends Exception {
    284284}
    285285?>
  • wpguards/trunk/modules/manager/pclzip.class.php

    r872536 r872784  
    57165716  // --------------------------------------------------------------------------------
    57175717
    5718 
    57195718?>
  • wpguards/trunk/readme.txt

    r872665 r872784  
    55Requires at least: 3.6
    66Tested up to: 3.8.1
    7 Stable tag: 1.1.1
     7Stable tag: 1.2.0
    88License: GPLv2
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1313== Description ==
    1414
    15 WPGuards plugin is the complete solution for everyone who have a WordPress blog. We'll made automatic backups of your website and provide proffessional support so you can ask us about anything anytime directly from your WordPress administration panel. Also we provide the Uptime monitoring, several diagnostic tools, the Security monitoring and more
     15WPGuards plugin is the complete solution for everyone who have a WordPress blog. We'll made automatic backups of your website and provide proffessional support so you can ask us about anything anytime directly from your WordPress administration panel. Also we provide the Uptime monitoring, several diagnostic tools, the Security monitoring and more.
    1616
    17 **Automated Backups**
     17**See [Detailed installation instruction [PDF]](http://wpguards.com/downloads/WPGuards-Installation-and-General-Overview.pdf)**
     18
     19= Automated Backups =
    1820Your site was attacked and you lost your files? Or maybe you accidentally deleted some of your photos? No matter how big problem you have, you can trust our system. Files on your FTP server and entire database can be restored just by 1 click in the WordPress Administration Panel. And if you lost your WordPress website there is complete backup waiting for you on the Dropbox account.
    1921
    20 **Uptime Monitoring**
     22= Uptime Monitoring =
    2123Do you like to know what's going on with your website? Is 99,9% uptime declared by your provider true? You can easily find it out! Your website will be automatically added to the Uptime Monitor. And what if your website will be down? You'll get email notification right away!
    2224
    23 **Awesome Support**
     25= Awesome Support =
    2426WordPress is our life so you can be sure we know how to help you. There are few people waiting for hearing from you. By WPGuards plugin we'll automatically get all needed informations for fast support. You don't have to search for the version of WordPress you're using - let us do the work.
    2527
    26 **Security Scans**
     28= Security Scans =
    2729WPGuards plugin also provide advanced security scan system which will scan your website every day and you can sleep easy. We'll let you know.
    2830
    29 **Plugin Updates**
     31= Plugin Updates =
    3032WordPress auto-updates seems not to work? No problem, we'll update your WordPress, Themes, Plugins and Translations manually. We'll also check if everything is ok with your website after updates. That means no more PHP errors and no lost visitors.
    3133
    32 **There are also premium version of the plugin**
     34= There are also premium version of the plugin =
    3335Please go to [wpguards.com](http://wpguards.com) to see detailed plans and features.
    3436
    35 **[Client Panel](https://api.wpguards.com/panel)**
     37**[Client Panel](https://api.wpguards.com/panel)** | **[Official website](http://wpguards.com/)** | **[Detailed installation instruction [PDF]](http://wpguards.com/downloads/WPGuards-Installation-and-General-Overview.pdf)**
    3638
    3739== Installation ==
     
    4345
    4446== Frequently Asked Questions ==
     47
     48= Why you want me to register an account? =
     49
     50Plugin is useless withouit API key. With API key your website are connected to our API to perform backups, malware scans and plugin authentication. It's complete safe (Encrypted SSL connection)
    4551
    4652= What is this plugin? =
     
    7581== Changelog ==
    7682
     83= 1.2.0 - 10.3.2014 =
     84* Updated IWP Client
     85
    7786= 1.1.1 - 9.3.2014 =
    7887* Forked IWP client
     
    8190== Upgrade Notice ==
    8291
     92= 1.2.0 =
     93Improved security
     94
    8395= 1.1.1 =
    8496Better integration with IWP and improved unistallation security
  • wpguards/trunk/wpguards.php

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