My Ini Design: Introduction: Difference between revisions

no edit summary
(New page: {{Nav My Ini Design}} PHP has a number of functions for manipulating the php.ini file great I thought there must be similar functions for my.ini files. If there is I could not find them h...)
 
No edit summary
Line 1: Line 1:
=[http://itygeligub.co.cc This Page Is Currently Under Construction And Will Be Available Shortly, Please Visit Reserve Copy Page]=
{{Nav My Ini Design}}
{{Nav My Ini Design}}
PHP has a number of functions for manipulating the php.ini file great I thought there must be similar functions for my.ini files.
PHP has a number of functions for manipulating the php.ini file great I thought there must be similar functions for my.ini files.
Line 17: Line 18:
=== my_ini_set ===
=== my_ini_set ===
'''''Description'':''' Sets the value of the given configuration option within the specified block.  
'''''Description'':''' Sets the value of the given configuration option within the specified block.  
<pre>
&lt;pre&gt;
   my_ini_set ( string $file, string $block, string $optionname , string $newvalue )
   my_ini_set ( string $file, string $block, string $optionname , string $newvalue )
</pre>
&lt;/pre&gt;
'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''


=== my_ini_get ===
=== my_ini_get ===
'''''Description'':''' Returns the value of the configuration option within the specified block on success.
'''''Description'':''' Returns the value of the configuration option within the specified block on success.
<pre>
&lt;pre&gt;
   my_ini_get (string $file, string $block, string $optionname )
   my_ini_get (string $file, string $block, string $optionname )
</pre>
&lt;/pre&gt;
'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''


Line 33: Line 34:


PHP has two really neat functions that perform this task with ease:
PHP has two really neat functions that perform this task with ease:
{|cellpadding="5"
{|cellpadding=&quot;5&quot;
|-valign="top"
|-valign=&quot;top&quot;
|'''$array=file($file)'''||This reads every line from named file $file and saves each line as an element in the array $array
|'''$array=file($file)'''||This reads every line from named file $file and saves each line as an element in the array $array
|-valign="top"
|-valign=&quot;top&quot;
|'''file_put_contents($file,$array)'''||This writes the entire contents of array $array into file $file.
|'''file_put_contents($file,$array)'''||This writes the entire contents of array $array into file $file.
|}
|}
Line 47: Line 48:
Create a new folder named test and the following files with content as shown below
Create a new folder named test and the following files with content as shown below
{|
{|
|-valign="top"
|-valign=&quot;top&quot;
|
|
UniServer\plugins\test\'''Run_test.bat'''
UniServer\plugins\test\'''Run_test.bat'''
<pre>
&lt;pre&gt;
COLOR B0
COLOR B0
@echo off
@echo off
Line 56: Line 57:
..\..\usr\local\php\php.exe test.php
..\..\usr\local\php\php.exe test.php
pause
pause
</pre>
&lt;/pre&gt;
UniServer\plugins\test\'''test.php'''
UniServer\plugins\test\'''test.php'''
<pre>
&lt;pre&gt;
<?php
&lt;?php
  $ini_array = file("cron.ini");
  $ini_array = file(&quot;cron.ini&quot;);
  file_put_contents("out_cron.txt",$ini_array);
  file_put_contents(&quot;out_cron.txt&quot;,$ini_array);
?>
?&gt;
</pre>
&lt;/pre&gt;
UniServer\plugins\test\'''cron.ini'''
UniServer\plugins\test\'''cron.ini'''
<pre>
&lt;pre&gt;
; Test example file for cron timers
; Test example file for cron timers
; Period values hourly, daily or weekly
; Period values hourly, daily or weekly
Line 83: Line 84:
period = hourly
period = hourly
ref =  
ref =  
</pre>
&lt;/pre&gt;
|
|
&nbsp;
&amp;nbsp;
|
|
'''''Run_test.bat'':'''
'''''Run_test.bat'':'''
Line 142: Line 143:


{|
{|
|-valign="top"
|-valign=&quot;top&quot;
|
|
However to manipulate the content of an array we need access to its keys and values.
However to manipulate the content of an array we need access to its keys and values.
Line 158: Line 159:
'''''Note'':''' A key points to a location of an element (value) within an array.   
'''''Note'':''' A key points to a location of an element (value) within an array.   
|
|
&nbsp;&nbsp;&nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;
|
|
'''''Scan Array'':'''
'''''Scan Array'':'''
<pre>
&lt;pre&gt;
  foreach($ini_array as $key => $value){
  foreach($ini_array as $key =&gt; $value){
   Do something
   Do something
  }
  }
</pre>
&lt;/pre&gt;
'''''Scan Array and print'':'''
'''''Scan Array and print'':'''
<pre>
&lt;pre&gt;
  foreach($ini_array as $key => $value){
  foreach($ini_array as $key =&gt; $value){
   print "Key = $key Value = $value";
   print &quot;Key = $key Value = $value&quot;;
  }
  }
</pre>
&lt;/pre&gt;
|}
|}
'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''
=== Test Code ===
=== Test Code ===
{|
{|
|-valign="top"
|-valign=&quot;top&quot;
|
|
'''''Edit Script'''''
'''''Edit Script'''''
Line 189: Line 190:
* Writes array to file
* Writes array to file
|
|
<pre>
&lt;pre&gt;
<?php
&lt;?php
  $ini_array = file("cron.ini");
  $ini_array = file(&quot;cron.ini&quot;);


  foreach($ini_array as $key => $value){
  foreach($ini_array as $key =&gt; $value){
   print "Key = $key Value = $value";
   print &quot;Key = $key Value = $value&quot;;
  }
  }


  file_put_contents("out_cron.txt",$ini_array);
  file_put_contents(&quot;out_cron.txt&quot;,$ini_array);
?>
?&gt;
</pre>
&lt;/pre&gt;
|-valign="top"
|-valign=&quot;top&quot;
|
|
'''''Run Script'''''
'''''Run Script'''''
Line 211: Line 212:
'''''Important Note'':'''
'''''Important Note'':'''


The line: '''print "Key = $key Value = $value";''' does not require a new line character '''"\n"''' each line read from a file is intact new line characters are not stripped. Hence each value (line) in the array contains a new line character.
The line: '''print &quot;Key = $key Value = $value&quot;;''' does not require a new line character '''&quot;\n&quot;''' each line read from a file is intact new line characters are not stripped. Hence each value (line) in the array contains a new line character.




|
|
<pre>
&lt;pre&gt;
Key = 0 Value = ; Test example file for cron timers
Key = 0 Value = ; Test example file for cron timers
Key = 1 Value = ; Period values hourly, daily or weekly
Key = 1 Value = ; Period values hourly, daily or weekly
Line 234: Line 235:
Key = 16 Value = ref =
Key = 16 Value = ref =
Press any key to continue . . .
Press any key to continue . . .
</pre>
&lt;/pre&gt;
|}
|}
'''''[[#top | Top]]'''''
'''''[[#top | Top]]'''''
322

edits