Skip to content

Instantly share code, notes, and snippets.

View thomaslarsson's full-sized avatar

Thomas Maurstad Larsson thomaslarsson

View GitHub Profile
@thomaslarsson
thomaslarsson / gist:3122868
Created July 16, 2012 13:58
User-Member composition illustration with print_r()
User object
{
private user_id = 1;
private user_email = 'thomas@juvenorge.com';
private user_access_key 'ergdvzwezsfgdzesgeszwsfd';
private user_access_level = '1'; // Administrator
private user_last_active '2012/07/16 16:00';
private member = Member object {
private member_id = 1; // Could be 2, 5, 72, etc
private date_of_registration = ''; // some date
@thomaslarsson
thomaslarsson / user_member.php
Created July 18, 2012 02:45
User-Member composition illustration with code
<?php
class User
{
private $user_id;
private $user_email;
private $password;
private $user_access_key;
private $user_access_level;
private $user_last_active;
@thomaslarsson
thomaslarsson / skeletons.php
Created July 19, 2012 15:49
User, Model_User, Hash and Session class skeletons
<?php
/**
* User class
*/
class User
{
/**
@thomaslarsson
thomaslarsson / dump
Created August 6, 2012 16:20
Groups, Users, Group members and Memberships
prefix_access_levels
--------------------------
access_level_id INT(2)
level TINYINT(1)
name VARCHAR(255)
prefix_groups
--------------------------
group_id INT(2)
@thomaslarsson
thomaslarsson / database.php
Created August 10, 2012 22:41
New Database::query()
/**
* Executes a query against the database.
*
* @param string $query The query to be executed
* @return mixed The result array on success, null if no data is matching and false if query fails.
*/
public function query ($query)
{
@thomaslarsson
thomaslarsson / Database.php
Created August 10, 2012 23:26
Improved Database wrapper
<?php
/**
* Database
*
* Database library using MySQLi.
*
* @package Core
* @author Lasse Brenden <lasse@pelota.no>
* @copyright (c)2012, Pelota
@thomaslarsson
thomaslarsson / return.php
Created August 11, 2012 00:39
Return values
<?php
$array = array
(
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
"String 1", "Hello", 'World'
);
foreach ( $array as $value )
{
@thomaslarsson
thomaslarsson / user.php
Created August 11, 2012 03:43
Library_User
<?php
/**
* Library_User
* User class providing authentication
*
* @package Core
* @author Thomas Larsson <thomas@juvenorge.com>
* @copyright (c)2012, Thomas Larsson
*
@thomaslarsson
thomaslarsson / maps
Last active December 19, 2015 10:09
Simple google maps helper
<?php
/**
* Simple Google maps address lookup
*
* Enables you to get latitude and longitude for an address
*
* @author Thomas Maurstad Larsson, Logoz As <thomas@logoz.no>
* @link http://logoz.no
* @copyright Copyright (c) 2012
<?php
// Make sure direct access is not allowed
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Allows you to calculate the remainder of time from now to a given DateTime
*
* @author Thomas Maurstad Larsson, Logoz As <thomas@logoz.no>
* @link http://nybilguiden.no