Forums / General Questions / check if admin logged (for ajax page)

check if admin logged (for ajax page)

Started by sidvizioso on 6 Mar 2012, 11:39 AM · Views: 1,216

Results 1 to 5 of 5
6 Mar 2012, 11:39 AM
#1
sidvizioso avatar

sidvizioso

New Zenner

Join Date:
Feb 2008
Location:
Roma Caput Mundi
Posts:
19
Plugin Contributions:
0

check if admin logged (for ajax page)

I need to check if admin is logged in a new page under admin folder.
I've tried to include application_top.php and check admin session, but i can't view nothing. How can i resolve this situation?
Thancks in advance

ps i've searched on forum but i have found nothing.
pps. i'm sorry for my bad english.

6 Mar 2012, 12:04 PM
#2
sidvizioso avatar

sidvizioso

New Zenner

Join Date:
Feb 2008
Location:
Roma Caput Mundi
Posts:
19
Plugin Contributions:
0

Re: check if admin logged (for ajax page)

I forgot to say I need to protect some functions to upload files via ajax.

6 Mar 2012, 12:47 PM
#3
sidvizioso avatar

sidvizioso

New Zenner

Join Date:
Feb 2008
Location:
Roma Caput Mundi
Posts:
19
Plugin Contributions:
0

Re: check if admin logged (for ajax page)

I'll explain my situation:

i've created a news manager under admin directory, using CKEditor to write up the news content and PDW File Browser to manage images and upload for the news itself, integrated in CKEditor.
PDW File Browser it's open in a popup where you can navigate in the image folder and upload new image if necessary, but if someone finds the admin renamed directory and knows the PDW file browser location can upload what he wants without being logged in as admin. I've tried using .htaccess to prevent guests using pdw files, but it works strange on firefox and on IE doesn't work at all, i think due to a limitations of SWFupload plugin used by PDW File Browser.

I don't know how to protect the index.php of PDW directory I've tried including application_top.php, but the pdw index.php is in a folder under admin, so some php files included/required in application_top.php are not loaded for url issues.

6 Mar 2012, 1:19 PM
#4
rodg avatar

rodg

Deceased

Join Date:
Jan 2007
Location:
Australia
Posts:
6,263
Plugin Contributions:
4

Re: check if admin logged (for ajax page)

Try adding this to the beginning of the file you wish to protect

if (!defined('IS_ADMIN_FLAG')) die('Illegal Access');

If you are lucky, that's all you'll need.

If unlucky you'll still need to load application_top.php (?), perhaps with a conditional statement to prevent it from being loaded twice.

Cheers
Rod

NOTE: We are sorry that Rod is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

Ozpost - The Ultimate Shipping module for Australian Merchants. Click these links for its Homepage, or Download from Zen-Cart.com.

23 Apr 2012, 11:45 AM
#5
infocom avatar

infocom

Zen Follower

Join Date:
Jul 2006
Location:
Cardiff, Wales
Posts:
308
Plugin Contributions:
0

Re: check if admin logged (for ajax page)

I also have this issue... using same add-on.
This does not work:
if (!defined('IS_ADMIN_FLAG')) die('Illegal Access');

You can access the URL direct, outside of Zencart, so this line is meaningless.

Including application_top.php does not work, because then application_top.php includes files from other directories, whereas we are including it in a file in a sub folder, so the path to comfigure.php is wrong, and it cant find it.

So basically we need a way to check if the admin is logged in, in a file ina sub-folder somewhere else, other than in Admin.