Skip to content

Instantly share code, notes, and snippets.

Avatar

George Butiri gbutiri

View GitHub Profile
@gbutiri
gbutiri / tokenizer_helper.php
Last active Dec 7, 2017
CodeIgniter - Tokenizer Helper
View tokenizer_helper.php
<?php
Class Tokenizer {
public $dataIn = "";
public $response_header = "";
function __construct($linkIn = '', $link = true) {
if ($link) {
$arrContextOptions=array(
"ssl"=>array(
@gbutiri
gbutiri / password_helper.php
Created Dec 7, 2017
CodeIgniter - Password Helper
View password_helper.php
<?php
function passwordError ($pwd) {
$error="";
if( strlen($pwd) < 8 ) {$error = "Password too short. Must be at least 8 characters.";}
elseif( strlen($pwd) > 20 ) {$error = "Password too long. Must be no longer than 20 characters.";}
elseif( !preg_match("#[0-9]+#", $pwd) ) {$error = "Password must include at least one number!";}
elseif( !preg_match("#[a-zA-Z]+#", $pwd) ) {$error = "Password must include at least one letter!";}
//elseif( !preg_match("#[a-z]+#", $pwd) ) {$error = "Password must include at least one lowercase letter!";}
//elseif( !preg_match("#[A-Z]+#", $pwd) ) {$error = "Password must include at least one uppercase letter!";}
//elseif( !preg_match("#\W+#", $pwd) ) {$error = "Password must include at least one symbol!";}
@gbutiri
gbutiri / friendlyurl_helper.php
Created Dec 7, 2017
CodeIgniter Helper - Friendly URL
View friendlyurl_helper.php
<?php
function friendlyURL($string, $is_file = false, $delimiter = '-'){
if ($is_file) {
$name = pathinfo($string, PATHINFO_FILENAME);
$ext = pathinfo($string, PATHINFO_EXTENSION);
$filename = friendlyUrl($name) . '.' . friendlyUrl($ext);
return $filename;
} else {
$string = preg_replace("`\[.*\]`U","",$string);
$string = preg_replace('`&(amp;)?#?[a-z0-9]+;`i', $delimiter, $string);