InfiniteWP Client - Version 1.3.4

Version Description

  • Feature: Maintenance mode with custom HTML.
  • New: WP site's server info can be viewed.
  • Improvement: Simplified site adding process - One-click copy & paste
  • Improvement: New addons compatibility.
Download this release

Release Info

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

Code changes from version 1.3.3 to 1.3.4

ZeroClipboard.js ADDED
@@ -0,0 +1,2295 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ * ZeroClipboard
3
+ * The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface.
4
+ * Copyright (c) 2014 Jon Rohan, James M. Greene
5
+ * Licensed MIT
6
+ * http://zeroclipboard.org/
7
+ * v2.1.1
8
+ */
9
+ (function(window, undefined) {
10
+ "use strict";
11
+ /**
12
+ * Store references to critically important global functions that may be
13
+ * overridden on certain web pages.
14
+ */
15
+ var _window = window, _document = _window.document, _navigator = _window.navigator, _setTimeout = _window.setTimeout, _parseInt = _window.Number.parseInt || _window.parseInt, _parseFloat = _window.Number.parseFloat || _window.parseFloat, _isNaN = _window.Number.isNaN || _window.isNaN, _encodeURIComponent = _window.encodeURIComponent, _Math = _window.Math, _Date = _window.Date, _ActiveXObject = _window.ActiveXObject, _slice = _window.Array.prototype.slice, _keys = _window.Object.keys, _hasOwn = _window.Object.prototype.hasOwnProperty, _defineProperty = function() {
16
+ if (typeof _window.Object.defineProperty === "function" && function() {
17
+ try {
18
+ var x = {};
19
+ _window.Object.defineProperty(x, "y", {
20
+ value: "z"
21
+ });
22
+ return x.y === "z";
23
+ } catch (e) {
24
+ return false;
25
+ }
26
+ }()) {
27
+ return _window.Object.defineProperty;
28
+ }
29
+ }();
30
+ /**
31
+ * Convert an `arguments` object into an Array.
32
+ *
33
+ * @returns The arguments as an Array
34
+ * @private
35
+ */
36
+ var _args = function(argumentsObj) {
37
+ return _slice.call(argumentsObj, 0);
38
+ };
39
+ /**
40
+ * Get the index of an item in an Array.
41
+ *
42
+ * @returns The index of an item in the Array, or `-1` if not found.
43
+ * @private
44
+ */
45
+ var _inArray = function(item, array, fromIndex) {
46
+ if (typeof array.indexOf === "function") {
47
+ return array.indexOf(item, fromIndex);
48
+ }
49
+ var i, len = array.length;
50
+ if (typeof fromIndex === "undefined") {
51
+ fromIndex = 0;
52
+ } else if (fromIndex < 0) {
53
+ fromIndex = len + fromIndex;
54
+ }
55
+ for (i = fromIndex; i < len; i++) {
56
+ if (_hasOwn.call(array, i) && array[i] === item) {
57
+ return i;
58
+ }
59
+ }
60
+ return -1;
61
+ };
62
+ /**
63
+ * Shallow-copy the owned, enumerable properties of one object over to another, similar to jQuery's `$.extend`.
64
+ *
65
+ * @returns The target object, augmented
66
+ * @private
67
+ */
68
+ var _extend = function() {
69
+ var i, len, arg, prop, src, copy, args = _args(arguments), target = args[0] || {};
70
+ for (i = 1, len = args.length; i < len; i++) {
71
+ if ((arg = args[i]) != null) {
72
+ for (prop in arg) {
73
+ if (_hasOwn.call(arg, prop)) {
74
+ src = target[prop];
75
+ copy = arg[prop];
76
+ if (target === copy) {
77
+ continue;
78
+ }
79
+ if (copy !== undefined) {
80
+ target[prop] = copy;
81
+ }
82
+ }
83
+ }
84
+ }
85
+ }
86
+ return target;
87
+ };
88
+ /**
89
+ * Return a deep copy of the source object or array.
90
+ *
91
+ * @returns Object or Array
92
+ * @private
93
+ */
94
+ var _deepCopy = function(source) {
95
+ var copy, i, len, prop;
96
+ if (typeof source !== "object" || source == null) {
97
+ copy = source;
98
+ } else if (typeof source.length === "number") {
99
+ copy = [];
100
+ for (i = 0, len = source.length; i < len; i++) {
101
+ if (_hasOwn.call(source, i)) {
102
+ copy[i] = _deepCopy(source[i]);
103
+ }
104
+ }
105
+ } else {
106
+ copy = {};
107
+ for (prop in source) {
108
+ if (_hasOwn.call(source, prop)) {
109
+ copy[prop] = _deepCopy(source[prop]);
110
+ }
111
+ }
112
+ }
113
+ return copy;
114
+ };
115
+ /**
116
+ * Makes a shallow copy of `obj` (like `_extend`) but filters its properties based on a list of `keys` to keep.
117
+ * The inverse of `_omit`, mostly. The big difference is that these properties do NOT need to be enumerable to
118
+ * be kept.
119
+ *
120
+ * @returns A new filtered object.
121
+ * @private
122
+ */
123
+ var _pick = function(obj, keys) {
124
+ var newObj = {};
125
+ for (var i = 0, len = keys.length; i < len; i++) {
126
+ if (keys[i] in obj) {
127
+ newObj[keys[i]] = obj[keys[i]];
128
+ }
129
+ }
130
+ return newObj;
131
+ };
132
+ /**
133
+ * Makes a shallow copy of `obj` (like `_extend`) but filters its properties based on a list of `keys` to omit.
134
+ * The inverse of `_pick`.
135
+ *
136
+ * @returns A new filtered object.
137
+ * @private
138
+ */
139
+ var _omit = function(obj, keys) {
140
+ var newObj = {};
141
+ for (var prop in obj) {
142
+ if (_inArray(prop, keys) === -1) {
143
+ newObj[prop] = obj[prop];
144
+ }
145
+ }
146
+ return newObj;
147
+ };
148
+ /**
149
+ * Get all of an object's owned, enumerable property names. Does NOT include prototype properties.
150
+ *
151
+ * @returns An Array of property names.
152
+ * @private
153
+ */
154
+ var _objectKeys = function(obj) {
155
+ if (obj == null) {
156
+ return [];
157
+ }
158
+ if (_keys) {
159
+ return _keys(obj);
160
+ }
161
+ var keys = [];
162
+ for (var prop in obj) {
163
+ if (_hasOwn.call(obj, prop)) {
164
+ keys.push(prop);
165
+ }
166
+ }
167
+ return keys;
168
+ };
169
+ /**
170
+ * Remove all owned, enumerable properties from an object.
171
+ *
172
+ * @returns The original object without its owned, enumerable properties.
173
+ * @private
174
+ */
175
+ var _deleteOwnProperties = function(obj) {
176
+ if (obj) {
177
+ for (var prop in obj) {
178
+ if (_hasOwn.call(obj, prop)) {
179
+ delete obj[prop];
180
+ }
181
+ }
182
+ }
183
+ return obj;
184
+ };
185
+ /**
186
+ * Mark an existing property as read-only.
187
+ * @private
188
+ */
189
+ var _makeReadOnly = function(obj, prop) {
190
+ if (prop in obj && typeof _defineProperty === "function") {
191
+ _defineProperty(obj, prop, {
192
+ value: obj[prop],
193
+ writable: false,
194
+ configurable: true,
195
+ enumerable: true
196
+ });
197
+ }
198
+ };
199
+ /**
200
+ * Get the current time in milliseconds since the epoch.
201
+ *
202
+ * @returns Number
203
+ * @private
204
+ */
205
+ var _now = function(Date) {
206
+ return function() {
207
+ var time;
208
+ if (Date.now) {
209
+ time = Date.now();
210
+ } else {
211
+ time = new Date().getTime();
212
+ }
213
+ return time;
214
+ };
215
+ }(_Date);
216
+ /**
217
+ * Determine if an element is contained within another element.
218
+ *
219
+ * @returns Boolean
220
+ * @private
221
+ */
222
+ var _containedBy = function(el, ancestorEl) {
223
+ if (el && el.nodeType === 1 && ancestorEl && (ancestorEl.nodeType === 1 || ancestorEl.nodeType === 9)) {
224
+ do {
225
+ if (el === ancestorEl) {
226
+ return true;
227
+ }
228
+ el = el.parentNode;
229
+ } while (el);
230
+ }
231
+ return false;
232
+ };
233
+ /**
234
+ * Keep track of the state of the Flash object.
235
+ * @private
236
+ */
237
+ var _flashState = {
238
+ bridge: null,
239
+ version: "0.0.0",
240
+ pluginType: "unknown",
241
+ disabled: null,
242
+ outdated: null,
243
+ unavailable: null,
244
+ deactivated: null,
245
+ overdue: null,
246
+ ready: null
247
+ };
248
+ /**
249
+ * The minimum Flash Player version required to use ZeroClipboard completely.
250
+ * @readonly
251
+ * @private
252
+ */
253
+ var _minimumFlashVersion = "11.0.0";
254
+ /**
255
+ * Keep track of all event listener registrations.
256
+ * @private
257
+ */
258
+ var _handlers = {};
259
+ /**
260
+ * Keep track of the currently activated element.
261
+ * @private
262
+ */
263
+ var _currentElement;
264
+ /**
265
+ * Keep track of data for the pending clipboard transaction.
266
+ * @private
267
+ */
268
+ var _clipData = {};
269
+ /**
270
+ * Keep track of data formats for the pending clipboard transaction.
271
+ * @private
272
+ */
273
+ var _clipDataFormatMap = null;
274
+ /**
275
+ * The `message` store for events
276
+ * @private
277
+ */
278
+ var _eventMessages = {
279
+ ready: "Flash communication is established",
280
+ error: {
281
+ "flash-disabled": "Flash is disabled or not installed",
282
+ "flash-outdated": "Flash is too outdated to support ZeroClipboard",
283
+ "flash-unavailable": "Flash is unable to communicate bidirectionally with JavaScript",
284
+ "flash-deactivated": "Flash is too outdated for your browser and/or is configured as click-to-activate",
285
+ "flash-overdue": "Flash communication was established but NOT within the acceptable time limit"
286
+ }
287
+ };
288
+ /**
289
+ * The presumed location of the "ZeroClipboard.swf" file, based on the location
290
+ * of the executing JavaScript file (e.g. "ZeroClipboard.js", etc.).
291
+ * @private
292
+ */
293
+ var _swfPath = function() {
294
+ var i, jsDir, tmpJsPath, jsPath, swfPath = "ZeroClipboard.swf";
295
+ if (!(_document.currentScript && (jsPath = _document.currentScript.src))) {
296
+ var scripts = _document.getElementsByTagName("script");
297
+ if ("readyState" in scripts[0]) {
298
+ for (i = scripts.length; i--; ) {
299
+ if (scripts[i].readyState === "interactive" && (jsPath = scripts[i].src)) {
300
+ break;
301
+ }
302
+ }
303
+ } else if (_document.readyState === "loading") {
304
+ jsPath = scripts[scripts.length - 1].src;
305
+ } else {
306
+ for (i = scripts.length; i--; ) {
307
+ tmpJsPath = scripts[i].src;
308
+ if (!tmpJsPath) {
309
+ jsDir = null;
310
+ break;
311
+ }
312
+ tmpJsPath = tmpJsPath.split("#")[0].split("?")[0];
313
+ tmpJsPath = tmpJsPath.slice(0, tmpJsPath.lastIndexOf("/") + 1);
314
+ if (jsDir == null) {
315
+ jsDir = tmpJsPath;
316
+ } else if (jsDir !== tmpJsPath) {
317
+ jsDir = null;
318
+ break;
319
+ }
320
+ }
321
+ if (jsDir !== null) {
322
+ jsPath = jsDir;
323
+ }
324
+ }
325
+ }
326
+ if (jsPath) {
327
+ jsPath = jsPath.split("#")[0].split("?")[0];
328
+ swfPath = jsPath.slice(0, jsPath.lastIndexOf("/") + 1) + swfPath;
329
+ }
330
+ return swfPath;
331
+ }();
332
+ /**
333
+ * ZeroClipboard configuration defaults for the Core module.
334
+ * @private
335
+ */
336
+ var _globalConfig = {
337
+ swfPath: _swfPath,
338
+ trustedDomains: window.location.host ? [ window.location.host ] : [],
339
+ cacheBust: true,
340
+ forceEnhancedClipboard: false,
341
+ flashLoadTimeout: 3e4,
342
+ autoActivate: true,
343
+ bubbleEvents: true,
344
+ containerId: "global-zeroclipboard-html-bridge",
345
+ containerClass: "global-zeroclipboard-container",
346
+ swfObjectId: "global-zeroclipboard-flash-bridge",
347
+ hoverClass: "zeroclipboard-is-hover",
348
+ activeClass: "zeroclipboard-is-active",
349
+ forceHandCursor: false,
350
+ title: null,
351
+ zIndex: 999999999
352
+ };
353
+ /**
354
+ * The underlying implementation of `ZeroClipboard.config`.
355
+ * @private
356
+ */
357
+ var _config = function(options) {
358
+ if (typeof options === "object" && options !== null) {
359
+ for (var prop in options) {
360
+ if (_hasOwn.call(options, prop)) {
361
+ if (/^(?:forceHandCursor|title|zIndex|bubbleEvents)$/.test(prop)) {
362
+ _globalConfig[prop] = options[prop];
363
+ } else if (_flashState.bridge == null) {
364
+ if (prop === "containerId" || prop === "swfObjectId") {
365
+ if (_isValidHtml4Id(options[prop])) {
366
+ _globalConfig[prop] = options[prop];
367
+ } else {
368
+ throw new Error("The specified `" + prop + "` value is not valid as an HTML4 Element ID");
369
+ }
370
+ } else {
371
+ _globalConfig[prop] = options[prop];
372
+ }
373
+ }
374
+ }
375
+ }
376
+ }
377
+ if (typeof options === "string" && options) {
378
+ if (_hasOwn.call(_globalConfig, options)) {
379
+ return _globalConfig[options];
380
+ }
381
+ return;
382
+ }
383
+ return _deepCopy(_globalConfig);
384
+ };
385
+ /**
386
+ * The underlying implementation of `ZeroClipboard.state`.
387
+ * @private
388
+ */
389
+ var _state = function() {
390
+ return {
391
+ browser: _pick(_navigator, [ "userAgent", "platform", "appName" ]),
392
+ flash: _omit(_flashState, [ "bridge" ]),
393
+ zeroclipboard: {
394
+ version: ZeroClipboard.version,
395
+ config: ZeroClipboard.config()
396
+ }
397
+ };
398
+ };
399
+ /**
400
+ * The underlying implementation of `ZeroClipboard.isFlashUnusable`.
401
+ * @private
402
+ */
403
+ var _isFlashUnusable = function() {
404
+ return !!(_flashState.disabled || _flashState.outdated || _flashState.unavailable || _flashState.deactivated);
405
+ };
406
+ /**
407
+ * The underlying implementation of `ZeroClipboard.on`.
408
+ * @private
409
+ */
410
+ var _on = function(eventType, listener) {
411
+ var i, len, events, added = {};
412
+ if (typeof eventType === "string" && eventType) {
413
+ events = eventType.toLowerCase().split(/\s+/);
414
+ } else if (typeof eventType === "object" && eventType && typeof listener === "undefined") {
415
+ for (i in eventType) {
416
+ if (_hasOwn.call(eventType, i) && typeof i === "string" && i && typeof eventType[i] === "function") {
417
+ ZeroClipboard.on(i, eventType[i]);
418
+ }
419
+ }
420
+ }
421
+ if (events && events.length) {
422
+ for (i = 0, len = events.length; i < len; i++) {
423
+ eventType = events[i].replace(/^on/, "");
424
+ added[eventType] = true;
425
+ if (!_handlers[eventType]) {
426
+ _handlers[eventType] = [];
427
+ }
428
+ _handlers[eventType].push(listener);
429
+ }
430
+ if (added.ready && _flashState.ready) {
431
+ ZeroClipboard.emit({
432
+ type: "ready"
433
+ });
434
+ }
435
+ if (added.error) {
436
+ var errorTypes = [ "disabled", "outdated", "unavailable", "deactivated", "overdue" ];
437
+ for (i = 0, len = errorTypes.length; i < len; i++) {
438
+ if (_flashState[errorTypes[i]] === true) {
439
+ ZeroClipboard.emit({
440
+ type: "error",
441
+ name: "flash-" + errorTypes[i]
442
+ });
443
+ break;
444
+ }
445
+ }
446
+ }
447
+ }
448
+ return ZeroClipboard;
449
+ };
450
+ /**
451
+ * The underlying implementation of `ZeroClipboard.off`.
452
+ * @private
453
+ */
454
+ var _off = function(eventType, listener) {
455
+ var i, len, foundIndex, events, perEventHandlers;
456
+ if (arguments.length === 0) {
457
+ events = _objectKeys(_handlers);
458
+ } else if (typeof eventType === "string" && eventType) {
459
+ events = eventType.split(/\s+/);
460
+ } else if (typeof eventType === "object" && eventType && typeof listener === "undefined") {
461
+ for (i in eventType) {
462
+ if (_hasOwn.call(eventType, i) && typeof i === "string" && i && typeof eventType[i] === "function") {
463
+ ZeroClipboard.off(i, eventType[i]);
464
+ }
465
+ }
466
+ }
467
+ if (events && events.length) {
468
+ for (i = 0, len = events.length; i < len; i++) {
469
+ eventType = events[i].toLowerCase().replace(/^on/, "");
470
+ perEventHandlers = _handlers[eventType];
471
+ if (perEventHandlers && perEventHandlers.length) {
472
+ if (listener) {
473
+ foundIndex = _inArray(listener, perEventHandlers);
474
+ while (foundIndex !== -1) {
475
+ perEventHandlers.splice(foundIndex, 1);
476
+ foundIndex = _inArray(listener, perEventHandlers, foundIndex);
477
+ }
478
+ } else {
479
+ perEventHandlers.length = 0;
480
+ }
481
+ }
482
+ }
483
+ }
484
+ return ZeroClipboard;
485
+ };
486
+ /**
487
+ * The underlying implementation of `ZeroClipboard.handlers`.
488
+ * @private
489
+ */
490
+ var _listeners = function(eventType) {
491
+ var copy;
492
+ if (typeof eventType === "string" && eventType) {
493
+ copy = _deepCopy(_handlers[eventType]) || null;
494
+ } else {
495
+ copy = _deepCopy(_handlers);
496
+ }
497
+ return copy;
498
+ };
499
+ /**
500
+ * The underlying implementation of `ZeroClipboard.emit`.
501
+ * @private
502
+ */
503
+ var _emit = function(event) {
504
+ var eventCopy, returnVal, tmp;
505
+ event = _createEvent(event);
506
+ if (!event) {
507
+ return;
508
+ }
509
+ if (_preprocessEvent(event)) {
510
+ return;
511
+ }
512
+ if (event.type === "ready" && _flashState.overdue === true) {
513
+ return ZeroClipboard.emit({
514
+ type: "error",
515
+ name: "flash-overdue"
516
+ });
517
+ }
518
+ eventCopy = _extend({}, event);
519
+ _dispatchCallbacks.call(this, eventCopy);
520
+ if (event.type === "copy") {
521
+ tmp = _mapClipDataToFlash(_clipData);
522
+ returnVal = tmp.data;
523
+ _clipDataFormatMap = tmp.formatMap;
524
+ }
525
+ return returnVal;
526
+ };
527
+ /**
528
+ * The underlying implementation of `ZeroClipboard.create`.
529
+ * @private
530
+ */
531
+ var _create = function() {
532
+ if (typeof _flashState.ready !== "boolean") {
533
+ _flashState.ready = false;
534
+ }
535
+ if (!ZeroClipboard.isFlashUnusable() && _flashState.bridge === null) {
536
+ var maxWait = _globalConfig.flashLoadTimeout;
537
+ if (typeof maxWait === "number" && maxWait >= 0) {
538
+ _setTimeout(function() {
539
+ if (typeof _flashState.deactivated !== "boolean") {
540
+ _flashState.deactivated = true;
541
+ }
542
+ if (_flashState.deactivated === true) {
543
+ ZeroClipboard.emit({
544
+ type: "error",
545
+ name: "flash-deactivated"
546
+ });
547
+ }
548
+ }, maxWait);
549
+ }
550
+ _flashState.overdue = false;
551
+ _embedSwf();
552
+ }
553
+ };
554
+ /**
555
+ * The underlying implementation of `ZeroClipboard.destroy`.
556
+ * @private
557
+ */
558
+ var _destroy = function() {
559
+ ZeroClipboard.clearData();
560
+ ZeroClipboard.blur();
561
+ ZeroClipboard.emit("destroy");
562
+ _unembedSwf();
563
+ ZeroClipboard.off();
564
+ };
565
+ /**
566
+ * The underlying implementation of `ZeroClipboard.setData`.
567
+ * @private
568
+ */
569
+ var _setData = function(format, data) {
570
+ var dataObj;
571
+ if (typeof format === "object" && format && typeof data === "undefined") {
572
+ dataObj = format;
573
+ ZeroClipboard.clearData();
574
+ } else if (typeof format === "string" && format) {
575
+ dataObj = {};
576
+ dataObj[format] = data;
577
+ } else {
578
+ return;
579
+ }
580
+ for (var dataFormat in dataObj) {
581
+ if (typeof dataFormat === "string" && dataFormat && _hasOwn.call(dataObj, dataFormat) && typeof dataObj[dataFormat] === "string" && dataObj[dataFormat]) {
582
+ _clipData[dataFormat] = dataObj[dataFormat];
583
+ }
584
+ }
585
+ };
586
+ /**
587
+ * The underlying implementation of `ZeroClipboard.clearData`.
588
+ * @private
589
+ */
590
+ var _clearData = function(format) {
591
+ if (typeof format === "undefined") {
592
+ _deleteOwnProperties(_clipData);
593
+ _clipDataFormatMap = null;
594
+ } else if (typeof format === "string" && _hasOwn.call(_clipData, format)) {
595
+ delete _clipData[format];
596
+ }
597
+ };
598
+ /**
599
+ * The underlying implementation of `ZeroClipboard.getData`.
600
+ * @private
601
+ */
602
+ var _getData = function(format) {
603
+ if (typeof format === "undefined") {
604
+ return _deepCopy(_clipData);
605
+ } else if (typeof format === "string" && _hasOwn.call(_clipData, format)) {
606
+ return _clipData[format];
607
+ }
608
+ };
609
+ /**
610
+ * The underlying implementation of `ZeroClipboard.focus`/`ZeroClipboard.activate`.
611
+ * @private
612
+ */
613
+ var _focus = function(element) {
614
+ if (!(element && element.nodeType === 1)) {
615
+ return;
616
+ }
617
+ if (_currentElement) {
618
+ _removeClass(_currentElement, _globalConfig.activeClass);
619
+ if (_currentElement !== element) {
620
+ _removeClass(_currentElement, _globalConfig.hoverClass);
621
+ }
622
+ }
623
+ _currentElement = element;
624
+ _addClass(element, _globalConfig.hoverClass);
625
+ var newTitle = element.getAttribute("title") || _globalConfig.title;
626
+ if (typeof newTitle === "string" && newTitle) {
627
+ var htmlBridge = _getHtmlBridge(_flashState.bridge);
628
+ if (htmlBridge) {
629
+ htmlBridge.setAttribute("title", newTitle);
630
+ }
631
+ }
632
+ var useHandCursor = _globalConfig.forceHandCursor === true || _getStyle(element, "cursor") === "pointer";
633
+ _setHandCursor(useHandCursor);
634
+ _reposition();
635
+ };
636
+ /**
637
+ * The underlying implementation of `ZeroClipboard.blur`/`ZeroClipboard.deactivate`.
638
+ * @private
639
+ */
640
+ var _blur = function() {
641
+ var htmlBridge = _getHtmlBridge(_flashState.bridge);
642
+ if (htmlBridge) {
643
+ htmlBridge.removeAttribute("title");
644
+ htmlBridge.style.left = "0px";
645
+ htmlBridge.style.top = "-9999px";
646
+ htmlBridge.style.width = "1px";
647
+ htmlBridge.style.top = "1px";
648
+ }
649
+ if (_currentElement) {
650
+ _removeClass(_currentElement, _globalConfig.hoverClass);
651
+ _removeClass(_currentElement, _globalConfig.activeClass);
652
+ _currentElement = null;
653
+ }
654
+ };
655
+ /**
656
+ * The underlying implementation of `ZeroClipboard.activeElement`.
657
+ * @private
658
+ */
659
+ var _activeElement = function() {
660
+ return _currentElement || null;
661
+ };
662
+ /**
663
+ * Check if a value is a valid HTML4 `ID` or `Name` token.
664
+ * @private
665
+ */
666
+ var _isValidHtml4Id = function(id) {
667
+ return typeof id === "string" && id && /^[A-Za-z][A-Za-z0-9_:\-\.]*$/.test(id);
668
+ };
669
+ /**
670
+ * Create or update an `event` object, based on the `eventType`.
671
+ * @private
672
+ */
673
+ var _createEvent = function(event) {
674
+ var eventType;
675
+ if (typeof event === "string" && event) {
676
+ eventType = event;
677
+ event = {};
678
+ } else if (typeof event === "object" && event && typeof event.type === "string" && event.type) {
679
+ eventType = event.type;
680
+ }
681
+ if (!eventType) {
682
+ return;
683
+ }
684
+ _extend(event, {
685
+ type: eventType.toLowerCase(),
686
+ target: event.target || _currentElement || null,
687
+ relatedTarget: event.relatedTarget || null,
688
+ currentTarget: _flashState && _flashState.bridge || null,
689
+ timeStamp: event.timeStamp || _now() || null
690
+ });
691
+ var msg = _eventMessages[event.type];
692
+ if (event.type === "error" && event.name && msg) {
693
+ msg = msg[event.name];
694
+ }
695
+ if (msg) {
696
+ event.message = msg;
697
+ }
698
+ if (event.type === "ready") {
699
+ _extend(event, {
700
+ target: null,
701
+ version: _flashState.version
702
+ });
703
+ }
704
+ if (event.type === "error") {
705
+ if (/^flash-(disabled|outdated|unavailable|deactivated|overdue)$/.test(event.name)) {
706
+ _extend(event, {
707
+ target: null,
708
+ minimumVersion: _minimumFlashVersion
709
+ });
710
+ }
711
+ if (/^flash-(outdated|unavailable|deactivated|overdue)$/.test(event.name)) {
712
+ _extend(event, {
713
+ version: _flashState.version
714
+ });
715
+ }
716
+ }
717
+ if (event.type === "copy") {
718
+ event.clipboardData = {
719
+ setData: ZeroClipboard.setData,
720
+ clearData: ZeroClipboard.clearData
721
+ };
722
+ }
723
+ if (event.type === "aftercopy") {
724
+ event = _mapClipResultsFromFlash(event, _clipDataFormatMap);
725
+ }
726
+ if (event.target && !event.relatedTarget) {
727
+ event.relatedTarget = _getRelatedTarget(event.target);
728
+ }
729
+ event = _addMouseData(event);
730
+ return event;
731
+ };
732
+ /**
733
+ * Get a relatedTarget from the target's `data-clipboard-target` attribute
734
+ * @private
735
+ */
736
+ var _getRelatedTarget = function(targetEl) {
737
+ var relatedTargetId = targetEl && targetEl.getAttribute && targetEl.getAttribute("data-clipboard-target");
738
+ return relatedTargetId ? _document.getElementById(relatedTargetId) : null;
739
+ };
740
+ /**
741
+ * Add element and position data to `MouseEvent` instances
742
+ * @private
743
+ */
744
+ var _addMouseData = function(event) {
745
+ if (event && /^_(?:click|mouse(?:over|out|down|up|move))$/.test(event.type)) {
746
+ var srcElement = event.target;
747
+ var fromElement = event.type === "_mouseover" && event.relatedTarget ? event.relatedTarget : undefined;
748
+ var toElement = event.type === "_mouseout" && event.relatedTarget ? event.relatedTarget : undefined;
749
+ var pos = _getDOMObjectPosition(srcElement);
750
+ var screenLeft = _window.screenLeft || _window.screenX || 0;
751
+ var screenTop = _window.screenTop || _window.screenY || 0;
752
+ var scrollLeft = _document.body.scrollLeft + _document.documentElement.scrollLeft;
753
+ var scrollTop = _document.body.scrollTop + _document.documentElement.scrollTop;
754
+ var pageX = pos.left + (typeof event._stageX === "number" ? event._stageX : 0);
755
+ var pageY = pos.top + (typeof event._stageY === "number" ? event._stageY : 0);
756
+ var clientX = pageX - scrollLeft;
757
+ var clientY = pageY - scrollTop;
758
+ var screenX = screenLeft + clientX;
759
+ var screenY = screenTop + clientY;
760
+ var moveX = typeof event.movementX === "number" ? event.movementX : 0;
761
+ var moveY = typeof event.movementY === "number" ? event.movementY : 0;
762
+ delete event._stageX;
763
+ delete event._stageY;
764
+ _extend(event, {
765
+ srcElement: srcElement,
766
+ fromElement: fromElement,
767
+ toElement: toElement,
768
+ screenX: screenX,
769
+ screenY: screenY,
770
+ pageX: pageX,
771
+ pageY: pageY,
772
+ clientX: clientX,
773
+ clientY: clientY,
774
+ x: clientX,
775
+ y: clientY,
776
+ movementX: moveX,
777
+ movementY: moveY,
778
+ offsetX: 0,
779
+ offsetY: 0,
780
+ layerX: 0,
781
+ layerY: 0
782
+ });
783
+ }
784
+ return event;
785
+ };
786
+ /**
787
+ * Determine if an event's registered handlers should be execute synchronously or asynchronously.
788
+ *
789
+ * @returns {boolean}
790
+ * @private
791
+ */
792
+ var _shouldPerformAsync = function(event) {
793
+ var eventType = event && typeof event.type === "string" && event.type || "";
794
+ return !/^(?:(?:before)?copy|destroy)$/.test(eventType);
795
+ };
796
+ /**
797
+ * Control if a callback should be executed asynchronously or not.
798
+ *
799
+ * @returns `undefined`
800
+ * @private
801
+ */
802
+ var _dispatchCallback = function(func, context, args, async) {
803
+ if (async) {
804
+ _setTimeout(function() {
805
+ func.apply(context, args);
806
+ }, 0);
807
+ } else {
808
+ func.apply(context, args);
809
+ }
810
+ };
811
+ /**
812
+ * Handle the actual dispatching of events to client instances.
813
+ *
814
+ * @returns `undefined`
815
+ * @private
816
+ */
817
+ var _dispatchCallbacks = function(event) {
818
+ if (!(typeof event === "object" && event && event.type)) {
819
+ return;
820
+ }
821
+ var async = _shouldPerformAsync(event);
822
+ var wildcardTypeHandlers = _handlers["*"] || [];
823
+ var specificTypeHandlers = _handlers[event.type] || [];
824
+ var handlers = wildcardTypeHandlers.concat(specificTypeHandlers);
825
+ if (handlers && handlers.length) {
826
+ var i, len, func, context, eventCopy, originalContext = this;
827
+ for (i = 0, len = handlers.length; i < len; i++) {
828
+ func = handlers[i];
829
+ context = originalContext;
830
+ if (typeof func === "string" && typeof _window[func] === "function") {
831
+ func = _window[func];
832
+ }
833
+ if (typeof func === "object" && func && typeof func.handleEvent === "function") {
834
+ context = func;
835
+ func = func.handleEvent;
836
+ }
837
+ if (typeof func === "function") {
838
+ eventCopy = _extend({}, event);
839
+ _dispatchCallback(func, context, [ eventCopy ], async);
840
+ }
841
+ }
842
+ }
843
+ return this;
844
+ };
845
+ /**
846
+ * Preprocess any special behaviors, reactions, or state changes after receiving this event.
847
+ * Executes only once per event emitted, NOT once per client.
848
+ * @private
849
+ */
850
+ var _preprocessEvent = function(event) {
851
+ var element = event.target || _currentElement || null;
852
+ var sourceIsSwf = event._source === "swf";
853
+ delete event._source;
854
+ switch (event.type) {
855
+ case "error":
856
+ if (_inArray(event.name, [ "flash-disabled", "flash-outdated", "flash-deactivated", "flash-overdue" ])) {
857
+ _extend(_flashState, {
858
+ disabled: event.name === "flash-disabled",
859
+ outdated: event.name === "flash-outdated",
860
+ unavailable: event.name === "flash-unavailable",
861
+ deactivated: event.name === "flash-deactivated",
862
+ overdue: event.name === "flash-overdue",
863
+ ready: false
864
+ });
865
+ }
866
+ break;
867
+
868
+ case "ready":
869
+ var wasDeactivated = _flashState.deactivated === true;
870
+ _extend(_flashState, {
871
+ disabled: false,
872
+ outdated: false,
873
+ unavailable: false,
874
+ deactivated: false,
875
+ overdue: wasDeactivated,
876
+ ready: !wasDeactivated
877
+ });
878
+ break;
879
+
880
+ case "copy":
881
+ var textContent, htmlContent, targetEl = event.relatedTarget;
882
+ if (!(_clipData["text/html"] || _clipData["text/plain"]) && targetEl && (htmlContent = targetEl.value || targetEl.outerHTML || targetEl.innerHTML) && (textContent = targetEl.value || targetEl.textContent || targetEl.innerText)) {
883
+ event.clipboardData.clearData();
884
+ event.clipboardData.setData("text/plain", textContent);
885
+ if (htmlContent !== textContent) {
886
+ event.clipboardData.setData("text/html", htmlContent);
887
+ }
888
+ } else if (!_clipData["text/plain"] && event.target && (textContent = event.target.getAttribute("data-clipboard-text"))) {
889
+ event.clipboardData.clearData();
890
+ event.clipboardData.setData("text/plain", textContent);
891
+ }
892
+ break;
893
+
894
+ case "aftercopy":
895
+ ZeroClipboard.clearData();
896
+ if (element && element !== _safeActiveElement() && element.focus) {
897
+ element.focus();
898
+ }
899
+ break;
900
+
901
+ case "_mouseover":
902
+ ZeroClipboard.focus(element);
903
+ if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
904
+ if (element && element !== event.relatedTarget && !_containedBy(event.relatedTarget, element)) {
905
+ _fireMouseEvent(_extend({}, event, {
906
+ type: "mouseenter",
907
+ bubbles: false,
908
+ cancelable: false
909
+ }));
910
+ }
911
+ _fireMouseEvent(_extend({}, event, {
912
+ type: "mouseover"
913
+ }));
914
+ }
915
+ break;
916
+
917
+ case "_mouseout":
918
+ ZeroClipboard.blur();
919
+ if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
920
+ if (element && element !== event.relatedTarget && !_containedBy(event.relatedTarget, element)) {
921
+ _fireMouseEvent(_extend({}, event, {
922
+ type: "mouseleave",
923
+ bubbles: false,
924
+ cancelable: false
925
+ }));
926
+ }
927
+ _fireMouseEvent(_extend({}, event, {
928
+ type: "mouseout"
929
+ }));
930
+ }
931
+ break;
932
+
933
+ case "_mousedown":
934
+ _addClass(element, _globalConfig.activeClass);
935
+ if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
936
+ _fireMouseEvent(_extend({}, event, {
937
+ type: event.type.slice(1)
938
+ }));
939
+ }
940
+ break;
941
+
942
+ case "_mouseup":
943
+ _removeClass(element, _globalConfig.activeClass);
944
+ if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
945
+ _fireMouseEvent(_extend({}, event, {
946
+ type: event.type.slice(1)
947
+ }));
948
+ }
949
+ break;
950
+
951
+ case "_click":
952
+ case "_mousemove":
953
+ if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
954
+ _fireMouseEvent(_extend({}, event, {
955
+ type: event.type.slice(1)
956
+ }));
957
+ }
958
+ break;
959
+ }
960
+ if (/^_(?:click|mouse(?:over|out|down|up|move))$/.test(event.type)) {
961
+ return true;
962
+ }
963
+ };
964
+ /**
965
+ * Dispatch a synthetic MouseEvent.
966
+ *
967
+ * @returns `undefined`
968
+ * @private
969
+ */
970
+ var _fireMouseEvent = function(event) {
971
+ if (!(event && typeof event.type === "string" && event)) {
972
+ return;
973
+ }
974
+ var e, target = event.target || null, doc = target && target.ownerDocument || _document, defaults = {
975
+ view: doc.defaultView || _window,
976
+ canBubble: true,
977
+ cancelable: true,
978
+ detail: event.type === "click" ? 1 : 0,
979
+ button: typeof event.which === "number" ? event.which - 1 : typeof event.button === "number" ? event.button : doc.createEvent ? 0 : 1
980
+ }, args = _extend(defaults, event);
981
+ if (!target) {
982
+ return;
983
+ }
984
+ if (doc.createEvent && target.dispatchEvent) {
985
+ args = [ args.type, args.canBubble, args.cancelable, args.view, args.detail, args.screenX, args.screenY, args.clientX, args.clientY, args.ctrlKey, args.altKey, args.shiftKey, args.metaKey, args.button, args.relatedTarget ];
986
+ e = doc.createEvent("MouseEvents");
987
+ if (e.initMouseEvent) {
988
+ e.initMouseEvent.apply(e, args);
989
+ e._source = "js";
990
+ target.dispatchEvent(e);
991
+ }
992
+ }
993
+ };
994
+ /**
995
+ * Create the HTML bridge element to embed the Flash object into.
996
+ * @private
997
+ */
998
+ var _createHtmlBridge = function() {
999
+ var container = _document.createElement("div");
1000
+ container.id = _globalConfig.containerId;
1001
+ container.className = _globalConfig.containerClass;
1002
+ container.style.position = "absolute";
1003
+ container.style.left = "0px";
1004
+ container.style.top = "-9999px";
1005
+ container.style.width = "1px";
1006
+ container.style.height = "1px";
1007
+ container.style.zIndex = "" + _getSafeZIndex(_globalConfig.zIndex);
1008
+ return container;
1009
+ };
1010
+ /**
1011
+ * Get the HTML element container that wraps the Flash bridge object/element.
1012
+ * @private
1013
+ */
1014
+ var _getHtmlBridge = function(flashBridge) {
1015
+ var htmlBridge = flashBridge && flashBridge.parentNode;
1016
+ while (htmlBridge && htmlBridge.nodeName === "OBJECT" && htmlBridge.parentNode) {
1017
+ htmlBridge = htmlBridge.parentNode;
1018
+ }
1019
+ return htmlBridge || null;
1020
+ };
1021
+ /**
1022
+ * Create the SWF object.
1023
+ *
1024
+ * @returns The SWF object reference.
1025
+ * @private
1026
+ */
1027
+ var _embedSwf = function() {
1028
+ var len, flashBridge = _flashState.bridge, container = _getHtmlBridge(flashBridge);
1029
+ if (!flashBridge) {
1030
+ var allowScriptAccess = _determineScriptAccess(_window.location.host, _globalConfig);
1031
+ var allowNetworking = allowScriptAccess === "never" ? "none" : "all";
1032
+ var flashvars = _vars(_globalConfig);
1033
+ var swfUrl = _globalConfig.swfPath + _cacheBust(_globalConfig.swfPath, _globalConfig);
1034
+ container = _createHtmlBridge();
1035
+ var divToBeReplaced = _document.createElement("div");
1036
+ container.appendChild(divToBeReplaced);
1037
+ _document.body.appendChild(container);
1038
+ var tmpDiv = _document.createElement("div");
1039
+ var oldIE = _flashState.pluginType === "activex";
1040
+ tmpDiv.innerHTML = '<object id="' + _globalConfig.swfObjectId + '" name="' + _globalConfig.swfObjectId + '" ' + 'width="100%" height="100%" ' + (oldIE ? 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"' : 'type="application/x-shockwave-flash" data="' + swfUrl + '"') + ">" + (oldIE ? '<param name="movie" value="' + swfUrl + '"/>' : "") + '<param name="allowScriptAccess" value="' + allowScriptAccess + '"/>' + '<param name="allowNetworking" value="' + allowNetworking + '"/>' + '<param name="menu" value="false"/>' + '<param name="wmode" value="transparent"/>' + '<param name="flashvars" value="' + flashvars + '"/>' + "</object>";
1041
+ flashBridge = tmpDiv.firstChild;
1042
+ tmpDiv = null;
1043
+ flashBridge.ZeroClipboard = ZeroClipboard;
1044
+ container.replaceChild(flashBridge, divToBeReplaced);
1045
+ }
1046
+ if (!flashBridge) {
1047
+ flashBridge = _document[_globalConfig.swfObjectId];
1048
+ if (flashBridge && (len = flashBridge.length)) {
1049
+ flashBridge = flashBridge[len - 1];
1050
+ }
1051
+ if (!flashBridge && container) {
1052
+ flashBridge = container.firstChild;
1053
+ }
1054
+ }
1055
+ _flashState.bridge = flashBridge || null;
1056
+ return flashBridge;
1057
+ };
1058
+ /**
1059
+ * Destroy the SWF object.
1060
+ * @private
1061
+ */
1062
+ var _unembedSwf = function() {
1063
+ var flashBridge = _flashState.bridge;
1064
+ if (flashBridge) {
1065
+ var htmlBridge = _getHtmlBridge(flashBridge);
1066
+ if (htmlBridge) {
1067
+ if (_flashState.pluginType === "activex" && "readyState" in flashBridge) {
1068
+ flashBridge.style.display = "none";
1069
+ (function removeSwfFromIE() {
1070
+ if (flashBridge.readyState === 4) {
1071
+ for (var prop in flashBridge) {
1072
+ if (typeof flashBridge[prop] === "function") {
1073
+ flashBridge[prop] = null;
1074
+ }
1075
+ }
1076
+ if (flashBridge.parentNode) {
1077
+ flashBridge.parentNode.removeChild(flashBridge);
1078
+ }
1079
+ if (htmlBridge.parentNode) {
1080
+ htmlBridge.parentNode.removeChild(htmlBridge);
1081
+ }
1082
+ } else {
1083
+ _setTimeout(removeSwfFromIE, 10);
1084
+ }
1085
+ })();
1086
+ } else {
1087
+ if (flashBridge.parentNode) {
1088
+ flashBridge.parentNode.removeChild(flashBridge);
1089
+ }
1090
+ if (htmlBridge.parentNode) {
1091
+ htmlBridge.parentNode.removeChild(htmlBridge);
1092
+ }
1093
+ }
1094
+ }
1095
+ _flashState.ready = null;
1096
+ _flashState.bridge = null;
1097
+ _flashState.deactivated = null;
1098
+ }
1099
+ };
1100
+ /**
1101
+ * Map the data format names of the "clipData" to Flash-friendly names.
1102
+ *
1103
+ * @returns A new transformed object.
1104
+ * @private
1105
+ */
1106
+ var _mapClipDataToFlash = function(clipData) {
1107
+ var newClipData = {}, formatMap = {};
1108
+ if (!(typeof clipData === "object" && clipData)) {
1109
+ return;
1110
+ }
1111
+ for (var dataFormat in clipData) {
1112
+ if (dataFormat && _hasOwn.call(clipData, dataFormat) && typeof clipData[dataFormat] === "string" && clipData[dataFormat]) {
1113
+ switch (dataFormat.toLowerCase()) {
1114
+ case "text/plain":
1115
+ case "text":
1116
+ case "air:text":
1117
+ case "flash:text":
1118
+ newClipData.text = clipData[dataFormat];
1119
+ formatMap.text = dataFormat;
1120
+ break;
1121
+
1122
+ case "text/html":
1123
+ case "html":
1124
+ case "air:html":
1125
+ case "flash:html":
1126
+ newClipData.html = clipData[dataFormat];
1127
+ formatMap.html = dataFormat;
1128
+ break;
1129
+
1130
+ case "application/rtf":
1131
+ case "text/rtf":
1132
+ case "rtf":
1133
+ case "richtext":
1134
+ case "air:rtf":
1135
+ case "flash:rtf":
1136
+ newClipData.rtf = clipData[dataFormat];
1137
+ formatMap.rtf = dataFormat;
1138
+ break;
1139
+
1140
+ default:
1141
+ break;
1142
+ }
1143
+ }
1144
+ }
1145
+ return {
1146
+ data: newClipData,
1147
+ formatMap: formatMap
1148
+ };
1149
+ };
1150
+ /**
1151
+ * Map the data format names from Flash-friendly names back to their original "clipData" names (via a format mapping).
1152
+ *
1153
+ * @returns A new transformed object.
1154
+ * @private
1155
+ */
1156
+ var _mapClipResultsFromFlash = function(clipResults, formatMap) {
1157
+ if (!(typeof clipResults === "object" && clipResults && typeof formatMap === "object" && formatMap)) {
1158
+ return clipResults;
1159
+ }
1160
+ var newResults = {};
1161
+ for (var prop in clipResults) {
1162
+ if (_hasOwn.call(clipResults, prop)) {
1163
+ if (prop !== "success" && prop !== "data") {
1164
+ newResults[prop] = clipResults[prop];
1165
+ continue;
1166
+ }
1167
+ newResults[prop] = {};
1168
+ var tmpHash = clipResults[prop];
1169
+ for (var dataFormat in tmpHash) {
1170
+ if (dataFormat && _hasOwn.call(tmpHash, dataFormat) && _hasOwn.call(formatMap, dataFormat)) {
1171
+ newResults[prop][formatMap[dataFormat]] = tmpHash[dataFormat];
1172
+ }
1173
+ }
1174
+ }
1175
+ }
1176
+ return newResults;
1177
+ };
1178
+ /**
1179
+ * Will look at a path, and will create a "?noCache={time}" or "&noCache={time}"
1180
+ * query param string to return. Does NOT append that string to the original path.
1181
+ * This is useful because ExternalInterface often breaks when a Flash SWF is cached.
1182
+ *
1183
+ * @returns The `noCache` query param with necessary "?"/"&" prefix.
1184
+ * @private
1185
+ */
1186
+ var _cacheBust = function(path, options) {
1187
+ var cacheBust = options == null || options && options.cacheBust === true;
1188
+ if (cacheBust) {
1189
+ return (path.indexOf("?") === -1 ? "?" : "&") + "noCache=" + _now();
1190
+ } else {
1191
+ return "";
1192
+ }
1193
+ };
1194
+ /**
1195
+ * Creates a query string for the FlashVars param.
1196
+ * Does NOT include the cache-busting query param.
1197
+ *
1198
+ * @returns FlashVars query string
1199
+ * @private
1200
+ */
1201
+ var _vars = function(options) {
1202
+ var i, len, domain, domains, str = "", trustedOriginsExpanded = [];
1203
+ if (options.trustedDomains) {
1204
+ if (typeof options.trustedDomains === "string") {
1205
+ domains = [ options.trustedDomains ];
1206
+ } else if (typeof options.trustedDomains === "object" && "length" in options.trustedDomains) {
1207
+ domains = options.trustedDomains;
1208
+ }
1209
+ }
1210
+ if (domains && domains.length) {
1211
+ for (i = 0, len = domains.length; i < len; i++) {
1212
+ if (_hasOwn.call(domains, i) && domains[i] && typeof domains[i] === "string") {
1213
+ domain = _extractDomain(domains[i]);
1214
+ if (!domain) {
1215
+ continue;
1216
+ }
1217
+ if (domain === "*") {
1218
+ trustedOriginsExpanded = [ domain ];
1219
+ break;
1220
+ }
1221
+ trustedOriginsExpanded.push.apply(trustedOriginsExpanded, [ domain, "//" + domain, _window.location.protocol + "//" + domain ]);
1222
+ }
1223
+ }
1224
+ }
1225
+ if (trustedOriginsExpanded.length) {
1226
+ str += "trustedOrigins=" + _encodeURIComponent(trustedOriginsExpanded.join(","));
1227
+ }
1228
+ if (options.forceEnhancedClipboard === true) {
1229
+ str += (str ? "&" : "") + "forceEnhancedClipboard=true";
1230
+ }
1231
+ if (typeof options.swfObjectId === "string" && options.swfObjectId) {
1232
+ str += (str ? "&" : "") + "swfObjectId=" + _encodeURIComponent(options.swfObjectId);
1233
+ }
1234
+ return str;
1235
+ };
1236
+ /**
1237
+ * Extract the domain (e.g. "github.com") from an origin (e.g. "https://github.com") or
1238
+ * URL (e.g. "https://github.com/zeroclipboard/zeroclipboard/").
1239
+ *
1240
+ * @returns the domain
1241
+ * @private
1242
+ */
1243
+ var _extractDomain = function(originOrUrl) {
1244
+ if (originOrUrl == null || originOrUrl === "") {
1245
+ return null;
1246
+ }
1247
+ originOrUrl = originOrUrl.replace(/^\s+|\s+$/g, "");
1248
+ if (originOrUrl === "") {
1249
+ return null;
1250
+ }
1251
+ var protocolIndex = originOrUrl.indexOf("//");
1252
+ originOrUrl = protocolIndex === -1 ? originOrUrl : originOrUrl.slice(protocolIndex + 2);
1253
+ var pathIndex = originOrUrl.indexOf("/");
1254
+ originOrUrl = pathIndex === -1 ? originOrUrl : protocolIndex === -1 || pathIndex === 0 ? null : originOrUrl.slice(0, pathIndex);
1255
+ if (originOrUrl && originOrUrl.slice(-4).toLowerCase() === ".swf") {
1256
+ return null;
1257
+ }
1258
+ return originOrUrl || null;
1259
+ };
1260
+ /**
1261
+ * Set `allowScriptAccess` based on `trustedDomains` and `window.location.host` vs. `swfPath`.
1262
+ *
1263
+ * @returns The appropriate script access level.
1264
+ * @private
1265
+ */
1266
+ var _determineScriptAccess = function() {
1267
+ var _extractAllDomains = function(origins, resultsArray) {
1268
+ var i, len, tmp;
1269
+ if (origins == null || resultsArray[0] === "*") {
1270
+ return;
1271
+ }
1272
+ if (typeof origins === "string") {
1273
+ origins = [ origins ];
1274
+ }
1275
+ if (!(typeof origins === "object" && typeof origins.length === "number")) {
1276
+ return;
1277
+ }
1278
+ for (i = 0, len = origins.length; i < len; i++) {
1279
+ if (_hasOwn.call(origins, i) && (tmp = _extractDomain(origins[i]))) {
1280
+ if (tmp === "*") {
1281
+ resultsArray.length = 0;
1282
+ resultsArray.push("*");
1283
+ break;
1284
+ }
1285
+ if (_inArray(tmp, resultsArray) === -1) {
1286
+ resultsArray.push(tmp);
1287
+ }
1288
+ }
1289
+ }
1290
+ };
1291
+ return function(currentDomain, configOptions) {
1292
+ var swfDomain = _extractDomain(configOptions.swfPath);
1293
+ if (swfDomain === null) {
1294
+ swfDomain = currentDomain;
1295
+ }
1296
+ var trustedDomains = [];
1297
+ _extractAllDomains(configOptions.trustedOrigins, trustedDomains);
1298
+ _extractAllDomains(configOptions.trustedDomains, trustedDomains);
1299
+ var len = trustedDomains.length;
1300
+ if (len > 0) {
1301
+ if (len === 1 && trustedDomains[0] === "*") {
1302
+ return "always";
1303
+ }
1304
+ if (_inArray(currentDomain, trustedDomains) !== -1) {
1305
+ if (len === 1 && currentDomain === swfDomain) {
1306
+ return "sameDomain";
1307
+ }
1308
+ return "always";
1309
+ }
1310
+ }
1311
+ return "never";
1312
+ };
1313
+ }();
1314
+ /**
1315
+ * Get the currently active/focused DOM element.
1316
+ *
1317
+ * @returns the currently active/focused element, or `null`
1318
+ * @private
1319
+ */
1320
+ var _safeActiveElement = function() {
1321
+ try {
1322
+ return _document.activeElement;
1323
+ } catch (err) {
1324
+ return null;
1325
+ }
1326
+ };
1327
+ /**
1328
+ * Add a class to an element, if it doesn't already have it.
1329
+ *
1330
+ * @returns The element, with its new class added.
1331
+ * @private
1332
+ */
1333
+ var _addClass = function(element, value) {
1334
+ if (!element || element.nodeType !== 1) {
1335
+ return element;
1336
+ }
1337
+ if (element.classList) {
1338
+ if (!element.classList.contains(value)) {
1339
+ element.classList.add(value);
1340
+ }
1341
+ return element;
1342
+ }
1343
+ if (value && typeof value === "string") {
1344
+ var classNames = (value || "").split(/\s+/);
1345
+ if (element.nodeType === 1) {
1346
+ if (!element.className) {
1347
+ element.className = value;
1348
+ } else {
1349
+ var className = " " + element.className + " ", setClass = element.className;
1350
+ for (var c = 0, cl = classNames.length; c < cl; c++) {
1351
+ if (className.indexOf(" " + classNames[c] + " ") < 0) {
1352
+ setClass += " " + classNames[c];
1353
+ }
1354
+ }
1355
+ element.className = setClass.replace(/^\s+|\s+$/g, "");
1356
+ }
1357
+ }
1358
+ }
1359
+ return element;
1360
+ };
1361
+ /**
1362
+ * Remove a class from an element, if it has it.
1363
+ *
1364
+ * @returns The element, with its class removed.
1365
+ * @private
1366
+ */
1367
+ var _removeClass = function(element, value) {
1368
+ if (!element || element.nodeType !== 1) {
1369
+ return element;
1370
+ }
1371
+ if (element.classList) {
1372
+ if (element.classList.contains(value)) {
1373
+ element.classList.remove(value);
1374
+ }
1375
+ return element;
1376
+ }
1377
+ if (typeof value === "string" && value) {
1378
+ var classNames = value.split(/\s+/);
1379
+ if (element.nodeType === 1 && element.className) {
1380
+ var className = (" " + element.className + " ").replace(/[\n\t]/g, " ");
1381
+ for (var c = 0, cl = classNames.length; c < cl; c++) {
1382
+ className = className.replace(" " + classNames[c] + " ", " ");
1383
+ }
1384
+ element.className = className.replace(/^\s+|\s+$/g, "");
1385
+ }
1386
+ }
1387
+ return element;
1388
+ };
1389
+ /**
1390
+ * Attempt to interpret the element's CSS styling. If `prop` is `"cursor"`,
1391
+ * then we assume that it should be a hand ("pointer") cursor if the element
1392
+ * is an anchor element ("a" tag).
1393
+ *
1394
+ * @returns The computed style property.
1395
+ * @private
1396
+ */
1397
+ var _getStyle = function(el, prop) {
1398
+ var value = _window.getComputedStyle(el, null).getPropertyValue(prop);
1399
+ if (prop === "cursor") {
1400
+ if (!value || value === "auto") {
1401
+ if (el.nodeName === "A") {
1402
+ return "pointer";
1403
+ }
1404
+ }
1405
+ }
1406
+ return value;
1407
+ };
1408
+ /**
1409
+ * Get the zoom factor of the browser. Always returns `1.0`, except at
1410
+ * non-default zoom levels in IE<8 and some older versions of WebKit.
1411
+ *
1412
+ * @returns Floating unit percentage of the zoom factor (e.g. 150% = `1.5`).
1413
+ * @private
1414
+ */
1415
+ var _getZoomFactor = function() {
1416
+ var rect, physicalWidth, logicalWidth, zoomFactor = 1;
1417
+ if (typeof _document.body.getBoundingClientRect === "function") {
1418
+ rect = _document.body.getBoundingClientRect();
1419
+ physicalWidth = rect.right - rect.left;
1420
+ logicalWidth = _document.body.offsetWidth;
1421
+ zoomFactor = _Math.round(physicalWidth / logicalWidth * 100) / 100;
1422
+ }
1423
+ return zoomFactor;
1424
+ };
1425
+ /**
1426
+ * Get the DOM positioning info of an element.
1427
+ *
1428
+ * @returns Object containing the element's position, width, and height.
1429
+ * @private
1430
+ */
1431
+ var _getDOMObjectPosition = function(obj) {
1432
+ var info = {
1433
+ left: 0,
1434
+ top: 0,
1435
+ width: 0,
1436
+ height: 0
1437
+ };
1438
+ if (obj.getBoundingClientRect) {
1439
+ var rect = obj.getBoundingClientRect();
1440
+ var pageXOffset, pageYOffset, zoomFactor;
1441
+ if ("pageXOffset" in _window && "pageYOffset" in _window) {
1442
+ pageXOffset = _window.pageXOffset;
1443
+ pageYOffset = _window.pageYOffset;
1444
+ } else {
1445
+ zoomFactor = _getZoomFactor();
1446
+ pageXOffset = _Math.round(_document.documentElement.scrollLeft / zoomFactor);
1447
+ pageYOffset = _Math.round(_document.documentElement.scrollTop / zoomFactor);
1448
+ }
1449
+ var leftBorderWidth = _document.documentElement.clientLeft || 0;
1450
+ var topBorderWidth = _document.documentElement.clientTop || 0;
1451
+ info.left = rect.left + pageXOffset - leftBorderWidth;
1452
+ info.top = rect.top + pageYOffset - topBorderWidth;
1453
+ info.width = "width" in rect ? rect.width : rect.right - rect.left;
1454
+ info.height = "height" in rect ? rect.height : rect.bottom - rect.top;
1455
+ }
1456
+ return info;
1457
+ };
1458
+ /**
1459
+ * Reposition the Flash object to cover the currently activated element.
1460
+ *
1461
+ * @returns `undefined`
1462
+ * @private
1463
+ */
1464
+ var _reposition = function() {
1465
+ var htmlBridge;
1466
+ if (_currentElement && (htmlBridge = _getHtmlBridge(_flashState.bridge))) {
1467
+ var pos = _getDOMObjectPosition(_currentElement);
1468
+ _extend(htmlBridge.style, {
1469
+ width: pos.width + "px",
1470
+ height: pos.height + "px",
1471
+ top: pos.top + "px",
1472
+ left: pos.left + "px",
1473
+ zIndex: "" + _getSafeZIndex(_globalConfig.zIndex)
1474
+ });
1475
+ }
1476
+ };
1477
+ /**
1478
+ * Sends a signal to the Flash object to display the hand cursor if `true`.
1479
+ *
1480
+ * @returns `undefined`
1481
+ * @private
1482
+ */
1483
+ var _setHandCursor = function(enabled) {
1484
+ if (_flashState.ready === true) {
1485
+ if (_flashState.bridge && typeof _flashState.bridge.setHandCursor === "function") {
1486
+ _flashState.bridge.setHandCursor(enabled);
1487
+ } else {
1488
+ _flashState.ready = false;
1489
+ }
1490
+ }
1491
+ };
1492
+ /**
1493
+ * Get a safe value for `zIndex`
1494
+ *
1495
+ * @returns an integer, or "auto"
1496
+ * @private
1497
+ */
1498
+ var _getSafeZIndex = function(val) {
1499
+ if (/^(?:auto|inherit)$/.test(val)) {
1500
+ return val;
1501
+ }
1502
+ var zIndex;
1503
+ if (typeof val === "number" && !_isNaN(val)) {
1504
+ zIndex = val;
1505
+ } else if (typeof val === "string") {
1506
+ zIndex = _getSafeZIndex(_parseInt(val, 10));
1507
+ }
1508
+ return typeof zIndex === "number" ? zIndex : "auto";
1509
+ };
1510
+ /**
1511
+ * Detect the Flash Player status, version, and plugin type.
1512
+ *
1513
+ * @see {@link https://code.google.com/p/doctype-mirror/wiki/ArticleDetectFlash#The_code}
1514
+ * @see {@link http://stackoverflow.com/questions/12866060/detecting-pepper-ppapi-flash-with-javascript}
1515
+ *
1516
+ * @returns `undefined`
1517
+ * @private
1518
+ */
1519
+ var _detectFlashSupport = function(ActiveXObject) {
1520
+ var plugin, ax, mimeType, hasFlash = false, isActiveX = false, isPPAPI = false, flashVersion = "";
1521
+ /**
1522
+ * Derived from Apple's suggested sniffer.
1523
+ * @param {String} desc e.g. "Shockwave Flash 7.0 r61"
1524
+ * @returns {String} "7.0.61"
1525
+ * @private
1526
+ */
1527
+ function parseFlashVersion(desc) {
1528
+ var matches = desc.match(/[\d]+/g);
1529
+ matches.length = 3;
1530
+ return matches.join(".");
1531
+ }
1532
+ function isPepperFlash(flashPlayerFileName) {
1533
+ return !!flashPlayerFileName && (flashPlayerFileName = flashPlayerFileName.toLowerCase()) && (/^(pepflashplayer\.dll|libpepflashplayer\.so|pepperflashplayer\.plugin)$/.test(flashPlayerFileName) || flashPlayerFileName.slice(-13) === "chrome.plugin");
1534
+ }
1535
+ function inspectPlugin(plugin) {
1536
+ if (plugin) {
1537
+ hasFlash = true;
1538
+ if (plugin.version) {
1539
+ flashVersion = parseFlashVersion(plugin.version);
1540
+ }
1541
+ if (!flashVersion && plugin.description) {
1542
+ flashVersion = parseFlashVersion(plugin.description);
1543
+ }
1544
+ if (plugin.filename) {
1545
+ isPPAPI = isPepperFlash(plugin.filename);
1546
+ }
1547
+ }
1548
+ }
1549
+ if (_navigator.plugins && _navigator.plugins.length) {
1550
+ plugin = _navigator.plugins["Shockwave Flash"];
1551
+ inspectPlugin(plugin);
1552
+ if (_navigator.plugins["Shockwave Flash 2.0"]) {
1553
+ hasFlash = true;
1554
+ flashVersion = "2.0.0.11";
1555
+ }
1556
+ } else if (_navigator.mimeTypes && _navigator.mimeTypes.length) {
1557
+ mimeType = _navigator.mimeTypes["application/x-shockwave-flash"];
1558
+ plugin = mimeType && mimeType.enabledPlugin;
1559
+ inspectPlugin(plugin);
1560
+ } else if (typeof ActiveXObject !== "undefined") {
1561
+ isActiveX = true;
1562
+ try {
1563
+ ax = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
1564
+ hasFlash = true;
1565
+ flashVersion = parseFlashVersion(ax.GetVariable("$version"));
1566
+ } catch (e1) {
1567
+ try {
1568
+ ax = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
1569
+ hasFlash = true;
1570
+ flashVersion = "6.0.21";
1571
+ } catch (e2) {
1572
+ try {
1573
+ ax = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
1574
+ hasFlash = true;
1575
+ flashVersion = parseFlashVersion(ax.GetVariable("$version"));
1576
+ } catch (e3) {
1577
+ isActiveX = false;
1578
+ }
1579
+ }
1580
+ }
1581
+ }
1582
+ _flashState.disabled = hasFlash !== true;
1583
+ _flashState.outdated = flashVersion && _parseFloat(flashVersion) < _parseFloat(_minimumFlashVersion);
1584
+ _flashState.version = flashVersion || "0.0.0";
1585
+ _flashState.pluginType = isPPAPI ? "pepper" : isActiveX ? "activex" : hasFlash ? "netscape" : "unknown";
1586
+ };
1587
+ /**
1588
+ * Invoke the Flash detection algorithms immediately upon inclusion so we're not waiting later.
1589
+ */
1590
+ _detectFlashSupport(_ActiveXObject);
1591
+ /**
1592
+ * A shell constructor for `ZeroClipboard` client instances.
1593
+ *
1594
+ * @constructor
1595
+ */
1596
+ var ZeroClipboard = function() {
1597
+ if (!(this instanceof ZeroClipboard)) {
1598
+ return new ZeroClipboard();
1599
+ }
1600
+ if (typeof ZeroClipboard._createClient === "function") {
1601
+ ZeroClipboard._createClient.apply(this, _args(arguments));
1602
+ }
1603
+ };
1604
+ /**
1605
+ * The ZeroClipboard library's version number.
1606
+ *
1607
+ * @static
1608
+ * @readonly
1609
+ * @property {string}
1610
+ */
1611
+ ZeroClipboard.version = "2.1.1";
1612
+ _makeReadOnly(ZeroClipboard, "version");
1613
+ /**
1614
+ * Update or get a copy of the ZeroClipboard global configuration.
1615
+ * Returns a copy of the current/updated configuration.
1616
+ *
1617
+ * @returns Object
1618
+ * @static
1619
+ */
1620
+ ZeroClipboard.config = function() {
1621
+ return _config.apply(this, _args(arguments));
1622
+ };
1623
+ /**
1624
+ * Diagnostic method that describes the state of the browser, Flash Player, and ZeroClipboard.
1625
+ *
1626
+ * @returns Object
1627
+ * @static
1628
+ */
1629
+ ZeroClipboard.state = function() {
1630
+ return _state.apply(this, _args(arguments));
1631
+ };
1632
+ /**
1633
+ * Check if Flash is unusable for any reason: disabled, outdated, deactivated, etc.
1634
+ *
1635
+ * @returns Boolean
1636
+ * @static
1637
+ */
1638
+ ZeroClipboard.isFlashUnusable = function() {
1639
+ return _isFlashUnusable.apply(this, _args(arguments));
1640
+ };
1641
+ /**
1642
+ * Register an event listener.
1643
+ *
1644
+ * @returns `ZeroClipboard`
1645
+ * @static
1646
+ */
1647
+ ZeroClipboard.on = function() {
1648
+ return _on.apply(this, _args(arguments));
1649
+ };
1650
+ /**
1651
+ * Unregister an event listener.
1652
+ * If no `listener` function/object is provided, it will unregister all listeners for the provided `eventType`.
1653
+ * If no `eventType` is provided, it will unregister all listeners for every event type.
1654
+ *
1655
+ * @returns `ZeroClipboard`
1656
+ * @static
1657
+ */
1658
+ ZeroClipboard.off = function() {
1659
+ return _off.apply(this, _args(arguments));
1660
+ };
1661
+ /**
1662
+ * Retrieve event listeners for an `eventType`.
1663
+ * If no `eventType` is provided, it will retrieve all listeners for every event type.
1664
+ *
1665
+ * @returns array of listeners for the `eventType`; if no `eventType`, then a map/hash object of listeners for all event types; or `null`
1666
+ */
1667
+ ZeroClipboard.handlers = function() {
1668
+ return _listeners.apply(this, _args(arguments));
1669
+ };
1670
+ /**
1671
+ * Event emission receiver from the Flash object, forwarding to any registered JavaScript event listeners.
1672
+ *
1673
+ * @returns For the "copy" event, returns the Flash-friendly "clipData" object; otherwise `undefined`.
1674
+ * @static
1675
+ */
1676
+ ZeroClipboard.emit = function() {
1677
+ return _emit.apply(this, _args(arguments));
1678
+ };
1679
+ /**
1680
+ * Create and embed the Flash object.
1681
+ *
1682
+ * @returns The Flash object
1683
+ * @static
1684
+ */
1685
+ ZeroClipboard.create = function() {
1686
+ return _create.apply(this, _args(arguments));
1687
+ };
1688
+ /**
1689
+ * Self-destruct and clean up everything, including the embedded Flash object.
1690
+ *
1691
+ * @returns `undefined`
1692
+ * @static
1693
+ */
1694
+ ZeroClipboard.destroy = function() {
1695
+ return _destroy.apply(this, _args(arguments));
1696
+ };
1697
+ /**
1698
+ * Set the pending data for clipboard injection.
1699
+ *
1700
+ * @returns `undefined`
1701
+ * @static
1702
+ */
1703
+ ZeroClipboard.setData = function() {
1704
+ return _setData.apply(this, _args(arguments));
1705
+ };
1706
+ /**
1707
+ * Clear the pending data for clipboard injection.
1708
+ * If no `format` is provided, all pending data formats will be cleared.
1709
+ *
1710
+ * @returns `undefined`
1711
+ * @static
1712
+ */
1713
+ ZeroClipboard.clearData = function() {
1714
+ return _clearData.apply(this, _args(arguments));
1715
+ };
1716
+ /**
1717
+ * Get a copy of the pending data for clipboard injection.
1718
+ * If no `format` is provided, a copy of ALL pending data formats will be returned.
1719
+ *
1720
+ * @returns `String` or `Object`
1721
+ * @static
1722
+ */
1723
+ ZeroClipboard.getData = function() {
1724
+ return _getData.apply(this, _args(arguments));
1725
+ };
1726
+ /**
1727
+ * Sets the current HTML object that the Flash object should overlay. This will put the global
1728
+ * Flash object on top of the current element; depending on the setup, this may also set the
1729
+ * pending clipboard text data as well as the Flash object's wrapping element's title attribute
1730
+ * based on the underlying HTML element and ZeroClipboard configuration.
1731
+ *
1732
+ * @returns `undefined`
1733
+ * @static
1734
+ */
1735
+ ZeroClipboard.focus = ZeroClipboard.activate = function() {
1736
+ return _focus.apply(this, _args(arguments));
1737
+ };
1738
+ /**
1739
+ * Un-overlays the Flash object. This will put the global Flash object off-screen; depending on
1740
+ * the setup, this may also unset the Flash object's wrapping element's title attribute based on
1741
+ * the underlying HTML element and ZeroClipboard configuration.
1742
+ *
1743
+ * @returns `undefined`
1744
+ * @static
1745
+ */
1746
+ ZeroClipboard.blur = ZeroClipboard.deactivate = function() {
1747
+ return _blur.apply(this, _args(arguments));
1748
+ };
1749
+ /**
1750
+ * Returns the currently focused/"activated" HTML element that the Flash object is wrapping.
1751
+ *
1752
+ * @returns `HTMLElement` or `null`
1753
+ * @static
1754
+ */
1755
+ ZeroClipboard.activeElement = function() {
1756
+ return _activeElement.apply(this, _args(arguments));
1757
+ };
1758
+ /**
1759
+ * Keep track of the ZeroClipboard client instance counter.
1760
+ */
1761
+ var _clientIdCounter = 0;
1762
+ /**
1763
+ * Keep track of the state of the client instances.
1764
+ *
1765
+ * Entry structure:
1766
+ * _clientMeta[client.id] = {
1767
+ * instance: client,
1768
+ * elements: [],
1769
+ * handlers: {}
1770
+ * };
1771
+ */
1772
+ var _clientMeta = {};
1773
+ /**
1774
+ * Keep track of the ZeroClipboard clipped elements counter.
1775
+ */
1776
+ var _elementIdCounter = 0;
1777
+ /**
1778
+ * Keep track of the state of the clipped element relationships to clients.
1779
+ *
1780
+ * Entry structure:
1781
+ * _elementMeta[element.zcClippingId] = [client1.id, client2.id];
1782
+ */
1783
+ var _elementMeta = {};
1784
+ /**
1785
+ * Keep track of the state of the mouse event handlers for clipped elements.
1786
+ *
1787
+ * Entry structure:
1788
+ * _mouseHandlers[element.zcClippingId] = {
1789
+ * mouseover: function(event) {},
1790
+ * mouseout: function(event) {},
1791
+ * mouseenter: function(event) {},
1792
+ * mouseleave: function(event) {},
1793
+ * mousemove: function(event) {}
1794
+ * };
1795
+ */
1796
+ var _mouseHandlers = {};
1797
+ /**
1798
+ * Extending the ZeroClipboard configuration defaults for the Client module.
1799
+ */
1800
+ _extend(_globalConfig, {
1801
+ autoActivate: true
1802
+ });
1803
+ /**
1804
+ * The real constructor for `ZeroClipboard` client instances.
1805
+ * @private
1806
+ */
1807
+ var _clientConstructor = function(elements) {
1808
+ var client = this;
1809
+ client.id = "" + _clientIdCounter++;
1810
+ _clientMeta[client.id] = {
1811
+ instance: client,
1812
+ elements: [],
1813
+ handlers: {}
1814
+ };
1815
+ if (elements) {
1816
+ client.clip(elements);
1817
+ }
1818
+ ZeroClipboard.on("*", function(event) {
1819
+ return client.emit(event);
1820
+ });
1821
+ ZeroClipboard.on("destroy", function() {
1822
+ client.destroy();
1823
+ });
1824
+ ZeroClipboard.create();
1825
+ };
1826
+ /**
1827
+ * The underlying implementation of `ZeroClipboard.Client.prototype.on`.
1828
+ * @private
1829
+ */
1830
+ var _clientOn = function(eventType, listener) {
1831
+ var i, len, events, added = {}, handlers = _clientMeta[this.id] && _clientMeta[this.id].handlers;
1832
+ if (typeof eventType === "string" && eventType) {
1833
+ events = eventType.toLowerCase().split(/\s+/);
1834
+ } else if (typeof eventType === "object" && eventType && typeof listener === "undefined") {
1835
+ for (i in eventType) {
1836
+ if (_hasOwn.call(eventType, i) && typeof i === "string" && i && typeof eventType[i] === "function") {
1837
+ this.on(i, eventType[i]);
1838
+ }
1839
+ }
1840
+ }
1841
+ if (events && events.length) {
1842
+ for (i = 0, len = events.length; i < len; i++) {
1843
+ eventType = events[i].replace(/^on/, "");
1844
+ added[eventType] = true;
1845
+ if (!handlers[eventType]) {
1846
+ handlers[eventType] = [];
1847
+ }
1848
+ handlers[eventType].push(listener);
1849
+ }
1850
+ if (added.ready && _flashState.ready) {
1851
+ this.emit({
1852
+ type: "ready",
1853
+ client: this
1854
+ });
1855
+ }
1856
+ if (added.error) {
1857
+ var errorTypes = [ "disabled", "outdated", "unavailable", "deactivated", "overdue" ];
1858
+ for (i = 0, len = errorTypes.length; i < len; i++) {
1859
+ if (_flashState[errorTypes[i]]) {
1860
+ this.emit({
1861
+ type: "error",
1862
+ name: "flash-" + errorTypes[i],
1863
+ client: this
1864
+ });
1865
+ break;
1866
+ }
1867
+ }
1868
+ }
1869
+ }
1870
+ return this;
1871
+ };
1872
+ /**
1873
+ * The underlying implementation of `ZeroClipboard.Client.prototype.off`.
1874
+ * @private
1875
+ */
1876
+ var _clientOff = function(eventType, listener) {
1877
+ var i, len, foundIndex, events, perEventHandlers, handlers = _clientMeta[this.id] && _clientMeta[this.id].handlers;
1878
+ if (arguments.length === 0) {
1879
+ events = _objectKeys(handlers);
1880
+ } else if (typeof eventType === "string" && eventType) {
1881
+ events = eventType.split(/\s+/);
1882
+ } else if (typeof eventType === "object" && eventType && typeof listener === "undefined") {
1883
+ for (i in eventType) {
1884
+ if (_hasOwn.call(eventType, i) && typeof i === "string" && i && typeof eventType[i] === "function") {
1885
+ this.off(i, eventType[i]);
1886
+ }
1887
+ }
1888
+ }
1889
+ if (events && events.length) {
1890
+ for (i = 0, len = events.length; i < len; i++) {
1891
+ eventType = events[i].toLowerCase().replace(/^on/, "");
1892
+ perEventHandlers = handlers[eventType];
1893
+ if (perEventHandlers && perEventHandlers.length) {
1894
+ if (listener) {
1895
+ foundIndex = _inArray(listener, perEventHandlers);
1896
+ while (foundIndex !== -1) {
1897
+ perEventHandlers.splice(foundIndex, 1);
1898
+ foundIndex = _inArray(listener, perEventHandlers, foundIndex);
1899
+ }
1900
+ } else {
1901
+ perEventHandlers.length = 0;
1902
+ }
1903
+ }
1904
+ }
1905
+ }
1906
+ return this;
1907
+ };
1908
+ /**
1909
+ * The underlying implementation of `ZeroClipboard.Client.prototype.handlers`.
1910
+ * @private
1911
+ */
1912
+ var _clientListeners = function(eventType) {
1913
+ var copy = null, handlers = _clientMeta[this.id] && _clientMeta[this.id].handlers;
1914
+ if (handlers) {
1915
+ if (typeof eventType === "string" && eventType) {
1916
+ copy = handlers[eventType] ? handlers[eventType].slice(0) : [];
1917
+ } else {
1918
+ copy = _deepCopy(handlers);
1919
+ }
1920
+ }
1921
+ return copy;
1922
+ };
1923
+ /**
1924
+ * The underlying implementation of `ZeroClipboard.Client.prototype.emit`.
1925
+ * @private
1926
+ */
1927
+ var _clientEmit = function(event) {
1928
+ if (_clientShouldEmit.call(this, event)) {
1929
+ if (typeof event === "object" && event && typeof event.type === "string" && event.type) {
1930
+ event = _extend({}, event);
1931
+ }
1932
+ var eventCopy = _extend({}, _createEvent(event), {
1933
+ client: this
1934
+ });
1935
+ _clientDispatchCallbacks.call(this, eventCopy);
1936
+ }
1937
+ return this;
1938
+ };
1939
+ /**
1940
+ * The underlying implementation of `ZeroClipboard.Client.prototype.clip`.
1941
+ * @private
1942
+ */
1943
+ var _clientClip = function(elements) {
1944
+ elements = _prepClip(elements);
1945
+ for (var i = 0; i < elements.length; i++) {
1946
+ if (_hasOwn.call(elements, i) && elements[i] && elements[i].nodeType === 1) {
1947
+ if (!elements[i].zcClippingId) {
1948
+ elements[i].zcClippingId = "zcClippingId_" + _elementIdCounter++;
1949
+ _elementMeta[elements[i].zcClippingId] = [ this.id ];
1950
+ if (_globalConfig.autoActivate === true) {
1951
+ _addMouseHandlers(elements[i]);
1952
+ }
1953
+ } else if (_inArray(this.id, _elementMeta[elements[i].zcClippingId]) === -1) {
1954
+ _elementMeta[elements[i].zcClippingId].push(this.id);
1955
+ }
1956
+ var clippedElements = _clientMeta[this.id] && _clientMeta[this.id].elements;
1957
+ if (_inArray(elements[i], clippedElements) === -1) {
1958
+ clippedElements.push(elements[i]);
1959
+ }
1960
+ }
1961
+ }
1962
+ return this;
1963
+ };
1964
+ /**
1965
+ * The underlying implementation of `ZeroClipboard.Client.prototype.unclip`.
1966
+ * @private
1967
+ */
1968
+ var _clientUnclip = function(elements) {
1969
+ var meta = _clientMeta[this.id];
1970
+ if (!meta) {
1971
+ return this;
1972
+ }
1973
+ var clippedElements = meta.elements;
1974
+ var arrayIndex;
1975
+ if (typeof elements === "undefined") {
1976
+ elements = clippedElements.slice(0);
1977
+ } else {
1978
+ elements = _prepClip(elements);
1979
+ }
1980
+ for (var i = elements.length; i--; ) {
1981
+ if (_hasOwn.call(elements, i) && elements[i] && elements[i].nodeType === 1) {
1982
+ arrayIndex = 0;
1983
+ while ((arrayIndex = _inArray(elements[i], clippedElements, arrayIndex)) !== -1) {
1984
+ clippedElements.splice(arrayIndex, 1);
1985
+ }
1986
+ var clientIds = _elementMeta[elements[i].zcClippingId];
1987
+ if (clientIds) {
1988
+ arrayIndex = 0;
1989
+ while ((arrayIndex = _inArray(this.id, clientIds, arrayIndex)) !== -1) {
1990
+ clientIds.splice(arrayIndex, 1);
1991
+ }
1992
+ if (clientIds.length === 0) {
1993
+ if (_globalConfig.autoActivate === true) {
1994
+ _removeMouseHandlers(elements[i]);
1995
+ }
1996
+ delete elements[i].zcClippingId;
1997
+ }
1998
+ }
1999
+ }
2000
+ }
2001
+ return this;
2002
+ };
2003
+ /**
2004
+ * The underlying implementation of `ZeroClipboard.Client.prototype.elements`.
2005
+ * @private
2006
+ */
2007
+ var _clientElements = function() {
2008
+ var meta = _clientMeta[this.id];
2009
+ return meta && meta.elements ? meta.elements.slice(0) : [];
2010
+ };
2011
+ /**
2012
+ * The underlying implementation of `ZeroClipboard.Client.prototype.destroy`.
2013
+ * @private
2014
+ */
2015
+ var _clientDestroy = function() {
2016
+ this.unclip();
2017
+ this.off();
2018
+ delete _clientMeta[this.id];
2019
+ };
2020
+ /**
2021
+ * Inspect an Event to see if the Client (`this`) should honor it for emission.
2022
+ * @private
2023
+ */
2024
+ var _clientShouldEmit = function(event) {
2025
+ if (!(event && event.type)) {
2026
+ return false;
2027
+ }
2028
+ if (event.client && event.client !== this) {
2029
+ return false;
2030
+ }
2031
+ var clippedEls = _clientMeta[this.id] && _clientMeta[this.id].elements;
2032
+ var hasClippedEls = !!clippedEls && clippedEls.length > 0;
2033
+ var goodTarget = !event.target || hasClippedEls && _inArray(event.target, clippedEls) !== -1;
2034
+ var goodRelTarget = event.relatedTarget && hasClippedEls && _inArray(event.relatedTarget, clippedEls) !== -1;
2035
+ var goodClient = event.client && event.client === this;
2036
+ if (!(goodTarget || goodRelTarget || goodClient)) {
2037
+ return false;
2038
+ }
2039
+ return true;
2040
+ };
2041
+ /**
2042
+ * Handle the actual dispatching of events to a client instance.
2043
+ *
2044
+ * @returns `this`
2045
+ * @private
2046
+ */
2047
+ var _clientDispatchCallbacks = function(event) {
2048
+ if (!(typeof event === "object" && event && event.type)) {
2049
+ return;
2050
+ }
2051
+ var async = _shouldPerformAsync(event);
2052
+ var wildcardTypeHandlers = _clientMeta[this.id] && _clientMeta[this.id].handlers["*"] || [];
2053
+ var specificTypeHandlers = _clientMeta[this.id] && _clientMeta[this.id].handlers[event.type] || [];
2054
+ var handlers = wildcardTypeHandlers.concat(specificTypeHandlers);
2055
+ if (handlers && handlers.length) {
2056
+ var i, len, func, context, eventCopy, originalContext = this;
2057
+ for (i = 0, len = handlers.length; i < len; i++) {
2058
+ func = handlers[i];
2059
+ context = originalContext;
2060
+ if (typeof func === "string" && typeof _window[func] === "function") {
2061
+ func = _window[func];
2062
+ }
2063
+ if (typeof func === "object" && func && typeof func.handleEvent === "function") {
2064
+ context = func;
2065
+ func = func.handleEvent;
2066
+ }
2067
+ if (typeof func === "function") {
2068
+ eventCopy = _extend({}, event);
2069
+ _dispatchCallback(func, context, [ eventCopy ], async);
2070
+ }
2071
+ }
2072
+ }
2073
+ return this;
2074
+ };
2075
+ /**
2076
+ * Prepares the elements for clipping/unclipping.
2077
+ *
2078
+ * @returns An Array of elements.
2079
+ * @private
2080
+ */
2081
+ var _prepClip = function(elements) {
2082
+ if (typeof elements === "string") {
2083
+ elements = [];
2084
+ }
2085
+ return typeof elements.length !== "number" ? [ elements ] : elements;
2086
+ };
2087
+ /**
2088
+ * Add a `mouseover` handler function for a clipped element.
2089
+ *
2090
+ * @returns `undefined`
2091
+ * @private
2092
+ */
2093
+ var _addMouseHandlers = function(element) {
2094
+ if (!(element && element.nodeType === 1)) {
2095
+ return;
2096
+ }
2097
+ var _suppressMouseEvents = function(event) {
2098
+ if (!(event || (event = _window.event))) {
2099
+ return;
2100
+ }
2101
+ if (event._source !== "js") {
2102
+ event.stopImmediatePropagation();
2103
+ event.preventDefault();
2104
+ }
2105
+ delete event._source;
2106
+ };
2107
+ var _elementMouseOver = function(event) {
2108
+ if (!(event || (event = _window.event))) {
2109
+ return;
2110
+ }
2111
+ _suppressMouseEvents(event);
2112
+ ZeroClipboard.focus(element);
2113
+ };
2114
+ element.addEventListener("mouseover", _elementMouseOver, false);
2115
+ element.addEventListener("mouseout", _suppressMouseEvents, false);
2116
+ element.addEventListener("mouseenter", _suppressMouseEvents, false);
2117
+ element.addEventListener("mouseleave", _suppressMouseEvents, false);
2118
+ element.addEventListener("mousemove", _suppressMouseEvents, false);
2119
+ _mouseHandlers[element.zcClippingId] = {
2120
+ mouseover: _elementMouseOver,
2121
+ mouseout: _suppressMouseEvents,
2122
+ mouseenter: _suppressMouseEvents,
2123
+ mouseleave: _suppressMouseEvents,
2124
+ mousemove: _suppressMouseEvents
2125
+ };
2126
+ };
2127
+ /**
2128
+ * Remove a `mouseover` handler function for a clipped element.
2129
+ *
2130
+ * @returns `undefined`
2131
+ * @private
2132
+ */
2133
+ var _removeMouseHandlers = function(element) {
2134
+ if (!(element && element.nodeType === 1)) {
2135
+ return;
2136
+ }
2137
+ var mouseHandlers = _mouseHandlers[element.zcClippingId];
2138
+ if (!(typeof mouseHandlers === "object" && mouseHandlers)) {
2139
+ return;
2140
+ }
2141
+ var key, val, mouseEvents = [ "move", "leave", "enter", "out", "over" ];
2142
+ for (var i = 0, len = mouseEvents.length; i < len; i++) {
2143
+ key = "mouse" + mouseEvents[i];
2144
+ val = mouseHandlers[key];
2145
+ if (typeof val === "function") {
2146
+ element.removeEventListener(key, val, false);
2147
+ }
2148
+ }
2149
+ delete _mouseHandlers[element.zcClippingId];
2150
+ };
2151
+ /**
2152
+ * Creates a new ZeroClipboard client instance.
2153
+ * Optionally, auto-`clip` an element or collection of elements.
2154
+ *
2155
+ * @constructor
2156
+ */
2157
+ ZeroClipboard._createClient = function() {
2158
+ _clientConstructor.apply(this, _args(arguments));
2159
+ };
2160
+ /**
2161
+ * Register an event listener to the client.
2162
+ *
2163
+ * @returns `this`
2164
+ */
2165
+ ZeroClipboard.prototype.on = function() {
2166
+ return _clientOn.apply(this, _args(arguments));
2167
+ };
2168
+ /**
2169
+ * Unregister an event handler from the client.
2170
+ * If no `listener` function/object is provided, it will unregister all handlers for the provided `eventType`.
2171
+ * If no `eventType` is provided, it will unregister all handlers for every event type.
2172
+ *
2173
+ * @returns `this`
2174
+ */
2175
+ ZeroClipboard.prototype.off = function() {
2176
+ return _clientOff.apply(this, _args(arguments));
2177
+ };
2178
+ /**
2179
+ * Retrieve event listeners for an `eventType` from the client.
2180
+ * If no `eventType` is provided, it will retrieve all listeners for every event type.
2181
+ *
2182
+ * @returns array of listeners for the `eventType`; if no `eventType`, then a map/hash object of listeners for all event types; or `null`
2183
+ */
2184
+ ZeroClipboard.prototype.handlers = function() {
2185
+ return _clientListeners.apply(this, _args(arguments));
2186
+ };
2187
+ /**
2188
+ * Event emission receiver from the Flash object for this client's registered JavaScript event listeners.
2189
+ *
2190
+ * @returns For the "copy" event, returns the Flash-friendly "clipData" object; otherwise `undefined`.
2191
+ */
2192
+ ZeroClipboard.prototype.emit = function() {
2193
+ return _clientEmit.apply(this, _args(arguments));
2194
+ };
2195
+ /**
2196
+ * Register clipboard actions for new element(s) to the client.
2197
+ *
2198
+ * @returns `this`
2199
+ */
2200
+ ZeroClipboard.prototype.clip = function() {
2201
+ return _clientClip.apply(this, _args(arguments));
2202
+ };
2203
+ /**
2204
+ * Unregister the clipboard actions of previously registered element(s) on the page.
2205
+ * If no elements are provided, ALL registered elements will be unregistered.
2206
+ *
2207
+ * @returns `this`
2208
+ */
2209
+ ZeroClipboard.prototype.unclip = function() {
2210
+ return _clientUnclip.apply(this, _args(arguments));
2211
+ };
2212
+ /**
2213
+ * Get all of the elements to which this client is clipped.
2214
+ *
2215
+ * @returns array of clipped elements
2216
+ */
2217
+ ZeroClipboard.prototype.elements = function() {
2218
+ return _clientElements.apply(this, _args(arguments));
2219
+ };
2220
+ /**
2221
+ * Self-destruct and clean up everything for a single client.
2222
+ * This will NOT destroy the embedded Flash object.
2223
+ *
2224
+ * @returns `undefined`
2225
+ */
2226
+ ZeroClipboard.prototype.destroy = function() {
2227
+ return _clientDestroy.apply(this, _args(arguments));
2228
+ };
2229
+ /**
2230
+ * Stores the pending plain text to inject into the clipboard.
2231
+ *
2232
+ * @returns `this`
2233
+ */
2234
+ ZeroClipboard.prototype.setText = function(text) {
2235
+ ZeroClipboard.setData("text/plain", text);
2236
+ return this;
2237
+ };
2238
+ /**
2239
+ * Stores the pending HTML text to inject into the clipboard.
2240
+ *
2241
+ * @returns `this`
2242
+ */
2243
+ ZeroClipboard.prototype.setHtml = function(html) {
2244
+ ZeroClipboard.setData("text/html", html);
2245
+ return this;
2246
+ };
2247
+ /**
2248
+ * Stores the pending rich text (RTF) to inject into the clipboard.
2249
+ *
2250
+ * @returns `this`
2251
+ */
2252
+ ZeroClipboard.prototype.setRichText = function(richText) {
2253
+ ZeroClipboard.setData("application/rtf", richText);
2254
+ return this;
2255
+ };
2256
+ /**
2257
+ * Stores the pending data to inject into the clipboard.
2258
+ *
2259
+ * @returns `this`
2260
+ */
2261
+ ZeroClipboard.prototype.setData = function() {
2262
+ ZeroClipboard.setData.apply(this, _args(arguments));
2263
+ return this;
2264
+ };
2265
+ /**
2266
+ * Clears the pending data to inject into the clipboard.
2267
+ * If no `format` is provided, all pending data formats will be cleared.
2268
+ *
2269
+ * @returns `this`
2270
+ */
2271
+ ZeroClipboard.prototype.clearData = function() {
2272
+ ZeroClipboard.clearData.apply(this, _args(arguments));
2273
+ return this;
2274
+ };
2275
+ /**
2276
+ * Gets a copy of the pending data to inject into the clipboard.
2277
+ * If no `format` is provided, a copy of ALL pending data formats will be returned.
2278
+ *
2279
+ * @returns `String` or `Object`
2280
+ */
2281
+ ZeroClipboard.prototype.getData = function() {
2282
+ return ZeroClipboard.getData.apply(this, _args(arguments));
2283
+ };
2284
+ if (typeof define === "function" && define.amd) {
2285
+ define(function() {
2286
+ return ZeroClipboard;
2287
+ });
2288
+ } else if (typeof module === "object" && module && typeof module.exports === "object" && module.exports) {
2289
+ module.exports = ZeroClipboard;
2290
+ } else {
2291
+ window.ZeroClipboard = ZeroClipboard;
2292
+ }
2293
+ })(function() {
2294
+ return this;
2295
+ }());
ZeroClipboard.swf ADDED
Binary file
addons/yoast_wp_seo/yoast_wp_seo.class.php ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if(basename($_SERVER['SCRIPT_FILENAME']) == "brokenlinks.class.php"):
3
+ exit;
4
+ endif;
5
+ class IWP_MMB_YWPSEO extends IWP_MMB_Core
6
+ {
7
+ function __construct()
8
+ {
9
+ parent::__construct( array(
10
+ 'singular' => 'interval', //singular name of the listed records
11
+ 'plural' => 'intervals', //plural name of the listed records
12
+ 'ajax' => false, //does this table support ajax?
13
+ 'screen' => 'interval-list' //hook suffix
14
+ ) );
15
+ }
16
+ /********
17
+ ** Private function - will return the status of the yoast premium
18
+ ********/
19
+ private function _checkYWPSEO() {
20
+ @include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
21
+ if ( is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) {
22
+ $ywpseo_main_file = WP_PLUGIN_DIR . '/wordpress-seo-premium/wp-seo-main.php';
23
+ $ywpseo_premium_file = WP_PLUGIN_DIR . '/wordpress-seo-premium/wp-seo-premium.php';
24
+ if(file_exists($ywpseo_main_file)){
25
+ @include_once($ywpseo_main_file);
26
+ }else{
27
+ return false;
28
+ }
29
+ if(file_exists($ywpseo_premium_file)){
30
+ @include_once($ywpseo_premium_file);
31
+ }else{
32
+ return false;
33
+ }
34
+ if (class_exists('WPSEO_Premium')) {
35
+ return true;
36
+ } else {
37
+ return false;
38
+ }
39
+ } else {
40
+ return false;
41
+ }
42
+ }
43
+
44
+ function get_seo_info($params){
45
+ if($this->_checkYWPSEO()){
46
+ @require_once(ABSPATH . 'wp-admin/includes/template.php' );
47
+ $ywpseo_title_editor_file = WP_PLUGIN_DIR . '/wordpress-seo-premium/admin/class-bulk-title-editor-list-table.php';
48
+ $ywpseo_desc_editor_file = WP_PLUGIN_DIR . '/wordpress-seo-premium/admin/class-bulk-description-editor-list-table.php';
49
+ if(file_exists($ywpseo_title_editor_file)){
50
+ @include_once($ywpseo_title_editor_file);
51
+ if(class_exists('WPSEO_Bulk_Title_Editor_List_Table')){
52
+ $wpseo_bulk_titles_table = new WPSEO_Bulk_Title_Editor_List_Table();
53
+ $wpseo_bulk_titles_table->prepare_items();
54
+ $titles = $wpseo_bulk_titles_table->items;
55
+ }else{return false;}
56
+ }else{return false;}
57
+ if(file_exists($ywpseo_desc_editor_file)){
58
+ @include_once($ywpseo_desc_editor_file);
59
+ if(class_exists('WPSEO_Bulk_Description_List_Table')){
60
+ $wpseo_bulk_desc_table = new WPSEO_Bulk_Description_List_Table();
61
+ $wpseo_bulk_desc_table->prepare_items();
62
+ $desc = $wpseo_bulk_desc_table->items;
63
+ }else{return false;}
64
+ }else{return false;}
65
+ $result = array();
66
+ foreach ($titles as $key => $value) {
67
+ $value = (array)$value;
68
+ $result[$value['ID']]['post_modified'] = $value['post_modified'];
69
+ $result[$value['ID']]['post_status'] = $value['post_status'];
70
+ $result[$value['ID']]['post_title'] = $value['post_title'];
71
+ $result[$value['ID']]['post_modified'] = @date('M d, Y @ h:ia', strtotime($value['post_modified']));
72
+ // $result[$value['ID']]['post_modified'] = $value['post_modified'];
73
+ $result[$value['ID']]['post_type'] = $value['post_type'];
74
+ $result[$value['ID']]['seo_title'] = $value['seo_title'];
75
+ $result[$value['ID']]['post_link'] = get_permalink($value['ID']);
76
+ }
77
+ foreach ($desc as $key => $value) {
78
+ $value = (array)$value;
79
+ $result[$value['ID']]['post_modified'] = $value['post_modified'];
80
+ $result[$value['ID']]['post_status'] = $value['post_status'];
81
+ $result[$value['ID']]['post_title'] = $value['post_title'];
82
+ $result[$value['ID']]['post_modified'] = @date('M d, Y @ h:ia', strtotime($value['post_modified']));
83
+ // $result[$value['ID']]['post_modified'] = $value['post_modified'];
84
+ $result[$value['ID']]['post_type'] = $value['post_type'];
85
+ $result[$value['ID']]['seo_meta_desc'] = $value['meta_desc'];
86
+ $result[$value['ID']]['post_link'] = get_permalink($value['ID']);
87
+ }
88
+ $refinedResult =array();
89
+ foreach ($result as $pid => $value) {
90
+ $check = 1;
91
+ if($params['type'] != 'all'){
92
+ if($params['type'] != $value['post_type']){
93
+ $check = 0;
94
+ }
95
+ }
96
+ if($params['status'] != 'all'){
97
+ if($params['status'] != $value['post_status']){
98
+ $check = 0;
99
+ }
100
+ }
101
+ if($check){
102
+ $refinedResult[$pid] = $value;
103
+ }
104
+ }
105
+ if(!empty($refinedResult)){
106
+ return $refinedResult;
107
+ }else{
108
+ return "No results available with the filters selected :(";
109
+ }
110
+ }
111
+ }
112
+
113
+
114
+
115
+
116
+
117
+
118
+ function save_seo_info($params){
119
+ if($this->_checkYWPSEO()){
120
+ $ywpseo_meta_file = WP_PLUGIN_DIR . '/wordpress-seo-premium/inc/class-wpseo-meta.php';
121
+ $ywpseo_ajax_file = WP_PLUGIN_DIR . '/wordpress-seo-premium/admin/ajax.php';
122
+ if(file_exists($ywpseo_meta_file)){
123
+ @include_once($ywpseo_meta_file);
124
+ if(class_exists('WPSEO_Meta')){
125
+ if(file_exists($ywpseo_ajax_file)){
126
+ @include_once($ywpseo_ajax_file);
127
+ for($i=0;$i<count($params['data']);$i++){
128
+ $post_id = $params['data'][$i]['post_id'];
129
+ $original_title = $params['data'][$i]['old_title'];
130
+ $new_title = $params['data'][$i]['new_title'];
131
+ $original_metadesc = $params['data'][$i]['old_metadesc'];
132
+ $new_metadesc = $params['data'][$i]['new_metadesc'];
133
+ $title_check = intval($params['data'][$i]['title_check']);
134
+ $metadesc_check = intval($params['data'][$i]['metadesc_check']);
135
+
136
+ if($original_title == 'null') $original_title == null;
137
+ if($new_title == 'null') $new_title == null;
138
+ if($original_metadesc == 'null') $original_metadesc == null;
139
+ if($new_metadesc == 'null') $new_metadesc == null;
140
+ $save_title = array();
141
+ $save_metadesc = array();
142
+ if($title_check){ $save_title = wpseo_upsert_new_title( $post_id, $new_title, $original_title );}else{$save_title = array('status'=>'neutral');}
143
+ if($metadesc_check){ $save_metadesc = wpseo_upsert_new_description( $post_id, $new_metadesc, $original_metadesc );}else{$save_metadesc = array('status'=>'neutral');}
144
+ if($save_title['status'] != 'failure' && $save_metadesc['status'] != 'failure'){
145
+ $result[$post_id] = array('original_title'=>$original_title,'original_metadesc'=>$original_metadesc,'new_title'=>$new_title,'new_metadesc'=>$new_metadesc);
146
+ }else{
147
+ if($save_title['status'] == 'failure'){$errorMsg = $save_title['results'];}
148
+ if($save_metadesc['status'] == 'failure'){$errorMsg = $save_metadesc['results'];}
149
+ $result[$post_id] = array('error'=>$errorMsg);
150
+ }
151
+ }
152
+ }else{return false;}
153
+ }else{return false;}
154
+ }else{return false;}
155
+ return $result;
156
+ }
157
+ }
158
+
159
+
160
+ function sample_func($params){
161
+ if($this->_checkYWPSEO()){
162
+ $a = array('aaaa' => 'vvvvv' );
163
+ return $a;
164
+ // return 'sample_res';
165
+ }
166
+ }
167
+
168
+
169
+ }
backup.class.singlecall.php CHANGED
@@ -1862,76 +1862,415 @@ function iwp_mmb_direct_to_any_copy($source, $destination, $overwrite = false, $
1862
  $unzip = "unzip";
1863
  return $unzip;
1864
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1865
 
1866
  function check_backup_compat()
1867
  {
 
1868
  $reqs = array();
 
1869
  if (strpos($_SERVER['DOCUMENT_ROOT'], '/') === 0) {
1870
- $reqs['Server OS']['status'] = 'Linux (or compatible)';
1871
- $reqs['Server OS']['pass'] = true;
1872
  } else {
1873
- $reqs['Server OS']['status'] = 'Windows';
1874
- $reqs['Server OS']['pass'] = true;
1875
- $pass = false;
1876
  }
1877
- $reqs['PHP Version']['status'] = phpversion();
 
 
 
 
1878
  if ((float) phpversion() >= 5.1) {
1879
- $reqs['PHP Version']['pass'] = true;
1880
  } else {
1881
- $reqs['PHP Version']['pass'] = false;
1882
- $pass = false;
1883
  }
1884
 
 
 
 
1885
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1886
  if (is_writable(WP_CONTENT_DIR)) {
1887
- $reqs['Backup Folder']['status'] = "writable";
1888
- $reqs['Backup Folder']['pass'] = true;
1889
  } else {
1890
- $reqs['Backup Folder']['status'] = "not writable";
1891
- $reqs['Backup Folder']['pass'] = false;
1892
  }
 
1893
 
1894
 
1895
  $file_path = IWP_BACKUP_DIR;
1896
- $reqs['Backup Folder']['status'] .= ' (' . $file_path . ')';
1897
 
 
1898
  if ($func = $this->check_sys()) {
1899
- $reqs['Execute Function']['status'] = $func;
1900
- $reqs['Execute Function']['pass'] = true;
1901
  } else {
1902
- $reqs['Execute Function']['status'] = "not found";
1903
- $reqs['Execute Function']['info'] = "(will try PHP replacement)";
1904
- $reqs['Execute Function']['pass'] = false;
1905
  }
1906
- $reqs['Zip']['status'] = $this->get_zip();
1907
-
1908
- $reqs['Zip']['pass'] = true;
1909
-
 
1910
 
1911
 
1912
- $reqs['Unzip']['status'] = $this->get_unzip();
1913
 
1914
- $reqs['Unzip']['pass'] = true;
 
 
 
1915
 
1916
  $paths = $this->check_mysql_paths();
1917
-
1918
  if (!empty($paths['mysqldump'])) {
1919
- $reqs['MySQL Dump']['status'] = $paths['mysqldump'];
1920
- $reqs['MySQL Dump']['pass'] = true;
1921
  } else {
1922
- $reqs['MySQL Dump']['status'] = "not found";
1923
- $reqs['MySQL Dump']['info'] = "(will try PHP replacement)";
1924
- $reqs['MySQL Dump']['pass'] = false;
1925
  }
 
1926
 
1927
  $exec_time = ini_get('max_execution_time');
1928
- $reqs['Execution time']['status'] = $exec_time ? $exec_time . "s" : 'unknown';
1929
- $reqs['Execution time']['pass'] = true;
 
 
1930
 
1931
  $mem_limit = ini_get('memory_limit');
1932
- $reqs['Memory limit']['status'] = $mem_limit ? $mem_limit : 'unknown';
1933
- $reqs['Memory limit']['pass'] = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
1934
 
 
 
 
 
 
 
 
 
 
 
1935
 
1936
  return $reqs;
1937
  }
1862
  $unzip = "unzip";
1863
  return $unzip;
1864
  }
