-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patheditor.php
149 lines (115 loc) · 4.65 KB
/
editor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
/**************************************************************************\
* PHPAdvocat *
* http://phpadvocat.sourceforge.net *
* By Burkhard Obergoeker <[email protected]> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
require("./include/phpadvocat.inc.php");
/* Get User Account from Session Vars */
$user = $_SESSION["dbuser"];
$passwd = $_SESSION["dbpasswd"];
$changecheck="";
/* initialize database */
$db = new www_db;
$db->connect($user, $passwd);
/* import invoice number if transmitted by GET or POST */
if($_POST["pfile"]) {
$pfile = $_POST["pfile"];
$savebutton = $_POST["savebutton"];
$pdfbutton = $_POST["pdfbutton"];
$filename = $_POST["filename"];
$filecontent = $_POST["filecontent"];
} elseif($_GET["pfile"]) {
$pfile = $_GET["pfile"];
$filename = $_GET["filename"];
}
$changecheck='';
/* check file name to prevent unauthorized acces on system files */
$filebase = './files';
$querystring = sprintf("select * from phpa_config where number=%s",1);
if(!$db->query($querystring) && $db->next_record() && $db->record["filebase"] != '') {
$filebase = trim($db->record["filebase"]);
$filebaselen = strlen($filebase);
}
/*
* work with files only if name begins with filebase and there
* are no '..' in the path
*/
if((0 == strncmp($filename, $filebase, $filebaselen)) && (!strstr($filename, '..'))) {
/* filename is OK */
/* Test in die Datei schreiben */
if($filename && $savebutton) {
if($fd=fopen($filename, "w")) {
/* we strip the DOS-like ^M */
$filecontent = str_ireplace(chr(13), '', $filecontent);
fwrite($fd, stripslashes($filecontent));
fclose($fd);
$changecheck='Datei gesichert';
}
}
/* Datei in den Editor laden */
if(file_exists($filename)){
if($fd=fopen($filename, "r")) {
$filecontent=fread($fd, filesize($filename));
fclose($fd);
// $filecontent=stripslashes($filecontent);
} else {
$changecheck='Datei geschuetzt';
}
}
} /* if filename is OK */
echo "<HTML><HEAD><TITLE>PHPAdvocat - Schriftverkehr</TITLE>";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-15\">\n";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"include/phpadvocat.css\">";
echo "</HEAD>";
echo "<BODY BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\">\n";
echo "<TABLE width=100%><TR><TD width=200 valign=top>";
/* here comes the menue */
$phpa_menue->account=$user;
$phpa_menue->selected = 2;
array_insert($phpa_menue->contents,
array( sprintf(" <b><a href=pfileedit.php?pnumber=%s&detail=4>".
"Akte bearbeiten</a></b>",$pfile)), 1);
array_insert($phpa_menue->contents,
array(' <b>Schriftverkehr</b>'), 2);
$phpa_menue->draw_menue();
/* display Title */
echo "</TD><TD><CENTER><H1>Schriftverkehr</H1></CENTER>";
echo "<table width=100%><tr>\n";
echo "<td>" . date("d.m.Y", time()) . "</td>";
/* display status at right side */
echo "<TD ALIGN=RIGHT><b>". $changecheck. "</b></A></TD>";
print "</tr></table>\n";
echo "<hr>";
echo "<table class=inputtable>";
/* Dateiname festlegen */
echo "<form method=post action=$PHP_SELF>";
echo "<tr><td>";
// echo "<input type=hidden name=filecontent value=\"". addslashes($filecontent) . "\">";
echo "<input type=hidden name=pfile value=\"". $pfile . "\">";
echo "<input type=hidden name=filename value=\"". $filename . "\">" .basename($filename);
echo "</td></tr>\n";
// $filecontent=stripslashes($filecontent);
echo "<tr><td>\n";
/* Dateiname festlegen */
printf("<TEXTAREA NAME=filecontent WRAP=VIRTUAL " .
"COLS=80 ROWS=25>%s</TEXTAREA>\n", $filecontent);
echo "</td></tr>\n";
echo "<tr><td>\n";
echo "<table width=100%><tr>";
echo "<td align=left><input type=submit name=savebutton value=Speichern></td>\n";
echo "<td align=right><a href=\"letterpdf.php?latexfile=".$filename .
"\" target=_BLANK>PDF-Ausgabe</a></td>\n";
echo "</tr></table>\n";
echo "</td></tr>\n";
echo "</form>";
echo "</table>\n";
$db->close();
/* End HTML PAGE */
echo "</td></tr></table></BODY></HTML>";
?>