Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 05-08-2007, 01:08 PM   #1
SilentSpic
Registered User
 
Join Date: Nov 2005
Posts: 24
Addhandler Images into php or html

I know this is possible but cannot find it anywhere how to fix this. I would like to open all of my images into a php or html file using htaccess.

Following line were placed in htaccess:

AddHandler headered .jpg
Action headered /header/header.php

Then in the header.php, I've placed:
<?php

$header = "header.html";
$footer = "footer.html";

$image = $_SERVER["PATH_TRANSLATED"];
readfile($header);
readfile($image);
readfile($footer);

?>

But the above is opening images as a file. Please Help. Thanks.
__________________
http://www.silentpix.com
SilentSpic is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-08-2007, 01:51 PM   #2
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,113
Quote:
Originally Posted by SilentSpic View Post
I know this is possible but cannot find it anywhere how to fix this. I would like to open all of my images into a php or html file using htaccess.

Following line were placed in htaccess:

AddHandler headered .jpg
Action headered /header/header.php

Then in the header.php, I've placed:
<?php

$header = "header.html";
$footer = "footer.html";

$image = $_SERVER["PATH_TRANSLATED"];
readfile($header);
readfile($image);
readfile($footer);

?>

But the above is opening images as a file. Please Help. Thanks.
You are going to have to get the image part into an img tag to get the browser to see that it is an image.

My brain is full right this second but let me think on it for a couple.

.
__________________
All cookies cleared!
sarettah is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-08-2007, 01:52 PM   #3
schneemann
Confirmed User
 
Join Date: Oct 2006
Posts: 749
You need to set the content type header for the file
__________________
Deranged World
schneemann is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-08-2007, 02:05 PM   #4
Masterchief
Confirmed User
 
Join Date: Jun 2006
Posts: 530
I dont even know where to start with explaining how bad that code right there is.
Masterchief is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-08-2007, 02:20 PM   #5
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,113
Quote:
Originally Posted by SilentSpic View Post
I know this is possible but cannot find it anywhere how to fix this. I would like to open all of my images into a php or html file using htaccess.

Following line were placed in htaccess:

AddHandler headered .jpg
Action headered /header/header.php

Then in the header.php, I've placed:
<?php

$header = "header.html";
$footer = "footer.html";

$image = $_SERVER["PATH_TRANSLATED"];
readfile($header);
readfile($image);
readfile($footer);

?>

But the above is opening images as a file. Please Help. Thanks.
Ok, back

None of that is going to work for what you are trying to do.
__________________
All cookies cleared!
sarettah is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-08-2007, 02:26 PM   #6
SilentSpic
Registered User
 
Join Date: Nov 2005
Posts: 24
Okay, since the code above won't work. Can someone lead me in the right direction? I've been looking around for a least 5 hours now.
__________________
http://www.silentpix.com
SilentSpic is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-08-2007, 03:07 PM   #7
schneemann
Confirmed User
 
Join Date: Oct 2006
Posts: 749
Quote:
Originally Posted by SilentSpic View Post
Okay, since the code above won't work. Can someone lead me in the right direction? I've been looking around for a least 5 hours now.
First things first:
If you're trying to keep people from stealing your images, don't put them online. Putting it into a file isn't going to help stop anyone but the most idiotic surfer. All you'll be doing is adding needless overhead to your site by requiring it to open & read and write files all the time. If your site is popular, this will increase the amount of memory being used up. This is because what you're trying to do is essentially reading all the binary data from an image into one big string. Only then will it be written to file.

Second, ANY display of an image on a web page needs to be done using the <img> element. yes, it can be done with <object> if you're a masochist and want to overcome all the browser compatibility nightmares. So all a surfer has to do is find the path to the file (whether it is a PHP file or a real image file) and there he can download your file. If you think displaying it in PHP will overcome theft you're wrong.

In case you've made it this far and don't care about what I've said, here ya go:

PHP Code:
<?php

$teh_img 
"/path/to/image.jpg";

// Do some magic to find the MIME type
// Also do magic to find the image size
// More on that elsewhere in my post


// Set the content type
header("Content-type: $mtype"); // where $mtype is the MIME type from above

// Set the image size
header("Content-Length: $img_size"); // where $img_size is the size of the image

$handle fopen($teh_img"r") or die("Cannot open $teh_img");
while (!
feof($handle))
    {
        
$data=fgets($handle900);
        echo 
$data;
    }
fclose($handle);

?>
Code above is untested.

I skipped over the part where you get the mime type and the image size. Image size is easy to get. Getting the MIME type is more involved and hey, if you want me to write the whole thing for you, you can pay me. ;-)