1865
+ function getDirectorySize($directory)
1866
+ {
1867
+ $dirSize=0;
1868
+ $fileCount=0;
1869
+ $dirInfo = array(
1870
+ 'dirSize' => 0,
1871
+ 'fileCount' => 0
1872
+ );
1873
+
1874
+ if(!$dh=opendir($directory))
1875
+ {
1876
+ return false;
1877
+ }
1878
+
1879
+ while($file = readdir($dh))
1880
+ {
1881
+ if($file == "." || $file == "..")
1882
+ {
1883
+ continue;
1884
+ }
1885
+
1886
+ if(is_file($directory."/".$file))
1887
+ {
1888
+ $dirInfo['dirSize'] += filesize($directory."/".$file);
1889
+ $dirInfo['fileCount'] += 1;
1890
+ }
1891
+
1892
+ if(is_dir($directory."/".$file))
1893
+ {
1894
+ $teminfo = $this->getDirectorySize($directory."/".$file);
1895
+ if(isset($teminfo['dirSize'])) $dirInfo['dirSize'] += $teminfo['dirSize'];
1896
+ if(isset($teminfo['fileCount'])) $dirInfo['fileCount'] += $teminfo['fileCount'];
1897
+ }
1898
+ }
1899
+
1900
+ closedir($dh);
1901
+
1902
+ return $dirInfo;
1903
+ }
1904
+
1905
+ function get_database_size() {
1906
+ global $wpdb;
1907
+
1908
+ $total_size = 0;
1909
+ $total_size_with_exclusions = 0;
1910
+ $rows = $wpdb->get_results( "SHOW TABLE STATUS", ARRAY_A );
1911
+ foreach( $rows as $row ) {
1912
+ $excluded = true; // Default.
1913
+
1914
+ // TABLE STATUS.
1915
+ $rowsb = $wpdb->get_results( "CHECK TABLE `{$row['Name']}`", ARRAY_A );
1916
+ foreach( $rowsb as $rowb ) {
1917
+ if ( $rowb['Msg_type'] == 'status' ) {
1918
+ $status = $rowb['Msg_text'];
1919
+ }
1920
+ }
1921
+ unset( $rowsb );
1922
+
1923
+ // TABLE SIZE.
1924
+ $size = ( $row['Data_length'] + $row['Index_length'] );
1925
+ $total_size += $size;
1926
+ }
1927
+ return $total_size;
1928
+ }
1929
+
1930
+ function loopback_test() {
1931
+ $loopback_url = admin_url('admin-ajax.php');
1932
+ //pb_backupbuddy::status( 'details', 'Testing loopback connections by connecting back to site at the URL: `' . $loopback_url . '`. It should display simply "0" or "-1" in the body.' );
1933
+
1934
+ $response = wp_remote_get(
1935
+ $loopback_url,
1936
+ array(
1937
+ 'method' => 'GET',
1938
+ 'timeout' => 8, // X second delay. A loopback should be very fast.
1939
+ 'redirection' => 5,
1940
+ 'httpversion' => '1.0',
1941
+ 'blocking' => true,
1942
+ 'headers' => array(),
1943
+ 'body' => null,
1944
+ 'cookies' => array()
1945
+ )
1946
+ );
1947
+
1948
+ if( is_wp_error( $response ) ) { // Loopback failed. Some kind of error.
1949
+ $error = $response->get_error_message();
1950
+ //pb_backupbuddy::status( 'error', 'Loopback test error: `' . $error . '`.' );
1951
+ return 'Error: ' . $error;
1952
+ } else {
1953
+ if ( ( $response['body'] == '-1' ) || ( $response['body'] == '0' ) ) { // Loopback succeeded.
1954
+ //pb_backupbuddy::status( 'details', 'HTTP Loopback test success. Returned `' . $response['body'] . '`.' );
1955
+ return true;
1956
+ } else { // Loopback failed.
1957
+ $error = 'Connected to server but unexpected output: ' . htmlentities( $response['body'] );
1958
+ //pb_backupbuddy::status( 'error', $error );
1959
+ return $error;
1960
+ }
1961
+ }
1962
+ }
1963
+
1964
+ function is_php( $bits ) {
1965
+
1966
+ $result = ( ( PHP_INT_SIZE * 8 ) == $bits ) ? true : false;
1967
+
1968
+ return $result;
1969
+
1970
+ }
1971
+
1972
+ function stat( $filename ) {
1973
+
1974
+ $result = false;
1975
+
1976
+ // If the file is readable then we should be able to stat it
1977
+ if ( @is_readable( $filename ) ) {
1978
+
1979
+ $stats = @stat( $filename );
1980
+
1981
+ if ( false !== $stats ) {
1982
+
1983
+ // Looks like we got some valid data - for now just process the size
1984
+ if ( $this->is_php( 32 ) ) {
1985
+
1986
+ // PHP is 32 bits so we may have a file size problem over 2GB.
1987
+ // This is one way to test for a file size problem - there are others
1988
+ if ( 0 > $stats[ 'size' ] ) {
1989
+
1990
+ // Unsigned long has been interpreted as a signed int and has sign bit
1991
+ // set so is appearing as negative - magically convert it to a double
1992
+ // Note: this only works to give us an extension from 2GB to 4GB but that
1993
+ // should be enough as the underlying OS probably can't support >4GB or
1994
+ // zip command cannot anyway
1995
+ $stats[ 'dsize' ] = ( (double)0x80000000 + ( $stats[ 'size' ] & 0x7FFFFFFF ) );
1996
+
1997
+ } else {
1998
+
1999
+ // Assume it's valid
2000
+ $stats[ 'dsize' ] = (double)$stats[ 'size' ];
2001
+
2002
+ }
2003
+
2004
+ } else {
2005
+
2006
+ // Looks like 64 bit PHP so file size should be fine
2007
+ // Force added item to double for consistency
2008
+ $stats[ 'dsize' ] = (double)$stats[ 'size' ];
2009
+
2010
+ }
2011
+
2012
+ // Add an additional item for short octal representation of mode
2013
+ $stats[ 'mode_octal_four' ] = substr( sprintf( '%o', $stats[ 'mode' ] ), -4 );
2014
+
2015
+ $result = $stats;
2016
+
2017
+ } else {
2018
+
2019
+ // Hmm, stat() failed for some reason - could be an LFS problem with the
2020
+ // way PHP has been built :-(
2021
+ // TODO: Consider alternatives - may be able to use exec to run the
2022
+ // command line stat function which _should_ be ok and we can map output
2023
+ // into the same array format. This does depend on having exec() and the
2024
+ // stat command available and it's definitely not a nice option
2025
+ $result = false;
2026
+
2027
+ }
2028
+
2029
+ }
2030
+
2031
+ return $result;
2032
+ }
2033
+
2034
+
2035
+ function getDirectoryInfo() {
2036
+ $tests = array();
2037
+
2038
+ $uploads_dirs = wp_upload_dir();
2039
+ $directories = array(
2040
+ ABSPATH . '',
2041
+ ABSPATH . 'wp-includes/',
2042
+ ABSPATH . 'wp-admin/',
2043
+ ABSPATH . 'wp-content/themes/',
2044
+ ABSPATH . 'wp-content/plugins/',
2045
+ ABSPATH . 'wp-content/',
2046
+ rtrim( $uploads_dirs['basedir'], '\\/' ) . '/',
2047
+ ABSPATH . 'wp-includes/',
2048
+
2049
+ );
2050
+
2051
+ foreach( $directories as $directory ) {
2052
+
2053
+ $mode_octal_four = '<i>Unknown</i>';
2054
+ $owner = '<i>Unknown</i>';
2055
+
2056
+ $stats = $this->stat( $directory );
2057
+ if ( false !== $stats ) {
2058
+ $mode_octal_four = $stats['mode_octal_four'];
2059
+ $owner = $stats['uid'] . ':' . $stats['gid'];
2060
+ }
2061
+ $this_test = array(
2062
+ 'title' => '/' . str_replace( ABSPATH, '', $directory ),
2063
+ 'suggestion' => '<= 755',
2064
+ 'value' => $mode_octal_four,
2065
+ 'owner' => $owner,
2066
+ );
2067
+ if ( false === $stats || $mode_octal_four > 755 ) {
2068
+ $this_test['status'] = 'WARNING';
2069
+ } else {
2070
+ $this_test['status'] = 'OK';
2071
+ }
2072
+ array_push( $tests, $this_test );
2073
+
2074
+ } // end foreach.
2075
+ return $tests;
2076
+
2077
+ }
2078
 
