admin-notes.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <?php
  2. header('Location: http://php-gtk.audean.com');
  3. //require_once 'cvs-auth.inc';
  4. require_once '../include/email-validation.inc';
  5. require_once '../include/shared-manual1.inc';
  6. $mailto = 'gtk-webmaster@lists.php.net';
  7. $num_entries_per_page = 50;
  8. if (isset($MAGIC_COOKIE)) {
  9. list($user, $pass) = explode(":", base64_decode($MAGIC_COOKIE));
  10. }
  11. if (!strstr($MYSITE, "gtk.php.net")) {
  12. header("Location: http://gtk.php.net/manual1/admin-notes.php");
  13. exit;
  14. }
  15. commonHeader("PHP-GTK 1 Manual Notes Administration");
  16. echo "<h1>PHP-GTK 1 Manual Notes Administration</h1>\n\n";
  17. echo "<p>If you just want to browse the manual notes, you're better off " .
  18. "<a href=\"http://gtk.php.net/manual1/browse-notes.php\">here</a>.</p>\n";
  19. if ($action != '') {
  20. list ($action, $id) = explode(' ', $action);
  21. if ($action!='edit'&& !isset($MAGIC_COOKIE)) {
  22. echo "<p><b>Authorization failed.</b></p>";
  23. commonFooter();
  24. exit;
  25. }
  26. switch($action) {
  27. case 'delete':
  28. $query = 'SELECT *,UNIX_TIMESTAMP(ts) AS xwhen FROM note WHERE id='.$id;
  29. if ($result = mysql_query($query)) {
  30. $row = mysql_fetch_array($result);
  31. mail($mailto, "note ".$row['id']." deleted from ".$row['sect']." by $user", stripslashes($row['note']), "From: ".$user."@php.net");
  32. $query = 'DELETE FROM note WHERE id=' . $id;
  33. if (mysql_query($query)) {
  34. echo '<p><b>Note deleted.</b></p>';
  35. if ($popup) {
  36. echo '<script language="javascript">window.close();</script>';
  37. }
  38. }
  39. }
  40. break;
  41. case 'reject':
  42. $reject_text = "If you are receiving this email is because your note posted\n";
  43. $reject_text .= "to the on-line PHP-GTK 1 manual has been removed by one of the editors.\n\n";
  44. $reject_text .= "Read the following paragraphs carefully, because they contain\n";
  45. $reject_text .= "pointers to resources better suited for requesting support or\n";
  46. $reject_text .= "reporting bugs, none of which are to be included in manual notes\n";
  47. $reject_text .= "because there are mechanisms and groups in place to deal with\n";
  48. $reject_text .= "those issues.\n\n";
  49. $reject_text .= "The user contributed notes are not an appropriate place to\n";
  50. $reject_text .= "ask questions, report bugs or suggest new features; please\n";
  51. $reject_text .= "use the resources listed in <http://gtk.php.net/resources.php>\n";
  52. $reject_text .= "for those purposes. This was clearly stated in the page\n";
  53. $reject_text .= "you used to submit your note, please carefully re-read\n";
  54. $reject_text .= "those instructions before submitting future contributions.\n\n";
  55. $reject_text .= "Bug Submissions should be entered at <http://bugs.php.net/>\n";
  56. $reject_text .= "Feature Requests should also be entered at <http://bugs.php.net/>\n";
  57. $reject_text .= "Support and ways to find answers to your guestions can be found\n";
  58. $reject_text .= "at <http://gtk.php.net/resources.php>\n\n";
  59. $reject_text .= "Your note has been removed from the on-line manual.\n\n";
  60. $query = 'SELECT *,UNIX_TIMESTAMP(ts) AS xwhen FROM note WHERE id='.$id;
  61. if ($result = mysql_query($query)) {
  62. $row = mysql_fetch_array($result);
  63. // email the submitter if the address looks reasonable
  64. // uses functions in include/email-validation.inc
  65. $submitter = clean_AntiSPAM($row['user']);
  66. echo "<p>Note ".$row['id']." by: ".$row['user']." ($submitter) ";
  67. if (is_emailable_address($submitter)) {
  68. mail($submitter,"note ".$row['id']." rejected and deleted from ".$row['sect']." by notes editor $user",$reject_text."----- Copy of your note below -----\n\n".stripslashes($row['note']),"From: ".$user."@php.net");
  69. }
  70. // email to the list
  71. mail($mailto, "note ".$row['id']." rejected and deleted from ".$row['sect']." by $user", stripslashes($row['note']), "From: ".$user."@php.net");
  72. $query = 'DELETE FROM note WHERE id=' . $id;
  73. if (mysql_query($query)) {
  74. echo '<b>rejected and deleted.</b></p>';
  75. }
  76. if ($popup) {
  77. echo '<script language="javascript">window.close();</script>';
  78. }
  79. }
  80. break;
  81. case 'edit':
  82. echo "<p>Only people with " . make_link('http://www.php.net/cvs-php.php', 'CVS accounts') .
  83. " are able to edit the manual notes, so please don't email us asking why this doesn't work for you.</p>";
  84. $query = 'SELECT *,UNIX_TIMESTAMP(ts) AS xwhen FROM note WHERE id='.$id;
  85. if ($result = mysql_query($query)) {
  86. $row = mysql_fetch_array($result);
  87. echo '<form method="POST" action="/manual1/admin-notes.php">';
  88. echo '<table border="0" cellpadding="5" cellspacing="0" bgcolor="#e0e0e0">';
  89. echo '<tr valign="top"><TD align="right"><small>E-mail:<br></small></td>' .
  90. '<td><input type="text" size="40" name="nuser" value="',$row['user'], '"><br /></td></tr>';
  91. echo '<tr valign="top"><TD align="right"><small>Note:<br></small></td>' .
  92. '<td><textarea name="note" rows="8" cols="50">' . $row['note'] . '</textarea><br /></td></tr>';
  93. echo '<tr valign="top"><TD align="right"><small>Reset rating:<br></small></td>' .
  94. '<td><select name="rating">';
  95. echo '<option value="0">leave unchanged';
  96. echo '<option value="-1">clear all votes';
  97. for ($i = 1; $i <= 5; $i++) {
  98. echo '<option value="' . $i . '">set to '.$i. "\n";
  99. }
  100. echo '</select><br /></td></tr>';
  101. echo '<tr bgcolor="#cccccc"><td colspan="2"></td></tr>';
  102. echo '<tr valign="top"><td align="right"><small>Your CVS username:<br></small></td>' .
  103. '<td><input type="text" size="8" name="user" value="' . $user . '"><br /></td></tr>';
  104. echo '<tr valign="top"><td align="right"><small>Your CVS password:<br></small></td>' .
  105. '<td><input type="password" size="8" name="pass" value="' . $pass . '"><br /></td></tr>';
  106. echo '<tr valign="top"><td align="right"><small>Remember me:<br></small></td>' .
  107. '<td><input type="checkbox" name="saveme" checked value="1"><br /></td></tr>';
  108. echo '<tr><td colspan="2"><input type="submit" name="action" value="modify ' . $id . '"></td></tr>';
  109. echo "</table></form>\n";
  110. commonFooter();
  111. exit;
  112. } else {
  113. echo "<p><b>Unable to find note for editing.</b></p>\n";
  114. }
  115. break;
  116. case 'modify':
  117. $query = 'SELECT *,UNIX_TIMESTAMP(ts) AS xwhen FROM note WHERE id='.$id;
  118. if ($result = mysql_query($query)) {
  119. $row = mysql_fetch_array($result);
  120. }
  121. $add_url = "\n\nhttp://gtk.php.net/manual1/en/".$row['sect']."\n";
  122. $query = "UPDATE note SET user='$nuser', note='$note'";
  123. $rating = (int)$rating;
  124. if ($rating==-1) {
  125. $query .= ", votes=0, rating=0";
  126. } else if ($rating > 0) {
  127. $query .= ",votes=10, rating=(10*".$rating.")";
  128. }
  129. $query .= " WHERE id=$id";
  130. if (mysql_query($query)) {
  131. echo "<p><b>Record modified.</b></p>";
  132. mail($mailto, "note ".$row['id']." modified in ".$row['sect']." by $user",stripslashes($note).$add_url,"From: ".$user."@php.net");
  133. } else {
  134. echo "<p><b>Record not modified (query failed).</b></p>";
  135. }
  136. break;
  137. default:
  138. if (!empty($action)) {
  139. echo "<p><b>Didn't understand action '$action'.</b></p>";
  140. }
  141. } // end of switch
  142. } // end of if($action != "")
  143. $MAGIC_COOKIE = 'temp';
  144. include 'browse.php';
  145. commonFooter();
  146. ?>