editing files

  • Rabid Dog
  • Web Master
  • Web Master
  • User avatar
  • Joined: May 21, 2004
  • Posts: 3229
  • Loc: South Africa
  • Status: Offline

Post December 22nd, 2004, 1:06 am

LEave it at post and change the following code
PHP Code: [ Select ]
 
$file = $_GET['file'];
 
$buffer = $_GET['buffer'];
 
$backup = $_GET['backup'];
 
 
 
$handle = fopen("page/$file", "a");
 
fwrite($handle, $buffer);
 
fclose($handle);
 
 
 
if($backup == 1) {
 
$handle = fopen("page/backup/$file", "a");
 
fwrite($handle, $buffer);
 
fclose($handle);
 
}
 
 
  1.  
  2. $file = $_GET['file'];
  3.  
  4. $buffer = $_GET['buffer'];
  5.  
  6. $backup = $_GET['backup'];
  7.  
  8.  
  9.  
  10. $handle = fopen("page/$file", "a");
  11.  
  12. fwrite($handle, $buffer);
  13.  
  14. fclose($handle);
  15.  
  16.  
  17.  
  18. if($backup == 1) {
  19.  
  20. $handle = fopen("page/backup/$file", "a");
  21.  
  22. fwrite($handle, $buffer);
  23.  
  24. fclose($handle);
  25.  
  26. }
  27.  
  28.  


to
PHP Code: [ Select ]
 
$file = $_GET['file'];
 
$buffer = $_POST['buffer'];
 
$backup = $_POST['backup'];
 
 
 
$handle = fopen("page/$file", "w");
 
fwrite($handle, $buffer);
 
fclose($handle);
 
 
 
if($backup == 1) {
 
$handle = fopen("page/backup/$file", "w");
 
fwrite($handle, $buffer);
 
fclose($handle);
 
}
 
 
  1.  
  2. $file = $_GET['file'];
  3.  
  4. $buffer = $_POST['buffer'];
  5.  
  6. $backup = $_POST['backup'];
  7.  
  8.  
  9.  
  10. $handle = fopen("page/$file", "w");
  11.  
  12. fwrite($handle, $buffer);
  13.  
  14. fclose($handle);
  15.  
  16.  
  17.  
  18. if($backup == 1) {
  19.  
  20. $handle = fopen("page/backup/$file", "w");
  21.  
  22. fwrite($handle, $buffer);
  23.  
  24. fclose($handle);
  25.  
  26. }
  27.  
  28.  


and change your form tag to
PHP Code: [ Select ]
 
echo "<form name='edit' method='post' action='writeFile.php?file=$file'>";
 
 
  1.  
  2. echo "<form name='edit' method='post' action='writeFile.php?file=$file'>";
  3.  
  4.  
Watch me grow
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post December 22nd, 2004, 1:06 am

  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Joined: May 22, 2004
  • Posts: 3415
  • Loc: Richland, WA
  • Status: Offline

Post December 22nd, 2004, 1:20 am

well eveything works fine exect that its making me make
PHP Code: [ Select ]
<?
 
$file = $_POST['file'];
 
$path = "page/" . $file;
 
 
 
