Initial revision

This commit is contained in:
Jeremy Newman
2004-03-15 16:22:00 +00:00
commit 8f28ae10c4
122 changed files with 8116 additions and 0 deletions

2
admin/.cvsignore Normal file
View File

@@ -0,0 +1,2 @@
stderr

37
admin/addAppFamily.php Normal file
View File

@@ -0,0 +1,37 @@
<?
include("path.php");
include(BASE."include/"."incl.php");
include(BASE."include/"."tableve.php");
include(BASE."include/"."qclass.php");
//check for admin privs
if(!loggedin() || (!havepriv("admin")) )
{
errorpage("Insufficient Privileges!");
exit;
}
apidb_header("Add Application Family");
$t = new TableVE("create");
if($HTTP_POST_VARS)
{
$t->update($HTTP_POST_VARS);
}
else
{
$table = "appFamily";
$query = "INSERT INTO $table VALUES(0, 'NONAME', 0, null, null, null, $catId)";
mysql_query("DELETE FROM $table WHERE appName = 'NONAME'");
if(debugging()) { echo "<p align=center><b>query:</b> $query </p>"; }
$t->create($query, $table, "appId");
}
apidb_footer();
?>

51
admin/addAppNote.php Normal file
View File

@@ -0,0 +1,51 @@
<?
/*
* Add Application Note
*
*/
include("path.php");
include(BASE."include/"."incl.php");
include(BASE."include/"."tableve.php");
include(BASE."include/"."qclass.php");
global $apidb_root;
//check for admin privs
if(!loggedin() || (!havepriv("admin") && !$current->ownsApp($appId)) )
{
errorpage("Insufficient Privileges!");
exit;
}
apidb_header("Add Application Note");
$t = new TableVE("create");
if($HTTP_POST_VARS)
{
$t->update($HTTP_POST_VARS);
}
else
{
$table = "appNotes";
if (!$versionId) { $versionId = 0; }
//delete old NONAMES
mysql_query("DELETE FROM $table WHERE noteTitle = 'NONAME'");
//show edit form
$query = "INSERT INTO $table VALUES(0, 'NONAME', '', $appId, $versionId)";
if(debugging()) { echo "<p align=center><b>query:</b> $query </p>"; }
$t->create($query, $table, "noteId");
echo html_back_link(1,$apidb_root."appview.php?appId=$appId&versionId=$versionId");
}
apidb_footer();
?>

48
admin/addAppVersion.php Normal file
View File

@@ -0,0 +1,48 @@
<?
include("path.php");
include(BASE."include/"."incl.php");
include(BASE."include/"."tableve.php");
include(BASE."include/"."qclass.php");
//FIXME: need to check for admin privs
if(!loggedin())
{
errorpage();
exit;
}
else
{
global $admin_mode;
$admin_mode = 1;
}
apidb_header("Add Application Version");
$t = new TableVE("create");
if(!$appId)
$appId = 0;
if($HTTP_POST_VARS)
{
$t->update($HTTP_POST_VARS);
}
else
{
$table = "appVersion";
$query = "INSERT INTO $table VALUES(0, $appId, 'NONAME', null, null, null, 0.0, 0.0)";
mysql_query("DELETE FROM $table WHERE versionName = 'NONAME'");
if(debugging())
echo "$query <br><br>\n";
$t->create($query, $table, "versionId");
}
echo html_back_link(1,$apidb_root."appview.php?appId=$appId");
apidb_footer();
?>

42
admin/addCategory.php Normal file
View File

@@ -0,0 +1,42 @@
<?
include("path.php");
include(BASE."include/"."incl.php");
include(BASE."include/"."tableve.php");
include(BASE."include/"."qclass.php");
if(!loggedin() || !havepriv("admin"))
{
errorpage();
exit;
}
else
{
global $admin_mode;
$admin_mode = 1;
}
apidb_header("Add Application Category");
$t = new TableVE("create");
if($HTTP_POST_VARS)
{
$t->update($HTTP_POST_VARS);
}
else
{
$table = "appCategory";
$query = "INSERT INTO $table VALUES(0, 'NONAME', null, 0)";
mysql_query("DELETE FROM $table WHERE catName = 'NONAME'");
if(debugging())
echo "$query <br><br>\n";
$t->create($query, $table, "catId");
}
apidb_footer();
?>

44
admin/addVendor.php Normal file
View File