2079
  function check_backup_compat()
2080
  {
2081
+ global $wpdb;
2082
  $reqs = array();
2083
+ $reqs['serverInfo']['server_os']['name'] = 'Server OS';
2084
  if (strpos($_SERVER['DOCUMENT_ROOT'], '/') === 0) {
2085
+ $reqs['serverInfo']['server_os']['status'] = php_uname('s')." ".php_uname('v');
2086
+ $reqs['serverInfo']['server_os']['pass'] = true;
2087
  } else {
2088
+ $reqs['serverInfo']['server_os']['status'] = php_uname('s')." ".php_uname('v');
2089
+ $reqs['serverInfo']['server_os']['pass'] = 'ok';
 
2090
  }
2091
+ $reqs['serverInfo']['server_os']['suggeted'] = 'Linux';
2092
+
2093
+ $reqs['serverInfo']['php_version']['name'] = 'PHP Version';
2094
+ $reqs['serverInfo']['php_version']['status'] = phpversion();
2095
+ $reqs['serverInfo']['php_version']['suggeted'] = '>= 5.2 (5.2.16+ best)';
2096
  if ((float) phpversion() >= 5.1) {
2097
+ $reqs['serverInfo']['php_version']['pass'] = true;
2098
  } else {
2099
+ $reqs['serverInfo']['php_version']['pass'] = false;
 
2100
  }
2101
 
2102
+ $reqs['mysqlInfo']['mysql_version']['name'] = 'MySql Version';
2103
+ $reqs['mysqlInfo']['mysql_version']['status'] = $wpdb->db_version();
2104
+ $reqs['mysqlInfo']['mysql_version']['suggeted'] = '>= 5.0';
2105
 
2106
+ if ((float) $wpdb->db_version() >= 5.0) {
2107
+ $reqs['mysqlInfo']['mysql_version']['pass'] = true;
2108
+ } else {
2109
+ $reqs['mysqlInfo']['mysql_version']['pass'] = false;
2110
+ }
2111
+
2112
+ $reqs['serverInfo']['php_max_execution_time']['name'] = 'PHP max_execution_time';
2113
+ $reqs['serverInfo']['php_max_execution_time']['status'] = ini_get( 'max_execution_time' );
2114
+ $reqs['serverInfo']['php_max_execution_time']['suggeted'] = '>= 30 seconds (30+ best)';
2115
+
2116
+ if (str_ireplace( 's', '', ini_get( 'max_execution_time' ) ) < 30) {
2117
+ $reqs['serverInfo']['php_max_execution_time']['pass'] = false;
2118
+ } else {
2119
+ $reqs['serverInfo']['php_max_execution_time']['pass'] = true;
2120
+ }
2121
+
2122
+ if ( !ini_get( 'memory_limit' ) ) {
2123
+ $parent_class_val = 'unknown';
2124
+ } else {
2125
+ $parent_class_val = ini_get( 'memory_limit' );
2126
+ }
2127
+ $reqs['serverInfo']['php_memory_limit']['name'] = 'PHP Memory Limit';
2128
+ $reqs['serverInfo']['php_memory_limit']['status'] = $parent_class_val;
2129
+ $reqs['serverInfo']['php_memory_limit']['suggeted'] = '>= 128M (256M+ best)';
2130
+
2131
+ if ( preg_match( '/(\d+)(\w*)/', $parent_class_val, $matches ) ) {
2132
+ $parent_class_val = $matches[1];
2133
+ $unit = $matches[2];
2134
+ // Up memory limit if currently lower than 256M.
2135
+ if ( 'g' !== strtolower( $unit ) ) {
2136
+ if ( ( $parent_class_val < 128 ) || ( 'm' !== strtolower( $unit ) ) ) {
2137
+ $reqs['serverInfo']['php_memory_limit']['pass'] = false;
2138
+ } else {
2139
+ $reqs['serverInfo']['php_memory_limit']['pass'] = true;
2140
+ }
2141
+ }
2142
+ } else {
2143
+ $reqs['serverInfo']['php_memory_limit']['pass'] = false;
2144
+ }
2145
+
2146
+ //$reqs['serverInfo']['Site Information']['status'] = $this->getDirectorySize(ABSPATH);
2147
+ $tempInfo = $this->getDirectorySize(ABSPATH);
2148
+
2149
+
2150
+ $reqs['serverInfo']['site_size']['name'] = 'Site size';
2151
+ $reqs['serverInfo']['site_size']['status'] = ($tempInfo['dirSize']/1048576). " MB";
2152
+ $reqs['serverInfo']['site_size']['pass'] = true;
2153
+ $reqs['serverInfo']['site_size']['suggeted'] = 'N/A';
2154
+
2155
+ $reqs['serverInfo']['site_number_of_files']['name'] = 'Site number of files';
2156
+ $reqs['serverInfo']['site_number_of_files']['status'] = $tempInfo['fileCount'];
2157
+ $reqs['serverInfo']['site_number_of_files']['pass'] = true;
2158
+ $reqs['serverInfo']['site_number_of_files']['suggeted'] = 'N/A';
2159
+
2160
+ $reqs['mysqlInfo']['database_size']['name'] = 'Database Size';
2161
+ $reqs['mysqlInfo']['database_size']['status'] = $this->get_database_size();
2162
+ $reqs['mysqlInfo']['database_size']['pass'] = true;
2163
+ $reqs['mysqlInfo']['database_size']['suggeted'] = 'N/A';
2164
+
2165
+ $reqs['serverInfo']['http_loopback']['name'] = 'Http Loopbacks';
2166
+ if($this->loopback_test() === true) {
2167
+ $reqs['serverInfo']['http_loopback']['status'] = true;
2168
+ $reqs['serverInfo']['http_loopback']['pass'] = true;
2169
+ } else {
2170
+ $reqs['serverInfo']['http_loopback']['status'] = false;
2171
+ $reqs['serverInfo']['http_loopback']['pass'] = false;
2172
+ }
2173
+ $reqs['serverInfo']['http_loopback']['suggeted'] = "enabled";
2174
+
2175
+ $reqs['serverInfo']['php_architecture']['name'] = 'PHP Architecture';
2176
+ $reqs['serverInfo']['php_architecture']['status'] = ( PHP_INT_SIZE * 8 ) . '-bit';
2177
+ $reqs['serverInfo']['php_architecture']['pass'] = true;
2178
+ $reqs['serverInfo']['php_architecture']['suggeted'] = '64-bit';
2179
+
2180
+ // http Server Software
2181
+ if ( isset( $_SERVER['SERVER_SOFTWARE'] ) ) {
2182
+ $server_software = $_SERVER['SERVER_SOFTWARE'];
2183
+ } else {
2184
+ $server_software = 'Unknown';
2185
+ }
2186
+ $reqs['serverInfo']['http_server_software']['name'] = 'Http Server Software';
2187
+ $reqs['serverInfo']['http_server_software']['status'] = $server_software;
2188
+ $reqs['serverInfo']['http_server_software']['pass'] = true;
2189
+ $reqs['serverInfo']['http_server_software']['suggeted'] = 'N/A';
2190
+
2191
+ $reqs['directoryInfo']['status'] = $this->getDirectoryInfo();
2192
+
2193
+
2194
+
2195
+ $reqs['serverInfo']['backup_folder']['name'] = "Backup Folder";
2196
  if (is_writable(WP_CONTENT_DIR)) {
2197
+ $reqs['serverInfo']['backup_folder']['status'] = "writable";
2198
+ $reqs['serverInfo']['backup_folder']['pass'] = true;
2199
  } else {
2200
+ $reqs['serverInfo']['backup_folder']['status'] = "not writable";
2201
+ $reqs['serverInfo']['backup_folder']['pass'] = false;
2202
  }
2203
+ $reqs['serverInfo']['backup_folder']['suggeted'] = 'Need to writiable';
2204
 
2205
 
2206
  $file_path = IWP_BACKUP_DIR;
2207
+ $reqs['serverInfo']['backup_folder']['status'] .= ' (' . $file_path . ')';
2208
 
2209
+ $reqs['serverInfo']['execute_function']['name'] = 'Execute Function';
2210
  if ($func = $this->check_sys()) {
2211
+ $reqs['serverInfo']['execute_function']['status'] = $func;
2212
+ $reqs['serverInfo']['execute_function']['pass'] = true;
2213
  } else {
2214
+ $reqs['serverInfo']['execute_function']['status'] = "not found";
2215
+ $reqs['serverInfo']['execute_function']['pass'] = false;
 
2216
  }
2217
+ $reqs['serverInfo']['execute_function']['suggeted'] = 'Need any one of support exec, system, passhtru (or will try PHP replacement)';
2218
+ $reqs['serverInfo']['zip']['name'] = 'Zip';
2219
+ $reqs['serverInfo']['zip']['status'] = $this->get_zip();
2220
+ $reqs['serverInfo']['zip']['suggeted'] = 'System Zip need or will try PHP replacement';
2221
+ $reqs['serverInfo']['zip']['pass'] = true;
2222
 
2223
 
 
2224
 
2225
+ $reqs['serverInfo']['unzip']['name'] = 'Unzip';
2226
+ $reqs['serverInfo']['unzip']['status'] = $this->get_unzip();
2227
+ $reqs['serverInfo']['unzip']['suggeted'] = 'System Zip need or will try PHP replacement';
2228
+ $reqs['serverInfo']['unzip']['pass'] = true;
2229
 
2230
  $paths = $this->check_mysql_paths();
2231
+ $reqs['mysqlInfo']['mysql_dump']['name'] = 'MySQL Dump';
2232
  if (!empty($paths['mysqldump'])) {
2233
+ $reqs['mysqlInfo']['mysql_dump']['status'] = $paths['mysqldump'];
2234
+ $reqs['mysqlInfo']['mysql_dump']['pass'] = true;
2235
  } else {
2236
+ $reqs['mysqlInfo']['mysql_dump']['status'] = "not found";
2237
+ $reqs['mysqlInfo']['mysql_dump']['pass'] = false;
 
2238
  }
2239
+ $reqs['mysqlInfo']['mysql_dump']['suggeted'] = "Command line [fastest] > PHP-based [slowest] (or will try PHP replacement)";
2240
 
2241
  $exec_time = ini_get('max_execution_time');
2242
+ $reqs['serverInfo']['mysql_dump']['name'] = 'Execution time';
2243
+ $reqs['serverInfo']['mysql_dump']['status'] = $exec_time ? $exec_time . "s" : 'unknown';
2244
+ $reqs['serverInfo']['mysql_dump']['pass'] = true;
2245
+ $reqs['serverInfo']['mysql_dump']['suggeted'] = 'N/A';
2246
 
2247
  $mem_limit = ini_get('memory_limit');
2248
+ $reqs['serverInfo']['memory_limit']['name'] = 'Memory limit';
2249
+ $reqs['serverInfo']['memory_limit']['status'] = $mem_limit ? $mem_limit : 'unknown';
2250
+ $reqs['serverInfo']['memory_limit']['pass'] = true;
2251
+ $reqs['serverInfo']['memory_limit']['suggeted'] = 'N/A';
2252
+
2253
+ $reqs['functionList']['file_put_content']['name'] = "File Put Content";
2254
+ if(function_exists('file_put_contents')) {
2255
+ $reqs['functionList']['file_put_content']['status'] = "Available";
2256
+ $reqs['functionList']['file_put_content']['pass'] = true;
2257
+ } else {
2258
+ $reqs['functionList']['file_put_content']['status'] = "Not Available";
2259
+ $reqs['functionList']['file_put_content']['pass'] = false;
2260
+
2261
+ }
2262
+ $reqs['functionList']['file_put_content']['suggeted'] = 'N/A';
2263
 
2264
+ $reqs['functionList']['ftp_functions']['name'] = "FTP Funtions";
2265
+ if(function_exists('ftp_connect')) {
2266
+ $reqs['functionList']['ftp_functions']['status'] = "Available";
2267
+ $reqs['functionList']['ftp_functions']['pass'] = true;
2268
+ } else {
2269
+ $reqs['functionList']['ftp_functions']['status'] = "Not Available";
2270
+ $reqs['functionList']['ftp_functions']['pass'] = false;
2271
+ $reqs['functionList']['ftp_functions']['pass'] = false;
2272
+ }
2273
+ $reqs['functionList']['ftp_functions']['suggeted'] = 'N/A';
2274
 
2275
  return $reqs;
2276
  }
