QRMAN - QR Code and Shorturl Generator

QRMAN written entirely in PHP with Ajax interface using jQuery is a simple QR Code and Shorturl Generator. Now you can run your own QR Code Generation and Shorturl service from your domain.


QRMAN Features


  • Open Source software - released under GPL License.
  • Generates 10 types of QR Codes.
  • Generates Shorturl for every QR Code.
  • Generates Tracking Code and Non Tracking Code.
  • Create, Edit and Delete QR codes.
  • Url Redirection for Urls and Bookmarks - similar to shorturl services.
  • Excellent statistics: click reports, referrers tracking, visitors geo-location, platform and browsers.
  • Clean Ajax interface.
  • API for QR Code Generation, Store QR Codes and Fetch statistics.
  • API output in JSON, JSONP and XML.
  • Supports Cross Domain Ajax Request.
  • Inbuilt Installer for easy Installation .
  • User Management feature for Admin.
  • Registration, Password reset feature for users.

Download

Download QRMAN from techlister.com


Your contribution will help in the further development of QRMAN

QRMAN 1.0 Installation

  • Unzip the QRMAN archive
  • Upload the unzipped files to your domain public_html or www folder
  • Create a new database ( tables are automatically created by the installer )
  • Point your browser to http://yoursite.com/ and follow the on screen instructions.

Configuration


qr-config.php - is automatically created by the installer. This file contains the settings required to run QRMAN so you must know few things about the settings within this file.


DB Settings

define('QRGEN_DB_HOST', 'localhost'); The database host, example: 'localhost'
define('QRGEN_DB_USER', 'db user'); your MySQL username, example: 'jack'
define('QRGEN_DB_PASS', 'db pass'); your MySQL password, example: 'Secret123'
define('QRGEN_DB_NAME', 'qrman'); The database name, example: 'qrman'
define('QRGEN_DB_PREFIX', 'qr_'); The name prefix for all the tables QRMAN will need, example: 'qr_'

Email Setting

define('EMAIL_WELCOME', true); set this false if you do not want your users to receive a welcome Email after registration.

QRMAN API - Generate QR Codes

Features

  • Generate QR Codes or Get the stats of existing QR Code
  • Save QR Codes based on the type.
  • Output format: JSON, XML, JSONP - for stats and save the qrcodes.
  • Output format: image/png - for generating QR Codes
  • Authentification through API key which is automatically generated when the user is created

Usage

You need to send parameters to http://yoursite.com/qr-api.php either via GET or POST always remember to URL encode the parameters if you are sending via GET.


Parameters for generating QR Code

ParameterValueDescription
actionqrSpecifies that your are requesting a QR Code
e.g: http://yoursite.com/qr-api.php?action=qr 
ecL, M, Q, H Error Correction value, it can be any one of these vales.
e.g: http://yoursite.com/qr-api.php?action=qr&ec=L 
More on Error Correction values below this table
sizewidth and heightWidth and height of the image
e.g: http://yoursite.com/qr-api.php?action=qr&size=widthxheight 
If size is not provided the size is determined automatically.
dataActual data to be encodedThis data will be coverted to QR Code, So you need to encode it for various types like urls, bookmarks, vcard etc
e.g: http://yoursite.com/qr-api.php?action=qr&data=yourdata 

Error Correction Values

These values specify the error correction level of the QR Code, so the generated QR Code can recover certain amount of data lost due to the damage of QR Codes.

  • L - Recovery of 7% Data loss
  • M - Recovery of 15% Data loss
  • Q - Recovery of 25% Data loss
  • H - Recovery of 30% Data loss

Sample PHP code

$width = $height = 200; $url = urlencode("http://techlister.com"); $error = 'L'; echo "<img src="http://yoursite.com/qr-api.php?size={$width}x{$height}&action=qr&ec=$error&data=$url" />";

Sample Output



Cross Domain Ajax request

You can also create QR Codes by sending data through Ajax request. But while sending through ajax you must set a parameter to identify ajax request. Set an hidden field with value "ajax" and send the form data via Ajax.

Example HTML

<form action="http://formican.com/qr-api.php" id="qrform" method="post"> <input type="text" name="data"> <input type="hidden" name="action" value="qr"> <input type="hidden" name="ajax" value="ajax"> <input type="submit" name="Send"> </form> <div id="qrc"></div>

Example Ajax ( jQuery )

$(document).on('submit', '#qrform', function( event ) { event.preventDefault(); var formd = $(this).serialize(); $.ajax({ type: 'POST', url: 'http://formican.com/qr-api.php', crossDomain: true, data: formd, success: function( image ) { $('#qrc').html( '<img src="data:image/png;base64,' + image + '"/>' ); }, error: function (responseData, textStatus, errorThrown) { alert( 'POST failed.' + responseData + ' | ' + textStatus + ' | ' + errorThrown ); } }); });

Note:

You must note that, setting an input field with "ajax" as value will send you the image as base64 encoded string which you need to insert in the document as shown above. If "ajax" field is not set while making an Ajax request you will not get the desired output

QRMAN API - Generate, Save and retrieve Statistics.

This feature provides a flexible interface to generate QR Codes. You simply send all the required data, and the QRMAN will take care of encoding them and converting them into QR Codes.

Usage

You need to send parameters to http://yoursite.com/qr-api.php either via GET or POST. This feature also supports cross domain Ajax request. Exmples can be found inside the docs folder.

Example

http://www.formican.com/qr-api.php?action=save&qt=bookmarks&title=free 3d models&url=http://animium.com&apk=420e6225cfb09dcd2c4b66b18ff1bed6&format=xml&tr=3

