version 0.0.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 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]."\">".$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 FROM tblIntroductionPuzzleRequests WHERE UUID NOT IN (SELECT UUID FROM tblIdentityIntroductionInserts) AND Day>='".gmdate('Y-m-d',strtotime('-1 day'))."' AND Found='true';");\r
57         $st->execute();\r
58         \r
59         while($record=$st->fetch())\r
60         {\r
61                 print "<img src=\"showcaptcha.php?UUID=".$record[0]."\">";\r
62                 print "<input type=\"hidden\" name=\"uuid[]\" value=\"".$record[0]."\">";\r
63                 print "<input type=\"hidden\" name=\"day[]\" value=\"".$record[1]."\">";\r
64                 print "<input type=\"text\" name=\"solution[]\">";\r
65                 print "<br>";\r
66         }\r
67         ?>\r
68         <input type="submit">\r
69         </form> \r
70         <?php   \r
71 }\r
72         \r
73         include_once('template.php');\r
74 \r
75 ?>