Exemple #1
0
 function &create($dbconf = array(), $gametype = null, $modtype = null)
 {
     $db = null;
     if (isset($dbconf['dbhandle'])) {
         $db =& $dbconf['dbhandle'];
     } else {
         require_once dirname(__FILE__) . "/class_DB.php";
         $db = PsychoDB::create($dbconf);
     }
     // determine the game::mod class to try and load
     $cmd = "SELECT value FROM " . $db->dbtblprefix . "config WHERE conftype='main' AND section IS NULL AND ";
     if (!$gametype and !$modtype) {
         $cmd .= "var IN ('gametype', 'modtype') ORDER BY var";
         list($gametype, $modtype) = $db->fetch_list($cmd);
     } elseif (!$gametype) {
         $cmd .= "var='gametype'";
         list($gametype) = $db->fetch_list($cmd);
     } elseif (!$modtype) {
         $cmd .= "var='modtype'";
         list($modtype) = $db->fetch_list($cmd);
     }
     // find the best sub class to use based on game::mod
     $root = dirname(__FILE__);
     $parts = array($gametype, $modtype);
     $class = '';
     while ($parts) {
         $file = $root . DIRECTORY_SEPARATOR . 'PS' . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $parts) . '.php';
         if (file_exists($file)) {
             if (include_once $file) {
                 $class = 'PS_' . implode('_', $parts);
                 break;
             } else {
                 die("Error loading PsychoStats subclass {$file}");
             }
         }
         array_pop($parts);
     }
     // use the base class if no subclasses were found
     if (!$class) {
         include_once 'PS' . DIRECTORY_SEPARATOR . 'PS.php';
         $class = 'PS';
     }
     $obj =& new $class($db);
     return $obj;
 }
Exemple #2
0
$dbpass = '';
$dbtblprefix = 'ps_';
$site_url = '';
@(include_once PS_ROOTDIR . "/config.php");
// Initialize our global variables for PsychoStats.
// Lets be nice to the global Name Space.
$db = null;
$cms = null;
// global PsychoCMS object
$PHP_SELF = $_SERVER['PHP_SELF'];
// this is used so much we make sure it's global
// Sanitize PHP_SELF and avoid XSS attacks.
// We use the constant in places we know we'll be outputting $PHP_SELF to the user
define(SAFE_PHP_SELF, htmlentities($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8'));
// create database handle
$db = PsychoDB::create(array('dbtype' => 'mysql', 'delaystart' => true, 'fatal' => false));
// start the PS CMS object
$cms = new PsychoCMS(array('dbhandle' => &$db, 'plugin_dir' => PS_ROOTDIR . '/plugins', 'site_url' => $site_url));
// this session will not actually store a session in a database or file.
// it's mearly used in the install for cookie support.
$cms->session = new PsychoSession(array('cms' => $cms, 'cookiename' => 'ps_install_sess', 'cookiesalt' => '', 'cookiecompress' => true, 'cookieencode' => true, 'cookielifeoptions' => 0, 'dbhandle' => $db, 'delaystart' => true));
$cms->init(true);
// quick init; no plugins, session or user
$cms->init_theme('default', array('theme_default' => 'default', 'theme_opt' => 'install_theme', 'in_db' => false, 'force_theme' => true, 'fetch_compile' => false, 'compile_id' => 'install', 'compile_dir' => null, 'js_compress' => false, 'css_compress' => false, 'template_dir' => dirname(__FILE__) . '/themes', 'theme_url' => null));
$cms->theme->load_styles();
$cms->theme->assign(array('SELF' => SAFE_PHP_SELF, 'install_version' => PS_INSTALL_VERSION));
// ----------------------------------
function init_session_opts($delete = false)
{
    global $cms;
    $opts = $cms->session->load_session_options();