Jump to content

sb1920alk

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

sb1920alk's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. So how does that work? It only emails if the age of the file is between 600 and 700 seconds?
  2. I have more information about the picture issue. It is not, as I originally thought, that the file is being saved by excel and that it's only blanking for a moment. Instead, there is some sort of corruption in the file and it's blanking until the corrupted file is replaced. The excel file is on a 15 second loop. The next time it loops, it saves over the corrupt file, allowing the page displays correctly. I found this out today when I noticed the page showing a blank box where the picture should have been. I quickly stopped the loop on the excel file before it could save another picture. I was not able to access the picture through a browser even by entering it's direct location in the address bar. I was able to access the file directly on the server's hard drive. It opened up as if nothing was wrong when I accessed it directly on the server, but it still wouldn't load from the browser. So I still need a better code than what I've got here because this one is also going down the "true" path: <?php unlink($filename); $filename = 'Chart.gif'; if (file_exists($filename)) { echo '<p align="center"><img border="0" src="Chart.gif" width="932" height="547"></p>'; } else { echo '<p align="center"><img border="0" src="NoChart.JPG" width="932" height="547"></p>'; } ?> I tried a few other functions besides file_exists() but everything I tried either came back as always false or always true. I need one that returns "true" when the file can be display and "false" when it cannot. As for the email script: $file = "file.html"; $stat = stat($file); if ( (time() - $stat['mtime']) > 600) { // 600 seconds // send email .... } I have put it on a cron and the email works, but it's emailing me every time the cron runs, so something is wrong with the if() test that is making it say always true. Here's what I'm using now: <?php unlink($stat); $file = "excel.htm"; $stat = stat($file); if ( (time() - $stat['mtime']) > 600) { // 600 seconds mail( "***my email address is here****", "Excel is stuck", "Please exit MS Excel on the web server, then restart it again", "From: ***my email address is here****" ); } ?> The final issue I need help with is also related to the cron script. I only want it to email me once. If I have the cron running every 5 minutes and the excel file freezes up right after I leave work, I'll have way too many emails by the time I get back in the next morning. Can I the cron script read a text file that either says "running" or "sent" before emailing? If is says "running" the script continues as normal. If the script determines that excel.htm is old, then it overwrites the text file with "sent" after it has emailed me. The next time around it will read the text file and see that it says "sent" and skip the email part. If the cron finds that the file is young again it replaces the text file again with "running" Anyways, that's my idea. I'm not sure how to implement it. Better ideas are also welcome. I appreciate your help.
  3. Ok, so with the cron job, it will send an email every five minutes, right? For AJAX, it would send an email every time someone accesses the page? There's one other issue with my page. Maybe you can help me with that too. Excel is exporting a chart as a GIF which is part of the page. Once in a while, the GIF does not load, just an empty box in it's place. Refreshing the page manually, or waiting for the auto-refresh usually loads the GIF properly. I'm not sure why this is happening. I think it only happens when the page is trying to load at the exact same time that Excel is saving a new version of the GIF. Any ideas on how to make this not show a blank page? I tried this already: I made an alternate pic with the same dimensions that says, "The chart is being updated, this page will refresh automatically." Using this code: <?php unlink($filename); $filename = 'Chart.gif'; if (file_exists($filename)) { echo '<p align="center"><img border="0" src="Chart.gif" width="932" height="547"></p>'; } else { echo '<p align="center"><img border="0" src="NoChart.JPG" width="932" height="547"></p>'; } ?> ...but it made no difference. The blank box still shows up once in a while, and I've never seen the alternate pic show up. I'm still new to PHP, so I'm not sure which function will work for this. I thought it would be file_exists, but I gues not.
  4. I have a page that updates itself every few minutes (it's an Excel file on a macro loop that saves a copy of itself onto a website as html). It works great, but once in a while Excel will hang and the html file will stop being updated as a result. I have a php page which calls this html file and adds the server time. My question is, can I set something up that will monitor the html page, and if a set amount of time (say, 10 minutes) goes by and the html page has not updated, that it will send me an email? Any help is appreciated.
  5. Thanks for your response. I haven't had a chance to try your idea. I just now found something else that looks like it will work at first glance. Hopefully my search is over. I encasesed the page in question in a new page's iframe. I set marginheight to 0, scrolling to no, width to 100%, and height to 190% - which fit the lenght of my page, I will probably need to adjust this setting if the page gets longer. Now when it refreshes, it's the iframe that refreshes instead of the page contain the iframe, even though that's all it contains and it's 100%. The only difference I can see is a slightly larger bottom margin, but I can live with that. The iframe is the only thing the new page contains. I'm going to rename the orginal page and name the new page in it's place.
  6. Nice forum! I'm using a meta refresh tag to automatically refresh a page. This works great except it resets the scroll position all the way up. If I hit the F5 key or click the refresh button, it keeps the current scroll postion. How can I code it to keep the scroll position with an auto-refresh? Thanks!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.