DIR : /home/kozerus/public_html/go/kogo_20211210_1200.php

/home/kozerus/public_html/go

<?php




	startup_kogo("");

function startup_kogo($args) {

# kogo init
	$kogo="";
	$t=0; $x=0; $y=0; $g=0;
	$bxlim=9; $bylim=9; $bhandi=0;
	$l=0; $d=0;
	$gid=""; $pb="pb"; $pw="pw";
	$moves="";
	$dttm=date('Ymd_His');
	if( ! isset($_REQUEST['kogo'])) {

		$htmout = "";
		$htmout .= "<html><head><title>kogo $dttm</title></head>\n";
		$htmout .= "<body bgcolor=linen>\n";
		$htmout .= "<hr color=goldenron>\n";
		$htmout .= "<div id=div_kogo>\n";
		$htmout .= "<hr color=goldenron>\n";
		$htmout .= "	<img src=/imgs/btn/koeye.png id=img_kogo ";
		$htmout .= "	onclick=\"window.open('./kogo.php');return false;\" height=25>\n";
		$htmout .= "	<h1>div_kogo $dttm</h1>\n";
		$htmout .= "	</div id=div_kogo_end>\n";
		$htmout .= "<hr color=goldenron>\n";
		$htmout .= "	</body></html>\n";
		print( $htmout );
		return( $htmout );
		}

# kogo_isset
	if ( isset($_REQUEST['kogo'] )) {$kogo=$_REQUEST['kogo'];}
	if ( isset($_REQUEST['t'] )) {$t=$_REQUEST['t'];}
	if ( isset($_REQUEST['x'] )) {$x=$_REQUEST['x'];}
	if ( isset($_REQUEST['y'] )) {$y=$_REQUEST['y'];}
	if ( isset($_REQUEST['g'] )) {$g=$_REQUEST['g'];}
	if ( isset($_REQUEST['bxlim'] )) {$bxlim=$_REQUEST['bxlim'];}
	if ( isset($_REQUEST['bylim'] )) {$bylim=$_REQUEST['bylim'];}
	if ( isset($_REQUEST['bhandi'] )) {$bhandi=$_REQUEST['bhandi'];}
	if ( isset($_REQUEST['l'] )) {$l=$_REQUEST['l'];}
	if ( isset($_REQUEST['d'] )) {$d=$_REQUEST['d'];}
	if ( isset($_REQUEST['moves'] )) {$moves=$_REQUEST['moves'];}
	if ( isset($_REQUEST['pb'] )) {$kbogo=$_REQUEST['kbogo'];}
	if ( isset($_REQUEST['pw'] )) {$pw=$_REQUEST['pw'];}
	if ( isset($_REQUEST['gid'] )) {$gid=$_REQUEST['gid'];}

# kogo_match ========================
	if( preg_match("/new/", $kogo )) {
		kogo_new($kogo,$t,$x,$y,$g,$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid);
		}
	if( preg_match("/new/", $kogo )) {
		kogo_add($kogo,$t,$x,$y,$g,$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid);
		}
	if( preg_match("/new/", $kogo )) {
		kogo_del($kogo,$t,$x,$y,$g,$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid);
		}
	if( preg_match("/new/", $kogo )) {
		kogo_upd($kogo,$t,$x,$y,$g,$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid);
		}
	if( preg_match("/new/", $kogo )) {
		kogo_sel($kogo,$t,$x,$y,$g,$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid);
		}
	}

# kogo ========================
function kogo_new($kogo,$t,$x,$y,$g,$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid) {
	$htmout=kogo_db3new($db3fil,$tbl,$kogo,$t,$x,$y,$g,$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid);
	return($htmout);
	}
function kogo_add($kogo,$t,$x,$y,$g,$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid) {
	$htmout=kogo_db3add($db3fil,$tbl,$kogo,$t,$x,$y,$g,$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid);
	return($htmout);
	}
function kogo_del($kogo,$t,$x,$y,$g,$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid) {
	$htmout=kogo_db3del($db3fil,$tbl,$kogo,$t,$x,$y,$g,$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid);
	return($htmout);
	}
function kogo_upd($kogo,$t,$x,$y,$g,$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid) {
	$htmout=kogo_db3upd($db3fil,$tbl,$kogo,$t,$x,$y,$g,$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid);
	return($htmout);
	}
