Skip to content

Instantly share code, notes, and snippets.

View jamsesso's full-sized avatar

Sam Jesso jamsesso

  • Replicant
  • Fredericton, Canada
View GitHub Profile
function valid($setting, $string) {
if($setting == "email") {
if(preg_match("/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/", $string)) {
return true;
} else {
return false;
}
} elseif($setting == "website") {
if(preg_match("/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/", $string)) {
return true;
body {
background: #fff url(images/bg.png) repeat-x top center;
font: normal 12px Georgia;
color: #000;
margin: 0px auto;
}
a:link, a:visited { color: #000; }
a:hover, a:visited:hover { text-decoration:none; }
p { clear: both; }
h1 {
$sql = fopen("installation.sql", "r");
$new_sql = str_replace("{PREFIX}", $_POST['prefix'], $sql);
$new_sql = str_replace("{USERNAME}", $post['username'], $sql);
$new_sql = str_replace("{PASSWORD}", $post['password'], $sql);
$new_sql = str_replace("{EMAIL}", $post['email'], $sql);
$new_sql = str_replace("{IPADDR}", $post['ipaddr'], $sql);
$new_sql = str_replace("{BLOGTITLE}", $post['title'], $sql);
$new_sql = str_replace("{BLOGKEYWORDS}", $post['keywords'], $sql);
$new_sql = str_replace("{BLOGDESCRIPTION}", $post['description'], $sql);
<?php
function upload($file) {
$allowed = array("image/png", "image/jpg", "image/jpeg", "image/gif");
$type = $file['type'];
$extension = end(explode("/", $type));
$destination = sha1(time().rand().md5($file['name'])).".".$extension;
$directory = "./uploads/";
$limit = 1024000;
$success = "Your photo has been uploaded!";
<?php
/* FrostBB - Open source bulletin board.
http://www.frostbb.net/
License: http://www.frostbb.net/about:license
File: /resources/class_core.php
Author: Sam Jesso (www.xiofire.com)
Handles the core class and functions of FrostBB. */
<?php
/* Configuration variables, edit accordingly */
$username = "cloudica";
$domain = "cloudi.ca"; //Alternative is cloudica.net
$max_posts = "10"; //Leave empty for all available posts.
/* Fetch the posts and loop. */
$xml = simplexml_load_file("http://".$domain."/feeds/".$username.".rss");
if(!empty($max_posts))
<?php
define("OBJECT", "object");
define("ASSOC", "assoc");
define("ARRAY", "array");
<?php
//Get the library.
require "mysql.php";
//New connection.
$db = new MySQL("localhost", "username", "password", "database");
if($db->errno())
{
print($db->error());
exit;
<?php
function secure_wysiwyg($filter)
{
$badattr = array('onclick="' => 'void="',
'onmouseover="' => 'void="',
'onload="' => 'void="',
'onblur="' => 'void="',
'onfocus="' => 'void="',
'class="' => 'void="',
'id="' => 'void="',
<?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
* */