document.write("<div class=\"pastie\">\n");
document.write("  <link href=\"http://pastie.org/stylesheets/embed.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n");
document.write("  <link href=\"http://pastie.org/stylesheets/clean.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n");
document.write("  \n");
document.write("\n");
document.write("  \n");
document.write("  \n");
document.write("\n");
document.write("\n");
document.write("\n");
document.write("\n");
document.write("\n");
document.write("\n");
document.write("\n");
document.write("	\n");
document.write("	<div class=\"allcode\">\n");
document.write("		<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n");
document.write("		<tr>\n");
document.write("			<td>\n");
document.write("				\n");
document.write("				<pre class=\"textmate-source-numbers\">1\n");
document.write("2\n");
document.write("3\n");
document.write("4\n");
document.write("5\n");
document.write("6\n");
document.write("7\n");
document.write("8\n");
document.write("9\n");
document.write("10\n");
document.write("11\n");
document.write("12\n");
document.write("13\n");
document.write("14\n");
document.write("15\n");
document.write("16\n");
document.write("17\n");
document.write("18\n");
document.write("19\n");
document.write("20\n");
document.write("21\n");
document.write("22\n");
document.write("23\n");
document.write("24\n");
document.write("25\n");
document.write("26\n");
document.write("27\n");
document.write("28\n");
document.write("29\n");
document.write("30\n");
document.write("31\n");
document.write("32\n");
document.write("33\n");
document.write("34\n");
document.write("35\n");
document.write("36\n");
document.write("37\n");
document.write("38\n");
document.write("39\n");
document.write("40\n");
document.write("41\n");
document.write("<\/pre>\n");
document.write("			<\/td>\n");
document.write("		<td>\n");
document.write("		<pre class=\"textmate-source\"><pre class=\"sunburst\"><span class=\'source source_php source_php_embedded source_php_embedded_block source_php_embedded_block_html\'>&lt;?php 	\n");
document.write("<span class=\'meta meta_class meta_class_php\'><span class=\'storage storage_type storage_type_class storage_type_class_php\'>class<\/span> <span class=\'entity entity_name entity_name_type entity_name_type_class entity_name_type_class_php\'>Auth<\/span> <span class=\'storage storage_modifier storage_modifier_extends storage_modifier_extends_php\'>extends<\/span> <span class=\'entity entity_other entity_other_inherited-class entity_other_inherited-class_php\'>Model<\/span> {<\/span>\n");
document.write("\n");
document.write("<span class=\'meta meta_function meta_function_php\'>	<span class=\'storage storage_type storage_type_function storage_type_function_php\'>function<\/span> <span class=\'entity entity_name entity_name_function entity_name_function_php\'>Auth<\/span>(<span class=\'meta meta_function meta_function_arguments meta_function_arguments_php\'><\/span>)<\/span> {\n");
document.write("		<span class=\'storage storage_type storage_type_php\'>parent<\/span><span class=\'keyword keyword_operator keyword_operator_class keyword_operator_class_php\'>::<\/span><span class=\'meta meta_function-call meta_function-call_static meta_function-call_static_php\'>Model<\/span>();\n");
document.write("	}\n");
document.write("\n");
document.write("<span class=\'meta meta_function meta_function_php\'>	<span class=\'storage storage_type storage_type_function storage_type_function_php\'>function<\/span> <span class=\'entity entity_name entity_name_function entity_name_function_php\'>jail<\/span>(<span class=\'meta meta_function meta_function_arguments meta_function_arguments_php\'><\/span>)<\/span> {\n");
document.write("<span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_php\'># Get the group id of the user.<\/span>\n");
document.write("		<span class=\'variable variable_other variable_other_php\'>$gid<\/span> <span class=\'keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_php\'>=<\/span> <span class=\'variable variable_other variable_other_php\'>$this<\/span><span class=\'keyword keyword_operator keyword_operator_class keyword_operator_class_php\'>-&gt;<\/span><span class=\'variable variable_other variable_other_property variable_other_property_php\'>session<\/span><span class=\'keyword keyword_operator keyword_operator_class keyword_operator_class_php\'>-&gt;<\/span><span class=\'meta meta_function-call meta_function-call_object meta_function-call_object_php\'>userdata<\/span>(<span class=\'string string_quoted string_quoted_single string_quoted_single_php\'>\'<span class=\'meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php\'>gid<\/span>\'<\/span>); <span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_php\'># Should be \'user\' or \'admin\'<\/span>\n");
document.write("		\n");
document.write("<span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_php\'># Determine where they were trying to go, if they aren\'t allowed there, store the link for when/if they are allowed.<\/span>\n");
document.write("		<span class=\'variable variable_other variable_other_php\'>$this<\/span><span class=\'keyword keyword_operator keyword_operator_class keyword_operator_class_php\'>-&gt;<\/span><span class=\'variable variable_other variable_other_property variable_other_property_php\'>session<\/span><span class=\'keyword keyword_operator keyword_operator_class keyword_operator_class_php\'>-&gt;<\/span><span class=\'meta meta_function-call meta_function-call_object meta_function-call_object_php\'>set_userdata<\/span>(<span class=\'meta meta_array meta_array_php\'><span class=\'support support_function support_function_construct support_function_construct_php\'>array<\/span>(<span class=\'string string_quoted string_quoted_single string_quoted_single_php\'>\'<span class=\'meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php\'>url<\/span>\'<\/span> <span class=\'keyword keyword_operator keyword_operator_key keyword_operator_key_php\'>=&gt;<\/span> <span class=\'meta meta_function-call meta_function-call_php\'>current_url<\/span>()<\/span>));\n");
document.write("		\n");
document.write("<span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_php\'># Define your groups, this could also be a dynamic database object ;)<\/span>\n");
document.write("<span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_php\'># The array values would be the function names they have access to.<\/span>\n");
document.write("		<span class=\'variable variable_other variable_other_php\'>$user<\/span> <span class=\'keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_php\'>=<\/span> <span class=\'meta meta_array meta_array_php\'><span class=\'support support_function support_function_construct support_function_construct_php\'>array<\/span>(<span class=\'string string_quoted string_quoted_single string_quoted_single_php\'>\'<span class=\'meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php\'>create<\/span>\'<\/span>, <span class=\'string string_quoted string_quoted_single string_quoted_single_php\'>\'<span class=\'meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php\'>read<\/span>\'<\/span>, <span class=\'string string_quoted string_quoted_single string_quoted_single_php\'>\'<span class=\'meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php\'>logout<\/span>\'<\/span>)<\/span>; <span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_php\'># User can access the &quot;create&quot; &quot;read&quot; and &quot;logout&quot; functions.<\/span>\n");
document.write("		<span class=\'variable variable_other variable_other_php\'>$admin<\/span> <span class=\'keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_php\'>=<\/span> <span class=\'meta meta_array meta_array_php\'><span class=\'support support_function support_function_construct support_function_construct_php\'>array<\/span>(<span class=\'string string_quoted string_quoted_single string_quoted_single_php\'>\'<span class=\'meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php\'>create<\/span>\'<\/span>, <span class=\'string string_quoted string_quoted_single string_quoted_single_php\'>\'<span class=\'meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php\'>read<\/span>\'<\/span>, <span class=\'string string_quoted string_quoted_single string_quoted_single_php\'>\'<span class=\'meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php\'>update<\/span>\'<\/span>, <span class=\'string string_quoted string_quoted_single string_quoted_single_php\'>\'<span class=\'meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php\'>delete<\/span>\'<\/span>, <span class=\'string string_quoted string_quoted_single string_quoted_single_php\'>\'<span class=\'meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php\'>logout<\/span>\'<\/span>)<\/span>; <span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_php\'># User can access all functions.<\/span>\n");
document.write("\n");
document.write("<span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_php\'># Get what function they are trying to access.<\/span>\n");
document.write("		<span class=\'variable variable_other variable_other_php\'>$uri<\/span> <span class=\'keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_php\'>=<\/span> <span class=\'variable variable_other variable_other_php\'>$this<\/span><span class=\'keyword keyword_operator keyword_operator_class keyword_operator_class_php\'>-&gt;<\/span><span class=\'variable variable_other variable_other_property variable_other_property_php\'>uri<\/span><span class=\'keyword keyword_operator keyword_operator_class keyword_operator_class_php\'>-&gt;<\/span><span class=\'meta meta_function-call meta_function-call_object meta_function-call_object_php\'>segment<\/span>(<span class=\'constant constant_numeric constant_numeric_php\'>2<\/span>);	\n");
document.write("	\n");
document.write("<span class=\'comment comment_line comment_line_number-sign comment_line_number-sign_php\'># Check to see if the user is allowed to access whichever function is currently being requested.<\/span>\n");
document.write("		<span class=\'keyword keyword_control keyword_control_php\'>switch<\/span> (<span class=\'variable variable_other variable_other_php\'>$gid<\/span>) {\n");
document.write("			<span class=\'keyword keyword_control keyword_control_php\'>case<\/span> <span class=\'string string_quoted string_quoted_single string_quoted_single_php\'>\'<span class=\'meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php\'>user<\/span>\'<\/span>:\n");
document.write("				<span class=\'keyword keyword_control keyword_control_php\'>if<\/span> (<span class=\'keyword keyword_operator keyword_operator_logical keyword_operator_logical_php\'>!<\/span><span class=\'support support_function support_function_array support_function_array_php\'>in_array<\/span>(<span class=\'variable variable_other variable_other_php\'>$uri<\/span>, <span class=\'variable variable_other variable_other_php\'>$user<\/span>)) {\n");
document.write("					<span class=\'meta meta_function-call meta_function-call_php\'>redirect<\/span>(<span class=\'string string_quoted string_quoted_single string_quoted_single_php\'>\'<span class=\'meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php\'>login<\/span>\'<\/span>);\n");
document.write("				}\n");
document.write("			<span class=\'keyword keyword_control keyword_control_php\'>break<\/span>;\n");
document.write("			<span class=\'keyword keyword_control keyword_control_php\'>case<\/span> <span class=\'string string_quoted string_quoted_single string_quoted_single_php\'>\'<span class=\'meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php\'>admin<\/span>\'<\/span>:\n");
document.write("				<span class=\'keyword keyword_control keyword_control_php\'>if<\/span> (<span class=\'keyword keyword_operator keyword_operator_logical keyword_operator_logical_php\'>!<\/span><span class=\'support support_function support_function_array support_function_array_php\'>in_array<\/span>(<span class=\'variable variable_other variable_other_php\'>$uri<\/span>, <span class=\'variable variable_other variable_other_php\'>$admin<\/span>)) {\n");
document.write("					<span class=\'meta meta_function-call meta_function-call_php\'>redirect<\/span>(<span class=\'string string_quoted string_quoted_single string_quoted_single_php\'>\'<span class=\'meta meta_string-contents meta_string-contents_quoted meta_string-contents_quoted_single meta_string-contents_quoted_single_php\'>login<\/span>\'<\/span>);\n");
document.write("				}\n");
document.write("			<span class=\'keyword keyword_control keyword_control_php\'>break<\/span>;\n");
document.write("		}\n");
document.write("		\n");
document.write("	}\n");
document.write("	\n");
document.write("}\n");
document.write("	\n");
document.write("<span class=\'source source_php\'>?<\/span>&gt;<\/span>\n");
document.write("<\/pre><\/pre>\n");
document.write("		<\/td>\n");
document.write("		<\/tr>\n");
document.write("		<\/table>\n");
document.write("	\n");
document.write("	<\/div>\n");
document.write("\n");
document.write("\n");
document.write("  \n");
document.write("  \n");
document.write("  <div class=\"credit\">\n");
document.write("    <div class=\"buttons\">\n");
document.write("      <a href=\"http://pastie.org/pastes/639154.txt\">\n");
document.write("      <img src=\"http://pastie.org/images/view.png\" height=\"20\" width=\"67\" /><\/a>\n");
document.write("    <\/div>\n");
document.write("  \n");
document.write("    <a href=\"http://pastie.org/639154\">Pastie #639154<\/a> linked directly from <a href=\"http://pastie.org/\">Pastie<\/a>.\n");
document.write("  <\/div><\/div>");

