TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 06-29-2009, 09:25 PM   #1 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default Need delphi to PHP translation

I know thisi s the python to PHP forum, but delphi always reminds me of python so here it goes. I found this script at random on the interweb and want to see what it does in PHP. Translation. Now.


Function GenStr(MaxLen,Restrictions:Integer):String;Overloa d;
{Possible Resctiction Values:
1 - All
2 - Just Letters and Numbers
3 - Just Numbers
4 - Just Letters
}
Var St:Byte;
Total:String;
begin
Repeat
Randomize;
St := Random(255);
If Restrictions = 1 then
Total := Total + chr(St);
If Restrictions = 2 then
If (St >= 48) and (St <= 57) or (St >= 65) and (St <= 90) or (St >= 97) and (St <= 122) then
Total := Total + chr(St);
If Restrictions = 3 then
If (St >= 48) and (St <= 57) then
Total := Total + chr(St);
If Restrictions = 4 then
If (St >= 65) and (St <= 90) or (St >= 97) and (St <= 122) then
Total := Total + chr(St);
Until Length(Total) = MaxLen;
Result := Total;
end;
Function GenStr(MaxLen:Integer;Pattern:String):String;Overl oad;
{Possible Resctiction Values:
1 - All
2 - Just Letters and Numbers
3 - Just Numbers
4 - Just Letters
Possble Pattern Parameters:
A or a - All
L - Letter In Capitals
l - Letter not in capitals
C or c - Character ( A,B or a,b (etc.))
N or n - Numbers
R or r - Random Generated Pattern
Ex:
If u wanted a generated string that was Number, number,number,Captiol
letter then any letter, u would use this pattern:
NNNLC or NNNLc
}
Var St:Byte;
Total:String;
Ptrn:String;
P:Byte;
PtrnCount:Integer;
begin
If (Pattern = 'R') or (Pattern = 'r') then
Begin
repeat
Randomize;
P := Random(225);
Case P of
65 or 97:Ptrn := Ptrn + 'A';
78:Ptrn := Ptrn + 'L';
108:Ptrn := Ptrn + 'l';
67 or 99:Ptrn := Ptrn + 'C';
78 or 110:Ptrn := Ptrn + 'N';
end;
until Length(Ptrn) = (MaxLen div 2) + 1;
Pattern := Ptrn;
end;
PtrnCount := 0;
Repeat
Randomize;
Inc(PtrnCount);
If (Pattern[PtrnCount] = 'A') or (Pattern[PtrnCount] = 'a') then
Total := Total + chr(Random(255));
If (Pattern[PtrnCount] = 'L') then
Begin
Repeat
St := Random(255);
Until (St >= 65) and (St <= 90);
Total := Total + chr(St);
end;
If (Pattern[PtrnCount] = 'l') then
Begin
Repeat
St := Random(255);
Until (St >= 97) and (St <= 122);
Total := Total + chr(St);
end;
If (Pattern[PtrnCount] = 'C') or (Pattern[PtrnCount] = 'c') then
begin
Repeat
St := Random(255);
Until (St >= 65) and (St <= 90) or (St >= 97) and (St <= 122);
Total := Total + chr(St);
end;
If (Pattern[PtrnCount] = 'N') or (Pattern[PtrnCount] = 'n') then
begin
Repeat
St := Random(255);
Until (St >= 48) and (St <= 57);
Total := Total + chr(St);
end;
If PtrnCount = Length(Pattern) then
PtrnCount := 0;
Until Length(Total) = MaxLen;
Result := Total;
end;



Wildhoney Green power
infraction was added to this post,
Village Idiot = lost 10 hp..

Behave! :)
__________________


Last edited by codefreek : 06-30-2009 at 02:10 AM.
Village Idiot is offline  
Reply With Quote
Old 06-29-2009, 10:07 PM   #2 (permalink)
The Addict
 
Enfernikus's Avatar
 
Join Date: Jun 2008
Posts: 335
Thanks: 2
Enfernikus is on a distinguished road
Default

LOL ( Char limit )
__________________
My Blog
Enfernikus is offline  
Reply With Quote
Old 06-29-2009, 10:12 PM   #3 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

WRONG FORUM!

Salathe! Codefreek! Hand out the infraction!
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 06-29-2009, 10:13 PM   #4 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Wildhoney; You are the green, mean, banmachine, so you infract him
__________________
Tanax is offline  
Reply With Quote
Old 06-29-2009, 10:22 PM   #5 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

Quote:
Wildhoney; You are the green, mean, banmachine, so you infract him
Don't provoke him! He gets violent!
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Old 06-29-2009, 10:34 PM   #6 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 06-30-2009, 12:34 AM   #7 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Quote:
Originally Posted by Wildhoney View Post
WRONG FORUM!

Salathe! Codefreek! Hand out the infraction!
Quote:
Originally Posted by Tanax View Post
Wildhoney; You are the green, mean, banmachine, so you infract him
Relax, I can add infractions. Oh, wait....
__________________

Village Idiot is offline  
Reply With Quote
Old 06-30-2009, 02:12 AM   #8 (permalink)
Super Moderator
Inquisitive 
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
codefreek is on a distinguished road
Default

i gave him the Wildhoney Green power infraction.

;)


PS: please format your code xD
codefreek is offline  
Reply With Quote
Old 07-02-2009, 09:43 PM   #9 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Enfernikus View Post
LOL ( Char limit )
this ( this aswell )
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 07-10-2009, 01:51 PM   #10 (permalink)
The Wanderer
 
Join Date: May 2009
Location: Lincoln
Posts: 9
Thanks: 0
James is on a distinguished road
Default

I 'eated' your code tags
Send a message via MSN to James
James is offline  
Reply With Quote
Old 06-25-2012, 12:34 PM   #11 (permalink)
The Wanderer
 
Join Date: May 2012
Location: usa
Posts: 6
Thanks: 0
cheapcnjerseys is on a distinguished road
Default

Nike NFL Jerseys from china, Nike NFL Jerseys online,cheap Nike NFL Jerseys,2012 nike nfl jerseys, nike nfl women jerseys,buy jerseys online, soccer jerseys shop online, nfl jerseys store online
cheapcnjerseys is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't get PHP 5. to work? Newbie windows PHP guy DotNetTim Absolute Beginners 11 02-01-2013 11:02 AM
10 PHP Myths Dispelled Wildhoney General 9 06-15-2009 06:55 AM
Tutorial for Beginners - Not a usual tutorial [Read it all and i think it will help] codefreek Absolute Beginners 8 01-26-2009 03:14 AM
PHP Compressor Kalle Script Giveaway 8 05-28-2008 12:14 AM
what are all the subjects in php? sarmenhb General 7 01-21-2008 05:41 PM


All times are GMT. The time now is 05:09 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design