Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Scaevolus
Apr 16, 2007

Treytor posted:

Wow, that was easy. Thank you sir!
Be aware that this is a very inefficient way to do this, and it would be better to use a database.

Adbot
ADBOT LOVES YOU

Scaevolus
Apr 16, 2007

drcru posted:

Does anyone have any idea on how to efficiently create a random maze via PHP?

I found this one but I'm not quite sure on how to make it better. It takes quite awhile for it to make 20x20 maze as it seems to make them by going through every cell in the grid.

Anyone happen to know the name of the formula that makes up a maze?

A much faster maze generation algorithm is Eller's algorithm. The mazes might not be quite as pretty or have as nice properties, but it is perfect, and it's easy to do efficiently-- I used it to do maze generation in TI-89 BASIC, using only a few single-dimensional arrays and integers.

The idea is that you generate and output the maze one line at a time-- there's a good summary at http://www.astrolog.org/labyrnth/algrithm.htm (Ctrl-F Eller)



The mazes are pretty good if you tweak it properly.

Scaevolus fucked around with this message at 08:49 on Jul 18, 2008

Scaevolus
Apr 16, 2007

duz posted:

How would you do it otherwise?

Python handles this nicely.

I think there was a hack somewhere that did reflection to let php do keyword arguments with defaults.

Scaevolus
Apr 16, 2007

duz posted:

MD5 is very broken, SHA1 is only kind of broken.

Are collisions really that big of a problem with password hashing?

Scaevolus
Apr 16, 2007

drcru posted:

So would you add a salt before and after?

If you want to be paranoid--

generate ~16 random bytes for salt
hash salt . password
do another ~100 rounds of hashing on the result
store the salt + hash in the database

This will make bruteforcing really slow, and rainbow tables impractical.

Adbot
ADBOT LOVES YOU

Scaevolus
Apr 16, 2007

IT Guy posted:

Am I doing this wrong?

It's getting to be loving retarded to do a simple task.
Manipulating the DOM directly sucks a lot.

If you're okay with XHTML instead of HTML, use XMLWriter instead. It's stream-based, so your code ends up looking a lot nicer:

php:
<?
$w=new XMLWriter();
$w->openMemory();
$w->startDocument('1.0','UTF-8');
$w->startElement("root");
    $w->writeAttribute("ah", "OK");
    $w->text('Wow, it works!');
$w->endElement();
echo $w->outputMemory(true);
?>

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply