CodeIgniter Forums
[SOLVED] CI2 - save Profile information in a separate page? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: [SOLVED] CI2 - save Profile information in a separate page? (/showthread.php?tid=32698)



[SOLVED] CI2 - save Profile information in a separate page? - El Forum - 08-01-2010

[eluser]John_Betong[/eluser]
 
If it is not already available then could it be an option in CI2?
 
It would be handy for viewing profile information on-line and not making the information public.

 
 
 


[SOLVED] CI2 - save Profile information in a separate page? - El Forum - 08-01-2010

[eluser]pickupman[/eluser]
I use this in my constructor

Code:
if($user->group == 'admin')
{
  $this->output->enable_profiler(TRUE);
}

You can change to display for a certain group/user.


[SOLVED] CI2 - save Profile information in a separate page? - El Forum - 08-01-2010

[eluser]John_Betong[/eluser]
[quote author="pickupman" date="1280717182"]I use this in my constructor

Code:
if($user->group == 'admin')
{
  $this->output->enable_profiler(TRUE);
}
You can change to display for a certain group/user.[/quote]
 
Many thanks for your reply.
 
It is obvious from your reply that I did not explain myself very well.
 
What I would like is the profiling information logged in a similar fashion to the error_log file.
 
I want the ONLINE profiling information hidden and not available to anyone who happens to visit my site.
 
Your submitted code will dab the profiler information on the end of the output page.
 
 


[SOLVED] CI2 - save Profile information in a separate page? - El Forum - 08-01-2010

[eluser]pickupman[/eluser]
It sounds like you want the information offline in a log file. My code will only show the profiler to a logged in group/user. Having it run in a log file maybe a bit inefficient as it's an additional read/write in the filesystem. For me the profiler is really for development purposes to view queries and $_REQUEST arrays beyond that it doesn't seem to make sense to log the output.

You could look at the output class, and extend the enable_profiler method to write to log instead of appending to the page.


[SOLVED] CI2 - save Profile information in a separate page? - El Forum - 08-01-2010

[eluser]John_Betong[/eluser]
[quote author="pickupman" date="1280725800"]It sounds like you want the information offline in a log file. My code will only show the profiler to a logged in group/user. Having it run in a log file maybe a bit inefficient as it's an additional read/write in the filesystem. For me the profiler is really for development purposes to view queries and $_REQUEST arrays beyond that it doesn't seem to make sense to log the output.

You could look at the output class, and extend the enable_profiler method to write to log instead of appending to the page.[/quote]

I have now solved the problem.

Solution steps:
1. Submit "SPECIFIC_STRING" in my input form
2. Test for "SPECIFIC_STRING" and toggle a $_SESSION['PROF_TOG'] TRUE or FALSE
3. In MY_Controller set $this->output->enable_profiler($_SESSION['PROF_TOG']);

Script:
Code:
// config.php
$_SESSION['PROF_TOG'] = isset($_SESSION['PROF_TOG']) ? $_SESSION['PROF_TOG'] : FALSE;



  // controller.php
  $_SESSION['words'] = $this->_get_search_words(); // uses $_POST
  
  // Toggle if search === SPECIF_STRING_ON & SPECIF_STRING_OFF
  if ('SPECIF_STRING_ON' == trim($_SESSION['words']))
  {
    $_SESSION['PROF_TOG'] = TRUE;
  }

  if ('SPECIF_STRING_OFF' == trim($_SESSION['words']))
  {
    $_SESSION['PROF_TOG'] = FALSE;
  }



// My_Controller.php
  $this->output->enable_profiler($_SESSION['PROF_TOG']);
 
The profile information is now browser specic depending on $_SESSION['PROF_TOG']
 
Many thanks for your suggestion which led to the solution where I did not want any user browsing my site to see the profiling information.