WordPress Backup & Security Plugin – BlogVault - Version 1.88

Version Description

  • Handling translations
  • Callback improvements
  • Adding delete transient callback
Download this release

Release Info

Developer akshatc
Plugin Icon 128x128 WordPress Backup & Security Plugin – BlogVault
Version 1.88
Comparing to
See all releases

Version 1.88

Files changed (67) hide show
  1. account.php +50 -0
  2. admin.php +184 -0
  3. admin/add_new_acc.php +76 -0
  4. admin/footer.php +20 -0
  5. admin/header.php +27 -0
  6. admin/main_page.php +38 -0
  7. admin/top_box.php +21 -0
  8. blogvault.php +97 -0
  9. callback.php +251 -0
  10. callback/recover.php +76 -0
  11. callback/response.php +107 -0
  12. callback/streams.php +166 -0
  13. callback/wings/account.php +34 -0
  14. callback/wings/auth.php +26 -0
  15. callback/wings/brand.php +48 -0
  16. callback/wings/bv_upgrader_skin.php +68 -0
  17. callback/wings/db.php +145 -0
  18. callback/wings/dynsync.php +81 -0
  19. callback/wings/fs.php +258 -0
  20. callback/wings/fw.php +34 -0
  21. callback/wings/info.php +292 -0
  22. callback/wings/ipstore.php +116 -0
  23. callback/wings/lp.php +72 -0
  24. callback/wings/manage.php +516 -0
  25. callback/wings/misc.php +71 -0
  26. callback/wings/monit.php +77 -0
  27. callback/wings/protect.php +62 -0
  28. css/bvmui.min.css +1 -0
  29. css/bvplugin.min.css +1 -0
  30. dynsync.php +576 -0
  31. fw/config.php +66 -0
  32. fw/fw.php +280 -0
  33. fw/request.php +295 -0
  34. img/adobe-logo.png +0 -0
  35. img/as_seen_in.png +0 -0
  36. img/bv.png +0 -0
  37. img/bv_badge.png +0 -0
  38. img/bv_for_free.jpg +0 -0
  39. img/bvlogo.png +0 -0
  40. img/cloudways-logo.png +0 -0
  41. img/icon.png +0 -0
  42. img/intel-logo.png +0 -0
  43. img/liquid-web.png +0 -0
  44. img/lock.png +0 -0
  45. img/malcare-wordpress-security.png +0 -0
  46. img/mclogo.png +0 -0
  47. img/pressable-logo.png +0 -0
  48. img/sap-logo.png +0 -0
  49. img/testimonial_bv.png +0 -0
  50. img/testimonial_mc.png +0 -0
  51. img/valet-logo.png +0 -0
  52. img/wp-engine-logo.png +0 -0
  53. img/wp-site-care-logo.png +0 -0
  54. img/yoast-logo.png +0 -0
  55. ipstore.php +97 -0
  56. license.txt +385 -0
  57. logger.php +24 -0
  58. lp/config.php +80 -0
  59. lp/lp.php +248 -0
  60. main.php +167 -0
  61. main/auth.php +106 -0
  62. main/db.php +166 -0
  63. main/lib.php +44 -0
  64. main/site_info.php +99 -0
  65. protect.php +45 -0
  66. publickeys/bvkey3.pub +14 -0
  67. readme.txt +427 -0
