I work on a website that has a link to our radio system. Myriad is the software running the radio, and it outputs the current presenter to a file on our web server via ftp. Let’s call the presenter Joe Bloggs.
This text file – permissions, group, & owner all correct – never changes apart from Myriad periodically updating the presenter name. There is a second txt file in the same location for testing purposes. This file only get’s changed manually by myself, and again is correct for permissions, group, & owner.
I have PHP code that extracts the data from the text file via file_get_contents() and then uses string manipulation to create the Dir & URL paths to the image file that associates with the presenter.
Example:
Presenter in file: Joe Bloggs
$presImgDir: /home/dir/path/further/path/img/presenters/joe_bloggs_1.png
$presImgURL: https://my.website/further/path/img/presenters/joe_bloggs_1.png
My PHP code then does a simple:
if(!file_exists($presImgDir)) {
$presentersImgURL = DIR_ROOT_CONST_INC_DS . 'further/path/img/presenters/fallback.png';
}
So that if – for any reason – the presenters image doesn’t exist, it falls back to a generic black silhouette of two people.
I have checked every line of code, every result of every php function, & my methods. When both the live Myriad changing text file & spoof file have the exact same presenter name, in the same format, case, spacing, characters – to the point of copying and pasting from one to the other (both ways) – they somehow change the result of the file_exists() check.
When using the live file (Myriad FTP connected) – file_exists returns false.
When using the spoof file (Manual edit file) – file_exists returns true.
I am at a loss. I am proud of my skills, whilst knowing you can never stop learning from sources or peers, but my somewhat autistic brain is now having a meltdown at the seemingly sheer illogic nature of this problem.
Why would a difference in text file containing the exact same data, change the result of a PHP file_exists() check, especially when all it receives is a string, and doesn’t interact with the text file otherwise?
Thanks for reading, I look forward to the responses. Happy to answer all questions. Please throw everything basic and advanced at me, even if it would seem silly not to assume I have done something. I’d rather be checked with a fine tooth comb at this point.
I tried: Logic.
I expected: Logic.
I received: The world ending.
(Not helpful I know but it made me feel better).