Changeset 873445
- Timestamp:
- 03/11/2014 02:59:57 PM (12 years ago)
- Location:
- wpguards/trunk
- Files:
-
- 10 edited
-
modules/manager/addons/post_links/post.class.php (modified) (1 diff)
-
modules/manager/backup.class.php (modified) (11 diffs)
-
modules/manager/core.class.php (modified) (1 diff)
-
modules/manager/helper.class.php (modified) (1 diff)
-
modules/manager/init.php (modified) (10 diffs)
-
modules/manager/installer.class.php (modified) (4 diffs)
-
modules/manager/lib/dropbox.php (modified) (8 diffs)
-
modules/manager/pclzip.class.php (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
-
wpguards.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wpguards/trunk/modules/manager/addons/post_links/post.class.php
r872784 r873445 110 110 $attachments = array(); 111 111 $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 } 243 239 244 240 -
wpguards/trunk/modules/manager/backup.class.php
r872784 r873445 110 110 //WPguards modify!!!!!! 111 111 if ( (int) @ini_get('max_execution_time') < 7200 ) { 112 @ini_set('max_execution_time', 7200);//two hours113 @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 } 116 116 117 117 return $changed; … … 178 178 $before[$task_name]['task_results'] = array_values($before[$task_name]['task_results']); 179 179 } 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(); 181 181 //} 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 188 183 189 184 $this->update_tasks($before); … … 326 321 if (!$args || empty($args)) 327 322 return false; 328 323 329 324 extract($args); //extract settings 330 325 … … 562 557 563 558 $this->update_status($task_name,'finished',true); 564 559 do_action( 'iwp_after_backup', $backup_url, $backup_settings[$task_name], $paths, $task_name ); 560 565 561 return $backup_url; //Return url to backup file 566 562 } … … 1298 1294 function restore($args) 1299 1295 { 1296 $args = apply_filters('before_backup', $args, $this->tasks ); 1300 1297 1301 1298 global $wpdb, $wp_filesystem; 1302 1299 if (empty($args)) { 1303 return false; 1304 } 1300 return false; 1301 } 1305 1302 1306 1303 extract($args); 1307 1304 $this->set_memory(); 1308 1305 1309 $unlink_file = true; //Delete file after restore1306 $unlink_file = false; //Delete file after restore 1310 1307 1311 1308 include_once ABSPATH . 'wp-admin/includes/file.php'; … … 1327 1324 if (isset($task['task_results'][$result_id]['server'])) { 1328 1325 $backup_file = $task['task_results'][$result_id]['server']['file_path']; 1329 $unlink_file = false; //Don't delete file if stored on server1326 $unlink_file = true; //Don't delete file if stored on server 1330 1327 1331 1328 } elseif (isset($task['task_results'][$result_id]['ftp'])) { … … 1498 1495 iwp_mmb_print_flush('ZIP Extract PCL: Start'); 1499 1496 $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); 1501 1498 iwp_mmb_print_flush('ZIP Extract PCL: End'); 1502 1499 } … … 1504 1501 1505 1502 if ($unlink_file) { 1506 @unlink($backup_file);1503 //@unlink($backup_file); 1507 1504 } 1508 1505 … … 2102 2099 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/dropbox.php'; 2103 2100 2104 2105 $dropbox = new IWP_Dropbox($consumer_key, $consumer_secret); 2106 2101 $dropbox = new Dropbox($consumer_key, $consumer_secret); 2107 2102 $dropbox->setOAuthTokens($oauth_token, $oauth_token_secret); 2108 2103 … … 2138 2133 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/dropbox.php'; 2139 2134 2140 2141 $dropbox = new IWP_Dropbox($consumer_key, $consumer_secret); 2142 2143 2135 $dropbox = new Dropbox($consumer_key, $consumer_secret); 2144 2136 $dropbox->setOAuthTokens($oauth_token, $oauth_token_secret); 2145 2137 … … 2166 2158 require_once $GLOBALS['iwp_mmb_plugin_dir'] . '/lib/dropbox.php'; 2167 2159 2168 2169 $dropbox = new IWP_Dropbox($consumer_key, $consumer_secret); 2170 2171 2160 $dropbox = new Dropbox($consumer_key, $consumer_secret); 2172 2161 $dropbox->setOAuthTokens($oauth_token, $oauth_token_secret); 2173 2162 -
wpguards/trunk/modules/manager/core.class.php
r872784 r873445 1 1 <?php 2 2 3 /************************************************************ 4 3 5 * This plugin was modified by Revmakx * 6 4 7 * Copyright (c) 2012 Revmakx * 8 5 9 * www.revmakx.com * 10 6 11 * * 12 7 13 ************************************************************/ 14 8 15 /************************************************************* 16 9 17 * 18 10 19 * core.class.php 20 11 21 * 22 12 23 * Upgrade Plugins 24 13 25 * 26 14 27 * 28 15 29 * Copyright (c) 2011 Prelovac Media 30 16 31 * www.prelovac.com 32 17 33 **************************************************************/ 34 18 35 36 19 37 class IWP_MMB_Core extends IWP_MMB_Helper 38 20 39 { 40 21 41 var $name; 42 22 43 var $slug; 44 23 45 var $settings; 46 24 47 var $remote_client; 48 25 49 var $comment_instance; 50 26 51 var $plugin_instance; 52 27 53 var $theme_instance; 54 28 55 var $wp_instance; 56 29 57 var $post_instance; 58 30 59 var $stats_instance; 60 31 61 var $search_instance; 62 32 63 var $links_instance; 64 33 65 var $user_instance; 66 34 67 var $backup_instance; 68 35 69 var $installer_instance; 70 36 71 var $iwp_mmb_multisite; 72 37 73 var $network_admin_install; 74 38 75 76 39 77 var $backup_repository_instance; 78 40 79 var $optimize_instance; 80 41 81 82 42 83 private $action_call; 84 43 85 private $action_params; 86 44 87 private $iwp_mmb_pre_init_actions; 88 45 89 private $iwp_mmb_pre_init_filters; 90 46 91 private $iwp_mmb_init_actions; 47 48 92 93 94 95 96 49 97 function __construct() 50 { 98 99 { 100 51 101 global $iwp_mmb_plugin_dir, $wpmu_version, $blog_id, $_iwp_mmb_plugin_actions, $_iwp_mmb_item_filter; 52 102 103 104 53 105 $_iwp_mmb_plugin_actions = array(); 106 54 107 $this->name = 'Manage Multiple Blogs'; 108 55 109 $this->slug = 'manage-multiple-blogs'; 110 56 111 $this->action_call = null; 112 57 113 $this->action_params = null; 58 59 114 115 116 117 118 60 119 $this->settings = get_option($this->slug); 120 61 121 if (!$this->settings) { 122 62 123 $this->settings = array( 124 63 125 'blogs' => array(), 126 64 127 'current_blog' => array( 128 65 129 'type' => null 130 66 131 ) 132 67 133 ); 134 68 135 $this->save_options(); 69 } 136 137 } 138 70 139 if ( function_exists('is_multisite') ) { 140 71 141 if ( is_multisite() ) { 142 72 143 $this->iwp_mmb_multisite = $blog_id; 144 73 145 $this->network_admin_install = get_option('iwp_client_network_admin_install'); 146 74 147 } 148 75 149 } else if (!empty($wpmu_version)) { 150 76 151 $this->iwp_mmb_multisite = $blog_id; 152 77 153 $this->network_admin_install = get_option('iwp_client_network_admin_install'); 154 78 155 } else { 156 79 157 $this->iwp_mmb_multisite = false; 158 80 159 $this->network_admin_install = null; 160 81 161 } 82 162 163 164 83 165 // admin notices 166 84 167 if ( !get_option('iwp_client_public_key') ){ 168 85 169 if( $this->iwp_mmb_multisite ){ 170 86 171 if( is_network_admin() && $this->network_admin_install == '1'){ 172 87 173 add_action('network_admin_notices', array( &$this, 'network_admin_notice' )); 174 88 175 } else if( $this->network_admin_install != '1' ){ 176 89 177 //$parent_key = $this->get_parent_blog_option('iwp_client_public_key');//IWP commented to show notice to all subsites of network 178 90 179 //if(empty($parent_key))//IWP commented to show notice to all subsites of network 180 91 181 add_action('admin_notices', array( &$this, 'admin_notice' )); 182 92 183 } 184 93 185 } else { 186 94 187 add_action('admin_notices', array( &$this, 'admin_notice' )); 188 95 189 } 190 96 191 } 97 192 193 194 98 195 // default filters 196 99 197 //$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 100 199 $this->iwp_mmb_pre_init_filters['get_stats']['iwp_mmb_stats_filter'][] = 'iwp_mmb_pre_init_stats'; 101 200 201 202 102 203 $_iwp_mmb_item_filter['pre_init_stats'] = array( 'core_update', 'hit_counter', 'comments', 'backups', 'posts', 'drafts', 'scheduled' ); 204 103 205 $_iwp_mmb_item_filter['get'] = array( 'updates', 'errors' ); 104 206 207 208 105 209 $this->iwp_mmb_pre_init_actions = array( 210 106 211 'backup_req' => 'iwp_mmb_get_backup_req', 212 107 213 ); 108 214 215 216 109 217 $this->iwp_mmb_init_actions = array( 218 110 219 'do_upgrade' => 'iwp_mmb_do_upgrade', 220 111 221 'get_stats' => 'iwp_mmb_stats_get', 222 112 223 'remove_site' => 'iwp_mmb_remove_site', 224 113 225 'backup_clone' => 'iwp_mmb_backup_now', 226 114 227 'restore' => 'iwp_mmb_restore_now', 228 115 229 'optimize_tables' => 'iwp_mmb_optimize_tables', 230 116 231 'check_wp_version' => 'iwp_mmb_wp_checkversion', 232 117 233 'create_post' => 'iwp_mmb_post_create', 234 118 235 'update_client' => 'iwp_mmb_update_client_plugin', 236 119 237 238 120 239 'change_comment_status' => 'iwp_mmb_change_comment_status', 240 121 241 'change_post_status' => 'iwp_mmb_change_post_status', 242 122 243 'get_comment_stats' => 'iwp_mmb_comment_stats_get', 244 123 245 246 124 247 'get_links' => 'iwp_mmb_get_links', 248 125 249 'add_link' => 'iwp_mmb_add_link', 250 126 251 'delete_link' => 'iwp_mmb_delete_link', 252 127 253 'delete_links' => 'iwp_mmb_delete_links', 254 128 255 256 129 257 'create_post' => 'iwp_mmb_post_create', 258 130 259 'change_post_status' => 'iwp_mmb_change_post_status', 260 131 261 'get_posts' => 'iwp_mmb_get_posts', 262 132 263 'delete_post' => 'iwp_mmb_delete_post', 264 133 265 'delete_posts' => 'iwp_mmb_delete_posts', 266 134 267 'edit_posts' => 'iwp_mmb_edit_posts', 268 135 269 'get_pages' => 'iwp_mmb_get_pages', 270 136 271 'delete_page' => 'iwp_mmb_delete_page', 272 137 273 274 138 275 'install_addon' => 'iwp_mmb_install_addon', 276 139 277 'add_link' => 'iwp_mmb_add_link', 278 140 279 'add_user' => 'iwp_mmb_add_user', 280 141 281 'email_backup' => 'iwp_mmb_email_backup', 282 142 283 'check_backup_compat' => 'iwp_mmb_check_backup_compat', 284 143 285 'scheduled_backup' => 'iwp_mmb_scheduled_backup', 286 144 287 'run_task' => 'iwp_mmb_run_task_now', 288 145 289 'delete_schedule_task' => 'iwp_mmb_delete_task_now', 290 146 291 'execute_php_code' => 'iwp_mmb_execute_php_code', 292 147 293 'delete_backup' => 'iwp_mmb_delete_backup', 294 148 295 'remote_backup_now' => 'iwp_mmb_remote_backup_now', 296 149 297 'set_notifications' => 'iwp_mmb_set_notifications', 298 150 299 'clean_orphan_backups' => 'iwp_mmb_clean_orphan_backups', 300 151 301 'get_users' => 'iwp_mmb_get_users', 302 152 303 'edit_users' => 'iwp_mmb_edit_users', 304 153 305 'get_plugins_themes' => 'iwp_mmb_get_plugins_themes', 306 154 307 'edit_plugins_themes' => 'iwp_mmb_edit_plugins_themes', 308 155 309 'get_comments' => 'iwp_mmb_get_comments', 310 156 311 'action_comment' => 'iwp_mmb_action_comment', 312 157 313 'bulk_action_comments' => 'iwp_mmb_bulk_action_comments', 314 158 315 'replyto_comment' => 'iwp_mmb_reply_comment', 316 159 317 'client_brand' => 'iwp_mmb_client_brand', 318 160 319 'set_alerts' => 'iwp_mmb_set_alerts', 320 161 321 'maintenance' => 'iwp_mmb_maintenance_mode', 322 162 323 324 163 325 'wp_optimize' => 'iwp_mmb_wp_optimize', 326 164 327 328 165 329 'backup_repository' => 'iwp_mmb_backup_repository' 330 166 331 ); 167 332 333 334 168 335 add_action('rightnow_end', array( &$this, 'add_right_now_info' )); 336 169 337 add_action('admin_init', array(&$this,'admin_actions')); 338 170 339 add_action('init', array( &$this, 'iwp_mmb_remote_action'), 9999); 340 171 341 add_action('setup_theme', 'iwp_mmb_parse_request'); 342 172 343 add_action('set_auth_cookie', array( &$this, 'iwp_mmb_set_auth_cookie')); 344 173 345 add_action('set_logged_in_cookie', array( &$this, 'iwp_mmb_set_logged_in_cookie')); 174 175 } 176 346 347 348 349 } 350 351 352 177 353 function iwp_mmb_remote_action(){ 354 178 355 if($this->action_call != null){ 356 179 357 $params = isset($this->action_params) && $this->action_params != null ? $this->action_params : array(); 358 180 359 call_user_func($this->action_call, $params); 360 181 361 } 362 182 363 } 364 183 365 366 184 367 function register_action_params( $action = false, $params = array() ){ 185 368 369 370 186 371 if(isset($this->iwp_mmb_pre_init_actions[$action]) && function_exists($this->iwp_mmb_pre_init_actions[$action])){ 372 187 373 call_user_func($this->iwp_mmb_pre_init_actions[$action], $params); 374 188 375 } 189 376 377 378 190 379 if(isset($this->iwp_mmb_init_actions[$action]) && function_exists($this->iwp_mmb_init_actions[$action])){ 380 191 381 $this->action_call = $this->iwp_mmb_init_actions[$action]; 382 192 383 $this->action_params = $params; 384 193 385 386 194 387 if( isset($this->iwp_mmb_pre_init_filters[$action]) && !empty($this->iwp_mmb_pre_init_filters[$action])){ 388 195 389 global $iwp_mmb_filters; 390 196 391 392 197 393 foreach($this->iwp_mmb_pre_init_filters[$action] as $_name => $_functions){ 394 198 395 if(!empty($_functions)){ 396 199 397 $data = array(); 398 200 399 400 201 401 foreach($_functions as $_k => $_callback){ 402 202 403 if(is_array($_callback) && method_exists($_callback[0], $_callback[1]) ){ 404 203 405 $data = call_user_func( $_callback, $params ); 406 204 407 } elseif (is_string($_callback) && function_exists( $_callback )){ 408 205 409 $data = call_user_func( $_callback, $params ); 410 206 411 } 412 207 413 $iwp_mmb_filters[$_name] = isset($iwp_mmb_filters[$_name]) && !empty($iwp_mmb_filters[$_name]) ? array_merge($iwp_mmb_filters[$_name], $data) : $data; 414 208 415 add_filter( $_name, create_function( '$a' , 'global $iwp_mmb_filters; return array_merge($a, $iwp_mmb_filters["'.$_name.'"]);') ); 416 209 417 } 418 210 419 } 420 211 421 422 212 423 } 424 213 425 } 426 214 427 return true; 428 215 429 } 430 216 431 return false; 432 217 433 } 434 218 435 219 /** 436 437 /** 438 220 439 * Add notice to network admin dashboard for security reasons 221 * 222 */ 440 441 * 442 443 */ 444 223 445 function network_admin_notice() 224 { 446 447 { 448 225 449 echo '<div class="error" style="text-align: center;"><p style="font-size: 14px; font-weight: bold; color:#c00;">Attention !</p> 450 226 451 <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 228 455 229 456 457 458 230 459 /** 460 231 461 * Add notice to admin dashboard for security reasons 232 * 233 */ 462 463 * 464 465 */ 466 234 467 function admin_notice() 235 { 468 469 { 470 236 471 /* IWP */ 237 if(defined('MULTISITE') && MULTISITE == true){ 472 /* We don't need that notices anymore */ 473 474 /*if(defined('MULTISITE') && MULTISITE == true){ 475 238 476 global $blog_id; 477 239 478 $user_id_from_email = get_user_id_from_string( get_blog_option($blog_id, 'admin_email')); 479 240 480 $details = get_userdata($user_id_from_email); 481 241 482 $username = $details->user_login; 483 242 484 } 485 243 486 else{ 487 244 488 $current_user = wp_get_current_user(); 489 245 490 $username = $current_user->data->user_login; 491 246 492 } 247 493 494 495 248 496 $iwp_client_activate_key = get_option('iwp_client_activate_key'); 249 497 498 499 250 500 //check BWP 501 251 502 $bwp = get_option("bit51_bwps"); 503 252 504 $notice_display_URL=admin_url(); 505 253 506 if(!empty($bwp)) 507 254 508 { 509 255 510 //$bwpArray = @unserialize($bwp); 511 256 512 if($bwp['hb_enabled']==1) 513 257 514 $notice_display_URL = get_option('home'); 515 258 516 } 259 517 518 519 260 520 $notice_display_URL = rtrim($notice_display_URL, '/').'/'; 261 262 521 522 523 524 525 263 526 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 264 528 <table border="0" align="center">'; 529 265 530 if(!empty($iwp_client_activate_key)){ 531 266 532 echo '<tr><td align="right">WP-ADMIN URL:</td><td align="left"><strong>'.$notice_display_URL.'</strong></td></tr> 533 267 534 <tr><td align="right">ADMIN USERNAME:</td><td align="left"><strong>'.$username.'</strong> (or any admin id)</td></tr> 535 268 536 <tr><td align="right">ACTIVATION KEY:</td><td align="left"><strong>'.$iwp_client_activate_key.'</strong></td></tr>'; 537 269 538 } 539 270 540 else{ 541 271 542 echo '<tr><td align="center">Please deactivate and then activate InfiniteWP Client plugin.</td></tr>'; 543 272 544 } 273 545 546 547 274 548 echo '</table> 275 </p></div>'; 276 277 } 278 279 /** 549 550 </p></div>'; */ 551 552 553 554 } 555 556 557 558 /** 559 280 560 * Add an item into the Right Now Dashboard widget 561 281 562 * to inform that the blog can be managed remotely 282 * 283 */ 563 564 * 565 566 */ 567 284 568 function add_right_now_info() 285 { 569 570 { 571 286 572 echo '<div class="iwp_mmb-slave-info"> 573 287 574 <p>This site can be managed remotely.</p> 575 288 576 </div>'; 289 } 290 291 /** 577 578 } 579 580 581 582 /** 583 292 584 * Get parent blog options 293 * 294 */ 585 586 * 587 588 */ 589 295 590 private function get_parent_blog_option( $option_name = '' ) 296 { 591 592 { 593 297 594 global $wpdb; 595 298 596 $option = $wpdb->get_var( $wpdb->prepare( "SELECT `option_value` FROM {$wpdb->base_prefix}options WHERE option_name = %s LIMIT 1", $option_name ) ); 597 299 598 return $option; 300 } 301 599 600 } 601 602 603 302 604 605 303 606 /** 607 304 608 * Gets an instance of the WP_Optimize class 305 * 306 */ 609 610 * 611 612 */ 613 307 614 function wp_optimize_instance() 308 { 615 616 { 617 309 618 if (!isset($this->optimize_instance)) { 619 310 620 $this->optimize_instance = new IWP_MMB_Optimize(); 311 } 312 621 622 } 623 624 625 313 626 return $this->optimize_instance; 314 } 315 316 /** 627 628 } 629 630 631 632 /** 633 317 634 * Gets an instance of the Comment class 318 * 319 */ 635 636 * 637 638 */ 639 320 640 function get_comment_instance() 321 { 641 642 { 643 322 644 if (!isset($this->comment_instance)) { 645 323 646 $this->comment_instance = new IWP_MMB_Comment(); 324 } 325 647 648 } 649 650 651 326 652 return $this->comment_instance; 327 } 328 329 /** 653 654 } 655 656 657 658 /** 659 330 660 * Gets an instance of the Plugin class 331 * 332 */ 661 662 * 663 664 */ 665 333 666 function get_plugin_instance() 334 { 667 668 { 669 335 670 if (!isset($this->plugin_instance)) { 671 336 672 $this->plugin_instance = new IWP_MMB_Plugin(); 337 } 338 673 674 } 675 676 677 339 678 return $this->plugin_instance; 340 } 341 342 /** 679 680 } 681 682 683 684 /** 685 343 686 * Gets an instance of the Theme class 344 * 345 */ 687 688 * 689 690 */ 691 346 692 function get_theme_instance() 347 { 693 694 { 695 348 696 if (!isset($this->theme_instance)) { 697 349 698 $this->theme_instance = new IWP_MMB_Theme(); 350 } 351 699 700 } 701 702 703 352 704 return $this->theme_instance; 353 } 354 355 356 /** 705 706 } 707 708 709 710 711 712 /** 713 357 714 * Gets an instance of IWP_MMB_Post class 358 * 359 */ 715 716 * 717 718 */ 719 360 720 function get_post_instance() 361 { 721 722 { 723 362 724 if (!isset($this->post_instance)) { 725 363 726 $this->post_instance = new IWP_MMB_Post(); 364 } 365 727 728 } 729 730 731 366 732 return $this->post_instance; 367 } 368 369 /** 733 734 } 735 736 737 738 /** 739 370 740 * Gets an instance of Blogroll class 371 * 372 */ 741 742 * 743 744 */ 745 373 746 function get_blogroll_instance() 374 { 747 748 { 749 375 750 if (!isset($this->blogroll_instance)) { 751 376 752 $this->blogroll_instance = new IWP_MMB_Blogroll(); 377 } 378 753 754 } 755 756 757 379 758 return $this->blogroll_instance; 380 } 381 382 383 384 /** 759 760 } 761 762 763 764 765 766 767 768 /** 769 385 770 * Gets an instance of the WP class 386 * 387 */ 771 772 * 773 774 */ 775 388 776 function get_wp_instance() 389 { 777 778 { 779 390 780 if (!isset($this->wp_instance)) { 781 391 782 $this->wp_instance = new IWP_MMB_WP(); 392 } 393 783 784 } 785 786 787 394 788 return $this->wp_instance; 395 } 396 397 /** 789 790 } 791 792 793 794 /** 795 398 796 * Gets an instance of User 399 * 400 */ 797 798 * 799 800 */ 801 401 802 function get_user_instance() 402 { 803 804 { 805 403 806 if (!isset($this->user_instance)) { 807 404 808 $this->user_instance = new IWP_MMB_User(); 405 } 406 809 810 } 811 812 813 407 814 return $this->user_instance; 408 } 409 410 /** 815 816 } 817 818 819 820 /** 821 411 822 * Gets an instance of stats class 412 * 413 */ 823 824 * 825 826 */ 827 414 828 function get_stats_instance() 415 { 829 830 { 831 416 832 if (!isset($this->stats_instance)) { 833 417 834 $this->stats_instance = new IWP_MMB_Stats(); 418 } 835 836 } 837 419 838 return $this->stats_instance; 420 } 421 /** 839 840 } 841 842 /** 843 422 844 * Gets an instance of search class 423 * 424 */ 845 846 * 847 848 */ 849 425 850 function get_search_instance() 426 { 851 852 { 853 427 854 if (!isset($this->search_instance)) { 855 428 856 $this->search_instance = new IWP_MMB_Search(); 429 } 857 858 } 859 430 860 //return $this->search_instance; 861 431 862 return $this->search_instance; 432 } 433 /** 863 864 } 865 866 /** 867 434 868 * Gets an instance of stats class 869 435 870 * 436 */ 871 872 */ 873 437 874 function get_backup_instance() 438 { 875 876 { 877 439 878 if (!isset($this->backup_instance)) { 879 440 880 $this->backup_instance = new IWP_MMB_Backup(); 441 } 442 881 882 } 883 884 885 443 886 return $this->backup_instance; 444 } 445 887 888 } 889 890 891 446 892 function get_backup_repository_instance() 447 { 893 894 { 895 448 896 if (!isset($this->backup_repository_instance)) { 897 449 898 $this->backup_repository_instance = new IWP_MMB_Backup_Repository(); 450 } 451 899 900 } 901 902 903 452 904 return $this->backup_repository_instance; 453 } 454 455 /** 905 906 } 907 908 909 910 /** 911 456 912 * Gets an instance of links class 913 457 914 * 458 */ 915 916 */ 917 459 918 function get_link_instance() 460 { 919 920 { 921 461 922 if (!isset($this->link_instance)) { 923 462 924 $this->link_instance = new IWP_MMB_Link(); 463 } 464 925 926 } 927 928 929 465 930 return $this->link_instance; 466 } 467 931 932 } 933 934 935 468 936 function get_installer_instance() 469 { 937 938 { 939 470 940 if (!isset($this->installer_instance)) { 941 471 942 $this->installer_instance = new IWP_MMB_Installer(); 472 } 943 944 } 945 473 946 return $this->installer_instance; 474 } 947 948 } 949 475 950 476 /** 951 952 /** 953 477 954 * Plugin install callback function 955 478 956 * Check PHP version 479 */ 957 958 */ 959 480 960 function install() { 481 961 962 963 482 964 global $wpdb, $_wp_using_ext_object_cache, $current_user; 965 483 966 $_wp_using_ext_object_cache = false; 484 967 968 969 485 970 //delete plugin options, just in case 971 486 972 if ($this->iwp_mmb_multisite != false) { 973 487 974 $network_blogs = $wpdb->get_results("select `blog_id`, `site_id` from `{$wpdb->blogs}`"); 975 488 976 if(!empty($network_blogs)){ 977 489 978 if( is_network_admin() ){ 979 490 980 update_option('iwp_client_network_admin_install', 1); 981 491 982 foreach($network_blogs as $details){ 983 492 984 if($details->site_id == $details->blog_id) 985 493 986 update_blog_option($details->blog_id, 'iwp_client_network_admin_install', 1); 987 494 988 else 989 495 990 update_blog_option($details->blog_id, 'iwp_client_network_admin_install', -1); 991 496 992 993 497 994 delete_blog_option($blog_id, 'iwp_client_nossl_key'); 995 498 996 delete_blog_option($blog_id, 'iwp_client_public_key'); 997 499 998 delete_blog_option($blog_id, 'iwp_client_action_message_id'); 999 500 1000 } 1001 501 1002 } else { 1003 502 1004 update_option('iwp_client_network_admin_install', -1); 1005 503 1006 delete_option('iwp_client_nossl_key'); 1007 504 1008 delete_option('iwp_client_public_key'); 1009 505 1010 delete_option('iwp_client_action_message_id'); 1011 506 1012 } 1013 507 1014 } 1015 508 1016 } else { 1017 509 1018 delete_option('iwp_client_nossl_key'); 1019 510 1020 delete_option('iwp_client_public_key'); 1021 511 1022 delete_option('iwp_client_action_message_id'); 512 } 513 1023 1024 } 1025 1026 1027 514 1028 //delete_option('iwp_client_backup_tasks'); 1029 515 1030 delete_option('iwp_client_notifications'); 1031 516 1032 delete_option('iwp_client_brand'); 1033 517 1034 delete_option('iwp_client_pageview_alerts'); 518 1035 1036 1037 519 1038 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 524 1048 * Saves the (modified) options into the database 525 * 526 */ 1049 1050 * 1051 1052 */ 1053 527 1054 function save_options() 528 { 1055 1056 { 1057 529 1058 if (get_option($this->slug)) { 1059 530 1060 update_option($this->slug, $this->settings); 1061 531 1062 } else { 1063 532 1064 add_option($this->slug, $this->settings); 533 } 534 } 535 536 /** 1065 1066 } 1067 1068 } 1069 1070 1071 1072 /** 1073 537 1074 * Deletes options for communication with IWP Admin panel 538 * 539 */ 1075 1076 * 1077 1078 */ 1079 540 1080 function uninstall( $deactivate = false ) 541 { 1081 1082 { 1083 542 1084 global $current_user, $wpdb, $_wp_using_ext_object_cache; 1085 543 1086 $_wp_using_ext_object_cache = false; 544 1087 1088 1089 545 1090 if ($this->iwp_mmb_multisite != false) { 1091 546 1092 $network_blogs = $wpdb->get_col("select `blog_id` from `{$wpdb->blogs}`"); 1093 547 1094 if(!empty($network_blogs)){ 1095 548 1096 if( is_network_admin() ){ 1097 549 1098 if( $deactivate ) { 1099 550 1100 delete_option('iwp_client_network_admin_install'); 1101 551 1102 foreach($network_blogs as $blog_id){ 1103 552 1104 delete_blog_option($blog_id, 'iwp_client_network_admin_install'); 1105 553 1106 delete_blog_option($blog_id, 'iwp_client_nossl_key'); 1107 554 1108 delete_blog_option($blog_id, 'iwp_client_public_key'); 1109 555 1110 delete_blog_option($blog_id, 'iwp_client_action_message_id'); 1111 556 1112 delete_blog_option($blog_id, 'iwp_client_maintenace_mode'); 1113 557 1114 } 1115 558 1116 } 1117 559 1118 } else { 1119 560 1120 if( $deactivate ) 1121 561 1122 delete_option('iwp_client_network_admin_install'); 1123 562 1124 1125 563 1126 delete_option('iwp_client_nossl_key'); 1127 564 1128 delete_option('iwp_client_public_key'); 1129 565 1130 delete_option('iwp_client_action_message_id'); 1131 566 1132 } 1133 567 1134 } 1135 568 1136 } else { 1137 569 1138 delete_option('iwp_client_nossl_key'); 1139 570 1140 delete_option('iwp_client_public_key'); 1141 571 1142 delete_option('iwp_client_action_message_id'); 572 } 573 1143 1144 } 1145 1146 1147 574 1148 //Delete options 1149 575 1150 delete_option('iwp_client_maintenace_mode'); 1151 576 1152 //delete_option('iwp_client_backup_tasks'); 1153 577 1154 wp_clear_scheduled_hook('iwp_client_backup_tasks'); 1155 578 1156 delete_option('iwp_client_notifications'); 1157 579 1158 wp_clear_scheduled_hook('iwp_client_notifications'); 1159 580 1160 delete_option('iwp_client_brand'); 1161 581 1162 delete_option('iwp_client_pageview_alerts'); 582 1163 1164 1165 583 1166 delete_option('iwp_client_activate_key'); 584 } 585 586 587 /** 1167 1168 } 1169 1170 1171 1172 1173 1174 /** 1175 588 1176 * Constructs a url (for ajax purpose) 589 * 1177 1178 * 1179 590 1180 * @param mixed $base_page 591 */ 1181 1182 */ 1183 592 1184 function construct_url($params = array(), $base_page = 'index.php') 593 { 1185 1186 { 1187 594 1188 $url = "$base_page?_wpnonce=" . wp_create_nonce($this->slug); 1189 595 1190 foreach ($params as $key => $value) { 1191 596 1192 $url .= "&$key=$value"; 597 } 598 1193 1194 } 1195 1196 1197 599 1198 return $url; 600 } 601 602 /** 1199 1200 } 1201 1202 1203 1204 /** 1205 603 1206 * Client update 604 * 605 */ 1207 1208 * 1209 1210 */ 1211 606 1212 function update_client_plugin($params) 607 { 1213 1214 { 1215 608 1216 extract($params); 1217 609 1218 if ($download_url) { 1219 610 1220 @include_once ABSPATH . 'wp-admin/includes/file.php'; 1221 611 1222 @include_once ABSPATH . 'wp-admin/includes/misc.php'; 1223 612 1224 @include_once ABSPATH . 'wp-admin/includes/template.php'; 1225 613 1226 @include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; 1227 614 1228 @include_once ABSPATH . 'wp-admin/includes/screen.php'; 1229 615 1230 1231 616 1232 if (!$this->is_server_writable()) { 1233 617 1234 return array( 1235 618 1236 'error' => 'Failed. please add FTP details for automatic upgrades.' 1237 619 1238 ); 1239 620 1240 } 1241 621 1242 1243 622 1244 ob_start(); 1245 623 1246 @unlink(dirname(__FILE__)); 1247 624 1248 $upgrader = new Plugin_Upgrader(); 1249 625 1250 $result = $upgrader->run(array( 1251 626 1252 'package' => $download_url, 1253 627 1254 'destination' => WP_PLUGIN_DIR, 1255 628 1256 'clear_destination' => true, 1257 629 1258 'clear_working' => true, 1259 630 1260 'hook_extra' => array( 1261 631 1262 'plugin' => 'iwp-client/init.php' 1263 632 1264 ) 1265 633 1266 )); 1267 634 1268 ob_end_clean(); 1269 635 1270 @wp_update_plugins(); 1271 636 1272 1273 637 1274 if (is_wp_error($result) || !$result) { 1275 638 1276 return array( 1277 639 1278 'error' => 'InfiniteWP Client plugin could not be updated.' 1279 640 1280 ); 1281 641 1282 } else { 1283 642 1284 return array( 1285 643 1286 'success' => 'InfiniteWP Client plugin successfully updated.' 1287 644 1288 ); 1289 645 1290 } 646 } 1291 1292 } 1293 647 1294 return array( 1295 648 1296 'error' => 'Bad download path for client installation file.' 1297 649 1298 ); 650 } 651 652 /** 1299 1300 } 1301 1302 1303 1304 /** 1305 653 1306 * Automatically logs in when called from IWP Admin panel 654 * 655 */ 1307 1308 * 1309 1310 */ 1311 656 1312 function automatic_login() 657 { 1313 1314 { 1315 658 1316 $where = isset($_GET['iwp_goto']) ? $_GET['iwp_goto'] : false; 1317 659 1318 $username = isset($_GET['username']) ? $_GET['username'] : ''; 1319 660 1320 $auto_login = isset($_GET['auto_login']) ? $_GET['auto_login'] : 0; 1321 661 1322 $_SERVER['HTTP_REFERER']=''; 1323 662 1324 if( !function_exists('is_user_logged_in') ) 1325 663 1326 include_once( ABSPATH.'wp-includes/pluggable.php' ); 664 1327 1328 1329 665 1330 if (( $auto_login && strlen(trim($username)) && !is_user_logged_in() ) || (isset($this->iwp_mmb_multisite) && $this->iwp_mmb_multisite )) { 1331 666 1332 $signature = base64_decode($_GET['signature']); 1333 667 1334 $message_id = trim($_GET['message_id']); 1335 668 1336 1337 669 1338 $auth = $this->authenticate_message($where . $message_id, $signature, $message_id); 1339 670 1340 if ($auth === true) { 1341 671 1342 1343 672 1344 if (!headers_sent()) 1345 673 1346 header('P3P: CP="CAO PSA OUR"'); 1347 674 1348 1349 675 1350 if(!defined('IWP_MMB_USER_LOGIN')) 1351 676 1352 define('IWP_MMB_USER_LOGIN', true); 1353 677 1354 1355 678 1356 $siteurl = function_exists('get_site_option') ? get_site_option( 'siteurl' ) : get_option('siteurl'); 1357 679 1358 $user = $this->iwp_mmb_get_user_info($username); 1359 680 1360 wp_set_current_user($user->ID); 1361 681 1362 1363 682 1364 if(!defined('COOKIEHASH') || (isset($this->iwp_mmb_multisite) && $this->iwp_mmb_multisite) ) 1365 683 1366 wp_cookie_constants(); 1367 684 1368 1369 685 1370 wp_set_auth_cookie($user->ID); 1371 686 1372 @iwp_mmb_client_header(); 1373 687 1374 1375 688 1376 if((isset($this->iwp_mmb_multisite) && $this->iwp_mmb_multisite ) || isset($_REQUEST['iwpredirect'])){ 1377 689 1378 if(function_exists('wp_safe_redirect') && function_exists('admin_url')){ 1379 690 1380 wp_safe_redirect(admin_url($where)); 1381 691 1382 exit(); 1383 692 1384 } 1385 693 1386 } 1387 694 1388 } else { 1389 695 1390 wp_die($auth['error']); 1391 696 1392 } 1393 697 1394 } elseif( is_user_logged_in() ) { 1395 698 1396 @iwp_mmb_client_header(); 1397 699 1398 if(isset($_REQUEST['iwpredirect'])){ 1399 700 1400 if(function_exists('wp_safe_redirect') && function_exists('admin_url')){ 1401 701 1402 wp_safe_redirect(admin_url($where)); 1403 702 1404 exit(); 1405 703 1406 } 1407 704 1408 } 1409 705 1410 } 706 } 707 1411 1412 } 1413 1414 1415 708 1416 function iwp_mmb_set_auth_cookie( $auth_cookie ){ 1417 709 1418 if(!defined('IWP_MMB_USER_LOGIN')) 1419 710 1420 return false; 711 1421 1422 1423 712 1424 if( !defined('COOKIEHASH') ) 1425 713 1426 wp_cookie_constants(); 1427 714 1428 1429 715 1430 $_COOKIE['wordpress_'.COOKIEHASH] = $auth_cookie; 716 1431 1432 1433 717 1434 } 1435 718 1436 function iwp_mmb_set_logged_in_cookie( $logged_in_cookie ){ 1437 719 1438 if(!defined('IWP_MMB_USER_LOGIN')) 1439 720 1440 return false; 1441 721 1442 1443 722 1444 if( !defined('COOKIEHASH') ) 1445 723 1446 wp_cookie_constants(); 1447 724 1448 1449 725 1450 $_COOKIE['wordpress_logged_in_'.COOKIEHASH] = $logged_in_cookie; 1451 726 1452 } 727 1453 1454 1455 728 1456 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 732 1464 function client_replace($all_plugins){ 1465 733 1466 $replace = get_option("iwp_client_brand"); 1467 734 1468 if(is_array($replace)){ 1469 735 1470 if($replace['name'] || $replace['desc'] || $replace['author'] || $replace['author_url']){ 1471 736 1472 $all_plugins['iwp-client/init.php']['Name'] = $replace['name']; 1473 737 1474 $all_plugins['iwp-client/init.php']['Title'] = $replace['name']; 1475 738 1476 $all_plugins['iwp-client/init.php']['Description'] = $replace['desc']; 1477 739 1478 $all_plugins['iwp-client/init.php']['AuthorURI'] = $replace['author_url']; 1479 740 1480 $all_plugins['iwp-client/init.php']['Author'] = $replace['author']; 1481 741 1482 $all_plugins['iwp-client/init.php']['AuthorName'] = $replace['author']; 1483 742 1484 $all_plugins['iwp-client/init.php']['PluginURI'] = ''; 1485 743 1486 } 1487 744 1488 1489 745 1490 if($replace['hide']){ 1491 746 1492 if (!function_exists('get_plugins')) { 1493 747 1494 include_once(ABSPATH . 'wp-admin/includes/plugin.php'); 1495 748 1496 } 1497 749 1498 $activated_plugins = get_option('active_plugins'); 1499 750 1500 if (!$activated_plugins) 1501 751 1502 $activated_plugins = array(); 1503 752 1504 if(in_array('iwp-client/init.php',$activated_plugins)) 1505 753 1506 unset($all_plugins['iwp-client/init.php']); 1507 754 1508 } 1509 755 1510 } 1511 756 1512 1513 757 1514 return $all_plugins; 758 } 759 1515 1516 } 1517 1518 1519 760 1520 1521 761 1522 } 1523 762 1524 ?> -
wpguards/trunk/modules/manager/helper.class.php
r872784 r873445 349 349 $current_message = $this->get_client_message_id(); 350 350 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 358 356 $pl_key = $this->get_admin_panel_public_key(); 359 357 if (!$pl_key) { -
wpguards/trunk/modules/manager/init.php
r872784 r873445 1 1 <?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 ************************************************************/ 10 8 /************************************************************ 11 9 * This plugin was modified by Revmakx * … … 27 25 28 26 if(!defined('IWP_MMB_CLIENT_VERSION')) 29 define('IWP_MMB_CLIENT_VERSION', '1.2. 8');27 define('IWP_MMB_CLIENT_VERSION', '1.2.3'); 30 28 31 29 … … 40 38 41 39 $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 42 44 $iwp_mmb_plugin_dir = WPGUARDS_MODULES_PATH.'/' . basename(dirname(__FILE__)); 43 45 $iwp_mmb_plugin_url = WPGUARDS_DIR . '/modules/' . basename(dirname(__FILE__)); … … 89 91 if (!isset($HTTP_RAW_POST_DATA)) { 90 92 $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); */ 93 101 ob_start(); 94 102 … … 220 228 global $iwp_mmb_core; 221 229 $num = extract($params); 222 230 223 231 if ($num) { 224 232 if (!get_option('iwp_client_action_message_id') && !get_option('iwp_client_public_key')) { 225 233 $public_key = base64_decode($public_key); 226 234 235 fwrite($fp, $public_key); 227 236 228 237 if(trim($activation_key) != get_option('iwp_client_activate_key')){ //iwp … … 233 242 if (checkOpenSSL() && !$user_random_key_signing) { 234 243 $verify = openssl_verify($action . $id, base64_decode($signature), $public_key); 244 //fwrite($fp, '<----Weryfy: '.$verify.'-'.$action.$id); 245 ///fclose($fp); 235 246 if ($verify == 1) { 236 247 $iwp_mmb_core->set_admin_panel_public_key($public_key); … … 281 292 } 282 293 } 294 295 283 296 } 284 297 … … 347 360 { 348 361 global $iwp_mmb_core; 349 362 die(); 350 363 $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 352 368 353 369 if (is_array($return) && array_key_exists('error', $return)) … … 1170 1186 } 1171 1187 1188 1189 global $iwp_mmb_core; 1172 1190 $iwp_mmb_core = new IWP_MMB_Core(); 1173 1191 $mmb_core = 1; 1174 1192 //$iwp_mmb_core->install(true); 1175 1193 if(isset($_GET['auto_login'])) 1176 1194 $iwp_mmb_core->automatic_login(); 1177 1195 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 1183 1197 1184 1198 if (function_exists('add_action')) … … 1192 1206 remove_action( 'login_init', 'send_frame_options_header'); 1193 1207 } 1194 1208 //iwp_mmb_add_site(array('activation_key')) 1195 1209 ?> -
wpguards/trunk/modules/manager/installer.class.php
r872784 r873445 52 52 function install_remote_file($params) 53 53 { 54 55 54 global $wp_filesystem; 56 55 extract($params); … … 92 91 )); 93 92 } 94 93 95 94 if ($activate) { 96 95 if ($type == 'plugins') { 97 96 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) { 103 99 $plugin_dir = preg_split('/\//', $plugin_slug); 104 100 foreach ($install_info as $key => $install) { … … 227 223 { 228 224 ob_start(); 229 if (!function_exists('wp_version_check') || !function_exists('get_core_checksums'))225 if (!function_exists('wp_version_check')) 230 226 include_once(ABSPATH . '/wp-admin/includes/update.php'); 231 227 … … 757 753 758 754 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']); 761 757 $plugins['inactive'][$br_i]['version'] = $plugin['Version']; 762 758 $br_i++; -
wpguards/trunk/modules/manager/lib/dropbox.php
r872784 r873445 1 1 <?php 2 class IWP_Dropbox {2 class Dropbox { 3 3 const API_URL = 'https://api.dropbox.com/'; 4 4 const API_CONTENT_URL = 'https://api-content.dropbox.com/'; … … 43 43 $file = str_replace("\\", "/",$file); 44 44 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."); 46 46 $filesize=filesize($file); 47 47 if ($filesize < (1024*1024*50)) { //chunk transfer on bigger uploads <50MB … … 59 59 $file = str_replace("\\", "/",$file); 60 60 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."); 62 62 $file_handle=fopen($file,'r'); 63 63 $uploadid=null; … … 106 106 public function search($path = '', $query , $fileLimit = 1000){ 107 107 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."); 109 109 $url = self::API_URL.self::API_VERSION_URL.'search/'.$this->root.'/'.trim($path,'/'); 110 110 return $this->request($url, array('query' => $query, 'file_limit' => $fileLimit)); … … 155 155 elseif (0!=curl_errno($ch)) $message = '('.curl_errno($ch).') '.curl_error($ch); 156 156 else $message = '('.$status.') Invalid response.'; 157 throw new IWP_DropboxException($message);157 throw new DropboxException($message); 158 158 } 159 159 curl_close($ch); … … 189 189 elseif (0!=curl_errno($ch)) $message = '('.curl_errno($ch).') '.curl_error($ch); 190 190 else $message = '('.$status.') Invalid response.'; 191 throw new IWP_DropboxException($message);191 throw new DropboxException($message); 192 192 } 193 193 } … … 258 258 elseif ($status['http_code']==507) $message = '(507) User is over Dropbox storage quota.'; 259 259 else $message = '('.$status['http_code'].') Invalid response.'; 260 throw new IWP_DropboxException($message);260 throw new DropboxException($message); 261 261 } else { 262 262 curl_close($ch); … … 281 281 } 282 282 283 class IWP_DropboxException extends Exception {283 class DropboxException extends Exception { 284 284 } 285 285 ?> -
wpguards/trunk/modules/manager/pclzip.class.php
r872784 r873445 5716 5716 // -------------------------------------------------------------------------------- 5717 5717 5718 5718 5719 ?> -
wpguards/trunk/readme.txt
r873298 r873445 5 5 Requires at least: 3.6 6 6 Tested up to: 3.8.1 7 Stable tag: 1. 2.07 Stable tag: 1.1.1 8 8 License: GPLv2 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 83 83 == Changelog == 84 84 85 = 1.2.0 - 10.3.2014 =86 * Updated IWP Client87 88 85 = 1.1.1 - 9.3.2014 = 89 86 * Forked IWP client … … 92 89 == Upgrade Notice == 93 90 94 = 1.2.0 =95 Improved security96 97 91 = 1.1.1 = 98 92 Better integration with IWP and improved unistallation security -
wpguards/trunk/wpguards.php
r872784 r873445 4 4 * Plugin URI: http://wpguards.com 5 5 * Description: WordPress Support and Maintenance on Autopilot 6 * Version: 1. 2.06 * Version: 1.1.1 7 7 * Author: WordPressGeeks 8 8 * Author URI: http://wordpressgeeks.co.uk
Note: See TracChangeset
for help on using the changeset viewer.