Jump to content

msing

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

msing's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Sounds like just what I need. Thanks. I knew it existed (pretty much anything you need already exists in php), but I wouldn't have known the function name.
  2. Hi, I'm looking to make a simple image gallery script. Displaying the images and other info is not a problem, but I'm looking to gather the names of the images from a list that is hosted on a different server. For example the list is located at http://www.site1.com/list.txt and is a simple one-name-per-line list of image names. The gallery script is located at http://www.site2.com/gallery.php and reads each image name from the list, and displays the appropriate images (which are hosted at site2). What would be the easiest way to do this? Basically, in summary I need to stick strings from a remotely-hosted txt file into an array. I know I could simply ftp or wget the file and the read from it, but I was hoping to avoid worrying about the permissions and whatnot of dealing with actual files. Thanks == Matt
  3. Hey there, I actually came to the forums because I was neck deep in my code trying to find out why deleting items out of my MPTT tree was causing problems. Funnily enough I couldn't explain my situation without drawing it out in mspaint, and go figure it became clear after a while of drawing and studying my own drawing. Anyway, I realized that there seems to be no obvious way to insert data into a MPTT tree without putting your inserted item as the LAST child of an existing node. I would really like to be able to insert data into my tree in its proper alphabetical position. Of course I can always re-run my function that re-structures the table into MPTT form from the stored parent node info (kept specifically for that reason). But I was hoping I could find a way to do this without running that cursed recursive function. Any insights? Thanks.
  4. Ok, I got it now. The loop syntax was the biggest problem. Thanks. I also remembered that I'm supposed to be a programmer or something... and started acting like it. Here's what I ended up with, it works great. <?php $daylength = 86400; //60*60*24 $path = '/path/to/file/'; $name_prefix = 'file_'; $link_path = './files/'; $current_date = time(); print " <h3>Here's a list of the daily files.</h3> Today:<br /> <br /> "; if (report_exists_from_x_days_ago(0)) { $filename = report_name_from_x_days_ago(0); $filedate = report_date_from_x_days_ago(0); $link = $link_path . $filename; print("<a href='$link'>$filedate</a><br /><br />"); } print " Previous:<br /> <br /> "; for($days_ago = 1; report_exists_from_x_days_ago($days_ago); $days_ago += 1) { $filename = report_name_from_x_days_ago($days_ago); $filedate = report_date_from_x_days_ago($days_ago); $link = $link_path . $filename; print("<a href='$link'>$filedate</a><br /><br />"); } function report_exists_from_x_days_ago($days_ago) { global $path; $filename = report_name_from_x_days_ago($days_ago); $filepath = $path . $filename; $exists = file_exists($filepath); return $exists; } function report_name_from_x_days_ago($days_ago) { global $name_prefix; $filedate = report_date_from_x_days_ago($days_ago); $filename = $name_prefix . $filedate . ".html"; return $filename; } function report_date_from_x_days_ago($days_ago) { global $daylength; global $current_date; $secs_ago = $days_ago * $daylength; $then_date = ($current_date - $secs_ago); $filedate = date('Y-m-d', $then_date); return $filedate; } ?> Hooray for functions and well-used globals ... and of course proper for loop syntax
  5. Ah yes, it's all starting to come back to me now. I really wish I could just use a function to re-run the values on these variables every time I wanted the values for a different number of days ago. But as I recall using globals in conjunction with functions is a nightmare. Too bad it can't just be like Perl, where you can turn globals on and off per file. Anyway, here is what I have now. It seems to be working for the most part. The first two file_exists test works, but the file_exists test in the for loop don't seem to return a bool like they're supposed to. See anything wrong? <?php $daylength = 86400; //60*60*24 $path = '/path/to/file/'; $current_date = time(); $days_ago = 0; $secs_ago = $days_ago * $daylength; $then_date = ($current_date - $secs_ago); $filedate = date('Y-m-d', $then_date); $filename = "file_$filedate.html"; $filepath = $path . $filename; $exists = file_exists($filepath); print " <h3>Here's a list of the daily files.</h3> Today:<br /> <br /> "; // Testing variables print " \$daylength = $daylength<br /> \$path = $path<br /> \$current_date = $current_date<br /> \$days_ago = $days_ago<br /> \$secs_ago = $secs_ago<br /> \$then_date = $then_date<br /> \$filedate = $filedate<br /> \$filename = $filename<br /> \$filepath = $filepath<br /> \$exists = $exists<br /> "; if(file_exists($filepath)) { print("<a href='./$filename'>$filedate</a><br />"); } print " <br /> Previous:<br /> <br /> "; for($i = 0; $i += 1; file_exists($filepath)) { $days_ago = $i; $secs_ago = $days_ago * $daylength; $then_date = ($current_date - $secs_ago); $filedate = date('Y-m-d', $then_date); $filename = "file_$filedate.html"; $filepath = $path . $filename; $exists = file_exists($filepath); // Testing variables print " \$daylength = $daylength<br /> \$current_date = $current_date <br /> \$days_ago = $days_ago <br /> \$secs_ago = $secs_ago <br /> \$then_date = $then_date <br /> \$filedate = $filedate <br /> \$filename = $filename <br /> \$filepath = $filepath <br /> \$exists = $exists <br /> "; print("<a href='./$filename'>$filedate</a><br /><br />"); } ?> So the output is still looping:
  6. @fnairb: I might give that a try, but I'm really more concerned with why my current code doesn't work. I don't see how daylight savings time has anything to do with this. It looks to me like a simple calculation error. For some reason $secs_ago (a.k.a. $days_ago * $daylength) always = 0, no matter what those values are. Ok, but how and why?
  7. Hi guys, it's been a while since I taught myself PHP, and I'm going back and noticing that I can't seem to get these variables to multiply like I want them. Here's the code I'm working on: <?php $daylength = 86400; //60*60*24 $current_date = time(); $days_ago = 0; $secs_ago = $days_ago * $daylength; $then_date = ($current_date - $secs_ago); $filedate = date('Y-m-d', $then_date); $filename = "file_$filedate.html"; // Testing variables print " \$daylength = $daylength<br /> \$current_date = $current_date <br /> \$days_ago = $days_ago <br /> \$secs_ago = $secs_ago <br /> \$then_date = $then_date <br /> \$filedate = $filedate <br /> \$filename = $filename <br /> "; print " <h3>Here's a list of the daily files.</h3> Today:<br /> <br /> "; if(file_exists($filename)) { print("<a href='./$filename'>$filedate</a><br />"); } print " <br /> Previous:<br /> <br /> "; $days_ago = 1; while(file_exists($filename)) { // Testing variables print " \$daylength = $daylength<br /> \$current_date = $current_date <br /> \$days_ago = $days_ago <br /> \$secs_ago = $secs_ago <br /> \$then_date = $then_date <br /> \$filedate = $filedate <br /> \$filename = $filename <br /> "; print("<a href='./$filename'>$filedate</a><br />"); $days_ago += 1; } print " <br /> "; ?> So the idea is that the loop increases $days_ago by 1 each time, and thus it is supposed to roll backwards printing a link to each previous file. But as proven by the variable tests, when $days_ago is incremented and I subsequently call $secs_ago (via $then_date via $filedate via $filename), $sec_ago always ends up as 0, thus making the loop at the end infinitely print today's file link, So can someone tell me why $secs_ago, when called, does not reflect its own calculation of $daylength * $days_ago? Thanks in advance, == Matt
  8. Nope doesn't look like it. There's an option for ignoring errors. I tried that in the hopes that the page would at least finish loading when the function call failed, but no dice either. I should note that I didn't write this code that finds file mod times and here it is BTW. So if you think of any ways to make this code read protected file/folder modification time info, please let me know.
  9. Hi I've got some PHP code in my nav bar (which is included in every site page) that recursively reads file/folder modification times in the entire site to find the most recently modified file time, and displays that. I recently made some pages that are password protected and now that code fails and stops the the rest of the page from processing. So it's trying to read all of the file mod times, but apparently gets stuck on the password protected directories and dies. So short of removing the protection on these directories, is there a way to allow this code (apparently executing as the anonymous user) to read the appropriate file/folder attribute information without giving read access to anonymous users?
  10. Well I would use Apache but I'm a huge newbie just trying to learn and implement PHP and MySQL. And I want to use my AD for permissions without jumping through a bunch of hoops to use my AD with Apache. Although the reason I am posting in the IIS forum is because I am having problems using AD even with IIS. So I would switch to Apache in a heartbeat if I could successfully integrate it with my AD. However my attempts at doing so have been unsuccessful thus far.
  11. That's not really the point is it.
  12. Hey guys, since this is apparently the most populated board in these forums, could some of you take a look in the IIS and PHP board if you've got some time? It gets virtually no traffic at all. Thanks a lot for any help. == Matt
  13. I did manage to find this MS KB article listed on this php.net faq page describing IIS's inability to allow CGI requests to open pages in protected directories. It seems to fit perfectly with the problem mentioned in my second post in this thread. I suppose it could be the cause of the problem in the first post as well. The only workaround options MS offers, however are: The first bullet point above is just lame. No one is going to allow any and all CGI applications to run as System. The second is alright, but I'd rather not have to go setting up a secure server for the simple web interface stuff for which this site was made. The third point could be possible If I were to turn off anon access for only the protected directories. I'll give that a try. Other than that the php.net faq page entry suggests simply letting a non-PHP-parsed html page do the jumping into the protected directory. This is also possible, but then I'd have to pass all my variables from my php page to an html page, and THEN have that html page auto-redirect (to prevent further need for user-interaction) into the protected directory. I'm not even sure how you go about passing variables into a pure-html webpage. Javascript maybe? I've never had experience passing variables to a non-CGI page. But I suppose it'd be worth looking up. So I've got a couple things to try now. Oui.
  14. I know every answer we get in these forums is free of charge and purely at the expense of each responder's time, but about 40% of the topics in this particular forum have had no replies at all. I'm just trying to direct a little attention in here. I originally posted my first and only other topic at PHPFreaks forums in the much more populated 'PHP Help' forum under the 'PHP and MySQL' category (even though it specifically deals with PHP and IIS) for the sole reason that this forum is dead. Unfortunately it quickly got dumped here Rightfully so, of course, however much to my dismay. So if anyone who has some PHP + IIS knowledge could spare some time for us neglected IIS users, we'd be quite appreciative! Thanks, == Matt
×
×
  • 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.