@@ -0,0 +1,44 @@
<?
include("path.php");
include(BASE."include/"."incl.php");
include(BASE."include/"."tableve.php");
include(BASE."include/"."qclass.php");
if(!loggedin() || !havepriv("admin"))
{
errorpage();
exit;
}
else
{
global $admin_mode;
$admin_mode = 1;
}
apidb_header("Add Vendor");
$t = new TableVE("create");
if($HTTP_POST_VARS)
{
$t->update($HTTP_POST_VARS);
}
else
{
$table = "vendor";
$query = "INSERT INTO $table VALUES(0, 'NONAME', null)";
mysql_query("DELETE FROM $table WHERE vendorName = 'NONAME'");
if(debugging())
echo "$query <br><br>\n";
$t->create($query, $table, "vendorId");
}
apidb_footer();
?>

308
admin/adminAppQueue.php Normal file
View File

@@ -0,0 +1,308 @@
<?
/* code to View and approve new Apps */
/* last modified 06-07-01 by Jeremy Newman */
include("path.php");
require(BASE."include/"."incl.php");
require(BASE."include/"."tableve.php");
//deny access if not logged in
if(!loggedin())
{
errorpage("You need to be logged in to use this page.");
exit;
}
else if (!havepriv("admin"))
{
errorpage("You must be an administrator to use this page.");
exit;
}
apidb_header("Admin App Queue");
echo '<form name="qform" action="adminAppQueue.php" method="post" enctype="multipart/form-data">',"\n";
if ($sub)
{
if ($queueId)
{
//get data
$query = "SELECT * from appQueue where queueId = $queueId;";
$result = mysql_query($query);
$ob = mysql_fetch_object($result);
mysql_free_result($result);
}
else
{
//error no Id!
echo html_frame_start("Error","300");
echo '<p><b>Application Not Found!</b></p>',"\n";
echo html_frame_end("&nbsp;");
}
//process according to sub flag
if ($sub == 'view' && $queueId)
{
$x = new TableVE("view");
//help
echo "<div align=center><table width='90%' border=0 cellpadding=3 cellspacing=0><tr><td>\n\n";
echo "<p>This is the full view of the application waiting to be approved. You need to pick a category before submitting \n";
echo "it into the database. If you approve this application, an email will be sent to the author of the submission.<p>\n";
echo "<p>There are two kinds of applications in this database:</p>\n";
echo "<ol>\n";
echo " <li><b>App Family</b> This is a parent group application, that will have multiple versions under it.<br>\n";
echo " To add this submission as a Family, choose 'Application' from the type drop down. Then set the category.\n";
echo " The version and app parent fields will be ignored in this type.<br>\n";
echo " If the vendor does not exist, leave the vendor drop down unset, and the field will be used.</li><p>\n";
echo " <li><b>App Version</b> This type of application will be nested under the selected application parent. The category,\n";
echo " name, and vendor fields will be ignored.</li>\n";
echo "</td></tr></table></div>\n\n";
//view application details
echo html_frame_start("New Application Form",400,"",0);
echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
//type
echo '<tr valign=top><td class=color0><b>Type</b></td><td>',"\n";
echo '<select name=type><option value=app>Application</option><option value=ver>Version</option></select>',"\n";
echo '</td></tr>',"\n";
//category
echo '<tr valign=top><td class=color0><b>Category</b></td><td>',"\n";
$x->make_option_list("cat","","appCategory","catId","catName");
echo '</td></tr>',"\n";
//app parent
echo '<tr valign=top><td class=color0><b>App Parent</b></td><td>',"\n";
$x->make_option_list("appParent","","appFamily","appId","appName");
echo '</td></tr>',"\n";
//name
echo '<tr valign=top><td class=color0><b>App Name</b></td><td><input type=text name="queueName" value="'.stripslashes($ob->queueName).'" size=20></td></tr>',"\n";
//version
echo '<tr valign=top><td class=color0><b>App Version</b></td><td><input type=text name="queueVersion" value="'.stripslashes($ob->queueVersion).'" size=20></td></tr>',"\n";
//vendor
echo '<tr valign=top><td class=color0><b>App Vendor</b></td><td><input type=text name="queueVendor" value="'.stripslashes($ob->queueVendor).'" size=20></td></tr>',"\n";
//alt vendor
echo '<tr valign=top><td class=color0>&nbsp;</td><td>',"\n";
$x->make_option_list("altvendor","","vendor","vendorId","vendorName");
echo '</td></tr>',"\n";
//url
echo '<tr valign=top><td class=color0><b>App URL</b></td><td><input type=text name="queueURL" value="'.stripslashes($ob->queueURL).'" size=20></td></tr>',"\n";
//desc
echo '<tr valign=top><td class=color0><b>App Desc</b></td><td><textarea name="queueDesc" rows=10 cols=35>'.stripslashes($ob->queueDesc).'</textarea></td></tr>',"\n";
//echo '<tr valign=top><td bgcolor=class=color0><b>Email</b></td><td><input type=text name="queueEmail" value="'.$ob->queueEmail.'" size=20></td></tr>',"\n";
//echo '<tr valign=top><td bgcolor=class=color0><b>Image</b></td><td><input type=file name="queueImage" value="'.$ob->.'" size=15></td></tr>',"\n";
echo '<tr valign=top><td class=color3 align=center colspan=2> <input type=submit value=" Submit App Into Database " class=button> </td></tr>',"\n";
echo '</table>',"\n";
echo '<input type=hidden name="sub" value="add">',"\n";
echo '<input type=hidden name="queueId" value="'.$queueId.'">',"\n";
echo html_frame_end("&nbsp;");
echo html_back_link(1,'adminAppQueue.php');
}
else if ($sub == 'add' && $queueId)
{
//add item to main db
$statusMessage = "";
$goodtogo = 0;
if ($type == 'app')
{
//process as application family
if ($altvendor == 0 && $queueVendor)
{
//add new vendor
mysql_query("INSERT into vendor VALUES (null, '".addslashes($queueVendor)."', '');");
$altvendor = mysql_insert_id();
}
$query = "INSERT into appFamily VALUES (null, '".
addslashes($queueName)."', $altvendor, '', '".
addslashes($queueDesc)."', '".
addslashes($queueURL)."', $cat);";
if (mysql_query($query))
{
//get the id of the app just added
$appParent = mysql_insert_id();
//delete queue item
mysql_query("DELETE from appQueue where queueId = $queueId;");
//set ver if not set
if (!$queueVersion)
$queueVersion = '1.0';
if (!$queueDesc)
$queueDesc = 'released version';
$verQuery = "INSERT into appVersion VALUES (null, $appParent, '".
addslashes($queueVersion)."', '', '".
addslashes($queueDesc)."', '".
addslashes($queueURL)."', 0.0, 0.0);";
//Now add a version
if (mysql_query($verQuery))
{
//successful
$statusMessage = "<p>The application $queueName was successfully added into the database</p>\n";
$goodtogo = 1;
}
else
{
//error
$statusMessage = "<p><b>Database Error!<br>".mysql_error()."</b></p>\n";
$statusMessage .= "<p><b>Note:</b> The application family was successfully added.</p>\n";
}
}
else
{
//error
$statusMessage = "<p><b>Database Error!<br>".mysql_error()."</b></p>\n";
}
}
else if ($type == 'ver')
{
//process as application version
if ($appParent)
{
$query = "INSERT into appVersion VALUES (null, $appParent, '".
addslashes($queueVersion)."', '', '".
addslashes($queueDesc)."', '".
addslashes($queueURL)."', 0.0, 0.0);";
if (mysql_query($query))
{
//successful
$statusMessage = "<p>The application $queueName was successfully added into the database</p>\n";
mysql_query("DELETE from appQueue where queueId = $queueId;");
$goodtogo = 1;
}
else
{
//error
$statusMessage = "<p><b>Database Error!<br>".mysql_error()."</b></p>\n";
}
}
else
{
$statusMessage = "<p><b>Error<br>You did not pick an application Parent!</b></p>\n";
}
}
//Send Status Email
if ($ob->queueEmail && $goodtogo)
{
$ms = "Application Database Status Report\n";
$ms .= "----------------------------------\n\n";
$ms .= "Your application ".stripslashes($ob->queueName)." has been entered ";
$ms .= "into the application database.\n\n";
$ms .= "Thanks!\n";
mail(stripslashes($ob->queueEmail),'[AppDB] Status Report',$ms);
}
//done
echo html_frame_start("Submit Application","300");
echo "<p><b>$statusMessage</b></p>\n";
echo html_frame_end("&nbsp;");
echo html_back_link(1,'adminAppQueue.php');
}
else if ($sub == 'delete' && $queueId)
{
//delete main item
$query = "DELETE from appQueue where queueId = $queueId;";
$result = mysql_query($query);
echo html_frame_start("Delete Application: $ob->queueName",400,"",0);
if(!$result)
{
//error
echo "<p>Internal Error: unable to delete selected application!</p>\n";
}
else
{
//success
echo "<p>Application was successfully deleted from the Queue.</p>\n";
}
echo html_frame_end("&nbsp;");
echo html_back_link(1,'adminAppQueue.php');
}
else
{
//error no sub!
echo html_frame_start("Error","300");
echo '<p><b>Internal Routine Not Found!</b></p>',"\n";
echo html_frame_end("&nbsp;");
echo html_back_link(1,'adminAppQueue.php');
}
}
else
{
//get available apps
$query = "SELECT * from appQueue;";
$result = mysql_query($query);
if(!$result || !mysql_num_rows($result))
{
//no apps in queue
echo html_frame_start("","90%");
echo '<p><b>The Application Queue is empty.</b></p>',"\n";
echo '<p>There is nothing for you to do. Check back later.</p>',"\n";
echo html_frame_end("&nbsp;");
}
else
{
//help
echo "<div align=center><table width='90%' border=0 cellpadding=3 cellspacing=0><tr><td>\n\n";
echo "<p>This is the list of applications waiting for your approval, or to be annihilated from existence.</p>\n";
echo "<p>To view a submission, click on its name. From that page you can edit, and approve it into the AppDB.<br>\n";
echo "Click the delete link to remove the selected item from the queue. An email will automatically be sent to the\n";
echo "submitter to let them know the item was deleted.</p>\n";
echo "</td></tr></table></div>\n\n";
//show applist
echo html_frame_start("","90%","",0);
echo "<table width='100%' border=0 cellpadding=3 cellspacing=0>\n\n";
echo "<tr class=color4>\n";
echo " <td><font color=white>Application Name</font></td>\n";
echo " <td><font color=white>Version</font></td>\n";
echo " <td><font color=white>Vendor</font></td>\n";
echo " <td><font color=white>Submitter Email</font></td>\n";
echo " <td>&nbsp;</td>\n";
echo "</tr>\n\n";
$c = 1;
while($ob = mysql_fetch_object($result))
{
if ($c % 2 == 1) { $bgcolor = 'color0'; } else { $bgcolor = 'color1'; }
echo "<tr class=$bgcolor>\n";
echo " <td><a href='adminAppQueue.php?sub=view&queueId=$ob->queueId'>$ob->queueName</a></td>\n";
echo " <td>".stripslashes($ob->queueVersion)." &nbsp;</td>\n";
echo " <td>".stripslashes($ob->queueVendor)." &nbsp;</td>\n";
echo " <td>".stripslashes($ob->queueEmail)." &nbsp;</td>\n";
echo " <td>[<a href='adminAppQueue.php?sub=delete&queueId=$ob->queueId'>delete</a>]</td>\n";
echo "</tr>\n\n";
$c++;
}
echo "</table>\n\n";
echo html_frame_end("&nbsp;");
}
}
echo "</form>";
apidb_footer();
?>

