function handle_openid_config() { global $signing_alg_values_supported, $encryption_alg_values_supported, $encryption_enc_values_supported; $endpoint_base = OP_INDEX_PAGE; $discovery = array('version' => '3.0', 'issuer' => OP_URL, 'authorization_endpoint' => $endpoint_base . '/auth', 'token_endpoint' => $endpoint_base . '/token', 'userinfo_endpoint' => $endpoint_base . '/userinfo', 'check_session_iframe' => OP_URL . '/opframe.php', 'end_session_endpoint' => $endpoint_base . '/endsession', 'jwks_uri' => OP_JWK_URL, 'registration_endpoint' => $endpoint_base . '/registration', 'scopes_supported' => array('openid', 'profile', 'email', 'address', 'phone', 'offline_access'), 'response_types_supported' => array('code', 'code token', 'code id_token', 'token', 'token id_token', 'code token id_token', 'id_token'), 'grant_types_supported' => array('authorization_code', 'implicit'), 'acr_values_supported' => array(), 'subject_types_supported' => array('public', 'pairwise'), 'userinfo_signing_alg_values_supported' => $signing_alg_values_supported, 'userinfo_encryption_alg_values_supported' => $encryption_alg_values_supported, 'userinfo_encryption_enc_values_supported' => $encryption_enc_values_supported, 'id_token_signing_alg_values_supported' => $signing_alg_values_supported, 'id_token_encryption_alg_values_supported' => $encryption_alg_values_supported, 'id_token_encryption_enc_values_supported' => $encryption_enc_values_supported, 'request_object_signing_alg_values_supported' => $signing_alg_values_supported, 'request_object_encryption_alg_values_supported' => $encryption_alg_values_supported, 'request_object_encryption_enc_values_supported' => $encryption_enc_values_supported, 'token_endpoint_auth_methods_supported' => array('client_secret_post', 'client_secret_basic', 'client_secret_jwt', 'private_key_jwt'), 'token_endpoint_auth_signing_alg_values_supported' => $signing_alg_values_supported, 'display_values_supported' => array('page'), 'claim_types_supported' => array('normal'), 'claims_supported' => array('name', 'given_name', 'family_name', 'middle_name', 'nickname', 'preferred_username', 'profile', 'picture', 'website', 'email', 'email_verified', 'gender', 'birthdate', 'zoneinfo', 'locale', 'phone_number', 'phone_number_verified', 'address', 'updated_at'), 'service_documentation' => $endpoint_base . '/servicedocs', 'claims_locales_supported' => array('en-US'), 'ui_locales_supported' => array('en-US'), 'require_request_uri_registration' => false, 'op_policy_uri' => $endpoint_base . '/op_policy', 'op_tos_uri' => $endpoint_base . '/op_tos', 'claims_parameter_supported' => true, 'request_parameter_supported' => true, 'request_uri_parameter_supported' => true); header('Content-Type: application/json'); echo pretty_json(json_encode($discovery)); }
function make_jwk($keys) { if (!is_array($keys)) { $keys = array($keys); } $jwk = array('keys' => $keys); return pretty_json(json_encode($jwk)); }
function bitMeta() { global $config; $data = $this->input->post(); $code = $this->loadModel('code_model'); $res = $code->getBitBySlug($data->slug, $data->version); $meta = $res->meta ? json_decode($res->meta) : array(); $meta = array_merge($config['bitSettings'], (array) $meta); $this->api_put(true, array('meta' => pretty_json(json_encode($meta)))); }
function apiquery($field = FALSE) { global $mysqli; $stmt = $mysqli->prepare("SELECT `ip`,`port`,`owner`,`version`,`status` FROM `nodes` ORDER BY `version` DESC, `owner` DESC"); $stmt->execute(); $stmt->bind_result($ip, $port, $owner, $version, $status); $i = 0; while ($stmt->fetch()) { $result[$i] = array("ip" => $ip, "port" => $port, "owner" => $owner, "version" => $version, "status" => $status); $i++; } $stmt->close(); header('Content-type: text/javascript'); echo pretty_json(json_encode($result)); }
function apiquery($field) { global $mysqli; $result = array(); $txrows = ""; $totalvalue = 0; $received_txs = 0; $received_mmc = 0; $sent_txs = 0; $sent_mmc = 0; $stmt = $mysqli->prepare("SELECT `keys`.`hash160`, `keys`.`address`, `keys`.`firstseen`, `blocks`.`height`, `blocks`.`time` FROM `keys` LEFT JOIN `blocks` ON (`blocks`.`hash` = `keys`.`firstseen`) WHERE `address` LIKE ? LIMIT 1"); $stmt->bind_param('s', $field); $stmt->execute(); $stmt->bind_result($hash160, $address, $firstseen, $height, $time); $stmt->fetch(); $stmt->close(); $stmt = $mysqli->prepare("\n\tSELECT `inputs`.`type` AS txtype, 'debit' AS type, `inputs`.`tx` AS tx, SUM(`inputs`.`value`) AS value, `inputs`.`index` AS id, `transactions`.`block` AS block, `blocks`.`height` AS blocknum, `blocks`.`time` AS time FROM `inputs`, `transactions`, `blocks` WHERE `inputs`.`hash160` = ? AND `inputs`.`tx` = `transactions`.`hash` AND `transactions`.`block` = `blocks`.`hash` GROUP BY tx \n\n\tUNION ALL\n\n\tSELECT `outputs`.`type` AS txtype, 'credit' AS type, `outputs`.`tx` AS tx, SUM(`outputs`.`value`) AS value, `outputs`.`index` AS id, `transactions`.`block` AS block, `blocks`.`height` AS blocknum, `blocks`.`time` AS time FROM `outputs`, `transactions`, `blocks` WHERE `outputs`.`hash160` = ? AND `outputs`.`tx` = `transactions`.`hash` AND `transactions`.`block` = `blocks`.`hash` GROUP BY tx \n\n\tORDER BY time DESC"); $stmt->bind_param('ss', $hash160, $hash160); $stmt->execute(); $stmt->bind_result($txtype, $type, $tx, $value, $id, $block, $blocknum, $time2); while ($stmt->fetch()) { if ($type == "credit") { $received_txs++; $received_mmc = bcadd($received_mmc, $value, 8); } elseif ($type == 'debit') { $sent_txs++; $sent_mmc = bcadd($sent_mmc, $value, 8); } $txrows .= ' <tr> <td class="blocksHash"> <a href="http://www.mmc-chain.com/?engine=blockexplorer&blockid=' . $blocknum . '" class="internal transactionLink">' . $blocknum . '</a></td> <td class="transactionHash"> <a href="http://www.mmc-chain.com/?engine=blockexplorer&tx=' . $tx . '" class="internal transactionLink">' . $tx . '</a> </td> <td class="hide-for-small transactedDate">' . gmdate("M j Y g:i:s A", $time2) . '</td> <td class="transactedAmount"><img class="transactionDirection" src="/img/' . $type . '.png" /></td> <td class="transactedAmount" style="text-align: right;">' . number_format($value, 8, '.', ',') . ' MMC</td> </tr>'; } $balance = bcsub($received_mmc, $sent_mmc, 8); $result = array("address" => $address, "hash160" => $hash160, "firstseen" => $firstseen, "height" => $height, "time" => $time, "tx_in" => $received_txs, "mmc_in" => $received_mmc, "tx_out" => $sent_txs, "mmc_out" => $sent_mmc, "balance" => $balance); header('Content-type: text/javascript'); echo pretty_json(json_encode($result)); }
public function list_item() { $page = intval($this->uri->segment(3)); $per_page = 10; $offset = $page == 0 ? $page : $page * $per_page - $per_page; $data = $this->db->order_by('created', 'desc')->limit($per_page, $offset)->get('beo_bengkel'); $total = $this->db->get('beo_bengkel')->num_rows(); foreach ($data->result() as $v) { $profile = json_decode($v->profile); $latlng = json_decode($v->latlng); $v->name = $profile->name; $key = $v->id_marker; $result[] = array("id" => $v->id, "id_marker" => $v->id_marker, "name" => $profile->name, "company" => $profile->company, "contact" => $profile->contact, "email" => $profile->email, "location" => $profile->location, "price" => $profile->price, "lat" => $latlng->lat, "lng" => $latlng->lng, "created" => $v->created, "updated" => $v->updated); } $output['ok'] = 1; $output['result'] = array('list' => $result, 'per_page' => $per_page, 'total_data' => $total, 'total_page' => ceil($total / $per_page)); pretty_json($output); }
/** * pretty_print_test * @param string $filename */ function pretty_print_test($data, $test_name) { echo "\n" . $test_name . "\n"; $sub_test_name = "json_encode > json_decode"; $result = json_decode(json_encode($data)); if (compare_values($data, $result)) { echo $sub_test_name . " - okay\n"; } else { echo $sub_test_name . " - FAIL!\n"; die; } $sub_test_name = "json_encode > pretty_json > json_decode"; $result = json_decode(pretty_json(json_encode($data))); if (compare_values($data, $result)) { echo $sub_test_name . " - okay\n"; } else { echo $sub_test_name . " - FAIL!\n"; die; } }
<?php include_once $_SERVER['DOCUMENT_ROOT'] . '/202-config.php'; include_once $_SERVER['DOCUMENT_ROOT'] . '/202-config/connect2.php'; include_once $_SERVER['DOCUMENT_ROOT'] . '/api/v1/functions.php'; header('Content-Type: application/json'); $data = array(); if ($_SERVER['REQUEST_METHOD'] == "GET") { $data = getStats($db, $_GET); } else { $data = array('msg' => 'Not allowed request method', 'error' => true, 'status' => 405); } $json = str_replace('\\/', '/', json_encode($data)); print_r(pretty_json($json));
static function formatJson($json) { $version = phpversion(); if (version_compare($version, '5.4', 'lt')) { return pretty_json($json); } else { if (version_compare($version, '5.4', 'ge')) { return json_encode(json_decode($json, TRUE), JSON_PRETTY_PRINT); } } }
public function update() { $id = $this->security->xss_clean($this->input->post('id')); $name = $this->security->xss_clean($this->input->post('name')); $username = $this->security->xss_clean($this->input->post('username')); $password = $this->security->xss_clean($this->input->post('password')); $contact = $this->security->xss_clean($this->input->post('contact')); $location = $this->security->xss_clean($this->input->post('location')); $latlng = $this->security->xss_clean($this->input->post('latlng')); if (!empty($id) && !empty($name) && !empty($username) && !empty($password) && !empty($contact) && !empty($location) && !empty($latlng)) { // location $latlng = fix_location($latlng); // profile $profile = array('name' => $name, 'contact' => $contact, 'location' => $location); $data = array('username' => $username, 'pass' => $password, 'profile' => json_encode($profile), 'latlng' => json_encode($latlng), 'updated' => date('Y-m-d H:i:s')); $update = $this->db->where('id', $id); $update = $this->db->update('beo_customer', $data); if ($update) { $result[] = array('id' => $id, 'name' => $name, 'username' => $username, 'pass' => $password, 'contact' => $contact, 'location' => $location); $output["ok"] = 1; $output["result"] = $result; pretty_json($output); } else { echo json_encode(array('ok' => 0, 'msg' => 'No auth found')); } } else { echo json_encode(array('ok' => 0, 'msg' => 'No auth found')); } }
function pretty_edit_filters() { global $context, $modSettings, $sourcedir, $txt; // Check the JSON extension is installed if (!function_exists('json_encode')) { unset($context['template_layers']['pretty_chrome']); fatal_lang_error('pretty_no_json', false); } // Save the filters array if (isset($_REQUEST['save'])) { // Try to process the edited JSON array $json_filters = isset($_POST['pretty_json_filters']) ? $_POST['pretty_json_filters'] : ''; $json_filters = stripslashes($json_filters); $filters_array = json_decode($json_filters, true); // Was that successful or not? if ($filters_array == NULL) { $_SESSION['pretty']['notice'] = 'There was an error with the JSON array you submitted'; $_SESSION['pretty']['json_filters'] = $json_filters; } else { require_once $sourcedir . '/Subs-PrettyUrls.php'; updateSettings(array('pretty_filters' => serialize($filters_array))); pretty_update_filters(); $_SESSION['pretty']['notice'] = 'Filters saved and updated'; } redirectexit('action=admin;area=pretty;sa=filters'); } // Action-specific chrome $context['page_title'] = $txt['pretty_chrome_page_title_filters']; $context['sub_template'] = 'pretty_filters'; $context['pretty']['chrome']['page_title'] = $txt['pretty_chrome_title_filters']; $context['pretty']['chrome']['caption'] = $txt['pretty_chrome_caption_filters']; if (isset($_SESSION['pretty']['json_filters'])) { // We're working on something already $context['pretty']['json_filters'] = $_SESSION['pretty']['json_filters']; unset($_SESSION['pretty']['json_filters']); } else { // Convert the filters array to JSON and format it nicely require_once $sourcedir . '/Subs-PrettyUrls.php'; $context['pretty']['json_filters'] = json_encode(unserialize($modSettings['pretty_filters'])); $context['pretty']['json_filters'] = pretty_json($context['pretty']['json_filters']); $context['pretty']['json_filters'] = str_replace('\\/', '/', $context['pretty']['json_filters']); } // Any new notices? if (isset($_SESSION['pretty']['notice'])) { $context['pretty']['chrome']['notice'] = $_SESSION['pretty']['notice']; unset($_SESSION['pretty']['notice']); } }
private function saveUserData() { $log = fopen($this->fileName, "w+"); fwrite($log, pretty_json(json_encode($this->userData))); fclose($log); }
function getCampaignID($db, $campaign, $user) { $mysql['user_id'] = $db->real_escape_string($user); $mysql['campaign_id'] = $db->real_escape_string($campaign); $key_sql = "SELECT \t*\n\t\t\t\tFROM \t`202_aff_campaigns` \n\t\t\t\tWHERE \t`user_id`='" . $mysql['user_id'] . "' AND `aff_campaign_id`='" . $mysql['campaign_id'] . "'"; $key_result = _mysqli_query($db, $key_sql); $key_row = $key_result->fetch_assoc(); if ($key_result->num_rows > 0) { return true; } else { $json = json_encode(array('msg' => 'Campaign not found', 'error' => true, 'status' => 404), true); print_r(pretty_json($json)); die; } }
{ if (defined('JSON_PRETTY_PRINT')) { return json_encode($data, JSON_PRETTY_PRINT); } $json = json_encode($data); if (getenv("PRETTY_VIA_PYTHON")) { $input = tmpfile(); fwrite($input, $json); rewind($input); $proc = proc_open('python -mjson.tool', array(0 => $input, 1 => array('pipe', 'w'), 2 => array('file', '/dev/null', 'w')), $pipes); $json = stream_get_contents($pipes[1]); } return $json; } // Save the document information file_put_contents("docs/declmap.js", 'var declmap = ' . pretty_json($decl_map) . ";\n" . 'var docs = ' . pretty_json($docs) . ";\n"); exit(0); function process_include($incname, &$docs) { $incfile = file_get_contents($incname); preg_match(',^include/phenom/(.*)\\.h$,', $incname, $matches); $target = $matches[1]; $md = array(); $decl_titles = array(); $page_title = null; preg_match_all(',/\\*\\*.*?\\*/,s', $incfile, $matches, PREG_OFFSET_CAPTURE); foreach ($matches[0] as $i => $entry) { list($comment, $offset) = $entry; // Look ahead and see if we can find the first C-ish declaration. $decl = ''; $title = '';
$cwd = getcwd(); $md5_file_name = 'assets.json'; $static_dir = array('js', 'css', 'static', 'imgs'); $extnames = array('js', 'css', 'jpg', 'png', 'gif'); if ($argc > 1) { $static_dir = array_slice($argv, 1); } $files = walk_file($static_dir); $results = array(); foreach ($files as $file) { $ext = pathinfo($file, PATHINFO_EXTENSION); if (in_array($ext, $extnames)) { $results[$file] = md5_file($file); } } file_put_contents($md5_file_name, pretty_json($results) . "\n"); function walk_file($path) { $res = array(); if (is_array($path)) { foreach ($path as $p) { $res = array_merge($res, walk_file($p)); } } elseif (is_string($path)) { if (file_exists($path)) { if (is_dir($path)) { $files = scandir($path); foreach ($files as $file) { if ($file == '.' || $file == '..') { continue; }
function register_client($url, $options = array()) { global $g_error; try { $is_post = true; $headers = NULL; $curl_options = array(); $request_uris = array(); for ($i = 1; $i < 2; $i++) { $request_uris[] = RP_INDEX_PAGE . sprintf("/reqfile?fileid=%010d", $i); } $data = array('contacts' => array('*****@*****.**'), 'application_type' => 'web', 'client_name' => 'ABRP-17', 'logo_uri' => RP_URL . '/media/logo.png', 'redirect_uris' => array(RP_REDIRECT_URI, RP_AUTHCHECK_REDIRECT_URI), 'post_logout_redirect_uris' => array(RP_POST_LOGOUT_REDIRECT_URI), 'jwks_uri' => RP_JWK_URL, 'policy_uri' => RP_INDEX_PAGE . '/policy', 'grant_types' => array('authorization_code', 'implicit'), 'response_types' => array('code', 'token', 'id_token', 'code token', 'code id_token', 'id_token token', 'code id_token token')); $curl_options[CURLOPT_POSTFIELDS] = pretty_json(json_encode(array_merge($data, $options))); $curl_options[CURLOPT_HTTPHEADER] = array('Content-Type: application/json'); list($code, $data_content_type, $req_out, $response_headers, $data_responseText) = curl_fetch_url($url, $headers, $curl_options, $is_post); if ($code != 200) { $g_error .= "Unable to register client.\n{$req_out}\n{$response_headers}\n{$data_responseText}"; throw new Exception($g_error); } elseif (strpos($data_content_type, 'application/json') !== false) { $client_info = json_decode($data_responseText, true); if (!$client_info) { $g_error .= "Unable to register client.\n{$req_out}\n{$response_headers}\n{$data_responseText}"; throw new Exception($g_error); } return $client_info; } else { $g_error .= "Unable to register client.\n{$req_out}\n{$response_headers}\n{$data_responseText}"; throw new Exception($g_error); } } catch (Exception $e) { log_error("register_client exception : %s", $e->getMessage()); } return NULL; }
public function saveAliases() { $f = fopen("userdata/aliases.egg", "w"); fwrite($f, pretty_json(json_encode($this->aliases))); fclose($f); }
function handle_client_operations() { try { $token = $_REQUEST['access_token']; if (!$token) { $token = get_bearer_token(); if (!$token) { throw new BearerException('invalid_request', 'No Access Code'); } } $pos = strpos($_SERVER['PATH_INFO'], '/client/'); if ($pos === false) { throw new OidcException('invailid_request', 'Invalid path'); } $uri_path = substr($_SERVER['PATH_INFO'], $pos + 8); $db_client = db_get_client_by_registration_uri_path($uri_path); if (!$db_client) { throw new OidcException('invalid_request', 'Invalid client'); } if ($db_client['registration_access_token'] != $token) { throw new OidcException('invalid _request', 'Invalid registration token'); } $params = $db_client->toArray(); unset($params['id']); unset($params['registration_access_token']); unset($params['registration_client_uri_path']); unset($params['jwk_encryption_uri']); unset($params['x509_uri']); unset($params['x509_encryption_uri']); $array_params = array('contacts', 'redirect_uris', 'request_uris', 'post_logout_redirect_uris', 'response_types', 'grant_types', 'default_acr_values'); foreach ($params as $key => $value) { if ($value) { if (in_array($key, $array_params)) { $params[$key] = explode('|', $value); } } else { unset($params[$key]); } } if (!empty($params['jwks'])) { $params['jwks'] = json_decode($params['jwks'], true); } if ($params['require_auth_time']) { $params['require_auth_time'] = $params['require_auth_time'] == 1; } header("Cache-Control: no-store"); header("Pragma: no-cache"); header('Content-Type: application/json'); echo pretty_json(json_encode($params)); } catch (BearerException $e) { send_error(NULL, $e->error_code, $e->desc, NULL, true, '403'); } catch (OidcException $e) { send_error(NULL, $e->error_code, $e->desc, NULL, true, '403'); } }
public function get_data() { $page = intval($this->uri->segment(3)); $per_page = 10; $offset = $page == 0 ? $page : $page * $per_page - $per_page; $data = $this->db->select('o.id, b.id_marker, b.profile AS profile_bengkel, b.latlng AS latlng_bengkel, o.created, o.type, o.latlng AS latlng_order, o.status, o.detail_order,')->from('beo_order AS o')->join('beo_customer AS c', 'o.customer_id = c.id', 'left')->join('beo_bengkel AS b', 'o.bengkel_id = b.id', 'left')->where('o.customer_id', $this->customer_id)->order_by('o.created', 'desc')->limit($per_page, $offset)->get(); $total = $this->db->where('customer_id', $this->customer_id)->get('beo_order')->num_rows(); $status = array('waiting', 'process', 'confirm', 'cancel', 'done'); $result = array(); foreach ($data->result() as $v) { $profile_bengkel = json_decode($v->profile_bengkel); $latlng_bengkel = json_decode($v->latlng_bengkel); $latlng_order = json_decode($v->latlng_order); $detail_order = json_decode($v->detail_order); $result[] = array('id' => intval($v->id), 'logo_bengkel' => short_name($profile_bengkel->name), 'name_bengkel' => $profile_bengkel->name, 'date_order' => $v->created, 'status_order' => intval($v->status), 'status_order_text' => $status[$v->status], 'damage_order' => $detail_order->damage, 'detail_bengkel' => array('id_marker' => floatval($v->id_marker), 'company' => $profile_bengkel->company, 'contact' => $profile_bengkel->contact, 'email' => $profile_bengkel->email, 'location' => $profile_bengkel->location, 'price' => $profile_bengkel->price, 'lat' => $latlng_bengkel->lat, 'lng' => $latlng_bengkel->lng), 'detail_order' => array('detail_location' => $detail_order->detail_location, 'lat' => $latlng_order->lat, 'lng' => $latlng_order->lng, 'distance' => $detail_order->distance, 'total_price' => $detail_order->total_price)); } $output['ok'] = 1; $output['result'] = array('list' => $result, 'per_page' => $per_page, 'total_data' => $total, 'total_page' => ceil($total / $per_page)); pretty_json($output); }