예제 #1
0
class MySQL2 implements SQL
{
    public function connect()
    {
        // TODO: Implement connect() method.
    }
}
class PostgresSQL2 implements SQL
{
    public function connect()
    {
        // TODO: Implement connect() method.
    }
}
class Database2
{
    public static function create($driver, $params)
    {
        switch ($driver) {
            case "mysql":
                $obj = new MySQL2($params['host'], $params['user'], $params['passwd']);
            case "postgreSQL":
                $obj = new PostgerSQL2($params['host'], $params['user'], $params['passwd']);
            default:
                $obj = new MySQL2($params['host'], $params['user'], $params['passwd']);
        }
        return $obj->connect();
    }
}
$db = Database2::create('mysql', $params);
예제 #2
0
 $loan_scheme_id = $row2->loan_scheme_id;
 $loan_scheme_name = $row2->loan_scheme_name;
 if ($personel_schemes->num_rows() > 0) {
     foreach ($personel_schemes->result() as $open) {
         $id = $open->id;
         if ($loan_scheme_id == $id) {
             $amount = $open->amount;
             $monthly = $open->monthly;
             $interest = $open->interest;
             $interest2 = $open->interest2;
             $sdate = $open->sdate;
             $edate = $open->edate;
             $today = date("y-m-d");
             $prev = new Database2();
             $prev_payments = $monthly * $prev->dateDiff($sdate . ' 00:00', $today . ' 00:00', 'month');
             $prev = new Database2();
             $prev_interest = $interest * $prev->dateDiff($sdate . ' 00:00', $today . ' 00:00', 'month');
             break;
         } else {
             $amount = 0;
             $monthly = 0;
             $interest = 0;
             $interest2 = 0;
             $sdate = "";
             $edate = "";
             $today = date("y-m-d");
             $prev_payments = "";
             $prev_interest = "";
         }
     }
 } else {
예제 #3
0
파일: info.php 프로젝트: Krinkle/xtools
<?php

#phpinfo();
//Requires
require_once 'WebTool.php';
$wt = new WebTool('test');
$wt->loadDBCredentials();
echo "Hallo";
#print_r($wt->metap);
foreach ($wt->metap as $db => $row) {
    $slice = $row["slice"];
    if ($db == "centralauth") {
        continue;
    }
    #	if ( in_array( $db, array("bgwiki","afwiki","abwiki","acewiki","amwiki", "angwiki") ) || $db == "commonswiki" ) { continue; }
    $queries[$slice][] = "\n\t\t\t(SELECT rev_timestamp, '{$db}' as wiki, page_namespace, page_title, rev_id\n\t\t\tFROM {$db}_p.revision_userindex\n\t\t\tJOIN {$db}_p.page on page_id = rev_page\n\t\t\twhere  rev_user_text = 'Hedonil' AND rev_timestamp > '20140628210110'\n\t\t\tLimit 10)\n\t";
}
#	print_r($queries);
foreach ($queries as $slice => $slarr) {
    $stime = microtime(true);
    $dbr = new Database2($slice, $dbUser, $dbPwd, '');
    $dur = number_format(microtime(true) - $stime, 3);
    $query = implode(" UNION ", $slarr);
    echo $query;
    $res = $dbr->query($query);
    $anz = count($res);
    echo "{$slice} --- {$db} --- {$anz} --- {$dur}  <br/>\n";
    $dbr->close();
}
예제 #4
0
 public function render($mode, &$renderer, $data)
 {
     if ($mode == 'xhtml') {
         list($state, $args) = $data;
         switch ($state) {
             case DOKU_LEXER_ENTER:
                 $this->tableName = trim($args['table']);
                 $this->dbName = trim($args['database']);
                 if ($this->dbName === '') {
                     // missing explicit selection of database
                     // --> choose file according to current page's namespace
                     $this->dbName = getID();
                 }
                 $this->options = $args;
                 break;
             case DOKU_LEXER_UNMATCHED:
                 self::includeLib();
                 $db = new Database2($renderer, $this);
                 if ($db->connect($this->dbName, $this->options['auth'])) {
                     $db->process($this->tableName, $args, $this->options);
                 }
                 break;
             case DOKU_LEXER_EXIT:
                 break;
         }
         return true;
     } else {
         if ($mode === 'metadata') {
             // metadata renderer tries to detect change of content to
             // support page caching ... disable by providing random meta data
             /**
              * @todo implement better cache control here
              */
             $renderer->doc .= uniqid(mt_rand(), true);
             return true;
         }
     }
     return false;
 }
예제 #5
0
                }
                $st->closeCursor();
                return $media[0];
            }
            public final function printTable()
            {
                return $this->showTable(false, true, true, null, true);
            }
        }
        // check salted hash provided in URL (used to proove authorization)
        $providedHash = @base64_decode($_GET['b']);
        if (!$providedHash) {
            throw new Exception('access denied, missing valid hash', 403);
        }
        $source = serialize($source);
        if (Database2::ssha($source, $salt) !== $providedHash) {
            throw new Exception('access denied, invalid hash', 403);
        }
        // query database for selected media file
        $db = new Database2_media($dsn, $authSlot, $table, $ioIndex, $pageID);
        switch ($_GET['m']) {
            case 'print':
                $data = $db->printTable();
                $title = sprintf($db->getLang('printtitle'), $table);
                $data = <<<EOT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{$title}</title>
<link rel="stylesheet" type="text/css" href="./print.css" />
</head>