99
admin/deleteAny.php Normal file
View File

@@ -0,0 +1,99 @@
<?
include("path.php");
include(BASE."include/"."incl.php");
if(!loggedin() || !havepriv("admin"))
{
errorpage();
exit;
}
if($confirmed != "yes")
{
// ask for confirmation
// could do some Real Damage if someone accidently hits the delete button on the main category :)
//
// perhaps we can do this with some javascript, popup
errorpage("Not confirmed");
}
function deleteCategory($catId)
{
$r = mysql_query("SELECT appId FROM appFamily WHERE catId = $catId");
if($r)
{
while($ob = mysql_fetch_object($r))
deleteAppFamily($ob->appId);
$r = mysql_query("DELETE FROM appCategory WHERE catId = $catId");
if($r)
addmsg("Category $catId deleted", "green");
else
addmsg("Failed to delete category $catId:".mysql_error(), "red");
}
else
{
addmsg("Failed to delete category $catId: ".mysql_error(), "red");
}
}
function deleteAppFamily($appId)
{
$r = mysql_query("DELETE FROM appFamily WHERE appId = $appId");
if($r)
{
$r = mysql_query("DELETE FROM appVersion WHERE appId = $appId");
if($r)
addmsg("Application and versions deleted", "green");
else
addmsg("Failed to delete appVersions: " . mysql_error(), "red");
}
else
addmsg("Failed to delete appFamily $appId: " . mysql_error(), "red");
}
function deleteAppVersion($versionId)
{
$r = mysql_query("DELETE FROM appVersion WHERE versionId = $versionId");
if($r)
addmsg("Application Version $versionId deleted", "green");
else
addmsg("Failed to delete appVersion $versionId: " . mysql_error(), "red");
}
if($what)
{
switch($what)
{
case "comment":
// delete a comment
//TODO
break;
case "category":
// delete category and the apps in it
deleteCategory($catId);
break;
case "appFamily":
// delete app family & all its versions
deleteAppFamily($appId);
break;
case "appVersion":
// delete a version
deleteAppVersion($versionId);
break;
}
//FIXME need to redirect to the page before the confirmation page
redirect($apidb_root."appbrowse.php");
}
?>