function kogo_sel($kogo,$t,$x,$y,$g,$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid) {
	$htmout=kogo_db3sel($db3fil,$tbl,$kogo,$t,$x,$y,$g,$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid);
	return($htmout);
	}

# kogo_db3 ========================
function kogo_db3new($db3fil,$tbl,$kogo,$t,$x,$y,$g,$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid) {
	$sql_cr = "";
	$sql_cr .= "create table if not exists $tbl (\n";
	$sql_cr .= "'db3fil varchar,',";
	$sql_cr .= "'tbl varchar,',";
	$sql_cr .= "'kogo varchar,',";
	$sql_cr .= "'t varchar,',";
	$sql_cr .= "'x varchar,',";
	$sql_cr .= "'y varchar,',";
	$sql_cr .= "'g varchar,',";
	$sql_cr .= "'bxlim varchar,',";
	$sql_cr .= "'bhandi varchar,',";
	$sql_cr .= "'l varchar,',";
	$sql_cr .= "'d varchar,',";
	$sql_cr .= "'moves varchar,',";
	$sql_cr .= "'pb varchar,',";
	$sql_cr .= "'pw varchar,',";
	$sql_cr .= "'gid varchar,',";
	$sql_cr .= "'status varchar,',";
	$sql_cr .= "'dttm varchar,',";
	$sql_cr .= "'note varchar'";
	$sql_cr .= " );\n";

	$pdo = newpdo($db3fil);
	$pdo->exec($sql_cr);
	$pdo=null; 
	kogo_db3add($db3fil,$tbl,$kogo,$t,$x,$y,$g,$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid);
	return($sql_cr);
	}
function kogo_db3add($db3fil,$tbl,$kogo,$t,$x,$y,$g,$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid) {
	$note="note"; $status="";
	$dttm=date('Ymd_His');
	$sql_add = "";
	$sql_add .="insert into $tbl (\n";
	$sql_add .="'db3fil',";
	$sql_add .="'tbl',";
	$sql_add .="'kogo',";
	$sql_add .="'t',";
	$sql_add .="'x',";
	$sql_add .="'y',";
	$sql_add .="'g',";
	$sql_add .="'bxlim',";
	$sql_add .="'bhandi',";
	$sql_add .="'l',";
	$sql_add .="'d',";
	$sql_add .="'moves',";
	$sql_add .="'pb',";
	$sql_add .="'pw',";
	$sql_add .="'gid',";
	$sql_add .="'status',";
	$sql_add .="'dttm',";
	$sql_add .="'note'";
	$sql_add .= " ) values ( \n";
	$sql_add .="'$db3fil',";
	$sql_add .="'$tbl',";
	$sql_add .="'$kogo',";
	$sql_add .="'$t',";
	$sql_add .="'$x',";
	$sql_add .="'$y',";
	$sql_add .="'$g',";
	$sql_add .="'$bxlim',";
	$sql_add .="'$bhandi',";
	$sql_add .="'$l',";
	$sql_add .="'$d',";
	$sql_add .="'$moves',";
	$sql_add .="'$pb',";
	$sql_add .="'$pw',";
	$sql_add .="'$gid',";
	$sql_add .="'$status',";
	$sql_add .="'$dttm',";
	$sql_add .="'$note'";
	$sql_add .= " );\n";
	print( "<h1>MSG_150 sql_add=$sql_add</h1>\n" );
	$pdo = newpdo($db3fil);
	$pdo->exec($sql_add);
	$pdo=null; 
	return($sql_add);
	}
function kogo_db3del($db3fil,$tbl,$kogo,$t,$x,$y,$g,$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid) {
	$sql_del="delete from $tbl where t=$t";
	$pdo = newpdo($db3fil);
	$pdo->exec($sql_del);
	$pdo=null; 
	return($sql_del);
	}
function kogo_db3upd($db3fil,$tbl,$kogo,$t,$x,$y,$g,$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid) {
	$fld="g"; $val=$g;
	$sql_upd="update $tbl set $fld='$val' where t=$t";
	$pdo = newpdo($db3fil);
	$pdo->exec($sql_upd);
	$pdo=null; 
	return($sql_upd);
	}
