add.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. //
  3. // this is the "add an app" form that end users use.
  4. //
  5. require_once("apps.inc");
  6. commonHeader('Add an Application', false);
  7. appHeader();
  8. print("<h1>Add a PHPGTK Application</h1>");
  9. //
  10. // if the form was submitted add it to the databas
  11. //
  12. if( $action == "add" ) {
  13. /*
  14. if( !empty($_FILES[screenshot][name])
  15. && ereg("^image/", $_FILES[screenshot][type])
  16. && !ereg("gif", $_FILES[screenshot][type])
  17. ) {
  18. $has_screenshot = 'Y';
  19. }else {
  20. $has_screenshot = 'N';
  21. }
  22. $res = mysql_query("
  23. INSERT INTO app
  24. (id, status, cat_id, date_added, name, has_screenshot, homepage_url, submitter, blurb)
  25. VALUES
  26. (0, 'P', $cat_id, NOW(), '$name', '$has_screenshot', '$homepage_url', '$submitter', '$blurb')
  27. ");
  28. if( $res == true ) {
  29. $app_id = mysql_insert_id();
  30. if( $has_screenshot == 'Y' ) {
  31. $app_id = mysql_insert_id();
  32. handleAppImage($_FILES[screenshot][tmp_name], $app_id);
  33. $screen_shot_link = "Screenshot : http://$_SERVER[SERVER_NAME]/apps/screenshot.php/$app_id.jpg\n";
  34. }
  35. mail($mailto, "app '$name' submitted for approval.",
  36. "The following application was submitted for approval:\n\n" .
  37. "Name : $name\n" .
  38. "URL : $homepage_url\n" .
  39. "Category : " . $appCats[$cat_id]->name . "\n" .
  40. "Submitter : $submitter\n" .
  41. $screen_shot_link .
  42. "Description: $blurb\n" .
  43. "\n" .
  44. "Administrative Actions\n" .
  45. "----------------------\n" .
  46. "Approve: http://$_SERVER[SERVER_NAME]/apps/admin-apps.php?action=approve&app_id=$app_id\n" .
  47. "Edit: http://$_SERVER[SERVER_NAME]/apps/admin-apps.php?action=edit&app_id=$app_id\n" .
  48. "Reject: http://$_SERVER[SERVER_NAME]/apps/admin-apps.php?action=reject&app_id=$app_id\n" .
  49. "Delete: http://$_SERVER[SERVER_NAME]/apps/admin-apps.php?action=delete&app_id=$app_id\n" .
  50. "",
  51. "From: $mailto");
  52. print("Thank you for the submission. Someone will review it shortly.");
  53. }else {
  54. print("There was a problem with your submission. Please try it again.");
  55. print("<br>");
  56. print("Error: (" . mysql_errno() . ") " . mysql_error() );
  57. }
  58. */
  59. print('Submissions have been disabled until the form is safe from spammers.');
  60. }else {
  61. $form_app = (object) 0;
  62. if( !empty($cat_id) ) {
  63. $form_app->cat_id = $cat_id;
  64. }
  65. $form_url = "add.php";
  66. $form_action = "add";
  67. $form_submit = "Add";
  68. include_once("form.php");
  69. }
  70. appFooter();
  71. commonFooter(false);
  72. ?>