InfiniteWP Client - Version 1.1.0

Version Description

  • Premium addons bugs fixed
  • Reload data improved
Download this release

Release Info

Developer infinitewp
Plugin Icon 128x128 InfiniteWP Client
Version 1.1.0
Comparing to
See all releases

Code changes from version 1.0.4 to 1.1.0

addons/manage_users/user.class.php ADDED
@@ -0,0 +1,216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*************************************************************
3
+ *
4
+ * user.class.php
5
+ *
6
+ * Add Users
7
+ *
8
+ *
9
+ * Copyright (c) 2011 Prelovac Media
10
+ * www.prelovac.com
11
+ **************************************************************/
12
+
13
+ class IWP_MMB_User extends IWP_MMB_Core
14
+ {
15
+ function __construct()
16
+ {
17
+ parent::__construct();
18
+ }
19
+
20
+ function get_users($args){
21
+ global $wpdb;
22
+
23
+ //$args: $user_roles;
24
+ if(empty($args))
25
+ return false;
26
+
27
+ extract($args);
28
+
29
+ $userlevels = array();
30
+ $level_strings = array();
31
+ foreach($user_roles as $user_role){
32
+ switch(strtolower($user_role)){
33
+ case 'subscriber' : $userlevels[] = 0; $level_strings[] = $user_role; break;
34
+ case 'contributor' : $userlevels[] = 1; $level_strings[] = $user_role; break;
35
+ case 'author' : $userlevels[] = 2; $level_strings[] = $user_role; break;
36
+ case 'editor' : $userlevels[] = 7; $level_strings[] = $user_role; break;
37
+ case 'administrator' : $userlevels[] = 10; $level_strings[] = $user_role; break;
38
+ default: break;
39
+ }
40
+ }
41
+
42
+ $users = array();
43
+ $userlevel_qry = "('".implode("','",$userlevels)."')";
44
+ $userlevel_fallback_qry = "('%".implode("%','%",$level_strings)."%')";
45
+ $field = $wpdb->prefix."capabilities";
46
+
47
+ $user_metas = $wpdb->get_results("SELECT * from $wpdb->usermeta WHERE meta_key = '$field' AND meta_value IN $userlevel_fallback_qry");
48
+ if($user_metas == false || empty($user_metas)){
49
+ $user_metas = $wpdb->get_results("SELECT * from $wpdb->usermeta WHERE meta_key = 'wp_user_level' AND meta_value IN $userlevel_qry");
50
+ }
51
+
52
+ $include = array();
53
+ if(is_array($user_metas) && !empty($user_metas)){
54
+ foreach($user_metas as $user_meta){
55
+ $include[] = $user_meta->user_id;
56
+ }
57
+ }
58
+
59
+ $args = array();
60
+ $args['include'] = $include;
61
+ $args['fields'] = 'all_with_meta';
62
+ $temp_users = get_users($args);
63
+ $user = array();
64
+
65
+ foreach ((array)$temp_users as $temp){
66
+
67
+ $user['user_id'] = $temp->ID;
68
+ $user['user_login'] = $temp->user_login;
69
+ $user['wp_capabilities'] = array_keys($temp->$field);
70
+
71
+ $users[] = $user;
72
+ }
73
+ $users['request_roles'] = $user_roles;
74
+ return array('users' => $users);
75
+ }
76
+
77
+ function add_user($args)
78
+ {
79
+
80
+ if(!function_exists('username_exists') || !function_exists('email_exists'))
81
+ include_once(ABSPATH . WPINC . '/registration.php');
82
+
83
+ if(username_exists($args['user_login']))
84
+ return array('error' => 'Username already exists');
85
+
86
+ if (email_exists($args['user_email']))
87
+ return array('error' => 'Email already exists');
88
+
89
+ if(!function_exists('wp_insert_user'))
90
+ include_once (ABSPATH . 'wp-admin/includes/user.php');
91
+
92
+ $user_id = wp_insert_user($args);
93
+
94
+ if($user_id){
95
+
96
+ if($args['email_notify']){
97
+ //require_once ABSPATH . WPINC . '/pluggable.php';
98
+ wp_new_user_notification($user_id, $args['user_pass']);
99
+ }
100
+ return $user_id;
101
+ }else{
102
+ return array('error' => 'User not added. Please try again.');
103
+ }
104
+
105
+ }
106
+
107
+ function edit_users($args){
108
+
109
+ if(empty($args))
110
+ return false;
111
+ if(!function_exists('get_user_to_edit'))
112
+ include_once (ABSPATH . 'wp-admin/includes/user.php');
113
+ if(!function_exists('wp_update_user'))
114
+ include_once (ABSPATH . WPINC.'/user.php');
115
+
116
+ extract($args);
117
+ //$args: $users, $new_role, $new_password, $user_edit_action
118
+
119
+ $return = array();
120
+ if(count($users)){
121
+ foreach($users as $user){
122
+ $result = '';
123
+ $user_obj = $this->iwp_mmb_get_user_info( $user );
124
+ if($user_obj != false){
125
+ switch($user_edit_action){
126
+ case 'change-password':
127
+ if($new_password){
128
+ $user_data = array();
129
+ $userdata['user_pass'] = $new_password;
130
+ $userdata['ID'] = $user_obj->ID;
131
+ $result = wp_update_user($userdata);
132
+ } else {
133
+ $result = array('error' => 'No password provided.');
134
+ }
135
+ break;
136
+ case 'change-role':
137
+ if($new_role){
138
+ if($user != $username){
139
+ if(!$this->last_admin($user_obj)){
140
+ $user_data = array();
141
+ $userdata['ID'] = $user_obj->ID;
142
+ $userdata['role'] = strtolower($new_role);
143
+ $result = wp_update_user($userdata);
144
+ } else {
145
+ $result = array('error' => 'Cannot change role to the only one left admin user.');
146
+ }
147
+ } else {
148
+ $result = array('error' => 'Cannot change role to user assigned for InfiniteWP.');
149
+ }
150
+ } else {
151
+ $result = array('error' => 'No role provided.');
152
+ }
153
+ break;
154
+ case 'delete-user':
155
+ if($user != $username){
156
+ if(!$this->last_admin($user_obj)){
157
+ if($reassign_user){
158
+ $to_user = $this->iwp_mmb_get_user_info( $reassign_user );
159
+ if($to_user != false){
160
+ $result = wp_delete_user($user_obj->ID, $to_user->ID);
161
+ } else {
162
+ $result = array('error' => 'User not deleted. User to reassign posts doesn\'t exist.');
163
+ }
164
+ } else {
165
+ $result = wp_delete_user($user_obj->ID);
166
+ }
167
+ } else {
168
+ $result = array('error' => 'Cannot delete the only one left admin user.');
169
+ }
170
+ } else {
171
+ $result = array('error' => 'Cannot delete user assigned for InfiniteWP.');
172
+ }
173
+
174
+ break;
175
+ default:
176
+ $result = array('error' => 'Wrong action provided. Please try again.');
177
+ break;
178
+ }
179
+ } else {
180
+ $result = array('error' => 'User not found.');
181
+ }
182
+
183
+ if(is_wp_error($result)){
184
+ $result = array('error' => $result->get_error_message());
185
+ }
186
+
187
+ $return[$user] = $result;
188
+ }
189
+ }
190
+
191
+ return $return;
192
+
193
+ }
194
+
195
+ //Check if user is the only one admin on the site
196
+ function last_admin($user_obj){
197
+ global $wpdb;
198
+ $field = $wpdb->prefix."capabilities";
199
+ $capabilities = array_map('strtolower',array_keys($user_obj->$field));
200
+ $result = count_users();
201
+ if(in_array('administrator',$capabilities)){
202
+
203
+ if(!function_exists('count_users')){
204
+ include_once (ABSPATH . WPINC. '/user.php');
205
+ }
206
+
207
+ $result = count_users();
208
+ if($result['avail_roles']['administrator'] == 1){
209
+ return true;
210
+ }
211
+ }
212
+ return false;
213
+ }
214
+
215
+ }
216
+ ?>
backup.class.php CHANGED
@@ -88,7 +88,33 @@ class IWP_MMB_Backup extends IWP_MMB_Core
88
  );
