/    Sign up×
Community /Pin to ProfileBookmark

I have this script (from apache):

[code=php]<?php
$WINDIR = $_SERVER[“WINDIR”];
$uri = $_SERVER[“PHP_SELF”];
$date = date(“Ymd0000”);
$realdate = date(“Y.m.d”);

preg_match (“/^.*?@(.*)$/”,$_SERVER[“SERVER_ADMIN”],$domain);
$curdomain = $domain[1];

$a = array (“Editing”,”a.html”);

#only required if Register globals is off
if($_GET[‘load’]){ $load=$_GET[‘load’]; }
if($_GET[‘feed’]){ $feed=$_GET[‘feed’]; }

$mesage = ${$load}[0];
$path = ${$load}[1];
$file = $path;
$feed = stripslashes($feed);

if($_GET[‘action’] == “write”){
$mesg = “Written modifications to $file”;
write_file($feed,$file);
}

$fhr = fopen(“$file”, “r”);
$data = fread($fhr,filesize($file));
fclose ($fhr);

function write_file($feed,$file){
$fhw = fopen(“$file”, “w”);
$ok = fwrite ($fhw,”$feed”);
fclose ($fhw);
}

?>

<html>
<title>Editing : <?php echo $mesage; ?></title>
<link rel=stylesheet href=style.css>
<center>
<p><font size=5><?php echo $mesage; ?></font></p>
<font color=red>This allows for remote editing of config files</font><br>
You are editing : <b><?php echo $file; ?></b>&nbsp;<?php echo $mesg; ?><br>

<form name=”form” method=”post” action=”<?php echo “{$uri}?load={$load}&action=write”; ?>”>
<textarea class=input name=”feed” cols=”130″ rows=”30″ wrap=”OFF”><?php echo $data; ?></textarea>
<br><input class=submit type=”submit” value=”Write to file”>
</form>

</center>
</html>[/code]

And I want to change this line:

[code=php]$a = array (“Editing”,”a.html”);[/code]

And i don`t know how.
I wanna make something that if I write at address [B][url]http://host/script.php?load=index.php[/url] to edit index.php
[url]http://host/script.php?load=safaj.html[/url] to edit safaj.html[/B]

But I don`t want to set the variables.
I don`
t know haw to eplain what I want, if you don`t understand I`ll try to explain again.

to post a comment
PHP

13 Comments(s)

Copy linkTweet thisAlerts:
@benifactorMay 02.2007 — try this....

[code=php]
$a = array ("Editing", $load);
[/code]


or

[code=php]
$a = array ("Editing", $_GET['load']);
[/code]
Copy linkTweet thisAlerts:
@bibistrocauthorMay 02.2007 — I dont understad what I want.<br/>
I wan
t to don`t set the variable $a.

This is what I want:

if $a = index.html to edit index.html

if $a = download.html to edit download.html

I wanna set the variabel $a with the world in the adrees: http://host/script.php?load=[U]thisworld[/U] .
Copy linkTweet thisAlerts:
@benifactorMay 02.2007 — did you try what i gave you?????
Copy linkTweet thisAlerts:
@benifactorMay 02.2007 — by replacing "a.html" with $_GET['load'] will give the variable $a a dynamic value that will change everytime you change the url.

for example:

www.website.com/?load=index.html : $a = index.html

www.website.com/?load=another.html : $a = another.html


www.website.com/?load=notA.html : $a = notA.html

is that what you are wanting?
Copy linkTweet thisAlerts:
@bibistrocauthorMay 02.2007 — This is the script:

[code=php]<?php
$WINDIR = $_SERVER["WINDIR"];
$uri = $_SERVER["PHP_SELF"];
$date = date("Ymd0000");
$realdate = date("Y.m.d");

preg_match ("/^.*?@(.*)$/",$_SERVER["SERVER_ADMIN"],$domain);
$curdomain = $domain[1];

$a = array ("Editing", $_GET['load']);


#only required if Register globals is off
if($_GET['load']){ $load=$_GET['load']; }
if($_GET['feed']){ $feed=$_GET['feed']; }

$mesage = ${$load}[0];
$path = ${$load}[1];
$file = $path;
$feed = stripslashes($feed);

if($_GET['action'] == "write"){
$mesg = "Written modifications to $file";
write_file($feed,$file);
}

$fhr = fopen("$file", "r");
$data = fread($fhr,filesize($file));
fclose ($fhr);

function write_file($feed,$file){
$fhw = fopen("$file", "w");
$ok = fwrite ($fhw,"$feed");
fclose ($fhw);
}

