version 0.1.6
[fms.git] / admin / addpeeridentity.php
1 <?php\r
2 \r
3         include_once('config.php');\r
4         include_once('linkbar.php');\r
5         \r
6 function content()\r
7 {\r
8         global $dblocation;\r
9         \r
10         if(isset($_REQUEST["formaction"]) && $_REQUEST["formaction"]=="addpeer" && $_REQUEST["publickey"]!="")\r
11         {\r
12                 $message="";\r
13                 $db=new PDO('sqlite:'.$dblocation);\r
14                 $st=$db->prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey=?;");\r
15                 $st->bindParam(1,$_REQUEST["publickey"]);\r
16                 $st->execute();\r
17                 if($record=$st->fetch())\r
18                 {\r
19                         $message="This peer already exists";\r
20                 }\r
21                 else\r
22                 {\r
23                         $st2=$db->prepare("INSERT INTO tblIdentity(PublicKey,DateAdded) VALUES(?,?);");\r
24                         $st2->bindParam(1,$_REQUEST["publickey"]);\r
25                         $st2->bindParam(2,gmdate('Y-m-d H:i:s'));\r
26                         $st2->execute();\r
27                         $message="Peer added";  \r
28                 }\r
29 ?>\r
30         <h2><?php print($message) ?></h2>\r
31 <?php\r
32         }\r
33         else\r
34         {\r
35 ?>\r
36         <h2>Add Peer</h2>\r
37         <form name="frmaddpeer" method="POST">\r
38         <input type="hidden" name="formaction" value="addpeer">\r
39         Peer Public Key<input type="text" name="publickey" size="100">\r
40         <br>\r
41         The public key must be a valid SSK public key and include the / at the end\r
42         <br>\r
43         <input type="submit" value="Add">\r
44         </form>\r
45 <?php\r
46         }\r
47 }\r
48         \r
49         include_once('template.php');\r
50 \r
51 ?>