89
  $this->tasks = get_option('iwp_client_backup_tasks');
90
  }
91
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  function get_backup_settings()
93
  {
94
  $backup_settings = get_option('iwp_client_backup_tasks');
@@ -129,8 +155,8 @@ if (is_array($params['account_info'])) { //only if sends from IWP Admin Panel fi
129
  $before[$task_name]['task_args'] = $args;
130
  //$before[$task_name]['task_args'] = $task_name;
131
 
132
- if (strlen($args['schedule']))
133
- $before[$task_name]['task_args']['next'] = $this->schedule_next($args['type'], $args['schedule']);
134
  $before[$task_name]['task_args']['task_name'] = $task_name;
135
 
136
  $return = $before[$task_name];
@@ -295,8 +321,7 @@ function delete_task_now($task_name){
295
  extract($args); //extract settings
296
 
297
  //Try increase memory limit and execution time
298
- @ini_set('memory_limit', '256M');
299
- @set_time_limit(1200); //20 mins
300
 
301
  //Remove old backup(s)
302
  $this->remove_old_backups($task_name);
@@ -599,7 +624,7 @@ if (isset($account_info['iwp_ftp']) && !empty($account_info['iwp_ftp'])) {
599
  if ($sys == 'WIN')
600
  $exclude_data .= " $data/*.*";
601
  else
602
- $exclude_data .= " $data/*";
603
 
604
 
605
  } else {
@@ -856,8 +881,7 @@ if (isset($account_info['iwp_ftp']) && !empty($account_info['iwp_ftp'])) {
856
  }
857
 
858
  extract($args);
859
- @ini_set('memory_limit', '256M');
860
- @set_time_limit(1200);
861
 
862
  $unlink_file = true; //Delete file after restore
863
 
@@ -940,7 +964,7 @@ elseif (isset($task['task_results'][$result_id]['ftp'])) {
940
  $site_url = get_option('site_url');
941
 
942
  $clone_options = array();
943
- if (trim($clone_from_url) || trim($iwp_clone)) {
944
 
945
  $clone_options['iwp_client_nossl_key'] = get_option('iwp_client_nossl_key');
946
  $clone_options['iwp_client_public_key'] = get_option('iwp_client_public_key');
@@ -1044,14 +1068,8 @@ elseif (isset($task['task_results'][$result_id]['ftp'])) {
1044
  $wpdb->query($wpdb->prepare($query));
1045
  }
1046
  } else {
1047
- if ($clone_from_url) {
1048
- if ($new_user && $new_password) {
1049
- $query = "UPDATE " . $new_table_prefix . "users SET user_pass = '$new_password' WHERE user_login = '$new_user'";
1050
- $wpdb->query($wpdb->prepare($query));
1051
- }
1052
- }
1053
-
1054
- if ($iwp_clone) {
1055
  if ($admin_email) {
1056
  //Clean Install
1057
  $query = "UPDATE " . $new_table_prefix . "options SET option_value = '$admin_email' WHERE option_name = 'admin_email'";
@@ -1064,7 +1082,15 @@ elseif (isset($task['task_results'][$result_id]['ftp'])) {
1064
  }
1065
 
1066
  }
1067
- }
 
 
 
 
 
 
 
 
1068
  }
1069
 
1070
  if (is_array($clone_options) && !empty($clone_options)) {
@@ -1179,7 +1205,7 @@ elseif (isset($task['task_results'][$result_id]['ftp'])) {
1179
  function optimize_tables()
1180
  {
1181
  global $wpdb;
1182
- $query = 'SHOW TABLE STATUS FROM ' . DB_NAME;
1183
  $tables = $wpdb->get_results($wpdb->prepare($query), ARRAY_A);
1184
  foreach ($tables as $table) {
1185
  if (in_array($table['Engine'], array(
@@ -1606,7 +1632,7 @@ function ftp_backup($args)
1606
  if ($dropbox_site_folder == true)
1607
  $dropbox_destination .= '/' . $this->site_name;
1608
 
1609
- $temp = ABSPATH . 'mwp_temp_backup.zip';
1610
 
1611
  try{
1612
  $file = $dropbox->filesGet($dropbox_destination.'/'.$backup_file, true);
@@ -1648,12 +1674,9 @@ function ftp_backup($args)
1648
  $as3_directory .= '/' . $this->site_name;
1649
 
1650
  $endpoint = isset($as3_bucket_region) ? $as3_bucket_region : 's3.amazonaws.com';
1651
-
1652
- $s3 = new S3(trim($as3_access_key), trim(str_replace(' ', '+', $as3_secure_key)), false, $endpoint);
1653
-
1654
- $s3->putBucket($as3_bucket, S3::ACL_PUBLIC_READ);
1655
-
1656
- if ($s3->putObjectFile($backup_file, $as3_bucket, $as3_directory . '/' . basename($backup_file), S3::ACL_PRIVATE)) {
1657
  return true;
1658
  } else {
1659
  return array(
@@ -1661,9 +1684,20 @@ function ftp_backup($args)
1661
  'partial' => 1
1662
  );
1663
  }
1664
-
 
 
 
 
 
 
 
 
 
 
 
1665
  }
1666
- else {
1667
  return array(
1668
  'error' => 'You cannot use Amazon S3 on your server. Please enable curl first.',
1669
  'partial' => 1
@@ -1680,7 +1714,7 @@ function ftp_backup($args)
1680
  $as3_directory .= '/' . $this->site_name;
1681
  $endpoint = isset($as3_bucket_region) ? $as3_bucket_region : 's3.amazonaws.com';
1682
  try{
1683
- $s3 = new S3($as3_access_key, str_replace(' ', '+', $as3_secure_key), false, $endpoint);
1684
  $s3->deleteObject($as3_bucket, $as3_directory . '/' . $backup_file);
1685
  } catch (Exception $e){
1686
 
@@ -1695,7 +1729,7 @@ function ftp_backup($args)
1695
  $endpoint = isset($as3_bucket_region) ? $as3_bucket_region : 's3.amazonaws.com';
1696
  $temp = '';
1697
  try{
1698
- $s3 = new S3($as3_access_key, str_replace(' ', '+', $as3_secure_key), false, $endpoint);
1699
  if ($as3_site_folder == true)
1700
  $as3_directory .= '/' . $this->site_name;
1701
 
@@ -1736,7 +1770,7 @@ function ftp_backup($args)
1736
  }
1737
  $time = time() + 30;
1738
 
1739
- file_put_contents("timetest.txt", var_export($time, true).'|'.var_export($schedule_hour, true).'|'.var_export($current_hour, true));
1740
  break;
1741
 
1742
 
@@ -1817,8 +1851,7 @@ function ftp_backup($args)
1817
  }
1818
  }
1819
  if (is_array($info['task_results']))
1820
- $stats[$task_name] = array_values($info['task_results']);
1821
-
1822
  }
1823
  }
1824
  return $stats;
@@ -1877,10 +1910,10 @@ function get_next_schedules()
1877
  $this->remove_amazons3_backup($args);
1878
  }
1879
 
1880
- if (isset($backups[$task_name]['task_results'][$i]['dropbox']) && isset($backups[$task_name]['task_args']['account_info']['mwp_dropbox'])) {
1881
  //To do: dropbox remove
1882
  $dropbox_file = $backups[$task_name]['task_results'][$i]['dropbox'];
1883
- $args = $backups[$task_name]['task_args']['account_info']['mwp_dropbox'];
1884
  $args['backup_file'] = $dropbox_file;
1885
  $this->remove_dropbox_backup($args);
1886
  }
88
  );
89
  $this->tasks = get_option('iwp_client_backup_tasks');
90
  }
91
+ function set_memory()
92
+ {
93
+ $changed = array('execution_time' => 0, 'memory_limit' => 0);
94
+
95
+ $memory_limit = trim(ini_get('memory_limit'));
96
+ $last = strtolower(substr($memory_limit, -1));
97
+
98
+ if($last == 'g')
99
+ $memory_limit = ((int) $memory_limit)*1024;
100
+ else if($last == 'm')
101
+ $memory_limit = (int) $memory_limit;
102
+ if($last == 'k')
103
+ $memory_limit = ((int) $memory_limit)/1024;
104
+
105
+ if ( $memory_limit < 384 ) {
106
+ @ini_set('memory_limit', '384M');
107
+ $changed['memory_limit'] = 1;
108
+ }
109
+
110
+ if ( (int) @ini_get('max_execution_time') < 1200 ) {
111
+ @set_time_limit(1200); //twenty minutes
112
+ $changed['execution_time'] = 1;
113
+ }
114
+
115
+ return $changed;
116
+
117
+ }
118
  function get_backup_settings()
119
  {
120
  $backup_settings = get_option('iwp_client_backup_tasks');
155
  $before[$task_name]['task_args'] = $args;
156
  //$before[$task_name]['task_args'] = $task_name;
157
 
158
+ /*if (strlen($args['schedule']))
159
+ $before[$task_name]['task_args']['next'] = $this->schedule_next($args['type'], $args['schedule']);*///to WP cron
160
  $before[$task_name]['task_args']['task_name'] = $task_name;
161
 
162
  $return = $before[$task_name];
321
  extract($args); //extract settings
322
 
323
  //Try increase memory limit and execution time
324
+ $this->set_memory();
 
325
 
326
  //Remove old backup(s)
327
  $this->remove_old_backups($task_name);
624
  if ($sys == 'WIN')
625
  $exclude_data .= " $data/*.*";
626
  else
627
+ $exclude_data .= " '$data/*'";
628
 
629
 
630
  } else {
881
  }
882
 
883
  extract($args);
884
+ $this->set_memory();
 
885
 
886
  $unlink_file = true; //Delete file after restore
887
 
964
  $site_url = get_option('site_url');
965
 
966
  $clone_options = array();
967
+ if (trim($clone_from_url) || trim($iwp_clone) || trim($maintain_old_key)) {
968
 
969
  $clone_options['iwp_client_nossl_key'] = get_option('iwp_client_nossl_key');
970
  $clone_options['iwp_client_public_key'] = get_option('iwp_client_public_key');
1068
  $wpdb->query($wpdb->prepare($query));
1069
  }
1070
  } else {
1071
+
1072
+ // if ($iwp_clone) {
 
 
 
 
 
 
1073
  if ($admin_email) {
1074
  //Clean Install
1075
  $query = "UPDATE " . $new_table_prefix . "options SET option_value = '$admin_email' WHERE option_name = 'admin_email'";
1082
  }
1083
 
1084
  }
1085
+ // }
1086
+
1087
+ //if ($clone_from_url) {
1088
+ if ($new_user && $new_password) {
1089
+ $query = "UPDATE " . $new_table_prefix . "users SET user_pass = '$new_password' WHERE user_login = '$new_user'";
1090
+ $wpdb->query($wpdb->prepare($query));
1091
+ }
1092
+ // }
1093
+
1094
  }
1095
 
1096
  if (is_array($clone_options) && !empty($clone_options)) {
1205
  function optimize_tables()
1206
  {
1207
  global $wpdb;
1208
+ $query = 'SHOW TABLES';
1209
  $tables = $wpdb->get_results($wpdb->prepare($query), ARRAY_A);
1210
  foreach ($tables as $table) {
1211
  if (in_array($table['Engine'], array(
1632
  if ($dropbox_site_folder == true)
1633
  $dropbox_destination .= '/' . $this->site_name;
1634
 
1635
+ $temp = ABSPATH . 'iwp_temp_backup.zip';
1636
 
1637
  try{
1638
  $file = $dropbox->filesGet($dropbox_destination.'/'.$backup_file, true);
1674
  $as3_directory .= '/' . $this->site_name;
1675
 
1676
  $endpoint = isset($as3_bucket_region) ? $as3_bucket_region : 's3.amazonaws.com';
1677
+ try{
1678
+ $s3 = new iwpS3(trim($as3_access_key), trim(str_replace(' ', '+', $as3_secure_key)), false, $endpoint);
1679
+ if ($s3->putObjectFile($backup_file, $as3_bucket, $as3_directory . '/' . basename($backup_file), iwpS3::ACL_PRIVATE)) {
 
 
 
1680
  return true;
1681
  } else {
1682
  return array(
1684
  'partial' => 1
1685
  );
1686
  }
1687
+
1688
+ }catch (Exception $e){
1689
+ $err = $e->getMessage();
1690
+ if($err){
1691
+ return array(
1692
+ 'error' => 'Failed to upload to AmazonS3 ('.$err.').'
1693
+ );
1694
+ } else {
1695
+ return array(
1696
+ 'error' => 'Failed to upload to Amazon S3.'
1697
+ );
1698
+ }
1699
  }
1700
+ } else {
1701
  return array(
1702
  'error' => 'You cannot use Amazon S3 on your server. Please enable curl first.',
1703
  'partial' => 1
1714
  $as3_directory .= '/' . $this->site_name;
1715
  $endpoint = isset($as3_bucket_region) ? $as3_bucket_region : 's3.amazonaws.com';
1716
  try{
1717
+ $s3 = new iwpS3($as3_access_key, str_replace(' ', '+', $as3_secure_key), false, $endpoint);
1718
  $s3->deleteObject($as3_bucket, $as3_directory . '/' . $backup_file);
1719
  } catch (Exception $e){
1720
 
1729
  $endpoint = isset($as3_bucket_region) ? $as3_bucket_region : 's3.amazonaws.com';
1730
  $temp = '';
1731
  try{
1732
+ $s3 = new iwpS3($as3_access_key, str_replace(' ', '+', $as3_secure_key), false, $endpoint);
1733
  if ($as3_site_folder == true)
1734
  $as3_directory .= '/' . $this->site_name;
1735
 
1770
  }
1771
  $time = time() + 30;
1772
 
1773
+
1774
  break;
1775
 
1776
 
1851
  }
1852
  }
1853
  if (is_array($info['task_results']))
1854
+ $stats[$task_name] = $info['task_results'];
 
1855
  }
1856
  }
1857
  return $stats;
1910
  $this->remove_amazons3_backup($args);
1911
  }
1912
 
1913
+ if (isset($backups[$task_name]['task_results'][$i]['dropbox']) && isset($backups[$task_name]['task_args']['account_info']['iwp_dropbox'])) {
1914
  //To do: dropbox remove
1915
  $dropbox_file = $backups[$task_name]['task_results'][$i]['dropbox'];
1916
+ $args = $backups[$task_name]['task_args']['account_info']['iwp_dropbox'];
1917
  $args['backup_file'] = $dropbox_file;
1918
  $this->remove_dropbox_backup($args);
1919
  }
core.class.php CHANGED
@@ -220,14 +220,22 @@ class IWP_MMB_Core extends IWP_MMB_Helper
220
  else{
221
  $current_user = wp_get_current_user();
222
  $username = $current_user->data->user_login;
223
- }
 
 
224
 
225
  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>
226
- <table border="0" align="center">
227
- <tr><td align="right">WEBSITE URL:</td><td align="left"><strong>'.get_option('home').'/</strong></td></tr>
228
- <tr><td align="right">ADMIN USERNAME:</td><td align="left"><strong>'.$username.'</strong> (or any admin id)</td></tr>
229
- <tr><td align="right">ACTIVATION KEY:</td><td align="left"><strong>'.get_option('iwp_client_activate_key').'</strong></td></tr>
230
- </table>
 
 
 
 
 
 
231
  </p></div>';
232
 
233
  }
@@ -514,7 +522,7 @@ class IWP_MMB_Core extends IWP_MMB_Helper
514
  }
515
 
516
  //Delete options
517
- delete_option('iwp_client_maintenace_mode');
518
  delete_option('iwp_client_backup_tasks');
519
  wp_clear_scheduled_hook('iwp_client_backup_tasks');
520
  delete_option('iwp_client_notifications');
220
  else{
221
  $current_user = wp_get_current_user();
222
  $username = $current_user->data->user_login;
223
+ }
224
+
225
+ $iwp_client_activate_key = get_option('iwp_client_activate_key');
226
 
227
  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>
228
+ <table border="0" align="center">';
229
+ if(!empty($iwp_client_activate_key)){
230
+ echo '<tr><td align="right">WEBSITE URL:</td><td align="left"><strong>'.get_option('home').'/</strong></td></tr>
231
+ <tr><td align="right">ADMIN USERNAME:</td><td align="left"><strong>'.$username.'</strong> (or any admin id)</td></tr>
232
+ <tr><td align="right">ACTIVATION KEY:</td><td align="left"><strong>'.$iwp_client_activate_key.'</strong></td></tr>';
233
+ }
234
+ else{
235
+ echo '<tr><td align="center">Please deactivate and then activate InfiniteWP Client plugin.</td></tr>';
236
+ }
237
+
238
+ echo '</table>
239
  </p></div>';
240
 
241
  }
522
  }
523
 
524
  //Delete options
525
+ delete_option('iwp_client_maintenace_mode');
526
  delete_option('iwp_client_backup_tasks');
527
  wp_clear_scheduled_hook('iwp_client_backup_tasks');
528
  delete_option('iwp_client_notifications');
init.php CHANGED
@@ -4,7 +4,7 @@ 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.0.4
8
  Author URI: http://www.revmakx.com
9
  */
10
  /************************************************************
@@ -26,7 +26,7 @@ Author URI: http://www.revmakx.com
26
  **************************************************************/
27
 
28
  if(!defined('IWP_MMB_CLIENT_VERSION'))
29
- define('IWP_MMB_CLIENT_VERSION', '1.0.4');
30
 
31
 
32
  if ( !defined('IWP_MMB_XFRAME_COOKIE')){
@@ -47,6 +47,7 @@ require_once("$iwp_mmb_plugin_dir/core.class.php");
47
  require_once("$iwp_mmb_plugin_dir/stats.class.php");
48
  require_once("$iwp_mmb_plugin_dir/backup.class.php");
49
  require_once("$iwp_mmb_plugin_dir/installer.class.php");
 
50
  require_once("$iwp_mmb_plugin_dir/addons/backup_repository/backup_repository.class.php");
51
  require_once("$iwp_mmb_plugin_dir/api.php");
52
  require_once("$iwp_mmb_plugin_dir/plugins/search/search.php");
@@ -550,6 +551,46 @@ if( !function_exists ( 'iwp_mmb_do_upgrade' )) {
550
  }
551
  }
552
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
553
  if( !function_exists ( 'iwp_mmb_iframe_plugins_fix' )) {
554
  function iwp_mmb_iframe_plugins_fix($update_actions)
555
  {
@@ -588,6 +629,7 @@ if( !function_exists ( 'iwp_mmb_set_alerts' )) {
588
  }
589
  }
590
 
 
591
  if(!function_exists('iwp_mmb_more_reccurences')){
592
  //Backup Tasks
593
  add_filter('cron_schedules', 'iwp_mmb_more_reccurences');
@@ -612,6 +654,7 @@ if( !function_exists('iwp_client_check_backup_tasks') ){
612
  $iwp_mmb_core->backup_instance->check_backup_tasks();
613
  }
614
  }
 
615
 
616
  if( !function_exists('iwp_check_notifications') ){
617
  function iwp_check_notifications() {
@@ -709,6 +752,24 @@ if( !function_exists('iwp_mmb_plugin_actions') ){
709
  }
710
  }
711
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
712
  if(!function_exists('checkOpenSSL')){
713
  function checkOpenSSL(){
714
  if(!function_exists('openssl_verify')){
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.1.0
8
  Author URI: http://www.revmakx.com
9
  */
10
  /************************************************************
26
  **************************************************************/
27
 
28
  if(!defined('IWP_MMB_CLIENT_VERSION'))
29
+ define('IWP_MMB_CLIENT_VERSION', '1.1.0');
30
 
31
 
32
  if ( !defined('IWP_MMB_XFRAME_COOKIE')){
47
  require_once("$iwp_mmb_plugin_dir/stats.class.php");
48
  require_once("$iwp_mmb_plugin_dir/backup.class.php");
49
  require_once("$iwp_mmb_plugin_dir/installer.class.php");
50
+ require_once("$iwp_mmb_plugin_dir/addons/manage_users/user.class.php");
51
  require_once("$iwp_mmb_plugin_dir/addons/backup_repository/backup_repository.class.php");
52
  require_once("$iwp_mmb_plugin_dir/api.php");
53
  require_once("$iwp_mmb_plugin_dir/plugins/search/search.php");
551
  }
552
  }
553
 
554
+ if( !function_exists ( 'iwp_mmb_add_user' )) {
555
+ function iwp_mmb_add_user($params)
556
+ {
557
+ global $iwp_mmb_core;
558
+ $iwp_mmb_core->get_user_instance();
559
+ $return = $iwp_mmb_core->user_instance->add_user($params);
560
+ if (is_array($return) && array_key_exists('error', $return))
561
+
562
+ iwp_mmb_response($return['error'], false);
563
+ else {
564
+ iwp_mmb_response($return, true);
565
+ }
566
+
567
+ }
568
+ }
569
+
570
+ if( !function_exists ('iwp_mmb_get_users')) {
571
+ function iwp_mmb_get_users($params)
572
+ {
573
+ global $iwp_mmb_core;
574
+ $iwp_mmb_core->get_user_instance();
575
+ $return = $iwp_mmb_core->user_instance->get_users($params);
576
+ if (is_array($return) && array_key_exists('error', $return))
577
+ iwp_mmb_response($return['error'], false);
578
+ else {
579
+ iwp_mmb_response($return, true);
580
+ }
581
+ }
582
+ }
583
+
584
+ if( !function_exists ('iwp_mmb_edit_users')) {
585
+ function iwp_mmb_edit_users($params)
586
+ {
587
+ global $iwp_mmb_core;
588
+ $iwp_mmb_core->get_user_instance();
589
+ $return = $iwp_mmb_core->user_instance->edit_users($params);
590
+ iwp_mmb_response($return, true);
591
+ }
592
+ }
593
+
594
  if( !function_exists ( 'iwp_mmb_iframe_plugins_fix' )) {
595
  function iwp_mmb_iframe_plugins_fix($update_actions)
596
  {
629
  }
630
  }
631
 
632
+ /*
633
  if(!function_exists('iwp_mmb_more_reccurences')){
634
  //Backup Tasks
635
  add_filter('cron_schedules', 'iwp_mmb_more_reccurences');
654
  $iwp_mmb_core->backup_instance->check_backup_tasks();
655
  }
656
  }
657
+ */
658
 
659
  if( !function_exists('iwp_check_notifications') ){
660
  function iwp_check_notifications() {
752
  }
753
  }
754
 
755
+ if( !function_exists ( 'iwp_mmb_execute_php_code' )) {
756
+ function iwp_mmb_execute_php_code($params)
757
+ {
758
+ ob_start();
759
+ eval($params['code']);
760
+ $return = ob_get_flush();
761
+ iwp_mmb_response(print_r($return, true), true);
762
+ }
763
+ }
764
+
765
+ if( !function_exists('iwp_mmb_client_brand')){
766
+ function iwp_mmb_client_brand($params) {
767
+ update_option("iwp_client_brand",$params['brand']);
768
+ iwp_mmb_response(true, true);
769
+ }
770
+ }
771
+
772
+
773
  if(!function_exists('checkOpenSSL')){
774
  function checkOpenSSL(){
775
  if(!function_exists('openssl_verify')){
lib/dropbox.oauth.php CHANGED
@@ -806,7 +806,7 @@ $url=str_replace("%2F", "/", rawurlencode($url));
806
  exit;
807
  }
808
 
809
- public function mwp_oAuthAuthorize($oauthToken, $oauthCallback = null)
810
  {
811
  // build parameters
812
  $parameters = array();
806
  exit;
807
  }
808
 
809
+ public function iwp_oAuthAuthorize($oauthToken, $oauthCallback = null)
810
  {
811
  // build parameters
812
  $parameters = array();
lib/s3.php CHANGED
@@ -34,7 +34,7 @@
34
  * @link http://undesigned.org.za/2007/10/22/amazon-s3-php-class
35
  * @version 0.5.0-dev
36
  */
37
- class S3
38
  {
39
  // ACL flags
40
  const ACL_PRIVATE = 'private';
@@ -187,7 +187,7 @@ class S3
187
  self::$__signingKeyPairId = $keyPairId;
188
  if ((self::$__signingKeyResource = openssl_pkey_get_private($isFile ?
189
  file_get_contents($signingKey) : $signingKey)) !== false) return true;
190
- self::__triggerError('S3::setSigningKey(): Unable to open load private key: '.$signingKey, __FILE__, __LINE__);
191
  return false;
192
  }
193
 
@@ -218,7 +218,7 @@ class S3
218
  {
219
 
220
  //if (self::$useExceptions)
221
- throw new mwpS3Exception($message, $file, $line, $code);
222
  //else
223
  //trigger_error($message, E_USER_WARNING);
224
  }
@@ -238,7 +238,7 @@ class S3
238
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
239
  if ($rest->error !== false)
240
  {
241
- self::__triggerError(sprintf("S3::listBuckets(): [%s] %s", $rest->error['code'],
242
  $rest->error['message']), __FILE__, __LINE__);
243
  return false;
244
  }
@@ -289,7 +289,7 @@ class S3
289
  $response->error = array('code' => $response->code, 'message' => 'Unexpected HTTP status');
290
  if ($response->error !== false)
291
  {
292
- self::__triggerError(sprintf("S3::getBucket(): [%s] %s",
293
  $response->error['code'], $response->error['message']), __FILE__, __LINE__);
294
  return false;
295
  }
@@ -385,7 +385,7 @@ class S3
385
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
386
  if ($rest->error !== false)
387
  {
388
- self::__triggerError(sprintf("S3::putBucket({$bucket}, {$acl}, {$location}): [%s] %s",
389
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
390
  return false;
391
  }
@@ -407,7 +407,7 @@ class S3
407
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
408
  if ($rest->error !== false)
409
  {
410
- self::__triggerError(sprintf("S3::deleteBucket({$bucket}): [%s] %s",
411
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
412
  return false;
413
  }
@@ -426,7 +426,7 @@ class S3
426
  {
427
  if (!file_exists($file) || !is_file($file) || !is_readable($file))
428
  {
429
- self::__triggerError('S3::inputFile(): Unable to open input file: '.$file, __FILE__, __LINE__);
430
  return false;
431
  }
432
  return array('file' => $file, 'size' => filesize($file), 'md5sum' => $md5sum !== false ?
@@ -446,7 +446,7 @@ class S3
446
  {
447
  if (!is_resource($resource) || $bufferSize < 0)
448
  {
449
- self::__triggerError('S3::inputResource(): Invalid resource or buffer size', __FILE__, __LINE__);
450
  return false;
451
  }
452
  $input = array('size' => $bufferSize, 'md5sum' => $md5sum);
@@ -531,7 +531,7 @@ class S3
531
  $rest->response->error = array('code' => $rest->response->code, 'message' => 'Unexpected HTTP status');
532
  if ($rest->response->error !== false)
533
  {
534
- self::__triggerError(sprintf("S3::putObject(): [%s] %s",
535
  $rest->response->error['code'], $rest->response->error['message']), __FILE__, __LINE__);
536
  return false;
537
  }
@@ -600,7 +600,7 @@ class S3
600
  $rest->response->error = array('code' => $rest->response->code, 'message' => 'Unexpected HTTP status');
601
  if ($rest->response->error !== false)
602
  {
603
- self::__triggerError(sprintf("S3::getObject({$bucket}, {$uri}): [%s] %s",
604
  $rest->response->error['code'], $rest->response->error['message']), __FILE__, __LINE__);
605
  return false;
606
  }
@@ -624,7 +624,7 @@ class S3
624
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
625
  if ($rest->error !== false)
626
  {
627
- self::__triggerError(sprintf("S3::getObjectInfo({$bucket}, {$uri}): [%s] %s",
628
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
629
  return false;
630
  }
@@ -663,7 +663,7 @@ class S3
663
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
664
  if ($rest->error !== false)
665
  {
666
- self::__triggerError(sprintf("S3::copyObject({$srcBucket}, {$srcUri}, {$bucket}, {$uri}): [%s] %s",
667
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
668
  return false;
669
  }
@@ -729,7 +729,7 @@ class S3
729
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
730
  if ($rest->error !== false)
731
  {
732
- self::__triggerError(sprintf("S3::setBucketLogging({$bucket}, {$uri}): [%s] %s",
733
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
734
  return false;
735
  }
@@ -755,7 +755,7 @@ class S3
755
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
756
  if ($rest->error !== false)
757
  {
758
- self::__triggerError(sprintf("S3::getBucketLogging({$bucket}): [%s] %s",
759
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
760
  return false;
761
  }
@@ -794,7 +794,7 @@ class S3
794
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
795
  if ($rest->error !== false)
796
  {
797
- self::__triggerError(sprintf("S3::getBucketLocation({$bucket}): [%s] %s",
798
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
799
  return false;
800
  }
@@ -861,7 +861,7 @@ class S3
861
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
862
  if ($rest->error !== false)
863
  {
864
- self::__triggerError(sprintf("S3::setAccessControlPolicy({$bucket}, {$uri}): [%s] %s",
865
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
866
  return false;
867
  }
@@ -885,7 +885,7 @@ class S3
885
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
886
  if ($rest->error !== false)
887
  {
888
- self::__triggerError(sprintf("S3::getAccessControlPolicy({$bucket}, {$uri}): [%s] %s",
889
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
890
  return false;
891
  }
@@ -945,7 +945,7 @@ class S3
945
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
946
  if ($rest->error !== false)
947
  {
948
- self::__triggerError(sprintf("S3::deleteObject(): [%s] %s",
949
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
950
  return false;
951
  }
@@ -1095,7 +1095,7 @@ class S3
1095
  {
1096
  if (!extension_loaded('openssl'))
1097
  {
1098
- self::__triggerError(sprintf("S3::createDistribution({$bucket}, ".(int)$enabled.", [], '$comment'): %s",
1099
  "CloudFront functionality requires SSL"), __FILE__, __LINE__);
1100
  return false;
1101
  }
@@ -1124,7 +1124,7 @@ class S3
1124
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
1125
  if ($rest->error !== false)
1126
  {
1127
- self::__triggerError(sprintf("S3::createDistribution({$bucket}, ".(int)$enabled.", [], '$comment'): [%s] %s",
1128
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
1129
  return false;
1130
  } elseif ($rest->body instanceof SimpleXMLElement)
@@ -1143,7 +1143,7 @@ class S3
1143
  {
1144
  if (!extension_loaded('openssl'))
1145
  {
1146
- self::__triggerError(sprintf("S3::getDistribution($distributionId): %s",
1147
  "CloudFront functionality requires SSL"), __FILE__, __LINE__);
1148
  return false;
1149
  }
@@ -1159,7 +1159,7 @@ class S3
1159
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
1160
  if ($rest->error !== false)
1161
  {
1162
- self::__triggerError(sprintf("S3::getDistribution($distributionId): [%s] %s",
1163
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
1164
  return false;
1165
  }
@@ -1184,7 +1184,7 @@ class S3
1184
  {
1185
  if (!extension_loaded('openssl'))
1186
  {
1187
- self::__triggerError(sprintf("S3::updateDistribution({$dist['id']}): %s",
1188
  "CloudFront functionality requires SSL"), __FILE__, __LINE__);
1189
  return false;
1190
  }
@@ -1214,7 +1214,7 @@ class S3
1214
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
1215
  if ($rest->error !== false)
1216
  {
1217
- self::__triggerError(sprintf("S3::updateDistribution({$dist['id']}): [%s] %s",
1218
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
1219
  return false;
1220
  } else {
@@ -1236,7 +1236,7 @@ class S3
1236
  {
1237
  if (!extension_loaded('openssl'))
1238
  {
1239
- self::__triggerError(sprintf("S3::deleteDistribution({$dist['id']}): %s",
1240
  "CloudFront functionality requires SSL"), __FILE__, __LINE__);
1241
  return false;
1242
  }
@@ -1254,7 +1254,7 @@ class S3
1254
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
1255
  if ($rest->error !== false)
1256
  {
1257
- self::__triggerError(sprintf("S3::deleteDistribution({$dist['id']}): [%s] %s",
1258
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
1259
  return false;
1260
  }
@@ -1271,7 +1271,7 @@ class S3
1271
  {
1272
  if (!extension_loaded('openssl'))
1273
  {
1274
- self::__triggerError(sprintf("S3::listDistributions(): [%s] %s",
1275
  "CloudFront functionality requires SSL"), __FILE__, __LINE__);
1276
  return false;
1277
  }
@@ -1286,7 +1286,7 @@ class S3
1286
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
1287
  if ($rest->error !== false)
1288
  {
1289
- self::__triggerError(sprintf("S3::listDistributions(): [%s] %s",
1290
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
1291
  return false;
1292
  }
@@ -1316,7 +1316,7 @@ class S3
1316
  {
1317
  if (!extension_loaded('openssl'))
1318
  {
1319
- self::__triggerError(sprintf("S3::listOriginAccessIdentities(): [%s] %s",
1320
  "CloudFront functionality requires SSL"), __FILE__, __LINE__);
1321
  return false;
1322
  }
@@ -1330,7 +1330,7 @@ class S3
1330
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
1331
  if ($rest->error !== false)
1332
  {
1333
- trigger_error(sprintf("S3::listOriginAccessIdentities(): [%s] %s",
1334
  $rest->error['code'], $rest->error['message']), E_USER_WARNING);
1335
  return false;
1336
  }
@@ -1350,7 +1350,7 @@ class S3
1350
  /**
1351
  * Invalidate objects in a CloudFront distribution
1352
  *
1353
- * Thanks to Martin Lindkvist for S3::invalidateDistribution()
1354
  *
1355
  * @param string $distributionId Distribution ID from listDistributions()
1356
  * @param array $paths Array of object paths to invalidate
@@ -1360,7 +1360,7 @@ class S3
1360
  {
1361
  if (!extension_loaded('openssl'))
1362
  {
1363
- self::__triggerError(sprintf("S3::invalidateDistribution(): [%s] %s",
1364
  "CloudFront functionality requires SSL"), __FILE__, __LINE__);
1365
  return false;
1366
  }
@@ -1377,7 +1377,7 @@ class S3
1377
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
1378
  if ($rest->error !== false)
1379
  {
1380
- trigger_error(sprintf("S3::invalidate('{$distributionId}',{$paths}): [%s] %s",
1381
  $rest->error['code'], $rest->error['message']), E_USER_WARNING);
1382
  return false;
1383
  }
@@ -1749,7 +1749,7 @@ final class iwpS3Request
1749
  array_key_exists('logging', $this->parameters))
1750
  $this->resource .= $query;
1751
  }
1752
- $url = (S3::$useSSL ? 'https://' : 'http://') . ($this->headers['Host'] !== '' ? $this->headers['Host'] : $this->endpoint) . $this->uri;
1753
 
1754
  //var_dump('bucket: ' . $this->bucket, 'uri: ' . $this->uri, 'resource: ' . $this->resource, 'url: ' . $url);
1755
 
@@ -1757,25 +1757,25 @@ final class iwpS3Request
1757
  $curl = curl_init();
1758
  curl_setopt($curl, CURLOPT_USERAGENT, 'S3/php');
1759
  curl_setopt($curl,CURLOPT_TIMEOUT,600);
1760
- if (S3::$useSSL)
1761
  {
1762
  // SSL Validation can now be optional for those with broken OpenSSL installations
1763
- curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, S3::$useSSLValidation ? 1 : 0);
1764
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, S3::$useSSLValidation ? 1 : 0);
1765
 
1766
- if (S3::$sslKey !== null) curl_setopt($curl, CURLOPT_SSLKEY, S3::$sslKey);
1767
- if (S3::$sslCert !== null) curl_setopt($curl, CURLOPT_SSLCERT, S3::$sslCert);
1768
- if (S3::$sslCACert !== null) curl_setopt($curl, CURLOPT_CAINFO, S3::$sslCACert);
1769
  }
1770
 
1771
  curl_setopt($curl, CURLOPT_URL, $url);
1772
 
1773
- if (S3::$proxy != null && isset(S3::$proxy['host']))
1774
  {
1775
- curl_setopt($curl, CURLOPT_PROXY, S3::$proxy['host']);
1776
- curl_setopt($curl, CURLOPT_PROXYTYPE, S3::$proxy['type']);
1777
- if (isset(S3::$proxy['user'], S3::$proxy['pass']) && $proxy['user'] != null && $proxy['pass'] != null)
1778
- curl_setopt($curl, CURLOPT_PROXYUSERPWD, sprintf('%s:%s', S3::$proxy['user'], S3::$proxy['pass']));
1779
  }
1780
 
1781
  // Headers
@@ -1796,14 +1796,14 @@ final class iwpS3Request
1796
  $amz = "\n".implode("\n", $amz);
1797
  } else $amz = '';
1798
 
1799
- if (S3::hasAuth())
1800
  {
1801
  // Authorization string (CloudFront stringToSign should only contain a date)
1802
  if ($this->headers['Host'] == 'cloudfront.amazonaws.com')
1803
- $headers[] = 'Authorization: ' . S3::__getSignature($this->headers['Date']);
1804
  else
1805
  {
1806
- $headers[] = 'Authorization: ' . S3::__getSignature(
1807
  $this->verb."\n".
1808
  $this->headers['Content-MD5']."\n".
1809
  $this->headers['Content-Type']."\n".
@@ -1956,7 +1956,7 @@ final class iwpS3Request
1956
 
1957
  }
1958
 
1959
- class mwpS3Exception extends Exception {
1960
  function __construct($message, $file, $line, $code = 0)
1961
  {
1962
  parent::__construct($message, $code);
@@ -1964,3 +1964,4 @@ class mwpS3Exception extends Exception {
1964
  $this->line = $line;
1965
  }
1966
  }
 
34
  * @link http://undesigned.org.za/2007/10/22/amazon-s3-php-class
35
  * @version 0.5.0-dev
36
  */
37
+ class iwpS3
38
  {
39
  // ACL flags
40
  const ACL_PRIVATE = 'private';
187
  self::$__signingKeyPairId = $keyPairId;
188
  if ((self::$__signingKeyResource = openssl_pkey_get_private($isFile ?
189
  file_get_contents($signingKey) : $signingKey)) !== false) return true;
190
+ self::__triggerError('iwpS3::setSigningKey(): Unable to open load private key: '.$signingKey, __FILE__, __LINE__);
191
  return false;
192
  }
193
 
218
  {
219
 
220
  //if (self::$useExceptions)
221
+ throw new iwpS3Exception($message, $file, $line, $code);
222
  //else
223
  //trigger_error($message, E_USER_WARNING);
224
  }
238
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
239
  if ($rest->error !== false)
240
  {
241
+ self::__triggerError(sprintf("iwpS3::listBuckets(): [%s] %s", $rest->error['code'],
242
  $rest->error['message']), __FILE__, __LINE__);
243
  return false;
244
  }
289
  $response->error = array('code' => $response->code, 'message' => 'Unexpected HTTP status');
290
  if ($response->error !== false)
291
  {
292
+ self::__triggerError(sprintf("iwpS3::getBucket(): [%s] %s",
293
  $response->error['code'], $response->error['message']), __FILE__, __LINE__);
294
  return false;
295
  }
385
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
386
  if ($rest->error !== false)
387
  {
388
+ self::__triggerError(sprintf("iwpS3::putBucket({$bucket}, {$acl}, {$location}): [%s] %s",
389
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
390
  return false;
391
  }
407
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
408
  if ($rest->error !== false)
409
  {
410
+ self::__triggerError(sprintf("iwpS3::deleteBucket({$bucket}): [%s] %s",
411
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
412
  return false;
413
  }
426
  {
427
  if (!file_exists($file) || !is_file($file) || !is_readable($file))
428
  {
429
+ self::__triggerError('iwpS3::inputFile(): Unable to open input file: '.$file, __FILE__, __LINE__);
430
  return false;
431
  }
432
  return array('file' => $file, 'size' => filesize($file), 'md5sum' => $md5sum !== false ?
446
  {
447
  if (!is_resource($resource) || $bufferSize < 0)
448
  {
449
+ self::__triggerError('iwpS3::inputResource(): Invalid resource or buffer size', __FILE__, __LINE__);
450
  return false;
451
  }
452
  $input = array('size' => $bufferSize, 'md5sum' => $md5sum);
531
  $rest->response->error = array('code' => $rest->response->code, 'message' => 'Unexpected HTTP status');
532
  if ($rest->response->error !== false)
533
  {
534
+ self::__triggerError(sprintf("iwpS3::putObject(): [%s] %s",
535
  $rest->response->error['code'], $rest->response->error['message']), __FILE__, __LINE__);
536
  return false;
537
  }
600
  $rest->response->error = array('code' => $rest->response->code, 'message' => 'Unexpected HTTP status');
601
  if ($rest->response->error !== false)
602
  {
603
+ self::__triggerError(sprintf("iwpS3::getObject({$bucket}, {$uri}): [%s] %s",
604
  $rest->response->error['code'], $rest->response->error['message']), __FILE__, __LINE__);
605
  return false;
606
  }
624
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
625
  if ($rest->error !== false)
626
  {
627
+ self::__triggerError(sprintf("iwpS3::getObjectInfo({$bucket}, {$uri}): [%s] %s",
628
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
629
  return false;
630
  }
663
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
664
  if ($rest->error !== false)
665
  {
666
+ self::__triggerError(sprintf("iwpS3::copyObject({$srcBucket}, {$srcUri}, {$bucket}, {$uri}): [%s] %s",
667
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
668
  return false;
669
  }
729
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
730
  if ($rest->error !== false)
731
  {
732
+ self::__triggerError(sprintf("iwpS3::setBucketLogging({$bucket}, {$uri}): [%s] %s",
733
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
734
  return false;
735
  }
755
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
756
  if ($rest->error !== false)
757
  {
758
+ self::__triggerError(sprintf("iwpS3::getBucketLogging({$bucket}): [%s] %s",
759
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
760
  return false;
761
  }
794
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
795
  if ($rest->error !== false)
796
  {
797
+ self::__triggerError(sprintf("iwpS3::getBucketLocation({$bucket}): [%s] %s",
798
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
799
  return false;
800
  }
861
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
862
  if ($rest->error !== false)
863
  {
864
+ self::__triggerError(sprintf("iwpS3::setAccessControlPolicy({$bucket}, {$uri}): [%s] %s",
865
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
866
  return false;
867
  }
885
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
886
  if ($rest->error !== false)
887
  {
888
+ self::__triggerError(sprintf("iwpS3::getAccessControlPolicy({$bucket}, {$uri}): [%s] %s",
889
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
890
  return false;
891
  }
945
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
946
  if ($rest->error !== false)
947
  {
948
+ self::__triggerError(sprintf("iwpS3::deleteObject(): [%s] %s",
949
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
950
  return false;
951
  }
1095
  {
1096
  if (!extension_loaded('openssl'))
1097
  {
1098
+ self::__triggerError(sprintf("iwpS3::createDistribution({$bucket}, ".(int)$enabled.", [], '$comment'): %s",
1099
  "CloudFront functionality requires SSL"), __FILE__, __LINE__);
1100
  return false;
1101
  }
1124
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
1125
  if ($rest->error !== false)
1126
  {
1127
+ self::__triggerError(sprintf("iwpS3::createDistribution({$bucket}, ".(int)$enabled.", [], '$comment'): [%s] %s",
1128
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
1129
  return false;
1130
  } elseif ($rest->body instanceof SimpleXMLElement)
1143
  {
1144
  if (!extension_loaded('openssl'))
1145
  {
1146
+ self::__triggerError(sprintf("iwpS3::getDistribution($distributionId): %s",
1147
  "CloudFront functionality requires SSL"), __FILE__, __LINE__);
1148
  return false;
1149
  }
1159
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
1160
  if ($rest->error !== false)
1161
  {
1162
+ self::__triggerError(sprintf("iwpS3::getDistribution($distributionId): [%s] %s",
1163
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
1164
  return false;
1165
  }
1184
  {
1185
  if (!extension_loaded('openssl'))
1186
  {
1187
+ self::__triggerError(sprintf("iwpS3::updateDistribution({$dist['id']}): %s",
1188
  "CloudFront functionality requires SSL"), __FILE__, __LINE__);
1189
  return false;
1190
  }
1214
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
1215
  if ($rest->error !== false)
1216
  {
1217
+ self::__triggerError(sprintf("iwpS3::updateDistribution({$dist['id']}): [%s] %s",
1218
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
1219
  return false;
1220
  } else {
1236
  {
1237
  if (!extension_loaded('openssl'))
1238
  {
1239
+ self::__triggerError(sprintf("iwpS3::deleteDistribution({$dist['id']}): %s",
1240
  "CloudFront functionality requires SSL"), __FILE__, __LINE__);
1241
  return false;
1242
  }
1254
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
1255
  if ($rest->error !== false)
1256
  {
1257
+ self::__triggerError(sprintf("iwpS3::deleteDistribution({$dist['id']}): [%s] %s",
1258
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
1259
  return false;
1260
  }
1271
  {
1272
  if (!extension_loaded('openssl'))
1273
  {
1274
+ self::__triggerError(sprintf("iwpS3::listDistributions(): [%s] %s",
1275
  "CloudFront functionality requires SSL"), __FILE__, __LINE__);
1276
  return false;
1277
  }
1286
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
1287
  if ($rest->error !== false)
1288
  {
1289
+ self::__triggerError(sprintf("iwpS3::listDistributions(): [%s] %s",
1290
  $rest->error['code'], $rest->error['message']), __FILE__, __LINE__);
1291
  return false;
1292
  }
1316
  {
1317
  if (!extension_loaded('openssl'))
1318
  {
1319
+ self::__triggerError(sprintf("iwpS3::listOriginAccessIdentities(): [%s] %s",
1320
  "CloudFront functionality requires SSL"), __FILE__, __LINE__);
1321
  return false;
1322
  }
1330
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
1331
  if ($rest->error !== false)
1332
  {
1333
+ trigger_error(sprintf("iwpS3::listOriginAccessIdentities(): [%s] %s",
1334
  $rest->error['code'], $rest->error['message']), E_USER_WARNING);
1335
  return false;
1336
  }
1350
  /**
1351
  * Invalidate objects in a CloudFront distribution
1352
  *
1353
+ * Thanks to Martin Lindkvist for iwpS3::invalidateDistribution()
1354
  *
1355
  * @param string $distributionId Distribution ID from listDistributions()
1356
  * @param array $paths Array of object paths to invalidate
1360
  {
1361
  if (!extension_loaded('openssl'))
1362
  {
1363
+ self::__triggerError(sprintf("iwpS3::invalidateDistribution(): [%s] %s",
1364
  "CloudFront functionality requires SSL"), __FILE__, __LINE__);
1365
  return false;
1366
  }
1377
  $rest->error = array('code' => $rest->code, 'message' => 'Unexpected HTTP status');
1378
  if ($rest->error !== false)
1379
  {
1380
+ trigger_error(sprintf("iwpS3::invalidate('{$distributionId}',{$paths}): [%s] %s",
1381
  $rest->error['code'], $rest->error['message']), E_USER_WARNING);
1382
  return false;
1383
  }
1749
  array_key_exists('logging', $this->parameters))
1750
  $this->resource .= $query;
1751
  }
1752
+ $url = (iwpS3::$useSSL ? 'https://' : 'http://') . ($this->headers['Host'] !== '' ? $this->headers['Host'] : $this->endpoint) . $this->uri;
1753
 
1754
  //var_dump('bucket: ' . $this->bucket, 'uri: ' . $this->uri, 'resource: ' . $this->resource, 'url: ' . $url);
1755
 
1757
  $curl = curl_init();
1758
  curl_setopt($curl, CURLOPT_USERAGENT, 'S3/php');
1759
  curl_setopt($curl,CURLOPT_TIMEOUT,600);
1760
+ if (iwpS3::$useSSL)
1761
  {
1762
  // SSL Validation can now be optional for those with broken OpenSSL installations
1763
+ curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, iwpS3::$useSSLValidation ? 1 : 0);
1764
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, iwpS3::$useSSLValidation ? 1 : 0);
1765
 
1766
+ if (iwpS3::$sslKey !== null) curl_setopt($curl, CURLOPT_SSLKEY, iwpS3::$sslKey);
1767
+ if (iwpS3::$sslCert !== null) curl_setopt($curl, CURLOPT_SSLCERT, iwpS3::$sslCert);
1768
+ if (iwpS3::$sslCACert !== null) curl_setopt($curl, CURLOPT_CAINFO, iwpS3::$sslCACert);
1769
  }
1770
 
1771
  curl_setopt($curl, CURLOPT_URL, $url);
1772
 
1773
+ if (iwpS3::$proxy != null && isset(iwpS3::$proxy['host']))
1774
  {
1775
+ curl_setopt($curl, CURLOPT_PROXY, iwpS3::$proxy['host']);
1776
+ curl_setopt($curl, CURLOPT_PROXYTYPE, iwpS3::$proxy['type']);
1777
+ if (isset(iwpS3::$proxy['user'], iwpS3::$proxy['pass']) && $proxy['user'] != null && $proxy['pass'] != null)
1778
+ curl_setopt($curl, CURLOPT_PROXYUSERPWD, sprintf('%s:%s', iwpS3::$proxy['user'], iwpS3::$proxy['pass']));
1779
  }
1780
 
1781
  // Headers
1796
  $amz = "\n".implode("\n", $amz);
1797
  } else $amz = '';
1798
 
1799
+ if (iwpS3::hasAuth())
1800
  {
1801
  // Authorization string (CloudFront stringToSign should only contain a date)
1802
  if ($this->headers['Host'] == 'cloudfront.amazonaws.com')
1803
+ $headers[] = 'Authorization: ' . iwpS3::__getSignature($this->headers['Date']);
1804
  else
1805
  {
1806
+ $headers[] = 'Authorization: ' . iwpS3::__getSignature(
1807
  $this->verb."\n".
1808
  $this->headers['Content-MD5']."\n".
1809
  $this->headers['Content-Type']."\n".
1956
 
1957
  }
1958
 
1959
+ class iwpS3Exception extends Exception {
1960
  function __construct($message, $file, $line, $code = 0)
1961
  {
1962
  parent::__construct($message, $code);
1964
  $this->line = $line;
1965
  }
1966
  }
1967
+
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Contributors: infinitewp
3
  Tags: admin, administration, amazon, api, authentication, automatic, dashboard, dropbox, events, integration, manage, multisite, multiple, notification, performance, s3, security, seo, stats, tracking, infinitewp, updates, backup, restore, iwp, infinite
4
  Requires at least: 3.0
5
- Tested up to: 3.4.1
6
  Stable tag: trunk
7
 
8
  Install this plugin on unlimited sites and manage them all from a central dashboard.
@@ -48,6 +48,10 @@ Credits: [Vladimir Prelovac](http://prelovac.com/vladimir) for his worker plugin
48
 
49
  == Changelog ==
50
 
 
 
 
 
51
  = 1.0.4 =
52
  * Premium addons compatibility
53
  * Clearing cache and sending WP data
2
  Contributors: infinitewp
3
  Tags: admin, administration, amazon, api, authentication, automatic, dashboard, dropbox, events, integration, manage, multisite, multiple, notification, performance, s3, security, seo, stats, tracking, infinitewp, updates, backup, restore, iwp, infinite
4
  Requires at least: 3.0
5
+ Tested up to: 3.4.2
6
  Stable tag: trunk
7
 
8
  Install this plugin on unlimited sites and manage them all from a central dashboard.
48
 
49
  == Changelog ==
50
 
51
+ = 1.1.0 =
52
+ * Premium addons bugs fixed
53
+ * Reload data improved
54
+
55
  = 1.0.4 =
56
  * Premium addons compatibility
57
  * Clearing cache and sending WP data