function kogo_db3sel($db3fil,$tbl,$kogo,$t,$x,$y,$g,$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid) {

	$fmt=""; if( isset($_REQUEST['fmt'] )) { $fmt=$_REQUEST['fmt']; }
	if( isset($_REQUEST['db3fil'] )) { $db3fil=$_REQUEST['db3fil']; }
	if( isset($_REQUEST['tbl'] )) { $db3fil=$_REQUEST['tbl']; }
	$htmout = ""; $psv=""; $csv=""; $json="";  $txt="";
	$sql_sel="select * from $tbl";
	$pdo = newpdo($db3fil);
#	$pdo =>query($sql_sel);


	$htmout="";
	$htmout .= "<html>\n";
	$htmout .= "<head>\n";
	$htmout .= "	<title>kogo $dttm $gid $bxlim $bylim $bhandi $pb $pw</title>\n";
	$htmout .= "	<head>\n";
	$htmout .= "<body bgcolor=linen>\n";
	$htmout .= "<div id=div_kogo_$gid>\n";
	$htmout .= "	<h1>kogo $dttm $gid $bxlim $bylim $bhandi $pb $pw</h1>\n";
	$htmout .= "<table id=table_kogo_$gid>\n";
	$htmout .= "<tr>";
	$htmout .= "<td>db3fil</td>";
	$htmout .= "<td>tbl</td>";
	$htmout .= "<td>t</td>";
	$htmout .= "<td>x</td>";
	$htmout .= "<td>y</td>";
	$htmout .= "<td>g</td>";
	$htmout .= "<td>bxlim</td>";
	$htmout .= "<td>bylim</td>";
	$htmout .= "<td>bhandi</td>";
	$htmout .= "<td>l</td>";
	$htmout .= "<td>d</td>";
	$htmout .= "<td>dttm</td>";
	$htmout .= "<td>status</td>";
	$htmout .= "<td>gid</td>";
	$htmout .= "<td>note</td>";
	$htmout .= "</tr>\n";



	$json = "";
	$json .= "{ 'kogo': [\n'";

	$j=0;
	foreach($pdo->query($sql_sel) as $row ) {
		$j=$j+1;
		$db3=$row['db3fil'];
		$tbl=$row['tbl'];
		$kogo=$row['kogo'];
		$t=$row['t'];
		$x=$row['x'];
		$y=$row['y'];
		$g=$row['g'];
		$bxlim=$row['bxlim'];
		$bylim=$row['bylim'];
		$bhandi=$row['bhandi'];
		$l=$row['l'];
		$d=$row['d'];
		$moves=$row['moves'];
		$pb=$row['pb'];
		$pw=$row['pw'];
		$gid=$row['gid'];
		$staus=$row['status'];
		$dttm=$row['dttm'];
		$note=$row['note'];

		$json .= "{\n";
		$json .= "'db3fil':'$db3',";

		$json .= "'note':'$note'";
		$json .= "	},\n";

		$psv .= "$db3fil|";
		$psv .= "$tbl|";
		$psv .= "$t|";
		$psv .= "$x|";
		$psv .= "$y|";
		$psv .= "$g|";
		$psv .= "$bxlim|";
		$psv .= "$bylim|";
		$psv .= "$bhandi|";
		$psv .= "$l|";
		$psv .= "$d|";
		$psv .= "$dttm|";
		$psv .= "$status|";
		$psv .= "$gid|";
		$psv .= "$note\n";


		$htmout .= "<tr>";
		$htmout .= "<td>$db3fil</td>";
		$htmout .= "<td>$tbl</td>";
		$htmout .= "<td>$t</td>";
		$htmout .= "<td>$x</td>";
		$htmout .= "<td>$y</td>";
		$htmout .= "<td>$g</td>";
		$htmout .= "<td>$bxlim</td>";
		$htmout .= "<td>$bylim</td>";
		$htmout .= "<td>$bhandi</td>";
		$htmout .= "<td>$l</td>";
		$htmout .= "<td>$dttm</td>";
		$htmout .= "<td>$status</td>";
		$htmout .= "<td>$note</td>";
		$htmout .= "<\tr>";

		}
	$pdo=null; 

	$csv=str_replace("|", $psv );
	$json .= " ]}\n";

	$htout .= "	</table>\n";
	$htmout .= "	</body>\n";
	$htmout .= "	</html>\n";


	if( preg_match( "/psv/", $fmt )) { return( $psv ); }
	if( preg_match( "/csv/", $fmt )) { 
		header("Content-type: text/csv");
		print( $csv );
		return( $csv ); 
		}
	if( preg_match( "/txt/", $fmt )) { 
		header("Content-type: text/plain");
		print($txt);
		return( $txt ); 
		}
	if( preg_match( "/json/", $fmt )) { 
#		header("Content-type: image/png");
#		header("Content-type: image/jpg");
#		header("Content-type: image/gif");
		header("Content-type: application/json");
		print( $json ); 
		return( $json );
		}
	if( preg_match( "/html/", $fmt )) { 
		print($htmout);
		return($htmout);
		}
	return( $htmout );
	}










