Debian Codegraph @

doc/examples/dynamic_comments_in_slides/add_comment.php

raw
1 <?php
2
3 /* get variables from the form */
4 $comment_file = $_GET['comment_file'];
5 $slide_url = $_GET['slide_url'];
6 $new_comment = $_GET['new_comment'];
7
8 /* change end of line into HTML end of line */
9 $new_comment = str_replace("\n", "<br />\n", $new_comment);
10
11 /* change escaped quotes into non-escaped */
12 $new_comment = str_replace("\'", "'", $new_comment);
13 $new_comment = str_replace('\"', '"', $new_comment);
14
15 /* open the comment file */
16 $fp = fopen ($comment_file, "a")
17 or die ("Couldn't open the file to add comment for ".$slide_url."\n");
18
19 /* lock it to protect against concurrent accesses */
20 flock($fp, LOCK_EX);
21
22 /* Add the comment and format it */
23 fwrite($fp, "<b>New comment:</b><br />\n");
24 fwrite($fp, "<i>".$new_comment."</i>");
25 fwrite($fp, "<br />\n");
26
27 /* unlock and close the file */
28 flock($fp, LOCK_UN);
29 fclose ($fp);
30
31 /* go back to the slide */
32 header("Location: ".$slide_url);
33
34 ?>