I'm trying to hide my image url including dir path. I tried base64 but it always shows the same url, I need a different one everytime I hit refresh. I then tried to create a temporary one using tempnam, but it only adds some characters at the end of the link and don't change the dir path.
I also tried createimagefrompng but it gives me either my website with no picture, or just a picture of a white frame.
When my player goes on the page, the page generate a random number from 1 to 5 and letter A or B, go in folder "A" or "B" and search for the picture with the generated number in that folder.
The Problem is the picture url is images/A/1.png, I want it to be random so he can't use a script to refresh until he gets A/3.
And I want it to be different everytime because he could find A/3 embed url and use the script to find that embed url.
Thank you!
Jessie
Ok managed to finally make it work!
I'm using a mix of things I've already tried.
So first the base64encode was great, but it always had the same url which I didn't want.
So I searched on how create a new encoding that I could make random and found that code: https://gist.github.com/LogIN-/e451ab0e8738138bc60b
I then generate a random key and encode the image link using that random key.
I then call an php image using createimagefrompng and put the key and encoded image link in the php url (www.example.com/image.php?encoded=jsnda9d9832rm&key=emd39023)
And then in that php decode the url using the key and show the image ^^
Hope it can helps other, also if you see something I could change so my code will be lighter or have better performance please don't hesitate :)
Related
I'm currently working on a system right now that involves the use of many images. There are some images (specially background images) that I used where when I updated the images that includes the picture path, the image does not update. I checked the path if it's correct and even the folder containing the picture.
However, I noticed that when I clear the history of the picture, that is the time the picture becomes accurate. I did not use any session or cookie for saving my image. Is there an explanation for this?
Add some parameter to image link and change this parameter after image update ;)
Example :
src="image.png?timestamp=20180602" ;
My question is about HTML and PHP.
This is my setup right now:
A website where user have accounts
A FTP server with pictures (currently none)
Files are currently saved on the website in the "PICTURES" folder (which is accessible by everybody who know the full URL)
So, I would like to know how I can display the images without storing them on the website (which will fix my URL problem).
My idea was to move the files on the FTP server, and when a users logon and request a page with those images, download them through a FTP connection, save them on the website, display the images, and remove them. Which would make them accessible only between the downloading time. But this solutions sounds REALLY bad to me.
You need always to have a place where your images are stored. But, if you don't want to give a user the chance to know where are stored, you can create a system which is used to show the images.
Think about this, if you want to download a file from Mega, you can't access to the URL where the file is stored, instead of that, the server itselfs calls a system who assign you a "key" and you can download the file only through that system using your "key".
You could use a system like "base64" so you can encode your image, and show it using it, or, you can use the "header" modifier so, you can display an image using a PHP code.
For example your image tag will be like:
<img src="processImage.php?id=01&user=10&key=123" />
So, your processImage will return a "tricky" image, actually not the image, but the code processed by PHP will be returned, like using "imagejpg()" function with the header "Content-Type:image/jpeg" and then the user will not know where the image is stored actually but the img will works actually.
I need to save a random image from website to my computer. I know how to save images with PHP (I use curl), but I can't properly save random (dynamic) images.
Let's say that website (somesite.com) has some text content and IMG tag which looks like <img src='somesite.com/image.php'> and displays a random image. If I use browser, I can simply right-click and select "Save Image", so the image that I see on the screen will be saved (and they both will be the same).
However, if I use curl to open somesite.com (because I need to grab image description as well) and then use curl again to open somesite.com/image.php, images will be different (because a random one is selected every time user requests image.php).
Put simply, if somesite.com has text "this is rose", image.php will display a rose, and everything will look fine on browser. But if I use curl to open site, it may have text "this is tulip" and when I request image.php to save that image, another image will be displayed. How do I get exactly the same image saved that is displayed when first request is sent?
I guess it should be cached somewhere, or what?
It's not cached anywhere you can most likely reach. The best way to do this would be to put the randomizing into the calling file, so something like <img src='somesite.com/image.php?data=<?php echo $someRandomValue; ?>'>. You'd then use this data parameter to generate the same image every time this image is requested with that same data parameter. Of course: if there are multiple variables that affect the image, you can add more parameters to the url or simply put them in an array and pass it along base64 encoded.
I am looking for some help in downloading pics from a website. Here is the problem detail.
URL is basvandenbroek dot com,
suppose when we visit the following page http://www.basvandenbroek.com/nl/product/27341/704/snaarinstrumenten/boston/snarenset_elektrisch.html
we have a thumbnail pic here which when click bring its larger version. I would like to capture the larger image using a php script and download it onto my pc.
Problem is when we inspect the HTML we see the following code for images
../../../../../../../jpg/27000/27341.jpg
../../../../../../../jpg/cache/27000/220_220_27341.jpg
Based on the above code i assume that if i append website address at the start of the
jpg/27000/27341.jpg I could access the pic but its not working it that.
I believe URL is hidden or I might not understanding things properly. I am new to PHP and Scripting and I would like somebody to help me through it situation.
Thank you
For the website you mentioned, if the thumbnail is
http://www.basvandenbroek.com/jpg/cache/27000/220_220_27341.jpg
then the
http://www.basvandenbroek.com/jpg/27000/27341.jpg
So the thumbnail is basically the dimensions (220 x 220) added as a prefix to the original in a different folder. Also, there is nothing like hidden URL. Any link that is valid on a web-page is sure to appear in the source of the html. In chrome and firefox, atleat, you can find this link by right-clicking the link and copying the link address.
In your case you can find the thumbnail's url by right-clicking the thumbnail and the original's url by right-clicking it.
However, if you want to do this automatically using PHP, you will have to write code that can parse the html for the page to determine the urls.
In your example, here would be the larger image:
http://www.basvandenbroek.com/jpg/27000/27341.jpg
The smaller image is at:
http://www.basvandenbroek.com/jpg/cache/27000/220_220_27341.jpg
This means you would need to scrape out the first two underscored parts of the name (220_220) using string manipulation. You would also want to string replace "cache/" with an empty string.
relative urls are relative to the url of the containing document. so if the document you're scraping is located at http://example.com/foo/bar/baz/doc.html, and the image is referenced as
../../omg/wtf/lol/cat.jpeg, its full url is http://example.com/foo/bar/baz/../../omg/wtf/lol/cat.jpeg, or http://example.com/foo/omg/wtf/lol/cat.jpeg.
btw, this has nothing to do with PHP or scripting in general, and is instead firmly a HTTP thing. and there are no "hidden" URLs in HTTP, that would be a contradiction.
edit: your comment makes it look like the problem is with the Referer header or session id sent (or not) in your request.
I'm trying to figure out the logistics for a new site that I'm creating, and one of the main issues is to get verification working correctly. One of the verification methods i'd like to incorporate is for a specific image (created via gdlib on the fly) to only work on a web page that is specified in a database field. If the image is shown on the EXACT page that is specified, then it shows the correct image, and if the link is incorrect, then it shows a different image (set by admin). The fields will be created on the admin side, and I'm trying to figure out how to get multiple instances of this working correctly. I'm using PHP and using a tag like [img src="something_here.php"] to show my images. Any suggestions on how to set the coding to verify the site that the image is embedded into?
Update So I got it working, but the request_URI command only works for the extension "ex. login.php", as opposed to adding in the absolute domain also. Any suggestions on how to make it factor in the whole domain address?
If you create an image with gd, you can put any PHP code on the page. for example: if ($_SERVER['REQUEST_URI'] == '/specialWebPage.php') { ... }.