echo("
 
<center>
  1. <?
  2.  
  3. $file = $_POST['file'];
  4.  
  5. $path = "page/" . $file;
  6.  
  7.  
  8.  
  9. echo("
  10.  
  11. <center>


to

PHP Code: [ Select ]
<?
 
$file = $_GET['file'];
 
$path = "page/" . $file;
 
 
 
echo("
 
<center>
  1. <?
  2.  
  3. $file = $_GET['file'];
  4.  
  5. $path = "page/" . $file;
  6.  
  7.  
  8.  
  9. echo("
  10.  
  11. <center>

But i dont know if this is just the tag but i get these errors

Quote:
Warning: fopen(page/header.inc): failed to open stream: Permission denied in /home/loshas/public_html/writeFile.php on line 6

Warning: fwrite(): supplied argument is not a valid stream resource in /home/loshas/public_html/writeFile.php on line 7

Warning: fclose(): supplied argument is not a valid stream resource in /home/loshas/public_html/writeFile.php on line 8


I went in and changed the permision on a file and it let me edit it. Is there a way to make it so when you create a file it gives the permission 777?
#define NULL (::rand() % 2)
  • Rabid Dog
  • Web Master
  • Web Master
  • User avatar
  • Joined: May 21, 2004
  • Posts: 3229
  • Loc: South Africa
  • Status: Offline

Post December 22nd, 2004, 1:24 am

I think it gets the permissions from the folder
Watch me grow
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Joined: May 22, 2004
  • Posts: 3415
  • Loc: Richland, WA
  • Status: Offline

Post December 22nd, 2004, 1:28 am

the folder is set to 777 but all the files but the ones i changed are at 644
#define NULL (::rand() % 2)
  • Rabid Dog
  • Web Master
  • Web Master
  • User avatar
  • Joined: May 21, 2004
  • Posts: 3229
  • Loc: South Africa
  • Status: Offline

Post December 22nd, 2004, 1:32 am

how are the files getting into the directory? Are you manually uploading them or are they being uploaded via a web browser?
Watch me grow
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Joined: May 22, 2004
  • Posts: 3415
  • Loc: Richland, WA
  • Status: Offline

Post December 22nd, 2004, 1:51 am

they are being manualy uploaded, the web and there being created and they all have 644
#define NULL (::rand() % 2)
  • Rabid Dog
  • Web Master
  • Web Master
  • User avatar
  • Joined: May 21, 2004
  • Posts: 3229
  • Loc: South Africa
  • Status: Offline

Post December 22nd, 2004, 1:59 am

well php has a chmod function
so you will do something like
PHP Code: [ Select ]
 
$file = $_GET['file'];
 
$buffer = $_POST['buffer'];
 
$backup = $_POST['backup'];
 
 
 
 
 
if (!is_writeable("page/$file")) {
 
    chmod("page/$file",0777); //according to PHP manual the mode most be octal
 
}
 
$handle = fopen("page/$file", "w");
 
fwrite($handle, $buffer);
 
fclose($handle);
 
 
 
if($backup == 1) {
 
$handle = fopen("page/backup/$file", "w");
 
fwrite($handle, $buffer);
 
fclose($handle);
 
}
 
 
  1.  
  2. $file = $_GET['file'];
  3.  
  4. $buffer = $_POST['buffer'];
  5.  
  6. $backup = $_POST['backup'];
  7.  
  8.  
  9.  
  10.  
  11.  
  12. if (!is_writeable("page/$file")) {
  13.  
  14.     chmod("page/$file",0777); //according to PHP manual the mode most be octal
  15.  
  16. }
  17.  
  18. $handle = fopen("page/$file", "w");
  19.  
  20. fwrite($handle, $buffer);
  21.  
  22. fclose($handle);
  23.  
  24.  
  25.  
  26. if($backup == 1) {
  27.  
  28. $handle = fopen("page/backup/$file", "w");
  29.  
  30. fwrite($handle, $buffer);
  31.  
  32. fclose($handle);
  33.  
  34. }
  35.  
  36.  


Let me know if that works
Watch me grow
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Joined: May 22, 2004
  • Posts: 3415
  • Loc: Richland, WA
  • Status: Offline

Post December 22nd, 2004, 2:10 am

nah that doesnt work i get the error

Quote:
Warning: chmod(): Operation not permitted in /home/loshas/public_html/writeFile.php on line 9


but then i just found out that you can edit 644 permission, dont get why it errored me before. So it looks like everything here is DONE! finaly, i though it would never end. Thank you once again. eveything is worken just fine.
#define NULL (::rand() % 2)
  • Rabid Dog
  • Web Master
  • Web Master
  • User avatar
  • Joined: May 21, 2004
  • Posts: 3229
  • Loc: South Africa
  • Status: Offline

Post December 22nd, 2004, 2:13 am

So the chmod works in PHP?
Watch me grow
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Joined: May 22, 2004
  • Posts: 3415
  • Loc: Richland, WA
  • Status: Offline

Post December 22nd, 2004, 2:24 am

no it didnt work, and now i need it, this is weird sometimes it lets you edit 644 files then it doesn't
#define NULL (::rand() % 2)

Post Information

  • Total Posts in this topic: 25 posts
  • Users browsing this forum: No registered users and 230 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.