Example #1
1
 echo "<div class=\"panel\" id=\"categories\">";
 echo "<a href=\"#\" class=\"list-group-item active\"><b>Categories items</b></a>";
 foreach ($categories as $category) {
     if (!empty($category)) {
         $category_id = $category['id'];
         echo "<a href=\"#\" id=\"{$category_id}\" class=\"list-group-item main\">";
         echo "<span class=\"badge\">";
         echo "<span class=\"countunread\">{$category['count_unread']}</span>";
         echo "<span class=\"countdivider\"> / </span>";
         echo "<span class=\"countall\">{$category['count_all']}</span>";
         echo "</span>";
         echo "<span id=\"title-bar\"><span class=\"glyphicon glyphicon-chevron-right\"></span><span id=\"title-name\">" . substr($category['category_name'], 0, 16) . "</span></span>";
         echo "</a>";
         // Get count-per-category using json
         $query = "{\"jsonrpc\": \"2.0\", \"request\": \"feeds-per-category-id\", \"value\": \"{$category_id}\"}";
         $feeds = get_json($query);
         if (!empty($feeds)) {
             echo "<div class=\"menu-sub\" id='{$category_id}'>";
             foreach ($feeds as $feed) {
                 if (empty($feed['count'])) {
                     $feed['count'] = "0";
                 }
                 $feed_id = $feed['id'];
                 //set favicon url
                 if (empty($feed['favicon'])) {
                     $faviconurl = "img/rss-default.gif";
                 } else {
                     $faviconurl = $feed['favicon'];
                 }
                 //show feed details
                 echo "<a href=\"#\" id=\"{$feed_id}\" class=\"list-group-item sub\">";
function lms_list_course()
{
    global $apiurl;
    $response = get_json($apiurl . "/accounts/1/courses");
    //print_r($response);
    return $response;
}
Example #3
0
 function login($as_guest = '')
 {
     # code...
     $this->load->library('guest');
     $this->_go_to_dashboard();
     $this->username_email = $this->input->post('username_email');
     $this->password = $this->input->post('password');
     if ($as_guest == 'as_guest') {
         $this->username_email = 'guest';
         $this->password = '******';
     }
     if ($this->login->login($this->username_email, $this->password)) {
         if ($this->input->post('ajax')) {
             $data['json'] = get_json('good_username_email_or_password');
             $this->load->view('json', $data);
         } else {
             redirect('books');
         }
     } else {
         if ($this->input->post('ajax')) {
             $data['json'] = get_json('error_username_email_or_password');
             $this->load->view('json', $data);
         } else {
             $this->index('error_username_email_or_password');
         }
     }
 }
Example #4
0
 function json_encode($var, $loose = FALSE)
 {
     $json = get_json();
     if ($loose) {
         $json->use = SERVICES_JSON_LOOSE_TYPE;
     } else {
         $json->use = 0;
     }
     return $json->encode($var);
 }
Example #5
0
function display_works($file_loc)
{
    $file_list = glob($file_loc . '/*.json');
    rsort($file_list);
    $current_year = "";
    foreach ($file_list as $file) {
        $work = get_json($file);
        if ($work) {
            // skip if error, won't break page
            $file_date = basename($file, '.json');
            // get filename without extension
            $file_date = substr($file_date, 0, 4);
            // keep date
            if ($file_date != $current_year) {
                echo '<div class="row piece">';
            } else {
                echo '<div class="row piece sameyear">';
            }
            echo '<div class="1u 2u(3)">' . $file_date . '</div>';
            echo '<div class="3u 5u(3) title">' . $work['title'] . '</div>';
            echo '<div class="3u 5u(3)">' . $work['instrumentation']['short'] . '</div>';
            // '<span id="full-inst" style="display: initial; min-height:0;">' . $work['instrumentation']['long'] . '</span>';
            echo '<div class="2u not-small">';
            if ($work['duration']['minutes']) {
                echo $work['duration']['minutes'] . '&prime;';
            }
            if ($work['duration']['seconds']) {
                echo $work['duration']['seconds'] . '&Prime;';
            }
            echo '&#8203;';
            echo '</div>';
            echo '<div class="1u not-small comp-link">';
            if ($work['links']['audio']) {
                echo '<a href="' . $work['links']['audio'] . '"><i class="fa fa-volume-up"></i></a>';
            }
            echo '</div>';
            echo '<div class="1u not-small comp-link">';
            if ($work['links']['video']) {
                echo '<a href="' . $work['links']['video'] . '"><i class="fa fa-youtube-play"></i></a>';
            }
            echo '</div>';
            // echo '<div class="1u 2u(3) not-small">' ;
            // 	if($work['links']['score']){echo '<a href="' . $work['links']['score'] . '">score</a>';}
            // echo '</div>';
            // echo '<div class="1u 2u(3) not-small">' .
            // 	'<a href="#">listen</a>' .
            // '</div>';
            echo '</div>';
            $current_year = $file_date;
        }
    }
}
Example #6
0
/**
 * 更新用户信息
 */
function update_profile()
{
    $userId = $_SESSION['userId'];
    $oldPassword = is_empty($_REQUEST['oldPassword']) ? null : $_REQUEST['oldPassword'];
    $password = is_empty($_REQUEST['password']) ? null : $_REQUEST['password'];
    $password2 = is_empty($_REQUEST['password2']) ? null : $_REQUEST['password2'];
    $code = '0';
    if ($_SESSION['userDetail']['user_password'] != md5($oldPassword)) {
        $code = 'wrongOldPassword';
    } else {
        $userService = new UserService();
        $userService->updatePassword($userId, md5($password));
    }
    $output = array('retCode' => $code);
    echo get_json($output);
}
Example #7
0
function fill_content()
{
    $json = get_json();
    $gallery = [];
    $newwork = [];
    foreach ($json->pieces as $piece) {
        $new = $piece->new;
        if ($new) {
            array_push($newwork, $piece);
        } else {
            array_push($gallery, $piece);
        }
    }
    //add functions for new and gallery
    fill_new($newwork);
    fill_gallery($gallery);
}
Example #8
0
/**
 * function get_conversation()
 * This function gets the conversation format
 * @param  array $convoArr - the conversation array
 * @return array $convoArr
**/
function get_conversation($convoArr)
{
    $conversation = get_conversation_to_display($convoArr);
    runDebug(__FILE__, __FUNCTION__, __LINE__, "Processing conversation as " . $convoArr['conversation']['format'], 4);
    switch ($convoArr['conversation']['format']) {
        case "html":
            $convoArr = get_html($convoArr, $conversation);
            break;
        case "json":
            $convoArr = get_json($convoArr, $conversation);
            break;
        case "xml":
            $convoArr = get_xml($convoArr, $conversation);
            break;
    }
    return $convoArr;
}
Example #9
0
function display_home($file_list)
{
    // $current_year = "";
    foreach ($file_list as $file) {
        $perf = get_json($file);
        if ($perf) {
            // skip if error, won't break page
            $end = $perf['endDate'];
            list($date, $date_year) = extract_date($file, $end);
            // if ($date_year != $current_year) { echo "<h3>" . $date_year . "</h3>"; }
            // $current_year = $date_year;
            // if($display == 'full') {
            home_json_perf($date, $perf);
            //}
            // elseif($display == 'short') {
            // short_json_perf($date, $perf); }
        }
    }
}
Example #10
0
 /**
  * Reorder roles
  * 
  * @return string json encoded object
  */
 public function moveRole()
 {
     if ($this->input) {
         $roles = get_json('items');
         foreach ($roles as $key => $role_arr) {
             $role = $this->model->find($role_arr['id']);
             if (!\Access::isSystemRole($role->name)) {
                 if (array_key_exists($key - 1, $roles)) {
                     $prev_role = $this->model->find($roles[$key - 1]['id']);
                     $role->level = $prev_role->level - 1;
                     if ($role->level <= 0) {
                         $role->level = 0;
                     }
                     $role->save();
                     $this->events->fire('role.move', array($role));
                 }
             }
         }
         return $this->setSuccess('alert.success.order_saved');
     }
 }
Example #11
0
        }
    }
    return $result;
}
function get_json($date)
{
    $file_day = "../OK/" . $date . "/config.txt";
    if (file_exists($file_day)) {
        return json_decode(file_get_contents($file_day));
    } else {
        return null;
    }
}
setlocale(LC_TIME, 'fr_FR.utf8', 'fra');
get_date($date, $day, $month, $year);
$jsonDay = get_json($date);
$podcasts = load_podcasts($jsonDay, $date);
$ecoutes = load_ecoutes($date);
?>
<title>Administration Podcast Radio Campus Clermont-Ferrand</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<link rel="stylesheet" href="css/circle.player.css">
<link rel="stylesheet" href="css/admin.css?date=<?php 
echo filemtime('css/admin.css');
?>
">
<!-- link rel="stylesheet" href="css/ui-lightness/jquery-ui-1.10.4.custom.min.css" -->
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css">
<script type="text/javascript" src="js/jquery-1.10.2.js"></script>
<script type="text/javascript" src="js/jquery.jplayer.min.js"></script>
<script type="text/javascript" src="js/jquery.transform2d.js"></script>
Example #12
0
File: ad.php Project: caina/pando
 function api_get_versao()
 {
     $this->load->model("../libraries/anuncios/model/ad_version_model", 'version_model');
     $model = $this->input->post('model_id', TRUE);
     $year = $this->input->post('year', TRUE);
     $year_id = $this->input->post('year_id', TRUE);
     $versions = get_json("http://www.webmotors.com.br/carro/versoes", array("modelo" => $model, "ano" => $year));
     $this->version_model->populate($versions, $year_id);
     $this->output->set_content_type('application/json', 'utf-8')->set_output(json_encode($this->version_model->listing($year_id)));
 }
Example #13
0
<?php

session_start();
error_reporting(E_ALL);
require_once 'api.php';
$region = 'na';
$file = "na.json";
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
    if (isset($_REQUEST['q']) && !isset($_REQUEST['w'])) {
        $matchId = $_REQUEST['q'];
        get_json($matchId, $region);
    } else {
        if (isset($_REQUEST['w']) && !isset($_REQUEST['q'])) {
            if ($_REQUEST[w]) {
                $fp = fopen($file, 'w+');
                /*parse to json again for printing*/
                $champs = json_encode($_SESSION['champs']);
                fwrite($fp, $champs);
                fclose($fp);
            }
        }
    }
}
/* get the json data returned and start messing with it*/
function get_json($id, $region)
{
    global $apikey;
    $url = 'https://' . $region . '.api.pvp.net/api/lol/' . $region . '/v2.2/match/' . $id . '?api_key=' . $apikey;
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
Example #14
0
/**
 * 删除账目
 */
function delete_bill()
{
    $billTypeFlag = (int) $_REQUEST['billTypeFlag'];
    $billId = (int) $_REQUEST['billId'];
    $code = '0';
    $billService = new BillService();
    switch ($billTypeFlag) {
        case 0:
        case 1:
            $billService->deleteNormalBill($billId, $billTypeFlag);
            break;
        case 2:
        case 3:
            $billService->deleteTransferBill($billId, $billTypeFlag);
            break;
        case 5:
        case 6:
            $billService->deleteDebtBill($billId, $billTypeFlag);
            break;
        case 4:
        case 7:
            $billService->deleteRepayBill($billId, $billTypeFlag);
            break;
    }
    $output = array('retCode' => $code);
    echo get_json($output);
}
Example #15
0
function load_podcasts(&$ecoutes)
{
    $jsons = array();
    foreach ($ecoutes as $when => $ecoute) {
        $datetime = explode(" ", $when);
        $hour = $datetime[1];
        $date = $datetime[0];
        $hour = explode(":", $hour);
        $hour = $hour[0];
        // on charge d'abord le json si nécessaire
        if (!isset($jsons[$date])) {
            $jsons[$date] = get_json($date);
        }
        $ecoutes[$when]["title"] = "Titre non défini";
        if (isset($jsons[$date])) {
            foreach ($jsons[$date]->track as $entry) {
                // puis on remplis le titre s'il existe
                if ($entry->time == $hour) {
                    $ecoutes[$when]["title"] = $entry->title;
                    break;
                }
            }
        }
    }
}
Example #16
0
function toPaulo()
{
    $resultat = array();
    $date = $_GET['d'];
    $time = "" . $_GET['t'];
    if (strlen($time) == 1) {
        $time = "0" . $_GET['t'];
    }
    $jsonDay = get_json($date);
    if (!$jsonDay) {
        $resultat["error"] = "Impossible de trouver l'entrée correspondante";
    }
    $jsonNewDay->track = array();
    if ($jsonDay->track) {
        foreach ($jsonDay->track as $track) {
            if (intval($track->time) != intval($time)) {
                $jsonNewDay->track[] = $track;
            }
        }
    }
    $fileOK = get_filename($date, $time, true);
    $fileKO = get_filename($date, $time, false);
    if (file_exists($fileOK)) {
        $valid = @rename($fileOK, $fileKO);
        if (!$valid) {
            $resultat["error"] = "Impossible de deplacer le fichier";
            return $resultat;
        }
    }
    save_json($date, $jsonNewDay);
    $resultat["action"] = "2paulo";
    return $resultat;
}
Example #17
0
     }
 } else {
     if ($_SERVER['REQUEST_METHOD'] == 'PUT') {
         if (ENABLE_REGISTER) {
             $db = new WeaveStorage(null);
             //Requests that an account be created for username.
             /*
             The JSON payload should include
             Field   Description
             password    The password to be associated with the account.
             email   Email address associated with the account
             captcha-challenge   The challenge string from the captcha (see miscellaneous functions below)
             captcha-response    The response to the captcha. Only required if WEAVE_REGISTER_USE_CAPTCHA is set 
             */
             log_error("PUT");
             $data = get_json();
             log_error(print_r($data, true));
             //werte vorhanden
             if ($data == NULL) {
                 report_problem(WEAVE_ERROR_JSON_PARSE, 400);
             }
             $name = $username;
             $pwd = fix_utf8_encoding($data['password']);
             $email = $data['email'];
             if ($email == '') {
                 log_error('create user datenfehler');
                 report_problem(WEAVE_ERROR_NO_EMAIL, 400);
             } else {
                 if ($pwd == '') {
                     log_error('create user datenfehler');
                     report_problem(WEAVE_ERROR_MISSING_PASSWORD, 400);
Example #18
0
<!doctype html>
<head>
  <title>JSON</title>
</head>
<?php 
// Functie om de JSON-array of -hash uit een bestand
// te halen met bestandsnaam $filename
function get_json($filename)
{
    // return:                       Stuurt iets terug in een functie.
    // json_decode(x, true):         Zet de String x om in een JSON-array of -hash.
    // file_get_contents(x):         Lees het bestand x en geef de inhoud.
    return json_decode(file_get_contents($filename), true);
}
// Krijg de hash uit "json.json"
$json = get_json("json.json");
// Sla de personen op in een variabele
$personen = $json['personen'];
// Dit kan je met een foreach() constructie doen, maar dit is even makkelijker
$charlie = $personen[0];
$marten = $personen[1];
// ### Charlie ### //
// Output de naam en leeftijd.
echo "<h1>Charlie</h1>";
echo "Naam: " . $charlie['naam'] . ' ' . $charlie['achternaam'] . "<br>";
echo "Leeftijd: " . $charlie['leeftijd'] . "<br>";
// Sla de hobby's op in een variable
$charlieshobbys = $charlie['hobbys'];
echo "Hobby's:";
echo "<ul>";
// Voor elke $hobby in $hobbys
Example #19
0
        text-align: center;
      }
    </style>
  </head>
  <body>
    <div class="iets">
    <?php 
function get_json($filename)
{
    // return               - stuurt de nieuwe waarde van de functie terug.
    // json_decode(x, true) - Zet de String x om in een JSON-array of -hash.
    // file_get_contents(x) - Lees het bestand x en geef de inhoud.
    return json_decode(file_get_contents($filename), true);
}
//later in je php bestand kun je deze functie oproepen
$json = get_json('voorbeeld.json');
//roept de functie op met je filename als parameter
//de data van je json betand zit nu in de variabele json
//haalt de array uit het .json bestand en stopt het in het variabele teksten
$teksten = $json['teksten'];
//stopt de informatie over de eerste tekst in een variabele en de andere in een ander variabele
$tekst1 = $teksten[0];
$tekst2 = $teksten[1];
// ### Tekst 1 ### //
//output de tekst en de titel
echo "<h1>" . $tekst1['titel'] . "</h1>";
echo "<p>" . $tekst1['tekst'] . "</p>";
// ### Tekst 2 ### //
//output de tekst en de titel
echo "<h1>" . $tekst2['titel'] . "</h1>";
echo "<p>" . $tekst2['tekst'] . "</p>";
Example #20
0
 function get_thumbnail($url)
 {
     $this->load->library('upload');
     $url_original = $url;
     if (parse_url($url)) {
         $url = $this->addhttp($url);
         $url = parse_url($url);
         switch ($url['host']) {
             case 'www.youtube.com':
                 parse_str($url['query'], $data);
                 $video = $data['v'];
                 $video_data = get_json("https://www.googleapis.com/youtube/v3/videos?id={$video}&part=snippet&key=AIzaSyBRa_48GW6LpDcB8VlQxrt5alf-4-GTThQ");
                 $thumbnail = $video_data->items[0]->snippet->thumbnails->high->url;
                 break;
             case 'youtu.be':
                 $video = str_replace('/', '', $url['path']);
                 $json = get_json("https://www.googleapis.com/youtube/v3/videos?id={$video}&part=snippet&key=AIzaSyBRa_48GW6LpDcB8VlQxrt5alf-4-GTThQ");
                 $video_data = json_decode($json);
                 $thumbnail = $video_data->items[0]->snippet->thumbnails->high->url;
                 break;
             case 'www.dailymotion.com':
                 $path = explode('/', $url['path']);
                 $video = $path[2];
                 $thumbnail = "http://www.dailymotion.com/thumbnail/video/{$video}";
                 break;
             case 'vimeo.com':
                 $path = explode('/', $url['path']);
                 $video = end($path);
                 $hash = unserialize(file_get_contents("http://vimeo.com/api/v2/video/{$video}.php"));
                 $thumbnail = $hash[0]['thumbnail_large'];
                 break;
             case 'www.mmpro.de':
                 $this->load->library('simple_html_dom');
                 $html = file_get_html($url_original);
                 foreach ($html->find('link[rel=canonical]') as $element) {
                     $canonical_url = $element->href;
                 }
                 $canonical_url = $this->addhttp($canonical_url);
                 $canonical_url = parse_url($canonical_url);
                 parse_str($canonical_url['query'], $data);
                 $video_id = $data['videoId'];
                 $json_output = get_json("http://www.mmpro.de/cache/videolist.json", true);
                 foreach ($json_output as $object) {
                     foreach ($object as $video) {
                         $video_to_display = $video;
                         foreach ($video["video"] as $video_data) {
                             $video_uri = $video_data['uri'];
                             if ($video_data['uri'] == $video_id) {
                                 break 3;
                             }
                         }
                     }
                 }
                 if (isset($video_to_display['mcf'])) {
                     $thumbnail = "http://www.mcfootage.com/imagereplace.php?width=900&height=600&kunde=archive&file=" . $video_to_display['picture'];
                 } else {
                     $json_output = get_json("http://www.admiralcloud.com/player/json/" . $video_uri);
                     $thumbnail = $json_output->movies[0]->jpg;
                 }
                 break;
             case 'www.tvbvideo.de':
                 $CI =& get_instance();
                 $CI->load->library('simple_html_dom');
                 $html = file_get_html($url_original);
                 $r = html_entity_decode($html->find('#export_website_code', 0)->innertext());
                 $r_html = str_get_html($r);
                 preg_match('(http://api.kewego.com/video/getHTML5Thumbnail.+\\"\\))', $r_html, $thumbnail);
                 $thumbnail = substr($thumbnail[0], 0, -2);
                 $thumbnail = $this->get_final_url($thumbnail);
                 break;
             default:
                 echo "Je ne connais pas ce site web... Veuillez vérifier le lien.";
                 break;
         }
         if (isset($thumbnail) && $thumbnail != "assets/img/nopic.jpg") {
             //UPLOAD THUMBNAILS
             $filename = 'import_' . slug($_POST['title']) . '.jpg';
             grab_image($thumbnail, $this->photos_path . $filename);
             $data['filename'] = $filename;
             if (autoCrop($data)) {
                 create_thumbnail($data);
                 create_header($data);
                 unlink($this->photos_path . $filename);
             }
             return $filename;
         } else {
             if ($thumbnail == "assets/img/nopic.jpg") {
                 return "nopic.jpg";
             } else {
                 return false;
             }
         }
     } else {
         return false;
     }
 }
Example #21
0
<?php

//This script retrieves the values from Cosm with the help of PachubeAPI and cosm_id_and_values_f.php.
//Former ist from https://github.com/cosm/cosm-js, the latter contains self-defined functions.
//functions from Cosm
include 'PachubeAPI.php';
//self-defined functions to get the values
include 'cosm_id_und_werte_f.php';
$pachube = new PachubeAPI("QgvMiPLj6wDkY3k2JSPpD3-rMAuSAKxLbVlLMVhxTURMOD0g");
//$alle contains all meta-information about all feeds with the tag 'munster' (ID,Title, see http://cosm.com/docs/v2/feed/list.html for further information) .
$alle = $pachube->getFeedsList("json", 0, 100000, "summary", "munster", "munster");
//array: contains all IDs with the tag 'munster'.
$ids = get_ids($alle);
//echo count($ids);
//array: contains the values for every ID in JSON format.
$json = get_json($ids);
//The following two arrays contain the coordinates. The values below are self-explaining.
$lat = get_lat($json);
$lon = get_lon($json);
$timestamp = get_timestamp($json);
$NO2 = get_NO2($json);
$CO = get_CO($json);
$O3 = get_O3($json);
$names = get_Name($json);
/*
for($i=0;$i<count($ids);$i++){
echo $ids[$i]."</br>";
echo $temperature[$i]."T"."</br>";
echo $humidity[$i]."H"."</br>";
}
for($i=0;$i<count($ids);$i++){
Example #22
0
function get_status()
{
    return get_json("STATUS\n");
}
Example #23
0
     $wbo->modified($server_time);
     #current microtime
     if ($wbo->validate()) {
         #if there's no payload (as opposed to blank), then update the metadata
         if ($wbo->payload_exists()) {
             $db->store_object($wbo);
         } else {
             $db->update_object($wbo);
         }
     } else {
         report_problem(WEAVE_ERROR_INVALID_WBO, 400);
     }
     echo json_encode($server_time);
 } else {
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $json = get_json();
         check_quota($db);
         check_timestamp($collection, $db);
         $success_ids = array();
         $failed_ids = array();
         $db->begin_transaction();
         foreach ($json as $wbo_data) {
             $wbo = new wbo();
             if (!$wbo->extract_json($wbo_data)) {
                 $failed_ids[$wbo->id()] = $wbo->get_error();
                 continue;
             }
             $wbo->collection($collection);
             $wbo->modified($server_time);
             if ($wbo->validate()) {
                 #if there's no payload (as opposed to blank), then update the metadata
Example #24
0
        curl_close($curl);
        return $content;
    }
    $github_latest = json_decode(get_json('https://api.github.com/repos/kyufox/manga/releases/latest'), true);
    $current_version = 'none';
    if (isset($github_latest['tag_name'])) {
        $latest_version = $github_latest['tag_name'];
    } else {
        $latest_version = 'none';
    }
    if ($latest_version != 'none' && $latest_version > $current_version) {
        $new_version = true;
    } else {
        $new_version = false;
    }
    $github_commit = json_decode(get_json('https://api.github.com/repos/kyufox/manga/commits'), true);
    ?>
      <div class="row">

        <div class="box col-12">
          <div class="breadcrumbs">
            <ol>
              <li><a href="admin">Admin Panel</a></li>
              <li class="active">Version Info</li>
            </ol>
          </div>
        </div>

        <?php 
    if ($new_version == true) {
        ?>
Example #25
0
 $count = 1;
 if ($key == 'report') {
     debugger("Value : " . print_r($value, TRUE));
     debugger("Got report URL : " . $value['@reportUri']);
     echo "NOTE: " . date("Y-m-d H:i:s") . ": Got report to process for {$start_date} to {$end_date}. Waiting...\n";
     sleep(300);
     $report = get_json($value['@reportUri']);
     $count = 1;
     $rc = FALSE;
     while ($rc == FALSE) {
         while ($report['@reportReady'] == "false" && $count <= 100) {
             //Wait 60 seconds
             debugger("Report Not Ready : Waiting 5 mins. Count is {$count}.");
             echo "NOTE: " . date("Y-m-d H:i:s") . ": Report Not Ready for {$start_date} to {$end_date}. Waiting 5 mins... Count is : {$count}.\n";
             sleep(300);
             $report = get_json($value['@reportUri']);
             $count++;
         }
         $file = get_file($value['@reportUri'], $report_file);
         echo "NOTE: " . date("Y-m-d H:i:s") . ": File {$file} parsing started for {$start_date} to {$end_date}.\n";
         if (!array_key_exists('x', $options)) {
             $fhs = fopen($output_file_sessions, 'w') or die("ERROR: Could not open session output file.\n");
             $fhe = fopen($output_file_events, 'w') or die("ERROR: Could not open events output file.\n");
             $rc = parse_file($file, $row['game_id'], $row['device_id'], $options);
             fclose($fhs);
             fclose($fhe);
             echo "NOTE: " . date("Y-m-d H:i:s") . ": File {$file} parsing complete for {$start_date} to {$end_date}.\n";
         } else {
             echo "NOTE: " . date("Y-m-d H:i:s") . ": File {$file} was not parsed for {$start_date} to {$end_date}.\n";
             $rc = TRUE;
         }
Example #26
0
function getEmissions($date)
{
    $podcasts = get_json($date->format("Y-m-d"));
    if (!isset($podcasts) || count($podcasts->track) == 0) {
        return $podcasts;
    }
    foreach ($podcasts->track as $key => $podcast) {
        if (strlen($podcast->mp3) == 0) {
            unset($podcasts->track[$key]);
        }
    }
    return $podcasts;
}
Example #27
0
function get_json($url)
{
    $base = "https://api.github.com/";
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
    curl_setopt($curl, CURLOPT_URL, $base . $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    $content = curl_exec($curl);
    curl_close($curl);
    return $content;
}
$feed = "repos/processing/processing/commits";
$cache_file = dirname(__FILE__) . '/cache/' . 'github-cache';
$modified = filemtime($cache_file);
$now = time();
$interval = 600;
// ten minutes
if (!$modified || $now - $modified > $interval) {
    $json = get_json($feed);
    if ($json) {
        $cache_static = fopen($cache_file, 'w');
        fwrite($cache_static, $json);
        fclose($cache_static);
    }
}
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json');
$json = file_get_contents($cache_file);
echo $json;
Example #28
0
    <?php 
include 'nav.php';
//includes the navigation bar; for easy modifications
?>

    <?php 
// ### Gekopieerd uit template ### //
//Functie om de data uit je .json te halen
//Parameter van je fucnite is de naam van je .json bestand
function get_json($filename)
{
    //return                - stuurt de nieuwe waarde van de functie terug.
    // json_decode(x, true) - Zet de String x om in een JSON-array of -hash.
    // file_get_contents(x) - Lees het bestand x en geef de inhoud.
    return json_decode(file_get_contents($filename), true);
}
//later in je php bestand kun je deze functie oproepen
$json = get_json('links.json');
//roept de functie op met je filename als parameter
//de data van je json betand zit nu in de variabele json
$paginas = $json['paginas'];
$link1 = $paginas[0];
$link2 = $paginas[1];
echo $link2['link'];
?>


  </body>
</html>
Example #29
0
function get_reports(&$reports, &$files)
{
    global $start_date;
    global $end_date;
    note("Starting file requests.");
    // Work through reports until we have pulled all of them
    foreach ($reports as $index => $report) {
        $json = get_json($report['request']['@reportUri']);
        if ($json['@reportReady'] != "false") {
            //Set report file name
            $report_file = "{$REPORT}/" . "report_" . $report['ref_name'] . "_" . $end_date . ".gz";
            // Get the report
            $file = get_file($report['request']['@reportUri'], $report_file);
            note("Got file {$file} for Game: " . $report['game_id'] . ", Client: " . $report['client_id']);
            // Are we writing this to a CSV?
            if (!array_key_exists('x', $options)) {
                // Write to a CSV file - split sessions and events
                $output_file_sessions = "{$CSV}/" . $report['ref_name'] . "_" . $end_date . '_sessions.csv';
                $output_file_events = "{$CSV}/" . $report['ref_name'] . "_" . $end_date . '_events.csv';
                $fhs = fopen($output_file_sessions, 'w') or die("ERROR: Could not open session output file.\n");
                $fhe = fopen($output_file_events, 'w') or die("ERROR: Could not open events output file.\n");
                note("File {$file} parsing started for Game: " . $report['game_id'] . ", Client: " . $report['client_id'] . " from {$start_date} to {$end_date}.");
                $rc = parse_file($file, $report['game_id'], $report['client_id'], $options);
                // Remove this entry
                if ($rc != FALSE) {
                    note("File {$file} parsing complete for Game: " . $report['game_id'] . ", Client: " . $report['client_id'] . " from {$start_date} to {$end_date}.");
                    $files[] = array('game_id' => $report['game_id'], 'client_id' => $report['client_id'], 'file' => $file);
                    unset($reports[$index]);
                }
                fclose($fhs);
                fclose($fhe);
            } else {
                note("File {$file} was not parsed for Game: " . $report['game_id'] . ", Client: " . $report['client_id'] . " from {$start_date} to {$end_date}.");
                unset($reports[$index]);
            }
        } else {
            note("File not ready for Game: " . $report['game_id'] . ", Client: " . $report['client_id'] . " from {$start_date} to {$end_date}.");
        }
    }
}
Example #30
-1
function get_commit($type)
{
    return json_decode(get_json("repos/BlueVM/Neon/commits/{$type}"), true);
}