Example Output

<result> <qrimg>http://formican.com/qrimages/admin/qrcode1365495952.png</qrimg> <width>273</width> <status>success</status> <trwidth>217</trwidth> <trimg>http://formican.com/qrimages/admin/trackcode1365495952.png</trimg> <trcstatus>3</trcstatus> <qrtype>bookmarks</qrtype> <shorturl>http://formican.com/o</shorturl> </result>

Parameters for generating QR Code


Expected Parameters

ParameterValueDescription
actionsaveSpecifies that your are requesting the api to save the QR Code
e.g: http://yoursite.com/qr-api.php?action=save 
qt QR Code Types

can be one of the following

  • urls
  • bookmarks
  • texts
  • telephones
  • sms
  • emails
  • emsg
  • mecard
  • vcard
  • geo
Specifies the type of qr code to be generated
e.g: http://yoursite.com/qr-api.php?action=save&qt=bookmarks
apk api key Your api key which you will get while registering your account.
e.g: http://yoursite.com/qr-api.php?action=save&apk=secret 
format Expected output format

can be one of the following

  • XML
  • JSON
  • JSONP
Output will be presented in these formats. Default format is xml
e.g: http://yoursite.com/qr-api.php?action=save&format=json 
tr Tracking Status

can be one of the following

  • 1 - Tracking Code only
  • 2 - Non Tracking Code
  • 3 - Both
The type of QR Code to be Generated. Default is 1
e.g: http://yoursite.com/qr-api.php?action=save&tr=3 

Tracking and Non Tracking

Tracking Code - Tracking code contains the shorturl generated for every QR Code, which actually provides tracking ability.

Non Tracking Code - This is the actual data, for example vcard data, that contains name, address etc.


QR Code Data Parameters

These are the actual parameters send to the server to be encoded into QR Code, for example to create a bookmark, the following parameters are required.


title - title of the website

url - url of the website

the above parameters can be send as shown in the example, and encoding will be taken care of by the api.


Following are the parameters to be sent for various types of QR Codes. You can setup a form with all the required field names and submit it to the api, also remember it supports Cross Domain Ajax requests.

ParameterDescription
Bookmarks
urlUrl of the site
titletitle of the site - will be detected automatically if left empty
Urls
urlUrl of the site
Texts
simptxtSimple Text
Telephones
phnoPhone number
Sms
phnoPhone number
smstxtSms Text
Emails
emailEmail id
Email message
emailEmail id
subjectSubject of the Email
bodyBody of the email
Mecard
fnameFirst name
fnameFirst name
phnoPhone number
emailEmail id
urlWeb address
noteAdditional Notes
bdayBirthday - in this format YYYY-MM-DD
streetAddress - street
cityAddress - city
stateAddress - state
zipAddress - zip
countryAddress - country
vCard
vcverVcard Version - can be one of the following - 2.1, 3.0 or 4.0 - do not leave the ".0" in version numbers
fnameFirst name
lnameLast name
wphnoWork phone number
hphnoHome phone number
bdayBirthday - in this format YYYY-MM-DD
emailEmail id
urlWeb address
photoUrl of the photo image
orgOranisaion
titleTitle
hstreetHome address - street
hcityHome addresss - city
hstateHome address - state
hzipHome address - zip
hcountryHome address - country
wstreetWork address - street
wcityWork address - city
wstateWork address - state
wzipWork address - zip
wcountryWork address - country
Geo Location
latLatitude
lngLongitude
altitudeAltitude

Retrieve Statistics

You can get the number clicks by country with this feature.

Usage

You need to send parameters to http://yoursite.com/qr-api.php either via GET or POST. This feature also supports cross domain Ajax request. Exmples can be found inside the docs folder.

Example

http://formican.com/qr-api.php?action=stat&kw=J&format=xml&apk=f0ebc7890scghjkyrwf651bc1a63d

Example Output

<result> <keyword>J</keyword> <type>vcard</type> <timestamp>2013-04-16 23:09:59</timestamp> <ip>117.254.148.117</ip> <clicks>3</clicks> <shorturl>http://formican.com/J</shorturl> <countries> <IN>2</IN> <US>1</US> </countries> </result>

Expected Parameters

ParameterValueDescription
actionstatSpecifies that your are requesting the api to fetch the statistics
e.g: http://yoursite.com/qr-api.php?action=stat 
format Expected output format

can be one of the following

  • XML
  • JSON
  • JSONP
Output will be presented in these formats. Default format is xml
e.g: http://yoursite.com/qr-api.php?action=stat&format=json 
apk api key Your api key which you will get while registering your account.
e.g: http://yoursite.com/qr-api.php?action=stat&apk=secret 
kw keyword keyword or shorturl for which the statistics is requested
e.g: http://yoursite.com/qr-api.php?action=stat&kw=Z 

Credits

Author

Savoul Pelister

pelister@techlister.com


Software Testing

Sathish Rajakumar

http://techlister.com


For support or feature requests write to us at the above email address or leave a comment on http://techlister.com/php/qrman-url-shortener-and-qr-code-generator/865/ Thanks to everyone who helped to make this simple piece of software.

Software Requirements

PHP 5.2.4+

MySQL 5.0+

PHP Data Objects ( PDO ) interface is used to access MySQL


htaccess file

QRMAN needs its own .htaccess located in the root of the installation You cannot install QRMAN along with other apps or scripts like WordPress, in the same directory. They need their own .htaccess file as they handle urls differently. If you want to install QRMAN on the same domain, then install it in a subdirectory, such as yoursite.com/qrman.