Exemple #1
0
    $results = $wpdb->get_results("SELECT id FROM `{$table_name}`");
    $ids = array();
    foreach ($results as $result) {
        $ids[] = $result->id;
    }
    //update_option('gcb_update_prompt_v2',1);
} else {
    $ids = explode(";", $_GET["gcb"]);
}
$final_text = array();
foreach ($ids as $id) {
    if (intval($id) > 0) {
        if ($_GET["gcb"] == 'all') {
            $entry = $wpdb->get_row("SELECT * FROM `{$table_name}` WHERE id=" . $id, ARRAY_A);
        } else {
            $entry = gcb::get_entry_by_id(intval($id));
        }
        $final_text[] = base64_encode($entry['name']) . "<;>" . base64_encode($entry['description']) . "<;>" . base64_encode($entry['value']) . "<;>" . base64_encode($entry['type']) . "<;>" . base64_encode($entry['custom_id']);
    }
}
$final = implode("\r\n", $final_text);
header("Content-Type: text/plain");
header("Content-disposition: attachment; filename=" . ($backup ? "backup" : "export") . "_gcb_" . date("d_m_y_H_i") . ".gcb;");
header("Content-Length: " . strlen($final));
header('Content-Transfer-Encoding: Binary');
header('Accept-Ranges: bytes');
header('ETag: "' . md5($final) . '"');
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
echo $final;
die;
function gcb($id, $attributes = array())
{
    //determine condition, since we can fetch blocks by 2 types of ids
    if (is_numeric($id)) {
        $entry = gcb::get_entry_by_id(intval($id));
    } else {
        $entry = gcb::get_entry_by_custom_id($id);
    }
    if (is_array($entry)) {
        $content = htmlspecialchars_decode(stripslashes($entry['value']));
        //process the attributes
        if (is_array($attributes) && count($attributes)) {
            foreach ($attributes as $attribute_key => $attribute_value) {
                $content = str_replace("%%" . $attribute_key . "%%", $attribute_value, $content);
            }
        }
        if ($entry['type'] == "php") {
            //execute the php code
            ob_start();
            $result = eval(" " . $content);
            $output = ob_get_contents();
            ob_end_clean();
            return apply_filters('gcb_block_output', do_shortcode($output . $result));
            //run the shortcodes as well
        } elseif ($entry['type'] == "html") {
            // alloyphoto: enable PHP code in < ?php ... ? > tags inside blocks
            ob_start();
            eval("?>{$content}<?php ");
            $output = ob_get_contents();
            ob_end_clean();
            return apply_filters('gcb_block_output', do_shortcode($output));
            //run the shortcodes as well
        } else {
            return apply_filters('gcb_block_output', do_shortcode($content));
            //make sure we also run the shortcodes in here
        }
    } else {
        return "";
    }
}