?>

<html>
<title>Editing : <?php echo $mesage; ?></title>
<link rel=stylesheet href=style.css>
<center>
<p><font size=5><?php echo $mesage; ?></font></p>
<font color=red>This allows for remote editing of config files</font><br>
You are editing : <b><?php echo $file; ?></b>&nbsp;<?php echo $mesg; ?><br>

<form name="form" method="post" action="<?php echo "{$uri}?load={$load}&action=write"; ?>">
<textarea class=input name="feed" cols="130" rows="30" wrap="OFF"><?php echo $data; ?></textarea>
<br><input class=submit type="submit" value="Write to file">
</form>

</center>
</html>[/code]


This is the error:

Warning: fread(): supplied argument is not a valid stream resource in /home/www/free/uv.ro/bibitest.uv.ro/editor.php on line 28

Warning: fclose(): supplied argument is not a valid stream resource in /home/www/free/uv.ro/bibitest.uv.ro/editor.php on line 29
Copy linkTweet thisAlerts:
@bibistrocauthorMay 02.2007 — That is what i want but it doesn`t work ?
Copy linkTweet thisAlerts:
@bibistrocauthorMay 02.2007 — If i put this address: http://host/script.php?load=a,

I get this error:

Warning: fopen() [function.fopen]: Unable to access a in /home/www/free/uv.ro/bibitest.uv.ro/editor.php on line 27

Warning: fopen(a) [function.fopen]: failed to open stream: No such file or directory in /home/www/free/uv.ro/bibitest.uv.ro/editor.php on line 27

Warning: filesize() [function.filesize]: stat failed for a in /home/www/free/uv.ro/bibitest.uv.ro/editor.php on line 28

Warning: fread(): supplied argument is not a valid stream resource in /home/www/free/uv.ro/bibitest.uv.ro/editor.php on line 28

Warning: fclose(): supplied argument is not a valid stream resource in /home/www/free/uv.ro/bibitest.uv.ro/editor.php on line 29
Copy linkTweet thisAlerts:
@benifactorMay 02.2007 — that has nothing to do with the fix i gave you. it is a problem with your fopen/read/close. i am googling right now as i have never used these.
Copy linkTweet thisAlerts:
@benifactorMay 02.2007 — ahhh, it looks like you are trying to open a file, inside a file and it is not there. you need to go down a directory i believe.
Copy linkTweet thisAlerts:
@bibistrocauthorMay 02.2007 — Can you make this script works?

Please try to fix it.
Copy linkTweet thisAlerts:
@benifactorMay 02.2007 — try this man...


[code=php]
<?php
$WINDIR = $_SERVER["WINDIR"];
$uri = $_SERVER["PHP_SELF"];
$date = date("Ymd0000");
$realdate = date("Y.m.d");

preg_match ("/^.*?@(.*)$/",$_SERVER["SERVER_ADMIN"],$domain);
$curdomain = $domain[1];

$a = array ("Editing",$_GET['load']);


#only required if Register globals is off
if($_GET['load']){ $load=$_GET['load']; }
if($_GET['feed']){ $feed=$_GET['feed']; }

$mesage = $_GET['load'];
$path = "/";
$file = $_GET['load'];
$feed = stripslashes($feed);

if($_GET['action'] == "write"){
$mesg = "Written modifications to $file";
write_file($feed,$file);
}

$fhr = fopen("$file", "r");
$data = fread($fhr,filesize($file));
fclose ($fhr);

function write_file($feed,$file){
$fhw = fopen("$file", "w");
$ok = fwrite ($fhw,"$feed");
fclose ($fhw);
}

?>

<html>
<title>Editing : <?php echo $mesage; ?></title>
<link rel=stylesheet href=style.css>
<center>
<p><font size=5><?php echo $mesage; ?></font></p>
<font color=red>This allows for remote editing of config files</font><br>
You are editing : <b><?php echo $file; ?></b>&nbsp;<?php echo $mesg; ?><br>

<form name="form" method="post" action="<?php echo "{$uri}?load={$load}&action=write"; ?>">
<textarea class=input name="feed" cols="130" rows="30" wrap="OFF"><?php echo $data; ?></textarea>
<br><input class=submit type="submit" value="Write to file">
</form>

</center>
</html>
[/code]
Copy linkTweet thisAlerts:
@bibistrocauthorMay 02.2007 — Thx man is perfect.

?
Copy linkTweet thisAlerts:
@benifactorMay 02.2007 — no problem.
×

Success!

Help @bibistroc spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...