I just finished installing the banner module and beat my head against the wall with an error that would not go away on the Administer->Settings->Banner page.
The error is Failed to access "banner_file.php", file does not exist. Unable to display banners.
I checked and rechecked permissions and file paths and then opened the banner.module in bbedit guessing that maybe I had a file path misunderstood. It was there that I noticed the comment on line 22 about the failing artificially. I am guessing this means that the error message is incorrect. I have tested several banners and I have had no issues.
Any thoughts. Should there be a warning in the install readme warning of this?
Thanks.
Comments
Comment #1
jlmeredith-original CreditAttribution: jlmeredith-original commentedFollowup info - apparently there is an issue here.
If set to no Cache (db) in the Settings menu I can turn the ad on and off via the Administer -> banners page. But if I turn on file cache, the banner will not go away. Any thoughts?
I am running Drupal 4.6.1 on a Linux server with apache. Standard install of drupal, though I have everything sitting in the base directory rather than in a separate folder named drupal. Is this the issue.
Topo of my install
public_html/drupal directory
public_html/banner_db.php
public_html/banner_file.php
public_html/modules/banner.module
public_html/files/banners
All permissions set to 775 with normal group and user.
Thanks
Comment #2
kyote CreditAttribution: kyote commentedI've been having the same problem. I even changed the permissions on the db file to 777 and that didn't work. any ideas on what's happening with this?
Comment #3
kyote CreditAttribution: kyote commentedI've been having the same problem. I even changed the permissions on both files to 777 and that didn't work. any ideas on what's happening with this?
Comment #4
jlmeredith-original CreditAttribution: jlmeredith-original commentedAdditional Followup Info
Ok all, I am less than a PHP newbie .. but I am learning.
I have the banner module working ... here is what I had to do.
Open up the dupal module and goto line 23 and delete the
../
from this line.Complete standard install as instructed.
Here is a before and after starting from the beginning of the function:
Apparently this is a known issue as there is a comment right above it. May be a system config issue, I am not sure. But it works now with the cache option turned on.
Comment #5
kyote CreditAttribution: kyote commentedHmmm, I wonder if I'm doing something wrong. I've tried what you suggested and didn't have the same results. It still says: Failed to access "banner_file.php", file does not exist. Unable to display banners.
I tried replacing '../' with just '' and still got the error. I've also tried '/', 'httpdocs/', '/httpdocs/' and removing it and the . completely and still get the error. This is what my code looks like now:
function banner_check_install() {
$error = NULL;
$cache_type = variable_get('banner_cache', '0');
$filename = $cache_type ? 'banner_file.php' : 'banner_db.php';
// TODO: use actual path rather than "../" (this can fail artificially)
$file = file_create_path(''. $filename);
if (file_exists($file)) {
$output = @file_get_contents($file);
if (!$output) {
$error = theme('error', t('Failed to access "%filename" due to improper file permissions. Unable to display banners.', array('%filename' => $filename)));
}
}
else {
$error = theme('error', t('Failed to access "%filename", file does not exist. Unable to display banners.', array('%filename' => $filename)));
}
return $error;
}
Every time I changed it, i dumped my browsers cache, removed and reinstalled the module just to make sure. still nothing.
jason
Comment #6
kyote CreditAttribution: kyote commentedI got it to work, but not the way i expected. :)
i reuploaded the files and put them in the 'files' folder, changed line 23 to read:
$file = file_create_path('files/'. $filename);
and it worked! How odd is that? Anyways, now it's working. so if anyone else has some odd luck like mine, you might try that.
jason
Comment #7
jlmeredith-original CreditAttribution: jlmeredith-original commentedCrap ... I apologize .. I did the same thing and just failed to mention it ..
Sorry about that.
:D
Yeah banners!
BTW .. you can check out my site at http://rivercitizen.com
Jamie
Comment #8
jlmeredith-original CreditAttribution: jlmeredith-original commentedactually .. I did not add the
files/
part .. just removed the ../Comment #9
kyote CreditAttribution: kyote commentedFor some reason it refused to work for me by jsut removing ../ I don't know why.
It looks like your doing something similar to what i'm doing. my drupal site is www.centralvalleysphere.com
Comment #10
pobster CreditAttribution: pobster commentedOooo-kay... Thought I'd follow this 'guide' to get rid of the annoying "Failed to access "banner_file.php", file does not exist. Unable to display banners." message. But have you noticed that regardless of whether that line reads:
[code]$file = file_create_path('../'. $filename);[/code]or:[code]$file = file_create_path('files/'. $filename);[/code]or:[code]$file = file_create_path(''. $filename);[/code]
None work with the php files in the top level directory? But regardless of what you put into that line - it *always* seems to pass the 'test' fine when I move the php files into the files directory! Great I thought! But when the php files are there "
return banner_display();
" returns an error saying it can't find the files... This only seems to work when the php files are actually in the top level directory and then it works fine (albeit with an error message on the admin/settings/banner screen).Bizarre!
Pobster
Comment #11
Jeremy CreditAttribution: Jeremy commentedI have made some large modification to the banner module this weekend. If you want, grab the cvs tarball (it may take up to 6 hours to be built) and give it a try. It should address this problem.
Note: If you choose to grab the cvs tarball, you need to install a new banner_file.php, and need to add the new 'banner_term' table to the database.
Comment #12
s.ample@www.drupal.org CreditAttribution: s.ample@www.drupal.org commentedi managed to get it installed without any "cant find..." message but i cant upload any image, html or something. every tim ei try to upload a file i get the message "file copy failed"
Comment #13
joel_guesclin CreditAttribution: joel_guesclin commentedThe reason for this problem seems to be a misunderstanding of the Drupal file_create_path function. If you look at the documentation then you will see this: "Returns FALSE if the path is invalid (i.e. outside the configured 'files'-directory)." In other words the files MUST be somewhere in the "files" directory for this to work. But will they work if they are put there?
I changed the code to read " $file = ('../'. $filename);" and it seems to work so far - a quick hack perhaps
Comment #14
nasi CreditAttribution: nasi commentedThe problem is indeed the use of the file_create_path function, as noted above. So putting the php files into the 'files' directory will make that function work, I doubt very much that the banner module would then function correctly. Besides, the downloaded files directory is hardly the place for php code.
What I can't find is a suitable function to form the necessary file path which will work. I tried the suggestion of
$file = ('../'.$filename);
but that alone doesn't work for me.It sounds like there is a fix in cvs, but how about a patch for us 4.6 users?
Comment #15
Jeremy CreditAttribution: Jeremy commentedThis is fixed in the banner-cvs version of the module, which works with the 4.6 version of Drupal (currently, I will fork it soon). Please use the banner-cvs tarball and try again.
Comment #16
dongkui CreditAttribution: dongkui commentedTried the workaround changing "../" to " " or "files/" but this did not work for me. So I had to try the cvs version. From the cvs, I have replaced the banner.module, banner_file.php, and created the banner_term table. I still get the error (Failed to access "banner_file.php", file does not exist. Unable to display banners.) and banners don't work. My banner_.php files are in public_html.
Hope to get help on this as I have lost a few weeks already. Jeremy if you can please.
Comment #17
Jeremy CreditAttribution: Jeremy commentedbanner_file.php needs to be in the same directory as index.php and cron.php, and it needs to have the same permissions. If you believe this is true, look in your web server error logs for hints as to why it is unable to find/read the file.
Comment #18
dongkui CreditAttribution: dongkui commentedBanner_file.php is in the same directory (public_html) as index.php and cron.php and permissions for all is 755. Checked the server error logs and all I can see is the message below which seems to be unrelated to the banner problem. Is there anything else maybe missed.
[warn] Apache does not support line-end comments. Consider using quotes around argument: "# 16th Sept 05"
Comment #19
crozilla CreditAttribution: crozilla commentedOddly, the module works fine for the most part (I just have trouble limiting ads to particular categories, doesn't seem to 'take'). But my logs are getting stuffed with this error message, bigtime.
Table 'drupal.banner_term' doesn't exist query: SELECT tid FROM banner_term WHERE id = 6 in ../domain.com/includes/database.mysql.inc on line 66.
The banner_term DOESN'T exist, but it works anyway. I wouldn't have noticed had I not looked at the logs. Any ideas?
Comment #20
wulff CreditAttribution: wulff commentedI looks like you need to create the table banner_term in your database:
Comment #21
wulff CreditAttribution: wulff commented