The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
!file_exists help
Hi guys
im trying to have a file created if not exist, so far i have PHP Code:
PHP Code:
i know this is not 100% correct but need the variable corrected |
#2
|
||||
|
||||
Quote:
|
#3
|
|||
|
|||
if file does not exist create this file using these variables simple
|
#4
|
|||
|
|||
I think this should work:
Code:
$ourFileName = $vbulletin->options['thefile']; if (!file_exists($ourFileName)) { $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file"); fclose($ourFileHandle); } but you probably wouldn't want the "or die()" part because that would leave you with a white page with an error message. You could do something like this: Code:
$ourFileName = $vbulletin->options['thefile']; if (!file_exists($ourFileName)) { $ourFileHandle = fopen($ourFileName, 'w'); if ($ourFileHandle === FALSE) { // Do something here to handle error } else { fclose($ourFileHandle); } } Also, using "w" in the fopen call will truncate the file (make it empty), so if you don't want that, use either "r" or "a". |
#5
|
|||
|
|||
Quote:
this worked for the end user but not the admin what was happening was the following 1) user visited forum 2) if variable was true, it wrote to the $ourFileName 3) but some admins could not create this file automacially ( for me it worked ) for another website ( admin did not work ) i will use the above code to see how today goes with it |
#6
|
|||
|
|||
Well, the ability to create a file will depend on how the server permissions are set of course. You may have your set up to allow creation of a file anywhere whereas someone else doesn't (really you probably shouldn't allow it in the same directories that your php scripts are in, but I'm not a server config expert or anything). Maybe what you want to do is have an option to specify a directory, then instruct the admin to enter a path that has create permission for whatever user the web server runs as.
|
#7
|
|||
|
|||
Quote:
only, this is why the $variable is called to create a file somewhere plugin : global start $seeks this file upon a $true value, which allows the $event to be logged the problem i am having with it is sharing this script which will also create the log in the same manner and folder, but they get the error message upon file creation and i dont which i am trying to figure out if its and issue with fopen or if (!file_exists($ourFileName)) which would be a permission issue somewhere on their webserver |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|