93
admin/editAppFamily.php Normal file
View File

@@ -0,0 +1,93 @@
<?
include("path.php");
include(BASE."include/"."incl.php");
include(BASE."include/"."tableve.php");
include(BASE."include/"."qclass.php");
global $apidb_root;
//FIXME: need to check for admin privs
if(!loggedin() || (!havepriv("admin") && !$current->ownsApp($appId)) )
{
errorpage("Insufficient Privileges!");
exit;
}
apidb_header("Edit Application Family");
$t = new TableVE("edit");
if($cmd)
{
$statusMessage = '';
//process add URL
if($cmd == "add_url")
{
$query = "INSERT INTO appData VALUES (null, $appId, 0, 'url', ".
"'$url_desc', '$url')";
if(debugging()) { echo "<p align=center><b>query:</b> $query </p>"; }
if (mysql_query($query))
{
//success
$statusMessage = "<p>The URL was successfully added into the database</p>\n";
}
else
{
//error
$statusMessage = "<p><b>Database Error!<br>".mysql_error()."</b></p>\n";
}
}
// display status message
if ($statusMessage)
{
echo html_frame_start("Edit Application","300");
echo "<p><b>$statusMessage</b></p>\n";
echo html_frame_end();
echo html_back_link(1,"editAppFamily.php?appId=$appId");
}
}
else if($HTTP_POST_VARS)
{
// commit changes of form to database
$t->update($HTTP_POST_VARS);
}
else
{
// show form
$table = "appFamily";
$query = "SELECT * FROM $table WHERE appId = $appId";
if(debugging()) { echo "<p align=center><b>query:</b> $query </p>"; }
$t->edit($query);
//url entry box
echo '<form enctype="multipart/form-data" action="editAppFamily.php" method="post">',"\n";
echo html_frame_start("Add URL","400","",0);
echo '<table border=0 cellpadding=6 cellspacing=0 width="100%">',"\n";
echo '<tr><td class=color1>URL</td><td class=color0><input name="url" type="text"></td></tr>',"\n";
echo '<tr><td class=color1>Description</td><td class=color0><input type="text" name="url_desc"></td></tr>',"\n";
echo '<tr><td colspan=2 align=center class=color3><input type="submit" value="Add URL"></td></tr>',"\n";
echo '</table>',"\n";
echo html_frame_end();
echo '<input type="hidden" name="cmd" value="add_url">',"\n";
echo '<input type="hidden" name="appId" value="'.$appId.'"></form>',"\n";
echo html_back_link(1,$apidb_root."appview.php?appId=$appId");
}
apidb_footer();
?>

