vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Authenticated User Session Control On Non-VB Page (https://vborg.vbsupport.ru/showthread.php?t=220072)

LifesGreatestGift 08-03-2009 01:12 AM

Authenticated User Session Control On Non-VB Page
 
I am currently running an image hosting script and want to limit it to my members only.

The image hosting script is located at

/home/jesse123/public_html/TW7S.com/images/

and my forum is

/home/jesse123/public_html/TheWindows7Site.com/forum/

Here is the code I have in the image hosting scripts index page:

PHP Code:

<?

$url = "http://www.thewindows7site.com/forum/";


$curdir = getcwd ();
chdir('/home/jesse123/public_html/thewindows7site.com/forum');
require_once('/home/jesse123/public_html/thewindows7site.com/forum/global.php');


if ($bbuserinfo['userid'] =0) {


?>
<script type="text/javascript" language="JavaScript">
<!--
alert("You Must Register/Login To The Forum\n\To Use This Feature. -Administration Team");

   window.location="<?php echo $url?>";
// -->
</script>

<?

}

else

{
   echo"Thanks For Logging In, <b>$username</b>";
}

chdir ($curdir);

// IMAGE HOSTING SCRIPT .........

What am I doing wrong?

Andrew Green 08-03-2009 01:56 AM

Try this:

PHP Code:

<?php

error_reporting
(E_ALL & ~E_NOTICE);

define('NO_REGISTER_GLOBALS'1);
define('THIS_SCRIPT''pageName'); 

chdir ("../forum");
require_once(
'./global.php');

if (! 
$vbulletin->userinfo['userid'])
{
    
print_no_permission();
    exit();
}
echo 
"Hello!";

exec_shut_down();
?>


LifesGreatestGift 08-03-2009 02:09 AM

Thanks for the reply

now when i visit the image hosting script, it redirects me to my forums login, I login and nothing happens.

Here is the image hosting

http://images.tw7s.com/
>exact location: /home/jesse123/public_html/TW7S.com/images

and here is my forum

http://thewindows7site.com/forum/
>exact location: /home/jesse123/public_html/thewindows7site.com/forum

I added this to the image host script

PHP Code:

<?

$url = "http://www.thewindows7site.com/forum/";


error_reporting(E_ALL & ~E_NOTICE);

define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'pageName'); 

chdir('/home/jesse123/public_html/thewindows7site.com/forum');
require_once('/home/jesse123/public_html/thewindows7site.com/forum/global.php');

if (! $vbulletin->userinfo['userid'])
{
    print_no_permission();
    exit();
}
echo "Hello!";

exec_shut_down();

// Below Here Is Image Host Script Index Code //


Andrew Green 08-03-2009 02:17 AM

cookies aren't going to work across different domains like that.

LifesGreatestGift 08-03-2009 02:21 AM

so i should put the script in forum/image/ ??

Its on the same server

Andrew Green 08-03-2009 02:24 AM

yes, you also don't need the full path for the chdir and require, the relative paths in my example should work.

LifesGreatestGift 08-03-2009 02:28 AM

ok image script is now in

/home/jesse123/public_html/thewindows7site.com/forum/imagehost

and forum is in

/home/jesse123/public_html/thewindows7site.com/forum

I put the following at the top of the imagehost index.php

PHP Code:

<?

$url = "http://www.thewindows7site.com/forum/";


error_reporting(E_ALL & ~E_NOTICE);

define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'pageName'); 

chdir ("../forum");
require_once('./global.php');

if (! $vbulletin->userinfo['userid'])
{
    print_no_permission();
    exit();
}
echo "Hello!";

exec_shut_down();

// Rest of Image Host Script Below //

and get this

Quote:

Warning: chdir() [function.chdir]: No such file or directory (errno 2) in /home/jesse123/public_html/thewindows7site.com/forum/imagehost/index.php on line 11

Warning: require_once(./global.php) [function.require-once]: failed to open stream: No such file or directory in /home/jesse123/public_html/thewindows7site.com/forum/imagehost/index.php on line 12

Fatal error: require_once() [function.require]: Failed opening required './global.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/jesse123/public_html/thewindows7site.com/forum/imagehost/index.php on line 12

Andrew Green 08-03-2009 02:32 AM

with this going into a subfolder of forum go with this:

PHP Code:

chdir ("../"); 


LifesGreatestGift 08-03-2009 02:36 AM

ok, its working! Thank you! But one quick question

How would I go about changing it from giving a no permission login screen when not logged in, to having my popup, and directing them to the main page like this



PHP Code:

$url = "http://www.thewindows7site.com/forum/";

<NON CODED> If user isnt logged in

then do this</NON CODED>

<script type="text/javascript" language="JavaScript">
<!--
alert("You Must Register/Login To The Forum\n\To Use This Feature. -Administration Team");

   window.location="<?php echo $url?>";
// -->
</script>


Andrew Green 08-03-2009 02:39 AM

Where it says "print_no_permission();" is what happens if they don't have a userid.

Where it says "hello!" is what happens if they do.

Replace each as you see fit.


All times are GMT. The time now is 08:44 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01877 seconds
  • Memory Usage 1,746KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (6)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete