Is there anything wrong with this script?
<?php
$username="";
$password="";
$database="";
$rom_name = $_POST['rom_name'];
$rom = $_FILES['rom']['name'];
function getExtension($str) {
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}
if (empty($rom)) {
$result = '<font color=FFFFFF>Please choose a ROM to upload</font>';
$error++;
}
else {
$filename = stripslashes($rom);
$extension = getextension($filename);
$extension = strtolower($extension);
if (($extension !== "zip") && ($extension !== "ZIP") && ($extension !== "rar") && ($extension !== "ZIP")) {
$result = '<font color=FFFFFF>Unknown file extension, please try again</font>';
$error++;
}
else {
$tmpFile = $_FILES['rom']['tmp_name'];
$sizekb = filesize($tmpFile);
if ($sizekb > 5000000) {
$result = '<font color=FFFFFF>The file has exceeded the size limit, please try again</font>';
$error++;
}
else {
$romName = '/gba_roms/files/' . time() . '.' . $extension;
$copy = copy($tmpFile, $romName);
$letter = ucfirst($rom_name);
if (!$copy) {
$result = '<font color=FFFFFF>File upload unsuccessful, please try again</font>';
$error++;
}
}
}
}
if ($error > 0) {
echo $result;
}
else {
$con = mysql_connect('localhost',$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$sql = "INSERT INTO `gba_roms` VALUES ('','$rom_name','$romName','$letter')";
$query = mysql_query($sql) or die('Error: ' . mysql_error());
}
mysql_close();
?>