Example #1
0
 rndSleep($pauseMin, $pauseMax);
 $contentHTML = file_get_contents($item["pdalink"], false, $context);
 echo "\tDownload " . strlen($contentHTML) . " bytes\tFrom: " . $item["pdalink"] . "\tTo: " . $path;
 flush();
 if ($contentHTML) {
     file_put_contents($path, $contentHTML);
 } else {
     echo "ERROR! NULL content: " . $path;
 }
 // } // COMMENT THIS LINE!!! DO NOT check existing files because every day cinema schedule must be actual
 // Parse local HTML files for JSON
 $localContent = file_get_contents($path);
 preg_match('#\\<b\\>Описание\\:\\<\\/b\\>(.*)\\<form.method\\=\\"get\\"#sim', $localContent, $arrayTextLocalContent);
 $textContent = trim($arrayTextLocalContent[1]);
 $textContent = strip_tags($textContent, '<br><b></b><i></i><br /><br/>');
 $textContent = prepareJSON($textContent);
 preg_match('#\\<\\/tr\\>\\<\\/table\\>(.*?)<a href="(.*?)\\".style#sim', $localContent, $imgUrl);
 $imgTag = str_ireplace('/uploads', '<img src="http://www.moigorod.ru/uploads', $imgUrl[2]) . '" /><br />';
 preg_match('/src="([^"]*)"/', $imgTag, $matches);
 $imgUrl = $matches[1];
 preg_match('#\\<fieldset\\>\\<legend\\>(.*?)\\<div.class\\=\\"dsc\\"\\>#sim', $localContent, $todaySchedule);
 $todaySchedule = $todaySchedule[1];
 $todaySchedule = '<h3>' . str_ireplace('</legend>', '</h3>', $todaySchedule);
 $todaySchedule = trim($todaySchedule);
 $todaySchedule = strip_tags($todaySchedule, '<h3></h3><br><b></b><i></i><br /><br/>');
 $pubDate = date('d.m.Y', strtotime($item["pubDate"]));
 // Add data to array
 // "pubDate" => date('d.m.Y',strtotime($item["pubDate"])),
 // "description" => $desc,
 $arrayOut['cinema']['all']['posts'][] = array("id" => $filename, "title" => $item["title"], "link" => $item["link"], "pdalink" => $item["pdalink"], "description" => $item["description"], "pubDate" => $pubDate, "img" => $imgTag, "imgurl" => $imgUrl, "content" => $textContent . $todaySchedule);
 // "content"  => $textContent
Example #2
0
function decodeJSON($input, $replace)
{
    $ret = json_decode(prepareJSON($input, $replace), 1);
    return $ret;
}
Example #3
0
// load default settings from file
$defaultSettings = file_get_contents('defaultSettings.json');
if ($defaultSettings == false) {
    die("Cannot open default settings file: defaultSettings.json");
}
$settingsArray = json_decode(prepareJSON($defaultSettings), true);
if (is_null($settingsArray)) {
    die("Cannot decode defaultSettings.json");
}
// overwrite default settings with user settings
if (file_exists('userSettings.json')) {
    $userSettings = file_get_contents('userSettings.json');
    if ($userSettings == false) {
        die("Error opening settings file userSettings.json");
    }
    $userSettingsArray = json_decode(prepareJSON($userSettings), true);
    if (is_null($settingsArray)) {
        die("Cannot decode userSettings.json");
    }
    foreach ($userSettingsArray as $key => $value) {
        $settingsArray[$key] = $userSettingsArray[$key];
    }
}
$beerName = $settingsArray["beerName"];
$tempFormat = $settingsArray["tempFormat"];
$profileName = $settingsArray["profileName"];
$dateTimeFormat = $settingsArray["dateTimeFormat"];
$dateTimeFormatDisplay = $settingsArray["dateTimeFormatDisplay"];
function prepareJSON($input)
{
    //This will convert ASCII/ISO-8859-1 to UTF-8.
Example #4
0
}
$response = null;
if (is_array($data)) {
    $response = array();
    foreach ($data as $d) {
        $response[] = doRpc($d);
    }
} else {
    $response = doRpc($data);
}
if ($isForm && $isUpload) {
    echo '<html><body><textarea>';
    echo json_encode($response);
    echo '</textarea></body></html>';
} else {
    echo prepareJSON($response);
}
/*	Function to permit json encoding of javascript functions */
function prepareJSON($resp)
{
    $value_arr = array();
    $replace_keys = array();
    // replacing all values defined as js functions by trailing ___ with a random number
    recursiveReplace($value_arr, $replace_keys, $resp);
    // transforming the data into json
    $encoded_json = json_encode($resp);
    // replacing the random numbers with their corresponding values from the value_array
    $encoded_json = str_replace($replace_keys, $value_arr, $encoded_json);
    return $encoded_json;
}
function recursiveReplace(&$value_arr, &$replace_keys, &$resp)