WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Simple way to replace a variable value in a .conf (.ini) file using a webbrowser - the first stage of a complete universal configuration editor
Categories : PHP, Regexps, Code Editors, Filesystem Update Picture
Andy Krause
Date : Nov 22nd 2000
Grade : Be the 1st to grade this Code Example
Viewed : 8259
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Andy Krause
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

As I found thousands of sample how to use ereg, replace and file functions, but no proper
answer on how to edit a config-file (I became too so lazy to manually edit all this stuff :)), I
wrote some code myself and the first part is here.

Usage: http://confedit.php?
strCfgFile=YOUR_CONFIG_FILE&strCfgVar=THE_VAR_TO_MODIFY&strCfgVal=THE_NEW_VALUE

Here's the content for confedit.php:

------ CUT ----------------

<?

$strOldContent = file ($strCfgFile);
$strNewContent = "";
while (list ($intLineNum, $strLine) = each ($strOldContent))
{
if(!eregi("^//",$strLine)) // dont show any line commented with //
{
if(eregi("^\\$".$strCfgVar."( |\t)*=",$strLine))         // show any line beginning with a $
{
$strLineParts=explode("=",$strLine);

// here we should have to determine type of value! (BOOL, INT or String)

if("$".$strCfgVar == trim($strLineParts[0]))
        {
        $strLineParts[1] = "\t\"".$strCfgVal."\"";
        $strLine = implode("=",$strLineParts).";\r\n";
        }
}
}
$strNewContent .= $strLine;
$fp = fopen($strCfgFile."_new", "w");
fputs($fp,$strNewContent);
fclose($fp);
}
copy($strCfgFile."_new",$strCfgFile);

echo "<pre>The value for <b>$$strCfgVar</b> has been replaced with <b>$strCfgVal</b> in
File <b>$strCfgFile</b></pre>";

?>

----- End CUT ----

As I did not have the time yet to explore all power of regular expressions, I dont mind, a Guru
finding a more elegant solution for the first two ereg-statement to merge them.

Otherwise, this little script will end up in a complete app, with which one can (finally) simply
configure and setup all kind of php-apps, which require many times heavy editing.

The full version will include form-based editing. Any comments are very welcome, esp. hints, if
such script already exists (could save me more time ;)

Enjoy


n-dee (aka ARK)


?>



Massreplace
Categories : Filesystem, Regexps, Strings, PHP
Show Source with Line Numbers
Categories : PHP, Regexps, Filesystem
A simple configuration file editor to ease you life in setting up php applications. Reads variables from a given file automatically and displays current value. New value will be written to file after submit.
Categories : PHP, Filesystem, Regexps, Java Script
file class , uploade file , download file already uploaded on another website
Categories : PHP, PHP Classes, Filesystem, Web Services
include php3 files
Categories : Filesystem, PHP, Apache, Web Servers
List the content of the directory of your webserver where this small PHP Script resides.
Categories : PHP, Filesystem, Directories, CSS
PHPBrowser - browsing linux file systems.
Categories : PHP, Linux, Filesystem
This is a simple photo gallery that reads the image files from multiple directories, and generates a web page styled with CSS1. It opens single auto window to view and print a given image.
Categories : Graphics, Filesystem, PHP, Complete Programs
PHP Youtube Downloader - This is a set of PHP functions that can be used to download movies from Youtube.com.
Categories : PHP, CURL, Regexps
Recursive function to move files on a filesystem. It can be minor changed in order to copy recursively.
Categories : PHP, Filesystem, Algorithms
Remote File Saving with PHP - Download and serve a remote file. The content of the file will be updated at fixed intervals.
Categories : PHP, Filesystem, Cache, Sockets, HTTP
Newbie Notes #7 - Ridiculous regex
Categories : PHP, Beginner Guides, Regexps
Simple PHP program which calls other PHP program you can pass the variables to other PHP program : by Raju
Categories : PHP, PHP Options and Info, Regexps, Program Execution
grab directory listings into an array the example prints out each subdirectory in the main dir - further work is to be performed on this one
Categories : Filesystem, PHP, Directories, Search, Utilities
A function which places the path and name of all subdirectories into an array
Categories : PHP, Filesystem, Arrays, Directories
 Andy Krause wrote :481
stupid me - 
the first eregi-statement is not necessary, if I just want to parse all lines starting with a "$".

n-dee