Second file
load_functions.php
<?php
/*********************************************************
This Free Script was downloaded at
Free-php-Scripts.net
This script is produced under the GPL license
You can do or modify this script as you like.
Note 1: Administrator copyright notice CAN NOT be removed
Note 2: User front Powered by Notices can be removed ONLY
if you change the site design/look so it won't reflect
www.myimage.us looks
*********************************************************/
//Function for ads (whcih
//Appears under download link and while uploading a file
function get_add(){
//Ads list Format: URL - TITLE - URL = WIDTH - HEIGHT
$add_array[] = array('http://www.GoldLand.us','Gold Land USA','http://www.myimage.us/images/gold_land.gif','170','113');
$add_array[] = array('http://www.FunTimes.us','Free Flash MSX Atari Games and Emulators','http://www.myimage.us/images/flash_games.gif','170','113');
$add_array[] = array('http://www.allfreetemplates.us','Free HTML Flash and Auction Templates','http://www.myimage.us/images/free_templates.gif','170','113');
$add_array[] = array('http://www.MyImage.us','Free Image Hosting','http://www.myimage.us/images/free_image_hosting.gif','170','113');
$add_array[] = array('http://www.GoldLand.us','Gold Land USA','http://www.myimage.us/images/gold_land.gif','170','113');
srand ((double) microtime()*1000000);
$random = rand(0,count($add_array)-1);
return $add_array[$random];
}
//Check File Extension
function check_extensions($extension,$isflash){
if($isflash == 1){
$allowed_array = array('gif','jpg','jpeg','bmp','png','swf');
} else {
$allowed_array = array('gif','jpg','jpeg','bmp','png');
}
return in_array($extension,$allowed_array);
}
//Function to report error
function do_error($error,$is_fatal){
mail($SITE_ADMIN,'Error @'.$SITE_TITLE,$error,$headers);
if($is_fatal == 2){
die('An error has occured, a message has been dispatched to site administrator.');
}
return;
}
//Function to encrypt
function encode_password($data,$keyfile) { //ecncrypt $data with the key in $keyfile with an rc4 algorithm
$pwd = $keyfile;
$pwd_length = strlen($pwd);
for ($i = 0; $i < 255; $i++) {
$key[$i] = ord(substr($pwd, ($i % $pwd_length)+1, 1));
$counter[$i] = $i;
}
for ($i = 0; $i < 255; $i++) {
$x = ($x + $counter[$i] + $key[$i]) % 256;
$temp_swap = $counter[$i];
$counter[$i] = $counter[$x];
$counter[$x] = $temp_swap;
}
for ($i = 0; $i < strlen($data); $i++) {
$a = ($a + 1) % 256;
$j = ($j + $counter[$a]) % 256;
$temp = $counter[$a];
$counter[$a] = $counter[$j];
$counter[$j] = $temp;
$k = $counter[(($counter[$a] + $counter[$j]) % 256)];
$Zcipher = ord(substr($data, $i, 1)) ^ $k;
$Zcrypt .= chr($Zcipher);
}
return $Zcrypt;
}
//Hex to binary
function hex2bin($hexdata) {
for ($i=0;$i<strlen($hexdata);$i+=2) {
$bindata.=chr(hexdec(substr($hexdata,$i,2)));
}
return $bindata;
}
//Function to generate a new random number
function generate_session($strlen){
return substr(md5(uniqid(rand(),1)),1,$strlen);
}
//function to get user_ip
function get_ip(){
$ipParts = explode(".", $_SERVER['REMOTE_ADDR']);
if ($ipParts[0] == "165" && $ipParts[1] == "21") {
if (getenv("HTTP_CLIENT_IP")) {
$ip = getenv("HTTP_CLIENT_IP");
} elseif (getenv("HTTP_X_FORWARDED_FOR")) {
$ip = getenv("HTTP_X_FORWARDED_FOR");
} elseif (getenv("REMOTE_ADDR")) {
$ip = getenv("REMOTE_ADDR");
}
} else {
return $_SERVER['REMOTE_ADDR'];
}
return $ip;
}
//Function to check for valid email
function is_valid_email($string) {
return preg_match('/^[.\w-]+@([\w-]+\.)+[a-zA-Z]{2,6}$/', $string);
}
//Find the difference in seconds
function find_difference($end_date){
list($date,$time) = explode(' ',$end_date);
$startdate = explode("-",$date);
$starttime = explode(":",$time);
list($date,$time) = explode(' ',date("Y-m-d G:i:s"));
$enddate = explode("-",$date);
$endtime = explode(":",$time);
$secons_dif = mktime($endtime[0],$endtime[1],$endtime[2],$enddate[1],$enddate[2],$enddate[0]) - mktime($starttime[0],$starttime[1],$starttime[2],$startdate[1],$startdate[2],$startdate[0]);
$difference = floor($secons_dif/60);
return $difference;
}
//Function to check for url filesize
function check_url_size($url){
$head = "";
$url_p = parse_url($url);
$host = $url_p["host"];
$path = $url_p["path"];
$fp = @fsockopen($host, 80, $errno, $errstr, 20);
if(!$fp)
{ return false; }
else
{
@fputs($fp, "HEAD ".$url." HTTP/1.1\r\n");
@fputs($fp, "HOST: dummy\r\n");
@fputs($fp, "Connection: close\r\n\r\n");
$headers = "";
while (!@feof($fp)) {
$headers .= @fgets ($fp, 128);
}
}
@fclose ($fp);
$return = false;
$arr_headers = explode("\n", $headers);
foreach($arr_headers as $header) {
$s = "Content-Length: ";
if(substr(strtolower ($header), 0, strlen($s)) == strtolower($s)) {
$return = trim(substr($header, strlen($s)));
break;
}
}
return $return;
}
//Function to download file
function download_image($url,$file_name,$dir){
$url_stuff = @parse_url($url);
$port = isset($url_stuff['port']) ? $url_stuff['port'] : 80;
$fp = fsockopen($url_stuff['host'], $port);
if(!$fp){ return false;}
$query = 'GET ' . $url_stuff['path'] . " HTTP/1.0\n";
$query .= 'Host: ' . $url_stuff['host'];
$query .= "\n\n";
@fwrite($fp, $query);
while ($tmp = fread($fp, 8192)) {
$buffer .= $tmp;
}
preg_match('/Content-Length: ([0-9]+)/', $buffer, $parts);
$image_binary = substr($buffer, - $parts[1]);
$file_open = @fopen($dir . "/" . $file_name,'w');
if(!$file_open){ return false;}
@fwrite($file_open,$image_binary);
@fclose($file_open);
return true;
}
//Function to generate thumbnail
function make_thumb($filename,$filename_is,$max_width,$max_height,$upload_dir,$thumb_dir){
$thumb_dir = $thumb_dir;
$comp_name = $upload_dir.$filename;
if( !file_exists( $thumb_dir ."$filename" ))
{
if ( strstr ( $filename_is, '.gif' ) )
{
$im = imagecreatefromgif( $path . $comp_name);
}
elseif ( preg_match( '/(.jpg|.jpeg)/i', $filename_is ))
{
$im = imagecreatefromjpeg( $path . $comp_name);
}
elseif ( preg_match( '/.png/i', $filename_is ))
{
$im = imagecreatefrompng( $path . $comp_name);
}
if(!$im){ return false;}
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0,0,0);
$y = 50 * imagesy($im) / 100;
$widths = imagesx($im);
$heights = imagesy($im);
if ( $widths > $max_width )
{
$img_width = $max_width;
$img_height = ceil( ( $heights * ( ( $max_width * 100 ) / $widths ) ) / 100 );
$heights = $img_height;
$widths = $img_width;
}
else
{
$img_height = $heights;
}
if ( $heights > $max_height )
{
$img_height = $max_height;
$img_width = ceil( ( $widths * ( ( $max_height * 100 ) / $heights ) ) / 100 );
}
else
{
$img_width = $widths;
}
$newwidth = $img_width;
$newheight = $img_height;
$sourcedata = getimagesize ( $path . $comp_name );
$image = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($image,$im,0,0,0,0,$newwidth,$newheight,$sourcedata[0],$sourcedata[1]);
$a = imagejpeg($image, $thumb_dir ."$filename");
if(!$a){ return false;}
}
return true;
}
?>
Solve my problem if you can.