Jump to content


Photo

Hiding Links


  • Please log in to reply
10 replies to this topic

#1 Twentyoneth

Twentyoneth
  • Members
  • PipPipPip
  • Advanced Member
  • 118 posts
  • LocationGlasgow, KY

Posted 07 June 2006 - 09:18 PM

Is there a way to hide links in php?

Like if you had embed src music, if you view source, you cant see the actual link to the song, but a substitute? Anything?

#2 mateamargo

mateamargo
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 08 June 2006 - 01:43 AM

The technique you are looking for is Obfuscation. Try searching google about that.
Look if this works for you:
[a href=\"http://www.yuki-onna.co.uk/html/encode.html\" target=\"_blank\"]http://www.yuki-onna.co.uk/html/encode.html[/a]

#3 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 08 June 2006 - 04:12 AM

Actually there is no real way to completely hide a link. As soons as the user clicks it, he/she can know the real location.

Unless you force the user to access the link through a proxy installed in your server, but this is kind of a waste of resources.

600th post! [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]
~ D Kuang

#4 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 08 June 2006 - 06:45 AM

Okay here is a method - You have 2 files: One will have your imbed/object tags in it (which we will call songlist.php), and the src='..' will point to your other file, with an $id variable. The other file will handle finding out the path and song name (which we will call playlist.php). So here goes:

songlist.php
<html>
<head>
<title>Untitled</title>
</head>
<body>
<object width="300" height="42">
    <param name="src" value="playlist.php?id=1">
    <param name="autoplay" value="true">
    <param name="controller" value="true">
    <param name="bgcolor" value="#FF9900">
    <embed src="playlist.php?id=1" autostart="true" loop="false" width="300" height="42" controller="true" bgcolor="#FF9900"></embed>
</object>
</body>
</html>
This is just a generic set of tags for embeding your song. Feel free to modify to fit your needs. The important part is the value="playlist.php?id=1" and src="playlist.php?id=1" now, depending on how you have the rest of your page setup, you can hardcode an id into it, or use a variable, like playlist.php?id=$id it's up to you.

and here is playlist.php:
<?php
   if ($_GET['id']) {
      $id = $_GET['id']; 
      $path_to_song = "../path/to/song/";
      
            // connect to your db
      // assumes that songname is the column
      // that holds the name of the song and
      // table is the name of your table and
      // id is the column that holds the song's id

     $sql = "select songname from table where id='$id'";
     $rs = mysql_query($sql);
     $songname = mysql_fetch_array($rs);
 
         if (is_file($path_to_song . $songname['songname'])) {
          header("Location:" . $path_to_song . $songname['songname']);
     } else {
        header("HTTP/1.1 404 Not Found");
     }
  } else {
       header("HTTP/1.1 404 Not Found");
    }
?> 

Basically what is happening here is that the id is being passed to this script. First, we check to see if it exists. if it does, we proceed to process. If it doesn't (as in, the user types in playlist.php with no ?id=x), we spit out a not found. Anyways, if id is passed with a value, we then proceed to select the song from the database based on the id number. then we check to see if there is a file at the location (path/file), and if so, we redirect to that file, in essence, creating a virtual linkie from songlist.php to the mp3 file. if there is no file there (as in, no selection was made from the db, or else the file doesn't actually exist on the server, even though you have it listed in the db), then we spit out a not found error.

I am using mysql as an example here, as far as storing song names and id's, but you can do some alternate method if you wish, like, if all your songs were blah1.mp3, blah2.mp3, blah3.mp3, etc.. then you could just build a string instead, like so:

$song = "blah" . $id . ".mp3";

Now, the important part, and the reason for all this: when the user tries to view the source code of songlist.php, all they will see is value="playlist.php?id=1" and src="playlist.php?id=1" as the filename and path of the song, instead of "path/to/song/song.mp3"

damn, i'm the shiz. maybe i could spruce this up a bit and offer it up as a tutorial? [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /]
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#5 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 08 June 2006 - 11:02 AM

Wow that's a real good idea! Nice mini-tutorial :)
Btw, swtich+cases can be used to if you dont want with a db, and the songs are not numbered.

