changeset 1089:00632d30bafe

Implement new settings for making user/votekeys case-insensitive and setting the array of characters used for generating keys in the config.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 26 Jan 2017 01:27:32 +0200
parents 4f132374df75
children 04495bb47dc9
files mconfig.inc.php.example msite.inc.php usrlogin.php
diffstat 3 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mconfig.inc.php.example	Thu Jan 26 00:48:34 2017 +0200
+++ b/mconfig.inc.php.example	Thu Jan 26 01:27:32 2017 +0200
@@ -26,8 +26,10 @@
   // Default page
   "defaultPage"     => "about", // Default page
 
-  // Vote key length in characters
-  "userKeyLength"   => 8,
+  // User key/votekey settings
+  "userKeyLength"   => 6,       // Vote key length in characters
+  //"userKeyCase"     => true,   // If false, keys are case-INsensitive
+  //"userKeyChars"    => "abdefghjkmnpqrstwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789", // Characters to be used for key generation
 
   // Voting settings
   "voteMin"         => -1,
--- a/msite.inc.php	Thu Jan 26 00:48:34 2017 +0200
+++ b/msite.inc.php	Thu Jan 26 01:27:32 2017 +0200
@@ -557,7 +557,15 @@
 function stGenerateUserKey()
 {
   global $db;
+
+  // Default keychars
   $keyChars = "abdefghjkmnpqrstwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
+
+  if (($tmp = stGetSetting("userKeyChars", NULL)) !== NULL)
+    $keyChars = $tmp;
+
+  if (($tmp = stGetSetting("userKeyCase", NULL)) !== NULL)
+    $keyChars = strtoupper($keyChars);
   
   while (TRUE)
   {
--- a/usrlogin.php	Thu Jan 26 00:48:34 2017 +0200
+++ b/usrlogin.php	Thu Jan 26 01:27:32 2017 +0200
@@ -26,6 +26,9 @@
 $gotoPage = stGetRequestItem("goto", FALSE);
 $errorPage = stGetRequestItem("error", FALSE);
 $password = stGetRequestItem("key", FALSE);
+if (stGetSetting("userKeyCase", NULL) === FALSE)
+  $password = strtoupper($password);
+
 $error = 0;
 
 $sql = stPrepareSQL("SELECT * FROM votekeys WHERE key=%s", $password);