示例#1
0
 function setTbl($tbl)
 {
     $tblpre = Gconf::get('tblpre');
     if (strpos($tbl, $tblpre) !== 0) {
         $tbl = $tblpre . $tbl;
     }
     $this->set("tbl", $tbl);
     if ($this->dba == null) {
         $this->dba = new DBA();
     }
 }
示例#2
0
 function __construct()
 {
     $gconf = new Gconf();
     $this->mDbHost = $gconf->get('dbhost');
     $this->mDbPort = $gconf->get('dbport');
     $this->mDbUser = $gconf->get('dbuser');
     $this->mDbPassword = $gconf->get('dbpassword');
     $this->mDbDatabase = $gconf->get('dbname');
 }
示例#3
0
$conf['welcometbl'] = $tblpre . 'info_welcometbl';
$conf['operatelogtbl'] = $tblpre . 'fin_operatelogtbl';
# db info
$conf['dbhost'] = '';
$conf['dbport'] = '';
$conf['dbuser'] = '';
$conf['dbpassword'] = '';
$conf['dbname'] = $conf['maindb'];
#
$conf['frontpage'] = '#-xxx';
$conf['is_debug'] = 1;
# set them all
Gconf::setConf($conf);
global $_CONFIG;
# will be used in page scripts
$_CONFIG = Gconf::getConf();
# configuration container
class Gconf
{
    private static $conf = array();
    public static function get($key)
    {
        return self::$conf[$key];
    }
    public static function set($key, $value)
    {
        self::$conf[$key] = $value;
    }
    public static function getConf()
    {
        return self::$conf;
示例#4
0
 public static function xml2hash($xmlpath, $sep, $db, $tbl)
 {
     $i = 0;
     $hm = array();
     $hmsortinxml = array();
     $attribute = array('name', 'type');
     if ($xmlpath == '') {
         print __FILE__ . ": xmlpath is empty. [1201231150]\n";
         return $hm;
     } else {
         if ($sep == '') {
             print __FILE__ . ": separator is empty. [1201231153]\n";
             return $hm;
         }
     }
     $tblpre = Gconf::get('tblpre');
     $tblconf = str_replace($tblpre, "", $tbl);
     if (file_exists($xmlpath . "/" . $tblconf . ".xml")) {
         $xmlobj = simplexml_load_file($xmlpath . "/" . $tblconf . ".xml");
         #print __FILE__.": xmlstr: [".print_r($xmlobj)."]\n";
         foreach ($xmlobj as $key => $value) {
             #print "leve-0: $key: [$value], name: [".$value['name']."] type:[".$value['type']."] typeof:[".gettype($value)."]\n";
             $sortk = (string) $value['name'];
             if (!array_key_exists($sortk, $hmsortinxml)) {
                 $hmsortinxml[$sortk] = $i;
                 $i++;
             }
             $tmpname = (string) $value['name'];
             if ($key == 'table') {
                 if (substr($tmpname, 0, strlen($tblpre)) !== $tblpre) {
                     $value['name'] = $tblpre . $tmpname;
                 }
             }
             $hm[$key . $sep . $value['name']] = $tmpname;
             foreach ($value as $key1 => $value1) {
                 #print "leve-1: $key1: [$value1] typeof:[".gettype($value1)."]\n";
                 $tmpkey1 = $key . $sep . $value['name'] . $sep . $key1;
                 if (!array_key_exists($tmpkey1, $hm)) {
                     $hm[$tmpkey1] = (string) $value1;
                 } else {
                     $hm[$tmpkey1] = $hm[$tmpkey1] . "|" . (string) $value1;
                 }
                 foreach ($value1 as $key2 => $value2) {
                     #print "leve-2: $key2: [$value2] typeof:[".gettype($value2)."]\n";
                     $tmpkey2 = $key . $sep . $value['name'] . $sep . $key1 . $value1['name'] . $sep . $key2;
                     if (!array_key_exists($tmpkey2, $hm)) {
                         $hm[$tmpkey2] = (string) $value2;
                     } else {
                         $hm[$tmpkey2] = $hm[$tmpkey2] . "|" . (string) $value2;
                     }
                     foreach ($value2 as $key3 => $value3) {
                         #print "leve-3: $key3: [$value3] typeof:[".gettype($value3)."]\n";
                         $tmpkey3 = $key . $sep . $value['name'] . $sep . $key1 . $value1['name'] . $sep . $key2 . $sep . $value2['name'] . $sep . $key3;
                         if (!array_key_exists($tmpkey3, $hm)) {
                             $hm[$tmpkey3] = (string) $value3;
                         } else {
                             $hm[$tmpkey3] = $hm[$tmpkey3] . "|" . (string) $value3;
                         }
                     }
                 }
             }
         }
     } else {
         error_log(__FILE__ . ": " . $xmlpath . "/" . $tblconf . ".xml was not found.");
     }
     #print_r($hmsortinxml);
     #print_r($hm);
     return array($hm, $hmsortinxml);
 }