changeset 64:e1b673be98ec

Remove external votekey generator script.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 05 Oct 2013 12:51:13 +0300
parents 922b5192b2ff
children 72b22729ae7e
files keygen.php
diffstat 1 files changed, 0 insertions(+), 133 deletions(-) [+]
line wrap: on
line diff
--- a/keygen.php	Sat Oct 05 12:35:33 2013 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,133 +0,0 @@
-#!/usr/bin/php
-<?
-require "mconfig.inc.php";
-require "msite.inc.php";
-
-// We don't want to be run from anywhere else than commandline
-stCheckCLIOrDie();
-
-
-// Settings
-$keyChars = "abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
-$maxItems = 4;
-$maxRows  = 25;
-
-
-//
-// Check for commandline arguments
-//
-if ($argc < 2)
-{
-  echo "Usage: ".$argv[0]." <mode> [args]\n".
-  "Where mode is one of following:\n".
-  "\n".
-  "  generate <#>    Generate # MORE vote keys. If previously\n".
-  "                  generated keys exist, # keys will be added.\n".
-  "\n".
-  "  print [all]     Print list of list of UNactive keys\n".
-  "                  (unless 'all' option is specified)\n".
-  "\n";
-  exit;
-}
-
-if (!stConnectSQLDB())
-  die("Could not connect to SQL database.\n");
-
-switch (substr(stCArgLC(1), 0, 2))
-{
-  case "ge":
-    // Check arguments for sanity
-    if (($num = stCArgLC(2)) === FALSE)
-    {
-      echo "No number of keys specified.\n";
-      exit;
-    }
-
-    if ($num < 1 || $num > 1000)
-    {
-      echo "Invalid number of keys.\n";
-      exit;
-    }
-
-    echo "Generating keys ..";
-    for ($i = 0; $i < $num; )
-    {
-      echo ".";
-      
-      // Generate one keycode
-      $key = "";
-      for ($n = 0; $n < stGetSetting("userKeyLength"); $n++)
-        $key .= $keyChars[rand() % strlen($keyChars)];
-
-      // Check if it already exists, to avoid duplicates
-      $sql = stPrepareSQL("SELECT * FROM users WHERE key=%s", $key);
-      if (($res = @$db->query($sql)) !== FALSE)
-      {
-        if ($res->fetchColumn() === FALSE)
-        {
-          // Nope, add into database
-          $sql = stPrepareSQL(
-            "INSERT INTO users (key,active) VALUES (%s,0)",
-            $key);
-
-          if (($res = $db->query($sql)) === FALSE)
-            stCSQLError($sql);
-
-          $i++;
-        }
-      }
-      else
-      {
-        stCSQLError($sql);
-      }
-    }
-    echo "\nGenerated ".$i." new keys.\n";
-    break;
-  
-  case "pr":
-    // Print keys
-    $all = stCArgLC(2) == "all";
-    $sql = "SELECT * FROM users ".($all ? "" : "WHERE enabled=0 ")."ORDER BY id ASC";
-    if (($res = @$db->query($sql)) !== FALSE)
-    {
-      $rows = 0;
-      $nitem = 0;
-      $total = 0;
-      $str = "";
-
-      foreach ($res as $item)
-      {
-        $total++;
-        $str .= sprintf("%s%04d  -  %8s",
-          $item["enabled"] ? "*" : " ",
-          $item["id"], $item["key"]);
-
-        if (++$nitem >= $maxItems)
-        {
-          echo $str."\n".str_repeat("-", strlen($str))."\n";
-          $str = "";
-          $nitem = 0;
-          if (++$rows % $maxRows == 0)
-            echo "\f\n";
-        }
-        else
-          $str .= " |";
-      }
-      
-      if ($nitem > 0)
-        echo $str."\n";
-
-      echo "Total of ".$total." ".($all ? "keys (all printed)" : "unactive keys")."\n";
-    }
-    else
-    {
-      stCSQLError($sql);
-    }
-    break;
-  
-  default:
-    echo "Unknown operating mode '".stCArg(1)."'.\n";
-    break;
-}
-
-?>
\ No newline at end of file