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

/home/kozerus/public_html/go

<?php

# kogo.php 20211212_1203	htmout_load $todo
# kogo.php 20211211_2211	fmt=json debug 
# kogo.php 20211210_1800 


$progid="kogo.php";
$dttm=date("Ymd_His");

	main('');


function main($args) {
	$htmout = "";
	$htmout .= "<h2>MSG_11 BEG main args=$args</h2>\n";
	$htmout .= htmout_head($args);
	$htmout .= htmout_load('../ko_styles.html');
	$htmout .= htmout_load('../ko_scripts.html');
	$htmout .= todos($args);
	$htmout .= startup_kogo("");
	$htmout .= "<h2>MSG_12 END main args=$args</h2>\n";
	$htmout .= htmout_tail($args);
	print($htmout);
	exit;	
	}

function todos($args) {
	$htmout = "";

	if( isset($_REQUEST['todo']) || isset($_REQUEST['todo'] )) {

		$todo="";

#		if( isset($_REQUEST['todo'] )) { 
#			$request=$_REQUEST['todo']; 
#			if( $request != "" ) { $todo=$request; }
#			print( "\n<h1>MSG_130 FINDIDS todo=$todo request=$request</h1><br>\n");
#			}
		if( isset($_REQUEST['fmt'] )) {$fmt=$_REQUEST['fmt'];}
$idfinds_ko='mp3s mp4s pdfs yts bcs txts htmls';

$idfinds='
ko|find pdf -type f -maxdepth 1 -name "*.pdf"
mp3s|find ../kb/aud/mp3 -type f -name "*.mp3"
mp4s|find ../kb/vid/jkwii -type f -maxdepth 1  -name "*.mp4"
pns|find ../pn/imgs -type f -maxdepth 1 -name "*.jpg"
pdf|find ../pdf -type f -maxdepth 1 -name "ko.pdf"
pdfs|find ../pdf -type f -maxdepth 1 -name "*.pdf"
yts|find yt/txt -type f -maxdepth 1 -name "ytlist_202111*.txt" -exec cat {} \; | grep "youtube" | head -100
bcs|find yt/txt -type f -maxdepth 1 -name "ytlist_202111*.txt" -exec cat {} \; | grep "bitchute" | head -100
htmls|find yt/txt -type f -maxdepth 1 -name "ytlist_202111*.txt" -exec cat {} \; | grep ".html" | head -100
pagesimgs|find ./pages -type f -maxdepth 1 -name "*.jpg"; find ./imgs -type f -maxdepth 1 -name "*.jpg" | grep -v "tn/";
pages|find fb/pages -type f -maxdepth 1 -name "*.jpg" 
pdfs1|find pdf -type f -maxdepth 1 -name "*.pdf"
fbd1|find fb -type d -maxdepth 1 -name "*"
txts|find txt -type f -maxdepth 2 -name "*.txt"
htms|find . -type f -maxdepth 1 -name "??.html"
dirs_mp3|find kb/aud -type d -maxdepth 3 -name "*"
dirs_mp4|find kb/vid -type d -maxdepth 3 -name "*"
dirs_pdf|find pdf -type d -maxdepth 3 -name "*"
dirs_yts|find yt/txt -type d -maxdepth 3 -name "ytlist_*.txt"
dirs_fb|find fb -type d -maxdepth 1 -name "*"
dirs_pn|find pn -type d -maxdepth 3 -name "*"
dirs_tl|find tl -type d -maxdepth 3 -name "*"
dirs_zn|find tl -type d -maxdepth 3 -name "*"
';

$idfinds_tests='
mp3_today|find kb/aud/mp3 -type f -name "library_of_congress.mp3"
mp4_today|find kb/aud/mp3 -type f -name "library_of_congress.mp3"
pdf_today|find kb/aud/mp3 -type f -name "library_of_congress.mp3"
txt_today|find kb/aud/mp3 -type f -name "library_of_congress.mp3"
htm_today|find kb/aud/mp3 -type f -name "library_of_congress.mp3"
yt_today|find kb/aud/mp3 -type f -name "library_of_congress.mp3"
fb_today|fb/mars
pn_today|pn/imgs/pano_creek.jpg
tl_todatoday|
zm_todatoday|
mp3s_n|find kb/aud/mp3 -type f -name "&ltn&gt.mp3"
mp4s2|find kb/vid/jkwii -type f -maxdepth &ltd&gt f -name "&ltn&gt.mp4"
mp4s_p|find kb/vid/&ltp&gt -type f -maxdepth &ltd&gt -name "&ltn&gt.mp4"
mp4s_n|find kb/vid/&ltp&gt -type f -maxdepth &ltd&gt -name "&ltn&gt.mp4"
mp4_p|find kb/vid -type d -maxdepth &ltd&gt -name "&ltn&gt"
yts|cat /yt/txt/ytlist.txt | grep "&ltn&gt" | head -100
yts_lim|cat /yt/txt/ytlist.txt | grep "&ltn&gt" | head -&ltlim&gt
ht_mp3|kb/aud/mp3/library_of_congress.mp3
ht_mp4|kb/vid/jkwii/dutch_jackson_weightup.mp4
ht_yt||https://www.youtube.com/watch?v=wQz5aG2tnd4|vladvt_megalithic_inca
ht_png|imgs/btn/koeye.png
ht_jpg|imgs/bg/bg_newton05b.jpg
ht_gif|imgs/gif/gifset_knots/knot1.gif
ht_zm|/index_zm.html
ht_zmd|/zm
ht_tl|/index_tl.html
ht_tld|/tl
find|find &ltp&gt -type f -maxdepth &ltlim&gt -name "&ltn&gt"
mp4s_jtfdc|find kb/vid -type f -name "jtfdc*.mp4"
gifd1|find imgs/gif -type d -maxdepth 2 -name "*"
gifs|find imgs/gif -type f -maxdepth 2 -name "*.gif"
pdfs|find pdf -type f -name "*.pdf"
pdfs2|find pdf/pdf -type f -maxdepth 1 -name "*.pdf"
fbd1|find fb -type d -maxdepth 1 -name "*"
fbds|find fb -type d -name "*"
pages|find fb/pages -type f -maxdepth 1 -name "*.jpg" \| head -5
pages_fb|find fb/pages -type f -maxdepth 1 -name "*.jpg"
pagesimgs|find ./pages -type f -maxdepth 1 -name "*.jpg"; find ./imgs -type f -maxdepth 1 -name "*.jpg";
topdirs|find / -type d -maxdepth 1 -name "??";
sh_ka1|./ka1.sh
sh_cp|find ./pages -type f -maxdepth 1 -name "*.jpg" | awk \'{ print "convert "$0" -resize 200x tn/tn_"$0"  # "NF }\' | sed "s/jpg  /png  /"

sql3_sel_db3tbllim|sqlite3 &ltdb3&gt "sel * from &lttbl&gt limit &ltlim&gt";
sql3_sel_tbllim|sqlite3 ko.db3 "sel * from &lttbl&gt limit &ltlim&gt";
sql3_tables|sqlite3 ko.db3 .tables
sql3_schema|sqlite3 ko.db3 .schema
sql3_files|sqlite3 ko.db3 "select * from files"
sql3_mp3|sqlite3 ko.db3 "select * from mp3"
sql3_mp4|sqlite3 ko.db3 "select * from mp4"
sql3_mp3|sqlite3 ko.db3 "select * from jpg"
sql3_books|sqlite3 ko.db3 "select * from books"
fb/iperms/pages|find fb/iperms/pages -type f -maxdepth 1 -name "*.jpg"
fb/konet/pages|find fb/konet/pages -type f -maxdepth 1 -name "*.jpg"
fb/jtfdc/pages|find fb/jtfdc_pages -type f -maxdepth 1 -name "*.jpg"
fb/jtfdcr/pages|find fb/jtfdcr/pages -type f -maxdepth 1 -name "*.jpg"
fb/jtfinc/pages|find fb/jtfinc/pages -type f -maxdepth 1 -name "*.jpg"
fb/kt/pages|find fb/kt/pages -type f -maxdepth 1 -name "*.jpg"
fb/iperms/pages|find fb/iperms/pages -type f -maxdepth 1 -name "*.jpg"
fb/konet/pages|find fb/konet/pages -type f -maxdepth 1 -name "*.jpg"
fb/jtfdc/pages|find fb/jtfdc_pages -type f -maxdepth 1 -name "*.jpg"
fb/jtfdcr/pages|find fb/jtfdcr/pages -type f -maxdepth 1 -name "*.jpg"
fb/jtfinc/pages|find fb/jtfinc/pages -type f -maxdepth 1 -name "*.jpg"
fb/kt/pages|find fb/kt/pages -type f -maxdepth 1 -name "&ltn&gt.jpg"
fb/go/pages|find fb/go/pages -type f -maxdepth 1 -name "&ltn&gt.jpg"
fb/kou/pages|find fb/kou/pages -type f -maxdepth 1 -name "&ltn&gt.jpg"
fb/royal1/pages|find fb/royal1/pages -type f -maxdepth 1 -name "&ltn&gt.jpg"
fb/iperms/imgs|find fb/iperms/imgs -type f -maxdepth 1 -name "&ltn&gt.jpg"
fb/konet/imgs|find fb/konet/imgs -type f -maxdepth 1 -name "&ltn&gt.jpg"
fb/jtfdc/imgs|find fb/jtfdc_imgs -type f -maxdepth 1 -name "&ltn&gt.jpg"
fb/jtfdcr/imgs|find fb/jtfdcr/imgs -type f -maxdepth 1 -name "&ltn&gt.jpg"
fb/jtfinc/imgs|find fb/jtfinc/imgs -type f -maxdepth 1 -name "&ltn&gt.jpg"
fb/kt/imgs|find fb/kt/imgs -type f -maxdepth 1 -name "&ltn&gt.jpg"
fb/go/imgs|find fb/go/imgs -type f -maxdepth 1 -name "&ltn&gt.jpg"
fb/kou/imgs|find fb/kou/imgs -type f -maxdepth 1 -name "&ltn&gt.jpg"
fb/royal1/imgs|find fb/royal1/imgs -type f -maxdepth 1 -name "&ltn&gt.jpg"
tls|find tl -type f -maxdepth 1 -name "&lt*&gt.json"
zms|find zm -type f -name "0-0-0.jpg"
pns|find pn -type f -name "*.jpg"
du|du -h -d 1 .
du_dp|du -h -d &ltd&gt
';


# du -h --max-depth 1 .	# bh
# du -h -d 1 .		# depth 1
# du -h -depth .	# depthtot







#		print( "<h1>BUGS_310 todo=$todo idfinds=$idfinds</h1><br>\n" );
		$ids=explode("\n",$idfinds);
		$htmout="";
		$list="";
		$todo="";
		if( isset($_REQUEST['todo'])) { $todo=$_REQUEST['todo']; }
		$db2=""; if( isset($_REQUEST['db2'])) { $db3=$_REQUEST['db2']; }
		$db3=""; if( isset($_REQUEST['db3'])) { $db3=$_REQUEST['db3']; }
		$tbl=""; if( isset($_REQUEST['tbl'])) { $tbl=$_REQUEST['tbl']; }
		$sel=""; if( isset($_REQUEST['sel'])) { $sel=$_REQUEST['sel']; }
		$fld=""; if( isset($_REQUEST['fld'])) { $fld=$_REQUEST['fld']; }
		$val=""; if( isset($_REQUEST['val'])) { $val=$_REQUEST['val']; }
		$fmt=""; if( isset($_REQUEST['fmt'])) { $fmt=$_REQUEST['fmt']; }
		$lim=""; if( isset($_REQUEST['lim'])) { $lim=$_REQUEST['lim']; }

		$a=""; if( isset($_REQUEST['a'])) { $a=$_REQUEST['a']; }
		$b=""; if( isset($_REQUEST['b'])) { $b=$_REQUEST['b']; }
		$c=""; if( isset($_REQUEST['c'])) { $c=$_REQUEST['c']; }
		$d=""; if( isset($_REQUEST['d'])) { $d=$_REQUEST['d']; }
		$d=""; if( isset($_REQUEST['d'])) { $d=$_REQUEST['d']; }
		$e=""; if( isset($_REQUEST['e'])) { $e=$_REQUEST['e']; }
		$f=""; if( isset($_REQUEST['f'])) { $f=$_REQUEST['f']; }
		$g=""; if( isset($_REQUEST['g'])) { $g=$_REQUEST['g']; }
		$h=""; if( isset($_REQUEST['h'])) { $h=$_REQUEST['h']; }
		$i=""; if( isset($_REQUEST['i'])) { $i=$_REQUEST['i']; }
		$j=""; if( isset($_REQUEST['j'])) { $j=$_REQUEST['j']; }
		$k=""; if( isset($_REQUEST['k'])) { $k=$_REQUEST['k']; }
		$l=""; if( isset($_REQUEST['l'])) { $l=$_REQUEST['l']; }
		$m=""; if( isset($_REQUEST['m'])) { $m=$_REQUEST['m']; }
		$n=""; if( isset($_REQUEST['n'])) { $n=$_REQUEST['n']; }
		$o=""; if( isset($_REQUEST['o'])) { $o=$_REQUEST['o']; }
		$p=""; if( isset($_REQUEST['p'])) { $p=$_REQUEST['p']; }
		$q=""; if( isset($_REQUEST['q'])) { $q=$_REQUEST['q']; }
		$r=""; if( isset($_REQUEST['r'])) { $r=$_REQUEST['r']; }
		$s=""; if( isset($_REQUEST['s'])) { $s=$_REQUEST['s']; }
		$t=""; if( isset($_REQUEST['t'])) { $t=$_REQUEST['t']; }
		$u=""; if( isset($_REQUEST['u'])) { $u=$_REQUEST['u']; }
		$v=""; if( isset($_REQUEST['v'])) { $v=$_REQUEST['v']; }
		$w=""; if( isset($_REQUEST['w'])) { $w=$_REQUEST['w']; }
		$x=""; if( isset($_REQUEST['x'])) { $x=$_REQUEST['x']; }
		$y=""; if( isset($_REQUEST['y'])) { $y=$_REQUEST['y']; }
		$z=""; if( isset($_REQUEST['z'])) { $z=$_REQUEST['z']; }


		$ids=explode("\n",$idfinds);
		$htmout="";
		$list="";
		$fmt="";
		if( isset($_REQUEST['fmt'])) { $fmt=$_REQUEST['fmt']; }
		if(( $todo === "" ) || ( $todo == 0 )) {
#			print( "<h1>BUGS_782 todo=$todo</h1><br>\n" );
			$htmout .= "<html>\n";
			$htmout .= "<head>\n";
			$htmout .= "	<title>$progid $dttm todo</title>\n";
			$htmout .= "	</head>\n";
			$htmout .= "<body bgcolor=linen>\n";
#			$htmout .= "<h1>todo</h1>\n";
			$htmout .= "<a href=/index.html target=_blank>";
			$htmout .= "<img src=ko.png height=20>";
			$htmout .= "</a>\n";
			$htmout .= "&nbsp &nbsp &nbsp &nbsp";
			$htmout .= "$progid $dttm";
			$htmout .= "<hr color=goldenrod>\n";
			$htmout .= "<table id=table_todo>";
			$htmout .= "<tr><td>j</td><td width=100 >url</td><td width=125>id</td><td width=400>find</td></tr>\n";
			for( $j=0; $j<count($ids); $j++ ) {
				$line=$ids[$j];
				$list .= $line;
				if( $line === "" ) { continue; }
				if( preg_match("/^#/", $line, $matches )) { continue; }

				if( preg_match("/^</", $line, $matches)) { 
#					$list .= $line;
#					$htmout .= $line;
#					print( "<h2>MSG_385 HTMFMT line=$line</h2><br>\n" );
					continue;
					}


				$id=explode("|",$line)[0];
				if( $id === "" ) { continue; }
				$find="";
				if( count(explode("|", $line)) > 1 ) {
					$idpipe=$id."|";
					$find=str_replace($idpipe,"",$line);
					}
				else {
					$find=explode("|",$line)[1];
					}
				$matches2="";

//				print( "<h1>BUGS_680 todo=$todo j=$j id=$id line=$line</h1><br>\n" );


				$find=str_replace('&ltfmt&gt',$fmt, $find, $matches2);
				$find=str_replace('&ltlim&gt',$lim, $find, $matches2);
				$find=str_replace('&ltdb3&gt',$db3, $find, $matches2);
				$find=str_replace('&lttbl&gt',$tbl, $find, $matches2);
				$find=str_replace('&ltsel&gt',$sel, $find, $matches2);
				$find=str_replace('&ltfld&gt',$fld, $find, $matches2);

				$find=str_replace('&lta&gt',$a, $find, $matches2);
				$find=str_replace('&ltb&gt',$b, $find, $matches2);
				$find=str_replace('&ltc&gt',$c, $find, $matches2);
				$find=str_replace('&ltd&gt',$d, $find, $matches2);
				$find=str_replace('&lte&gt',$e, $find, $matches2);
				$find=str_replace('&ltf&gt',$f, $find, $matches2);
				$find=str_replace('&ltg&gt',$g, $find, $matches2);
				$find=str_replace('&lth&gt',$h, $find, $matches2);
				$find=str_replace('&lti&gt',$i, $find, $matches2);
				$find=str_replace('&ltj&gt',$j, $find, $matches2);
				$find=str_replace('&ltk&gt',$k, $find, $matches2);
				$find=str_replace('&ltl&gt',$l, $find, $matches2);
				$find=str_replace('&ltm&gt',$m, $find, $matches2);
				$find=str_replace('&ltn&gt',$n, $find, $matches2);
				$find=str_replace('&lto&gt',$o, $find, $matches2);
				$find=str_replace('&ltp&gt',$p, $find, $matches2);
				$find=str_replace('&ltq&gt',$q, $find, $matches2);
				$find=str_replace('&ltr&gt',$r, $find, $matches2);
				$find=str_replace('&lts&gt',$s, $find, $matches2);
				$find=str_replace('&ltt&gt',$t, $find, $matches2);
				$find=str_replace('&ltu&gt',$u, $find, $matches2);
				$find=str_replace('&ltv&gt',$v, $find, $matches2);
				$find=str_replace('&ltw&gt',$w, $find, $matches2);
				$find=str_replace('&ltx&gt',$x, $find, $matches2);
				$find=str_replace('&lty&gt',$y, $find, $matches2);
				$find=str_replace('&ltx&gt',$z, $find, $matches2);
# 				print( "<h3>BUGS_460 j=$j id=$id p=$p find=$find</h3>\n") ;
				$k=$j+1;
				$htmout .= "<tr>";
				$htmout .= "<td>$k</td>";
				$htmout .= "<td width=100>";
				$htmout .= "<a href=/ko.php?todo=$id target=_blank>\n";
				$htmout .= "<img src=/imgs/btn/koeye.png height=25>";
				$htmout .= "</a>";
				$htmout .= "</td>\n";
				$htmout .= "<td width=125><b>$id</b></td>";
				$htmout .= "<td width=470>$find</td>";
				$htmout .= "</tr>";
				}
			$htmout .= "	</table>";
			$htmout .= "<hr color=goldenrod>\n";
			$htmout .= "	</body>\n";
			$htmout .= "	</html>\n";
			if( $fmt == "list" ) {	print( $list ); }
			else { 			print( $htmout ); }
			exit;
			}

		$todo=""; if( isset( $_REQUEST['todo'] )) { $todo=$_REQUEST['todo']; }

		$min=1; $max=3;	
		if( $todo == "ko" ) {
			$id=$todo;
			$min=0;$max=0;
			$min=1; $max=count(explode(" ",$idfinds_ko))-1;
			$random=random_int($min,$max);
			$todo=explode(" ",$idfinds_ko)[$random];
			}

		for( $j=0; $j<count($ids); $j++) {
			$line=$ids[$j];
			$id=explode("|",$line)[0];
#			print( "<h1>BUGS_871 j=$j id=$id line=$line todo=$todo</h1><br>\n" );
			if( $id === "" ) { continue; }
			if( $id != $todo ) {continue; }
#			print( "<h1>BUGS_873 MATCH j=$j id=$id= todo=$todo= line=$line todo=$todo</h1><br>\n" );

#			$find=explode("|",$line)[1];
			$find=str_replace("$id|","", $line);
#			print( "<h1>BUGS_675 id=$id find=$find line=$line</h1>" );

			$list="";
			$url=$find;

			$url = urlcheck($url);
		

#			print( "<h1>MSG_661 query_string=$query_string name=name  id=$id find=$find</h1><br>\n" );
			$find=str_replace_all($find);

#			$find=str_replace("&ltn&gt", "$name", $find );
#			print( "<h1>MSG_900 j=$j k=$k todo=$todo id=$id find=$find</h1><br>\n" );
			$out = "";



# pqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpq
			exec( $find, $out, $err );
# bdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbdbd

			$outcnt=count($out);
//			print( "<h1>BUGS_900 fmt=$fmt out=".$out[2]."</h1>" );
			$psv="";
			$csv="";
			$txt="";
			$json="";
			$json.="{\"todo\": [\n";

			$dttm=date('Ymd_His');
			$htmout = "";
			$htmout .= "<html>\n";
			$htmout .= "<head>\n";
			$htmout .= "	<title>todo=$todo $dttm</title>\n";
$icon="./favicon_ko64.ico";
#			$htmout .= "<link rel=\"icon\" href=\"$icon\" type=\"image/icon\">\n";
$icon_png="koeye.png";
$icon_png="ko.png";
$icon_gif="koeye_handhither.gif";
#			$htmout .= "<link rel=\"icon\" href=\"$icon_png\" type=\"image/png\">\n";
			$htmout .= "<link rel=\"icon\" href=\"$icon_gif\" type=\"image/gif\">\n";

			$htmout .= "	</head>\n";
			$htmout .= "<body bgcolor=linen>\n";
			$htmout .= "	<div id=div_todo_$todo>\n";
			$htmout .= "	<h1>div_todo_$todo</h1>\n";
			$htmout .= "	<hr color=goldenrod>\n";

			for( $j=0; $j< count($out); $j++ ) {
				$line= $out[$j];
				$txt .= $line."\n";
				$psv .= $line."|\n";
				$csv .= $line.",";
				$json .= "{ \"j\":\"".$j."\", \"line\":\"".$line."\" },\n";	
				}

			$psv .= preg_replace("/|$/", "", $psv );
			$csv .= preg_replace("/|/", ",", $psv );
//			$json .= preg_replace("/},$/", "}", $json );
//			$json .= str_lreplace( ",$", "", $json );
			$j=""; $line="";
			$json .= "{ \"j\":\"".$j."\", \"line\":\"".$line."\" }\n";	
//			$json .= str_replace_last( ",", "" , $json );
			$json .="]}\n\n"; 

			$fmt="";
			if( isset( $_REQUEST['fmt'] )) {$fmt=$_REQUEST['fmt']; }
//			print( "<h1>BUGS_925 fmt=$fmt</h1>\n" );
			if( $fmt == "txt" ) { 
				header('Content-type: text/plain');
				print($txt); exit(); 
				}
			if( $fmt == "list" ) { print($txt);exit(); }
			if( $fmt == "psv" ) { print($psv); exit(); }
			if( $fmt == "csv" ) { 
				header('Content-type: text/csv');
				print($csv); exit(); 
				}
			if( $fmt == "json" ) { 
				header('Content-type: application/json');
				print( $json );
				exit();
				}

##			$k=1;
##			$line=$out[$k];
#			print( "<h1>MSG_691 k=$k line=$line</h1>" );	
#			print( "<h1>MSG_700 k=$k id=$id find=$find outcnt=$outcnt out0=".$out[0]." </h1><br>\n" );
#			print( "<h2>MSG_704 out4=".$out[4]."</h2>" );
#			print( "<h2>MSG_705 out5=".$out[5]."</h2>" );
#			print( "<h2>MSG_706 out6=".$out[6]."</h2>" );
#			print( "<h2>MSG_707 out7=".$out[7]."</h2>" );

			$htmout_table = "";
			$htmout_table .= "<table id=table_media>\n";
			$htmout_table .= "<tr>";
			$htmout_table .= "<td>j</td>";
			$htmout_table .= "<td>k</td>";
			$htmout_table .= "<td>tot</td>";
			$htmout_table .= "<td>link</td>";
			$htmout_table .= "<td>group</td>";
			$htmout_table .= "<td width=400>base bugs_700</td>";
			$htmout_table .= "</tr>";
#			$htmout_table .= "</table>";

			$txt = "";
			$psv = "";
			$csv = "";
			$sql = "";
			$sql .= "insert into table files (\n";
			$json = "";
			$json .= "{\n";

#			print( "<h1>BUGS_710 skiplist $htmout_table</table></h1>" );
			$out_skiplist = skiplist($out);
			$out=$out_skiplist;

			$j=0; $k=0;
			for( $j=0; $j<count($out); $j++ ) {
				$k=$j+1;
				$line = $out[$j]."\n";
				$list .= $line."\n";
				$pathfile = $line;
#				print( "<h1>BUGS_950 j=$j k=$k line=$line</h1>" );

				
#				$extension = pathinfo($pathfile, PATHINFO_EXTENSION);
				$dirname=dirname($pathfile);
				$group = str_replace("/","_", $dirname );
				$temp= explode('.',$pathfile);
				$ext = end($temp);
				$base=basename($pathfile,".$ext");
	
				$link  = htmout_link($pathfile,'');
#				$url=$pathfile;
#				$tn="/imgs/btn/koeye.png";

				$txt .= "$line\n";
				$psv .= "$j|$k|$outcnt|$pathfile|$link|$group|$base\n";
				$csv .= "$j,$k,$outcnt,$pathfile,$link,$group,$base\n";

				$sql .= "( 'j','k','outcnt',pathfile,'link','group','base' ),";

				
				$json .= "{\n";
				$json .= "'j':'$k', ";
				$json .= " 'k':'$k', ";
				$json .= "'outcnt':'$outcnt', ";
				$json .= "'pathfile':'$pathfile', ";
				$json .= "'link':'$link', ";
				$json .= "'group':'$group', ";
				$json .= "'base':'$base' ";
				$json .= "},\n";


				$htmout_table .= "<tr>";
				$htmout_table .= "<td>$j</td>";
				$htmout_table .= "<td>$k</td>";
				$htmout_table .= "<td>$outcnt</td>";
				$htmout_table .= "<td>".htmout_link($pathfile,'')."</td>";
#				$htmout_table .= "<td><img src=/imgs/btn/koeye_handhither.gif height=100></td>";
				$htmout_table .= "<td>$group</td>";
				$htmout_table .= "<td>$base</td>";
				$htmout_table .= "</tr>\n";
#				print( "<h3>BUGS_740 j=$j k=$k outcnt=$outcnt group=$group base=$base ext=$ext </h3>" );
				$htmout_link=htmout_link($pathfile,'');
#				print( "<h3>BUGS_710 j=$j k=$k pathfile=<$pathfile></h3>" );
#				print( "<h3>BUGS_711 j=$j k=$k  htmout_link=<$htmout_link></h3>" );
				}
	
			
			$json .= "	}\n";
			$matches = "";
			$json = preg_replace( "/,}$/", "}", $matches );
			$sql = preg_replace( "/,\)$/", ")", $matches );
			$psv = preg_replace( "/|$/", "", $matches );
			$csv = preg_replace( "/,$/", "", $matches );

			$htmout_table .= "	</table>";
			$htmout .= "<hr color=goldenrod>";
			$htmout .= $htmout_table;
			$htmout .= "<hr color=goldenrod>";
			$htmout .= "	</body>\n";
			$htmout .= "	</html>\n";

		
			$fmt="";
			if( isset($_REQUEST['fmt'])) { $fmt=$_REQUEST['fmt']; }
#			print( "<h1>BUGS_1000 find=$find fmt=$fmt</h1>" );
			if( $fmt == "txt" ) { print( $txt ); exit; }
			if( $fmt == "psv" ) { print( $psv ); exit; }
			if( $fmt == "csv" ) { print( $csv ); exit; }
			if( $fmt == "sql" ) { print( $sql ); exit; }
			if( $fmt == "json" ) { 
   				header('Content-type: application/json');
				print( $json ); 
				exit; 
				}
			if( $fmt == "html" ) { print( $htmout ); exit; }
			print($htmout); exit;
			print( "<h3>BUGS_1021 j=$j k=$k outcnt=$outcnt group=$group base=$base ext=$ext </h3>" );
			}
		$outcnt="";
		$group="";
		$base="";
		$ext="";
#		print( "<h3>BUGS_1022 j=$j k=$k outcnt=$outcnt group=$group base=$base ext=$ext </h3>" );
		return($htmout);
		exit;
		}





	$htmout .= "<h3>MSG_20 todos args=$args</h3>\n";	









	return($htmout);
	}



