Tag: code

PHP

Getting visitors country from their IP

geoplugin geoPlugin is a free and easy webmaster resource to provide geolocation technology to your pages. $xml = simplexml_load_file(’http://www.geoplugin.net/xml.gp?ip=’.$visitor_ip_address);   foreach ($xml as $key => $value) { echo $key , ‘= ‘ , $value , ‘<br>’; }$xml = simplexml_load_file(‘http://www.geoplugin.net/xml.gp?ip=’.$visitor_ip_address); foreach ($xml as $key => $value) { echo $key , ‘= ‘ , $value , ‘<br>’; …

Kohana, PHP

How to avoid repeating code to check if a user is logged in

First of all create your own Controller that all other controllers will inherit from. Name it Mycontroller, for example: defined(’SYSPATH’) or die(’No direct script access.’);   class Controller_Mycontroller extends Controller {   public function before() { parent::before(); //…. }   } // Enddefined(‘SYSPATH’) or die(‘No direct script access.’); class Controller_Mycontroller extends Controller { public function …

General

Issuer certificate is invalid. (Error code: sec_error_ca_cert_invalid)

If you receive the following error in firefox when you try to visit a secure web site: https://mywebsite.com/index.php Secure Connection Failed An error occurred during a connection to mywebsite.com. Issuer certificate is invalid. (Error code: sec_error_ca_cert_invalid)https://mywebsite.com/index.php Secure Connection Failed An error occurred during a connection to mywebsite.com. Issuer certificate is invalid. (Error code: sec_error_ca_cert_invalid) You …

C, Linux

Create QR codes with c

Library To create QR codes we are going to use open source library libqrencode. Installation I you are in Ubuntu install libqrencode by issuing the following command: sudo apt-get install libqrencode libqrencode-devsudo apt-get install libqrencode libqrencode-dev Source code #include <stdio.h> #include <qrencode.h> #include <errno.h>   int main(){ QRcode *qrcode; qrcode = QRcode_encodeString("http://webnetsoft.gr", 4, QR_ECLEVEL_H, QR_MODE_8, …

General

QR code

QR Code (Quick Response Code) is two dimensional code which is categorized in matrix code. The code consists of black modules arranged in a square pattern on a white background. The information encoded can be made up of four standardized kinds of data (numeric, alphanumeric, byte/binary, Kanji). The QR Code was designed for high speed …

Cross-Platform, Java

Get URL contents with Java

It is very easy to download url contents using a few lines of java code: The source code below is licensed under GPLv3. GetURLContents.java (GetURLContents) import java.io.*; import java.net.*;   public class GetURLContents {   public static void main (String[] args) { URL url; InputStream input = null; BufferedReader inputs; String str;   try { …