function kogo_drop($ftarget,$ttarget) {
	$htmout="";
	if(( preg_match("/^stone/",$ftarget))
	&& ( preg_match("/^stone/",$ttarget))) {
		$htmout += $htmout_status("stone2stone",$t,$x,$y,$g,$bxlim,$bylim,$bhandi,d,l,$ftarget,$ttarget);
		}
	if(( preg_match("/^stone/",$ftarget))
	&& ( preg_match("/^board/",$ttarget))) {
	$htmout += $htmout_status("stone2board",$t,$x,$y,$g,$bxlim,$bylim,$bhandi,d,l,$ftarget,$ttarget);
		}
	if(( preg_match("/^stone/",$ftarget))
	&& ( preg_match("/^lid/",$ttarget))) {
		$htmout += $htmout_status("stone2lid",$t,$x,$y,$g,$bxlim,$bylim,$bhandi,d,l,$ftarget,$ttarget);
		}
	if(( preg_match("/^stone/",$ftarget))
	&& ( preg_match("/^bowl/",$ttarget))) {
		$htmout += $htmout_status("stone2bowl",$t,$x,$y,$g,$bxlim,$bylim,$bhandi,d,l,$ftarget,$ttarget);
		}
	if(( preg_match("/^bowl/",$ftarget))
	&& ( preg_match("/^stone/",$ttarget))) {
		$htmout += $htmout_status("bowl2stone",$t,$x,$y,$g,$bxlim,$bylim,$bhandi,d,l,$ftarget,$ttarget);
		}
	if(( preg_match("/^bowl/",$ftarget))
	&& ( preg_match("/^board/",$ttarget))) {
		$htmout += $htmout_status("bowl2bowl",$t,$x,$y,$g,$bxlim,$bylim,$bhandi,d,l,$ftarget,$ttarget);
		}
	if(( preg_match("/^bowl/",$ftarget))
	&& ( preg_match("/^lid/",$ttarget))) {
		$htmout += $htmout_status("bowl2lid",$t,$x,$y,$g,$bxlim,$bylim,$bhandi,d,l,$ftarget,$ttarget);
		}
	print("MSG_200 $htmout="+$htmout );
	return($htmout);
	}







function newpdo( $dbfile ) {
        $php_self=$_SERVER['PHP_SELF'];
        $http_host=$_SERVER['HTTP_HOST'];
        $request_uri=$_SERVER['REQUEST_URI'];

	if( ! file_exists( $dbfile )) {
		print( "$php_self newpdo ERR_3979:  NOT_EXISTS dbfile=[$dbfile]<br>\n" );
		if( $GLOBALS['install'] != true ) {
			print( "$php_self newpdo ERR:  NOT_INSTALL dbfile=[$dbfile]<br>\n" );
			return;
			}
		else {
			print( "$php_self newpdo MSG:  CREATE dbfile=[$dbfile]<br>\n" );
			}
		}

	try {
		$pdo = null;
		$pdo = new PDO("sqlite:$dbfile" );
		$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
//		$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
//		$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
		
		if( $pdo == null ) {
			print( "$php_self newpdo ERR:   dbfile=[$dbfile]<br>\n" );
			return $pdo;
			}
		return $pdo;
		}


	catch(PDOException $e ) {
		$errmsg = $e->getMessage();
		print( "$php_self newpdo ERR:  pdo=[$pdo] dbfile=[$dbfile] errmsg=[$errmsg]<br>\n" );
		$pdo = null;
		return $pdo;
		}
	}






//


koh5_pano



Your browser does not support the HTML5 canvas element.


Drag mouse to navigate.

Navigation





17.Aug.2010, Martin Wengenmayer