account.php ADDED
@@ -0,0 +1,50 @@
1
+ <?php
2
+ if (!defined('ABSPATH')) exit;
3
+ if (!class_exists('BVAccountInfo')) :
4
+
5
+ class BVAccountInfo {
6
+ public $bvmain;
7
+
8
+ function __construct($bvmain) {
9
+ $this->bvmain = $bvmain;
10
+ }
11
+
12
+ public function add($info) {
13
+ $accounts = $this->allAccounts();
14
+ if(!is_array($accounts)) {
15
+ $accounts = array();
16
+ }
17
+ $pubkey = $info['pubkey'];
18
+ $accounts[$pubkey]['lastbackuptime'] = time();
19
+ $accounts[$pubkey]['url'] = $info['url'];
20
+ $accounts[$pubkey]['email'] = $info['email'];
21
+ $this->update($accounts);
22
+ }
23
+
24
+ public function remove($pubkey) {
25
+ $bvkeys = $this->bvmain->info->getOption('bvkeys');
26
+ $accounts = $this->allAccounts();
27
+ $this->bvmain->auth->rmkeys($pubkey);
28
+ $this->bvmain->setup($this->bvmain->lib->randString(32));
29
+ if ($accounts && is_array($accounts)) {
30
+ unset($accounts[$pubkey]);
31
+ $this->update($accounts);
32
+ return true;
33
+ }
34
+ return false;
35
+ }
36
+
37
+ public function allAccounts() {
38
+ return $this->bvmain->info->getOption('bvAccounts');
39
+ }
40
+
41
+ public function doesAccountExists($pubkey) {
42
+ $accounts = $this->allAccounts();
43
+ return array_key_exists($pubkey, $accounts);
44
+ }
45
+
46
+ public function update($accounts) {
47
+ $this->bvmain->info->updateOption('bvAccounts', $accounts);
48
+ }
49
+ }
50
+ endif;
admin.php ADDED
@@ -0,0 +1,184 @@
1
+ <?php
2
+
3
+ if (!defined('ABSPATH')) exit;
4
+ if (!class_exists('BVAdmin')) :
5
+
6
+ require_once dirname( __FILE__ ) . '/account.php';
7
+
8
+ class BVAdmin {
9
+ public $bvmain;
10
+ public $account;
11
+ function __construct($bvmain) {
12
+ $this->bvmain = $bvmain;
13
+ $this->account = new BVAccountInfo($this->bvmain);
14
+ }
15
+
16
+ public function mainUrl($_params = '') {
17
+ if (function_exists('network_admin_url')) {
18
+ return network_admin_url('admin.php?page='.$this->bvmain->plugname.$_params);
19
+ } else {
20
+ return admin_url('admin.php?page='.$this->bvmain->plugname.$_params);
21
+ }
22
+ }
23
+
24
+ public function initHandler() {
25
+ if (!current_user_can('activate_plugins'))
26
+ return;
27
+
28
+ if (array_key_exists('bvnonce', $_REQUEST) &&
29
+ wp_verify_nonce($_REQUEST['bvnonce'], "bvnonce") &&
30
+ array_key_exists('blogvaultkey', $_REQUEST) &&
31
+ (strlen($_REQUEST['blogvaultkey']) == 64) &&
32
+ (array_key_exists('page', $_REQUEST) &&
33
+ $_REQUEST['page'] == $this->bvmain->plugname)) {
34
+ $keys = str_split($_REQUEST['blogvaultkey'], 32);
35
+ $this->bvmain->auth->updateKeys($keys[0], $keys[1]);
36
+ if (array_key_exists('redirect', $_REQUEST)) {
37
+ $location = $_REQUEST['redirect'];
38
+ wp_redirect($this->bvmain->appUrl()."/dash/redir?q=".urlencode($location));
39
+ exit();
40
+ }
41
+ }
42
+ if ($this->bvmain->isActivateRedirectSet()) {
43
+ wp_redirect($this->mainUrl());
44
+ }
45
+ }
46
+
47
+ public function menu() {
48
+ $brand = $this->bvmain->getBrandInfo();
49
+ if (!$brand || (!array_key_exists('hide', $brand) && !array_key_exists('hide_from_menu', $brand))) {
50
+ $bname = $this->bvmain->getBrandName();
51
+ add_menu_page($bname, $bname, 'manage_options', $this->bvmain->plugname,
52
+ array($this, 'adminPage'), plugins_url('img/icon.png', __FILE__ ));
53
+ }
54
+ }
55
+
56
+ public function hidePluginDetails($plugin_metas, $slug) {
57
+ $brand = $this->bvmain->getBrandInfo();
58
+ $bvslug = $this->bvmain->slug;
59
+
60
+ if ($slug === $bvslug && $brand && array_key_exists('hide_plugin_details', $brand)){
61
+ foreach ($plugin_metas as $pluginKey => $pluginValue) {
62
+ if (strpos($pluginValue, sprintf('>%s<', translate('View details')))) {
63
+ unset($plugin_metas[$pluginKey]);
64
+ break;
65
+ }
66
+ }
67
+ }
68
+ return $plugin_metas;
69
+ }
70
+
71
+ public function settingsLink($links, $file) {
72
+ #XNOTE: Fix this
73
+ if ( $file == plugin_basename( dirname(__FILE__).'/blogvault.php' ) ) {
74
+ $brand = $this->bvmain->getBrandInfo();
75
+ if (!$brand || !array_key_exists('hide_plugin_details', $brand)) {
76
+ $links[] = '<a href="'.$this->mainUrl().'">'.__( 'Settings' ).'</a>';
77
+ }
78
+ }
79
+ return $links;
80
+ }
81
+
82
+ public function getPluginLogo() {
83
+ $brand = $this->bvmain->getBrandInfo();
84
+ if ($brand && array_key_exists('logo', $brand)) {
85
+ return $brand['logo'];
86
+ }
87
+ return $this->bvmain->logo;
88
+ }
89
+
90
+ public function getWebPage() {
91
+ $brand = $this->bvmain->getBrandInfo();
92
+ if ($brand && array_key_exists('webpage', $brand)) {
93
+ return $brand['webpage'];
94
+ }
95
+ return $this->bvmain->webpage;
96
+ }
97
+
98
+ public function siteInfoTags() {
99
+ $bvnonce = wp_create_nonce("bvnonce");
100
+ $secret = $this->bvmain->auth->defaultSecret();
101
+ $tags = "<input type='hidden' name='url' value='".$this->bvmain->info->wpurl()."'/>\n".
102
+ "<input type='hidden' name='homeurl' value='".$this->bvmain->info->homeurl()."'/>\n".
103
+ "<input type='hidden' name='siteurl' value='".$this->bvmain->info->siteurl()."'/>\n".
104
+ "<input type='hidden' name='dbsig' value='".$this->bvmain->lib->dbsig(false)."'/>\n".
105
+ "<input type='hidden' name='plug' value='".$this->bvmain->plugname."'/>\n".
106
+ "<input type='hidden' name='adminurl' value='".$this->mainUrl()."'/>\n".
107
+ "<input type='hidden' name='bvversion' value='".$this->bvmain->version."'/>\n".
108
+ "<input type='hidden' name='serverip' value='".$_SERVER["SERVER_ADDR"]."'/>\n".
109
+ "<input type='hidden' name='abspath' value='".ABSPATH."'/>\n".
110
+ "<input type='hidden' name='secret' value='".$secret."'/>\n".
111
+ "<input type='hidden' name='bvnonce' value='".$bvnonce."'/>\n";
112
+ return $tags;
113
+ }
114
+
115
+ public function activateWarning() {
116
+ global $hook_suffix;
117
+ if (!$this->bvmain->isConfigured() && $hook_suffix == 'index.php' ) {
118
+ ?>
119
+ <div id="message" class="updated" style="padding: 8px; font-size: 16px; background-color: #dff0d8">
120
+ <a class="button-primary" href="<?php echo $this->mainUrl(); ?>">Activate BlogVault</a>
121
+ &nbsp;&nbsp;&nbsp;<b>Almost Done:</b> Activate your BlogVault account to backup & secure your site.
122
+ </div>
123
+ <?php
124
+ }
125
+ }
126
+
127
+ public function isConfigured() {
128
+ $accounts = $this->account->allAccounts();
129
+ return (is_array($accounts) && sizeof($accounts) >= 1);
130
+ }
131
+
132
+ public function adminPage() {
133
+ wp_enqueue_style( 'bvsurface', plugins_url('css/bvmui.min.css', __FILE__));
134
+ wp_enqueue_style( 'bvplugin', plugins_url('css/bvplugin.min.css', __FILE__));
135
+ if (isset($_REQUEST['bvnonce']) && wp_verify_nonce( $_REQUEST['bvnonce'], 'bvnonce' )) {
136
+ $this->account->remove($_REQUEST['pubkey']);
137
+ }
138
+ require_once dirname( __FILE__ ) . '/admin/header.php';
139
+ if ($this->isConfigured()) {
140
+ if (!isset($_REQUEST['add_account'])) {
141
+ require_once dirname( __FILE__ ) . '/admin/main_page.php';
142
+ } else {
143
+ require_once dirname( __FILE__ ) . '/admin/add_new_acc.php';
144
+ }
145
+ } else {
146
+ require_once dirname( __FILE__ ) . '/admin/add_new_acc.php';
147
+ }
148
+ require_once dirname( __FILE__ ) . '/admin/footer.php';
149
+ }
150
+
151
+ public function initBranding($plugins) {
152
+ $slug = $this->bvmain->slug;
153
+ $brand = $this->bvmain->getBrandInfo();
154
+ if ($brand) {
155
+ if (array_key_exists('hide', $brand)) {
156
+ unset($plugins[$slug]);
157
+ } else {
158
+ if (array_key_exists('name', $brand)) {
159
+ $plugins[$slug]['Name'] = $brand['name'];
160
+ }
161
+ if (array_key_exists('title', $brand)) {
162
+ $plugins[$slug]['Title'] = $brand['title'];
163
+ }
164
+ if (array_key_exists('description', $brand)) {
165
+ $plugins[$slug]['Description'] = $brand['description'];
166
+ }
167
+ if (array_key_exists('authoruri', $brand)) {
168
+ $plugins[$slug]['AuthorURI'] = $brand['authoruri'];
169
+ }
170
+ if (array_key_exists('author', $brand)) {
171
+ $plugins[$slug]['Author'] = $brand['author'];
172
+ }
173
+ if (array_key_exists('authorname', $brand)) {
174
+ $plugins[$slug]['AuthorName'] = $brand['authorname'];
175
+ }
176
+ if (array_key_exists('pluginuri', $brand)) {
177
+ $plugins[$slug]['PluginURI'] = $brand['pluginuri'];
178
+ }
179
+ }
180
+ }
181
+ return $plugins;
182
+ }
183
+ }
184
+ endif;
admin/add_new_acc.php ADDED
@@ -0,0 +1,76 @@
1
+ <?php
2
+ if ($this->bvmain->isMalcare()) {
3
+ $signupFormTitle = "Let's scan your website";
4
+ $signupPurpose = array("Malware Scan", "Malware Clean", "Firewall", "Login Protection", "Others");
5
+ $signupButtonText = "Scan Site";
6
+ $signupButtonColor = "#4686f5";
7
+ } else {
8
+ $signupFormTitle = "Let's get your FREE Backup";
9
+ $signupPurpose = array("Backup", "Staging", "Restore", "Migrate", "Manage", "Others");
10
+ $signupButtonText = "Get started";
11
+ $signupButtonColor = "#25bea0";
12
+ }
13
+ ?>
14
+ <div id="content-wrapper" style="width: 99%">
15
+ <div class="mui-container-fluid" style="padding: 0px;">
16
+ <div class="mui-col-md-10" style="padding-left: 0px;">
17
+ <br>
18
+ <div class="bv-box" style="padding-top: 10px; padding-bottom: 10px;">
19
+ <?php require_once dirname( __FILE__ ) . "/top_box.php";?>
20
+ </div>
21
+ <div class="mui-panel new-account-panel">
22
+ <form dummy=">" action="<?php echo $this->bvmain->appUrl(); ?>/plugin/bvstart" style="padding-top:10px; margin: 0px;" onsubmit="document.getElementById('get-started').disabled = true;" method="post" name="signup">
23
+ <div style="width: 800px; margin: 0 auto; padding: 10px;">
24
+ <div class="mui--text-title form-title"><?php echo $signupFormTitle; ?></div>
25
+ <input type='hidden' name='bvsrc' value='wpplugin' />
26
+ <?php echo $this->siteInfoTags(); ?>
27
+ <input type="text" class="bv-input" id="email" name="email" style="width:430px;" placeholder="Enter your email" required>
28
+ <select name="purpose" class="bv-input select-purpose" required>
29
+ <option value="" hidden>Looking for?</option>
30
+ <?php
31
+ foreach($signupPurpose as $value) {
32
+ echo "<option value='".$value."'>".$value."</option>";
33
+ }
34
+ ?>
35
+ </select>
36
+ <button id="get-started" class="mui-btn mui-btn--raised mui-btn--primaryi get-started-button" type="submit" style="background: <?php echo $signupButtonColor; ?>;"><?php echo $signupButtonText; ?></button><br/>
37
+ <input type="checkbox" name="consent" value="1" required/>I agree to Blogvault <a href="https://www.blogvault.net/tos" target="_blank" rel="noopener noreferrer">Terms of Service</a> and <a href="https://www.blogvault.net/privacy" target="_blank" rel="noopener noreferrer">Privacy Policy</a>
38
+ </div>
39
+ </form>
40
+ <br/>
41
+ </div>
42
+ </div>
43
+ <div class="mui-col-md-2 side">
44
+ <?php if ($this->bvmain->isBlogvault()) { ?>
45
+ <div class="side-box" style="margin: 0px !important;">
46
+ <h2 class="side-box-title">Why choose BlogVault ?</h2>
47
+ <strong>
48
+ <ul>
49
+ <li><span class="bv-tick">&#10003;</span> 100% Working Backups</li>
50
+ <li><span class="bv-tick">&#10003;</span> FREE Staging Site</li>
51
+ <li><span class="bv-tick">&#10003;</span> Fastest Website Recovery</li>
52
+ <li><span class="bv-tick">&#10003;</span> Flawless 1-Click Migrations</li>
53
+ <li><span class="bv-tick">&#10003;</span> WooCommerce Backups</li>
54
+ <li><span class="bv-tick">&#10003;</span> Doesn't slow website ever</li>
55
+ <li><span class="bv-tick">&#10003;</span> Full Website Management</li>
56
+ </ul>
57
+ </strong>
58
+ </div>
59
+ <div class="side-box" style="margin-top: 20px; overflow: hidden;">
60
+ <h2 class="side-box-title">What's in BlogVault Pro?</h2>
61
+ <strong>
62
+ <ul>
63
+ <li><span class="bv-tick">&#10003;</span> Daily Automatic Backups</li>
64
+ <li><span class="bv-tick">&#10003;</span> Real-Time backups</li>
65
+ <li><span class="bv-tick">&#10003;</span> Personalized Support</li>
66
+ <li><span class="bv-tick">&#10003;</span> Add Users and Clients</li>
67
+ <li><span class="bv-tick">&#10003;</span> White Label Plugin</li>
68
+ <li><span class="bv-tick">&#10003;</span> Client Reporting</li>
69
+ </ul>
70
+ </strong>
71
+ <div class="bv-upgrade-button"><a href="https://blogvault.net/pricing/?utm_source=bv_plugin_lp_pricing&utm_medium=lp_upgrade&utm_campaign=bv_plugin_lp_upgrade&utm_term=upgrade_button&utm_content=button_link">Get Me Pro &raquo;</a></span>
72
+ </div>
73
+ </div>
74
+ <?php } ?>
75
+ </div>
76
+ </div>
admin/footer.php ADDED
@@ -0,0 +1,20 @@
1
+ <footer>
2
+ <div style="background: #45b3e0; margin-top: 20px; padding-top:10px;">
3
+ <div style="width: 850px; margin: 0 auto;">
4
+ <span class="footer-logo" style="color: #FFF; padding: 10px; display: inline-block; font-weight: bold; font-size: 28px; margin-top: 26px; float: left;"> Trusted By </span>
5
+ <span class="footer-logo"><img src="<?php echo plugins_url("/../img/adobe-logo.png", __FILE__); ?>" style="height: 36px; margin-left: 70px;"/></span>
6
+ <span class="footer-logo"><img src="<?php echo plugins_url("/../img/intel-logo.png", __FILE__); ?>" style="height: 38px;" /></span>
7
+ <span class="footer-logo"><img src="<?php echo plugins_url("/../img/wp-site-care-logo.png", __FILE__); ?>" style="height: 32px;" /></span>
8
+ <span class="footer-logo"><img src="<?php echo plugins_url("/../img/valet-logo.png", __FILE__); ?>" style="height: 42px;" /></span>
9
+ <span><img src="<?php echo plugins_url("/../img/yoast-logo.png", __FILE__); ?>" style="height: 32px;" /></span>
10
+ </div>
11
+ </div>
12
+ <div style="background: #45b3e0;">
13
+ <div style="width: 850px; margin: 0 auto;">
14
+ <span class="footer-logo"><img src="<?php echo plugins_url("/../img/cloudways-logo.png", __FILE__); ?>" style="height: 48px; margin-bottom: 10px;" /></span>
15
+ <span class="footer-logo"><img src="<?php echo plugins_url("/../img/wp-engine-logo.png", __FILE__); ?>"/></span>
16
+ <span class="footer-logo"><img src="<?php echo plugins_url("/../img/liquid-web.png", __FILE__); ?>" /></span>
17
+ <span><img src="<?php echo plugins_url("/../img/pressable-logo.png", __FILE__); ?>" /></span>
18
+ </div>
19
+ </div>
20
+ </footer>
admin/header.php ADDED
@@ -0,0 +1,27 @@
1
+ <?php
2
+ if ($this->bvmain->isMalcare()) {
3
+ $headerColor = "#4686f5";
4
+ $pluginSlug = "malcare-security";
5
+ $headerLogoLink = $this->getWebPage() . "/?utm_source=mc_plugin_lp_logo&utm_medium=logo_link&utm_campaign=mc_plugin_lp_header&utm_term=header_logo&utm_content=image_link";
6
+ } else {
7
+ $headerColor = "#25bea0";
8
+ $pluginSlug = "blogvault-real-time-backup";
9
+ $headerLogoLink = $this->getWebPage() . "/?utm_source=bv_plugin_lp_logo&utm_medium=logo_link&utm_campaign=bv_plugin_lp_header&utm_term=header_logo&utm_content=image_link";
10
+ }
11
+ ?>
12
+ <div id="content-wrapper" style="width: 99%;">
13
+ <!-- Content HTML goes here -->
14
+ <div class="mui-container-fluid">
15
+ <div class="mui--appbar-height"></div>
16
+ <br><br>
17
+ <div class="mui-row">
18
+ <div style="background: <?php echo $headerColor;?>; overflow: hidden;">
19
+ <a href="<?php echo $headerLogoLink; ?>"><img src="<?php echo plugins_url($this->getPluginLogo(), __FILE__); ?>" style="padding: 10px;"></a>
20
+ <div class="top-links">
21
+ <span class="bv-top-button"><a href="https://wordpress.org/support/plugin/<?php echo $pluginSlug; ?>/reviews/#new-post">Leave a Review</a></span>
22
+ <span class="bv-top-button"><a href="https://wordpress.org/support/plugin/<?php echo $pluginSlug; ?>/">Need Help?</a></span>
23
+ </div>
24
+ </div>
25
+ </div>
26
+ </div>
27
+ </div>
admin/main_page.php ADDED
@@ -0,0 +1,38 @@
1
+ <div id="content-wrapper">
2
+ <div class="bv-box" style= "width: 800px; margin: 20px auto; overflow: hidden; padding: 15px;">
3
+ <?php require_once dirname( __FILE__ ) . "/top_box.php";?>
4
+ </div>
5
+ <div class="mui-container-fluid">
6
+ <?php $accounts = $this->account->allAccounts();?>
7
+ <div class="mui-panel" style="width:800px; margin:0 auto;border:1px solid #CCC;">
8
+ <div class="mui--text-body1" style="text-align:center;font-size:18px;">Accounts associated with this website.</div><br/>
9
+ <table cellpadding="10" style="width:700px; margin:0 auto;border:1px solid black;">
10
+ <tr style="text-align:center;font-size:15px;border: 1px solid black;"> <th> Account Email</th><th>Last Synced At</th><th></th></tr>
11
+ <?php
12
+ $nonce = wp_create_nonce( 'bvnonce' );
13
+ foreach($accounts as $key => $value){
14
+ ?>
15
+ <form dummy=">" action="" style="padding:0 2% 2em 1%;" method="post">
16
+ <input type='hidden' name='bvnonce' value="<?php echo $nonce ?>" />
17
+ <input type='hidden' name='pubkey' value="<?php echo $key ?>" />
18
+ <tr style="text-align:center;font-size:15px;border: 1px solid black;">
19
+ <td >
20
+ <?php echo $value['email'] ?>
21
+ </td>
22
+ <td>
23
+ <?php echo date('Y-m-d H:i:s', $value['lastbackuptime']); ?>
24
+ </td>
25
+ <td >
26
+ <input type='submit' class="button-primary" value='Disconnect' name='disconnect'>
27
+ </td>
28
+ </tr>
29
+ </form>
30
+ <?php } ?>
31
+ </table>
32
+ <div class="mui-col-md-12 mui-col-md-offset-3" style="padding-top:2%;">
33
+ <a class="mui-btn mui-btn--raised mui-btn--primary" href=<?php echo $this->bvmain->appUrl(); ?> target="_blank">Visit Dashboard</a>
34
+ <a class="mui-btn mui-btn--raised mui-btn--primary" href=<?php echo $this->mainUrl('&add_account=true'); ?> >Connect New Account</a>
35
+ </div>
36
+ </div>
37
+ </div>
38
+ </div>
admin/top_box.php ADDED
@@ -0,0 +1,21 @@
1
+ <?php
2
+ if ($this->bvmain->isMalcare()) {
3
+ $mainTitle = "Are you Hacked? Scan Your Website for FREE.";
4
+ $videoId = "rBuYh2dIadk";
5
+ $testimonialImg = "/../img/testimonial_mc.png";
6
+ } else {
7
+ $mainTitle = "Create Smart Incremental Backups On Cloud.";
8
+ $videoId = "Y4teDRL08mY";
9
+ $testimonialImg = "/../img/testimonial_bv.png";
10
+ }
11
+ ?>
12
+ <div class="mui--text-title main-title"><?php echo $mainTitle; ?></div>
13
+ <br/><br/>
14
+ <div style= "width: 800px; margin: 20px auto; overflow: hidden;">
15
+ <div style="width: 49%; float: left; border-right: 2px solid #333;">
16
+ <iframe width="380" height="215" src="https://www.youtube.com/embed/<?php echo $videoId; ?>"></iframe>
17
+ </div>
18
+ <div style="width: 49%; float: right;">
19
+ <img src="<?php echo plugins_url($testimonialImg, __FILE__); ?>"/>
20
+ </div>
21
+ </div>
blogvault.php ADDED
@@ -0,0 +1,97 @@
1
+ <?php
2
+ /*
3
+ Plugin Name: WordPress Backup & Security Plugin - BlogVault
4
+ Plugin URI: https://blogvault.net
5
+ Description: Easiest way to backup & secure your WordPress site
6
+ Author: Backup by BlogVault
7
+ Author URI: https://blogvault.net
8
+ Version: 1.88
9
+ Network: True
10
+ */
11
+
12
+ /* Copyright 2017 BlogVault (email : support@blogvault.net)
13
+
14
+ This program is free software; you can redistribute it and/or modify
15
+ it under the terms of the GNU General Public License, version 2, as
16
+ published by the Free Software Foundation.
17
+
18
+ This program is distributed in the hope that it will be useful,
19
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ GNU General Public License for more details.
22
+
23
+ You should have received a copy of the GNU General Public License
24
+ along with this program; if not, write to the Free Software
25
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
+ */
27
+
28
+ /* Global response array */
29
+
30
+ if (!defined('ABSPATH')) exit;
31
+ global $bvcb, $bvresp;
32
+
33
+ require_once dirname( __FILE__ ) . '/main.php';
34
+ $bvmain = new BVBackup();
35
+
36
+ register_uninstall_hook(__FILE__, array('BVBackup', 'uninstall'));
37
+ register_activation_hook(__FILE__, array($bvmain, 'activate'));
38
+ register_deactivation_hook(__FILE__, array($bvmain, 'deactivate'));
39
+
40
+ add_action('wp_footer', array($bvmain, 'footerHandler'), 100);
41
+
42
+ if (is_admin()) {
43
+ require_once dirname( __FILE__ ) . '/admin.php';
44
+ $bvadmin = new BVAdmin($bvmain);
45
+ add_action('admin_init', array($bvadmin, 'initHandler'));
46
+ add_filter('all_plugins', array($bvadmin, 'initBranding'));
47
+ add_filter('plugin_row_meta', array($bvadmin, 'hidePluginDetails'), 10, 2);
48
+ if ($bvmain->info->isMultisite()) {
49
+ add_action('network_admin_menu', array($bvadmin, 'menu'));
50
+ } else {
51
+ add_action('admin_menu', array($bvadmin, 'menu'));
52
+ }
53
+ add_filter('plugin_action_links', array($bvadmin, 'settingsLink'), 10, 2);
54
+ add_action('admin_notices', array($bvadmin, 'activateWarning'));
55
+ ##ADMINENQUEUESCRIPTS##
56
+ }
57
+
58
+ if ((array_key_exists('bvreqmerge', $_POST)) || (array_key_exists('bvreqmerge', $_GET))) {
59
+ $_REQUEST = array_merge($_GET, $_POST);
60
+ }
61
+
62
+ if ((array_key_exists('bvplugname', $_REQUEST)) &&
63
+ stristr($_REQUEST['bvplugname'], $bvmain->plugname)) {
64
+ require_once dirname( __FILE__ ) . '/callback.php';
65
+ $bvcb = new BVCallback($bvmain);
66
+ $bvresp = new BVResponse();
67
+ if ($bvcb->preauth() === 1) {
68
+ if ($bvcb->authenticate() === 1) {
69
+ if (array_key_exists('afterload', $_REQUEST)) {
70
+ add_action('wp_loaded', array($bvcb, 'execute'));
71
+ } else if (array_key_exists('adajx', $_REQUEST)) {
72
+ add_action('wp_ajax_bvadm', array($bvcb, 'bvAdmExecuteWithUser'));
73
+ add_action('wp_ajax_nopriv_bvadm', array($bvcb, 'bvAdmExecuteWithoutUser'));
74
+ } else {
75
+ $bvcb->execute();
76
+ }
77
+ } else {
78
+ $bvcb->terminate(false, array_key_exists('bvdbg', $_REQUEST));
79
+ }
80
+ }
81
+ } else {
82
+ if ($bvmain->isProtectModuleEnabled()) {
83
+ require_once dirname( __FILE__ ) . '/protect.php';
84
+ $bvprotect = new BVProtect($bvmain);
85
+ $bvprotect->init();
86
+ require_once dirname( __FILE__ ) . '/ipstore.php';
87
+ $bvipstore = new BVIPStore($bvmain);
88
+ $bvipstore->init();
89
+ }
90
+
91
+ if ($bvmain->isDynSyncModuleEnabled()) {
92
+ require_once dirname( __FILE__ ) . '/dynsync.php';
93
+ $dynsync = new BVDynSync($bvmain);
94
+ $dynsync->init();
95
+ }
96
+
97
+ }
callback.php ADDED
@@ -0,0 +1,251 @@
1
+ <?php
2
+
3
+ if (!defined('ABSPATH')) exit;
4
+ if (!class_exists('BVCallback')) :
5
+
6
+ require_once dirname( __FILE__ ) . '/callback/response.php';
7
+
8
+ class BVCallback {
9
+ public $bvmain;
10
+ function __construct($bvmain) {
11
+ $this->bvmain = $bvmain;
12
+ }
13
+
14
+ public function serversig($full = false) {
15
+ $sig = sha1($_SERVER['SERVER_ADDR'].ABSPATH);
16
+ if ($full)
17
+ return $sig;
18
+ else
19
+ return substr($sig, 0, 6);
20
+ }
21
+
22
+ public function terminate($with_basic, $bvdebug = false) {
23
+ global $bvresp;
24
+ $public = $this->bvmain->auth->defaultPublic();
25
+ $bvresp->addStatus("signature", "Blogvault API");
26
+ $bvresp->addStatus("asymauth", "true");
27
+ $bvresp->addStatus("sha1", "true");
28
+ $bvresp->addStatus("dbsig", $this->bvmain->lib->dbsig(false));
29
+ $bvresp->addStatus("serversig", $this->serversig(false));
30
+ $bvresp->addStatus("public", substr($public, 0, 6));
31
+ if (array_key_exists('adajx', $_REQUEST)) {
32
+ $bvresp->addStatus("adajx", true);
33
+ }
34
+ if ($with_basic) {
35
+ $binfo = array();
36
+ $this->bvmain->info->basic($binfo);
37
+ $bvresp->addStatus("basic", $binfo);
38
+ $bvresp->addStatus("bvversion", $this->bvmain->version);
39
+ }
40
+
41
+ if ($bvdebug) {
42
+ $bvresp->addStatus("inreq", $_REQUEST);
43
+ }
44
+
45
+ $bvresp->finish();
46
+ exit;
47
+ }
48
+
49
+ public function processParams() {
50
+ if (array_key_exists('concat', $_REQUEST)) {
51
+ foreach ($_REQUEST['concat'] as $key) {
52
+ $concated = '';
53
+ $count = intval($_REQUEST[$key]);
54
+ for ($i = 1; $i <= $count; $i++) {
55
+ $concated .= $_REQUEST[$key."_bv_".$i];
56
+ }
57
+ $_REQUEST[$key] = $concated;
58
+ }
59
+ }
60
+ if (array_key_exists('b64', $_REQUEST)) {
61
+ foreach ($_REQUEST['b64'] as $key) {
62
+ if (is_array($_REQUEST[$key])) {
63
+ $_REQUEST[$key] = array_map('base64_decode', $_REQUEST[$key]);
64
+ } else {
65
+ $_REQUEST[$key] = base64_decode($_REQUEST[$key]);
66
+ }
67
+ }
68
+ }
69
+ if (array_key_exists('unser', $_REQUEST)) {
70
+ foreach ($_REQUEST['unser'] as $key) {
71
+ $_REQUEST[$key] = json_decode($_REQUEST[$key], TRUE);
72
+ }
73
+ }
74
+ if (array_key_exists('b642', $_REQUEST)) {
75
+ foreach ($_REQUEST['b642'] as $key) {
76
+ if (is_array($_REQUEST[$key])) {
77
+ $_REQUEST[$key] = array_map('base64_decode', $_REQUEST[$key]);
78
+ } else {
79
+ $_REQUEST[$key] = base64_decode($_REQUEST[$key]);
80
+ }
81
+ }
82
+ }
83
+ if (array_key_exists('dic', $_REQUEST)) {
84
+ foreach ($_REQUEST['dic'] as $key => $mkey) {
85
+ $_REQUEST[$mkey] = $_REQUEST[$key];
86
+ unset($_REQUEST[$key]);
87
+ }
88
+ }
89
+ if (array_key_exists('clacts', $_REQUEST)) {
90
+ foreach ($_REQUEST['clacts'] as $action) {
91
+ remove_all_actions($action);
92
+ }
93
+ }
94
+ if (array_key_exists('clallacts', $_REQUEST)) {
95
+ global $wp_filter;
96
+ foreach ( $wp_filter as $filter => $val ){
97
+ remove_all_actions($filter);
98
+ }
99
+ }
100
+ if (array_key_exists('memset', $_REQUEST)) {
101
+ $val = intval(urldecode($_REQUEST['memset']));
102
+ @ini_set('memory_limit', $val.'M');
103
+ }
104
+ }
105
+
106
+ public function recover() {
107
+ $recover = new BVRecover(base64_decode($_REQUEST['sig']), $_REQUEST['orig'],
108
+ $_REQUEST['keyname'], $_REQUEST["keysize"]);
109
+ if ($recover->validate() && ($recover->process() === 1)) {
110
+ $recover->processKeyExchange();
111
+ return 1;
112
+ }
113
+ return false;
114
+ }
115
+
116
+ public function preauth() {
117
+ global $bvresp;
118
+ if (array_key_exists('obend', $_REQUEST) && function_exists('ob_end_clean'))
119
+ @ob_end_clean();
120
+ if (array_key_exists('op_reset', $_REQUEST) && function_exists('output_reset_rewrite_vars'))
121
+ @output_reset_rewrite_vars();
122
+ if (array_key_exists('binhead', $_REQUEST)) {
123
+ header("Content-type: application/binary");
124
+ header('Content-Transfer-Encoding: binary');
125
+ }
126
+ if (array_key_exists('bvrcvr', $_REQUEST)) {
127
+ require_once dirname( __FILE__ ) . '/callback/recover.php';
128
+ if ($this->recover() !== 1) {
129
+ $bvresp->addStatus("statusmsg", 'failed authentication');
130
+ }
131
+ $this->terminate(false, array_key_exists('bvdbg', $_REQUEST));
132
+ return false;
133
+ }
134
+ return 1;
135
+ }
136
+
137
+ public function authenticate() {
138
+ global $bvresp;
139
+ $auth = $this->bvmain->auth;
140
+ $method = $_REQUEST['bvMethod'];
141
+ $time = intval($_REQUEST['bvTime']);
142
+ $version = $_REQUEST['bvVersion'];
143
+ $sig = $_REQUEST['sig'];
144
+ $public = $auth->publicParam();
145
+
146
+ $bvresp->addStatus("requestedsig", $sig);
147
+ $bvresp->addStatus("requestedtime", $time);
148
+ $bvresp->addStatus("requestedversion", $version);
149
+
150
+ $sig_match = $auth->validate($public, $method, $time, $version, $sig);
151
+ if ($sig_match === 1) {
152
+ return 1;
153
+ } else {
154
+ $bvresp->addStatus("sigmatch", substr($sig_match, 0, 6));
155
+ $bvresp->addStatus("statusmsg", 'failed authentication');
156
+ return false;
157
+ }
158
+ }
159
+
160
+ public function route($wing, $method) {
161
+ global $bvresp;
162
+ $bvresp->addStatus("callback", $method);
163
+ switch ($wing) {
164
+ case 'manage':
165
+ require_once dirname( __FILE__ ) . '/callback/wings/manage.php';
166
+ $module = new BVManageCallback();
167
+ break;
168
+ case 'fs':
169
+ require_once dirname( __FILE__ ) . '/callback/wings/fs.php';
170
+ $module = new BVFSCallback();
171
+ break;
172
+ case 'db':
173
+ require_once dirname( __FILE__ ) . '/callback/wings/db.php';
174
+ $module = new BVDBCallback();
175
+ break;
176
+ case 'info':
177
+ require_once dirname( __FILE__ ) . '/callback/wings/info.php';
178
+ $module = new BVInfoCallback();
179
+ break;
180
+ case 'dynsync':
181
+ require_once dirname( __FILE__ ) . '/callback/wings/dynsync.php';
182
+ $module = new BVDynSyncCallback();
183
+ break;
184
+ case 'ipstr':
185
+ require_once dirname( __FILE__ ) . '/callback/wings/ipstore.php';
186
+ $module = new BVIPStoreCallback();
187
+ break;
188
+ case 'auth':
189
+ require_once dirname( __FILE__ ) . '/callback/wings/auth.php';
190
+ $module = new BVAuthCallback();
191
+ break;
192
+ case 'fw':
193
+ require_once dirname( __FILE__ ) . '/callback/wings/fw.php';
194
+ $module = new BVFirewallCallback();
195
+ break;
196
+ case 'lp':
197
+ require_once dirname( __FILE__ ) . '/callback/wings/lp.php';
198
+ $module = new BVLoginProtectCallback();
199
+ break;
200
+ case 'monit':
201
+ require_once dirname( __FILE__ ) . '/callback/wings/monit.php';
202
+ $module = new BVMonitCallback();
203
+ break;
204
+ case 'brand':
205
+ require_once dirname( __FILE__ ) . '/callback/wings/brand.php';
206
+ $module = new BVBrandCallback();
207
+ break;
208
+ case 'pt':
209
+ require_once dirname( __FILE__ ) . '/callback/wings/protect.php';
210
+ $module = new BVProtectCallback();
211
+ break;
212
+ case 'act':
213
+ require_once dirname( __FILE__ ) . '/callback/wings/account.php';
214
+ $module = new BVAccountCallback();
215
+ break;
216
+ default:
217
+ require_once dirname( __FILE__ ) . '/callback/wings/misc.php';
218
+ $module = new BVMiscCallback();
219
+ break;
220
+ }
221
+ $rval = $module->process($method);
222
+ if ($rval === false) {
223
+ $bvresp->addStatus("statusmsg", "Bad Command");
224
+ $bvresp->addStatus("status", false);
225
+ }
226
+ return 1;
227
+ }
228
+
229
+ public function bvAdmExecuteWithoutUser() {
230
+ global $bvresp;
231
+ $bvresp->addStatus("bvadmwithoutuser", true);
232
+ $this->execute();
233
+ }
234
+
235
+ public function bvAdmExecuteWithUser() {
236
+ global $bvresp;
237
+ $bvresp->addStatus("bvadmwithuser", true);
238
+ $this->execute();
239
+ }
240
+
241
+ public function execute() {
242
+ global $bvresp;
243
+ $this->processParams();
244
+ if ($bvresp->startStream()) {
245
+ $this->route($_REQUEST['wing'], $_REQUEST['bvMethod']);
246
+ $bvresp->endStream();
247
+ }
248
+ $this->terminate(true, array_key_exists('bvdbg', $_REQUEST));
249
+ }
250
+ }
251
+ endif;
callback/recover.php ADDED
@@ -0,0 +1,76 @@
1
+ <?php
2
+
3
+ if (!defined('ABSPATH')) exit;
4
+ if (!class_exists('BVRecover')) :
5
+ class BVRecover {
6
+ public $keyname;
7
+ public $keysize;
8
+ public $signature;
9
+ public $original;
10
+
11
+ function __construct($_sig, $_orig, $_keyname, $_keysize) {
12
+ $this->keyname = $_keyname;
13
+ $this->keysize = $_keysize;
14
+ $this->signature = $_sig;
15
+ $this->original = $_orig;
16
+ }
17
+
18
+ public function keyFile() {
19
+ return dirname(__DIR__)."/publickeys/$this->keyname.pub";
20
+ }
21
+
22
+ public function getAsymKey() {
23
+ return file_get_contents($this->keyFile());
24
+ }
25
+
26
+ public function asymEncrypt($source) {
27
+ $output = '';
28
+ $blocksize = 1 + floor(($this->keysize - 1) / 8) - 11;
29
+ while ($source) {
30
+ $input = substr($source, 0, $blocksize);
31
+ $source = substr($source, $blocksize);
32
+ openssl_public_encrypt($input, $encrypted, $this->getAsymKey());
33
+
34
+ $output .= $encrypted;
35
+ }
36
+ return base64_encode($output);
37
+ }
38
+
39
+ public function validate() {
40
+ global $bvresp;
41
+ if (!preg_match('/^\w+#x2F;', $this->keyname)) {
42
+ $bvresp->addStatus('asymerror', 'badkey');
43
+ return false;
44
+ } else if (!file_exists($this->keyFile())) {
45
+ $bvresp->addStatus('asymerror', 'missingkey');
46
+ return false;
47
+ } else if (!function_exists('openssl_public_decrypt')) {
48
+ $bvresp->addStatus('asymerror', 'openssl_public_decrypt');
49
+ return false;
50
+ } else if (!function_exists('openssl_public_encrypt')) {
51
+ $bvresp->addStatus('asymerror', 'openssl_public_encrypt');
52
+ return false;
53
+ }
54
+ return true;
55
+ }
56
+
57
+ public function process() {
58
+ openssl_public_decrypt($this->signature, $decrypted, $this->getAsymKey());
59
+ if ((strlen($decrypted) >= 32) && ($this->original === substr($decrypted, 0, 32))) {
60
+ return 1;
61
+ }
62
+ return false;
63
+ }
64
+
65
+ public function processKeyExchange() {
66
+ global $bvresp, $bvcb;
67
+ $bvmain = $bvcb->bvmain;
68
+ $keys = $bvmain->auth->allKeys();
69
+ $keys['dbsig'] = $bvmain->lib->dbsig(true);
70
+ $keys['salt'] = $bvmain->lib->randString(32);
71
+ $bvresp->addStatus("activatetime", $bvmain->info->getOption('bvActivateTime'));
72
+ $bvresp->addStatus("currenttime", time());
73
+ $bvresp->addStatus("keys", $this->asymEncrypt(serialize($keys)));
74
+ }
75
+ }
76
+ endif;
callback/response.php ADDED
@@ -0,0 +1,107 @@
1
+ <?php
2
+
3
+ if (!defined('ABSPATH')) exit;
4
+ if (!class_exists('BVResponse')) :
5
+
6
+ require_once dirname( __FILE__ ) . '/streams.php';
7
+
8
+ class BVResponse {
9
+ public $status;
10
+ public $stream;
11
+
12
+ function __construct() {
13
+ $this->status = array("blogvault" => "response");
14
+ }
15
+
16
+ public function addStatus($key, $value) {
17
+ $this->status[$key] = $value;
18
+ }
19
+
20
+ public function addArrayToStatus($key, $value) {
21
+ if (!isset($this->status[$key])) {
22
+ $this->status[$key] = array();
23
+ }
24
+ $this->status[$key][] = $value;
25
+ }
26
+
27
+ public function base64Encode($data, $chunk_size) {
28
+ if ($chunk_size) {
29
+ $out = "";
30
+ $len = strlen($data);
31
+ for ($i = 0; $i < $len; $i += $chunk_size) {
32
+ $out .= base64_encode(substr($data, $i, $chunk_size));
33
+ }
34
+ } else {
35
+ $out = base64_encode($data);
36
+ }
37
+ return $out;
38
+ }
39
+
40
+ public function finish() {
41
+ $response = "bvbvbvbvbv".serialize($this->status)."bvbvbvbvbv";
42
+ if (array_key_exists('bvb64resp', $_REQUEST)) {
43
+ $chunk_size = array_key_exists('bvb64cksize', $_REQUEST) ? intval($_REQUEST['bvb64cksize']) : false;
44
+ $response = "bvb64bvb64".$this->base64Encode($response, $chunk_size)."bvb64bvb64";
45
+ }
46
+ die($response);
47
+ }
48
+
49
+ public function writeStream($_string) {
50
+ if (strlen($_string) > 0) {
51
+ $chunk = "";
52
+ if (isset($_REQUEST['bvb64stream'])) {
53
+ $chunk_size = array_key_exists('bvb64cksize', $_REQUEST) ? intval($_REQUEST['bvb64cksize']) : false;
54
+ $_string = $this->base64Encode($_string, $chunk_size);
55
+ $chunk .= "BVB64" . ":";
56
+ }
57
+ $chunk .= (strlen($_string) . ":" . $_string);
58
+ if (isset($_REQUEST['checksum'])) {
59
+ if ($_REQUEST['checksum'] == 'crc32') {
60
+ $chunk = "CRC32" . ":" . crc32($_string) . ":" . $chunk;
61
+ } else if ($_REQUEST['checksum'] == 'md5') {
62
+ $chunk = "MD5" . ":" . md5($_string) . ":" . $chunk;
63
+ }
64
+ }
65
+ $this->stream->writeChunk($chunk);
66
+ }
67
+ }
68
+
69
+ public function startStream() {
70
+ global $bvcb;
71
+ $this->stream = new BVRespStream();
72
+ if (array_key_exists('apicall',$_REQUEST)) {
73
+ $this->stream = new BVHttpStream($_REQUEST['apihost'], intval($_REQUEST['apiport']), array_key_exists('apissl', $_REQUEST));
74
+ if (!$this->stream->connect()) {
75
+ $this->addStatus("httperror", "Cannot Open Connection to Host");
76
+ $this->addStatus("streamerrno", $this->stream->errno);
77
+ $this->addStatus("streamerrstr", $this->stream->errstr);
78
+ return false;
79
+ }
80
+ if (array_key_exists('acbmthd', $_REQUEST)) {
81
+ $url = $bvcb->bvmain->authenticatedUrl('/bvapi/'.$_REQUEST['acbmthd'], $_REQUEST['bvapicheck'], false);
82
+ if (array_key_exists('acbqry', $_REQUEST)) {
83
+ $url .= "&".$_REQUEST['acbqry'];
84
+ }
85
+ $this->stream->multipartChunkedPost($url);
86
+ } else {
87
+ $this->addStatus("httperror", "ApiCall method not present");
88
+ return false;
89
+ }
90
+ }
91
+ return true;
92
+ }
93
+
94
+ public function endStream() {
95
+ $this->stream->endStream();
96
+ if (array_key_exists('apicall', $_REQUEST)) {
97
+ $resp = $this->stream->getResponse();
98
+ if (array_key_exists('httperror', $resp)) {
99
+ $this->addStatus("httperror", $resp['httperror']);
100
+ } else {
101
+ $this->addStatus("respstatus", $resp['status']);
102
+ $this->addStatus("respstatus_string", $resp['status_string']);
103
+ }
104
+ }
105
+ }
106
+ }
107
+ endif;
callback/streams.php ADDED
@@ -0,0 +1,166 @@
1
+ <?php
2
+
3
+ if (!defined('ABSPATH')) exit;
4
+ if (!class_exists('BVRespStream')) :
5
+
6
+ class BVRespStream {
7
+ public function writeChunk($_string) {
8
+ echo "ckckckckck".$_string."ckckckckck";
9
+ }
10
+
11
+ public function endStream() {
12
+ echo "rerererere";
13
+ }
14
+ }
15
+
16
+ class BVHttpStream {
17
+ var $user_agent = 'BVHttpStream';
18
+ var $host;
19
+ var $port;
20
+ var $timeout = 20;
21
+ var $conn;
22
+ var $errno;
23
+ var $errstr;
24
+ var $boundary;
25
+ var $apissl;
26
+
27
+ /**
28
+ * PHP5 constructor.
29
+ */
30
+ function __construct($_host, $_port, $_apissl) {
31
+ $this->host = $_host;
32
+ $this->port = $_port;
33
+ $this->apissl = $_apissl;
34
+ }
35
+
36
+ public function connect() {
37
+ if ($this->apissl && function_exists('stream_socket_client')) {
38
+ $this->conn = stream_socket_client("ssl://".$this->host.":".$this->port, $errno, $errstr, $this->timeout);
39
+ } else {
40
+ $this->conn = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);
41
+ }
42
+ if (!$this->conn) {
43
+ $this->errno = $errno;
44
+ $this->errstr = $errstr;
45
+ return false;
46
+ }
47
+ socket_set_timeout($this->conn, $this->timeout);
48
+ return true;
49
+ }
50
+
51
+ public function write($data) {
52
+ fwrite($this->conn, $data);
53
+ }
54
+
55
+ public function sendChunk($data) {
56
+ $this->write(sprintf("%x\r\n", strlen($data)));
57
+ $this->write($data);
58
+ $this->write("\r\n");
59
+ }
60
+
61
+ public function sendRequest($method, $url, $headers = array(), $body = null) {
62
+ $def_hdrs = array("Connection" => "keep-alive",
63
+ "Host" => $this->host);
64
+ $headers = array_merge($def_hdrs, $headers);
65
+ $request = strtoupper($method)." ".$url." HTTP/1.1\r\n";
66
+ if (null != $body) {
67
+ $headers["Content-length"] = strlen($body);
68
+ }
69
+ foreach($headers as $key=>$val) {
70
+ $request .= $key.":".$val."\r\n";
71
+ }
72
+ $request .= "\r\n";
73
+ if (null != $body) {
74
+ $request .= $body;
75
+ }
76
+ $this->write($request);
77
+ return $request;
78
+ }
79
+
80
+ public function post($url, $headers = array(), $body = "") {
81
+ if(is_array($body)) {
82
+ $b = "";
83
+ foreach($body as $key=>$val) {
84
+ $b .= $key."=".urlencode($val)."&";
85
+ }
86
+ $body = substr($b, 0, strlen($b) - 1);
87
+ }
88
+ $this->sendRequest("POST", $url, $headers, $body);
89
+ }
90
+
91
+ public function streamedPost($url, $headers = array()) {
92
+ $headers['Transfer-Encoding'] = "chunked";
93
+ $this->sendRequest("POST", $url, $headers);
94
+ }
95
+
96
+ public function multipartChunkedPost($url) {
97
+ $mph = array(
98
+ "Content-Disposition" => "form-data; name=bvinfile; filename=data",
99
+ "Content-Type" => "application/octet-stream"
100
+ );
101
+ $rnd = rand(100000, 999999);
102
+ $this->boundary = "----".$rnd;
103
+ $prologue = "--".$this->boundary."\r\n";
104
+ foreach($mph as $key=>$val) {
105
+ $prologue .= $key.":".$val."\r\n";
106
+ }
107
+ $prologue .= "\r\n";
108
+ $headers = array('Content-Type' => "multipart/form-data; boundary=".$this->boundary);
109
+ $this->streamedPost($url, $headers);
110
+ $this->sendChunk($prologue);
111
+ }
112
+
113
+ public function writeChunk($data) {
114
+ $this->sendChunk($data);
115
+ }
116
+
117
+ public function closeChunk() {
118
+ $this->sendChunk("");
119
+ }
120
+
121
+ public function endStream() {
122
+ $epilogue = "\r\n\r\n--".$this->boundary."--\r\n";
123
+ $this->sendChunk($epilogue);
124
+ $this->closeChunk();
125
+ }
126
+
127
+ public function getResponse() {
128
+ $response = array();
129
+ $response['headers'] = array();
130
+ $state = 1;
131
+ $conlen = 0;
132
+ stream_set_timeout($this->conn, 300);
133
+ while (!feof($this->conn)) {
134
+ $line = fgets($this->conn, 4096);
135
+ if (1 == $state) {
136
+ if (!preg_match('/HTTP\/(\\d\\.\\d)\\s*(\\d+)\\s*(.*)/', $line, $m)) {
137
+ $response['httperror'] = "Status code line invalid: ".htmlentities($line);
138
+ return $response;
139
+ }
140
+ $response['http_version'] = $m[1];
141
+ $response['status'] = $m[2];
142
+ $response['status_string'] = $m[3];
143
+ $state = 2;
144
+ } else if (2 == $state) {
145
+ # End of headers
146
+ if (2 == strlen($line)) {
147
+ if ($conlen > 0)
148
+ $response['body'] = fread($this->conn, $conlen);
149
+ return $response;
150
+ }
151
+ if (!preg_match('/([^:]+):\\s*(.*)/', $line, $m)) {
152
+ // Skip to the next header
153
+ continue;
154
+ }
155
+ $key = strtolower(trim($m[1]));
156
+ $val = trim($m[2]);
157
+ $response['headers'][$key] = $val;
158
+ if ($key == "content-length") {
159
+ $conlen = intval($val);
160
+ }
161
+ }
162
+ }
163
+ return $response;
164
+ }
165
+ }
166
+ endif;
callback/wings/account.php ADDED
@@ -0,0 +1,34 @@
1
+ <?php
2
+
3
+ if (!defined('ABSPATH')) exit;
4
+ if (!class_exists('BVAccountCallback')) :
5
+
6
+ require_once dirname( __FILE__ ) . '/../../account.php';
7
+
8
+ class BVAccountCallback {
9
+
10
+ function process($method) {
11
+ global $bvresp, $bvcb;
12
+ $account = new BVAccountInfo($bvcb->bvmain);
13
+ switch ($method) {
14
+ case "updt":
15
+ $info = array();
16
+ $info['email'] = $_REQUEST['email'];
17
+ $info['url'] = $_REQUEST['url'];
18
+ $info['pubkey'] = $_REQUEST['pubkey'];
19
+ $account->add($info);
20
+ $bvresp->addStatus("status", $account->doesAccountExists($_REQUEST['pubkey']));
21
+ break;
22
+ case "disc":
23
+ $account->remove($_REQUEST['pubkey']);
24
+ $bvresp->addStatus("status", !$account->doesAccountExists($_REQUEST['pubkey']));
25
+ case "fetch":
26
+ $bvresp->addStatus("status", $account->allAccounts());
27
+ break;
28
+ default:
29
+ return false;
30
+ }
31
+ return true;
32
+ }
33
+ }
34
+ endif;
callback/wings/auth.php ADDED
@@ -0,0 +1,26 @@
1
+ <?php
2
+
3
+ if (!defined('ABSPATH')) exit;
4
+ if (!class_exists('BVAuthCallback')) :
5
+ class BVAuthCallback {
6
+
7
+ function process($method) {
8
+ global $bvresp, $bvcb;
9
+ $auth = $bvcb->bvmain->auth;
10
+ switch ($method) {
11
+ case "addkeys":
12
+ $bvresp->addStatus("status", $auth->addKeys($_REQUEST['public'], $_REQUEST['secret']));
13
+ break;
14
+ case "updatekeys":
15
+ $bvresp->addStatus("status", $auth->updateKeys($_REQUEST['public'], $_REQUEST['secret']));
16
+ break;
17
+ case "rmkeys":
18
+ $bvresp->addStatus("status", $auth->rmKeys($_REQUEST['public']));
19
+ break;
20
+ default:
21
+ return false;
22
+ }
23
+ return true;
24
+ }
25
+ }
26
+ endif;
callback/wings/brand.php ADDED
@@ -0,0 +1,48 @@
1
+ <?php
2
+
3
+ if (!defined('ABSPATH')) exit;
4
+ if (!class_exists('BVBrandCallback')) :
5
+
6
+ class BVBrandCallback {
7
+ public function process($method) {
8
+ global $bvresp, $bvcb;
9
+ $info = $bvcb->bvmain->info;
10
+ $option_name = $bvcb->bvmain->brand_option;
11
+ switch($method) {
12
+ case 'setbrand':
13
+ $brandinfo = array();
14
+ if (array_key_exists('hide', $_REQUEST)) {
15
+ $brandinfo['hide'] = $_REQUEST['hide'];
16
+ } else {
17
+ $brandinfo['name'] = $_REQUEST['name'];
18
+ $brandinfo['title'] = $_REQUEST['title'];
19
+ $brandinfo['description'] = $_REQUEST['description'];
20
+ $brandinfo['pluginuri'] = $_REQUEST['pluginuri'];
21
+ $brandinfo['author'] = $_REQUEST['author'];
22
+ $brandinfo['authorname'] = $_REQUEST['authorname'];
23
+ $brandinfo['authoruri'] = $_REQUEST['authoruri'];
24
+ $brandinfo['menuname'] = $_REQUEST['menuname'];
25
+ $brandinfo['logo'] = $_REQUEST['logo'];
26
+ $brandinfo['webpage'] = $_REQUEST['webpage'];
27
+ $brandinfo['appurl'] = $_REQUEST['appurl'];
28
+ if (array_key_exists('hide_plugin_details', $_REQUEST)) {
29
+ $brandinfo['hide_plugin_details'] = $_REQUEST['hide_plugin_details'];
30
+ }
31
+ if (array_key_exists('hide_from_menu', $_REQUEST)) {
32
+ $brandinfo['hide_from_menu'] = $_REQUEST['hide_from_menu'];
33
+ }
34
+ }
35
+ $info->updateOption($option_name, $brandinfo);
36
+ $bvresp->addStatus("setbrand", $info->getOption($option_name));
37
+ break;
38
+ case 'rmbrand':
39
+ $info->deleteOption($option_name);
40
+ $bvresp->addStatus("rmbrand", !$info->getOption($option_name));
41
+ break;
42
+ default:
43
+ return false;
44
+ }
45
+ return true;
46
+ }
47
+ }
48
+ endif;
callback/wings/bv_upgrader_skin.php ADDED
@@ -0,0 +1,68 @@
1
+ <?php
2
+
3
+ if (!defined('ABSPATH')) exit;
4
+ if (!class_exists('BVUpgraderSkin')) :
5
+ class BVUpgraderSkin extends WP_Upgrader_Skin {
6
+ public $action = '';
7
+ public $plugin_info = array();
8
+ public $theme_info = array();
9
+ public $language_update = null;
10
+
11
+ function __construct($type, $package = '') {
12
+ $this->action = $type;
13
+ $this->package = $package;
14
+ parent::__construct(array());
15
+ }
16
+
17
+ function header() {}
18
+
19
+ function footer() {}
20
+
21
+ function get_key() {
22
+ $key = "bvgeneral";
23
+ switch ($this->action) {
24
+ case "theme_upgrade":
25
+ if (!empty($this->theme_info))
26
+ $key = $this->theme_info['Name'];
27
+ break;
28
+ case "plugin_upgrade":
29
+ if (!empty($this->plugin_info))
30
+ $key = $this->plugin_info['Name'];
31
+ break;
32
+ case "installer":
33
+ if (!empty($this->package))
34
+ $key = $this->package;
35
+ break;
36
+ case "upgrade_translations":
37
+ if (null != $this->language_update)
38
+ $key = $this->language_update->package;
39
+ break;
40
+ }
41
+ return $key;
42
+ }
43
+
44
+ function error($errors) {
45
+ global $bvresp;
46
+ $key = $this->get_key();
47
+ $message = array();
48
+ $message['error'] = true;
49
+ if (is_string($errors)) {
50
+ $message['message'] = $errors;
51
+ } elseif (is_wp_error($errors) && $errors->get_error_code()) {
52
+ $message['data'] = $errors->get_error_data();
53
+ $message['code'] = $errors->get_error_code();
54
+ }
55
+ $bvresp->addArrayToStatus($this->action.':'.$key, $message);
56
+ }
57
+
58
+ function feedback($string) {
59
+ global $bvresp;
60
+ if ( empty($string) )
61
+ return;
62
+ $key = $this->get_key();
63
+ $message = array();
64
+ $message['message'] = $string;
65
+ $bvresp->addArrayToStatus($this->action.':'.$key, $message);
66
+ }
67
+ }
68
+ endif;
callback/wings/db.php ADDED
@@ -0,0 +1,145 @@
1
+ <?php
2
+
3
+ if (!defined('ABSPATH')) exit;
4
+ if (!class_exists('BVDBCallback')) :
5
+ class BVDBCallback {
6
+
7
+ public function getLastID($pkeys, $end_row) {
8
+ $last_ids = array();
9
+ foreach($pkeys as $pk) {
10
+ $last_ids[$pk] = $end_row[$pk];
11
+ }
12
+ return $last_ids;
13
+ }
14
+
15
+ public function getTableData($table, $tname, $rcount, $offset, $limit, $bsize, $filter, $pkeys, $include_rows = false) {
16
+ global $bvcb, $bvresp;
17
+ $tinfo = array();
18
+
19
+ $rows_count = $bvcb->bvmain->db->rowsCount($table);
20
+ $bvresp->addStatus('count', $rows_count);
21
+ if ($limit == 0) {
22
+ $limit = $rows_count;
23
+ }
24
+ $srows = 1;
25
+ while (($limit > 0) && ($srows > 0)) {
26
+ if ($bsize > $limit)
27
+ $bsize = $limit;
28
+ $rows = $bvcb->bvmain->db->getTableContent($table, '*', $filter, $bsize, $offset);
29
+ $srows = sizeof($rows);
30
+ $data = array();
31
+ $data["offset"] = $offset;
32
+ $data["size"] = $srows;
33
+ $data["md5"] = md5(serialize($rows));
34
+ array_push($tinfo, $data);
35
+ if (!empty($pkeys) && $srows > 0) {
36
+ $end_row = end($rows);
37
+ $last_ids = $this->getLastID($pkeys, $end_row);
38
+ $data['last_ids'] = $last_ids;
39
+ $bvresp->addStatus('last_ids', $last_ids);
40
+ }
41
+ if ($include_rows) {
42
+ $data["rows"] = $rows;
43
+ $str = serialize($data);
44
+ $bvresp->writeStream($str);
45
+ }
46
+ $offset += $srows;
47
+ $limit -= $srows;
48
+ }
49
+ $bvresp->addStatus('size', $offset);
50
+ $bvresp->addStatus('tinfo', $tinfo);
51
+ }
52
+
53
+ public function process($method) {
54
+ global $bvresp, $bvcb;
55
+ $db = $bvcb->bvmain->db;
56
+ switch ($method) {
57
+ case "gettbls":
58
+ $bvresp->addStatus("tables", $db->showTables());
59
+ break;
60
+ case "tblstatus":
61
+ $bvresp->addStatus("statuses", $db->showTableStatus());
62
+ break;
63
+ case "tablekeys":
64
+ $table = urldecode($_REQUEST['table']);
65
+ $bvresp->addStatus("table_keys", $db->tableKeys($table));
66
+ break;
67
+ case "describetable":
68
+ $table = urldecode($_REQUEST['table']);
69
+ $bvresp->addStatus("table_description", $db->describeTable($table));
70
+ break;
71
+ case "checktable":
72
+ $table = urldecode($_REQUEST['table']);
73
+ $type = urldecode($_REQUEST['type']);
74
+ $bvresp->addStatus("status", $db->checkTable($table, $type));
75
+ break;
76
+ case "repairtable":
77
+ $table = urldecode($_REQUEST['table']);
78
+ $bvresp->addStatus("status", $db->repairTable($table));
79
+ break;
80
+ case "gettcrt":
81
+ $table = urldecode($_REQUEST['table']);
82
+ $bvresp->addStatus("create", $db->showTableCreate($table));
83
+ break;
84
+ case "getrowscount":
85
+ $table = urldecode($_REQUEST['table']);
86
+ $bvresp->addStatus("count", $db->rowsCount($table));
87
+ break;
88
+ case "gettablecontent":
89
+ $table = urldecode($_REQUEST['table']);
90
+ $fields = urldecode($_REQUEST['fields']);
91
+ $filter = (array_key_exists('filter', $_REQUEST)) ? urldecode($_REQUEST['filter']) : "";
92
+ $limit = intval(urldecode($_REQUEST['limit']));
93
+ $offset = intval(urldecode($_REQUEST['offset']));
94
+ $pkeys = (array_key_exists('pkeys', $_REQUEST)) ? $_REQUEST['pkeys'] : array();
95
+ $bvresp->addStatus('timestamp', time());
96
+ $bvresp->addStatus('tablename', $table);
97
+ $rows = $db->getTableContent($table, $fields, $filter, $limit, $offset);
98
+ $srows = sizeof($rows);
99
+ if (!empty($pkeys) && $srows > 0) {
100
+ $end_row = end($rows);
101
+ $bvresp->addStatus('last_ids', $this->getLastID($pkeys, $end_row));
102
+ }
103
+ $bvresp->addStatus("rows", $rows);
104
+ break;
105
+ case "tableinfo":
106
+ $table = urldecode($_REQUEST['table']);
107
+ $offset = intval(urldecode($_REQUEST['offset']));
108
+ $limit = intval(urldecode($_REQUEST['limit']));
109
+ $bsize = intval(urldecode($_REQUEST['bsize']));
110
+ $filter = (array_key_exists('filter', $_REQUEST)) ? urldecode($_REQUEST['filter']) : "";
111
+ $rcount = intval(urldecode($_REQUEST['rcount']));
112
+ $tname = urldecode($_REQUEST['tname']);
113
+ $pkeys = (array_key_exists('pkeys', $_REQUEST)) ? $_REQUEST['pkeys'] : array();
114
+ $this->getTableData($table, $tname, $rcount, $offset, $limit, $bsize, $filter, $pkeys, false);
115
+ break;
116
+ case "uploadrows":
117
+ $table = urldecode($_REQUEST['table']);
118
+ $offset = intval(urldecode($_REQUEST['offset']));
119
+ $limit = intval(urldecode($_REQUEST['limit']));
120
+ $bsize = intval(urldecode($_REQUEST['bsize']));
121
+ $filter = (array_key_exists('filter', $_REQUEST)) ? urldecode($_REQUEST['filter']) : "";
122
+ $rcount = intval(urldecode($_REQUEST['rcount']));
123
+ $tname = urldecode($_REQUEST['tname']);
124
+ $pkeys = (array_key_exists('pkeys', $_REQUEST)) ? $_REQUEST['pkeys'] : array();
125
+ $this->getTableData($table, $tname, $rcount, $offset, $limit, $bsize, $filter, $pkeys, true);
126
+ break;
127
+ case "tblexists":
128
+ $bvresp->addStatus("tblexists", $db->isTablePresent($_REQUEST['tablename']));
129
+ break;
130
+ case "crttbl":
131
+ $bvresp->addStatus("crttbl", $db->createTable($_REQUEST['query'], $_REQUEST['tablename']));
132
+ break;
133
+ case "drptbl":
134
+ $bvresp->addStatus("drptbl", $db->dropBVTable($_REQUEST['name']));
135
+ break;
136
+ case "trttbl":
137
+ $bvresp->addStatus("trttbl", $db->truncateBVTable($_REQUEST['name']));
138
+ break;
139
+ default:
140
+ return false;
141
+ }
142
+ return true;
143
+ }
144
+ }
145
+ endif;
callback/wings/dynsync.php ADDED
@@ -0,0 +1,81 @@
1
+ <?php
2
+
3
+ if (!defined('ABSPATH')) exit;
4
+ if (!class_exists('BVDynSyncCallback')) :
5
+
6
+ require_once dirname( __FILE__ ) . '/../../dynsync.php';
7
+
8
+ class BVDynSyncCallback {
9
+ public function dropDynSyncTable() {
10
+ global $bvcb;
11
+ return $bvcb->bvmain->db->dropBVTable(BVDynSync::$dynsync_table);
12
+ }
13
+
14
+ public function createDynSyncTable() {
15
+ global $bvcb;
16
+ $db = $bvcb->bvmain->db;
17
+ $charset_collate = $db->getCharsetCollate();
18
+ $table = $bvcb->bvmain->db->getBVTable(BVDynSync::$dynsync_table);
19
+ $query = "CREATE TABLE $table (
20
+ id bigint(20) NOT NULL AUTO_INCREMENT,
21
+ site_id int NOT NULL,
22
+ event_type varchar(40) NOT NULL DEFAULT '',
23
+ event_tag varchar(40) NOT NULL DEFAULT '',
24
+ event_data text NOT NULL DEFAULT '',
25
+ PRIMARY KEY (id)
26
+ ) $charset_collate;";
27
+ return $db->createTable($query, BVDynSync::$dynsync_table);
28
+ }
29
+
30
+ public function process($method) {
31
+ global $bvresp, $bvcb;
32
+ $info = $bvcb->bvmain->info;
33
+ switch ($method) {
34
+ case "truncdynsynctable":
35
+ $bvresp->addStatus("status", $bvcb->bvmain->db->truncateBVTable(BVDynSync::$dynsync_table));
36
+ break;
37
+ case "dropdynsynctable":
38
+ $bvresp->addStatus("status", $this->dropDynSyncTable());
39
+ break;
40
+ case "createdynsynctable":
41
+ $bvresp->addStatus("status", $this->createDynSyncTable());
42
+ break;
43
+ case "setdynsync":
44
+ if (array_key_exists('dynplug', $_REQUEST)) {
45
+ $info->updateOption('bvdynplug', $_REQUEST['dynplug']);
46
+ } else {
47
+ $info->deleteOption('bvdynplug');
48
+ }
49
+ $info->updateOption('bvDynSyncActive', $_REQUEST['dynsync']);
50
+ break;
51
+ case "setwoodyn":
52
+ $info->updateOption('bvWooDynSync', $_REQUEST['woodyn']);
53
+ break;
54
+ case "setignorednames":
55
+ switch ($_REQUEST['table']) {
56
+ case "options":
57
+ $info->updateOption('bvIgnoredOptions', $_REQUEST['names']);
58
+ break;
59
+ case "postmeta":
60
+ $info->updateOption('bvIgnoredPostmeta', $_REQUEST['names']);
61
+ break;
62
+ }
63
+ break;
64
+ case "getignorednames":
65
+ switch ($_REQUEST['table']) {
66
+ case "options":
67
+ $names = $info->getOption('bvIgnoredOptions');
68
+ break;
69
+ case "postmeta":
70
+ $names = $info->getOption('bvIgnoredPostmeta');
71
+ break;
72
+ }
73
+ $bvresp->addStatus("names", $names);
74
+ break;
75
+ default:
76
+ return false;
77
+ }
78
+ return true;
79
+ }
80
+ }
81
+ endif;
callback/wings/fs.php ADDED
@@ -0,0 +1,258 @@
1
+ <?php
2
+
3
+ if (!defined('ABSPATH')) exit;
4
+ if (!class_exists('BVFSCallback')) :
5
+ class BVFSCallback {
6
+ function fileStat($relfile) {
7
+ $absfile = ABSPATH.$relfile;
8
+ $fdata = array();
9
+ $fdata["filename"] = $relfile;
10
+ $stats = @stat($absfile);
11
+ if ($stats) {
12
+ foreach (preg_grep('#size|uid|gid|mode|mtime#i', array_keys($stats)) as $key ) {
13
+ $fdata[$key] = $stats[$key];
14
+ }
15
+ if (is_link($absfile)) {
16
+ $fdata["link"] = @readlink($absfile);
17
+ }
18
+ } else {
19
+ $fdata["failed"] = true;
20
+ }
21
+ return $fdata;
22
+ }
23
+
24
+ function scanFilesUsingGlob($initdir = "./", $offset = 0, $limit = 0, $bsize = 512, $recurse = true, $regex = '{.??,}*') {
25
+ global $bvresp;
26
+ $i = 0;
27
+ $dirs = array();
28
+ $dirs[] = $initdir;
29
+ $bfc = 0;
30
+ $bfa = array();
31
+ $current = 0;
32
+ $abspath = realpath(ABSPATH).'/';
33
+ $abslen = strlen($abspath);
34
+ # XNOTE: $recurse cannot be used directly here
35
+ while ($i < count($dirs)) {
36
+ $dir = $dirs[$i];
37
+
38
+ foreach (glob($abspath.$dir.$regex, GLOB_NOSORT | GLOB_BRACE) as $absfile) {
39
+ $relfile = substr($absfile, $abslen);
40
+ if (is_dir($absfile) && !is_link($absfile)) {
41
+ $dirs[] = $relfile."/";
42
+ }
43
+ $current++;
44
+ if ($offset >= $current)
45
+ continue;
46
+ if (($limit != 0) && (($current - $offset) > $limit)) {
47
+ $i = count($dirs);
48
+ break;
49
+ }
50
+ $bfa[] = $this->fileStat($relfile);
51
+ $bfc++;
52
+ if ($bfc == $bsize) {
53
+ $str = serialize($bfa);
54
+ $bvresp->writeStream($str);
55
+ $bfc = 0;
56
+ $bfa = array();
57
+ }
58
+ }
59
+ $regex = '{.??,}*';
60
+ $i++;
61
+ if ($recurse == false)
62
+ break;
63
+ }
64
+ if ($bfc != 0) {
65
+ $str = serialize($bfa);
66
+ $bvresp->writeStream($str);
67
+ }
68
+ }
69
+
70
+ function scanFiles($initdir = "./", $offset = 0, $limit = 0, $bsize = 512, $recurse = true) {
71
+ global $bvresp;
72
+ $i = 0;
73
+ $dirs = array();
74
+ $dirs[] = $initdir;
75
+ $bfc = 0;
76
+ $bfa = array();
77
+ $current = 0;
78
+ while ($i < count($dirs)) {
79
+ $dir = $dirs[$i];
80
+ $d = @opendir(ABSPATH.$dir);
81
+ if ($d) {
82
+ while (($file = readdir($d)) !== false) {
83
+ if ($file == '.' || $file == '..') { continue; }
84
+ $relfile = $dir.$file;
85
+ $absfile = ABSPATH.$relfile;
86
+ if (is_dir($absfile) && !is_link($absfile)) {
87
+ $dirs[] = $relfile."/";
88
+ }
89
+ $current++;
90
+ if ($offset >= $current)
91
+ continue;
92
+ if (($limit != 0) && (($current - $offset) > $limit)) {
93
+ $i = count($dirs);
94
+ break;
95
+ }
96
+ $bfa[] = $this->fileStat($relfile);
97
+ $bfc++;
98
+ if ($bfc == $bsize) {
99
+ $str = serialize($bfa);
100
+ $bvresp->writeStream($str);
101
+ $bfc = 0;
102
+ $bfa = array();
103
+ }
104
+ }
105
+ closedir($d);
106
+ }
107
+ $i++;
108
+ if ($recurse == false)
109
+ break;
110
+ }
111
+ if ($bfc != 0) {
112
+ $str = serialize($bfa);
113
+ $bvresp->writeStream($str);
114
+ }
115
+ }
116
+
117
+ function calculateMd5($absfile, $fdata, $offset, $limit, $bsize) {
118
+ if ($offset == 0 && $limit == 0) {
119
+ $md5 = md5_file($absfile);
120
+ } else {
121
+ if ($limit == 0)
122
+ $limit = $fdata["size"];
123
+ if ($offset + $limit < $fdata["size"])
124
+ $limit = $fdata["size"] - $offset;
125
+ $handle = fopen($absfile, "rb");
126
+ $ctx = hash_init('md5');
127
+ fseek($handle, $offset, SEEK_SET);
128
+ $dlen = 1;
129
+ while (($limit > 0) && ($dlen > 0)) {
130
+ if ($bsize > $limit)
131
+ $bsize = $limit;
132
+ $d = fread($handle, $bsize);
133
+ $dlen = strlen($d);
134
+ hash_update($ctx, $d);
135
+ $limit -= $dlen;
136
+ }
137
+ fclose($handle);
138
+ $md5 = hash_final($ctx);
139
+ }
140
+ return $md5;
141
+ }
142
+
143
+ function getFilesStats($files, $offset = 0, $limit = 0, $bsize = 102400, $md5 = false) {
144
+ global $bvresp;
145
+ foreach ($files as $file) {
146
+ $fdata = $this->fileStat($file);
147
+ $absfile = ABSPATH.$file;
148
+ if (!is_readable($absfile)) {
149
+ $bvresp->addArrayToStatus("missingfiles", $file);
150
+ continue;
151
+ }
152
+ if ($md5 === true) {
153
+ $fdata["md5"] = $this->calculateMd5($absfile, $fdata, $offset, $limit, $bsize);
154
+ }
155
+ $bvresp->addArrayToStatus("stats", $fdata);
156
+ }
157
+ }
158
+
159
+ function uploadFiles($files, $offset = 0, $limit = 0, $bsize = 102400) {
160
+ global $bvresp;
161
+
162
+ foreach ($files as $file) {
163
+ if (!is_readable(ABSPATH.$file)) {
164
+ $bvresp->addArrayToStatus("missingfiles", $file);
165
+ continue;
166
+ }
167
+ $handle = fopen(ABSPATH.$file, "rb");
168
+ if (($handle != null) && is_resource($handle)) {
169
+ $fdata = $this->fileStat($file);
170
+ $_limit = $limit;
171
+ $_bsize = $bsize;
172
+ if ($_limit == 0)
173
+ $_limit = $fdata["size"];
174
+ if ($offset + $_limit > $fdata["size"])
175
+ $_limit = $fdata["size"] - $offset;
176
+ $fdata["limit"] = $_limit;
177
+ $sfdata = serialize($fdata);
178
+ $bvresp->writeStream($sfdata);
179
+ fseek($handle, $offset, SEEK_SET);
180
+ $dlen = 1;
181
+ while (($_limit > 0) && ($dlen > 0)) {
182
+ if ($_bsize > $_limit)
183
+ $_bsize = $_limit;
184
+ $d = fread($handle, $_bsize);
185
+ $dlen = strlen($d);
186
+ $bvresp->writeStream($d);
187
+ $_limit -= $dlen;
188
+ }
189
+ fclose($handle);
190
+ } else {
191
+ $bvresp->addArrayToStatus("unreadablefiles", $file);
192
+ }
193
+ }
194
+ }
195
+
196
+ function process($method) {
197
+ switch ($method) {
198
+ case "scanfilesglob":
199
+ $initdir = urldecode($_REQUEST['initdir']);
200
+ $offset = intval(urldecode($_REQUEST['offset']));
201
+ $limit = intval(urldecode($_REQUEST['limit']));
202
+ $bsize = intval(urldecode($_REQUEST['bsize']));
203
+ $regex = urldecode($_REQUEST['regex']);
204
+ $recurse = true;
205
+ if (array_key_exists('recurse', $_REQUEST) && $_REQUEST["recurse"] == "false") {
206
+ $recurse = false;
207
+ }
208
+ $this->scanFilesUsingGlob($initdir, $offset, $limit, $bsize, $recurse, $regex);
209
+ break;
210
+ case "scanfiles":
211
+ $initdir = urldecode($_REQUEST['initdir']);
212
+ $offset = intval(urldecode($_REQUEST['offset']));
213
+ $limit = intval(urldecode($_REQUEST['limit']));
214
+ $bsize = intval(urldecode($_REQUEST['bsize']));
215
+ $recurse = true;
216
+ if (array_key_exists('recurse', $_REQUEST) && $_REQUEST["recurse"] == "false") {
217
+ $recurse = false;
218
+ }
219
+ $this->scanFiles($initdir, $offset, $limit, $bsize, $recurse);
220
+ break;
221
+ case "getfilesstats":
222
+ $files = $_REQUEST['files'];
223
+ $offset = intval(urldecode($_REQUEST['offset']));
224
+ $limit = intval(urldecode($_REQUEST['limit']));
225
+ $bsize = intval(urldecode($_REQUEST['bsize']));
226
+ $md5 = false;
227
+ if (array_key_exists('md5', $_REQUEST)) {
228
+ $md5 = true;
229
+ }
230
+ $this->getFilesStats($files, $offset, $limit, $bsize, $md5);
231
+ break;
232
+ case "sendmanyfiles":
233
+ $files = $_REQUEST['files'];
234
+ $offset = intval(urldecode($_REQUEST['offset']));
235
+ $limit = intval(urldecode($_REQUEST['limit']));
236
+ $bsize = intval(urldecode($_REQUEST['bsize']));
237
+ $this->uploadFiles($files, $offset, $limit, $bsize);
238
+ break;
239
+ case "filelist":
240
+ $initdir = $_REQUEST['initdir'];
241
+ $glob_option = GLOB_MARK;
242
+ if(array_key_exists('onlydir', $_REQUEST)) {
243
+ $glob_option = GLOB_ONLYDIR;
244
+ }
245
+ $regex = "*";
246
+ if(array_key_exists('regex', $_REQUEST)){
247
+ $regex = $_REQUEST['regex'];
248
+ }
249
+ $directoryList = glob($initdir.$regex, $glob_option);
250
+ $this->getFilesStats($directoryList);
251
+ break;
252
+ default:
253
+ return false;
254
+ }
255
+ return true;
256
+ }
257
+ }
258
+ endif;
callback/wings/fw.php ADDED
@@ -0,0 +1,34 @@
1
+ <?php
2
+
3
+ if (!defined('ABSPATH')) exit;
4
+ if (!class_exists('BVFirewallCallback')) :
5
+
6
+ require_once dirname( __FILE__ ) . '/../../fw/config.php';
7
+
8
+ class BVFirewallCallback {
9
+ public function process($method) {
10
+ global $bvcb, $bvresp;
11
+ $config = new BVFWConfig($bvcb->bvmain);
12
+ switch ($method) {
13
+ case "clrconfig":
14
+ $bvresp->addStatus("clearconfig", $config->clear());
15
+ break;
16
+ case "setmode":
17
+ $config->setMode($_REQUEST['mode']);
18
+ $bvresp->addStatus("setmode", $config->getMode());
19
+ break;
20
+ case "dsblrules":
21
+ $config->setDisabledRules($_REQUEST['disabled_rules']);
22
+ $bvresp->addStatus("disabled_rules", $config->getDisabledRules());
23
+ break;
24
+ case "setrulesmode":
25
+ $config->setRulesMode($_REQUEST['rules_mode']);
26
+ $bvresp->addStatus("rules_mode", $config->getRulesMode());
27
+ break;
28
+ default:
29
+ return false;
30
+ }
31
+ return true;
32
+ }
33
+ }
34
+ endif;
callback/wings/info.php ADDED
@@ -0,0 +1,292 @@