The Beast Within
A look inside EE's source code
Rob Sanchez
EECI 2011
October 21, 2011
A look inside EE's source code
Rob Sanchez
EECI 2011
October 21, 2011
![]()
A good composer does not imitate; he steals.
application/ = expressionengine/EE controller & Core lib{exp:channel:entries channel="users"
search:cf_username="{username}"}
{if no_results}Why?!?{/if}
{title}
{/exp:channel:entries}
system/expressionengine/modules/,
channel/mod.channel.phpentries function
class Channel
{
function entries()
{
var_dump($this->EE->TMPL->tagparams);
...

Example: "Disallowed Key Characters."
http://ee2.local/index.php/site/index/?st.louis,mo=true

Example: "Disallowed Key Characters."
Take a deep breath, open favorite text editor, do a folder search for the offending error message.
system/codeigniter/system/core/Input.php, line 552
function _clean_input_keys($str)
{
if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
{
exit('Disallowed Key Characters.');
}
...
Example: "Disallowed Key Characters."
function _clean_input_keys($str)
{
if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
{
var_dump($str);
exit('Disallowed Key Characters.');
}
...
Example: "Disallowed Key Characters."

Example: "You are not authorized to access this page"
http://ee2.local/admin.php?S=0&D=cp&C=content_edit&M=delete_entries

Example: "You are not authorized to access this page"
Searching for that error message turned up:
system/expressionengine/language/english/cp_lang.php, line 275
'unauthorized_access' => 'You are not authorized to access this page',
Searching for unauthorized_access turns up 385 occurrences. Yikes. Let's narrow that down.
http://ee2.local/admin.php?S=0&D=cp&C=content_edit&M=delete_entries
system/expressionengine/controllers/cp/content_edit.php.
Example: "You are not authorized to access this page"
public function delete_entries()
{
if ( ! $this->cp->allowed_group('can_access_content'))
{
show_error(lang('unauthorized_access'));
}
if ( ! $this->cp->allowed_group('can_delete_self_entries') AND
! $this->cp->allowed_group('can_delete_all_entries'))
{
show_error(lang('unauthorized_access'));
}
Example: "You are not authorized to access this page"
public function delete_entries()
{
if ( ! $this->cp->allowed_group('can_access_content'))
{
show_error(lang('unauthorized_access').' 1st');
}
if ( ! $this->cp->allowed_group('can_delete_self_entries') AND
! $this->cp->allowed_group('can_delete_all_entries'))
{
show_error(lang('unauthorized_access').' 2nd');
}
Example: "You are not authorized to access this page"

Now we know it's related to can_delete_all_entries or can_delete_self_entries
Found in system/codeigniter/system/core, system/expressionengine/libraries and system/codeigniter/system/libraries
//get POSTed form input, with xss clean
echo $this->EE->input->post('form_input', TRUE);
//get a query string element /site/index?element=foo
echo $this->EE->input->get('element');
//get user information, like their member group
echo $this->EE->session->userdata('group_id');
//get the last page visited by the user echo $this->EE->session->tracker[1];
Grab the current url (site/stuff)
{if logged_out}
{redirect='site/login/<php echo $this->EE->uri->uri_string(); ?>'}
{/if}
Redirected to site/login/site/stuff. Grab all the segments after 2 and set return login form
<?php
$segments = $this->EE->uri->segment_array();
$segments = array_slice($segments, 2);
$return = implode('/', $segments);
?>
{exp:member:login_form return="<?php echo $return; ?>"}
$this->EE->load->model('member_model');
There are <?php echo $this->EE->member_model->get_member_count(5); ?> in the Members group.