edit.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. //
  3. // This is the form end users use to submit modifications to their apps to the database.
  4. // A modified app is actually a new record with a pointer to the old one. Once an administrator
  5. // approves the new one the status is changed to active and the old one is removed from the system.
  6. // This has the added benefit of bringing it to the top of the "newest applications" list.
  7. //
  8. require_once("apps.inc");
  9. commonHeader('Edit your Application', false);
  10. appHeader();
  11. print("<h1>Edit Your PHPGTK Application</h1>");
  12. //
  13. // if the form was submitted add it to the databas
  14. //
  15. if( $action == "modify" ) {
  16. $res = mysql_query("SELECT * FROM app WHERE id = $app_id");
  17. if( $res ) {
  18. $app = mysql_fetch_object($res);
  19. if( $app->submitter == $submitter ) {
  20. if( !empty($_FILES[screenshot][name]) && ereg("^image/", $_FILES[screenshot][type]) ) {
  21. $has_screenshot = 'Y';
  22. }else {
  23. $has_screenshot = 'N';
  24. }
  25. $res = mysql_query("
  26. INSERT INTO app
  27. (id, modify_id, status, cat_id, date_added, name, has_screenshot, homepage_url, submitter, blurb)
  28. VALUES
  29. (0, $app->id, 'M', $cat_id, NOW(), '$name', '$has_screenshot', '$homepage_url', '$submitter', '$blurb')
  30. ");
  31. if( $res == true ) {
  32. if( $has_screenshot == 'Y' ) {
  33. $app_id = mysql_insert_id();
  34. handleAppImage($_FILES[screenshot][tmp_name], $app_id);
  35. }
  36. print("Thank you for the update. Someone will review it shortly.");
  37. }else {
  38. print("There was a problem with your update. Please try it again.");
  39. print("<br>");
  40. print("Error: (" . mysql_errno() . ") " . mysql_error() );
  41. }
  42. }else {
  43. print("<p><b>Sorry, the email address you entered does not match the address on file for this application.</b></p>");
  44. }
  45. }else {
  46. print("<p><b>Unable to find app #$app_id for editing.</b></p>");
  47. }
  48. }else if( $action == "edit" ) {
  49. $res = mysql_query("SELECT * FROM app WHERE id = $app_id");
  50. if( $res ) {
  51. $form_app = mysql_fetch_object($res);
  52. $form_app->submitter = "";
  53. $form_url = "edit.php";
  54. $form_action = "modify";
  55. $form_submit = "Edit";
  56. print("Please enter your email again for security purposes.");
  57. include_once("form.php");
  58. appFooter();
  59. commonFooter();
  60. exit;
  61. }else {
  62. print("<p><b>Unable to find app #$app_id for editing.</b></p>");
  63. }
  64. }else if( $action == "list" ) {
  65. $email = ereg_replace("'", "", $email);
  66. $res = mysql_query("SELECT * FROM app WHERE status = 'A' AND submitter = '$email' ORDER BY name");
  67. $num_rows = mysql_num_rows($res);
  68. if( $res && $num_rows > 0 ) {
  69. print("<table border=0 cellpadding=2 cellspacing=0 width=100%>");
  70. while( $row = mysql_fetch_object($res) ) {
  71. displayApp($row, $the_cat, $the_subcat, 0, true);
  72. }
  73. print("</table>");
  74. }else {
  75. print("Unable to find any applications that you submitted.");
  76. }
  77. }else {
  78. print("
  79. <form action='edit.php' method=post>
  80. <input type=hidden name='action' value='list'>
  81. Please enter your email address.
  82. <br>
  83. <br>
  84. <input type=text name='email'>
  85. <input type=submit value='Continue'>
  86. <br>
  87. <br>
  88. Your email address will be used to locate applications that you have submitted.
  89. </form>
  90. ");
  91. }
  92. appFooter();
  93. commonFooter(false);
  94. ?>