Login   Register  
PHP Classes
elePHPant
Icontem

File: testinifilereader.php3

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Scott Christensen  >  Ini File Reader  >  testinifilereader.php3  >  Download  
File: testinifilereader.php3
Role: ???
Content type: text/plain
Description: Test program to view and edit ini files
Class: Ini File Reader
Author: By
Last change:
Date: 13 years ago
Size: 2,970 bytes
 

Contents

Class file image Download
<?
require($DOCUMENT_ROOT."/library/headers/hIniFileReader.inc");

if (isset($GetValue)) {
    $ini = new IniFileReader($DOCUMENT_ROOT."/test.ini");
    $tmp = $ini->getIniFile($section, $key, "This is the default value");
    $tmp = "Value retrieved from the ini file for key ($key): " . $tmp;
} elseif (isset($GetAllSections)) {
    $ini = new IniFileReader($DOCUMENT_ROOT."/test.ini");
    $tmp = $ini->sections();
    $tmp2 = "<center><table border=1><tr><td>The Sections Returned</td></tr>";
    while (list($key, $sec) = each($tmp)) {
        $tmp2 .= "<tr><td>$sec</td></tr>";
    }
    $tmp2 .= "</table></center>";
    $tmp = $tmp2;
} elseif (isset($GetAllKeys)) {
    $ini = new IniFileReader($DOCUMENT_ROOT."/test.ini");
    $tmp = $ini->keys($section);
    $tmp2 = "<center><table border=1><tr><td>The Keys Returned For Section $section</td></tr>";
    while (list($key, $val) = each($tmp)) {
        $tmp2 .= "<tr><td>$val</td></tr>";
    }
    $tmp2 .= "</table></center>";
    $tmp = $tmp2;
} elseif (isset($SetValue)) {
    $ini = new IniFileReader($DOCUMENT_ROOT."/test.ini");
    $tmp = $ini->setIniFile($section, $key, $value);
    $tmp = "The file was successfully updated: " . ($tmp ? "True" : "False");
}
?>
<HTML>
<BODY>
<center>
<table width="100%" border=1>
  <tr>
    <td align="center" width="50%">
        <font face="Arial" size="+1">Test find the value for a given key and section</font>
        <form method="post" action="<?php echo $PHP_SELF ?>">
        Section: <input type="text" name="section"><br>
        Key: <input type="text" name="key"><br>
        <input type="submit" name="GetValue" value="Get Value For Key"><br>
        </form>
        <p>
        <font face="Arial" size="+1">Test find all keys for a given section</font>
        <form method="post" action="<?php echo $PHP_SELF ?>">
        Section: <input type="text" name="section"><br>
        <input type="submit" name="GetAllKeys" value="Get Keys For Section"><br>
        </form>
        <p>
        <font face="Arial" size="+1">Test find all sections in the ini file</font>
        <form method="post" action="<?php echo $PHP_SELF ?>">
        <input type="submit" name="GetAllSections" value="Get All Sections"><br>
        </form>
        <p>
        <font face="Arial" size="+1">Test add a key/value pair to the given section</font>
        <form method="post" action="<?php echo $PHP_SELF ?>">
        Section: <input type="text" name="section"><br>
        Key: <input type="text" name="key"><br>
        Value: <input type="text" name="value"><br>
        <input type="submit" name="SetValue" value="Set Value For Key"><br>
        </form>
    </td>
    <td valign="top" width="50%" align="center">
        <font face="Arial" size="+1">Results</font>
        <? if (isset($tmp)) { ?>
        <p><? echo($tmp) ?></p>
        <? } ?>
    </td>
  </tr>
</table>
</center>
</BODY>
</HTML>