GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Addhandler Images into php or html (https://gfy.com/showthread.php?t=731451)

SilentSpic 05-08-2007 01:08 PM

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.

sarettah 05-08-2007 01:51 PM

Quote:

Originally Posted by SilentSpic (Post 12393335)
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.

.

schneemann 05-08-2007 01:52 PM

You need to set the content type header for the file

Masterchief 05-08-2007 02:05 PM

I dont even know where to start with explaining how bad that code right there is.

sarettah 05-08-2007 02:20 PM

Quote:

Originally Posted by SilentSpic (Post 12393335)
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.

SilentSpic 05-08-2007 02:26 PM

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.

schneemann 05-08-2007 03:07 PM

Quote:

Originally Posted by SilentSpic (Post 12393799)
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.

SilentSpic 05-08-2007 03:41 PM

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?

sarettah 05-09-2007 11:12 AM

Quote:

Originally Posted by SilentSpic (Post 12394379)
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 :helpme


.

SilentSpic 05-09-2007 04:24 PM

looking for something along this line.

gyrls.com/upload/show.php?image=0719.jpg

schneemann 05-09-2007 05:47 PM

Quote:

Originally Posted by SilentSpic (Post 12400291)
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>


sarettah 05-09-2007 06:46 PM

Quote:

Originally Posted by schneemann (Post 12400765)
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.

.

SilentSpic 05-10-2007 06:27 AM

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.

sarettah 05-10-2007 07:18 AM

Quote:

Originally Posted by SilentSpic (Post 12403023)
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 times are GMT -7. The time now is 10:41 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123