Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: jak się pozbyć "enterów"?
Forum PHP.pl > Forum > Przedszkole
ga-cek
Używam skryptu do edycji plików o następuj±cym kodzie:

Kod 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<?php

$LOGIN 
"admin\";
$PASSWORD = \"demo\";

function error ($error_message) {
    echo $error_message.\"<BR>\";
    exit;
}

if ( (!isset($PHP_AUTH_USER)) || ! (($PHP_AUTH_USER == $LOGIN) && ( $PHP_AUTH_PW == \"$PASSWORD\" )) ) {
    header(\"WWW-Authenticate: Basic entrer=\"Form2txt admin\"\");
    header(\"HTTP/1.0 401 Unauthorized\");
    error(\"Brak uprawnień...\");
}
?>

<?php
function iso ($in) {$out = strtr($in, "
ˇ±ŃńŁł¦¶Ććę¬ĽŻż\"\"·&plusmn;ŃńŁł&brvbar;Ććꥯż\");
  return $out;
}
?>

<?php
set_magic_quotes_runtime(0);

function show_header($title)
{
    print 
\"<HTML>\n\";
    print 
\"<HEAD>\n\";
    print 
\"<TITLE>$title</TITLE>\n\";
    print 
\"</HEAD>\n\";
    print 
\"<BODY BGCOLOR=\"#FFFFFF\">\n\";
}

function show_footer()
{
    ?>
    </BODY>
    </HTML>
    <?php
}

function check_ext($filename)
{
    $extns = array(
\"html\",\"htm\",\"shtml\",\"php\",\"phps\",\"css\",\"txt\",\"text\",\"js\");
    $fileext = substr($filename,strrpos($filename,'.'),strlen($filename));

    while(list($id,$ext) = each($extns))
    
{
  $ext = 
\".$ext\";
  if($ext == $fileext)
  
{
  return 1;
  
}
    
}
    return 0;
}

function get_dir_list($directory)
{
    $files = array();
    $numfiles = 0;

    $handle=opendir($directory);

    while($file = readdir($handle))
    
{
  if($file != 
\".\")
  
{
      if((($directory != 
\".\")||($file != \"..\"))&&(($directory != \".\")||($file != \"data\")))
      
{
    if(is_file($file) && check_ext($file))
    
{
    $files
[$numfiles] = $file;
    $numfiles++;
    
}
      
}
  
}
    
}

    sort($files);

    reset($files);

    return $files;
}

$hasaccess = 1;

if(!$hasaccess)
{
    // Show Access denied error here
}
else
{
    $action = (isset($action) ? $action : 
\"\");

    switch($action)
    
{
    case 
\"new\":
    case 
\"edit\":
  if(isset($file))
  
{
      show_header(
\"Web Editor ( '\".$file.\"' )\");
      $filedata = join(
\"\",file($file));
      $filedata = htmlspecialchars($filedata);
      print 
\"<FONT SIZE=\"+1\">Editing $file</FONT>\n\";
      print 
\"<FORM METHOD=\"POST\" ACTION=\"webedit.php\">\n\";    
      print 
\"<INPUT TYPE=\"hidden\" NAME=\"file\" VALUE=\"\".(isset($file) ? $file : \"\").\"\">\n\";    
  
}
  else
  
{
      show_header(
\"Web Editor ( 'Untitled' )\");
      $filedata = 
\"\";
      print 
\"<FONT SIZE=\"+1\">Editing new file</FONT>\n\";
      print 
\"<FORM METHOD=\"POST\" ACTION=\"webedit.php\">\n\";    
      print 
\"Filename: <INPUT TYPE=\"text\" NAME=\"file\" VALUE=\"Untitled\">\n\";    
      print 
\"<BR>\n\";    
  
}

  print 
\"<INPUT TYPE=\"hidden\" NAME=\"action\" VALUE=\"save\">\n\";    
  print 
\"<TEXTAREA NOWRAP WRAP=\"off\" STYLE=\"display: block; white-space: pre;\" NAME=\"filecontent\" ROWS=20 COLS=55 NOWRAP>\n\";
  print $filedata;
  print 
\"</TEXTAREA>\n\";
  print 
\"<TABLE BORDER=0>\n\";
  print 
\"<TR>\n\";
  print 
\"<TD>\n\";
  print 
\"<INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Save\">\n\";    
  print 
\"</FORM>\n\";
  print 
\"</TD>\n\";
  print 
\"<TD>\n\";
  print 
\"<FORM METHOD=\"POST\" ACTION=\"webedit.php\">\n\";

  if(isset($file))
  
{
      print 
\"<INPUT TYPE=\"hidden\" NAME=\"file\" VALUE=\"\".(isset($file) ? $file : \"\").\"\">\n\";    
  
}
  
  print 
\"<INPUT TYPE=\"hidden\" NAME=\"action\" VALUE=\"cancel\">\n\";
  print 
\"<INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Cancel\">\n\";    
  print 
\"</FORM>\n\";
  print 
\"</TD>\n\";
  print 
\"</TR>\n\";
  print 
\"</TABLE>\n\";
  show_footer();
  break;
    case 
\"rename\":
  show_header(
\"Online Web Editor\");
  print 
\"Renaming: $file\n\";
  print 
\"<FORM METHOD=\"POST\" ACTION=\"webedit.php\">\n\";
  print 
\"New Name: <INPUT TYPE=\"text\" NAME=\"newfile\" SIZE=\"20\"VALUE=\"\">\n\";    
  print 
\"<BR><BR>\n\";
  print 
\"<TABLE BORDER=0 CELLSPACING=4 CELLPADDING=0>\n\";
  print 
\"<TR>\n\";
  print 
\"<TD ALIGN=\"center\" VALIGN=\"middle\">\n\";
  print 
\"<INPUT TYPE=\"hidden\" NAME=\"file\" VALUE=\"\".(isset($file) ? $file : \"\").\"\">\n\";    
  print 
\"<INPUT TYPE=\"hidden\" NAME=\"action\" VALUE=\"rename-check\">\n\";
  print 
\"<INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Rename\">\n\";    
  print 
\"</TD>\n\";
  print 
\"</FORM>\n\";
  print 
\"<FORM METHOD=\"POST\" ACTION=\"webedit.php\">\n\";    
  print 
\"<TD ALIGN=\"center\" VALIGN=\"middle\">\n\";
  print 
\"<INPUT TYPE=\"hidden\" NAME=\"file\" VALUE=\"\".(isset($file) ? $file : \"\").\"\">\n\";    
  print 
\"<INPUT TYPE=\"hidden\" NAME=\"action\" VALUE=\"cancel\">\n\";
  print 
\"<INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Cancel\">\n\";    
  print 
\"</TD>\n\";
  print 
\"</FORM>\n\";
  print 
\"</TR>\n\";
  print 
\"</TABLE>\n\";
  show_footer();
  break;
    case 
\"delete\":
  show_header(
\"Online Web Editor\");
  print 
\"<CENTER>\n\";
  print 
\"<FONT SIZE=\"+1\">Are you sure you want to permanently remove the file $file?</FONT>\n\";
  print 
\"<CENTER>\n\";
  print 
\"<TABLE BORDER=0>\n\";
  print 
\"<TR>\n\";
  print 
\"<TD>\n\";
  print 
\"<FORM METHOD=\"POST\" ACTION=\"webedit.php\">\n\";    
  print 
\"<TD ALIGN=\"center\" VALIGN=\"middle\">\n\";
  print 
\"<INPUT TYPE=\"hidden\" NAME=\"file\" VALUE=\"\".(isset($file) ? $file : \"\").\"\">\n\";  
  print 
\"<INPUT TYPE=\"hidden\" NAME=\"action\" VALUE=\"delete-ok\">\n\";
  print 
\"<INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Yes\">\n\";    
  print 
\"</TD>\n\";
  print 
\"</FORM>\n\";
  print 
\"<FORM METHOD=\"POST\" ACTION=\"webedit.php\">\n\";    
  print 
\"<TD ALIGN=\"center\" VALIGN=\"middle\">\n\";
  print 
\"<INPUT TYPE=\"hidden\" NAME=\"file\" VALUE=\"\".(isset($file) ? $file : \"\").\"\">\n\";    
  print 
\"<INPUT TYPE=\"hidden\" NAME=\"action\" VALUE=\"cancel\">\n\";
  print 
\"<INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"No\">\n\";    
  print 
\"</TD>\n\";
  print 
\"</FORM>\n\";
  print 
\"</TR>\n\";
  print 
\"</TABLE>\n\";
  print 
\"</CENTER>\n\";
  show_footer();
  break;
    case 
\"delete-ok\":
  if(file_exists($file))
  
{
  unlink($file);
  
}
    case 
\"rename-check\":
    case 
\"rename-ok\":
  if(isset($file) && isset($newfile))
  
{
      if((file_exists($newfile))&&($action != 
\"rename-ok\"))
      
{
      show_header(
\"Online Web Editor\");
      print 
\"<CENTER>\n\";
      print 
\"<FONT SIZE=\"+1\">The file $newfile aready exists. If you rename $file to $newfile, $newfile wil be destroyed! Do you want to continue?</FONT>\n\";
      print 
\"<CENTER>\n\";
      print 
\"<TABLE BORDER=0>\n\";
      print 
\"<TR>\n\";
      print 
\"<TD>\n\";
      print 
\"<FORM METHOD=\"POST\" ACTION=\"webedit.php\">\n\";    
      print 
\"<TD ALIGN=\"center\" VALIGN=\"middle\">\n\";
      print 
\"<INPUT TYPE=\"hidden\" NAME=\"file\" VALUE=\"\".(isset($file) ? $file : \"\").\"\">\n\";    
      print 
\"<INPUT TYPE=\"hidden\" NAME=\"newfile\" VALUE=\"$newfile\">\n\";    
      print 
\"<INPUT TYPE=\"hidden\" NAME=\"action\" VALUE=\"rename-ok\">\n\";
      print 
\"<INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Yes\">\n\";    
      print 
\"</TD>\n\";
      print 
\"</FORM>\n\";
      print 
\"<FORM METHOD=\"POST\" ACTION=\"webedit.php\">\n\";    
      print 
\"<TD ALIGN=\"center\" VALIGN=\"middle\">\n\";
      print 
\"<INPUT TYPE=\"hidden\" NAME=\"file\" VALUE=\"\".(isset($file) ? $file : \"\").\"\">\n\";    
      print 
\"<INPUT TYPE=\"hidden\" NAME=\"action\" VALUE=\"rename\">\n\";
      print 
\"<INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"No\">\n\";    
      print 
\"</TD>\n\";
      print 
\"</FORM>\n\";
      print 
\"</TR>\n\";
      print 
\"</TABLE>\n\";
      print 
\"</CENTER>\n\";
      show_footer();
      break;
      
}
      else
      
{
    if(file_exists($newfile))
    
{
    unlink($newfile);
    
}
    copy($file,$newfile);
    unlink($file);
      
}
  
}
    case 
\"save\":
    case 
\"cancel\":
    default:
  if(isset($file)&&($action == 
\"save\"))
  
{
      $filecontent = stripslashes($filecontent);
      $filehandle = fopen($file,
\"w\");
      $filecontent=iso($filecontent);
      fwrite($filehandle,$filecontent);      
      fclose($filehandle);
  
}
  show_header(
\"Online Web Editor\");
  $files = get_dir_list(
\".
ga-cek
A gdzie to dorzucić, znaczy wstawić? :-)
rogrog
przy odczycie danych z pliku przepusc je przez trim" title="Zobacz w manualu PHP" target="_manual
ga-cek
Kombinuje i nic z tego nie wychodzi. Wstawiłam pomiędzy $filehandle = fopen($file,"w"); i $filecontent=iso($filecontent);
  1. <?php
  2.  
  3. echo trim($file);  
  4. echo trim($file, &#092;" rn.\");
  5. $clean = trim($binary, &#092;"x00..x1F\");
  6.  
  7. ?>

i pewnie nie w tym miejscu bo nie działa sad.gif
Prosiłabym o pomoc...
Pozdr.
To jest wersja lo-fi głównej zawarto¶ci. Aby zobaczyć pełn± wersję z większ± zawarto¶ci±, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.