14064510 by Jeff Balicki

Merge branch 'master' of git.gotenzing.com:msf/msf-climate-hub

2 parents 4314b649 3bc7e3e7
Showing 29 changed files with 4536 additions and 0 deletions
<?php
if (!defined('ABSPATH')) exit;
if (!class_exists('PTNAccount')) :
class PTNAccount {
public $settings;
public $public;
public $secret;
public static $api_public_key = 'bvApiPublic';
public static $accounts_list = 'bvAccountsList';
public function __construct($settings, $public, $secret) {
$this->settings = $settings;
$this->public = $public;
$this->secret = $secret;
}
public static function find($settings, $public) {
$accounts = self::allAccounts($settings);
if (array_key_exists($public, $accounts) && isset($accounts[$public]['secret'])) {
$secret = $accounts[$public]['secret'];
}
if (empty($secret) || (strlen($secret) < 32)) {
return null;
}
return new self($settings, $public, $secret);
}
public static function update($settings, $allAccounts) {
$settings->updateOption(self::$accounts_list, $allAccounts);
}
public static function randString($length) {
$chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
$str = "";
$size = strlen($chars);
for( $i = 0; $i < $length; $i++ ) {
$str .= $chars[rand(0, $size - 1)];
}
return $str;
}
public static function sanitizeKey($key) {
return preg_replace('/[^a-zA-Z0-9_\-]/', '', $key);
}
public static function apiPublicAccount($settings) {
$pubkey = $settings->getOption(self::$api_public_key);
return self::find($settings, $pubkey);
}
public static function updateApiPublicKey($settings, $pubkey) {
$settings->updateOption(self::$api_public_key, $pubkey);
}
public static function getApiPublicKey($settings) {
return $settings->getOption(self::$api_public_key);
}
public static function getPlugName($settings) {
$bvinfo = new PTNInfo($settings);
return $bvinfo->plugname;
}
public static function allAccounts($settings) {
$accounts = $settings->getOption(self::$accounts_list);
if (!is_array($accounts)) {
$accounts = array();
}
return $accounts;
}
public static function accountsByPlugname($settings) {
$accounts = self::allAccounts($settings);
$accountsByPlugname = array();
$plugname = self::getPlugName($settings);
foreach ($accounts as $pubkey => $value) {
if (array_key_exists($plugname, $value) && $value[$plugname] == 1) {
$accountsByPlugname[$pubkey] = $value;
}
}
return $accountsByPlugname;
}
public static function accountsByType($settings, $account_type) {
$accounts = self::allAccounts($settings);
$accounts_by_type = array();
foreach ($accounts as $pubkey => $value) {
if (array_key_exists('account_type', $value) && $value['account_type'] === $account_type) {
$accounts_by_type[$pubkey] = $value;
}
}
return $accounts_by_type;
}
public static function accountsByGid($settings, $account_gid) {
$accounts = self::allAccounts($settings);
$accounts_by_gid = array();
foreach ($accounts as $pubkey => $value) {
if (array_key_exists('account_gid', $value) && $value['account_gid'] === $account_gid) {
$accounts_by_gid[$pubkey] = $value;
}
}
return $accounts_by_gid;
}
public static function accountsByPattern($settings, $search_key, $search_pattern) {
$accounts = self::allAccounts($settings);
$accounts_by_pattern = array();
foreach ($accounts as $pubkey => $value) {
if (array_key_exists($search_key, $value) &&
PTNHelper::safePregMatch($search_pattern, $value[$search_key]) == 1) {
$accounts_by_pattern[$pubkey] = $value;
}
}
return $accounts_by_pattern;
}
public static function isConfigured($settings) {
$accounts = self::accountsByPlugname($settings);
return (sizeof($accounts) >= 1);
}
public static function setup($settings) {
$bvinfo = new PTNInfo($settings);
$settings->updateOption($bvinfo->plug_redirect, 'yes');
$settings->updateOption('bvActivateTime', time());
}
public function authenticatedUrl($method) {
$bvinfo = new PTNInfo($this->settings);
$qstr = http_build_query($this->newAuthParams($bvinfo->version));
return $bvinfo->appUrl().$method."?".$qstr;
}
public function newAuthParams($version) {
$bvinfo = new PTNInfo($this->settings);
$args = array();
$time = time();
$sig = sha1($this->public.$this->secret.$time.$version);
$args['sig'] = $sig;
$args['bvTime'] = $time;
$args['bvPublic'] = $this->public;
$args['bvVersion'] = $version;
$args['sha1'] = '1';
$args['plugname'] = $bvinfo->plugname;
return $args;
}
public static function addAccount($settings, $public, $secret) {
$accounts = self::allAccounts($settings);
if (!isset($public, $accounts)) {
$accounts[$public] = array();
}
$accounts[$public]['secret'] = $secret;
self::update($settings, $accounts);
}
public function info() {
return array(
"public" => substr($this->public, 0, 6)
);
}
public function updateInfo($info) {
$accounts = self::allAccounts($this->settings);
$account_type = $info["account_type"];
$pubkey = $info['pubkey'];
if (!array_key_exists($pubkey, $accounts)) {
$accounts[$pubkey] = array();
}
if (array_key_exists('secret', $info)) {
$accounts[$pubkey]['secret'] = $info['secret'];
}
$accounts[$pubkey]['account_gid'] = $info['account_gid'];
$accounts[$pubkey]['lastbackuptime'] = time();
if (isset($info["speed_plugname"])) {
$speed_plugname = $info["speed_plugname"];
$accounts[$pubkey][$speed_plugname] = true;
}
if (isset($info["plugname"])) {
$plugname = $info["plugname"];
$accounts[$pubkey][$plugname] = true;
}
$accounts[$pubkey]['account_type'] = $account_type;
$accounts[$pubkey]['url'] = $info['url'];
$accounts[$pubkey]['email'] = $info['email'];
self::update($this->settings, $accounts);
}
public static function remove($settings, $pubkey) {
$accounts = self::allAccounts($settings);
if (array_key_exists($pubkey, $accounts)) {
unset($accounts[$pubkey]);
self::update($settings, $accounts);
return true;
}
return false;
}
public static function removeByAccountType($settings, $account_type) {
$accounts = PTNAccount::accountsByType($settings, $account_type);
if (sizeof($accounts) >= 1) {
foreach ($accounts as $pubkey => $value) {
PTNAccount::remove($settings, $pubkey);
}
return true;
}
return false;
}
public static function removeByAccountGid($settings, $account_gid) {
$accounts = PTNAccount::accountsByGid($settings, $account_gid);
if (sizeof($accounts) >= 1) {
foreach ($accounts as $pubkey => $value) {
PTNAccount::remove($settings, $pubkey);
}
return true;
}
return false;
}
public static function exists($settings, $pubkey) {
$accounts = self::allAccounts($settings);
return array_key_exists($pubkey, $accounts);
}
}
endif;
\ No newline at end of file
<div class="logo-container" style="padding: 50px 0px 10px 20px">
<a href="http://blogvault.net/" style="padding-right: 20px;"><img src="<?php echo esc_url(plugins_url($this->getPluginLogo(), __FILE__)); ?>" /></a>
</div>
<div id="wrapper toplevel_page_ptn-automated-migration">
<form id="ptn_migrate_form" dummy=">" action="<?php echo esc_url($this->bvinfo->appUrl()); ?>/home/migrate" onsubmit="document.getElementById('migratesubmit').disabled = true;" style="padding:0 2% 2em 1%;" method="post" name="signup">
<h1>Migrate Site to Pantheon</h1>
<p><font size="3">This plugin makes it very easy to migrate your site to Pantheon</font></p>
<input type="hidden" name="bvsrc" value="wpplugin" />
<input type="hidden" name="migrate" value="pantheon" />
<input type="hidden" name="type" value="sftp" />
<?php echo $this->siteInfoTags(); ?>
<p>No Pantheon site yet? Start by <a href="https://dashboard.pantheon.io/sites/migrate">migrating an existing site</a> on your Pantheon dashboard.</p>
<div class="row-fluid">
<div class="span5" style="border-right: 1px solid #EEE; padding-top:1%;">
<label class="control-label" for="input02">Pantheon Site Name</label>
<div class="control-group">
<div class="controls">
<input type="text" class="input-large" name="newurl">
</div>
</div>
<label class="control-label" for="input01">Machine Token</label>
<div class="control-group">
<div class="controls">
<input type="text" class="input-large" name="machine_token">
</div>
</div>
<?php if (array_key_exists('auth_required_source', $_REQUEST)) { ?>
<div id="source-auth">
<label class="control-label" for="input02" style="color:red">User <small>(for this site)</small></label>
<div class="control-group">
<div class="controls">
<input type="text" class="input-large" name="httpauth_src_user">
</div>
</div>
<label class="control-label" for="input02" style="color:red">Password <small>(for this site)</small></label>
<div class="control-group">
<div class="controls">
<input type="password" class="input-large" name="httpauth_src_password">
</div>
</div>
</div>
<?php } ?>
<?php if (array_key_exists('auth_required_dest', $_REQUEST)) { ?>
<label class="control-label" for="input02" style="color:red">Username <small>(for Pantheon Install)</small></label>
<div class="control-group">
<div class="controls">
<input type="text" class="input-large" name="httpauth_dest_user">
</div>
</div>
<label class="control-label" for="input02" style="color:red">Password <small>(for Pantheon Install)</small></label>
<div class="control-group">
<div class="controls">
<input type="password" class="input-large" name="httpauth_dest_password">
</div>
</div>
<?php } ?>
<div class="control-group">
<div class="controls">
<br><input type="checkbox" name="consent" onchange="document.getElementById('migratesubmit').disabled = !this.checked;" value="1"/>I agree to Blogvault <a href="https://blogvault.net/tos" target="_blank" rel="noopener noreferrer">Terms of Service</a> and <a href="https://blogvault.net/privacy" target="_blank" rel="noopener noreferrer">Privacy Policy</a>
</div>
</div>
</div>
</div>
</div>
<input type='submit' disabled id='migratesubmit' value='Migrate'>
</form>
</div> <!-- wrapper ends here -->
\ No newline at end of file
<?php
if (!defined('ABSPATH')) exit;
if (!class_exists('BVCallbackBase')) :
class BVCallbackBase {
public static $wing_infos = array("BRAND_WING_VERSION" => '1.0',
"DB_WING_VERSION" => '1.3',
"ACCOUNT_WING_VERSION" => '1.2',
"MISC_WING_VERSION" => '1.2',
"FS_WING_VERSION" => '1.2',
"INFO_WING_VERSION" => '1.8',
);
public function objectToArray($obj) {
return json_decode(json_encode($obj), true);
}
public function base64Encode($data, $chunk_size) {
if ($chunk_size) {
$out = "";
$len = strlen($data);
for ($i = 0; $i < $len; $i += $chunk_size) {
$out .= base64_encode(substr($data, $i, $chunk_size));
}
} else {
$out = base64_encode($data);
}
return $out;
}
}
endif;
\ No newline at end of file
<?php
if (!defined('ABSPATH')) exit;
if (!class_exists('BVCallbackHandler')) :
class BVCallbackHandler {
public $db;
public $settings;
public $siteinfo;
public $request;
public $account;
public $response;
public $bvinfo;
public function __construct($db, $settings, $siteinfo, $request, $account, $response) {
$this->db = $db;
$this->settings = $settings;
$this->siteinfo = $siteinfo;
$this->request = $request;
$this->account = $account;
$this->response = $response;
$this->bvinfo = new PTNInfo($this->settings);
}
public function bvAdmExecuteWithoutUser() {
$this->execute(array("bvadmwithoutuser" => true));
}
public function bvAdmExecuteWithUser() {
$this->execute(array("bvadmwithuser" => true));
}
public function execute($resp = array()) {
$params = $this->request->params;
if (array_key_exists('disable_global_cache', $params)) {
$GLOBALS['_wp_using_ext_object_cache'] = false;
}
$this->routeRequest();
$resp = array(
"request_info" => $this->request->info(),
"site_info" => $this->siteinfo->info(),
"account_info" => $this->account->info(),
"bvinfo" => $this->bvinfo->info(),
"api_pubkey" => substr(PTNAccount::getApiPublicKey($this->settings), 0, 8)
);
$this->response->terminate($resp);
}
public function routeRequest() {
switch ($this->request->wing) {
case 'manage':
require_once dirname( __FILE__ ) . '/wings/manage.php';
$module = new BVManageCallback($this);
break;
case 'fs':
require_once dirname( __FILE__ ) . '/wings/fs.php';
$module = new BVFSCallback($this);
break;
case 'db':
require_once dirname( __FILE__ ) . '/wings/db.php';
$module = new BVDBCallback($this);
break;
case 'info':
require_once dirname( __FILE__ ) . '/wings/info.php';
$module = new BVInfoCallback($this);
break;
case 'dynsync':
require_once dirname( __FILE__ ) . '/wings/dynsync.php';
$module = new BVDynSyncCallback($this);
break;
case 'ipstr':
require_once dirname( __FILE__ ) . '/wings/ipstore.php';
$module = new BVIPStoreCallback($this);
break;
case 'wtch':
require_once dirname( __FILE__ ) . '/wings/watch.php';
$module = new BVWatchCallback($this);
break;
case 'brand':
require_once dirname( __FILE__ ) . '/wings/brand.php';
$module = new BVBrandCallback($this);
break;
case 'pt':
require_once dirname( __FILE__ ) . '/wings/protect.php';
$module = new BVProtectCallback($this);
break;
case 'act':
require_once dirname( __FILE__ ) . '/wings/account.php';
$module = new BVAccountCallback($this);
break;
case 'fswrt':
require_once dirname( __FILE__ ) . '/wings/fs_write.php';
$module = new BVFSWriteCallback();
break;
case 'actlg':
require_once dirname( __FILE__ ) . '/wings/actlog.php';
$module = new BVActLogCallback($this);
break;
case 'speed':
require_once dirname( __FILE__ ) . '/wings/speed.php';
$module = new BVSpeedCallback($this);
break;
case 'scrty':
require_once dirname( __FILE__ ) . '/wings/security.php';
$module = new BVSecurityCallback($this);
break;
default:
require_once dirname( __FILE__ ) . '/wings/misc.php';
$module = new BVMiscCallback($this);
break;
}
$resp = $module->process($this->request);
if ($resp === false) {
$resp = array(
"statusmsg" => "Bad Command",
"status" => false);
}
$resp = array(
$this->request->wing => array(
$this->request->method => $resp
)
);
$this->response->addStatus("callbackresponse", $resp);
return 1;
}
}
endif;
<?php
if (!defined('ABSPATH')) exit;
if (!class_exists('BVCallbackRequest')) :
class BVCallbackRequest {
public $params;
public $method;
public $wing;
public $is_afterload;
public $is_admin_ajax;
public $is_debug;
public $account;
public $settings;
public $sig;
public $sighshalgo;
public $time;
public $version;
public $is_sha1;
public $bvb64stream;
public $bvb64cksize;
public $checksum;
public $error = array();
public $pubkey_name;
public $bvprmsmac;
public $bvboundry;
public function __construct($account, $in_params, $settings) {
$this->params = array();
$this->account = $account;
$this->settings = $settings;
$this->wing = $in_params['wing'];
$this->method = $in_params['bvMethod'];
$this->is_afterload = array_key_exists('afterload', $in_params);
$this->is_admin_ajax = array_key_exists('adajx', $in_params);
$this->is_debug = array_key_exists('bvdbg', $in_params);
$this->sig = $in_params['sig'];
$this->sighshalgo = !empty($in_params['sighshalgo']) ? $in_params['sighshalgo'] : null;
$this->time = intval($in_params['bvTime']);
$this->version = $in_params['bvVersion'];
$this->is_sha1 = array_key_exists('sha1', $in_params);
$this->bvb64stream = isset($in_params['bvb64stream']);
$this->bvb64cksize = array_key_exists('bvb64cksize', $in_params) ? intval($in_params['bvb64cksize']) : false;
$this->checksum = array_key_exists('checksum', $in_params) ? $in_params['checksum'] : false;
$this->pubkey_name = !empty($in_params['pubkeyname']) ?
PTNAccount::sanitizeKey($in_params['pubkeyname']) : 'm_public';
$this->bvprmsmac = !empty($in_params['bvprmsmac']) ? PTNAccount::sanitizeKey($in_params['bvprmsmac']) : "";
$this->bvboundry = !empty($in_params['bvboundry']) ? $in_params['bvboundry'] : "";
}
public function isAPICall() {
return array_key_exists('apicall', $this->params);
}
public function curlRequest($url, $body) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($body));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
return curl_exec($ch);
}
public function fileGetContentRequest($url, $body) {
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($body)
)
);
$context = stream_context_create($options);
return file_get_contents($url, false, $context);
}
public function http_request($url, $body) {
if (in_array('curl', get_loaded_extensions())) {
return $this->curlRequest($url, $body);
} else {
return $this->fileGetContentRequest($url, $body);
}
}
public function get_params_via_api($params_key, $apiurl) {
$res = $this->http_request($apiurl, array('bvkey' => $params_key));
if ($res === FALSE) {
return false;
}
return $res;
}
public function info() {
$info = array(
"requestedsig" => $this->sig,
"requestedtime" => $this->time,
"requestedversion" => $this->version,
"error" => $this->error
);
if ($this->is_debug) {
$info["inreq"] = $this->params;
}
if ($this->is_admin_ajax) {
$info["adajx"] = true;
}
if ($this->is_afterload) {
$info["afterload"] = true;
}
return $info;
}
public function processParams($in_params) {
$params = array();
if (array_key_exists('obend', $in_params) && function_exists('ob_end_clean'))
@ob_end_clean();
if (array_key_exists('op_reset', $in_params) && function_exists('output_reset_rewrite_vars'))
@output_reset_rewrite_vars();
if (array_key_exists('concat', $in_params)) {
foreach ($in_params['concat'] as $key) {
$concated = '';
$count = intval($in_params[$key]);
for ($i = 1; $i <= $count; $i++) {
$concated .= $in_params[$key."_bv_".$i];
}
$in_params[$key] = $concated;
}
}
if (isset($in_params['bvpdataviaapi']) && isset($in_params['bvapiurl'])) {
$pdata = $this->get_params_via_api($in_params['bvpdataviaapi'], $in_params['bvapiurl']);
if ($pdata !== false) {
$in_params["bvprms"] = $pdata;
}
}
if (array_key_exists('bvprms', $in_params) && isset($in_params['bvprms'])) {
if (!empty($in_params['bvprmshshalgo']) && $in_params['bvprmshshalgo'] === 'sha256') {
$calculated_mac = hash_hmac('SHA256', $in_params['bvprms'], $this->account->secret);
} else {
$calculated_mac = hash_hmac('SHA1', $in_params['bvprms'], $this->account->secret);
}
if ($this->compare_mac($this->bvprmsmac, $calculated_mac) === true) {
if (array_key_exists('b64', $in_params)) {
foreach ($in_params['b64'] as $key) {
if (is_array($in_params[$key])) {
$in_params[$key] = array_map('base64_decode', $in_params[$key]);
} else {
$in_params[$key] = base64_decode($in_params[$key]);
}
}
}
if (array_key_exists('unser', $in_params)) {
foreach ($in_params['unser'] as $key) {
$in_params[$key] = json_decode($in_params[$key], TRUE);
}
}
if (array_key_exists('sersafe', $in_params)) {
$key = $in_params['sersafe'];
$in_params[$key] = BVCallbackRequest::serialization_safe_decode($in_params[$key]);
}
if (array_key_exists('bvprms', $in_params) && isset($in_params['bvprms'])) {
$params = $in_params['bvprms'];
}
if (array_key_exists('clacts', $in_params)) {
foreach ($in_params['clacts'] as $action) {
remove_all_actions($action);
}
}
if (array_key_exists('clallacts', $in_params)) {
global $wp_filter;
foreach ( $wp_filter as $filter => $val ){
remove_all_actions($filter);
}
}
if (array_key_exists('memset', $in_params)) {
$val = intval($in_params['memset']);
@ini_set('memory_limit', $val.'M');
}
return $params;
}
}
return false;
}
private function compare_mac($l_hash, $r_hash) {
if (!is_string($l_hash) || !is_string($r_hash)) {
return false;
}
if (strlen($l_hash) !== strlen($r_hash)) {
return false;
}
if (function_exists('hash_equals')) {
return hash_equals($l_hash, $r_hash);
} else {
return $l_hash === $r_hash;
}
}
public static function serialization_safe_decode($data) {
if (is_array($data)) {
$data = array_map(array('BVCallbackRequest', 'serialization_safe_decode'), $data);
} elseif (is_string($data)) {
$data = base64_decode($data);
}
return $data;
}
public function authenticate() {
if (!$this->account) {
$this->error["message"] = "ACCOUNT_NOT_FOUND";
return false;
}
$bv_last_recv_time = $this->settings->getOption('bvLastRecvTime');
if ($this->time < intval($bv_last_recv_time) - 300) {
return false;
}
$data = $this->method.$this->account->secret.$this->time.$this->version.$this->bvprmsmac;
if (!$this->verify($data, base64_decode($this->sig), $this->sighshalgo)) {
return false;
}
$this->settings->updateOption('bvLastRecvTime', $this->time);
return 1;
}
public function verify($data, $sig, $sighshalgo) {
if (!function_exists('openssl_verify') || !function_exists('openssl_pkey_get_public')) {
$this->error["message"] = "OPENSSL_FUNCS_NOT_FOUND";
return false;
}
$key_file = dirname( __FILE__ ) . '/../public_keys/' . $this->pubkey_name . '.pub';
if (!file_exists($key_file)) {
$this->error["message"] = "PUBLIC_KEY_NOT_FOUND";
return false;
}
$public_key_str = file_get_contents($key_file);
$public_key = openssl_pkey_get_public($public_key_str);
if (!$public_key) {
$this->error["message"] = "UNABLE_TO_LOAD_PUBLIC_KEY";
return false;
}
if ($sighshalgo === 'sha256') {
$verify = openssl_verify($data, $sig, $public_key, OPENSSL_ALGO_SHA256);
} else {
$verify = openssl_verify($data, $sig, $public_key);
}
if ($verify === 1) {
return true;
} elseif ($verify === 0) {
$this->error["message"] = "INCORRECT_SIGNATURE";
$this->error["pubkey_sig"] = substr(hash('md5', $public_key_str), 0, 8);
} else {
$this->error["message"] = "OPENSSL_VERIFY_FAILED";
}
return false;
}
public function corruptedParamsResp() {
$bvinfo = new PTNInfo($this->settings);
return array(
"account_info" => $this->account->info(),
"request_info" => $this->info(),
"bvinfo" => $bvinfo->info(),
"statusmsg" => "BVPRMS_CORRUPTED"
);
}
public function authFailedResp() {
$api_public_key = PTNAccount::getApiPublicKey($this->settings);
$default_secret = PTNRecover::getDefaultSecret($this->settings);
$bvinfo = new PTNInfo($this->settings);
$resp = array(
"request_info" => $this->info(),
"bvinfo" => $bvinfo->info(),
"statusmsg" => "FAILED_AUTH",
"api_pubkey" => substr($api_public_key, 0, 8),
"def_sigmatch" => substr(hash('sha1', $this->method.$default_secret.$this->time.$this->version), 0, 8)
);
if ($this->account) {
$resp["account_info"] = $this->account->info();
$resp["sigmatch"] = substr(hash('sha1', $this->method.$this->account->secret.$this->time.$this->version), 0, 6);
} else {
$resp["account_info"] = array("error" => "ACCOUNT_NOT_FOUND");
}
return $resp;
}
}
endif;
\ No newline at end of file
<?php
if (!defined('ABSPATH')) exit;
if (!class_exists('BVCallbackResponse')) :
class BVCallbackResponse extends BVCallbackBase {
public $status;
public $bvb64cksize;
public function __construct($bvb64cksize) {
$this->status = array("blogvault" => "response");
$this->bvb64cksize = $bvb64cksize;
}
public function addStatus($key, $value) {
$this->status[$key] = $value;
}
public function addArrayToStatus($key, $value) {
if (!isset($this->status[$key])) {
$this->status[$key] = array();
}
$this->status[$key][] = $value;
}
public function terminate($resp = array()) {
$resp = array_merge($this->status, $resp);
$resp["signature"] = "Blogvault API";
$response = "bvbvbvbvbv".serialize($resp)."bvbvbvbvbv";
$response = "bvb64bvb64".$this->base64Encode($response, $this->bvb64cksize)."bvb64bvb64";
die($response);
exit;
}
}
endif;
\ No newline at end of file
<?php
if (!defined('ABSPATH')) exit;
if (!class_exists('BVRespStream')) :
class BVStream extends BVCallbackBase {
public $bvb64stream;
public $bvb64cksize;
public $checksum;
function __construct($request) {
$this->bvb64stream = $request->bvb64stream;
$this->bvb64cksize = $request->bvb64cksize;
$this->checksum = $request->checksum;
}
public function writeChunk($chunk) {
}
public static function startStream($account, $request) {
$result = array();
$params = $request->params;
$stream = new BVRespStream($request);
if ($request->isAPICall()) {
$stream = new BVHttpStream($request);
if (!$stream->connect()) {
$apicallstatus = array(
"httperror" => "Cannot Open Connection to Host",
"streamerrno" => $stream->errno,
"streamerrstr" => $stream->errstr
);
return array("apicallstatus" => $apicallstatus);
}
if (array_key_exists('acbmthd', $params)) {
$qstr = http_build_query(array('bvapicheck' => $params['bvapicheck']));
$url = '/bvapi/'.$params['acbmthd']."?".$qstr;
if (array_key_exists('acbqry', $params)) {
$url .= "&".$params['acbqry'];
}
$stream->multipartChunkedPost($url);
} else {
return array("apicallstatus" => array("httperror" => "ApiCall method not present"));
}
}
return array('stream' => $stream);
}
public function writeStream($chunk) {
if (strlen($chunk) > 0) {
$bvb64_prefix = "";
if ($this->bvb64stream) {
$chunk_size = $this->bvb64cksize;
$chunk = $this->base64Encode($chunk, $chunk_size);
$bvb64_prefix .= "BVB64" . ":";
}
$hash_prefix = "";
if ($this->checksum == 'crc32') {
$hash_prefix .= "CRC32" . ":" . crc32($chunk) . ":";
} else if ($this->checksum == 'md5') {
$hash_prefix .= "MD5" . ":" . md5($chunk) . ":";
}
$chunk = $hash_prefix . $bvb64_prefix . strlen($chunk) . ":" . $chunk;
$this->writeChunk($chunk);
}
}
}
class BVRespStream extends BVStream {
public $bvboundry;
function __construct($request) {
parent::__construct($request);
$this->bvboundry = $request->bvboundry;
}
public function writeChunk($chunk) {
echo $this->bvboundry . "ckckckckck" . $chunk . $this->bvboundry . "ckckckckck";
}
public function endStream() {
echo $this->bvboundry . "rerererere";
return array();
}
}
class BVHttpStream extends BVStream {
var $user_agent = 'BVHttpStream';
var $host;
var $port;
var $timeout = 20;
var $conn;
var $errno;
var $errstr;
var $boundary;
var $apissl;
function __construct($request) {
parent::__construct($request);
$this->host = $request->params['apihost'];
$this->port = intval($request->params['apiport']);
$this->apissl = array_key_exists('apissl', $request->params);
}
public function connect() {
if ($this->apissl && function_exists('stream_socket_client')) {
$this->conn = stream_socket_client("ssl://".$this->host.":".$this->port, $errno, $errstr, $this->timeout);
} else {
$this->conn = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);
}
if (!$this->conn) {
$this->errno = $errno;
$this->errstr = $errstr;
return false;
}
socket_set_timeout($this->conn, $this->timeout);
return true;
}
public function write($data) {
fwrite($this->conn, $data);
}
public function sendChunk($data) {
$this->write(sprintf("%x\r\n", strlen($data)));
$this->write($data);
$this->write("\r\n");
}
public function sendRequest($method, $url, $headers = array(), $body = null) {
$def_hdrs = array("Connection" => "keep-alive",
"Host" => $this->host);
$headers = array_merge($def_hdrs, $headers);
$request = strtoupper($method)." ".$url." HTTP/1.1\r\n";
if (null != $body) {
$headers["Content-length"] = strlen($body);
}
foreach($headers as $key=>$val) {
$request .= $key.":".$val."\r\n";
}
$request .= "\r\n";
if (null != $body) {
$request .= $body;
}
$this->write($request);
return $request;
}
public function post($url, $headers = array(), $body = "") {
if(is_array($body)) {
$b = "";
foreach($body as $key=>$val) {
$b .= $key."=".urlencode($val)."&";
}
$body = substr($b, 0, strlen($b) - 1);
}
$this->sendRequest("POST", $url, $headers, $body);
}
public function streamedPost($url, $headers = array()) {
$headers['Transfer-Encoding'] = "chunked";
$this->sendRequest("POST", $url, $headers);
}
public function multipartChunkedPost($url) {
$mph = array(
"Content-Disposition" => "form-data; name=bvinfile; filename=data",
"Content-Type" => "application/octet-stream"
);
$rnd = rand(100000, 999999);
$this->boundary = "----".$rnd;
$prologue = "--".$this->boundary."\r\n";
foreach($mph as $key=>$val) {
$prologue .= $key.":".$val."\r\n";
}
$prologue .= "\r\n";
$headers = array('Content-Type' => "multipart/form-data; boundary=".$this->boundary);
$this->streamedPost($url, $headers);
$this->sendChunk($prologue);
}
public function writeChunk($data) {
$this->sendChunk($data);
}
public function closeChunk() {
$this->sendChunk("");
}
public function endStream() {
$epilogue = "\r\n\r\n--".$this->boundary."--\r\n";
$this->sendChunk($epilogue);
$this->closeChunk();
$result = array();
$resp = $this->getResponse();
if (array_key_exists('httperror', $resp)) {
$result["httperror"] = $resp['httperror'];
} else {
$result["respstatus"] = $resp['status'];
$result["respstatus_string"] = $resp['status_string'];
}
return array("apicallstatus" => $result);
}
public function getResponse() {
$response = array();
$response['headers'] = array();
$state = 1;
$conlen = 0;
stream_set_timeout($this->conn, 300);
while (!feof($this->conn)) {
$line = fgets($this->conn, 4096);
if (1 == $state) {
if (!PTNHelper::safePregMatch('/HTTP\/(\\d\\.\\d)\\s*(\\d+)\\s*(.*)/', $line, $m)) {
$response['httperror'] = "Status code line invalid: ".htmlentities($line);
return $response;
}
$response['http_version'] = $m[1];
$response['status'] = $m[2];
$response['status_string'] = $m[3];
$state = 2;
} else if (2 == $state) {
# End of headers
if (2 == strlen($line)) {
if ($conlen > 0)
$response['body'] = fread($this->conn, $conlen);
return $response;
}
if (!PTNHelper::safePregMatch('/([^:]+):\\s*(.*)/', $line, $m)) {
// Skip to the next header
continue;
}
$key = strtolower(trim($m[1]));
$val = trim($m[2]);
$response['headers'][$key] = $val;
if ($key == "content-length") {
$conlen = intval($val);
}
}
}
return $response;
}
}
endif;
\ No newline at end of file
<?php
if (!defined('ABSPATH')) exit;
if (!class_exists('BVAccountCallback')) :
class BVAccountCallback extends BVCallbackBase {
public $account;
public $settings;
const ACCOUNT_WING_VERSION = 1.2;
public function __construct($callback_handler) {
$this->account = $callback_handler->account;
$this->settings = $callback_handler->settings;
}
function updateInfo($args) {
$result = array();
if (array_key_exists('update_info', $args)) {
$this->account->updateInfo($args['update_info']);
$result['update_info'] = array(
"status" => PTNAccount::exists($this->settings, $args['update_info']['pubkey'])
);
}
if (array_key_exists('update_api_key', $args)) {
PTNAccount::updateApiPublicKey($this->settings, $args['update_api_key']['pubkey']);
$result['update_api_key'] = array(
"status" => $this->settings->getOption(PTNAccount::$api_public_key)
);
}
if (array_key_exists('update_options', $args))
$result['update_options'] = $this->settings->updateOptions($args['update_options']);
if (array_key_exists('delete_options', $args))
$result['delete_options'] = $this->settings->deleteOptions($args['delete_options']);
$result['status'] = true;
return $result;
}
function process($request) {
$params = $request->params;
$account = $this->account;
$settings = $this->settings;
switch ($request->method) {
case "addacc":
PTNAccount::addAccount($this->settings, $params['public'], $params['secret']);
$resp = array("status" => PTNAccount::exists($this->settings, $params['public']));
break;
case "rmacc":
$resp = array("status" => PTNAccount::remove($this->settings, $params['public']));
break;
case "updt":
$account->updateInfo($params);
$resp = array("status" => PTNAccount::exists($this->settings, $params['pubkey']));
break;
case "updtapikey":
PTNAccount::updateApiPublicKey($this->settings, $params['pubkey']);
$resp = array("status" => $this->settings->getOption(PTNAccount::$api_public_key));
break;
case "rmbvscrt":
$resp = array("status" => $settings->deleteOption('bvSecretKey'));
break;
case "rmbvkeys":
$resp = array("status" => $settings->deleteOption('bvKeys'));
break;
case "rmdefpub":
$resp = array("status" => $settings->deleteOption('bvDefaultPublic'));
break;
case "rmoldbvacc":
$resp = array("status" => $settings->deleteOption('bvAccounts'));
break;
case "fetch":
$accounts = PTNAccount::allAccounts($this->settings);
if (!isset($params['full'])) {
foreach ($accounts as &$account) {
if (isset($account['secret'])) {
unset($account['secret']);
}
}
}
$resp = array("status" => $accounts);
break;
case "updtinfo":
$resp = $this->updateInfo($params);
break;
default:
$resp = false;
}
return $resp;
}
}
endif;
\ No newline at end of file
<?php
if (!defined('ABSPATH')) exit;
if (!class_exists('BVBrandCallback')) :
class BVBrandCallback extends BVCallbackBase {
public $settings;
const BRAND_WING_VERSION = 1.0;
public function __construct($callback_handler) {
$this->settings = $callback_handler->settings;
}
public function process($request) {
$bvinfo = new PTNInfo($this->settings);
$option_name = $bvinfo->brand_option;
$params = $request->params;
switch($request->method) {
case 'setbrand':
$brandinfo = array();
if (array_key_exists('hide', $params)) {
$brandinfo['hide'] = $params['hide'];
} else {
$brandinfo['name'] = $params['name'];
$brandinfo['title'] = $params['title'];
$brandinfo['description'] = $params['description'];
$brandinfo['pluginuri'] = $params['pluginuri'];
$brandinfo['author'] = $params['author'];
$brandinfo['authorname'] = $params['authorname'];
$brandinfo['authoruri'] = $params['authoruri'];
$brandinfo['menuname'] = $params['menuname'];
$brandinfo['logo'] = $params['logo'];
$brandinfo['webpage'] = $params['webpage'];
$brandinfo['appurl'] = $params['appurl'];
if (array_key_exists('hide_plugin_details', $params)) {
$brandinfo['hide_plugin_details'] = $params['hide_plugin_details'];
}
if (array_key_exists('hide_from_menu', $params)) {
$brandinfo['hide_from_menu'] = $params['hide_from_menu'];
}
}
$this->settings->updateOption($option_name, $brandinfo);
$resp = array("setbrand" => $this->settings->getOption($option_name));
break;
case 'rmbrand':
$this->settings->deleteOption($option_name);
$resp = array("rmbrand" => !$this->settings->getOption($option_name));
break;
default:
$resp = false;
}
return $resp;
}
}
endif;
\ No newline at end of file
<?php
if (!defined('ABSPATH')) exit;
if (!class_exists('BVDBCallback')) :
require_once dirname( __FILE__ ) . '/../streams.php';
class BVDBCallback extends BVCallbackBase {
public $db;
public $stream;
public $account;
public $siteinfo;
public static $bvTables = array("fw_requests", "lp_requests", "ip_store");
const DB_WING_VERSION = 1.3;
public function __construct($callback_handler) {
$this->db = $callback_handler->db;
$this->account = $callback_handler->account;
$this->siteinfo = $callback_handler->siteinfo;
}
public function getLastID($pkeys, $end_row) {
$last_ids = array();
foreach($pkeys as $pk) {
$last_ids[$pk] = $end_row[$pk];
}
return $last_ids;
}
public function getTableData($table, $tname, $offset, $limit, $bsize, $filter, $pkeys, $include_rows = false) {
$tinfo = array();
$rows_count = $this->db->rowsCount($table);
$result = array('count' => $rows_count);
if ($limit == 0) {
$limit = $rows_count;
}
$srows = 1;
while (($limit > 0) && ($srows > 0)) {
if ($bsize > $limit)
$bsize = $limit;
$rows = $this->db->getTableContent($table, '*', $filter, $bsize, $offset);
$srows = sizeof($rows);
$data = array();
$data["table_name"] = $tname;
$data["offset"] = $offset;
$data["size"] = $srows;
$serialized_rows = serialize($rows);
$data['md5'] = md5($serialized_rows);
$data['length'] = strlen($serialized_rows);
array_push($tinfo, $data);
if (!empty($pkeys) && $srows > 0) {
$end_row = end($rows);
$last_ids = $this->getLastID($pkeys, $end_row);
$data['last_ids'] = $last_ids;
$result['last_ids'] = $last_ids;
}
if ($include_rows) {
$data["rows"] = $rows;
$str = serialize($data);
$this->stream->writeStream($str);
}
$offset += $srows;
$limit -= $srows;
}
$result['size'] = $offset;
$result['tinfo'] = $tinfo;
return $result;
}
public function streamQueryResult($identifier, $query, $pkeys) {
$data = array();
$data["identifier"] = $identifier;
$data["query"] = $query;
$data["query_start_time"] = time();
$rows = $this->db->getResult($query);
$srows = sizeof($rows);
$data["size"] = $srows;
$data["query_end_time"] = time();
if (!empty($pkeys) && $srows > 0) {
$end_row = end($rows);
$last_ids = $this->getLastID($pkeys, $end_row);
$data['last_ids'] = $last_ids;
}
$result = array_merge($data);
$data["rows"] = $rows;
$serialized_rows = serialize($data);
$this->stream->writeStream($serialized_rows);
$result['length'] = strlen($serialized_rows);
return $result;
}
function getRandomData($totalSize, $bsize) {
if ($bsize == 0) {
$bsize = $totalSize;
}
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
while ($totalSize > 0) {
if ($bsize > $totalSize) {
$bsize = $totalSize;
}
$randomString = '';
for ($i = 0; $i < $bsize; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
$this->stream->writeStream($randomString);
$totalSize -= $bsize;
}
return array("status" => "true");
}
public function getCreateTableQueries($tables) {
$resp = array();
foreach($tables as $table) {
$tname = $table;
$resp[$tname] = array("create" => $this->db->showTableCreate($table));
}
return $resp;
}
public function checkTables($tables, $type) {
$resp = array();
foreach($tables as $table) {
$tname = $table;
$resp[$tname] = array("status" => $this->db->checkTable($table, $type));
}
return $resp;
}
public function describeTables($tables) {
$resp = array();
foreach($tables as $table) {
$tname = $table;
$resp[$tname] = array("description" => $this->db->describeTable($table));
$resp[$tname]["primary_keys_index"] = $this->db->showTableIndex($table);
}
return $resp;
}
public function checkTablesExist($tables) {
$resp = array();
foreach($tables as $table) {
$tname = $table;
$resp[$tname] = array("tblexists" => $this->db->isTablePresent($table));
}
return $resp;
}
public function getTablesRowCount($tables) {
$resp = array();
foreach($tables as $table) {
$tname = $table;
$resp[$tname] = array("count" => $this->db->rowsCount($table));
}
return $resp;
}
public function getTablesKeys($tables) {
$resp = array();
foreach($tables as $table) {
$tname = $table;
$resp[$tname] = array("keys" => $this->db->tableKeys($table));
}
return $resp;
}
public function multiGetResult($queries) {
$resp = array();
foreach($queries as $query) {
array_push($resp, $this->db->getResult($query));
}
return $resp;
}
public function process($request) {
$db = $this->db;
$params = $request->params;
$stream_init_info = BVStream::startStream($this->account, $request);
if (array_key_exists('stream', $stream_init_info)) {
$this->stream = $stream_init_info['stream'];
switch ($request->method) {
case "gettbls":
$resp = array("tables" => $db->showTables());
break;
case "tblstatus":
$resp = array("statuses" => $db->showTableStatus());
break;
case "tablekeys":
$table = $params['table'];
$resp = array("table_keys" => $db->tableKeys($table));
break;
case "describetable":
$table = $params['table'];
$resp = array("table_description" => $db->describeTable($table));
$resp["primary_keys_index"] = $db->showTableIndex($table);
break;
case "checktable":
$table = $params['table'];
$type = $params['type'];
$resp = array("status" => $db->checkTable($table, $type));
break;
case "repairtable":
$table = $params['table'];
$resp = array("status" => $db->repairTable($table));
break;
case "gettcrt":
$table = $params['table'];
$resp = array("create" => $db->showTableCreate($table));
break;
case "tblskys":
$tables = $params['tables'];
$resp = $this->getTablesKeys($tables);
break;
case "getmlticrt":
$tables = $params['tables'];
$resp = $this->getCreateTableQueries($tables);
break;
case "desctbls":
$tables = $params['tables'];
$resp = $this->describeTables($tables);
break;
case "mltirwscount":
$tables = $params['tables'];
$resp = $this->getTablesRowCount($tables);
break;
case "chktabls":
$tables = $params['tables'];
$type = $params['type'];
$resp = $this->checkTables($tables, $type);
break;
case "chktablsxist":
$tables = $params['tables'];
$resp = $this->checkTablesExist($tables);
break;
case "getrowscount":
$table = $params['table'];
$resp = array("count" => $db->rowsCount($table));
break;
case "gettablecontent":
$result = array();
$table = $params['table'];
$fields = $params['fields'];
$filter = (array_key_exists('filter', $params)) ? $params['filter'] : "";
$limit = intval($params['limit']);
$offset = intval($params['offset']);
$pkeys = (array_key_exists('pkeys', $params)) ? $params['pkeys'] : array();
$result['timestamp'] = time();
$result['tablename'] = $table;
$rows = $db->getTableContent($table, $fields, $filter, $limit, $offset);
$srows = sizeof($rows);
if (!empty($pkeys) && $srows > 0) {
$end_row = end($rows);
$result['last_ids'] = $this->getLastID($pkeys, $end_row);
}
$result["rows"] = $rows;
$resp = $result;
break;
case "multitablecontent":
$tableParams = $params['table_params'];
$resp = array();
foreach($tableParams as $tableParam) {
$result = array();
$identifier = $tableParam['identifier'];
$table = $tableParam['table'];
$tname = $tableParam['tname'];
$fields = $tableParam['fields'];
$filter = (array_key_exists('filter', $tableParam)) ? $tableParam['filter'] : "";
$limit = $tableParam['limit'];
$offset = $tableParam['offset'];
$pkeys = (array_key_exists('pkeys', $tableParam)) ? $tableParam['pkeys'] : array();
$result['timestamp'] = time();
$result['table_name'] = $tname;
$rows = $db->getTableContent($table, $fields, $filter, $limit, $offset);
$srows = sizeof($rows);
if (!empty($pkeys) && $srows > 0) {
$end_row = end($rows);
$result['last_ids'] = $this->getLastID($pkeys, $end_row);
}
$result["rows"] = $rows;
$result["size"] = $srows;
$resp[$identifier] = $result;
}
break;
case "tableinfo":
$table = $params['table'];
$offset = intval($params['offset']);
$limit = intval($params['limit']);
$bsize = intval($params['bsize']);
$filter = (array_key_exists('filter', $params)) ? $params['filter'] : "";
$tname = $params['tname'];
$pkeys = (array_key_exists('pkeys', $params)) ? $params['pkeys'] : array();
$resp = $this->getTableData($table, $tname, $offset, $limit, $bsize, $filter, $pkeys, false);
break;
case "getmulttables":
$result = array();
$tableParams = $params['table_params'];
$resp = array();
foreach($tableParams as $tableParam) {
$table = $tableParam['table'];
$tname = $tableParam['tname'];
$filter = (array_key_exists('filter', $tableParam)) ? $tableParam['filter'] : "";
$limit = intval($tableParam['limit']);
$offset = intval($tableParam['offset']);
$bsize = intval($tableParam['bsize']);
$pkeys = (array_key_exists('pkeys', $tableParam)) ? $tableParam['pkeys'] : array();
$resp[$tname] = $this->getTableData($table, $tname, $offset, $limit, $bsize, $filter, $pkeys, true);
}
break;
case "uploadrows":
$table = $params['table'];
$offset = intval($params['offset']);
$limit = intval($params['limit']);
$bsize = intval($params['bsize']);
$filter = (array_key_exists('filter', $params)) ? $params['filter'] : "";
$tname = $params['tname'];
$pkeys = (array_key_exists('pkeys', $params)) ? $params['pkeys'] : array();
$resp = $this->getTableData($table, $tname, $offset, $limit, $bsize, $filter, $pkeys, true);
break;
case "tblexists":
$resp = array("tblexists" => $db->isTablePresent($params['table']));
break;
case "crttbl":
$usedbdelta = array_key_exists('usedbdelta', $params);
$resp = array("crttbl" => $db->createTable($params['query'], $params['table'], $usedbdelta));
break;
case "drptbl":
$resp = array("drptbl" => $db->dropBVTable($params['table']));
break;
case "trttbl":
$resp = array("trttbl" => $db->truncateBVTable($params['table']));
break;
case "altrtbl":
$resp = array("altrtbl" => $db->alterBVTable($params['query'], $params['query']));
break;
case "mltigtrslt":
$resp = array("mltigtrslt" => $this->multiGetResult($params['queries']));
break;
case "mltiqrsstrm":
$queries = $params['queries'];
$result = array();
foreach ($queries as $qparams) {
$identifier = $qparams['identifier'];
$query = $qparams['query'];
$pkeys = (array_key_exists('pkeys', $qparams)) ? $qparams['pkeys'] : array();
array_push($result, $this->streamQueryResult($identifier, $query, $pkeys));
}
$resp = array('mltqrsstrm' => $result);
break;
case "getrndmdata":
$resp = array("getrndmdata" => $this->getRandomData($params['size'], $params['batch_size']));
break;
case "tbls":
$resp = array();
if (array_key_exists('truncate', $params))
$resp['truncate'] = $db->truncateTables($params['truncate']);
if (array_key_exists('drop', $params))
$resp['drop'] = $db->dropTables($params['drop']);
if (array_key_exists('create', $params))
$resp['create'] = $db->createTables($params['create']);
if (array_key_exists('alter', $params))
$resp['alter'] = $db->alterTables($params['alter']);
break;
default:
$resp = false;
}
$end_stream_info = $this->stream->endStream();
if (!empty($end_stream_info) && is_array($resp)) {
$resp = array_merge($resp, $end_stream_info);
}
} else {
$resp = $stream_init_info;
}
return $resp;
}
}
endif;
\ No newline at end of file
<?php
if (!defined('ABSPATH')) exit;
if (!class_exists('BVFSCallback')) :
require_once dirname( __FILE__ ) . '/../streams.php';
class BVFSCallback extends BVCallbackBase {
public $stream;
public $account;
public static $cwAllowedFiles = array(".htaccess", ".user.ini", "malcare-waf.php");
const FS_WING_VERSION = 1.2;
public function __construct($callback_handler) {
$this->account = $callback_handler->account;
}
function fileStat($relfile, $md5 = false) {
$absfile = ABSPATH.$relfile;
$fdata = array();
$fdata["filename"] = $relfile;
$stats = @stat($absfile);
if ($stats) {
foreach (preg_grep('#size|uid|gid|mode|mtime#i', array_keys($stats)) as $key ) {
$fdata[$key] = $stats[$key];
}
if (is_link($absfile)) {
$fdata["link"] = @readlink($absfile);
}
if ($md5 === true && !is_dir($absfile)) {
$fdata["md5"] = $this->calculateMd5($absfile, array(), 0, 0, 0);
}
} else {
$fdata["failed"] = true;
}
return $fdata;
}
function scanFilesUsingGlob($initdir = "./", $offset = 0, $limit = 0, $bsize = 512, $recurse = true, $regex = '{.??,}*') {
$i = 0;
$dirs = array();
$dirs[] = $initdir;
$bfc = 0;
$bfa = array();
$current = 0;
$abspath = realpath(ABSPATH).'/';
$abslen = strlen($abspath);
# XNOTE: $recurse cannot be used directly here
while ($i < count($dirs)) {
$dir = $dirs[$i];
foreach (glob($abspath.$dir.$regex, GLOB_NOSORT | GLOB_BRACE) as $absfile) {
$relfile = substr($absfile, $abslen);
if (is_dir($absfile) && !is_link($absfile)) {
$dirs[] = $relfile."/";
}
$current++;
if ($offset >= $current)
continue;
if (($limit != 0) && (($current - $offset) > $limit)) {
$i = count($dirs);
break;
}
$bfa[] = $this->fileStat($relfile);
$bfc++;
if ($bfc == $bsize) {
$str = serialize($bfa);
$this->stream->writeStream($str);
$bfc = 0;
$bfa = array();
}
}
$regex = '{.??,}*';
$i++;
if ($recurse == false)
break;
}
if ($bfc != 0) {
$str = serialize($bfa);
$this->stream->writeStream($str);
}
return array("status" => "done");
}
function scanFiles($initdir = "./", $offset = 0, $limit = 0, $bsize = 512, $recurse = true, $md5 = false) {
$i = 0;
$links = array();
$dirs = array();
$dirs[] = $initdir;
$bfc = 0;
$bfa = array();
$current = 0;
while ($i < count($dirs)) {
$dir = $dirs[$i];
$d = @opendir(ABSPATH.$dir);
if ($d) {
while (($file = readdir($d)) !== false) {
if ($file == '.' || $file == '..') { continue; }
$relfile = $dir.$file;
$absfile = ABSPATH.$relfile;
if (is_link($absfile)) {
$links[] = $relfile;
}
if (is_dir($absfile) && !is_link($absfile)) {
$dirs[] = $relfile."/";
}
$current++;
if ($offset >= $current)
continue;
if (($limit != 0) && (($current - $offset) > $limit)) {
$i = count($dirs);
break;
}
$bfa[] = $this->fileStat($relfile, $md5);
$bfc++;
if ($bfc == $bsize) {
$str = serialize($bfa);
$this->stream->writeStream($str);
$bfc = 0;
$bfa = array();
}
}
closedir($d);
}
$i++;
if ($recurse == false)
break;
}
if ($bfc != 0) {
$str = serialize($bfa);
$this->stream->writeStream($str);
}
return $links;
}
function calculateMd5($absfile, $fdata, $offset, $limit, $bsize) {
if ($offset == 0 && $limit == 0) {
$md5 = md5_file($absfile);
} else {
if ($limit == 0)
$limit = $fdata["size"];
if ($offset + $limit < $fdata["size"])
$limit = $fdata["size"] - $offset;
$handle = fopen($absfile, "rb");
$ctx = hash_init('md5');
fseek($handle, $offset, SEEK_SET);
$dlen = 1;
while (($limit > 0) && ($dlen > 0)) {
if ($bsize > $limit)
$bsize = $limit;
$d = fread($handle, $bsize);
$dlen = strlen($d);
hash_update($ctx, $d);
$limit -= $dlen;
}
fclose($handle);
$md5 = hash_final($ctx);
}
return $md5;
}
function getFilesContent($files, $withContent = true) {
$result = array();
foreach ($files as $file) {
$fdata = $this->fileStat($file);
$absfile = ABSPATH.$file;
if (is_dir($absfile) && !is_link($absfile)) {
$fdata['is_dir'] = true;
} else {
if (!is_readable($absfile)) {
$fdata['error'] = 'file not readable';
} else {
if ($withContent === true) {
if ($content = file_get_contents($absfile)) {
$fdata['content'] = $content;
} else {
$fdata['error'] = 'unable to read file';
}
}
}
}
$result[$file] = $fdata;
}
return $result;
}
function getFilesStats($files, $offset = 0, $limit = 0, $bsize = 102400, $md5 = false) {
$result = array();
foreach ($files as $file) {
$fdata = $this->fileStat($file);
$absfile = ABSPATH.$file;
if (!is_readable($absfile)) {
$result["missingfiles"][] = $file;
continue;
}
if ($md5 === true && !is_dir($absfile)) {
$fdata["md5"] = $this->calculateMd5($absfile, $fdata, $offset, $limit, $bsize);
}
$result["stats"][] = $fdata;
}
return $result;
}
function uploadFiles($files, $offset = 0, $limit = 0, $bsize = 102400) {
$result = array();
foreach ($files as $file) {
if (!is_readable(ABSPATH.$file)) {
$result["missingfiles"][] = $file;
continue;
}
$handle = fopen(ABSPATH.$file, "rb");
if (($handle != null) && is_resource($handle)) {
$fdata = $this->fileStat($file);
$_limit = $limit;
$_bsize = $bsize;
if ($_limit == 0)
$_limit = $fdata["size"];
if ($offset + $_limit > $fdata["size"])
$_limit = $fdata["size"] - $offset;
$fdata["limit"] = $_limit;
$sfdata = serialize($fdata);
$this->stream->writeStream($sfdata);
fseek($handle, $offset, SEEK_SET);
$dlen = 1;
while (($_limit > 0) && ($dlen > 0)) {
if ($_bsize > $_limit)
$_bsize = $_limit;
$d = fread($handle, $_bsize);
$dlen = strlen($d);
$this->stream->writeStream($d);
$_limit -= $dlen;
}
fclose($handle);
} else {
$result["unreadablefiles"][] = $file;
}
}
$result["status"] = "done";
return $result;
}
function process($request) {
$params = $request->params;
$stream_init_info = BVStream::startStream($this->account, $request);
if (array_key_exists('stream', $stream_init_info)) {
$this->stream = $stream_init_info['stream'];
switch ($request->method) {
case "scanfilesglob":
$initdir = $params['initdir'];
$offset = intval($params['offset']);
$limit = intval($params['limit']);
$bsize = intval($params['bsize']);
$regex = $params['regex'];
$recurse = true;
if (array_key_exists('recurse', $params) && $params["recurse"] == "false") {
$recurse = false;
}
$resp = $this->scanFilesUsingGlob($initdir, $offset, $limit, $bsize, $recurse, $regex);
break;
case "scanfiles":
$links = array();
$dir_options = array();
if (array_key_exists('dir_options', $params)) {
$dir_options = $params['dir_options'];
}
$bsize = intval($params['bsize']);
foreach($dir_options as $option) {
$dir = $option['dir'];
$offset = intval($option['offset']);
$limit = intval($option['limit']);
$recurse = true;
if (array_key_exists('recurse', $option) && $option["recurse"] == "false") {
$recurse = false;
}
$md5 = true;
if (array_key_exists('md5', $option) && $option["md5"] == "false") {
$md5 = false;
}
$_links = $this->scanFiles($dir, $offset, $limit, $bsize, $recurse, $md5);
$links = array_merge($links, $_links);
}
$resp = array("status" => "done", "links" => $links);
break;
case "getfilesstats":
$files = $params['files'];
$offset = intval($params['offset']);
$limit = intval($params['limit']);
$bsize = intval($params['bsize']);
$md5 = false;
if (array_key_exists('md5', $params)) {
$md5 = true;
}
$resp = $this->getFilesStats($files, $offset, $limit, $bsize, $md5);
break;
case "sendmanyfiles":
$files = $params['files'];
$offset = intval($params['offset']);
$limit = intval($params['limit']);
$bsize = intval($params['bsize']);
$resp = $this->uploadFiles($files, $offset, $limit, $bsize);
break;
case "filelist":
$dir_options = array();
if (array_key_exists('dir_options', $params)) {
$dir_options = $params['dir_options'];
}
if (array_key_exists('chdir', $params)) {
chdir(ABSPATH);
}
$resp = array();
foreach($dir_options as $options) {
$glob_option = 0;
if (array_key_exists('onlydir', $options)) {
$glob_option = GLOB_ONLYDIR;
}
$regexes = array("*", ".*");
if (array_key_exists('regex', $options)) {
$regexes = array($options['regex']);
}
$md5 = false;
if (array_key_exists('md5', $options)) {
$md5 = $options['md5'];
}
$directoryList = array();
foreach($regexes as $regex) {
$directoryList = array_merge($directoryList, glob($options['dir'].$regex, $glob_option));
}
$resp[$options['dir']] = $this->getFilesStats($directoryList, 0, 0, 0, $md5);
}
break;
case "dirsexists":
$resp = array();
$dirs = $params['dirs'];
foreach ($dirs as $dir) {
$path = ABSPATH.$dir;
if (file_exists($path) && is_dir($path) && !is_link($path)) {
$resp[$dir] = true;
} else {
$resp[$dir] = false;
}
}
$resp["status"] = "Done";
break;
case "gtfilescntent":
$files = $params['files'];
$withContent = array_key_exists('withcontent', $params) ? $params['withcontent'] : true;
$resp = array("files_content" => $this->getFilesContent($files, $withContent));
break;
case "gtfls":
$resp = array();
if (array_key_exists('get_files_content', $params)) {
$args = $params['get_files_content'];
$with_content = array_key_exists('withcontent', $args) ? $args['withcontent'] : true;
$resp['get_files_content'] = $this->getFilesContent($args['files'], $with_content);
}
if (array_key_exists('get_files_stats', $params)) {
$args = $params['get_files_stats'];
$md5 = array_key_exists('md5', $args) ? $args['md5'] : false;
$stats = $this->getFilesStats(
$args['files'], $args['offset'], $args['limit'], $args['bsize'], $md5
);
$result = array();
if (array_key_exists('stats', $stats)) {
$result['stats'] = array();
foreach ($stats['stats'] as $stat) {
$result['stats'][$stat['filename']] = $stat;
}
}
if (array_key_exists('missingfiles', $stats)) {
$result['missingfiles'] = $stats['missingfiles'];
}
$resp['get_files_stats'] = $result;
}
break;
default:
$resp = false;
}
$end_stream_info = $this->stream->endStream();
if (!empty($end_stream_info) && is_array($resp)) {
$resp = array_merge($resp, $end_stream_info);
}
} else {
$resp = $stream_init_info;
}
return $resp;
}
}
endif;
\ No newline at end of file
<?php
if (!defined('ABSPATH')) exit;
if (!class_exists('BVInfoCallback')) :
class BVInfoCallback extends BVCallbackBase {
public $db;
public $settings;
public $siteinfo;
public $bvinfo;
public $bvapi;
const INFO_WING_VERSION = 1.8;
public function __construct($callback_handler) {
$this->db = $callback_handler->db;
$this->siteinfo = $callback_handler->siteinfo;
$this->settings = $callback_handler->settings;
$this->bvinfo = new PTNInfo($this->settings);
$this->bvapi = new PTNWPAPI($this->settings);
}
public function getPosts($post_type, $count = 5) {
$output = array();
$args = array('numberposts' => $count, 'post_type' => $post_type);
$posts = get_posts($args);
$keys = array('post_title', 'guid', 'ID', 'post_date');
$result = array();
foreach ($posts as $post) {
$pdata = array();
$post_array = get_object_vars($post);
foreach ($keys as $key) {
$pdata[$key] = $post_array[$key];
}
$result["posts"][] = $pdata;
}
return $result;
}
public function getStats() {
return array(
"posts" => get_object_vars(wp_count_posts()),
"pages" => get_object_vars(wp_count_posts("page")),
"comments" => get_object_vars(wp_count_comments())
);
}
public function getLatestWooCommerceDB() {
$version = false;
if (defined('WC_ABSPATH') && file_exists(WC_ABSPATH . 'includes/class-wc-install.php')) {
include_once WC_ABSPATH . 'includes/class-wc-install.php';
}
if (class_exists('WC_Install')) {
$update_versions = array_keys(WC_Install::get_db_update_callbacks());
usort($update_versions, 'version_compare');
if (!empty($update_versions)) {
$version = end($update_versions);
}
}
return $version;
}
public function addDBInfoToPlugin($pdata, $plugin_file) {
switch ($plugin_file) {
case "woocommerce/woocommerce.php":
$pdata['current_db_version'] = $this->settings->getOption('woocommerce_db_version');
$pdata['latest_db_version'] = $this->getLatestWooCommerceDB();
break;
}
return $pdata;
}
public function getPlugins() {
if (!function_exists('get_plugins')) {
require_once (ABSPATH."wp-admin/includes/plugin.php");
}
$plugins = get_plugins();
$result = array();
foreach ($plugins as $plugin_file => $plugin_data) {
$pdata = array(
'file' => $plugin_file,
'title' => $plugin_data['Title'],
'version' => $plugin_data['Version'],
'active' => is_plugin_active($plugin_file),
'network' => $plugin_data['Network']
);
$pdata = $this->addDBInfoToPlugin($pdata, $plugin_file);
$result["plugins"][] = $pdata;
}
return $result;
}
public function themeToArray($theme) {
if (is_object($theme)) {
$pdata = array(
'name' => $theme->Name,
'title' => $theme->Title,
'stylesheet' => $theme->get_stylesheet(),
'template' => $theme->Template,
'version' => $theme->Version
);
} else {
$pdata = array(
'name' => $theme["Name"],
'title' => $theme["Title"],
'stylesheet' => $theme["Stylesheet"],
'template' => $theme["Template"],
'version' => $theme["Version"]
);
}
return $pdata;
}
public function getThemes() {
$result = array();
$themes = function_exists('wp_get_themes') ? wp_get_themes() : get_themes();
foreach($themes as $theme) {
$pdata = $this->themeToArray($theme);
$result["themes"][] = $pdata;
}
$theme = function_exists('wp_get_theme') ? wp_get_theme() : get_current_theme();
$pdata = $this->themeToArray($theme);
$result["currenttheme"] = $pdata;
return $result;
}
public function getSystemInfo() {
$sys_info = array(
'host' => $_SERVER['HTTP_HOST'],
'phpversion' => phpversion(),
'AF_INET6' => defined('AF_INET6')
);
if (array_key_exists('SERVER_ADDR', $_SERVER)) {
$sys_info['serverip'] = $_SERVER['SERVER_ADDR'];
}
if (function_exists('get_current_user')) {
$sys_info['user'] = get_current_user();
}
if (function_exists('getmygid')) {
$sys_info['gid'] = getmygid();
}
if (function_exists('getmyuid')) {
$sys_info['uid'] = getmyuid();
}
if (function_exists('posix_getuid')) {
$sys_info['webuid'] = posix_getuid();
$sys_info['webgid'] = posix_getgid();
}
return $sys_info;
}
public function getWpInfo() {
global $wp_version, $wp_db_version, $wp_local_package;
$siteinfo = $this->siteinfo;
$db = $this->db;
$upload_dir = wp_upload_dir();
$wp_info = array(
'dbprefix' => $db->dbprefix(),
'wpmu' => $siteinfo->isMultisite(),
'mainsite' => $siteinfo->isMainSite(),
'main_site_id' => $siteinfo->getMainSiteId(),
'name' => get_bloginfo('name'),
'siteurl' => $siteinfo->siteurl(),
'homeurl' => $siteinfo->homeurl(),
'charset' => get_bloginfo('charset'),
'wpversion' => $wp_version,
'dbversion' => $wp_db_version,
'mysql_version' => $db->getMysqlVersion(),
'abspath' => ABSPATH,
'bvpluginpath' => defined('PTNBASEPATH') ? PTNBASEPATH : null,
'uploadpath' => $upload_dir['basedir'],
'uploaddir' => wp_upload_dir(),
'contentdir' => defined('WP_CONTENT_DIR') ? WP_CONTENT_DIR : null,
'contenturl' => defined('WP_CONTENT_URL') ? WP_CONTENT_URL : null,
'plugindir' => defined('WP_PLUGIN_DIR') ? WP_PLUGIN_DIR : null,
'dbcharset' => defined('DB_CHARSET') ? DB_CHARSET : null,
'disallow_file_edit' => defined('DISALLOW_FILE_EDIT'),
'disallow_file_mods' => defined('DISALLOW_FILE_MODS'),
'custom_users' => defined('CUSTOM_USER_TABLE') ? CUSTOM_USER_TABLE : null,
'custom_usermeta' => defined('CUSTOM_USERMETA_TABLE') ? CUSTOM_USERMETA_TABLE : null,
'locale' => get_locale(),
'wp_local_string' => $wp_local_package,
'charset_collate' => $db->getCharsetCollate()
);
return $wp_info;
}
public function getUsers($full, $args = array()) {
$results = array();
$users = get_users($args);
if ('true' == $full) {
$results = $this->objectToArray($users);
} else {
foreach( (array) $users as $user) {
$result = array();
$result['user_email'] = $user->user_email;
$result['ID'] = $user->ID;
$result['roles'] = $user->roles;
$result['user_login'] = $user->user_login;
$result['display_name'] = $user->display_name;
$result['user_registered'] = $user->user_registered;
$result['user_status'] = $user->user_status;
$result['user_url'] = $user->url;
$results[] = $result;
}
}
return $results;
}
public function availableFunctions(&$info) {
if (extension_loaded('openssl')) {
$info['openssl'] = "1";
}
if (function_exists('is_ssl') && is_ssl()) {
$info['https'] = "1";
}
if (function_exists('openssl_public_encrypt')) {
$info['openssl_public_encrypt'] = "1";
}
if (function_exists('openssl_public_decrypt')) {
$info['openssl_public_decrypt'] = "1";
}
$info['sha1'] = "1";
$info['apissl'] = "1";
if (function_exists('base64_encode')) {
$info['b64encode'] = true;
}
if (function_exists('base64_decode')) {
$info['b64decode'] = true;
}
return $info;
}
public function servicesInfo(&$data) {
$settings = $this->settings;
$data['protect'] = $settings->getOption('bvptconf');
$data['brand'] = $settings->getOption($this->bvinfo->brand_option);
$data['badgeinfo'] = $settings->getOption($this->bvinfo->badgeinfo);
$data[$this->bvinfo->services_option_name] = $this->bvinfo->config;
}
public function dbconf(&$info) {
$db = $this->db;
if (defined('DB_CHARSET'))
$info['dbcharset'] = DB_CHARSET;
$info['dbprefix'] = $db->dbprefix();
$info['charset_collate'] = $db->getCharsetCollate();
return $info;
}
public function cookieInfo() {
$info = array();
if (defined('COOKIEPATH'))
$info['cookiepath'] = COOKIEPATH;
if (defined('COOKIE_DOMAIN'))
$info['cookiedomain'] = COOKIE_DOMAIN;
return $info;
}
public function activate() {
$info = array();
$this->siteinfo->basic($info);
$this->servicesInfo($info);
$this->dbconf($info);
$this->availableFunctions($info);
return $info;
}
public function getHostInfo() {
$host_info = $_SERVER;
$host_info['PHP_SERVER_NAME'] = php_uname('\n');
if (array_key_exists('IS_PRESSABLE', get_defined_constants())) {
$host_info['IS_PRESSABLE'] = true;
}
if (array_key_exists('GRIDPANE', get_defined_constants())) {
$host_info['IS_GRIDPANE'] = true;
}
if (defined('WPE_APIKEY')) {
$host_info['WPE_APIKEY'] = WPE_APIKEY;
}
return $host_info;
}
public function serverConfig() {
return array(
'software' => $_SERVER['SERVER_SOFTWARE'],
'sapi' => (function_exists('php_sapi_name')) ? php_sapi_name() : false,
'has_apache_get_modules' => function_exists('apache_get_modules'),
'posix_getuid' => (function_exists('posix_getuid')) ? posix_getuid() : null,
'uid' => (function_exists('getmyuid')) ? getmyuid() : null,
'user_ini' => ini_get('user_ini.filename'),
'php_major_version' => PHP_MAJOR_VERSION
);
}
function refreshUpdatesInfo() {
global $wp_current_filter;
$wp_current_filter[] = 'load-update-core.php';
if (function_exists('wp_clean_update_cache')) {
wp_clean_update_cache();
} else {
$this->settings->deleteTransient('update_plugins');
$this->settings->deleteTransient('update_themes');
$this->settings->deleteTransient('update_core');
}
wp_update_plugins();
wp_update_themes();
array_pop($wp_current_filter);
wp_update_plugins();
wp_update_themes();
wp_version_check();
wp_version_check(array(), true);
return true;
}
function getUsersHandler($args = array()) {
$db = $this->db;
$table = "{$db->dbprefix()}users";
$count = $db->rowsCount($table);
$result = array("count" => $count);
$max_users = array_key_exists('max_users', $args) ? $args['max_users'] : 500;
$roles = array_key_exists('roles', $args) ? $args['roles'] : array();
$users = array();
if (($count > $max_users) && !empty($roles)) {
foreach ($roles as $role) {
if ($max_users <= 0)
break;
$args['number'] = $max_users;
$args['role'] = $role;
$fetched = $this->getUsers($args['full'], $args);
$max_users -= sizeof($fetched);
$users = array_merge($users, $fetched);
}
} else {
$args['number'] = $max_users;
$users = $this->getUsers($args['full'], $args);
}
$result['users_info'] = $users;
return $result;
}
function getTransient($name, $asarray = true) {
$transient = $this->settings->getTransient($name);
if ($transient && $asarray)
$transient = $this->objectToArray($transient);
return array("transient" => $transient);
}
function getPluginsHandler($args = array()) {
$result = array_merge($this->getPlugins(), $this->getTransient('update_plugins'));
if (array_key_exists('clear_filters', $args)) {
$filters = $args['clear_filters'];
foreach ($filters as $filter)
remove_all_filters($filter);
$transient_without_filters = $this->getTransient('update_plugins');
$result['transient_without_filters'] = $transient_without_filters['transient'];
}
return $result;
}
function getThemesHandler($args = array()) {
$result = array_merge($this->getThemes(), $this->getTransient('update_themes'));
if (array_key_exists('clear_filters', $args)) {
$filters = $args['clear_filters'];
foreach ($filters as $filter)
remove_all_filters($filter);
$transient_without_filters = $this->getTransient('update_themes');
$result['transient_without_filters'] = $transient_without_filters['transient'];
}
return $result;
}
function getCoreHandler() {
global $wp_db_version;
$result = $this->getTransient('update_core');
$result['current_db_version'] = $this->settings->getOption('db_version');
$result['latest_db_version'] = $wp_db_version;
return $result;
}
function getSiteInfo($args) {
$result = array();
if (array_key_exists('pre_refresh_get_options', $args)) {
$result['pre_refresh_get_options'] = $this->settings->getOptions(
$args['pre_refresh_get_options']
);
}
if (array_key_exists('refresh', $args))
$result['refreshed'] = $this->refreshUpdatesInfo();
if (array_key_exists('users', $args))
$result['users'] = $this->getUsersHandler($args['users']);
if (array_key_exists('plugins', $args))
$result['plugins'] = $this->getPluginsHandler($args['plugins']);
if (array_key_exists('themes', $args))
$result['themes'] = $this->getThemesHandler($args['themes']);
if (array_key_exists('core', $args))
$result['core'] = $this->getCoreHandler();
if (array_key_exists('sys', $args))
$result['sys'] = $this->getSystemInfo();
if (array_key_exists('get_options', $args))
$result['get_options'] = $this->settings->getOptions($args['get_options']);
return $result;
}
function pingBV() {
$info = array();
$this->siteinfo->basic($info);
$this->bvapi->pingbv('/bvapi/pingbv', $info);
return true;
}
function getPostActivateInfo($args) {
$result = array();
if (array_key_exists('pingbv', $args))
$result['pingbv'] = array('status' => $this->pingBV());
if (array_key_exists('activate_info', $args))
$result['activate_info'] = $this->activate();
if (array_key_exists('cookie_info', $args))
$result['cookie_info'] = $this->cookieInfo();
if (array_key_exists('get_host', $args))
$result['get_host'] = $this->getHostInfo();
if (array_key_exists('get_wp', $args))
$result['get_wp'] = $this->getWpInfo();
if (array_key_exists('get_options', $args))
$result['get_options'] = $this->settings->getOptions($args['get_options']);
if (array_key_exists('get_tables', $args))
$result['get_tables'] = $this->db->showTables();
$result['status'] = true;
return $result;
}
function getPluginServicesInfo($args) {
$result = array();
if (array_key_exists('get_options', $args))
$result['get_options'] = $this->settings->getOptions($args['get_options']);
if (array_key_exists('pingbv', $args))
$result['pingbv'] = array('status' => $this->pingBV());
if (array_key_exists('server_config', $args))
$result['server_config'] = $this->serverConfig();
return $result;
}
public function process($request) {
$db = $this->db;
$params = $request->params;
switch ($request->method) {
case "activateinfo":
$resp = array('actinfo' => $this->activate());
break;
case "ckeyinfo":
$resp = array('cookieinfo' => $this->cookieInfo());
break;
case "gtpsts":
$count = 5;
if (array_key_exists('count', $params))
$count = $params['count'];
$resp = $this->getPosts($params['post_type'], $count);
break;
case "gtsts":
$resp = $this->getStats();
break;
case "gtdbvariables":
$variable = (array_key_exists('variable', $params)) ? $variable : "";
$resp = $this->db->showDbVariables($variable);
break;
case "gtplgs":
$resp = $this->getPlugins();
break;
case "gtthms":
$resp = $this->getThemes();
break;
case "gtsym":
$resp = array('sys' => $this->getSystemInfo());
break;
case "gtwp":
$resp = array('wp' => $this->getWpInfo());
break;
case "gtallhdrs":
$data = (function_exists('getallheaders')) ? getallheaders() : false;
$resp = array("allhdrs" => $data);
break;
case "gtsvr":
$resp = array("svr" => $_SERVER);
break;
case "getoption":
$resp = array("option" => $this->settings->getOption($params['name']));
break;
case "gtusrs":
$full = false;
if (array_key_exists('full', $params))
$full = true;
$resp = array('users' => $this->getUsers($full, $params['args']));
break;
case "gttrnsnt":
$resp = $this->getTransient($params['name'], array_key_exists('asarray', $params));
break;
case "gthost":
$resp = array('host_info' => $this->getHostInfo());
break;
case "gtplinfo":
$args = array(
'slug' => wp_unslash($params['slug'])
);
$action = $params['action'];
$args = (object) $args;
$args = apply_filters('plugins_api_args', $args, $action);
$data = apply_filters('plugins_api', false, $action, $args);
$resp = array("plugins_info" => $data);
break;
case "gtpostactinfo":
$resp = $this->getPostActivateInfo($params);
break;
case "gtsteinfo":
$resp = $this->getSiteInfo($params);
break;
case "psinfo":
$resp = $this->getPluginServicesInfo($params);
break;
default:
$resp = false;
}
return $resp;
}
}
endif;
\ No newline at end of file
<?php
if (!defined('ABSPATH')) exit;
if (!class_exists('BVMiscCallback')) :
class BVMiscCallback extends BVCallbackBase {
public $settings;
public $bvinfo;
public $siteinfo;
public $account;
public $bvapi;
public $db;
const MISC_WING_VERSION = 1.2;
public function __construct($callback_handler) {
$this->settings = $callback_handler->settings;
$this->siteinfo = $callback_handler->siteinfo;
$this->account = $callback_handler->account;
$this->db = $callback_handler->db;
$this->bvinfo = new PTNInfo($callback_handler->settings);
$this->bvapi = new PTNWPAPI($callback_handler->settings);
}
public function refreshPluginUpdates() {
global $wp_current_filter;
$wp_current_filter[] = 'load-update-core.php';
wp_update_plugins();
array_pop($wp_current_filter);
wp_update_plugins();
return array("wpupdateplugins" => true);
}
public function refreshThemeUpdates() {
global $wp_current_filter;
$wp_current_filter[] = 'load-update-core.php';
wp_update_themes();
array_pop($wp_current_filter);
wp_update_themes();
return array("wpupdatethemes" => true);
}
public function getWingInfo() {
return array('wing_info' => self::$wing_infos);
}
public function post_types_data($post_params) {
$result = array();
$get_post_types_args = $post_params['get_post_types_args'];
$post_types = get_post_types($get_post_types_args);
$post_types = array_merge($post_types, $post_params['include_post_types']);
$post_types = array_diff( $post_types, $post_params['exclude_post_types']);
$result['post_types'] = $post_types;
$post_types = esc_sql($post_types);
$post_types = "'" . implode("','", $post_types) . "'";
$post_table = $post_params['table'];
$post_select_columns = implode(", ", $post_params['select_column']);
$post_query = "SELECT MAX(ID) as $post_select_columns FROM ( SELECT
$post_select_columns FROM $post_table WHERE post_type IN ( $post_types )
AND post_status='publish' ORDER BY post_date DESC ) AS posts GROUP BY post_type";
$posts = $this->db->getResult($post_query);
foreach ( $posts as $key => $post ) {
$posts[$key]['url'] = get_permalink($post['ID']);
}
$result['posts'] = $posts;
return $result;
}
public function taxonomy_data($taxonomy_params) {
$result = array();
$get_taxonomies_args = $taxonomy_params['get_taxonomies_args'];
$taxonomies = get_taxonomies($get_taxonomies_args);
$taxonomies = array_diff($taxonomies, $taxonomy_params['exclude_taxonomies']);
$result['taxonomies'] = $taxonomies;
$taxonomies = esc_sql( $taxonomies );
$taxonomies = "'" . implode( "','", $taxonomies ) . "'";
$taxonomy_table = $taxonomy_params['table'];
$taxonomy_select_columns = implode(", ", $taxonomy_params['select_column']);
$taxonomy_query = "SELECT MAX( term_id ) AS $taxonomy_select_columns FROM (
SELECT $taxonomy_select_columns FROM $taxonomy_table WHERE taxonomy IN (
$taxonomies ) AND count > 0) AS taxonomies GROUP BY taxonomy";
$taxonomies = $this->db->getResult($taxonomy_query);
foreach($taxonomies as $key => $taxonomy) {
$taxonomies[$key]['url'] = get_term_link((int)$taxonomy['term_id'], $taxonomy['taxonomy']);
}
$result['taxonomy_data'] = $taxonomies;
return $result;
}
public function process($request) {
$bvinfo = $this->bvinfo;
$settings = $this->settings;
$params = $request->params;
switch ($request->method) {
case "dummyping":
$resp = array();
$resp = array_merge($resp, $this->siteinfo->info());
$resp = array_merge($resp, $this->account->info());
$resp = array_merge($resp, $this->bvinfo->info());
$resp = array_merge($resp, $this->getWingInfo());
break;
case "pngbv":
$info = array();
$this->siteinfo->basic($info);
$this->bvapi->pingbv('/bvapi/pingbv', $info);
$resp = array("status" => true);
break;
case "enablebadge":
$option = $bvinfo->badgeinfo;
$badgeinfo = array();
$badgeinfo['badgeurl'] = $params['badgeurl'];
$badgeinfo['badgeimg'] = $params['badgeimg'];
$badgeinfo['badgealt'] = $params['badgealt'];
$settings->updateOption($option, $badgeinfo);
$resp = array("status" => $settings->getOption($option));
break;
case "disablebadge":
$option = $bvinfo->badgeinfo;
$settings->deleteOption($option);
$resp = array("status" => !$settings->getOption($option));
break;
case "getoption":
$resp = array('getoption' => $settings->getOption($params['opkey']));
break;
case "setdynplug":
$settings->updateOption('bvdynplug', $params['dynplug']);
$resp = array("setdynplug" => $settings->getOption('bvdynplug'));
break;
case "unsetdynplug":
$settings->deleteOption('bvdynplug');
$resp = array("unsetdynplug" => $settings->getOption('bvdynplug'));
break;
case "wpupplgs":
$resp = $this->refreshPluginUpdates();
break;
case "wpupthms":
$resp = $this->refreshThemeUpdates();
break;
case "wpupcre":
$resp = array("wpupdatecore" => wp_version_check());
break;
case "phpinfo":
phpinfo();
die();
break;
case "wpnonce":
$resp = array("wpnonce" => wp_create_nonce($params["wpnonce_action"]));
break;
case "dlttrsnt":
$resp = array("dlttrsnt" => $settings->deleteTransient($params['key']));
break;
case "optns":
$resp = array();
if (array_key_exists("get_options", $params))
$resp["get_options"] = $settings->getOptions($params["get_options"]);
if (array_key_exists("update_options", $params))
$resp["update_options"] = $settings->updateOptions($params["update_options"]);
if (array_key_exists("delete_options", $params))
$resp["delete_options"] = $settings->deleteOptions($params["delete_options"]);
break;
case "setbvss":
$resp = array("status" => $settings->updateOption('bv_site_settings', $params['bv_site_settings']));
break;
case "stsrvcs":
$resp = array();
$deleted_configs = array();
$updated_configs = array();
if (array_key_exists("configs_to_delete", $params)) {
foreach($params["configs_to_delete"] as $config_name) {
$deleted_configs[$config_name] = $settings->deleteOption($config_name);
}
}
if (array_key_exists("configs_to_update", $params)) {
foreach($params["configs_to_update"] as $config_name => $config_value) {
$settings->updateOption($config_name, $config_value);
$updated_configs[$config_name] = $settings->getOption($config_name);
}
}
$resp["updated_configs"] = $updated_configs;
$resp["deleted_configs"] = $deleted_configs;
break;
case "critical_css_data":
$resp = array();
if (array_key_exists('fetch_post_data', $params) && $params['fetch_post_data'] == true) {
$post_params = $params['post_params'];
$post_result = $this->post_types_data($post_params);
$resp['post_cp_results'] = $post_result['posts'];
$resp['post_types'] = $post_result['post_types'];
}
if (array_key_exists('fetch_taxonomy_data', $params) && $params['fetch_taxonomy_data'] == true) {
$taxonomy_params = $params['taxonomy_params'];
$taxonomy_result = $this->taxonomy_data($taxonomy_params);
$resp['taxonomy_cp_results'] = $taxonomy_result['taxonomy_data'];
$resp['taxonomies'] = $taxonomy_result['taxonomies'];
}
break;
case "get_post_ids":
if (array_key_exists('urls', $params)) {
$resp = array();
foreach ( $params['urls'] as $url ) {
$resp[$url] = url_to_postid($url);
}
}
break;
case "permalink":
if (array_key_exists('post_ids', $params)) {
$resp = array();
foreach ( $params['post_ids'] as $id ) {
$resp[$id]['url'] = get_permalink($id);
}
}
break;
default:
$resp = false;
}
return $resp;
}
}
endif;
\ No newline at end of file
.toplevel_page_ptn-automated-migration label{
float: left;
width: 220px;
font-weight: bold;
}
.toplevel_page_ptn-automated-migration input, .toplevel_page_ptn-automated-migration textarea{
width: 180px;
margin-bottom: 20px;
}
.toplevel_page_ptn-automated-migration textarea{
width: 250px;
height: 150px;
}
.boxes{
width: 1em;
}
#submitbutton{
margin-left: 300px;
margin-top: 5px;
width: 100px;
}
br{
clear: left;
}
#wrapper {
width:100%;
clear:both;
overflow: hidden;
position: relative;
width: 100%;
}
.logo-left {
max-width: 50%;
float: left;
}
.logo-right {
max-width: 50%;
float: right;
}
<?php
if (!class_exists('PTNHelper')) :
class PTNHelper {
public static function safePregMatch($pattern, $subject, &$matches = null, $flags = 0, $offset = 0) {
if (!is_string($pattern) || !is_string($subject)) {
return false;
}
return preg_match($pattern, $subject, $matches, $flags, $offset);
}
}
endif;
\ No newline at end of file
<?php
if (!defined('ABSPATH')) exit;
if (!class_exists('PTNInfo')) :
class PTNInfo {
public $settings;
public $config;
public $plugname = 'pantheon';
public $brandname = 'Pantheon Migrate';
public $badgeinfo = 'ptnbadge';
public $ip_header_option = 'ptnipheader';
public $brand_option = 'ptnbrand';
public $version = '5.25';
public $webpage = 'https://pantheon.io';
public $appurl = 'https://migrate.blogvault.net';
public $slug = 'bv-pantheon-migration/pantheon.php';
public $plug_redirect = 'ptnredirect';
public $logo = '../img/logo.png';
public $brand_icon = '/img/icon.png';
public $services_option_name = 'BVSERVICESOPTIONNAME';
public $author = 'Pantheon';
public $title = 'Pantheon Migration';
const DB_VERSION = '4';
public function __construct($settings) {
$this->settings = $settings;
$this->config = $this->settings->getOption($this->services_option_name);
}
public function getCurrentDBVersion() {
$bvconfig = $this->config;
if ($bvconfig && array_key_exists('db_version', $bvconfig)) {
return $bvconfig['db_version'];
}
return false;
}
public function hasValidDBVersion() {
return PTNInfo::DB_VERSION === $this->getCurrentDBVersion();
}
public static function getRequestID() {
if (!defined("BV_REQUEST_ID")) {
define("BV_REQUEST_ID", uniqid(mt_rand()));
}
return BV_REQUEST_ID;
}
public function canSetCWBranding() {
if (PTNWPSiteInfo::isCWServer()) {
$bot_protect_accounts = PTNAccount::accountsByType($this->settings, 'botprotect');
if (sizeof($bot_protect_accounts) >= 1)
return true;
$bot_protect_accounts = PTNAccount::accountsByPattern($this->settings, 'email', '/@cw_user\.com$/');
if (sizeof($bot_protect_accounts) >= 1)
return true;
}
return false;
}
public function getBrandInfo() {
return $this->settings->getOption($this->brand_option);
}
public function getBrandName() {
$brand = $this->getBrandInfo();
if (is_array($brand) && array_key_exists('menuname', $brand)) {
return $brand['menuname'];
}
return $this->brandname;
}
public function getBrandIcon() {
$brand = $this->getBrandInfo();
if (is_array($brand) && array_key_exists('brand_icon', $brand)) {
return $brand['brand_icon'];
}
return $this->brand_icon;
}
public function getWatchTime() {
$time = $this->settings->getOption('bvwatchtime');
return ($time ? $time : 0);
}
public function appUrl() {
if (defined('BV_APP_URL')) {
return BV_APP_URL;
} else {
$brand = $this->getBrandInfo();
if (is_array($brand) && array_key_exists('appurl', $brand)) {
return $brand['appurl'];
}
return $this->appurl;
}
}
public function isActivePlugin() {
$expiry_time = time() - (3 * 24 * 3600);
return ($this->getWatchTime() > $expiry_time);
}
public function isValidEnvironment(){
$bvsiteinfo = new PTNWPSiteInfo();
$bvconfig = $this->config;
if (is_multisite()) {
return true;
} elseif ($bvconfig && array_key_exists("siteurl_scheme", $bvconfig)) {
$siteurl = $bvsiteinfo->siteurl('', $bvconfig["siteurl_scheme"]);
if (array_key_exists("abspath", $bvconfig) &&
array_key_exists("siteurl", $bvconfig) && !empty($siteurl)) {
return ($bvconfig["abspath"] == ABSPATH && $bvconfig["siteurl"] == $siteurl);
}
}
return true;
}
public function isProtectModuleEnabled() {
return $this->isServiceActive("protect") && $this->isValidEnvironment();
}
public function isDynSyncModuleEnabled() {
if ($this->isServiceActive("dynsync")) {
$dynconfig = $this->config['dynsync'];
if (array_key_exists('dynplug', $dynconfig) && ($dynconfig['dynplug'] === $this->plugname)) {
return true;
}
}
return false;
}
public function isServiceActive($service) {
$bvconfig = $this->config;
if ($bvconfig && array_key_exists('services', $bvconfig)) {
return in_array($service, $bvconfig['services']) && $this->isActivePlugin();
}
return false;
}
public function isActivateRedirectSet() {
return ($this->settings->getOption($this->plug_redirect) === 'yes') ? true : false;
}
public function isMalcare() {
return $this->getBrandName() === 'MalCare';
}
public function isBlogvault() {
return $this->getBrandName() === 'BlogVault';
}
public function info() {
return array(
"bvversion" => $this->version,
"sha1" => "true",
"plugname" => $this->plugname
);
}
}
endif;
\ No newline at end of file
WordPress - Web publishing software
Copyright 2015 by the contributors
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
This program incorporates work covered by the following copyright and
permission notices:
b2 is (c) 2001, 2002 Michel Valdrighi - m@tidakada.com -
http://tidakada.com
Wherever third party code has been used, credit has been given in the code's
comments.
b2 is released under the GPL
and
WordPress - Web publishing software
Copyright 2003-2010 by the contributors
WordPress is released under the GPL
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
WRITTEN OFFER
The source code for any program binaries or compressed scripts that are
included with WordPress can be freely obtained at the following URL:
https://wordpress.org/download/source/
<?php
/*
Plugin Name: Pantheon Migration
Plugin URI: https://pantheon.io
Description: The easiest way to migrate your site to Pantheon
Author: Pantheon
Author URI: https://pantheon.io
Version: 5.25
Network: True
*/
/* Copyright 2017 Pantheon Migrate (email : support@blogvault.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* Global response array */
if (!defined('ABSPATH')) exit;
##OLDWPR##
require_once dirname( __FILE__ ) . '/wp_settings.php';
require_once dirname( __FILE__ ) . '/wp_site_info.php';
require_once dirname( __FILE__ ) . '/wp_db.php';
require_once dirname( __FILE__ ) . '/wp_api.php';
require_once dirname( __FILE__ ) . '/wp_actions.php';
require_once dirname( __FILE__ ) . '/info.php';
require_once dirname( __FILE__ ) . '/account.php';
require_once dirname( __FILE__ ) . '/helper.php';
##WPCACHEMODULE##
$bvsettings = new PTNWPSettings();
$bvsiteinfo = new PTNWPSiteInfo();
$bvdb = new PTNWPDb();
$bvapi = new PTNWPAPI($bvsettings);
$bvinfo = new PTNInfo($bvsettings);
$wp_action = new PTNWPAction($bvsettings, $bvsiteinfo, $bvapi);
register_uninstall_hook(__FILE__, array('PTNWPAction', 'uninstall'));
register_activation_hook(__FILE__, array($wp_action, 'activate'));
register_deactivation_hook(__FILE__, array($wp_action, 'deactivate'));
add_action('wp_footer', array($wp_action, 'footerHandler'), 100);
add_action('clear_bv_services_config', array($wp_action, 'clear_bv_services_config'));
##SOADDUNINSTALLACTION##
##DISABLE_OTHER_OPTIMIZATION_PLUGINS##
##WPCLIMODULE##
if (is_admin()) {
require_once dirname( __FILE__ ) . '/wp_admin.php';
$wpadmin = new PTNWPAdmin($bvsettings, $bvsiteinfo);
add_action('admin_init', array($wpadmin, 'initHandler'));
add_filter('all_plugins', array($wpadmin, 'initBranding'));
add_filter('plugin_row_meta', array($wpadmin, 'hidePluginDetails'), 10, 2);
##HEALTH_INFO_HOOK##
if ($bvsiteinfo->isMultisite()) {
add_action('network_admin_menu', array($wpadmin, 'menu'));
} else {
add_action('admin_menu', array($wpadmin, 'menu'));
}
add_filter('plugin_action_links', array($wpadmin, 'settingsLink'), 10, 2);
add_action('admin_head', array($wpadmin, 'removeAdminNotices'), 3);
##ACTIVATEWARNING##
add_action('admin_enqueue_scripts', array($wpadmin, 'ptnsecAdminMenu'));
##ALPURGECACHEFUNCTION##
##ALADMINMENU##
}
if ((array_key_exists('bvreqmerge', $_POST)) || (array_key_exists('bvreqmerge', $_GET))) {
$_REQUEST = array_merge($_GET, $_POST);
}
if ($bvinfo->hasValidDBVersion()) {
##ACTLOGMODULE##
}
if ((array_key_exists('bvplugname', $_REQUEST)) && ($_REQUEST['bvplugname'] == "pantheon")) {
require_once dirname( __FILE__ ) . '/callback/base.php';
require_once dirname( __FILE__ ) . '/callback/response.php';
require_once dirname( __FILE__ ) . '/callback/request.php';
require_once dirname( __FILE__ ) . '/recover.php';
$pubkey = PTNAccount::sanitizeKey($_REQUEST['pubkey']);
if (array_key_exists('rcvracc', $_REQUEST)) {
$account = PTNRecover::find($bvsettings, $pubkey);
} else {
$account = PTNAccount::find($bvsettings, $pubkey);
}
$request = new BVCallbackRequest($account, $_REQUEST, $bvsettings);
$response = new BVCallbackResponse($request->bvb64cksize);
if ($request->authenticate() === 1) {
##BVBASEPATH##
require_once dirname( __FILE__ ) . '/callback/handler.php';
$params = $request->processParams($_REQUEST);
if ($params === false) {
$response->terminate($request->corruptedParamsResp());
}
$request->params = $params;
$callback_handler = new BVCallbackHandler($bvdb, $bvsettings, $bvsiteinfo, $request, $account, $response);
if ($request->is_afterload) {
add_action('wp_loaded', array($callback_handler, 'execute'));
} else if ($request->is_admin_ajax) {
add_action('wp_ajax_bvadm', array($callback_handler, 'bvAdmExecuteWithUser'));
add_action('wp_ajax_nopriv_bvadm', array($callback_handler, 'bvAdmExecuteWithoutUser'));
} else {
$callback_handler->execute();
}
} else {
$response->terminate($request->authFailedResp());
}
} else {
if ($bvinfo->hasValidDBVersion()) {
##PROTECTMODULE##
##DYNSYNCMODULE##
}
##WPAUTOUPDATEBLOCKMODULE##
##HIDEPLUGINUPDATEMODULE##
}
\ No newline at end of file
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzBFU9onxE3A+NpctmsLi
ZvPgj9QV2aBKDKEsRDJw7O0vyI2bpU/aScYJVOkuqlAkyrbZglJA0H+mSf+alvWp
pDFO4pyal04uxwwzji9xZ7kCSiA1wrzZFxG4SwZXpwr4qc+XtrnkSakxkyi2V4RX
ey42pOvSbSASBs6zcPq28R6LSBDhLNHho2T2qXBf7vKeuE4DR1nNcBlsLnge0x/Q
YBey+64b/8cJGyxcceAMV3F5jKI2XkkbyXtE8v+N2K5HjStyMwS3dUa4aoHl8ph4
buoEXCu6WFyUF2oMqKmkVAaE8qZQA8Q9Qni7rNHRRjVss5Z+tFOxbDBBSfsYjmvE
lQIDAQAB
-----END PUBLIC KEY-----
=== Pantheon Migrations ===
Contributors: akshatc, blogvault, getpantheon
Tags: pantheon, migration
Requires at least: 4.0
Tested up to: 6.4
Requires PHP: 5.4.0
Stable tag: 5.25
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
The easiest way to migrate your site to Pantheon
== Description ==
Pantheon is a website management platform that is the best place to run your WordPress site — hands down. And migrating your WordPress site doesn’t get any easier than with Pantheon Migrations.
With this plugin forget the headaches of manually migrating your site. All you need to activate the plugin is administrative access to your WordPress site. Just copy and paste your SFTP credentials from your new Pantheon site to the Pantheon Migrations tab in your WordPress Dashboard and click “migrate”. You can get back to work on other projects, and our migrations team will email you when everything is complete.
For full instructions please see our [docs page](https://pantheon.io/docs/migrate-wordpress/) on Pantheon Migrations.
Shout out to [BlogVault.net](https://blogvault.net/) for the development and hand in creating this plugin. By using this plugin you are agreeing to their [Terms of Service](https://blogvault.net/tos)
== Installation ==
= There are two methods =
1. Upload `bv-pantheon-migration` to the `/wp-content/plugins/` directory
2. Activate the plugin through the 'Plugins' menu in WordPress
Once the plugin is activated, click on Pantheon Migration in the left side navigation
Enter the required information:
`Destination URL:` (this will be your pantheon address you are migrating to, example: http://dev-sitename.pantheon.io)
`Machine Token:` (Machine tokens are used to uniquely identify your machine and securely authenticate via Terminus)
Click the `Migrate` button and you will be redirected to the migration landing page. The plugin will automatically verify your Machine Token and let you know if there are any issues.
After the migration is complete there will be a button you can click to see the results of your migration and automatically redirected to your Pantheon site URL.
== Frequently Asked Questions ==
= 1) I do not have a Pantheon account, can I still use this plugin? =
No, but signing up for a Pantheon account is free and so is migrating your site with Pantheon Migrations. [Sign up here!](https://pantheon.io/register)
= 2) What information will the plugin ask for? =
You will have to provide the plugin your destination url and Machine Token from your Pantheon account. Please read the [Installation section](https://wordpress.org/plugins/bv-pantheon-migration/installation/) for more information on where to find this.
= 3) Why do you need my email? =
We require an email address to send you updates on the migration process, notify you of any errors that occur during the migration.
= 4) Is Multisite supported with this plugin =
Not yet, Pantheon is currently working on testing the support of Multisite on our platform but it's still too soon. We will update this section when it's available.
= 5) How long does it take to migrate a website? =
This can range anywhere from 30 minutes to several hours depending on the size of the website. On average, migrations to Pantheon take about 1 hour.
= 6) Can I migrate a site from WordPress.com? =
Currently you can only migrate a self hosted WordPress installation, the plugin does not support migrating from WordPress.com.
= 7) What happens if I run into an error after the migration is complete? =
We are always wanting to assist and help out in any way that we can. If you encounter any type of issue please use the support section of our plugin. [Click here](https://wordpress.org/support/plugin/bv-pantheon-migration/) to file an issue. `This section is monitored daily.`
= 8) Do I need to leave the window open while the migration is processing? =
No, that's the beauty of this plugin. It runs on a SAAS based technology and a secure web address that runs everything in the background. Once you start the migration you can close the window at any time and come back to it later while it's still running, no need to wait for hours. You will also receive an email once the migration has completed.
== Screenshots ==
1. Accessing your SFTP credentials within Pantheon
2. Adding information to the Pantheon Migrations plugin
== Changelog ==
= 5.25 =
* Bug fix get_admin_url
= 5.24 =
* SHA256 Support
* Stream Improvements
= 5.22 =
* Code Improvements
* Reduced Memory Footprint
= 5.16 =
* Bug Fixes
= 5.15 =
* Upgraded Authentication
= 5.05 =
* Code Improvements for PHP 8.2 compatibility
* Site Health BugFix
= 4.97 =
* Code Improvements
* Sync Improvements
* Code Cleanup
* Bug Fixes
= 4.78 =
* Better handling for plugin, theme infos
* Sync Improvements
= 4.69 =
* Improved network call efficiency for site info callbacks.
= 4.68 =
* Removing use of constants for arrays for PHP 5.4 support.
* Post type fetch improvement.
= 4.65 =
* Robust handling of requests params.
* Callback wing versioning.
= 4.62 =
* MultiTable Sync in single callback functionality added.
* Improved host info
* Fixed services data fetch bug
* Fixed account listing bug in wp-admin
= 4.58 =
* Better Handling of error message from Server on signup
= 4.35 =
* Improved scanfiles and filelist api
= 4.31 =
* Fetching Mysql Version
* Robust data fetch APIs
* Core plugin changes
* Sanitizing incoming params
= 3.4 =
* Plugin branding fixes
= 3.2 =
* Updating account authentication struture
= 3.1 =
* Adding params validation
* Adding support for custom user tables
= 2.1 =
* Restructuring classes
= 1.88 =
* Callback improvements
= 1.86 =
* Updating tested upto 5.1
= 1.84 =
* Disable form on submit
= 1.82 =
* Updating tested upto 5.0
= 1.77 =
* Adding function_exists for getmyuid and get_current_user functions
= 1.76 =
* Removing create_funtion for PHP 7.2 compatibility
= 1.72 =
* Adding Misc Callback
= 1.71 =
* Adding logout functionality in the plugin
= 1.69 =
* Adding support for chunked base64 encoding
= 1.68 =
* Updating upload rows
= 1.66 =
* Updating TOS and privacy policies
= 1.64 =
* Bug fixes for lp and fw
= 1.62 =
* SSL support in plugin for API calls
* Adding support for plugin branding
= 1.44 =
* Removed bv_manage_site
* Updated asym_key
= 1.41 =
* Better integrity checking
* Woo Commerce Dynamic sync support
= 1.40 =
* Manage sites straight from BlogVault dashboard
= 1.31 =
* Changing dynamic backups to be pull-based
= 1.30 =
* Using dbsig based authenticatation
= 1.22 =
* Adding support for GLOB based directory listings
* Adding support for Machine Tokens instead of SFTP details
= 1.21 =
* Adding support for PHP 5 style constructors
= 1.20 =
* Adding DB Signature and Server Signature to uniquely identify a site
* Adding the stats api to the WordPress Backup plugin.
* Sending tablename/rcount as part of the callback
= 1.17 =
* Add support for repair table so that the backup plugin itself can be used to repair tables without needing PHPMyAdmin access
* Making the plugin to be available network wide.
* Adding support for 401 Auth checks on the source or destination
= 1.16 =
* Improving the Base64 Decode functionality so that it is extensible for any parameter in the future and backups can be completed for any site
* Separating out callbacks gettablecreate and getrowscount to make the backups more modular
* The plugin will now automatically ping the server once a day. This will ensure that we know if we are not doing the backup of a site where the plugin is activated.
* Use SHA1 for authentication instead of MD5
= 1.15 =
* First release of Pantheon Plugin
<?php
if (!defined('ABSPATH')) exit;
if (!class_exists('PTNRecover')) :
class PTNRecover {
public static $default_secret_key = 'bvSecretKey';
public static function defaultSecret($settings) {
$secret = self::getDefaultSecret($settings);
if (empty($secret)) {
$secret = PTNAccount::randString(32);
self::updateDefaultSecret($settings, $secret);
}
return $secret;
}
public static function deleteDefaultSecret($settings) {
$settings->deleteOption(self::$default_secret_key);
}
public static function getDefaultSecret($settings) {
return $settings->getOption(self::$default_secret_key);
}
public static function updateDefaultSecret($settings, $secret) {
$settings->updateOption(self::$default_secret_key, $secret);
}
public static function validate($pubkey) {
if ($pubkey && strlen($pubkey) >= 32) {
return true;
} else {
return false;
}
}
public static function find($settings, $pubkey) {
if (!self::validate($pubkey)) {
return null;
}
$secret = self::getDefaultSecret($settings);
if (!empty($secret) && (strlen($secret) >= 32)) {
$account = new PTNAccount($settings, $pubkey, $secret);
}
return $account;
}
}
endif;
\ No newline at end of file
<?php
if (!defined('ABSPATH')) exit;
if (!class_exists('PTNWPAction')) :
class PTNWPAction {
public $settings;
public $siteinfo;
public $bvinfo;
public $bvapi;
public function __construct($settings, $siteinfo, $bvapi) {
$this->settings = $settings;
$this->siteinfo = $siteinfo;
$this->bvapi = $bvapi;
$this->bvinfo = new PTNInfo($settings);
}
public function activate() {
if (!isset($_REQUEST['blogvaultkey'])) {
##BVKEYSLOCATE##
}
if (PTNAccount::isConfigured($this->settings)) {
/* This informs the server about the activation */
$info = array();
$this->siteinfo->basic($info);
$this->bvapi->pingbv('/bvapi/activate', $info);
} else {
PTNAccount::setup($this->settings);
}
}
public function deactivate() {
$info = array();
$this->siteinfo->basic($info);
##DISABLECACHE##
$this->bvapi->pingbv('/bvapi/deactivate', $info);
}
public static function uninstall() {
##CLEARPTCONFIG##
##CLEARIPSTORE##
##CLEARDYNSYNCCONFIG##
##CLEARCACHECONFIG##
do_action('clear_bv_services_config');
}
public function clear_bv_services_config() {
$this->settings->deleteOption($this->bvinfo->services_option_name);
}
##SOUNINSTALLFUNCTION##
public function footerHandler() {
$bvfooter = $this->settings->getOption($this->bvinfo->badgeinfo);
if ($bvfooter) {
echo '<div style="max-width:150px;min-height:70px;margin:0 auto;text-align:center;position:relative;">
<a href='.esc_url($bvfooter['badgeurl']).' target="_blank" ><img src="'.esc_url(plugins_url($bvfooter['badgeimg'], __FILE__)).'" alt="'.esc_attr($bvfooter['badgealt']).'" /></a></div>';
}
}
}
endif;
\ No newline at end of file
<?php
if (!defined('ABSPATH')) exit;
if (!class_exists('PTNWPAdmin')) :
class PTNWPAdmin {
public $settings;
public $siteinfo;
public $bvinfo;
public $bvapi;
function __construct($settings, $siteinfo, $bvapi = null) {
$this->settings = $settings;
$this->siteinfo = $siteinfo;
$this->bvapi = $bvapi;
$this->bvinfo = new PTNInfo($this->settings);
}
public function mainUrl($_params = '') {
if (function_exists('network_admin_url')) {
return network_admin_url('admin.php?page='.$this->bvinfo->plugname.$_params);
} else {
return admin_url('admin.php?page='.$this->bvinfo->plugname.$_params);
}
}
function removeAdminNotices() {
if (array_key_exists('page', $_REQUEST) && $_REQUEST['page'] == $this->bvinfo->plugname) {
remove_all_actions('admin_notices');
remove_all_actions('all_admin_notices');
}
}
public function initHandler() {
if (!current_user_can('activate_plugins'))
return;
if ($this->bvinfo->isActivateRedirectSet()) {
$this->settings->updateOption($this->bvinfo->plug_redirect, 'no');
wp_redirect($this->mainUrl());
}
}
public function menu() {
$brand = $this->bvinfo->getBrandInfo();
if (!is_array($brand) || (!array_key_exists('hide', $brand) && !array_key_exists('hide_from_menu', $brand))) {
$bname = $this->bvinfo->getBrandName();
$icon = $this->bvinfo->getBrandIcon();
add_menu_page($bname, $bname, 'manage_options', $this->bvinfo->plugname,
array($this, 'adminPage'), plugins_url($icon, __FILE__ ));
}
}
public function hidePluginDetails($plugin_metas, $slug) {
$brand = $this->bvinfo->getBrandInfo();
$bvslug = $this->bvinfo->slug;
if ($slug === $bvslug && is_array($brand) && array_key_exists('hide_plugin_details', $brand)) {
foreach ($plugin_metas as $pluginKey => $pluginValue) {
if (strpos($pluginValue, sprintf('>%s<', translate('View details')))) {
unset($plugin_metas[$pluginKey]);
break;
}
}
}
return $plugin_metas;
}
public function settingsLink($links, $file) {
if ( $file == plugin_basename( dirname(__FILE__).'/pantheon.php' ) ) {
$links[] = '<a href="'.$this->mainUrl().'">'.__( 'Settings' ).'</a>';
}
return $links;
}
public function ptnsecAdminMenu($hook) {
if ($hook === 'toplevel_page_pantheon') {
wp_enqueue_style( 'ptnsurface', plugins_url( 'css/style.css', __FILE__));
wp_enqueue_style('ptnsurface');
}
}
public function getPluginLogo() {
$brand = $this->bvinfo->getBrandInfo();
if ($brand && array_key_exists('logo', $brand)) {
return $brand['logo'];
}
return $this->bvinfo->logo;
}
public function getWebPage() {
$brand = $this->bvinfo->getBrandInfo();
if ($brand && array_key_exists('webpage', $brand)) {
return $brand['webpage'];
}
return $this->bvinfo->webpage;
}
public function siteInfoTags() {
require_once dirname( __FILE__ ) . '/recover.php';
$secret = PTNRecover::defaultSecret($this->settings);
$public = PTNAccount::getApiPublicKey($this->settings);
$tags = "<input type='hidden' name='url' value='".esc_attr($this->siteinfo->wpurl())."'/>\n".
"<input type='hidden' name='homeurl' value='".esc_attr($this->siteinfo->homeurl())."'/>\n".
"<input type='hidden' name='siteurl' value='".esc_attr($this->siteinfo->siteurl())."'/>\n".
"<input type='hidden' name='dbsig' value='".esc_attr($this->siteinfo->dbsig(false))."'/>\n".
"<input type='hidden' name='plug' value='".esc_attr($this->bvinfo->plugname)."'/>\n".
"<input type='hidden' name='adminurl' value='".esc_attr($this->mainUrl())."'/>\n".
"<input type='hidden' name='bvversion' value='".esc_attr($this->bvinfo->version)."'/>\n".
"<input type='hidden' name='serverip' value='".esc_attr($_SERVER["SERVER_ADDR"])."'/>\n".
"<input type='hidden' name='abspath' value='".esc_attr(ABSPATH)."'/>\n".
"<input type='hidden' name='secret' value='".esc_attr($secret)."'/>\n".
"<input type='hidden' name='public' value='".esc_attr($public)."'/>\n";
return $tags;
}
public function activateWarning() {
global $hook_suffix;
if (!PTNAccount::isConfigured($this->settings) && $hook_suffix == 'index.php' ) {
?>
<div id="message" class="updated" style="padding: 8px; font-size: 16px; background-color: #dff0d8">
<a class="button-primary" href="<?php echo esc_url($this->mainUrl()); ?>">Activate Pantheon</a>
&nbsp;&nbsp;&nbsp;<b>Almost Done:</b> Activate your Pantheon account to migrate your site.
</div>
<?php
}
}
public function adminPage() {
require_once dirname( __FILE__ ) . '/admin/main_page.php';
}
public function initBranding($plugins) {
$slug = $this->bvinfo->slug;
if (!is_array($plugins) || !isset($slug, $plugins)) {
return $plugins;
}
$brand = $this->bvinfo->getBrandInfo();
if (is_array($brand)) {
if (array_key_exists('hide', $brand)) {
unset($plugins[$slug]);
} else {
if (array_key_exists('name', $brand)) {
$plugins[$slug]['Name'] = $brand['name'];
}
if (array_key_exists('title', $brand)) {
$plugins[$slug]['Title'] = $brand['title'];
}
if (array_key_exists('description', $brand)) {
$plugins[$slug]['Description'] = $brand['description'];
}
if (array_key_exists('authoruri', $brand)) {
$plugins[$slug]['AuthorURI'] = $brand['authoruri'];
}
if (array_key_exists('author', $brand)) {
$plugins[$slug]['Author'] = $brand['author'];
}
if (array_key_exists('authorname', $brand)) {
$plugins[$slug]['AuthorName'] = $brand['authorname'];
}
if (array_key_exists('pluginuri', $brand)) {
$plugins[$slug]['PluginURI'] = $brand['pluginuri'];
}
}
}
return $plugins;
}
}
endif;
\ No newline at end of file
<?php
if (!defined('ABSPATH')) exit;
if (!class_exists('PTNWPAPI')) :
class PTNWPAPI {
public $settings;
public function __construct($settings) {
$this->settings = $settings;
}
public function pingbv($method, $body, $public = false) {
if ($public) {
return $this->do_request($method, $body, $public);
} else {
$api_public_key = $this->settings->getOption('bvApiPublic');
if (!empty($api_public_key) && (strlen($api_public_key) >= 32)) {
return $this->do_request($method, $body, $api_public_key);
}
}
}
public function do_request($method, $body, $pubkey) {
$account = PTNAccount::find($this->settings, $pubkey);
if (isset($account)) {
$url = $account->authenticatedUrl($method);
return $this->http_request($url, $body);
}
}
public function http_request($url, $body, $headers = array()) {
$_body = array(
'method' => 'POST',
'timeout' => 15,
'body' => $body
);
if (!empty($headers)) {
$_body['headers'] = $headers;
}
return wp_remote_post($url, $_body);
}
}
endif;
\ No newline at end of file
<?php
if (!defined('ABSPATH')) exit;
if (!class_exists('PTNWPDb')) :
class PTNWPDb {
public function dbprefix() {
global $wpdb;
$prefix = $wpdb->base_prefix ? $wpdb->base_prefix : $wpdb->prefix;
return $prefix;
}
public function prepare($query, $args) {
global $wpdb;
return $wpdb->prepare($query, $args);
}
public function getSiteId() {
global $wpdb;
return $wpdb->siteid;
}
public function getResult($query, $obj = ARRAY_A) {
global $wpdb;
return $wpdb->get_results($query, $obj);
}
public function query($query) {
global $wpdb;
return $wpdb->query($query);
}
public function getVar($query, $col = 0, $row = 0) {
global $wpdb;
return $wpdb->get_var($query, $col, $row);
}
public function getCol($query, $col = 0) {
global $wpdb;
return $wpdb->get_col($query, $col);
}
public function tableName($table) {
return $table[0];
}
public function showTables() {
$tables = $this->getResult("SHOW TABLES", ARRAY_N);
return array_map(array($this, 'tableName'), $tables);
}
public function showTableStatus() {
return $this->getResult("SHOW TABLE STATUS");
}
public function tableKeys($table) {
return $this->getResult("SHOW KEYS FROM $table;");
}
public function showDbVariables($variable) {
$variables = $this->getResult("Show variables like '%$variable%' ;");
$result = array();
foreach ($variables as $variable) {
$result[$variable["Variable_name"]] = $variable["Value"];
}
return $result;
}
public function describeTable($table) {
return $this->getResult("DESCRIBE $table;");
}
public function showTableIndex($table) {
return $this->getResult("SHOW INDEX FROM $table");
}
public function checkTable($table, $type) {
return $this->getResult("CHECK TABLE $table $type;");
}
public function repairTable($table) {
return $this->getResult("REPAIR TABLE $table;");
}
public function showTableCreate($table) {
return $this->getVar("SHOW CREATE TABLE $table;", 1);
}
public function rowsCount($table) {
$count = $this->getVar("SELECT COUNT(*) FROM $table;");
return intval($count);
}
public function createTable($query, $name, $usedbdelta = false) {
$table = $this->getBVTable($name);
if (!$this->isTablePresent($table)) {
if ($usedbdelta) {
if (!function_exists('dbDelta'))
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta($query);
} else {
$this->query($query);
}
}
return $this->isTablePresent($table);
}
public function createTables($tables, $usedbdelta = false) {
$result = array();
foreach ($tables as $table => $query) {
$result[$table] = $this->createTable($query, $table, $usedbdelta);
}
return $result;
}
public function alterBVTable($query, $name) {
$resp = false;
$table = $this->getBVTable($name);
if ($this->isTablePresent($table)) {
$resp = $this->query($query);
}
return $resp;
}
public function alterTables($tables) {
$result = array();
foreach ($tables as $table => $query) {
$result[$table] = $this->alterBVTable($query, $table);
}
return $result;
}
public function getTableContent($table, $fields = '*', $filter = '', $limit = 0, $offset = 0) {
$query = "SELECT $fields from $table $filter";
if ($limit > 0)
$query .= " LIMIT $limit";
if ($offset > 0)
$query .= " OFFSET $offset";
$rows = $this->getResult($query);
return $rows;
}
public function isTablePresent($table) {
return ($this->getVar("SHOW TABLES LIKE '$table'") === $table);
}
public function getCharsetCollate() {
global $wpdb;
return $wpdb->get_charset_collate();
}
public function getWPTable($name) {
return ($this->dbprefix() . $name);
}
public function getBVTable($name) {
return ($this->getWPTable("bv_" . $name));
}
public function truncateBVTable($name) {
$table = $this->getBVTable($name);
if ($this->isTablePresent($table)) {
return $this->query("TRUNCATE TABLE $table;");
} else {
return false;
}
}
public function deleteBVTableContent($name, $filter = "") {
$table = $this->getBVTable($name);
if ($this->isTablePresent($table)) {
return $this->query("DELETE FROM $table $filter;");
} else {
return false;
}
}
public function dropBVTable($name) {
$table = $this->getBVTable($name);
if ($this->isTablePresent($table)) {
$this->query("DROP TABLE IF EXISTS $table;");
}
return !$this->isTablePresent($table);
}
public function dropTables($tables) {
$result = array();
foreach ($tables as $table) {
$result[$table] = $this->dropBVTable($table);
}
return $result;
}
public function truncateTables($tables) {
$result = array();
foreach ($tables as $table) {
$result[$table] = $this->truncateBVTable($table);
}
return $result;
}
public function deleteRowsFromtable($name, $count = 1) {
$table = $this->getBVTable($name);
if ($this->isTablePresent($table)) {
return $this->getResult("DELETE FROM $table LIMIT $count;");
} else {
return false;
}
}
public function replaceIntoBVTable($name, $value) {
global $wpdb;
$table = $this->getBVTable($name);
return $wpdb->replace($table, $value);
}
public function tinfo($name) {
$result = array();
$table = $this->getBVTable($name);
$result['name'] = $table;
if ($this->isTablePresent($table)) {
$result['exists'] = true;
$result['createquery'] = $this->showTableCreate($table);
}
return $result;
}
public function getMysqlVersion() {
return $this->showDbVariables('version')['version'];
}
}
endif;
\ No newline at end of file
<?php
if (!defined('ABSPATH')) exit;
if (!class_exists('PTNWPSettings')) :
class PTNWPSettings {
public function getOption($key) {
$res = false;
if (function_exists('get_site_option')) {
$res = get_site_option($key, false);
}
if ($res === false) {
$res = get_option($key, false);
}
return $res;
}
public function deleteOption($key) {
if (function_exists('delete_site_option')) {
return delete_site_option($key);
} else {
return delete_option($key);
}
}
public function updateOption($key, $value) {
if (function_exists('update_site_option')) {
return update_site_option($key, $value);
} else {
return update_option($key, $value);
}
}
public function getOptions($options = array()) {
$result = array();
foreach ($options as $option)
$result[$option] = $this->getOption($option);
return $result;
}
public function updateOptions($args) {
$result = array();
foreach ($args as $option => $value) {
$this->updateOption($option, $value);
$result[$option] = $this->getOption($option);
}
return $result;
}
public function deleteOptions($options) {
$result = array();
foreach ($options as $option) {
$this->deleteOption($option);
$result[$option] = !$this->getOption($option);
}
return $result;
}
public function setTransient($name, $value, $time) {
if (function_exists('set_site_transient')) {
return set_site_transient($name, $value, $time);
}
return false;
}
public function deleteTransient($name) {
if (function_exists('delete_site_transient')) {
return delete_site_transient($name);
}
return false;
}
public function getTransient($name) {
if (function_exists('get_site_transient')) {
return get_site_transient($name);
}
return false;
}
}
endif;
\ No newline at end of file
<?php
if (!defined('ABSPATH')) exit;
if (!class_exists('PTNWPSiteInfo')) :
class PTNWPSiteInfo {
public function wpurl() {
if (function_exists('network_site_url'))
return network_site_url();
else
return get_bloginfo('wpurl');
}
public function siteurl($path = '', $scheme = null) {
if (function_exists('site_url')) {
return site_url($path, $scheme);
} else {
return get_bloginfo('wpurl');
}
}
public function homeurl() {
if (function_exists('home_url')) {
return home_url();
} else {
return get_bloginfo('url');
}
}
public function isMultisite() {
if (function_exists('is_multisite') && is_multisite())
return true;
return false;
}
public function isMainSite() {
if (!function_exists('is_main_site' ) || !$this->isMultisite())
return true;
return is_main_site();
}
public function getMainSiteId() {
if (!function_exists('get_main_site_id'))
return 0;
return get_main_site_id();
}
public function info() {
$info = array();
$this->basic($info);
$info['dbsig'] = $this->dbsig(false);
$info["serversig"] = $this->serversig(false);
return $info;
}
public function basic(&$info) {
$info['wpurl'] = $this->wpurl();
$info['siteurl'] = $this->siteurl();
$info['homeurl'] = $this->homeurl();
if (array_key_exists('SERVER_ADDR', $_SERVER)) {
$info['serverip'] = $_SERVER['SERVER_ADDR'];
}
$info['abspath'] = ABSPATH;
}
public function serversig($full = false) {
$sig_param = ABSPATH;
if (array_key_exists('SERVER_ADDR', $_SERVER)) {
$sig_param = $_SERVER['SERVER_ADDR'].ABSPATH;
}
$sig = sha1($sig_param);
if ($full)
return $sig;
else
return substr($sig, 0, 6);
}
public function dbsig($full = false) {
if (defined('DB_USER') && defined('DB_NAME') &&
defined('DB_PASSWORD') && defined('DB_HOST')) {
$sig = sha1(DB_USER.DB_NAME.DB_PASSWORD.DB_HOST);
} else {
$sig = "bvnone".PTNAccount::randString(34);
}
if ($full)
return $sig;
else
return substr($sig, 0, 6);
}
public static function isCWServer() {
return isset($_SERVER['cw_allowed_ip']);
}
}
endif;
\ No newline at end of file