$error) { $uploaddir = 'E:\\xampp\\htdocs\\mmsServer\\upload\\'; $uploadfile = $uploaddir . basename($_FILES['MMSFile']['name'][$key]); $stringData .= " ** ".$_FILES['MMSFile']['tmp_name'][$key] . " => ".$uploadfile." ** \n"; if (move_uploaded_file($_FILES['MMSFile']['tmp_name'][$key], $uploadfile)) { $stringData .= "File is valid, and was successfully uploaded.\n"; //$stringData .= " -- ".preg_match('/jpg/',$uploadfile)." -- ".preg_match('/jpeg/',$uploadfile)." -- ".$uploadfile." -- "; if(preg_match('/jpg/',$uploadfile) || preg_match('/jpeg/',$uploadfile)){ $imgFile = $uploadfile; $stringData .= "using file: ".$imgFile . " | "; } } else { $stringData .= "Possible file upload attack!\n"; } } fwrite($fh, $stringData); if($imgFile != ""){ $fromNumber = $_REQUEST['MMSFrom']; $str = getPongrResponse($imgFile,$fromNumber); if(preg_match('/did not match anything/i',$str)) $str = "Congratulations! We didn't recognize your photo, but you've been entered for a chance to win a new Apple iPhone 4!"; get_web_page( "http://localhost:8800/Send%20Text%20Message.htm?PhoneNumber=$fromNumber&Text=".urlencode($str)."&InfoCharCounter=&PID=&DCS=&DestPort=&DelayUntil=&Submit=Submit",$fromNumber); $stringData = "http://localhost:8800/Send%20Text%20Message.htm?PhoneNumber=$fromNumber&Text=".urlencode($str)."&InfoCharCounter=&PID=&DCS=&DestPort=&DelayUntil=&Submit=Submit"; } fwrite($fh, $stringData); /*$returnHttp500OnError = True; $errorFlag = False; $dateString = date("YmdHis"); $savedImageFile = False; if (!isset($_REQUEST['MMSFrom']) || !$_REQUEST['MMSFrom']) { echo "ERROR: MMSFrom variable (sender) is not set"; $stringData .= "ERROR: MMSFrom variable (sender) is not set"; $errorFlag = True; } if (!isset($_REQUEST['MMSSubject']) || !$_REQUEST['MMSSubject']) { $MMSSubject = "Multimedia Message"; } else { $MMSSubject = $_REQUEST['MMSSubject']; } if (!$errorFlag) { $errorFlag = True; if ($_FILES["MMSFile"] && is_array($_FILES["MMSFile"]) && count($_FILES["MMSFile"])) { foreach ($_FILES["MMSFile"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $errorFlag = False; } } } if ($errorFlag) { echo "ERROR: Request does not include any uploaded files!"; $stringData .= "ERROR: Request does not include any uploaded files!"; } } if (!$errorFlag) { $user_path = $upload_path . $_REQUEST['MMSFrom']; if (!@file_exists ($user_path)) { @mkdir ($user_path); } $user_path = $user_path . "\\"; $tmp_filename = $user_path . "temp.tmp"; $tmp_handle = @fopen ($tmp_filename, "w+"); if (!$tmp_handle) { if ($returnHttp500OnError) header("HTTP/1.0 500 Internal Error"); echo "ERROR: Cannot create files in upload directory " . $user_path; $stringData .= "ERROR: Cannot create files in upload directory " . $user_path; $errorFlag = True; } else { fclose ($tmp_handle); @unlink ($tmp_filename); } } if (!$errorFlag) { $image_path = $user_path . $dateString; if (!@file_exists ($image_path)) { @mkdir ($image_path); } $image_path = $image_path . "\\"; $tmp_filename = $image_path . "temp.tmp"; $tmp_handle = @fopen ($tmp_filename, "w+"); if (!$tmp_handle) { if ($returnHttp500OnError) header("HTTP/1.0 500 Internal Error"); echo "ERROR: Cannot create files in upload directory " . $image_path; $stringData .= "ERROR: Cannot create files in upload directory " . $image_path; $errorFlag = True; } else { fclose ($tmp_handle); @unlink ($tmp_filename); } } if (!$errorFlag) { $msglogTxt = $user_path . "msglog.txt"; $msglogTmp = $user_path . "msglog.tmp"; if (@file_exists ($msglogTmp)) { @unlink ($msglogTmp); } if (@file_exists ($msglogTxt)) { if (!@copy ($msglogTxt, $msglogTmp)) { if ($returnHttp500OnError) header("HTTP/1.0 500 Internal Error"); echo "ERROR: Cannot create temporary file in upload directory " . $user_path; $stringData .= "ERROR: Cannot create temporary file in upload directory " . $user_path; $errorFlag = True; } } if (!$errorFlag) { $msglogTxt_handle = @fopen ($msglogTxt, "w+"); if (!$msglogTxt_handle) { if ($returnHttp500OnError) header("HTTP/1.0 500 Internal Error"); echo "ERROR: Cannot create temporary file in upload directory " . $user_path; $stringData .= "ERROR: Cannot create temporary file in upload directory " . $user_path; $errorFlag = True; } } if (!$errorFlag) { fwrite ($msglogTxt_handle, "\r\n"); fwrite ($msglogTxt_handle, "
" . date("F j, Y, H:i") . "
\r\n"); foreach ($_FILES["MMSFile"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["MMSFile"]["tmp_name"][$key]; if (!strcmp (strtolower($_FILES["MMSFile"]["type"][$key]), "text/plain")) { fwrite ($msglogTxt_handle, "" . file_get_contents ($tmp_name) . "
\r\n"); echo "The file ". basename( $_FILES["MMSFile"]["name"][$key]). " has been uploadedVideo attachment: " . basename($_FILES["MMSFile"]["name"][$key]) . "
\r\n"); } else { fwrite ($msglogTxt_handle, "File attachment: " . basename($_FILES["MMSFile"]["name"][$key]) . "
\r\n"); } } else { echo "Error uploading file ". basename( $_FILES["MMSFile"]["name"][$key]) . "