Skip to content

Instantly share code, notes, and snippets.

View Shaz3e's full-sized avatar

Shahrukh A. Khan Shaz3e

View GitHub Profile
@Shaz3e
Shaz3e / .htaccess
Last active November 26, 2015 15:54
RewriteEngine On
RewriteCond $1 !^(index\.php)
RewriteRule ^(.*)$ index.php?l=$1 [L]
@Shaz3e
Shaz3e / CSS---Blur-Filter-vs-Opacity.markdown
Last active August 29, 2015 13:58
CSS - Blur filter vs Opacity
@Shaz3e
Shaz3e / XML with PHP
Last active August 29, 2015 13:57
Get XML Elements into PHP File
<?php
$xml = simplexml_load_file("file.xml");
//print_r($xml);
//echo '<br>';
//echo $xml;
//echo '<br>';
//$xml = simplexml_load_file("xml_file.xml");
//$details = $xml->getName();
//$type = $xml->show->attributes()->type;
@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/
@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]
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php [L,QSA]
# http://domain/about -> http://domain/about.php
--------------------------------------------------
.htaccess
<?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 / 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