The code above needs to be saved as its own file. Then you call it as any other image in your HTML.
__________________
Deranged World
schneemann is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-08-2007, 03:41 PM   #8
SilentSpic
Registered User
 
Join Date: Nov 2005
Posts: 24
Damn, I made it thus far but still don't know where to implement the above code. I am already protected my images buy using htaccess and only giving access to images on certain sites like this one. (Actually giving access to site gfy.com) Anywho, I just would like to open images on php instead of opening on browser. Eventually I would like to put a link above the image. If payment is what you want, so be it. So back to my original question, do I place the above code on all of my php pages?
__________________
http://www.silentpix.com
SilentSpic is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-09-2007, 11:12 AM   #9
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,113
Quote:
Originally Posted by SilentSpic View Post
Damn, I made it thus far but still don't know where to implement the above code. I am already protected my images buy using htaccess and only giving access to images on certain sites like this one. (Actually giving access to site gfy.com) Anywho, I just would like to open images on php instead of opening on browser. Eventually I would like to put a link above the image. If payment is what you want, so be it. So back to my original question, do I place the above code on all of my php pages?
If all you want to do is have php deliver the image then that is actually pretty simple to do. But I am confused as to what you are asking when you say "I just would like to open images on php instead of opening on browser".

The browser is always making the call to the server, delivering the image via a php script still displays the image in the browser.

What exactly are you trying to accomplish with this? It originally looked to me like you were just trying to add a header and a footer to an image (watermarking it in essence)

But, now I am thoroughly confused


.
__________________
All cookies cleared!
sarettah is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-09-2007, 04:24 PM   #10
SilentSpic
Registered User
 
Join Date: Nov 2005
Posts: 24
looking for something along this line.

gyrls.com/upload/show.php?image=0719.jpg
__________________
http://www.silentpix.com
SilentSpic is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-09-2007, 05:47 PM   #11
schneemann
Confirmed User
 
Join Date: Oct 2006
Posts: 749
Quote:
Originally Posted by SilentSpic View Post
looking for something along this line.

gyrls.com/upload/show.php?image=0719.jpg
Why?
I don't mean that to sound negative. I just think if we had a better idea of what exactly you're trying to accomplish we might be better equipped to answer you more effectively.

It looks to me like the page you've referenced above does this:

Code:
<html>
<!--All the other stuff at the top of the document-->
<body>
<?php
$image = $_GET['image'];
// lots more should be done here, such as 
//  input filtering and ensuring against XSS
// then, check that the image actually exists before displaying it.

print("<img src=\"img/$image\">");
?>
</body>
</html>
__________________
Deranged World
schneemann is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-09-2007, 06:46 PM   #12
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,113
Quote:
Originally Posted by schneemann View Post
Why?
I don't mean that to sound negative. I just think if we had a better idea of what exactly you're trying to accomplish we might be better equipped to answer you more effectively.

It looks to me like the page you've referenced above does this:

Code:
<html>
<!--All the other stuff at the top of the document-->
<body>
<?php
$image = $_GET['image'];
// lots more should be done here, such as 
//  input filtering and ensuring against XSS
// then, check that the image actually exists before displaying it.

print("<img src=\"img/$image\">");
?>
</body>
</html>
Yeah, that's about it, other than a header section at the top of the page and a footer section at the bottom of the page. It's just passing back html.

The method he was going at it at the beginning was what confused the issue.

.
__________________
All cookies cleared!
sarettah is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-10-2007, 06:27 AM   #13
SilentSpic
Registered User
 
Join Date: Nov 2005
Posts: 24
Basically this is what I need. All of my gallery images opens up in the browser like this.

silentpix.com/gallery/nsfw/planet-mandy-showing-off-huge-sexy-titties/00.jpg

is there a way I can open all images to look like this...

silentpix.com/image.html

using htaccess so I don't have to recreate all htmls manually.

Thank you in advance.
__________________
http://www.silentpix.com
SilentSpic is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 05-10-2007, 07:18 AM   #14
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,113
Quote:
Originally Posted by SilentSpic View Post
Basically this is what I need. All of my gallery images opens up in the browser like this.

silentpix.com/gallery/nsfw/planet-mandy-showing-off-huge-sexy-titties/00.jpg

is there a way I can open all images to look like this...

silentpix.com/image.html

using htaccess so I don't have to recreate all htmls manually.

Thank you in advance.
No. There is no way (that I know of) to display html from an image call.

The <img> tag expects an image type file in return. If you return an html file to an <img> tage, the browser will not be able to display it.

If you want to do what you are talking about from a thumb click than the url needs to reference a text type file (html, php, txt, whatever) to display it in the browser as html.

That is all as "far as I know".

.
__________________
All cookies cleared!
sarettah is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.