Skip to content

Instantly share code, notes, and snippets.

View jamsesso's full-sized avatar

Sam Jesso jamsesso

  • Fredericton, Canada
  • 03:33 (UTC -03:00)
View GitHub Profile
@jamsesso
jamsesso / str_time.php
Created May 30, 2011 21:30
Supply a time stamp, get a time ago statement.
<?php
function str_time($stamp)
{
$difference = time() - $stamp;
$intervals = array(
'minute' => 60,
'hour' => 3600,
'day' => 86400,
'month' => 2628000,
'year' => 31536000
<?php
/* By Sam Jesso - [email protected]
* File: oceansql.php
* License: GNU GPL.
* Type: PHP
* Description: A MySQL (PHP 4 mysql_*) wrapper that makes queries visually easier to follow, execute, and debug. */
defined("SYSTEM") or die("Access denied.");
class MySQL
{
<?php
function toCoordinates($address)
{
$bad = array(
" " => "+",
"," => "",
"?" => "",
"&" => "",
"=" => ""
);
<?php
/* #!modules/mysql.php
* Bike-This.com - Modules
* By Sam Jesso - [email protected]
* File: mysql.php
* Type: PHP
* Description: A MySQL (PHP 4 mysql_*) wrapper that makes queries visually easier to follow, execute, and debug.
*/
class MySQL
<?php
#! Photo resize controller.
#! Class interface.
interface iResize
{
public function __construct($filename);
public function resize($x, $y);
public function save($locale);
}
/* Usage:
* Return element: elem("name-of-element");
* Value of element: elem("name-of-element").val();
* Any method in jQuery works here since it returns a jQuery object.
* */
var elem = function(selector)
{
return $("*[name="+ selector +"]");
}
<?php
/* !
* PHP typeof() function - Similar to the JavaScript method.
* Usage: if(typeof($phpQuery) == "undefined") require_once "phpQuery.php";
* if(typeof($_GET) == "array") echo "There are \$_GET arguments present.";
* etc...
* Author: Sam Jesso
* URI: http://sammm.net/
* Date: Sun, 9 Oct, 2010
* */
<?php
function secure_wysiwyg($filter)
{
$badattr = array('onclick="' => 'void="',
'onmouseover="' => 'void="',
'onload="' => 'void="',
'onblur="' => 'void="',
'onfocus="' => 'void="',
'class="' => 'void="',
'id="' => 'void="',
<?php
//Get the library.
require "mysql.php";
//New connection.
$db = new MySQL("localhost", "username", "password", "database");
if($db->errno())
{
print($db->error());
exit;
<?php
define("OBJECT", "object");
define("ASSOC", "assoc");
define("ARRAY", "array");