Hi Experts!
I’m a sound engineer. I’m using an open source file repository - Sonuku dump - so clients can retrieve audio files from me. Despite being a newb with php, I’ve made some good small hacks, including email notification when a client downloads a file - very useful for me to know!.
I’m now trying to add a bit of back end to this script, so I can add private folders and users at easily. All going well so far but I’m totally stuck with trying to load an array from a file, within a class.
Originally, the array is declared as a constant at the top of the class:
[php]
var $CFG_PRIVATE = array(
“folder1/”,
“folder2/”
); //hides these folders unless logged in
[/php]
Later on, this array is used like thus:
[php]
foreach($this->CFG_PRIVATE as $private) {
if (preg_match("/^".preg_quote($private, ‘/’)."/i",$this->DIR."/") && !$this->checkpass($_SESSION[‘DUMP_PASS’])) {
$foundmatch = true;
}
[/php]
With another (separate) array for users, I successfully got it to load it’s data from a csv file with this code:
[php]
$dump->DUMP_PASS = array();
$arrLines = file(’/path/to/users.txt’);
foreach($arrLines as $line) {
$dump->DUMP_PASS = explode( ‘,’, $line);
}
[/php]
Can anybody advise me how I construct a function to load the array from a file, such that the array can be used as it is being used in code snippet #2 ?? I hope I have explained that clearly, any help would be massively appreciated.
thanks…
green_as