View file includes/utils.php

File size: 944B
<?php

// decoding all array strings from UTF-8 to WIN
function decode_array($data)
{
/*
   foreach($data as $key => $value)
      //$data[$key] = iconv("UTF-8", "WINDOWS-1251", $value);
      //$data[$key] = mb_convert_encoding($value, "WINDOWS-1251","UTF-8");
*/
   return $data;
}

// generates random key for password with length $count
function generatekey($count)
{
 srand((double)microtime()*1000000);
 $key = "";
 for ($i=0; $i<$count; $i++)
 {
   $c = rand(0,2);
   if ($c==0)
   {
     $key .= chr(rand(65,90));
   }
   elseif ($c==1)
   {
    $key .= chr(rand(97,122));
   }
   else
   {
     $key .= rand(0,9);
   }
 }
 return $key;
}

function get_random_link()
{
   $links = mysql_query('select name, url from advertising_links ORDER by RAND() LIMIT 1');
   $link = mysql_fetch_array($links, MYSQL_ASSOC);
   return '<a href="' . $link['url'] . '">' . $link['name'] . "</a><br/>\n";
}
?>