Welcome Guest, Not a member yet? Register   Sign In
prevent direct access to this function/page ?
#14

[eluser]bEz[/eluser]
An alternative method to the HELPER solution would be to create a new constant in:

./application/config/constant.php
Code:
/*
|--------------------------------------------------------------------------
| Define Ajax Request
|--------------------------------------------------------------------------
|
*/
define(
     'IS_AJAX',
     isset($_SERVER['HTTP_X_REQUESTED_WITH']) &&
     strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'
);

Line separated for clarity.

Stumbled upon this code while viewing the recent weblee screencast for JQuery (btw, a must view).

You can then change the controller code as follows:
Code:
if (! IS_AJAX)
{
  // not ajax
} else {
  // ajax
}

Subtle change, but it works!


Messages In This Thread
prevent direct access to this function/page ? - by El Forum - 06-09-2009, 04:58 AM
prevent direct access to this function/page ? - by El Forum - 06-09-2009, 05:02 AM
prevent direct access to this function/page ? - by El Forum - 06-09-2009, 05:05 AM
prevent direct access to this function/page ? - by El Forum - 06-09-2009, 06:37 AM
prevent direct access to this function/page ? - by El Forum - 06-10-2009, 03:23 AM
prevent direct access to this function/page ? - by El Forum - 06-10-2009, 03:36 AM
prevent direct access to this function/page ? - by El Forum - 06-10-2009, 03:41 AM
prevent direct access to this function/page ? - by El Forum - 06-10-2009, 03:59 AM
prevent direct access to this function/page ? - by El Forum - 06-10-2009, 04:06 AM
prevent direct access to this function/page ? - by El Forum - 06-10-2009, 04:18 AM
prevent direct access to this function/page ? - by El Forum - 06-10-2009, 08:15 AM
prevent direct access to this function/page ? - by El Forum - 06-10-2009, 08:19 AM
prevent direct access to this function/page ? - by El Forum - 06-10-2009, 07:39 PM
prevent direct access to this function/page ? - by El Forum - 07-09-2009, 05:39 PM



Theme © iAndrew 2016 - Forum software by © MyBB