PHP QR Code Generator page is the most visited page on my blog. It has evolved from a small page with a few features into a full featured real time generator on which you can choose from a lot of actions for your device and create different image types, even vector images. As far as I know, there are no free generators on the internet that can match its features, and it is also better than most of the paid ones.
It even works on new generation mobile phones like iPhone or Nexus One.
And as of today, it can also create Data Matrix codes, thanks to the folks who have created the wonderful libdmtx library. So, I have made a name change on the page.
It is now called PHP QR Code and Data Matrix Generator. I hope it continues to prove useful to everyone who use it.
Checking my blog stats, I saw that most people come to my Real Time QR Code Generator PHP Function post. So, I decided to create a decent page for QR Code generation instead of linking to a URL which accepts only base64 encoded variables. The new page is PHP QR Code Generator page, and now you can, not only create an image that redirects you to a web address, but also can call a phone number, send an sms and send an e-mail. Also you can just encode plain text into a QR Code image.
UPDATE: vCard and bookmarks creation added.
Hope it proves to be useful for some people out there.
We were having stale connection problems when a RAC node was behaving abnormally, because the JDBC pool which was created by Tomcat was not getting any notification about it. So I started searching for a way to take advantage of Oracle’s Fast Connection Failover (FCF) mechanism. FCF is superior to Transparent Application Failover (TAF) as it is event based and supports load balancing across the RAC nodes. It is also superior to having no failover mechanism whatsoever.
FCF leverages Oracle Notification Service (ONS) to get information about database events. With the help of ONS, a JDBC pool which has FCF enabled can see if a RAC node is up or down and can act accordingly. To be able to use the method I am about to show, you will have to have a minimum Oracle RAC version of 10.2.0, because Oracle versions prior to that do not support “Remote ONS”, which is an essential part of this configuration.
To have a working Oracle connection pool in your Tomcat server, first you must have the necessary JAR files in your Tomcat classpath. Also you must use the appropriate JAR files for your JVM. If you are using Java SDK 1.5 or 1.6, you will have to get the JAR files from Oracle Client 18.104.22.168 or above. If you don’t use the appropriate JAR files with your JVM, you will most probably have severe problems. Pick one of the following configurations:
- Java SDK 1.4:
ons.jarfrom Oracle client 10.2.0.3 or above
- Java SDK 1.5:
ons.jarfrom Oracle client 22.214.171.124 or above
- Java SDK 1.6:
ons.jarfrom Oracle client 126.96.36.199 or above
I am using Tomcat 6.0.20 and Java SDK 1.6 as of this writing. And I have
ons.jar from Oracle client 188.8.131.52.
Copy these two JAR files to
/common/lib directory of your Tomcat server. If one of these files does not exist in your environment, your pool will not work.
Now, create a file named
ons.config in the directory
$ORACLE_HOME/opmn/conf/ and add the following to that file:
localport=6100 remoteport=6200 nodes=rac1:6200,rac2:6200
You will override the settings written in this file in the JDBC Pool in your server.xml file. Oracle just needs to see this file to get Remote ONS working in Tomcat.
Add the following to your Tomcat startup script:
export ORACLE_HOME="Path to your Oracle Home Directory" export CATALINA_OPTS="$CATALINA_OPTS -Doracle.ons.oraclehome=$ORACLE_HOME"
Now your environment is complete. To get FCF working, you have to create a special JDBC pool in your
server.xml. You can create the pool in both
GlobalNamingResources or your web application’s own
context. The advantage of creating the pool globally gives you the ability to use the connection in every web application defined in your Tomcat server. I will create the pool globally in this example.
server.xml and add the following into
<Resource name="JDBC/Pool" auth="Container" ONSConfiguration="nodes=rac1:6200,rac2:6200" connectionCachingEnabled="true" description="FCF Datasource" driverClassName="oracle.jdbc.OracleDriver" factory="oracle.jdbc.pool.OracleDataSourceFactory" fastConnectionFailoverEnabled="true" implicitCachingEnabled="true" connectionCacheProperties="(InitialLimit=5, MinLimit=5, MaxLimit=20, ConnectionWaitTimeout=30)" connectionCacheName="tomcatConnectionCache" user="username" password="password" type="oracle.jdbc.pool.OracleDataSource" url="jdbc:oracle:thin:@(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip)(PORT = 1521))(LOAD_BALANCE = yes)(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = SERVICE)))" />
Let’s explain the important directives in this configuration:
name: The name of the pool to be used when getting a connection from it.
ONSConfiguration: Remote ONS configuration which is used for getting notifications from the RAC. Important: The IP addresses or hostnames to use here should point to the main IP addresses of the RAC nodes, not the VIP addresses.
fastConnectionFailoverEnabled: Enable FCF mechanism.
implicitCachingEnabled: Enable implicit caching. This is a requirement of FCF, without implicit caching, FCF will not work.
connectionCacheProperties: Here, you can set the connection cache limits. To get a thorough explanation of these variables, refer to Implicit Connection Caching Page at Oracle.
connectionCacheName: The name of the cache. If you don’t set a name, Oracle will create a unique name everytime the cache is created, which is not recommended. Also if you create more than one JDBC pool (for example, if you have two user schemas to connect on Oracle) be sure to give a unique name for each of those pools, because this name is used on server side (database side).
url: Be careful to use the VIP addresses of RAC nodes in your url, not the main IP addresses.
For all web applications to see the newly created pool, you can add the following to the global
context.xml of your Tomcat server:
<ResourceLink global="JDBC/Pool" name="JDBC/Pool"/>
Restart your Tomcat server and you are done. You now have a FCF enabled JDBC pool. I suggest you to read the following documents thoroughly:
Today I am releasing PHP Captcha 1.0.
The main difference of PHP Captcha from other free or paid PHP implementations is, that it is written to utilize ImageMagick functions through the wonderful MagickWand PHP API to create CAPTCHA images that are hard enough for bots to crack, while more readable by humans than the others.
Quoting Aleksey Kolupaev of OCR Research Team, to whom I am thankful for his help on PHP Captcha:
“Everything can be cracked, but this one is a hard nut.”
Output of default configuration:
Output of a custom (a little too unpractical) configuration:
PHP Captcha has a lot of configuration options including:
- Random background colors
- Random background noise
- Random text fill and stroke colors
- Random text string length
- Random font size
- Random text direction
- Random character rotation
- Random image swirling
- Random foreground noise and so on…
The default configuration of PHP Captcha is based on a simple principle told by Aleksey: When average users come to your site and read a CAPTCHA image, they tend to enter the characters they read from left to right first, instead of reading any instructions that may accompany the image and say “enter X characters from the image” or “enter the text in the direction the arrow in the image points to” etc. PHP Captcha tries to address the needs of the sites with an average user base as default. But it also has a lot of options for you to customize your image according to your user base.
You can download PHP Captcha from the downloads page.
UPDATE: PHP Captcha 1.0 is released. Thanks to all who beta tested it.
I have started a new project named PHP Captcha which will be released as open source.
It will be a PHP Captcha implementation which will use ImageMagick instead of standard PHP GD libraries. It purpose is to create less crackable CAPTCHAs than the ones created with the readily available implementations that use GD.
I need beta testers who have some free time to test PHP Captcha. All you need to do is go to http://www.keremerkan.net/captchatest.php and solve the CAPTCHA that is written there. Please solve as many as you can, so that I can optimize the configuration.
Also I am getting help from Aleksey from OCR Research Team hoping to release PHP Captcha stronger than most two dimensional CAPTCHA implementations out on the wild. Thanks very much Aleksey for all your time.
Thanks to all who tested and still test PHP Captcha.
UPDATE: Please read this post. You will be able to create more different images now!
If you have read my earlier posts, you must have seen that I am excited about implementing QR Code to my projects. These mostly include my work projects.
Today I have discovered that Fukuchi Kentaro, who is an assistant professor has written a very useful QR Code library to use on UNIX based systems. I have immediately downloaded the library and compiled it. It ran smoothly on my server, so I created a little PHP function to use with this library, for real time QR Code generation.
I have put a page on my server for you to use the function. You can call that page supplying a base64 encoded URL and it will create a QR Code PNG on the fly.
This is a demonstration of calling the page:
UPDATE: The page gets redirected to PHP QR Code Generator page on this blog now.
aHR0cDovL2tlcmVtZXJrYW4ubmV0Lwo= is Base64 encoded presentation of my blog URL, http://keremerkan.net/
You can easily Base64 encode this string by executing the command below from a UNIX shell:
echo http://keremerkan.net/ | openssl enc -base64
The function will only accept Base64 encoded URLs to avoid some nasty side effects. Also after decoding the URL, there should be no dangerous characters like ‘,!,<,> in the URL.
By calling the page like I gave above, you will get the image below (It is auto generated):
To read this image from your phone, you will need a QR Code reader installed on your mobile phone. You can get a QR Code reader from QuickMark or Kaywa sites for free. (PS: Kaywa reader needs you to register for download)