Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 private function output($response)
 {
     include_once EBLOG_CLASSES . DIRECTORY_SEPARATOR . 'json.php';
     $json = new Services_JSON();
     echo $json->encode($response);
     exit;
 }
Ejemplo n.º 3
0
 function genJSON()
 {
     $this->fillMyArrays();
     $this->oJSONObject = new BxDolPFMAreaJSONObj($this);
     $oJSONConv = new Services_JSON();
     return $oJSONConv->encode($this->oJSONObject);
 }
Ejemplo n.º 4
0
 /**
  * Transforma el texto enviado en formato JSON a un objeto PHP
  *
  * @param string $html texto JSON a decodear
  * @return object objeto PHP
  */
 public function decode($html)
 {
     //         include_once("classes/JSON.class.php");
     $json = new Services_JSON();
     $data = stripslashes($html);
     return $json->decode($data);
 }
Ejemplo n.º 5
0
 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);
     }
 }
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));
}
Ejemplo n.º 7
0
 /**
  * Send the HTTP request via cURL
  *
  * @return SiftResponse
  */
 public function send()
 {
     $json = new Services_JSON();
     $propertiesString = http_build_query($this->properties);
     $curlUrl = $this->url;
     if ($this->method == self::GET) {
         $curlUrl .= '?' . $propertiesString;
     }
     // Mock the request if self::$mock exists
     if (self::$mock) {
         if (self::$mock['url'] == $curlUrl && self::$mock['method'] == $this->method) {
             return self::$mock['response'];
         }
         return null;
     }
     // Open and configure curl connection
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_URL, $curlUrl);
     curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
     if ($this->method == self::POST) {
         $jsonString = $json->encodeUnsafe($this->properties);
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonString);
         curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($jsonString), 'User-Agent: SiftScience/v' . SiftClient::API_VERSION . ' sift-php/' . SiftClient::VERSION));
     }
     // Send the request using curl and parse result
     $result = curl_exec($ch);
     $httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     // Close the curl connection
     curl_close($ch);
     return new SiftResponse($result, $httpStatusCode, $this);
 }
Ejemplo n.º 8
0
 function getFiltersFor($msg, $id = null)
 {
     $json = new Services_JSON();
     if ($id !== null) {
         $this->id = $id;
     }
     $this->find();
     $res = array();
     while ($this->fetch()) {
         $fltrs = $json->decode($this->filter);
         // Serach for "from" and "subject"
         foreach ($fltrs as $f) {
             $from = !isset($f->from) || trim($f->from) == "";
             $subj = !isset($f->subject) || trim($f->subject) == "";
             if ($from && $subj) {
                 continue;
             }
             if (!$from) {
                 $from = strpos($msg->from, $f->from) !== false;
             }
             if (!$subj) {
                 $subj = strpos($msg->subject, $f->subject) !== false;
             }
             if ($from && $subj) {
                 $res[] = $this->toArray();
                 break;
             }
         }
     }
     return $res;
 }
Ejemplo n.º 9
0
 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 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);
     }
 }
Ejemplo n.º 11
0
 /**
  * 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);
 }
Ejemplo n.º 12
0
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;
    }
}
Ejemplo n.º 13
0
/**
 * Smarty {json} plugin
 *
 * Type:     function
 * Name:     json
 * Purpose:  fetch json file and  assign result as a template variable (array) 
 * @param url (url to fetch)
 * @param assign (element to assign to)
 * @return array|null if the assign parameter is passed, Smarty assigns the
 *                     result to a template variable
 */
function smarty_function_json($params, &$smarty)
{
    if (empty($params['url'])) {
        $smarty->_trigger_fatal_error("[json] parameter 'url' cannot be empty");
        return;
    }
    $content = array();
    $data = file_get_contents($params['url']);
    if (empty($data)) {
        return false;
    }
    if (!is_callable('json_decode')) {
        require_once 'JSON.php';
        $json = new Services_JSON();
        $content = $json->decode(trim(file_get_contents($params['url'])));
    } else {
        $content = json_decode(trim(file_get_contents($params['url'])));
    }
    if ($params['debug'] === true) {
        echo "<pre>";
        print_r($content);
        echo "</pre>";
    }
    if (!empty($params['assign'])) {
        $smarty->assign($params['assign'], $content);
    } else {
        return $content;
    }
}
Ejemplo n.º 14
0
 static function loginTeacher($class, $pass, $ignoreNonexistent = false)
 {
     $json = new Services_JSON();
     if (!$class) {
         return "クラス名を入力してください。";
     }
     if (!$pass) {
         return "パスワードを入力してください。";
     }
     if (!file_exists("fs/home/{$class}") && !$ignoreNonexistent) {
         return "存在しないクラスIDが入力されています。";
     }
     if (preg_match('/^[a-zA-Z0-9\\-_]+$/', $pass)) {
         $fp = fopen("user/list.txt", "r");
         while ($line = fgets($fp)) {
             $classlist = $json->decode($line);
             if ($classlist["classid"] == $class) {
                 break;
             }
         }
         fclose($fp);
         if (isset($classlist) && $classlist["pass"] == $pass) {
             // Success
             MySession::set("class", $class);
             MySession::set("user", self::TEACHER);
             setcookie("class", $class, time() + 60 * 60 * 24 * 30);
             return true;
         } else {
             return "クラスIDかパスワードが間違っています。";
         }
     } else {
         return "パスワードは半角英数とハイフン、アンダースコアだけが使えます。";
     }
 }
