forked from ornicar/pgn4web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathencoder-example.php
82 lines (56 loc) · 2.08 KB
/
encoder-example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/*
* pgn4web javascript chessboard
* copyright (C) 2009, 2010 Paolo Casaschi
* see README file and http://pgn4web.casaschi.net
* for credits, license and more details
*/
include "pgn-encoder.php";
$pgnText = $_REQUEST["pgnText"];
if (!$pgnText) { $pgnText = $_REQUEST["pgnTextbox"]; }
if (!$pgnText) { $pgnText = $_REQUEST["pt"]; }
if ($pgnText) {
$pgnTextbox = $pgnText = str_replace("\\\"", "\"", $pgnText);
$pgnText = preg_replace("/\[/", "\n\n[", $pgnText);
$pgnText = preg_replace("/\]/", "]\n\n", $pgnText);
$pgnText = preg_replace("/([012\*])(\s*)(\[)/", "$1\n\n$3", $pgnText);
$pgnText = preg_replace("/\]\s*\[/", "]\n[", $pgnText);
$pgnText = preg_replace("/^\s*\[/", "[", $pgnText);
$pgnText = preg_replace("/\n[\s*\n]+/", "\n\n", $pgnText);
} else {
$pgnTextbox = $pgnText = <<<END
[White "?"]
[Black "?"]
[Result "?"]
[Date "?"]
[Event "?"]
[Site "?"]
[Round "?"]
{please enter your PGN games in the textbox and then click the button}
END;
}
$pgnEncoded = EncodePGN($pgnText);
$thisScript = $_SERVER['SCRIPT_NAME'];
print <<<END
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>pgn4web PGN encoder/decoder php example</title>
<link rel="shortcut icon" href="pawn.ico" />
</head>
<body style="font-family: sans-serif;">
<h1>pgn4web PGN encoder/decoder php example</h1>
<center>
<iframe src="board.html?am=l&d=1000&ss=26&ps=d&pf=d&lcs=YeiP&dcs=Qcij&bbcs=D91v&hm=n&hcs=Udiz&bd=s&cbcs=YeiP&ctcs=\$\$\$\$&hd=j&md=j&tm=13&fhcs=\$\$\$\$&fhs=80p&fmcs=\$\$\$\$&fccs=v71\$&hmcs=Qcij&fms=80p&fcs=m&cd=i&bcs=____&fp=13&hl=t&fh=b&fw=p&pe=$pgnEncoded"
height="312" width="900" frameborder="0" scrolling="no" marginheight="0" marginwidth="0">
your web browser and/or your host do not support iframes as required to display the chessboard
</iframe>
<form action="$thisScript" method="POST">
<input type="submit" style="width:900px;" value="pgn4web PGN encoder/decoder php example">
<textarea id="pgnTextbox" name="pgnTextbox" style="height:300px; width:900px;">$pgnTextbox</textarea>
</form>
</center>
</body>
</html>
END;
?>