Hi, I would like to know how to write the default settings to a .txt file.
I already know how to write it to file and also how to read it from file, what I am struggling with is writing the new values to a file. I either get an error or a empty string. Here is a sample code.
function GetDefaultSettings( & $params )
{
$plug_url = $this->get_plugin_url();
$currentDirectory = array_pop(explode("/", getcwd()));
$b_url = $currentDirectory.''.$plug_url.'settings.txt';
$fh = fopen($b_url, 'r') or die("can't open file");
$Data_url_stat = fread($fh, 512);
fclose($fh);
if(empty($Data_url_stat))
{$blog_url = $_SERVER['HTTP_HOST'];}
else {$blog_url = $Data_url_stat;}
$r = array(
'blog_url' => array(
'label' => 'Site Url',
'type' => 'text',
'size' => 35,
'defaultvalue' => $blog_url,
'note' => T_('If your default url is incorrect please change it here.'),
),);
$currentDirectory = array_pop(explode("/", getcwd()));
$b_url = $currentDirectory.''.$plug_url.'settings.txt';
$fh = fopen($b_url, 'w') or die("can't open file");
/* HOW TO CALL THE NEW DEFINED VALUE */
$blog_url_n = $this->Settings->get('blog_url'); // Not Working
$blog_url_n = $this->settings['blog_url']; // Not Working - Returned empty
/* HOW TO CALL THE NEW DEFINED VALUE */
$stringData = $blog_url_n;
fwrite($fh, $stringData);
fclose($fh);
return $r;
}
Any help would be appreciated.
Hi, I managed to resolve the problem so: