DIR : /home/kozerus/safer/db2cfg.php
/home/kozerus/safer
<?php
# ../safer/db2cfg 20211127_2000 kolog db2_drop,create,insert
# ../safer/db2cfg 20211127_2000
startup_db2('');
function startup_db2($args) {
$server="localhost"; $dbname="dgs"; $user="dgsmstr"; $pass=""; $sql="select tables;";
$host="ka12";
$query_string="";
# print( "<h1>BUGS_10 safer/db2cfg.php host=$host query_string=$query_string</h1><hr color=goldenrod>" );
$progid="ko.php";
$dttm=date('Ymd_His');
$user="dgsmstr";
$addr="127.0.0.1";
$port="80";
$agent="";
$referer="referer";
$describ="describ_$dttm";
$cnt=0;
if( isset($_SERVER['host'] )) { $host=$_SERVER['host']; }
if( isset( $_SERVER['REMOTE_ADDR'])) {
$remote_addr=$_SERVER['REMOTE_ADDR'];
$remote_addr=str_replace(".","-",$remote_addr);
$addr=$remote_addr;
}
if( isset($_SERVER['HTTP_USER_AGENT'] )) {
$http_user_agent=$_SERVER['HTTP_USER_AGENT'];
$http_user_agent=str_replace(" ","",$http_user_agent );
$http_user_agent=str_replace(".","",$http_user_agent );
$http_user_agent=str_replace(";","",$http_user_agent );
$http_user_agent=str_replace(":","",$http_user_agent );
$http_user_agent=str_replace("/","",$http_user_agent );
$http_user_agent=str_replace("\n","",$http_user_agent );
$http_user_agent=str_replace("(","",$http_user_agent );
$http_user_agent=str_replace(")","",$http_user_agent );
$http_user_agent=str_replace(" ","",$http_user_agent );
$http_user_agent=str_replace(" ","",$http_user_agent );
$agent=$http_user_agent;
}
if( isset( $_SERVER['REMOTE_PORT'])) {
$remote_port=$_SERVER['REMOTE_PORT'];
$port=$remote_port;
}
if( isset( $_SERVER['REFERER'])) { $referer=$_SERVER['REFERER']; }
if( isset( $_SERVER['QUERY_STRING'])) {
$query_string=$_SERVER['QUERY_STRING'];
$query_string=str_replace("%27","",$query_string);
}
$tbllog = "kolog";
$db2_sql_create = "";
$db2_sql_create .= "create table if not exists $tbllog (";
$db2_sql_create .= " progid text,";
$db2_sql_create .= " dttm text,";
$db2_sql_create .= " host text,";
$db2_sql_create .= " user text,";
$db2_sql_create .= " addr text,";
$db2_sql_create .= " port text,";
$db2_sql_create .= " agent text,";
$db2_sql_create .= " referer text,";
$db2_sql_create .= " query_string text,";
$db2_sql_create .= " cnt text, ";
$db2_sql_create .= " describ text ";
$db2_sql_create .= " );";
$db2_sql_drop = "";
$db2_sql_drop .= "drop table if exists $tbllog";
$db2_sql_insert ="insert into $tbllog ";
$db2_sql_insert .= "(progid,dttm,host,user,addr,port,agent,referer,query_string,cnt,describ)";
$db2_sql_insert .= " values ";
$db2_sql_insert .= "('$progid','$dttm','$host','$user','$addr','$port','$agent','$referer','$query_string','$cnt','$describ')";
# print("<h3>MSG_11 db2_sql=$db2_sql_create</h3>" );
# print("<h3>MSG_12 db2_sql=$db2_sql_drop</h3>" );
# print("<h3>MSG_13 db2_sql=$db2_sql_insert</h3>" );
$hostid="ka1";
$hostids="ko2 ko1 ka1";
# $user="root"; $pass="..root";
if( isset( $_REQUEST['hostids'] )) { $hostids=$_REQUEST['hostids']; }
if( isset( $_REQUEST['hostid'] )) { $hostids=$hostid; }
if( isset( $_REQUEST['dbname'] )) { $dbname=$_REQUEST['dbname']; }
if( isset( $_REQUEST['sql'] )) { $sql=$_REQUEST['sql']; }
if( isset( $_REQUEST['tbl'] )) { $sql=$_REQUEST['tbl']; }
if( isset( $_SERVER['HOME'])) { $home=$_SERVER['HOME']; }
if( isset( $_SERVER['SERVER_NAME'])) { $server_name=$_SERVER['SERVER_NAME']; }
if( isset( $_SERVER['HTTP_HOST'])) { $http_host=$_SERVER['HTTP_HOST']; }
$hostid=$http_host;
$hostids=$hostid;
# print( "<h1>BUGS_100 http_host=$http_host home=$home server_name=$server_name </h1>" );
foreach( explode(" ", $hostids) as $hostid ) {
if( $hostid=="ko2" ) {
$server="ko2.us";
$server="localhost";
$sql="show tables;";
if( $dbname=="dgs") {
$tbl="Games";
$sql="select * from $tbl";
$user="dgsmstr"; $pass="=dgsmstr=";
}
if( $dbname=="zc") { $tbl="ko_temp";
$tbl="Categories";
$sql="select * from $tbl";
$user="adam"; $pass="yumcart2";
}
}
if( $hostid == "ko0" ) {
$server="ko0.us";
$server="localhost";
$dbname="dgs";
$sql="show tables;";
$tbl="ko_temp";
if( $dbname=="dgs") {
$tbl="Players";
$sql="select * from $tbl";
$user="dgsmstr"; $pass="=dgsmstr=";
}
if( $dbname=="zc") {
$tbl="Categories";
$sql="select * from $tbl";
$user="adam"; $pass="yumcart0";
}
}
if( $hostid=="ka12" ) {
$server="localhost";
$sql="show tables;";
if( $dbname=="dgs") { $tbl="ko_temp";
$tbl="Games";
$sql="select * from $tbl";
$user="dgsmstr"; $pass="=dgsmstr=";
}
if( $dbname=="zc") {
$tbl="Categories";
$sql="select * from $tbl";
$user="adam"; $pass="yumcart1";
}
}
# print( "<h3>BUGS_150 DB2_CONNECT host=$server dbname=$dbname user=$user pass=$pass</h3>" );
# print( "<h3>MSG_60 hostid=$hostid server=$server dbname=$dbname user=$user sql=$sql</h3>" );
$db2="";
# $server="localhost"; $dbname="dgs"; $user="dgsmstr"; $pass="=dgsmstr=";
## print( "<h3>MSG_141 DB2_CONNECT dbname=$dbname user=$user</h3>" );
$db2=db2conn($server,$dbname,$user,$pass);
# print( "<h3>BUGS_151 DB2_CONN_DONE db2=\$db2 server=$server dbname=$dbname user=$user" );
if( $db2 ) {
# print( "<h3>MSG_142 DB2_DROP dbname=$dbname db2_sql_drop=$db2_sql_drop</h3>" );
# $db2->exec($db2_sql_drop);
# print( "<h3>MSG_143 DB2_CREATE dbname=$dbname db2_sql_create=$db2_sql_create</h3>" );
$db2->exec($db2_sql_create);
# print( "<h3>MSG_144 DB2_INSERT dbname=$dbname db2_sql_insert=$db2_sql_insert</h3>" );
$db2->exec($db2_sql_insert);
# print( "<h3>MSG_145 DB2_CLOSE dbname=$dbname</h3>" );
# $db2->close();
$db2 = null;
# print( "<h3>MSG_149 DB2_DONE dbname=$dbname db2_sql_insert=$db2_sql_insert</h3>" );
}
else {
print( "<h3>ERR_159 DB2_FAIL dbname=$dbname db2_sql_insert=$db2_sql_insert</h3>" );
}
$sql = "select * from $tbllog";
$htmout = db2_select( $db2,$sql);
print( $htmout );
return( $htmout );
}
}
function db2conn($server,$dbname,$user,$pass) {
$htmout = ""; $db2="";
# $htmout .= "<h1>MSG_181 DB2CONN server=$server $dbname=$dbname user=$user</h1>";
try {
$db2 = new PDO("mysql:host=$server;dbname=$dbname",$user, $pass);
# print( "<h2>MSG_182 db2=\$db2 host=$server dbname=$dbname user=$user</h2>");
// set the PDO error mode to exception
$db2->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$htmout .= "<h1>MSG_183 server=$server dbname=$dbname user=$user </h1>";
}
catch(PDOException $e) {
// echo "<h1>ERR_34003 FAIL_CONNECT server=$server dbname=$dbname user=$user err=" . $e->getMessage();
$htmout .= "<h1>ERR_13 FAIL DB2_CONNECT: server=$server dbname=$dbname user=$user server=$server errmsg=" . $e->getMessage();
}
return($db2);
}
function db2_select($db2,$sql) {
# print( "<h3>MSG_170 DB2_SELECT sql=$sql</h3>" );
if( $db2 == "" ) { return(""); }
# $db3->query($sql);
$stm = $db2->query($sql);
$j=0;
$htmout = "";
$rowcnt=$db2->rowCount;
$colcnt=$db2->columnCount;
while( $row = $stmt->fetch(PDO::FETCH_BOTH)) {
$j=$j+1;
$row0=$row[0];
$htmout .= $row0."<br>\n";
}
print( "<h3>MSG_180 DB2_SELECT rowcnt=$rowcnt colcnt=$colcnt sql=$sql</h3>" );
}
# echo get_cfg_var("mysqli.default_pw")
# my_raldfklg_random_key_pw=top-secret-password
# echo get_cfg_var("my_raldfklg_random_key_pw")
#
# php.ini's standard section. like: mongodb_dflkjadkfl_username=... and mongodb_dflkjadkfl_password=..., then get the value via get_cfg_var("mongodb_dflkjadkfl_username") and get_cfg_var("mongodb_dflkjadkfl_password") , where dflkjadkfl is some random text
//
koh5_pano
Drag mouse to navigate.
Navigation
- Left/Right Mouse drag: Changes camera heading.
- Up/Sown Mouse drag: Changes camera pitch.
- Scroll wheel: Changes camera field of view.
- I-Key: Displays Info panel with canvas size, image size and FPS.
17.Aug.2010, Martin Wengenmayer