PDA

View Full Version : File Create Option


TheSupportForum
10-17-2012, 06:33 AM
Hello

i am wondering if there is an optioncode for vboptions in admincp
i have a field that requires admins to input a file name which would be soemthing like
blahblah.txt

now what i am hoping is after clicking OK, the file is created, i have the rest of the code sorted in php which looks for the file, i just need handle (optioncode )
that allowed the file creation

is this possible ?

kh99
10-17-2012, 10:53 AM
You could do something like this in the "Validation PHP code" for the option:

if (!empty($data))
{
return touch($data);
}
else
{
return false;
}


of course if you want to write something to the file and not just create it empty, then you could use fopen, fwrite, etc.

TheSupportForum
10-17-2012, 01:07 PM
You could do something like this in the "Validation PHP code" for the option:

if (!empty($data))
{
return touch($data);
}
else
{
return false;
}of course if you want to write something to the file and not just create it empty, then you could use fopen, fwrite, etc.


i wrote this


$ourFileName = "$vbulletin->options['aglogname'];";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fclose($ourFileHandle);
which is handy, and now looking for the part that will create the file from
$vbulletin->options['aglogname'];

but only run once, i am not sure if thats possible, but i imagine that eash time i change the name in $vbulletin->options['aglogname'];

it will create the new file

i dont need to write to it, just create it