<!--%%INCLUDE "i_defaulthead.incl" ("PolluStop Database")-->
   <form action="database" method="post" enctype="multipart/form-data">

   <fieldset>
      <legend>Token database Status</legend><ul><!--%%IF database.iscasesensitive-->
      <li>The database contains mixed-case tokens</li><!--%%ELSE-->
      <li>The database contains only lower-case tokens</li><!--%%ENDIF--><!--%%IF zzz--><!--% %IF database.haschainedtokens-->
      <li>The database contains chained tokens</li><!--% %ELSE-->
      <li>The database doesn't contain chained tokens</li><!--% %ENDIF--><!--%%ENDIF--><!--%%IF database.hascontextualtokens-->
      <li>The database contains contextual tokens</li><!--%%ENDIF--><!--%%IF database.isniversoft-->
      <li>The Spam database has been trained starting with a Niversoft-provided database</li><!--%%ENDIF-->
      <li>The Spam set contains <span class="tt">%%database.spamtokens%%</span> unique tokens from <span class="tt">%%database.spammessages%%</span> messages (approx <span class="tt">%%database.spamtokpermsg%%</span> / message).</li>
      <li>The Good set contains <span class="tt">%%database.goodtokens%%</span> unique tokens from <span class="tt">%%database.goodmessages%%</span> messages (approx <span class="tt">%%database.goodtokpermsg%%</span> / message).</li>
      <li>The Spam set <!--%%IF NOT(database.spamok)--><span class="bolderrors">does not</span> contain<!--%%ELSE-->contains<!--%%ENDIF--> enough tokens and messages to be considered reliable.</li>
      <li>The Good set <!--%%IF NOT(database.goodok)--><span class="bolderrors">does not</span> contain<!--%%ELSE-->contains<!--%%ENDIF--> enough tokens and messages to be considered reliable.</li><!--%%IF NOT(database.goodunbroke)-->
      <li style="color:red">The Good set uses an old format and doesn't take advantage of all features provided by PolluStop. You should retrain it from scratch to get a better accuracy when searching for spam.</li><!--%%ENDIF--><!--%%IF NOT(database.spamunbroke)-->
      <li style="color:red">The Spam set uses an old format and doesn't take advantage of all features provided by PolluStop. You should retrain it from scratch to get a better accuracy when searching for spam.</li><!--%%ENDIF-->
   </ul></fieldset>

   <fieldset>
      <legend>SQLite database status</legend><ul>
      <li>The database contains data for <span class="tt">%%database.sqliteusrcount%%</span> accounts in <span class="tt">%%database.sqlitedomcount%%</span> domains</li>
      <li>The database contains <span class="tt">%%database.sqliteswcount%%</span> sender whitelist entries</li>
      <li>The database contains <span class="tt">%%database.sqlitesbcount%%</span> sender blacklist entries</li>
      <li>The database contains <span class="tt">%%database.sqlitetwcount%%</span> case-sensitive token whitelist entries</li>
      <li>The database contains <span class="tt">%%database.sqliteitwcount%%</span> case-insensitive token whitelist entries</li>
      <li>The database engine currently use <span class="tt">%%database.sqlitecurmem%%</span> kb of memory. The peak use since last startup was <span class="tt">%%database.sqlitehimem%%</span> kb.</li>
      <li>The database file takes <span class="tt">%%database.sqlitefilesize%%</span> kb on disk</li>
      </ul>   <!--%%IF serveradminlevel-->
      <p class="explain">You can reclaim freed space and defragment the database for better performance if your db grew big. The operation can take several seconds depending on the size of the database</p>
      <p><input type="submit" name="vacuum" value="VACUUM SQlite database" /></p><!--%%ENDIF-->
   </fieldset>

   <fieldset>
      <legend>Database query</legend>
      <p class="explain">Enter one or more (space-separated) words you want to know the score of:</p>
      <p><textarea name="tokens" style="width:100%" cols="80" rows="5"></textarea></p>
      <p><input name="query" type="submit" value="Query Database" /></p>

      <!--%%IF EXISTS(results)-->
      <table cellspacing="0">
         <tr><th class="table">Token</th><th class="table" colspan="2">Spam occurences</th><th class="table" colspan=2>Good occurences</th><th  class="table">Score</th></tr><!--%%FORALL result in results-->
         <tr><td class="table">%%result[].token%%</td><td class="table1">%%result[].spam%%</td><td class="table2">(%%result[].spamratio%%)</td><td class="table1">%%result[].good%%</td><td class="table2">(%%result[].goodratio%%)</td><td class="table">%%result[].score%%</td></tr>
      <!--%%ENDFOR result--></table>
      <!--%%ENDIF-->
   </fieldset>

   <!--%%IF serveradminlevel-->

   <fieldset><legend>Database operations</legend>
      <fieldset><legend>Create manual backup</legend>
         <p class="explain">A backup of the database is automatically created each time the database is saved after modification. Previous backups are kept for the time specified in the <a href="/general#backup">Backup Files</a> section of the <a href="/general">General Settings</a> page. You can create a manual backup of the database which will not be automatically deleted.</p>
         <p><input type="submit" name="createbackup" value="Create manual backup" /></p>
      </fieldset>

      <fieldset><legend>Restore backup</legend>
         <p class="explain">You can restore a previous backup of the database:</p>
         <p>Good messages: <select style="width:auto;" name="goodbackuptorestore"><!--%%STRINGMENU "*" IN goodbackups--></select></p>
         <p>Spam messages: <select style="width:auto;" name="spambackuptorestore"><!--%%STRINGMENU "*" IN spambackups--></select></p>
         <p><input type="submit" name="restorebackup" value="Restore selected backup[s]" /></p>
      </fieldset>

      <fieldset><legend>Delete backup</legend>
         <p class="explain">Automatic backups are automatically deleted after the delay specified in the <a href="/general#backup">Backup Files</a> section of the <a href="/general">General Settings</a> page. Manual backups are not deleted automatically, you can delete them manually.</p>
         <p>Good messages: <select style="width:auto;" name="goodbackuptodelete"><!--%%STRINGMENU "*" IN goodbackups--></select></p>
         <p>Spam messages: <select style="width:auto;" name="spambackuptodelete"><!--%%STRINGMENU "*" IN spambackups--></select></p>
         <p><input type="submit" name="deletebackup" value="Delete selected backup[s]" /></p>
      </fieldset>

      <fieldset><legend>Purge database</legend>
         <p class="explain">You can purge the databases to start over with training:</p>
         <p><input disabled="disabled" type="submit" name="purgegooddb" value="Purge Good messages DB" /> <input disabled="disabled" type="submit" name="purgespamdb" value="Purge Spam messages DB" /></p>
         <p><label><input onclick="IAmSure(this, 'purgegooddb', 'purgespamdb')" type="checkbox" name="purgedbsure" value="1" /> I am sure</label></p>
      </fieldset>

      <fieldset><legend>Upload database file</legend>
         <p class="explain">You can upload a database file (.db72 files only) to replace or append to the existing one :</p>
         <p><input type="file" name="newfile" />
            <label><input type="radio" name="appendfile" onclick="IAmSure(this,'uploadgooddb','uploadspamdb')" value="0" />Replace</label>
            <label><input type="radio" name="appendfile" onclick="IAmSure(this,'uploadgooddb','uploadspamdb')" value="1" />Append</label></p>
         <p><input type="submit" disabled="disabled" name="uploadgooddb" value="Upload new Good DB" />
            <input type="submit" disabled="disabled" name="uploadspamdb" value="Upload new Spam DB" /></p>
      </fieldset>

   </fieldset><!--%%ENDIF-->
   </form>
<!--%%INCLUDE "i_defaultfoot.incl"-->
