コード例 #1
0
/**
 * callback function for inline note edits
 */
function rolo_edit_note_callback()
{
    $new_value = $_POST['new_value'];
    $note_id = $_POST['note_id'];
    $note_id = substr($note_id, strripos($note_id, "-") + 1);
    $current_comment = get_comment($note_id, ARRAY_A);
    $current_comment['comment_content'] = $new_value;
    wp_update_comment($current_comment);
    $results = array('is_error' => false, 'error_text' => '', 'html' => $new_value);
    include_once ABSPATH . 'wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php';
    $json = new Moxiecode_JSON();
    $results = $json->encode($results);
    die($results);
}
コード例 #2
0
ファイル: Error.php プロジェクト: kifah4itTeam/phpapps
/**
 * Calls the MCError class, returns true.
 *
 * @param Int $errno Number of the error.
 * @param String $errstr Error message.
 * @param String $errfile The file the error occured in.
 * @param String $errline The line in the file where error occured.
 * @param Array $errcontext Error context array, contains all variables.
 * @return Bool Just return true for now.
 */
function StreamErrorHandler($errno, $errstr, $errfile, $errline, $errcontext)
{
    global $MCErrorHandler;
    // Ignore these
    if ($errno == E_STRICT) {
        return true;
    }
    // Just pass it through	to the class.
    $data = $MCErrorHandler->handleError($errno, $errstr, $errfile, $errline, $errcontext);
    if ($data['break']) {
        if ($_SERVER["REQUEST_METHOD"] == "GET") {
            header("HTTP/1.1 500 Internal server error");
            die($errstr);
        } else {
            unset($data['break']);
            unset($data['title']);
            $data['level'] = "FATAL";
            $json = new Moxiecode_JSON();
            $result = new stdClass();
            $result->result = null;
            $result->id = 'err';
            $result->error = $data;
            echo '<html><body><script type="text/javascript">parent.handleJSON(' . $json->encode($result) . ');</script></body></html>';
            die;
        }
    }
}
コード例 #3
0
        // Check command, do command, stream file.
        $man->dispatchEvent("onStream", array($cmd, &$args));
        // Dispatch event after stream
        $man->dispatchEvent("onAfterStream", array($cmd, &$args));
    } else {
        if ($_SERVER["REQUEST_METHOD"] == "POST") {
            $args = array_merge($_POST, $_GET);
            $json = new Moxiecode_JSON();
            // Dispatch event before starting to stream
            $man->dispatchEvent("onBeforeUpload", array($cmd, &$args));
            // Check command, do command, stream file.
            $result = $man->executeEvent("onUpload", array($cmd, &$args));
            $data = $result->toArray();
            if (isset($args["chunk"])) {
                // Output JSON response to multiuploader
                die('{method:\'' . $method . '\',result:' . $json->encode($data) . ',error:null,id:\'m0\'}');
            } else {
                // Output JSON function
                echo '<html><body><script type="text/javascript">';
                if (isset($args["domain"]) && $args["domain"]) {
                    echo 'document.domain="' . $args["domain"] . '";';
                }
                echo 'parent.handleJSON({method:\'' . $method . '\',result:' . $json->encode($data) . ',error:null,id:\'m0\'});</script></body></html>';
            }
            // Dispatch event after stream
            $man->dispatchEvent("onAfterUpload", array($cmd, &$args));
        }
    }
} else {
    if (isset($_GET["format"]) && $_GET["format"] == "flash") {
        header("HTTP/1.1 405 Method Not Allowed");
コード例 #4
0
 function return_json($results)
 {
     // Check for callback
     if (isset($_GET['callback'])) {
         // Add the relevant header
         header('Content-type: text/javascript');
         echo addslashes($_GET['callback']) . " (";
     } else {
         if (isset($_GET['pretty'])) {
             // Will output pretty version
             header('Content-type: text/html');
         } else {
             //header('Content-type: application/json');
             //header('Content-type: text/javascript');
         }
     }
     if (function_exists('json_encode')) {
         echo json_encode($results);
     } else {
         // PHP4 version
         require_once ABSPATH . "wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php";
         $json_obj = new Moxiecode_JSON();
         echo $json_obj->encode($results);
     }
     if (isset($_GET['callback'])) {
         echo ")";
     }
 }
コード例 #5
0
 /**
  * Backwards compatible json_encode.
  *
  * @param mixed $data
  * @return string
  */
 function json_encode($data)
 {
     if (function_exists('json_encode')) {
         return json_encode($data);
     }
     if (class_exists('Services_JSON')) {
         $json = new Services_JSON();
         return $json->encodeUnsafe($data);
     } elseif (class_exists('Moxiecode_JSON')) {
         $json = new Moxiecode_JSON();
         return $json->encode($data);
     } else {
         trigger_error('No JSON parser available', E_USER_ERROR);
         return '';
     }
 }
コード例 #6
0
ファイル: upload.php プロジェクト: TNTCccc/jqswfupload
<?php

include 'JSON.php';
header('Content-type: application/json');
$files = $_FILES['Filedata'];
$json_obj = new Moxiecode_JSON();
/* encode */
$json = $json_obj->encode($files);
echo $json;
コード例 #7
0
 /**
  * Encode JSON objects
  *
  * A wrapper for JSON encode methods. Pass in the PHP array and get a string
  * in return that is formatted as JSON.
  *
  * @param $obj - the array to be encoded
  *
  * @return string that is formatted as JSON
  */
 public function json_encode($obj)
 {
     // Try to use native PHP 5.2+ json_encode
     // Switch back to JSON library included with Tiny MCE
     if (function_exists('json_encode')) {
         return json_encode($obj);
     } else {
         require_once ABSPATH . "/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php";
         $json_obj = new Moxiecode_JSON();
         $json = $json_obj->encode($obj);
         return $json;
     }
 }
コード例 #8
0
ファイル: autoblogadmin.php プロジェクト: hscale/webento
 function return_json($results)
 {
     if (isset($_GET['callback'])) {
         echo addslashes($_GET['callback']) . " (";
     }
     if (function_exists('json_encode')) {
         echo json_encode($results);
     } else {
         // PHP4 version
         require_once ABSPATH . "wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php";
         $json_obj = new Moxiecode_JSON();
         echo $json_obj->encode($results);
     }
     if (isset($_GET['callback'])) {
         echo ")";
     }
 }
コード例 #9
0
/**
 * helper function for callback function
 * @param <type> $new_value 
 * @since 0.1
 */
function _rolo_edit_callback_success($new_value)
{
    $results = array('is_error' => false, 'error_text' => '', 'html' => $new_value);
    include_once ABSPATH . 'wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php';
    $json = new Moxiecode_JSON();
    $results = $json->encode($results);
    die($results);
}
コード例 #10
0
ファイル: deprecated.php プロジェクト: Ingenex/redesign
 function json_encode($str)
 {
     $json = new Moxiecode_JSON();
     return $json->encode($str);
 }
コード例 #11
0
ファイル: rpc.php プロジェクト: manis6062/sagarmathaonline
$type = $chunks[0];
$input['method'] = $chunks[1];
// Clean up type, only a-z stuff.
$type = preg_replace("/[^a-z]/i", "", $type);
if ($type == "") {
    die('{"result":null,"id":null,"error":{"errstr":"No type set.","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}');
}
// Include Base and Core and Config.
$man = new Moxiecode_ManagerEngine($type);
require_once $basepath . "CorePlugin.php";
require_once "../config.php";
$man->dispatchEvent("onPreInit", array($type));
$config =& $man->getConfig();
// Include all plugins
$pluginPaths = $man->getPluginPaths();
foreach ($pluginPaths as $path) {
    require_once "../" . $path;
}
// Dispatch onInit event
if ($man->isAuthenticated()) {
    $man->dispatchEvent("onBeforeRPC", array($input['method'], $input['params'][0]));
    $result = new stdClass();
    $result->result = $man->executeEvent("onRPC", array($input['method'], $input['params'][0]));
    $result->id = $input['id'];
    $result->error = null;
    $data = $json->encode($result);
    //header('Content-Length: ' . strlen($data));
    die($data);
} else {
    die('{"result":{"login_url":"' . addslashes($config["authenticator.login_page"]) . '"},"id":null,"error":{"errstr":"Access denied by authenicator.","errfile":"","errline":null,"errcontext":"","level":"AUTH"}}');
}
コード例 #12
0
ファイル: stream.php プロジェクト: oaki/demoshop
                            header("HTTP/1.1 409 Conflict");
                            die('status=' . $row["status"]);
                            break;
                        case "RW_ERROR":
                            header("HTTP/1.1 412 Precondition Failed");
                            die('status=' . $row["status"]);
                            break;
                        case "SIZE_ERROR":
                            header("HTTP/1.1 414 Request-URI Too Long");
                            die('status=' . $row["status"]);
                            break;
                        default:
                            header("HTTP/1.1 501 Not Implemented");
                            die('status=' . $row["status"]);
                    }
                }
            } else {
                // Output JSON function
                $data = $result->toArray();
                echo '<html><body><script type="text/javascript">parent.handleJSON({method:\'' . $method . '\',result:' . $json->encode($data) . ',error:null,id:\'m0\'});</script></body></html>';
            }
            // Dispatch event after stream
            $man->dispatchEvent("onAfterUpload", array($cmd, &$args));
        }
    }
} else {
    if (isset($_GET["format"]) && $_GET["format"] == "flash") {
        header("HTTP/1.1 405 Method Not Allowed");
    }
    die('{"result":{login_url:"' . addslashes($config["authenticator.login_page"]) . '"},"id":null,"error":{"errstr":"Access denied by authenicator.","errfile":"","errline":null,"errcontext":"","level":"AUTH"}}');
}
コード例 #13
0
ファイル: common.php プロジェクト: rajankz/webspace
/**
 * Creates a JSON string from an array
 * @param array $array
 */