Ejemplo n.º 15
0
 public function __construct($result, $httpStatusCode, $request)
 {
     if (function_exists('json_decode')) {
         $this->body = json_decode($result, true);
     } else {
         require_once dirname(__FILE__) . '/Services_JSON-1.0.3/JSON.php';
         $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
         $this->body = $json->decode($result);
     }
     $this->httpStatusCode = $httpStatusCode;
     // If there is an error we want to build out an error string.
     if ($this->httpStatusCode !== 200) {
         $this->error = $this->body['error'];
         $this->errorMessage = $this->error . ': ' . $this->body['description'];
         if (array_key_exists('issues', $this->body)) {
             $this->errorIssues = $this->body['issues'];
             foreach ($this->errorIssues as &$issue) {
                 $this->errorMessage .= array_search($issue, $this->errorIssues) . ': ' . $issue;
             }
             unset($issue);
         }
     }
     if (array_key_exists('request', $this->body)) {
         $this->request = $this->body['request'];
     } else {
         $this->request = null;
     }
     $this->request = $request;
     $this->result = $result;
 }
Ejemplo n.º 16
0
 function decode($str)
 {
     //$lib='native';
     // $lib='services_JSON';
     // $lib='jsonrpc';
     // dirty trick to correct bad json for photos
     //$str = preg_replace('/\t} {/','}, {', $str);
     // remove trailing ,
     //$str = preg_replace('/,[ \r\n\t]+}/',' }', $str);
     // echo "Using $lib<BR>";
     // echo $str;
     if (function_exists('json_decode') && JSON_LIB_DECODE == 'native') {
         $arr = json_decode($str, true);
     } else {
         if (JSON_LIB_DECODE == 'services_JSON') {
             require_once dirname(__FILE__) . '/json.php';
             $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
             $arr = $json->decode($str);
         } else {
             if (JSON_LIB_DECODE == 'jsonrpc') {
                 require_once dirname(__FILE__) . '/jsonrpc/xmlrpc.php';
                 require_once dirname(__FILE__) . '/jsonrpc/jsonrpc.php';
                 $GLOBALS['xmlrpc_internalencoding'] = 'UTF-8';
                 //require_once dirname(__FILE__).'/jsonrpc/json_extension_api.php';
                 //$arr=json_decode($str, true);
                 $value = php_jsonrpc_decode_json($str);
                 if ($value) {
                     $arr = php_jsonrpc_decode($value, array());
                 }
             }
         }
     }
     // print_r($arr);
     return $arr;
 }
Ejemplo n.º 17
0
function json($file)
{
    global $fs, $word, $around;
    $j = new Services_JSON();
    $a = explode("T", $word);
    $date = preg_replace("/-/", "/", $a[0]);
    $time = $a[1];
    echo "{$time} ---  {$date}<BR>";
    $lines = explode("\n", $fs->getContent("{$file}-data.log"));
    $a = array();
    $around = $around / 10;
    $found = false;
    foreach ($lines as $line) {
        $e = $j->decode($line);
        if ($e) {
            $a[] = toHTML($e);
            //echo $e["date"]." ".$e["time"]. "<BR>";
            if ($found) {
                if (count($a) > $around * 2) {
                    break;
                }
            } else {
                if (count($a) > $around) {
                    array_shift($a);
                }
                if ($e["date"] == $date && $e["time"] == $time) {
                    array_push($a, "<a name='center'/><font color=red>-----------------------------------</font><BR>");
                    $found = TRUE;
                }
            }
        }
    }
    print join("<BR>", $a);
}
Ejemplo n.º 18
0
 function make_short_url($restURL)
 {
     $out = "GET " . $restURL . " HTTP/1.1\r\n";
     $out .= "Host: api.bit.ly\r\n";
     $out .= "Content-type: application/x-www-form-urlencoded\r\n";
     $out .= "Connection: Close\r\n\r\n";
     $handle = @fsockopen('api.bit.ly', 80, $errno, $errstr, 30);
     fwrite($handle, $out);
     $body = false;
     $contents = '';
     while (!feof($handle)) {
         $return = fgets($handle, 1024);
         if ($body) {
             $contents .= $return;
         }
         if ($return == "\r\n") {
             $body = true;
         }
     }
     fclose($handle);
     $json = new Services_JSON();
     $data = $json->decode($contents);
     //for issues with unable to authenticate error, somehow they return errors instead of error.
     if (!isset($data->status_code)) {
         return false;
     }
     if ($data->status_code != '200') {
         return false;
     }
     return $data->data->url;
 }
