<?php
function msg_error($state, $msg) {
if(!empty($_REQUEST['callback'])) {
$callback = $_REQUEST['callback'];
$callback = preg_replace(array('/</', '/>/', '/"/', '/\'/', '/\+/', '/\\\\/', '/\//'), array('<', '>', '', '', '', '', ''), $callback);
}
$a = array(
'state' => $state,
'msg' => $msg,
);
$ret = json_encode($a);
if(!empty($callback)) $ret = sprintf("%s(%s)", $callback, $ret);
header("Content-type: application/json");
echo $ret;
exit;
}