Version Description
- Old backups retained when a site is restored
- Compatible with Better WP Security
- Compatible with WP Engine
- Improved backups
- Bug fixes
Download this release
Release Info
Developer | infinitewp |
Plugin | InfiniteWP Client |
Version | 1.1.7 |
Comparing to | |
See all releases |
Code changes from version 1.1.6 to 1.1.7
- addons/comments/comments.class.php +256 -0
- addons/post_links/link.class.php +182 -0
- addons/post_links/post.class.php +773 -0
- backup.class.php +106 -63
- core.class.php +745 -711
- helper.class.php +1 -1
- init.php +287 -4
- installer.class.php +1 -1
- lib/dropbox.php +6 -6
- readme.txt +8 -1
- stats.class.php +28 -5
addons/comments/comments.class.php
ADDED
@@ -0,0 +1,256 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*************************************************************
|
3 |
+
*
|
4 |
+
* comment.class.php
|
5 |
+
*
|
6 |
+
* Get comments
|
7 |
+
*
|
8 |
+
*
|
9 |
+
* Copyright (c) 2011 Prelovac Media
|
10 |
+
* www.prelovac.com
|
11 |
+
**************************************************************/
|
12 |
+
if(basename($_SERVER['SCRIPT_FILENAME']) == "comments.class.php"):
|
13 |
+
exit;
|
14 |
+
endif;
|
15 |
+
class IWP_MMB_Comment extends IWP_MMB_Core
|
16 |
+
{
|
17 |
+
function __construct()
|
18 |
+
{
|
19 |
+
parent::__construct();
|
20 |
+
}
|
21 |
+
|
22 |
+
function change_status($args)
|
23 |
+
{
|
24 |
+
|
25 |
+
global $wpdb;
|
26 |
+
$comment_id = $args['comment_id'];
|
27 |
+
$status = $args['status'];
|
28 |
+
|
29 |
+
if ( 'approve' == $status )
|
30 |
+
$status_sql = '1';
|
31 |
+
elseif ( 'unapprove' == $status )
|
32 |
+
$status_sql = '0';
|
33 |
+
elseif ( 'spam' == $status )
|
34 |
+
$status_sql = 'spam';
|
35 |
+
elseif ( 'trash' == $status )
|
36 |
+
$status_sql = 'trash';
|
37 |
+
$sql = "update ".$wpdb->prefix."comments set comment_approved = '%s' where comment_ID = '%s'";
|
38 |
+
$success = $wpdb->query($wpdb->prepare($sql, $status_sql, $comment_id));
|
39 |
+
|
40 |
+
|
41 |
+
return $success;
|
42 |
+
}
|
43 |
+
|
44 |
+
function get_comments($args){
|
45 |
+
|
46 |
+
global $wpdb;
|
47 |
+
|
48 |
+
$where='';
|
49 |
+
|
50 |
+
extract($args);
|
51 |
+
|
52 |
+
if(!empty($filter_comments))
|
53 |
+
{
|
54 |
+
$where.=" AND (c.comment_author LIKE '%".mysql_real_escape_string($filter_comments)."%' OR c.comment_content LIKE '%".mysql_real_escape_string($filter_comments)."%')";
|
55 |
+
}
|
56 |
+
$comment_array = array();
|
57 |
+
$comment_statuses = array('approved', 'pending', 'spam', 'trash');
|
58 |
+
foreach ($args as $checkbox => $checkbox_val)
|
59 |
+
{
|
60 |
+
if($checkbox_val=="on") {
|
61 |
+
$status_val = str_replace("iwp_get_comments_","",$checkbox);
|
62 |
+
if($status_val == 'approved'){
|
63 |
+
$status_val = 1;
|
64 |
+
}elseif($status_val == 'pending'){
|
65 |
+
$status_val = 0;
|
66 |
+
}
|
67 |
+
$comment_array[]="'".$status_val."'";
|
68 |
+
}
|
69 |
+
}
|
70 |
+
if(!empty($comment_array))
|
71 |
+
{
|
72 |
+
$where.=" AND c.comment_approved IN (".implode(",",$comment_array).")";
|
73 |
+
}
|
74 |
+
|
75 |
+
$sql_query = "$wpdb->comments as c, $wpdb->posts as p WHERE c.comment_post_ID = p.ID ".$where;
|
76 |
+
|
77 |
+
$comments_total = $wpdb->get_results("SELECT count(*) as total_comments FROM ".$sql_query);
|
78 |
+
$total=$comments_total[0]->total_comments;
|
79 |
+
$comments_approved = $this->comment_total();
|
80 |
+
|
81 |
+
$query_comments = $wpdb->get_results("SELECT c.comment_ID, c.comment_post_ID, c.comment_author, c.comment_author_email, c.comment_author_url, c.comment_author_IP, c.comment_date, c.comment_content, c.comment_approved, c.comment_parent, p.post_title, p.post_type, p.guid FROM ".$sql_query." ORDER BY c.comment_date DESC LIMIT 500");
|
82 |
+
$comments = array();
|
83 |
+
foreach ( $query_comments as $comments_info )
|
84 |
+
{
|
85 |
+
$comment_total_approved = 0;
|
86 |
+
if(isset($comments_approved[$comments_info->comment_post_ID]['approved'])){
|
87 |
+
$comment_total_approved = $comments_approved[$comments_info->comment_post_ID]['approved'];
|
88 |
+
}
|
89 |
+
$comment_total_pending = 0;
|
90 |
+
if(isset($comments_approved[$comments_info->comment_post_ID]['pending'])){
|
91 |
+
$comment_total_pending = $comments_approved[$comments_info->comment_post_ID]['pending'];
|
92 |
+
}
|
93 |
+
$comment_parent_author = '';
|
94 |
+
if($comments_info->comment_parent > 0){
|
95 |
+
$select_parent_author = "SELECT comment_author FROM $wpdb->comments WHERE comment_ID = ".$comments_info->comment_parent;
|
96 |
+
$select_parent_author_res = $wpdb->get_row($select_parent_author);
|
97 |
+
$comment_parent_author = $select_parent_author_res->comment_author;
|
98 |
+
}
|
99 |
+
|
100 |
+
$comments[$comments_info->comment_ID] = array(
|
101 |
+
"comment_post_ID" => $comments_info->comment_post_ID,
|
102 |
+
"comment_author" => $comments_info->comment_author,
|
103 |
+
"comment_author_email" => $comments_info->comment_author_email,
|
104 |
+
"comment_author_url" => $comments_info->comment_author_url,
|
105 |
+
"comment_author_IP" => $comments_info->comment_author_IP,
|
106 |
+
"comment_date" => $comments_info->comment_date,
|
107 |
+
"comment_content" => $comments_info->comment_content,
|
108 |
+
"comment_approved" => $comments_info->comment_approved,
|
109 |
+
"comment_parent" => $comments_info->comment_parent,
|
110 |
+
"comment_parent_author" => $comment_parent_author,
|
111 |
+
"post_title" => $comments_info->post_title,
|
112 |
+
"post_type" => $comments_info->post_type,
|
113 |
+
"guid" => $comments_info->guid,
|
114 |
+
"comment_total_approved" => $comment_total_approved,
|
115 |
+
"comment_total_pending" => $comment_total_pending,
|
116 |
+
);
|
117 |
+
}
|
118 |
+
|
119 |
+
return array('comments' => $comments, 'total' => $total);
|
120 |
+
}
|
121 |
+
|
122 |
+
function comment_total(){
|
123 |
+
global $wpdb;
|
124 |
+
$totals = array();
|
125 |
+
$select_total_approved = "SELECT COUNT(*) as total, p.ID FROM $wpdb->comments as c, $wpdb->posts as p WHERE c.comment_post_ID = p.ID AND c.comment_approved = 1 GROUP BY p.ID";
|
126 |
+
$select_total_approved_res = $wpdb->get_results($select_total_approved);
|
127 |
+
|
128 |
+
if(!empty($select_total_approved_res)){
|
129 |
+
foreach($select_total_approved_res as $row){
|
130 |
+
$totals[$row->ID]['approved'] = $row->total;
|
131 |
+
}
|
132 |
+
}
|
133 |
+
$select_total_pending = "SELECT COUNT(*) as total, p.ID FROM $wpdb->comments as c, $wpdb->posts as p WHERE c.comment_post_ID = p.ID AND c.comment_approved = 0 GROUP BY p.ID";
|
134 |
+
$select_total_pending_res = $wpdb->get_results($select_total_pending);
|
135 |
+
if(!empty($select_total_pending_res)){
|
136 |
+
foreach($select_total_pending_res as $row){
|
137 |
+
$totals[$row->ID]['pending'] = $row->total;
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
return $totals;
|
142 |
+
}
|
143 |
+
|
144 |
+
function action_comment($args){
|
145 |
+
global $wpdb;
|
146 |
+
extract($args);
|
147 |
+
if($docomaction == 'approve'){
|
148 |
+
$docomaction = '1';
|
149 |
+
}else if($docomaction == 'unapprove' || $docomaction == 'untrash' || $docomaction == 'unspam'){
|
150 |
+
$docomaction = '0';
|
151 |
+
}
|
152 |
+
|
153 |
+
if(!empty($comment_id)){
|
154 |
+
if($docomaction == 'delete'){
|
155 |
+
$update_query = "DELETE FROM $wpdb->comments WHERE comment_ID = ".$comment_id;
|
156 |
+
$delete_query = "DELETE FROM $wpdb->commentmeta WHERE comment_id = ".$comment_id;
|
157 |
+
$wpdb->query($delete_query);
|
158 |
+
}else{
|
159 |
+
$update_query = "UPDATE $wpdb->comments SET comment_approved = '".$docomaction."' WHERE comment_ID = ".$comment_id;
|
160 |
+
}
|
161 |
+
$wpdb->query($update_query);
|
162 |
+
|
163 |
+
return 'Comment updated.';
|
164 |
+
}else{
|
165 |
+
return 'No ID...';
|
166 |
+
}
|
167 |
+
}
|
168 |
+
|
169 |
+
function bulk_action_comments($args){
|
170 |
+
global $wpdb;
|
171 |
+
extract($args);
|
172 |
+
|
173 |
+
if($docomaction=='delete'){
|
174 |
+
$update_query_intro = "DELETE FROM $wpdb->comments WHERE comment_ID = ";
|
175 |
+
}else{
|
176 |
+
if($docomaction=='unapprove' || $docomaction == 'untrash' || $docomaction == 'unspam'){
|
177 |
+
$docomaction = '0';
|
178 |
+
}else if($docomaction == 'approve'){
|
179 |
+
$docomaction = '1';
|
180 |
+
}
|
181 |
+
$update_query_intro = "UPDATE $wpdb->comments SET comment_approved = '".$docomaction."' WHERE comment_ID = ";
|
182 |
+
}
|
183 |
+
foreach($args as $key=>$val){
|
184 |
+
|
185 |
+
if(!empty($val) && is_numeric($val))
|
186 |
+
{
|
187 |
+
if($docomaction=='delete'){
|
188 |
+
$delete_query = "DELETE FROM $wpdb->commentmeta WHERE comment_id = ".$val;
|
189 |
+
$wpdb->query($delete_query);
|
190 |
+
}
|
191 |
+
$update_query = $update_query_intro.$val;
|
192 |
+
|
193 |
+
$wpdb->query($update_query);
|
194 |
+
}
|
195 |
+
}
|
196 |
+
return "comments updated";
|
197 |
+
}
|
198 |
+
|
199 |
+
function reply_comment($args){
|
200 |
+
global $wpdb, $current_user;
|
201 |
+
|
202 |
+
extract($args);
|
203 |
+
|
204 |
+
$comments = array();
|
205 |
+
|
206 |
+
if(!empty($comment_id) && !empty($reply_text)){
|
207 |
+
$admins = get_userdata($current_user->ID);
|
208 |
+
$now = time();
|
209 |
+
$insert_reply = "INSERT INTO $wpdb->comments(comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_karma, comment_approved, comment_agent, comment_parent, user_id) VALUES(".$post_id.", '".$admins->user_login."', '".$admins->user_email."', '".$admins->user_url."', '".$_SERVER['REMOTE_ADDR']."', NOW(), NOW(), '%s', 0, 1, '".$_SERVER['HTTP_USER_AGENT']."', ".$comment_id.", ".$current_user->ID.")";
|
210 |
+
$insert_reply_res = $wpdb->query($wpdb->prepare($insert_reply, $reply_text));
|
211 |
+
$lastid = $wpdb->insert_id;
|
212 |
+
|
213 |
+
$comments_approved = $this->comment_total();
|
214 |
+
|
215 |
+
$comment_total_approved = 0;
|
216 |
+
if(isset($comments_approved[$post_id]['approved'])){
|
217 |
+
$comment_total_approved = $comments_approved[$post_id]['approved'];
|
218 |
+
}
|
219 |
+
$comment_total_pending = 0;
|
220 |
+
if(isset($comments_approved[$post_id]['pending'])){
|
221 |
+
$comment_total_pending = $comments_approved[$post_id]['pending'];
|
222 |
+
}
|
223 |
+
|
224 |
+
$comment_parent_author = '';
|
225 |
+
if($comment_id > 0){
|
226 |
+
$select_parent_author = "SELECT c.comment_author, p.post_title, p.post_type, p.guid FROM $wpdb->comments as c, $wpdb->posts as p WHERE c.comment_post_ID = p.ID AND c.comment_ID = ".$comment_id;
|
227 |
+
$select_parent_author_res = $wpdb->get_row($select_parent_author);
|
228 |
+
$comment_parent_author = $select_parent_author_res->comment_author;
|
229 |
+
}
|
230 |
+
|
231 |
+
$comments[$lastid] = array(
|
232 |
+
"comment_post_ID" => $post_id,
|
233 |
+
"comment_author" => $admins->user_login,
|
234 |
+
"comment_author_email" => $admins->user_email,
|
235 |
+
"comment_author_url" => $admins->user_url,
|
236 |
+
"comment_author_IP" => $_SERVER['REMOTE_ADDR'],
|
237 |
+
"comment_date" => $now,
|
238 |
+
"comment_content" => $reply_text,
|
239 |
+
"comment_approved" => '1',
|
240 |
+
"comment_parent" => $comment_id,
|
241 |
+
"comment_parent_author" => $comment_parent_author,
|
242 |
+
"post_title" => $select_parent_author_res->post_title,
|
243 |
+
"post_type" => $select_parent_author_res->post_type,
|
244 |
+
"guid" => $select_parent_author_res->guid,
|
245 |
+
"comment_total_approved" => $comment_total_approved,
|
246 |
+
"comment_total_pending" => $comment_total_pending,
|
247 |
+
);
|
248 |
+
|
249 |
+
|
250 |
+
}
|
251 |
+
|
252 |
+
return $comments;
|
253 |
+
}
|
254 |
+
|
255 |
+
}
|
256 |
+
?>
|
addons/post_links/link.class.php
ADDED
@@ -0,0 +1,182 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*************************************************************
|
3 |
+
*
|
4 |
+
* link.class.php
|
5 |
+
*
|
6 |
+
* Manage/Add Links
|
7 |
+
*
|
8 |
+
*
|
9 |
+
* Copyright (c) 2011 Prelovac Media
|
10 |
+
* www.prelovac.com
|
11 |
+
**************************************************************/
|
12 |
+
if(basename($_SERVER['SCRIPT_FILENAME']) == "link.class.php"):
|
13 |
+
exit;
|
14 |
+
endif;
|
15 |
+
class IWP_MMB_Link extends IWP_MMB_Core
|
16 |
+
{
|
17 |
+
function __construct()
|
18 |
+
{
|
19 |
+
parent::__construct();
|
20 |
+
}
|
21 |
+
|
22 |
+
function add_link($args)
|
23 |
+
{
|
24 |
+
extract($args);
|
25 |
+
|
26 |
+
$params['link_url'] = esc_html($url);
|
27 |
+
$params['link_url'] = esc_url($params['link_url']);
|
28 |
+
$params['link_name'] = esc_html($name);
|
29 |
+
$params['link_id'] = '';
|
30 |
+
$params['link_description'] = $description;
|
31 |
+
$params['link_target'] = $link_target;
|
32 |
+
$params['link_category'] = array();
|
33 |
+
|
34 |
+
//Add Link category
|
35 |
+
if(is_array($link_category) && !empty($link_category)){
|
36 |
+
$terms = get_terms('link_category',array('hide_empty' => 0));
|
37 |
+
|
38 |
+
if($terms){
|
39 |
+
foreach($terms as $term){
|
40 |
+
if(in_array($term->name,$link_category)){
|
41 |
+
$params['link_category'][] = $term->term_id;
|
42 |
+
$link_category = $this->remove_element($link_category, $term->name);
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
46 |
+
if(!empty($link_category)){
|
47 |
+
foreach($link_category as $linkkey => $linkval){
|
48 |
+
if(!empty($linkval)){
|
49 |
+
$link = wp_insert_term($linkval,'link_category');
|
50 |
+
|
51 |
+
if(isset($link['term_id']) && !empty($link['term_id'])){
|
52 |
+
$params['link_category'][] = $link['term_id'];
|
53 |
+
}
|
54 |
+
}
|
55 |
+
}
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
//Add Link Owner
|
60 |
+
$user_obj = get_userdatabylogin($user);
|
61 |
+
if($user_obj && $user_obj->ID){
|
62 |
+
$params['link_owner'] = $user_obj->ID;
|
63 |
+
}
|
64 |
+
|
65 |
+
|
66 |
+
if(!function_exists('wp_insert_link'))
|
67 |
+
include_once (ABSPATH . 'wp-admin/includes/bookmark.php');
|
68 |
+
|
69 |
+
$is_success = wp_insert_link($params);
|
70 |
+
|
71 |
+
return $is_success ? true : array('error' => 'Failed to add link.');
|
72 |
+
}
|
73 |
+
|
74 |
+
function remove_element($arr, $val){
|
75 |
+
foreach ($arr as $key => $value){
|
76 |
+
if ($value == $val){
|
77 |
+
unset($arr[$key]);
|
78 |
+
}
|
79 |
+
}
|
80 |
+
return $arr = array_values($arr);
|
81 |
+
}
|
82 |
+
|
83 |
+
function get_links($args){
|
84 |
+
global $wpdb;
|
85 |
+
|
86 |
+
$where='';
|
87 |
+
|
88 |
+
extract($args);
|
89 |
+
|
90 |
+
if(!empty($filter_links))
|
91 |
+
{
|
92 |
+
$where.=" AND (link_name LIKE '%".mysql_real_escape_string($filter_links)."%' OR link_url LIKE '%".mysql_real_escape_string($filter_links)."%')";
|
93 |
+
}
|
94 |
+
|
95 |
+
$linkcats = $this->getLinkCats();
|
96 |
+
$sql_query = "$wpdb->links WHERE 1=1 ".$where;
|
97 |
+
|
98 |
+
$links_total = $wpdb->get_results("SELECT count(*) as total_links FROM ".$sql_query);
|
99 |
+
$total=$links_total[0]->total_links;
|
100 |
+
|
101 |
+
$query_links = $wpdb->get_results("SELECT link_id, link_url, link_name, link_target, link_visible, link_rating, link_rel FROM ".$sql_query." ORDER BY link_name ASC LIMIT 500");
|
102 |
+
$links = array();
|
103 |
+
foreach ( $query_links as $link_info )
|
104 |
+
{
|
105 |
+
$link_cat = $linkcats[$link_info->link_id];
|
106 |
+
$cats = array();
|
107 |
+
foreach($link_cat as $catkey=>$catval)
|
108 |
+
{
|
109 |
+
$cats[] = $catval;
|
110 |
+
}
|
111 |
+
|
112 |
+
$links[$link_info->link_id] = array(
|
113 |
+
"link_url" => $link_info->link_url,
|
114 |
+
"link_name" => $link_info->link_name,
|
115 |
+
"link_target" => $link_info->link_target,
|
116 |
+
"link_visible" => $link_info->link_visible,
|
117 |
+
"link_rating" => $link_info->link_rating,
|
118 |
+
"link_rel" => $link_info->link_rel,
|
119 |
+
"link_cats" => $cats
|
120 |
+
);
|
121 |
+
}
|
122 |
+
|
123 |
+
return array('links' => $links, 'total' => $total);
|
124 |
+
}
|
125 |
+
|
126 |
+
function getLinkCats($taxonomy = 'link_category')
|
127 |
+
{
|
128 |
+
global $wpdb;
|
129 |
+
|
130 |
+
$cats = $wpdb->get_results("SELECT l.link_id, $wpdb->terms.name
|
131 |
+
FROM $wpdb->links AS l
|
132 |
+
INNER JOIN $wpdb->term_relationships ON ( l.link_id = $wpdb->term_relationships.object_id )
|
133 |
+
INNER JOIN $wpdb->term_taxonomy ON ( $wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id
|
134 |
+
AND $wpdb->term_taxonomy.taxonomy = '".$taxonomy."' )
|
135 |
+
INNER JOIN $wpdb->terms ON ( $wpdb->term_taxonomy.term_id = $wpdb->terms.term_id )");
|
136 |
+
|
137 |
+
foreach ( $cats as $post_val )
|
138 |
+
{
|
139 |
+
|
140 |
+
$post_cats[$post_val->link_id][] = $post_val->name;
|
141 |
+
}
|
142 |
+
|
143 |
+
return $post_cats;
|
144 |
+
}
|
145 |
+
|
146 |
+
function delete_link($args){
|
147 |
+
global $wpdb;
|
148 |
+
|
149 |
+
if(!empty($args['link_id']))
|
150 |
+
{
|
151 |
+
$delete_query = "DELETE FROM $wpdb->links WHERE link_id = ".$args['link_id'];
|
152 |
+
$wpdb->get_results($delete_query);
|
153 |
+
|
154 |
+
return 'Link deleted.';
|
155 |
+
}
|
156 |
+
else
|
157 |
+
{
|
158 |
+
return 'No ID...';
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
function delete_links($args){
|
163 |
+
global $wpdb;
|
164 |
+
extract($args);
|
165 |
+
|
166 |
+
if($deleteaction=='delete'){
|
167 |
+
$delete_query_intro = "DELETE FROM $wpdb->links WHERE link_id = ";
|
168 |
+
}
|
169 |
+
foreach($args as $key=>$val){
|
170 |
+
|
171 |
+
if(!empty($val) && is_numeric($val))
|
172 |
+
{
|
173 |
+
$delete_query = $delete_query_intro.$val;
|
174 |
+
|
175 |
+
$wpdb->query($delete_query);
|
176 |
+
}
|
177 |
+
}
|
178 |
+
return "Link deleted";
|
179 |
+
}
|
180 |
+
|
181 |
+
}
|
182 |
+
?>
|
addons/post_links/post.class.php
ADDED
@@ -0,0 +1,773 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*************************************************************
|
3 |
+
*
|
4 |
+
* post.class.php
|
5 |
+
*
|
6 |
+
* Create remote post
|
7 |
+
*
|
8 |
+
*
|
9 |
+
* Copyright (c) 2011 Prelovac Media
|
10 |
+
* www.prelovac.com
|
11 |
+
**************************************************************/
|
12 |
+
if(basename($_SERVER['SCRIPT_FILENAME']) == "post.class.php"):
|
13 |
+
exit;
|
14 |
+
endif;
|
15 |
+
class IWP_MMB_Post extends IWP_MMB_Core
|
16 |
+
{
|
17 |
+
function __construct()
|
18 |
+
{
|
19 |
+
parent::__construct();
|
20 |
+
}
|
21 |
+
|
22 |
+
function create($args)
|
23 |
+
{
|
24 |
+
|
25 |
+
//$this->_log($args);
|
26 |
+
global $wpdb;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* algorithm
|
30 |
+
* 1. create post using wp_insert_post (insert tags also here itself)
|
31 |
+
* 2. use wp_create_categories() to create(not exists) and insert in the post
|
32 |
+
* 3. insert meta values
|
33 |
+
*/
|
34 |
+
|
35 |
+
include_once ABSPATH . 'wp-admin/includes/taxonomy.php';
|
36 |
+
include_once ABSPATH . 'wp-admin/includes/image.php';
|
37 |
+
include_once ABSPATH . 'wp-admin/includes/file.php';
|
38 |
+
|
39 |
+
$post_struct = $args['post_data'];
|
40 |
+
|
41 |
+
|
42 |
+
|
43 |
+
$post_data = $post_struct['post_data'];
|
44 |
+
$new_custom = $post_struct['post_extras']['post_meta'];
|
45 |
+
$post_categories = explode(',', $post_struct['post_extras']['post_categories']);
|
46 |
+
$post_atta_img = $post_struct['post_extras']['post_atta_images'];
|
47 |
+
$post_upload_dir = $post_struct['post_extras']['post_upload_dir'];
|
48 |
+
$post_checksum = $post_struct['post_extras']['post_checksum'];
|
49 |
+
$post_featured_img = $post_struct['post_extras']['featured_img'];
|
50 |
+
|
51 |
+
$upload = wp_upload_dir();
|
52 |
+
|
53 |
+
// create dynamic url RegExp
|
54 |
+
$iwp_base_url = parse_url($post_upload_dir['url']);
|
55 |
+
$iwp_regexp_url = $iwp_base_url['host'] . $iwp_base_url['path'];
|
56 |
+
$rep = array(
|
57 |
+
'/',
|
58 |
+
'+',
|
59 |
+
'.',
|
60 |
+
':',
|
61 |
+
'?'
|
62 |
+
);
|
63 |
+
$with = array(
|
64 |
+
'\/',
|
65 |
+
'\+',
|
66 |
+
'\.',
|
67 |
+
'\:',
|
68 |
+
'\?'
|
69 |
+
);
|
70 |
+
$iwp_regexp_url = str_replace($rep, $with, $iwp_regexp_url);
|
71 |
+
|
72 |
+
// rename all src ../wp-content/ with hostname/wp-content/
|
73 |
+
|
74 |
+
$iwp_mmb_dot_url = '..' . $iwp_mmb_base_url['path'];
|
75 |
+
$iwp_mmb_dot_url = str_replace($rep, $with, $iwp_mmb_dot_url);
|
76 |
+
$dot_match_count = preg_match_all('/(<a[^>]+href=\"([^"]+)\"[^>]*>)?(<\s*img.[^\/>]*src="([^"]*' . $iwp_mmb_dot_url . '[^\s]+\.(jpg|jpeg|png|gif|bmp))"[^>]*>)/ixu', $post_data['post_content'], $dot_get_urls, PREG_SET_ORDER);
|
77 |
+
|
78 |
+
file_put_contents("C:\wamp\www\_teste.php", var_export($iwp_base_url, true).'--iwp_mmb_base_url---'.var_export($post_data['post_content'], true).'--iwp_mmb_base_url---'.var_export($dot_match_count, true).'--iwp_mmb_dot_url---'.var_export($iwp_mmb_dot_url, true).'--iwp_mmb_base_url---'.var_export($iwp_mmb_base_url, true).'--iwp_mmb_base_url---'.var_export($dot_get_urls, true));
|
79 |
+
|
80 |
+
if ($dot_match_count > 0) {
|
81 |
+
foreach ($dot_get_urls as $dot_url) {
|
82 |
+
$match_dot = '/' . str_replace($rep, $with, $dot_url[4]) . '/';
|
83 |
+
$replace_dot = 'http://' . $iwp_mmb_base_url['host'] . substr($dot_url[4], 2, strlen($dot_url[4]));
|
84 |
+
$post_data['post_content'] = preg_replace($match_dot, $replace_dot, $post_data['post_content']);
|
85 |
+
|
86 |
+
if ($dot_url[1] != '') {
|
87 |
+
$match_dot_a = '/' . str_replace($rep, $with, $dot_url[2]) . '/';
|
88 |
+
$replace_dot_a = 'http://' . $iwp_mmb_base_url['host'] . substr($dot_url[2], 2, strlen($dot_url[2]));
|
89 |
+
$post_data['post_content'] = preg_replace($match_dot_a, $replace_dot_a, $post_data['post_content']);
|
90 |
+
}
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
//to find all the images
|
95 |
+
$match_count = preg_match_all('/(<a[^>]+href=\"([^"]+)\"[^>]*>)?(<\s*img.[^\/>]*src="([^"]+' . $iwp_mmb_regexp_url . '[^\s]+\.(jpg|jpeg|png|gif|bmp))"[^>]*>)/ixu', $post_data['post_content'], $get_urls, PREG_SET_ORDER);
|
96 |
+
|
97 |
+
///////////
|
98 |
+
//$html = $params['postContent'];
|
99 |
+
//
|
100 |
+
// $doc = new DOMDocument();
|
101 |
+
// @$doc->loadHTML($html);
|
102 |
+
//
|
103 |
+
// $tags = $doc->getElementsByTagName('img');
|
104 |
+
//
|
105 |
+
// foreach ($tags as $tag) {
|
106 |
+
// $img[]['src'] = str_replace('\"','',$tag->getAttribute('src'));
|
107 |
+
// }
|
108 |
+
/////////////////
|
109 |
+
|
110 |
+
if ($match_count > 0) {
|
111 |
+
$attachments = array();
|
112 |
+
$post_content = $post_data['post_content'];
|
113 |
+
|
114 |
+
foreach ($get_urls as $get_url_k => $get_url) {
|
115 |
+
// unset url in attachment array
|
116 |
+
foreach ($post_atta_img as $atta_url_k => $atta_url_v) {
|
117 |
+
$match_patt_url = '/' . str_replace($rep, $with, substr($atta_url_v['src'], 0, strrpos($atta_url_v['src'], '.'))) . '/';
|
118 |
+
if (preg_match($match_patt_url, $get_url[4])) {
|
119 |
+
unset($post_atta_img[$atta_url_k]);
|
120 |
+
}
|
121 |
+
}
|
122 |
+
$pic_from_other_site = $get_urls[$get_url_k][4];
|
123 |
+
/* if(strpos($pic_from_other_site,'exammple.com') === false){
|
124 |
+
continue;
|
125 |
+
}*/
|
126 |
+
|
127 |
+
if (isset($get_urls[$get_url_k][6])) { // url have parent, don't download this url
|
128 |
+
if ($get_url[1] != '') {
|
129 |
+
// change src url
|
130 |
+
$s_mmb_mp = '/' . str_replace($rep, $with, $get_url[4]) . '/';
|
131 |
+
|
132 |
+
$s_img_atta = wp_get_attachment_image_src($get_urls[$get_url_k][6]);
|
133 |
+
$s_mmb_rp = $s_img_atta[0];
|
134 |
+
$post_content = preg_replace($s_mmb_mp, $s_mmb_rp, $post_content);
|
135 |
+
// change attachment url
|
136 |
+
if (preg_match('/attachment_id/i', $get_url[2])) {
|
137 |
+
$iwp_mmb_mp = '/' . str_replace($rep, $with, $get_url[2]) . '/';
|
138 |
+
$iwp_mmb_rp = get_bloginfo('wpurl') . '/?attachment_id=' . $get_urls[$get_url_k][6];
|
139 |
+
$post_content = preg_replace($iwp_mmb_mp, $iwp_mmb_rp, $post_content);
|
140 |
+
}
|
141 |
+
}
|
142 |
+
continue;
|
143 |
+
}
|
144 |
+
|
145 |
+
$no_thumb = '';
|
146 |
+
if (preg_match('/-\d{3}x\d{3}\.[a-zA-Z0-9]{3,4}$/', $get_url[4])) {
|
147 |
+
$no_thumb = preg_replace('/-\d{3}x\d{3}\.[a-zA-Z0-9]{3,4}$/', '.' . $get_url[5], $get_url[4]);
|
148 |
+
} else {
|
149 |
+
$no_thumb = $get_url[4];
|
150 |
+
}
|
151 |
+
|
152 |
+
if(isset($upload['error']) && !empty($upload['error'])){
|
153 |
+
return array('error' => $upload['error']);
|
154 |
+
}
|
155 |
+
$file_name = basename($no_thumb);
|
156 |
+
$tmp_file = download_url($no_thumb);
|
157 |
+
|
158 |
+
if(is_wp_error($tmp_file)){
|
159 |
+
return array('error' => $tmp_file->get_error_message());
|
160 |
+
}
|
161 |
+
|
162 |
+
$attach_upload['url'] = $upload['url'] . '/' . $file_name;
|
163 |
+
$attach_upload['path'] = $upload['path'] . '/' . $file_name;
|
164 |
+
$renamed = @rename($tmp_file, $attach_upload['path']);
|
165 |
+
if ($renamed === true) {
|
166 |
+
$match_pattern = '/' . str_replace($rep, $with, $get_url[4]) . '/';
|
167 |
+
$replace_pattern = $attach_upload['url'];
|
168 |
+
$post_content = preg_replace($match_pattern, $replace_pattern, $post_content);
|
169 |
+
if (preg_match('/-\d{3}x\d{3}\.[a-zA-Z0-9]{3,4}$/', $get_url[4])) {
|
170 |
+
$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])) . '/';
|
171 |
+
$post_content = preg_replace($match_pattern, $replace_pattern, $post_content);
|
172 |
+
}
|
173 |
+
|
174 |
+
$attachment = array(
|
175 |
+
'post_title' => $file_name,
|
176 |
+
'post_content' => '',
|
177 |
+
'post_type' => 'attachment',
|
178 |
+
//'post_parent' => $post_id,
|
179 |
+
'post_mime_type' => 'image/' . $get_url[5],
|
180 |
+
'guid' => $attach_upload['url']
|
181 |
+
);
|
182 |
+
|
183 |
+
// Save the data
|
184 |
+
|
185 |
+
$attach_id = wp_insert_attachment($attachment, $attach_upload['path']);
|
186 |
+
|
187 |
+
$attachments[$attach_id] = 0;
|
188 |
+
|
189 |
+
// featured image
|
190 |
+
if ($post_featured_img != '') {
|
191 |
+
$feat_img_url = '';
|
192 |
+
if (preg_match('/-\d{3}x\d{3}\.[a-zA-Z0-9]{3,4}$/', $post_featured_img)) {
|
193 |
+
$feat_img_url = substr($post_featured_img, 0, strrpos($post_featured_img, '.') - 8);
|
194 |
+
} else {
|
195 |
+
$feat_img_url = substr($post_featured_img, 0, strrpos($post_featured_img, '.'));
|
196 |
+
}
|
197 |
+
$m_feat_url = '/' . str_replace($rep, $with, $feat_img_url) . '/';
|
198 |
+
if (preg_match($m_feat_url, $get_url[4])) {
|
199 |
+
$post_featured_img = '';
|
200 |
+
$attachments[$attach_id] = $attach_id;
|
201 |
+
}
|
202 |
+
}
|
203 |
+
|
204 |
+
// set $get_urls value[6] - parent atta_id
|
205 |
+
foreach ($get_urls as $url_k => $url_v) {
|
206 |
+
if ($get_url_k != $url_k) {
|
207 |
+
$s_get_url = '';
|
208 |
+
if (preg_match('/-\d{3}x\d{3}\.[a-zA-Z0-9]{3,4}$/', $url_v[4])) {
|
209 |
+
$s_get_url = substr($url_v[4], 0, strrpos($url_v[4], '.') - 8);
|
210 |
+
} else {
|
211 |
+
$s_get_url = substr($url_v[4], 0, strrpos($url_v[4], '.'));
|
212 |
+
}
|
213 |
+
$m_patt_url = '/' . str_replace($rep, $with, $s_get_url) . '/';
|
214 |
+
if (preg_match($m_patt_url, $get_url[4])) {
|
215 |
+
array_push($get_urls[$url_k], $attach_id);
|
216 |
+
}
|
217 |
+
}
|
218 |
+
}
|
219 |
+
|
220 |
+
|
221 |
+
$some_data = wp_generate_attachment_metadata($attach_id, $attach_upload['path']);
|
222 |
+
wp_update_attachment_metadata($attach_id, $some_data);
|
223 |
+
|
224 |
+
|
225 |
+
//changing href of a tag
|
226 |
+
if ($get_url[1] != '') {
|
227 |
+
$iwp_mmb_mp = '/' . str_replace($rep, $with, $get_url[2]) . '/';
|
228 |
+
if (preg_match('/attachment_id/i', $get_url[2])) {
|
229 |
+
$iwp_mmb_rp = get_bloginfo('wpurl') . '/?attachment_id=' . $attach_id;
|
230 |
+
$post_content = preg_replace($iwp_mmb_mp, $iwp_mmb_rp, $post_content);
|
231 |
+
}
|
232 |
+
}
|
233 |
+
} else {
|
234 |
+
@unlink($tmp_file);
|
235 |
+
return array('error' => "Cannot create attachment file in ".$attach_upload['path']." Please set correct permissions.");
|
236 |
+
|
237 |
+
}
|
238 |
+
@unlink($tmp_file);
|
239 |
+
}
|
240 |
+
|
241 |
+
|
242 |
+
$post_data['post_content'] = $post_content;
|
243 |
+
|
244 |
+
}
|
245 |
+
if (count($post_atta_img)) {
|
246 |
+
foreach ($post_atta_img as $img) {
|
247 |
+
$file_name = basename($img['src']);
|
248 |
+
|
249 |
+
if(isset($upload['error']) && !empty($upload['error'])){
|
250 |
+
return array('error' => $upload['error']);
|
251 |
+
}
|
252 |
+
|
253 |
+
$tmp_file = download_url($img['src']);
|
254 |
+
if(is_wp_error($tmp_file)){
|
255 |
+
return array('error' => $tmp_file->get_error_message());
|
256 |
+
}
|
257 |
+
|
258 |
+
$attach_upload['url'] = $upload['url'] . '/' . $file_name;
|
259 |
+
$attach_upload['path'] = $upload['path'] . '/' . $file_name;
|
260 |
+
$renamed = @rename($tmp_file, $attach_upload['path']);
|
261 |
+
if ($renamed === true) {
|
262 |
+
$atta_ext = end(explode('.', $file_name));
|
263 |
+
|
264 |
+
$attachment = array(
|
265 |
+
'post_title' => $file_name,
|
266 |
+
'post_content' => '',
|
267 |
+
'post_type' => 'attachment',
|
268 |
+
//'post_parent' => $post_id,
|
269 |
+
'post_mime_type' => 'image/' . $atta_ext,
|
270 |
+
'guid' => $attach_upload['url']
|
271 |
+
);
|
272 |
+
|
273 |
+
// Save the data
|
274 |
+
$attach_id = wp_insert_attachment($attachment, $attach_upload['path']);
|
275 |
+
wp_update_attachment_metadata($attach_id, wp_generate_attachment_metadata($attach_id, $attach_upload['path']));
|
276 |
+
$attachments[$attach_id] = 0;
|
277 |
+
|
278 |
+
// featured image
|
279 |
+
if ($post_featured_img != '') {
|
280 |
+
$feat_img_url = '';
|
281 |
+
if (preg_match('/-\d{3}x\d{3}\.[a-zA-Z0-9]{3,4}$/', $post_featured_img)) {
|
282 |
+
$feat_img_url = substr($post_featured_img, 0, strrpos($post_featured_img, '.') - 8);
|
283 |
+
} else {
|
284 |
+
$feat_img_url = substr($post_featured_img, 0, strrpos($post_featured_img, '.'));
|
285 |
+
}
|
286 |
+
$m_feat_url = '/' . str_replace($rep, $with, $feat_img_url) . '/';
|
287 |
+
if (preg_match($m_feat_url, $img['src'])) {
|
288 |
+
$post_featured_img = '';
|
289 |
+
$attachments[$attach_id] = $attach_id;
|
290 |
+
}
|
291 |
+
}
|
292 |
+
|
293 |
+
} else {
|
294 |
+
@unlink($tmp_file);
|
295 |
+
return array('error' => "Cannot create attachment file in ".$attach_upload['path']." Please set correct permissions.");
|
296 |
+
}
|
297 |
+
@unlink($tmp_file);
|
298 |
+
}
|
299 |
+
}
|
300 |
+
|
301 |
+
//Prepare post data and temporarily remove content filters before insert post
|
302 |
+
$user = $this->iwp_mmb_get_user_info( $args['username'] );
|
303 |
+
if($user && $user->ID){
|
304 |
+
$post_data['post_author'] = $user->ID;
|
305 |
+
}
|
306 |
+
//remove filter which can brake scripts or html
|
307 |
+
remove_filter('content_save_pre', 'wp_filter_post_kses');
|
308 |
+
|
309 |
+
//check for edit post
|
310 |
+
$post_result = 0;
|
311 |
+
if(isset($post_data['iwp_post_edit']) && $post_data['iwp_post_edit']){
|
312 |
+
|
313 |
+
|
314 |
+
if($post_data['iwp_match_by'] == 'title'){
|
315 |
+
$match_by = "post_title = '".$post_data['post_title']."'";
|
316 |
+
} else {
|
317 |
+
$match_by = "post_name = '".$post_data['post_name']."'";
|
318 |
+
}
|
319 |
+
|
320 |
+
$query = "SELECT ID FROM $wpdb->posts WHERE $match_by AND post_status NOT IN('inherit','auto-draft','draft') LIMIT 1";
|
321 |
+
|
322 |
+
$post_result = $wpdb->get_var($query);
|
323 |
+
|
324 |
+
}
|
325 |
+
|
326 |
+
|
327 |
+
if($post_result){
|
328 |
+
//update existing post
|
329 |
+
$post_data['ID'] = $post_result;
|
330 |
+
$post_id = wp_update_post($post_data);
|
331 |
+
|
332 |
+
//check for previous attachments
|
333 |
+
$atta_allimages =& get_children('post_type=attachment&post_parent=' . $post_id);
|
334 |
+
if (!empty($atta_allimages)) {
|
335 |
+
foreach ($atta_allimages as $image) {
|
336 |
+
wp_delete_attachment($image->ID);
|
337 |
+
}
|
338 |
+
}
|
339 |
+
|
340 |
+
} else {
|
341 |
+
if($post_data['iwp_post_edit'] && $post_data['iwp_force_publish']){
|
342 |
+
$post_id = wp_insert_post($post_data);
|
343 |
+
} elseif($post_data['iwp_post_edit'] && !$post_data['iwp_force_publish']) {
|
344 |
+
return array('error' => "Post not found.");
|
345 |
+
} else {
|
346 |
+
$post_id = wp_insert_post($post_data);
|
347 |
+
}
|
348 |
+
|
349 |
+
}
|
350 |
+
|
351 |
+
if (count($attachments)) {
|
352 |
+
foreach ($attachments as $atta_id => $featured_id) {
|
353 |
+
$result = wp_update_post(array(
|
354 |
+
'ID' => $atta_id,
|
355 |
+
'post_parent' => $post_id
|
356 |
+
));
|
357 |
+
if ($featured_id > 0) {
|
358 |
+
$new_custom['_thumbnail_id'] = array(
|
359 |
+
$featured_id
|
360 |
+
);
|
361 |
+
}
|
362 |
+
}
|
363 |
+
}
|
364 |
+
|
365 |
+
// featured image
|
366 |
+
if ($post_featured_img != '') {
|
367 |
+
$file_name = basename($post_featured_img);
|
368 |
+
if(isset($upload['error']) && !empty($upload['error'])){
|
369 |
+
return array('error' => $upload['error']);
|
370 |
+
}
|
371 |
+
$tmp_file = download_url($post_featured_img);
|
372 |
+
if(is_wp_error($tmp_file)){
|
373 |
+
return array('error' => $tmp_file->get_error_message());
|
374 |
+
}
|
375 |
+
$attach_upload['url'] = $upload['url'] . '/' . $file_name;
|
376 |
+
$attach_upload['path'] = $upload['path'] . '/' . $file_name;
|
377 |
+
$renamed = @rename($tmp_file, $attach_upload['path']);
|
378 |
+
if ($renamed === true) {
|
379 |
+
$atta_ext = end(explode('.', $file_name));
|
380 |
+
|
381 |
+
$attachment = array(
|
382 |
+
'post_title' => $file_name,
|
383 |
+
'post_content' => '',
|
384 |
+
'post_type' => 'attachment',
|
385 |
+
'post_parent' => $post_id,
|
386 |
+
'post_mime_type' => 'image/' . $atta_ext,
|
387 |
+
'guid' => $attach_upload['url']
|
388 |
+
);
|
389 |
+
|
390 |
+
// Save the data
|
391 |
+
$attach_id = wp_insert_attachment($attachment, $attach_upload['path']);
|
392 |
+
wp_update_attachment_metadata($attach_id, wp_generate_attachment_metadata($attach_id, $attach_upload['path']));
|
393 |
+
$new_custom['_thumbnail_id'] = array(
|
394 |
+
$attach_id
|
395 |
+
);
|
396 |
+
} else {
|
397 |
+
@unlink($tmp_file);
|
398 |
+
return array('error' => "Cannot create attachment file in ".$attach_upload['path']." Please set correct permissions.");
|
399 |
+
}
|
400 |
+
@unlink($tmp_file);
|
401 |
+
}
|
402 |
+
|
403 |
+
if ($post_id && is_array($post_categories)) {
|
404 |
+
//insert categories
|
405 |
+
|
406 |
+
$cat_ids = wp_create_categories($post_categories, $post_id);
|
407 |
+
}
|
408 |
+
|
409 |
+
|
410 |
+
//get current custom fields
|
411 |
+
$cur_custom = get_post_custom($post_id);
|
412 |
+
//check which values doesnot exists in new custom fields
|
413 |
+
$diff_values = array_diff_key($cur_custom, $new_custom);
|
414 |
+
|
415 |
+
if (is_array($diff_values))
|
416 |
+
foreach ($diff_values as $meta_key => $value) {
|
417 |
+
delete_post_meta($post_id, $meta_key);
|
418 |
+
}
|
419 |
+
//insert new post meta
|
420 |
+
foreach ($new_custom as $meta_key => $value) {
|
421 |
+
if (strpos($meta_key, '_mmb') === 0 || strpos($meta_key, '_edit') === 0) {
|
422 |
+
continue;
|
423 |
+
} else {
|
424 |
+
update_post_meta($post_id, $meta_key, $value[0]);
|
425 |
+
}
|
426 |
+
}
|
427 |
+
return $post_id;
|
428 |
+
}
|
429 |
+
|
430 |
+
|
431 |
+
function change_status($args)
|
432 |
+
{
|
433 |
+
|
434 |
+
global $wpdb;
|
435 |
+
$post_id = $args['post_id'];
|
436 |
+
$status = $args['status'];
|
437 |
+
$success = false;
|
438 |
+
|
439 |
+
if(in_array($status, array('draft', 'publish', 'trash'))){
|
440 |
+
$sql = "update ".$wpdb->prefix."posts set post_status = '$status' where ID = '$post_id'";
|
441 |
+
$success = $wpdb->query($sql);
|
442 |
+
}
|
443 |
+
|
444 |
+
return $success;
|
445 |
+
}
|
446 |
+
|
447 |
+
/**
|
448 |
+
* Function which gets posts from client depending on arguments.
|
449 |
+
* If FROM and TO dates are provided and range, range has bigger priority to date FROM.
|
450 |
+
* This means if there are less posts between FROM and TO than range provided,
|
451 |
+
* this function omit date from and returns last range number posts to date TO.
|
452 |
+
*
|
453 |
+
* @param array $args arguments passed to function
|
454 |
+
* @arg string filter_posts search phrase for post titles
|
455 |
+
* @arg string iwp_get_posts_date_from date in format(Y-m-d H:i:s) when posts are publishes from
|
456 |
+
* @arg string iwp_get_posts_date_to date in format(Y-m-d H:i:s) when posts are publishes to
|
457 |
+
* @arg string iwp_get_posts_range range number of returned posts
|
458 |
+
* @arg string iwp_get_posts_publish on or off
|
459 |
+
* @arg string iwp_get_posts_pending on or off
|
460 |
+
* @arg string iwp_get_posts_private on or off
|
461 |
+
* @arg string iwp_get_posts_future on or off
|
462 |
+
* @arg string iwp_get_posts_draft on or off
|
463 |
+
* @arg string iwp_get_posts_trash on or off
|
464 |
+
* @return array posts related to args
|
465 |
+
*/
|
466 |
+
function get_posts($args){
|
467 |
+
global $wpdb;
|
468 |
+
|
469 |
+
$where='';
|
470 |
+
|
471 |
+
extract($args);
|
472 |
+
|
473 |
+
if(!empty($filter_posts))
|
474 |
+
{
|
475 |
+
$where.=" AND post_title LIKE '%".mysql_real_escape_string($filter_posts)."%'";
|
476 |
+
}
|
477 |
+
|
478 |
+
if(!empty($iwp_get_posts_date_from) && !empty($iwp_get_posts_date_to))
|
479 |
+
{
|
480 |
+
$where.=" AND post_date BETWEEN '".mysql_real_escape_string($iwp_get_posts_date_from)."' AND '".mysql_real_escape_string($iwp_get_posts_date_to)."'";
|
481 |
+
}
|
482 |
+
else if(!empty($iwp_get_posts_date_from) && empty($iwp_get_posts_date_to))
|
483 |
+
{
|
484 |
+
$where.=" AND post_date >= '".mysql_real_escape_string($iwp_get_posts_date_from)."'";
|
485 |
+
}
|
486 |
+
else if(empty($iwp_get_posts_date_from) && !empty($iwp_get_posts_date_to))
|
487 |
+
{
|
488 |
+
$where.=" AND post_date <= '".mysql_real_escape_string($iwp_get_posts_date_to)."'";
|
489 |
+
}
|
490 |
+
$post_array=array();
|
491 |
+
$post_statuses = array('publish', 'pending', 'private', 'future', 'draft', 'trash');
|
492 |
+
foreach ($args as $checkbox => $checkbox_val)
|
493 |
+
{
|
494 |
+
if($checkbox_val=="on") {
|
495 |
+
$post_array[]="'".str_replace("iwp_get_posts_","",$checkbox)."'";
|
496 |
+
}
|
497 |
+
}
|
498 |
+
if(!empty($post_array))
|
499 |
+
{
|
500 |
+
$where.=" AND post_status IN (".implode(",",$post_array).")";
|
501 |
+
}
|
502 |
+
|
503 |
+
$limit = ($iwp_get_posts_range) ? ' LIMIT ' . mysql_real_escape_string($iwp_get_posts_range) : ' LIMIT 500';
|
504 |
+
|
505 |
+
$sql_query = "$wpdb->posts WHERE post_status!='auto-draft' AND post_status!='inherit' AND post_type='post' ".$where." ORDER BY post_date DESC";
|
506 |
+
|
507 |
+
$total = array();
|
508 |
+
$posts = array();
|
509 |
+
$posts_info = $wpdb->get_results("SELECT * FROM ".$sql_query.$limit);
|
510 |
+
$user_info = $this->getUsersIDs();
|
511 |
+
$post_cats=$this->getPostCats();
|
512 |
+
$post_tags=$this->getPostCats('post_tag');
|
513 |
+
$total['total_num']=count($posts_info);
|
514 |
+
|
515 |
+
if($iwp_get_posts_range && !empty($iwp_get_posts_date_from) && !empty($iwp_get_posts_date_to) && $total['total_num'] < $iwp_get_posts_range) {
|
516 |
+
$sql_query = "$wpdb->posts
|
517 |
+
WHERE post_status!='auto-draft' AND post_status!='inherit' AND post_type='post' AND post_date <= '".mysql_real_escape_string($iwp_get_posts_date_to)."'
|
518 |
+
ORDER BY post_date DESC
|
519 |
+
LIMIT " . mysql_real_escape_string($iwp_get_posts_range);
|
520 |
+
|
521 |
+
$posts_info = $wpdb->get_results("SELECT * FROM ".$sql_query);
|
522 |
+
$total = array();
|
523 |
+
$total['total_num']=count($posts_info);
|
524 |
+
}
|
525 |
+
|
526 |
+
foreach ( $posts_info as $post_info )
|
527 |
+
{
|
528 |
+
|
529 |
+
$cats=array();
|
530 |
+
foreach($post_cats[$post_info->ID] as $cat_array => $cat_array_val)
|
531 |
+
{
|
532 |
+
$cats[] = array('name' => $cat_array_val);
|
533 |
+
}
|
534 |
+
|
535 |
+
$tags=array();
|
536 |
+
if (!empty($post_tags[$post_info->ID])) {
|
537 |
+
foreach($post_tags[$post_info->ID] as $tag_array => $tag_array_val)
|
538 |
+
{
|
539 |
+
$tags[] = array('name' => $tag_array_val);
|
540 |
+
}
|
541 |
+
}
|
542 |
+
|
543 |
+
$posts[]=array(
|
544 |
+
'post_id'=>$post_info->ID,
|
545 |
+
'post_title'=>$post_info->post_title,
|
546 |
+
'post_name'=>$post_info->post_name,
|
547 |
+
'post_author'=>array('author_id'=>$post_info->post_author, 'author_name'=>$user_info[$post_info->post_author]),
|
548 |
+
'post_date'=>$post_info->post_date,
|
549 |
+
'post_modified'=>$post_info->post_modified,
|
550 |
+
'post_status'=>$post_info->post_status,
|
551 |
+
'post_type'=>$post_info->post_type,
|
552 |
+
'guid'=>$post_info->guid,
|
553 |
+
'post_password'=>$post_info->post_password,
|
554 |
+
'ping_status'=>$post_info->ping_status,
|
555 |
+
'comment_status'=>$post_info->comment_status,
|
556 |
+
'comment_count'=>$post_info->comment_count,
|
557 |
+
'cats'=>$cats,
|
558 |
+
'tags'=>$tags,
|
559 |
+
|
560 |
+
);
|
561 |
+
}
|
562 |
+
|
563 |
+
return array('posts' => $posts, 'total' => $total);
|
564 |
+
}
|
565 |
+
|
566 |
+
function delete_post($args){
|
567 |
+
global $wpdb;
|
568 |
+
if(!empty($args['post_id']) && !empty($args['action']))
|
569 |
+
{
|
570 |
+
if($args['action']=='delete')
|
571 |
+
{
|
572 |
+
$delete_query = "UPDATE $wpdb->posts SET post_status = 'trash' WHERE ID = ".$args['post_id'];
|
573 |
+
}
|
574 |
+
else if($args['action']=='delete_perm'){
|
575 |
+
$delete_query = "DELETE FROM $wpdb->posts WHERE ID = ".$args['post_id'];
|
576 |
+
}
|
577 |
+
else if($args['action']=='delete_restore'){
|
578 |
+
$delete_query = "UPDATE $wpdb->posts SET post_status = 'publish' WHERE ID = ".$args['post_id'];
|
579 |
+
}
|
580 |
+
$wpdb->get_results($delete_query);
|
581 |
+
|
582 |
+
return 'Post deleted.';
|
583 |
+
}
|
584 |
+
else
|
585 |
+
{
|
586 |
+
return 'No ID...';
|
587 |
+
}
|
588 |
+
}
|
589 |
+
|
590 |
+
function delete_posts($args){
|
591 |
+
global $wpdb;
|
592 |
+
extract($args);
|
593 |
+
if($deleteaction=='delete'){
|
594 |
+
$delete_query_intro = "DELETE FROM $wpdb->posts WHERE ID = ";
|
595 |
+
}elseif($deleteaction=='trash'){
|
596 |
+
$delete_query_intro = "UPDATE $wpdb->posts SET post_status = 'trash' WHERE ID = ";
|
597 |
+
}elseif($deleteaction=='draft'){
|
598 |
+
$delete_query_intro = "UPDATE $wpdb->posts SET post_status = 'draft' WHERE ID = ";
|
599 |
+
}elseif($deleteaction=='publish'){
|
600 |
+
$delete_query_intro = "UPDATE $wpdb->posts SET post_status = 'publish' WHERE ID = ";
|
601 |
+
}
|
602 |
+
foreach($args as $key=>$val){
|
603 |
+
|
604 |
+
if(!empty($val) && is_numeric($val))
|
605 |
+
{
|
606 |
+
$delete_query = $delete_query_intro.$val;
|
607 |
+
|
608 |
+
$wpdb->query($delete_query);
|
609 |
+
}
|
610 |
+
}
|
611 |
+
return "Post deleted";
|
612 |
+
|
613 |
+
}
|
614 |
+
|
615 |
+
/**
|
616 |
+
* Function which gets pages from client depending on arguments.
|
617 |
+
* If FROM and TO dates are provided and range, range has bigger priority to date FROM.
|
618 |
+
* This means if there are less pages between FROM and TO than range provided,
|
619 |
+
* this function omit date from and returns last range number pages to date TO.
|
620 |
+
*
|
621 |
+
* @param array $args arguments passed to function
|
622 |
+
* @arg string filter_pages search phrase for page titles
|
623 |
+
* @arg string iwp_get_pages_date_from date in format(Y-m-d H:i:s) when pages are publishes from
|
624 |
+
* @arg string iwp_get_pages_date_to date in format(Y-m-d H:i:s) when pages are publishes to
|
625 |
+
* @arg string iwp_get_pages_range range number of returned pages
|
626 |
+
* @arg string iwp_get_pages_publish on or off
|
627 |
+
* @arg string iwp_get_pages_pending on or off
|
628 |
+
* @arg string iwp_get_pages_private on or off
|
629 |
+
* @arg string iwp_get_pages_future on or off
|
630 |
+
* @arg string iwp_get_pages_draft on or off
|
631 |
+
* @arg string iwp_get_pages_trash on or off
|
632 |
+
* @return array pages related to args
|
633 |
+
*/
|
634 |
+
function get_pages($args){
|
635 |
+
global $wpdb;
|
636 |
+
|
637 |
+
$where='';
|
638 |
+
extract($args);
|
639 |
+
|
640 |
+
if(!empty($filter_pages))
|
641 |
+
{
|
642 |
+
$where.=" AND post_title LIKE '%".mysql_real_escape_string($filter_pages)."%'";
|
643 |
+
}
|
644 |
+
if(!empty($iwp_get_pages_date_from) && !empty($iwp_get_pages_date_to))
|
645 |
+
{
|
646 |
+
$where.=" AND post_date BETWEEN '".mysql_real_escape_string($iwp_get_pages_date_from)."' AND '".mysql_real_escape_string($iwp_get_pages_date_to)."'";
|
647 |
+
}
|
648 |
+
else if(!empty($iwp_get_pages_date_from) && empty($iwp_get_pages_date_to))
|
649 |
+
{
|
650 |
+
$where.=" AND post_date >= '".mysql_real_escape_string($iwp_get_pages_date_from)."'";
|
651 |
+
}
|
652 |
+
else if(empty($iwp_get_pages_date_from) && !empty($iwp_get_pages_date_to))
|
653 |
+
{
|
654 |
+
$where.=" AND post_date <= '".mysql_real_escape_string($iwp_get_pages_date_to)."'";
|
655 |
+
}
|
656 |
+
|
657 |
+
$post_array=array();
|
658 |
+
$post_statuses = array('publish', 'pending', 'private', 'future', 'draft', 'trash');
|
659 |
+
foreach ($args as $checkbox => $checkbox_val)
|
660 |
+
{
|
661 |
+
if($checkbox_val=="on") {
|
662 |
+
$post_array[]="'".str_replace("iwp_get_pages_","",$checkbox)."'";
|
663 |
+
}
|
664 |
+
}
|
665 |
+
if(!empty($post_array))
|
666 |
+
{
|
667 |
+
$where.=" AND post_status IN (".implode(",",$post_array).")";
|
668 |
+
}
|
669 |
+
|
670 |
+
$limit = ($iwp_get_pages_range) ? ' LIMIT ' . mysql_real_escape_string($iwp_get_pages_range) : ' LIMIT 500';
|
671 |
+
|
672 |
+
$sql_query = "$wpdb->posts WHERE post_status!='auto-draft' AND post_status!='inherit' AND post_type='page' ".$where.' ORDER BY post_date DESC';
|
673 |
+
|
674 |
+
$total = array();
|
675 |
+
$posts = array();
|
676 |
+
$posts_info = $wpdb->get_results("SELECT * FROM ".$sql_query.$limit);
|
677 |
+
$user_info = $this->getUsersIDs();
|
678 |
+
$total['total_num']=count($posts_info);
|
679 |
+
|
680 |
+
if($iwp_get_pages_range && !empty($iwp_get_pages_date_from) && !empty($iwp_get_pages_date_to) && $total['total_num'] < $iwp_get_pages_range) {
|
681 |
+
$sql_query = "$wpdb->posts
|
682 |
+
WHERE post_status!='auto-draft' AND post_status!='inherit' AND post_type='post' AND post_date <= '".mysql_real_escape_string($iwp_get_pages_date_to)."'
|
683 |
+
ORDER BY post_date DESC
|
684 |
+
LIMIT " . mysql_real_escape_string($iwp_get_pages_range);
|
685 |
+
|
686 |
+
$posts_info = $wpdb->get_results("SELECT * FROM ".$sql_query);
|
687 |
+
$total = array();
|
688 |
+
$total['total_num']=count($posts_info);
|
689 |
+
}
|
690 |
+
|
691 |
+
foreach ( $posts_info as $post_info )
|
692 |
+
{
|
693 |
+
|
694 |
+
$posts[]=array(
|
695 |
+
'post_id'=>$post_info->ID,
|
696 |
+
'post_title'=>$post_info->post_title,
|
697 |
+
'post_name'=>$post_info->post_name,
|
698 |
+
'post_author'=>array('author_id'=>$post_info->post_author, 'author_name'=>$user_info[$post_info->post_author]),
|
699 |
+
'post_date'=>$post_info->post_date,
|
700 |
+
'post_modified'=>$post_info->post_modified,
|
701 |
+
'post_status'=>$post_info->post_status,
|
702 |
+
'post_type'=>$post_info->post_type,
|
703 |
+
'guid'=>$post_info->guid,
|
704 |
+
'post_password'=>$post_info->post_password,
|
705 |
+
'ping_status'=>$post_info->ping_status,
|
706 |
+
'comment_status'=>$post_info->comment_status,
|
707 |
+
'comment_count'=>$post_info->comment_count
|
708 |
+
|
709 |
+
);
|
710 |
+
}
|
711 |
+
|
712 |
+
return array('pages' => $posts, 'total' => $total);
|
713 |
+
}
|
714 |
+
|
715 |
+
function delete_page($args){
|
716 |
+
global $wpdb;
|
717 |
+
if(!empty($args['post_id']) && !empty($args['action']))
|
718 |
+
{
|
719 |
+
if($args['action']=='delete')
|
720 |
+
{
|
721 |
+
$delete_query = "UPDATE $wpdb->posts SET post_status = 'trash' WHERE ID = ".$args['post_id'];
|
722 |
+
}
|
723 |
+
else if($args['action']=='delete_perm'){
|
724 |
+
$delete_query = "DELETE FROM $wpdb->posts WHERE ID = ".$args['post_id'];
|
725 |
+
}
|
726 |
+
else if($args['action']=='delete_restore'){
|
727 |
+
$delete_query = "UPDATE $wpdb->posts SET post_status = 'publish' WHERE ID = ".$args['post_id'];
|
728 |
+
}
|
729 |
+
$wpdb->get_results($delete_query);
|
730 |
+
|
731 |
+
return 'Page deleted.';
|
732 |
+
}
|
733 |
+
else
|
734 |
+
{
|
735 |
+
return 'No ID...';
|
736 |
+
}
|
737 |
+
}
|
738 |
+
|
739 |
+
function getPostCats($taxonomy = 'category')
|
740 |
+
{
|
741 |
+
global $wpdb;
|
742 |
+
|
743 |
+
$cats = $wpdb->get_results("SELECT p.ID AS post_id, $wpdb->terms.name
|
744 |
+
FROM $wpdb->posts AS p
|
745 |
+
INNER JOIN $wpdb->term_relationships ON ( p.ID = $wpdb->term_relationships.object_id )
|
746 |
+
INNER JOIN $wpdb->term_taxonomy ON ( $wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id
|
747 |
+
AND $wpdb->term_taxonomy.taxonomy = '".$taxonomy."' )
|
748 |
+
INNER JOIN $wpdb->terms ON ( $wpdb->term_taxonomy.term_id = $wpdb->terms.term_id )");
|
749 |
+
|
750 |
+
foreach ( $cats as $post_val )
|
751 |
+
{
|
752 |
+
|
753 |
+
$post_cats[$post_val->post_id][] = $post_val->name;
|
754 |
+
}
|
755 |
+
|
756 |
+
return $post_cats;
|
757 |
+
}
|
758 |
+
|
759 |
+
function getUsersIDs()
|
760 |
+
{
|
761 |
+
global $wpdb;
|
762 |
+
$users_authors=array();
|
763 |
+
$users = $wpdb->get_results("SELECT ID as user_id, display_name FROM $wpdb->users WHERE user_status=0");
|
764 |
+
|
765 |
+
foreach ( $users as $user_key=>$user_val )
|
766 |
+
{
|
767 |
+
$users_authors[$user_val->user_id] = $user_val->display_name;
|
768 |
+
}
|
769 |
+
|
770 |
+
return $users_authors;
|
771 |
+
}
|
772 |
+
}
|
773 |
+
?>
|
backup.class.php
CHANGED
@@ -22,18 +22,18 @@ $zip_errors = array(
|
|
22 |
'No error',
|
23 |
'No error',
|
24 |
'Unexpected end of zip file',
|
25 |
-
'A generic error in the zipfile format was detected
|
26 |
'zip was unable to allocate itself memory',
|
27 |
'A severe error in the zipfile format was detected',
|
28 |
'Entry too large to be split with zipsplit',
|
29 |
'Invalid comment format',
|
30 |
'zip -T failed or out of memory',
|
31 |
'The user aborted zip prematurely',
|
32 |
-
'zip encountered an error while using a temp file',
|
33 |
'Read or seek error',
|
34 |
'zip has nothing to do',
|
35 |
'Missing or empty zip file',
|
36 |
-
'Error writing to a file',
|
37 |
'zip was unable to create a file to write to',
|
38 |
'bad command line parameters',
|
39 |
'no error',
|
@@ -596,29 +596,31 @@ if (isset($account_info['iwp_ftp']) && !empty($account_info['iwp_ftp'])) {
|
|
596 |
$disable_comp = $this->tasks[$task_name]['task_args']['disable_comp'];
|
597 |
$comp_level = $disable_comp ? '-0' : '-1';
|
598 |
$zip = $this->get_zip();
|
|
|
599 |
//Add database file
|
600 |
chdir(IWP_BACKUP_DIR);
|
601 |
$command = "$zip -q -r $comp_level $backup_file 'iwp_db'";
|
602 |
ob_start();
|
603 |
$result = $this->iwp_mmb_exec($command);
|
604 |
ob_get_clean();
|
605 |
-
echo "\n".'DB ZIP CMD';
|
606 |
/*zip_backup_db*/
|
607 |
|
608 |
if(!$result){
|
609 |
$zip_archive_db_result = false;
|
610 |
if (class_exists("ZipArchive")) {
|
|
|
611 |
$this->_log("DB zip, fallback to ZipArchive");
|
612 |
$zip_archive_db_result = $this->zip_archive_backup_db($task_name, $db_result, $backup_file);
|
613 |
-
echo "\n".'DB ZIP Archive';
|
614 |
}
|
615 |
|
616 |
if (!$zip_archive_db_result) {
|
617 |
-
echo "\n".'DB ZIP PCL';
|
618 |
define('PCLZIP_TEMPORARY_DIR', IWP_BACKUP_DIR . '/');
|
619 |
require_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.php';
|
620 |
$archive = new IWPPclZip($backup_file);
|
621 |
-
|
622 |
if($fail_safe_files && $disable_comp){
|
623 |
$result_db = $archive->add(IWP_DB_DIR, PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR, PCLZIP_OPT_NO_COMPRESSION, PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1);
|
624 |
}
|
@@ -631,6 +633,7 @@ if (isset($account_info['iwp_ftp']) && !empty($account_info['iwp_ftp'])) {
|
|
631 |
else{
|
632 |
$result_db = $archive->add(IWP_DB_DIR, PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR);
|
633 |
}
|
|
|
634 |
|
635 |
@unlink($db_result);
|
636 |
@unlink(IWP_BACKUP_DIR.'/iwp_db/index.php');
|
@@ -675,23 +678,21 @@ if (isset($account_info['iwp_ftp']) && !empty($account_info['iwp_ftp'])) {
|
|
675 |
$exclude_data .= " $data/*.*";
|
676 |
else
|
677 |
$exclude_data .= " '$data/*'";
|
678 |
-
|
679 |
-
|
680 |
-
} else {
|
681 |
if ($sys == 'WIN'){
|
682 |
if(file_exists(ABSPATH . $data)){
|
683 |
-
|
684 |
$exclude_file_data .= " $data";
|
685 |
}
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
|
696 |
if($exclude_file_data){
|
697 |
$exclude_file_data = "-x".$exclude_file_data;
|
@@ -704,7 +705,7 @@ if (isset($account_info['iwp_ftp']) && !empty($account_info['iwp_ftp'])) {
|
|
704 |
$exclude_data .= " $data/*.*";
|
705 |
else
|
706 |
$exclude_data .= " '$data/*'";
|
707 |
-
}
|
708 |
|
709 |
//Include paths by default
|
710 |
$add = array(
|
@@ -737,37 +738,63 @@ if (isset($account_info['iwp_ftp']) && !empty($account_info['iwp_ftp'])) {
|
|
737 |
|
738 |
$this->update_status($task_name, $this->statuses['files_zip']);
|
739 |
chdir(ABSPATH);
|
740 |
-
|
741 |
-
|
|
|
|
|
|
|
|
|
|
|
742 |
$result_f = $this->iwp_mmb_exec($command, false, true);
|
743 |
-
|
|
|
744 |
$command = "$zip -q -r $comp_level $backup_file $include_data $exclude_data";
|
745 |
-
|
|
|
|
|
746 |
if ($result_d && $result_d != 18) {
|
747 |
@unlink($backup_file);
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
756 |
}
|
757 |
}
|
758 |
-
|
759 |
-
|
760 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
761 |
$zip_archive_result = false;
|
762 |
if (class_exists("ZipArchive")) {
|
|
|
763 |
$this->_log("Files zip fallback to ZipArchive");
|
764 |
$zip_archive_result = $this->zip_archive_backup($task_name, $backup_file, $exclude, $include);
|
765 |
-
echo "\n".'Files ZIP Archive';
|
766 |
}
|
767 |
|
768 |
|
769 |
if (!$zip_archive_result) { //Try pclZip
|
770 |
-
echo "\n".'Files ZIP PCL';
|
771 |
if (!isset($archive)) {
|
772 |
define('PCLZIP_TEMPORARY_DIR', IWP_BACKUP_DIR . '/');
|
773 |
//require_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
|
@@ -827,6 +854,8 @@ if (isset($account_info['iwp_ftp']) && !empty($account_info['iwp_ftp'])) {
|
|
827 |
$result = $archive->add($include_data, PCLZIP_OPT_REMOVE_PATH, ABSPATH, PCLZIP_OPT_IWP_EXCLUDE, $exclude_data);
|
828 |
}
|
829 |
|
|
|
|
|
830 |
if (!$result) {
|
831 |
@unlink($backup_file);
|
832 |
return array(
|
@@ -960,10 +989,11 @@ if (isset($account_info['iwp_ftp']) && !empty($account_info['iwp_ftp'])) {
|
|
960 |
$paths = $this->check_mysql_paths();
|
961 |
$brace = (substr(PHP_OS, 0, 3) == 'WIN') ? '"' : '';
|
962 |
$command = $brace . $paths['mysqldump'] . $brace . ' --force --host="' . DB_HOST . '" --user="' . DB_USER . '" --password="' . DB_PASSWORD . '" --add-drop-table --skip-lock-tables "' . DB_NAME . '" > ' . $brace . $file . $brace;
|
|
|
963 |
ob_start();
|
964 |
$result = $this->iwp_mmb_exec($command);
|
965 |
ob_get_clean();
|
966 |
-
echo "\n".'DB DUMP CMD';
|
967 |
|
968 |
if (!$result) { // Fallback to php
|
969 |
$result = $this->backup_db_php($file);
|
@@ -983,7 +1013,7 @@ if (isset($account_info['iwp_ftp']) && !empty($account_info['iwp_ftp'])) {
|
|
983 |
global $wpdb;
|
984 |
|
985 |
if(empty($GLOBALS['fail_safe_db'])){
|
986 |
-
echo "\n".'DB DUMP PHP Normal';
|
987 |
$fp = fopen( $file, 'w' );
|
988 |
if ( !mysql_ping( $wpdb->dbh ) ) {
|
989 |
mysql_connect( DB_HOST, DB_USER, DB_PASSWORD );
|
@@ -1064,9 +1094,11 @@ if (isset($account_info['iwp_ftp']) && !empty($account_info['iwp_ftp'])) {
|
|
1064 |
}
|
1065 |
fclose( $fp );
|
1066 |
unset ($fp);
|
|
|
1067 |
}
|
1068 |
else{
|
1069 |
-
echo "\n".'DB DUMP PHP Fail-safe';
|
|
|
1070 |
$tables = $wpdb->get_results('SHOW TABLES', ARRAY_N);
|
1071 |
foreach ($tables as $table) {
|
1072 |
//drop existing table
|
@@ -1111,6 +1143,7 @@ if (isset($account_info['iwp_ftp']) && !empty($account_info['iwp_ftp'])) {
|
|
1111 |
unset($rows);
|
1112 |
unset($dump_data);
|
1113 |
}
|
|
|
1114 |
}
|
1115 |
|
1116 |
if (filesize($file) == 0 || !is_file($file)) {
|
@@ -1126,6 +1159,7 @@ if (isset($account_info['iwp_ftp']) && !empty($account_info['iwp_ftp'])) {
|
|
1126 |
|
1127 |
function restore($args)
|
1128 |
{
|
|
|
1129 |
global $wpdb;
|
1130 |
if (empty($args)) {
|
1131 |
return false;
|
@@ -1153,13 +1187,8 @@ if (isset($account_info['iwp_ftp']) && !empty($account_info['iwp_ftp'])) {
|
|
1153 |
if (isset($task['task_results'][$result_id]['server'])) {
|
1154 |
$backup_file = $task['task_results'][$result_id]['server']['file_path'];
|
1155 |
$unlink_file = false; //Don't delete file if stored on server
|
1156 |
-
|
1157 |
-
|
1158 |
-
/*
|
1159 |
-
//IWP Remove starts here//IWP Remove ends here
|
1160 |
-
*/
|
1161 |
-
|
1162 |
-
elseif (isset($task['task_results'][$result_id]['ftp'])) {
|
1163 |
$ftp_file = $task['task_results'][$result_id]['ftp'];
|
1164 |
$args = $task['task_args']['account_info']['iwp_ftp'];
|
1165 |
$args['backup_file'] = $ftp_file;
|
@@ -1230,9 +1259,10 @@ elseif (isset($task['task_results'][$result_id]['ftp'])) {
|
|
1230 |
|
1231 |
} else {
|
1232 |
$restore_options = array();
|
1233 |
-
$restore_options['iwp_client_notifications'] = get_option('iwp_client_notifications');
|
1234 |
-
$restore_options['iwp_client_pageview_alerts'] = get_option('iwp_client_pageview_alerts');
|
1235 |
-
$restore_options['iwp_client_user_hit_count'] = get_option('iwp_client_user_hit_count');
|
|
|
1236 |
}
|
1237 |
|
1238 |
|
@@ -1250,6 +1280,7 @@ elseif (isset($task['task_results'][$result_id]['ftp'])) {
|
|
1250 |
$archive = new IWPPclZip($backup_file);
|
1251 |
$result = $archive->extract(PCLZIP_OPT_PATH, ABSPATH, PCLZIP_OPT_REPLACE_NEWER);
|
1252 |
}
|
|
|
1253 |
|
1254 |
if ($unlink_file) {
|
1255 |
@unlink($backup_file);
|
@@ -1371,15 +1402,25 @@ elseif (isset($task['task_results'][$result_id]['ftp'])) {
|
|
1371 |
//Check for .htaccess permalinks update
|
1372 |
$this->replace_htaccess($home);
|
1373 |
} else {
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1383 |
|
1384 |
return !empty($new_user) ? $new_user : true ;
|
1385 |
}
|
@@ -1416,7 +1457,9 @@ elseif (isset($task['task_results'][$result_id]['ftp'])) {
|
|
1416 |
|
1417 |
function restore_db_php($file_name)
|
1418 |
{
|
1419 |
-
|
|
|
|
|
1420 |
$current_query = '';
|
1421 |
// Read in entire file
|
1422 |
$lines = file($file_name);
|
@@ -1680,7 +1723,7 @@ function ftp_backup($args)
|
|
1680 |
}
|
1681 |
} else {
|
1682 |
return array(
|
1683 |
-
'error' => 'Your server doesn\'t support
|
1684 |
'partial' => 1
|
1685 |
);
|
1686 |
}
|
@@ -2423,7 +2466,7 @@ function get_next_schedules()
|
|
2423 |
}
|
2424 |
|
2425 |
}
|
2426 |
-
if (isset($task['account_info']) && is_array($task['account_info'])) { //only if sends from
|
2427 |
$task['args']['account_info'] = $task['account_info'];
|
2428 |
}
|
2429 |
|
22 |
'No error',
|
23 |
'No error',
|
24 |
'Unexpected end of zip file',
|
25 |
+
'A generic error in the zipfile format was detected',
|
26 |
'zip was unable to allocate itself memory',
|
27 |
'A severe error in the zipfile format was detected',
|
28 |
'Entry too large to be split with zipsplit',
|
29 |
'Invalid comment format',
|
30 |
'zip -T failed or out of memory',
|
31 |
'The user aborted zip prematurely',
|
32 |
+
'zip encountered an error while using a temp file. Please check if this domain\'s account has enough disk space.',
|
33 |
'Read or seek error',
|
34 |
'zip has nothing to do',
|
35 |
'Missing or empty zip file',
|
36 |
+
'Error writing to a file. Please check if this domain\'s account has enough disk space.',
|
37 |
'zip was unable to create a file to write to',
|
38 |
'bad command line parameters',
|
39 |
'no error',
|
596 |
$disable_comp = $this->tasks[$task_name]['task_args']['disable_comp'];
|
597 |
$comp_level = $disable_comp ? '-0' : '-1';
|
598 |
$zip = $this->get_zip();
|
599 |
+
echo "\n".'DB ZIP CMD: Start';
|
600 |
//Add database file
|
601 |
chdir(IWP_BACKUP_DIR);
|
602 |
$command = "$zip -q -r $comp_level $backup_file 'iwp_db'";
|
603 |
ob_start();
|
604 |
$result = $this->iwp_mmb_exec($command);
|
605 |
ob_get_clean();
|
606 |
+
echo "\n".'DB ZIP CMD: End';
|
607 |
/*zip_backup_db*/
|
608 |
|
609 |
if(!$result){
|
610 |
$zip_archive_db_result = false;
|
611 |
if (class_exists("ZipArchive")) {
|
612 |
+
echo "\n".'DB ZIP Archive: Start';
|
613 |
$this->_log("DB zip, fallback to ZipArchive");
|
614 |
$zip_archive_db_result = $this->zip_archive_backup_db($task_name, $db_result, $backup_file);
|
615 |
+
echo "\n".'DB ZIP Archive: End';
|
616 |
}
|
617 |
|
618 |
if (!$zip_archive_db_result) {
|
619 |
+
echo "\n".'DB ZIP PCL: Start';
|
620 |
define('PCLZIP_TEMPORARY_DIR', IWP_BACKUP_DIR . '/');
|
621 |
require_once $GLOBALS['iwp_mmb_plugin_dir'].'/pclzip.class.php';
|
622 |
$archive = new IWPPclZip($backup_file);
|
623 |
+
|
624 |
if($fail_safe_files && $disable_comp){
|
625 |
$result_db = $archive->add(IWP_DB_DIR, PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR, PCLZIP_OPT_NO_COMPRESSION, PCLZIP_OPT_TEMP_FILE_THRESHOLD, 1);
|
626 |
}
|
633 |
else{
|
634 |
$result_db = $archive->add(IWP_DB_DIR, PCLZIP_OPT_REMOVE_PATH, IWP_BACKUP_DIR);
|
635 |
}
|
636 |
+
echo "\n".'DB ZIP PCL: End';
|
637 |
|
638 |
@unlink($db_result);
|
639 |
@unlink(IWP_BACKUP_DIR.'/iwp_db/index.php');
|
678 |
$exclude_data .= " $data/*.*";
|
679 |
else
|
680 |
$exclude_data .= " '$data/*'";
|
681 |
+
}else {
|
|
|
|
|
682 |
if ($sys == 'WIN'){
|
683 |
if(file_exists(ABSPATH . $data)){
|
684 |
+
$exclude_data .= " $data";
|
685 |
$exclude_file_data .= " $data";
|
686 |
}
|
687 |
+
}else {
|
688 |
+
if(file_exists(ABSPATH . $data)){
|
689 |
+
$exclude_data .= " '$data'";
|
690 |
+
$exclude_file_data .= " '$data'";
|
691 |
+
}
|
692 |
+
}
|
693 |
+
}
|
694 |
+
}
|
695 |
+
}
|
696 |
|
697 |
if($exclude_file_data){
|
698 |
$exclude_file_data = "-x".$exclude_file_data;
|
705 |
$exclude_data .= " $data/*.*";
|
706 |
else
|
707 |
$exclude_data .= " '$data/*'";
|
708 |
+
}*/ //commented for pclzip modifications
|
709 |
|
710 |
//Include paths by default
|
711 |
$add = array(
|
738 |
|
739 |
$this->update_status($task_name, $this->statuses['files_zip']);
|
740 |
chdir(ABSPATH);
|
741 |
+
|
742 |
+
$do_cmd_zip_alternative = false;
|
743 |
+
@copy($backup_file, $backup_file.'_2');
|
744 |
+
|
745 |
+
echo "\n".'Files ZIP CMD: Start';
|
746 |
+
$command = "$zip -q -j $comp_level $backup_file .* * $exclude_file_data";
|
747 |
+
ob_start();
|
748 |
$result_f = $this->iwp_mmb_exec($command, false, true);
|
749 |
+
ob_get_clean();
|
750 |
+
if (!$result_f || $result_f == 18) { // disregard permissions error, file can't be accessed
|
751 |
$command = "$zip -q -r $comp_level $backup_file $include_data $exclude_data";
|
752 |
+
ob_start();
|
753 |
+
$result_d = $this->iwp_mmb_exec($command, false, true);
|
754 |
+
ob_get_clean();
|
755 |
if ($result_d && $result_d != 18) {
|
756 |
@unlink($backup_file);
|
757 |
+
$do_cmd_zip_alternative = true;
|
758 |
+
|
759 |
+
|
760 |
+
if($result_d > 0 && $result_d < 18){
|
761 |
+
//return array(
|
762 |
+
// 'error' => 'Failed to archive files (' . $zip_errors[$result_d] . ') .'
|
763 |
+
// );
|
764 |
+
echo "\n".'Files ZIP CMD: Failed to archive files (' . $zip_errors[$result_d] . ') .';
|
765 |
+
}
|
766 |
+
else{
|
767 |
+
//return array(
|
768 |
+
// 'error' => 'Failed to archive files.'
|
769 |
+
//);
|
770 |
+
echo "\n".'Files ZIP CMD: Failed to archive files.';
|
771 |
+
}
|
772 |
}
|
773 |
}
|
774 |
+
|
775 |
+
if(!$do_cmd_zip_alternative){//if FILE ZIP CMD successful
|
776 |
+
@unlink($backup_file.'_2');
|
777 |
+
}
|
778 |
+
|
779 |
+
echo "\n".'Files ZIP CMD: End';
|
780 |
+
if (($result_f && $result_f != 18) || ($do_cmd_zip_alternative)) {
|
781 |
+
|
782 |
+
if($do_cmd_zip_alternative){
|
783 |
+
@copy($backup_file.'_2', $backup_file);
|
784 |
+
@unlink($backup_file.'_2');
|
785 |
+
}
|
786 |
+
|
787 |
$zip_archive_result = false;
|
788 |
if (class_exists("ZipArchive")) {
|
789 |
+
echo "\n".'Files ZIP Archive: Start';
|
790 |
$this->_log("Files zip fallback to ZipArchive");
|
791 |
$zip_archive_result = $this->zip_archive_backup($task_name, $backup_file, $exclude, $include);
|
792 |
+
echo "\n".'Files ZIP Archive: End';
|
793 |
}
|
794 |
|
795 |
|
796 |
if (!$zip_archive_result) { //Try pclZip
|
797 |
+
echo "\n".'Files ZIP PCL: Start';
|
798 |
if (!isset($archive)) {
|
799 |
define('PCLZIP_TEMPORARY_DIR', IWP_BACKUP_DIR . '/');
|
800 |
//require_once ABSPATH . '/wp-admin/includes/class-pclzip.php';
|
854 |
$result = $archive->add($include_data, PCLZIP_OPT_REMOVE_PATH, ABSPATH, PCLZIP_OPT_IWP_EXCLUDE, $exclude_data);
|
855 |
}
|
856 |
|
857 |
+
echo "\n".'Files ZIP PCL: End';
|
858 |
+
|
859 |
if (!$result) {
|
860 |
@unlink($backup_file);
|
861 |
return array(
|
989 |
$paths = $this->check_mysql_paths();
|
990 |
$brace = (substr(PHP_OS, 0, 3) == 'WIN') ? '"' : '';
|
991 |
$command = $brace . $paths['mysqldump'] . $brace . ' --force --host="' . DB_HOST . '" --user="' . DB_USER . '" --password="' . DB_PASSWORD . '" --add-drop-table --skip-lock-tables "' . DB_NAME . '" > ' . $brace . $file . $brace;
|
992 |
+
echo "\n".'DB DUMP CMD: Start';
|
993 |
ob_start();
|
994 |
$result = $this->iwp_mmb_exec($command);
|
995 |
ob_get_clean();
|
996 |
+
echo "\n".'DB DUMP CMD: End';
|
997 |
|
998 |
if (!$result) { // Fallback to php
|
999 |
$result = $this->backup_db_php($file);
|
1013 |
global $wpdb;
|
1014 |
|
1015 |
if(empty($GLOBALS['fail_safe_db'])){
|
1016 |
+
echo "\n".'DB DUMP PHP Normal: Start';
|
1017 |
$fp = fopen( $file, 'w' );
|
1018 |
if ( !mysql_ping( $wpdb->dbh ) ) {
|
1019 |
mysql_connect( DB_HOST, DB_USER, DB_PASSWORD );
|
1094 |
}
|
1095 |
fclose( $fp );
|
1096 |
unset ($fp);
|
1097 |
+
echo "\n".'DB DUMP PHP Normal: End';
|
1098 |
}
|
1099 |
else{
|
1100 |
+
echo "\n".'DB DUMP PHP Fail-safe: Start';
|
1101 |
+
file_put_contents($file, '');//safe to reset any old data
|
1102 |
$tables = $wpdb->get_results('SHOW TABLES', ARRAY_N);
|
1103 |
foreach ($tables as $table) {
|
1104 |
//drop existing table
|
1143 |
unset($rows);
|
1144 |
unset($dump_data);
|
1145 |
}
|
1146 |
+
echo "\n".'DB DUMP PHP Fail-safe: End';
|
1147 |
}
|
1148 |
|
1149 |
if (filesize($file) == 0 || !is_file($file)) {
|
1159 |
|
1160 |
function restore($args)
|
1161 |
{
|
1162 |
+
|
1163 |
global $wpdb;
|
1164 |
if (empty($args)) {
|
1165 |
return false;
|
1187 |
if (isset($task['task_results'][$result_id]['server'])) {
|
1188 |
$backup_file = $task['task_results'][$result_id]['server']['file_path'];
|
1189 |
$unlink_file = false; //Don't delete file if stored on server
|
1190 |
+
|
1191 |
+
} elseif (isset($task['task_results'][$result_id]['ftp'])) {
|
|
|
|
|
|
|
|
|
|
|
1192 |
$ftp_file = $task['task_results'][$result_id]['ftp'];
|
1193 |
$args = $task['task_args']['account_info']['iwp_ftp'];
|
1194 |
$args['backup_file'] = $ftp_file;
|
1259 |
|
1260 |
} else {
|
1261 |
$restore_options = array();
|
1262 |
+
$restore_options['iwp_client_notifications'] = serialize(get_option('iwp_client_notifications'));
|
1263 |
+
$restore_options['iwp_client_pageview_alerts'] = serialize(get_option('iwp_client_pageview_alerts'));
|
1264 |
+
$restore_options['iwp_client_user_hit_count'] = serialize(get_option('iwp_client_user_hit_count'));
|
1265 |
+
$restore_options['iwp_client_backup_tasks'] = serialize(get_option('iwp_client_backup_tasks'));
|
1266 |
}
|
1267 |
|
1268 |
|
1280 |
$archive = new IWPPclZip($backup_file);
|
1281 |
$result = $archive->extract(PCLZIP_OPT_PATH, ABSPATH, PCLZIP_OPT_REPLACE_NEWER);
|
1282 |
}
|
1283 |
+
$this->wpdb_reconnect();
|
1284 |
|
1285 |
if ($unlink_file) {
|
1286 |
@unlink($backup_file);
|
1402 |
//Check for .htaccess permalinks update
|
1403 |
$this->replace_htaccess($home);
|
1404 |
} else {
|
1405 |
+
//restore client options
|
1406 |
+
if (is_array($restore_options) && !empty($restore_options)) {
|
1407 |
+
foreach ($restore_options as $key => $option) {
|
1408 |
+
if (!empty($key)) {
|
1409 |
+
$query = "SELECT option_value FROM " . $wpdb->base_prefix . "options WHERE option_name = %s";
|
1410 |
+
$res = $wpdb->get_var($wpdb->prepare($query, $key));
|
1411 |
+
if ($res == false) {
|
1412 |
+
$query = "INSERT INTO " . $wpdb->base_prefix . "options (option_value,option_name) VALUES(%s,%s)";
|
1413 |
+
$wpdb->query($wpdb->prepare($query, $option, $key));
|
1414 |
+
} else {
|
1415 |
+
$query = "UPDATE " . $wpdb->base_prefix . "options SET option_value = %s WHERE option_name = %s";
|
1416 |
+
$wpdb->query($wpdb->prepare($query, $option, $key));
|
1417 |
+
}
|
1418 |
+
}
|
1419 |
+
|
1420 |
+
/*$test = update_option($key,$option);*/
|
1421 |
+
}
|
1422 |
+
}
|
1423 |
+
}
|
1424 |
|
1425 |
return !empty($new_user) ? $new_user : true ;
|
1426 |
}
|
1457 |
|
1458 |
function restore_db_php($file_name)
|
1459 |
{
|
1460 |
+
|
1461 |
+
$this->wpdb_reconnect();
|
1462 |
+
global $wpdb;
|
1463 |
$current_query = '';
|
1464 |
// Read in entire file
|
1465 |
$lines = file($file_name);
|
1723 |
}
|
1724 |
} else {
|
1725 |
return array(
|
1726 |
+
'error' => 'Your server doesn\'t support FTP SSL',
|
1727 |
'partial' => 1
|
1728 |
);
|
1729 |
}
|
2466 |
}
|
2467 |
|
2468 |
}
|
2469 |
+
if (isset($task['account_info']) && is_array($task['account_info'])) { //only if sends from panel first time(secure data)
|
2470 |
$task['args']['account_info'] = $task['account_info'];
|
2471 |
}
|
2472 |
|
core.class.php
CHANGED
@@ -1,712 +1,746 @@
|
|
1 |
-
<?php
|
2 |
-
/************************************************************
|
3 |
-
* This plugin was modified by Revmakx *
|
4 |
-
* Copyright (c) 2012 Revmakx *
|
5 |
-
* www.revmakx.com *
|
6 |
-
* *
|
7 |
-
************************************************************/
|
8 |
-
/*************************************************************
|
9 |
-
*
|
10 |
-
* core.class.php
|
11 |
-
*
|
12 |
-
* Upgrade Plugins
|
13 |
-
*
|
14 |
-
*
|
15 |
-
* Copyright (c) 2011 Prelovac Media
|
16 |
-
* www.prelovac.com
|
17 |
-
**************************************************************/
|
18 |
-
|
19 |
-
class IWP_MMB_Core extends IWP_MMB_Helper
|
20 |
-
{
|
21 |
-
var $name;
|
22 |
-
var $slug;
|
23 |
-
var $settings;
|
24 |
-
var $remote_client;
|
25 |
-
var $comment_instance;
|
26 |
-
var $plugin_instance;
|
27 |
-
var $theme_instance;
|
28 |
-
var $wp_instance;
|
29 |
-
var $post_instance;
|
30 |
-
var $stats_instance;
|
31 |
-
var $search_instance;
|
32 |
-
var $links_instance;
|
33 |
-
var $user_instance;
|
34 |
-
var $backup_instance;
|
35 |
-
var $installer_instance;
|
36 |
-
var $iwp_mmb_multisite;
|
37 |
-
var $network_admin_install;
|
38 |
-
|
39 |
-
var $backup_repository_instance;
|
40 |
-
|
41 |
-
|
42 |
-
private $
|
43 |
-
private $
|
44 |
-
private $
|
45 |
-
private $
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
$this->
|
55 |
-
|
56 |
-
$this->
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
'
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
$this->
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
$this->
|
77 |
-
|
78 |
-
|
79 |
-
$this->
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
$_iwp_mmb_item_filter['
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
'
|
111 |
-
'
|
112 |
-
'
|
113 |
-
'
|
114 |
-
'
|
115 |
-
'
|
116 |
-
'
|
117 |
-
'
|
118 |
-
'
|
119 |
-
|
120 |
-
'
|
121 |
-
'
|
122 |
-
'
|
123 |
-
|
124 |
-
'
|
125 |
-
'
|
126 |
-
'
|
127 |
-
'
|
128 |
-
|
129 |
-
'
|
130 |
-
'
|
131 |
-
'
|
132 |
-
'
|
133 |
-
'
|
134 |
-
'
|
135 |
-
'
|
136 |
-
'
|
137 |
-
|
138 |
-
'
|
139 |
-
'
|
140 |
-
'
|
141 |
-
|
142 |
-
'
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
*
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
/**
|
406 |
-
* Gets an instance of
|
407 |
-
*
|
408 |
-
*/
|
409 |
-
function
|
410 |
-
{
|
411 |
-
if (!isset($this->
|
412 |
-
$this->
|
413 |
-
}
|
414 |
-
|
415 |
-
return $this->
|
416 |
-
}
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
712 |
?>
|
1 |
+
<?php
|
2 |
+
/************************************************************
|
3 |
+
* This plugin was modified by Revmakx *
|
4 |
+
* Copyright (c) 2012 Revmakx *
|
5 |
+
* www.revmakx.com *
|
6 |
+
* *
|
7 |
+
************************************************************/
|
8 |
+
/*************************************************************
|
9 |
+
*
|
10 |
+
* core.class.php
|
11 |
+
*
|
12 |
+
* Upgrade Plugins
|
13 |
+
*
|
14 |
+
*
|
15 |
+
* Copyright (c) 2011 Prelovac Media
|
16 |
+
* www.prelovac.com
|
17 |
+
**************************************************************/
|
18 |
+
|
19 |
+
class IWP_MMB_Core extends IWP_MMB_Helper
|
20 |
+
{
|
21 |
+
var $name;
|
22 |
+
var $slug;
|
23 |
+
var $settings;
|
24 |
+
var $remote_client;
|
25 |
+
var $comment_instance;
|
26 |
+
var $plugin_instance;
|
27 |
+
var $theme_instance;
|
28 |
+
var $wp_instance;
|
29 |
+
var $post_instance;
|
30 |
+
var $stats_instance;
|
31 |
+
var $search_instance;
|
32 |
+
var $links_instance;
|
33 |
+
var $user_instance;
|
34 |
+
var $backup_instance;
|
35 |
+
var $installer_instance;
|
36 |
+
var $iwp_mmb_multisite;
|
37 |
+
var $network_admin_install;
|
38 |
+
|
39 |
+
var $backup_repository_instance;
|
40 |
+
var $optimize_instance;
|
41 |
+
|
42 |
+
private $action_call;
|
43 |
+
private $action_params;
|
44 |
+
private $iwp_mmb_pre_init_actions;
|
45 |
+
private $iwp_mmb_pre_init_filters;
|
46 |
+
private $iwp_mmb_init_actions;
|
47 |
+
|
48 |
+
|
49 |
+
function __construct()
|
50 |
+
{
|
51 |
+
global $iwp_mmb_plugin_dir, $wpmu_version, $blog_id, $_iwp_mmb_plugin_actions, $_iwp_mmb_item_filter;
|
52 |
+
|
53 |
+
$_iwp_mmb_plugin_actions = array();
|
54 |
+
$this->name = 'Manage Multiple Blogs';
|
55 |
+
$this->slug = 'manage-multiple-blogs';
|
56 |
+
$this->action_call = null;
|
57 |
+
$this->action_params = null;
|
58 |
+
|
59 |
+
|
60 |
+
$this->settings = get_option($this->slug);
|
61 |
+
if (!$this->settings) {
|
62 |
+
$this->settings = array(
|
63 |
+
'blogs' => array(),
|
64 |
+
'current_blog' => array(
|
65 |
+
'type' => null
|
66 |
+
)
|
67 |
+
);
|
68 |
+
$this->save_options();
|
69 |
+
}
|
70 |
+
if ( function_exists('is_multisite') ) {
|
71 |
+
if ( is_multisite() ) {
|
72 |
+
$this->iwp_mmb_multisite = $blog_id;
|
73 |
+
$this->network_admin_install = get_option('iwp_client_network_admin_install');
|
74 |
+
}
|
75 |
+
} else if (!empty($wpmu_version)) {
|
76 |
+
$this->iwp_mmb_multisite = $blog_id;
|
77 |
+
$this->network_admin_install = get_option('iwp_client_network_admin_install');
|
78 |
+
} else {
|
79 |
+
$this->iwp_mmb_multisite = false;
|
80 |
+
$this->network_admin_install = null;
|
81 |
+
}
|
82 |
+
|
83 |
+
// admin notices
|
84 |
+
if ( !get_option('iwp_client_public_key') ){
|
85 |
+
if( $this->iwp_mmb_multisite ){
|
86 |
+
if( is_network_admin() && $this->network_admin_install == '1'){
|
87 |
+
add_action('network_admin_notices', array( &$this, 'network_admin_notice' ));
|
88 |
+
} else if( $this->network_admin_install != '1' ){
|
89 |
+
//$parent_key = $this->get_parent_blog_option('iwp_client_public_key');//IWP commented to show notice to all subsites of network
|
90 |
+
//if(empty($parent_key))//IWP commented to show notice to all subsites of network
|
91 |
+
add_action('admin_notices', array( &$this, 'admin_notice' ));
|
92 |
+
}
|
93 |
+
} else {
|
94 |
+
add_action('admin_notices', array( &$this, 'admin_notice' ));
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
// default filters
|
99 |
+
//$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
|
100 |
+
$this->iwp_mmb_pre_init_filters['get_stats']['iwp_mmb_stats_filter'][] = 'iwp_mmb_pre_init_stats';
|
101 |
+
|
102 |
+
$_iwp_mmb_item_filter['pre_init_stats'] = array( 'core_update', 'hit_counter', 'comments', 'backups', 'posts', 'drafts', 'scheduled' );
|
103 |
+
$_iwp_mmb_item_filter['get'] = array( 'updates', 'errors' );
|
104 |
+
|
105 |
+
$this->iwp_mmb_pre_init_actions = array(
|
106 |
+
'backup_req' => 'iwp_mmb_get_backup_req',
|
107 |
+
);
|
108 |
+
|
109 |
+
$this->iwp_mmb_init_actions = array(
|
110 |
+
'do_upgrade' => 'iwp_mmb_do_upgrade',
|
111 |
+
'get_stats' => 'iwp_mmb_stats_get',
|
112 |
+
'remove_site' => 'iwp_mmb_remove_site',
|
113 |
+
'backup_clone' => 'iwp_mmb_backup_now',
|
114 |
+
'restore' => 'iwp_mmb_restore_now',
|
115 |
+
'optimize_tables' => 'iwp_mmb_optimize_tables',
|
116 |
+
'check_wp_version' => 'iwp_mmb_wp_checkversion',
|
117 |
+
'create_post' => 'iwp_mmb_post_create',
|
118 |
+
'update_client' => 'iwp_mmb_update_client_plugin',
|
119 |
+
|
120 |
+
'change_comment_status' => 'iwp_mmb_change_comment_status',
|
121 |
+
'change_post_status' => 'iwp_mmb_change_post_status',
|
122 |
+
'get_comment_stats' => 'iwp_mmb_comment_stats_get',
|
123 |
+
|
124 |
+
'get_links' => 'iwp_mmb_get_links',
|
125 |
+
'add_link' => 'iwp_mmb_add_link',
|
126 |
+
'delete_link' => 'iwp_mmb_delete_link',
|
127 |
+
'delete_links' => 'iwp_mmb_delete_links',
|
128 |
+
|
129 |
+
'create_post' => 'iwp_mmb_post_create',
|
130 |
+
'change_post_status' => 'iwp_mmb_change_post_status',
|
131 |
+
'get_posts' => 'iwp_mmb_get_posts',
|
132 |
+
'delete_post' => 'iwp_mmb_delete_post',
|
133 |
+
'delete_posts' => 'iwp_mmb_delete_posts',
|
134 |
+
'edit_posts' => 'iwp_mmb_edit_posts',
|
135 |
+
'get_pages' => 'iwp_mmb_get_pages',
|
136 |
+
'delete_page' => 'iwp_mmb_delete_page',
|
137 |
+
|
138 |
+
'install_addon' => 'iwp_mmb_install_addon',
|
139 |
+
'add_link' => 'iwp_mmb_add_link',
|
140 |
+
'add_user' => 'iwp_mmb_add_user',
|
141 |
+
'email_backup' => 'iwp_mmb_email_backup',
|
142 |
+
'check_backup_compat' => 'iwp_mmb_check_backup_compat',
|
143 |
+
'scheduled_backup' => 'iwp_mmb_scheduled_backup',
|
144 |
+
'run_task' => 'iwp_mmb_run_task_now',
|
145 |
+
'delete_schedule_task' => 'iwp_mmb_delete_task_now',
|
146 |
+
'execute_php_code' => 'iwp_mmb_execute_php_code',
|
147 |
+
'delete_backup' => 'mmm_delete_backup',
|
148 |
+
'remote_backup_now' => 'iwp_mmb_remote_backup_now',
|
149 |
+
'set_notifications' => 'iwp_mmb_set_notifications',
|
150 |
+
'clean_orphan_backups' => 'iwp_mmb_clean_orphan_backups',
|
151 |
+
'get_users' => 'iwp_mmb_get_users',
|
152 |
+
'edit_users' => 'iwp_mmb_edit_users',
|
153 |
+
'get_plugins_themes' => 'iwp_mmb_get_plugins_themes',
|
154 |
+
'edit_plugins_themes' => 'iwp_mmb_edit_plugins_themes',
|
155 |
+
'get_comments' => 'iwp_mmb_get_comments',
|
156 |
+
'action_comment' => 'iwp_mmb_action_comment',
|
157 |
+
'bulk_action_comments' => 'iwp_mmb_bulk_action_comments',
|
158 |
+
'replyto_comment' => 'iwp_mmb_reply_comment',
|
159 |
+
'client_brand' => 'iwp_mmb_client_brand',
|
160 |
+
'set_alerts' => 'iwp_mmb_set_alerts',
|
161 |
+
'maintenance' => 'iwp_mmb_maintenance_mode',
|
162 |
+
|
163 |
+
'backup_repository' => 'iwp_mmb_backup_repository'
|
164 |
+
);
|
165 |
+
|
166 |
+
add_action('rightnow_end', array( &$this, 'add_right_now_info' ));
|
167 |
+
add_action('admin_init', array(&$this,'admin_actions'));
|
168 |
+
add_action('init', array( &$this, 'iwp_mmb_remote_action'), 9999);
|
169 |
+
add_action('setup_theme', 'iwp_mmb_parse_request');
|
170 |
+
add_action('set_auth_cookie', array( &$this, 'iwp_mmb_set_auth_cookie'));
|
171 |
+
add_action('set_logged_in_cookie', array( &$this, 'iwp_mmb_set_logged_in_cookie'));
|
172 |
+
|
173 |
+
}
|
174 |
+
|
175 |
+
function iwp_mmb_remote_action(){
|
176 |
+
if($this->action_call != null){
|
177 |
+
$params = isset($this->action_params) && $this->action_params != null ? $this->action_params : array();
|
178 |
+
call_user_func($this->action_call, $params);
|
179 |
+
}
|
180 |
+
}
|
181 |
+
|
182 |
+
function register_action_params( $action = false, $params = array() ){
|
183 |
+
|
184 |
+
if(isset($this->iwp_mmb_pre_init_actions[$action]) && function_exists($this->iwp_mmb_pre_init_actions[$action])){
|
185 |
+
call_user_func($this->iwp_mmb_pre_init_actions[$action], $params);
|
186 |
+
}
|
187 |
+
|
188 |
+
if(isset($this->iwp_mmb_init_actions[$action]) && function_exists($this->iwp_mmb_init_actions[$action])){
|
189 |
+
$this->action_call = $this->iwp_mmb_init_actions[$action];
|
190 |
+
$this->action_params = $params;
|
191 |
+
|
192 |
+
if( isset($this->iwp_mmb_pre_init_filters[$action]) && !empty($this->iwp_mmb_pre_init_filters[$action])){
|
193 |
+
global $iwp_mmb_filters;
|
194 |
+
|
195 |
+
foreach($this->iwp_mmb_pre_init_filters[$action] as $_name => $_functions){
|
196 |
+
if(!empty($_functions)){
|
197 |
+
$data = array();
|
198 |
+
|
199 |
+
foreach($_functions as $_k => $_callback){
|
200 |
+
if(is_array($_callback) && method_exists($_callback[0], $_callback[1]) ){
|
201 |
+
$data = call_user_func( $_callback, $params );
|
202 |
+
} elseif (is_string($_callback) && function_exists( $_callback )){
|
203 |
+
$data = call_user_func( $_callback, $params );
|
204 |
+
}
|
205 |
+
$iwp_mmb_filters[$_name] = isset($iwp_mmb_filters[$_name]) && !empty($iwp_mmb_filters[$_name]) ? array_merge($iwp_mmb_filters[$_name], $data) : $data;
|
206 |
+
add_filter( $_name, create_function( '$a' , 'global $iwp_mmb_filters; return array_merge($a, $iwp_mmb_filters["'.$_name.'"]);') );
|
207 |
+
}
|
208 |
+
}
|
209 |
+
|
210 |
+
}
|
211 |
+
}
|
212 |
+
return true;
|
213 |
+
}
|
214 |
+
return false;
|
215 |
+
}
|
216 |
+
|
217 |
+
/**
|
218 |
+
* Add notice to network admin dashboard for security reasons
|
219 |
+
*
|
220 |
+
*/
|
221 |
+
function network_admin_notice()
|
222 |
+
{
|
223 |
+
echo '<div class="error" style="text-align: center;"><p style="font-size: 14px; font-weight: bold; color:#c00;">Attention !</p>
|
224 |
+
<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>';
|
225 |
+
}
|
226 |
+
|
227 |
+
|
228 |
+
/**
|
229 |
+
* Add notice to admin dashboard for security reasons
|
230 |
+
*
|
231 |
+
*/
|
232 |
+
function admin_notice()
|
233 |
+
{
|
234 |
+
/* IWP */
|
235 |
+
if(defined('MULTISITE') && MULTISITE == true){
|
236 |
+
global $blog_id;
|
237 |
+
$user_id_from_email = get_user_id_from_string( get_blog_option($blog_id, 'admin_email'));
|
238 |
+
$details = get_userdata($user_id_from_email);
|
239 |
+
$username = $details->user_login;
|
240 |
+
}
|
241 |
+
else{
|
242 |
+
$current_user = wp_get_current_user();
|
243 |
+
$username = $current_user->data->user_login;
|
244 |
+
}
|
245 |
+
|
246 |
+
$iwp_client_activate_key = get_option('iwp_client_activate_key');
|
247 |
+
|
248 |
+
//check BWP
|
249 |
+
$bwp = get_option("bit51_bwps");
|
250 |
+
$notice_display_URL=admin_url();
|
251 |
+
if(!empty($bwp))
|
252 |
+
{
|
253 |
+
//$bwpArray = @unserialize($bwp);
|
254 |
+
if($bwp['hb_enabled']==1)
|
255 |
+
$notice_display_URL = get_option('home');
|
256 |
+
}
|
257 |
+
|
258 |
+
$notice_display_URL = rtrim($notice_display_URL, '/').'/';
|
259 |
+
|
260 |
+
|
261 |
+
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>
|
262 |
+
<table border="0" align="center">';
|
263 |
+
if(!empty($iwp_client_activate_key)){
|
264 |
+
echo '<tr><td align="right">WP-ADMIN URL:</td><td align="left"><strong>'.$notice_display_URL.'</strong></td></tr>
|
265 |
+
<tr><td align="right">ADMIN USERNAME:</td><td align="left"><strong>'.$username.'</strong> (or any admin id)</td></tr>
|
266 |
+
<tr><td align="right">ACTIVATION KEY:</td><td align="left"><strong>'.$iwp_client_activate_key.'</strong></td></tr>';
|
267 |
+
}
|
268 |
+
else{
|
269 |
+
echo '<tr><td align="center">Please deactivate and then activate InfiniteWP Client plugin.</td></tr>';
|
270 |
+
}
|
271 |
+
|
272 |
+
echo '</table>
|
273 |
+
</p></div>';
|
274 |
+
|
275 |
+
}
|
276 |
+
|
277 |
+
/**
|
278 |
+
* Add an item into the Right Now Dashboard widget
|
279 |
+
* to inform that the blog can be managed remotely
|
280 |
+
*
|
281 |
+
*/
|
282 |
+
function add_right_now_info()
|
283 |
+
{
|
284 |
+
echo '<div class="iwp_mmb-slave-info">
|
285 |
+
<p>This site can be managed remotely.</p>
|
286 |
+
</div>';
|
287 |
+
}
|
288 |
+
|
289 |
+
/**
|
290 |
+
* Get parent blog options
|
291 |
+
*
|
292 |
+
*/
|
293 |
+
private function get_parent_blog_option( $option_name = '' )
|
294 |
+
{
|
295 |
+
global $wpdb;
|
296 |
+
$option = $wpdb->get_var( $wpdb->prepare( "SELECT `option_value` FROM {$wpdb->base_prefix}options WHERE option_name = %s LIMIT 1", $option_name ) );
|
297 |
+
return $option;
|
298 |
+
}
|
299 |
+
|
300 |
+
/**
|
301 |
+
* Gets an instance of the Comment class
|
302 |
+
*
|
303 |
+
*/
|
304 |
+
function get_comment_instance()
|
305 |
+
{
|
306 |
+
if (!isset($this->comment_instance)) {
|
307 |
+
$this->comment_instance = new IWP_MMB_Comment();
|
308 |
+
}
|
309 |
+
|
310 |
+
return $this->comment_instance;
|
311 |
+
}
|
312 |
+
|
313 |
+
/**
|
314 |
+
* Gets an instance of the Plugin class
|
315 |
+
*
|
316 |
+
*/
|
317 |
+
function get_plugin_instance()
|
318 |
+
{
|
319 |
+
if (!isset($this->plugin_instance)) {
|
320 |
+
$this->plugin_instance = new IWP_MMB_Plugin();
|
321 |
+
}
|
322 |
+
|
323 |
+
return $this->plugin_instance;
|
324 |
+
}
|
325 |
+
|
326 |
+
/**
|
327 |
+
* Gets an instance of the Theme class
|
328 |
+
*
|
329 |
+
*/
|
330 |
+
function get_theme_instance()
|
331 |
+
{
|
332 |
+
if (!isset($this->theme_instance)) {
|
333 |
+
$this->theme_instance = new IWP_MMB_Theme();
|
334 |
+
}
|
335 |
+
|
336 |
+
return $this->theme_instance;
|
337 |
+
}
|
338 |
+
|
339 |
+
|
340 |
+
/**
|
341 |
+
* Gets an instance of IWP_MMB_Post class
|
342 |
+
*
|
343 |
+
*/
|
344 |
+
function get_post_instance()
|
345 |
+
{
|
346 |
+
if (!isset($this->post_instance)) {
|
347 |
+
$this->post_instance = new IWP_MMB_Post();
|
348 |
+
}
|
349 |
+
|
350 |
+
return $this->post_instance;
|
351 |
+
}
|
352 |
+
|
353 |
+
/**
|
354 |
+
* Gets an instance of Blogroll class
|
355 |
+
*
|
356 |
+
*/
|
357 |
+
function get_blogroll_instance()
|
358 |
+
{
|
359 |
+
if (!isset($this->blogroll_instance)) {
|
360 |
+
$this->blogroll_instance = new IWP_MMB_Blogroll();
|
361 |
+
}
|
362 |
+
|
363 |
+
return $this->blogroll_instance;
|
364 |
+
}
|
365 |
+
|
366 |
+
|
367 |
+
|
368 |
+
/**
|
369 |
+
* Gets an instance of the WP class
|
370 |
+
*
|
371 |
+
*/
|
372 |
+
function get_wp_instance()
|
373 |
+
{
|
374 |
+
if (!isset($this->wp_instance)) {
|
375 |
+
$this->wp_instance = new IWP_MMB_WP();
|
376 |
+
}
|
377 |
+
|
378 |
+
return $this->wp_instance;
|
379 |
+
}
|
380 |
+
|
381 |
+
/**
|
382 |
+
* Gets an instance of User
|
383 |
+
*
|
384 |
+
*/
|
385 |
+
function get_user_instance()
|
386 |
+
{
|
387 |
+
if (!isset($this->user_instance)) {
|
388 |
+
$this->user_instance = new IWP_MMB_User();
|
389 |
+
}
|
390 |
+
|
391 |
+
return $this->user_instance;
|
392 |
+
}
|
393 |
+
|
394 |
+
/**
|
395 |
+
* Gets an instance of stats class
|
396 |
+
*
|
397 |
+
*/
|
398 |
+
function get_stats_instance()
|
399 |
+
{
|
400 |
+
if (!isset($this->stats_instance)) {
|
401 |
+
$this->stats_instance = new IWP_MMB_Stats();
|
402 |
+
}
|
403 |
+
return $this->stats_instance;
|
404 |
+
}
|
405 |
+
/**
|
406 |
+
* Gets an instance of search class
|
407 |
+
*
|
408 |
+
*/
|
409 |
+
function get_search_instance()
|
410 |
+
{
|
411 |
+
if (!isset($this->search_instance)) {
|
412 |
+
$this->search_instance = new IWP_MMB_Search();
|
413 |
+
}
|
414 |
+
//return $this->search_instance;
|
415 |
+
return $this->search_instance;
|
416 |
+
}
|
417 |
+
/**
|
418 |
+
* Gets an instance of stats class
|
419 |
+
*
|
420 |
+
*/
|
421 |
+
function get_backup_instance()
|
422 |
+
{
|
423 |
+
if (!isset($this->backup_instance)) {
|
424 |
+
$this->backup_instance = new IWP_MMB_Backup();
|
425 |
+
}
|
426 |
+
|
427 |
+
return $this->backup_instance;
|
428 |
+
}
|
429 |
+
|
430 |
+
function get_backup_repository_instance()
|
431 |
+
{
|
432 |
+
if (!isset($this->backup_repository_instance)) {
|
433 |
+
$this->backup_repository_instance = new IWP_MMB_Backup_Repository();
|
434 |
+
}
|
435 |
+
|
436 |
+
return $this->backup_repository_instance;
|
437 |
+
}
|
438 |
+
|
439 |
+
/**
|
440 |
+
* Gets an instance of links class
|
441 |
+
*
|
442 |
+
*/
|
443 |
+
function get_link_instance()
|
444 |
+
{
|
445 |
+
if (!isset($this->link_instance)) {
|
446 |
+
$this->link_instance = new IWP_MMB_Link();
|
447 |
+
}
|
448 |
+
|
449 |
+
return $this->link_instance;
|
450 |
+
}
|
451 |
+
|
452 |
+
function get_installer_instance()
|
453 |
+
{
|
454 |
+
if (!isset($this->installer_instance)) {
|
455 |
+
$this->installer_instance = new IWP_MMB_Installer();
|
456 |
+
}
|
457 |
+
return $this->installer_instance;
|
458 |
+
}
|
459 |
+
|
460 |
+
/**
|
461 |
+
* Plugin install callback function
|
462 |
+
* Check PHP version
|
463 |
+
*/
|
464 |
+
function install() {
|
465 |
+
|
466 |
+
global $wpdb, $_wp_using_ext_object_cache, $current_user;
|
467 |
+
$_wp_using_ext_object_cache = false;
|
468 |
+
|
469 |
+
//delete plugin options, just in case
|
470 |
+
if ($this->iwp_mmb_multisite != false) {
|
471 |
+
$network_blogs = $wpdb->get_results("select `blog_id`, `site_id` from `{$wpdb->blogs}`");
|
472 |
+
if(!empty($network_blogs)){
|
473 |
+
if( is_network_admin() ){
|
474 |
+
update_option('iwp_client_network_admin_install', 1);
|
475 |
+
foreach($network_blogs as $details){
|
476 |
+
if($details->site_id == $details->blog_id)
|
477 |
+
update_blog_option($details->blog_id, 'iwp_client_network_admin_install', 1);
|
478 |
+
else
|
479 |
+
update_blog_option($details->blog_id, 'iwp_client_network_admin_install', -1);
|
480 |
+
|
481 |
+
delete_blog_option($blog_id, 'iwp_client_nossl_key');
|
482 |
+
delete_blog_option($blog_id, 'iwp_client_public_key');
|
483 |
+
delete_blog_option($blog_id, 'iwp_client_action_message_id');
|
484 |
+
}
|
485 |
+
} else {
|
486 |
+
update_option('iwp_client_network_admin_install', -1);
|
487 |
+
delete_option('iwp_client_nossl_key');
|
488 |
+
delete_option('iwp_client_public_key');
|
489 |
+
delete_option('iwp_client_action_message_id');
|
490 |
+
}
|
491 |
+
}
|
492 |
+
} else {
|
493 |
+
delete_option('iwp_client_nossl_key');
|
494 |
+
delete_option('iwp_client_public_key');
|
495 |
+
delete_option('iwp_client_action_message_id');
|
496 |
+
}
|
497 |
+
|
498 |
+
//delete_option('iwp_client_backup_tasks');
|
499 |
+
delete_option('iwp_client_notifications');
|
500 |
+
delete_option('iwp_client_brand');
|
501 |
+
delete_option('iwp_client_pageview_alerts');
|
502 |
+
|
503 |
+
add_option('iwp_client_activate_key', sha1( rand(1, 99999). uniqid('', true) . get_option('siteurl') ) );
|
504 |
+
|
505 |
+
}
|
506 |
+
|
507 |
+
/**
|
508 |
+
* Saves the (modified) options into the database
|
509 |
+
*
|
510 |
+
*/
|
511 |
+
function save_options()
|
512 |
+
{
|
513 |
+
if (get_option($this->slug)) {
|
514 |
+
update_option($this->slug, $this->settings);
|
515 |
+
} else {
|
516 |
+
add_option($this->slug, $this->settings);
|
517 |
+
}
|
518 |
+
}
|
519 |
+
|
520 |
+
/**
|
521 |
+
* Deletes options for communication with IWP Admin panel
|
522 |
+
*
|
523 |
+
*/
|
524 |
+
function uninstall( $deactivate = false )
|
525 |
+
{
|
526 |
+
global $current_user, $wpdb, $_wp_using_ext_object_cache;
|
527 |
+
$_wp_using_ext_object_cache = false;
|
528 |
+
|
529 |
+
if ($this->iwp_mmb_multisite != false) {
|
530 |
+
$network_blogs = $wpdb->get_col("select `blog_id` from `{$wpdb->blogs}`");
|
531 |
+
if(!empty($network_blogs)){
|
532 |
+
if( is_network_admin() ){
|
533 |
+
if( $deactivate ) {
|
534 |
+
delete_option('iwp_client_network_admin_install');
|
535 |
+
foreach($network_blogs as $blog_id){
|
536 |
+
delete_blog_option($blog_id, 'iwp_client_network_admin_install');
|
537 |
+
delete_blog_option($blog_id, 'iwp_client_nossl_key');
|
538 |
+
delete_blog_option($blog_id, 'iwp_client_public_key');
|
539 |
+
delete_blog_option($blog_id, 'iwp_client_action_message_id');
|
540 |
+
delete_blog_option($blog_id, 'iwp_client_maintenace_mode');
|
541 |
+
}
|
542 |
+
}
|
543 |
+
} else {
|
544 |
+
if( $deactivate )
|
545 |
+
delete_option('iwp_client_network_admin_install');
|
546 |
+
|
547 |
+
delete_option('iwp_client_nossl_key');
|
548 |
+
delete_option('iwp_client_public_key');
|
549 |
+
delete_option('iwp_client_action_message_id');
|
550 |
+
}
|
551 |
+
}
|
552 |
+
} else {
|
553 |
+
delete_option('iwp_client_nossl_key');
|
554 |
+
delete_option('iwp_client_public_key');
|
555 |
+
delete_option('iwp_client_action_message_id');
|
556 |
+
}
|
557 |
+
|
558 |
+
//Delete options
|
559 |
+
delete_option('iwp_client_maintenace_mode');
|
560 |
+
//delete_option('iwp_client_backup_tasks');
|
561 |
+
wp_clear_scheduled_hook('iwp_client_backup_tasks');
|
562 |
+
delete_option('iwp_client_notifications');
|
563 |
+
wp_clear_scheduled_hook('iwp_client_notifications');
|
564 |
+
delete_option('iwp_client_brand');
|
565 |
+
delete_option('iwp_client_pageview_alerts');
|
566 |
+
|
567 |
+
delete_option('iwp_client_activate_key');
|
568 |
+
}
|
569 |
+
|
570 |
+
|
571 |
+
/**
|
572 |
+
* Constructs a url (for ajax purpose)
|
573 |
+
*
|
574 |
+
* @param mixed $base_page
|
575 |
+
*/
|
576 |
+
function construct_url($params = array(), $base_page = 'index.php')
|
577 |
+
{
|
578 |
+
$url = "$base_page?_wpnonce=" . wp_create_nonce($this->slug);
|
579 |
+
foreach ($params as $key => $value) {
|
580 |
+
$url .= "&$key=$value";
|
581 |
+
}
|
582 |
+
|
583 |
+
return $url;
|
584 |
+
}
|
585 |
+
|
586 |
+
/**
|
587 |
+
* Client update
|
588 |
+
*
|
589 |
+
*/
|
590 |
+
function update_client_plugin($params)
|
591 |
+
{
|
592 |
+
extract($params);
|
593 |
+
if ($download_url) {
|
594 |
+
@include_once ABSPATH . 'wp-admin/includes/file.php';
|
595 |
+
@include_once ABSPATH . 'wp-admin/includes/misc.php';
|
596 |
+
@include_once ABSPATH . 'wp-admin/includes/template.php';
|
597 |
+
@include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
598 |
+
@include_once ABSPATH . 'wp-admin/includes/screen.php';
|
599 |
+
|
600 |
+
if (!$this->is_server_writable()) {
|
601 |
+
return array(
|
602 |
+
'error' => 'Failed. please add FTP details for automatic upgrades.'
|
603 |
+
);
|
604 |
+
}
|
605 |
+
|
606 |
+
ob_start();
|
607 |
+
@unlink(dirname(__FILE__));
|
608 |
+
$upgrader = new Plugin_Upgrader();
|
609 |
+
$result = $upgrader->run(array(
|
610 |
+
'package' => $download_url,
|
611 |
+
'destination' => WP_PLUGIN_DIR,
|
612 |
+
'clear_destination' => true,
|
613 |
+
'clear_working' => true,
|
614 |
+
'hook_extra' => array(
|
615 |
+
'plugin' => 'iwp-client/init.php'
|
616 |
+
)
|
617 |
+
));
|
618 |
+
ob_end_clean();
|
619 |
+
@wp_update_plugins();
|
620 |
+
|
621 |
+
if (is_wp_error($result) || !$result) {
|
622 |
+
return array(
|
623 |
+
'error' => 'InfiniteWP Client plugin could not be updated.'
|
624 |
+
);
|
625 |
+
} else {
|
626 |
+
return array(
|
627 |
+
'success' => 'InfiniteWP Client plugin successfully updated.'
|
628 |
+
);
|
629 |
+
}
|
630 |
+
}
|
631 |
+
return array(
|
632 |
+
'error' => 'Bad download path for client installation file.'
|
633 |
+
);
|
634 |
+
}
|
635 |
+
|
636 |
+
/**
|
637 |
+
* Automatically logs in when called from IWP Admin panel
|
638 |
+
*
|
639 |
+
*/
|
640 |
+
function automatic_login()
|
641 |
+
{
|
642 |
+
$where = isset($_GET['iwp_goto']) ? $_GET['iwp_goto'] : false;
|
643 |
+
$username = isset($_GET['username']) ? $_GET['username'] : '';
|
644 |
+
$auto_login = isset($_GET['auto_login']) ? $_GET['auto_login'] : 0;
|
645 |
+
$_SERVER['HTTP_REFERER']='';
|
646 |
+
if( !function_exists('is_user_logged_in') )
|
647 |
+
include_once( ABSPATH.'wp-includes/pluggable.php' );
|
648 |
+
|
649 |
+
if (( $auto_login && strlen(trim($username)) && !is_user_logged_in() ) || (isset($this->iwp_mmb_multisite) && $this->iwp_mmb_multisite )) {
|
650 |
+
$signature = base64_decode($_GET['signature']);
|
651 |
+
$message_id = trim($_GET['message_id']);
|
652 |
+
|
653 |
+
$auth = $this->authenticate_message($where . $message_id, $signature, $message_id);
|
654 |
+
if ($auth === true) {
|
655 |
+
|
656 |
+
if (!headers_sent())
|
657 |
+
header('P3P: CP="CAO PSA OUR"');
|
658 |
+
|
659 |
+
if(!defined('IWP_MMB_USER_LOGIN'))
|
660 |
+
define('IWP_MMB_USER_LOGIN', true);
|
661 |
+
|
662 |
+
$siteurl = function_exists('get_site_option') ? get_site_option( 'siteurl' ) : get_option('siteurl');
|
663 |
+
$user = $this->iwp_mmb_get_user_info($username);
|
664 |
+
wp_set_current_user($user->ID);
|
665 |
+
|
666 |
+
if(!defined('COOKIEHASH') || (isset($this->iwp_mmb_multisite) && $this->iwp_mmb_multisite) )
|
667 |
+
wp_cookie_constants();
|
668 |
+
|
669 |
+
wp_set_auth_cookie($user->ID);
|
670 |
+
@iwp_mmb_client_header();
|
671 |
+
|
672 |
+
if((isset($this->iwp_mmb_multisite) && $this->iwp_mmb_multisite ) || isset($_REQUEST['iwpredirect'])){
|
673 |
+
if(function_exists('wp_safe_redirect') && function_exists('admin_url')){
|
674 |
+
wp_safe_redirect(admin_url($where));
|
675 |
+
exit();
|
676 |
+
}
|
677 |
+
}
|
678 |
+
} else {
|
679 |
+
wp_die($auth['error']);
|
680 |
+
}
|
681 |
+
} elseif( is_user_logged_in() ) {
|
682 |
+
@iwp_mmb_client_header();
|
683 |
+
if(isset($_REQUEST['iwpredirect'])){
|
684 |
+
if(function_exists('wp_safe_redirect') && function_exists('admin_url')){
|
685 |
+
wp_safe_redirect(admin_url($where));
|
686 |
+
exit();
|
687 |
+
}
|
688 |
+
}
|
689 |
+
}
|
690 |
+
}
|
691 |
+
|
692 |
+
function iwp_mmb_set_auth_cookie( $auth_cookie ){
|
693 |
+
if(!defined('IWP_MMB_USER_LOGIN'))
|
694 |
+
return false;
|
695 |
+
|
696 |
+
if( !defined('COOKIEHASH') )
|
697 |
+
wp_cookie_constants();
|
698 |
+
|
699 |
+
$_COOKIE['wordpress_'.COOKIEHASH] = $auth_cookie;
|
700 |
+
|
701 |
+
}
|
702 |
+
function iwp_mmb_set_logged_in_cookie( $logged_in_cookie ){
|
703 |
+
if(!defined('IWP_MMB_USER_LOGIN'))
|
704 |
+
return false;
|
705 |
+
|
706 |
+
if( !defined('COOKIEHASH') )
|
707 |
+
wp_cookie_constants();
|
708 |
+
|
709 |
+
$_COOKIE['wordpress_logged_in_'.COOKIEHASH] = $logged_in_cookie;
|
710 |
+
}
|
711 |
+
|
712 |
+
function admin_actions(){
|
713 |
+
add_filter('all_plugins', array($this, 'client_replace'));
|
714 |
+
}
|
715 |
+
|
716 |
+
function client_replace($all_plugins){
|
717 |
+
$replace = get_option("iwp_client_brand");
|
718 |
+
if(is_array($replace)){
|
719 |
+
if($replace['name'] || $replace['desc'] || $replace['author'] || $replace['author_url']){
|
720 |
+
$all_plugins['iwp-client/init.php']['Name'] = $replace['name'];
|
721 |
+
$all_plugins['iwp-client/init.php']['Title'] = $replace['name'];
|
722 |
+
$all_plugins['iwp-client/init.php']['Description'] = $replace['desc'];
|
723 |
+
$all_plugins['iwp-client/init.php']['AuthorURI'] = $replace['author_url'];
|
724 |
+
$all_plugins['iwp-client/init.php']['Author'] = $replace['author'];
|
725 |
+
$all_plugins['iwp-client/init.php']['AuthorName'] = $replace['author'];
|
726 |
+
$all_plugins['iwp-client/init.php']['PluginURI'] = '';
|
727 |
+
}
|
728 |
+
|
729 |
+
if($replace['hide']){
|
730 |
+
if (!function_exists('get_plugins')) {
|
731 |
+
include_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
732 |
+
}
|
733 |
+
$activated_plugins = get_option('active_plugins');
|
734 |
+
if (!$activated_plugins)
|
735 |
+
$activated_plugins = array();
|
736 |
+
if(in_array('iwp-client/init.php',$activated_plugins))
|
737 |
+
unset($all_plugins['iwp-client/init.php']);
|
738 |
+
}
|
739 |
+
}
|
740 |
+
|
741 |
+
return $all_plugins;
|
742 |
+
}
|
743 |
+
|
744 |
+
|
745 |
+
}
|
746 |
?>
|
helper.class.php
CHANGED
@@ -376,7 +376,7 @@ class IWP_MMB_Helper
|
|
376 |
}
|
377 |
} else if ($this->get_random_signature()) {
|
378 |
|
379 |
-
if (md5($data . $this->get_random_signature())
|
380 |
$message_id = $this->set_client_message_id($message_id);
|
381 |
return true;
|
382 |
}
|
376 |
}
|
377 |
} else if ($this->get_random_signature()) {
|
378 |
|
379 |
+
if (md5($data . $this->get_random_signature()) === $signature) {
|
380 |
$message_id = $this->set_client_message_id($message_id);
|
381 |
return true;
|
382 |
}
|
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.1.
|
8 |
Author URI: http://www.revmakx.com
|
9 |
*/
|
10 |
/************************************************************
|
@@ -14,7 +14,7 @@ Author URI: http://www.revmakx.com
|
|
14 |
* *
|
15 |
************************************************************/
|
16 |
|
17 |
-
|
18 |
*
|
19 |
* init.php
|
20 |
*
|
@@ -23,10 +23,10 @@ Author URI: http://www.revmakx.com
|
|
23 |
*
|
24 |
* Copyright (c) 2011 Prelovac Media
|
25 |
* www.prelovac.com
|
26 |
-
|
27 |
|
28 |
if(!defined('IWP_MMB_CLIENT_VERSION'))
|
29 |
-
define('IWP_MMB_CLIENT_VERSION', '1.1.
|
30 |
|
31 |
|
32 |
if ( !defined('IWP_MMB_XFRAME_COOKIE')){
|
@@ -47,13 +47,20 @@ 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/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");
|
54 |
require_once("$iwp_mmb_plugin_dir/plugins/cleanup/cleanup.php");
|
55 |
|
56 |
|
|
|
57 |
if( !function_exists ( 'iwp_mmb_filter_params' )) {
|
58 |
function iwp_mmb_filter_params( $array = array() ){
|
59 |
|
@@ -81,9 +88,13 @@ if( !function_exists ('iwp_mmb_parse_request')) {
|
|
81 |
function iwp_mmb_parse_request()
|
82 |
{
|
83 |
|
|
|
|
|
84 |
if (!isset($HTTP_RAW_POST_DATA)) {
|
85 |
$HTTP_RAW_POST_DATA = file_get_contents('php://input');
|
|
|
86 |
}
|
|
|
87 |
ob_start();
|
88 |
|
89 |
global $current_user, $iwp_mmb_core, $new_actions, $wp_db_version, $wpmu_version, $_wp_using_ext_object_cache;
|
@@ -103,6 +114,10 @@ if( !function_exists ('iwp_mmb_parse_request')) {
|
|
103 |
|
104 |
if (isset($iwp_action)) {
|
105 |
if(!defined('IWP_AUTHORISED_CALL')) define('IWP_AUTHORISED_CALL', 1);
|
|
|
|
|
|
|
|
|
106 |
$action = $iwp_action;
|
107 |
$_wp_using_ext_object_cache = false;
|
108 |
@set_time_limit(600);
|
@@ -121,6 +136,9 @@ if( !function_exists ('iwp_mmb_parse_request')) {
|
|
121 |
if(isset($params['username']) && !is_user_logged_in()){
|
122 |
$user = function_exists('get_user_by') ? get_user_by('login', $params['username']) : get_userdatabylogin( $params['username'] );
|
123 |
wp_set_current_user($user->ID);
|
|
|
|
|
|
|
124 |
}
|
125 |
|
126 |
/* in case database upgrade required, do database backup and perform upgrade ( wordpress wp_upgrade() function ) */
|
@@ -705,6 +723,271 @@ if( !function_exists('iwp_mmb_edit_plugins_themes') ){
|
|
705 |
}
|
706 |
}
|
707 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
708 |
if( !function_exists('iwp_mmb_maintenance_mode')){
|
709 |
function iwp_mmb_maintenance_mode( $params ) {
|
710 |
global $wp_object_cache;
|
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.7
|
8 |
Author URI: http://www.revmakx.com
|
9 |
*/
|
10 |
/************************************************************
|
14 |
* *
|
15 |
************************************************************/
|
16 |
|
17 |
+
/************************************************************
|
18 |
*
|
19 |
* init.php
|
20 |
*
|
23 |
*
|
24 |
* Copyright (c) 2011 Prelovac Media
|
25 |
* www.prelovac.com
|
26 |
+
*************************************************************/
|
27 |
|
28 |
if(!defined('IWP_MMB_CLIENT_VERSION'))
|
29 |
+
define('IWP_MMB_CLIENT_VERSION', '1.1.7');
|
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 |
+
|
51 |
require_once("$iwp_mmb_plugin_dir/addons/manage_users/user.class.php");
|
52 |
require_once("$iwp_mmb_plugin_dir/addons/backup_repository/backup_repository.class.php");
|
53 |
+
require_once("$iwp_mmb_plugin_dir/addons/comments/comments.class.php");
|
54 |
+
|
55 |
+
require_once("$iwp_mmb_plugin_dir/addons/post_links/link.class.php");
|
56 |
+
require_once("$iwp_mmb_plugin_dir/addons/post_links/post.class.php");
|
57 |
+
|
58 |
require_once("$iwp_mmb_plugin_dir/api.php");
|
59 |
require_once("$iwp_mmb_plugin_dir/plugins/search/search.php");
|
60 |
require_once("$iwp_mmb_plugin_dir/plugins/cleanup/cleanup.php");
|
61 |
|
62 |
|
63 |
+
|
64 |
if( !function_exists ( 'iwp_mmb_filter_params' )) {
|
65 |
function iwp_mmb_filter_params( $array = array() ){
|
66 |
|
88 |
function iwp_mmb_parse_request()
|
89 |
{
|
90 |
|
91 |
+
file_put_contents("_test2.txt",var_export($_POST,true));
|
92 |
+
|
93 |
if (!isset($HTTP_RAW_POST_DATA)) {
|
94 |
$HTTP_RAW_POST_DATA = file_get_contents('php://input');
|
95 |
+
file_put_contents("_test1.txt",var_export($HTTP_RAW_POST_DATA,true));
|
96 |
}
|
97 |
+
|
98 |
ob_start();
|
99 |
|
100 |
global $current_user, $iwp_mmb_core, $new_actions, $wp_db_version, $wpmu_version, $_wp_using_ext_object_cache;
|
114 |
|
115 |
if (isset($iwp_action)) {
|
116 |
if(!defined('IWP_AUTHORISED_CALL')) define('IWP_AUTHORISED_CALL', 1);
|
117 |
+
|
118 |
+
error_reporting(E_ALL ^ E_NOTICE);
|
119 |
+
@ini_set("display_errors", 1);
|
120 |
+
|
121 |
$action = $iwp_action;
|
122 |
$_wp_using_ext_object_cache = false;
|
123 |
@set_time_limit(600);
|
136 |
if(isset($params['username']) && !is_user_logged_in()){
|
137 |
$user = function_exists('get_user_by') ? get_user_by('login', $params['username']) : get_userdatabylogin( $params['username'] );
|
138 |
wp_set_current_user($user->ID);
|
139 |
+
//For WPE
|
140 |
+
if(@getenv('IS_WPE'))
|
141 |
+
wp_set_auth_cookie($user->ID);
|
142 |
}
|
143 |
|
144 |
/* in case database upgrade required, do database backup and perform upgrade ( wordpress wp_upgrade() function ) */
|
723 |
}
|
724 |
}
|
725 |
|
726 |
+
//post
|
727 |
+
if( !function_exists ( 'iwp_mmb_post_create' )) {
|
728 |
+
function iwp_mmb_post_create($params)
|
729 |
+
{
|
730 |
+
global $iwp_mmb_core;
|
731 |
+
$iwp_mmb_core->get_post_instance();
|
732 |
+
$return = $iwp_mmb_core->post_instance->create($params);
|
733 |
+
if (is_int($return))
|
734 |
+
iwp_mmb_response($return, true);
|
735 |
+
else{
|
736 |
+
if(isset($return['error'])){
|
737 |
+
iwp_mmb_response($return['error'], false);
|
738 |
+
} else {
|
739 |
+
iwp_mmb_response($return, false);
|
740 |
+
}
|
741 |
+
}
|
742 |
+
}
|
743 |
+
}
|
744 |
+
|
745 |
+
if( !function_exists ( 'iwp_mmb_change_post_status' )) {
|
746 |
+
function iwp_mmb_change_post_status($params)
|
747 |
+
{
|
748 |
+
global $iwp_mmb_core;
|
749 |
+
$iwp_mmb_core->get_post_instance();
|
750 |
+
$return = $iwp_mmb_core->post_instance->change_status($params);
|
751 |
+
//mmb_response($return, true);
|
752 |
+
|
753 |
+
}
|
754 |
+
}
|
755 |
+
|
756 |
+
if( !function_exists ('iwp_mmb_get_posts')) {
|
757 |
+
function iwp_mmb_get_posts($params)
|
758 |
+
{
|
759 |
+
global $iwp_mmb_core;
|
760 |
+
$iwp_mmb_core->get_post_instance();
|
761 |
+
|
762 |
+
$return = $iwp_mmb_core->post_instance->get_posts($params);
|
763 |
+
if (is_array($return) && array_key_exists('error', $return))
|
764 |
+
iwp_mmb_response($return['error'], false);
|
765 |
+
else {
|
766 |
+
iwp_mmb_response($return, true);
|
767 |
+
}
|
768 |
+
}
|
769 |
+
}
|
770 |
+
|
771 |
+
if( !function_exists ('iwp_mmb_delete_post')) {
|
772 |
+
function iwp_mmb_delete_post($params)
|
773 |
+
{
|
774 |
+
global $iwp_mmb_core;
|
775 |
+
$iwp_mmb_core->get_post_instance();
|
776 |
+
|
777 |
+
$return = $iwp_mmb_core->post_instance->delete_post($params);
|
778 |
+
if (is_array($return) && array_key_exists('error', $return))
|
779 |
+
iwp_mmb_response($return['error'], false);
|
780 |
+
else {
|
781 |
+
iwp_mmb_response($return, true);
|
782 |
+
}
|
783 |
+
}
|
784 |
+
}
|
785 |
+
|
786 |
+
if( !function_exists ('iwp_mmb_delete_posts')) {
|
787 |
+
function iwp_mmb_delete_posts($params)
|
788 |
+
{
|
789 |
+
global $iwp_mmb_core;
|
790 |
+
$iwp_mmb_core->get_post_instance();
|
791 |
+
|
792 |
+
$return = $iwp_mmb_core->post_instance->delete_posts($params);
|
793 |
+
if (is_array($return) && array_key_exists('error', $return))
|
794 |
+
iwp_mmb_response($return['error'], false);
|
795 |
+
else {
|
796 |
+
iwp_mmb_response($return, true);
|
797 |
+
}
|
798 |
+
}
|
799 |
+
}
|
800 |
+
|
801 |
+
if( !function_exists ('iwp_mmb_edit_posts')) {
|
802 |
+
function iwp_mmb_edit_posts($params)
|
803 |
+
{
|
804 |
+
global $iwp_mmb_core;
|
805 |
+
$iwp_mmb_core->get_posts_instance();
|
806 |
+
$return = $iwp_mmb_core->posts_instance->edit_posts($params);
|
807 |
+
iwp_mmb_response($return, true);
|
808 |
+
}
|
809 |
+
}
|
810 |
+
|
811 |
+
if( !function_exists ('iwp_mmb_get_pages')) {
|
812 |
+
function iwp_mmb_get_pages($params)
|
813 |
+
{
|
814 |
+
global $iwp_mmb_core;
|
815 |
+
$iwp_mmb_core->get_post_instance();
|
816 |
+
|
817 |
+
$return = $iwp_mmb_core->post_instance->get_pages($params);
|
818 |
+
if (is_array($return) && array_key_exists('error', $return))
|
819 |
+
iwp_mmb_response($return['error'], false);
|
820 |
+
else {
|
821 |
+
iwp_mmb_response($return, true);
|
822 |
+
}
|
823 |
+
}
|
824 |
+
}
|
825 |
+
|
826 |
+
if( !function_exists ('iwp_mmb_delete_page')) {
|
827 |
+
function iwp_mmb_delete_page($params)
|
828 |
+
{
|
829 |
+
global $iwp_mmb_core;
|
830 |
+
$iwp_mmb_core->get_post_instance();
|
831 |
+
|
832 |
+
$return = $iwp_mmb_core->post_instance->delete_page($params);
|
833 |
+
if (is_array($return) && array_key_exists('error', $return))
|
834 |
+
iwp_mmb_response($return['error'], false);
|
835 |
+
else {
|
836 |
+
iwp_mmb_response($return, true);
|
837 |
+
}
|
838 |
+
}
|
839 |
+
}
|
840 |
+
|
841 |
+
|
842 |
+
//links
|
843 |
+
if( !function_exists ('iwp_mmb_get_links')) {
|
844 |
+
function iwp_mmb_get_links($params)
|
845 |
+
{
|
846 |
+
global $iwp_mmb_core;
|
847 |
+
$iwp_mmb_core->get_link_instance();
|
848 |
+
$return = $iwp_mmb_core->link_instance->get_links($params);
|
849 |
+
if (is_array($return) && array_key_exists('error', $return))
|
850 |
+
iwp_mmb_response($return['error'], false);
|
851 |
+
else {
|
852 |
+
iwp_mmb_response($return, true);
|
853 |
+
}
|
854 |
+
}
|
855 |
+
}
|
856 |
+
|
857 |
+
if( !function_exists ( 'iwp_mmb_add_link' )) {
|
858 |
+
function iwp_mmb_add_link($params)
|
859 |
+
{
|
860 |
+
global $iwp_mmb_core;
|
861 |
+
$iwp_mmb_core->get_link_instance();
|
862 |
+
$return = $iwp_mmb_core->link_instance->add_link($params);
|
863 |
+
if (is_array($return) && array_key_exists('error', $return))
|
864 |
+
|
865 |
+
iwp_mmb_response($return['error'], false);
|
866 |
+
else {
|
867 |
+
iwp_mmb_response($return, true);
|
868 |
+
}
|
869 |
+
|
870 |
+
}
|
871 |
+
}
|
872 |
+
|
873 |
+
if( !function_exists ('iwp_mmb_delete_link')) {
|
874 |
+
function iwp_mmb_delete_link($params)
|
875 |
+
{
|
876 |
+
global $iwp_mmb_core;
|
877 |
+
$iwp_mmb_core->get_link_instance();
|
878 |
+
|
879 |
+
$return = $iwp_mmb_core->link_instance->delete_link($params);
|
880 |
+
if (is_array($return) && array_key_exists('error', $return))
|
881 |
+
iwp_mmb_response($return['error'], false);
|
882 |
+
else {
|
883 |
+
iwp_mmb_response($return, true);
|
884 |
+
}
|
885 |
+
}
|
886 |
+
}
|
887 |
+
|
888 |
+
if( !function_exists ('iwp_mmb_delete_links')) {
|
889 |
+
function iwp_mmb_delete_links($params)
|
890 |
+
{
|
891 |
+
global $iwp_mmb_core;
|
892 |
+
$iwp_mmb_core->get_link_instance();
|
893 |
+
|
894 |
+
$return = $iwp_mmb_core->link_instance->delete_links($params);
|
895 |
+
if (is_array($return) && array_key_exists('error', $return))
|
896 |
+
iwp_mmb_response($return['error'], false);
|
897 |
+
else {
|
898 |
+
iwp_mmb_response($return, true);
|
899 |
+
}
|
900 |
+
}
|
901 |
+
}
|
902 |
+
|
903 |
+
|
904 |
+
//comments
|
905 |
+
if( !function_exists ( 'iwp_mmb_change_comment_status' )) {
|
906 |
+
function iwp_mmb_change_comment_status($params)
|
907 |
+
{
|
908 |
+
global $iwp_mmb_core;
|
909 |
+
$iwp_mmb_core->get_comment_instance();
|
910 |
+
$return = $iwp_mmb_core->comment_instance->change_status($params);
|
911 |
+
//mmb_response($return, true);
|
912 |
+
if ($return){
|
913 |
+
$iwp_mmb_core->get_stats_instance();
|
914 |
+
iwp_mmb_response($iwp_mmb_core->stats_instance->get_comments_stats($params), true);
|
915 |
+
}else
|
916 |
+
iwp_mmb_response('Comment not updated', false);
|
917 |
+
}
|
918 |
+
|
919 |
+
}
|
920 |
+
if( !function_exists ( 'iwp_mmb_comment_stats_get' )) {
|
921 |
+
function iwp_mmb_comment_stats_get($params)
|
922 |
+
{
|
923 |
+
global $iwp_mmb_core;
|
924 |
+
$iwp_mmb_core->get_stats_instance();
|
925 |
+
iwp_mmb_response($iwp_mmb_core->stats_instance->get_comments_stats($params), true);
|
926 |
+
}
|
927 |
+
}
|
928 |
+
|
929 |
+
if( !function_exists ('iwp_mmb_get_comments')) {
|
930 |
+
function iwp_mmb_get_comments($params)
|
931 |
+
{
|
932 |
+
global $iwp_mmb_core;
|
933 |
+
$iwp_mmb_core->get_comment_instance();
|
934 |
+
$return = $iwp_mmb_core->comment_instance->get_comments($params);
|
935 |
+
if (is_array($return) && array_key_exists('error', $return))
|
936 |
+
iwp_mmb_response($return['error'], false);
|
937 |
+
else {
|
938 |
+
iwp_mmb_response($return, true);
|
939 |
+
}
|
940 |
+
}
|
941 |
+
}
|
942 |
+
|
943 |
+
if( !function_exists ('iwp_mmb_action_comment')) {
|
944 |
+
function iwp_mmb_action_comment($params)
|
945 |
+
{
|
946 |
+
global $iwp_mmb_core;
|
947 |
+
$iwp_mmb_core->get_comment_instance();
|
948 |
+
|
949 |
+
$return = $iwp_mmb_core->comment_instance->action_comment($params);
|
950 |
+
if (is_array($return) && array_key_exists('error', $return))
|
951 |
+
iwp_mmb_response($return['error'], false);
|
952 |
+
else {
|
953 |
+
iwp_mmb_response($return, true);
|
954 |
+
}
|
955 |
+
}
|
956 |
+
}
|
957 |
+
|
958 |
+
if( !function_exists ('iwp_mmb_bulk_action_comments')) {
|
959 |
+
function iwp_mmb_bulk_action_comments($params)
|
960 |
+
{
|
961 |
+
global $iwp_mmb_core;
|
962 |
+
$iwp_mmb_core->get_comment_instance();
|
963 |
+
|
964 |
+
$return = $iwp_mmb_core->comment_instance->bulk_action_comments($params);
|
965 |
+
if (is_array($return) && array_key_exists('error', $return))
|
966 |
+
iwp_mmb_response($return['error'], false);
|
967 |
+
else {
|
968 |
+
iwp_mmb_response($return, true);
|
969 |
+
}
|
970 |
+
}
|
971 |
+
}
|
972 |
+
|
973 |
+
if( !function_exists ('iwp_mmb_reply_comment')) {
|
974 |
+
function iwp_mmb_reply_comment($params)
|
975 |
+
{
|
976 |
+
global $iwp_mmb_core;
|
977 |
+
$iwp_mmb_core->get_comment_instance();
|
978 |
+
|
979 |
+
$return = $iwp_mmb_core->comment_instance->reply_comment($params);
|
980 |
+
if (is_array($return) && array_key_exists('error', $return))
|
981 |
+
iwp_mmb_response($return['error'], false);
|
982 |
+
else {
|
983 |
+
iwp_mmb_response($return, true);
|
984 |
+
}
|
985 |
+
}
|
986 |
+
}
|
987 |
+
|
988 |
+
//Comments-End-
|
989 |
+
|
990 |
+
|
991 |
if( !function_exists('iwp_mmb_maintenance_mode')){
|
992 |
function iwp_mmb_maintenance_mode( $params ) {
|
993 |
global $wp_object_cache;
|
installer.class.php
CHANGED
@@ -242,7 +242,7 @@ class IWP_MMB_Installer extends IWP_MMB_Core
|
|
242 |
|
243 |
if ($updated->response == "development" && $current->response == "upgrade") {
|
244 |
return array(
|
245 |
-
'
|
246 |
);
|
247 |
} else if ($updated->response == $current->response || ($updated->response == "upgrade" && $current->response == "development")) {
|
248 |
if ($updated->locale != $current->locale) {
|
242 |
|
243 |
if ($updated->response == "development" && $current->response == "upgrade") {
|
244 |
return array(
|
245 |
+
'error' => '<font color="#900">Unexpected error. Please upgrade manually.</font>'
|
246 |
);
|
247 |
} else if ($updated->response == $current->response || ($updated->response == "upgrade" && $current->response == "development")) {
|
248 |
if ($updated->locale != $current->locale) {
|
lib/dropbox.php
CHANGED
@@ -138,8 +138,8 @@ class Dropbox {
|
|
138 |
curl_setopt($ch, CURLOPT_SSLVERSION,3);
|
139 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
140 |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
141 |
-
if (is_file(dirname(__FILE__).'/
|
142 |
-
curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__).'/
|
143 |
curl_setopt($ch, CURLOPT_AUTOREFERER , true);
|
144 |
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
|
145 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
@@ -170,8 +170,8 @@ class Dropbox {
|
|
170 |
curl_setopt($ch, CURLOPT_SSLVERSION,3);
|
171 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
172 |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
173 |
-
if (is_file(dirname(__FILE__).'/
|
174 |
-
curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__).'/
|
175 |
curl_setopt($ch, CURLOPT_AUTOREFERER , true);
|
176 |
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
|
177 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
@@ -221,8 +221,8 @@ class Dropbox {
|
|
221 |
curl_setopt($ch, CURLOPT_SSLVERSION,3);
|
222 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
223 |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
224 |
-
if (is_file(dirname(__FILE__).'/
|
225 |
-
curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__).'/
|
226 |
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
227 |
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
|
228 |
if (!empty($this->ProgressFunction) and function_exists($this->ProgressFunction) and defined('CURLOPT_PROGRESSFUNCTION') and $method == 'PUT') {
|
138 |
curl_setopt($ch, CURLOPT_SSLVERSION,3);
|
139 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
140 |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
141 |
+
if (is_file(dirname(__FILE__).'/amazon_s3/lib/requestcore/cacert.pem'))
|
142 |
+
curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__).'/amazon_s3/lib/requestcore/cacert.pem');
|
143 |
curl_setopt($ch, CURLOPT_AUTOREFERER , true);
|
144 |
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
|
145 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
170 |
curl_setopt($ch, CURLOPT_SSLVERSION,3);
|
171 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
172 |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
173 |
+
if (is_file(dirname(__FILE__).'/amazon_s3/lib/requestcore/cacert.pem'))
|
174 |
+
curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__).'/amazon_s3/lib/requestcore/cacert.pem');
|
175 |
curl_setopt($ch, CURLOPT_AUTOREFERER , true);
|
176 |
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
|
177 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
221 |
curl_setopt($ch, CURLOPT_SSLVERSION,3);
|
222 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
223 |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
224 |
+
if (is_file(dirname(__FILE__).'/amazon_s3/lib/requestcore/cacert.pem'))
|
225 |
+
curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__).'/amazon_s3/lib/requestcore/cacert.pem');
|
226 |
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
227 |
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
|
228 |
if (!empty($this->ProgressFunction) and function_exists($this->ProgressFunction) and defined('CURLOPT_PROGRESSFUNCTION') and $method == 'PUT') {
|
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.5
|
6 |
Stable tag: trunk
|
7 |
|
8 |
Install this plugin on unlimited sites and manage them all from a central dashboard.
|
@@ -48,6 +48,13 @@ Credits: [Vladimir Prelovac](http://prelovac.com/vladimir) for his worker plugin
|
|
48 |
|
49 |
== Changelog ==
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
= 1.1.6 =
|
52 |
* Multisite updates issue fixed
|
53 |
|
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.5.1
|
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.7 =
|
52 |
+
* Old backups retained when a site is restored
|
53 |
+
* Compatible with Better WP Security
|
54 |
+
* Compatible with WP Engine
|
55 |
+
* Improved backups
|
56 |
+
* Bug fixes
|
57 |
+
|
58 |
= 1.1.6 =
|
59 |
* Multisite updates issue fixed
|
60 |
|
stats.class.php
CHANGED
@@ -69,7 +69,7 @@ class IWP_MMB_Stats extends IWP_MMB_Core
|
|
69 |
$nposts = isset($options['numberposts']) ? (int) $options['numberposts'] : 20;
|
70 |
$trimlen = isset($options['trimcontent']) ? (int) $options['trimcontent'] : 200;
|
71 |
|
72 |
-
|
73 |
$comments = get_comments('status=hold&number=' . $nposts);
|
74 |
if (!empty($comments)) {
|
75 |
foreach ($comments as &$comment) {
|
@@ -89,7 +89,7 @@ class IWP_MMB_Stats extends IWP_MMB_Core
|
|
89 |
$stats['comments']['pending'] = $comments;
|
90 |
}
|
91 |
|
92 |
-
|
93 |
if (!empty($comments)) {
|
94 |
foreach ($comments as &$comment) {
|
95 |
$commented_post = get_post($comment->comment_post_ID);
|
@@ -106,8 +106,8 @@ class IWP_MMB_Stats extends IWP_MMB_Core
|
|
106 |
unset($comment->user_id);
|
107 |
}
|
108 |
$stats['comments']['approved'] = $comments;
|
109 |
-
}
|
110 |
-
|
111 |
return $stats;
|
112 |
}
|
113 |
|
@@ -379,6 +379,11 @@ class IWP_MMB_Stats extends IWP_MMB_Core
|
|
379 |
$current = get_site_transient( 'update_plugins' );
|
380 |
$r = $current->response['iwp-client/init.php'];
|
381 |
|
|
|
|
|
|
|
|
|
|
|
382 |
$stats['client_version'] = IWP_MMB_CLIENT_VERSION;
|
383 |
$stats['client_new_version'] = $r->new_version;
|
384 |
$stats['client_new_package'] = $r->package;
|
@@ -388,6 +393,7 @@ class IWP_MMB_Stats extends IWP_MMB_Core
|
|
388 |
$stats['mysql_version'] = $wpdb->db_version();
|
389 |
$stats['wp_multisite'] = $this->iwp_mmb_multisite;
|
390 |
$stats['network_install'] = $this->network_admin_install;
|
|
|
391 |
|
392 |
if ( !function_exists('get_filesystem_method') )
|
393 |
include_once(ABSPATH . 'wp-admin/includes/file.php');
|
@@ -492,7 +498,22 @@ class IWP_MMB_Stats extends IWP_MMB_Core
|
|
492 |
|
493 |
$current = get_site_transient( 'update_plugins' );
|
494 |
$r = $current->response['iwp-client/init.php'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
495 |
|
|
|
|
|
|
|
|
|
|
|
496 |
$stats['email'] = get_option('admin_email');
|
497 |
$stats['no_openssl'] = $this->get_random_signature();
|
498 |
$stats['content_path'] = WP_CONTENT_DIR;
|
@@ -503,9 +524,11 @@ class IWP_MMB_Stats extends IWP_MMB_Core
|
|
503 |
$stats['site_title'] = get_bloginfo('name');
|
504 |
$stats['site_tagline'] = get_bloginfo('description');
|
505 |
$stats['site_home'] = get_option('home');
|
506 |
-
$stats['admin_url'] =
|
507 |
$stats['wp_multisite'] = $this->iwp_mmb_multisite;
|
508 |
$stats['network_install'] = $this->network_admin_install;
|
|
|
|
|
509 |
|
510 |
if ($this->iwp_mmb_multisite) {
|
511 |
$details = get_blog_details($this->iwp_mmb_multisite);
|
69 |
$nposts = isset($options['numberposts']) ? (int) $options['numberposts'] : 20;
|
70 |
$trimlen = isset($options['trimcontent']) ? (int) $options['trimcontent'] : 200;
|
71 |
|
72 |
+
// if ($nposts) {
|
73 |
$comments = get_comments('status=hold&number=' . $nposts);
|
74 |
if (!empty($comments)) {
|
75 |
foreach ($comments as &$comment) {
|
89 |
$stats['comments']['pending'] = $comments;
|
90 |
}
|
91 |
|
92 |
+
/* $comments = get_comments('status=approve&number=' . $nposts);
|
93 |
if (!empty($comments)) {
|
94 |
foreach ($comments as &$comment) {
|
95 |
$commented_post = get_post($comment->comment_post_ID);
|
106 |
unset($comment->user_id);
|
107 |
}
|
108 |
$stats['comments']['approved'] = $comments;
|
109 |
+
}*/
|
110 |
+
//}
|
111 |
return $stats;
|
112 |
}
|
113 |
|
379 |
$current = get_site_transient( 'update_plugins' );
|
380 |
$r = $current->response['iwp-client/init.php'];
|
381 |
|
382 |
+
//For WPE
|
383 |
+
$use_cookie = 0;
|
384 |
+
if(@getenv('IS_WPE'))
|
385 |
+
$use_cookie=1;
|
386 |
+
|
387 |
$stats['client_version'] = IWP_MMB_CLIENT_VERSION;
|
388 |
$stats['client_new_version'] = $r->new_version;
|
389 |
$stats['client_new_package'] = $r->package;
|
393 |
$stats['mysql_version'] = $wpdb->db_version();
|
394 |
$stats['wp_multisite'] = $this->iwp_mmb_multisite;
|
395 |
$stats['network_install'] = $this->network_admin_install;
|
396 |
+
$stats['use_cookie'] = $use_cookie;
|
397 |
|
398 |
if ( !function_exists('get_filesystem_method') )
|
399 |
include_once(ABSPATH . 'wp-admin/includes/file.php');
|
498 |
|
499 |
$current = get_site_transient( 'update_plugins' );
|
500 |
$r = $current->response['iwp-client/init.php'];
|
501 |
+
//For BWP
|
502 |
+
$bwp = get_option("bit51_bwps");
|
503 |
+
$wp_admin_URL=admin_url();
|
504 |
+
if(!empty($bwp))
|
505 |
+
{
|
506 |
+
if($bwp['hb_enabled']==1)
|
507 |
+
$wp_admin_URL = admin_url()."?".$bwp['hb_key'];
|
508 |
+
|
509 |
+
|
510 |
+
}
|
511 |
|
512 |
+
//For WPE
|
513 |
+
$use_cookie = 0;
|
514 |
+
if(@getenv('IS_WPE'))
|
515 |
+
$use_cookie=1;
|
516 |
+
|
517 |
$stats['email'] = get_option('admin_email');
|
518 |
$stats['no_openssl'] = $this->get_random_signature();
|
519 |
$stats['content_path'] = WP_CONTENT_DIR;
|
524 |
$stats['site_title'] = get_bloginfo('name');
|
525 |
$stats['site_tagline'] = get_bloginfo('description');
|
526 |
$stats['site_home'] = get_option('home');
|
527 |
+
$stats['admin_url'] = $wp_admin_URL;
|
528 |
$stats['wp_multisite'] = $this->iwp_mmb_multisite;
|
529 |
$stats['network_install'] = $this->network_admin_install;
|
530 |
+
$stats['use_cookie'] = $use_cookie;
|
531 |
+
|
532 |
|
533 |
if ($this->iwp_mmb_multisite) {
|
534 |
$details = get_blog_details($this->iwp_mmb_multisite);
|