-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdfileedit.php
More file actions
135 lines (104 loc) · 4.13 KB
/
dfileedit.php
File metadata and controls
135 lines (104 loc) · 4.13 KB
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
<?php
/**************************************************************************\
* PHPAdvocat *
* http://phpadvocat.sourceforge.net *
* By Burkhard Obergoeker <phpadvocat@obergoeker.de> *
* -------------------------------------------- *
* 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["number"] !=0) {
$number = $_POST["number"];
$pfile = $_POST["pfile"];
$knopf = $_POST["knopf"];
$filename = $_POST["filename"];
$filecontent = $_POST["filecontent"];
} elseif($_GET["number"] !=0) {
$number = $_GET["number"];
$pfile = $_GET["pfile"];
$path = $_GET["path"];
}
echo "<HTML><HEAD><TITLE>PHPAdvocat - Korrespondenz</TITLE>";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-15\"></HEAD>\n";
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>Korrespondenz</H1></CENTER>";
/* if nothing is in config table ./files is default */
$filebase = 'files';
$querystring = sprintf("select * from config where number=%s",1);
if(!$db->query($querystring) && $db->next_record())
$filebase = $db->record["filebase"];
/* Test in die Datei schreiben */
if($filename && $knopf=="Speichern") {
$fullpath = $filebase .'/'. $filename;
$fd=fopen($fullpath, "w");
fwrite($fd, stripslashes($filecontent));
fclose($fd);
}
/* Datei in den Editor laden */
if($path != '') $fullpath = $filebase .'/'. $path;
if(file_exists($fullpath)){
$fd=fopen($fullpath, "r");
$filecontent=fread($fd, filesize($fullpath));
fclose($fd);
$filename = $path;
} elseif(file_exists($filebase .'/'. $filename) && ($knopf=="Laden" || $knopf=="Speichern")){
$fullpath = $filebase .'/'. $filename;
echo "<hr>". $fullpath ."<hr>"; $filename;
$fd=fopen($fullpath, "r");
$filecontent=fread($fd, filesize($fullpath));
fclose($fd);
}
$filecontent=stripslashes($filecontent);
echo "<table>";
/* Dateiname festlegen */
echo "<form method=post action=$PHP_SELF>";
echo "<tr><td>";
echo "<select name=filename>\n";
$handle=opendir ($filebase);
while (false !== ($file = readdir ($handle))) {
if(($file) == $filename){
printf("<option selected>%s\n", $file);
} else {
printf("<option>%s\n", $file);
}
}
closedir($handle);
echo "</select>\n";
// echo "<input type=hidden name=filecontent value=\"". addslashes($filecontent) . "\">";
echo "<input type=hidden name=pfile value=\"". $pfile . "\">";
echo "<input type=hidden name=number value=\"". $number . "\">";
echo "<input type=submit name=knopf value=Laden>";
echo "<input type=submit name=knopf value=Speichern>";
echo "</td></tr>\n<tr><td>";
// $filecontent=stripslashes($filecontent);
/* Dateiname festlegen */
printf("<TEXTAREA NAME=filecontent WRAP=VIRTUAL " .
"COLS=60 ROWS=10>%s</TEXTAREA>\n", $filecontent);
echo "</form>";
echo "</td></tr></table>\n";
$db->close();
/* End HTML PAGE */
echo "</BODY></HTML>";
?>