/* code to Submit a new application */
// Check the input of a submitted form. And output with a list
// of errors. (
)
function checkInput( $fields )
{
$errors = "";
if ( strlen($fields['queueName']) > 200 )
{
$errors .= "Your application name is too long.\n";
}
if ( empty( $fields['queueName']) )
{
$errors .= "Please enter an application name.\n";
}
if ( empty( $fields['queueVersion']) )
{
$errors .= "Please enter an application version.\n";
}
// No vendor entered, and nothing in the list is selected
if ( empty( $fields['queueVendor']) and $fields['altvendor'] == '0' )
{
$errors .= "Please enter a vendor.\n";
}
if ( empty( $fields['queueDesc']) )
{
$errors .= "Please enter a description of your application.\n";
}
// Not empty and an invalid e-mail address
if ( !empty( $fields['queueEmail']) AND !preg_match('/^[A-Za-z0-9\._-]+[@][A-Za-z0-9_-]+([.][A-Za-z0-9_-]+)+[A-Za-z]$/',$fields['queueEmail']) )
{
$errors .= "Please enter a valid e-mail address.\n";
}
if ( empty($errors) )
{
return "";
}
else
{
return $errors;
}
}
include("path.php");
require(BASE."include/"."incl.php");
require(BASE."include/"."tableve.php");
global $current;
if ($_REQUEST['queueName'])
{
// Check input and exit if we found errors
$errors = checkInput($_REQUEST);
if( !empty($errors) )
{
errorpage("We found the following errors:","
Please go back and correct them.");
exit;
}
/* if the user picked the vendor we need to retrieve the vendor name */
/* and store it into the $queueVendor */
if($_REQUEST['altvendor'])
{
/* retrieve the actual name here */
$query = "select * from vendor where vendorId = '$altvendor';";
$result = mysql_query($query);
if($result)
{
$ob = mysql_fetch_object($result);
$_REQUEST['queueVendor'] = $ob->vendorName;
}
}
// header
apidb_header("Submit Application");
// add to queue
$query = "INSERT INTO appQueue VALUES (null, '".
addslashes($_REQUEST['queueName'])."', '".
addslashes($_REQUEST['queueVersion'])."', '".
addslashes($_REQUEST['queueVendor'])."', '".
addslashes($_REQUEST['queueDesc'])."', '".
addslashes($_REQUEST['queueEmail'])."', '".
addslashes($_REQUEST['queueURL'])."', '".
addslashes($_REQUEST['queueImage'])."');";
mysql_query($query);
if ($error = mysql_error())
{
echo "Error:
\n";
echo "$error
\n";
}
else
{
echo "Your application has been submitted for Review. You should hear back\n";
echo "soon about the status of your submission
\n";
}
}
else
{
// set email field if logged in
if ($current && loggedin())
{
$email = $current->lookup_email($current->userid);
}
// header
apidb_header("Submit Application");
// show add to queue form
echo '";
}
apidb_footer();
?>