function startup_kogo($args) {
#	print( "<h1>BUGS_10 startup_kogo args=$args</h1>\n" );

# kogo init
	$db3fil="kogo.db3";
	$tbl="games";
	$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');
	$htmout = "";

	$htmout .= htmout_head("");



	if( ! isset($_REQUEST['kogo'])) {
$game = 'gid|bxlim|bylim|bhandi|t|x|y|g|l|d|pb|pw|lidb|lidw|dttm|status|note
1|1|1
1|1|2
1|1|3
1|2|1
1|2|2
1|2|3
1|3|1
1|3|2
1|3|3
';
		$htmout .= htmout_kogo_form("");
		$htmout .= htmout_kogo_gamedata($game);
		$htmout .= htmout_board($game);
		$htmout .= htmout_stones($game);
		$htmout .= htmout_lids($game);
		$htmout .= "	</body>\n";
		$htmout .= "</html>\n";
		print( $htmout );
		return( $htmout );
		}

# kogo_isset
	$bxlim=9; $bylim=9; $bhandi=9;
	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['txy'] )) {
		$txy=$_REQUEST['txy'];
		$t=explode(",",$txy)[0];
		if( count(explode(",",$txy)) > 1 ) {$x=explode(",",$txy)[1]; }
		if( count(explode(",",$txy)) > 2 ) {$y=explode(",",$txt)[2];}
		}

