Hi there,
I'm currently building a small stand-alone application that generates SEO-friendly URLs in the directory it is executed in, based on keywords submitted to the file. It's relatively simple, however, I'm having a very strange problem.
<?php
$root = "http://www.wx5.org";
$seo_names = "free,money,win,prizes,fun,games,play,cash,easy";
$seo_array = explode(",", $seo_names);
$keywords = 9;
function formulate($wpu, $kw)
{ $n = $kw^$wpu; return $n; }
$ct = 0;
while ( $ct<=1000 ) {
while ( empty($r1) )
{ $r1 = $seo_array[rand(0, $keywords)]; }
while ( empty($r2) )
{ $r2 = $seo_array[rand(0, $keywords)]; }
while ( empty($r3) )
{ $r3 = $seo_array[rand(0, $keywords)]; }
$filename = $r1."_".$r2."_".$r3;
$file = $filename.".html";
if ( !is_file($file) )
{ $redir = "<script>document.location='$root'</script>";
$fp = fopen ($file, "w");
fwrite($fp, $redir);
fclose($fp);
$ct++;
$cre = $cre . " ::[AND]:: " . $file; }
else
{ $nc++; }
}
echo "Created: $cre";
echo "<br><br>";
echo "Not Created: " . $nc . " pages.";
echo "Pages Generated: " . formulate(3, $keywords);
?>
The script worked fine before I added the "if empty" $rX checking, so I'm not sure why it wouldn't work now.
When I execute the file on my server, I get a DNS error, saying the page cannot be displayed. When I look in the directory where it was executed, it does create one file.
Before I added the "if empty" checking, it created 700 unique files after a few page refreshes.
Since there are 9 keywords there, and 3 keywords used per URL, the xy equation tells me that there should be 19,683 possible combinations. (39 = 19,683)
If anyone has any input, it would be greatly appriciated.
Thanks,
- Mike