<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tasty Bytes</title>
	<atom:link href="http://www.tastybytes.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tastybytes.net</link>
	<description>Coding, Design, etc</description>
	<lastBuildDate>Tue, 24 Aug 2010 16:58:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Sunrise in the Neighborhood</title>
		<link>http://www.tastybytes.net/2010/08/sunrise-in-the-neighborhood/</link>
		<comments>http://www.tastybytes.net/2010/08/sunrise-in-the-neighborhood/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 16:58:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[Pic-a-Day]]></category>

		<guid isPermaLink="false">http://www.tastybytes.net/?p=135</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-137" href="http://www.tastybytes.net/2010/08/sunrise-in-the-neighborhood/sunrise2/"><img class="aligncenter size-full wp-image-137" title="sunrise2" src="http://www.tastybytes.net/wp-content/uploads/2010/08/sunrise2.jpg" alt="" width="500" height="750" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tastybytes.net/2010/08/sunrise-in-the-neighborhood/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple File Caching Script</title>
		<link>http://www.tastybytes.net/2010/08/simple-file-caching-script/</link>
		<comments>http://www.tastybytes.net/2010/08/simple-file-caching-script/#comments</comments>
		<pubDate>Fri, 06 Aug 2010 19:24:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Cache]]></category>
		<category><![CDATA[File Caching]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.tastybytes.net/?p=122</guid>
		<description><![CDATA[On a recent project, I needed a quick, easy and simple caching function for XML files, so whipped up this little function.

It takes: 

- The URL of the file / XML you need to cache
- The cache file, if one is not specified, it creates and uses "temp.txt"
- The amount of time to cache the file, if one is not specified, it uses 12 minutes (you can change this to whatever you would like
]]></description>
			<content:encoded><![CDATA[<p>On a recent project, I needed a quick, easy and simple caching function for XML files, so whipped up this little function.</p>
<p><strong>How it works</strong></p>
<p>It takes: </p>
<ul>
<li>The URL of the file / XML you need to cache</li>
<li>The cache file, if one is not specified, it creates and uses &#8220;temp.txt&#8221;</li>
<li>The amount of time to cache the file, if one is not specified, it uses 12 minutes (you can change this to whatever you would like</li>
</ul>
<p><span id="more-122"></span></p>
<p><strong>The Function</strong></p>
<pre class="brush: php">
function cacheFeed( $feed, $cacheFile='temp.txt', $cacheTime=12 ) {
	$debug = false; // Set this to true for output and debuging
	if ( $debug ) echo "Begining feed";
	if ( $debug ) echo "File Exists: ";

	// Make sure the file is there
	if ( file_exists($cacheFile) ) { // Make sure the file is there
		if ( $debug ) echo "True";

		// If the file modified time is outside of the cache time OR the file size is 0 (empty file)
		if ( strtotime('+'.$cacheTime.' minutes',filemtime($cacheFile)) < strtotime("now") || !filesize($cacheFile) ) {
			// Set up curl and options
			$ch = curl_init();
			curl_setopt( $ch, CURLOPT_URL, $feed );
			curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
			curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
			curl_setopt( $ch, CURLOPT_HEADER, 0);
			$data = curl_exec( $ch );
			curl_close( $ch );

			if ( $data != "" ) {
				if ( $debug ) echo "Recieved Feed";
				file_put_contents($cacheFile,$data);
				if ( $debug ) echo "Writing to Cache File";
			}
		} else {
			$data = file_get_contents($cacheFile);
		}
	} else {
		if ( $debug ) echo "False";

		$f = fopen($cacheFile,'x'); // Create file to write to.
		fclose($f); // No need to keep it open

		$data = cacheFeed($feed,$cacheFile,$cacheTime);
	}
	return $data;
}
</pre>
<p><strong>Example Usage</strong></p>
<pre class="brush: php">
	include_once( 'cacheFeed.php' );
	$cacheFile = 'cache/cacheFile.xml';
	$feed = 'http://linktoyour.com/XMLfile.xml';
	$data = cacheFeed($feed, $cacheFile, 30);
	$xml = new SimpleXMLElement($data);
</pre>
</p>
<p>Thats it, pretty simple to use. I hope someone gets some use out of this!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tastybytes.net/2010/08/simple-file-caching-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bradford Pear</title>
		<link>http://www.tastybytes.net/2010/03/bradford-pear/</link>
		<comments>http://www.tastybytes.net/2010/03/bradford-pear/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 06:28:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[Pic-a-Day]]></category>

		<guid isPermaLink="false">http://www.tastybytes.net/?p=103</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-104" href="http://www.tastybytes.net/2010/03/bradford-pear/5-2/"><a rel="attachment wp-att-104" href="http://www.tastybytes.net/2010/03/bradford-pear/5-2/"><img class="aligncenter size-full wp-image-104" title="5-2" src="http://www.tastybytes.net/wp-content/uploads/2010/03/5-2.jpg" alt="" width="570" height="855" /></a><br />
</a></p>
<p><a rel="attachment wp-att-102" href="http://www.tastybytes.net/2010/03/bradford-pear/attachment/5/"><br />
</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tastybytes.net/2010/03/bradford-pear/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fountain at Frisco Square</title>
		<link>http://www.tastybytes.net/2010/01/fountain-at-frisco-square/</link>
		<comments>http://www.tastybytes.net/2010/01/fountain-at-frisco-square/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 17:31:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Pic-a-Day]]></category>
		<category><![CDATA[fountain]]></category>
		<category><![CDATA[frisco square]]></category>

		<guid isPermaLink="false">http://www.tastybytes.net/2010/01/fountain/</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-67" href="http://www.tastybytes.net/2010/01/fountain-at-frisco-square/img_4203/"><img class="alignnone size-large wp-image-67" title="IMG_4203" src="http://www.tastybytes.net/wp-content/uploads/2010/01/IMG_4203-950x472.jpg" alt="" width="950" height="472" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tastybytes.net/2010/01/fountain-at-frisco-square/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Painted Fire Sunset</title>
		<link>http://www.tastybytes.net/2010/01/painted-fire-sunset/</link>
		<comments>http://www.tastybytes.net/2010/01/painted-fire-sunset/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 00:22:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Pic-a-Day]]></category>
		<category><![CDATA[Painted]]></category>
		<category><![CDATA[sunset]]></category>

		<guid isPermaLink="false">http://www.tastybytes.net/?p=49</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-57" href="http://www.tastybytes.net/2010/01/painted-fire-sunset/img_4165/"><img class="alignnone size-large wp-image-57" title="IMG_4165" src="http://www.tastybytes.net/wp-content/uploads/2010/01/IMG_4165-950x543.jpg" alt="" width="950" height="543" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tastybytes.net/2010/01/painted-fire-sunset/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>5+ E-Learning sites</title>
		<link>http://www.tastybytes.net/2010/01/5-e-learning-sites/</link>
		<comments>http://www.tastybytes.net/2010/01/5-e-learning-sites/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 01:55:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[e-learning]]></category>
		<category><![CDATA[school]]></category>

		<guid isPermaLink="false">http://www.tastybytes.net/?p=15</guid>
		<description><![CDATA[I personally prefer tutorials and articles above little walk-throughs or videos that do little more than slow me down.  I can comprehend whats going on with out some one holding my hand.  Though if I do get a little lost or confused, the authors text is always a nice added feature.]]></description>
			<content:encoded><![CDATA[<p>I personally prefer tutorials and articles above little walk-throughs or videos that do little more than slow me down.  I can comprehend whats going on with out some one holding my hand.  Though if I do get a little lost or confused, the authors text is always a nice added feature.</p>
<p><a title="http://www.elearningsites.net/" href="http://www.elearningsites.net/" target="_blank">http://www.elearningsites.net/</a> &#8211; A list of (old) E-Learning sites, mostly from Berkeley&#8217;s online courses and all just &#8220;books on tape&#8221;&#8230; whats that I hear, a foghorn? BORING</p>
<p><a title="http://webcast.berkeley.edu/" href="http://webcast.berkeley.edu/course_details.php?seriesid=1906978374" target="_blank">http://webcast.berkeley.edu/course_details.php?seriesid=1906978374</a> &#8211; An example of the previously mentioned Berkeley sites.</p>
<p><a title="http://www.ehow.com/" href="http://www.ehow.com/" target="_blank">http://www.ehow.com/</a> &#8211; A tutorial site (my preferred method) that has a collection of tutorials on numerous topics.</p>
<p><a title="http://www.techtutorials.net/" href="http://www.techtutorials.net/" target="_blank">http://www.techtutorials.net/</a> &#8211; Another tutorial site that specializes in technologies, such as software, coding, web development, etc.</p>
<p><a title="http://www.articulate.com/rapid-elearning/how-to-create-e-learning-courses-that-dont-waste-your-learners-time/" href="http://www.articulate.com/rapid-elearning/how-to-create-e-learning-courses-that-dont-waste-your-learners-time/" target="_blank">http://www.articulate.com/rapid-elearning/how-to-create-e-learning-courses-that-dont-waste-your-learners-time/</a> &#8211; A great site about constructing E-Learning sites, the pros and cons about different methods, and examples of walk-throughs and lessons.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tastybytes.net/2010/01/5-e-learning-sites/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sunrise over Lake Lewisville</title>
		<link>http://www.tastybytes.net/2010/01/sunrise-over-lake-lewisville/</link>
		<comments>http://www.tastybytes.net/2010/01/sunrise-over-lake-lewisville/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 19:33:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[Pic-a-Day]]></category>
		<category><![CDATA[lake lewisville]]></category>
		<category><![CDATA[sunrise]]></category>

		<guid isPermaLink="false">http://www.tastybytes.net/?p=39</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-40" href="http://www.tastybytes.net/2010/01/sunrise-over-lake-lewisville/img_4106/"><img class="alignnone size-large wp-image-40" title="IMG_4106" src="http://www.tastybytes.net/wp-content/uploads/2010/01/IMG_4106-950x1425.jpg" alt="" width="570" height="855" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tastybytes.net/2010/01/sunrise-over-lake-lewisville/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lincoln Continental</title>
		<link>http://www.tastybytes.net/2010/01/lincoln-continental/</link>
		<comments>http://www.tastybytes.net/2010/01/lincoln-continental/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 19:14:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Pic-a-Day]]></category>
		<category><![CDATA[Continental]]></category>
		<category><![CDATA[Lincoln]]></category>
		<category><![CDATA[photo]]></category>

		<guid isPermaLink="false">http://www.tastybytes.net/?p=28</guid>
		<description><![CDATA[I will be attempting to upload one quality photo per day.  To kick things off, here are a few.]]></description>
			<content:encoded><![CDATA[<p>I will be attempting to upload one quality photo per day.  To kick things off, here are a few.</p>
<p><a rel="attachment wp-att-29" href="http://www.tastybytes.net/?attachment_id=29"></a><a rel="attachment wp-att-29" href="http://www.tastybytes.net/?attachment_id=29"><img class="alignnone size-large wp-image-29" title="Lincoln Continental" src="http://www.tastybytes.net/wp-content/uploads/2010/01/IMG_41004-950x507.jpg" alt="" width="950" height="507" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tastybytes.net/2010/01/lincoln-continental/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple ACL Class for CodeIgniter</title>
		<link>http://www.tastybytes.net/2009/10/simple-acl-class-for-codeigniter/</link>
		<comments>http://www.tastybytes.net/2009/10/simple-acl-class-for-codeigniter/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 14:03:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ACL]]></category>
		<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.tastybytes.net/?p=1</guid>
		<description><![CDATA[Hey guys, I was originally using an ACL Class that was posted on net tuts. After scouring the internet for an ACL plugin that was similar to the net tuts one I opted to just adapt the net tuts one since I couldn't find one similar.  I tried out the Zend ACL library but it didnt (that i saw) have the same functionality

- User by user permissions
- Multiple Roles
- Database configured
- Etc.]]></description>
			<content:encoded><![CDATA[<p>Hey guys, I was originally using an ACL Class that was posted on net tuts. After scouring the internet for an ACL plugin that was similar to the net tuts one I opted to just adapt the net tuts one since I couldn&#8217;t find one similar.  I tried out the Zend ACL library but it didnt (that i saw) have the same functionality</p>
<p>- User by user permissions<br />
- Multiple Roles<br />
- Database configured<br />
- Etc.<br />
<span id="more-1"></span><br />
Here is the net.tutsplus.com walk through if anyone needs it.<br />
<a href="http://net.tutsplus.com/tutorials/php/a-better-login-system/">http://net.tutsplus.com/tutorials/php/a-better-login-system/</a></p>
<p><strong>Database</strong><br />
- Same as the net tuts, just renamed the tables for my own preference.<br />
- USER_DATA can be basically anything you want, just needs to have &#8220;id</p>
<pre class="brush: sql;">SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- Table structure for table `perm_data`
-- 

CREATE TABLE `perm_data` (
  `ID` bigint(20) unsigned NOT NULL auto_increment,
  `permKey` varchar(30) NOT NULL,
  `permName` varchar(30) NOT NULL,
  PRIMARY KEY  (`ID`),
  UNIQUE KEY `permKey` (`permKey`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=39 ;

-- --------------------------------------------------------

--
-- Table structure for table `role_data`
-- 

CREATE TABLE `role_data` (
  `ID` bigint(20) unsigned NOT NULL auto_increment,
  `roleName` varchar(20) NOT NULL,
  PRIMARY KEY  (`ID`),
  UNIQUE KEY `roleName` (`roleName`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

-- --------------------------------------------------------

--
-- Table structure for table `role_perms`
-- 

CREATE TABLE `role_perms` (
  `ID` bigint(20) unsigned NOT NULL auto_increment,
  `roleID` bigint(20) NOT NULL,
  `permID` bigint(20) NOT NULL,
  `value` tinyint(1) NOT NULL default '0',
  `addDate` datetime NOT NULL,
  PRIMARY KEY  (`ID`),
  UNIQUE KEY `roleID_2` (`roleID`,`permID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

-- --------------------------------------------------------

--
-- Table structure for table `user_data`
-- 

CREATE TABLE `user_data` (
  `ID` int(10) unsigned NOT NULL auto_increment,
  `username` varchar(20) NOT NULL,
  `password` text NOT NULL,
  `name` tinytext NOT NULL,
  `address` tinytext,
  `address2` tinytext,
  `city` tinytext,
  `state` tinytext,
  `zip` tinytext,
  `cellphone` tinytext,
  `telephone` tinytext,
  `email` tinytext,
  `aim` tinytext,
  `yahoo` tinytext,
  `icq` tinytext,
  `other` tinytext,
  `dateAdded` timestamp NOT NULL default CURRENT_TIMESTAMP,
  PRIMARY KEY  (`ID`),
  KEY `Username` (`username`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

-- --------------------------------------------------------

--
-- Table structure for table `user_perms`
-- 

CREATE TABLE `user_perms` (
  `ID` bigint(20) unsigned NOT NULL auto_increment,
  `userID` bigint(20) NOT NULL,
  `permID` bigint(20) NOT NULL,
  `value` tinyint(1) NOT NULL default '0',
  `addDate` datetime NOT NULL,
  PRIMARY KEY  (`ID`),
  UNIQUE KEY `userID` (`userID`,`permID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

-- --------------------------------------------------------

--
-- Table structure for table `user_roles`
-- 

CREATE TABLE `user_roles` (
  `userID` bigint(20) NOT NULL,
  `roleID` bigint(20) NOT NULL,
  `addDate` datetime NOT NULL,
  UNIQUE KEY `userID` (`userID`,`roleID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;</pre>
<p><strong>The Class File</strong><br />
- Just a converted version of the net tuts class.</p>
<pre class="brush: php">	class acl
	{
		var $perms = array();		//Array : Stores the permissions for the user
		var $userID;			//Integer : Stores the ID of the current user
		var $userRoles = array();	//Array : Stores the roles of the current user
		var $ci;
		function __construct($config=array()) {
			$this-&gt;ci = &amp;get_instance();

			$this-&gt;userID = floatval($config['userID']);
			$this-&gt;userRoles = $this-&gt;getUserRoles();
			$this-&gt;buildACL();
		}

		function buildACL() {
			//first, get the rules for the user's role
			if (count($this-&gt;userRoles) &gt; 0)
			{
				$this-&gt;perms = array_merge($this-&gt;perms,$this-&gt;getRolePerms($this-&gt;userRoles));
			}
			//then, get the individual user permissions
			$this-&gt;perms = array_merge($this-&gt;perms,$this-&gt;getUserPerms($this-&gt;userID));
		}

		function getPermKeyFromID($permID) {
			//$strSQL = "SELECT `permKey` FROM `".DB_PREFIX."permissions` WHERE `ID` = " . floatval($permID) . " LIMIT 1";
			$this-&gt;ci-&gt;db-&gt;select('permKey');
			$this-&gt;ci-&gt;db-&gt;where('id',floatval($permID));
			$sql = $this-&gt;ci-&gt;db-&gt;get('perm_data',1);
			$data = $sql-&gt;result();
			return $data[0]-&gt;permKey;
		}

		function getPermNameFromID($permID) {
			//$strSQL = "SELECT `permName` FROM `".DB_PREFIX."permissions` WHERE `ID` = " . floatval($permID) . " LIMIT 1";
			$this-&gt;ci-&gt;db-&gt;select('permName');
			$this-&gt;ci-&gt;db-&gt;where('id',floatval($permID));
			$sql = $this-&gt;ci-&gt;db-&gt;get('perm_data',1);
			$data = $sql-&gt;result();
			return $data[0]-&gt;permName;
		}

		function getRoleNameFromID($roleID) {
			//$strSQL = "SELECT `roleName` FROM `".DB_PREFIX."roles` WHERE `ID` = " . floatval($roleID) . " LIMIT 1";
			$this-&gt;ci-&gt;db-&gt;select('roleName');
			$this-&gt;ci-&gt;db-&gt;where('id',floatval($roleID),1);
			$sql = $this-&gt;ci-&gt;db-&gt;get('role_data');
			$data = $sql-&gt;result();
			return $data[0]-&gt;roleName;
		}

		function getUserRoles() {
			//$strSQL = "SELECT * FROM `".DB_PREFIX."user_roles` WHERE `userID` = " . floatval($this-&gt;userID) . " ORDER BY `addDate` ASC";

			$this-&gt;ci-&gt;db-&gt;where(array('userID'=&gt;floatval($this-&gt;userID)));
			$this-&gt;ci-&gt;db-&gt;order_by('addDate','asc');
			$sql = $this-&gt;ci-&gt;db-&gt;get('user_roles');
			$data = $sql-&gt;result();

			$resp = array();
			foreach( $data as $row )
			{
				$resp[] = $row-&gt;roleID;
			}
			return $resp;
		}

		function getAllRoles($format='ids') {
			$format = strtolower($format);
			//$strSQL = "SELECT * FROM `".DB_PREFIX."roles` ORDER BY `roleName` ASC";
			$this-&gt;ci-&gt;db-&gt;order_by('roleName','asc');
			$sql = $this-&gt;ci-&gt;db-&gt;get('role_data');
			$data = $sql-&gt;result();

			$resp = array();
			foreach( $data as $row )
			{
				if ($format == 'full')
				{
					$resp[] = array("id" =&gt; $row-&gt;ID,"name" =&gt; $row-&gt;roleName);
				} else {
					$resp[] = $row-&gt;ID;
				}
			}
			return $resp;
		}

		function getAllPerms($format='ids') {
			$format = strtolower($format);
			//$strSQL = "SELECT * FROM `".DB_PREFIX."permissions` ORDER BY `permKey` ASC";

			$this-&gt;ci-&gt;db-&gt;order_by('permKey','asc');
			$sql = $this-&gt;ci-&gt;db-&gt;get('perm_data');
			$data = $sql-&gt;result();

			$resp = array();
			foreach( $data as $row )
			{
				if ($format == 'full')
				{
					$resp[$row-&gt;permKey] = array('id' =&gt; $row-&gt;ID, 'name' =&gt; $row-&gt;permName, 'key' =&gt; $row-&gt;permKey);
				} else {
					$resp[] = $row-&gt;ID;
				}
			}
			return $resp;
		}

		function getRolePerms($role) {
			if (is_array($role))
			{
				//$roleSQL = "SELECT * FROM `".DB_PREFIX."role_perms` WHERE `roleID` IN (" . implode(",",$role) . ") ORDER BY `ID` ASC";
				$this-&gt;ci-&gt;db-&gt;where_in('roleID',$role);
			} else {
				//$roleSQL = "SELECT * FROM `".DB_PREFIX."role_perms` WHERE `roleID` = " . floatval($role) . " ORDER BY `ID` ASC";
				$this-&gt;ci-&gt;db-&gt;where(array('roleID'=&gt;floatval($role)));

			}
			$this-&gt;ci-&gt;db-&gt;order_by('id','asc');
			$sql = $this-&gt;ci-&gt;db-&gt;get('role_perms'); //$this-&gt;db-&gt;select($roleSQL);
			$data = $sql-&gt;result();
			$perms = array();
			foreach( $data as $row )
			{
				$pK = strtolower($this-&gt;getPermKeyFromID($row-&gt;permID));
				if ($pK == '') { continue; }
				if ($row-&gt;value === '1') {
					$hP = true;
				} else {
					$hP = false;
				}
				$perms[$pK] = array('perm' =&gt; $pK,'inheritted' =&gt; true,'value' =&gt; $hP,'name' =&gt; $this-&gt;getPermNameFromID($row-&gt;permID),'id' =&gt; $row-&gt;permID);
			}
			return $perms;
		}

		function getUserPerms($userID) {
			//$strSQL = "SELECT * FROM `".DB_PREFIX."user_perms` WHERE `userID` = " . floatval($userID) . " ORDER BY `addDate` ASC";

			$this-&gt;ci-&gt;db-&gt;where('userID',floatval($userID));
			$this-&gt;ci-&gt;db-&gt;order_by('addDate','asc');
			$sql = $this-&gt;ci-&gt;db-&gt;get('user_perms');
			$data = $sql-&gt;result();

			$perms = array();
			foreach( $data as $row )
			{
				$pK = strtolower($this-&gt;getPermKeyFromID($row-&gt;permID));
				if ($pK == '') { continue; }
				if ($row-&gt;value == '1') {
					$hP = true;
				} else {
					$hP = false;
				}
				$perms[$pK] = array('perm' =&gt; $pK,'inheritted' =&gt; false,'value' =&gt; $hP,'name' =&gt; $this-&gt;getPermNameFromID($row-&gt;permID),'id' =&gt; $row-&gt;permID);
			}
			return $perms;
		}

		function hasRole($roleID) {
			foreach($this-&gt;userRoles as $k =&gt; $v)
			{
				if (floatval($v) === floatval($roleID))
				{
					return true;
				}
			}
			return false;
		}

		function hasPermission($permKey) {
			$permKey = strtolower($permKey);
			if (array_key_exists($permKey,$this-&gt;perms))
			{
				if ($this-&gt;perms[$permKey]['value'] === '1' || $this-&gt;perms[$permKey]['value'] === true)
				{
					return true;
				} else {
					return false;
				}
			} else {
				return false;
			}
		}
	}
</pre>
<p><strong>Example Usage</strong></p>
<pre class="brush: php">// Use whatever user script you would like, just make sure it has an ID field to tie into the ACL with
$this-&gt;load-&gt;library('user',array('username'=&gt;'admin','password'=&gt;'abc123') );	

// Get the user's ID and add it to the config array
$config = array('userID'=&gt;$this-&gt;user-&gt;getUserID());

// Load the ACL library and pas it the config array
$this-&gt;load-&gt;library('acl',$config);

// Get the perm key
// I'm using the URI to keep this pretty simple ( http://www.example.com/test/this ) would be 'test_this'
$acl_test = $this-&gt;uri-&gt;segment(1).'_';
$acl_test .= ($this-&gt;uri-&gt;segment(2)!="")?$this-&gt;uri-&gt;segment(2):'view';

// If the user does not have permission either in 'user_perms' or 'role_perms' redirect to login, or restricted, etc
if ( !$this-&gt;acl-&gt;hasPermission($acl_test) ) {
	redirect('/login/');
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.tastybytes.net/2009/10/simple-acl-class-for-codeigniter/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
