Twentyoneth Posted June 7, 2006 Share Posted June 7, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/11443-hiding-links/ Share on other sites More sharing options...
mateamargo Posted June 8, 2006 Share Posted June 8, 2006 The technique you are looking for is [b]Obfuscation[/b]. 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] Quote Link to comment https://forums.phpfreaks.com/topic/11443-hiding-links/#findComment-43040 Share on other sites More sharing options...
poirot Posted June 8, 2006 Share Posted June 8, 2006 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\" /] Quote Link to comment https://forums.phpfreaks.com/topic/11443-hiding-links/#findComment-43068 Share on other sites More sharing options...
.josh Posted June 8, 2006 Share Posted June 8, 2006 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[code]<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>[/code]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 [b]value="playlist.php?id=1"[/b] and [b]src="playlist.php?id=1"[/b] 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:[code]<?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"); }?> [/code]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 [b]value="playlist.php?id=1"[/b] and [b]src="playlist.php?id=1"[/b] 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\" /] Quote Link to comment https://forums.phpfreaks.com/topic/11443-hiding-links/#findComment-43076 Share on other sites More sharing options...
Orio Posted June 8, 2006 Share Posted June 8, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/11443-hiding-links/#findComment-43105 Share on other sites More sharing options...
Twentyoneth Posted June 10, 2006 Author Share Posted June 10, 2006 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.mp3Ect...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 :) Quote Link to comment https://forums.phpfreaks.com/topic/11443-hiding-links/#findComment-43935 Share on other sites More sharing options...
Twentyoneth Posted June 10, 2006 Author Share Posted June 10, 2006 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[code]<?phpif ($_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."; } } }?>[/code]This is what I have so far, any help would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/11443-hiding-links/#findComment-43943 Share on other sites More sharing options...
.josh Posted June 10, 2006 Share Posted June 10, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/11443-hiding-links/#findComment-43946 Share on other sites More sharing options...
Twentyoneth Posted June 10, 2006 Author Share Posted June 10, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/11443-hiding-links/#findComment-43948 Share on other sites More sharing options...
Twentyoneth Posted June 15, 2006 Author Share Posted June 15, 2006 **bump** Quote Link to comment https://forums.phpfreaks.com/topic/11443-hiding-links/#findComment-45810 Share on other sites More sharing options...
Twentyoneth Posted June 23, 2006 Author Share Posted June 23, 2006 Could anyone explain how I could create a database so that I could work on this? Quote Link to comment https://forums.phpfreaks.com/topic/11443-hiding-links/#findComment-48706 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.