Skip to content

Instantly share code, notes, and snippets.

View tomschlick's full-sized avatar

Tom Schlick tomschlick

View GitHub Profile
function get_blog_post($where)
{
$this->db->where($where);
$query = $this->db->get(‘blog_posts’, 1);
if($query->num_rows() == 1)
{
return $query->row_array();
}
return FALSE;
}
function insert_blog_post($data)
{
$this->db->insert('blog_posts', $data);
return $this->db->insert_id();
}
< ?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Blog_model extends Model
{
function __construct()
{
parent::Model();
}
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Log extends CI_Log
{
var $mongo;
function __construct()
{
$this->mongo = new Mongo("localhost");
@tomschlick
tomschlick / gist:233561
Created November 13, 2009 03:21
checks to see if the current server request was made with AJAX , returns boolean TRUE or FALSE
function _is_ajax()
{
return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'));
}
@tomschlick
tomschlick / Environments to bypass .htpasswd protection
Created November 8, 2009 08:30
This allows you to set certain urls/domains that are allowed to bypass a htpasswd protection layer, which is very useful for multiple environment setups (developement, staging, production)
#allows a single uri through the .htaccess password protection
SetEnvIf Request_URI "/testing_uri$" test_uri
#allows everything if its on a certain host
SetEnvIf HOST "^testing.yoursite.com" testing_url
SetEnvIf HOST "^yoursite.com" live_url
Order Deny,Allow
AuthName "Restricted Area"
AuthType Basic