core.class.php CHANGED
@@ -178,7 +178,11 @@ class IWP_MMB_Core extends IWP_MMB_Helper
178
  'put_redirect_url' => 'iwp_mmb_gwmt_redirect_url',
179
  'put_redirect_url_again'=> 'iwp_mmb_gwmt_redirect_url_again',
180
  'wordfence_scan' => 'iwp_mmb_wordfence_scan',
181
- 'wordfence_load' => 'iwp_mmb_wordfence_load'
 
 
 
 
182
  );
183
 
184
  add_action('rightnow_end', array( &$this, 'add_right_now_info' ));
@@ -277,11 +281,48 @@ class IWP_MMB_Core extends IWP_MMB_Helper
277
 
278
 
279
  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>
280
- <table border="0" align="center">';
281
  if(!empty($iwp_client_activate_key)){
282
  echo '<tr><td align="right">WP-ADMIN URL:</td><td align="left"><strong>'.$notice_display_URL.'</strong></td></tr>
283
  <tr><td align="right">ADMIN USERNAME:</td><td align="left"><strong>'.$username.'</strong> (or any admin id)</td></tr>
284
- <tr><td align="right">ACTIVATION KEY:</td><td align="left"><strong>'.$iwp_client_activate_key.'</strong></td></tr>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
285
  }
286
  else{
287
  echo '<tr><td align="center">Please deactivate and then activate InfiniteWP Client plugin.</td></tr>';
@@ -376,6 +417,22 @@ class IWP_MMB_Core extends IWP_MMB_Helper
376
  return $this->get_file_editor;
377
  }
378
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
379
 
380
  /**
381
  * Gets an instance of the Comment class
178
  'put_redirect_url' => 'iwp_mmb_gwmt_redirect_url',
179
  'put_redirect_url_again'=> 'iwp_mmb_gwmt_redirect_url_again',
180
  'wordfence_scan' => 'iwp_mmb_wordfence_scan',
181
+ 'wordfence_load' => 'iwp_mmb_wordfence_load',
182
+ 'backup_test_site' => 'iwp_mmb_backup_test_site',
183
+ 'ithemes_security_load' => 'iwp_mmb_ithemes_security_load',
184
+ 'get_seo_info' => 'iwp_mmb_yoast_get_seo_info',
185
+ 'save_seo_info' => 'iwp_mmb_yoast_save_seo_info'
186
  );
187
 
188
  add_action('rightnow_end', array( &$this, 'add_right_now_info' ));
281
 
282
 
283
  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>
284
+ <table border="0" align="center" cellpadding="5">';
285
  if(!empty($iwp_client_activate_key)){
286
  echo '<tr><td align="right">WP-ADMIN URL:</td><td align="left"><strong>'.$notice_display_URL.'</strong></td></tr>
287
  <tr><td align="right">ADMIN USERNAME:</td><td align="left"><strong>'.$username.'</strong> (or any admin id)</td></tr>
288
+ <tr><td align="right">ACTIVATION KEY:</td><td align="left"><strong>'.$iwp_client_activate_key.'</strong></td></tr>
289
+ <tr id="copy_at_once"><td align="right">To quick add, copy this</td><td align="left" style="position:relative;"><input type="text" style="width:295px;" class="read_creds" readonly value="'.$notice_display_URL.'|^|'.$username.'|^|'.$iwp_client_activate_key.'" /></td></tr>
290
+ <tr class="only_flash"><td></td><td align="left" style="position:relative;"><div id="copy_details" style="background:#008000;display: inline-block;padding: 4px 10px;border-radius: 5px;color:#fff;font-weight:600;cursor:pointer;">Copy details</div><span class="copy_message" style="display:none;margin-left:10px;color:#008000;">Copied :)</span></td></tr>
291
+ <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
292
+ <script type="text/javascript" src="'.WP_PLUGIN_URL.'/iwp-client/ZeroClipboard.js"></script>
293
+ <script type="text/javascript">
294
+ var hasFlash = function() {
295
+ return (typeof navigator.plugins == "undefined" || navigator.plugins.length == 0) ? !!(new ActiveXObject("ShockwaveFlash.ShockwaveFlash")) : navigator.plugins["Shockwave Flash"];
296
+ };
297
+ var onhoverMsg = "<span class=\"aftercopy_instruction\" style=\"position: absolute;top: 32px;left:20px;background:#fff;border:1px solid #000;-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;padding:2px;margin:2px;text-align:center;\">Paste this in any field in the Add Website dialogue in the InfiniteWP admin panel.</span>";
298
+ if(typeof hasFlash() != "undefined"){
299
+ var client = new ZeroClipboard( $("#copy_details") );
300
+ client.on( "ready", function(event) {
301
+ // console.log( "movie is loaded" );
302
+
303
+ client.on( "copy", function(event) {
304
+ event.clipboardData.setData("text/plain", $(".read_creds").val());
305
+ } );
306
+
307
+ client.on( "aftercopy", function(event) {
308
+ // console.log("Copied text to clipboard: " + event.data["text/plain"]);
309
+ $(".copy_message").show();
310
+ setTimeout("$(\'.copy_message\').hide()",1000);
311
+ } );
312
+ } );
313
+
314
+ client.on( "error", function(event) {
315
+ ZeroClipboard.destroy();
316
+ } );
317
+ $("#copy_at_once").hide();
318
+ $("#copy_details").mouseenter(function(){$(onhoverMsg).appendTo($(this).parent());}).mouseleave(function(){$(".aftercopy_instruction").remove();});
319
+
320
+ }else{
321
+ $(".only_flash").remove();
322
+ $(".read_creds").click(function(){$(this).select();});
323
+ $(".read_creds").mouseenter(function(e){$(onhoverMsg).appendTo($(this).parent());}).mouseleave(function(){$(".aftercopy_instruction").remove();});
324
+ }
325
+ </script>';
326
  }
327
  else{
328
  echo '<tr><td align="center">Please deactivate and then activate InfiniteWP Client plugin.</td></tr>';
417
  return $this->get_file_editor;
418
  }
419
 
420
+
421
+ /**
422
+ * Gets an instance of the yoastWpSeo class
423
+ *
424
+ */
425
+ function wp_get_yoast_seo()
426
+ {
427
+ global $iwp_mmb_plugin_dir;
428
+ require_once("$iwp_mmb_plugin_dir/addons/yoast_wp_seo/yoast_wp_seo.class.php");
429
+ if (!isset($this->get_yoast_seo)) {
430
+ $this->get_yoast_seo = new IWP_MMB_YWPSEO();
431
+ }
432
+
433
+ return $this->get_yoast_seo;
434
+ }
435
+
436
 
