I have this great randomizer that does all the job with texts and html codes, but not php codes... If you could improve it so it randomizes php codes too - that would be just awesome!
Codes:
File: config.inc.php
<?
$user_pass = "password";
$filename = "data.dat";
?>
File: random.php
<?
include("config.inc.php");
$input = file($filename);
if (count($input) != 0) {
if (empty($r) || $r == "1") {
$input = file($filename);
srand ((double) microtime() * 10000000);
$a = rand(0, sizeof($input) - 1);
echo $header.$input[$a].$footer; }
else {
$input = file($filename);
$max=count($input);
srand ((float) microtime() * 10000000);
$rand_keys = array_rand ($input, $max);
if ($r < 0) {
for ($i=0; $i<$max;$i++)
echo $header.$input[$rand_keys[$i]].$footer;
}
elseif ($r <= $max) {
for ($i=0; $i<$r;$i++)
echo $header.$input[$rand_keys[$i]].$footer;
}
else {
$r = $max;
for ($i=0; $i<$r;$i++)
echo $header.$input[$rand_keys[$i]].$footer;
}
}
}
else {
echo "Add at least one phrase.";
}
?>
File: rand_js.php
<?
include("config.inc.php");
$input = file($filename);
if (count($input) != 0) {
if (empty($r) || $r == "1") {
$input = file($filename);
srand ((double) microtime() * 10000000);
$a = rand(0, sizeof($input) - 1);
$header = str_replace("\"","\\\"",$header);
$header = str_replace("\n","",$header);
$header = str_replace("\r","",$header);
$footer = str_replace("\"","\\\"",$footer);
$footer = str_replace("\n","",$footer);
$footer = str_replace("\r","",$footer);
$input[$a] = str_replace("\"","\\\"",$input[$a]);
$input[$a] = str_replace("\n","",$input[$a]);
$input[$a] = str_replace("\r","",$input[$a]);
echo "document.write(\"".$header.$input[$a].$footer."\");"; }
else {
$input = file($filename);
$max=count($input);
srand ((float) microtime() * 10000000);
$rand_keys = array_rand ($input, $max);
if ($r < 0) {
for ($i=0; $i<$max;$i++) {
$input[$rand_keys[$i]] = str_replace("\"","\\\"",$input[$rand_keys[$i]]);
$input[$rand_keys[$i]] = str_replace("\n","",$input[$rand_keys[$i]]);
$input[$rand_keys[$i]] = str_replace("\r","",$input[$rand_keys[$i]]);
echo "document.write(\"".$header.$input[$rand_keys[$i]].$footer."\");";
}
}
elseif ($r <= $max) {
for ($i=0; $i<$r;$i++) {
$input[$rand_keys[$i]] = str_replace("\"","\\\"",$input[$rand_keys[$i]]);
$input[$rand_keys[$i]] = str_replace("\n","",$input[$rand_keys[$i]]);
$input[$rand_keys[$i]] = str_replace("\r","",$input[$rand_keys[$i]]);
echo "document.write(\"".$header.$input[$rand_keys[$i]].$footer."\");";
}
}
else {
$r = $max;
for ($i=0; $i<$r;$i++) {
$input[$rand_keys[$i]] = str_replace("\"","\\\"",$input[$rand_keys[$i]]);
$input[$rand_keys[$i]] = str_replace("\n","",$input[$rand_keys[$i]]);
$input[$rand_keys[$i]] = str_replace("\r","",$input[$rand_keys[$i]]);
echo "document.write(\"".$header.$input[$rand_keys[$i]].$footer."\");";
}
}
}
}
else {
echo "document.write(\"Add at least one phrase.\");";
}
?>
File: data.dat (where what should be randomized is placed)
for example, I need these very randomizers to be randomized:
<?
$r = "1";
include("random.php");
?>
<?
$r = "1";
include("random1.php");
?>
<?
$r = "1";
include("random2.php");
?>
Thanks for your help in advance!