<?php 
}
?>
					<div class="text"><?php 
echo form_input($search_form['search']);
?>
</div>
					<div class="submit"><?php 
echo form_submit($search_form['submit']);
?>
</div>
				<?php 
echo form_close();
?>
				<div class="result" data-searchid="<?php 
echo $main_search_id;
?>
"></div>
			</div>
		</div>
	</div>
	<div id="header_placeholder">
	</div>
	<div id="main-eyecatcher" class="eyecatcher image-mover" style="background-image:url(<%=eyecatcher_image:<?php 
echo iimage('eyecatcher');
?>
%>);">
	</div>
	<div class="outfader">
	</div>
	<div class="wrapper">
 /**
  * Returns image-link of an avatar with fallback to no-avatar
  * @param int $id userid
  * @return mixed BOOL(FALSE) | STRING(link)
  */
 function avatar_image($id)
 {
     if ($i = iimage($id, 1)) {
         return $i;
     }
     return data('users/avatar/no-avatar.png');
 }
 /**
  * Edit a user
  * @param mixed $slug Used as command-recognition; If int it will be used as userid else it will execute special functions for ajax-usage
  * @param mixed $value Value for the command
  * @param bool $ajax will output json on true
  */
 function edit($slug = false, $value = false, $ajax = false)
 {
     $user = $this->auth->user();
     if ($user == false) {
         redirect('user/register');
         return;
     }
     if ($slug == 'picture') {
         if (strtolower($value) == 'profile' || strtolower($value) == 'avatar') {
             $value = 'avatar';
         } else {
             $value = 'background';
         }
         if ($this->input->post('delete')) {
             if (file_exists(FCPATH . 'data/users/' . $value . '/' . $user->id . '.png')) {
                 unlink(FCPATH . 'data/users/' . $value . '/' . $user->id . '.png');
             }
             if (file_exists(FCPATH . 'data/users/' . $value . '/' . $user->id . '.jpg')) {
                 unlink(FCPATH . 'data/users/' . $value . '/' . $user->id . '.jpg');
             }
             $returnarray = array("success" => true, "action" => "delete", "type" => $value);
             if ($value == 'avatar') {
                 $returnarray["path"] = base_url() . 'data/users/avatar/no-avatar.png';
             }
             if ($value == 'background') {
                 $returnarray["path"] = base_url() . 'data/images/eyecatcher.png';
             }
         } else {
             if (isset($_FILES['picture'])) {
                 $this->fileinfo->filepath = $_FILES['picture']['tmp_name'];
                 if ($this->fileinfo->is_file_type('jpg') == true) {
                     move_uploaded_file($this->fileinfo->filepath, FCPATH . 'data/users/' . $value . '/' . $user->id . '.jpg');
                     if (file_exists(FCPATH . 'data/users/' . $value . '/' . $user->id . '.png')) {
                         unlink(FCPATH . 'data/users/' . $value . '/' . $user->id . '.png');
                     }
                     $returnarray = array("success" => true, "action" => "change", "path" => base_url() . 'data/users/' . $value . '/' . $user->id . '.jpg', "type" => $value);
                 } elseif ($this->fileinfo->is_file_type('png') == true) {
                     move_uploaded_file($this->fileinfo->filepath, FCPATH . 'data/users/' . $value . '/' . $user->id . '.png');
                     if (file_exists(FCPATH . 'data/users/' . $value . '/' . $user->id . '.jpg')) {
                         unlink(FCPATH . 'data/users/' . $value . '/' . $user->id . '.jpg');
                     }
                     $returnarray = array("success" => true, "action" => "change", "path" => base_url() . 'data/users/' . $value . '/' . $user->id . '.png', "type" => $value);
                 } else {
                     $returnarray = array("success" => false, "error" => "File signature does not fit png or jpg files.");
                 }
             } else {
                 $returnarray = array("success" => false, "error" => "No file selected.");
             }
         }
         if ($ajax) {
             $this->template->disable();
             $this->output->set_content_type('application/json')->set_output(json_encode($returnarray));
         } else {
             redirect('user/edit');
         }
     }
     if (isint($slug)) {
         $this->permissions->set_user($user->id);
         if (!$this->permissions->has_user_permission('edit_others_profile')) {
             $this->template->render_permission_error();
             return;
         }
         $edit_user = $this->auth->user($slug);
         if ($value == 'profile_picture') {
             if ($this->input->post('delete') && $this->permissions->has_user_permission('delete_others_profile_picture')) {
                 $returnarray = array("success" => true, "action" => "delete", "type" => 'profile');
                 if (file_exists(FCPATH . 'data/users/avatar/' . $edit_user->id . '.png')) {
                     unlink(FCPATH . 'data/users/avatar/' . $edit_user->id . '.png');
                 }
                 if (file_exists(FCPATH . 'data/users/avatar/' . $edit_user->id . '.jpg')) {
                     unlink(FCPATH . 'data/users/avatar/' . $edit_user->id . '.jpg');
                 }
                 $returnarray = array("success" => true, "action" => "delete", "type" => 'avatar');
                 $returnarray["path"] = base_url() . 'data/users/avatar/no-avatar.png';
             } else {
                 $returnarray = array("success" => false, "error" => "You have no permissions to remove the avatar-image.");
             }
             if ($ajax) {
                 $this->template->disable();
                 $this->output->set_content_type('application/json')->set_output(json_encode($returnarray));
             } else {
                 redirect('user/edit/' . $edit_user->id);
             }
             return;
         } elseif ($value == 'background_picture') {
             if ($this->input->post('delete') && $this->permissions->has_user_permission('delete_others_background_picture')) {
                 $returnarray = array("success" => true, "action" => "delete", "type" => 'background');
                 if (file_exists(FCPATH . 'data/users/avatar/' . $edit_user->id . '.png')) {
                     unlink(FCPATH . 'data/users/avatar/' . $edit_user->id . '.png');
                 }
                 if (file_exists(FCPATH . 'data/users/avatar/' . $edit_user->id . '.jpg')) {
                     unlink(FCPATH . 'data/users/avatar/' . $edit_user->id . '.jpg');
                 }
                 $returnarray = array("success" => true, "action" => "delete", "type" => 'avatar');
                 $returnarray["path"] = base_url() . 'data/users/images/eyecatcher.png';
             } else {
                 $returnarray = array("success" => false, "error" => "You have no permissions to remove the background-image.");
             }
             if ($ajax) {
                 $this->template->disable();
                 $this->output->set_content_type('application/json')->set_output(json_encode($returnarray));
             } else {
                 redirect('user/edit/' . $edit_user->id);
             }
             return;
         }
         $permissions_array = $this->permissions->has_user_permissions(array('edit_others_email', 'edit_others_username', 'edit_others_ingame_name', 'edit_others_about', 'edit_others_password', 'delete_others_profile_picture', 'delete_others_background_picture', 'change_activation_status'), false, true);
         $this->_get_edit_others_data($data, $edit_user, $permissions_array);
         if (isset($_POST['submit'])) {
             $update_data = array();
             $validate_array = array();
             $this->_update_if_allowed($update_data, $data['edit_form']['username'], 'username', $validate_array);
             $this->_update_if_allowed($update_data, $data['edit_form']['password_verification'], 'password_verification', $validate_array);
             if (isset($update_data['password_verification'])) {
                 $this->_update_if_allowed($update_data, $data['edit_form']['password'], 'password', $validate_array);
             }
             $this->_update_if_allowed($update_data, $data['edit_form']['email'], 'email', $validate_array);
             $this->_update_if_allowed($update_data, $data['edit_form']['about'], 'about', $validate_array);
             $this->_update_if_allowed($update_data, $data['edit_form']['ingame_name'], 'ingame_name', $validate_array);
             $this->_update_if_allowed($update_data, $data['edit_form']['active'], 'active', $validate_array);
             $errors = $this->auth->update_user($update_data, $edit_user->id, $validate_array);
             $edit_user = $this->auth->user($edit_user->id);
             $this->_get_edit_others_data($data, $edit_user, $permissions_array);
             $data['errors'] = $errors;
         }
         $data['edit_user'] = $edit_user;
         $data['edit_user_permissions'] = false;
         if ($this->permissions->has_user_permission('edit_permissions')) {
             if ($this->permissions->has_user_permission('edit_permission_editors_permissions') || !$this->permissions->has_user_permission('edit_permissions', $edit_user->id)) {
                 $data['edit_user_permissions'] = true;
             }
         }
         $this->_render_page('user/edit_others', $data);
     } elseif ($ajax != true) {
         $data['user'] = $user;
         $this->_get_edit_data($data, $user);
         if ($this->input->post('submit')) {
             $this->config->load('auth');
             $error = array();
             $update_data['username'] = $this->input->post($data['edit_form']['username']['name']);
             $update_data['password'] = $this->input->post($data['edit_form']['password']['name']);
             $update_data['password_verification'] = $this->input->post($data['edit_form']['password_verification']['name']);
             $update_data['about'] = $this->input->post($data['edit_form']['about']['name']);
             $update_data['ingame_name'] = $this->input->post($data['edit_form']['ingame_name']['name']);
             $data['edit_form']['username']['value'] = $update_data['username'];
             $data['edit_form']['about']['value'] = $update_data['about'];
             if (strlen($update_data['password_verification']) == 0) {
                 unset($update_data['password']);
             }
             if ($update_data['username'] == $user->username) {
                 unset($update_data['username']);
             }
             if ($update_data['ingame_name'] == $user->ingame_name) {
                 unset($update_data['ingame_name']);
             }
             if ($this->auth->check_password_id($user->id, $this->input->post($data['edit_form']['old_password']['name']))) {
                 $errors = $this->auth->update_user($update_data, false, array_keys($update_data));
                 $data['form_validation'] = array('success' => TRUE);
                 if ($errors['count'] > 0) {
                     $data['form_validation']['errors'] = TRUE;
                     $data['form_validation']['messages'] = $errors['messages'];
                 } else {
                     $data['form_validation']['messages'] = array('Successfully updated. Reload to see full changes.');
                 }
             } else {
                 $data['form_validation'] = array('success' => FALSE, 'errors' => TRUE, 'messages' => array('The old password is wrong.'));
             }
         }
         $this->template->add_js('jquery.form');
         $this->template->add_js('ajax_upload.settings', $this);
         $userbackground = iimage($user->id, 'background');
         if ($userbackground) {
             $this->template->variable('eyecatcher_image', $userbackground, true);
         }
         $this->_render_page('user/edit', $data);
     }
 }
        ?>
" class="user-section<?php 
        if ($image = iimage($u->id, 2)) {
            ?>
 image-mover" style="background-image:url( <?php 
            echo $image;
            ?>
);" <?php 
        } else {
            echo '"';
            /* complex for correct syntax highlighting ;-) */
        }
        ?>
>
				<span class="avatar" style="background-image:url(<?php 
        echo iimage($u->id, 'avatar');
        ?>
);"></span>
				<h3 class="text-contrast"><?php 
        echo showname($u);
        ?>
</h3>
			</a>
			<?php 
    }
    ?>
		<?php 
}
?>
	</div>
</div>