xxxxxxxxxx
def get_area_test():
list_data = [
{
'area_id': 1,
'area_name': 'Bioquimica',
'test_id': 2,
'test_name': 'Glucosa'
},
{
'area_id': 1,
'area_name': 'Bioquimica',
'test_id': 3,
'test_name': 'Leucositos'
},
{
'area_id': 1,
'area_name': 'Bioquimica',
'test_id': 4,
'test_name': 'Linfocitos'
},
{
'area_id': 2,
'area_name': 'Perfil Hepatico',
'test_id': 3,
'test_name': 'Hemograma'
}
] # data de la BD
array_test = []
array_area_tmp = []
array_area_tmp1 = {} # {1: [], } map key, valor
for item in list_data:
print(item)
if item['area_id'] not in array_area_tmp:
array_area_tmp.append(item['area_id'])
array_test.append({
'area_id': item['area_id'],
'name': item['area_name'],
'array_test': []
})
array_area_tmp1[item['area_id']] = [] # map key, valor
array_area_tmp1[item['area_id']].append({
'test_id': item['test_id'],
'name': item['test_name']
})
for item in array_test:
item['array_test'] = array_area_tmp1[item['area_id']]
print('array_test', array_test)
xxxxxxxxxx
?php
// CURL http get request
function curl_http_get ($url, $headers = []) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
return json_decode($output, true);
}
xxxxxxxxxx
?php
// Get Username and Password for mac-address
function getUserPassForMac($mac, $base_url) {
// URL Encode MAC for processing
$mac_address = urlencode($mac);
// URL's
$token_url = '/portal.php?action=handshake&type=stb&token=';
$profile_url = '/portal.php?type=stb&action=get_profile';
$list_url = '/portal.php?action=get_ordered_list&type=vod&p=1&JsHttpRequest=1-xml';
// Get token from server
$first_token = curl_http_get($base_url . $token_url)['js']['token'];
$res = explode('/', $result['js']['cmd']);
if (count($res) < 6) {
return false;
}
return [
'username' => $res[4],
'password' => $res[5]
];
}
xxxxxxxxxx
?php
// CURL http get request
function curl_http_get ($url, $headers = []) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec($ch);
curl_close($ch);
return json_decode($output, true);
}
xxxxxxxxxx
public static string DoEncrypt(string unencryptedString)
{
string encryptedString = "";
unencryptedString = new string(unencryptedString.ToCharArray().Reverse().ToArray());
foreach (char character in unencryptedString.ToCharArray())
{
string randomizationSeed = (encryptedString.Length > 0) ? unencryptedString.Substring(0, encryptedString.Length) : "";
encryptedString += GetRandomSubstitutionArray(randomizationSeed)[int.Parse(character.ToString())];
}
return Shuffle(encryptedString);
}
public static string DoDecrypt(string encryptedString)
{
// Unshuffle the string first to make processing easier.
encryptedString = Unshuffle(encryptedString);
string unencryptedString = "";
foreach (char character in encryptedString.ToCharArray().ToArray())
unencryptedString += GetRandomSubstitutionArray(unencryptedString).IndexOf(int.Parse(character.ToString()));
// Reverse string since encrypted string was reversed while processing.
return new string(unencryptedString.ToCharArray().Reverse().ToArray());
xxxxxxxxxx
print(30*"-")
print("asp191.py version 1.000630")
print("Written by ")
print(30*"-")
print(" error.")
print(30*"-")
print("You should use this app only one time.")
print("Following file will be changed:")
xxxxxxxxxx
foreach($data as $key => &$value)
{
$output[$value["id"]] = &$value;
$output[$value["id"]];
}