Jump to content

mtylerb

Members
  • Posts

    69
  • Joined

  • Last visited

    Never

About mtylerb

  • Birthday 09/25/1983

Contact Methods

  • MSN
    fuzzystuff@telus.net
  • Website URL
    http://www.tbeckett.net

Profile Information

  • Gender
    Male
  • Location
    Edmonton, AB, Canada

mtylerb's Achievements

Member

Member (2/5)

0

Reputation

  1. I want to take a list of image files that I have transferred to a local server and compress them into one file. So: image1.jpg image2.jpg image3.jpg image4.jpg into images.gz or images.tar.gz Whatever is easier.
  2. Thanks corbin! I haven't found any information on php.net regarding the creation of tarballs. Is it only available through PEAR? Is there a good site for information on using this?
  3. Anyone? I suppose I could deal with a .zip file, if someone's able to help out, but I'd still prefer a .gz file.
  4. The current code looks like: function createArchive() { $archive = gzopen($_SERVER['DOCUMENT_ROOT'].'/grab/files/'.$this->year.'-'.$this->month.'-'.$this->day.'.gz','wb9'); $x=0; foreach($this->images as $url) { $x++; $parsed = parse_url($url); $host = $parsed["host"]; $fp = @fsockopen($host, 80, $errno, $errstr, 20); if(!$fp)return false; else { @fputs($fp, "HEAD $url HTTP/1.1\r\n"); @fputs($fp, "HOST: $host\r\n"); @fputs($fp, "Connection: close\r\n\r\n"); $headers = ""; while(!@feof($fp))$headers .= @fgets ($fp, 128); } @fclose ($fp); $return = false; $arr_headers = explode("\n", $headers); foreach($arr_headers as $header) { $s = "Content-Length: "; if(substr(strtolower ($header), 0, strlen($s)) == strtolower($s)) { $return = trim(substr($header, strlen($s))); break; } } $imgsize = $return; $fp = explode('/',$url); copy($url, $_SERVER['DOCUMENT_ROOT'].'/grab/files/'.$fp[count($fp)-1]); //unlink($_SERVER['DOCUMENT_ROOT'].'/grab/files/'.$fp[count($fp)-1]); } gzclose($archive); //unlink($_SERVER['DOCUMENT_ROOT'].'/grab/files/'.$this->year.'-'.$this->month.'-'.$this->day.'.gz'); } Probably should have posted that before. The unlinks are just there so I can uncomment them and delete the relevant files. Is anyone able to help?
  5. Ok, I've changed it up a bit and, instead, copied the files to the local server. Now how would I go about placing those files into a gz archive?
  6. Hey guys (and gals), I'm trying to call files from one of my servers to another. They are all image files and I'm mostly doing this as a learning experiment. Right now I have it so that it is reading the contents of the files, but the .gz file it creates only has one file and the image in it is about the first 10 pixels deep, and then nothing. So, assuming $contents is the fread of the file and $imagesize is just that, how would I put multiple files into a .gz compressed archive? I'm currently trying: $archive = gzopen($_SERVER['DOCUMENT_ROOT'].'/grab/files/'.$this->year.'-'.$this->month.'-'.$this->day.'.gz','wb9'); foreach($this->images as $url) { $parsed = parse_url($url); $host = $parsed["host"]; $fp = @fsockopen($host, 80, $errno, $errstr, 20); if(!$fp)return false; else { @fputs($fp, "HEAD $url HTTP/1.1\r\n"); @fputs($fp, "HOST: $host\r\n"); @fputs($fp, "Connection: close\r\n\r\n"); $headers = ""; while(!@feof($fp))$headers .= @fgets ($fp, 128); } @fclose ($fp); $return = false; $arr_headers = explode("\n", $headers); foreach($arr_headers as $header) { $s = "Content-Length: "; if(substr(strtolower ($header), 0, strlen($s)) == strtolower($s)) { $return = trim(substr($header, strlen($s))); break; } } $imgsize = $return; $fp = fopen($url,'r'); $contents = fread($fp, $imgsize); echo $imgsize."\r\n"; gzwrite($archive,$contents); } gzclose($archive); with no success. Any ideas? Thanks in advance! EDIT: That echo near the end is just for debugging.
  7. Ok, after playing around, I got it. Changed my .htaccess to: Options +FollowSymLinks AddDefaultCharset UTF-8 <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^plugins.xhtml articles/plugins.xhtml [R=permanent,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l # Administration URL rewriting. RewriteRule ^admin(.*)$ admin/index.php?$1 [L,QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l # Main URL rewriting. RewriteRule ^(.*)$ index.php?$1 [L,QSA] </IfModule> Adding that first RewriteRule in. While you're reading this, could someone tell me what the !-l, !-f, and !-d mean?
  8. I noticed this has been moved to a new board. Does anyone over here have any ideas?
  9. I posted that last addition as an Edit, this is just to let you know I replied.
  10. Ok, thank you, I figured out the .htaccess thing. Just placed the following code in and it worked perfectly: redirect 301 /plugins.xhtml http://www.tbeckett.net/articles/plugins.xhtml I don't know why it didn't work before. Thanks for your help Mchl and premiso! EDIT: Actually, I just noticed that it's now sending me to: http://www.tbeckett.net/articles/plugins.xhtml?plugins.xhtml My .htaccess looks like: Options +FollowSymLinks AddDefaultCharset UTF-8 redirect 301 /plugins.xhtml http://www.tbeckett.net/articles/plugins.xhtml <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l # Administration URL rewriting. RewriteRule ^admin(.*)$ admin/index.php?$1 [L,QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l # Main URL rewriting. RewriteRule ^(.*)$ index.php?$1 [L,QSA] </IfModule> Any ideas?
  11. Is there a way to fix this? The other files are all xhtml as well, for example, http://www.tbeckett.net/articles/libertarianism.xhtml Redirects to http://www.tbeckett.net/articles/politics/libertarianism.xhtml With no trouble. EDIT: Ok, you've offered ways to fix it, sorry, missed that. How would I do that with mod_rewrite? I already use mod_rewrite to remove the question mark from the url. I didn't design it though and the original 301 redirects that were put in the .htaccess never worked.
  12. Hey guys, I have a file that has moved and I'm trying to set up, what should be, a simple PHP header redirect. In my file at http://www.tbeckett.net/plugins.xhtml I'm using the following code: <?php header("HTTP/1.0 301 Moved Permanently"); header("Status: 301 Moved Permanently"); header("Location: http://www.tbeckett.net/articles/plugins.xhtml"); ?> But I only seem to get an error when I try to open that: Can anyone help me with this? I have the exact same script running in a number of other files, since I changed the structure of my page, they all work fine, it's just this one.
  13. http://www.tbeckett.net/ I thought it was in enough of the code. I went with BlueBoden's first solution in his last post and it works wonderfully! Thanks guys!
  14. I've also tried changing the second part with the RSS link and image to be a span instead of a div and the result is the same. It's broken in IE. The code with span instead of div looks like: <div class="path"> <div class="breadcrumb"> <a href="http://www.tbeckett.net/" title="Home Page">Home Page</a> <span class="breadcrumb-separator">-></span> <a href="http://www.tbeckett.net/articles.xhtml" title="Articles">Articles</a> <span class="breadcrumb-separator">-></span> <a href="http://www.tbeckett.net/articles/politics.xhtml" title="Politics">Politics</a> <span class="breadcrumb-separator">-></span> <span class="breadcrumb-current">Political Leaning</span><span style="float:right;position: relative;top:-16px;"><a href="http://www.tbeckett.net/rss"><img src="http://www.tbeckett.net/public/stylesheets/img_dirtylicious/rss.png" alt="rss" style="vertical-align:middle;border: 0px;" /> RSS Feed</a></span></div> </div> <!-- end #path--> I'll leave it like that for now so you can see it, if you want. It only affects IE, I only have access to IE7, so I don't know about other versions.
  15. I did, that's what the str_replace accomplished. After the str_replace, the code looked like: <div class="path"> <div class="breadcrumb"> <a href="http://www.tbeckett.net/" title="Home Page">Home Page</a> <span class="breadcrumb-separator">-></span> <a href="http://www.tbeckett.net/articles.xhtml" title="Articles">Articles</a> <span class="breadcrumb-separator">-></span> <a href="http://www.tbeckett.net/articles/politics.xhtml" title="Politics">Politics</a> <span class="breadcrumb-separator">-></span> <span class="breadcrumb-current">Political Leaning</span><div style="float:right;position: relative;top:-16px;"><a href="http://www.tbeckett.net/rss"><img src="http://www.tbeckett.net/public/stylesheets/img_dirtylicious/rss.png" alt="rss" style="border: 0px;" /> RSS Feed</a></div></div> </div> <!-- end #path--> As soon as this was in place, IE no longer worked. FF and Opera did, but IE started displaying the left hand menus below the main content. After I removed it, IE reverted back to normal. I'm sure it has something to do with the float.
×
×
  • 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.