Current location: Hot Scripts Forums » Programming Languages » PHP » PHP and Mod Rewrites I need a pros advise..


PHP and Mod Rewrites I need a pros advise..

Reply
  #1 (permalink)  
Old 02-23-06, 01:38 AM
0o0o0 0o0o0 is offline
Wannabe Coder
 
Join Date: Jul 2005
Posts: 213
Thanks: 0
Thanked 0 Times in 0 Posts
PHP and Mod Rewrites I need a pros advise..

Only one question.. is it possible to NOT SHOW where your getting a photo from??

I have access to a private sites photos.. and I dont want the average joe to know where I get private photos from, only cause Im contracted and its a violation of my contract if someone gets into those folders and sees all the pics.. dont ask me why tho cause they dont need a password to get into. Anyhow.. any ideas??

http://www.thesitewhereIlinktothesoc...vatephotos.php

to..

www.spoofedto"looklike"mydomian.com/privatephotos.php

Is it possible?
Reply With Quote
  #2 (permalink)  
Old 02-23-06, 09:11 AM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
Quote:
Originally Posted by 0o0o0
Only one question.. is it possible to NOT SHOW where your getting a photo from??
I think the best way to do this is to use a small PHP script to serve the image from a directory above the web root. I do this on several of my site to prevent bandwidth hogs and hotlinking. You can combine this with mod_rewrite to get a very secure setup.
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Reply With Quote
  #3 (permalink)  
Old 02-23-06, 09:40 AM
0o0o0 0o0o0 is offline
Wannabe Coder
 
Join Date: Jul 2005
Posts: 213
Thanks: 0
Thanked 0 Times in 0 Posts
awsome sounds like what I need ..........? lol any examples tho? thanks

Php Scriptwise

I know how to do the rewrites thats not a problem.

More or less what your saying is... instead of... www.blabla.com/photos.jpg

make it so you do.. /photospoofedfolder/photos.jpg

this eliminates the domain..

then mod rewrite

Blablaimaginary address from /photospoofedfolder/photos.jpg


and it wont show a domain? when you right click on your stuff.. ( from another domain) what does it show?? the real link or the spoofed link?

Last edited by 0o0o0; 02-23-06 at 09:48 AM.
Reply With Quote
  #4 (permalink)  
Old 02-23-06, 01:38 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
No, I meant that you could use a script to serve up the image (which could be stored above the web root for security). Mod-rewrite could make the URLs friendlier, but the script would prevent any direct access to the image itself. The script would stream the image out to the browser. The IMG tag would look something like:

<img src="myscript.php?pic=coolpicture.jpg">

The 'myscript.php' would grab the image and spit it out to the browser.
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Reply With Quote
  #5 (permalink)  
Old 02-23-06, 02:14 PM
0o0o0 0o0o0 is offline
Wannabe Coder
 
Join Date: Jul 2005
Posts: 213
Thanks: 0
Thanked 0 Times in 0 Posts
so more or less your making a temp or cache file on the ftp? that grabs the pics.. lets the script or page load em... then deletes them?

and the link on getting these would be..

yoursitenotthesourcesite.com/cacheortempfolder/123.pic

can you show me a script or list a few functions needed for this?

php just gets more and more interesting!
Reply With Quote
  #6 (permalink)  
Old 02-23-06, 02:15 PM
Acecool's Avatar
Acecool Acecool is offline
Aspiring Coder
 
Join Date: Nov 2003
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
Yes, that is possible..

You can have the php script open the file, then put it into the image, basically modify the headers of the php script so that it will be displayed as an image...

image/type... etc

just open the source of the file, file_get_contents and check the headers..

I can code this for you if you want for $15 USD (Simple, but Paypal fees..)
__________________
Check Acecoolco.com for PHP Tutorials, and other tuts
If you plan on contacting me, please read this: Legal Terms & Conditions
Reply With Quote
  #7 (permalink)  
Old 02-23-06, 02:17 PM
0o0o0 0o0o0 is offline
Wannabe Coder
 
Join Date: Jul 2005
Posts: 213
Thanks: 0
Thanked 0 Times in 0 Posts
acecool.. not that im cheap.. but doing the work myself only helps the learning process.

plus a partial part of your post alone.. found me this

http://ca.php.net/header

http://php.mirrors.ilisys.com.au/man...fromstring.php

http://ca.php.net/variables.external

http://ca3.php.net/gd


<?
$loadFile = "http://static.php.net/images/php.gif";

$im = imagecreatefromstring(file_get_contents($loadFile) );

then something else lol.

Whoa! now im in a whole other area.. can you rip a pic, and place your logo in it using a script?????????? or merge a gif onto a jpg? instead of manually in photoshop layering your logo on photos? ( that are yours in the first place of course!)