Orio.
Think you're smarty?

(Gone until 20 to November)

#6 Twentyoneth

Twentyoneth
  • Members
  • PipPipPip
  • Advanced Member
  • 118 posts
  • LocationGlasgow, KY

Posted 10 June 2006 - 06:31 AM

Well I'm not using a database (sorry it's taken so long to respond, been kinda busy), but as of now, I have a directory listing that works like this:

Artists
- 12 Stones
-Aero Smith
-- I Dont Want To Miss A Thing.mp3

Ect...

When you click on artists, it pulls all the artists in the "Artists" dir, and then you can click on "Aero Smith" dir, and It pulls up "I Dont Want To Miss A Thing", which when you click on, will play it, or download, depending on the browser, of course.

But is there a way I can use this script to work like this, "id=I%20Dont%20Want%20To%20Miss%20A%20Thing", instead of number ID's? Without having to manually put 17 gigs of music ID's in a file?

Thanks for the help btw :)

#7 Twentyoneth

Twentyoneth
  • Members
  • PipPipPip
  • Advanced Member
  • 118 posts
  • LocationGlasgow, KY

Posted 10 June 2006 - 07:30 AM

Ok, I have been pondering a few things and trying a few things. This is the closest I have come, but I'm not sure if it will work even it will show up... :P

<?php

if ($_GET['id']) {
    $id = $_GET['id'];
    $dirone = "Artists/";
    $list = opendir($dirone);
    while (false !== ($otherdirs = readdir($list))) {
           $path = $dirone . $otherdirs . "/";
           $extmp3 = ".mp3";
           $extwav = ".wav";
           $extwma = ".wma";
           $filemp3 = $path . $id . $extmp3;
           $filewav = $path . $id . $extwav;
           $filewma = $path . $id . $extwma;
           if (is_file($filemp3)) {
               echo $filemp3;
              } elseif ($is_file($filewav)) {
               echo $filewav;
              } else if ($is_file($filewma)) {
               echo $filewma;
              } else {
               echo "Sorry, no song.";
              }
          }
   }

?>

This is what I have so far, any help would be greatly appreciated.

#8 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 10 June 2006 - 07:46 AM

i suggest you go with the database thing. but instead of manually entering in 17gigs worth of song names and ids for them, write a 1 time use type script to do it for you.

basically you will want to scan all your files in your directory(s) and get the names of them and then insert them into your database, and you would have your song id column auto-inc'd. hell, most of the script to do that is already been posted in this thread.

see i'm not entirely sure what you're trying to do here now... in your ^^ post it seems as though you want to pass the name of the song as the id. you CAN do it that way, just the same as the db option. The code i provided you gets the song name from the db based on the id number, and then checks to see if the song file exists, based on the name, anyways.

in your ^ post.. well that's where i'm really starting to get confused as to what you are trying to accomplish. I mean, I can see what you are doing, but i don't think you can echo a result back to your embeded object like that. That's assuming that you have done it that way. Have you gone ahead and done it that way, or is this some new method you are trying?
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#9 Twentyoneth

Twentyoneth
  • Members
  • PipPipPip
  • Advanced Member
  • 118 posts
  • LocationGlasgow, KY

Posted 10 June 2006 - 07:50 AM

I don't know how to use a database, and I dont know how to set it up, at all.

What I was trying to do is have it check each dir for the song name in the id, and pass the string to the embed. I wasn't sure that it would work, and I'm kind of a newb, so my checking doesnt work all to well.

If someone could completely explain what I needed to to for the database, as far as setting it up and what not, I could do that, no prob.

Or atleast how to fix my listing to check for the file and try to pass it, to see if it would work, that would be the quick way out :P

#10 Twentyoneth

Twentyoneth
  • Members
  • PipPipPip
  • Advanced Member
  • 118 posts
  • LocationGlasgow, KY

Posted 15 June 2006 - 06:38 AM

**bump**

#11 Twentyoneth

Twentyoneth
  • Members
  • PipPipPip
  • Advanced Member
  • 118 posts
  • LocationGlasgow, KY

Posted 23 June 2006 - 05:29 AM

Could anyone explain how I could create a database so that I could work on this?





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users