46
admin/editAppNote.php Normal file
View File

@@ -0,0 +1,46 @@
<?
/*
* Edit AppNote
*/
include("path.php");
include(BASE."include/"."incl.php");
include(BASE."include/"."tableve.php");
include(BASE."include/"."qclass.php");
global $apidb_root;
//check for admin privs
if(!loggedin() || (!havepriv("admin") && !$current->ownsApp($appId)) )
{
errorpage("Insufficient Privileges!");
exit;
}
apidb_header("Edit Application Note");
$t = new TableVE("edit");
if($HTTP_POST_VARS)
{
// commit changes of form to database
$t->update($HTTP_POST_VARS);
}
else
{
// show form
$table = "appNotes";
$query = "SELECT * FROM $table WHERE noteId = $noteId";
if(debugging()) { echo "<p align=center><b>query:</b> $query </p>"; }
$t->edit($query);
echo html_back_link(1,$apidb_root."noteview.php?noteId=$noteId");
}
apidb_footer();
?>

120
admin/editAppOwners.php Normal file
View File

@@ -0,0 +1,120 @@
<?
include("path.php");
include(BASE."include/"."incl.php");
if(!loggedin() || !havepriv("admin"))
{
errorpage("Insufficient Privileges","You do not have access to this section of the website");
exit;
}
function build_user_list()
{
$result = mysql_query("SELECT username,email FROM user_list ORDER BY username");
echo "<select name=username size=15 onChange='this.form.ownerName.value = this.value; this.form.submit()'>\n";
while($ob = mysql_fetch_object($result))
{
echo "<option value='$ob->username'>$ob->username - $ob->email</option>\n";
}
echo "</select>\n";
}
if($cmd)
{
if($cmd == "delete")
{
$result = mysql_query("DELETE FROM appOwners WHERE appId = $appId AND ownerId = $ownerId");
if($result)
{
addmsg("Owner deleted", "green");
redirectref();
}
else
echo "Failed: " . mysql_error();
}
if($cmd == "add")
{
$result = mysql_query("SELECT userid FROM user_list WHERE username = '$ownerName'");
if($result)
{
$ob = mysql_fetch_object($result);
if(!$ob || !$ob->userid)
{
errorpage("Not Found!","User $ownerName was not found in the database");
exit;
}
$result = mysql_query("INSERT INTO appOwners VALUES ($appId, $ob->userid)");
if(!$result)
{
errorpage("Failed!",mysql_error());
exit;
}
addmsg("Owner $ownerName added", "green");
redirectref();
}
else
echo "Failed: " . mysql_error();
}
}
else
{
apidb_header("Edit Application Owners");
$result = mysql_query("SELECT ownerId,username FROM appOwners, user_list WHERE appId = $appId AND userid = ownerId");
if($result && mysql_num_rows($result))
{
echo html_frame_start("Current Owners","300",'',0);
echo "<table width='100%' border=0 cellpadding=3 cellspacing=0>\n\n";
echo "<tr class=color4>\n";
echo " <td><font color=white> User Name </font></td>\n";
echo " <td><font color=white> Delete </font></td>\n";
echo "</tr>\n\n";
$c = 1;
while($ob = mysql_fetch_object($result))
{
//set row color
if ($c % 2 == 1) { $bgcolor = 'color0'; } else { $bgcolor = 'color1'; }
$delete_link = "[<a href='editAppOwners.php?cmd=delete&appId=$appId&ownerId=$ob->ownerId'>delete</a>]";
echo "<tr class=$bgcolor>\n";
echo " <td>$ob->username &nbsp;</td>\n";
echo " <td>$delete_link &nbsp;</td>\n";
echo "</tr>\n\n";
$c++;
}
echo "</table>\n\n";
echo html_frame_end();
}
echo "<form method=post action=editAppOwners.php>\n";
echo html_frame_start("Manually Add User","300",'',5);
echo "<input type=text name=ownerName size=15>\n";
echo "<input type=submit value=' Add User ' class=button>\n";
echo html_frame_end();
echo html_frame_start("User List","",'',2);
build_user_list();
echo html_frame_end();
echo "<input type=hidden name=appId value=$appId>\n";
echo "<input type=hidden name=cmd value=add>\n";
echo "</form>\n";
apidb_footer();
}
?>

