Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8846819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:05:38+00:00 2026-06-14T12:05:38+00:00

So on my site (https://example.com) I have a page that parses the last.fm API

  • 0

So on my site (https://example.com) I have a page that parses the last.fm API and pulls back the images off their akamai CDN and displays them on the page.

The thing is all the images are served on HTTP ONLY, https is not supported.

e.g: http://userserve-ak.last.fm/serve/64s/76030502.png

I have an image proxy written in php:

<?php
header('Content-Type: image/png');
if(isset($_GET['img'])){echo file_get_contents($_GET['img']);}
?>

This works perfectly, however, is NOT secure at all, I want it so that only my server can use the image proxy and as such a hash in the URL might be the best option?

https://example.com/proxy.php?url=http://last.fm/image.jpg&hash=hashhere

I had thought of using:

md5($_GET['img']."privatekeyhere");

Then my problem turned to, how to I put the private key in the javascript code without the whole world having access to it?

Any help much appreciated.


I have since written this script that is somewhat effective but still open to being circumvented:

<?php
$args = $_GET['q'];
$date = date('m-d-Y-h-i', time());

list($hash,$img,$auth) = explode("/", $args);

if($hash=="need" && $auth=="key"){
    $checksum = md5($img.$date);
    echo $checksum;
}

if($hash==md5($img.$date))
{
    header('Content-Type: image/png');
    echo file_get_contents('http://userserve-ak.last.fm/serve/64s/' . $img);
}
?>

This can be called like so: https://www.mylesgray.com/lastfm/need/76030502.png/key

The auth code can then be plugged in to display the image: https://www.mylesgray.com/lastfm/{code-here}/76030502.png

However it doesn’t take long for someone to figure out they can set up a script to poll for a key every minute – any advice?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:05:40+00:00Added an answer on June 14, 2026 at 12:05 pm

    Generate unique tokens. You’re on the right track with a hash, but if you keep your private key constant, it’ll eventually get brute-forced. From there, rainbow tables say hi.

    You’re effectively going to have to borrow a leaf or two from mechanisms used to prevent CSRF abuse, as you’re effectively trying to do the same thing: limit the user to one query per token, with a token that cannot be regenerated by them.

    There are tons of ways to do this, and the usual trade-off is between efficiency and security. The simplest is what you’ve suggested – which is easily brute-forceable.
    At the opposite end of the spectrum is the DB approach – generate a unique token per visit, store it in a DB, and validate subsequent calls against this. It is pretty DB-intensive but works out relatively well – and is virtually impossible to break unless the token generation is weak.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a site that sits in a directory on a domain: http://www.example.com/site/ I
I have just installed CentOS, Apache and PHP. When I visit my site http://example.com/myapp/
I want to have my site urls look like http://example.com/place/info?var=info&morevars=ifneeded Place and info are
I was already running a sub-website under following path http://example.com/sub-site/ Now, I have created
I have a PHP5/Zend Framework 1.8.1 web site which is located at: http://www.example.com/foo The
1) I have a Drupal site located at http://example.com and I have a directory
Say I have a blogging site http://www.example.com using custom cms, and I want each
I have a profile page like so: https://i.stack.imgur.com/Rx4kg.png . In management I would like
I have a site that operates in different geographical locations. Some example URLs for
I have a JS photo gallery that loads individual images from an API into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.