437
  /**
438
  * Gets an instance of the Comment class
init.php CHANGED
@@ -1,1582 +1,1775 @@
1
- <?php
2
- /*
3
- Plugin Name: InfiniteWP - Client
4
- Plugin URI: http://infinitewp.com/
5
- Description: This is the client plugin of InfiniteWP that communicates with the InfiniteWP Admin panel.
6
- Author: Revmakx
7
- Version: 1.3.3
8
- Author URI: http://www.revmakx.com
9
- */
10
- /************************************************************
11
- * This plugin was modified by Revmakx *
12
- * Copyright (c) 2012 Revmakx *
13
- * www.revmakx.com *
14
- * *
15
- ************************************************************/
16
-
17
- /*************************************************************
18
- *
19
- * init.php
20
- *
21
- * Initialize the communication with master
22
- *
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.3.3');
30
-
31
-
32
-
33
- if ( !defined('IWP_MMB_XFRAME_COOKIE')){
34
- $siteurl = function_exists('get_site_option') ? get_site_option( 'siteurl' ) : get_option('siteurl');
35
- define('IWP_MMB_XFRAME_COOKIE', $xframe = 'wordpress_'.md5($siteurl).'_xframe');
36
- }
37
- global $wpdb, $iwp_mmb_plugin_dir, $iwp_mmb_plugin_url, $wp_version, $iwp_mmb_filters, $_iwp_mmb_item_filter;
38
- if (version_compare(PHP_VERSION, '5.0.0', '<')) // min version 5 supported
39
- exit("<p>InfiniteWP Client plugin requires PHP 5 or higher.</p>");
40
-
41
-
42
- $iwp_mmb_wp_version = $wp_version;
43
- $iwp_mmb_plugin_dir = WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__));
44
- $iwp_mmb_plugin_url = WP_PLUGIN_URL . '/' . basename(dirname(__FILE__));
45
-
46
- require_once("$iwp_mmb_plugin_dir/helper.class.php");
47
- require_once("$iwp_mmb_plugin_dir/core.class.php");
48
- require_once("$iwp_mmb_plugin_dir/stats.class.php");
49
- //require_once("$iwp_mmb_plugin_dir/backup.class.php");
50
- require_once("$iwp_mmb_plugin_dir/backup.class.singlecall.php");
51
- require_once("$iwp_mmb_plugin_dir/backup.class.multicall.php");
52
- require_once("$iwp_mmb_plugin_dir/installer.class.php");
53
-
54
- require_once("$iwp_mmb_plugin_dir/addons/manage_users/user.class.php");
55
- require_once("$iwp_mmb_plugin_dir/addons/backup_repository/backup_repository.class.php");
56
- require_once("$iwp_mmb_plugin_dir/addons/comments/comments.class.php");
57
-
58
- require_once("$iwp_mmb_plugin_dir/addons/post_links/link.class.php");
59
- require_once("$iwp_mmb_plugin_dir/addons/post_links/post.class.php");
60
-
61
- require_once("$iwp_mmb_plugin_dir/addons/wp_optimize/optimize.class.php");
62
-
63
- require_once("$iwp_mmb_plugin_dir/api.php");
64
- require_once("$iwp_mmb_plugin_dir/plugins/search/search.php");
65
- require_once("$iwp_mmb_plugin_dir/plugins/cleanup/cleanup.php");
66
-
67
-
68
-
69
- if( !function_exists ( 'iwp_mmb_filter_params' )) {
70
- function iwp_mmb_filter_params( $array = array() ){
71
-
72
- $filter = array( 'current_user', 'wpdb' );
73
- $return = array();
74
- foreach ($array as $key => $val) {
75
- if( !is_int($key) && in_array($key, $filter) )
76
- continue;
77
-
78
- if( is_array( $val ) ) {
79
- $return[$key] = iwp_mmb_filter_params( $val );
80
- } else {
81
- $return[$key] = $val;
82
- }
83
- }
84
-
85
- return $return;
86
- }
87
- }
88
-
89
- if( !function_exists ('iwp_mmb_parse_request')) {
90
- function iwp_mmb_parse_request()
91
- {
92
- if (!isset($HTTP_RAW_POST_DATA)) {
93
- $HTTP_RAW_POST_DATA = file_get_contents('php://input');
94
- }
95
-
96
- ob_start();
97
-
98
- global $current_user, $iwp_mmb_core, $new_actions, $wp_db_version, $wpmu_version, $_wp_using_ext_object_cache;
99
- $data = base64_decode($HTTP_RAW_POST_DATA);
100
- if ($data){
101
- //$num = @extract(unserialize($data));
102
- $unserialized_data = @unserialize($data);
103
- if(isset($unserialized_data['params'])){
104
- $unserialized_data['params'] = iwp_mmb_filter_params($unserialized_data['params']);
105
- }
106
-
107
- $iwp_action = $unserialized_data['iwp_action'];
108
- $params = $unserialized_data['params'];
109
- $id = $unserialized_data['id'];
110
- $signature = $unserialized_data['signature'];
111
- }
112
-
113
- if (isset($iwp_action)) {
114
-
115
- if(!defined('IWP_AUTHORISED_CALL')) define('IWP_AUTHORISED_CALL', 1);
116
- if(function_exists('register_shutdown_function')){ register_shutdown_function("iwp_mmb_shutdown"); }
117
- $GLOBALS['IWP_MMB_PROFILING']['ACTION_START'] = microtime(1);
118
-
119
- error_reporting(E_ALL ^ E_NOTICE);
120
- @ini_set("display_errors", 1);
121
-
122
- iwp_mmb_create_backup_table();
123
-
124
- $action = $iwp_action;
125
- $_wp_using_ext_object_cache = false;
126
- @set_time_limit(600);
127
-
128
- if (!$iwp_mmb_core->check_if_user_exists($params['username']))
129
- iwp_mmb_response(array('error' => 'Username <b>' . $params['username'] . '</b> does not have administrative access. Enter the correct username in the site options.', 'error_code' => 'username_does_not_have_administrative_access'), false);
130
-
131
- if ($action == 'add_site') {
132
- iwp_mmb_add_site($params);
133
- iwp_mmb_response(array('error' => 'You should never see this.', 'error_code' => 'you_should_never_see_this'), false);
134
- }
135
-
136
- $auth = $iwp_mmb_core->authenticate_message($action . $id, $signature, $id);
137
- if ($auth === true) {
138
- @ignore_user_abort(true);
139
- $GLOBALS['IWP_CLIENT_HISTORY_ID'] = $id;
140
-
141
- if(isset($params['username']) && !is_user_logged_in()){
142
- $user = function_exists('get_user_by') ? get_user_by('login', $params['username']) : get_userdatabylogin( $params['username'] );
143
- wp_set_current_user($user->ID);
144
- //For WPE
145
- if(@getenv('IS_WPE'))
146
- wp_set_auth_cookie($user->ID);
147
- }
148
-
149
- /* in case database upgrade required, do database backup and perform upgrade ( wordpress wp_upgrade() function ) */
150
- if( strlen(trim($wp_db_version)) && !defined('ACX_PLUGIN_DIR') ){
151
- if ( get_option('db_version') != $wp_db_version ) {
152
- /* in multisite network, please update database manualy */
153
- if (empty($wpmu_version) || (function_exists('is_multisite') && !is_multisite())){
154
- if( ! function_exists('wp_upgrade'))
155
- include_once(ABSPATH.'wp-admin/includes/upgrade.php');
156
-
157
- ob_clean();
158
- @wp_upgrade();
159
- @do_action('after_db_upgrade');
160
- ob_end_clean();
161
- }
162
- }
163
- }
164
-
165
- if(isset($params['secure'])){
166
-
167
- if($decrypted = $iwp_mmb_core->_secure_data($params['secure'])){
168
- $decrypted = maybe_unserialize($decrypted);
169
- if(is_array($decrypted)){
170
-
171
- foreach($decrypted as $key => $val){
172
- if(!is_numeric($key))
173
- $params[$key] = $val;
174
-
175
- }
176
- unset($params['secure']);
177
- } else $params['secure'] = $decrypted;
178
- }
179
- elseif(isset($params['secure']['account_info'])){
180
- $params['account_info'] = $params['secure']['account_info'];
181
- }
182
- }
183
-
184
- if( !$iwp_mmb_core->register_action_params( $action, $params ) ){
185
- global $_iwp_mmb_plugin_actions;
186
- $_iwp_mmb_plugin_actions[$action] = $params;
187
- }
188
-
189
- } else {
190
- iwp_mmb_response($auth, false);
191
- }
192
- } else {
193
- //IWP_MMB_Stats::set_hit_count();
194
- }
195
- ob_end_clean();
196
- }
197
- }
198
- /* Main response function */
199
- if( !function_exists ( 'iwp_mmb_response' )) {
200
-
201
- function iwp_mmb_response($response = false, $success = true)
202
- {
203
- $return = array();
204
-
205
- if ((is_array($response) && empty($response)) || (!is_array($response) && strlen($response) == 0)){
206
- $return['error'] = 'Empty response.';
207
- $return['error_code'] = 'empty_response';
208
- }
209
- else if ($success){
210
- $return['success'] = $response;
211
- }
212
- else{
213
- $return['error'] = $response['error'];
214
- $return['error_code'] = $response['error_code'];
215
- }
216
-
217
- if( !headers_sent() ){
218
- header('HTTP/1.0 200 OK');
219
- header('Content-Type: text/plain');
220
- }
221
- $GLOBALS['IWP_RESPONSE_SENT'] = true;
222
- exit("<IWPHEADER>" . base64_encode(serialize($return))."<ENDIWPHEADER>");
223
- }
224
- }
225
-
226
-
227
-
228
- if( !function_exists ( 'iwp_mmb_add_site' )) {
229
- function iwp_mmb_add_site($params)
230
- {
231
- global $iwp_mmb_core;
232
- $num = extract($params);
233
-
234
- if ($num) {
235
- if (!get_option('iwp_client_action_message_id') && !get_option('iwp_client_public_key')) {
236
- $public_key = base64_decode($public_key);
237
-
238
-
239
- if(trim($activation_key) != get_option('iwp_client_activate_key')){ //iwp
240
- iwp_mmb_response(array('error' => 'Invalid activation key', 'error_code' => 'iwp_mmb_add_site_invalid_activation_key'), false);
241
- return;
242
- }
243
-
244
- if (checkOpenSSL() && !$user_random_key_signing) {
245
- $verify = openssl_verify($action . $id, base64_decode($signature), $public_key);
246
- if ($verify == 1) {
247
- $iwp_mmb_core->set_admin_panel_public_key($public_key);
248
- $iwp_mmb_core->set_client_message_id($id);
249
- $iwp_mmb_core->get_stats_instance();
250
- if(isset($notifications) && is_array($notifications) && !empty($notifications)){
251
- $iwp_mmb_core->stats_instance->set_notifications($notifications);
252
- }
253
- if(isset($brand) && is_array($brand) && !empty($brand)){
254
- update_option('iwp_client_brand',$brand);
255
- }
256
-
257
- iwp_mmb_response($iwp_mmb_core->stats_instance->get_initial_stats(), true);
258
- delete_option('iwp_client_activate_key');//iwp
259
- } else if ($verify == 0) {
260
- iwp_mmb_response(array('error' => 'Invalid message signature. Please contact us if you see this message often.', 'error_code' => 'iwp_mmb_add_site_invalid_message_signature'), false);
261
- } else {
262
- iwp_mmb_response(array('error' => 'Command not successful. Please try again.', 'error_code' => 'iwp_mmb_add_site_command_not_successful'), false);
263
- }
264
- } else {
265
- if (!get_option('iwp_client_nossl_key')) {
266
- srand();
267
-
268
- $random_key = md5(base64_encode($public_key) . rand(0, getrandmax()));
269
-
270
- $iwp_mmb_core->set_random_signature($random_key);
271
- $iwp_mmb_core->set_client_message_id($id);
272
- $iwp_mmb_core->set_admin_panel_public_key($public_key);
273
- $iwp_mmb_core->get_stats_instance();
274
- if(is_array($notifications) && !empty($notifications)){
275
- $iwp_mmb_core->stats_instance->set_notifications($notifications);
276
- }
277
-
278
- if(is_array($brand) && !empty($brand)){
279
- update_option('iwp_client_brand',$brand);
280
- }
281
-
282
- iwp_mmb_response($iwp_mmb_core->stats_instance->get_initial_stats(), true);
283
- delete_option('iwp_client_activate_key');//IWP
284
- } else
285
- iwp_mmb_response(array('error' => 'Please deactivate & activate InfiniteWP Client plugin on your site, then add the site again.', 'error_code' => 'deactivate_ctivate_InfiniteWP_Client_plugin_add_site_again_not_iwp_client_nossl_key'), false);
286
- }
287
- } else {
288
- iwp_mmb_response(array('error' => 'Please deactivate &amp; activate InfiniteWP Client plugin on your site, then add the site again.', 'error_code' => 'deactivate_ctivate_InfiniteWP_Client_plugin_add_site_again_not_iwp_client_nossl_key'), false);
289
- }
290
- } else {
291
- iwp_mmb_response(array('error' => 'Invalid parameters received. Please try again.', 'error_code' => 'iwp_mmb_add_site_invalid_parameters_received'), false);
292
- }
293
- }
294
- }
295
-
296
- if( !function_exists ( 'iwp_mmb_remove_site' )) {
297
- function iwp_mmb_remove_site($params)
298
- {
299
- extract($params);
300
- global $iwp_mmb_core;
301
- $iwp_mmb_core->uninstall( $deactivate );
302
-
303
- include_once(ABSPATH . 'wp-admin/includes/plugin.php');
304
- $plugin_slug = basename(dirname(__FILE__)) . '/' . basename(__FILE__);
305
-
306
- if ($deactivate) {
307
- deactivate_plugins($plugin_slug, true);
308
- }
309
-
310
- if (!is_plugin_active($plugin_slug))
311
- iwp_mmb_response(array(
312
- 'deactivated' => 'Site removed successfully. <br /><br />InfiniteWP Client plugin successfully deactivated.'
313
- ), true);
314
- else
315
- iwp_mmb_response(array(
316
- 'removed_data' => 'Site removed successfully. <br /><br /><b>InfiniteWP Client plugin was not deactivated.</b>'
317
- ), true);
318
-
319
- }
320
- }
321
- if( !function_exists ( 'iwp_mmb_stats_get' )) {
322
- function iwp_mmb_stats_get($params)
323
- {
324
- global $iwp_mmb_core;
325
- $iwp_mmb_core->get_stats_instance();
326
- iwp_mmb_response($iwp_mmb_core->stats_instance->get($params), true);
327
- }
328
- }
329
-
330
- if( !function_exists ( 'iwp_mmb_client_header' )) {
331
- function iwp_mmb_client_header()
332
- { global $iwp_mmb_core, $current_user;
333
-
334
- if(!headers_sent()){
335
- if(isset($current_user->ID))
336
- $expiration = time() + apply_filters('auth_cookie_expiration', 10800, $current_user->ID, false);
337
- else
338
- $expiration = time() + 10800;
339
-
340
- setcookie(IWP_MMB_XFRAME_COOKIE, md5(IWP_MMB_XFRAME_COOKIE), $expiration, COOKIEPATH, COOKIE_DOMAIN, false, true);
341
- $_COOKIE[IWP_MMB_XFRAME_COOKIE] = md5(IWP_MMB_XFRAME_COOKIE);
342
- }
343
- }
344
- }
345
-
346
- if( !function_exists ( 'iwp_mmb_pre_init_stats' )) {
347
- function iwp_mmb_pre_init_stats( $params )
348
- {
349
- global $iwp_mmb_core;
350
- $iwp_mmb_core->get_stats_instance();
351
- return $iwp_mmb_core->stats_instance->pre_init_stats($params);
352
- }
353
- }
354
-
355
- if( !function_exists ( 'iwp_mmb_trigger_check' )) {
356
- //backup multi call trigger and status check.
357
- function iwp_mmb_trigger_check($params)
358
- {
359
- global $iwp_mmb_core;
360
- $iwp_mmb_core->get_backup_instance($params['mechanism']);
361
- $return = $iwp_mmb_core->backup_instance->trigger_check($params);
362
-
363
- if (is_array($return) && array_key_exists('error', $return))
364
- iwp_mmb_response($return, false);
365
- else {
366
- iwp_mmb_response($return, true);
367
- }
368
- }
369
- }
370
-
371
-
372
- if( !function_exists ( 'iwp_mmb_backup_now' )) {
373
- //backup
374
- function iwp_mmb_backup_now($params)
375
- {
376
- global $iwp_mmb_core;
377
-
378
- $iwp_mmb_core->get_backup_instance();
379
- $return = $iwp_mmb_core->backup_instance->backup($params);
380
-
381
- if (is_array($return) && array_key_exists('error', $return))
382
- iwp_mmb_response($return, false);
383
- else {
384
- iwp_mmb_response($return, true);
385
- }
386
- }
387
- }
388
-
389
- if( !function_exists ( 'iwp_mmb_run_task_now' )) {
390
- function iwp_mmb_run_task_now($params)
391
- {
392
- global $iwp_mmb_core;
393
- $iwp_mmb_core->get_backup_instance($params['mechanism']);
394
- //$return = $iwp_mmb_core->backup_instance->task_now(); //set_backup_task($params)
395
- $return = $iwp_mmb_core->backup_instance->set_backup_task($params);
396
- if (is_array($return) && array_key_exists('error', $return))
397
- iwp_mmb_response($return, false);
398
- else {
399
- iwp_mmb_response($return, true);
400
- }
401
- }
402
- }
403
-
404
- if( !function_exists ( 'iwp_mmb_delete_task_now' )) {
405
- function iwp_mmb_delete_task_now($params)
406
- {
407
- global $iwp_mmb_core;
408
- $iwp_mmb_core->get_backup_instance();
409
- $return = $iwp_mmb_core->backup_instance->delete_task_now($params['task_name']);
410
- if (is_array($return) && array_key_exists('error', $return))
411
- iwp_mmb_response($return, false);
412
- else {
413
- iwp_mmb_response($return, true);
414
- }
415
- }
416
- }
417
- if( !function_exists ( 'iwp_mmb_check_backup_compat' )) {
418
- function iwp_mmb_check_backup_compat($params)
419
- {
420
- global $iwp_mmb_core;
421
- $iwp_mmb_core->get_backup_instance();
422
- $return = $iwp_mmb_core->backup_instance->check_backup_compat($params);
423
-
424
- if (is_array($return) && array_key_exists('error', $return))
425
- iwp_mmb_response($return, false);
426
- else {
427
- iwp_mmb_response($return, true);
428
- }
429
- }
430
- }
431
-
432
- if( !function_exists ( 'iwp_mmb_get_backup_req' )) {
433
- function iwp_mmb_get_backup_req( $params )
434
- {
435
- global $iwp_mmb_core;
436
- $iwp_mmb_core->get_stats_instance();
437
- $return = $iwp_mmb_core->stats_instance->get_backup_req($params);
438
-
439
- if (is_array($return) && array_key_exists('error', $return))
440
- iwp_mmb_response($return, false);
441
- else {
442
- iwp_mmb_response($return, true);
443
- }
444
- }
445
- }
446
-
447
-
448
- if( !function_exists ( 'iwp_mmb_scheduled_backup' )) {
449
- function iwp_mmb_scheduled_backup($params)
450
- {
451
- global $iwp_mmb_core;
452
-
453
- $iwp_mmb_core->get_backup_instance($params['mechanism']);
454
- $return = $iwp_mmb_core->backup_instance->set_backup_task($params);
455
- iwp_mmb_response($return, $return);
456
- }
457
- }
458
-
459
-
460
- if( !function_exists ( 'iwp_mmb_delete_backup' )) {
461
- function iwp_mmb_delete_backup($params)
462
- {
463
- global $iwp_mmb_core;
464
- $iwp_mmb_core->get_backup_instance();
465
- $return = $iwp_mmb_core->backup_instance->delete_backup($params);
466
- iwp_mmb_response($return, $return);
467
- }
468
- }
469
-
470
- if( !function_exists ( 'iwp_mmb_optimize_tables' )) {
471
- function iwp_mmb_optimize_tables($params)
472
- {
473
- global $iwp_mmb_core;
474
- $iwp_mmb_core->get_backup_instance();
475
- $return = $iwp_mmb_core->backup_instance->optimize_tables();
476
- if ($return)
477
- iwp_mmb_response($return, true);
478
- else
479
- iwp_mmb_response(false, false);
480
- }
481
- }
482
- if( !function_exists ( 'iwp_mmb_restore_now' )) {
483
- function iwp_mmb_restore_now($params)
484
- {
485
- global $iwp_mmb_core;
486
- $iwp_mmb_core->get_backup_instance('multiCall');
487
- $return = $iwp_mmb_core->backup_instance->restore($params);
488
-
489
- if (is_array($return) && array_key_exists('error', $return))
490
- iwp_mmb_response($return, false);
491
- else
492
- iwp_mmb_response($return, true);
493
-
494
- }
495
- }
496
-
497
-
498
- if( !function_exists ( 'iwp_mmb_backup_repository' )) {
499
- function iwp_mmb_backup_repository($params)
500
- {
501
- global $iwp_mmb_core;
502
- $iwp_mmb_core->get_backup_repository_instance();
503
- $return = $iwp_mmb_core->backup_repository_instance->backup_repository($params);
504
- if (is_array($return) && array_key_exists('error', $return))
505
- iwp_mmb_response($return, false);
506
- else
507
- iwp_mmb_response($return, true);
508
- }
509
- }
510
-
511
-
512
- if( !function_exists ( 'iwp_mmb_clean_orphan_backups' )) {
513
- function iwp_mmb_clean_orphan_backups()
514
- {
515
- global $iwp_mmb_core;
516
- $backup_instance = $iwp_mmb_core->get_backup_instance();
517
- $return = $iwp_mmb_core->backup_instance->cleanup();
518
- if(is_array($return))
519
- iwp_mmb_response($return, true);
520
- else
521
- iwp_mmb_response($return, false);
522
- }
523
- }
524
-
525
-
526
-
527
- add_filter( 'iwp_website_add', 'iwp_mmb_readd_backup_task' );
528
-
529
- if (!function_exists('iwp_mmb_readd_backup_task')) {
530
- function iwp_mmb_readd_backup_task($params = array()) {
531
- global $iwp_mmb_core;
532
- $backup_instance = $iwp_mmb_core->get_backup_instance();
533
- $settings = $backup_instance->readd_tasks($params);
534
- return $settings;
535
- }
536
- }
537
-
538
- if( !function_exists ( 'iwp_mmb_update_client_plugin' )) {
539
- function iwp_mmb_update_client_plugin($params)
540
- {
541
- global $iwp_mmb_core;
542
- iwp_mmb_response($iwp_mmb_core->update_client_plugin($params), true);
543
- }
544
- }
545
-
546
- if( !function_exists ( 'iwp_mmb_wp_checkversion' )) {
547
- function iwp_mmb_wp_checkversion($params)
548
- {
549
- include_once(ABSPATH . 'wp-includes/version.php');
550
- global $iwp_mmb_wp_version, $iwp_mmb_core;
551
- iwp_mmb_response($iwp_mmb_wp_version, true);
552
- }
553
- }
554
- if( !function_exists ( 'iwp_mmb_search_posts_by_term' )) {
555
- function iwp_mmb_search_posts_by_term($params)
556
- {
557
- global $iwp_mmb_core;
558
- $iwp_mmb_core->get_search_instance();
559
-
560
- $search_type = trim($params['search_type']);
561
- $search_term = strtolower(trim($params['search_term']));
562
-
563
- switch ($search_type){
564
- case 'plugin':
565
- $plugins = get_option('active_plugins');
566
-
567
- $have_plugin = false;
568
- foreach ($plugins as $plugin) {
569
- if(strpos($plugin, $search_term)>-1){
570
- $have_plugin = true;
571
- }
572
- }
573
- if($have_plugin){
574
- iwp_mmb_response(serialize($plugin), true);
575
- }else{
576
- iwp_mmb_response(false, false);
577
- }
578
- break;
579
- case 'theme':
580
- $theme = strtolower(get_option('template'));
581
- if(strpos($theme, $search_term)>-1){
582
- iwp_mmb_response($theme, true);
583
- }else{
584
- iwp_mmb_response(false, false);
585
- }
586
- break;
587
- default: iwp_mmb_response(false, false);
588
- }
589
- $return = $iwp_mmb_core->search_instance->iwp_mmb_search_posts_by_term($params);
590
-
591
-
592
-
593
- if ($return_if_true) {
594
- iwp_mmb_response($return_value, true);
595
- } else {
596
- iwp_mmb_response($return_if_false, false);
597
- }
598
- }
599
- }
600
-
601
- if( !function_exists ( 'iwp_mmb_install_addon' )) {
602
- function iwp_mmb_install_addon($params)
603
- {
604
- global $iwp_mmb_core;
605
- $iwp_mmb_core->get_installer_instance();
606
- $return = $iwp_mmb_core->installer_instance->install_remote_file($params);
607
- iwp_mmb_response($return, true);
608
-
609
- }
610
- }
611
-
612
- if( !function_exists ( 'iwp_mmb_do_upgrade' )) {
613
- function iwp_mmb_do_upgrade($params)
614
- {
615
- global $iwp_mmb_core, $iwp_mmb_upgrading;
616
- $iwp_mmb_core->get_installer_instance();
617
- $return = $iwp_mmb_core->installer_instance->do_upgrade($params);
618
- iwp_mmb_response($return, true);
619
-
620
- }
621
- }
622
-
623
- if( !function_exists ( 'iwp_mmb_add_user' )) {
624
- function iwp_mmb_add_user($params)
625
- {
626
- global $iwp_mmb_core;
627
- $iwp_mmb_core->get_user_instance();
628
- $return = $iwp_mmb_core->user_instance->add_user($params);
629
- if (is_array($return) && array_key_exists('error', $return)){
630
- iwp_mmb_response($return, false);
631
- }
632
- else {
633
- iwp_mmb_response($return, true);
634
- }
635
-
636
- }
637
- }
638
-
639
- if( !function_exists ('iwp_mmb_get_users')) {
640
- function iwp_mmb_get_users($params)
641
- {
642
- global $iwp_mmb_core;
643
- $iwp_mmb_core->get_user_instance();
644
- $return = $iwp_mmb_core->user_instance->get_users($params);
645
- if (is_array($return) && array_key_exists('error', $return))
646
- iwp_mmb_response($return, false);
647
- else {
648
- iwp_mmb_response($return, true);
649
- }
650
- }
651
- }
652
-
653
- if( !function_exists ('iwp_mmb_edit_users')) {
654
- function iwp_mmb_edit_users($params)
655
- {
656
- global $iwp_mmb_core;
657
- $iwp_mmb_core->get_user_instance();
658
- $return = $iwp_mmb_core->user_instance->edit_users($params);
659
- iwp_mmb_response($return, true);
660
- }
661
- }
662
-
663
- if( !function_exists ( 'iwp_mmb_iframe_plugins_fix' )) {
664
- function iwp_mmb_iframe_plugins_fix($update_actions)
665
- {
666
- foreach($update_actions as $key => $action)
667
- {
668
- $update_actions[$key] = str_replace('target="_parent"','',$action);
669
- }
670
-
671
- return $update_actions;
672
-
673
- }
674
- }
675
-
676
- if( !function_exists ( 'iwp_mmb_set_notifications' )) {
677
- function iwp_mmb_set_notifications($params)
678
- {
679
- global $iwp_mmb_core;
680
- $iwp_mmb_core->get_stats_instance();
681
- $return = $iwp_mmb_core->stats_instance->set_notifications($params);
682
- if (is_array($return) && array_key_exists('error', $return))
683
- iwp_mmb_response($return, false);
684
- else {
685
- iwp_mmb_response($return, true);
686
- }
687
-
688
- }
689
- }
690
-
691
- if( !function_exists ( 'iwp_mmb_set_alerts' )) {
692
- function iwp_mmb_set_alerts($params)
693
- {
694
- global $iwp_mmb_core;
695
- $iwp_mmb_core->get_stats_instance();
696
- $return = $iwp_mmb_core->stats_instance->set_alerts($params);
697
- iwp_mmb_response(true, true);
698
- }
699
- }
700
-
701
- /*
702
- if(!function_exists('iwp_mmb_more_reccurences')){
703
- //Backup Tasks
704
- add_filter('cron_schedules', 'iwp_mmb_more_reccurences');
705
- function iwp_mmb_more_reccurences($schedules) {
706
- $schedules['halfminute'] = array('interval' => 30, 'display' => 'Once in a half minute');
707
- $schedules['minutely'] = array('interval' => 60, 'display' => 'Once in a minute');
708
- $schedules['fiveminutes'] = array('interval' => 300, 'display' => 'Once every five minutes');
709
- $schedules['tenminutes'] = array('interval' => 600, 'display' => 'Once every ten minutes');
710
-
711
- return $schedules;
712
- }
713
- }
714
-
715
- add_action('iwp_client_backup_tasks', 'iwp_client_check_backup_tasks');
716
-
717
- if( !function_exists('iwp_client_check_backup_tasks') ){
718
- function iwp_client_check_backup_tasks() {
719
- global $iwp_mmb_core, $_wp_using_ext_object_cache;
720
- $_wp_using_ext_object_cache = false;
721
-
722
- $iwp_mmb_core->get_backup_instance();
723
- $iwp_mmb_core->backup_instance->check_backup_tasks();
724
- }
725
- }
726
- */
727
-
728
- if( !function_exists('iwp_check_notifications') ){
729
- function iwp_check_notifications() {
730
- global $iwp_mmb_core, $_wp_using_ext_object_cache;
731
- $_wp_using_ext_object_cache = false;
732
-
733
- $iwp_mmb_core->get_stats_instance();
734
- $iwp_mmb_core->stats_instance->check_notifications();
735
- }
736
- }
737
-
738
-
739
- if( !function_exists('iwp_mmb_get_plugins_themes') ){
740
- function iwp_mmb_get_plugins_themes($params) {
741
- global $iwp_mmb_core;
742
- $iwp_mmb_core->get_installer_instance();
743
- $return = $iwp_mmb_core->installer_instance->get($params);
744
- iwp_mmb_response($return, true);
745
- }
746
- }
747
-
748
- if( !function_exists('iwp_mmb_edit_plugins_themes') ){
749
- function iwp_mmb_edit_plugins_themes($params) {
750
- global $iwp_mmb_core;
751
- $iwp_mmb_core->get_installer_instance();
752
- $return = $iwp_mmb_core->installer_instance->edit($params);
753
- iwp_mmb_response($return, true);
754
- }
755
- }
756
-
757
- //post
758
- if( !function_exists ( 'iwp_mmb_post_create' )) {
759
- function iwp_mmb_post_create($params)
760
- {
761
- global $iwp_mmb_core;
762
- $iwp_mmb_core->get_post_instance();
763
- $return = $iwp_mmb_core->post_instance->create($params);
764
- if (is_int($return))
765
- iwp_mmb_response($return, true);
766
- else{
767
- if(isset($return['error'])){
768
- iwp_mmb_response($return, false);
769
- } else {
770
- iwp_mmb_response($return, false);
771
- }
772
- }
773
- }
774
- }
775
-
776
- if( !function_exists ( 'iwp_mmb_change_post_status' )) {
777
- function iwp_mmb_change_post_status($params)
778
- {
779
- global $iwp_mmb_core;
780
- $iwp_mmb_core->get_post_instance();
781
- $return = $iwp_mmb_core->post_instance->change_status($params);
782
- //mmb_response($return, true);
783
-
784
- }
785
- }
786
-
787
- if( !function_exists ('iwp_mmb_get_posts')) {
788
- function iwp_mmb_get_posts($params)
789
- {
790
- global $iwp_mmb_core;
791
- $iwp_mmb_core->get_post_instance();
792
-
793
- $return = $iwp_mmb_core->post_instance->get_posts($params);
794
- if (is_array($return) && array_key_exists('error', $return))
795
- iwp_mmb_response($return, false);
796
- else {
797
- iwp_mmb_response($return, true);
798
- }
799
- }
800
- }
801
-
802
- if( !function_exists ('iwp_mmb_delete_post')) {
803
- function iwp_mmb_delete_post($params)
804
- {
805
- global $iwp_mmb_core;
806
- $iwp_mmb_core->get_post_instance();
807
-
808
- $return = $iwp_mmb_core->post_instance->delete_post($params);
809
- if (is_array($return) && array_key_exists('error', $return))
810
- iwp_mmb_response($return, false);
811
- else {
812
- iwp_mmb_response($return, true);
813
- }
814
- }
815
- }
816
-
817
- if( !function_exists ('iwp_mmb_delete_posts')) {
818
- function iwp_mmb_delete_posts($params)
819
- {
820
- global $iwp_mmb_core;
821
- $iwp_mmb_core->get_post_instance();
822
-
823
- $return = $iwp_mmb_core->post_instance->delete_posts($params);
824
- if (is_array($return) && array_key_exists('error', $return))
825
- iwp_mmb_response($return, false);
826
- else {
827
- iwp_mmb_response($return, true);
828
- }
829
- }
830
- }
831
-
832
- if( !function_exists ('iwp_mmb_edit_posts')) {
833
- function iwp_mmb_edit_posts($params)
834
- {
835
- global $iwp_mmb_core;
836
- $iwp_mmb_core->get_posts_instance();
837
- $return = $iwp_mmb_core->posts_instance->edit_posts($params);
838
- iwp_mmb_response($return, true);
839
- }
840
- }
841
-
842
- if( !function_exists ('iwp_mmb_get_pages')) {
843
- function iwp_mmb_get_pages($params)
844
- {
845
- global $iwp_mmb_core;
846
- $iwp_mmb_core->get_post_instance();
847
-
848
- $return = $iwp_mmb_core->post_instance->get_pages($params);
849
- if (is_array($return) && array_key_exists('error', $return))
850
- iwp_mmb_response($return, false);
851
- else {
852
- iwp_mmb_response($return, true);
853
- }
854
- }
855
- }
856
-
857
- if( !function_exists ('iwp_mmb_delete_page')) {
858
- function iwp_mmb_delete_page($params)
859
- {
860
- global $iwp_mmb_core;
861
- $iwp_mmb_core->get_post_instance();
862
-
863
- $return = $iwp_mmb_core->post_instance->delete_page($params);
864
- if (is_array($return) && array_key_exists('error', $return))
865
- iwp_mmb_response($return, false);
866
- else {
867
- iwp_mmb_response($return, true);
868
- }
869
- }
870
- }
871
-
872
-
873
- //links
874
- if( !function_exists ('iwp_mmb_get_links')) {
875
- function iwp_mmb_get_links($params)
876
- {
877
- global $iwp_mmb_core;
878
- $iwp_mmb_core->get_link_instance();
879
- $return = $iwp_mmb_core->link_instance->get_links($params);
880
- if (is_array($return) && array_key_exists('error', $return))
881
- iwp_mmb_response($return, false);
882
- else {
883
- iwp_mmb_response($return, true);
884
- }
885
- }
886
- }
887
-
888
- if( !function_exists ( 'iwp_mmb_add_link' )) {
889
- function iwp_mmb_add_link($params)
890
- {
891
- global $iwp_mmb_core;
892
- $iwp_mmb_core->get_link_instance();
893
- $return = $iwp_mmb_core->link_instance->add_link($params);
894
- if (is_array($return) && array_key_exists('error', $return)){
895
- iwp_mmb_response($return, false);
896
- }
897
- else {
898
- iwp_mmb_response($return, true);
899
- }
900
-
901
- }
902
- }
903
-
904
- if( !function_exists ('iwp_mmb_delete_link')) {
905
- function iwp_mmb_delete_link($params)
906
- {
907
- global $iwp_mmb_core;
908
- $iwp_mmb_core->get_link_instance();
909
-
910
- $return = $iwp_mmb_core->link_instance->delete_link($params);
911
- if (is_array($return) && array_key_exists('error', $return)){
912
- iwp_mmb_response($return, false);
913
- }
914
- else {
915
- iwp_mmb_response($return, true);
916
- }
917
- }
918
- }
919
-
920
- if( !function_exists ('iwp_mmb_delete_links')) {
921
- function iwp_mmb_delete_links($params)
922
- {
923
- global $iwp_mmb_core;
924
- $iwp_mmb_core->get_link_instance();
925
-
926
- $return = $iwp_mmb_core->link_instance->delete_links($params);
927
- if (is_array($return) && array_key_exists('error', $return)){
928
- iwp_mmb_response($return, false);
929
- }
930
- else {
931
- iwp_mmb_response($return, true);
932
- }
933
- }
934
- }
935
-
936
-
937
- //comments
938
- if( !function_exists ( 'iwp_mmb_change_comment_status' )) {
939
- function iwp_mmb_change_comment_status($params)
940
- {
941
- global $iwp_mmb_core;
942
- $iwp_mmb_core->get_comment_instance();
943
- $return = $iwp_mmb_core->comment_instance->change_status($params);
944
- //mmb_response($return, true);
945
- if ($return){
946
- $iwp_mmb_core->get_stats_instance();
947
- iwp_mmb_response($iwp_mmb_core->stats_instance->get_comments_stats($params), true);
948
- }else
949
- iwp_mmb_response(array('error' => 'Comment not updated', 'error_code' => 'comment_not_updated'), false);
950
- }
951
-
952
- }
953
- if( !function_exists ( 'iwp_mmb_comment_stats_get' )) {
954
- function iwp_mmb_comment_stats_get($params)
955
- {
956
- global $iwp_mmb_core;
957
- $iwp_mmb_core->get_stats_instance();
958
- iwp_mmb_response($iwp_mmb_core->stats_instance->get_comments_stats($params), true);
959
- }
960
- }
961
-
962
- if( !function_exists ('iwp_mmb_get_comments')) {
963
- function iwp_mmb_get_comments($params)
964
- {
965
- global $iwp_mmb_core;
966
- $iwp_mmb_core->get_comment_instance();
967
- $return = $iwp_mmb_core->comment_instance->get_comments($params);
968
- if (is_array($return) && array_key_exists('error', $return))
969
- iwp_mmb_response($return, false);
970
- else {
971
- iwp_mmb_response($return, true);
972
- }
973
- }
974
- }
975
-
976
- if( !function_exists ('iwp_mmb_action_comment')) {
977
- function iwp_mmb_action_comment($params)
978
- {
979
- global $iwp_mmb_core;
980
- $iwp_mmb_core->get_comment_instance();
981
-
982
- $return = $iwp_mmb_core->comment_instance->action_comment($params);
983
- if (is_array($return) && array_key_exists('error', $return))
984
- iwp_mmb_response($return, false);
985
- else {
986
- iwp_mmb_response($return, true);
987
- }
988
- }
989
- }
990
-
991
- if( !function_exists ('iwp_mmb_bulk_action_comments')) {
992
- function iwp_mmb_bulk_action_comments($params)
993
- {
994
- global $iwp_mmb_core;
995
- $iwp_mmb_core->get_comment_instance();
996
-
997
- $return = $iwp_mmb_core->comment_instance->bulk_action_comments($params);
998
- if (is_array($return) && array_key_exists('error', $return))
999
- iwp_mmb_response($return, false);
1000
- else {
1001
- iwp_mmb_response($return, true);
1002
- }
1003
- }
1004
- }
1005
-
1006
- if( !function_exists ('iwp_mmb_reply_comment')) {
1007
- function iwp_mmb_reply_comment($params)
1008
- {
1009
- global $iwp_mmb_core;
1010
- $iwp_mmb_core->get_comment_instance();
1011
-
1012
- $return = $iwp_mmb_core->comment_instance->reply_comment($params);
1013
- if (is_array($return) && array_key_exists('error', $return))
1014
- iwp_mmb_response($return, false);
1015
- else {
1016
- iwp_mmb_response($return, true);
1017
- }
1018
- }
1019
- }
1020
-
1021
- //Comments-End-
1022
-
1023
- //WP-Optimize
1024
-
1025
- if( !function_exists('iwp_mmb_wp_optimize')){
1026
- function iwp_mmb_wp_optimize($params){
1027
- global $iwp_mmb_core;
1028
- $iwp_mmb_core->wp_optimize_instance();
1029
-
1030
- $return = $iwp_mmb_core->optimize_instance->cleanup_system($params);
1031
- if (is_array($return) && array_key_exists('error', $return))
1032
- iwp_mmb_response($return, false);
1033
- else {
1034
- iwp_mmb_response($return, true);
1035
- }
1036
- }
1037
- }
1038
-
1039
- //WP-Optimize_end
1040
-
1041
- /*
1042
- *WordFence Addon Start
1043
- */
1044
-
1045
- if( !function_exists('iwp_mmb_wordfence_scan')){
1046
- function iwp_mmb_wordfence_scan($params){
1047
- global $iwp_mmb_core,$iwp_mmb_plugin_dir;
1048
- require_once("$iwp_mmb_plugin_dir/addons/wordfence/wordfence.class.php");
1049
- $iwp_mmb_core->get_wordfence_instance();
1050
-
1051
- $return = $iwp_mmb_core->wordfence_instance->scan($params);
1052
- if (is_array($return) && array_key_exists('error', $return))
1053
- iwp_mmb_response($return, false);
1054
- else {
1055
- iwp_mmb_response($return, true);
1056
- }
1057
- }
1058
- }
1059
-
1060
- if( !function_exists('iwp_mmb_wordfence_load')){
1061
- function iwp_mmb_wordfence_load($params){
1062
- global $iwp_mmb_core,$iwp_mmb_plugin_dir;
1063
- require_once("$iwp_mmb_plugin_dir/addons/wordfence/wordfence.class.php");
1064
- $iwp_mmb_core->get_wordfence_instance();
1065
-
1066
- $return = $iwp_mmb_core->wordfence_instance->load($params);
1067
- if (is_array($return) && array_key_exists('error', $return))
1068
- iwp_mmb_response($return, false);
1069
- else {
1070
- iwp_mmb_response($return, true);
1071
- }
1072
- }
1073
- }
1074
-
1075
- /*
1076
- *WordFence Addon End
1077
- */
1078
-
1079
- //WP-BrokenLinks start
1080
-
1081
- if( !function_exists('iwp_mmb_get_all_links')){
1082
- function iwp_mmb_get_all_links(){
1083
- global $iwp_mmb_core;
1084
- $iwp_mmb_core->wp_blc_get_blinks();
1085
- $return = $iwp_mmb_core->blc_get_blinks->blc_get_all_links($params);
1086
- if (is_array($return) && array_key_exists('error', $return))
1087
- iwp_mmb_response($return, false);
1088
- else {
1089
- iwp_mmb_response($return, true);
1090
- }
1091
- }
1092
- }
1093
-
1094
- if( !function_exists('iwp_mmb_update_broken_link')){
1095
- function iwp_mmb_update_broken_link($params){
1096
- global $iwp_mmb_core;
1097
- $iwp_mmb_core->wp_blc_get_blinks();
1098
- $return = $iwp_mmb_core->blc_get_blinks->blc_update_link($params);
1099
- if (is_array($return) && array_key_exists('error', $return))
1100
- iwp_mmb_response($return, false);
1101
- else {
1102
- iwp_mmb_response($return, true);
1103
- }
1104
- }
1105
- }
1106
-
1107
- if( !function_exists('iwp_mmb_unlink_broken_link')){
1108
- function iwp_mmb_unlink_broken_link($params){
1109
- global $iwp_mmb_core;
1110
- $iwp_mmb_core->wp_blc_get_blinks();
1111
- $return = $iwp_mmb_core->blc_get_blinks->blc_unlink($params);
1112
- if (is_array($return) && array_key_exists('error', $return))
1113
- iwp_mmb_response($return, false);
1114
- else {
1115
- iwp_mmb_response($return, true);
1116
- }
1117
- }
1118
- }
1119
-
1120
- if( !function_exists('iwp_mmb_markasnot_broken_link')){
1121
- function iwp_mmb_markasnot_broken_link($params){
1122
- global $iwp_mmb_core;
1123
- $iwp_mmb_core->wp_blc_get_blinks();
1124
- $return = $iwp_mmb_core->blc_get_blinks->blc_mark_as_not_broken($params);
1125
- if (is_array($return) && array_key_exists('error', $return))
1126
- iwp_mmb_response($return, false);
1127
- else {
1128
- iwp_mmb_response($return, true);
1129
- }
1130
- }
1131
- }
1132
-
1133
- if( !function_exists('iwp_mmb_dismiss_broken_link')){
1134
- function iwp_mmb_dismiss_broken_link($params){
1135
- global $iwp_mmb_core;
1136
- $iwp_mmb_core->wp_blc_get_blinks();
1137
- $return = $iwp_mmb_core->blc_get_blinks->blc_dismiss_link($params);
1138
- if (is_array($return) && array_key_exists('error', $return))
1139
- iwp_mmb_response($return, false);
1140
- else {
1141
- iwp_mmb_response($return, true);
1142
- }
1143
- }
1144
- }
1145
-
1146
- if( !function_exists('iwp_mmb_undismiss_broken_link')){
1147
- function iwp_mmb_undismiss_broken_link($params){
1148
- global $iwp_mmb_core;
1149
- $iwp_mmb_core->wp_blc_get_blinks();
1150
- $return = $iwp_mmb_core->blc_get_blinks->blc_undismiss_link($params);
1151
- if (is_array($return) && array_key_exists('error', $return))
1152
- iwp_mmb_response($return, false);
1153
- else {
1154
- iwp_mmb_response($return, true);
1155
- }
1156
- }
1157
- }
1158
-
1159
- if( !function_exists('iwp_mmb_bulk_actions_processor')){
1160
- function iwp_mmb_bulk_actions_processor($params){
1161
- global $iwp_mmb_core;
1162
- $iwp_mmb_core->wp_blc_get_blinks();
1163
- $return = $iwp_mmb_core->blc_get_blinks->blc_bulk_actions($params);
1164
- if (is_array($return) && array_key_exists('error', $return))
1165
- iwp_mmb_response($return, false);
1166
- else {
1167
- iwp_mmb_response($return, true);
1168
- }
1169
- }
1170
- }
1171
-
1172
- //WP-BrokenLinks end
1173
-
1174
- //WP-GWMTools start
1175
-
1176
- if( !function_exists('iwp_mmb_gwmt_redirect_url')){
1177
- function iwp_mmb_gwmt_redirect_url($params){
1178
- global $iwp_mmb_core;
1179
- $iwp_mmb_core->wp_google_webmasters_crawls();
1180
- $return = $iwp_mmb_core->get_google_webmasters_crawls->google_webmasters_redirect($params);
1181
- if (is_array($return) && array_key_exists('error', $return))
1182
- iwp_mmb_response($return, false);
1183
- else {
1184
- iwp_mmb_response($return, true);
1185
- }
1186
- }
1187
- }
1188
-
1189
- if( !function_exists('iwp_mmb_gwmt_redirect_url_again')){
1190
- function iwp_mmb_gwmt_redirect_url_again($params){
1191
- global $iwp_mmb_core;
1192
- $iwp_mmb_core->wp_google_webmasters_crawls();
1193
- $return = $iwp_mmb_core->get_google_webmasters_crawls->google_webmasters_redirect_again($params);
1194
- if (is_array($return) && array_key_exists('error', $return))
1195
- iwp_mmb_response($return, false);
1196
- else {
1197
- iwp_mmb_response($return, true);
1198
- }
1199
- }
1200
- }
1201
-
1202
-
1203
- //WP-GWMTools end
1204
-
1205
- //fileEditor start
1206
-
1207
- if( !function_exists('iwp_mmb_file_editor_upload')){
1208
- function iwp_mmb_file_editor_upload($params){
1209
- global $iwp_mmb_core;
1210
- $iwp_mmb_core->wp_get_file_editor();
1211
- $return = $iwp_mmb_core->get_file_editor->file_editor_upload($params);
1212
- if (is_array($return) && array_key_exists('error', $return))
1213
- iwp_mmb_response($return, false);
1214
- else {
1215
- iwp_mmb_response($return, true);
1216
- }
1217
- }
1218
- }
1219
-
1220
-
1221
- //fileEditor end
1222
-
1223
- if( !function_exists('iwp_mmb_maintenance_mode')){
1224
- function iwp_mmb_maintenance_mode( $params ) {
1225
- global $wp_object_cache;
1226
-
1227
- $default = get_option('iwp_client_maintenace_mode');
1228
- $params = empty($default) ? $params : array_merge($default, $params);
1229
- update_option("iwp_client_maintenace_mode", $params);
1230
-
1231
- if(!empty($wp_object_cache))
1232
- @$wp_object_cache->flush();
1233
- iwp_mmb_response(true, true);
1234
- }
1235
- }
1236
-
1237
- if( !function_exists('iwp_mmb_plugin_actions') ){
1238
- function iwp_mmb_plugin_actions() {
1239
- global $iwp_mmb_actions, $iwp_mmb_core;
1240
-
1241
- if(!empty($iwp_mmb_actions)){
1242
- global $_iwp_mmb_plugin_actions;
1243
- if(!empty($_iwp_mmb_plugin_actions)){
1244
- $failed = array();
1245
- foreach($_iwp_mmb_plugin_actions as $action => $params){
1246
- if(isset($iwp_mmb_actions[$action]))
1247
- call_user_func($iwp_mmb_actions[$action], $params);
1248
- else
1249
- $failed[] = $action;
1250
- }
1251
- if(!empty($failed)){
1252
- $f = implode(', ', $failed);
1253
- $s = count($f) > 1 ? 'Actions "' . $f . '" do' : 'Action "' . $f . '" does';
1254
- iwp_mmb_response(array('error' => $s.' not exist. Please update your IWP Client plugin.', 'error_code' => 'update_your_client_plugin'), false);
1255
- }
1256
-
1257
- }
1258
- }
1259
-
1260
- global $pagenow, $current_user, $mmode;
1261
- if( !is_admin() && !in_array($pagenow, array( 'wp-login.php' ))){
1262
- $mmode = get_option('iwp_client_maintenace_mode');
1263
- if( !empty($mmode) ){
1264
- if(isset($mmode['active']) && $mmode['active'] == true){
1265
- if(isset($current_user->data) && !empty($current_user->data) && isset($mmode['hidecaps']) && !empty($mmode['hidecaps'])){
1266
- $usercaps = array();
1267
- if(isset($current_user->caps) && !empty($current_user->caps)){
1268
- $usercaps = $current_user->caps;
1269
- }
1270
- foreach($mmode['hidecaps'] as $cap => $hide){
1271
- if(!$hide)
1272
- continue;
1273
-
1274
- foreach($usercaps as $ucap => $val){
1275
- if($ucap == $cap){
1276
- ob_end_clean();
1277
- ob_end_flush();
1278
- die($mmode['template']);
1279
- }
1280
- }
1281
- }
1282
- } else
1283
- die($mmode['template']);
1284
- }
1285
- }
1286
- }
1287
- }
1288
- }
1289
-
1290
- if( !function_exists ( 'iwp_mmb_execute_php_code' )) {
1291
- function iwp_mmb_execute_php_code($params)
1292
- {
1293
- ob_start();
1294
- eval($params['code']);
1295
- $return = ob_get_flush();
1296
- iwp_mmb_response(print_r($return, true), true);
1297
- }
1298
- }
1299
-
1300
- if( !function_exists('iwp_mmb_client_brand')){
1301
- function iwp_mmb_client_brand($params) {
1302
- update_option("iwp_client_brand",$params['brand']);
1303
- iwp_mmb_response(true, true);
1304
- }
1305
- }
1306
-
1307
-
1308
- if(!function_exists('checkOpenSSL')){
1309
- function checkOpenSSL(){
1310
- if(!function_exists('openssl_verify')){
1311
- return false;
1312
- }
1313
- else{
1314
- $key = @openssl_pkey_new();
1315
- @openssl_pkey_export($key, $privateKey);
1316
- $privateKey = base64_encode($privateKey);
1317
- $publicKey = @openssl_pkey_get_details($key);
1318
- $publicKey = $publicKey["key"];
1319
-
1320
- if(empty($publicKey) || empty($privateKey)){
1321
- return false;
1322
- }
1323
- }
1324
- return true;
1325
- }
1326
- }
1327
-
1328
-
1329
- if(!function_exists('iwp_mmb_shutdown')){
1330
- function iwp_mmb_shutdown(){
1331
- $isError = false;
1332
-
1333
- if ($error = error_get_last()){
1334
- switch($error['type']){
1335
- /*case E_PARSE:*/
1336
- case E_ERROR:
1337
- case E_CORE_ERROR:
1338
- case E_COMPILE_ERROR:
1339
- case E_USER_ERROR:
1340
- $isError = true;
1341
- break;
1342
- }
1343
- }
1344
- if ($isError){
1345
-
1346
- $response = '<span style="font-weight:700;">PHP Fatal error occured:</span> '.$error['message'].' in '.$error['file'].' on line '.$error['line'].'.';
1347
- if(stripos($error['message'], 'allowed memory size') !== false){
1348
- $response .= '<br>Try <a href="http://infinitewp.com/knowledge-base/increase-memory-limit/?utm_source=application&utm_medium=userapp&utm_campaign=kb" target="_blank">increasing the PHP memory limit</a> for this WP site.';
1349
- }
1350
- if(!$GLOBALS['IWP_RESPONSE_SENT']){
1351
- iwp_mmb_response(array('error' => $response, 'error_code' => 'iwp_mmb_shutdown'), false);
1352
- }
1353
-
1354
- }
1355
- }
1356
- }
1357
-
1358
-
1359
- if(!function_exists('iwp_mmb_print_flush')){
1360
- function iwp_mmb_print_flush($print_string){// this will help responding web server, will keep alive the script execution
1361
-
1362
- echo $print_string." ||| ";
1363
- echo "TT:".(microtime(1) - $GLOBALS['IWP_MMB_PROFILING']['ACTION_START'])."\n";
1364
- ob_flush();
1365
- flush();
1366
- }
1367
- }
1368
-
1369
- if(!function_exists('iwp_mmb_auto_print')){
1370
- function iwp_mmb_auto_print($unique_task){// this will help responding web server, will keep alive the script execution
1371
- $print_every_x_secs = 5;
1372
-
1373
- $current_time = microtime(1);
1374
- if(!$GLOBALS['IWP_MMB_PROFILING']['TASKS'][$unique_task]['START']){
1375
- $GLOBALS['IWP_MMB_PROFILING']['TASKS'][$unique_task]['START'] = $current_time;
1376
- }
1377
-
1378
- if(!$GLOBALS['IWP_MMB_PROFILING']['LAST_PRINT'] || ($current_time - $GLOBALS['IWP_MMB_PROFILING']['LAST_PRINT']) > $print_every_x_secs){
1379
-
1380
- //$print_string = "TT:".($current_time - $GLOBALS['IWP_MMB_PROFILING']['ACTION_START'])."\n";
1381
- $print_string = $unique_task." TT:".($current_time - $GLOBALS['IWP_MMB_PROFILING']['TASKS'][$unique_task]['START']);
1382
- iwp_mmb_print_flush($print_string);
1383
- $GLOBALS['IWP_MMB_PROFILING']['LAST_PRINT'] = $current_time;
1384
- }
1385
- }
1386
- }
1387
-
1388
- if(!function_exists('iwp_mmb_check_redirects')){
1389
- function iwp_mmb_check_redirects(){
1390
- global $wpdb;
1391
- $current_url = ($_SERVER['SERVER_PORT']=='443'?'https://':'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
1392
- $current_url = rtrim($current_url,'/');
1393
- $table_name = $wpdb->base_prefix."iwp_redirects";
1394
- if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name) {
1395
- $success = $wpdb -> get_col($wpdb->prepare("SELECT redirectLink FROM ".$wpdb->base_prefix."iwp_redirects WHERE oldLink = %s LIMIT 1",$current_url));
1396
- if(count($success)){
1397
- if(function_exists(wp_redirect)){
1398
- wp_redirect($success[0]);
1399
- }
1400
- }
1401
- }
1402
- }
1403
- }
1404
-
1405
- if(!function_exists('iwp_mmb_convert_data')){
1406
- function iwp_mmb_convert_data(){
1407
-
1408
- //Schedule backup key need to save .
1409
- global $wpdb;
1410
-
1411
- $client_backup_tasks = get_option('iwp_client_backup_tasks');
1412
-
1413
- $type = $action = $category = '';
1414
-
1415
- if(!empty($client_backup_tasks) && is_array($client_backup_tasks)){
1416
- foreach($client_backup_tasks as $key){
1417
- if(!is_array($key) || !is_array($key['task_args'])){
1418
- continue;
1419
- }
1420
- $task_name = $key['task_args']['task_name'];
1421
-
1422
- if($task_name == 'Backup Now'){
1423
- $type = 'backup';
1424
- $action = 'now';
1425
- $category = $key['task_args']['what'];
1426
- }
1427
- else{
1428
- $type = 'scheduleBackup';
1429
- $action = 'runTask';
1430
- $category = $key['task_args']['what'];
1431
- }
1432
- if(is_array($key['task_results'])){
1433
- $taskResultData = array();
1434
- foreach($key['task_results'] as $keys => $task_results){
1435
-
1436
- $historyID = $task_results['backhack_status']['adminHistoryID'];
1437
-
1438
- $taskResultData = array('task_results' => array($historyID => $task_results));
1439
- $taskResultData['task_results'][$historyID]['adminHistoryID'] = $historyID;
1440
-
1441
- $insert = $wpdb->insert($wpdb->base_prefix.'iwp_backup_status',array( 'stage' => 'finished', 'status' => 'completed', 'action' => $action, 'type' => $type,'category' => $category ,'historyID' => $task_results['backhack_status']['adminHistoryID'],'finalStatus' => 'completed','startTime' => $task_results['time'],'endTime' => $task_results['time'],'statusMsg' => $statusArray['statusMsg'],'requestParams' => serialize($key),'taskName' => $task_name, 'responseParams' => '', 'taskResults' => serialize($taskResultData)), array( '%s', '%s','%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%s', '%s', '%s', '%s', '%s') );
1442
-
1443
- }
1444
- }
1445
- }
1446
- }
1447
- }
1448
- }
1449
-
1450
-
1451
-
1452
- if(!function_exists('iwp_mmb_create_backup_table')){
1453
- function iwp_mmb_create_backup_table(){
1454
- global $wpdb;
1455
-
1456
- $IWP_MMB_BACKUP_TABLE_VERSION = get_site_option( 'iwp_backup_table_version' );
1457
- $table_name = $wpdb->base_prefix . "iwp_backup_status";
1458
-
1459
- if(version_compare($IWP_MMB_BACKUP_TABLE_VERSION, '1.1') == -1){
1460
- if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
1461
-
1462
- $sql = "
1463
- CREATE TABLE IF NOT EXISTS $table_name (
1464
- `ID` int(11) NOT NULL AUTO_INCREMENT,
1465
- `historyID` int(11) NOT NULL,
1466
- `taskName` varchar(255) NOT NULL,
1467
- `action` varchar(50) NOT NULL,
1468
- `type` varchar(50) NOT NULL,
1469
- `category` varchar(50) NOT NULL,
1470
- `stage` varchar(255) NOT NULL,
1471
- `status` varchar(255) NOT NULL,
1472
- `finalStatus` varchar(50) DEFAULT NULL,
1473
- `statusMsg` varchar(255) NOT NULL,
1474
- `requestParams` text NOT NULL,
1475
- `responseParams` longtext,
1476
- `taskResults` text,
1477
- `startTime` int(11) DEFAULT NULL,
1478
- `endTime` int(11) NOT NULL,
1479
- PRIMARY KEY (`ID`)
1480
- ) ENGINE=InnoDB;
1481
- ";
1482
-
1483
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
1484
- dbDelta( $sql );
1485
-
1486
- if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
1487
- //echo "table creation failed";
1488
- $table_created = false;
1489
- }
1490
- else{
1491
-
1492
- iwp_mmb_convert_data();
1493
- $_NEW_IWP_MMB_BACKUP_TABLE_VERSION = '1.1';
1494
- }
1495
-
1496
- }else{
1497
- $table_created = true;
1498
- $_NEW_IWP_MMB_BACKUP_TABLE_VERSION = '1.1';
1499
- }
1500
- }
1501
-
1502
- if(!empty($_NEW_IWP_MMB_BACKUP_TABLE_VERSION)){
1503
- add_option( "iwp_backup_table_version", $_NEW_IWP_MMB_BACKUP_TABLE_VERSION);
1504
- }
1505
- }
1506
- }
1507
-
1508
- //-------------------------------------------------------------------
1509
-
1510
- //-Function name - iwp_mmb_get_file_size()
1511
- //-This is the alternate function to calculate file size
1512
- //-This function is introduced to support the filesize calculation for the files which are larger than 2048MB
1513
-
1514
- //----------------------------------------------------------------------
1515
-
1516
- if(!function_exists('iwp_mmb_get_file_size')){
1517
- function iwp_mmb_get_file_size($file)
1518
- {
1519
- clearstatcache();
1520
- $normal_file_size = filesize($file);
1521
- if(($normal_file_size !== false)&&($normal_file_size >= 0))
1522
- {
1523
- return $normal_file_size;
1524
- }
1525
- else
1526
- {
1527
- $file = realPath($file);
1528
- if(!$file)
1529
- {
1530
- echo 'iwp_mmb_get_file_size_error : realPath error';
1531
- }
1532
- $ch = curl_init("file://" . $file);
1533
- curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_FILE);
1534
- curl_setopt($ch, CURLOPT_NOBODY, true);
1535
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1536
- curl_setopt($ch, CURLOPT_HEADER, true);
1537
- $data = curl_exec($ch);
1538
- $curl_error = curl_error($ch);
1539
- curl_close($ch);
1540
- if ($data !== false && preg_match('/Content-Length: (\d+)/', $data, $matches)) {
1541
- return (string) $matches[1];
1542
- }
1543
- else
1544
- {
1545
- echo 'iwp_mmb_get_file_size_error : '.$curl_error;
1546
- return $normal_file_size;
1547
- }
1548
- }
1549
- }
1550
- }
1551
-
1552
- //add_action( 'plugins_loaded', 'iwp_mmb_create_backup_table' );
1553
-
1554
- //register_activation_hook( __FILE__, 'iwp_mmb_create_backup_table' );
1555
-
1556
- $iwp_mmb_core = new IWP_MMB_Core();
1557
- $mmb_core = 1;
1558
-
1559
- if(isset($_GET['auto_login']))
1560
- $iwp_mmb_core->automatic_login();
1561
-
1562
- if (function_exists('register_activation_hook'))
1563
- register_activation_hook( __FILE__ , array( $iwp_mmb_core, 'install' ));
1564
-
1565
- if (function_exists('register_deactivation_hook'))
1566
- register_deactivation_hook(__FILE__, array( $iwp_mmb_core, 'uninstall' ));
1567
-
1568
- if (function_exists('add_action'))
1569
- add_action('init', 'iwp_mmb_plugin_actions', 99999);
1570
-
1571
- if (function_exists('add_action'))
1572
- add_action('wp_head', 'iwp_mmb_check_redirects', 99999);
1573
-
1574
- if (function_exists('add_filter'))
1575
- add_filter('install_plugin_complete_actions','iwp_mmb_iframe_plugins_fix');
1576
-
1577
- if( isset($_COOKIE[IWP_MMB_XFRAME_COOKIE]) ){
1578
- remove_action( 'admin_init', 'send_frame_options_header');
1579
- remove_action( 'login_init', 'send_frame_options_header');
1580
- }
1581
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1582
  ?>
