<?php

class Backend_model extends CI_Model {

    var $thisUser = 'oameye';
    var $USER = '';
    var $jubabox;

    function __construct() {

        $this->USER = $_SERVER['SCRIPT_FILENAME'];
        $this->USER = str_replace('/home', '', $this->USER);
        $this->USER = strtok($this->USER, '/');
        if ($this->USER == 'opt') {
            $this->USER = 'root';
        }
        $this->thisUser = $this->USER;
    }

    public function jubabox_api($in, $out = array()) {
        $this->jubabox_load();
        $ret = $this->jubabox->jubabox_api($in, $out);
        return $ret;
    }

    public function cfgReadChar($str) {
        $this->jubabox_load();
        $ret = $this->jubabox->cfgReadChar($str);
        return $ret;
    }

    private function jubabox_load() {
        // $this->$USER = $_SERVER['SCRIPT_FILENAME'];
        $jubabox_class = 'jubabox_api_' . $this->USER . '\\jubabox';
        if (!is_object($this->jubabox)) {
            $this->jubabox = new $jubabox_class();
        }
    }
}
