function planche_wp_tunneling()
{
    $domains = trim(get_option('planche-cors'));
    $domains = preg_replace("/[\r\n]+/", ", ", $domains);
    if ($domains) {
        header('Access-Control-Allow-Origin: ' . $domains);
    }
    header('Access-Control-Allow-Credentials: true');
    require_once 'includes/Planche.php';
    require_once 'includes/PlancheWPDB.php';
    $Planche = new Planche();
    if (!is_admin()) {
        $Planche->error('Please. signin wordpress by admin account');
        exit;
    }
    if (isset($_REQUEST['callback']) === true) {
        $Planche->setCallback($_REQUEST['callback']);
    }
    $cmd = json_decode(base64_decode($_REQUEST['cmd']), true);
    extract($cmd);
    if (isset($_REQUEST['cmd']) === false) {
        $Planche->error('Invalid request');
        exit;
    }
    if (@$db) {
        $Planche->conn->select($db);
    }
    if ($type === 'export') {
        if (is_array($query) == true) {
            $Planche->export($query[0], $csv);
        } else {
            $Planche->export($query, $csv);
        }
    } elseif ($type === 'bookmark') {
        $Planche->bookmark($sql);
    } elseif ($type === 'loadBookmark') {
        $Planche->loadBookmark();
    } else {
        if ($type == 'copy') {
            $Planche->query('SET foreign_key_checks = 0');
        }
        $Planche->execute($query);
    }
    exit;
}
Esempio n. 2
0
<?php

$dirname = dirname(dirname(dirname(dirname(dirname(__FILE__)))));
/** Sets up the WordPress Environment. */
require $dirname . '/wp-load.php';
$domains = trim(get_option('planche-cors'));
$domains = preg_replace("/[\r\n]+/", ", ", $domains);
if ($domains) {
    header('Access-Control-Allow-Origin: ' . $domains);
}
header('Access-Control-Allow-Credentials: true');
require_once '../includes/Planche.php';
require_once '../includes/PlancheWPDB.php';
$Planche = new Planche();
if (isset($_REQUEST['callback']) === true) {
    $Planche->setCallback($_REQUEST['callback']);
}
if (!is_user_logged_in()) {
    $Planche->error('Please, login admin');
    exit;
}
if (isset($_REQUEST['cmd']) === false) {
    $Planche->error('Invalid request');
    exit;
}
$cmd = json_decode(base64_decode($_REQUEST['cmd']));
if (!$cmd->db) {
    $db = DB_NAME;
} else {
    $db = $cmd->db;
}