Trying to do my first Ajax call. Users can upload a file to my server. I want to add the feature of scanning for nudity and not accepting if nudity is found. I found a javascript scanner nude.js that will scan pics for nudity. I comes with demos and all. I am trying to apply it to my site.
<script type="text/javascript" src="nude.js">
function CheckNude() {
nude.load("pics/". <?
$q = "select max(id) from $table";
$result = mysql_query($q);
$resrow = mysql_fetch_row($result);
$id = $resrow[0] + 1;
$file = $_FILES['file'];
$file_name = $_FILES['file']['name'];
$picextorg = substr($file_name, -3);
$picext = strtolower($picextorg);
$picfile = "pics/" . $id . "." . $picext;
echo $picfile;
?>);
nude.scan(function (result) {
if (!result) {
nude = false;
} else {
nude = true;
}
});
nude.load( <? $_FILES['file']['tmp_name'] ?> );
nude.scan(function (result) {
if (!result) {
var nude = "false";
} else {
var nude = "true";
}
});
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
if (xmlhttp.responseText == true) {
alert("Nudity was found in your picture. Please try again.");
}
}
}
xmlhttp.open("GET", "new2.php?nude=" + nude, true);
xmlhttp.send();
}
</script>
<tr>
<td width="150">
<!--<INPUT type="image" name="search" src="../images/formbutton.gif" border="0" >-->
</td>
<td width="119"> </td>
<td width="147"> <button type='submit' name='submit' value='Submit' onclick="CheckNude()">
<img src='../images/formbutton.gif' width='40' height='40' /> <label>
Submit photo</label>
</td>
Here is the PHP:
$email = $_POST['email'];
$aim = $_POST['aim'];
$icq = $_POST['icq'];
$yahoo = $_POST['yahoo'];
$homepage = $_POST['homepage'];
$myip = $_POST['myip'];
if (!$myip)
$myip = $ip;
$email2 = $_POST['email2'];
$password = $_POST['password'];
$title = $_POST['title'];
$download = $_POST['download'];
$approved = $_POST['approved'];
$allowdelete = $_POST['allowdelete'];
$author = $_POST['author'];
$facebook = $_POST['facebook'];
$piclink = $_POST['piclink'];
$domain = $_POST['domain'];
$option3 = $_POST['option3'];
$secret = $_POST['secret'];
$q = "insert into $table values('', '$email', '$aim', '$icq', '$yahoo', '$homepage', '0', '0', '0', '0', '0', '0', '', now(),'$myip','$email2','$password','$title','$download','$approved','$allowdelete','$autho r','$facebook','$piclink','$domain','$option3','$secret')";
$result = mysql_query($q) or die("Failed: $sql - " . mysql_error());
$q = "select max(id) from $table";
$result = mysql_query($q);
$resrow = mysql_fetch_row($result);
$id = $resrow[0];
$file = $_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'], "pics/" . $id . "." . $picext);
$picfile = $id . "." . $picext;
$nude = $_REQUEST['nude'];
$alert = "false";
if ($nude === "false") {
$q = "update $table set picfile = '" . $id . "." . $picext . "' where id='$id'";
$result = mysql_query($q);
Header("Location: index.php?id=$id");
}
if ($nude === "true") {
$alert = "true";
$q = "delete from $table where id='$id'";
$result = mysql_query($q);
unlink("pics/" . $picfile);
Header("Location: new2.php");
}
echo $alert;
My page just loads to a blank white page with this code. What am I doing wrong?