1
+ <?php
2
+ /*
3
+ Plugin Name: InfiniteWP - Client
4
+ Plugin URI: http://infinitewp.com/
5
+ Description: This is the client plugin of InfiniteWP that communicates with the InfiniteWP Admin panel.
6
+ Author: Revmakx
7
+ Version: 1.3.4
8
+ Author URI: http://www.revmakx.com
9
+ */
10
+ /************************************************************
11
+ * This plugin was modified by Revmakx *
12
+ * Copyright (c) 2012 Revmakx *
13
+ * www.revmakx.com *
14
+ * *
15
+ ************************************************************/
16
+
17
+ /*************************************************************
18
+ *
19
+ * init.php
20
+ *
21
+ * Initialize the communication with master
22
+ *
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.3.4');
30
+
31
+
32
+
33
+ if ( !defined('IWP_MMB_XFRAME_COOKIE')){
34
+ $siteurl = function_exists('get_site_option') ? get_site_option( 'siteurl' ) : get_option('siteurl');
35
+ define('IWP_MMB_XFRAME_COOKIE', $xframe = 'wordpress_'.md5($siteurl).'_xframe');
36
+ }
37
+ global $wpdb, $iwp_mmb_plugin_dir, $iwp_mmb_plugin_url, $wp_version, $iwp_mmb_filters, $_iwp_mmb_item_filter;
38
+ if (version_compare(PHP_VERSION, '5.0.0', '<')) // min version 5 supported
39
+ exit("<p>InfiniteWP Client plugin requires PHP 5 or higher.</p>");
40
+
41
+
42
+ $iwp_mmb_wp_version = $wp_version;
43
+ $iwp_mmb_plugin_dir = WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__));
44
+ $iwp_mmb_plugin_url = WP_PLUGIN_URL . '/' . basename(dirname(__FILE__));
45
+
46
+ require_once("$iwp_mmb_plugin_dir/helper.class.php");
47
+ require_once("$iwp_mmb_plugin_dir/core.class.php");
48
+ require_once("$iwp_mmb_plugin_dir/stats.class.php");
49
+ //require_once("$iwp_mmb_plugin_dir/backup.class.php");
50
+ require_once("$iwp_mmb_plugin_dir/backup.class.singlecall.php");
51
+ require_once("$iwp_mmb_plugin_dir/backup.class.multicall.php");
52
+ require_once("$iwp_mmb_plugin_dir/installer.class.php");
53
+
54
+ require_once("$iwp_mmb_plugin_dir/addons/manage_users/user.class.php");
55
+ require_once("$iwp_mmb_plugin_dir/addons/backup_repository/backup_repository.class.php");
56
+ require_once("$iwp_mmb_plugin_dir/addons/comments/comments.class.php");
57
+
58
+ require_once("$iwp_mmb_plugin_dir/addons/post_links/link.class.php");
59
+ require_once("$iwp_mmb_plugin_dir/addons/post_links/post.class.php");
60
+
61
+ require_once("$iwp_mmb_plugin_dir/addons/wp_optimize/optimize.class.php");
62
+
63
+ require_once("$iwp_mmb_plugin_dir/api.php");
64
+ require_once("$iwp_mmb_plugin_dir/plugins/search/search.php");
65
+ require_once("$iwp_mmb_plugin_dir/plugins/cleanup/cleanup.php");
66
+
67
+
68
+
69
+ if( !function_exists ( 'iwp_mmb_filter_params' )) {
70
+ function iwp_mmb_filter_params( $array = array() ){
71
+
72
+ $filter = array( 'current_user', 'wpdb' );
73
+ $return = array();
74
+ foreach ($array as $key => $val) {
75
+ if( !is_int($key) && in_array($key, $filter) )
76
+ continue;
77
+
78
+ if( is_array( $val ) ) {
79
+ $return[$key] = iwp_mmb_filter_params( $val );
80
+ } else {
81
+ $return[$key] = $val;
82
+ }
83
+ }
84
+
85
+ return $return;
86
+ }
87
+ }
88
+
89
+ if( !function_exists ('iwp_mmb_parse_request')) {
90
+ function iwp_mmb_parse_request()
91
+ {
92
+ if (!isset($HTTP_RAW_POST_DATA)) {
93
+ $HTTP_RAW_POST_DATA = file_get_contents('php://input');
94
+ }
95
+
96
+ ob_start();
97
+
98
+ global $current_user, $iwp_mmb_core, $new_actions, $wp_db_version, $wpmu_version, $_wp_using_ext_object_cache;
99
+ $data = base64_decode($HTTP_RAW_POST_DATA);
100
+ if ($data){
101
+ //$num = @extract(unserialize($data));
102
+ $unserialized_data = @unserialize($data);
103
+ if(isset($unserialized_data['params'])){
104
+ $unserialized_data['params'] = iwp_mmb_filter_params($unserialized_data['params']);
105
+ }
106
+
107
+ $iwp_action = $unserialized_data['iwp_action'];
108
+ $params = $unserialized_data['params'];
109
+ $id = $unserialized_data['id'];
110
+ $signature = $unserialized_data['signature'];
111
+ }
112
+
113
+ if (isset($iwp_action)) {
114
+
115
+ if(!defined('IWP_AUTHORISED_CALL')) define('IWP_AUTHORISED_CALL', 1);
116
+ if(function_exists('register_shutdown_function')){ register_shutdown_function("iwp_mmb_shutdown"); }
117
+ $GLOBALS['IWP_MMB_PROFILING']['ACTION_START'] = microtime(1);
118
+
119
+ error_reporting(E_ALL ^ E_NOTICE);
120
+ @ini_set("display_errors", 1);
121
+
122
+ iwp_mmb_create_backup_table();
123
+
124
+ $action = $iwp_action;
125
+ $_wp_using_ext_object_cache = false;
126
+ @set_time_limit(600);
127
+
128
+ if (!$iwp_mmb_core->check_if_user_exists($params['username']))
129
+ iwp_mmb_response(array('error' => 'Username <b>' . $params['username'] . '</b> does not have administrative access. Enter the correct username in the site options.', 'error_code' => 'username_does_not_have_administrative_access'), false);
130
+
131
+ if ($action == 'add_site') {
132
+ iwp_mmb_add_site($params);
133
+ iwp_mmb_response(array('error' => 'You should never see this.', 'error_code' => 'you_should_never_see_this'), false);
134
+ }
135
+ if ($action == 'readd_site') {
136
+ $params['id'] = $id;
137
+ $params['signature'] = $signature;
138
+ iwp_mmb_readd_site($params);
139
+ iwp_mmb_response(array('error' => 'You should never see this.', 'error_code' => 'you_should_never_see_this'), false);
140
+ }
141
+ if ($action == 'maintain_site') {
142
+ iwp_mmb_maintain_site($params);
143
+ iwp_mmb_response(array('error' => 'You should never see this.', 'error_code' => 'you_should_never_see_this'), false);
144
+ }
145
+
146
+ $auth = $iwp_mmb_core->authenticate_message($action . $id, $signature, $id);
147
+ if ($auth === true) {
148
+ @ignore_user_abort(true);
149
+ $GLOBALS['IWP_CLIENT_HISTORY_ID'] = $id;
150
+
151
+ if(isset($params['username']) && !is_user_logged_in()){
152
+ $user = function_exists('get_user_by') ? get_user_by('login', $params['username']) : get_userdatabylogin( $params['username'] );
153
+ wp_set_current_user($user->ID);
154
+ //For WPE
155
+ if(@getenv('IS_WPE'))
156
+ wp_set_auth_cookie($user->ID);
157
+ }
158
+
159
+ /* in case database upgrade required, do database backup and perform upgrade ( wordpress wp_upgrade() function ) */
160
+ if( strlen(trim($wp_db_version)) && !defined('ACX_PLUGIN_DIR') ){
161
+ if ( get_option('db_version') != $wp_db_version ) {
162
+ /* in multisite network, please update database manualy */
163
+ if (empty($wpmu_version) || (function_exists('is_multisite') && !is_multisite())){
164
+ if( ! function_exists('wp_upgrade'))
165
+ include_once(ABSPATH.'wp-admin/includes/upgrade.php');
166
+
167
+ ob_clean();
168
+ @wp_upgrade();
169
+ @do_action('after_db_upgrade');
170
+ ob_end_clean();
171
+ }
172
+ }
173
+ }
174
+
175
+ if(isset($params['secure'])){
176
+
177
+ if($decrypted = $iwp_mmb_core->_secure_data($params['secure'])){
178
+ $decrypted = maybe_unserialize($decrypted);
179
+ if(is_array($decrypted)){
180
+
181
+ foreach($decrypted as $key => $val){
182
+ if(!is_numeric($key))
183
+ $params[$key] = $val;
184
+
185
+ }
186
+ unset($params['secure']);
187
+ } else $params['secure'] = $decrypted;
188
+ }
189
+ elseif(isset($params['secure']['account_info'])){
190
+ $params['account_info'] = $params['secure']['account_info'];
191
+ }
192
+ }
193
+
194
+ if( !$iwp_mmb_core->register_action_params( $action, $params ) ){
195
+ global $_iwp_mmb_plugin_actions;
196
+ $_iwp_mmb_plugin_actions[$action] = $params;
197
+ }
198
+
199
+ } else {
200
+ iwp_mmb_response($auth, false);
201
+ }
202
+ } else {
203
+ //IWP_MMB_Stats::set_hit_count();
204
+ }
205
+ ob_end_clean();
206
+ }
207
+ }
208
+ /* Main response function */
209
+ if( !function_exists ( 'iwp_mmb_response' )) {
210
+
211
+ function iwp_mmb_response($response = false, $success = true)
212
+ {
213
+ $return = array();
214
+
215
+ if ((is_array($response) && empty($response)) || (!is_array($response) && strlen($response) == 0)){
216
+ $return['error'] = 'Empty response.';
217
+ $return['error_code'] = 'empty_response';
218
+ }
219
+ else if ($success){
220
+ $return['success'] = $response;
221
+ }
222
+ else{
223
+ $return['error'] = $response['error'];
224
+ $return['error_code'] = $response['error_code'];
225
+ }
226
+
227
+ if( !headers_sent() ){
228
+ header('HTTP/1.0 200 OK');
229
+ header('Content-Type: text/plain');
230
+ }
231
+ $GLOBALS['IWP_RESPONSE_SENT'] = true;
232
+ exit("<IWPHEADER>" . base64_encode(serialize($return))."<ENDIWPHEADER>");
233
+ }
234
+ }
235
+
236
+
237
+
238
+ if( !function_exists ( 'iwp_mmb_add_site' )) {
239
+ function iwp_mmb_add_site($params)
240
+ {
241
+ global $iwp_mmb_core;
242
+ $num = extract($params);
243
+
244
+ if ($num) {
245
+ if (!get_option('iwp_client_action_message_id') && !get_option('iwp_client_public_key')) {
246
+ $public_key = base64_decode($public_key);
247
+
248
+
249
+ if(trim($activation_key) != get_option('iwp_client_activate_key')){ //iwp
250
+ iwp_mmb_response(array('error' => 'Invalid activation key', 'error_code' => 'iwp_mmb_add_site_invalid_activation_key'), false);
251
+ return;
252
+ }
253
+
254
+ if (checkOpenSSL() && !$user_random_key_signing) {
255
+ $verify = openssl_verify($action . $id, base64_decode($signature), $public_key);
256
+ if ($verify == 1) {
257
+ $iwp_mmb_core->set_admin_panel_public_key($public_key);
258
+ $iwp_mmb_core->set_client_message_id($id);
259
+ $iwp_mmb_core->get_stats_instance();
260
+ if(isset($notifications) && is_array($notifications) && !empty($notifications)){
261
+ $iwp_mmb_core->stats_instance->set_notifications($notifications);
262
+ }
263
+ if(isset($brand) && is_array($brand) && !empty($brand)){
264
+ update_option('iwp_client_brand',$brand);
265
+ }
266
+
267
+ iwp_mmb_response($iwp_mmb_core->stats_instance->get_initial_stats(), true);
268
+ delete_option('iwp_client_activate_key');//iwp
269
+ } else if ($verify == 0) {
270
+ iwp_mmb_response(array('error' => 'Invalid message signature. Please contact us if you see this message often.', 'error_code' => 'iwp_mmb_add_site_invalid_message_signature'), false);
271
+ } else {
272
+ iwp_mmb_response(array('error' => 'Command not successful. Please try again.', 'error_code' => 'iwp_mmb_add_site_command_not_successful'), false);
273
+ }
274
+ } else {
275
+ if (!get_option('iwp_client_nossl_key')) {
276
+ srand();
277
+
278
+ $random_key = md5(base64_encode($public_key) . rand(0, getrandmax()));
279
+
280
+ $iwp_mmb_core->set_random_signature($random_key);
281
+ $iwp_mmb_core->set_client_message_id($id);
282
+ $iwp_mmb_core->set_admin_panel_public_key($public_key);
283
+ $iwp_mmb_core->get_stats_instance();
284
+ if(is_array($notifications) && !empty($notifications)){
285
+ $iwp_mmb_core->stats_instance->set_notifications($notifications);
286
+ }
287
+
288
+ if(is_array($brand) && !empty($brand)){
289
+ update_option('iwp_client_brand',$brand);
290
+ }
291
+
292
+ iwp_mmb_response($iwp_mmb_core->stats_instance->get_initial_stats(), true);
293
+ delete_option('iwp_client_activate_key');//IWP
294
+ } else
295
+ iwp_mmb_response(array('error' => 'Please deactivate & activate InfiniteWP Client plugin on your site, then add the site again.', 'error_code' => 'deactivate_ctivate_InfiniteWP_Client_plugin_add_site_again_not_iwp_client_nossl_key'), false);
296
+ }
297
+ } else {
298
+ iwp_mmb_response(array('error' => 'Please deactivate &amp; activate InfiniteWP Client plugin on your site, then add the site again.', 'error_code' => 'deactivate_ctivate_InfiniteWP_Client_plugin_add_site_again_not_iwp_client_nossl_key'), false);
299
+ }
300
+ } else {
301
+ iwp_mmb_response(array('error' => 'Invalid parameters received. Please try again.', 'error_code' => 'iwp_mmb_add_site_invalid_parameters_received'), false);
302
+ }
303
+ }
304
+ }
305
+
306
+ if( !function_exists ( 'iwp_mmb_readd_site' )) {
307
+ function iwp_mmb_readd_site($params){
308
+ global $iwp_mmb_core;
309
+ $num = extract($params);
310
+ if ($num) {
311
+ if (!get_option('iwp_client_action_message_id') && !get_option('iwp_client_public_key')) {
312
+ $public_key = base64_decode($public_key);
313
+ if(trim($activation_key) != get_option('iwp_client_activate_key')){ //iwp
314
+ iwp_mmb_response(array('error' => 'Invalid activation key', 'error_code' => 'iwp_mmb_readd_site_invalid_activation_key'), false);
315
+ return;
316
+ }
317
+ if (checkOpenSSL() && !$user_random_key_signing) {
318
+
319
+ $verify = openssl_verify($action . $id, $signature, $public_key);
320
+ if ($verify == 1) {
321
+ $iwp_mmb_core->set_admin_panel_public_key($public_key);
322
+ $iwp_mmb_core->set_client_message_id($id);
323
+ $iwp_mmb_core->get_stats_instance();
324
+ if(isset($notifications) && is_array($notifications) && !empty($notifications)){
325
+ $iwp_mmb_core->stats_instance->set_notifications($notifications);
326
+ }
327
+ if(isset($brand) && is_array($brand) && !empty($brand)){
328
+ update_option('iwp_client_brand',$brand);
329
+ }
330
+ iwp_mmb_response($iwp_mmb_core->stats_instance->get_initial_stats(), true);
331
+ delete_option('iwp_client_activate_key');//iwp
332
+ } else if ($verify == 0) {
333
+ iwp_mmb_response(array('error' => 'Invalid message signature. Please contact us if you see this message often.', 'error_code' => 'iwp_mmb_readd_site_invalid_message_signature'), false);
334
+ } else {
335
+ iwp_mmb_response(array('error' => 'Command not successful. Please try again.', 'error_code' => 'iwp_mmb_readd_site_command_not_successful'), false);
336
+ }
337
+ } else {
338
+ if (!get_option('iwp_client_nossl_key')) {
339
+ srand();
340
+
341
+ $random_key = md5(base64_encode($public_key) . rand(0, getrandmax()));
342
+
343
+ $iwp_mmb_core->set_random_signature($random_key);
344
+ $iwp_mmb_core->set_client_message_id($id);
345
+ $iwp_mmb_core->set_admin_panel_public_key($public_key);
346
+ $iwp_mmb_core->get_stats_instance();
347
+ if(is_array($notifications) && !empty($notifications)){
348
+ $iwp_mmb_core->stats_instance->set_notifications($notifications);
349
+ }
350
+
351
+ if(is_array($brand) && !empty($brand)){
352
+ update_option('iwp_client_brand',$brand);
353
+ }
354
+
355
+ iwp_mmb_response($iwp_mmb_core->stats_instance->get_initial_stats(), true);
356
+ delete_option('iwp_client_activate_key');//IWP
357
+ } else
358
+ iwp_mmb_response(array('error' => 'Please deactivate & activate InfiniteWP Client plugin on your site, then add the site again.', 'error_code' => 'deactivate_ctivate_InfiniteWP_Client_plugin_add_site_again_not_iwp_client_nossl_key'), false);
359
+ }
360
+ } else {
361
+ iwp_mmb_response(array('error' => 'Please deactivate &amp; activate InfiniteWP Client plugin on your site, then add the site again.', 'error_code' => 'deactivate_ctivate_InfiniteWP_Client_plugin_add_site_again_not_iwp_client_nossl_key'), false);
362
+ }
363
+ } else {
364
+ iwp_mmb_response(array('error' => 'Invalid parameters received. Please try again.', 'error_code' => 'iwp_mmb_add_site_invalid_parameters_received'), false);
365
+ }
366
+ }
367
+ }
368
+
369
+ if(!function_exists('iwp_mmb_maintain_site')){
370
+ function iwp_mmb_maintain_site($params){
371
+ $check = 1;
372
+ if(get_option('iwp_mmb_maintenance_mode') != $params['maintenance_mode'])
373
+ if(update_option('iwp_mmb_maintenance_mode',$params['maintenance_mode']) ){ $check = 1;}else{$check = 0;}
374
+ if(get_option('iwp_mmb_maintenance_html') != $params['maintenance_html'])
375
+ if(update_option('iwp_mmb_maintenance_html',$params['maintenance_html']) ){ $check = 1;}else{$check = 0;}
376
+ if($check == 1){
377
+ iwp_mmb_response($params, true);
378
+ }else{
379
+ iwp_mmb_response(array('error' => 'Some error with database connection in client site', 'error_code' => 'database_connection_in_client_site'), false);
380
+ }
381
+ }
382
+ }
383
+
384
+
385
+ if( !function_exists ( 'iwp_mmb_remove_site' )) {
386
+ function iwp_mmb_remove_site($params)
387
+ {
388
+ extract($params);
389
+ global $iwp_mmb_core;
390
+ $iwp_mmb_core->uninstall( $deactivate );
391
+
392
+ include_once(ABSPATH . 'wp-admin/includes/plugin.php');
393
+ $plugin_slug = basename(dirname(__FILE__)) . '/' . basename(__FILE__);
394
+
395
+ if ($deactivate) {
396
+ deactivate_plugins($plugin_slug, true);
397
+ }
398
+
399
+ if (!is_plugin_active($plugin_slug))
400
+ iwp_mmb_response(array(
401
+ 'deactivated' => 'Site removed successfully. <br /><br />InfiniteWP Client plugin successfully deactivated.'
402
+ ), true);
403
+ else
404
+ iwp_mmb_response(array(
405
+ 'removed_data' => 'Site removed successfully. <br /><br /><b>InfiniteWP Client plugin was not deactivated.</b>'
406
+ ), true);
407
+
408
+ }
409
+ }
410
+ if( !function_exists ( 'iwp_mmb_stats_get' )) {
411
+ function iwp_mmb_stats_get($params)
412
+ {
413
+ global $iwp_mmb_core;
414
+ $iwp_mmb_core->get_stats_instance();
415
+ iwp_mmb_response($iwp_mmb_core->stats_instance->get($params), true);
416
+ }
417
+ }
418
+
419
+ if( !function_exists ( 'iwp_mmb_client_header' )) {
420
+ function iwp_mmb_client_header()
421
+ { global $iwp_mmb_core, $current_user;
422
+
423
+ if(!headers_sent()){
424
+ if(isset($current_user->ID))
425
+ $expiration = time() + apply_filters('auth_cookie_expiration', 10800, $current_user->ID, false);
426
+ else
427
+ $expiration = time() + 10800;
428
+
429
+ setcookie(IWP_MMB_XFRAME_COOKIE, md5(IWP_MMB_XFRAME_COOKIE), $expiration, COOKIEPATH, COOKIE_DOMAIN, false, true);
430
+ $_COOKIE[IWP_MMB_XFRAME_COOKIE] = md5(IWP_MMB_XFRAME_COOKIE);
431
+ }
432
+ }
433
+ }
434
+
435
+ if( !function_exists ( 'iwp_mmb_pre_init_stats' )) {
436
+ function iwp_mmb_pre_init_stats( $params )
437
+ {
438
+ global $iwp_mmb_core;
439
+ $iwp_mmb_core->get_stats_instance();
440
+ return $iwp_mmb_core->stats_instance->pre_init_stats($params);
441
+ }
442
+ }
443
+
444
+ if( !function_exists ( 'iwp_mmb_trigger_check' )) {
445
+ //backup multi call trigger and status check.
446
+ function iwp_mmb_trigger_check($params)
447
+ {
448
+ global $iwp_mmb_core;
449
+ $iwp_mmb_core->get_backup_instance($params['mechanism']);
450
+ $return = $iwp_mmb_core->backup_instance->trigger_check($params);
451
+
452
+ if (is_array($return) && array_key_exists('error', $return))
453
+ iwp_mmb_response($return, false);
454
+ else {
455
+ iwp_mmb_response($return, true);
456
+ }
457
+ }
458
+ }
459
+
460
+
461
+ if( !function_exists ( 'iwp_mmb_backup_now' )) {
462
+ //backup
463
+ function iwp_mmb_backup_now($params)
464
+ {
465
+ global $iwp_mmb_core;
466
+
467
+ $iwp_mmb_core->get_backup_instance();
468
+ $return = $iwp_mmb_core->backup_instance->backup($params);
469
+
470
+ if (is_array($return) && array_key_exists('error', $return))
471
+ iwp_mmb_response($return, false);
472
+ else {
473
+ iwp_mmb_response($return, true);
474
+ }
475
+ }
476
+ }
477
+
478
+ if( !function_exists ( 'iwp_mmb_run_task_now' )) {
479
+ function iwp_mmb_run_task_now($params)
480
+ {
481
+ global $iwp_mmb_core;
482
+ $iwp_mmb_core->get_backup_instance($params['mechanism']);
483
+ //$return = $iwp_mmb_core->backup_instance->task_now(); //set_backup_task($params)
484
+ $return = $iwp_mmb_core->backup_instance->set_backup_task($params);
485
+ if (is_array($return) && array_key_exists('error', $return))
486
+ iwp_mmb_response($return, false);
487
+ else {
488
+ iwp_mmb_response($return, true);
489
+ }
490
+ }
491
+ }
492
+
493
+ if( !function_exists ( 'iwp_mmb_delete_task_now' )) {
494
+ function iwp_mmb_delete_task_now($params)
495
+ {
496
+ global $iwp_mmb_core;
497
+ $iwp_mmb_core->get_backup_instance();
498
+ $return = $iwp_mmb_core->backup_instance->delete_task_now($params['task_name']);
499
+ if (is_array($return) && array_key_exists('error', $return))
500
+ iwp_mmb_response($return, false);
501
+ else {
502
+ iwp_mmb_response($return, true);
503
+ }
504
+ }
505
+ }
506
+ if( !function_exists ( 'iwp_mmb_check_backup_compat' )) {
507
+ function iwp_mmb_check_backup_compat($params)
508
+ {
509
+ global $iwp_mmb_core;
510
+ $iwp_mmb_core->get_backup_instance();
511
+ $return = $iwp_mmb_core->backup_instance->check_backup_compat($params);
512
+
513
+ if (is_array($return) && array_key_exists('error', $return))
514
+ iwp_mmb_response($return, false);
515
+ else {
516
+ iwp_mmb_response($return, true);
517
+ }
518
+ }
519
+ }
520
+
521
+ if( !function_exists ( 'iwp_mmb_get_backup_req' )) {
522
+ function iwp_mmb_get_backup_req( $params )
523
+ {
524
+ global $iwp_mmb_core;
525
+ $iwp_mmb_core->get_stats_instance();
526
+ $return = $iwp_mmb_core->stats_instance->get_backup_req($params);
527
+
528
+ if (is_array($return) && array_key_exists('error', $return))
529
+ iwp_mmb_response($return, false);
530
+ else {
531
+ iwp_mmb_response($return, true);
532
+ }
533
+ }
534
+ }
535
+
536
+
537
+ if( !function_exists ( 'iwp_mmb_scheduled_backup' )) {
538
+ function iwp_mmb_scheduled_backup($params)
539
+ {
540
+ global $iwp_mmb_core;
541
+
542
+ $iwp_mmb_core->get_backup_instance($params['mechanism']);
543
+ $return = $iwp_mmb_core->backup_instance->set_backup_task($params);
544
+ iwp_mmb_response($return, $return);
545
+ }
546
+ }
547
+
548
+
549
+ if( !function_exists ( 'iwp_mmb_delete_backup' )) {
550
+ function iwp_mmb_delete_backup($params)
551
+ {
552
+ global $iwp_mmb_core;
553
+ $iwp_mmb_core->get_backup_instance();
554
+ $return = $iwp_mmb_core->backup_instance->delete_backup($params);
555
+ iwp_mmb_response($return, $return);
556
+ }
557
+ }
558
+
559
+ if( !function_exists ( 'iwp_mmb_optimize_tables' )) {
560
+ function iwp_mmb_optimize_tables($params)
561
+ {
562
+ global $iwp_mmb_core;
563
+ $iwp_mmb_core->get_backup_instance();
564
+ $return = $iwp_mmb_core->backup_instance->optimize_tables();
565
+ if ($return)
566
+ iwp_mmb_response($return, true);
567
+ else
568
+ iwp_mmb_response(false, false);
569
+ }
570
+ }
571
+ if( !function_exists ( 'iwp_mmb_restore_now' )) {
572
+ function iwp_mmb_restore_now($params)
573
+ {
574
+ global $iwp_mmb_core;
575
+ $iwp_mmb_core->get_backup_instance('multiCall');
576
+ $return = $iwp_mmb_core->backup_instance->restore($params);
577
+
578
+ if (is_array($return) && array_key_exists('error', $return))
579
+ iwp_mmb_response($return, false);
580
+ else
581
+ iwp_mmb_response($return, true);
582
+
583
+ }
584
+ }
585
+
586
+
587
+ if( !function_exists ( 'iwp_mmb_backup_repository' )) {
588
+ function iwp_mmb_backup_repository($params)
589
+ {
590
+ global $iwp_mmb_core;
591
+ $iwp_mmb_core->get_backup_repository_instance();
592
+ $return = $iwp_mmb_core->backup_repository_instance->backup_repository($params);
593
+ if (is_array($return) && array_key_exists('error', $return))
594
+ iwp_mmb_response($return, false);
595
+ else
596
+ iwp_mmb_response($return, true);
597
+ }
598
+ }
599
+
600
+
601
+ if( !function_exists ( 'iwp_mmb_clean_orphan_backups' )) {
602
+ function iwp_mmb_clean_orphan_backups()
603
+ {
604
+ global $iwp_mmb_core;
605
+ $backup_instance = $iwp_mmb_core->get_backup_instance();
606
+ $return = $iwp_mmb_core->backup_instance->cleanup();
607
+ if(is_array($return))
608
+ iwp_mmb_response($return, true);
609
+ else
610
+ iwp_mmb_response($return, false);
611
+ }
612
+ }
613
+
614
+
615
+
616
+ add_filter( 'iwp_website_add', 'iwp_mmb_readd_backup_task' );
617
+
618
+ if (!function_exists('iwp_mmb_readd_backup_task')) {
619
+ function iwp_mmb_readd_backup_task($params = array()) {
620
+ global $iwp_mmb_core;
621
+ $backup_instance = $iwp_mmb_core->get_backup_instance();
622
+ $settings = $backup_instance->readd_tasks($params);
623
+ return $settings;
624
+ }
625
+ }
626
+
627
+ if( !function_exists ( 'iwp_mmb_update_client_plugin' )) {
628
+ function iwp_mmb_update_client_plugin($params)
629
+ {
630
+ global $iwp_mmb_core;
631
+ iwp_mmb_response($iwp_mmb_core->update_client_plugin($params), true);
632
+ }
633
+ }
634
+
635
+ if( !function_exists ( 'iwp_mmb_wp_checkversion' )) {
636
+ function iwp_mmb_wp_checkversion($params)
637
+ {
638
+ include_once(ABSPATH . 'wp-includes/version.php');
639
+ global $iwp_mmb_wp_version, $iwp_mmb_core;
640
+ iwp_mmb_response($iwp_mmb_wp_version, true);
641
+ }
642
+ }
643
+ if( !function_exists ( 'iwp_mmb_search_posts_by_term' )) {
644
+ function iwp_mmb_search_posts_by_term($params)
645
+ {
646
+ global $iwp_mmb_core;
647
+ $iwp_mmb_core->get_search_instance();
648
+
649
+ $search_type = trim($params['search_type']);
650
+ $search_term = strtolower(trim($params['search_term']));
651
+
652
+ switch ($search_type){
653
+ case 'plugin':
654
+ $plugins = get_option('active_plugins');
655
+
656
+ $have_plugin = false;
657
+ foreach ($plugins as $plugin) {
658
+ if(strpos($plugin, $search_term)>-1){
659
+ $have_plugin = true;
660
+ }
661
+ }
662
+ if($have_plugin){
663
+ iwp_mmb_response(serialize($plugin), true);
664
+ }else{
665
+ iwp_mmb_response(false, false);
666
+ }
667
+ break;
668
+ case 'theme':
669
+ $theme = strtolower(get_option('template'));
670
+ if(strpos($theme, $search_term)>-1){
671
+ iwp_mmb_response($theme, true);
672
+ }else{
673
+ iwp_mmb_response(false, false);
674
+ }
675
+ break;
676
+ default: iwp_mmb_response(false, false);
677
+ }
678
+ $return = $iwp_mmb_core->search_instance->iwp_mmb_search_posts_by_term($params);
679
+
680
+
681
+
682
+ if ($return_if_true) {
683
+ iwp_mmb_response($return_value, true);
684
+ } else {
685
+ iwp_mmb_response($return_if_false, false);
686
+ }
687
+ }
688
+ }
689
+
690
+ if( !function_exists ( 'iwp_mmb_install_addon' )) {
691
+ function iwp_mmb_install_addon($params)
692
+ {
693
+ global $iwp_mmb_core;
694
+ $iwp_mmb_core->get_installer_instance();
695
+ $return = $iwp_mmb_core->installer_instance->install_remote_file($params);
696
+ iwp_mmb_response($return, true);
697
+
698
+ }
699
+ }
700
+
701
+ if( !function_exists ( 'iwp_mmb_do_upgrade' )) {
702
+ function iwp_mmb_do_upgrade($params)
703
+ {
704
+ global $iwp_mmb_core, $iwp_mmb_upgrading;
705
+ $iwp_mmb_core->get_installer_instance();
706
+ $return = $iwp_mmb_core->installer_instance->do_upgrade($params);
707
+ iwp_mmb_response($return, true);
708
+
709
+ }
710
+ }
711
+
712
+ if( !function_exists ( 'iwp_mmb_add_user' )) {
713
+ function iwp_mmb_add_user($params)
714
+ {
715
+ global $iwp_mmb_core;
716
+ $iwp_mmb_core->get_user_instance();
717
+ $return = $iwp_mmb_core->user_instance->add_user($params);
718
+ if (is_array($return) && array_key_exists('error', $return)){
719
+ iwp_mmb_response($return, false);
720
+ }
721
+ else {
722
+ iwp_mmb_response($return, true);
723
+ }
724
+
725
+ }
726
+ }
727
+
728
+ if( !function_exists ('iwp_mmb_get_users')) {
729
+ function iwp_mmb_get_users($params)
730
+ {
731
+ global $iwp_mmb_core;
732
+ $iwp_mmb_core->get_user_instance();
733
+ $return = $iwp_mmb_core->user_instance->get_users($params);
734
+ if (is_array($return) && array_key_exists('error', $return))
735
+ iwp_mmb_response($return, false);
736
+ else {
737
+ iwp_mmb_response($return, true);
738
+ }
739
+ }
740
+ }
741
+
742
+ if( !function_exists ('iwp_mmb_edit_users')) {
743
+ function iwp_mmb_edit_users($params)
744
+ {
745
+ global $iwp_mmb_core;
746
+ $iwp_mmb_core->get_user_instance();
747
+ $return = $iwp_mmb_core->user_instance->edit_users($params);
748
+ iwp_mmb_response($return, true);
749
+ }
750
+ }
751
+
752
+ if( !function_exists ( 'iwp_mmb_iframe_plugins_fix' )) {
753
+ function iwp_mmb_iframe_plugins_fix($update_actions)
754
+ {
755
+ foreach($update_actions as $key => $action)
756
+ {
757
+ $update_actions[$key] = str_replace('target="_parent"','',$action);
758
+ }
759
+
760
+ return $update_actions;
761
+
762
+ }
763
+ }
764
+
765
+ if( !function_exists ( 'iwp_mmb_set_notifications' )) {
766
+ function iwp_mmb_set_notifications($params)
767
+ {
768
+ global $iwp_mmb_core;
769
+ $iwp_mmb_core->get_stats_instance();
770
+ $return = $iwp_mmb_core->stats_instance->set_notifications($params);
771
+ if (is_array($return) && array_key_exists('error', $return))
772
+ iwp_mmb_response($return, false);
773
+ else {
774
+ iwp_mmb_response($return, true);
775
+ }
776
+
777
+ }
778
+ }
779
+
780
+ if( !function_exists ( 'iwp_mmb_set_alerts' )) {
781
+ function iwp_mmb_set_alerts($params)
782
+ {
783
+ global $iwp_mmb_core;
784
+ $iwp_mmb_core->get_stats_instance();
785
+ $return = $iwp_mmb_core->stats_instance->set_alerts($params);
786
+ iwp_mmb_response(true, true);
787
+ }
788
+ }
789
+
790
+ /*
791
+ if(!function_exists('iwp_mmb_more_reccurences')){
792
+ //Backup Tasks
793
+ add_filter('cron_schedules', 'iwp_mmb_more_reccurences');
794
+ function iwp_mmb_more_reccurences($schedules) {
795
+ $schedules['halfminute'] = array('interval' => 30, 'display' => 'Once in a half minute');
796
+ $schedules['minutely'] = array('interval' => 60, 'display' => 'Once in a minute');
797
+ $schedules['fiveminutes'] = array('interval' => 300, 'display' => 'Once every five minutes');
798
+ $schedules['tenminutes'] = array('interval' => 600, 'display' => 'Once every ten minutes');
799
+
800
+ return $schedules;
801
+ }
802
+ }
803
+
804
+ add_action('iwp_client_backup_tasks', 'iwp_client_check_backup_tasks');
805
+
806
+ if( !function_exists('iwp_client_check_backup_tasks') ){
807
+ function iwp_client_check_backup_tasks() {
808
+ global $iwp_mmb_core, $_wp_using_ext_object_cache;
809
+ $_wp_using_ext_object_cache = false;
810
+
811
+ $iwp_mmb_core->get_backup_instance();
812
+ $iwp_mmb_core->backup_instance->check_backup_tasks();
813
+ }
814
+ }
815
+ */
816
+
817
+ if( !function_exists('iwp_check_notifications') ){
818
+ function iwp_check_notifications() {
819
+ global $iwp_mmb_core, $_wp_using_ext_object_cache;
820
+ $_wp_using_ext_object_cache = false;
821
+
822
+ $iwp_mmb_core->get_stats_instance();
823
+ $iwp_mmb_core->stats_instance->check_notifications();
824
+ }
825
+ }
826
+
827
+
828
+ if( !function_exists('iwp_mmb_get_plugins_themes') ){
829
+ function iwp_mmb_get_plugins_themes($params) {
830
+ global $iwp_mmb_core;
831
+ $iwp_mmb_core->get_installer_instance();
832
+ $return = $iwp_mmb_core->installer_instance->get($params);
833
+ iwp_mmb_response($return, true);
834
+ }
835
+ }
836
+
837
+ if( !function_exists('iwp_mmb_edit_plugins_themes') ){
838
+ function iwp_mmb_edit_plugins_themes($params) {
839
+ global $iwp_mmb_core;
840
+ $iwp_mmb_core->get_installer_instance();
841
+ $return = $iwp_mmb_core->installer_instance->edit($params);
842
+ iwp_mmb_response($return, true);
843
+ }
844
+ }
845
+
846
+ //post
847
+ if( !function_exists ( 'iwp_mmb_post_create' )) {
848
+ function iwp_mmb_post_create($params)
849
+ {
850
+ global $iwp_mmb_core;
851
+ $iwp_mmb_core->get_post_instance();
852
+ $return = $iwp_mmb_core->post_instance->create($params);
853
+ if (is_int($return))
854
+ iwp_mmb_response($return, true);
855
+ else{
856
+ if(isset($return['error'])){
857
+ iwp_mmb_response($return, false);
858
+ } else {
859
+ iwp_mmb_response($return, false);
860
+ }
861
+ }
862
+ }
863
+ }
864
+
865
+ if( !function_exists ( 'iwp_mmb_change_post_status' )) {
866
+ function iwp_mmb_change_post_status($params)
867
+ {
868
+ global $iwp_mmb_core;
869
+ $iwp_mmb_core->get_post_instance();
870
+ $return = $iwp_mmb_core->post_instance->change_status($params);
871
+ //mmb_response($return, true);
872
+
873
+ }
874
+ }
875
+
876
+ if( !function_exists ('iwp_mmb_get_posts')) {
877
+ function iwp_mmb_get_posts($params)
878
+ {
879
+ global $iwp_mmb_core;
880
+ $iwp_mmb_core->get_post_instance();
881
+
882
+ $return = $iwp_mmb_core->post_instance->get_posts($params);
883
+ if (is_array($return) && array_key_exists('error', $return))
884
+ iwp_mmb_response($return, false);
885
+ else {
886
+ iwp_mmb_response($return, true);
887
+ }
888
+ }
889
+ }
890
+
891
+ if( !function_exists ('iwp_mmb_delete_post')) {
892
+ function iwp_mmb_delete_post($params)
893
+ {
894
+ global $iwp_mmb_core;
895
+ $iwp_mmb_core->get_post_instance();
896
+
897
+ $return = $iwp_mmb_core->post_instance->delete_post($params);
898
+ if (is_array($return) && array_key_exists('error', $return))
899
+ iwp_mmb_response($return, false);
900
+ else {
901
+ iwp_mmb_response($return, true);
902
+ }
903
+ }
904
+ }
905
+
906
+ if( !function_exists ('iwp_mmb_delete_posts')) {
907
+ function iwp_mmb_delete_posts($params)
908
+ {
909
+ global $iwp_mmb_core;
910
+ $iwp_mmb_core->get_post_instance();
911
+
912
+ $return = $iwp_mmb_core->post_instance->delete_posts($params);
913
+ if (is_array($return) && array_key_exists('error', $return))
914
+ iwp_mmb_response($return, false);
915
+ else {
916
+ iwp_mmb_response($return, true);
917
+ }
918
+ }
919
+ }
920
+
921
+ if( !function_exists ('iwp_mmb_edit_posts')) {
922
+ function iwp_mmb_edit_posts($params)
923
+ {
924
+ global $iwp_mmb_core;
925
+ $iwp_mmb_core->get_posts_instance();
926
+ $return = $iwp_mmb_core->posts_instance->edit_posts($params);
927
+ iwp_mmb_response($return, true);
928
+ }
929
+ }
930
+
931
+ if( !function_exists ('iwp_mmb_get_pages')) {
932
+ function iwp_mmb_get_pages($params)
933
+ {
934
+ global $iwp_mmb_core;
935
+ $iwp_mmb_core->get_post_instance();
936
+
937
+ $return = $iwp_mmb_core->post_instance->get_pages($params);
938
+ if (is_array($return) && array_key_exists('error', $return))
939
+ iwp_mmb_response($return, false);
940
+ else {
941
+ iwp_mmb_response($return, true);
942
+ }
943
+ }
944
+ }
945
+
946
+ if( !function_exists ('iwp_mmb_delete_page')) {
947
+ function iwp_mmb_delete_page($params)
948
+ {
949
+ global $iwp_mmb_core;
950
+ $iwp_mmb_core->get_post_instance();
951
+
952
+ $return = $iwp_mmb_core->post_instance->delete_page($params);
953
+ if (is_array($return) && array_key_exists('error', $return))
954
+ iwp_mmb_response($return, false);
955
+ else {
956
+ iwp_mmb_response($return, true);
957
+ }
958
+ }
959
+ }
960
+
961
+
962
+ //links
963
+ if( !function_exists ('iwp_mmb_get_links')) {
964
+ function iwp_mmb_get_links($params)
965
+ {
966
+ global $iwp_mmb_core;
967
+ $iwp_mmb_core->get_link_instance();
968
+ $return = $iwp_mmb_core->link_instance->get_links($params);
969
+ if (is_array($return) && array_key_exists('error', $return))
970
+ iwp_mmb_response($return, false);
971
+ else {
972
+ iwp_mmb_response($return, true);
973
+ }
974
+ }
975
+ }
976
+
977
+ if( !function_exists ( 'iwp_mmb_add_link' )) {
978
+ function iwp_mmb_add_link($params)
979
+ {
980
+ global $iwp_mmb_core;
981
+ $iwp_mmb_core->get_link_instance();
982
+ $return = $iwp_mmb_core->link_instance->add_link($params);
983
+ if (is_array($return) && array_key_exists('error', $return)){
984
+ iwp_mmb_response($return, false);
985
+ }
986
+ else {
987
+ iwp_mmb_response($return, true);
988
+ }
989
+
990
+ }
991
+ }
992
+
993
+ if( !function_exists ('iwp_mmb_delete_link')) {
994
+ function iwp_mmb_delete_link($params)
995
+ {
996
+ global $iwp_mmb_core;
997
+ $iwp_mmb_core->get_link_instance();
998
+
999
+ $return = $iwp_mmb_core->link_instance->delete_link($params);
1000
+ if (is_array($return) && array_key_exists('error', $return)){
1001
+ iwp_mmb_response($return, false);
1002
+ }
1003
+ else {
1004
+ iwp_mmb_response($return, true);
1005
+ }
1006
+ }
1007
+ }
1008
+
1009
+ if( !function_exists ('iwp_mmb_delete_links')) {
1010
+ function iwp_mmb_delete_links($params)
1011
+ {
1012
+ global $iwp_mmb_core;
1013
+ $iwp_mmb_core->get_link_instance();
1014
+
1015
+ $return = $iwp_mmb_core->link_instance->delete_links($params);
1016
+ if (is_array($return) && array_key_exists('error', $return)){
1017
+ iwp_mmb_response($return, false);
1018
+ }
1019
+ else {
1020
+ iwp_mmb_response($return, true);
1021
+ }
1022
+ }
1023
+ }
1024
+
1025
+
1026
+ //comments
1027
+ if( !function_exists ( 'iwp_mmb_change_comment_status' )) {
1028
+ function iwp_mmb_change_comment_status($params)
1029
+ {
1030
+ global $iwp_mmb_core;
1031
+ $iwp_mmb_core->get_comment_instance();
1032
+ $return = $iwp_mmb_core->comment_instance->change_status($params);
1033
+ //mmb_response($return, true);
1034
+ if ($return){
1035
+ $iwp_mmb_core->get_stats_instance();
1036
+ iwp_mmb_response($iwp_mmb_core->stats_instance->get_comments_stats($params), true);
1037
+ }else
1038
+ iwp_mmb_response(array('error' => 'Comment not updated', 'error_code' => 'comment_not_updated'), false);
1039
+ }
1040
+
1041
+ }
1042
+ if( !function_exists ( 'iwp_mmb_comment_stats_get' )) {
1043
+ function iwp_mmb_comment_stats_get($params)
1044
+ {
1045
+ global $iwp_mmb_core;
1046
+ $iwp_mmb_core->get_stats_instance();
1047
+ iwp_mmb_response($iwp_mmb_core->stats_instance->get_comments_stats($params), true);
1048
+ }
1049
+ }
1050
+
1051
+ if( !function_exists ('iwp_mmb_get_comments')) {
1052
+ function iwp_mmb_get_comments($params)
1053
+ {
1054
+ global $iwp_mmb_core;
1055
+ $iwp_mmb_core->get_comment_instance();
1056
+ $return = $iwp_mmb_core->comment_instance->get_comments($params);
1057
+ if (is_array($return) && array_key_exists('error', $return))
1058
+ iwp_mmb_response($return, false);
1059
+ else {
1060
+ iwp_mmb_response($return, true);
1061
+ }
1062
+ }
1063
+ }
1064
+
1065
+ if( !function_exists ('iwp_mmb_action_comment')) {
1066
+ function iwp_mmb_action_comment($params)
1067
+ {
1068
+ global $iwp_mmb_core;
1069
+ $iwp_mmb_core->get_comment_instance();
1070
+
1071
+ $return = $iwp_mmb_core->comment_instance->action_comment($params);
1072
+ if (is_array($return) && array_key_exists('error', $return))
1073
+ iwp_mmb_response($return, false);
1074
+ else {
1075
+ iwp_mmb_response($return, true);
1076
+ }
1077
+ }
1078
+ }
1079
+
1080
+ if( !function_exists ('iwp_mmb_bulk_action_comments')) {
1081
+ function iwp_mmb_bulk_action_comments($params)
1082
+ {
1083
+ global $iwp_mmb_core;
1084
+ $iwp_mmb_core->get_comment_instance();
1085
+
1086
+ $return = $iwp_mmb_core->comment_instance->bulk_action_comments($params);
1087
+ if (is_array($return) && array_key_exists('error', $return))
1088
+ iwp_mmb_response($return, false);
1089
+ else {
1090
+ iwp_mmb_response($return, true);
1091
+ }
1092
+ }
1093
+ }
1094
+
1095
+ if( !function_exists ('iwp_mmb_reply_comment')) {
1096
+ function iwp_mmb_reply_comment($params)
1097
+ {
1098
+ global $iwp_mmb_core;
1099
+ $iwp_mmb_core->get_comment_instance();
1100
+
1101
+ $return = $iwp_mmb_core->comment_instance->reply_comment($params);
1102
+ if (is_array($return) && array_key_exists('error', $return))
1103
+ iwp_mmb_response($return, false);
1104
+ else {
1105
+ iwp_mmb_response($return, true);
1106
+ }
1107
+ }
1108
+ }
1109
+
1110
+ //Comments-End-
1111
+
1112
+ //WP-Optimize
1113
+
1114
+ if( !function_exists('iwp_mmb_wp_optimize')){
1115
+ function iwp_mmb_wp_optimize($params){
1116
+ global $iwp_mmb_core;
1117
+ $iwp_mmb_core->wp_optimize_instance();
1118
+
1119
+ $return = $iwp_mmb_core->optimize_instance->cleanup_system($params);
1120
+ if (is_array($return) && array_key_exists('error', $return))
1121
+ iwp_mmb_response($return, false);
1122
+ else {
1123
+ iwp_mmb_response($return, true);
1124
+ }
1125
+ }
1126
+ }
1127
+
1128
+ //WP-Optimize_end
1129
+
1130
+ /*
1131
+ *WordFence Addon Start
1132
+ */
1133
+
1134
+ if( !function_exists('iwp_mmb_wordfence_scan')){
1135
+ function iwp_mmb_wordfence_scan($params){
1136
+ global $iwp_mmb_core,$iwp_mmb_plugin_dir;
1137
+ require_once("$iwp_mmb_plugin_dir/addons/wordfence/wordfence.class.php");
1138
+ $iwp_mmb_core->get_wordfence_instance();
1139
+
1140
+ $return = $iwp_mmb_core->wordfence_instance->scan($params);
1141
+ if (is_array($return) && array_key_exists('error', $return))
1142
+ iwp_mmb_response($return, false);
1143
+ else {
1144
+ iwp_mmb_response($return, true);
1145
+ }
1146
+ }
1147
+ }
1148
+
1149
+ if( !function_exists('iwp_mmb_wordfence_load')){
1150
+ function iwp_mmb_wordfence_load($params){
1151
+ global $iwp_mmb_core,$iwp_mmb_plugin_dir;
1152
+ require_once("$iwp_mmb_plugin_dir/addons/wordfence/wordfence.class.php");
1153
+ $iwp_mmb_core->get_wordfence_instance();
1154
+
1155
+ $return = $iwp_mmb_core->wordfence_instance->load($params);
1156
+ if (is_array($return) && array_key_exists('error', $return))
1157
+ iwp_mmb_response($return, false);
1158
+ else {
1159
+ iwp_mmb_response($return, true);
1160
+ }
1161
+ }
1162
+ }
1163
+
1164
+ /*
1165
+ *WordFence Addon End
1166
+ */
1167
+
1168
+
1169
+ /*
1170
+ * iTheams Security Addon Start here
1171
+ */
1172
+
1173
+ if(!function_exists('iwp_mmb_ithemes_security_load')) {
1174
+ function iwp_mmb_ithemes_security_load() {
1175
+ if(_check_ithemes_security()) {
1176
+ include_once(ABSPATH . "wp-includes/pluggable.php");
1177
+ //$ITSECdashboard = new ITSEC_Dashboard_Admin( new ITSEC_Core(WP_PLUGIN_DIR . '/better-wp-security/better-wp-security.php', __( 'iThemes Security', 'it-l10n-better-wp-security' )) );
1178
+ //add_action( 'itsec_add_admin_meta_boxes', array( $ITSECdashboard, 'add_admin_meta_boxes' ) );
1179
+ $statuses = array(
1180
+ 'safe-high' => array(),
1181
+ 'high' => array(),
1182
+ 'safe-medium' => array(),
1183
+ 'medium' => array(),
1184
+ 'safe-low' => array(),
1185
+ 'low' => array(),
1186
+ );
1187
+
1188
+ $statuses = apply_filters( 'itsec_add_dashboard_status', $statuses );
1189
+ iwp_mmb_response($statuses, true);
1190
+ }
1191
+ }
1192
+ }
1193
+
1194
+ /*
1195
+ * Private function, Will return the iTheams Security is load or not
1196
+ */
1197
+ function _check_ithemes_security() {
1198
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
1199
+ if ( is_plugin_active( 'better-wp-security/better-wp-security.php' ) ) {
1200
+ @include_once(WP_PLUGIN_DIR . '/better-wp-security/better-wp-security.php');
1201
+ if (class_exists('ITSEC_Core')) {
1202
+ return true;
1203
+ } else {
1204
+ return false;
1205
+ }
1206
+ } else {
1207
+ return false;
1208
+ }
1209
+ }
1210
+
1211
+ /*
1212
+ * iTheams Security Addon End here
1213
+ */
1214
+
1215
+ //WP-BrokenLinks start
1216
+
1217
+ if( !function_exists('iwp_mmb_get_all_links')){
1218
+ function iwp_mmb_get_all_links(){
1219
+ global $iwp_mmb_core;
1220
+ $iwp_mmb_core->wp_blc_get_blinks();
1221
+ $return = $iwp_mmb_core->blc_get_blinks->blc_get_all_links($params);
1222
+ if (is_array($return) && array_key_exists('error', $return))
1223
+ iwp_mmb_response($return, false);
1224
+ else {
1225
+ iwp_mmb_response($return, true);
1226
+ }
1227
+ }
1228
+ }
1229
+
1230
+ if( !function_exists('iwp_mmb_update_broken_link')){
1231
+ function iwp_mmb_update_broken_link($params){
1232
+ global $iwp_mmb_core;
1233
+ $iwp_mmb_core->wp_blc_get_blinks();
1234
+ $return = $iwp_mmb_core->blc_get_blinks->blc_update_link($params);
1235
+ if (is_array($return) && array_key_exists('error', $return))
1236
+ iwp_mmb_response($return, false);
1237
+ else {
1238
+ iwp_mmb_response($return, true);
1239
+ }
1240
+ }
1241
+ }
1242
+
1243
+ if( !function_exists('iwp_mmb_unlink_broken_link')){
1244
+ function iwp_mmb_unlink_broken_link($params){
1245
+ global $iwp_mmb_core;
1246
+ $iwp_mmb_core->wp_blc_get_blinks();
1247
+ $return = $iwp_mmb_core->blc_get_blinks->blc_unlink($params);
1248
+ if (is_array($return) && array_key_exists('error', $return))
1249
+ iwp_mmb_response($return, false);
1250
+ else {
1251
+ iwp_mmb_response($return, true);
1252
+ }
1253
+ }
1254
+ }
1255
+
1256
+ if( !function_exists('iwp_mmb_markasnot_broken_link')){
1257
+ function iwp_mmb_markasnot_broken_link($params){
1258
+ global $iwp_mmb_core;
1259
+ $iwp_mmb_core->wp_blc_get_blinks();
1260
+ $return = $iwp_mmb_core->blc_get_blinks->blc_mark_as_not_broken($params);
1261
+ if (is_array($return) && array_key_exists('error', $return))
1262
+ iwp_mmb_response($return, false);
1263
+ else {
1264
+ iwp_mmb_response($return, true);
1265
+ }
1266
+ }
1267
+ }
1268
+
1269
+ if( !function_exists('iwp_mmb_dismiss_broken_link')){
1270
+ function iwp_mmb_dismiss_broken_link($params){
1271
+ global $iwp_mmb_core;
1272
+ $iwp_mmb_core->wp_blc_get_blinks();
1273
+ $return = $iwp_mmb_core->blc_get_blinks->blc_dismiss_link($params);
1274
+ if (is_array($return) && array_key_exists('error', $return))
1275
+ iwp_mmb_response($return, false);
1276
+ else {
1277
+ iwp_mmb_response($return, true);
1278
+ }
1279
+ }
1280
+ }
1281
+
1282
+ if( !function_exists('iwp_mmb_undismiss_broken_link')){
1283
+ function iwp_mmb_undismiss_broken_link($params){
1284
+ global $iwp_mmb_core;
1285
+ $iwp_mmb_core->wp_blc_get_blinks();
1286
+ $return = $iwp_mmb_core->blc_get_blinks->blc_undismiss_link($params);
1287
+ if (is_array($return) && array_key_exists('error', $return))
1288
+ iwp_mmb_response($return, false);
1289
+ else {
1290
+ iwp_mmb_response($return, true);
1291
+ }
1292
+ }
1293
+ }
1294
+
1295
+ if( !function_exists('iwp_mmb_bulk_actions_processor')){
1296
+ function iwp_mmb_bulk_actions_processor($params){
1297
+ global $iwp_mmb_core;
1298
+ $iwp_mmb_core->wp_blc_get_blinks();
1299
+ $return = $iwp_mmb_core->blc_get_blinks->blc_bulk_actions($params);
1300
+ if (is_array($return) && array_key_exists('error', $return))
1301
+ iwp_mmb_response($return, false);
1302
+ else {
1303
+ iwp_mmb_response($return, true);
1304
+ }
1305
+ }
1306
+ }
1307
+
1308
+ //WP-BrokenLinks end
1309
+
1310
+ //WP-GWMTools start
1311
+
1312
+ if( !function_exists('iwp_mmb_gwmt_redirect_url')){
1313
+ function iwp_mmb_gwmt_redirect_url($params){
1314
+ global $iwp_mmb_core;
1315
+ $iwp_mmb_core->wp_google_webmasters_crawls();
1316
+ $return = $iwp_mmb_core->get_google_webmasters_crawls->google_webmasters_redirect($params);
1317
+ if (is_array($return) && array_key_exists('error', $return))
1318
+ iwp_mmb_response($return, false);
1319
+ else {
1320
+ iwp_mmb_response($return, true);
1321
+ }
1322
+ }
1323
+ }
1324
+
1325
+ if( !function_exists('iwp_mmb_gwmt_redirect_url_again')){
1326
+ function iwp_mmb_gwmt_redirect_url_again($params){
1327
+ global $iwp_mmb_core;
1328
+ $iwp_mmb_core->wp_google_webmasters_crawls();
1329
+ $return = $iwp_mmb_core->get_google_webmasters_crawls->google_webmasters_redirect_again($params);
1330
+ if (is_array($return) && array_key_exists('error', $return))
1331
+ iwp_mmb_response($return, false);
1332
+ else {
1333
+ iwp_mmb_response($return, true);
1334
+ }
1335
+ }
1336
+ }
1337
+
1338
+
1339
+ //WP-GWMTools end
1340
+
1341
+ //fileEditor start
1342
+
1343
+ if( !function_exists('iwp_mmb_file_editor_upload')){
1344
+ function iwp_mmb_file_editor_upload($params){
1345
+ global $iwp_mmb_core;
1346
+ $iwp_mmb_core->wp_get_file_editor();
1347
+ $return = $iwp_mmb_core->get_file_editor->file_editor_upload($params);
1348
+ if (is_array($return) && array_key_exists('error', $return))
1349
+ iwp_mmb_response($return, false);
1350
+ else {
1351
+ iwp_mmb_response($return, true);
1352
+ }
1353
+ }
1354
+ }
1355
+
1356
+
1357
+ //fileEditor end
1358
+
1359
+ //yoastWpSeo start
1360
+ if( !function_exists('iwp_mmb_yoast_get_seo_info')){
1361
+ function iwp_mmb_yoast_get_seo_info($params){
1362
+ global $iwp_mmb_core;
1363
+ $iwp_mmb_core->wp_get_yoast_seo();
1364
+ $return = $iwp_mmb_core->get_yoast_seo->get_seo_info($params);
1365
+ if (is_array($return) && array_key_exists('error', $return))
1366
+ iwp_mmb_response($return, false);
1367
+ else {
1368
+ iwp_mmb_response($return, true);
1369
+ }
1370
+ }
1371
+ }
1372
+ if( !function_exists('iwp_mmb_yoast_save_seo_info')){
1373
+ function iwp_mmb_yoast_save_seo_info($params){
1374
+ global $iwp_mmb_core;
1375
+ $iwp_mmb_core->wp_get_yoast_seo();
1376
+ $return = $iwp_mmb_core->get_yoast_seo->save_seo_info($params);
1377
+ if (is_array($return) && array_key_exists('error', $return))
1378
+ iwp_mmb_response($return, false);
1379
+ else {
1380
+ iwp_mmb_response($return, true);
1381
+ }
1382
+ }
1383
+ }
1384
+ //yoastWpSeo end
1385
+
1386
+ if( !function_exists('iwp_mmb_maintenance_mode')){
1387
+ function iwp_mmb_maintenance_mode( $params ) {
1388
+ global $wp_object_cache;
1389
+
1390
+ $default = get_option('iwp_client_maintenace_mode');
1391
+ $params = empty($default) ? $params : array_merge($default, $params);
1392
+ update_option("iwp_client_maintenace_mode", $params);
1393
+
1394
+ if(!empty($wp_object_cache))
1395
+ @$wp_object_cache->flush();
1396
+ iwp_mmb_response(true, true);
1397
+ }
1398
+ }
1399
+
1400
+ if( !function_exists('iwp_mmb_plugin_actions') ){
1401
+ function iwp_mmb_plugin_actions() {
1402
+ global $iwp_mmb_actions, $iwp_mmb_core;
1403
+
1404
+ if(!empty($iwp_mmb_actions)){
1405
+ global $_iwp_mmb_plugin_actions;
1406
+ if(!empty($_iwp_mmb_plugin_actions)){
1407
+ $failed = array();
1408
+ foreach($_iwp_mmb_plugin_actions as $action => $params){
1409
+ if(isset($iwp_mmb_actions[$action]))
1410
+ call_user_func($iwp_mmb_actions[$action], $params);
1411
+ else
1412
+ $failed[] = $action;
1413
+ }
1414
+ if(!empty($failed)){
1415
+ $f = implode(', ', $failed);
1416
+ $s = count($f) > 1 ? 'Actions "' . $f . '" do' : 'Action "' . $f . '" does';
1417
+ iwp_mmb_response(array('error' => $s.' not exist. Please update your IWP Client plugin.', 'error_code' => 'update_your_client_plugin'), false);
1418
+ }
1419
+
1420
+ }
1421
+ }
1422
+
1423
+ global $pagenow, $current_user, $mmode;
1424
+ if( !is_admin() && !in_array($pagenow, array( 'wp-login.php' ))){
1425
+ $mmode = get_option('iwp_client_maintenace_mode');
1426
+ if( !empty($mmode) ){
1427
+ if(isset($mmode['active']) && $mmode['active'] == true){
1428
+ if(isset($current_user->data) && !empty($current_user->data) && isset($mmode['hidecaps']) && !empty($mmode['hidecaps'])){
1429
+ $usercaps = array();
1430
+ if(isset($current_user->caps) && !empty($current_user->caps)){
1431
+ $usercaps = $current_user->caps;
1432
+ }
1433
+ foreach($mmode['hidecaps'] as $cap => $hide){
1434
+ if(!$hide)
1435
+ continue;
1436
+
1437
+ foreach($usercaps as $ucap => $val){
1438
+ if($ucap == $cap){
1439
+ ob_end_clean();
1440
+ ob_end_flush();
1441
+ die($mmode['template']);
1442
+ }
1443
+ }
1444
+ }
1445
+ } else
1446
+ die($mmode['template']);
1447
+ }
1448
+ }
1449
+ }
1450
+ }
1451
+ }
1452
+
1453
+ if( !function_exists ( 'iwp_mmb_execute_php_code' )) {
1454
+ function iwp_mmb_execute_php_code($params)
1455
+ {
1456
+ ob_start();
1457
+ eval($params['code']);
1458
+ $return = ob_get_flush();
1459
+ iwp_mmb_response(print_r($return, true), true);
1460
+ }
1461
+ }
1462
+
1463
+ if( !function_exists('iwp_mmb_client_brand')){
1464
+ function iwp_mmb_client_brand($params) {
1465
+ update_option("iwp_client_brand",$params['brand']);
1466
+ iwp_mmb_response(true, true);
1467
+ }
1468
+ }
1469
+
1470
+
1471
+ if(!function_exists('checkOpenSSL')){
1472
+ function checkOpenSSL(){
1473
+ if(!function_exists('openssl_verify')){
1474
+ return false;
1475
+ }
1476
+ else{
1477
+ $key = @openssl_pkey_new();
1478
+ @openssl_pkey_export($key, $privateKey);
1479
+ $privateKey = base64_encode($privateKey);
1480
+ $publicKey = @openssl_pkey_get_details($key);
1481
+ $publicKey = $publicKey["key"];
1482
+
1483
+ if(empty($publicKey) || empty($privateKey)){
1484
+ return false;
1485
+ }
1486
+ }
1487
+ return true;
1488
+ }
1489
+ }
1490
+
1491
+
1492
+ if(!function_exists('iwp_mmb_shutdown')){
1493
+ function iwp_mmb_shutdown(){
1494
+ $isError = false;
1495
+
1496
+ if ($error = error_get_last()){
1497
+ switch($error['type']){
1498
+ /*case E_PARSE:*/
1499
+ case E_ERROR:
1500
+ case E_CORE_ERROR:
1501
+ case E_COMPILE_ERROR:
1502
+ case E_USER_ERROR:
1503
+ $isError = true;
1504
+ break;
1505
+ }
1506
+ }
1507
+ if ($isError){
1508
+
1509
+ $response = '<span style="font-weight:700;">PHP Fatal error occured:</span> '.$error['message'].' in '.$error['file'].' on line '.$error['line'].'.';
1510
+ if(stripos($error['message'], 'allowed memory size') !== false){
1511
+ $response .= '<br>Try <a href="http://infinitewp.com/knowledge-base/increase-memory-limit/?utm_source=application&utm_medium=userapp&utm_campaign=kb" target="_blank">increasing the PHP memory limit</a> for this WP site.';
1512
+ }
1513
+ if(!$GLOBALS['IWP_RESPONSE_SENT']){
1514
+ iwp_mmb_response(array('error' => $response, 'error_code' => 'iwp_mmb_shutdown'), false);
1515
+ }
1516
+
1517
+ }
1518
+ }
1519
+ }
1520
+
1521
+
1522
+ if(!function_exists('iwp_mmb_print_flush')){
1523
+ function iwp_mmb_print_flush($print_string){// this will help responding web server, will keep alive the script execution
1524
+
1525
+ echo $print_string." ||| ";
1526
+ echo "TT:".(microtime(1) - $GLOBALS['IWP_MMB_PROFILING']['ACTION_START'])."\n";
1527
+ ob_flush();
1528
+ flush();
1529
+ }
1530
+ }
1531
+
1532
+ if(!function_exists('iwp_mmb_auto_print')){
1533
+ function iwp_mmb_auto_print($unique_task){// this will help responding web server, will keep alive the script execution
1534
+ $print_every_x_secs = 5;
1535
+
1536
+ $current_time = microtime(1);
1537
+ if(!$GLOBALS['IWP_MMB_PROFILING']['TASKS'][$unique_task]['START']){
1538
+ $GLOBALS['IWP_MMB_PROFILING']['TASKS'][$unique_task]['START'] = $current_time;
1539
+ }
1540
+
1541
+ if(!$GLOBALS['IWP_MMB_PROFILING']['LAST_PRINT'] || ($current_time - $GLOBALS['IWP_MMB_PROFILING']['LAST_PRINT']) > $print_every_x_secs){
1542
+
1543
+ //$print_string = "TT:".($current_time - $GLOBALS['IWP_MMB_PROFILING']['ACTION_START'])."\n";
1544
+ $print_string = $unique_task." TT:".($current_time - $GLOBALS['IWP_MMB_PROFILING']['TASKS'][$unique_task]['START']);
1545
+ iwp_mmb_print_flush($print_string);
1546
+ $GLOBALS['IWP_MMB_PROFILING']['LAST_PRINT'] = $current_time;
1547
+ }
1548
+ }
1549
+ }
1550
+
1551
+ if(!function_exists('iwp_mmb_check_maintenance')){
1552
+ function iwp_mmb_check_maintenance(){
1553
+ global $wpdb;
1554
+ if(get_option('iwp_mmb_maintenance_mode')){
1555
+ $html_maintenance = get_option('iwp_mmb_maintenance_html');
1556
+ echo $html_maintenance;
1557
+ exit;
1558
+ }
1559
+ }
1560
+ }
1561
+
1562
+ if(!function_exists('iwp_mmb_check_redirects')){
1563
+ function iwp_mmb_check_redirects(){
1564
+ global $wpdb;
1565
+ $current_url = ($_SERVER['SERVER_PORT']=='443'?'https://':'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
1566
+ $current_url = rtrim($current_url,'/');
1567
+ $table_name = $wpdb->base_prefix."iwp_redirects";
1568
+ if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name) {
1569
+ $success = $wpdb -> get_col($wpdb->prepare("SELECT redirectLink FROM ".$wpdb->base_prefix."iwp_redirects WHERE oldLink = %s LIMIT 1",$current_url));
1570
+ if(count($success)){
1571
+ if(function_exists(wp_redirect)){
1572
+ wp_redirect($success[0]);
1573
+ }
1574
+ }
1575
+ }
1576
+ }
1577
+ }
1578
+
1579
+ if(!function_exists('iwp_mmb_convert_data')){
1580
+ function iwp_mmb_convert_data(){
1581
+
1582
+ //Schedule backup key need to save .
1583
+ global $wpdb;
1584
+
1585
+ $client_backup_tasks = get_option('iwp_client_backup_tasks');
1586
+
1587
+ $type = $action = $category = '';
1588
+
1589
+ if(!empty($client_backup_tasks) && is_array($client_backup_tasks)){
1590
+ foreach($client_backup_tasks as $key){
1591
+ if(!is_array($key) || !is_array($key['task_args'])){
1592
+ continue;
1593
+ }
1594
+ $task_name = $key['task_args']['task_name'];
1595
+
1596
+ if($task_name == 'Backup Now'){
1597
+ $type = 'backup';
1598
+ $action = 'now';
1599
+ $category = $key['task_args']['what'];
1600
+ }
1601
+ else{
1602
+ $type = 'scheduleBackup';
1603
+ $action = 'runTask';
1604
+ $category = $key['task_args']['what'];
1605
+ }
1606
+ if(is_array($key['task_results'])){
1607
+ $taskResultData = array();
1608
+ foreach($key['task_results'] as $keys => $task_results){
1609
+
1610
+ $historyID = $task_results['backhack_status']['adminHistoryID'];
1611
+
1612
+ $taskResultData = array('task_results' => array($historyID => $task_results));
1613
+ $taskResultData['task_results'][$historyID]['adminHistoryID'] = $historyID;
1614
+
1615
+ $insert = $wpdb->insert($wpdb->base_prefix.'iwp_backup_status',array( 'stage' => 'finished', 'status' => 'completed', 'action' => $action, 'type' => $type,'category' => $category ,'historyID' => $task_results['backhack_status']['adminHistoryID'],'finalStatus' => 'completed','startTime' => $task_results['time'],'endTime' => $task_results['time'],'statusMsg' => $statusArray['statusMsg'],'requestParams' => serialize($key),'taskName' => $task_name, 'responseParams' => '', 'taskResults' => serialize($taskResultData)), array( '%s', '%s','%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%s', '%s', '%s', '%s', '%s') );
1616
+
1617
+ }
1618
+ }
1619
+ }
1620
+ }
1621
+ }
1622
+ }
1623
+
1624
+
1625
+
1626
+ if(!function_exists('iwp_mmb_create_backup_table')){
1627
+ function iwp_mmb_create_backup_table(){
1628
+ global $wpdb;
1629
+
1630
+ $IWP_MMB_BACKUP_TABLE_VERSION = get_site_option( 'iwp_backup_table_version' );
1631
+ $table_name = $wpdb->base_prefix . "iwp_backup_status";
1632
+
1633
+ if(version_compare($IWP_MMB_BACKUP_TABLE_VERSION, '1.1') == -1){
1634
+ if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
1635
+
1636
+ $sql = "
1637
+ CREATE TABLE IF NOT EXISTS $table_name (
1638
+ `ID` int(11) NOT NULL AUTO_INCREMENT,
1639
+ `historyID` int(11) NOT NULL,
1640
+ `taskName` varchar(255) NOT NULL,
1641
+ `action` varchar(50) NOT NULL,
1642
+ `type` varchar(50) NOT NULL,
1643
+ `category` varchar(50) NOT NULL,
1644
+ `stage` varchar(255) NOT NULL,
1645
+ `status` varchar(255) NOT NULL,
1646
+ `finalStatus` varchar(50) DEFAULT NULL,
1647
+ `statusMsg` varchar(255) NOT NULL,
1648
+ `requestParams` text NOT NULL,
1649
+ `responseParams` longtext,
1650
+ `taskResults` text,
1651
+ `startTime` int(11) DEFAULT NULL,
1652
+ `endTime` int(11) NOT NULL,
1653
+ PRIMARY KEY (`ID`)
1654
+ ) ENGINE=InnoDB;
1655
+ ";
1656
+
1657
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
1658
+ dbDelta( $sql );
1659
+
1660
+ if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
1661
+ //echo "table creation failed";
1662
+ $table_created = false;
1663
+ }
1664
+ else{
1665
+
1666
+ iwp_mmb_convert_data();
1667
+ $_NEW_IWP_MMB_BACKUP_TABLE_VERSION = '1.1';
1668
+ }
1669
+
1670
+ }else{
1671
+ $table_created = true;
1672
+ $_NEW_IWP_MMB_BACKUP_TABLE_VERSION = '1.1';
1673
+ }
1674
+ }
1675
+
1676
+ if(!empty($_NEW_IWP_MMB_BACKUP_TABLE_VERSION)){
1677
+ add_option( "iwp_backup_table_version", $_NEW_IWP_MMB_BACKUP_TABLE_VERSION);
1678
+ }
1679
+ }
1680
+ }
1681
+
1682
+ //-------------------------------------------------------------------
1683
+
1684
+ //-Function name - iwp_mmb_get_file_size()
1685
+ //-This is the alternate function to calculate file size
1686
+ //-This function is introduced to support the filesize calculation for the files which are larger than 2048MB
1687
+
1688
+ //----------------------------------------------------------------------
1689
+
1690
+ if(!function_exists('iwp_mmb_get_file_size')){
1691
+ function iwp_mmb_get_file_size($file)
1692
+ {
1693
+ clearstatcache();
1694
+ $normal_file_size = filesize($file);
1695
+ if(($normal_file_size !== false)&&($normal_file_size >= 0))
1696
+ {
1697
+ return $normal_file_size;
1698
+ }
1699
+ else
1700
+ {
1701
+ $file = realPath($file);
1702
+ if(!$file)
1703
+ {
1704
+ echo 'iwp_mmb_get_file_size_error : realPath error';
1705
+ }
1706
+ $ch = curl_init("file://" . $file);
1707
+ curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_FILE);
1708
+ curl_setopt($ch, CURLOPT_NOBODY, true);
1709
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1710
+ curl_setopt($ch, CURLOPT_HEADER, true);
1711
+ $data = curl_exec($ch);
1712
+ $curl_error = curl_error($ch);
1713
+ curl_close($ch);
1714
+ if ($data !== false && preg_match('/Content-Length: (\d+)/', $data, $matches)) {
1715
+ return (string) $matches[1];
1716
+ }
1717
+ else
1718
+ {
1719
+ echo 'iwp_mmb_get_file_size_error : '.$curl_error;
1720
+ return $normal_file_size;
1721
+ }
1722
+ }
1723
+ }
1724
+ }
1725
+
1726
+ if( !function_exists('iwp_mmb_backup_test_site')){
1727
+ function iwp_mmb_backup_test_site($params){
1728
+ global $iwp_mmb_core,$iwp_mmb_plugin_dir;
1729
+ $return = array();
1730
+
1731
+ $iwp_mmb_core->get_backup_instance();
1732
+ $return = $iwp_mmb_core->backup_instance->check_backup_compat($params);
1733
+
1734
+ if (is_array($return) && array_key_exists('error', $return))
1735
+ iwp_mmb_response($return, false);
1736
+ else {
1737
+ iwp_mmb_response($return, true);
1738
+ }
1739
+ }
1740
+ }
1741
+
1742
+ //add_action( 'plugins_loaded', 'iwp_mmb_create_backup_table' );
1743
+
1744
+ //register_activation_hook( __FILE__, 'iwp_mmb_create_backup_table' );
1745
+
1746
+ $iwp_mmb_core = new IWP_MMB_Core();
1747
+ $mmb_core = 1;
1748
+
1749
+ if(isset($_GET['auto_login']))
1750
+ $iwp_mmb_core->automatic_login();
1751
+
1752
+ if (function_exists('register_activation_hook'))
1753
+ register_activation_hook( __FILE__ , array( $iwp_mmb_core, 'install' ));
1754
+
1755
+ if (function_exists('register_deactivation_hook'))
1756
+ register_deactivation_hook(__FILE__, array( $iwp_mmb_core, 'uninstall' ));
1757
+
1758
+ if (function_exists('add_action'))
1759
+ add_action('init', 'iwp_mmb_plugin_actions', 99999);
1760
+
1761
+ if (function_exists('add_action'))
1762
+ add_action('wp_head', 'iwp_mmb_check_maintenance', 99999);
1763
+
1764
+ if (function_exists('add_action'))
1765
+ add_action('wp_head', 'iwp_mmb_check_redirects', 99999);
1766
+
1767
+ if (function_exists('add_filter'))
1768
+ add_filter('install_plugin_complete_actions','iwp_mmb_iframe_plugins_fix');
1769
+
1770
+ if( isset($_COOKIE[IWP_MMB_XFRAME_COOKIE]) ){
1771
+ remove_action( 'admin_init', 'send_frame_options_header');
1772
+ remove_action( 'login_init', 'send_frame_options_header');
1773
+ }
1774
+
1775
  ?>
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.9.1
6
  Stable tag: trunk
7
 
8
  Install this plugin on unlimited sites and manage them all from a central dashboard.
@@ -48,6 +48,12 @@ Credits: [Vladimir Prelovac](http://prelovac.com/vladimir) for his worker plugin
48
 
49
  == Changelog ==
50
 
 
 
 
 
 
 
51
  = 1.3.3 =
52
  * Fix: False "FTP verification failed: File may be corrupted" error.
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.9.2
6
  Stable tag: trunk
7
 
8
  Install this plugin on unlimited sites and manage them all from a central dashboard.
48
 
49
  == Changelog ==
50
 
51
+ = 1.3.4 =
52
+ * Feature: Maintenance mode with custom HTML.
53
+ * New: WP site's server info can be viewed.
54
+ * Improvement: Simplified site adding process - One-click copy & paste
55
+ * Improvement: New addons compatibility.
56
+
57
  = 1.3.3 =
58
  * Fix: False "FTP verification failed: File may be corrupted" error.
59