function del($params) { $json = new Services_JSON(); $subcategory = DB_DataObject::factory("subcategory"); $subcategory->id = $params["id"]; print $subcategory->delete() ? $json->encode(array("error" => false)) : $json->encode(array("error" => true)); }
public function send() { // if( ob_get_length() !== false ) // { // while (@ ob_end_clean()); // if( function_exists( 'ob_clean' ) ) // { // @ob_clean(); // } // } header('Content-type: text/x-json; UTF-8'); require_once( KOMENTO_CLASSES . DIRECTORY_SEPARATOR . 'json.php' ); $json = new Services_JSON(); $callback = JRequest::getVar('callback'); if (isset($callback)) { echo $callback . '(' . $json->encode( $this->commands ) . ');'; } else { echo $json->encode( $this->commands ); } exit; }
public function run() { require_once _lms_ . '/lib/lib.kbres.php'; $kbres = new KbRes(); $data = false; if ($this->res_id > 0) { $data = $kbres->getResource($this->res_id, true, true); } else { if (!empty($this->r_item_id) && !empty($this->r_type)) { $data = $kbres->getResourceFromItem($this->r_item_id, $this->r_type, $this->r_env, true, true); } } if ($data == false) { $data = array('res_id' => 0, 'r_name' => '', 'original_name' => '', 'r_desc' => '', 'r_item_id' => $this->r_item_id, 'r_type' => $this->r_type, 'r_env' => $this->r_env, 'r_env_parent_id' => $this->r_env_parent_id, 'r_param' => $this->r_param, 'r_alt_desc' => '', 'r_lang' => !empty($this->language) ? $this->language : getLanguage(), 'force_visible' => 0, 'is_mobile' => 0, 'folders' => array(), 'tags' => array()); } if (!empty($this->original_name)) { $data['original_name'] = $this->original_name; } $c_folders = array_keys($data['folders']); unset($data['folders']); $c_tags = $data['tags']; unset($data['tags']); $json = new Services_JSON(); $this->render('kbcategorize', array('selected_node' => $this->_getSelectedNode(), 'back_url' => $this->back_url, 'form_url' => $this->form_url, 'form_extra_hidden' => $this->form_extra_hidden, 'data' => $data, 'c_folders' => $c_folders, 'c_tags_json' => $json->encode(array_values($c_tags)), 'all_tags_json' => $json->encode(array_values($kbres->getAllTags())))); }
function getUserData($id) { $user = new AMP_User_Profile(AMP_registry::getDbcon(), $id); if ($user) { $data = array(); $data['Email'] = $user->getData('Email'); $data['First_Name'] = $user->getData('First_Name'); $data['Last_Name'] = $user->getData('Last_Name'); $data['Phone'] = $user->getData('Phone'); $data['Company'] = $user->getData('Company'); $data['City'] = $user->getData('City'); $data['Country'] = $user->getData('Country'); $data['custom1'] = $user->getData('custom1'); $data['custom3'] = $user->getData('custom3'); $data['custom4'] = $user->getData('custom4'); $message = array(); $message['type'] = 'good'; $message['text'] = 'Success'; $json = new Services_JSON(); $json_data = array('data' => $data, 'message' => $message, 'success' => true); $output = $json->encode($json_data); return $output; } else { $message = array(); $message['type'] = 'bad'; $message['text'] = 'Unrecognized User ID'; $json_data = array('message' => $message); $output = $json->encode($json_data); return $output; } }
function doLogin($usu_login, $usu_senha) { $db = new db("../config.php"); $json = new Services_JSON(); $db->executa($db->getJoinRecord("funcionarios", "fun_nome='{$usu_login}' and fun_senha='{$usu_senha}'", '', 0), true, "user"); if ($db->num_rows == 1) { $id = $db->user["usu_id"]; $login = $db->user["usu_login"]; $itens = array("usu_id" => $id, "usu_login" => $login, "status" => 1); $str = $json->encode($itens); session_register("usu_nome"); session_register("usu_id"); $_SESSION["usu_modulo"] = 0; $_SESSION["usu_nome"] = $db->user["fun_nome"]; $_SESSION["usu_id"] = $db->user["fun_id"]; $_SESSION["sis_exerc"] = $exercicio; $_SESSION["usu_grpid"] = $grp_id; $_SESSION["bgcolor"] = "#EAE5DA"; $_SESSION["dtatend"] = date("d/m/Y"); if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) { $ip = $_SERVER["HTTP_X_FORWARDED_FOR"]; } else { $ip = $HTTP_SERVER_VARS['REMOTE_ADDR']; } } else { $itens = array("usu_id" => '', "usu_login" => $_GET["usu_login"], "status" => 2); $str = $json->encode($itens); } return $str; }
function handleJSON_getContent($smarty, $module_name, $appletlist) { $respuesta = array('status' => 'success', 'message' => '(no message)'); // Leer credenciales a partir del usuario y el perfil asociado global $arrConf; $dbAcl = new paloDB($arrConf["elastix_dsn"]["acl"]); $pACL = new paloACL($dbAcl); $userId = $pACL->getIdUser($_SESSION['elastix_user']); $mailCred = $this->leerPropiedadesWebmail($dbAcl, $userId); if (count($mailCred) <= 0) { $respuesta['status'] = 'error'; $respuesta['message'] = _tr("You don't have a webmail account"); } elseif (!$this->_checkEmailPassword("{$mailCred['login']}@{$mailCred['domain']}", isset($mailCred['password']) ? $mailCred['password'] : '')) { $respuesta['status'] = 'error'; $respuesta['message'] = "{$mailCred['login']}@{$mailCred['domain']} " . _tr("does not exist locally or password is incorrect"); } else { $imap = @imap_open("{localhost:143/notls}", "{$mailCred['login']}@{$mailCred['domain']}", isset($mailCred['password']) ? $mailCred['password'] : ''); if (!$imap) { $respuesta['status'] = 'error'; $respuesta['message'] = _tr('Imap: Connection error'); } else { $this->leerInformacionImap($smarty, $module_name, $imap, $respuesta); imap_close($imap); } } $json = new Services_JSON(); Header('Content-Type: application/json'); return $json->encode($respuesta); }
function index($params) { $search_criteria = array("sort" => "date DESC"); if (!empty($this->search_for_payments)) { $search_criteria = array_merge($search_criteria, $this->search_for_payments); } $this->data->payments = Payment::getMany($search_criteria); if (!empty($params['spokes'])) { $spokes_data = $this->data->payments; $rows = array(); foreach ($spokes_data as $data_item) { $rows[] = $data_item->to_spokes(); } $json = new Services_JSON(); $this->response = array('body' => $json->encode($rows)); if (!empty($params['callback'])) { $this->response['body'] = $params['callback'] . '(' . $this->response['body'] . ')'; } return; } $this->data->search_payment = new Payment(); $this->data->search_payment->set($search_criteria); $this->data->new_payment = new Payment(); $this->data->new_payment->set(array('date' => date('Y-m-d'))); }
public function saveupload() { $json = new Services_JSON(); $uploadpath = 'upload/goods/'; $filepath = '/upload/goods/'; $upload = new upload($uploadpath, array('gif', 'jpg', 'jpge', 'png')); //upload $file = $upload->getfile(); if ($upload->errno != 15 && $upload->errno != 0) { $msg = $json->encode(array('error' => 1, 'message' => $upload->errmsg())); } else { $msg = $json->encode(array('error' => 0, 'url' => $filepath . $file[0][saveName], 'trueurl' => $upload->returninfo['name'])); } echo $msg; exit; }
/** * It is specific implementation of ancestor method getData() * * @return <String> JSON represantation of given data. */ public function getData() { $attributes = $this->solveData(); $this->jsonObject['attributes'] = $attributes; $interestMeasure = $this->solveInterestMeasures(); $this->jsonObject['interestMeasures'] = $interestMeasure; $this->solveNumberBBA(); $this->solveDepthNesting(); $this->solveMoreRules(); $interestMeasure = $this->domFL->getElementsByTagName("InterestMeasures")->item(0); $bba = $this->domFL->getElementsByTagName("BasicBooleanAttribute")->item(0); $threshold = "optional"; $coefficient = "optional"; if ($interestMeasure->getAttribute("threshold") != "") { $threshold = $interestMeasure->getAttribute("threshold"); } if ($bba->getAttribute("coefficient") != "") { $coefficient = $bba->getAttribute("coefficient"); } $this->jsonObject['imThreshold'] = $threshold; $this->jsonObject['attrCoef'] = $coefficient; $posCoef = $this->solvePosCoef(); $this->jsonObject['possibleCoef'] = $posCoef; if ($this->domER != null) { $this->solveExistingRules(); } else { $this->jsonObject['rules'] = 0; } $this->jsonObject['lang'] = $this->lang; $json = new Services_JSON(); return $json->encode($this->jsonObject); }
function HTTP_GET() { $json = new paloSantoJSON(); $pCore_calendar = new core_Calendar(); $fields = isset($_GET["fields"]) ? $_GET["fields"] : NULL; if (is_null($fields)) { header("HTTP/1.1 400 Bad Request"); $error = "You need to specify by GET the parameter \"fields\""; $json->set_status("ERROR"); $json->set_error($error); return $json->createJSON(); } $result = $pCore_calendar->getHash($fields); if ($result === FALSE) { $error = $pCore_calendar->getError(); if ($error["fc"] == "DBERROR") { header("HTTP/1.1 500 Internal Server Error"); } else { header("HTTP/1.1 400 Bad Request"); } $json->set_status("ERROR"); $json->set_error($error); return $json->createJSON(); } else { $json = new Services_JSON(); return $json->encode($result); } }
public function send() { // If no commands were added, just resolve this ajax request. if (empty($this->commands)) { $nulldata = array(); $this->addCommand('resolve', $nulldata); } require_once DISCUSS_CLASSES . '/json.php'; $json = new Services_JSON(); $transport = JRequest::getVar('transport'); $response = $json->encode($this->commands); switch ($transport) { case "jsonp": header('Content-type: text/javascript; UTF-8'); $callback = JRequest::getVar('callback'); echo $callback . '(' . $response . ');'; break; case "iframe": header('Content-type: text/html; UTF-8'); echo '<textarea data-type="application/json" data-status="200" data-statusText="OK">' . $response . '</textarea>'; break; default: header('Content-type: text/javascript; UTF-8'); echo $response; } exit; }
function display($tpl = null) { $params =& JComponentHelper::getParams('com_mediasyndicator'); $basebrowserpath = $params->get('basebrowserpath', DS . 'images'); $dir = JRequest::getVar('dir', ''); $firephp = FirePHP::getInstance(true); $firephp->log('%^' . preg_quote($basebrowserpath) . '%', 'regex'); $dir = preg_replace('%^' . preg_quote($basebrowserpath) . '%', '', $dir); $document =& JFactory::getDocument(); //$document->setMimeEncoding('application/json'); $document->setMimeEncoding('application/x-javascript'); //TODO: verify that this is a logged in user in the backend of Joomla! // include JSON service file $JSONfile = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_mediasyndicator' . DS . 'libraries' . DS . 'JSON.php'; $includeFile = $this->includeFile($JSONfile); if ($includeFile) { print $includeFile; return; } $directoryarray = $this->createDirectoryArray($dir, $basebrowserpath); $directoryarray['requestdir'] = $dir; $json = new Services_JSON(); $output = $json->encode($directoryarray); print $output; }
function json_encode($content) { global $homedir; require_once $homedir . "/classes/json/JSON.php"; $json = new Services_JSON(); return $json->encode($content); }
private function output($response) { include_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'json.php'; $json = new Services_JSON(); echo $json->encode($response); exit; }
/** * Outputs a Multipass token for the array provided. The array is a freeform * array that should conform to the requirements set forth by TenderApp with * regards to required and recommended values. * * It is not necessary to pass in the expiration date. This library will * generate that for you automatically. * * @param data An associative array containing the data to be encoded. * @return An encoded multipass token. */ function to_string($data) { require_once "JSON.php"; $json = new Services_JSON(); // error checking for key names // unique_id, email required $data['expires'] = date('D M d H:i:s e Y', time() + 60 * $this->expires); $sso = $json->encode($data); $salted = $this->site_key . $this->api_key; $hash = hash('sha1', $salted, true); $saltedHash = substr($hash, 0, 16); $iv = "OpenSSL for PHP!"; for ($i = 0; $i < 16; $i++) { $sso[$i] = $sso[$i] ^ $iv[$i]; } $pad = 16 - strlen($sso) % 16; $sso = $sso . str_repeat(chr($pad), $pad); $cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', 'cbc', ''); mcrypt_generic_init($cipher, $saltedHash, $iv); $enc = mcrypt_generic($cipher, $sso); mcrypt_generic_deinit($cipher); $b64 = base64_encode($enc); $b64 = preg_replace('/\\n/', '', $b64); $b64 = preg_replace('/\\=*$/', '', $b64); $b64 = preg_replace('/\\+/', '-', $b64); $b64 = preg_replace('/\\//', '_', $b64); return $b64; }
function get_json($data, $status = 'ok') { // Include a status value with the response if (is_array($data)) { $data = array_merge(array('status' => $status), $data); } else { if (is_object($data)) { $data = get_object_vars($data); $data = array_merge(array('status' => $status), $data); } } $data = apply_filters('json_api_encode', $data); if (function_exists('json_encode')) { // Use the built-in json_encode function if it's available return json_encode($data); } else { // Use PEAR's Services_JSON encoder otherwise if (!class_exists('Services_JSON')) { $dir = gb_json_api_dir(); require_once "{$dir}/library/JSON.php"; } $json = new Services_JSON(); return $json->encode($data); } }
public function getAjaxTemplate() { $files = JRequest::getVar('names', ''); if (empty($files)) { return false; } // Ensure the integrity of each items submitted to be an array. if (!is_array($files)) { $files = array($files); } $result = array(); $template = EB::template(); foreach ($files as $file) { $dashboard = explode('/', $file); if ($dashboard[0] == "dashboard") { $out = $template->output('site/dashboard/' . $dashboard[1] . '.ejs'); } elseif ($dashboard[0] == "media") { $out = $template->output('site/media/' . $dashboard[1] . '.ejs'); } else { $out = $template->output('site/' . $file . '.ejs'); } $obj = new stdClass(); $obj->name = $file; $obj->content = $out; $result[] = $obj; } header('Content-type: text/x-json; UTF-8'); $json = new Services_JSON(); echo $json->encode($result); exit; }
/** * Transforma los datos pasados como parametro en un JSON válido * * @param int $error si hubo error en la operación o no (0 = NO o 1 = SI) * @param string $msg mensaje a mostrar al usuario * @param string $html html a incluir en el JSON * @return object objeto PHP */ public function encode($error, $msg, $html = '') { // include_once("classes/JSON.class.php"); $json = new Services_JSON(); $data = array("error" => $error, "msg" => $msg, "html" => $html); return $json->encode($data); }
/** * Get download progress from CURL */ public static function progressCallback($download_size, $downloaded, $upload_size, $uploaded) { //error_log(self::$packagesize.", $downloaded, $upload_size, $uploaded"); //error_log("$download_size, $downloaded, $upload_size, $uploaded"); if (self::$packagesize > 0) { $pct = round($downloaded / self::$packagesize * 100, 0); if (self::$lastpct != $pct) { self::$lastpct = $pct; //error_log($pct); //no progress info if (!self::$doprogress) { return; } //echo "azcommunity.reportAutoUpdateProgress('".$pct."');"; if (count(self::$ajaxresponse->_response) > 0) { array_pop(self::$ajaxresponse->_response); } self::$ajaxresponse->addScriptCall("azcommunity.reportAutoUpdateProgress('" . $pct . "');"); //copied from plugins/system/.../ajax.php $json = new Services_JSON(); echo $json->encode(self::$ajaxresponse->_response); //echo "<body onload=\"parent.jax_iresponse();\">" .htmlentities($json->encode(self::$ajaxresponse->_response)). "</body>"; @ob_flush(); flush(); } } }
function create_form_token_json($form_id) { global $class_path; include_once $class_path . 'lgpl/Services_JSON.class.php'; $json_encoder = new Services_JSON(); return $json_encoder->encode(create_form_token_array($form_id)); }
public function getResource() { $resources = JRequest::getVar('resource'); if (!is_array($resources)) { header('Content-type: text/x-json; UTF-8'); echo '[]'; exit; } foreach ($resources as &$resource) { $resource = (object) $resource; switch ($resource->type) { case 'language': $resource->content = JText::_(strtoupper($resource->name)); break; case 'view': $template = Komento::getTheme(); $out = $template->fetch($resource->name . '.ejs'); if ($out !== false) { $resource->content = $out; } break; } } Komento::getClass('json', 'Services_JSON'); header('Content-type: text/x-json; UTF-8'); $json = new Services_JSON(); echo $json->encode($resources); exit; }
function genJSON() { $this->fillMyArrays(); $this->oJSONObject = new BxDolPFMAreaJSONObj($this); $oJSONConv = new Services_JSON(); return $oJSONConv->encode($this->oJSONObject); }
function json_encode($content) { if (!class_exists("Services_JSON")) { require_once "json.php"; } $json = new Services_JSON(); return $json->encode($content); }
function json_encode($arg) { global $services_json; if (!isset($services_json)) { $services_json = new Services_JSON(); } return $services_json->encode($arg); }
function json_encode($value) { static $jsonobj; if (!isset($jsonobj)) { include_once (IA_ROOT . '/source/library/json/JSON.php'); $jsonobj = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); } return $jsonobj->encode($value); }
protected function ajax_out($res_arr) { require_once _base_ . '/lib/lib.json.php'; $json = new Services_JSON(); $array_j = $json->encode($res_arr); ob_clean(); echo $array_j; }
function json_encode($data = null) { $json = new Services_JSON(); if ($data == null) { return false; } return $json->encode($data); }
static function encode($data) { if (function_exists('json_encode')) { return json_encode($data); } $json = new Services_JSON(); return $json->encode($data); }
function json_encode($value) { if (!class_exists('Services_JSON', false)) { include 'Services_JSON.php'; } $inst = new Services_JSON(); return $inst->encode($value); }
function alert($msg) { header('Content-type: text/html; charset=UTF-8'); $json = new Services_JSON(); echo $json->encode(array('error' => 1, 'message' => $msg)); exit; }