version 0.1.7
authorSomeDude <SomeDude@NuBL7aaJ6Cn4fB7GXFb9Zfi8w1FhPyW3oKgU9TweZMw>
Sun, 3 Feb 2008 09:23:00 +0000 (10:23 +0100)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Sun, 3 Feb 2008 09:23:00 +0000 (10:23 +0100)
42 files changed:
CMakeLists.txt
admin/addpeeridentity.php [deleted file]
admin/config.php [deleted file]
admin/createidentity.php [deleted file]
admin/identitytrust.php [deleted file]
admin/index.php [deleted file]
admin/introduce.php [deleted file]
admin/introductionstatus.php [deleted file]
admin/layout_deneva.css [deleted file]
admin/linkbar.php [deleted file]
admin/localidentities.php [deleted file]
admin/options.php [deleted file]
admin/showcaptcha.php [deleted file]
admin/style_deneva.css [deleted file]
admin/template.php [deleted file]
include/global.h
include/http/httpthread.h
include/http/ipagehandler.h
include/http/pages/addpeerpage.h [new file with mode: 0644]
include/http/pages/announceidentitypage.h [new file with mode: 0644]
include/http/pages/createidentitypage.h [new file with mode: 0644]
include/http/pages/homepage.h
include/http/pages/localidentitiespage.h [new file with mode: 0644]
include/http/pages/optionspage.h [new file with mode: 0644]
include/http/pages/peertrustpage.h [new file with mode: 0644]
include/http/pages/showcaptchapage.h [new file with mode: 0644]
src/freenet/fcpv2.cpp
src/freenet/trustlistrequester.cpp
src/global.cpp
src/http/httpthread.cpp
src/http/ipagehandler.cpp
src/http/pages/addpeerpage.cpp [new file with mode: 0644]
src/http/pages/announceidentitypage.cpp [new file with mode: 0644]
src/http/pages/createidentitypage.cpp [new file with mode: 0644]
src/http/pages/homepage.cpp
src/http/pages/localidentitiespage.cpp [new file with mode: 0644]
src/http/pages/optionspage.cpp [new file with mode: 0644]
src/http/pages/peertrustpage.cpp [new file with mode: 0644]
src/http/pages/showcaptchapage.cpp [new file with mode: 0644]
src/message.cpp
src/nntp/nntpconnection.cpp
template.htm [new file with mode: 0644]

index 52233e8..3a14d8f 100644 (file)
@@ -48,7 +48,14 @@ src/freenet/captcha/easybmp/EasyBMP_Font.cpp
 src/freenet/captcha/easybmp/EasyBMP_Geometry.cpp\r
 src/http/httpthread.cpp\r
 src/http/ipagehandler.cpp\r
+src/http/pages/addpeerpage.cpp\r
+src/http/pages/announceidentitypage.cpp\r
+src/http/pages/createidentitypage.cpp\r
 src/http/pages/homepage.cpp\r
+src/http/pages/localidentitiespage.cpp\r
+src/http/pages/optionspage.cpp\r
+src/http/pages/peertrustpage.cpp\r
+src/http/pages/showcaptchapage.cpp\r
 src/nntp/nntpconnection.cpp\r
 src/nntp/nntplistener.cpp\r
 src/nntp/uwildmat.cpp\r
@@ -66,7 +73,8 @@ src/xyssl/sha1.c
 ADD_DEFINITIONS(-DTIXML_USE_STL)\r
 \r
 IF(CMAKE_COMPILER_IS_GNUCXX)\r
-       ADD_DEFINITIONS(-fpermissive)\r
+       #ADD_DEFINITIONS(-fpermissive)\r
+       SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")\r
 ENDIF(CMAKE_COMPILER_IS_GNUCXX)\r
 \r
 ADD_EXECUTABLE(fms ${FMS_SRC})\r
@@ -111,9 +119,10 @@ IF(SHTTPD_LIBRARY)
        TARGET_LINK_LIBRARIES(fms ${SHTTPD_LIBRARY})\r
 ELSE(SHTTPD_LIBRARY)\r
        MESSAGE(STATUS "Could not find shttpd library.  Will compile from included source.")\r
-       ADD_DEFINITIONS(-DEMBEDDED -DNO_GUI)\r
+       ADD_DEFINITIONS(-DEMBEDDED)\r
        INCLUDE_DIRECTORIES(libs/shttpd/include)\r
        IF(WIN32)\r
+               ADD_DEFINITIONS(-DNO_GUI)\r
                SET(SHTTPD_PLATFORM_SRC libs/shttpd/compat_win32.c)\r
        ELSE(WIN32)\r
                SET(SHTTPD_PLATFORM_SRC libs/shttpd/compat_unix.c)\r
