gmui/php probs

    Date: 09/09/05 (Computer Geeks)    Keywords: php, mysql, sql, apache

    I'm having trouble getting gmui to work properly. I have MySQL and Apache2 running fine behind it, but I just get this:

    Warning: displaysite(/var/www/localhost/gmui/./themes/default/template.php): failed to open stream: No such file or directory in /var/www/localhost/htdocs/gmui/class/Core.php on line 369

    EDIT:
    This is Line 369:
    require_once($this->gmui_dir.$this->subDirs['theme_dir'].$_SESSION['user']->theme."/template.php");




    * @author Don Seiler
    */
    class Core {

    /*
    * The version of GMUI
    */
    var $version;

    /*
    * Array containing settings for GMUI from conf.php
    */
    var $settings = array();

    /*
    * Array containing all CORE_OP
    * where the page refresh should enabled
    */
    var $pageRefresh = array("vd", "servers", "upl");

    /*
    * all available GMUI panels which are optional when mldonkey is running/off
    *
    */
    var $clientUpPanels = array("vd" => "Downloads", "s" =>"Search", "dllink" => "Links",
    "upl" => "Uploads", "upstats" => "Statistics", "servers" => "Servers", "shares" => "Shares",// "vfr" => "Friends",
    "cmd" => "Console", "opt" => "Client Options", "uopt" => "User Options",
    "umanage" => "Users", "gmanage" => "Groups", "other" => "Other", "inc" => "Incoming", "kill" => "Kill Client", "logout" => "Logout");

    var $clientDownPanels = array("umanage" => "Users", "gmanage" => "Groups",
    "other" => "Other", "uopt" => "User Options", "inc" => "Incoming",
    "start" => "Start Client", "logout" => "Logout");

    /*
    * GMUIs subdirectories
    */
    var $subDirs = array( "conf_dir" => "./conf/",
    "lang_dir" => "./lang/",
    "theme_dir" => "./themes/",
    "client_dir" => "./client/",
    "bin_dir" => "./bin/",
    "lib_dir" => "./lib/");
    /*
    * GMUIs priority mapping
    */
    var $priorities = array();

    /*
    * reload id
    */
    var $refreshed = FALSE;

    /*
    * client stat
    */
    var $alive;

    /*
    * settings from conf.php
    *
    */
    var $gmui_dir;
    var $gmui_http;

    var $client_basedir;
    var $client_startup;
    var $client_incoming;

    var $min_page_refresh;
    var $data_sync_time;
    var $use_javascript;
    var $allow_http_download;
    var $allow_http_upload;
    var $max_upload_size;
    var $make_commit_script;
    var $use_hard_links;
    var $include_incoming_size;
    var $max_displayed_sources;
    var $max_displayed_names;
    var $content_src;
    var $use_http_auth;
    var $use_db;
    var $sqlite_db_file;

    var $mysql_user;
    var $mysql_passwd;
    var $mysql_host;
    var $mysql_db;

    /*
    * use php file functions, workaround for file too big errors
    */
    var $use_php_ff;

    /**
    * Constructor for Core class
    *
    * Loads all settings and initializes what is needed.
    */
    function Core()
    {
    $this->loadSettings();
    $this->checkSettings();
    }
    /*
    * hack to use settings during Core Object is created
    */
    function postInit()
    {
    $this->setVersion();
    $this->setInterface();
    $this->setDataBase();
    $this->setPriorities();
    }

    function setPriorities() {
    $this->priorities = array(
    "-20" => _("Very Low"),
    "-10" => _("Low"),
    "0" => _("None (priority)"),
    "10" => _("High"),
    "20" => _("Very High")
    );
    }

    /**
    * Get database wrapper Object
    *
    * @author Moritz Warning
    */
    function setDataBase() {
    require($this->subDirs['conf_dir']."config.php");

    if($use_db == "sqlite") {
    $_SESSION['db'] = new SQLite($sqlite_db_file);
    } elseif ($this->use_db == "mysql") {
    $_SESSION['db'] = new MySQL($mysql_user, $mysql_passwd, $mysql_host, $mysql_db);
    } else exit(''._("No valid database type selected!")."
    \n");
    }

    /**
    * Get Interface Objekt to get data from MLDonkey
    *
    * @author Moritz Warning
    */
    function setInterface() {
    require($this->subDirs['conf_dir']."config.php");

    $_SESSION['interface'] = new MLD_Interface($client_host, $client_port, $client_user, $client_passwd);
    $_SESSION['interface']->postInit();
    }

    /**
    * Grabs version from VERSION file
    *
    * @author Don Seiler
    */
    function setVersion() {
    if (file_exists("./VERSION")) {
    $lines = file("./VERSION");
    $this->version = $lines[0];
    } else {
    exit(''._("Version File not found!")."
    \n");
    }
    }

    /**
    * Return available languages.
    *
    * @author Moritz Warning
    */
    function getLanguages() {
    return getDirs($this->subDirs['lang_dir']);
    }

    /**
    * Return available themes
    *
    * @author Moritz Warning
    */
    function getThemes() {
    return getDirs($this->subDirs['theme_dir']);
    }

    /**
    * Loads core settings into $this->settings array
    *
    * @author Moritz Warning
    */
    function loadSettings() {
    $conf_file = $this->subDirs['conf_dir']."config.php";
    if (!file_exists($conf_file)) {
    exit(''."Required file conf/config.php not found!"."
    \n");
    }
    require($conf_file);

    //check for optional $gmui_dir in conf.php
    if(!isset($gmui_dir)) {
    $this->gmui_dir = dirname($_SERVER["DOCUMENT_ROOT"].$_SERVER["PHP_SELF"]).DIRECTORY_SEPARATOR;
    } else {
    $this->gmui_dir = $gmui_dir;
    }

    //check for optional $gmui_http in conf.php
    if(!isset($gmui_http)) {
    $this->gmui_http = dirname("http://".$_SERVER["SERVER_ADDR"].":".$_SERVER["SERVER_PORT"].$_SERVER["PHP_SELF"]).DIRECTORY_SEPARATOR;
    } else {
    $this->gmui_http = $gmui_http;
    }

    //needed settings in ./conf/conf.php
    $this->client_basedir = $client_basedir;
    $this->client_startup = $client_startup;
    $this->client_incoming = $client_incoming;
    $this->data_sync_time = $data_sync_time;
    $this->min_page_refresh = $min_page_refresh;
    $this->use_javascript = $use_javascript;
    $this->allow_http_download = $allow_http_download;
    $this->allow_http_upload = $allow_http_upload;
    $this->max_upload_size = $max_upload_size;
    $this->make_commit_script = $make_commit_script;
    $this->chmod = $chmod;
    $this->use_hard_links = $use_hard_links;
    $this->include_incoming_size = $include_incoming_size;
    $this->max_displayed_sources = $max_displayed_sources;
    $this->max_displayed_names = $max_displayed_names;
    $this->content_src = $content_src;
    $this->use_http_auth = $use_http_auth;
    $this->use_db = $use_db;
    $this->use_php_ff = $use_php_ff;

    //other settings, depend on others
    if($use_db == "sqlite") {
    $this->sqlite_db_file = $sqlite_db_file;
    } elseif($use_db == "mysql") {
    $this->mysql_user = $mysql_user;
    $this->mysql_passwd = $mysql_passwd;
    $this->mysql_host = $mysql_host;
    $this->mysql_db = $mysql_db;
    }
    }

    function checkSettings() {
    $check_settings = array(
    'client_basedir',
    'client_startup',
    'client_incoming',
    'min_page_refresh',
    'data_sync_time',
    'use_javascript',
    'allow_http_download',
    'allow_http_upload',
    'max_upload_size',
    'make_commit_script',
    'use_hard_links',
    'include_incoming_size',
    'max_displayed_sources',
    'max_displayed_names',
    //'content_src', this may be empty b y purpose
    'use_http_auth',
    'use_db'
    );

    foreach ($check_settings as $setting) {
    $value = $this->{$setting};
    if (is_null($value) or $value === "") {
    $missingsettings[] = $setting;
    }
    }

    if(count($missingsettings) > 0) {
    $errorstring = "

    \nConfig file incomplete. The following values are missing:
    \n

      \n";
      foreach ($missingsettings as $setting) {
      $errorstring .= "
    • $setting
    • \n";
      }
      $errorstring .= "
    \n

    \n";
    $errorstring .= "If you have recently upgraded, please check config.php.sample for any new settings.\n";
    exit($errorstring);
    }
    }

    /**
    * Lets you know if a menu item is currently active
    *
    * @author CJ Kucera
    */
    function isMenuActive($menu)
    {
    return ($_SESSION["active"] == $menu);
    }

    /**
    * Returns a list of available menu items, for themes
    *
    * @author Moritz Warning
    */
    function getMenu() {
    $menu = array();
    $panels = array();

    if($this->alive) { $panels = $this->clientUpPanels; }
    else { $panels = $this->clientDownPanels; }

    foreach($_SESSION['user']->titlebar as $id) {
    if(isset($panels[$id])) {
    $menu[] = new MenuItem($id, _($panels[$id]), $this->isMenuActive($id));
    }
    }
    return $menu;
    }

    /*
    * this function print the entire site using getSite() in themes/template.php
    *
    * Moritz Warning
    */
    function displaySite() {
    $this->setConstants();
    $this->setAlive();
    $this->setLanguage();
    $this->setTimeMark();

    //update users downloads and settings
    if($this->timemark) {
    $_SESSION['user']->refill_settings();
    $_SESSION['user']->refill_downloads();
    }

    require_once($this->gmui_dir.$this->subDirs['theme_dir'].$_SESSION['user']->theme."/template.php");
    echo getSite(); //getSite is part of the theme

    //reset text variables
    $_SESSION['title'] = "";
    $_SESSION['message'] = "";
    $_SESSION['headline'] = "";

    exit();
    }

    //$this->subDirs
    /*
    * set constants
    *
    * Moritz Warning
    */
    function setConstants() {
    define("NL", "\n");
    define("BN", "
    \n");
    define("BBN", "

    \n");
    }

    /*
    * set alive status of the client
    *
    * Moritz Warning
    */
    function setAlive() {
    $this->alive = $_SESSION['interface']->alive();
    }


    /*
    *
    set gettext variables
    *
    * Moritz Warning
    */
    function setLanguage() {
    $lang = $_SESSION['user']->lang;

    if($lang == "en") {
    setlocale(LC_ALL, 'en_US');
    } else {
    setlocale(LC_ALL, $lang."_".strtoupper($lang));
    }
    putenv("LANG=".$lang);
    bindtextdomain('messages', $this->subDirs['lang_dir']);
    textdomain('messages');
    }

    /*
    * set $this->timemark every $data_sync_time seconds (set in config.php)
    *
    * Moritz Warning
    */
    function setTimeMark() {
    $this->timemark = FALSE;
    if(!isset($_SESSION['last_time_check']) OR (time() - $_SESSION['last_time_check']) > $this->data_sync_time) {
    $_SESSION['last_time_check'] = time();
    $this->timemark = TRUE;
    }
    }

    /**
    * Reads $_REQUEST var and takes appropriate action
    *
    * @author Don Seiler
    * @author Moritz Warning
    */
    function getBody() {

    $core_op = $_REQUEST["CORE_OP"];

    if(!$this->alive) {
    $_SESSION['was_dead'] = TRUE;
    }

    list($prefix,$suffix) = explode("_", $core_op);
    //set CORE_OP if it is not valid
    if(!$_SESSION['user']->allow_show_Menu($prefix)) {
    if(!empty($core_op)) {
    $core_op = "";
    $prefix = "";
    } elseif($this->alive AND $_SESSION['user']->allow_show_Menu("vd")) {
    $core_op = "vd"; //default is CORE_OP when not set and "vd" allowed
    $prefix = "vd";
    }
    }
    $_REQUEST["CORE_OP"] = $core_op; //reset core_op because other programms use it

    $this->dbCare();

    //select availabel panels
    $panels = array();
    if($this->alive) { $panels = $this->clientUpPanels; }
    else { $panels = $this->clientDownPanels; }

    if(function_exists($core_op)) {
    $_SESSION["title"] = "Web-GMUI: ".$panels[$prefix];
    $_SESSION["active"] = $prefix;
    $content = call_user_func($core_op);
    } else {
    $_SESSION["title"] = "Web-GMUI: "._("Welcome");
    $_SESSION["active"] = "";
    $content = "";
    }
    return $content;
    }

    /*
    * dbCare check if mlnet was restarted and initiate an auto reassignment program (verify_db)
    *
    * Moritz Warning
    */
    function dbCare() {
    $restarted = FALSE;

    if($this->alive AND $_SESSION['was_dead']) {
    $restarted = TRUE;
    $_SESSION['was_dead'] = FALSE;
    }

    if($this->alive AND !$restarted AND ($_REQUEST["CORE_OP"] == "vd")) {
    $restarted = $_SESSION['interface']->check_MLDrestart();
    }

    if($restarted) {
    $check_all = FALSE;
    if($_SESSION['user']->username == "admin") { $check_all = TRUE; }

    $_SESSION['user']->verify_db($check_all);
    $_SESSION['user']->refill_downloads();
    } elseif($this->alive AND $this->timemark) {
    $_SESSION['user']->remove_finished();
    }
    }

    /*
    * logout - what should i say any more? ;)
    *
    * Moritz Warning
    */
    function logout() {
    //for gettext tool
    _("Logout");

    $_SESSION['user']->search_delAll();
    unset($_SESSION);
    session_destroy();
    if($this->use_http_auth) { //send a 401 to clear the browser cache
    Header('WWW-Authenticate: Basic realm="Logout"');
    Header('HTTP/1.0 401 Unauthorized');
    }
    }
    }
    ?>


    x-posted to #linux and #computergeeks

    Source: http://www.livejournal.com/community/computergeeks/771090.html

« another problem... || Convert .wmv to playable... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home