Lost Password?


Go Back   CodeCall Programming Forum > Web Development Forum > PHP Forum

PHP Forum Use this forum to discuss all aspects of PHP Development. PHP is a server-side, cross-platform, HTML embedded scripting language that lets you create dynamic web pages.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-12-2007, 11:28 AM
111222 111222 is offline
Newbie
 
Join Date: Sep 2007
Posts: 5
Rep Power: 0
111222 is on a distinguished road
Exclamation help me solve a file edit problem

how can i make the php to open a file, search a specific sentance in it, replace it to another sentance, and then save the file automaticly without "777 command".
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 12-12-2007, 12:21 PM
Jordan's Avatar   
Jordan Jordan is offline
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 9,203
Last Blog:
Ext JS or Ext GWT
Rep Power: 20
Jordan is just really niceJordan is just really niceJordan is just really niceJordan is just really nice
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default

PHP Code:
//To open/read file contents:
$myFile "filename.ext";
$fh fopen($myFile'r');
$data fread($fh9999999);
fclose($fh);

//Search the data and replace a string:
$data str_replace("STRING HERE""REPLACE HERE"$data);

//To write to a file:
$myFile "filename.ext";
$fh fopen($myFile'a');
fwrite($fh$data);
fclose($fh); 
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog
The CodeCall Wiki is now fully integrated with vBulletin users! Check it out and add some new pages!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 12-12-2007, 12:25 PM
Jordan's Avatar   
Jordan Jordan is offline
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 9,203
Last Blog:
Ext JS or Ext GWT
Rep Power: 20
Jordan is just really niceJordan is just really niceJordan is just really niceJordan is just really nice
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default

Here is better code:

PHP Code:
//To open/read file contents:
$myFile "filename.ext";
$fh fopen($myFile'r+');
$data fread($fh9999999);

//Search the data and replace a string:
$data str_replace("STRING HERE""REPLACE HERE"$data);

//To write to a file:
fwrite($fh$data);
fclose($fh); 
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog
The CodeCall Wiki is now fully integrated with vBulletin users! Check it out and add some new pages!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 12-12-2007, 02:01 PM
111222 111222 is offline
Newbie
 
Join Date: Sep 2007
Posts: 5
Rep Power: 0
111222 is on a distinguished road
Default

i sayed witout 777 commend.
when i do your programing
i get permission dineded
i have 644 commend.

Last edited by 111222; 12-12-2007 at 02:15 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 12-12-2007, 02:03 PM
NeedHelp NeedHelp is offline
Programming God
 
Join Date: May 2006
Posts: 527
Rep Power: 13
NeedHelp is on a distinguished road
Default

That is an OS issue, not a PHP issue. You say 777 command you need to either be the user that owns the file or in the group that owns the directory or chmod the file to '777'.
__________________
I Need Help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 12-12-2007, 02:07 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,433
Last Blog:
Google Web Toolkit
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default

I' pretty sure you can do this using the FTP wrapper along with some file system functions.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 12-12-2007, 02:17 PM
111222 111222 is offline
Newbie
 
Join Date: Sep 2007
Posts: 5
Rep Power: 0
111222 is on a distinguished road
Default

hah!? you dont helped me.
i want it to edit the file without commend it (the orginal commend is 644)
plez give me a script to edit the file with the orginal commend (644)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 12-12-2007, 02:18 PM
NeedHelp NeedHelp is offline
Programming God
 
Join Date: May 2006
Posts: 527
Rep Power: 13
NeedHelp is on a distinguished road
Default

The file system commands will still not help him if he doesn't own the file (doesn't have write permission).
__________________
I Need Help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 12-12-2007, 02:59 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,433
Last Blog:
Google Web Toolkit
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default

Well if he doesn't own the file, it is impossible to write or execute that file. That's why permissions exist.

However he never said he didn't own the file. Assuming he uploaded the file, the FTP user does own the file and has mod 6 - meaning he can read (4) and (+) write (2). The php user only has a mod of 4 meaning he can only read. Which is why, using the file system commands with the php user will not work, but using the file system commands with the FTP user will...
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall

Last edited by John; 12-12-2007 at 03:02 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 12-12-2007, 03:07 PM
111222 111222 is offline
Newbie
 
Join Date: Sep 2007
Posts: 5
Rep Power: 0
111222 is on a distinguished road
Default

i own the file!!! i just want to edit it without givin him a command.
how can i do that?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Project: ionFiles - Joomla Simple File Download Jordan Community Projects 324 11-10-2008 08:34 PM
Project: ionFiles - Joomla Simple File Download - Mirror 2 Jordan ionFiles 6 11-06-2008 01:24 PM
Windows XP Tricks & Tips!!!!..new ones. pranky Tutorials 9 08-23-2008 04:22 PM
can you solve this problem with java kadriatil Java Help 6 05-29-2007 09:17 AM
Weird problem with code, functions when not suppose to Murph-s C and C++ 0 05-14-2007 08:11 PM


All times are GMT -5. The time now is 06:10 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 97%

Ads