Welcome Guest, Not a member yet? Register   Sign In
How to use CI instance outside application?
#1

[eluser]dbashyal[/eluser]
I want to use iBrowser of tinymce WYSIWYG editor. But it can be accessed by anyone without login. Is there anyway i can restrict access to logged in admins only?

It doesn't use base index.php as it has separate files itself.

Any help would be appreciated.

Thanks.
#2

[eluser]mddd[/eluser]
That kind of script works totally separate from CI. So you have to think of another solution than using a CI instance.
However most 'browsing scripts' have an option to hook into a session to check if they are allowed to 'do their thing'.
If your CI login works via a php session, it should be easy to have your browser check if that session is correct.
For instance if a user logs in, you set $_SESSION['allow_browsing']=1 and in the browser script you check for that.

Note: I am talking about php sessions, not CI sessions because CI's session library works through cookies.
(Which you could also tap into if you wanted, but not quite as easily especially if they are encrypted).
#3

[eluser]dbashyal[/eluser]
Thanks Mddd.

It would have been so good if i can use CI session, so that i can check if the user is logged in or not.

May be I'll try cookies.

Thanks again.
#4

[eluser]mddd[/eluser]
I don't use CI cookies, so I'm no expert. But I guess it would be possible to write some code that checks the CI session outside of CI. That would be the least work for you I think.
#5

[eluser]cahva[/eluser]
If this "iBrowser" is like the imagemanager, then you could just do "oldschool" query to your ci-sessions table. For example I have this in imagemanager plugin(index.php):

Code:
<?php
session_start();

if (!isset($_COOKIE['ci_session']))
{
    die();
}

$ses = unserialize($_COOKIE['ci_session']);

mysql_connect("server", "mysql_user", "mysql_pass");
mysql_select_db('database');

$sql = "SELECT user_data FROM ci_sessions WHERE session_id = '".$ses['session_id']."'";
$result = mysql_query($sql);

if(mysql_num_rows($result) == 0)
{
    die();
}

$_SESSION['logged_in'] = true;

...

I have set in the imagemanger's config:
Code:
$mcImageManagerConfig['SessionAuthenticator.logged_in_key'] = "logged_in";

So it looks for native session 'logged_in'.




Theme © iAndrew 2016 - Forum software by © MyBB