version 0.1.2
[fms.git] / admin / introduce.php
1 <?php\r
2 \r
3         include_once('config.php');\r
4         include_once('linkbar.php');\r
5         \r
6 function localiddropdown($name)\r
7 {\r
8         global $dblocation;\r
9         \r
10         $db=new PDO('sqlite:'.$dblocation);\r
11         \r
12         $st=$db->prepare("SELECT LocalIdentityID, Name, PublicKey FROM tblLocalIdentity ORDER BY Name;");       \r
13         $st->execute();\r
14         \r
15         print "<select name=\"".$name."\">";\r
16         while($record=$st->fetch())\r
17         {\r
18                 print "<option value=\"".$record[0]."\" title=\"".$record[2]."\">".$record[1]."</option>";\r
19         }\r
20         print "</select>";\r
21 }\r
22         \r
23 function content()\r
24 {\r
25         global $dblocation;\r
26         \r
27         $db=new PDO('sqlite:'.$dblocation);\r
28         \r
29         if(isset($_REQUEST["formaction"]) && $_REQUEST["formaction"]=="announce" && $_REQUEST["localidentityid"]!="")\r
30         {\r
31                 $st=$db->prepare("INSERT INTO tblIdentityIntroductionInserts(LocalIdentityID,Day,UUID,Solution) VALUES(?,?,?,?);");\r
32                 \r
33                 for($i=0; $i<count($_REQUEST["uuid"]); $i++)\r
34                 {\r
35                         if($_REQUEST["solution"][$i]!="")\r
36                         {\r
37                                 $st->bindParam(1,$_REQUEST["localidentityid"]);\r
38                                 $st->bindParam(2,$_REQUEST["day"][$i]);\r
39                                 $st->bindParam(3,$_REQUEST["uuid"][$i]);\r
40                                 $st->bindParam(4,$_REQUEST["solution"][$i]);\r
41                                 $st->execute(); \r
42                         }\r
43                 }\r
44         }\r
45         \r
46         ?>\r
47         <h2>Announce Identity</h2>\r
48         <form name="frmannounce" method="POST">\r
49         <input type="hidden" name="formaction" value="announce">\r
50         Select Identity to announce\r
51         <?php\r
52         localiddropdown("localidentityid");\r
53         print "<br>Type answers for a few puzzles and submit<br>";\r
54         \r
55         \r
56         $st=$db->prepare("SELECT UUID,Day,IdentityID FROM tblIntroductionPuzzleRequests WHERE UUID NOT IN (SELECT UUID FROM tblIdentityIntroductionInserts) AND Day>='".gmdate('Y-m-d',strtotime('-1 day'))."' AND Found='true' ORDER BY IdentityID, Day DESC, RequestIndex DESC;");\r
57         $st->execute();\r
58         \r
59         // only show latest captcha for each known identity\r
60         $lastid='';\r
61         $shown=0;\r
62         while(($record=$st->fetch()) && $shown<30)\r
63         {\r
64                 if($lastid!=$record[2])\r
65                 {\r
66                         $lastid=$record[2];\r
67                         print "<img src=\"showcaptcha.php?UUID=".$record[0]."\">";\r
68                         print "<input type=\"hidden\" name=\"uuid[]\" value=\"".$record[0]."\">";\r
69                         print "<input type=\"hidden\" name=\"day[]\" value=\"".$record[1]."\">";\r
70                         print "<input type=\"text\" name=\"solution[]\">";\r
71                         print "<br>";\r
72                         $shown++;\r
73                 }\r
74         }\r
75         \r
76         if($shown>0)\r
77         {\r
78         ?>\r
79         <input type="submit" value="Announce">\r
80         <?php\r
81         }\r
82         else\r
83         {\r
84                 print "You must wait for some puzzles to be downloaded.  Check back later.";\r
85         }\r
86         ?>\r
87         </form> \r
88         <?php   \r
89 }\r
90         \r
91         include_once('template.php');\r
92 \r
93 ?>