Ejemplo n.º 19
0
 public function __construct($result, $httpStatusCode, $request)
 {
     $this->body = null;
     $this->apiStatus = null;
     $this->apiErrorMessage = null;
     if (function_exists('json_decode')) {
         $this->body = json_decode($result, true);
     } else {
         require_once dirname(__FILE__) . '/Services_JSON-1.0.3/JSON.php';
         $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
         $this->body = $json->decode($result);
     }
     $this->httpStatusCode = $httpStatusCode;
     $this->request = $request;
     $this->rawResponse = $result;
     // Only attempt to get our response body if the http status code expects a body
     if (!in_array($this->httpStatusCode, array(204, 304))) {
         $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
         $this->body = $json->decode($result);
         // NOTE: Responses from /v3 endpoints don't contain status or error_message.
         if (array_key_exists('status', $this->body)) {
             $this->apiStatus = intval($this->body['status']);
         }
         if (array_key_exists('error_message', $this->body)) {
             $this->apiErrorMessage = $this->body['error_message'];
         }
     }
 }
Ejemplo n.º 20
0
 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')));
 }
Ejemplo n.º 21
0
 /**
  * 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();
         }
     }
 }
Ejemplo n.º 22
0
 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);
 }
Ejemplo n.º 23
0
function diffapplydiff($base, $diff)
{
    if (function_exists('json_encode')) {
        $diffs = json_decode($diff);
    } else {
        require_once "JSON.php";
        $jsonser = new Services_JSON();
        return $jsonser->decode($diff);
    }
    for ($i = count($diffs) - 1; $i >= 0; $i--) {
        if ($diffs[$i][0] == 2) {
            //replace
            array_splice($base, $diffs[$i][1], $diffs[$i][2], $diffs[$i][3]);
        } else {
            if ($diffs[$i][0] == 0) {
                //insert
                array_splice($base, $diffs[$i][1], 0, $diffs[$i][2]);
            } else {
                if ($diffs[$i][0] == 1) {
                    //delete
                    array_splice($base, $diffs[$i][1], $diffs[$i][2]);
                }
            }
        }
    }
    return $base;
}
 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));
 }
Ejemplo n.º 25
0
 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;
 }
Ejemplo n.º 26
0
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;
}
Ejemplo n.º 27
0
 function json_encode($content)
 {
     global $homedir;
     require_once $homedir . "/classes/json/JSON.php";
     $json = new Services_JSON();
     return $json->encode($content);
 }
Ejemplo n.º 28
0
 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;
 }
Ejemplo n.º 29
0
function display($persona)
{
    $json = new Services_JSON();
    $persona->get_configuration_data();
    $properties =& PersonaProperty::load_persona_properties($persona->persona_id);
    $propertyCount = count($properties);
    // echo "<pre>" . print_r($persona, true) . "</pre>";
    if (!$propertyCount) {
        echo "No status info available";
    } else {
        foreach ($properties as $k => $property) {
            if ($property->name == 'Status') {
                $content = $json->decode($property->content);
                if ($content->friendly) {
                    echo $content->friendly;
                    echo '<br />';
                    echo 'Last fetch on: ' . date("H:i D jS M", strtotime($content->date));
                } else {
                    echo "No status info available";
                }
                /*
                echo '<!-- ' . "\n";
                echo print_r($property, true) . "\n";
                echo print_r($content, true) . "\n";
                echo ' -->';
                */
            }
        }
    }
}
Ejemplo n.º 30
-1
function alert($msg)
{
    header('Content-type: text/html; charset=UTF-8');
    $json = new Services_JSON();
    echo $json->encode(array('error' => 1, 'message' => $msg));
    exit;
}