Page 1 of 1

need help with script!

Posted: Thu Jan 01, 2009 8:17 pm
by tomsace
Hey.

I recently have had a few files decoded from ioncube.
One part of a script is showing as been this:

function remove_accents ($string)
{
return strtr ($string, 'ÀÁÂÃÄÅÆàáâãäåæÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñÞßÿý', 'aaaaaaaaaaaaaaoooooooooooooeeeeeeeeecceiiiiiiiiuuuuuuuunntsyy');
}

Also further down the page there is a script that uses these symbols also, it is like this:

$entities = array ('&amp' => '&', '&apos' => '\'', 'Þ' => 'Þ', 'ß' => 'ß', 'à' => 'à', 'á' => 'á', 'â' => 'â', 'ã' => 'ã', 'ä' => 'ä', 'å' => 'å', 'æ' => 'æ', 'ç' => 'ç', 'è' => 'è', 'é' => 'é', 'ê' => 'ê', 'ë' => 'ë', 'ì' => 'ì', 'í' => 'í', 'î' => 'î', 'ï' => 'ï', 'ð' => 'ð', 'ñ' => 'ñ', 'ò' => 'ò', 'ó' => 'ó', 'ô' => 'ô', 'õ' => 'õ', 'ö' => 'ö', 'ø' => 'ø', 'ù' => 'ù', 'ú' => 'ú', 'û' => 'û', 'ü' => 'ü', 'ý' => 'ý', 'þ' => 'þ', 'ÿ' => 'ÿ', 'Þ' => 'Þ', 'ß' => 'ß', 'À' => 'à', 'Á' => 'á', 'Â' => 'â', 'Ã' => 'ã', 'Ä' => 'ä', 'Å' => 'å', '&Aelig;' => 'æ', 'Ç' => 'ç', 'È' => 'è', 'É' => 'é', 'Ê' => 'ê', 'Ë' => 'ë', 'Ì' => 'ì', 'Í' => 'í', 'Î' => 'î', 'Ï' => 'ï', 'Ð' => 'ð', 'Ñ' => 'ñ', 'Ò' => 'ò', 'Ó' => 'ó', 'Ô' => 'ô', 'Õ' => 'õ', 'Ö' => 'ö', 'Ø' => 'ø', 'Ù' => 'ù', 'Ú' => 'ú', 'Û' => 'û', 'Ü' => 'ü', 'Ý' => 'ý', '&Yhorn;' => 'þ', 'Ÿ' => 'ÿ');
$apache_indexes = array ('N=A' => 1, 'N=D' => 1, 'M=A' => 1, 'M=D' => 1, 'S=A' => 1, 'S=D' => 1, 'D=A' => 1, 'D=D' => 1, 'C=N;O=A' => 1, 'C=M;O=A' => 1, 'C=S;O=A' => 1, 'C=D;O=A' => 1, 'C=N;O=D' => 1, 'C=M;O=D' => 1, 'C=S;O=D' => 1, 'C=D;O=D' => 1);
$common = array ();
$lines = @file ($include_dir . '/common.txt');
if (is_array ($lines))
{
while (list ($id, $word) = each ($lines))
{
$common[trim ($word)] = 1;
}
}

Can this be right? It doesn't seem like your usual php code.
Its a part of my search engine site and all I know is before I have the file decoded I could search for things with a ' in it for example: thing's. but now I recieve an error page (403 forbidden). Is this the reason why?
Its a file called commonfuncs.php by the way and also when a user signs up to the site when they register there email address the symbols such as @ and . dont submit so there registered email would be like: exampleyahoocom which could be linked to this script I think.
Please if you can fill in the blanks or give me a reason the script is like this please let me know.

Thanks.

P.S if you require the full page script for a better understanding of the script please ask and I will email it you.

Re: need help with script!

Posted: Thu Jan 01, 2009 8:40 pm
by requinix

Code: Select all

function remove_accents ($string)
{
  return strtr ($string, 'ÀÁÂÃÄÅÆàáâãäåæÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñÞßÿý', 'aaaaaaaaaaaaaaoooooooooooooeeeeeeeeecceiiiiiiiiuuuuuuuunntsyy');
}
strtr:
string strtr ( string $str , string $from , string $to )

This function returns a copy of str, translating all occurrences of each character in from to the corresponding character in to.
So À gets translated into a, Ò into o, È into e, and so on. So basically it remove_accents from a string.

Code: Select all

$entities = ...;
A big list of HTML entities.

Code: Select all

$apache_indexes = ...;
Dunno.

Code: Select all

$common = array ();
$lines = @file ($include_dir . '/common.txt');
if (is_array ($lines))
{
  while (list ($id, $word) = each ($lines))
  {
    $common[trim ($word)] = 1;
  }
}
Open up this "common.txt" file, and for each line (word?) in it, add an entry into the $common array.
My guess is that common.txt contains a bunch of words that are too common to search for (a, an, the, ...) and that later on $common will be used to filter out or ignore them.

Since I'm bored, I will comment on how that last bit of code could be simplified to

Code: Select all

$common = array ();
$lines = @file ($include_dir . '/common.txt');
if (is_array ($lines))
{
  array_walk($lines, "trim");
  $common = array_combine(array_values($lines), array_fill(0, count($lines), 1));
}
Though I bet it's not the 1 that's important but the fact that it's not false. Heck, its existence may be all that matters:

Code: Select all

$common = array_flip($lines);
Check your server logs as to why you get a 403 error. There was probably a change in configuration sometime somewhere: PHP tends to throw server errors, not access denied errors.

Re: need help with script!

Posted: Fri Jan 02, 2009 7:08 am
by tomsace
Thanks for your help.
tasairis wrote:Open up this "common.txt" file, and for each line (word?) in it, add an entry into the $common array.
My guess is that common.txt contains a bunch of words that are too common to search for (a, an, the, ...) and that later on $common will be used to filter out or ignore them.
Hey, I cannot find this common.txt. I have searched everywhere, It should be in the root directory by the look of the script but not to be found. Do you know what should be in this file? Just a list of common words? Could I add a ' to this file in order for it to be ignored as you said?

Thanks.