Page 1 of 3

QR Code

PostPosted: Thu Nov 03, 2011 2:59 pm
by neumannon
Anyone try adding a scannable code (QR Code or whatever) to the file download file page? I may mod the download php page if it hasn't been done. That may be a cool feature for a future release.

Re: QR Code

PostPosted: Fri Nov 04, 2011 2:02 am
by SamEA
At the moment there are no QR Codes/scannable codes in any DFH release, but feel free to mod this into the download page :). If successful, it will be included in a future release.

Re: QR Code

PostPosted: Fri Nov 04, 2011 12:09 pm
by neumannon
I was able to mod the download.php file to show a qr code for downloading the file on a mobile device. It was actually quite simple using the google qr code api. When I have a chance, I will post the code with a screenshot of the result. I am a noob to php so there may have been a better way to implement but it works and I'm happy :). Stay tuned...

Re: QR Code

PostPosted: Fri Nov 04, 2011 2:07 pm
by SamEA
neumannon wrote:I was able to mod the download.php file to show a qr code for downloading the file on a mobile device. It was actually quite simple using the google qr code api. When I have a chance, I will post the code with a screenshot of the result. I am a noob to php so there may have been a better way to implement but it works and I'm happy :). Stay tuned...


No ones 100% when it comes to coding and besides, the more one codes the more experience he/she will gain in how to (style) code more efficiently. Well done and I look forward to your mod.

SamEA

Re: QR Code

PostPosted: Fri Nov 04, 2011 3:07 pm
by neumannon
Alright! I am testing the image upload feature of the site. For some reason when I tried uploading a png file, it said the file wasn't allowed even though png is in the list of allowed image formats. Must not have support for png images yet. No biggie though. I just removed .png as a possible image format for upload. I was able to get the jpg screenshot uploaded.

So here is the download.php screenshot modded for qr code...
Image

I added the below code to the [root]/download.php file. There are various parameters for the google function which can be adjusted. I left the defaults alone and seems to work well. There may be an easier way to get the current URL for encoding but that was the one I was able to find.
Code: Select all
function generateQRwithGoogle($chl,$widhtHeight ='150',$EC_level='L',$margin='0')
 {
     $url = urlencode($url);
     echo '<img src="http://chart.apis.google.com/chart?chs='.$widhtHeight.
'x'.$widhtHeight.'&cht=qr&chld='.$EC_level.'|'.$margin.
'&chl='.$chl.'" alt="QR code" widhtHeight="'.$size.
'" widhtHeight="'.$size.'"/>';
 }

function currPageURL()
{
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 return $pageURL;
}


Then I added this line to [root]/styles/Indigo/download.php at the bottom of the table. Of course it can be put anywhere on the page.
Code: Select all
<?php
$urlToEncode=currPageURL();
?>

<tr><td align=left valign=top bgcolor=#F4F4F4 background="img/button03.gif\">QR Code: </td><td bgcolor=#EEF4FB background="img/button03.gif"><?php generateQRwithGoogle($urlToEncode);?></td></tr>


I hope that helps out anyone interested in doing the same thing. If there is an easier/simpler way to do any of this, please let me know and I'll make the change.

And this was done on the 1.2.3 DFH release.

Re: QR Code

PostPosted: Fri Nov 04, 2011 3:11 pm
by neumannon
And don't try to scan that code btw. I just loaded DFH the other day and I have only been doing testing on the local host. so the URL for that code is localhost and not my actual public hostname. I just did test using my public domain name and it worked perfectly on my phone. WooHoo!

Re: QR Code

PostPosted: Fri Nov 04, 2011 3:15 pm
by neumannon
I suppose I could also add that to the view image page as well.

Re: QR Code

PostPosted: Fri Nov 04, 2011 4:28 pm
by neumannon
Image viewer page has been modded too. Takes me right to the image on my phone.

Re: QR Code

PostPosted: Tue Nov 08, 2011 11:04 am
by SamEA
Any functioning demo available? Thank you.

Re: QR Code

PostPosted: Tue Nov 08, 2011 3:38 pm
by neumannon
Ha, in my excitement I forgot to post demos.

Here is one for a normal file download.
http://home.sk1llsh0t.com/dfh/download.php?file=608online.wav

Here is one for the image viewer.
http://home.sk1llsh0t.com/dfh/viewer.php?id=52545Desert.jpg