111
admin/editAppVersion.php Normal file
View File

@@ -0,0 +1,111 @@
<?
include("path.php");
include(BASE."include/"."incl.php");
include(BASE."include/"."tableve.php");
include(BASE."include/"."qclass.php");
//check for admin privs
if(!loggedin() || (!havepriv("admin") && !$current->ownsApp($appId)) )
{
errorpage("Insufficient Privileges!");
exit;
}
apidb_header("Edit Application Version");
$t = new TableVE("edit");
if($cmd)
{
$statusMessage = '';
//process screenshot upload
if($cmd == "screenshot_upload")
{
if(debugging())
{
echo "<p align=center>Screenshot: ($appId) file=$imagefile size=$imagefile_size\n";
echo " name=$imagefile_name type=$imagefile_type<br>";
}
if(!copy($imagefile, "../data/screenshots/".basename($imagefile_name)))
{
// whoops, copy failed. do something
echo html_frame_start("Edit Application","300");
echo "<p><b>debug: copy failed; $imagefile; $imagefile_name</b></p>\n";
echo html_frame_end();
echo html_back_link(1,"editAppVersion.php?appId=$appId&versionID=$versionId");
apidb_footer();
exit;
}
$query = "INSERT INTO appData VALUES (null, $appId, $versionId, 'image', ".
"'".addslashes($screenshot_desc)."', '".basename($imagefile_name)."')";
if(debugging()) { echo "<p align=center><b>query:</b> $query </p>"; }
if (mysql_query($query))
{
//success
$statusMessage = "<p>The image was successfully added into the database</p>\n";
}
else
{
//error
$statusMessage = "<p><b>Database Error!<br>".mysql_error()."<br></b></p>\n";
if(debugging()) { $statusMessage .= "<p>$query</p>"; }
}
}
// display status message
if ($statusMessage)
{
echo html_frame_start("Edit Application","300");
echo "<p><b>$statusMessage</b></p>\n";
echo html_frame_end();
echo html_back_link(1,"editAppVersion.php?appId=$appId&versionId=$versionId");
}
}
else if($HTTP_POST_VARS)
{
$t->update($HTTP_POST_VARS);
}
else
{
$table = "appVersion";
$query = "SELECT * FROM $table WHERE appId = $appId AND versionId = $versionId";
if(debugging()) { echo "<p align=center><b>query:</b> $query </p>"; }
$t->edit($query);
//image upload box
echo '<form enctype="multipart/form-data" action="editAppVersion.php" name=imageForm method="post">',"\n";
echo html_frame_start("Upload Screenshot","400","",0);
echo '<table border=0 cellpadding=6 cellspacing=0 width="100%">',"\n";
echo '<tr><td class=color1>Image</td><td class=color0><input name="imagefile" type="file"></td></tr>',"\n";
echo '<tr><td class=color1>Description</td><td class=color0><input type="text" name="screenshot_desc"></td></tr>',"\n";
echo '<tr><td colspan=2 align=center class=color3><input type="submit" value="Send File"></td></tr>',"\n";
echo '</table>',"\n";
echo html_frame_end();
echo '<input type="hidden" name="MAX_FILE_SIZE" value="10000000">',"\n";
echo '<input type="hidden" name="cmd" value="screenshot_upload">',"\n";
echo '<input type="hidden" name="appId" value="'.$appId.'">',"\n";
echo '<input type="hidden" name="versionId" value="'.$versionId.'"></form>',"\n";
echo html_back_link(1,$apidb_root."appview.php?appId=$appId&versionId=$versionId");
}
apidb_footer();
?>

