utility_helper.php 1.38 KB
Newer Older
Vipo's avatar
Vipo committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
<?php defined('BASEPATH') OR exit('No direct script access allowed');

// ------------------------------------------------------------------------

if (!function_exists('image_base64_encode')) {
    function image_base64_encode($image)
    {
        $type = pathinfo($image, PATHINFO_EXTENSION);
        $data = file_get_contents($image);

        return 'data:image/' . $type . ';base64,' . base64_encode($data);
    }
}

// ------------------------------------------------------------------------

if (!function_exists('check_ci_version')) {
    function check_ci_version($url)
    {
        if(!$ci_version = file_get_contents($url)) {
            return false;
        }

        $ci_version = htmlentities($ci_version);

        preg_match("/CI_VERSION',\s'(.*)'\)/", $ci_version, $matches);

        if(count($matches) && version_compare($matches[1], CI_VERSION, '>')) {
            return $matches[1];
        }

        return FALSE;
    }
}

// ------------------------------------------------------------------------

if (!function_exists('check_develbar_version')) {
    function check_develbar_version($url)
    {
        if(!$develbar = file_get_contents($url))
            return FALSE;

        $develbar = json_decode($develbar, TRUE);

        if(version_compare($develbar['version'], DevelBar::VERSION, '>')) {
            return $develbar['version'];
        }

        return FALSE;
    }
}