Skip to content

Instantly share code, notes, and snippets.

View Shaz3e's full-sized avatar

Shahrukh A. Khan Shaz3e

View GitHub Profile
@Shaz3e
Shaz3e / Skype API
Created February 11, 2014 19:33
How to use Skype API to Detect Online Users example
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>How to use Skype API to Detect Online Users</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<style type="text/css">
.inputbox{
display: inline-block;
@Shaz3e
Shaz3e / Image Less CAPTCHA with PHP
Created February 12, 2014 19:37
Image Less CAPTCHA with PHP
<?php
session_start();
if (isset($_POST['submit'])){
$number = floatval($_POST['number']);
if ($number != $_SESSION['correctNumber']) {
$message = "<br /><span class='errors'>The number you entered for the spam filter is incorrect.</span><br />";
}else{
$message = "<br /><span class='success'>CAPTCHA Verified!!!</span><br />";
}
@Shaz3e
Shaz3e / Random String in PHP
Created February 16, 2014 14:07
HOW TO GENERATE RANDOM STRING IN PHP.
<?php
echo randomString(10);
function randomString($length, $type = '') {
// Select which type of characters you want in your random string
switch($type) {
case 'num':
// Use only numbers
@Shaz3e
Shaz3e / Add text to images with PHP
Created February 16, 2014 13:57
Add text to images with PHP
<?php
header ("Content-type: image/jpeg");
$string = "All Copyrights reserved.";
$font = 4;
$width = imagefontwidth($font) * strlen($string) ;
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php [L,QSA]
# http://domain/about -> http://domain/about.php
--------------------------------------------------
.htaccess
@Shaz3e
Shaz3e / Login Class
Last active August 29, 2015 13:56
PHP Login Class
class Auth {
var $user_id;
var $username;
var $password;
var $ok;
var $salt = "shaz3e";
var $domain = ".domain.com";
function Auth(){
global $db;
# .htaccess - www -> http:// - http:// -> www - nice URLs
Options -Indexes
Options +FollowSymLinks
RewriteBase /
RewriteEngine On
## /id/product-name/ to index.php?id=id
RewriteRule ^([0-9]*)/(.*)$ index.php?id=$1 [L]
# add www to any url
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
# remove www from any url
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.domain\.com [NC]
<?php
functino isValidEmail($email){
$checkEmail = "/[a-zA-Z0-9_-.+]+@[a-zA-Z0-9-]+.[a-zA-Z]+/";
// check if its valid email return true
if(preg_match($checkEmail,$email) > 0){
return true;
}else{
return false;
@Shaz3e
Shaz3e / RSS Feeds with PHP
Created March 1, 2014 20:30
Get RSS Feeds using PHP
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>RSS Feeds</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>
<body>
<?php
$feedname = 'TechCrunch/'; // feedname/ or feed/