PageRenderTime 29ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/Helios Engine/helios/functions/randomchars.php

https://code.google.com/p/prjtest00/
PHP | 70 lines | 50 code | 0 blank | 20 comment | 1 complexity | aca8796ea0bff23b68b25383f9efb455 MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0
  1. <?php
  2. ############################################################################
  3. # Copyright (C) 2007 by Arturo Mann #
  4. # arturo.mann@gmail.com #
  5. # #
  6. # This program is free software; you can redistribute it and#or modify #
  7. # it under the terms of the GNU General Public License as published by #
  8. # the Free Software Foundation; either version 2 of the License, or #
  9. # (at your option) any later version. #
  10. # #
  11. # This program is distributed in the hope that it will be useful, #
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of #
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  14. # GNU General Public License for more details. #
  15. # #
  16. # You should have received a copy of the GNU General Public License #
  17. # along with this program; if not, write to the #
  18. # Free Software Foundation, Inc., #
  19. # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
  20. ############################################################################
  21. function generateChars($key) {
  22. $seed = date(Hmsy);
  23. mt_srand($seed);
  24. $chararr = array( 1 => "A",
  25. 2 => "B",
  26. 3 => "C",
  27. 4 => "D",
  28. 5 => "E",
  29. 6 => "F",
  30. 7 => "G",
  31. 8 => "H",
  32. 9 => "I",
  33. 10 => "J",
  34. 11 => "K",
  35. 12 => "L",
  36. 13 => "M",
  37. 14 => "N",
  38. 15 => "P",
  39. 16 => "Q",
  40. 17 => "R",
  41. 18 => "S",
  42. 19 => "T",
  43. 20 => "U",
  44. 21 => "V",
  45. 22 => "W",
  46. 23 => "X",
  47. 24 => "Y",
  48. 25 => "Z",
  49. 26 => 1,
  50. 27 => 2,
  51. 28 => 3,
  52. 29 => 4,
  53. 30 => 5,
  54. 31 => 6,
  55. 32 => 7,
  56. 33 => 8,
  57. 34 => 9,
  58. 35 => 0,
  59. );
  60. $counter = 0;
  61. while ($counter <= $key) {
  62. $target = mt_rand(1,35);
  63. //echo $target;
  64. $rawst = $rawst.$chararr[$target];
  65. $counter++;
  66. }
  67. return $rawst;
  68. }
  69. $stream = $_REQUEST["lenght"];
  70. $string = generateChars($stream);