Index: trunk/obscure.php
===================================================================
diff -u -r13 -r1253
--- trunk/obscure.php (.../obscure.php) (revision 13)
+++ trunk/obscure.php (.../obscure.php) (revision 1253)
@@ -1,18 +1,48 @@
#!/usr/local/bin/php
+
$start,"end"=>$end,"attribs"=>$attribs,"newname"=>$newname);
}
}
}
+// print_r($functions);
//echo "
"; print_r($functions); echo "
";
function GetVarName($s)
@@ -78,8 +109,8 @@
$g = strpos($line,"global");
if(is_numeric($g))
{
- $vars = substr($line,$g+7);
- $vars = substr($vars,0,-2);
+ $vars = trim(substr($line,$g+7));
+ $vars = substr($vars,0,-1);
$v = explode(",",$vars);
for($z=0;$z3)
{
- $a = explode(",",substr($Attribs,1,-2));
- if (is_array($a)) {
+ $Attribs = trim($Attribs);
+ $Attribs = str_replace("\t","",$Attribs);
+ //echo "getting attribs from $Attribs\n";
+ $a = explode(",",substr($Attribs,1,-1));
+// echo "got attribs for func [$Attribs]:\n";
+// var_dump($a);
+ if (is_array($a) && $a[0] != '') {
foreach($a as $attr)
{
- $variables[$attr] = '$_'.md5($VarCount++);
+ list($attr,$default) = explode('=', $attr);
+ //echo "attr: $attr / def = $default\n";
+ if ($default != '') {
+ $defaults[$attr] = $default;
+ //echo "stored defaults for $attr\n";
+ }
+ $variables[$attr] = '$_'.gen_name($VarCount++);
}
}
}
@@ -123,7 +165,7 @@
{
$name = "$".trim($name);
if(!in_array($name,$globals) && !array_key_exists($name,$variables))
- $variables[$name] = '$_'.md5($VarCount++);
+ $variables[$name] = '$_'.gen_name($VarCount++);
}
}
$p = strpos($line,"$",$p+1);
@@ -132,8 +174,10 @@
for($x=0;$x$varname)
{
+ //echo "strpos ".$code[$x].', '.$v."\n";
$p = strpos($code[$x],$v);
while(is_numeric($p))
{
@@ -151,21 +195,30 @@
if (is_array($a)) {
foreach($a as $attr)
{
- $av[] = $variables[$attr];
+ list($attr,$default) = explode('=', $attr);
+ $av[] = ($variables[$attr].(isset($defaults[$attr]) ? '='.$defaults[$attr] : ''));
}
}
if(count($av)>0)
$o .= implode(",",$av);
$o .= ")";
+ //echo "reversed: $o\n";
$o .= implode(" ",$code);
//$o = str_replace("\n","",$o);
return $o;
}
$out = "";
$outline = 0;
- foreach($functions as $name =>$pos)
- {
+
+ $shuffled = array_rand($functions, count($functions));
+// print_r($shuffled);
+
+ foreach ($shuffled as $name) {
+ $pos = $functions[$name];
+
+ //foreach($functions as $name =>$pos)
+ //{
$dest = $pos["start"];
$newname = $pos["newname"];
if(!$outline)
@@ -206,16 +259,16 @@
for($x=0;$x
\ No newline at end of file
+?>