Category : "Coding"

All kinds of Programming.

15+ tips to secure your php application

Php is used to write web applications which are online and publicly accessible. Therefore security is a fundamental necessity of these applications to keep the data safe and free from unauthorized access. Below are a bunch of simple tips/hacks/ideas to design your php applications to have better security. The Code 1. Avoid short tags If they are disabled on some server , then all ...

40+ Useful Php tips for beginners – Part 1

In this series we are going to look into some useful tips and techniques that can be used to improve and optimise your php code. Note that these php tips are meant for beginners and not those who are already using mvc frameworks etc. The Techniques 1. Do not use relative paths , instead define a ROOT path Its quite common to see ...

Execute shell commands in PHP

Like any other language php applications often need to execute system commands like they are run from the terminal/console/commandline. Php has multiple functions to do this task. Lets take a look at each of these 1. system "system() is just like the C version of the function in that it executes the given command and outputs the result. The system() call also ...

Php get list of locales installed on system

On linux , the list of locales installed on the system can be fetched through the terminal command locale -a : $ locale -a C C.UTF-8 en_AG en_AG.utf8 en_AU.utf8 en_BW.utf8 en_CA.utf8 en_DK.utf8 en_GB.utf8 en_HK.utf8 en_IE.utf8 en_IN en_IN.utf8 en_NG en_NG.utf8 en_NZ.utf8 en_PH.utf8 en_SG.utf8 en_US.utf8 en_ZA.utf8 en_ZM en_ZM.utf8 en_ZW.utf8 es_AR.utf8 es_BO.utf8 es_CL.utf8 es_CO.utf8 es_CR.utf8 es_DO.utf8 es_EC.utf8 es_ES.utf8 es_GT.utf8 es_HN.utf8 es_MX.utf8 es_NI.utf8 es_PA.utf8 es_PE.utf8 es_PR.utf8 es_PY.utf8 es_SV.utf8 es_US.utf8 es_UY.utf8 es_VE.utf8 hi_IN hi_IN.utf8 nl_AW nl_AW.utf8 nl_BE.utf8 nl_NL.utf8 POSIX si_LK si_LK.utf8 zh_CN.utf8 zh_SG.utf8 Now this command can be used inside php to get the list. Along with this list we can also add some information like language name and country name using a list of countries and languages. Here is a list ...

Php script to fetch whois information of ip address

Whois information of ip addresses IP addresses are in the form of a.a.a.a where each letter is a number from 0-255. You would be happy to know that every ip address has some information associated to it. For example which isp or organisation has been allotted that ip address and where is that organisation located. This in turn tells the location ...

C program to get mac address from interface name on Linux

The mac address or the hardware address or the ethernet address of an interface is a 48 bit number that looks like this : 00:1c:c0:f8:79:ee The mac address of an interface can be found given its name. The function to use is ioctl. Code #include <stdio.h> //printf #include <string.h> //strncpy #include <sys/socket.h> #include <sys/ioctl.h> #include <net/if.h> //ifreq #include <unistd.h> //close int main() { int fd; struct ifreq ifr; char *iface = "eth0"; unsigned char *mac; fd = socket(AF_INET, SOCK_DGRAM, ...

C program to get ip address from interface name on Linux

Interface name is something like "eth0" and the ip address of the interface can be retrieved using the ioctl function. Here is a simple piece of code that demonstrates how : Code #include <stdio.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/ioctl.h> #include <netinet/in.h> #include <net/if.h> #include <unistd.h> #include <arpa/inet.h> int main() { int fd; struct ifreq ifr; char iface = "eth0"; fd = socket(AF_INET, SOCK_DGRAM, 0); //Type of address to retrieve - IPv4 IP address ifr.ifr_addr.sa_family = AF_INET; //Copy ...

Use google maps in desktop applications

Google maps is a popular geomap service used by many sites to display maps and locations. The api provides javascript code to integrate itself into any website. It is now possible to use google maps in desktops applications. Check Terms for more information. For this a browser has to be embedded in the desktop application. Here is a desktop application made ...

Get time difference in microtime in C

The function gettimeofday can be used to retrieve the total number of seconds and balance microseconds elapsed since EPOCH. Structure timeval looks like this : struct timeval { time_t tv_sec; /* seconds */ suseconds_t tv_usec; /* microseconds */ }; On Linux it can be done like ...

Data type u_int8_t , u_int16_t , u_int32_t on windows

On Linux the header file sys/types.h provides the fixed sized integer data types like these : u_int8_t; u_int16_t; u_int32_t; On windows the header file stdint.h provides similar ones but with slightly different names , uint8_t etc. So if you are writing cross platform code you can get the same ones on windows as in a manner shown below : #if defined(_WIN32) #include <stdint.h> typedef uint8_t u_int8_t; typedef uint16_t ...

Pages:«1...78910111213...19»


Connect with us