Skip to content

Instantly share code, notes, and snippets.

@mebcomputers
mebcomputers / gist:2499697
Created April 26, 2012 13:40
html5: basic template
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<title></title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
@mebcomputers
mebcomputers / gist:2505353
Created April 27, 2012 03:08
php: auto update copyright
function autoUpdatingCopyright($startYear){
// given start year (e.g. 2004)
$startYear = intval($startYear);
// current year (e.g. 2007)
$year = intval(date('Y'));
// is the current year greater than the
// given start year?
@mebcomputers
mebcomputers / gist:2505346
Created April 27, 2012 03:04
php: get twiiter followers amount
function get_followers($twitter_id){
$xml=file_get_contents('http://twitter.com/users/show.xml?screen_name='.$twitter_id);
if (preg_match('/followers_count>(.*)</',$xml,$match)!=0) {
$tw['count'] = $match[1];
}
return $tw['count'];
}
$nb = get_followers('phpsnippets');
@mebcomputers
mebcomputers / gist:2505377
Created April 27, 2012 03:15
php: check website is running
//returns true, if domain is availible, false if not
function isDomainAvailible($domain)
{
//check, if a valid url is provided
if(!filter_var($domain, FILTER_VALIDATE_URL))
{
return false;
}
//initialize curl
@mebcomputers
mebcomputers / check.php
Created April 29, 2012 06:14
php: visitor log
$filename = 'log.txt';
$timestamp = date('l d F Y H:i:s');
$u_agent = $_SERVER['HTTP_USER_AGENT'];
$ub = '';
if(preg_match('/MSIE/i',$u_agent))
{
$ub = "Internet Explorer";
}
elseif(preg_match('/Firefox/i',$u_agent))
{
@mebcomputers
mebcomputers / gist:2551712
Created April 29, 2012 16:30
php: explode to array from file
<?php
$filename = "file.txt";
$handle = fopen($filename, "r");
$data = fread($handle, filesize($filename));
$data_array = explode(",", $data);
@mebcomputers
mebcomputers / gist:2558567
Created April 30, 2012 14:02
php: get latest twitter status
class twitter {
public $twitter_base = 'http://twitter.com/statuses';
public $twitter_username = '<-username->'; //Your username here
function latest(){
$url = "$this->twitter_base/user_timeline/$this->twitter_username.xml?count=5";
$content = file_get_contents($url);
@mebcomputers
mebcomputers / gist:2550712
Created April 29, 2012 14:21
php: create visitor log file
<?php
class log {
public $filename;
public $timestamp;
public $ip;
public $u_agent;
public $u_refer;
public $ub;