#	if( preg_match("/.,.,.$/",$kogo)) {
	if( count(explode(",",$kogo)) > 1 ) {
		$txy=str_replace("add","",$kogo);
		$t=explode(",",$txy)[0];
		$x=explode(",",$txy)[1];
		$y=explode(",",$txy)[2];
		if( preg_match("/^a/",$t)) {
			$t=explode(",",$txy)[1];
			$x=explode(",",$txy)[2];
			$y=explode(",",$txy)[3];
			}
		$x=explode(",",$txy)[1];
		$y=explode(",",$txy)[2];
		}
#	print( "<h1>MSG_84 kogo=$kogo t=$t x=$x y=$y</h1>\n" );


	if ( isset($_REQUEST['step'] )) {$step=$_REQUEST['step'];}
	if ( isset($_REQUEST['gid'] )) {$gid=$_REQUEST['gid'];}
	if ( isset($_REQUEST['bhid'] )) {$bhid=$_REQUEST['bhid'];}
	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'];}
	if ( ! isset( $htmout )) { $htmout = ""; }
# kogo_match ========================
	if( preg_match("/new/", $kogo )) {
#		$htmout = "";
		$htmout .= kogo_new($db3fil,$tbl,$kogo,$t,$x,$y,$g,$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid);
		$htmout .= "<h3>kogo_new $db3fil,$tbl,$kogo</h3><h2>$t,$x,$y,$g</h2>$bxlim,$bylim,$bhandi</h1>$l,$d,$moves,$pb,$pw,$gid\n";
		print($htmout);
		return($htmout);	
		}
	if( preg_match("/add/", $kogo )) {
#		$htmout="";
		$htmout .= kogo_add($db3fil,$tbl,$kogo,$t,$x,$y,$g,$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid);
		$htmout .= "<h3>kogo_add $db3fil,$tbl,$kogo</h3><h2>$t,$x,$y,$g</h2>$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid)";
		print($htmout);
		return($htmout);
		}
	if( preg_match("/del/", $kogo )) {
#		$htmout="";
		$htmout .= kogo_del($db3fil,$tbl,$kogo,$t,$x,$y,$g,$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid);
		return($htmout);
		}
	if( preg_match("/upd/", $kogo )) {
#		$htmout = "";
		$htmout .= kogo_upd($db3fil,$tbl,$kogo,$t,$x,$y,$g,$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid);
		return($htmout);
		}
	if( preg_match("/sel/", $kogo )) {
#		$htmout = "";
		$htmout .= kogo_sel($db3fil,$tbl,$kogo,$t,$x,$y,$g,$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid);
		$htmout .= "<h3>kogo_sel$db3fil,$tbl,$kogo</h3><h2>$t,$x,$y,$g</h2>$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid\n";
		print($htmout);
		return($htmout);
		}
	}

