Skip to content
functions.php 1.1 KiB
Newer Older
klimplant's avatar
klimplant committed
<?php

function getDirFile($dirFile) {
klimplant's avatar
klimplant committed
    if (debug) {
        var_dump($dirFile);
    }
klimplant's avatar
klimplant committed
    switch ($dirFile['srcType']) {
        case 'url':
            $curl = curl_init($dirFile['src']);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
            $content = curl_exec($curl);
            curl_close($curl);
            break;
        case 'path': 
            if (!file_exists($dirFile['src'])) {
                return false;
            }
            $content = file_get_contents($dirFile['src']);
            break;
        default:
            return false;
            break;
klimplant's avatar
klimplant committed
    }
klimplant's avatar
klimplant committed
    $content = json_decode($content, true);
klimplant's avatar
klimplant committed
    if (debug) {
        var_dump($content);
klimplant's avatar
klimplant committed
    }
klimplant's avatar
klimplant committed
    return $content;
}
klimplant's avatar
klimplant committed

function getHostInformation($librehostJsonUrl) {
    $hostInformaton = getHostJson($librehostJsonUrl);
    return $hostInformaton;
}

function getHostJson($librehostJsonUrl) {
    $curl = curl_init($librehostJsonUrl);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($curl);
    curl_close($curl);
    $response = json_decode($response, true);
    return $response;
}