Skip to content

Instantly share code, notes, and snippets.

@khoand0000
khoand0000 / check_login.php
Created September 9, 2014 19:10
check login
<?php
// http://prajapatinilesh.wordpress.com/2009/01/14/manually-set-php-session-timeout-php-session/
// Change the session timeout value to 30 minutes // 8*60*60 = 8 hours
//ini_set('session.gc_maxlifetime', 30*60);
//// php.ini setting required for session timeout.
//
//ini_set('session.gc_maxlifetime',30);
//ini_set('session.gc_probability',1);
//ini_set('session.gc_divisor',1);
@khoand0000
khoand0000 / use_phpexcel.php
Created September 9, 2014 19:19
How to use PHPExcel
<?php
/**
* User: videde
* Date: 8/21/13
* Time: 1:37 AM
*/
set_include_path(dirname(__FILE__).'/Classes/');
include 'PHPExcel/IOFactory.php';
function action() {
@khoand0000
khoand0000 / use_phpquery.php
Created September 9, 2014 19:20
How to use phpQuery
<?php
/**
* User: videde
* Date: 8/21/13
* Time: 1:41 AM
*/
require('phpQuery/phpQuery.php');
function action() {
$content = ""; // content of web page
$doc = phpQuery::newDocument($content);
@khoand0000
khoand0000 / use_pusher.php
Last active December 3, 2015 08:33
How to use pusher
<?php
/**
* Author: videde
* Date: 9/13/13
* Time: 2:26 AM
*/
require('Pusher.php');
$app_id = '';
$app_key = '';
$app_secret = '';
@khoand0000
khoand0000 / url_class.php
Created September 9, 2014 19:22
Url class
<?php
/**
* Author: videde
* Date: 8/21/13
* Time: 12:46 AM
*/
require_once 'random-user-agent.php';
class Url {
/*
* use proxy:
@khoand0000
khoand0000 / connect_azure.php
Created September 9, 2014 19:26
connect azure
<?php
try {
$conn = odbc_connect(
"DRIVER={SQL Server};Server=tcp:ac1wr559wv.database.windows.net,1433;Database=1407_test",
"project", "Plastic48");
$cur = odbc_exec($conn, "select username, password, address from users");
while (odbc_fetch_row($cur)) {
//collect results
<?php function getCloud( $data = array(), $minFontSize = 12, $maxFontSize = 30 )
{
$minimumCount = min($data);
$maximumCount = max($data);
$spread = $maximumCount - $minimumCount;
$cloudHTML = '';
$cloudTags = array();
$spread == 0 && $spread = 1;
<?php
// $imageDirectory = the directory of the image with out the trailing slash
// $thumbDirectory = the directory where you want to save the thumb
// $imageName = the file name of the image example: myimage.gif
// $thumbWidth = the final size of the thumb
// $percent = the scaling size of the image. values = .1 - 1
// This function will Save the image on your server
function transparentGif($imageDirectory,$thumbDirectory, $imageName, $thumbWidth){
$image = imagecreatefromgif("$imageDirectory/$imageName");
function encodeimg($file) {
$contents = file_get_contents($file);
$base64 = base64_encode($contents);
$imagetype = exif_imagetype($file);
$mime = image_type_to_mime_type($imagetype);
return "data:$mime;base64,$base64";
}
?>
@khoand0000
khoand0000 / format_social_security_number.php
Created September 11, 2014 15:18
http://phpsnips.com/610/Format-Social-Security-Number#.VBG8-fmSySr Takes a string of numbers and formats it into a Social Security number format. Example: formatSSN('123456789'); //returns "123-45-6789"
<?php
// Format a Social Security Number.
function formatSSN($ssn)
{
return preg_replace("/^(\d{3})(\d{2})(\d{4})$/", "$1-$2-$3", $ssn);
}
?>