2 $title = "Template(s) & file editing";
5 function add_magic_quotes($array) {
6 foreach ($array as $k => $v) {
8 $array[$k] = add_magic_quotes($v);
10 $array[$k] = addslashes($v);
16 if (!get_magic_quotes_gpc()) {
17 $HTTP_GET_VARS = add_magic_quotes($HTTP_GET_VARS);
18 $HTTP_POST_VARS = add_magic_quotes($HTTP_POST_VARS);
19 $HTTP_COOKIE_VARS = add_magic_quotes($HTTP_COOKIE_VARS);
22 $b2varstoreset = array('action','standalone','redirect','profile','error','warning','a','file');
23 for ($i=0; $i<count($b2varstoreset); $i +
= 1) {
24 $b2var = $b2varstoreset[$i];
25 if (!isset($
$b2var)) {
26 if (empty($HTTP_POST_VARS["$b2var"])) {
27 if (empty($HTTP_GET_VARS["$b2var"])) {
30 $
$b2var = $HTTP_GET_VARS["$b2var"];
33 $
$b2var = $HTTP_POST_VARS["$b2var"];
44 $newcontent = stripslashes($HTTP_POST_VARS["newcontent"]);
45 $file = $HTTP_POST_VARS["file"];
46 $f = fopen($file,"w+");
47 fwrite($f,$newcontent);
50 // header("Location: index.php?file=$file&a=te");
57 $file = $HTTP_POST_VARS["file"];
59 if ( ereg('/', $file ) && !ereg('^/', $file ) )
60 $file = str_replace('/', '.', $file);
62 if ( !ereg('.comment[2]?$', $file) )
65 if ($file==".comment2") {
66 // prepend with '<directory name>.' if comments under <directory name>
67 $file = "notes.html.comment2";
68 // change from notes to whichever page it is your comments are on
71 if ( !ereg('^/usr', $file ) )
72 $file = ANNOTATE_DIR
. $project . '/' . $file;
77 $file = stripslashes($file);
80 $f = fopen($file,"r");
81 $content = fread($f,filesize($file));
82 $content = htmlspecialchars($content);
87 <table width=
"100%" cellpadding=
"5" cellspacing=
"0">
91 echo "Listing <b>$file</b>".$warning;
93 echo "<i> [ file edited ! ]</i>";
97 <form name=
"template" action=
"edit.html" method=
"post">
98 <textarea cols=
"80" rows=
"20" style=
"width:100%" name=
"newcontent" tabindex=
"1"><?php echo $content ?></textarea>
99 <input type=
"hidden" name=
"action" value=
"update" />
100 <input type=
"hidden" name=
"file" value=
"<?php echo $file ?>" />
103 if (is_writeable($file)) {
104 echo "<input type=\"submit\" name=\"submit\" class=\"search\" value=\"update template !\" tabindex=\"2\" />";
106 echo "<input type=\"button\" name=\"oops\" class=\"search\" value=\"(you cannot update that file/template: must make it writable, e.g. CHMOD 766)\" tabindex=\"2\" />";
112 echo "<p>oops, no such file !</p>";