[appDB] appsubmit no annonymous application sumitions
Jonathan Ernst
Jonathan at ErnstFamily.ch
Fri Dec 10 05:10:55 CST 2004
Sorry for the length of this small patch, I cleaned up the code because
it was not easily readable.
Change Log:
- stop annoymous applications submitions
- code cleanup (more php style than c style + correct indentation +
comments + replaced globally registered vars)
Files changed:
- appsubmit.php
-------------- next part --------------
Index: appsubmit.php
===================================================================
RCS file: /home/wine/appdb/appsubmit.php,v
retrieving revision 1.8
diff -u -r1.8 appsubmit.php
--- appsubmit.php 6 Dec 2004 23:12:23 -0000 1.8
+++ appsubmit.php 10 Dec 2004 11:04:15 -0000
@@ -1,63 +1,65 @@
<?
-
+/************************************/
/* code to Submit a new application */
+/************************************/
-// Check the input of a submitted form. And output with a list
-// of errors. (<ul></ul>)
-function checkInput( $fields )
-{
- $errors = "";
-
- if ( strlen($fields['queueName']) > 200 )
- {
- $errors .= "<li>Your application name is too long.</li>\n";
- }
-
- if ( empty( $fields['queueName']) )
- {
- $errors .= "<li>Please enter an application name.</li>\n";
- }
-
- if ( empty( $fields['queueVersion']) )
- {
- $errors .= "<li>Please enter an application version.</li>\n";
- }
-
- // No vendor entered, and nothing in the list is selected
- if ( empty( $fields['queueVendor']) and $fields['altvendor'] == '0' )
- {
- $errors .= "<li>Please enter a vendor.</li>\n";
- }
+# ENVIRONMENT AND HEADER
+include("path.php");
+require(BASE."include/"."incl.php");
+require(BASE."include/"."tableve.php");
- if ( empty( $fields['queueDesc']) )
- {
- $errors .= "<li>Please enter a description of your application.</li>\n";
- }
+// Send user to the correct branch of code even if they try to bypass
+// the first page (appsubmit.php without parameters)
+if(!loggedin()) {
+ unset($_REQUEST['queueName']);
+ unset($_REQUEST['apptype']);
+}
- // 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 .= "<li>Please enter a valid e-mail address.</li>\n";
- }
+// Check the input of a submitted form. And output with a list
+// of errors. (<ul></ul>)
+function checkInput($fields) {
+ $errors = "";
- if ( empty($errors) )
- {
- return "";
- }
- else
- {
- return $errors;
- }
+ if (strlen($fields['queueName']) > 200 ) {
+ $errors .= "<li>Your application name is too long.</li>\n";
+ }
+
+ if (empty( $fields['queueName'])) {
+ $errors .= "<li>Please enter an application name.</li>\n";
+ }
+
+ if (empty( $fields['queueVersion'])) {
+ $errors .= "<li>Please enter an application version.</li>\n";
+ }
+
+ // No vendor entered, and nothing in the list is selected
+ if (empty( $fields['queueVendor']) and $fields['altvendor'] == '0') {
+ $errors .= "<li>Please enter a vendor.</li>\n";
+ }
+
+ if (empty( $fields['queueDesc'])) {
+ $errors .= "<li>Please enter a description of your application.</li>\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 .= "<li>Please enter a valid e-mail address.</li>\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'])
+#################################
+# USER SUBMITTED APP OR VERSION #
+#################################
+if (isset($_REQUEST['queueName']))
{
// Check input and exit if we found errors
$errors = checkInput($_REQUEST);
@@ -110,21 +112,21 @@
echo "soon about the status of your submission</p>\n";
}
}
-else if ($_REQUEST['apptype'])
-{
- // set email field if logged in
- if ($current && loggedin())
- {
- $email = $current->lookup_email($current->userid);
- }
- // header
- apidb_header("Submit Application");
+#######################################
+# USER WANTS TO SUBMIT APP OR VERSION #
+#######################################
+else if (isset($_REQUEST['apptype'])) {
+ // set email field if logged in
+ if (loggedin()) {
+ $email = $_SESSION[current]->lookup_email($_SESSION[current]->userid);
+ }
- // show add to queue form
-
- echo '<form name="newApp" action="appsubmit.php" method="post" enctype="multipart/form-data">',"\n";
+ // header
+ apidb_header("Submit Application");
+ // show add to queue form
+ echo '<form name="newApp" action="appsubmit.php" method="post" enctype="multipart/form-data">',"\n";
echo "<p>This page is for submitting new applications to be added to this\n";
echo "database. The application will be reviewed by the AppDB Administrator\n";
echo "and you will be notified via email if this application will be added to\n";
@@ -136,108 +138,110 @@
echo "<p>To submit screenshots, please email them to ";
echo "<a href='mailto:appdb at winehq.org'>appdb at winehq.org</a></p>\n";
- if ($apptype == 1)
- {
- echo html_frame_start("New Application Form",400,"",0);
- echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
-
- echo '<tr valign=top><td class=color0><b>App Name</b></td>',"\n";
- echo '<td><input type=text name="queueName" value="" size=20></td></tr>',"\n";
-
-
- echo '<tr valign=top><td class=color0><b>App Version</b></td>',"\n";
- echo '<td><input type=text name="queueVersion" value="" size=20></td></tr>',"\n";
-
- // app Category
- $w = new TableVE("view");
- echo '<tr valign=top><td class=color0><b>Category</b></td><td>',"\n";
- $w->make_option_list("queueCatId","","appCategory","catId","catName");
- echo '</td></tr>',"\n";
-
-
- echo '<tr valign=top><td class=color0><b>App Vendor</b></td>',"\n";
- echo '<td><input type=text name="queueVendor" value="" size=20></td></tr>',"\n";
-
-
- //alt vendor
- $x = new TableVE("view");
- echo '<tr valign=top><td class=color0> </td><td>',"\n";
- $x->make_option_list("altvendor","","vendor","vendorId","vendorName");
- echo '</td></tr>',"\n";
-
- echo '<tr valign=top><td class=color0><b>App URL</b></td>',"\n";
- echo '<td><input type=text name="queueURL" value="" size=20></td></tr>',"\n";
-
- echo '<tr valign=top><td class=color0><b>App Desc</b></td>',"\n";
- echo '<td><textarea name="queueDesc" rows=10 cols=35></textarea></td></tr>',"\n";
-
- echo '<tr valign=top><td class=color0><b>Email</b></td>',"\n";
- echo '<td><input type=text name="queueEmail" value="'.$email.'" size=20></td></tr>',"\n";
+ # NEW APPLICATION
+ if ($_REQUEST[apptype] == 1) {
+ echo html_frame_start("New Application Form",400,"",0);
+ echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
+ echo '<tr valign=top><td class=color0><b>App Name</b></td>',"\n";
+ echo '<td><input type=text name="queueName" value="" size=20></td></tr>',"\n";
+ echo '<tr valign=top><td class=color0><b>App Version</b></td>',"\n";
+ echo '<td><input type=text name="queueVersion" value="" size=20></td></tr>',"\n";
+
+ // app Category
+ $w = new TableVE("view");
+ echo '<tr valign=top><td class=color0><b>Category</b></td><td>',"\n";
+ $w->make_option_list("queueCatId","","appCategory","catId","catName");
+ echo '</td></tr>',"\n";
+
+ echo '<tr valign=top><td class=color0><b>App Vendor</b></td>',"\n";
+ echo '<td><input type=text name="queueVendor" value="" size=20></td></tr>',"\n";
+
+ // alt vendor
+ $x = new TableVE("view");
+ echo '<tr valign=top><td class=color0> </td><td>',"\n";
+ $x->make_option_list("altvendor","","vendor","vendorId","vendorName");
+ echo '</td></tr>',"\n";
+
+ echo '<tr valign=top><td class=color0><b>App URL</b></td>',"\n";
+ echo '<td><input type=text name="queueURL" value="" size=20></td></tr>',"\n";
+
+ echo '<tr valign=top><td class=color0><b>App Desc</b></td>',"\n";
+ echo '<td><textarea name="queueDesc" rows=10 cols=35></textarea></td></tr>',"\n";
- echo '<tr valign=top><td class=color3 align=center colspan=2>',"\n";
- echo '<input type=submit value=" Submit New Application " class=button> </td></tr>',"\n";
- echo '</table>',"\n";
+ echo '<tr valign=top><td class=color0><b>Email</b></td>',"\n";
+ echo '<td><input type=text name="queueEmail" value="'.$email.'" size=20></td></tr>',"\n";
- echo html_frame_end();
+ echo '<tr valign=top><td class=color3 align=center colspan=2>',"\n";
+ echo '<input type=submit value=" Submit New Application " class=button> </td></tr>',"\n";
+
+
+ echo '</table>',"\n";
- echo "</form>";
- }
- else
- {
- echo html_frame_start("New Version Form",400,"",0);
+ echo html_frame_end();
- echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
+ echo "</form>";
+ }
+
+ # NEW VERSION
+ else {
+ echo html_frame_start("New Version Form",400,"",0);
- //app parent
- $x = new TableVE("view");
- echo '<tr valign=top><td class=color0><b>App Parent</b></td><td>',"\n";
- $x->make_option_list("queueName",stripslashes($appId),"appFamily","appId","appName");
- echo '</td></tr>',"\n";
+ echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
- echo '<tr valign=top><td class=color0><b>App Version</b></td>',"\n";
- echo '<td><input type=text name="queueVersion" size=20 value="'.$queueVersion.'"></td></tr>',"\n";
+ // app parent
+ $x = new TableVE("view");
+ echo '<tr valign=top><td class=color0><b>App Parent</b></td><td>',"\n";
+ $x->make_option_list("queueName",stripslashes($appId),"appFamily","appId","appName");
+ echo '</td></tr>',"\n";
- echo '<tr valign=top><td class=color0><b>App URL</b></td>',"\n";
- echo '<td><input type=text name="queueURL" size=20 value="'.$queueURL.'"></td></tr>',"\n";
+ echo '<tr valign=top><td class=color0><b>App Version</b></td>',"\n";
+ echo '<td><input type=text name="queueVersion" size=20 value="'.$queueVersion.'"></td></tr>',"\n";
- echo '<tr valign=top><td class=color0><b>App Desc</b></td>',"\n";
- echo '<td><textarea name="queueDesc" rows=10 cols=35 value="'.$queueDesc.'"></textarea></td></tr>',"\n";
+ echo '<tr valign=top><td class=color0><b>App URL</b></td>',"\n";
+ echo '<td><input type=text name="queueURL" size=20 value="'.$queueURL.'"></td></tr>',"\n";
- echo '<tr valign=top><td class=color0><b>Email</b></td>',"\n";
- echo '<td><input type=text name="queueEmail" value="'.$email.'" size=20></td></tr>',"\n";
+ echo '<tr valign=top><td class=color0><b>App Desc</b></td>',"\n";
+ echo '<td><textarea name="queueDesc" rows=10 cols=35 value="'.$queueDesc.'"></textarea></td></tr>',"\n";
- echo '<input type=hidden name="queueVendor" value="">',"\n";
- echo '<input type=hidden name="queueCatId" value=-1>',"\n";
+ echo '<tr valign=top><td class=color0><b>Email</b></td>',"\n";
+ echo '<td><input type=text name="queueEmail" value="'.$email.'" size=20></td></tr>',"\n";
+ echo '<input type=hidden name="queueVendor" value="">',"\n";
+ echo '<input type=hidden name="queueCatId" value=-1>',"\n";
- echo '<tr valign=top><td class=color3 align=center colspan=2>',"\n";
- echo '<input type=submit value=" Submit New Version" class=button> </td></tr>',"\n";
- echo '</table>',"\n";
+ echo '<tr valign=top><td class=color3 align=center colspan=2>',"\n";
+ echo '<input type=submit value=" Submit New Version" class=button> </td></tr>',"\n";
+
+ echo '</table>',"\n";
- echo html_frame_end();
+ echo html_frame_end();
- echo "</form>";
- }
+ echo "</form>";
+ }
}
-else
-{
- // choose type of app
- apidb_header("Choose Application Type");
-
- echo '<form name="ChooseApp" >',"\n";
- echo "Please search through the database first. If you cannot find your application in the database select ","\n";
- echo "<b>New Application</b>.","\n";
- echo "If you have found your application but have not found your version then choose <b>New Version</b>.","\n";
- echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
- echo "<tr valign=top><td class=color0 align=center><a href='appsubmit.php?apptype=1'>New Application</a></td>","\n";
- echo "<td class=color0 align=center><a href='appsubmit.php?apptype=2'>New Version</a></td></tr>","\n";
- echo '</table>',"\n";
-
- echo "</form>";
+##########################
+# HOME PAGE OF APPSUBMIT #
+##########################
+else {
+ if(!loggedin()) {
+ // you must be logged in to submit app
+ apidb_header("Please login");
+ echo "To submit an application to the database you must be logged in. Please <a href=\"account.php?cmd=login\">login now</a> or create a <a href=\"account.php?cmd=new\">new account</a>.","\n";
+ }
+ else {
+ // choose type of app
+ apidb_header("Choose Application Type");
+ echo "Please search through the database first. If you cannot find your application in the database select ","\n";
+ echo "<b>New Application</b>.","\n";
+ echo "If you have found your application but have not found your version then choose <b>New Version</b>.","\n";
+ echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
+ echo "<tr valign=top><td class=color0 align=center><a href='appsubmit.php?apptype=1'>New Application</a></td>","\n";
+ echo "<td class=color0 align=center><a href='appsubmit.php?apptype=2'>New Version</a></td></tr>","\n";
+ echo '</table>',"\n";
+ }
}
apidb_footer();
-
-?>
+?>
\ No newline at end of file
More information about the wine-patches
mailing list