diff --git a/admin/addpeeridentity.php b/admin/addpeeridentity.php
deleted file mode 100644 (file)
index 5d24f0c..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-<?php\r
-\r
-       include_once('config.php');\r
-       include_once('linkbar.php');\r
-       \r
-function content()\r
-{\r
-       global $dblocation;\r
-       \r
-       if(isset($_REQUEST["formaction"]) && $_REQUEST["formaction"]=="addpeer" && $_REQUEST["publickey"]!="")\r
-       {\r
-               $message="";\r
-               $db=new PDO('sqlite:'.$dblocation);\r
-               $st=$db->prepare("SELECT IdentityID FROM tblIdentity WHERE PublicKey=?;");\r
-               $st->bindParam(1,$_REQUEST["publickey"]);\r
-               $st->execute();\r
-               if($record=$st->fetch())\r
-               {\r
-                       $message="This peer already exists";\r
-               }\r
-               else\r
-               {\r
-                       $st2=$db->prepare("INSERT INTO tblIdentity(PublicKey,DateAdded) VALUES(?,?);");\r
-                       $st2->bindParam(1,$_REQUEST["publickey"]);\r
-                       $st2->bindParam(2,gmdate('Y-m-d H:i:s'));\r
-                       $st2->execute();\r
-                       $message="Peer added";  \r
-               }\r
-?>\r
-       <h2><?php print($message) ?></h2>\r
-<?php\r
-       }\r
-       else\r
-       {\r
-?>\r
-       <h2>Add Peer</h2>\r
-       <form name="frmaddpeer" method="POST">\r
-       <input type="hidden" name="formaction" value="addpeer">\r
-       Peer Public Key<input type="text" name="publickey" size="100">\r
-       <br>\r
-       The public key must be a valid SSK public key and include the / at the end\r
-       <br>\r
-       <input type="submit" value="Add">\r
-       </form>\r
-<?php\r
-       }\r
-}\r
-       \r
-       include_once('template.php');\r
-\r
-?>
\ No newline at end of file
diff --git a/admin/config.php b/admin/config.php
deleted file mode 100644 (file)
index 8f8947e..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php\r
-\r
-       session_start();\r
-\r
-       $dblocation='./fms.db3';\r
-\r
-?>
\ No newline at end of file
diff --git a/admin/createidentity.php b/admin/createidentity.php
deleted file mode 100644 (file)
index 804b4cf..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php\r
-       \r
-       include_once('config.php');\r
-       include_once('linkbar.php');\r
-\r
-function content()\r
-{\r
-       \r
-       global $dblocation;\r
-       \r
-       if(isset($_REQUEST["formaction"]) && $_REQUEST["formaction"]=="create" && $_REQUEST["name"]!="")\r
-       {\r
-               $db=new PDO('sqlite:'.$dblocation);\r
-               $st=$db->prepare("INSERT INTO tblLocalIdentity(Name,PublishTrustList) VALUES(?,'true');");\r
-               $st->bindParam(1,$_REQUEST["name"]);\r
-               $st->execute();\r
-?>\r
-       <h2>Identity Created</h2>\r
-<?php\r
-       }\r
-       else\r
-       {\r
-?>\r
-       <h2>Create Identity</h2>\r
-       <form name="frmcreateidentity" method="POST">\r
-       <input type="hidden" name="formaction" value="create">\r
-       Name : <input type="text" name="name">\r
-       <input type="submit" value="Create">\r
-       </form>\r
-<?php\r
-       }\r
-}\r
-       \r
-       include_once('template.php');\r
-\r
-?>
\ No newline at end of file
diff --git a/admin/identitytrust.php b/admin/identitytrust.php
deleted file mode 100644 (file)
index bdc4718..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-<?php\r
-\r
-       include_once('config.php');\r
-       include_once('linkbar.php');\r
-       \r
-function content()\r
-{\r
-       \r
-       global $dblocation;\r
-       \r
-       $db=new PDO('sqlite:'.$dblocation);\r
-       \r
-       if(isset($_REQUEST['formaction']) && $_REQUEST['formaction']=='updatetrust')\r
-       {\r
-               $st=$db->prepare("UPDATE tblIdentity SET LocalMessageTrust=?, LocalTrustListTrust=? WHERE IdentityID=?;");\r
-               for($i=0; $i<count($_REQUEST['identityid']); $i++)\r
-               {\r
-                       if($_REQUEST['oldlocalmessagetrust'][$i]!=$_REQUEST['newlocalmessagetrust'][$i] || $_REQUEST['oldlocaltrustlisttrust']!=$_REQUEST['newlocaltrustlisttrust'])\r
-                       {\r
-                               $st->bindParam(1,$_REQUEST['newlocalmessagetrust'][$i]);\r
-                               $st->bindParam(2,$_REQUEST['newlocaltrustlisttrust'][$i]);\r
-                               $st->bindParam(3,$_REQUEST['identityid'][$i]);\r
-                               $rval=$st->execute();\r
-                       }\r
-               }\r
-       }\r
-       \r
-       $st=$db->prepare("SELECT IdentityID,Name,LocalMessageTrust,PeerMessageTrust,LocalTrustListTrust,PeerTrustListTrust,PublicKey FROM tblIdentity ORDER BY Name;");\r
-       $st->execute();\r
-       ?>\r
-       <h2>Identity Trust</h2>\r
-       Message Trust is how much you trust the identity to post good messages.  Trust List Trust is how much weight you want the trust list of that identity to have when calculating the total.  The local trust levels are set by you, and the peer trust levels are calculated by a weighted average using other identities trust lists.\r
-       <form name="frmtrust" method="post">\r
-       <input type="hidden" name="formaction" value="updatetrust">\r
-       <table>\r
-               <tr>\r
-                       <th>Peer</th>\r
-                       <th>Local Message Trust</th>\r
-                       <th>Peer Message Trust</th>\r
-                       <th>Local Trust List Trust</th>\r
-                       <th>Peer Trust List Trust</th>\r
-               </tr>\r
-               <?php\r
-               while($record=$st->fetch())\r
-               {\r
-               ?>\r
-               <tr>\r
-                       <td title="<?php print($record[6]); ?>">\r
-                               <?php \r
-                                       print($record[1]);\r
-                                       if($record[1]=='')\r
-                                       {\r
-                                               print("[Unknown Name]");        \r
-                                       }\r
-                               ?>\r
-                               <input type="hidden" name="identityid[]" value="<?php print($record[0]); ?>">\r
-                       </td>\r
-                       <td>\r
-                               <input type="hidden" name="oldlocalmessagetrust[]" value="<?php print($record[2]); ?>">\r
-                               <input type="text" name="newlocalmessagetrust[]" size="2" maxlength="3" value="<?php print($record[2]); ?>">\r
-                       </td>\r
-                       <td>\r
-                               <?php print($record[3]); ?>\r
-                       </td>\r
-                       <td>\r
-                               <input type="hidden" name="oldlocaltrustlisttrust[]" value="<?php print($record[4]); ?>">\r
-                               <input type="text" name="newlocaltrustlisttrust[]" size="2" maxlength="3" value="<?php print($record[4]); ?>">\r
-                       </td>\r
-                       <td><?php print($record[5]) ?></td>\r
-               </tr>\r
-               <?php   \r
-               }\r
-               ?>\r
-               <tr>\r
-                       <td colspan="5">\r
-                               <input type="submit" value="Update Trust">\r
-                       </td>\r
-               </tr>\r
-       </table>\r
-       </form>\r
-       <?php\r
-}\r
-       \r
-       include_once('template.php');\r
-\r
-?>
\ No newline at end of file
diff --git a/admin/index.php b/admin/index.php
deleted file mode 100644 (file)
index 12c1653..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php\r
-       include_once('config.php');\r
-\r
-function content()\r
-{\r
-?>\r
-               <h2>Home</h2>\r
-               <p class="paragraph">\r
-               Use these pages to administer your FMS installation.  Make sure to set $dblocation correctly in config.php, and that the database is writable to your web service user account.  While you should be able to safely use these pages while FMS is running, it is recommended that you shut down FMS prior to make any changes here.\r
-               </p>\r
-<?php\r
-}\r
-\r
-       include_once('linkbar.php');\r
-       include_once('template.php');\r
-\r
-?>
\ No newline at end of file
diff --git a/admin/introduce.php b/admin/introduce.php
deleted file mode 100644 (file)
index 216809d..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-<?php\r
-\r
-       include_once('config.php');\r
-       include_once('linkbar.php');\r
-       \r
-function localiddropdown($name)\r
-{\r
-       global $dblocation;\r
-       \r
-       $db=new PDO('sqlite:'.$dblocation);\r
-       \r
-       $st=$db->prepare("SELECT LocalIdentityID, Name, PublicKey FROM tblLocalIdentity ORDER BY Name;");       \r
-       $st->execute();\r
-       \r
-       print "<select name=\"".$name."\">";\r
-       while($record=$st->fetch())\r
-       {\r
-               print "<option value=\"".$record[0]."\" title=\"".$record[2]."\">".$record[1]."</option>";\r
-       }\r
-       print "</select>";\r
-}\r
-       \r
-function content()\r
-{\r
-       global $dblocation;\r
-       \r
-       $db=new PDO('sqlite:'.$dblocation);\r
-       \r
-       if(isset($_REQUEST["formaction"]) && $_REQUEST["formaction"]=="announce" && $_REQUEST["localidentityid"]!="")\r
-       {\r
-               $st=$db->prepare("INSERT INTO tblIdentityIntroductionInserts(LocalIdentityID,Day,UUID,Solution) VALUES(?,?,?,?);");\r
-               \r
-               for($i=0; $i<count($_REQUEST["uuid"]); $i++)\r
-               {\r
-                       if($_REQUEST["solution"][$i]!="")\r
-                       {\r
-                               $st->bindParam(1,$_REQUEST["localidentityid"]);\r
-                               $st->bindParam(2,$_REQUEST["day"][$i]);\r
-                               $st->bindParam(3,$_REQUEST["uuid"][$i]);\r
-                               $st->bindParam(4,$_REQUEST["solution"][$i]);\r
-                               $st->execute(); \r
-                       }\r
-               }\r
-       }\r
-       \r
-       ?>\r
-       <h2>Announce Identity</h2>\r
-       <form name="frmannounce" method="POST">\r
-       <input type="hidden" name="formaction" value="announce">\r
-       Select Identity to announce\r
-       <?php\r
-       localiddropdown("localidentityid");\r
-       print "<br>Type answers for a few puzzles and submit<br>";\r
-       \r
-       \r
-       $st=$db->prepare("SELECT UUID,Day,IdentityID FROM tblIntroductionPuzzleRequests WHERE UUID NOT IN (SELECT UUID FROM tblIdentityIntroductionInserts) AND UUID NOT IN (SELECT UUID FROM tblIntroductionPuzzleInserts) AND Day>='".gmdate('Y-m-d',strtotime('-1 day'))."' AND Found='true' ORDER BY IdentityID, Day DESC, RequestIndex DESC;");\r
-       $st->execute();\r
-       \r
-       // only show latest captcha for each known identity\r
-       $lastid='';\r
-       $shown=0;\r
-       while(($record=$st->fetch()) && $shown<30)\r
-       {\r
-               if($lastid!=$record[2])\r
-               {\r
-                       $lastid=$record[2];\r
-                       print "<img src=\"showcaptcha.php?UUID=".$record[0]."\">";\r
-                       print "<input type=\"hidden\" name=\"uuid[]\" value=\"".$record[0]."\">";\r
-                       print "<input type=\"hidden\" name=\"day[]\" value=\"".$record[1]."\">";\r
-                       print "<input type=\"text\" name=\"solution[]\">";\r
-                       print "<br>";\r
-                       $shown++;\r
-               }\r
-       }\r
-       \r
-       if($shown>0)\r
-       {\r
-       ?>\r
-       <input type="submit" value="Announce">\r
-       <?php\r
-       }\r
-       else\r
-       {\r
-               print "You must wait for some puzzles to be downloaded.  Check back later.";\r
-       }\r
-       ?>\r
-       </form> \r
-       <?php   \r
-}\r
-       \r
-       include_once('template.php');\r
-\r
-?>
\ No newline at end of file
diff --git a/admin/introductionstatus.php b/admin/introductionstatus.php
deleted file mode 100644 (file)
index c346ef6..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php\r
-\r
-       include_once('config.php');\r
-       include_once('linkbar.php');\r
-               \r
-function content()\r
-{\r
-       global $dblocation;\r
-       \r
-       $db=new PDO('sqlite:'.$dblocation);\r
-       $st=$db->prepare("SELECT tblLocalIdentity.Name, COUNT(Inserted), tblLocalIdentity.PublicKey FROM tblLocalIdentity LEFT JOIN tblIdentityIntroductionInserts ON tblLocalIdentity.LocalIdentityID=tblIdentityIntroductionInserts.LocalIdentityID WHERE (Inserted='true' OR Inserted IS NULL) GROUP BY tblLocalIdentity.LocalIdentityID;");\r
-       $st->execute();\r
-       \r
-       ?>\r
-       <h2>Introduction Status</h2>\r
-       <table>\r
-               <tr>\r
-                       <th>Identity</th>\r
-                       <th>Successful introduction inserts</th>\r
-               </tr>\r
-               <?php\r
-               while($record=$st->fetch())\r
-               {\r
-                       ?>\r
-               <tr>\r
-                       <td title="<?php print $record[2]; ?>">\r
-                               <?php print $record[0]; ?>\r
-                       </td>\r
-                       <td>\r
-                               <?php print $record[1]; ?>\r
-                       </td>\r
-               </tr>\r
-                       <?php   \r
-               }\r
-               ?>\r
-       </table>\r
-       <?php\r
-}\r
-       \r
-       include_once('template.php');\r
-\r
-?>
\ No newline at end of file
diff --git a/admin/layout_deneva.css b/admin/layout_deneva.css
deleted file mode 100644 (file)
index f3a8172..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-body {\r
-       width: auto;\r
-       margin: 1em;\r
-}\r
-p, div {\r
-       margin: 0em 0em 0em 0em;\r
-       padding: 0em;\r
-}\r
-h1, h2, h3, h4, h5, h6 {\r
-       margin: 0em 0em .2em 0em;\r
-       padding: 0em 0em .1em 0em;\r
-}\r
-\r
-.banner { \r
-       margin: 0em;\r
-       padding: .5em;\r
-\r
-}\r
-.navigation {\r
-       margin: 0em 0em 0em 0em;\r
-       padding: .3em;\r
-}\r
-\r
-.content_main {\r
-       margin: 0em;\r
-       padding: 0em;\r
-}\r
-\r
-.content_left {\r
-       float: left;\r
-       width: 200px;\r
-       margin: 1em 0em 0em 0em;\r
-       padding: 0em;\r
-}\r
-.content_left .box {\r
-       margin: 0em 0em 1em 0em;\r
-}\r
-.content_left .box .header {\r
-       padding: .5em;\r
-}\r
-.content_left .box p {\r
-       padding: 0em .3em 0em .3em;\r
-       margin: .0em 0em .5em 0em;\r
-}\r
-\r
-.content_right {\r
-       position:absolute;\r
-       left:220px;\r
-       margin: 0px 0px 0px 0px;\r
-       padding: 1em;\r
-}\r
-\r
-.meta-info {\r
-       text-align: right;\r
-}\r
-\r
-.footer {\r
-       clear: both;\r
-       padding: 1em;\r
-       margin: 0em;\r
-}\r
-\r
-.paragraph             {\r
-                                       margin-bottom:.5em;\r
-                               }
\ No newline at end of file
diff --git a/admin/linkbar.php b/admin/linkbar.php
deleted file mode 100644 (file)
index 4e80f20..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php\r
-\r
-function linkbar()\r
-{\r
-?>\r
-               <div class="box">\r
-               <div class="header">Links</div>\r
-               <ul>\r
-                       <li><a href="index.php">Home</a></li>\r
-                       <li><a href="options.php">Options</a></li>\r
-                       <li><a href="createidentity.php">Create Identity</a></li>\r
-                       <li><a href="localidentities.php">Local Identities</a></li>\r
-                       <li><a href="introduce.php">Introduce Identity</a></li>\r
-                       <li><a href="introductionstatus.php">Introduction Status</a></li>\r
-                       <li><a href="addpeeridentity.php">Manually Add Peer</a></li>\r
-                       <li><a href="identitytrust.php">Identity Trust</a></li>\r
-               </ul>\r
-               </div>\r
-<?php\r
-};\r
-\r
-?>
\ No newline at end of file
diff --git a/admin/localidentities.php b/admin/localidentities.php
deleted file mode 100644 (file)
index b98f420..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-<?php\r
-       \r
-       include_once('config.php');\r
-       include_once('linkbar.php');\r
-\r
-function truefalsedropdown($name,$currentval)\r
-{\r
-       ?>\r
-       <select name="<?php print($name); ?>">\r
-               <option value="true" <?php if($currentval=="true") print("SELECTED"); ?>>true</option>\r
-               <option value="false" <?php if($currentval=="false") print("SELECTED"); ?>>false</option>\r
-       </select>\r
-       <?php\r
-}\r
-\r
-function content()\r
-{\r
-       global $dblocation;\r
-       $db=new PDO('sqlite:'.$dblocation);\r
-       \r
-       if(isset($_REQUEST['formaction']))\r
-       {\r
-               if($_REQUEST['formaction']=='update' && isset($_REQUEST['update']))\r
-               {\r
-                       $st=$db->prepare("UPDATE tblLocalIdentity SET SingleUse=?, PublishTrustList=? WHERE LocalIdentityID=?;");\r
-                       for($i=0; $i<count($_REQUEST['update']); $i++)\r
-                       {\r
-                               if($_REQUEST['update'][$i]!='')\r
-                               {\r
-                                       $st->bindParam(1,$_REQUEST['singleuse'][$_REQUEST['update'][$i]]);\r
-                                       $st->bindParam(2,$_REQUEST['publishtrustlist'][$_REQUEST['update'][$i]]);\r
-                                       $st->bindParam(3,$_REQUEST['localidentityid'][$_REQUEST['update'][$i]]);\r
-                                       $st->execute();\r
-                               }\r
-                       }\r
-               }\r
-               if($_REQUEST['formaction']=='delete' && isset($_REQUEST['update']))\r
-               {\r
-                       $st=$db->prepare("DELETE FROM tblLocalIdentity WHERE LocalIdentityID=?;");\r
-\r
-                       for($i=0; $i<count($_REQUEST['update']); $i++)\r
-                       {\r
-                               if($_REQUEST['update'][$i]!='')\r
-                               {\r
-                                       $st->bindParam(1,$_REQUEST['localidentityid'][$_REQUEST['update'][$i]]);\r
-                                       $st->execute();\r
-                               }                               \r
-                       }                       \r
-               }\r
-       }\r
-       \r
-       $st=$db->prepare("SELECT LocalIdentityID,Name,PublicKey,PublishTrustList,SingleUse,PublishBoardList FROM tblLocalIdentity ORDER BY Name;");\r
-       $st->execute();\r
-       ?>\r
-       <h2>Local Identities</h2>\r
-       <form name="frmlocalidentity" method="post">\r
-       <input type="hidden" name="formaction" value="update">\r
-       <table>\r
-               <tr>\r
-                       <td></td>\r
-                       <th>Name</th>\r
-                       <th>Single Use</th>\r
-                       <th>Publish Trust List</th>\r
-               </tr>\r
-       <?php\r
-       $row=0;\r
-       while($record=$st->fetch())\r
-       {\r
-               ?>\r
-               <tr>\r
-                       <td>\r
-                               <input type="checkbox" name="update[]" value="<?php print($row); ?>">\r
-                       </td>\r
-                       <td title="<?php print($record[2]); ?>">\r
-                               <input type="hidden" name="localidentityid[]" value="<?php print($record[0]); ?>">\r
-                               <?php print($record[1]); ?>\r
-                       </td>\r
-                       <td>\r
-                               <?php\r
-                               truefalsedropdown("singleuse[]",$record[4]);\r
-                               ?>\r
-                       </td>\r
-                       <td>\r
-                               <?php\r
-                               truefalsedropdown("publishtrustlist[]",$record[3]);\r
-                               ?>\r
-                       </td>\r
-               </tr>\r
-               <?php\r
-               $row++;\r
-       }\r
-       ?>\r
-       </table>\r
-       <input type="submit" value="Update Selected">\r
-       <input type="submit" value="Delete Selected" onClick="if(confirm('Delete Selected Identities?')){frmlocalidentity.formaction.value='delete';}else{return false;}">\r
-       </form>\r
-       <?php\r
-}\r
-\r
-       include_once('template.php');\r
-\r
-?>
\ No newline at end of file
diff --git a/admin/options.php b/admin/options.php
deleted file mode 100644 (file)
index b4f3757..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php\r
-\r
-       include_once('config.php');\r
-       \r
-       if(isset($_REQUEST['formaction']) && $_REQUEST['formaction']=='saveoptions')\r
-       {\r
-               $db=new PDO('sqlite:'.$dblocation);\r
-               $st=$db->prepare("UPDATE tblOption SET OptionValue=? WHERE Option=?;");\r
-               foreach($_REQUEST as $key=>$val)\r
-               {\r
-                       $st->bindParam(1,$val);\r
-                       $st->bindParam(2,$key);\r
-                       $st->execute();\r
-               }\r
-       }\r
-\r
-function content()\r
-{\r
-       global $dblocation;\r
-       $db=new PDO('sqlite:'.$dblocation);\r
-       \r
-       $rs=$db->query("SELECT Option, OptionValue, OptionDescription FROM tblOption;");\r
-       \r
-?>\r
-       <h2 style="text-align:center;">Options</h2>\r
-       <form name="frmoptions" method="post">\r
-       <input type="hidden" name="formaction" value="saveoptions">\r
-       <table>\r
-               <tr>\r
-                       <th>Option</th>\r
-                       <th>Value</th>\r
-                       <th>Description</th>\r
-               </tr>\r
-               <?php\r
-               while($record=$rs->fetch())\r
-               {\r
-                       print '<tr>';\r
-                       print '<td valign="TOP">'.$record[0].'</td>';\r
-                       print '<td valign="TOP"><input type="text" name="'.$record[0].'" value="'.$record[1].'"></td>';\r
-                       print '<td valign="TOP">'.$record[2].'</td>';\r
-                       print '</tr>';\r
-               }\r
-               ?>\r
-               <tr>\r
-                       <td colspan="3">\r
-                               <center>\r
-                               <input type="submit" value="Save">\r
-                               </center>\r
-                       </td>\r
-               </tr>\r
-       </table>\r
-<?php\r
-}\r
-\r
-       include_once('linkbar.php');\r
-       include_once('template.php');\r
-\r
-?>
\ No newline at end of file
diff --git a/admin/showcaptcha.php b/admin/showcaptcha.php
deleted file mode 100644 (file)
index 81a01dd..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php\r
-\r
-       require_once('config.php');\r
-       \r
-       $db=new PDO('sqlite:'.$dblocation);\r
-       \r
-       if(isset($_REQUEST['UUID']))\r
-       {\r
-               $st=$db->prepare("SELECT MimeType,PuzzleData FROM tblIntroductionPuzzleRequests WHERE UUID=?;");\r
-               $st->bindParam(1,$_REQUEST['UUID']);\r
-               $st->execute();\r
-               \r
-               if($record=$st->fetch())\r
-               {\r
-                       $data=base64_decode($record[1]);\r
-                       header("Content-type: ".$record[0]);\r
-                       header("Content-Length: ".strlen($data));\r
-                       print $data;\r
-               }\r
-       }\r
-\r
-?>
\ No newline at end of file
diff --git a/admin/style_deneva.css b/admin/style_deneva.css
deleted file mode 100644 (file)
index ffe4673..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-body {\r
-       background-color: #FFF;\r
-       color: #000;\r
-       font-family: Verdana, Arial, Helvetica, sans-serif;\r
-       font-size: 90%;\r
-}\r
-a, a:link, a:active { color: #0000FF; text-decoration: none; }\r
-a:visited { color: #003399; text-decoration: none; }\r
-a:hover { color: #990000; text-decoration: underline; }\r
-p      {}\r
-div {\r
-}\r
-h1 {}\r
-h2 { color: #003366;}\r
-h3 { color: #336699; border-bottom: 1px solid #336699;}\r
-h4 { color: #6699CC; border-bottom: 1px solid #6699CC;}\r
-h5 { color: #99CCFF;}\r
-\r
-ul             {\r
-                       padding:0px;\r
-                       margin-top:5px;\r
-                       margin-bottom:5px;\r
-                       margin-left:25px;\r
-               }\r
-\r
-.banner { \r
-       background-color: #003366;\r
-       color: #FFFFFF;\r
-       font-weight: bolder;\r
-}\r
-.navigation {\r
-       background-color: #CCDDEE;\r
-       border: 1px solid #999999;\r
-       font-size: 80%;\r
-}\r
-.content_main { background-color: #FFFFFF;}\r
-.content_left {\r
-               font-size: 90%;\r
-}\r
-.content_left .box {\r
-       border: 1px solid #336699;\r
-       background-color: #DDEEFF;\r
-       font-size: 85%;\r
-}\r
-.content_left .box .header {\r
-       background-color: #003366;      \r
-       color: #FFFFFF;\r
-       font-weight: bold;\r
-       font-size: 1em;\r
-}\r
-.content_left .box p {\r
-}\r
-.content_right {\r
-}\r
-.footer {      \r
-       color: #999;\r
-       font-size: smaller;\r
-       text-align: center;\r
-       border-top: 1px dashed #CCCCCC;\r
-}\r
-.meta-info {\r
-       font-size: 80%;\r
-}\r
-.paragraph {\r
-       line-height: 1.4em;\r
-}\r
-\r
-.smaller { font-size: 65%; }\r
-.darkest { background-color: #003366; }\r
-.darker { background-color: #336699; }\r
-.dark { background-color: #6699CC; }\r
-.light { background-color: #99CCFF; }\r
-.lighter { background-color: #DDEEFF; }\r
-.lightest { background-color: #FFFFFF; }\r
-\r
-.xml1-attributename { color: #800000; }\r
-.xml1-attributevalue { color: #FF0000; }\r
-.xml1-cdatasection { color: #808000; }\r
-.xml1-comment { color: #808080; font-style: italic; }\r
-.xml1-currentline { color: #000000; }\r
-.xml1-doctypesection { color: #008080; }\r
-.xml1-elementname { color: #000080; }\r
-.xml1-entityreference { color: #0000FF; }\r
-.xml1-matchedbraces { color: #FF0000; }\r
-.xml1-namespaceattributename { color: #008000; }\r
-.xml1-namespaceattributevalue { color: #0000FF; }\r
-.xml1-processinginstruction { color: #000080; }\r
-.xml1-rightedge { color: #C0C0C0; }\r
-.xml1-selection { color: #FFFFFF; }\r
-.xml1-symbol { color: #808080; }\r
-.xml1-text { color: #000000; }\r
-.xml1-whitespace { color: #FFFFFF; }\r
-\r
-.calcheading   {\r
-                                       font-weight:bold;\r
-                               }\r
-                               \r
-.calcheading td        {\r
-                                       padding-left:10px;\r
-                                       padding-right:10px;\r
-                               }\r
-                               \r
-.calcrow td            {\r
-                                       background-color:#EEEEEE;\r
-                                       text-align:right;\r
-                               }\r
-                               \r
-.totalrow td   {\r
-                                       text-align:right;\r
-                               }
\ No newline at end of file
diff --git a/admin/template.php b/admin/template.php
deleted file mode 100644 (file)
index 91f308d..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">\r
-<head>\r
-       <title>FMS : Freenet Message System</title>\r
-       <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />\r
-       <link rel="stylesheet" href="layout_deneva.css" type="text/css" media="screen" />\r
-       <link rel="stylesheet" href="style_deneva.css" type="text/css" media="screen" />\r
-</head>\r
-\r
-<body>\r
-       \r
-       <div class="banner">\r
-\r
-       FMS : Freenet Message System\r
-       </div>\r
-       \r
-       <div class="content_main">\r
-\r
-       <div class="content_left">\r
-\r
-               <?php\r
-               if(function_exists('linkbar'))\r
-               {\r
-                       linkbar();      \r
-               }\r
-               ?>\r
-       \r
-       </div>\r
-       \r
-       <div class="content_right">\r
-       \r
-               <?php\r
-               if(function_exists('content'))\r
-               {\r
-                       content();      \r
-               }\r
-               ?>\r
-               \r
-       </div>\r
-       \r
-       </div>\r
-\r
-\r
-</body>\r
-</html>\r
index cee8ab5..ba2e84f 100644 (file)
@@ -5,7 +5,7 @@
 //#include <zthread/Thread.h>\r
 #include "pthreadwrapper/thread.h"\r
 \r
-#define FMS_VERSION    "0.1.6"\r
+#define FMS_VERSION    "0.1.7"\r
 \r
 // opens database and creates tables and initial inserts if necessary\r
 void SetupDB();\r
index ecb61e4..8ebd00d 100644 (file)
@@ -7,6 +7,7 @@
 #include "ipagehandler.h"\r
 #include "httpdefs.h"\r
 \r
+#include <cstdlib>\r
 #include <shttpd.h>\r
 \r
 class HTTPThread:public PThread::Runnable,public ILogger, public IDatabase\r
index 7624c4a..313aa56 100644 (file)
@@ -1,13 +1,18 @@
 #ifndef _ipagehandler_\r
 #define _ipagehandler_\r
 \r
-#include <shttpd.h>\r
+#include <cstdlib>\r
 #include <string>\r
 #include <map>\r
+#include <vector>\r
+#include <shttpd.h>\r
 \r
 class IPageHandler\r
 {\r
 public:\r
+       IPageHandler()  {}\r
+       IPageHandler(const std::string &templatestr)    { m_template=templatestr; }\r
+       virtual ~IPageHandler() {}\r
 \r
        /**\r
                \brief Handles request for a page\r
@@ -22,6 +27,12 @@ private:
        virtual const bool WillHandleURI(const std::string &uri)=0;\r
        virtual const std::string GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars)=0;\r
        \r
+protected:\r
+       // converts from basename[#] query args into a vector where the vector pos is the index pos #\r
+       void CreateArgArray(const std::map<std::string,std::string> &vars, const std::string &basename, std::vector<std::string> &args);\r
+\r
+       std::string m_template;\r
+\r
 };\r
 \r
 #endif // _ipagehandler_\r
diff --git a/include/http/pages/addpeerpage.h b/include/http/pages/addpeerpage.h
new file mode 100644 (file)
index 0000000..79aedb3
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef _addpeerpage_\r
+#define _addpeerpage_\r
+\r
+#include "../ipagehandler.h"\r
+#include "../../idatabase.h"\r
+\r
+class AddPeerPage:public IPageHandler,public IDatabase\r
+{\r
+public:\r
+       AddPeerPage(const std::string &templatestr):IPageHandler(templatestr)   {}\r
+\r
+private:\r
+       const bool WillHandleURI(const std::string &uri);\r
+       const std::string GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars);\r
+       \r
+};\r
+\r
+#endif // _addpeerpage_\r
diff --git a/include/http/pages/announceidentitypage.h b/include/http/pages/announceidentitypage.h
new file mode 100644 (file)
index 0000000..e2817f9
--- /dev/null
@@ -0,0 +1,19 @@
+#ifndef _announceidentitypage_\r
+#define _announceidentitypage_\r
+\r
+#include "../ipagehandler.h"\r
+#include "../../idatabase.h"\r
+\r
+class AnnounceIdentityPage:public IPageHandler,public IDatabase\r
+{\r
+public:\r
+       AnnounceIdentityPage(const std::string &templatestr):IPageHandler(templatestr)  {}\r
+\r
+private:\r
+       const bool WillHandleURI(const std::string &uri);\r
+       const std::string GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars);\r
+\r
+       const std::string CreateLocalIdentityDropDown(const std::string &name, const std::string &selected);\r
+};\r
+\r
+#endif // _announceidentitypage_\r
diff --git a/include/http/pages/createidentitypage.h b/include/http/pages/createidentitypage.h
new file mode 100644 (file)
index 0000000..4a5374c
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef _createidentitypage_\r
+#define _createidentitypage_\r
+\r
+#include "../ipagehandler.h"\r
+#include "../../idatabase.h"\r
+\r
+class CreateIdentityPage:public IPageHandler,public IDatabase\r
+{\r
+public:\r
+       CreateIdentityPage(const std::string &templatestr):IPageHandler(templatestr)    {}\r
+\r
+private:\r
+       const bool WillHandleURI(const std::string &uri);\r
+       const std::string GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars);\r
+};\r
+\r
+#endif // _createidentitypage_\r
index 977a015..d8eaa0c 100644 (file)
@@ -6,6 +6,7 @@
 class HomePage:public IPageHandler\r
 {\r
 public:\r
+       HomePage(const std::string &templatestr):IPageHandler(templatestr) {}\r
 \r
 private:\r
        const bool WillHandleURI(const std::string &uri);\r
diff --git a/include/http/pages/localidentitiespage.h b/include/http/pages/localidentitiespage.h
new file mode 100644 (file)
index 0000000..bc687e1
--- /dev/null
@@ -0,0 +1,19 @@
+#ifndef _localidentitiespage_\r
+#define _localidentitiespage_\r
+\r
+#include "../ipagehandler.h"\r
+#include "../../idatabase.h"\r
+\r
+class LocalIdentitiesPage:public IPageHandler,public IDatabase\r
+{\r
+public:\r
+       LocalIdentitiesPage(const std::string &templatestr):IPageHandler(templatestr)   {}\r
+private:\r
+       const bool WillHandleURI(const std::string &uri);\r
+       const std::string GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars);\r
+\r
+       const std::string CreateTrueFalseDropDown(const std::string &name, const std::string &selected);\r
+\r
+};\r
+\r
+#endif // _localidentitiespage_\r
diff --git a/include/http/pages/optionspage.h b/include/http/pages/optionspage.h
new file mode 100644 (file)
index 0000000..6ca15db
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef _optionspage_\r
+#define _optionspage_\r
+\r
+#include "../ipagehandler.h"\r
+#include "../../idatabase.h"\r
+\r
+class OptionsPage:public IPageHandler,public IDatabase\r
+{\r
+public:\r
+       OptionsPage(const std::string &templatestr):IPageHandler(templatestr)   {}\r
+       \r
+private:\r
+       const bool WillHandleURI(const std::string &uri);\r
+       const std::string GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars);\r
+};\r
+\r
+#endif // _optionspage_\r
diff --git a/include/http/pages/peertrustpage.h b/include/http/pages/peertrustpage.h
new file mode 100644 (file)
index 0000000..b9a5f4e
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef _peertrustpage_\r
+#define _peertrustpage_\r
+\r
+#include "../ipagehandler.h"\r
+#include "../../idatabase.h"\r
+\r
+class PeerTrustPage:public IPageHandler,public IDatabase\r
+{\r
+public:\r
+       PeerTrustPage(const std::string &templatestr):IPageHandler(templatestr)         {}\r
+\r
+private:\r
+       const bool WillHandleURI(const std::string &uri);\r
+       const std::string GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars);\r
+\r
+};\r
+\r
+#endif // _peertrustpage_\r
diff --git a/include/http/pages/showcaptchapage.h b/include/http/pages/showcaptchapage.h
new file mode 100644 (file)
index 0000000..121ad9a
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef _showcaptchapage_\r
+#define _showcaptchapage_\r
+\r
+#include "../ipagehandler.h"\r
+#include "../../idatabase.h"\r
+\r
+class ShowCaptchaPage:public IPageHandler,public IDatabase\r
+{\r
+public:\r
+\r
+private:\r
+       const bool WillHandleURI(const std::string &uri);\r
+       const std::string GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars);\r
+\r
+};\r
+\r
+#endif // _showcaptchapage_\r
index 42995f4..fdc83fb 100644 (file)
@@ -66,7 +66,7 @@ const bool FCPv2::Connect(const char *host, const int port)
        struct sockaddr_storage m_serveraddr;\r
 \r
        std::ostringstream portstring;\r
-       addrinfo hint,*result;\r
+       addrinfo hint,*result,*current;\r
        result=NULL;\r
        portstring << port;\r
 \r
@@ -80,16 +80,19 @@ const bool FCPv2::Connect(const char *host, const int port)
 \r
        if(result)\r
        {\r
-               memset(&m_serveraddr,0,sizeof(struct sockaddr_storage));\r
+               for(current=result; current!=NULL && m_serversocket==-1; current=current->ai_next)\r
+               {\r
+                       memset(&m_serveraddr,0,sizeof(struct sockaddr_storage));\r
 \r
-               m_serversocket=socket(result->ai_family,result->ai_socktype,result->ai_protocol);\r
+                       m_serversocket=socket(current->ai_family,current->ai_socktype,current->ai_protocol);\r
 \r
-               if(m_serversocket!=-1)\r
-               {\r
-                       rval=connect(m_serversocket,result->ai_addr,result->ai_addrlen);\r
-                       if(rval==-1)\r
+                       if(m_serversocket!=-1)\r
                        {\r
-                               Disconnect();\r
+                               rval=connect(m_serversocket,current->ai_addr,current->ai_addrlen);\r
+                               if(rval==-1)\r
+                               {\r
+                                       Disconnect();\r
+                               }\r
                        }\r
                }\r
 \r
index 3d7f129..4eeaf79 100644 (file)
@@ -230,7 +230,7 @@ void TrustListRequester::PopulateIDList()
 \r
        // select identities we want to query (we've seen them today and they are publishing trust list) - sort by their trust level (descending) with secondary sort on how long ago we saw them (ascending)\r
        sql="SELECT IdentityID FROM tblIdentity ";\r
-       sql+="WHERE PublicKey IS NOT NULL AND PublicKey <> '' AND LastSeen>='"+date.Format("%Y-%m-%d")+"' AND PublishTrustList='true' AND LocalTrustListTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinLocalTrustListTrust') AND ( PeerTrustListTrust IS NULL OR PeerTrustListTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinPeerTrustListTrust') )";\r
+       sql+="WHERE Name IS NOT NULL AND Name <> '' AND PublicKey IS NOT NULL AND PublicKey <> '' AND LastSeen>='"+date.Format("%Y-%m-%d")+"' AND PublishTrustList='true' AND LocalTrustListTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinLocalTrustListTrust') AND ( PeerTrustListTrust IS NULL OR PeerTrustListTrust>=(SELECT OptionValue FROM tblOption WHERE Option='MinPeerTrustListTrust') )";\r
        sql+="ORDER BY LocalMessageTrust+LocalTrustListTrust DESC, LastSeen;";\r
 \r
        SQLite3DB::Statement st=m_db->Prepare(sql);\r
index 6430d85..0437eb4 100644 (file)
@@ -204,16 +204,14 @@ void SetupDB()
                                );");\r
 \r
        // low / high / message count for each board\r
-       db->Execute("DROP VIEW IF EXISTS vwBoardStats; \\r
-                               CREATE VIEW IF NOT EXISTS vwBoardStats AS \\r
+       db->Execute("CREATE VIEW IF NOT EXISTS vwBoardStats AS \\r
                                SELECT tblBoard.BoardID AS 'BoardID', IFNULL(MIN(MessageID),0) AS 'LowMessageID', IFNULL(MAX(MessageID),0) AS 'HighMessageID', COUNT(MessageID) AS 'MessageCount' \\r
                                FROM tblBoard LEFT JOIN tblMessageBoard ON tblBoard.BoardID=tblMessageBoard.BoardID \\r
                                WHERE MessageID>=0 OR MessageID IS NULL \\r
                                GROUP BY tblBoard.BoardID;");\r
 \r
        // calculates peer trust\r
-       db->Execute("DROP VIEW IF EXISTS vwCalculatedPeerTrust; \\r
-                               CREATE VIEW IF NOT EXISTS vwCalculatedPeerTrust AS \\r
+       db->Execute("CREATE VIEW IF NOT EXISTS vwCalculatedPeerTrust AS \\r
                                SELECT TargetIdentityID, \\r
                                ROUND(SUM(MessageTrust*(LocalMessageTrust/100.0))/SUM(LocalMessageTrust/100.0),0) AS 'PeerMessageTrust', \\r
                                ROUND(SUM(TrustListTrust*(LocalTrustListTrust/100.0))/SUM(LocalTrustListTrust/100.0),0) AS 'PeerTrustListTrust' \\r
@@ -291,7 +289,7 @@ void SetupDB()
 \r
        // insert SomeDude's public key\r
        date.SetToGMTime();\r
-       //db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded) VALUES('SSK@NuBL7aaJ6Cn4fB7GXFb9Zfi8w1FhPyW3oKgU9TweZMw,iXez4j3qCpd596TxXiJgZyTq9o-CElEuJxm~jNNZAuA,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"');");\r
+       db->Execute("INSERT INTO tblIdentity(PublicKey,DateAdded) VALUES('SSK@NuBL7aaJ6Cn4fB7GXFb9Zfi8w1FhPyW3oKgU9TweZMw,iXez4j3qCpd596TxXiJgZyTq9o-CElEuJxm~jNNZAuA,AQACAAE/','"+date.Format("%Y-%m-%d %H:%M:%S")+"');");\r
 \r
 }\r
 \r
@@ -360,7 +358,7 @@ void SetupDefaultOptions()
 \r
        // FCPHost\r
        st.Bind(0,"FCPHost");\r
-       st.Bind(1,"localhost");\r
+       st.Bind(1,"127.0.0.1");\r
        st.Bind(2,"Host name or address of Freenet node.");\r
        st.Step();\r
        st.Reset();\r
@@ -421,7 +419,7 @@ void SetupDefaultOptions()
        st.Reset();\r
 \r
        st.Bind(0,"MinPeerMessageTrust");\r
-       st.Bind(1,"25");\r
+       st.Bind(1,"30");\r
        st.Bind(2,"Specifies a peer message trust level that a peer must have before its messages will be downloaded.");\r
        st.Step();\r
        st.Reset();\r
@@ -433,7 +431,7 @@ void SetupDefaultOptions()
        st.Reset();\r
 \r
        st.Bind(0,"MinPeerTrustListTrust");\r
-       st.Bind(1,"25");\r
+       st.Bind(1,"30");\r
        st.Bind(2,"Specifies a peer trust list trust level that a peer must have before its trust list will be included in the weighted average.  Any peers below this number will be excluded from the results.");\r
        st.Step();\r
        st.Reset();\r
index dd4bd9b..827ce28 100644 (file)
@@ -2,6 +2,13 @@
 #include "../../include/option.h"\r
 #include "../../include/stringfunctions.h"\r
 #include "../../include/http/pages/homepage.h"\r
+#include "../../include/http/pages/optionspage.h"\r
+#include "../../include/http/pages/showcaptchapage.h"\r
+#include "../../include/http/pages/createidentitypage.h"\r
+#include "../../include/http/pages/localidentitiespage.h"\r
+#include "../../include/http/pages/announceidentitypage.h"\r
+#include "../../include/http/pages/addpeerpage.h"\r
+#include "../../include/http/pages/peertrustpage.h"\r
 \r
 #include <iostream>\r
 \r
 \r
 HTTPThread::HTTPThread()\r
 {\r
-\r
+       std::string templatestr;\r
        int port;\r
        std::string portstr;\r
        Option::Instance()->Get("HTTPListenPort",portstr);\r
        StringFunctions::Convert(portstr,port);\r
 \r
-       m_pagehandlers.push_back(new HomePage());\r
+       // set template\r
+       templatestr="<html><head></head><body><a href=\"home.htm\">Home</a><br>[CONTENT]</body></html>";\r
+       FILE *infile=fopen("template.htm","r+b");\r
+       if(infile)\r
+       {\r
+               fseek(infile,0,SEEK_END);\r
+               long len=ftell(infile);\r
+               std::vector<char> data(len,0);\r
+               fseek(infile,0,SEEK_SET);\r
+               fread(&data[0],1,len,infile);\r
+               fclose(infile);\r
+               templatestr.assign(data.begin(),data.end());\r
+       }\r
+       else\r
+       {\r
+               m_log->WriteLog(LogFile::LOGLEVEL_ERROR,"HTTPThread::HTTPThread could not open template.htm");\r
+       }\r
+\r
+       // push back page handlers\r
+       m_pagehandlers.push_back(new ShowCaptchaPage());\r
+       m_pagehandlers.push_back(new OptionsPage(templatestr));\r
+       m_pagehandlers.push_back(new LocalIdentitiesPage(templatestr));\r
+       m_pagehandlers.push_back(new CreateIdentityPage(templatestr));\r
+       m_pagehandlers.push_back(new AnnounceIdentityPage(templatestr));\r
+       m_pagehandlers.push_back(new AddPeerPage(templatestr));\r
+       m_pagehandlers.push_back(new PeerTrustPage(templatestr));\r
+       // homepage must be last - catch all page handler\r
+       m_pagehandlers.push_back(new HomePage(templatestr));\r
 \r
        m_ctx=0;\r
        m_ctx=shttpd_init(NULL,"listen_ports",portstr.c_str(),NULL);\r
index 230da65..fc77815 100644 (file)
@@ -6,6 +6,31 @@
        #include <xmem.h>\r
 #endif\r
 \r
+void IPageHandler::CreateArgArray(const std::map<std::string,std::string> &vars, const std::string &basename, std::vector<std::string> &args)\r
+{\r
+       for(std::map<std::string,std::string>::const_iterator i=vars.begin(); i!=vars.end(); i++)\r
+       {\r
+               if((*i).first.find(basename)==0 && (*i).first.find("[")!=std::string::npos && (*i).first.find("]")!=std::string::npos)\r
+               {\r
+                       int index;\r
+                       std::string indexstr;\r
+                       std::string::size_type startpos;\r
+                       std::string::size_type endpos;\r
+                       startpos=(*i).first.find("[");\r
+                       endpos=(*i).first.find("]");\r
+\r
+                       indexstr=(*i).first.substr(startpos+1,(endpos-startpos)-1);\r
+                       StringFunctions::Convert(indexstr,index);\r
+\r
+                       while(args.size()<index+1)\r
+                       {\r
+                               args.push_back("");\r
+                       }\r
+                       args[index]=(*i).second;\r
+               }\r
+       }\r
+}\r
+\r
 const bool IPageHandler::Handle(shttpd_arg *arg)\r
 {\r
        const char *uri=shttpd_get_env(arg,"REQUEST_URI");\r
@@ -34,7 +59,8 @@ const bool IPageHandler::Handle(shttpd_arg *arg)
                                {\r
                                        long len;\r
                                        StringFunctions::Convert(std::string(lenstr),len);\r
-                                       mystate->m_indata=new char[len];\r
+                                       mystate->m_indata=new char[len+1];\r
+                                       mystate->m_indata[len]=NULL;\r
                                        mystate->m_indatalen=len;\r
                                        mystate->m_indatapos=0;\r
                                }\r
@@ -45,7 +71,7 @@ const bool IPageHandler::Handle(shttpd_arg *arg)
                if(arg->in.len>0)\r
                {\r
                        int pos=0;\r
-                       while(arg->in.num_bytes<arg->in.len)\r
+                       while(pos<arg->in.len)\r
                        {\r
                                mystate->m_indata[mystate->m_indatapos++]=arg->in.buf[pos++];\r
                        }\r
@@ -56,7 +82,32 @@ const bool IPageHandler::Handle(shttpd_arg *arg)
                if(mystate->m_indatalen==mystate->m_indatapos && mystate->m_outdata==NULL)\r
                {\r
                        //TODO parse POST data and any QUERY_STRING before generating page\r
-                       std::string page=GeneratePage(methodstr,std::map<std::string,std::string>());\r
+                       std::map<std::string,std::string> args;\r
+                       std::vector<std::string> argparts;\r
+                       \r
+                       if(mystate->m_indata)\r
+                       {\r
+                               StringFunctions::Split(mystate->m_indata,"&",argparts);\r
+                       }\r
+                       if(shttpd_get_env(arg,"QUERY_STRING"))\r
+                       {\r
+                               StringFunctions::Split(shttpd_get_env(arg,"QUERY_STRING"),"&",argparts);\r
+                       }\r
+                       for(std::vector<std::string>::iterator argi=argparts.begin(); argi!=argparts.end(); argi++)\r
+                       {\r
+                               std::vector<std::string> parts;\r
+                               StringFunctions::Split((*argi),"=",parts);\r
+                               if(parts.size()>0)\r
+                               {\r
+                                       args[StringFunctions::UriDecode(parts[0])];\r
+                                       if(parts.size()>1)\r
+                                       {\r
+                                               args[StringFunctions::UriDecode(parts[0])]=StringFunctions::UriDecode(parts[1]);\r
+                                       }\r
+                               }\r
+                       }\r
+\r
+                       std::string page=GeneratePage(methodstr,args);\r
                        mystate->m_outdata=new char[page.size()];\r
                        memcpy(mystate->m_outdata,page.c_str(),page.size());\r
                        mystate->m_outdatalen=page.size();\r
@@ -79,11 +130,11 @@ const bool IPageHandler::Handle(shttpd_arg *arg)
                {\r
                        if(mystate->m_indata)\r
                        {\r
-                               delete mystate->m_indata;\r
+                               delete [] mystate->m_indata;\r
                        }\r
                        if(mystate->m_outdata)\r
                        {\r
-                               delete mystate->m_outdata;\r
+                               delete [] mystate->m_outdata;\r
                        }\r
                        delete mystate;\r
                        arg->state=NULL;\r
diff --git a/src/http/pages/addpeerpage.cpp b/src/http/pages/addpeerpage.cpp
new file mode 100644 (file)
index 0000000..7b4d706
--- /dev/null
@@ -0,0 +1,56 @@
+#include "../../../include/http/pages/addpeerpage.h"\r
+#include "../../../include/stringfunctions.h"\r
+#include "../../../include/datetime.h"\r
+\r
+#ifdef XMEM\r
+       #include <xmem.h>\r
+#endif\r
+\r
+const std::string AddPeerPage::GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars)\r
+{\r
+       std::string content="";\r
+\r
+       if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="add")\r
+       {\r
+               DateTime date;\r
+               std::string publickey="";\r
+               if(queryvars.find("publickey")!=queryvars.end())\r
+               {\r
+                       publickey=(*queryvars.find("publickey")).second;\r
+               }\r
+               if(publickey!="" && publickey.find("SSK@")==0 && publickey[publickey.size()-1]=='/')\r
+               {\r
+                       date.SetToGMTime();\r
+                       SQLite3DB::Statement st=m_db->Prepare("INSERT INTO tblIdentity(PublicKey,DateAdded) VALUES(?,?);");\r
+                       st.Bind(0,publickey);\r
+                       st.Bind(1,date.Format("%Y-%m-%d %H:%M:%S"));\r
+                       st.Step();\r
+                       st.Reset();\r
+               }\r
+       }\r
+\r
+       content+="<h2>Add Peer</h2>";\r
+       content+="<form name=\"frmaddpeer\" method=\"POST\">";\r
+       content+="<input type=\"hidden\" name=\"formaction\" value=\"add\">";\r
+       content+="Public Key : ";\r
+       content+="<input type=\"text\" name=\"publickey\" size=\"100\">";\r
+       content+="<br>";\r
+       content+="The public key must be a valid SSK public key and include the / at the end";\r
+       content+="<br>";\r
+       content+="<input type=\"submit\" value=\"Add\">";\r
+       content+="</form>";\r
+\r
+       return "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"+StringFunctions::Replace(m_template,"[CONTENT]",content);\r
+}\r
+\r
+const bool AddPeerPage::WillHandleURI(const std::string &uri)\r
+{\r
+       if(uri.find("addpeer.")!=std::string::npos)\r
+       {\r
+               return true;\r
+       }\r
+       else\r
+       {\r
+               return false;\r
+       }\r
+}\r
diff --git a/src/http/pages/announceidentitypage.cpp b/src/http/pages/announceidentitypage.cpp
new file mode 100644 (file)
index 0000000..460302a
--- /dev/null
@@ -0,0 +1,140 @@
+#include "../../../include/http/pages/announceidentitypage.h"\r
+#include "../../../include/stringfunctions.h"\r
+#include "../../../include/datetime.h"\r
+\r
+#ifdef XMEM\r
+       #include <xmem.h>\r
+#endif\r
+\r
+const std::string AnnounceIdentityPage::CreateLocalIdentityDropDown(const std::string &name, const std::string &selected)\r
+{\r
+       std::string rval="";\r
+       SQLite3DB::Statement st=m_db->Prepare("SELECT LocalIdentityID, Name, PublicKey FROM tblLocalIdentity ORDER BY Name;");\r
+       st.Step();\r
+\r
+       rval+="<select name=\""+name+"\">";\r
+       while(st.RowReturned())\r
+       {\r
+               std::string id;\r
+               std::string name;\r
+               std::string pubkey;\r
+\r
+               st.ResultText(0,id);\r
+               st.ResultText(1,name);\r
+               st.ResultText(2,pubkey);\r
+\r
+               rval+="<option value=\""+id+"\" title=\""+pubkey+"\">"+name+"</option>";\r
+               st.Step();\r
+       }\r
+       rval+="</select>";\r
+       return rval;\r
+}\r
+\r
+const std::string AnnounceIdentityPage::GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars)\r
+{\r
+       DateTime date;\r
+       std::string content;\r
+       int shown=0;\r
+       std::string countstr="";\r
+       std::string uuid;\r
+       std::string lastid="";\r
+       std::string thisid="";\r
+       std::string day="";\r
+\r
+       if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="announce")\r
+       {\r
+               SQLite3DB::Statement insert=m_db->Prepare("INSERT INTO tblIdentityIntroductionInserts(LocalIdentityID,Day,UUID,Solution) VALUES(?,?,?,?);");\r
+               std::string localidentityidstr="";\r
+               int localidentityid=0;\r
+               std::vector<std::string> uuids;\r
+               std::vector<std::string> days;\r
+               std::vector<std::string> solutions;\r
+\r
+               if(queryvars.find("localidentityid")!=queryvars.end())\r
+               {\r
+                       localidentityidstr=(*queryvars.find("localidentityid")).second;\r
+                       StringFunctions::Convert(localidentityidstr,localidentityid);\r
+               }\r
+               CreateArgArray(queryvars,"uuid",uuids);\r
+               CreateArgArray(queryvars,"day",days);\r
+               CreateArgArray(queryvars,"solution",solutions);\r
+\r
+               for(int i=0; i<solutions.size(); i++)\r
+               {\r
+                       if(solutions[i]!="")\r
+                       {\r
+                               insert.Bind(0,localidentityid);\r
+                               insert.Bind(1,days[i]);\r
+                               insert.Bind(2,uuids[i]);\r
+                               insert.Bind(3,solutions[i]);\r
+                               insert.Step();\r
+                               insert.Reset();\r
+                       }\r
+               }\r
+\r
+       }\r
+\r
+       content+="<h2>Announce Identity</h2>";\r
+       content+="<form name=\"frmannounce\" method=\"POST\">";\r
+       content+="<input type=\"hidden\" name=\"formaction\" value=\"announce\">";\r
+       content+="<table>";\r
+       content+="<tr><td colspan=\"4\"><center>Select Identity : ";\r
+       content+=CreateLocalIdentityDropDown("localidentityid","");\r
+       content+="</td></tr>";\r
+       content+="<tr><td colspan=\"4\"><center>Type the answers of a few puzzles</td></tr>";\r
+       content+="<tr>";\r
+\r
+       date.SetToGMTime();\r
+       date.Add(0,0,0,-1);\r
+       SQLite3DB::Statement st=m_db->Prepare("SELECT UUID,Day,IdentityID FROM tblIntroductionPuzzleRequests WHERE UUID NOT IN (SELECT UUID FROM tblIdentityIntroductionInserts) AND UUID NOT IN (SELECT UUID FROM tblIntroductionPuzzleInserts) AND Day>='"+date.Format("%Y-%m-%d")+"' AND Found='true' ORDER BY IdentityID, Day DESC, RequestIndex DESC;");\r
+       st.Step();\r
+\r
+       if(st.RowReturned()==false)\r
+       {\r
+               content+="<td colspan=\"4\"><center>You must wait for some puzzles to be downloaded.  Check back later.</td>";\r
+       }\r
+       \r
+       while(st.RowReturned() && shown<20)\r
+       {\r
+               st.ResultText(0,uuid);\r
+               st.ResultText(1,day);\r
+               st.ResultText(2,thisid);\r
+\r
+               if(thisid!=lastid)\r
+               {\r
+                       StringFunctions::Convert(shown,countstr);\r
+                       if(shown>0 && shown%4==0)\r
+                       {\r
+                               content+="</tr>\r\n<tr>";\r
+                       }\r
+                       content+="<td>";\r
+                       content+="<img src=\"showcaptcha.htm?UUID="+uuid+"\"><br>";\r
+                       content+="<input type=\"hidden\" name=\"uuid["+countstr+"]\" value=\""+uuid+"\">";\r
+                       content+="<input type=\"hidden\" name=\"day["+countstr+"]\" value=\""+day+"\">";\r
+                       content+="<input type=\"text\" name=\"solution["+countstr+"]\">";\r
+                       content+="</td>\r\n";\r
+                       thisid=lastid;\r
+                       shown++;\r
+               }\r
+               \r
+               st.Step();\r
+       }\r
+\r
+       content+="</tr><td colspan=\"4\"><center><input type=\"submit\" value=\"Announce\"></td></tr>";\r
+       content+="</table>";\r
+       content+="</form>";\r
+\r
+       return "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"+StringFunctions::Replace(m_template,"[CONTENT]",content);\r
+}\r
+\r
+const bool AnnounceIdentityPage::WillHandleURI(const std::string &uri)\r
+{\r
+       if(uri.find("announceidentity.")!=std::string::npos)\r
+       {\r
+               return true;\r
+       }\r
+       else\r
+       {\r
+               return false;\r
+       }\r
+}\r
diff --git a/src/http/pages/createidentitypage.cpp b/src/http/pages/createidentitypage.cpp
new file mode 100644 (file)
index 0000000..2c55c02
--- /dev/null
@@ -0,0 +1,50 @@
+#include "../../../include/http/pages/createidentitypage.h"\r
+#include "../../../include/stringfunctions.h"\r
+\r
+#ifdef XMEM\r
+       #include <xmem.h>\r
+#endif\r
+\r
+const std::string CreateIdentityPage::GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars)\r
+{\r
+       std::string content="";\r
+\r
+       if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="create")\r
+       {\r
+               SQLite3DB::Statement st=m_db->Prepare("INSERT INTO tblLocalIdentity(Name,PublishTrustList) VALUES(?,'true');");\r
+               std::string name="";\r
+\r
+               if(queryvars.find("name")!=queryvars.end())\r
+               {\r
+                       name=(*queryvars.find("name")).second;\r
+               }\r
+\r
+               st.Bind(0,name);\r
+               st.Step();\r
+\r
+               content+="<h2>Created Identity</h2>";\r
+       }\r
+       else\r
+       {\r
+               content+="<h2>Create Identity</h2>";\r
+               content+="<form name=\"frmcreateidentity\" method=\"POST\">";\r
+               content+="<input type=\"hidden\" name=\"formaction\" value=\"create\">";\r
+               content+="Name : <input type=\"text\" name=\"name\">";\r
+               content+=" <input type=\"submit\" value=\"Create\">";\r
+               content+="</form>";\r
+       }\r
+\r
+       return "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"+StringFunctions::Replace(m_template,"[CONTENT]",content);\r
+}\r
+\r
+const bool CreateIdentityPage::WillHandleURI(const std::string &uri)\r
+{\r
+       if(uri.find("createidentity.")!=std::string::npos)\r
+       {\r
+               return true;\r
+       }\r
+       else\r
+       {\r
+               return false;\r
+       }\r
+}\r
index 28bfa0f..cbc57e4 100644 (file)
@@ -1,4 +1,5 @@
 #include "../../../include/http/pages/homepage.h"\r
+#include "../../../include/stringfunctions.h"\r
 \r
 #ifdef XMEM\r
        #include <xmem.h>\r
@@ -6,7 +7,11 @@
 \r
 const std::string HomePage::GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars)\r
 {\r
-       return "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<html><body>Home</body></html>";\r
+       std::string content="<h2>Home</h2>";\r
+       content+="<p class=\"paragraph\">";\r
+       content+="Use these pages to administer your FMS installation.";\r
+       content+="</p>";\r
+       return "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"+StringFunctions::Replace(m_template,"[CONTENT]",content);\r
 }\r
 \r
 const bool HomePage::WillHandleURI(const std::string &uri)\r
diff --git a/src/http/pages/localidentitiespage.cpp b/src/http/pages/localidentitiespage.cpp
new file mode 100644 (file)
index 0000000..821339d
--- /dev/null
@@ -0,0 +1,139 @@
+#include "../../../include/http/pages/localidentitiespage.h"\r
+#include "../../../include/stringfunctions.h"\r
+\r
+#ifdef XMEM\r
+       #include <xmem.h>\r
+#endif\r
+\r
+const std::string LocalIdentitiesPage::CreateTrueFalseDropDown(const std::string &name, const std::string &selected)\r
+{\r
+       std::string rval="";\r
+\r
+       rval+="<select name=\""+name+"\">";\r
+       rval+="<option value=\"true\"";\r
+       if(selected=="true")\r
+       {\r
+               rval+=" SELECTED";\r
+       }\r
+       rval+=">true</option>";\r
+       rval+="<option value=\"false\"";\r
+       if(selected=="false")\r
+       {\r
+               rval+=" SELECTED";\r
+       }\r
+       rval+=">false</option>";\r
+       rval+="</select>";\r
+\r
+       return rval;\r
+}\r
+\r
+const std::string LocalIdentitiesPage::GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars)\r
+{\r
+       int count;\r
+       std::string countstr;\r
+       std::string content="";\r
+\r
+\r
+       if(queryvars.find("formaction")!=queryvars.end())\r
+       {\r
+               int id;\r
+               std::vector<std::string> ids;\r
+               std::vector<std::string> singleuse;\r
+               std::vector<std::string> publishtrustlist;\r
+\r
+               CreateArgArray(queryvars,"chkidentityid",ids);\r
+               CreateArgArray(queryvars,"singleuse",singleuse);\r
+               CreateArgArray(queryvars,"publishtrustlist",publishtrustlist);\r
+\r
+               if((*queryvars.find("formaction")).second=="update")\r
+               {\r
+                       SQLite3DB::Statement update=m_db->Prepare("UPDATE tblLocalIdentity SET SingleUse=?, PublishTrustList=? WHERE LocalIdentityID=?;");\r
+                       for(int i=0; i<ids.size(); i++)\r
+                       {\r
+                               if(ids[i]!="")\r
+                               {\r
+                                       StringFunctions::Convert(ids[i],id);\r
+                                       update.Bind(0,singleuse[i]);\r
+                                       update.Bind(1,publishtrustlist[i]);\r
+                                       update.Bind(2,id);\r
+                                       update.Step();\r
+                                       update.Reset();\r
+                               }\r
+                       }\r
+               }\r
+               if((*queryvars.find("formaction")).second=="delete")\r
+               {\r
+                       SQLite3DB::Statement del=m_db->Prepare("DELETE FROM tblLocalIdentity WHERE LocalIdentityID=?;");\r
+                       for(int i=0; i<ids.size(); i++)\r
+                       {\r
+                               if(ids[i]!="")\r
+                               {\r
+                                       StringFunctions::Convert(ids[i],id);\r
+                                       del.Bind(0,id);\r
+                                       del.Step();\r
+                                       del.Reset();\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+\r
+       content+="<h2>Local Identities</h2>";\r
+       content+="<form name=\"frmlocalidentity\" method=\"POST\">";\r
+       content+="<input type=\"hidden\" name=\"formaction\" value=\"update\">";\r
+       content+="<table><tr><td></td><th>Name</th><th>Single Use</th><th>Publish Trust List</th><th>Announced? *</th></tr>";\r
+\r
+       SQLite3DB::Statement st=m_db->Prepare("SELECT LocalIdentityID,tblLocalIdentity.Name,tblLocalIdentity.PublicKey,tbLLocalIdentity.PublishTrustList,tblLocalIdentity.SingleUse,tblLocalIdentity.PublishBoardList,tblIdentity.IdentityID FROM tblLocalIdentity LEFT JOIN tblIdentity ON tblLocalIdentity.PublicKey=tblIdentity.PublicKey ORDER BY tblLocalIdentity.Name;");\r
+       st.Step();\r
+\r
+       count=0;\r
+       while(st.RowReturned())\r
+       {\r
+               StringFunctions::Convert(count,countstr);\r
+               std::string id;\r
+               std::string name;\r
+               std::string publickey;\r
+               std::string publishtrustlist;\r
+               std::string singleuse;\r
+\r
+               st.ResultText(0,id);\r
+               st.ResultText(1,name);\r
+               st.ResultText(2,publickey);\r
+               st.ResultText(3,publishtrustlist);\r
+               st.ResultText(4,singleuse);\r
+\r
+               content+="<tr>";\r
+               content+="<td><input type=\"checkbox\" name=\"chkidentityid["+countstr+"]\" value=\""+id+"\"></td>";\r
+               content+="<td title=\""+publickey+"\">"+name+"</td>";\r
+               content+="<td>"+CreateTrueFalseDropDown("singleuse["+countstr+"]",singleuse)+"</td>";\r
+               content+="<td>"+CreateTrueFalseDropDown("publishtrustlist["+countstr+"]",publishtrustlist)+"</td>";\r
+               if(st.ResultNull(6))\r
+               {\r
+                       content+="<td>No</td>";\r
+               }\r
+               else\r
+               {\r
+                       content+="<td>Yes</td>";\r
+               }\r
+               content+="</tr>";\r
+               st.Step();\r
+               count++;\r
+       }\r
+\r
+       content+="<tr><td colspan=\"4\"><center><input type=\"submit\" value=\"Update Selected\"> <input type=\"submit\" value=\"Delete Selected\" onClick=\"if(confirm('Delete Selected Identities?')){frmlocalidentity.formaction.value='delete';}else{return false;}\"></td></tr>";\r
+       content+="</table>";\r
+       content+="<p class=\"paragraph=\">* An identity is considered successfully announced when you have downloaded a trust list from someone that contains the identity.</p>";\r
+\r
+       return "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"+StringFunctions::Replace(m_template,"[CONTENT]",content);\r
+}\r
+\r
+const bool LocalIdentitiesPage::WillHandleURI(const std::string &uri)\r
+{\r
+       if(uri.find("localidentities.")!=std::string::npos)\r
+       {\r
+               return true;\r
+       }\r
+       else\r
+       {\r
+               return false;\r
+       }\r
+}\r
diff --git a/src/http/pages/optionspage.cpp b/src/http/pages/optionspage.cpp
new file mode 100644 (file)
index 0000000..4c39834
--- /dev/null
@@ -0,0 +1,78 @@
+#include "../../../include/http/pages/optionspage.h"\r
+#include "../../../include/stringfunctions.h"\r
+\r
+#ifdef XMEM\r
+       #include <xmem.h>\r
+#endif\r
+\r
+const std::string OptionsPage::GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars)\r
+{\r
+       std::string content="<h2 style=\"text-align:center;\">Options</h2>\r\n";\r
+       content+="<form name=\"frmoptions\" method=\"POST\"><input type=\"hidden\" name=\"formaction\" value=\"save\">";\r
+       content+="<table><tr><th>Option</th><th>Value</th><th>Description</th></tr>";\r
+\r
+       if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="save")\r
+       {\r
+               SQLite3DB::Statement update=m_db->Prepare("UPDATE tblOption SET OptionValue=? WHERE Option=?;");\r
+               std::vector<std::string> options;\r
+               std::vector<std::string> oldvalues;\r
+               std::vector<std::string> newvalues;\r
+               CreateArgArray(queryvars,"option",options);\r
+               CreateArgArray(queryvars,"oldvalue",oldvalues);\r
+               CreateArgArray(queryvars,"value",newvalues);\r
+\r
+               for(int i=0; i<options.size(); i++)\r
+               {\r
+                       if(oldvalues[i]!=newvalues[i])\r
+                       {\r
+                               update.Bind(0,newvalues[i]);\r
+                               update.Bind(1,options[i]);\r
+                               update.Step();\r
+                               update.Reset();\r
+                       }\r
+               }\r
+       }\r
+\r
+       SQLite3DB::Statement st=m_db->Prepare("SELECT Option,OptionValue,OptionDescription FROM tblOption;");\r
+       st.Step();\r
+\r
+       int count=0;\r
+       std::string countstr;\r
+       while(st.RowReturned())\r
+       {\r
+               std::string option;\r
+               std::string value;\r
+               std::string description;\r
+\r
+               st.ResultText(0,option);\r
+               st.ResultText(1,value);\r
+               st.ResultText(2,description);\r
+\r
+               StringFunctions::Convert(count,countstr);\r
+               content+="<tr>";\r
+               content+="<td valign=\"top\"><input type=\"hidden\" name=\"option["+countstr+"]\" value=\""+option+"\">"+option+"</td>";\r
+               content+="<td valign=\"top\"><input type=\"hidden\" name=\"oldvalue["+countstr+"]\" value=\""+value+"\">";\r
+               content+="<input type=\"text\" name=\"value["+countstr+"]\" value=\""+value+"\"></td>";\r
+               content+="<td valign=\"top\">"+description+"</td>";\r
+               content+="</tr>";\r
+               st.Step();\r
+               count++;\r
+       }\r
+\r
+       content+="<tr><td colspan=\"3\"><center><input type=\"submit\" value=\"Save\"></form></td></tr>";\r
+       content+="</table>";\r
+       \r
+       return "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"+StringFunctions::Replace(m_template,"[CONTENT]",content);\r
+}\r
+\r
+const bool OptionsPage::WillHandleURI(const std::string &uri)\r
+{\r
+       if(uri.find("options.")!=std::string::npos)\r
+       {\r
+               return true;\r
+       }\r
+       else\r
+       {\r
+               return false;\r
+       }\r
+}\r
diff --git a/src/http/pages/peertrustpage.cpp b/src/http/pages/peertrustpage.cpp
new file mode 100644 (file)
index 0000000..a9ac96f
--- /dev/null
@@ -0,0 +1,123 @@
+#include "../../../include/http/pages/peertrustpage.h"\r
+#include "../../../include/stringfunctions.h"\r
+\r
+#ifdef XMEM\r
+       #include <xmem.h>\r
+#endif\r
+\r
+const std::string PeerTrustPage::GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars)\r
+{\r
+       int count=0;\r
+       std::string countstr;\r
+       std::string content="";\r
+\r
+       if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="update")\r
+       {\r
+               std::vector<std::string> identityids;\r
+               std::vector<std::string> oldlmt;\r
+               std::vector<std::string> lmt;\r
+               std::vector<std::string> oldltlt;\r
+               std::vector<std::string> ltlt;\r
+               int localmessagetrust=0;\r
+               int localtrustlisttrust=0;\r
+               int identityid;\r
+\r
+               CreateArgArray(queryvars,"identityid",identityids);\r
+               CreateArgArray(queryvars,"oldlocalmessagetrust",oldlmt);\r
+               CreateArgArray(queryvars,"localmessagetrust",lmt);\r
+               CreateArgArray(queryvars,"oldlocaltrustlisttrust",oldltlt);\r
+               CreateArgArray(queryvars,"localtrustlisttrust",ltlt);\r
+               \r
+               SQLite3DB::Statement update=m_db->Prepare("UPDATE tblIdentity SET LocalMessageTrust=?, LocalTrustListTrust=? WHERE IdentityID=?;");\r
+\r
+               for(int i=0; i<identityids.size(); i++)\r
+               {\r
+                       if(oldlmt[i]!=lmt[i] || oldltlt[i]!=ltlt[i])\r
+                       {\r
+                               StringFunctions::Convert(lmt[i],localmessagetrust);\r
+                               StringFunctions::Convert(ltlt[i],localtrustlisttrust);\r
+                               StringFunctions::Convert(identityids[i],identityid);\r
+\r
+                               update.Bind(0,localmessagetrust);\r
+                               update.Bind(1,localtrustlisttrust);\r
+                               update.Bind(2,identityid);\r
+                               update.Step();\r
+                               update.Reset();\r
+                       }\r
+               }\r
+\r
+       }\r
+\r
+       content+="<h2>Peer Trust</h2>";\r
+       content+="Message Trust is how much you trust the identity to post good messages. Trust List Trust is how much weight you want the trust list of that identity to have when calculating the total. The local trust levels are set by you, and the peer trust levels are calculated by a weighted average using other identities trust lists.";\r
+       content+="<form name=\"frmtrust\" method=\"POST\">";\r
+       content+="<input type=\"hidden\" name=\"formaction\" value=\"update\">";\r
+       content+="<table>";\r
+       content+="<tr><th>Name</th><th>Local Message Trust</th><th>Peer Message Trust</th><th>Local Trust List Trust</th><th>Peer Trust List Trust</th></tr>";\r
+       \r
+       SQLite3DB::Statement st=m_db->Prepare("SELECT IdentityID,Name,LocalMessageTrust,PeerMessageTrust,LocalTrustListTrust,PeerTrustListTrust,PublicKey FROM tblIdentity ORDER BY Name;");\r
+       st.Step();\r
+\r
+       while(st.RowReturned())\r
+       {\r
+               std::string identityid;\r
+               std::string name;\r
+               std::string localmessagetrust;\r
+               std::string peermessagetrust;\r
+               std::string localtrustlisttrust;\r
+               std::string peertrustlisttrust;\r
+               std::string publickey;\r
+\r
+               StringFunctions::Convert(count,countstr);\r
+\r
+               st.ResultText(0,identityid);\r
+               st.ResultText(1,name);\r
+               st.ResultText(2,localmessagetrust);\r
+               st.ResultText(3,peermessagetrust);\r
+               st.ResultText(4,localtrustlisttrust);\r
+               st.ResultText(5,peertrustlisttrust);\r
+               st.ResultText(6,publickey);\r
+\r
+               content+="<tr>";\r
+               content+="<td title=\""+publickey+"\">";\r
+               content+="<input type=\"hidden\" name=\"identityid["+countstr+"]\" value=\""+identityid+"\">";\r
+               if(name!="")\r
+               {\r
+                       content+=name;\r
+               }\r
+               else\r
+               {\r
+                       content+="[Unknown Name]";\r
+               }\r
+               content+="</td>";\r
+               content+="<td>";\r
+               content+="<input type=\"hidden\" name=\"oldlocalmessagetrust["+countstr+"]\" value=\""+localmessagetrust+"\">";\r
+               content+="<input type=\"text\" name=\"localmessagetrust["+countstr+"]\" value=\""+localmessagetrust+"\" size=\"2\" maxlength=\"3\"></td>";\r
+               content+="<td>"+peermessagetrust+"</td>";\r
+               content+="<td>";\r
+               content+="<input type=\"hidden\" name=\"oldlocaltrustlisttrust["+countstr+"]\" value=\""+localtrustlisttrust+"\">";\r
+               content+="<input type=\"text\" name=\"localtrustlisttrust["+countstr+"]\" value=\""+localtrustlisttrust+"\" size=\"2\" maxlength=\"3\"></td>";\r
+               content+="<td>"+peertrustlisttrust+"</td>";\r
+               content+="</tr>";\r
+               st.Step();\r
+               count++;\r
+       }\r
+\r
+       content+="<tr><td colspan=\"5\"><input type=\"submit\" value=\"Update Trust\"></td></tr>";\r
+       content+="</table>";\r
+       content+="</form>";\r
+\r
+       return "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"+StringFunctions::Replace(m_template,"[CONTENT]",content);\r
+}\r
+\r
+const bool PeerTrustPage::WillHandleURI(const std::string &uri)\r
+{\r
+       if(uri.find("peertrust.")!=std::string::npos)\r
+       {\r
+               return true;\r
+       }\r
+       else\r
+       {\r
+               return false;\r
+       }\r
+}\r
diff --git a/src/http/pages/showcaptchapage.cpp b/src/http/pages/showcaptchapage.cpp
new file mode 100644 (file)
index 0000000..abd65b3
--- /dev/null
@@ -0,0 +1,48 @@
+#include "../../../include/http/pages/showcaptchapage.h"\r
+#include "../../../include/base64.h"\r
+#include "../../../include/stringfunctions.h"\r
+\r
+#ifdef XMEM\r
+       #include <xmem.h>\r
+#endif\r
+\r
+const std::string ShowCaptchaPage::GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars)\r
+{\r
+       std::string content="HTTP/1.1 200 OK\r\n";\r
+       if(queryvars.find("UUID")!=queryvars.end())\r
+       {\r
+               SQLite3DB::Statement st=m_db->Prepare("SELECT MimeType,PuzzleData FROM tblIntroductionPuzzleRequests WHERE UUID=?;");\r
+               st.Bind(0,(*queryvars.find("UUID")).second);\r
+               st.Step();\r
+\r
+               if(st.RowReturned())\r
+               {\r
+                       std::string mime;\r
+                       std::string b64data;\r
+                       std::vector<unsigned char> data;\r
+                       std::string lenstr;\r
+\r
+                       st.ResultText(0,mime);\r
+                       st.ResultText(1,b64data);\r
+                       Base64::Decode(b64data,data);\r
+                       StringFunctions::Convert(data.size(),lenstr);\r
+\r
+                       content+="Content-Type: "+mime+"\r\n";\r
+                       content+="Content-Length: "+lenstr+"\r\n\r\n";\r
+                       content+=std::string(data.begin(),data.end());\r
+               }\r
+       }\r
+       return content;\r
+}\r
+\r
+const bool ShowCaptchaPage::WillHandleURI(const std::string &uri)\r
+{\r
+       if(uri.find("showcaptcha.")!=std::string::npos)\r
+       {\r
+               return true;\r
+       }\r
+       else\r
+       {\r
+               return false;\r
+       }\r
+}\r
index f4d3a95..dee644d 100644 (file)
@@ -22,7 +22,7 @@ Message::Message(const long messageid)
 \r
 const std::string Message::GetNNTPArticleID() const\r
 {\r
-       return "<"+m_messageuuid+">";\r
+       return "<"+m_messageuuid+"@freenetproject.org>";\r
 }\r
 \r
 const std::string Message::GetNNTPBody() const\r
@@ -57,7 +57,7 @@ const std::string Message::GetNNTPHeaders() const
                        {\r
                                rval+=" ";\r
                        }\r
-                       rval+="<"+(*j).second+">";\r
+                       rval+="<"+(*j).second+"@freenetproject.org>";\r
                }\r
                rval+="\r\n";\r
        }\r
@@ -276,6 +276,18 @@ const bool Message::ParseNNTPMessage(const std::string &nntpmessage)
                        }\r
                }\r
                m_fromname=StringFunctions::TrimWhitespace(m_fromname);\r
+\r
+               // trim off " from beginning and end\r
+               if(m_fromname.size()>0 && m_fromname[0]=='\"')\r
+               {\r
+                       m_fromname.erase(0,1);\r
+               }\r
+               if(m_fromname.size()>0 && m_fromname[m_fromname.size()-1]=='\"')\r
+               {\r
+                       m_fromname.erase(m_fromname.size()-1,1);\r
+               }\r
+\r
+               m_fromname=StringFunctions::TrimWhitespace(m_fromname);\r
        }\r
        else\r
        {\r
@@ -328,9 +340,15 @@ const bool Message::ParseNNTPMessage(const std::string &nntpmessage)
                StringFunctions::SplitMultiple(temp,", \t",parts);\r
                for(std::vector<std::string>::reverse_iterator i=parts.rbegin(); i!=parts.rend(); i++)\r
                {\r
+                       // get rid of < and > and any whitespace\r
                        (*i)=StringFunctions::Replace((*i),"<","");\r
                        (*i)=StringFunctions::Replace((*i),">","");\r
                        (*i)=StringFunctions::TrimWhitespace((*i));\r
+                       // erase @ and everything after\r
+                       if((*i).find("@")!=std::string::npos)\r
+                       {\r
+                               (*i).erase((*i).find("@"));\r
+                       }\r
                        if((*i)!="")\r
                        {\r
                                m_inreplyto[count++]=(*i);\r
index d909c36..d7eaa70 100644 (file)
@@ -636,6 +636,11 @@ const bool NNTPConnection::HandleOverCommand(const NNTPCommand &command)
                        messageuuid=command.m_arguments[0];\r
                        messageuuid=StringFunctions::Replace(messageuuid,"<","");\r
                        messageuuid=StringFunctions::Replace(messageuuid,">","");\r
+                       // get rid of @ and everything after\r
+                       if(messageuuid.find("@")!=std::string::npos)\r
+                       {\r
+                               messageuuid.erase(messageuuid.find("@"));\r
+                       }\r
                }\r
                // single article or range\r
                else\r
@@ -944,7 +949,7 @@ void NNTPConnection::SendArticleOverInfo(Message &message)
                        {\r
                                line+=" ";\r
                        }\r
-                       line+="<"+(*i).second+">";\r
+                       line+="<"+(*i).second+"@freenetproject.org>";\r
                }\r
                line+="\t";\r
        }\r
diff --git a/template.htm b/template.htm
new file mode 100644 (file)
index 0000000..7c4782e
--- /dev/null
@@ -0,0 +1,221 @@
+<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">\r
+<head>\r
+<title>FMS : Freenet Message System</title>\r
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />\r
+<style type="text/css">\r
+body {\r
+       background-color: #FFF;\r
+       color: #000;\r
+       font-family: Verdana, Arial, Helvetica, sans-serif;\r
+       font-size: 90%;\r
+}\r
+a, a:link, a:active { color: #0000FF; text-decoration: none; }\r
+a:visited { color: #003399; text-decoration: none; }\r
+a:hover { color: #990000; text-decoration: underline; }\r
+p      {}\r
+div {\r
+}\r
+h1 {}\r
+h2 { color: #003366;}\r
+h3 { color: #336699; border-bottom: 1px solid #336699;}\r
+h4 { color: #6699CC; border-bottom: 1px solid #6699CC;}\r
+h5 { color: #99CCFF;}\r
+\r
+ul             {\r
+                       padding:0px;\r
+                       margin-top:5px;\r
+                       margin-bottom:5px;\r
+                       margin-left:25px;\r
+               }\r
+\r
+.banner { \r
+       background-color: #003366;\r
+       color: #FFFFFF;\r
+       font-weight: bolder;\r
+}\r
+.navigation {\r
+       background-color: #CCDDEE;\r
+       border: 1px solid #999999;\r
+       font-size: 80%;\r
+}\r
+.content_main { background-color: #FFFFFF;}\r
+.content_left {\r
+               font-size: 90%;\r
+}\r
+.content_left .box {\r
+       border: 1px solid #336699;\r
+       background-color: #DDEEFF;\r
+       font-size: 85%;\r
+}\r
+.content_left .box .header {\r
+       background-color: #003366;      \r
+       color: #FFFFFF;\r
+       font-weight: bold;\r
+       font-size: 1em;\r
+}\r
+.content_left .box p {\r
+}\r
+.content_right {\r
+}\r
+.footer {      \r
+       color: #999;\r
+       font-size: smaller;\r
+       text-align: center;\r
+       border-top: 1px dashed #CCCCCC;\r
+}\r
+.meta-info {\r
+       font-size: 80%;\r
+}\r
+.paragraph {\r
+       line-height: 1.4em;\r
+}\r
+\r
+.smaller { font-size: 65%; }\r
+.darkest { background-color: #003366; }\r
+.darker { background-color: #336699; }\r
+.dark { background-color: #6699CC; }\r
+.light { background-color: #99CCFF; }\r
+.lighter { background-color: #DDEEFF; }\r
+.lightest { background-color: #FFFFFF; }\r
+\r
+.xml1-attributename { color: #800000; }\r
+.xml1-attributevalue { color: #FF0000; }\r
+.xml1-cdatasection { color: #808000; }\r
+.xml1-comment { color: #808080; font-style: italic; }\r
+.xml1-currentline { color: #000000; }\r
+.xml1-doctypesection { color: #008080; }\r
+.xml1-elementname { color: #000080; }\r
+.xml1-entityreference { color: #0000FF; }\r
+.xml1-matchedbraces { color: #FF0000; }\r
+.xml1-namespaceattributename { color: #008000; }\r
+.xml1-namespaceattributevalue { color: #0000FF; }\r
+.xml1-processinginstruction { color: #000080; }\r
+.xml1-rightedge { color: #C0C0C0; }\r
+.xml1-selection { color: #FFFFFF; }\r
+.xml1-symbol { color: #808080; }\r
+.xml1-text { color: #000000; }\r
+.xml1-whitespace { color: #FFFFFF; }\r
+\r
+.calcheading   {\r
+                                       font-weight:bold;\r
+                               }\r
+                               \r
+.calcheading td        {\r
+                                       padding-left:10px;\r
+                                       padding-right:10px;\r
+                               }\r
+                               \r
+.calcrow td            {\r
+                                       background-color:#EEEEEE;\r
+                                       text-align:right;\r
+                               }\r
+                               \r
+.totalrow td   {\r
+                                       text-align:right;\r
+                               }\r
+               \r
+/* layout */\r
+                               \r
+body {\r
+       width: auto;\r
+       margin: 1em;\r
+}\r
+p, div {\r
+       margin: 0em 0em 0em 0em;\r
+       padding: 0em;\r
+}\r
+h1, h2, h3, h4, h5, h6 {\r
+       margin: 0em 0em .2em 0em;\r
+       padding: 0em 0em .1em 0em;\r
+}\r
+\r
+.banner { \r
+       margin: 0em;\r
+       padding: .5em;\r
+\r
+}\r
+.navigation {\r
+       margin: 0em 0em 0em 0em;\r
+       padding: .3em;\r
+}\r
+\r
+.content_main {\r
+       margin: 0em;\r
+       padding: 0em;\r
+}\r
+\r
+.content_left {\r
+       float: left;\r
+       width: 200px;\r
+       margin: 1em 0em 0em 0em;\r
+       padding: 0em;\r
+}\r
+.content_left .box {\r
+       margin: 0em 0em 1em 0em;\r
+}\r
+.content_left .box .header {\r
+       padding: .5em;\r
+}\r
+.content_left .box p {\r
+       padding: 0em .3em 0em .3em;\r
+       margin: .0em 0em .5em 0em;\r
+}\r
+\r
+.content_right {\r
+       position:absolute;\r
+       left:220px;\r
+       margin: 0px 0px 0px 0px;\r
+       padding: 1em;\r
+}\r
+\r
+.meta-info {\r
+       text-align: right;\r
+}\r
+\r
+.footer {\r
+       clear: both;\r
+       padding: 1em;\r
+       margin: 0em;\r
+}\r
+\r
+.paragraph             {\r
+                                       margin-bottom:.5em;\r
+                               }\r
+</style>\r
+</head>\r
+\r
+<body>\r
+       \r
+       <div class="banner">\r
+       FMS : Freenet Message System\r
+       </div>\r
+       \r
+       <div class="content_main">\r
+\r
+       <div class="content_left">\r
+               <div class="box">\r
+               <div class="header">Links</div>\r
+               <ul>\r
+                       <li><a href="index.htm">Home</a></li>\r
+                       <li><a href="options.htm">Options</a></li>\r
+                       <li><a href="createidentity.htm">Create Identity</a></li>\r
+                       <li><a href="localidentities.htm">Local Identities</a></li>\r
+                       <li><a href="announceidentity.htm">Announce Identity</a></li>\r
+                       <li><a href="addpeer.htm">Add Peer</a></li>\r
+                       <li><a href="peertrust.htm">Peer Trust</a></li>\r
+               </ul>\r
+               </div>\r
+       \r
+       </div>\r
+       \r
+       <div class="content_right">\r
+       \r
+               [CONTENT]\r
+               \r
+       </div>\r
+       \r
+       </div>\r
+\r
+\r
+</body>\r
+</html>\r