[SOLVED] Â hash an external link |
9/15/2016 6:55:51 PM |
PHPRunner General questions | |
![]() Hi, |
|
![]() |
romaldus 9/15/2016 |
Hi, How can I hash an external link? I send an email from my view page & receive the email with the link "http://localhost:8085/clmain_view.php?editid1=1" but I want it to be hash else I expose the rest of database. This is an example I've come across below but I'm not amending a record, just a simple view record. if ($_REQUEST["hash"]) { CustomQuery("Update Table_1 SET Confirm='Yes' WHERE hash = '".addslashes($_REQUEST["hash"])."'"; header("Location: Thankyoupage.php"); } & the link should look like example below. http://test/view.php...7sklf03kjsjd3md Thanx <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=80309&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
function my_random_string($length=30)
$values["ID"] = my_random_string();
http://localhost:8085/clmain_view.php?editid1=hmF6R7Sij2AGQiE0gFdcpFyjLehsHY
|
![]() |
mtpocket author 9/16/2016 |
Thanx Romaldus will try later. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=80311&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' /> Encrypt URL Parameter requires some custom code and risky (not secure), unless you have a strong knowledge in cryptography. The easiest solution, do not use integer (autonumber) as primary key field. Use random string instead. For example, set your ID field as varchar (60) in event use the following code to generate 30 (or any length you want) random string: function my_random_string($length=30)
$values["ID"] = my_random_string();
http://localhost:8085/clmain_view.php?editid1=hmF6R7Sij2AGQiE0gFdcpFyjLehsHY
|
![]() |
romaldus 9/16/2016 |
Thanx Romaldus will try later. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=80313&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
|
![]() |
mtpocket author 9/17/2016 |
Hi Romaldus, if you want to use my_random_string() function in more than one table, just put that function in global session like After Successfully Login or After application Initialized event |
![]() |
romaldus 9/17/2016 |
Hi Romaldus, If this goes before record added. function my_random_string($length=30) { $chars ="1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; $final_rand=''; for($i=0;$i<$length; $i++) { $final_rand .= $chars[ rand(0,strlen($chars)-1)]; } return $final_rand; } Where would the below go? $values["ID"] = my_random_string(); Thanks
|
![]() |
mtpocket author 9/19/2016 |
Thanks Romaldus, it worked like a charm. also in before record added event, just after my_random_string function |
![]() |
mtpocket author 9/22/2016 |
Hi, |
![]() |
romaldus 9/22/2016 |
Hi, This code has hashed the record ID successfully and this is what the link displays, localhost/CashBackupview.php?editid1=TNFwH5KO49uqlBjdsH1aN4S5haHvqS. This email link will be sent to external people (guests) to view the viewpage. By removing / changing some characters I can expose my entire list page as well. The link can change to localhost/CashBackuplist.php. How can I provide guest view permissions only? My guest permissions I've set to List/View but would like view & not list. Thanks
|