Skip to content

Instantly share code, notes, and snippets.

View dhrrgn's full-sized avatar
🦙

Dan Horrigan dhrrgn

🦙
  • OH, USA
  • 21:33 (UTC -04:00)
View GitHub Profile
$page = $this->pages_model->get($page_id);
set_value('title') or $page->title = set_value('title');
set_value('description') or $page->description = set_value('description');
set_value('contents') or $page->contents = set_value('contents');
<?php
function safe_string($string)
{
$from = explode(',',
'&lt;,&gt;,&#039;,&amp;,&quot;,À,Á,Â,Ã,Ä,&Auml;,Å,Ā,Ą,Ă,Æ,Ç,Ć,Č,Ĉ,Ċ,Ď,Đ,Ð,È,É,Ê,Ë,Ē,Ę,Ě,Ĕ,Ė,Ĝ,Ğ,Ġ,Ģ,Ĥ,Ħ,Ì,Í,Î,Ï,Ī,Ĩ,Ĭ,Į,İ,IJ,Ĵ,Ķ,Ł,Ľ,Ĺ,Ļ,Ŀ,Ñ,Ń,Ň,Ņ,Ŋ,Ò,Ó,Ô,Õ,Ö,&Ouml;,Ø,Ō,Ő,Ŏ,Œ,Ŕ,Ř,Ŗ,Ś,Š,Ş,Ŝ,Ș,Ť,Ţ,Ŧ,Ț,Ù,Ú,Û,Ü,Ū,&Uuml;,Ů,Ű,Ŭ,Ũ,Ų,Ŵ,Ý,Ŷ,Ÿ,Ź,Ž,Ż,Þ,Þ,à,á,â,ã,ä,&auml;,å,ā,ą,ă,æ,ç,ć,č,ĉ,ċ,ď,đ,ð,è,é,ê,ë,ē,ę,ě,ĕ,ė,ƒ,ĝ,ğ,ġ,ģ,ĥ,ħ,ì,í,î,ï,ī,ĩ,ĭ,į,ı,ij,ĵ,ķ,ĸ,ł,ľ,ĺ,ļ,ŀ,ñ,ń,ň,ņ,ʼn,ŋ,ò,ó,ô,õ,ö,&ouml;,ø,ō,ő,ŏ,œ,ŕ,ř,ŗ,š,ù,ú,û,ü,ū,&uuml;,ů,ű,ŭ,ũ,ų,ŵ,ý,ÿ,ŷ,ž,ż,ź,þ,ß,ſ,А,Б,В,Г,Д,Е,Ё,Ж,З,И,Й,К,Л,М,Н,О,П,Р,С,Т,У,Ф,Х,Ц,Ч,Ш,Щ,Ъ,Ы,Э,Ю,Я,а,б,в,г,д,е,ё,ж,з,и,й,к,л,м,н,о,п,р,с,т,у,ф,х,ц,ч,ш,щ,ъ,ы,э,ю,я');
$to = explode(',',
',,,,,A,A,A,A,Ae,A,A,A,A,A,Ae,C,C,C,C,C,D,D,D,E,E,E,E,E,E,E,E,E,G,G,G,G,H,H,I,I,I,I,I,I,I,I,I,IJ,J,K,K,K,K,K,K,N,N,N,N,N,O,O,O,O,Oe,Oe,O,O,O,O,OE,R,R,R,S,S,S,S,S,T,T,T,T,U,U,U,Ue,U,Ue,U,U,U,U,U,W,Y,Y,Y,Z,Z,Z,T,T,a,a,a,a,ae,ae,a,a,a,a,ae,c,c,c,c,c,d,d,d,e,e,e,e,e,e,e,e,e,f,g,g,g,g,h,h,i,i,i,i,i,i,i,i,i,ij,j,k,k,l,l,l,l,l,n,n,n,n,n,n,o,o,o,o,oe,oe,o,o,o,o,oe,r,r
<?php
$route['api'] = 'api';
$route['short/test/(:num)'] = 'short/test/$1';
$route['(:any)'] = 'short/route/$1';
@dhrrgn
dhrrgn / hello.php
Created December 2, 2010 19:41
An example template controller
<?php
namespace Fuel\Application;
class Controller_Hello extends Controller\Template {
public $template = 'vm';
public function action_index()
{
@dhrrgn
dhrrgn / redis_test.php
Created December 2, 2010 19:58
An Example on Redis Usage
<?php
namespace Fuel\Application;
class Controller_Test extends Controller\Base {
public function action_index()
{
// You can access it this way
Redis::instance()->set('username', 'Dan');
@dhrrgn
dhrrgn / user.php
Created December 3, 2010 03:58
An Example ActiveRecord model
<?php
// Need to add 'activerecord' to your packages in config.php
namespace Fuel\Application;
use ActiveRecord;
class Model_User extends ActiveRecord\Model {
// This will eventually be "guessed"
protected static $table_name = 'users';
@dhrrgn
dhrrgn / group.php
Created December 5, 2010 06:33
Example of the new ActiveRecord package
<?php
namespace Fuel\Application\Model;
use ActiveRecord;
class Group extends ActiveRecord\Model {
protected $has_many = array('users');
@dhrrgn
dhrrgn / install.php
Created December 7, 2010 01:58
example usage of the Cli class
<?php
namespace Fuel\Application;
class Controller_Install extends Controller\Base {
public function action_index()
{
CLI::write(Cli::color('Getting ready to Install!', 'blue'));
Cli::write("We need some information first.\n");
@dhrrgn
dhrrgn / get_uri.php
Created February 2, 2011 00:36
Get URI
<?php
/**
* Get's the current "pretty" URI from the URL. It will also correct the QUERY_STRING server var and the $_GET array.
* It supports all forms of mod_rewrite and the following forms of URL:
*
* http://example.com/index.php/foo (returns '/foo')
* http://example.com/index.php?/foo (returns '/foo')
* http://example.com/index.php/foo?baz=bar (returns '/foo')
* http://example.com/index.php?/foo?baz=bar (returns '/foo')
*
@dhrrgn
dhrrgn / post-update
Created February 18, 2011 21:54
A simple post-update hook for Git. It simply touches the fastCGI dispatch script when you "git pull". Equivalent of restarting the Python server.
#!/bin/sh
touch ~/public_html/dispatch.fcgi