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 : set file ini class - Provides a simple ini-type settings file interface. Great for saving and reading variables quick between executions.
Categories : PHP, PHP Classes, Filesystem Click here to Update Your Picture
lalith nayak
Date : Jan 28th 2006
Grade : 1 of 5 (graded 1 times)
Viewed : 2731
File : No file for this code example.
Images : No Images for this code example.
Search : More code by lalith nayak
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

Type: class, text functions
Version: 1.0
Requires: PHP4 (uses "foreach", easily "back-ported")
Author: the mighty Indian



<?php if (! defined('lib_ini')) { define('lib_ini', true);

class
setfile
   
{
    var
$values;
    var
$filename;
     
    function
setfile($filename=false, $load=false)
        {
        if (
$filename)
            {
           
$this->filename=$filename;
            return
$this->read();
            }
         
        }

    function
write($filename=false)
        {
        if (!
$filename)
           
$filename=$this->filename;

        if (!isset(
$this->values) && !is_array($this->values))
            return
false;


        if (!
$f = @fopen($filename, 'w+'))
            return
false;
         
        while (!
flock($f, LOCK_EX))
            {
            if (
$ct++ >= 3)
                {
               
// Couldnt get an exclusive lock after 4 seconds.
               
fclose($f);                 
                return
false;
                }
           
sleep(1);
            }

        foreach(
$this->values as $k => $v)
            {
           
$tw = urlencode($k) . '=' . urlencode($v) . "rn";
           
fputs($f, $tw, strlen($tw));
            }

       
fclose($f);
        return
true;
        }
     
    function
read($filename=false)
        {
        if (!
$filename)
           
$filename=$this->filename;

        if (!
$lns = @file($filename))
            return
false;

        foreach(
$lns as $line)
            {
            list(
$k, $v)=explode('=', $line);
           
$this->values[urldecode($k)]=urldecode(chop($v));
            }
        return
true;
        }
    }
}
?> 


Usage Example

<?
$f
= new setfile('db.cfg', true);
echo
$f->values['hostname'];
$f->values['hostname']='somesite.com';
$f->write(); 
?>



PHP4 DirectoryIterator Class
Categories : PHP, PHP Classes, Filesystem, Directories
Class that allows the PHP developer to create and manage UNIX like password files suitable for use as Apache authentication password files.
Categories : HTTP, PHP, PHP Classes, Filesystem
Compare two texts and display a block of text with the differences between them.
Categories : PHP, PHP Classes, Filesystem, Strings, Arrays
3 lines of Code to extract Tar, Zip, Gzip etc..
Categories : PHP, Filesystem, PHP Classes, Compression
Remote Archive (Zip, Tar, Gzip) downloader with FTP and local extration support
Categories : PHP, FTP, Filesystem, PHP Classes, Compression
filesplit : Split big text files in multiple small ones
Categories : PHP, Log Files, Filesystem, PHP Classes
A File Browser Class.To Read Drives,Directories and Files .Files writing is also possible
Categories : PHP, PHP Classes, Filesystem
file class , uploade file , download file already uploaded on another website
Categories : PHP, PHP Classes, Filesystem, Web Services
Bs_IniHandler is a class that can read and write ini-style files (and strings)
Categories : PHP, Filesystem, PHP Classes
An efficient iterative and buffered text file reader
Categories : PHP, Classes and Objects, Filesystem, PHP Classes, Log Files
Search and Replace Text : Searches Files for Specified Text and Replaces It by a Given Text
Categories : PHP, PHP Classes, Search, Filesystem
PHP Transfer data from text file to Mysql Table
Categories : PHP, PHP Classes, Filesystem, Databases, MySQL
Easy upload class
Categories : PHP Classes, Filesystem, HTTP, PHP
How To Create a PDF Using PHP
Categories : PHP, PDF, PHP Classes, HTML and PHP
Listing the 10 most recently updated files in a given dir by using last- modified variable and printing to html with link to the file
Categories : PHP, Directories, Filesystem