Forum

> > Off Topic > Online Sourcecode ändern
Forums overviewOff Topic overviewLog in to reply

German Online Sourcecode ändern

3 replies
To the start Previous 1 Next To the start

old Online Sourcecode ändern

Stranded_fan
User Off Offline

Quote
Ich weiß nicht ob ihr den Titel versteht, aber:

Ich möchte ein Textfeld auf meinen Server setzten, mit welchem ich per PHP andere Sourcodes ändern kann, halt n online editor. Ist glaub ich am besten, wenn ich mal die Source poste:

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
<?
session_start();
?>

<html>
	<head>
		<title>Online Sourcecode changing menu</title>
	</head>
	
	<body>
		<?
		
		if(session_is_registered('logedin') && $_SESSION['logedin']) {
		?>
		<form action="admin.php" method="get">
			<select name="file">
				<option name="../head.php">../head.php</option>
				<option name="../left.php">../left.php</option>
				<option name="../index.php">../index.php</option>
				<option name="../index2.php">../index2.php</option>
				<option name="../navi.php">../navi.php</option>
			</select>
			
			<input name="save" type="submit" value="Datei wählen">
		</form>
		
		<form action="admin.php" method="post">
			<textarea name="code" cols="120" rows="25">
			<?
			if(isset($_GET['file'])) {
				$array = file($_GET['file']);
				for($x=0;$x<count($array);$x++){
					echo $array[$x];  
				}
			}
			?>
			</textarea>
			
			<input name="save" type="submit" value="Speichern">
			<input type="hidden" name="file" value="<? echo $_GET['file']; ?>">
		</form>
		
		<?
			if(!(isset($_POST['save'])&&isset($_POST['file']))) {
				$f = fopen($_POST['file'],"r+");
				
				fputs($f,$_POST['code']);
				
				fclose($f);
			}
		
		} else {
			echo "You are not authorized!";
		}
		?>
	</body>
</head>

er übernimmt das nach dem Speichern nicht.

Your timmeTheOnly

old Re: Online Sourcecode ändern

jeepohahyo
User Off Offline

Quote
Das ist total wurscht, jedenfalls bei der üblichen Serverkonfiguration.

Ich habe das Gefühl, dass das an der Bedingung beim if liegt.
Es wird nur gespeichert, wenn entweder save oder file nicht übergeben werden

not (false and true) == not false == true
wäre das dann, was ja aber wohl nicht gewünscht ist...

old Re: Online Sourcecode ändern

bizzl
User Off Offline

Quote
Klara has written
Gröbstens überflogen sage ich mal: PHP beginnt mit

<?php

und nicht mit

<?

php kann sehr wohl mit <? beginnen, auch wenn es schlechter stil ist.
Siehe dazu SelfPHP


@Strandedfan: probier eventuell mal "w" statt "r+":
1
$f = fopen($_POST['file'],"w");
To the start Previous 1 Next To the start
Log in to replyOff Topic overviewForums overview