質問するログイン新規登録

質問編集履歴

1

具体的な事例を入力

2019/10/22 21:04

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -22,4 +22,101 @@
22
22
  '"AAAA"AAAA'AAAA'AAAA"AAAA"'
23
23
  などというように試したのですが、やはりできませんでした。
24
24
  特殊なやり方があるのでしょうか。
25
- それともそのようなことは各言語別々でないとできないのでしょうか。
25
+ それともそのようなことは各言語別々でないとできないのでしょうか。
26
+
27
+ 具体例
28
+ ---
29
+ 以下のhtmlは私の作成しているゲームなのですが、
30
+ 3行目 document.write("<?php");の最後の;
31
+ また、
32
+ 16行目あたり ,
33
+ そして、
34
+ さらに下 
35
+  ],
36
+ ['59:59.96','xyz'],
37
+ ['59:59.97','ijk'],
38
+ ['59:59.98','aaa'],
39
+ ['59:59.99','zzz'],
40
+ ];
41
+ の最初 ], と最後 ] でエラーが発生していました。
42
+ ```js
43
+ var r=[
44
+ [
45
+ document.write("<?php");
46
+ document.write("if (isset($_POST['message']) && $_POST['message'] != '') {");
47
+ document.write('$f = fopen("message.txt", "a");');
48
+ document.write('fwrite($f, htmlspecialchars($_POST["message"]) . "\n");');
49
+ document.write("fclose($f);");
50
+ document.write('}');
51
+ document.write("?>");
52
+ document.write('<form action="append.php" method="post">');
53
+ document.write('<p>メッセージ: <input name="message" size="60"></p>');
54
+ document.write('</form>');
55
+ document.write('<pre>');
56
+ document.write('<?php readfile("message.txt"); ?>');
57
+ document.write('</pre>*/');
58
+ ,
59
+ document.write("<?php");
60
+ document.write("if (isset($_POST['message']) && $_POST['message'] != '') {");
61
+ document.write('$f = fopen("message.txt", "a");');
62
+ document.write('fwrite($f, htmlspecialchars($_POST["message"]) . "\n");');
63
+ document.write("fclose($f);");
64
+ document.write('}');
65
+ document.write("?>");
66
+ document.write('<form action="append.php" method="post">');
67
+ document.write('<p>メッセージ: <input name="message" size="60"></p>');
68
+ document.write('</form>');
69
+ document.write('<pre>');
70
+ document.write('<?php readfile("message.txt"); ?>');
71
+ document.write('</pre>*/');
72
+ ],
73
+ ['59:59.96','xyz'],
74
+ ['59:59.97','ijk'],
75
+ ['59:59.98','aaa'],
76
+ ['59:59.99','zzz'],
77
+ ];
78
+ var qs=[
79
+ 'q1',
80
+ ];
81
+ const viewRank=()=>{
82
+ document.querySelector('#rank span').innerHTML=r.map(x=>x.join(" ")).join("<br>");
83
+ };
84
+ window.addEventListener('DOMContentLoaded',()=>{
85
+ viewRank();
86
+ document.querySelector('#start').addEventListener('click',e=>{
87
+ const t1=e.target;
88
+ const t2=document.querySelector('#a');
89
+ t1.disabled=true;
90
+ t2.disabled=false;
91
+ const name=prompt("お名前を入力してください。");
92
+ if(name=="") name="UnKnown";
93
+ (async()=>{
94
+ const s=new Date().getTime();
95
+ for(var i=0;i<qs.length;i++){
96
+ const qStr=qs[i];
97
+ document.querySelector('#q span').textContent=qStr;
98
+ t2.value="";
99
+ t2.focus();
100
+ await new Promise(resolve=>{
101
+ const timerId=setInterval(()=>{
102
+ if(t2.value==qStr){
103
+ clearInterval(timerId);
104
+ resolve();
105
+ }
106
+ },10);
107
+ });
108
+ }
109
+ const e=new Date().getTime();
110
+ const diff=e-s;
111
+ const str=(10000+diff/1000).toString();
112
+ const time=str.substr(1,2)+":"+
113
+ str.substr(3,5);
114
+ r.push([time,name]);
115
+ r=await r.sort((x,y)=>x[0]>y[0]?1:-1).splice(0,5);
116
+ viewRank();
117
+ t1.disabled=false;
118
+ t2.disabled=true;
119
+ })();
120
+ });
121
+ });
122
+ ```