function read_database($fname) { global $log; $log->lwrite("read_database:: " . $fname); $ret = file_get_contents($fname); if ($ret === false) { $log->lwrite("read_database:: ERROR read_database from file: " . $fname); return false; } else { $log->lwrite("read_database:: Success read_database"); } $cfg = json_clean_decode($ret, true); return $cfg; }
function send_request_to_host($cmd_array, $host_data) { $socket = getsock($host_data['address'], $host_data['port']); if ($socket != null) { $cmd = json_encode($cmd_array); socket_write($socket, $cmd, strlen($cmd)); $line = readsockline($socket); socket_close($socket); if (strlen($line) == 0) { return null; } $line = add_quotes_to_numbers($line); if (substr($line, 0, 1) == '{') { $data = json_clean_decode($line, true); } else { return null; } } else { return null; } return $data; }
function generate_pub($filetype, $filename, $formatfile, $prefix) { $entries = array(); $format = pub_format_parse_file($formatfile); $pub = new PubWriter($format, $filename); $entries = array(); $max_id = 0; foreach (glob($prefix . '*.json') as $jsonfile) { $entry = json_clean_decode(file_get_contents($jsonfile), true); if (!$entry) { throw new Exception("Bad JSON file: {$jsonfile}"); } $entries[$entry['id']] = $entry; $max_id = max($max_id, $entry['id']); } $pub->writeHeader(array('type' => $filetype, 'num' => $max_id + 1)); for ($i = 1; $i <= $max_id; ++$i) { // testing /* if ($filetype == 'ENF') { foreach (array('unknown1', 'unknown4') as $k) { if ($entries[$i][$k] != 0) { echo "$i (" . $entries[$i]['name'] . ") has $k = ", $entries[$i][$k], "\n"; } } } */ if (isset($entries[$i])) { $pub->writeEntry($entries[$i]); } else { echo "{$filetype} #{$i} unused.\n"; $pub->writeDummyEntry(); } } $pub->writeEOFEntry(); $rid = sprintf('%x', $pub->finish()); $kbsize = number_format(filesize($filename) / 1024, 1); echo "Wrote {$max_id}+1 entries to {$filename} ({$kbsize} kB). RID={$rid}\n"; if ($kbsize > 62.5) { echo "WARNING! {$filename} may be too large.\n"; } }
float: left; padding: 0 10px; } </style> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title">Editando Item</h3> </div> <div class="panel-body"> <?php include_once '_Functions.php'; $Lists_Fields = $SKTDB->get_row("SELECT * FROM lists_fields WHERE IDLists = " . GetSQLValueString($ListID, "int")); $lists_values = $SKTDB->get_row("SELECT * FROM lists_values WHERE ID = " . GetSQLValueString($ID, "int")); $Values = json_clean_decode($lists_values->Value, true); //echo "<pre>". var_dump($Values)."</pre>"; $rand = rand(2, 100000); ?> <form action="" method="post" name="Edit_Item_List" id="Edit_Item_List" style="margin-bottom: 100px;"> <input name="ID" id="ID" type="hidden" value="<?php echo $ID; ?> " /> <input name="IDLists" id="IDLists" type="hidden" value="<?php echo $ListID; ?> " /> <table width="100%" border="0" align="left" cellpadding="5" cellspacing="0" class="table table-striped"> <tr> <td align="right"><label><span>Publicación</span></label></td>