98
admin/editBundle.php Normal file
View File

@@ -0,0 +1,98 @@
<?
include("path.php");
include(BASE."include/"."incl.php");
if(!loggedin() || !havepriv("admin"))
{
errorpage();
exit;
}
function build_app_list()
{
$result = mysql_query("SELECT appId, appName FROM appFamily ORDER BY appName");
echo "<select name=appId size=5 onChange='this.form.submit()'>\n";
while($ob = mysql_fetch_object($result))
{
echo "<option value=$ob->appId>$ob->appName</option>\n";
}
echo "</select>\n";
}
if($cmd)
{
if($cmd == "delete")
{
$result = mysql_query("DELETE FROM appBundle WHERE appId = $appId AND bundleId = $bundleId");
if($result)
addmsg("App deleted from bundle", "green");
else
addmsg("Failed: " . mysql_error(), "red");
}
if($cmd == "add")
{
$result = mysql_query("INSERT INTO appBundle VALUES ($bundleId, $appId)");
if($result)
addmsg("App $appId added to Bundle $bundleId", "green");
else
addmsg("Failed: " . mysql_error(), "red");
}
redirectref();
exit;
}
else
{
apidb_header("Edit Application Bundle");
$result = mysql_query("SELECT bundleId, appBundle.appId, appName FROM appBundle, appFamily ".
"WHERE bundleId = $bundleId AND appFamily.appId = appBundle.appId");
if($result && mysql_num_rows($result))
{
echo html_frame_start("Apps in this Bundle","300",'',0);
echo "<table width='100%' border=0 cellpadding=3 cellspacing=0>\n\n";
echo "<tr class=color4>\n";
echo " <td><font color=white> Application Name </font></td>\n";
echo " <td><font color=white> Delete </font></td>\n";
echo "</tr>\n\n";
$c = 1;
while($ob = mysql_fetch_object($result))
{
//set row color
if ($c % 2 == 1) { $bgcolor = 'color0'; } else { $bgcolor = 'color1'; }
$delete_link = "[<a href='editBundle.php?cmd=delete&bundleId=$bundleId&appId=$ob->appId'>delete</a>]";
echo "<tr class=$bgcolor>\n";
echo " <td>$ob->appName &nbsp;</td>\n";
echo " <td>$delete_link &nbsp;</td>\n";
echo "</tr>\n\n";
$c++;
}
echo "</table>\n\n";
echo html_frame_end();
}
echo "<form method=post action=editBundle.php>\n";
echo html_frame_start("Application List (double click to add)","",'',2);
build_app_list();
echo html_frame_end();
echo "<input type=hidden name=bundleId value=$bundleId>\n";
echo "<input type=hidden name=cmd value=add>\n";
echo "</form>\n";
apidb_footer();
}
?>

