<?php
#
# Copyright 2003 James Seng. See LICENSE for the Software License.
#

#
# Configure this!
#
#$conf_dbdir         = 'NOT CONFIGURE';
$conf_dbdir         = '/home/jseng/pong-db/';

#
# Configure these only if you know what you doing.
#
$conf_moduledir     = 'modules/';
$conf_fconfig       = 'config';
$conf_stylesheet    = 'pong.css';

$conf_version       = '1.0.2';
#
# Base class and common functions
#
if (!isset($conf_basedir)) $conf_basedir  = '';

class pong_base {
    var $msg;

    function error($str = "Unknown Error") {
        $str = rtrim($str);
        $this->msg = $str . "\n";
        return 0;
    }

    function errstr() {
        return $this->msg;
    }
}

function long_datetime($time = 0) {
    return gmdate("D, j M Y G:i:s \G\M\T");
}

function firstupper($str) {
    return strtoupper(substr($str,0,1)) . substr($str,1);
}

function params_convert($params) {
  $cparams= array();
  $num_params = $params->getNumParams();

  for ($i = 0; $i < $num_params; $i++) {
    $sn = $params->getParam($i);
    $cparams[] = $sn->scalarval();
  }
  return $cparams;
}

#
# Check for configuration
#
if ($conf_dbdir == 'NOT CONFIGURE') {
    print <<<_WARN_
<center>
<table style="border:1px dashed #00F" cellpadding="5" width="50%">
<tr>
  <td style="background:#336699;color:#FFF" align=center>
    PonG Warning</td>
  </tr>
<tr>
  <td align="left">
You have not configure your PonG yet. Please follow the instructions described in the <a href="http://james.seng.cc/wiki/wiki.cgi?PonG/Installation">Installation Guide</a>. You might also want to read the <a href="http://james.seng.cc/wiki/wiki.cgi?PonG/User_Guide">User Guide</a> too.
    </td>
  </tr>
</table>
<p>
<font size="-1"><b><a href="http://james.seng.cc/wiki/wiki.cgi?PonG">PonG</a> version $conf_version</b> : Copyright &copy; 2003 <a href="http://james.seng.cc/">James Seng</a>. All Right Reserved.</font>
</center>
_WARN_;

    exit();
}


#
# Start the session
#
session_start();

#
# Include Pong libraries
#

include_once "${conf_basedir}includes/xmlrpc.inc";

include_once "${conf_basedir}includes/commands.inc";
include_once "${conf_basedir}includes/theme.inc";

include_once "${conf_basedir}includes/opml.inc";
    include_once "${conf_basedir}includes/config.inc";

    include_once "${conf_basedir}includes/module.inc";
        include_once "${conf_basedir}includes/attrib.inc";
        include_once "${conf_basedir}includes/function.inc";

#
# Init Configuration
#
$config = new pong_config;
$config->load($conf_fconfig);

if ($config->get('userid') == NULL) {
    $config->set('userid','james');
    $config->set('passwd',crypt('seng'));
    $config->save();
}

#
# Init Modules
#
$modules = array();

$module_tree = new module_base;
$module_tree->load_submod($conf_moduledir);

?>
