DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • May 18, 2013, 03:11:43 AM
Home Forums News Links Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
IRC Channels
Search

Pages: [1]   Go Down
  Print  
Author Topic: Question: Passwords? Answer: zedpass()  (Read 1274 times)
0 Members and 1 Guest are viewing this topic.
KaosKaizer
Mod God
*****
Offline Offline

Posts: 1000


Love bites, but so do I!


View Profile
« on: July 09, 2011, 08:56:28 PM »

I didn't really know what else to title this post... BUT....
Have you ever wanted to provide your users with a random default password? Or how about giving them the option of resetting their password instead of giving it back to them or letting them log in? Or have it possible for them to create a random password until they can think of one for themselves? Well... Here is ZEDPASS! It will generate any password of any lengths(of at least 7 characters and no more than 75 characters). I think that if it were to be included in the core, then it could be left up to modders to come up with their own ways to use it.

Well, here's the code:
Code:
<?php
// Code by KaosKaizer, aka Douglas, of Kaizer iTek
function zedpass($strlen=7,$nums=false,$caps=true){
if ($strlen 7$strlen 7// set the default as the lowest accepted length
if ($strlen 75$strlen 75// do not allow the length to exceed 75
$low "abcdefghijklmnopqrstuvwxyz";
$cap "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$num "0123456789";
$fin $low;
if ($caps === true$fin .= $cap;
if ($nums === true$fin .= $num;
$password "";
for ($i=0$i $strlen$i++){
$password .= $fin[rand(0,strlen($fin))];
}
return $password;
}
?>
Logged

My Mods
Like to read? "Like" my page. Smiley
For reasons I'd prefer not to explain, I will not be active until further notice. I will not make any posts and I will ignore all PMs.
Afkamm
Mod God
*****
Offline Offline

Posts: 1563

MarcTheSlayer


View Profile WWW
« Reply #1 on: July 10, 2011, 07:46:25 AM »

Needs more characters. Cheesy
Logged

KaosKaizer
Mod God
*****
Offline Offline

Posts: 1000


Love bites, but so do I!


View Profile
« Reply #2 on: July 10, 2011, 09:42:42 AM »

Well, I left symbols out because one of them was messing with syntax and they aren't easy to remember. This is to just create a temporary password, nothing more. Like, if a player forgets theirs, it resets their password to this until they log in and change it.
Logged

My Mods
Like to read? "Like" my page. Smiley
For reasons I'd prefer not to explain, I will not be active until further notice. I will not make any posts and I will ignore all PMs.
backflip
Codemeister
****
Offline Offline

Posts: 278


om nom nom


View Profile WWW
« Reply #3 on: July 14, 2011, 01:03:06 AM »

Useful! Here's mine:
function smfintegration_make_password() {
  require_once(
"lib/e_rand.php");
  
$password="";
  for (
$i=0;$i<6;$i++) {
    
$char=e_rand(48,109);
    if (
$char>57$char+=7;
    if (
$char>90$char+=6;
    
$password.=chr($char);
  }
  return 
$password;
}
... but yours is easier to understand.

Theoretically, yes, but you cannot include characters that some players might not be able to produce.
« Last Edit: July 14, 2011, 01:06:50 AM by backflip » Logged

Bruce Schneier's functions don't have parameters. They have arguments, and they always win them.
Frodolin LoGD
JollyGG
Mod God
*****
Offline Offline

Posts: 545


Jolly Good!


View Profile WWW
« Reply #4 on: July 15, 2011, 04:11:17 AM »


Also I've noticed that code doesn't seem to like the input of special alt characters. I had a module that used those once (April Fool's Day upside down chat) and what I had to do was put the array in a txt file and load it that way, kinda annoying >.<
Logged

Owner of: Hogwarts Now
Supporter of: LotGD4Adults2, The Complex, and Dragons of Myth
Released Modules: Here
Srch
Captain of the Guard
***
Offline Offline

Posts: 133

Hi, I'm Ver!


View Profile
« Reply #5 on: August 06, 2012, 08:02:31 AM »

Was able to get a great result, which will probably not happen ever again: dR@GN?1

Modified with just a small example for special characters. Using ` caused some colors to show, unfortunately. (Unless you use rawoutput)

Code:
<?php
function zedpass($strlen=7){
if ($strlen 7$strlen 7// set the default as the lowest accepted length
if ($strlen 75$strlen 75// do not allow the length to exceed 75
$low "abcdefghijklmnopqrstuvwxyz";
$cap "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$num "0123456789";
$spec "+-=_)(*&^%#@!~:[];,.?";
$fin $low;
$fin .= $cap;
$fin .= $num;
$fin .= $spec;
$password "";
for ($i=0$i $strlen$i++){
$password .= $fin[rand(0,strlen($fin))];
}
return $password;
}
Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Play LoGD on Dragonprime

Support Us
$100 raised this year
Your help is greatly appreciated!
Who's Online
26 Guests, 1 User
Aeo
DragonPrime LoGD
Recent Topics
Home Forums News Links Downloads Login Register Advanced Search