Search…

X3 Photo Gallery Support Forums

Search…
 
User avatar
amwpsaa
Experienced
Topic Author
Posts: 53
Joined: 29 Jul 2021, 08:46

PHP regular expression issues for excluding or including files

13 Nov 2021, 22:30

PHP regular expression issues for excluding or including files,

I want to hide the .php.js.css extension, which can be written like this:
Code
'files_exclude' =>'/\.(php|js|css)$/i',
I also want to hide the hidden.jpg file. It can be written like this:
Code
'files_exclude' =>'/hidden.jpg/',
I don’t know how to combine wording, please ask  Karl, thank you
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13993
Joined: 30 Sep 2006, 03:37

Re: PHP regular expression issues for excluding or including files

13 Nov 2021, 23:52

I'm not an expert with regex, but I think that can be achived like this:
Code
'files_exclude' =>'/\.(php|js|css)$|^hidden.jpg$/i',
The above will hide only exact file name "hidden.jpg", because I included ^starts and ends$. I used this tool to test:
https://www.phpliveregex.com/

PS! You can also create filenames that start with _files* (for example _fileshidden.jpg), which will automatically be hidden.
 
User avatar
amwpsaa
Experienced
Topic Author
Posts: 53
Joined: 29 Jul 2021, 08:46

Re: PHP regular expression issues for excluding or including files

14 Nov 2021, 01:13

mjau-mjau wrote: I'm not an expert with regex, but I think that can be achived like this:
Code
'files_exclude' =>'/\.(php|js|css)$|^hidden.jpg$/i',
The above will hide only exact file name "hidden.jpg", because I included ^starts and ends$. I used this tool to test:
https://www.phpliveregex.com/
No, there's a mistake!

Error
Invalid files_exclude regex /\.(php|js|css)$|^hidden.jpg$/i/

PS! You can also create filenames that start with _files* (for example _fileshidden.jpg), which will automatically be hidden.
I want to customize my name.
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13993
Joined: 30 Sep 2006, 03:37

Re: PHP regular expression issues for excluding or including files

14 Nov 2021, 02:57

amwpsaa wrote:Error
Invalid files_exclude regex /\.(php|js|css)$|^hidden.jpg$/i/
Not sure where you get /i/ from with ending/. It should be /i not /i/.

I have tried and tested it successfully from here. You can try to escape the \. dot:
Code
'files_exclude' =>'/\.(php|js|css)$|^hidden\.jpg$/i',