better yet.. automatic thumbnail maker script! ( bare with me im still somewhat of a newbie so this stuffs incredible to me)

this one below is worth lol $15 times 200,000. Since all search engines are starting to get into this

<?php
require("dbconfig.inc");

$id = $_GET['id'];

if($id) {

$link = @mysql_connect($host, $user, $password) or die("Could not connect: " . mysql_error());
@mysql_select_db($dbname, $link);

$query = "select filetype, image from pictures where id = $id";
$result = @mysql_query($query);

$data = @mysql_result($result,0,"image");
$type = @mysql_result($result,0,"filetype");

Header( "Content-type: $type");

$size = 150; // new image width
$src = imagecreatefromstring($data);
$width = imagesx($src);
$height = imagesy($src);
$aspect_ratio = $height/$width;

if ($width <= $size) {
$new_w = $width;
$new_h = $height;
} else {
$new_w = $size;
$new_h = abs($new_w * $aspect_ratio);
}

$img = imagecreatetruecolor($new_w,$new_h);
imagecopyresized($img,$src,0,0,0,0,$new_w,$new_h,$ width,$height);

// determine image type and send it to the client
if ($type == "image/pjpeg") {
imagejpeg($img);
} else if ($type == "image/x-png") {
imagepng($img);
} else if ($type == "image/gif") {
imagegif($img);
}
imagedestroy($img);
mysql_close($link);
};
?>

Last edited by 0o0o0; 02-23-06 at 02:42 PM.
Reply With Quote
  #8 (permalink)  
Old 02-23-06, 06:06 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
Quote:
Originally Posted by 0o0o0
so more or less your making a temp or cache file on the ftp? that grabs the pics.. lets the script or page load em... then deletes them?
No, no need to copy or anything like that. You open the image file wherever it happens to be and send it out as a stream. I have a perl example but no php example handy.

Quote:
Originally Posted by 0o0o0
and the link on getting these would be..

yoursitenotthesourcesite.com/cacheortempfolder/123.pic
Yes, it could be using mod_rewrite if you want (I'd do it).

Quote:
Originally Posted by 0o0o0
can you show me a script or list a few functions needed for this?
php just gets more and more interesting!
Here's a snippet from a page that has some sample code that does this. It's from http://www.thesitewizard.com/archive...ctimages.shtml

Code:
      $imagepath = $imagedir . $image ;

      $imageinfo = getimagesize( $imagepath );

      if ($imageinfo[2] == 1) {
        $imagetype = "gif" ;
      }
      elseif ($imageinfo[2] == 2) {
        $imagetype = "jpeg" ;
      }
      elseif ($imageinfo[2] == 3) {
        $imagetype = "png" ;
      }
      else {
        header( "HTTP/1.0 404 Not Found" );
        exit ;
      }

      header( "Content-type: image/$imagetype" );
      @readfile( $imagepath );

    }
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Reply With Quote
  #9 (permalink)  
Old 02-23-06, 06:07 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
Quote:
Originally Posted by 0o0o0
Whoa! now im in a whole other area.. can you rip a pic, and place your logo in it using a script?
Yup, you can do this. I think you need the GD library installed. There's an interesting example of this here: www.quotationnation.com

View a quote, then click the button that says "put this on a t-shirt", then click on any f the "get it" buttons. You'll end up in a "designer" script that lets you put the quotation (or free-form text) onto a blank image.

It could just as easily be an image of something instead of blank, or you could superimpose your image over the top of an existing picture.
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]

Last edited by End User; 02-23-06 at 06:12 PM.
Reply With Quote
  #10 (permalink)  
Old 03-09-06, 03:42 AM
0o0o0 0o0o0 is offline
Wannabe Coder
 
Join Date: Jul 2005
Posts: 213
Thanks: 0
Thanked 0 Times in 0 Posts
any further help??

Tried figuring this out, gave it a week cant get it. Anyone have anymore clearer ideas??

thanks.

Quote:
Only one question.. is it possible to NOT SHOW where your getting a photo from??

I have access to a private sites photos.. and I dont want the average joe to know where I get private photos from, only cause Im contracted and its a violation of my contract if someone gets into those folders and sees all the pics.. dont ask me why tho cause they dont need a password to get into. Anyhow.. any ideas??

http://www.thesitewhereIlinktotheso...ivatephotos.php

to..

www.spoofedto"looklike"mydomian.com/privatephotos.php

Is it possible?
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Complex Wildcard Mod for MySQL search with php todayscoffee PHP 2 02-13-06 04:12 PM


All times are GMT -5. The time now is 06:34 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.