function FA_lite_json($array)
{
    if (function_exists('json_encode')) {
        return json_encode($array);
    } else {
        if (file_exists(ABSPATH . '/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php')) {
            require_once ABSPATH . '/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php';
            $json_obj = new Moxiecode_JSON();
            return $json_obj->encode($array);
        }
    }
}
コード例 #14
0
function modulo_venda_obter_info()
{
    $envio = $_POST['envio'];
    $pagamento = $_POST['pagamento'];
    $modulo = array('opcoes-de-envio' => array('PAC' => array('titulo' => 'Encomenda Normal', 'conteudo' => 'o PAC é mais barato que o sedex.<br /> Prazo de entrega: 6 dias úteis. Envio totalmente rastreado.', 'link' => 'http://www.correios.com.br/encomendas/servicos/Pac/default.cfm'), 'Sedex' => array('titulo' => 'Sedex', 'conteudo' => 'Com o Sedex, o tempo médio de entrega é de 48 horas e a encomenda é totalmente rastreável', 'link' => 'http://www.correios.com.br/encomendas/servicos/Sedex/sedex.cfm'), 'Grátis' => array('titulo' => 'Grátis', 'conteudo' => 'O frete está incluído no preço do guia. <br />Prazo de entrega: 6 dias úteis. Envio totalmente rastreado.')), 'opcoes-de-pagamento' => array('Cartão de crédito ou boleto bancário (via pagseguro)' => array('titulo' => 'Pagseguro', 'conteudo' => 'O Pagseguro é um serviço prático e seguro de efetuar pagamentos online. Não é necessário se cadastrar, não tem custo adicional para o comprador e possui as maiorias de formas de pagamento disponíveis no mercado, além de ter o cálculo de frete próprio.', 'link' => 'https://pagseguro.uol.com.br/para_voce/como_funciona.jhtml'), 'Transferência bancária' => array('titulo' => 'Transferência bancária', 'conteudo' => 'Através do Blog você poderá efetuar a compra e o vendedor entrará em contato fornecendo o número da conta. Após o pagamento ser efetuado, a mercadoria é enviada no modo de entrega escolhido. O valor do frete é enviado pelo vendedor')));
    $json_obj = new Moxiecode_JSON();
    /* encode */
    $json = $json_obj->encode($modulo[$pagamento][$envio]);
    echo $json;
    die;
}
コード例 #15
0
ファイル: rpc.php プロジェクト: esyacelga/sisadmaca
    if ($socket) {
        // Send request headers
        fputs($socket, $req);
        // Read response headers and data
        $resp = "";
        while (!feof($socket)) {
            $resp .= fgets($socket, 4096);
        }
        fclose($socket);
        // Split response header/data
        $resp = explode("\r\n\r\n", $resp);
        echo $resp[1];
        // Output body
    }
    die;
}
// Get JSON data
$json = new Moxiecode_JSON();
$input = $json->decode($raw);
// Execute RPC
if (isset($config['general.engine'])) {
    $spellchecker = new $config['general.engine']($config);
    $result = call_user_func_array(array($spellchecker, $input['method']), $input['params']);
} else {
    die('{"result":null,"id":null,"error":{"errstr":"You must choose an spellchecker engine in the config.php file.","errfile":"","errline":null,"errcontext":"","level":"FATAL"}}');
}
// Request and response id should always be the same
$output = array("id" => $input->id, "result" => $result, "error" => null);
// Return JSON encoded string
echo $json->encode($output);
コード例 #16
0
 function update_json_file($theme, $context = '', $secondary_content = '')
 {
     $theme = sanitize_file_name(sanitize_title($theme));
     // create micro theme of 'new' has been requested
     if ($context == 'new') {
         // Check for micro theme with same name now so that config.json is created in the right dir
         $name = $theme;
         if (is_dir($this->micro_root_dir . $name)) {
             $suffix = 1;
             do {
                 $alt_name = substr($name, 0, 200 - (strlen($suffix) + 1)) . "-{$suffix}";
                 $dir_check = is_dir($this->micro_root_dir . $alt_name);
                 $suffix++;
             } while ($dir_check);
             $name = $alt_name;
         }
         $theme = $name;
         $this->create_micro_theme($theme, 'export', '');
     }
     // Create new file if it doesn't already exist
     $json_file = $this->micro_root_dir . $theme . '/config.json';
     if (!file_exists($json_file)) {
         if (!($write_file = fopen($json_file, 'w'))) {
             // this creates a blank file for writing
             $this->log(wp_kses(__('Create json error', 'tvr-microthemer'), array()), '<p>' . wp_kses(__('WordPress does not have permission to create: ', 'tvr-microthemer'), array()) . $this->root_rel($json_file) . '. ' . $this->permissionshelp . '</p>');
         }
         $task = 'created';
     } else {
         $task = 'updated';
     }
     // check if it's writable (can skip this bit if a new blank micro theme has been created from the Manage page)
     if ($context != 'create-blank') {
         if (is_writable($json_file)) {
             // tap into WordPress native JSON functions
             if (!class_exists('Moxiecode_JSON')) {
                 require_once $this->thisplugindir . 'includes/class-json.php';
             }
             $json_object = new Moxiecode_JSON();
             // Always a selective export now
             // copy full options to var for editing
             $json_data = $this->options;
             // loop through full options
             foreach ($this->options as $section_name => $array) {
                 // if the section wasn't selected, remove it from json data var (along with the view_state var)
                 if (!array_key_exists($section_name, $this->serialised_post['export_sections']) and $section_name != 'non_section') {
                     unset($json_data[$section_name]);
                     unset($json_data['non_section']['view_state'][$section_name]);
                 }
             }
             // set handcoded css to nothing if not marked for export
             if (empty($this->serialised_post['export_sections']['hand_coded_css'])) {
                 $json_data['non_section']['hand_coded_css'] = '';
                 echo wp_kses(_x('unset: hand-coded', 'Verb', 'tvr-microthemer'), array()) . '<br />';
             } else {
                 echo '<b>don\'t</b> unset: hand-coded<br />';
             }
             // ie too
             foreach ($this->preferences['ie_css'] as $key => $value) {
                 if (empty($this->serialised_post['export_sections']['ie_css'][$key])) {
                     $json_data['non_section']['ie_css'][$key] = '';
                     echo wp_kses(_x('unset: ', 'Verb', 'tvr-microthemer'), array()) . $key . '<br />';
                 } else {
                     echo wp_kses(__('<b>don\'t</b> unset: ', 'tvr-microthemer'), array('b' => array())) . $key . '<br />';
                 }
             }
             // create debug selective export file if specified at top of script
             if ($this->debug_selective_export) {
                 $data = '';
                 $debug_file = $this->micro_root_dir . $this->preferences['theme_in_focus'] . '/debug-selective-export.txt';
                 $write_file = fopen($debug_file, 'w');
                 $data .= __('The Selectively Exported Options', 'tvr-microthemer') . "\n\n";
                 $data .= print_r($json_data, true);
                 $data .= "\n\n" . __('The Full Options', 'tvr-microthemer') . "\n\n";
                 $data .= print_r($this->options, true);
                 fwrite($write_file, $data);
                 fclose($write_file);
             }
             // write data to json file
             if ($data = $json_object->encode($json_data)) {
                 // the file will be created if it doesn't exist. otherwise it is overwritten.
                 $write_file = fopen($json_file, 'w');
                 fwrite($write_file, $data);
                 fclose($write_file);
             } else {
                 $this->log(wp_kses(__('Encode json error', 'tvr-microthemer'), array()), '<p>' . wp_kses(__('WordPress failed to convert your settings into json.', 'tvr-microthemer'), array()) . '</p>');
             }
         } else {
             $this->log(wp_kses(__('Write json error', 'tvr-microthemer'), array()), '<p>' . wp_kses(__('WordPress does not have "write" permission	for: ', 'tvr-microthemer'), array()) . $this->root_rel($json_file) . '. ' . $this->permissionshelp . '</p>');
         }
     }
     return $theme;
     // sanitised theme name
 }
コード例 #17
0
ファイル: compat.php プロジェクト: idreamsoft/iCMS5.0
 function json_encode($input)
 {
     $json = new Moxiecode_JSON();
     return $json->encode($input);
 }
コード例 #18
0
 private static function _encode_json($results)
 {
     if (function_exists('json_encode')) {
         return json_encode($results);
     } else {
         // PHP4 version
         require_once ABSPATH . "wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php";
         $json_obj = new Moxiecode_JSON();
         return $json_obj->encode($results);
     }
 }