bekommenteztem neked hogy mi mit csin?l.
<?php
// k?ld? IP c?m?nek leh?v?sa
if (getenv(HTTP_X_FORWARDED_FOR)) {
$ip = getenv(HTTP_X_FORWARDED_FOR);
} else {
$ip = getenv(REMOTE_ADDR);
// c?l e-mail megad?sa
$to = 'zaqrack@mail.datanet.hu';
//a v?ltoz?k leh?v?sa a form adataib?l
$fro = $_SESSION['username'];
$from = $_SESSION['username']." ".$ip;
$subject = $_POST['subject'];
$message = $_POST['message'];
$direct= $_POST['direct'];
$trans= $_POST['trans'];
$penalty=$_POST['penalty'];
}
// A csatolt replay el?h?v?sa tmp-b?l, nem kell piszk?lni
$fileatt = $_FILES['fileatt']['tmp_name'];
$fileatt_type = $_FILES['fileatt']['type'];
$fileatt_name = $_FILES['fileatt']['name'];
//email header be?ll?t?s, maradhat ?gy
$headers = "From:".$from;
//ez a sor neked nem kell ha nincs include.php -nekem ott csatlakozik az adatb?zishoz
include("include.php");
//newspost csatol?sa mint email sz?vege
$mess=$message;
//negat?v penalty sz?r?se :)
if ($penalty<0){
echo "Cheater! Don't even dare to try this!";
}
//felt?lt?tt file csatol?sa az emailhez
if (is_uploaded_file($fileatt)) {
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
//mindenf?le emailes header k?pz?se, hagyd ?gy eg?sz addig m?g azt nem ?rom hogy ?LLJ
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// Add the headers for a file attachment
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
// Add a multipart boundary above the plain message
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
// Base64 encode the file data
$data = chunk_split(base64_encode($data));
// Add file attachment to the message
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
}
// ?LLJ. K?sz a mail, a k?vetkez? 1 sor k?ldi el.
$ok = @mail($to, $subject, $message, $headers);
//ha elk?ldte, akkor csin?lja meg az al?bbiakat (pl. ki?rja hogy elk?ldte)
if ($ok) {
echo "<p>Replay was sent in mail!<br></p>";
}
//csatolt replay m?ret?nek leh?v?sa
$fupload_size=filesize($fileatt);
//k?ld?si ?ra-perc-id? leh?v?sa
$date=date("H:i:s");
//adjunk n?mi infot a k?perny?re a k?ld?nek hogy mit csin?lt
print "<table border=0><tr><td><b>Your name:</b></td><td>$fro</td></tr><tr><td><b>Current time:</td><td></b> $date</td></tr>";
print "<tr><td><b>Filesize:</b></td><td>";
print $fupload_size;
print " bytes</td></tr><tr><td><b>Your Result: </b></td><td><i>";
//ez a r?sz sz?m?t filem?retb?l replay id?t. Ki is ?rja
$timeraw=$fupload_size-1848;
$timeraw=$timeraw+$penalty*20;
echo floor($timeraw/1200);
$min=floor($timeraw/1200);
$timeraw=$timeraw-(floor($timeraw/1200)*1200);
echo ":";
if (floor($timeraw/20)<10){
echo "0";
}
echo floor($timeraw/20);
$sec=floor($timeraw/20);
$timeraw=$timeraw-(floor($timeraw/20)*20);
echo ".";
if (($timeraw*5)<10){
echo "0";
}
echo $timeraw*5;
$msec=$timeraw*5;
echo "</b></i></td></tr></table><br>";
//m?g adjunk neki inf?kat j?l
$suba="ZCT$atrack RPL";
$subb="ZCT$atrack NoRH";
echo $subject;
$date=date("Ymd");
$time=date("Hi");
//a k?vetkez? r?sz teszi be az SQL adatb?zisba az IP adatokat
$result2 = mysql_query("INSERT INTO ghost (name, ip, date) VALUES ('$fro','$ip','$date')")
or die("Can't write into SQL database!".mysql_error());
//a k?vetkez? pedig a scoreboard adatb?zis?ba k?ldi az id?t
if (($direct==yes) && ($subject==$suba)){
$track=C.$atrack;
$result2 = mysql_query("INSERT INTO 2006times (name, track, min, sec, msec, trm, date, time) VALUES ('$fro','$track','$min','$sec','$msec','$trans','$date','$time')")
or die("Can't write into SQL database!".mysql_error());
//ha siker?lt akkor j?
echo "<br>Result was submitted to scoreboard succesfully!";
//ha ?rt be sz?veget
if ($mess!=NULL){
//akkor azt meg a news adatb?zisba k?ldi be
$time=date("His");
$result2 = mysql_query("INSERT INTO news (date, poster, news, time) VALUES ('$date','$fro','$mess','$time')")
or die("Can't write into SQL database!".mysql_error());
echo "<br>Message was posted as news!";
}
}
//ugyanaz csak NoRH adatb?zissal
elseif ($subject==$subb){
$track=C.$atrack;
$date=date("Ymd");
$time=date("Hi");
$result2 = mysql_query("INSERT INTO 2006norh (name, track, min, sec, msec, trm, date, time) VALUES ('$fro','$track','$min','$sec','$msec','$trans','$date','$time')")
or die("Can't write into SQL database!".mysql_error());
echo "<br>Result was submitted to scoreboard succesfully!";
if ($mess!=NULL){
$time=date("His");
$result2 = mysql_query("INSERT INTO news (date, poster, news, time) VALUES ('$date','$fro','$mess','$time')")
or die("Can't write into SQL database!".mysql_error());
echo "<br>Message was posted as news!";
}
}
else {
echo "You didn't choose direct submitting to the scoreboard, or selected permanent competition";
}
}
//ha meg valami g?z volt akkor ezt kapja:
else {
echo "<p>Mail could not be sent. Sorry! Contact Administrator!</p>";
}