# kogo ========================
function kogo_new($db3fil,$tbl,$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($db3fil,$tbl,$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($db3fil,$tbl,$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($db3fil,$tbl,$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($db3fil,$tbl,$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_db3drop($db3fil,$tbl) {
	$htmout = "";
	$sql_drop = "";
	$sql_drop .= "drop table if exists $tbl";
#	$htmout .= "<h1>BUGS_150 DB3DROP db3fil=$db3fil tbl=$tbl sql_drop=$sql_drop</h1>\n";
	$pdo=newpdo($db3fil); 
	if($pdo) { 
		$pdo->exec($sql_drop); 
		$pdo=null;
		}
	return($htmout);
	}

function kogo_db3new($db3fil,$tbl,$kogo,$t,$x,$y,$g,$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid) {
	$htmout = "";
	$htmout .= kogo_db3drop($db3fil,$tbl);

	$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 .= "bylim 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";
#	print( "<h1>BUGS_140 sql_cr=$sql_cr</h1>\n");

	$pdo=newpdo($db3fil);
	if( $pdo ) {
		$pdo->exec($sql_cr);
		$pdo=null; 
		}
	$htmout .= "<h3>db3new db3fil=$db3fil tbl=$tbl sql_cr=$sql_cr<h3>\n";


	$htmout .= kogo_db3add($db3fil,$tbl,$kogo,$t,$x,$y,$g,$bxlim,$bylim,$bhandi,$l,$d,$moves,$pb,$pw,$gid);
	return($htmout);
	}
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);
	if( $pdo ) {
		$pdo->exec($sql_add);
		$pdo=null; 
		}
#	print( "<h1>MSG_200 sql_add=$sql_add db3fil=$db3fil tbl=$tbl</h1>\n" );
	$htmout = "";
	$htmout .= "<h3>MSG_250 db3fil=$db3fil tbl=$tbl sql_add=$sql_add</h3>\n";
	return($htmout);
	}

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) {
#	print( "<h1>BUGS_230 bxlim=$bxlim bylim=$bylim t=$t x=$x y=$y g=$g</h1>\n" );
	$htmout = "";
	$fmt=""; if( isset($_REQUEST['fmt'] )) { $fmt=$_REQUEST['fmt']; }
	if( isset($_REQUEST['db3fil'] )) { $db3fil=$_REQUEST['db3fil']; }
	if( isset($_REQUEST['tbl'] )) { $db3fil=$_REQUEST['tbl']; }
	$psv=""; $csv=""; $json="";  $txt="";
	$sql_sel="select * from $tbl";
#	$htmout .= "<h3>$db3fil $tbl sql_sel=$sql_sel</h3>\n";
	$pdo = newpdo($db3fil);
	$pdo->query($sql_sel);
	$progid="kogo";
	$dttm=date('Ymd_His');


#	$htmout="";
	$htmout .= "<div id=div_db3sel>";
	$htmout .= "<h2>$kogo $dttm $gid $bxlim $bylim $bhandi $pb $pw</h2>";
	$htmout .= "<table id=table_kogo_$gid>";
	$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";

	$sql=""; $lidb=""; $lidw="";


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

	$sql=""; $lidb=0; $lidw=0;
	$j=0;
	foreach($pdo->query($sql_sel) as $row ) {
		$j=$j+1;

	$sql=""; $lidb=0; $lidw=0;
		if( $row['db3fil'] ) { $dbfil=$row['db3fil']; }
		if( $row['tbl'] ) { $tbl=$row['tbl']; } 
#		if( $row['sql'] ) { $sql=$row['sql'];}
		if( $row['kogo'] ) { $kogo=$row['kogo']; }
		if( $row['t'] ) { $t=$row['kogo']; }
		if( $row['x'] ) { $x=$row['x'];}
		if( $row['y'] ) { $y=$row['y'];}
		if( $row['g'] ) { $g=$row['g'];}
		if( $row['bxlim'] ) { $bxlim=$row['bxlim'];}
		if( $row['bylim'] ) { $bylim=$row['bylim'];}
#		print_r($row);
#		print( "<h1>BUGS_290 bxlim=$bxlim bylim=$bylim</h1>\n" );
		if( $row['bhandi'] ) { $bhandi=$row['bhandi'];}
		if( $row['l'] ) { $l=$row['l'];}
		if( $row['d'] ) { $d=$row['d'];}
#		if( $row['lidb'] ) { $lidb=$row['lidb'];}
#		if( $row['lidw'] ) { $lidw=$row['lidw'];}
		if( $row['moves'] ) { $moves=$row['moves'];}
	
		if( $row['pb'] ) { $pb=$row['pb'];}
		if( $row['pb'] ) { $pb=$row['pb'];}
		if( $row['pw'] ) { $pw=$row['pw'];}
		if( $row['gid'] ) { $gid=$row['gid'];}
		if( $row['status'] ) { $status=$row['status'];} else { $status=""; }
		if( $row['dttm'] ) { $dttm=$row['dttm'];}
		if( $row['note'] ) { $note=$row['note'];}


		$json .= "{";
		$json .= '"db3fil":"$db3fil",';
		$json .= '"tbl":"$tbl",';
		$json .= '"sql":"$sql",';
		$json .= '"t":"$t",';
		$json .= '"x":"$x",';
		$json .= '"y":"$y",';
		$json .= '"bxlim":"$bxlim",';
		$json .= '"bylim":"$bylim",';
		$json .= '"bhandi":"$bhandi",';
		$json .= '"g":"$g",';
		$json .= '"l":"$l",';
		$json .= '"d":"$d",';
		$json .= '"lidb":"$lidb",';
		$json .= '"lidw":"$lidw",';
		$json .= '"pb":"$pb",';
		$json .= '"pw":"$pw",';
		$json .= '"gid":"$gid",';
		$json .= '"status":"$status",';
		$json .= '"dttm":"$dttm",';
		$json .= '"note":"$note"';
		$json .= '	},';

		$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; 
	$matches="";
	$csv=str_replace("|", $psv, $matches );


	$json .= '{';
	$json .= '"db3fil":"$db3fil",';
	$json .= '"tbl":"$tbl",';
	$json .= '"sql":"$sql",';
	$json .= '"t":"$t",';
	$json .= '"x":"$x",';
	$json .= '"y":"$y",';
	$json .= '"bxlim":"$bxlim",';
	$json .= '"bylim":"$bylim",';
	$json .= '"bhandi":"$bhandi",';
	$json .= '"g":"$g",';
	$json .= '"l":"$l",';
	$json .= '"d":"$d",';
	$json .= '"lidb":"$lidb",';
	$json .= '"lidw":"$lidw",';
	$json .= '"pb":"$pb",';
	$json .= '"pw":"$pw",';
	$json .= '"gid":"$gid",';
	$json .= '"status":"$status",';
	$json .= '"dttm":"$dttm",';
	$json .= '"note":"$note"';
	$json .= '	}';
	$json .= ' ]}';

	$htmout .= "	</table>\n";
	$htmout .= "	</div id=div_db3sel_end>\n";
	$htmout .= "<hr color=goldenrod>\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 ); 
		exit;
#		return( $json );
#		return("");
		}
	if( preg_match( "/html/", $fmt )) { 
		print($htmout);
		return($htmout);
		}
	return( $htmout );
	}

function htmout_head($args) {
	$htmout = "";
	$htmout .= "<html><head><title>ko.php 20211126_2030 $args</title>\n";
	$htmout .= "	</head>\n";
	$htmout .= "<body bgcolor=\"linen\" onload=\"startup($args); return false;\">\n";
	return($htmout);
	}

function htmout_load($htmfil) {
	$htmout = "";
        $f = fopen( $htmfil, "r" ) or die("<h1>ERR_100 OPEN htmfil=$htmfil</h1>" );
        $htmout .= fread($f, filesize($htmfil));
        fclose($f);
	return($htmout);
	}

function htmout_tail($args) {
	$htmout = "";
	$htmout .= "	</body>\n";
	$htmout .= "	</html>\n";
	return( $htmout );
	}












function htmout_kogo_gamedata($game) {
	$htmout = "";
	$htmout .= "<script id=script_gamedata>\n";
	$htmout .= "	function kogo_gamedata(args) {\n";
	$htmout .= "var kogo_gamedata = '\n";

	for( $j=0; $j<count(explode("\n",$game)); $j++ ) {
		$line=explode("\n",$game)[$j];
		if( $line == "" ) { continue; }
		$htmout .= "$line\n";
		}

	$htmout .= "';\n";
	$htmout .= "		return(kogo_gamedata);\n";
	$htmout .= "		}\n";
	$htmout .= "	</script>\n";
	return($htmout);
	}

function htmout_kogo_game($game) {
	$htmout = "";
	$htmout .= "<img  src=/imgs/btn/koeye.png id=img_kogo_game ";
	$htmout .= " onclick=\"toggle('div_kogo_game');return false;\" height=25>game\n";
	$htmout .= "<hr color=goldenrod>\n";
	$htmout .= "<div id=div_kogo_game>\n";
	$htmout .= "	<h1>div_kogo_game</h1>\n";
	$htmout_table = "";
	for( $j=0; $j<count(explode("\n",$game)); $j++ ) {
		$line = explode("\n",$game)[$j];
		if( $line == "" ) { continue; }
		if( $j == 0 ) {
			$flds=explode("|",$line);
			$gid=$flds[0];
			$bxlim=$flds[2];
			$bxylim=$flds[3];
			$bhandi=$flds[4];
			$t=$flds[5];
			$x=$flds[6];
			$y=$flds[7];
			$l=$flds[8];
			$d=$flds[9];
			$pb=$flds[10];
			$libb=$flds[11];
			$libw=$flds[12];
			$dttm=$flds[13];
			$status=$flds[14];
			$note=$flds[15];
#			($gid,$bxlim,$bylim,$bhandi,$t,$x,$y,$g,$l,$d,$pb,$pw,$lidb,$lidw,$dttm,$status,$note) = explode("|",$line));
			$htmout .= "<h1>$gid ($bxlim,$bylim,$bhandi) ($t,$x,$y,$g,$l)</h1>\n";
			$htmout_table .= "<table id=table_$gid>\n";
			}
		$t=explode("|",$line)[0];
		$x=explode("|",$line)[0];
		$y=explode("|",$line)[0];
		$g=$t;
		$l=4;
		$htmout_table .= "<tr>";
		$htmout_table .= "<td>$t</td>";
		$htmout_table .= "<td>$x</td>";
		$htmout_table .= "<td>$y</td>";
		$htmout_table .= "<td>$g</td>";
		$htmout_table .= "<td>$l</td>";
		$htmout_table .= "</tr>\n";
		}
	$htmout_table .= "	</table>\n";
	$htmout .= $htmout_table;
	$htmout .= "	</div id=div_kogo_game_end>\n";
	return($htmout);
	}


function htmout_board($game) {
	$htmout = "";
#	print( "<h1>BUGS_420 game=$game</h1>\n" );
	$gamelen = count(explode("\n",$game));

	$k=0;
	for( $j=0; $j<$gamelen; $j++ ) {
		$line = explode("\n",$game)[$j];
		if( $line =="" ) {continue;}
		$k=$k+1;
//		print( "<h1>BUGS_421 j=$j line=$line</h1>\n" );
		}
	$line=explode("\n",$game)[0];
	$flds=explode("|",$line);
	$fldslen = count(explode("|",$line));
//	print( "<h1>BUGS_421 gamelen=$gamelen fldslen=$fldslen line=$line</h1>\n" );
	$gid=$flds[0]; 
	if( $fldslen > 0 ) { $bxlim=$flds[1]; }
	if( $fldslen > 1 ) { $bylim=$flds[2]; }
	if( $fldslen > 2 ) { $bhandi=$flds[3]; }
	if( $fldslen > 3 ) { $t=$flds[4]; }
	if( $fldslen > 4 ) { $x=$flds[5]; }
	if( $fldslen > 5 ) { $y=$flds[6]; }
	if( $fldslen > 6 ) { $g=$flds[7]; }
	if( $fldslen > 7 ) { $l=$flds[8]; }
	if( $fldslen > 8 ) { $d=$flds[9]; }
	if( $fldslen > 9 ) { $pb=$flds[10]; }
	if( $fldslen > 10 ) { $libb=$flds[11]; }
	if( $fldslen > 11 ) { $libw=$flds[12]; }
	if( $fldslen > 12 ) { $dttm=$flds[13]; }
	if( $fldslen > 13 ) { $status=$flds[14]; }
	if( $fldslen > 14 ) { $note=$flds[15]; }

	$bt=0; $bx=0; $by=0;
	$board="";
	$gamelen=count(explode("\n",$game));
#	print( "<h1>BUGS_470 bx=$bx by=$by bt=$bt bxlim=$bxlim bylim=$bylim</h1>\n" );
	return("");
	for( $bx=0; $bx<$bxlim; $bx++ ) {
		for( $by=0; $by<$bylim; $by++ ) {
			$line=explode("\n",$game)[$bt];
			if( $line == "" ) { continue; }
			$flds=explode("|",$line);
			$fldslen=count($flds);
print( "BUGS_470 line=$line gamelen=$gamelen fldslen=$fldslen</h1>\n" );
			$t=$flds[0];
			if( $fldslen > 0 ) { $x=$flds[1]; }
			if( $fldslen > 1 ) { $y=$flds[2]; }
			if( $fldslen > 2 ) { $g=$flds[3]; }
			if( $fldslen > 3 ) { $l=$flds[4]; }
			if( $t == 0 ) {$bxby = ".";}
			else {
				if( isOdd($bt)) { $bxby = "*"; } else { $bxby = "o"; }
				}
			$board .= $bxby;
			if( $bx == $bxlim ) { $board .= "<br>\n"; }
			$bt=$bt+1;
			}
		}
	return( $board );

//	for( $j=1; $j<explode("\n",$game); $j++ ) {
//		$line = explode("\n",$game)[$j];
//		$t=explode(" ", $line)[0];
//		$x=explode(" ", $line)[1];
//		$y=explode(" ", $line)[2];
//		}
	return($htmout);
	}


function htmout_boardtime($game) {
	$htmout = "";
	$line = explode("\n",$game)[0];
	$flds=explode("|",$line);
	$gid=$flds[0];
	$bxlim=$flds[2];
	$bxylim=$flds[3];
	$bhandi=$flds[4];
	$t=$flds[5];
	$x=$flds[6];
	$y=$flds[7];
	$l=$flds[8];
	$d=$flds[9];
	$pb=$flds[10];
	$libb=$flds[11];
	$libw=$flds[12];
	$dttm=$flds[13];
	$status=$flds[14];
	$note=$flds[15];
#	($gid,$bxlim,$bylim,$bhandi,$t,$x,$y,$g,$l,$d,$pb,$pw,$lidb,$lidw,$dttm,$status,$note) = explode("|",$line));

	$j=1;
	$board="";
	for( $by=0; $by<$bylim; $by++ ) {
		for( $bx=0; $bx<$bxlim; $bx++ ) {
			$line = explode("\n",$game)[$j];
			$flds = explode(" ",$line);
			$t=flds[0];
			$x=flds[1];
			$y=flds[2];
			$g=flds[3];
			$l=flds[4];
			$board .= sprintf( "%3d|",$t );
			if( $bx == $bxlim ) { $board .= "<br>\n"; }
			$j=$j+1;
			}
		}
	return( $board );

//	for( $j=1; $j<explode("\n",$game); $j++ ) {
//		$line = explode("\n",$game)[$j];
//		$t=explode(" ", $line)[0];
//		$x=explode(" ", $line)[1];
//		$y=explode(" ", $line)[2];
//		}
	return($htmout);
	}


function htmout_stones($game) {
	$htmout = "";
	$line = explode("\n",$game)[0];
	$flds=explode("|",$line);
	$gid=$flds[0];
	$bxlim=$flds[2];
	$bxylim=$flds[3];
	$bhandi=$flds[4];
	$t=$flds[5];
	$x=$flds[6];
	$y=$flds[7];
	$l=$flds[8];
	$d=$flds[9];
	$pb=$flds[10];
	$libb=$flds[11];
	$libw=$flds[12];
	$dttm=$flds[13];
	$status=$flds[14];
	$note=$flds[15];
#	($gid,$bxlim,$bylim,$bhandi,$t,$x,$y,$g,$l,$d,$pb,$pw,$lidb,$lidw,$dttm,$status,$note) = explode("|",$line));
	return( $htmout );
	}

function htmout_lids($game) {
 	$htmout = "";
 	$line = explode("\n",$game)[0];
 	$flds=explode("|",$line);
 	$gid=$flds[0];
 	$bxlim=$flds[2];
 	$bxylim=$flds[3];
 	$bhandi=$flds[4];
 	$t=$flds[5];
 	$x=$flds[6];
 	$y=$flds[7];
 	$l=$flds[8];
 	$d=$flds[9];
 	$pb=$flds[10];
 	$libb=$flds[11];
 	$libw=$flds[12];
 	$dttm=$flds[13];
 	$status=$flds[14];
 	$note=$flds[15];
#	($gid,$bxlim,$bylim,$bhandi,$t,$x,$y,$g,$l,$d,$pb,$pw,$lidb,$lidw,$dttm,$status,$note) = explode("|",$line));
	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 htmout_kogo_form($args) {
	$htmout="";
	$htmout .= "<img src=/imgs/btn/koeye.png id=img_form_kogo ";
	$htmout .= " onclick=\"toggle('div_form_kogo','');return false;\" height=25>\n";
	$htmout .= "form_kogo\n";
	$htmout .= "<div id=div_form_kogo hidden>\n";
	$htmout .= "<h1>div_form_kogo</h1>\n";
	$htmout .= "<form id=form_kogo name=form_kogo action=\"/go/kogo.php?kogo=formback\" type=\"GET\">\n";
	$htmout .= "<table id=table_form_kogo>\n";
	$htmout .= "	<tr><td>db3fil</td><td><input type=text id=form_db3file name=form_db3file value='kogo.db3' ></td><tr>\n";
	$htmout .= "	<tr><td>db3fil</td><td><input type=text id=form_tbl name=form_tbl value='games' ></td><tr>\n";
	$htmout .= "	<tr><td>db3fil</td><td><input type=text id=form_t name=form_t value='0'  ></td>\<tr>n";
	$htmout .= "	<tr><td>db3fil</td><td><input type=text id=form_x name=form_x value='0'  ></td>\<tr>n";
	$htmout .= "	<tr><td>db3fil</td><td><input type=text id=form_y name=form_y value='0'  ></td>\<tr>n";
	$htmout .= "	<tr><td>db3fil</td><td><input type=text id=form_g name=form_g value='0'  ></td>\<tr>n";
	$htmout .= "	<tr><td>db3fil</td><td><input type=text id=form_bxlim name=form_bxlim value='9'  ></td>\<tr>n";
	$htmout .= "	<tr><td>db3fil</td><td><input type=text id=form_bylim name=form_bylim value='9'  ></td>\<tr>n";
	$htmout .= "	<tr><td>db3fil</td><td><input type=text id=form_bhandi name=form_bhandi value='9'  ></td>\<tr>n";
	$htmout .= "	<tr><td>db3fil</td><td><input type=text id=form_l name=form_l value='0'  ></td>\<tr>n";
	$htmout .= "	<tr><td>db3fil</td><td><input type=text id=form_d name=form_d value='0'  ></td>\<tr>n";
	$htmout .= "	<tr><td>db3fil</td><td><input type=text id=form_dttm name=form_dttm value='0'  ></td>\<tr>n";
	$htmout .= "	<tr><td>db3fil</td><td><input type=text id=form_status name=form_status value='0'  ></td>\<tr>n";
	$htmout .= "	<tr><td>db3fil</td><td><input type=text id=form_gid name=form_gid value=''  ></td>\<tr>n";
	$htmout .= "	<tr><td>db3fil</td><td><input type=text id=form_note name=form_note value='0'  ></td>\<tr>n";
	$htmout .= "	<tr><td>db3fil</td><td><input type=submit id=submit name=form_submit></td>\<tr>n";
	$htmout .= "	</table>\n";
	$htmout .= "	</form>\n";
	$htmout .= "	</div id=div_kogo_form_end>\n";
	return($htmout);
	}


function htmout_script_toggle($divid) {
# $script_toggle = <<<SCRIPT_TOGGLE
	$htmout_script= "";
 	$htmout_script.= "<script id=script_toggle>\n";
	$htmout_script .= " 		function toggle(divid) {\n";
	$htmout_script .= " 			var imgid=divid.replace(\"div_\",\"img_\" );\n";
	$htmout_script .= " 			if(! document.getElementById(divid)) { return; }\n";
	$htmout_script .= " \n";
	$htmout_script .= " 			var imgid=divid.replace(\"div_\",\"img_\" );\n";
	$htmout_script .= " 			style_display=document.getElementById(divid).style.display;\n";
	$htmout_script .= " 			\n";
	$htmout_script .= " 			if( style_display == \"none\" ) {\n";
	$htmout_script .= " 				img=\"<img src=/imgs/btn/koeyew.png id=\"+imgid+\" height=50 onclick=\"toggle('+divid+'); return false;\" >";
	$htmout_script .= " 				document.getElementById(divid).style.display=\"inline\";\n";
	$htmout_script .= " 				document.getElementById(imgid).innerHTML=img;\n";
	$htmout_script .= " 				document.getElementById(imgid).src=\"/imgs/btn/koeyew.png\";\n";
	$htmout_script .= " 				}\n";
	$htmout_script .= " 			else {\n";
	$htmout_script .= " 				img=\"<img src=/imgs/btn/koeyeb.png id=\"+imgid+\" height=50 onclick=\"toggle('+divid+'); return false;\" >";
	$htmout_script .= " 				document.getElementById(divid).style.display=\"none\";\n";
	$htmout_script .= " 				document.getElementById(imgid).innerHTML=img;\n";
	$htmout_script .= " 				document.getElementById(imgid).src=\"/imgs/btn/koeyeb.png\"";
	$htmout_script .= " 				}\n";
	$htmout_script .= " 			}\n";
	$htmout_script .= " 		</script>\n";
# <<<SCRIPT_TOGGLE;
#	print( "<h1>BUGS_660 htmout_script_toggle</h1>\n" );
 	return( $htmout_script );
	}

function str_replace_last( $search , $replace , $str ) {
	if( ( $pos = strrpos( $str , $search ) ) !== false ) {
	        $search_length  = strlen( $search );
		$str    = substr_replace( $str , $replace , $pos , $search_length );
		}
    return $str;
}

function isOdd($n) {
	if($n % 2 == 0 ) {return(0); } else { return(1); }
	}


function urlcheck($url) {	
	if( is_dir($url)) { window.location($url); exit; }
$urltypes = ".php .html .htm .mp3 .mp4 .jpg .pdf .txt";
	if( preg_match("/http/", $url, $matches )) { window.location($url); exit; }
#	print( "<h1>MSG_650 query_string=$query_string id=$id find=$find</h1><br>\n" );

#	$name="*";
	foreach( explode(" ", $urltypes) as $urltype ) {
		if( preg_match("/$urltype$/", $url, $matches )) {
			$htmout_link = "";
#			$htmout_link .= "<a href=$url target=_blank>";
#			$htmout_link .= "<img src=/imgs/btn/koeye.png height=20>";
#			$htmout_link .= "</a><br>\n";
#			$htmout_link .= "<img src=/imgs/btn/koeye.png height=20 onclick=\"window.location('$url');return false;\" >";
			print( "<h2>MSG_651 MATCH id=$id url=$url urltype=$urltype </h2><br>\n" );
			print( $htmout_link );
#			if( is_file($url)) { window.location($url); exit; }
			}
		}
	return($url);
	}


function skiplist($out) {
#$fbid1_skiplist="
#fb/chap01
#fb/chap02
#fb/chap03
#fb/imgs
#fb/i
#fb/extras
#";
#	for( $k=0; $k<count($out); $k++ ) {
#		if( $id === "fbd1" ) {
#			$skiplist=explode("\n",$fbid1_skiplist );
#			$skiplist_len=count($skiplist);
#			$fbid=$out[$k];
#			$tn=$fbid."/pages/tn/tn_1.png";
#
#//	print( "<h1>BUGS_240 $k fbid=$fbid tn=$tn</h1>\n" );
#			if(! is_file($tn)) { continue; }
#			for($i=0; $i<$skiplist_len; $i++ ) {
#				if( $skiplist[$i] === "" ) { continue; }
#				if( $fbid === $skiplist[$i] ) { continue; }
#				}
#			}
#		}

	return($out);
	}

function htmout_head_dup($args) {
	$htmout = "";
	$htmout .= "<html><head><title>ko.php 20211126_2030 $args</title>\n";
	$htmout .= "	</head>\n";
	$htmout .= "<body bgcolor=\"linen\" onload=\"startup($args); return false;\">\n";
	return($htmout);
	}

function htmout_load_dup($htmfil) {
	$htmout = "";
        $f = fopen( $htmfil, "r" ) or die("<h1>ERR_100 OPEN htmfil=$htmfil</h1>" );
        $htmout .= fread($f, filesize($htmfil));
        fclose($f);
	return($htmout);
	}

function htmout_tail_dup($args) {
	$htmout = "";
	$htmout .= "	</body>\n";
	$htmout .= "	</html>\n";
	return( $htmout );
	}


function htmout_link($pathfile,$tn) {
 	$htmout = "";
 	if( $pathfile == "" ) { return(""); }
 	if( $tn == "" ) { $tn="/imgs/btn/koeye.png"; }
 
  	if( preg_match("/.pdf/", $pathfile, $matches )) {
		$pathfile=str_replace("\n","",$pathfile );

 		$tn="/imgs/btn/btn_pdf1.png";
#  		$tn="/imgs/btn/koeye_pdf.png";
#  		$htmout .= "<a href=\"/pdf/web/viewer.html?file=/$pathfile\" target=_blank>";
#  		$htmout .= "<a href=\"/pdf/web/viewer.html?file=/$pathfile\" target=_blankk >";
#		$htmout .= "<a href=/pdf/web/viewer.html?file=/$pathfile target=_blank>";

		$htmout_pdf = "";
		$htmout_pdf .= "<a href=/pdf/web/viewer.html?file=/$pathfile>";
#  		$htmout_pdf .= "<img src=$tn alt=$tn height=50>";
		$htmout_pdf .= "<img src=/imgs/btn/koeye_pdf.png height=60>";
  		$htmout_pdf .= "</a>\n";
#		print( "<h1>BUGS_1320 htmout_pdf=$htmout_pdf</h1>" );		

		$query_string="";
		if( isset( $_SERVER['QUERY_STRING'] )) {
			$query_string = $_SERVER['QUERY_STRING'];
			}
		$htmout .= "<h1>BUGS_1610   pathfile=$pathfile query_string=$query_string</h1>";
#		$htmout = "<h1>BUGS BUGS BUGS_1325</h1>";
#		print( "<h1>BUGS_1324 htmout pathfile >>>>$pathfile<<<<</h1>" );
#		print( "<h1>BUGS_1325 htmout htmout_pdf >>>>$htmout_pdf<<<</h1>" );
#		print( "<h1>BUGS_1326 htmout query_string >>>>$query_string<<<<h1>" );
		return( $htmout_pdf );
  		}
  
  	if( preg_match("/.mp3/", $pathfile, $matches )) {
  		$tn="/imgs/btn/koeye_mp3.png";
  		$htmout .= "<a href=\"$pathfile\" target=_blank>";
  		$htmout .= "	<img src=$tn alt=$tn height=50>\n";
  		$htmout .= "	</a>\n";
  		}
  
  	if( preg_match("/.mp4/", $pathfile, $matches )) {
  		$tn="/imgs/btn/koeye_mp4.png";
  		$htmout .= "<a href=\"$pathfile\" target=_blank>";
  		$htmout .= "	<img src=$tn alt=$tn height=50>\n";
  		$htmout .= "	</a>\n";
  		}
  
  	if( preg_match("/.jpg/", $pathfile, $matches )) {
  		$basename=basename($pathfile);
  		$path=str_replace($basename,"",$pathfile );
  		$tn="$path/tn/tn_$basename";
  		$tn=str_replace(".jpg", ".png",$tn );
  		$htmout .= "<a href=\"$pathfile\" target=_blank>";
  		$htmout .= "	<img src=$tn alt=$tn height=50>\n";
  		$htmout .= "	</a>\n";
  		}
  
  	if( preg_match("/.txt/", $pathfile, $matches )) {
  		$tn="/imgs/btn/koeye_txt.png";
  		$htmout .= "<a href=\"$pathfile\" target=_blank>";
  		$htmout .= "	<img src=$tn alt=$tn height=50>\n";
  		$htmout .= "	</a>\n";
  		}
  
  	if( preg_match("/bitchute.com/", $pathfile, $matches )) {
		$line=$pathfile;
		$bcid="";
		$url="";
		if( count( explode("video/", $line)) > 0 ) {
			$bcid=explode("video/",$line)[1];
			}
#		print( "<h1>BUGS_1350 bcid=$bcid url=$url line=$line</h1>" );
# https://www.bitchute.com/video/gDceXFTxSDk9/
		$url="https://www.bitchute.com/video/$bcid";
		$htmout_bitchute = "";
		$htmout_bitchute .= "<a href=$url target=_blank>";
		$htmout_bitchute .= "<img src=/imgs/btn/koeye_youtube.png height=50>";
		$htmout_bitchute .= "</a>";
#		$htmout_bitchute .= "<br>";
#		$htmout_bitchute .= $url;
#		$htmout_bitchute .= "<br>";
#		$htmout_bitchute .= "<iframe src=https://www.bitchute.com/embed/$bcid/ width=100% height=100></iframe>";
#		$htmout_bitchute .= "<iframe src=https://www.bitchute.com/embed/yecefLsE44U/ width=100% height=300></iframe>";
#		$htmout_bitchute .= "iframe src=https://www.bitchute.com/embed/$bcid/ width=100% height=500"
		$htmout .= $htmout_bitchute;
		return($htmout);
		}

  	if( preg_match("/youtube.com/", $pathfile, $matches )) {
		$ytid="";
  		if( preg_match("/www.youtube.com\/embed\//", $pathfile, $matches )) {
  			$ytid=explode("embed/", $pathfile)[1];
  			}
  		else {
			$line=$pathfile;
			if( count(explode("=",$line)) > 0 ) {
				if( isset( explode("=", $pathfile)[1])) {
		  			$ytid=explode("=",$pathfile)[1];
					}
				}
			else {
	  			$ytid=$pathfile;
				}
			}

		$ytid = str_lreplace("\n","", $ytid );
		$label=explode("|",$pathfile)[0];
  		$tn="https://img.youtube.com/vi/$ytid/default.jpg";
# 		https://www.youtube.com/watch?v=BtccrKwRTEA
		$url="https://www.youtube.com/watch?v=$ytid";

#		print( "<h2>BUGS_1360 YOUTUBE  ytid=$ytid </h2>" );
#		print( "<h3>BUGS_1362 tn=$tn<h3>" );
#		print( "<h3>BUGS_1363 label=$label<h3>" );
#		print( "<h3>BUGS_1364 url=$url<h3>" );

  		$htmout .= "<a href=\"$url\" target=_blank>";
  		$htmout .= "	<img src=$tn alt=$tn height=50>\n";
  		$htmout .= "	</a>\n";

#		print( "<h1>BUGS_1381 YOUTUBE htmout=$htmout</h1>" );
#		print( "<h1>BUGS_1380 YOUTUBE pathfile=$pathfile</h1>" );
#		print( "<h1>BUGS_1381 YOUTUBE url=$url</h1>" );
#		print( "<h1>BUGS_1382 YOUTUBE label=$label</h1>" );
		return($htmout);
  		}

	if( $htmout == "" ) {
	 	$htmout .= "<a href=\"$pathfile\" target=_blank>";
	 	$htmout .= "	<img src=$tn height=50>\n";
	 	$htmout .= "	</a>\n";
		}
	return($htmout);
	}

function str_lreplace($search, $replace, $subject) {
	$pos = strpos($subject, $search);
	if($pos !== false) {
		$subject = substr_replace($subject, $replace, $pos, strlen($search));
		}

	return $subject;
	}



function htmout_list( $id, $list, $fmt ) {
  	print( "<h1>BUGS_1100 fmt=$fmt id=$id</h1>\n" );
# 	$fmt="json";
# 	if( $fmt == "" ) { $fmt="html"; }
#
  	$urlcols = "";
  	$pipecount=0;
  	$spacecount=0;
  	$j=0;$k=0; $filetest="";
  	$lines=explode("\n", $list );
  	$lines_len=count($lines);
  	print( "<h1>BUGS_1180 lines_len=$lines_len</h1><br>\n" );

#  check for url columns
# 	print( "<h1>BUGS_1085 j=$j k=$k filetest=$filetest utlcols=$urlcols</h1><br>\n" );


  	$lines = "";
  	$htmout = "";
  	$htmout .= "<div id=div_list_$id>\n";
  	$htmout .= "	<h1>div_list_$id</h1>\n";
  	$htmout .= "	<hr color=goldenrod>\n";
  	$htmout .= "	<table id=table_$id>\n";
  	$htmout .= "<tr>";

   	for( $k=0; $k<$delim_len; $k++ ) {
		$fld=explode("$delim", $line)[$k];
  		$htmout .= "<td>";
  		$htmout .= $fld;
  		$htmout .= "</td>";
  		}
  	$htmout .= "</tr>\n";
  	$htmout .= "	<tr><td>j</td><td>line</td></tr>\n";
  	$json = "";
  	$json = '{"list":[';
 	
  	$list_len=count(explode("\n",$list));
  	print( "<h1>BUGS_1100 fmt=$fmt list_len=$list_len </h1>\n");
#	print_r($list);
#	$fmt="html";
#	$delim="|";
	if( $fmt == "list" ) { 
		print( "<h1>BUGS_851 LIST j=$j list_len=$list_len line=$line </h1>\n");
		$lines .= "$line\n"; 
		print( "<h1>BUGS_852 LIST j=$j list_len=$list_len lines=$lines </h1>\n");
		}


	print( "BUGS_1140 fmt=$fmt json=$json" );
  	if( $fmt == "json" ) { 
  		$json .= "{";
		for( $k=0; $k<$delim_len; $k++ ) {
  			$fld=explode($delim,$line)[$k];
  			$json .= '"fld_$k":"$fld",';
			}	
  		$json .= "},";
  		}
# 	}
  	$json .= "]}";
 
   	$htmout .= "	</table>\n";
   	$htmout .= "	<hr color=goldenrod>\n";
   	$htmout .= "	</div>\n";


	alert( "<h1>BUGS_1800 ko.php htmout=$htmout</h1>" );
   
   	if( $fmt == "list" ) { return($lines); }
   	if( $fmt == "html" ) { return($htmout); }
   	if( $fmt == "json" ) { 
   		header('Content-type: application/json');
   		print( $json );
   		exit();
   		}
 
 	return($htmout);
	}





function str_replace_first($search, $replace, $subject) {
	$search = '/'.preg_quote($search, '/').'/';
	return preg_replace($search, $replace, $subject, 1);
	}

function str_replace_all($find) {
$a=""; $b=""; $c=""; $e=""; $f="";
$g=""; $h=""; $i=""; $j=""; $k="";
$l=""; $m=""; $n=""; $o=""; $p=""; 
$q=""; $r=""; $s=""; $t=""; $u="";
$v=""; $w=""; $x=""; $y=""; $z="";
$fmt=""; $lim=""; $db3=""; $tbl=""; $sel=""; $fld=""; $val="";
$matches="";
  
  
  		$a=""; if( isset($_REQUEST['a'] )) { $a=$_REQUEST['a']; }
  		$b=""; if( isset($_REQUEST['b'] )) { $b=$_REQUEST['b']; }
  		$c=""; if( isset($_REQUEST['c'] )) { $c=$_REQUEST['c']; }
  		$d=""; if( isset($_REQUEST['d'] )) { $d=$_REQUEST['d']; }
  		$e=""; if( isset($_REQUEST['e'] )) { $e=$_REQUEST['e']; }
  		$f=""; if( isset($_REQUEST['f'] )) { $f=$_REQUEST['f']; }
  		$g=""; if( isset($_REQUEST['g'] )) { $g=$_REQUEST['g']; }
  		$g=""; if( isset($_REQUEST['g'] )) { $g=$_REQUEST['g']; }
  		$h=""; if( isset($_REQUEST['h'] )) { $h=$_REQUEST['h']; }
  		$i=""; if( isset($_REQUEST['i'] )) { $i=$_REQUEST['i']; }
  		$j=""; if( isset($_REQUEST['j'] )) { $j=$_REQUEST['j']; }
  		$k=""; if( isset($_REQUEST['k'] )) { $k=$_REQUEST['k']; }
  		$l=""; if( isset($_REQUEST['l'] )) { $l=$_REQUEST['l']; }
  		$m=""; if( isset($_REQUEST['m'] )) { $m=$_REQUEST['m']; }
  		$n=""; if( isset($_REQUEST['n'] )) { $n=$_REQUEST['n']; }
  		$o=""; if( isset($_REQUEST['o'] )) { $o=$_REQUEST['o']; }
  		$p=""; if( isset($_REQUEST['p'] )) { $p=$_REQUEST['p']; }
  		$q=""; if( isset($_REQUEST['q'] )) { $q=$_REQUEST['q']; }
  		$r=""; if( isset($_REQUEST['r'] )) { $r=$_REQUEST['r']; }
  		$s=""; if( isset($_REQUEST['s'] )) { $s=$_REQUEST['s']; }
  		$t=""; if( isset($_REQUEST['t'] )) { $t=$_REQUEST['t']; }
  		$u=""; if( isset($_REQUEST['u'] )) { $u=$_REQUEST['u']; }
  		$v=""; if( isset($_REQUEST['v'] )) { $v=$_REQUEST['v']; }
  		$w=""; if( isset($_REQUEST['w'] )) { $w=$_REQUEST['w']; }
  		$x=""; if( isset($_REQUEST['x'] )) { $x=$_REQUEST['x']; }
  		$y=""; if( isset($_REQUEST['y'] )) { $y=$_REQUEST['y']; }
  		$z=""; if( isset($_REQUEST['z'] )) { $z=$_REQUEST['z']; }
  		$j=""; if( isset($_REQUEST['j'] )) { $j=$_REQUEST['j']; }
  		$j=""; if( isset($_REQUEST['j'] )) { $j=$_REQUEST['j']; }
  		$j=""; if( isset($_REQUEST['j'] )) { $j=$_REQUEST['j']; }
  		$j=""; if( isset($_REQUEST['j'] )) { $j=$_REQUEST['j']; }
  		$j=""; if( isset($_REQUEST['j'] )) { $j=$_REQUEST['j']; }
  		$j=""; if( isset($_REQUEST['j'] )) { $j=$_REQUEST['j']; }
  		$j=""; if( isset($_REQUEST['j'] )) { $j=$_REQUEST['j']; }
  		$j=""; if( isset($_REQUEST['j'] )) { $j=$_REQUEST['j']; }
  		$j=""; if( isset($_REQUEST['j'] )) { $j=$_REQUEST['j']; }
  		$j=""; if( isset($_REQUEST['j'] )) { $j=$_REQUEST['j']; }
  		$j=""; if( isset($_REQUEST['j'] )) { $j=$_REQUEST['j']; }
  		$j=""; if( isset($_REQUEST['j'] )) { $j=$_REQUEST['j']; }
  		$j=""; if( isset($_REQUEST['j'] )) { $j=$_REQUEST['j']; }
  		$j=""; if( isset($_REQUEST['j'] )) { $j=$_REQUEST['j']; }
  
 		$fmt=""; if( isset($_REQUEST['fmt'] )) { $a=$_REQUEST['fmt']; }
 		$lim=""; if( isset($_REQUEST['lim'] )) { $a=$_REQUEST['lim']; }
 		$db3=""; if( isset($_REQUEST['db3'] )) { $a=$_REQUEST['db3']; }
 		$tbl=""; if( isset($_REQUEST['tbl'] )) { $a=$_REQUEST['tbl']; }
 		$sel=""; if( isset($_REQUEST['sel'] )) { $a=$_REQUEST['sel']; }
 		$fld=""; if( isset($_REQUEST['fld'] )) { $a=$_REQUEST['fld']; }
 		$val=""; if( isset($_REQUEST['val'] )) { $a=$_REQUEST['val']; }
 
 		str_replace("&lta&gt", $a, $find, $matches );
 		str_replace("&ltb&gt", $b, $find, $matches );
 		str_replace("&ltc&gt", $c, $find, $matches );
 		str_replace("&ltd&gt", $d, $find, $matches );
 		str_replace("&lte&gt", $e, $find, $matches );
 		str_replace("&ltf&gt", $f, $find, $matches );
 		str_replace("&ltg&gt", $g, $find, $matches );
 		str_replace("&lth&gt", $h, $find, $matches );
 		str_replace("&lti&gt", $i, $find, $matches );
 		str_replace("&ltj&gt", $j, $find, $matches );
 		str_replace("&ltk&gt", $k, $find, $matches );
 		str_replace("&ltl&gt", $l, $find, $matches );
 		str_replace("&ltm&gt", $m, $find, $matches );
 		str_replace("&ltn&gt", $n, $find, $matches );
 		str_replace("&lto&gt", $o, $find, $matches );
 		str_replace("&ltp&gt", $p, $find, $matches );
 		str_replace("&ltq&gt", $q, $find, $matches );
 		str_replace("&ltr&gt", $r, $find, $matches );
 		str_replace("&lts&gt", $s, $find, $matches );
 		str_replace("&ltt&gt", $t, $find, $matches );
 		str_replace("&ltv&gt", $v, $find, $matches );
 		str_replace("&ltw&gt", $w, $find, $matches );
 		str_replace("&ltx&gt", $x, $find, $matches );
 		str_replace("&lty&gt", $y, $find, $matches );
 		str_replace("&ltz&gt", $z, $find, $matches );
 
 		str_replace("&ltfmt&gt", $fmt, $find, $matches );
 		str_replace("&ltlim&gt", $lim, $find, $matches );
 		str_replace("&ltdb3&gt", $db3, $find, $matches );
 		str_replace("&lttbl&gt", $tbl, $find, $matches );
 		str_replace("&ltsel&gt", $sel, $find, $matches );
 		str_replace("&ltfld&gt", $fld, $find, $matches );
 		str_replace("&lval3&gt", $val, $find, $matches );
 	return($find);
	}



# str_replace(html_entity_decode('&ndash;', ENT_COMPAT, 'UTF-8'), '', $string);
// Fix for mb overloading strlen option
function decodeString($str) {
	if (function_exists('mb_strlen')) { 
		$len = mb_strlen($str, '8bit');
		} 
	else {
		$len = strlen($str);
		}
	$ret = '';
	for ($i = 0; $i < $len; $i++) {
		$ret .= dechex(ord($str[$i])).' ';
		}
	return trim($ret);
	}
function decode1($str) {
$arr1 = explode(",","0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F");
$arr2 = explode(",","B,C,D,E,F");

	foreach($arr2 as $t1){
		foreach($arr1 as $t2){
			$val = $t1.$t2;
			$desc = str_replace(chr(hexdec($val)),"",$desc);
			}   
		}

// if need removing individual value
	$desc = str_replace(chr(hexdec('A2')),"",$desc);
#	$string = str_replace("\x96", "-", $string);
#	$new_string = str_replace('&#8211;', 'or', $string);
#	$arr_needle = array("This", "function");
#	$arr_replace = array("That", "method");
#	$source_string= "This is a replace string tutorial by using str_replace function.";
#	$str_replaced = str_replace($arr_needle, $arr_replace, $source_string);
	}


class  Input {
	static $errors = true;

	static function check($arr, $on = false) {
		if ($on === false) {
			$on = $_REQUEST;
			}
		foreach ($arr as $value) {	
			if (empty($on[$value])) {
				self::throwError('Data is missing', 900);
				}
			}
		}

	static function int($val) {
		$val = filter_var($val, FILTER_VALIDATE_INT);
		if ($val === false) {
			self::throwError('Invalid Integer', 901);
			}
		return $val;
		}

	static function str($val) {
		if (!is_string($val)) {
			self::throwError('Invalid String', 902);
			}
		$val = trim(htmlspecialchars($val));
		return $val;
		}

	static function bool($val) {
		$val = filter_var($val, FILTER_VALIDATE_BOOLEAN);
		return $val;
		}

	static function email($val) {
		$val = filter_var($val, FILTER_VALIDATE_EMAIL);
		if ($val === false) {
			self::throwError('Invalid Email', 903);
			}
		return $val;
		}

	static function url($val) {
		$val = filter_var($val, FILTER_VALIDATE_URL);
		if ($val === false) {
			self::throwError('Invalid URL', 904);
			}
		return $val;
		}
	
	static function throwError($error = 'Error In Processing', $errorCode = 0) {
		if (self::$errors === true) {
			throw new Exception($error, $errorCode);
			}
		}
	}


function db2($dbname,$server,$user,$pass) {
		$htmout = "";
		$htmout .= "<h3>MSGS_1540 DB2 dbname=$dbname server=$server user=$user</h3>\n";
		print( $htmout );
		return($htmout);
		}


function db3($db3fil) {
		$htmout = "";
		$htmout .= "<h3>MSGS_1550 DB3 dbname=$dbname server=$server user=$user</h3>\n";
		print( $htmout );
		return($htmout);
		}

function ko_form($args) {
$fids="a b c d e f g h i j k l m n o p q r s t u v w x y z db3 tbl sel fld val fmt lim";
	$htmout = "";
	$htmout .= "<div id=div_ko_form>\n";
	$htmout .= "<h1>div_ko_form</h1>\n";
	$htmout .= '<form method=\"POST\" action="ko.php?ko_form_submit">\n';
	$htmout .= '	<input onkeydown="ko_onkeydown(event)" ><br>\n';
	$htmout .= "		</input>\n";
	foreach( $fids as $fid ) {
		$htmout .= '	<div id=div_form_$fid> <label for="$fid">$fid: </label> <input id="$fid" type="text"> </div>\n';
		}
	$htmout .= '	<div id=div_form_date> <label for="date">date: </label> <input id="date" type="date"> </div>\n';
	$htmout .= '	<div id=div_form_time> <label for="time">time: </label> <input id="time" type="time"> </div>\n';
	$htmout .= '	<div id=div_form_color> <label for="color">color: </label> <input id="color" type="color"> </div>\n';
	$htmout .= '	<div id=div_form_textarea> <label for="textarea">textarea: </label> <textarea name="comment" id="comment" type="textarea"></textarea> </div>\n';

	$htmout .= '	<div id=div_form_radio> <label for="radio">radio: </label><br>\n';
	$htmout .= '		 <input id="radio" name="gender" value="m" type="radio">m<br>\n'; 
	$htmout .= '		 <input id="radio" name="gender" value="f" type="radio">f<br>\n'; 
	$htmout .= '		</div>\n';
	$htmout .= '	<div id=div_form_checkbox> <label for="checkbox">checkbox: </label>\n';


	$htmout .= '		<input id="checkbox" name="checkbox" value="box1" type="checkbox">box1<br>\n';
	$htmout .= '		<input id="checkbox" name="checkbox" value="box1"type="checkbox">box2<br>\n';
	$htmout .= '		<input id="checkbox" name="checkbox" value="box1" type="checkbox">box3<br>\n';
	$htmout .= '		<input id="checkbox" name="checkbox" value="box1" type="checkbox">box4<br>\n';
	$htmout .= '		</div>\n';
	$htmout .= '	<div id=div_form_dropdown> <label for="dropdown">dropdown: </label> <input id="dropdown" type="dropdown"> </div>\n';
	$htmout .= '	<div id=div_form_email> <label for="email">email: </label> <input id="email" type="email"> </div>\n';





	$htmout .= '	<div id=div_form_submit> <label for="submit">submit: </label> <input id="submit" type="submit"> </div>\n';
	$htmout .= '	<div id=div_form_cancel> <label for="cancel">cancel: </label> <input id="cancel" type="cancel"> </div>\n';
	$htmout .= "</div>\n";

	$htmout .= "	</form>\n";




	}
# kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk 1302


function htmout_head_dup_dup($args) {
	$dttm=date('Ymd_His');
	$htmout = "";
	$htmout .= "<html><head>\n";
	$htmout .= "	<title>kogo $dttm</title>\n";
	$htmout .= htmout_script_toggle("");
	$htmout .= "	</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=goldenrod>\n";
	return($htmout);
	}

function htmout_tail2($args) {
	$htmout = "";
	$htmout .= "	</body>\n";
	$htmout .= "	</html>\n";
	return($htmout);
	}





function htmout_script_startup_kogo($args) {
	$htmout = "";
	$htmout .= "<script id=script_startup_kogo>\n";
	$htmout .= "	function startup_kogo(args) {\n";
	$htmout .= "		alert( \"MSG_101 srtup_kogo args=\"+args );\n";
#	$htmout .= "		var gamedata=load_gamedata('');\n";
#	$htmout .= "		if (document.getElementById('div_gamedata')) {\n";
#	$htmout .= "			document.getElementById('div_gamedata').innerHTML=gamedata;\n";
#	$htmout .= "			}\n";

#	$htmout .= "	divid=\"div_board\";\n"


#	$htmout .= "	$(\"\'+divid+\'\").html(gamedata);\n";
#	$htmout .= "	divid=\"div_stones\";"
#	$htmout .= "	$(\"'+divid+'\").html(gamedata);\n";
#	$htmout .= "	divid=\"div_gamelist\";"
#	$htmout .= "	$(\"'+divid+'\").html(gamedata);\n";
#	$htmout .= "	return(\"\")\n";
	$htmout .= "	}\n";
	$htmout .= "	</script>\n";
	return($htmout);
	}

function isodd_dup($n) {if($n % 2 == 0 ) {return(0);} else {return(1);}}



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