42
admin/editCategory.php Normal file
View File

@@ -0,0 +1,42 @@
<?
include("path.php");
include(BASE."include/"."incl.php");
include(BASE."include/"."tableve.php");
include(BASE."include/"."qclass.php");
if(!loggedin() || !havepriv("admin"))
{
errorpage();
exit;
}
else
{
global $admin_mode;
$admin_mode = 1;
}
apidb_header("Edit Category");
$t = new TableVE("edit");
if($HTTP_POST_VARS)
{
$t->update($HTTP_POST_VARS);
}
else
{
$table = "appCategory";
$query = "SELECT * FROM $table WHERE catId = $catId";
if(debugging())
echo "$query <br><br>\n";
$t->edit($query);
}
apidb_footer();
?>

41
admin/editVendor.php Normal file
View File

@@ -0,0 +1,41 @@
<?
include("path.php");
include(BASE."include/"."incl.php");
include(BASE."include/"."tableve.php");
include(BASE."include/"."qclass.php");
if(!loggedin() || !havepriv("admin"))
{
errorpage();
exit;
}
else
{
global $admin_mode;
$admin_mode = 1;
}
apidb_header("Edit Vendor Information");
$t = new TableVE("edit");
if($HTTP_POST_VARS)
{
$t->update($HTTP_POST_VARS);
}
else
{
$table = "vendor";
$query = "SELECT * FROM $table WHERE vendorId = $vendorId";
if(debugging())
echo "$query <br><br>\n";
$t->edit($query);
}
apidb_footer();
?>

78
admin/index.php Normal file
View File

@@ -0,0 +1,78 @@
<?
//
// Admin Script for API Db
// last modified 04-20-01
//
include("path.php");
include(BASE."include/"."incl.php");
include(BASE."include/"."tableve.php");
//FIXME: need to check for admin privs
if(!loggedin())
{
errorpage();
exit;
}
// desc
function get_tables()
{
$result = mysql_query("SHOW TABLES");
$arr = array();
$arr[] = "ALL";
while($r = mysql_fetch_array($result))
{
$arr[] = $r[0];
}
return $arr;
}
// desc
function input_form()
{
echo "<form method=get action=".apidb_url("admin").">\n";
echo "</form>\n";
}
//desc
function make_options($name, $options, $label = "Submit")
{
echo "<select name='$name'>\n";
while(list($idx, $val) = each($options))
echo "<option>$val</option>\n";
echo "</select>\n";
}
//desc
if($table_cmd)
{
apidb_header("Table Operation");
$t = new TableVE("view");
switch($table_cmd)
{
case "check":
$t->view("CHECK TABLE $table_id");
break;
case "describe":
$t->view("DESCRIBE $table_id");
break;
case "optimize":
$t->view("OPTIMIZE TABLE $table_id");
break;
}
apidb_footer();
exit;
}
// output of admin page begins here
apidb_header("Admin");
// Draw User List
include(BASE."include/"."query_users.php");
apidb_footer();
?>

3
admin/path.php Normal file
View File

@@ -0,0 +1,3 @@
<?
define("BASE","../");
?>