Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-03-2009, 02:12 AM
LifesGreatestGift's Avatar
LifesGreatestGift LifesGreatestGift is offline
 
Join Date: Jul 2009
Location: Louisville, KY USA
Posts: 885
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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?
Reply With Quote
  #2  
Old 08-03-2009, 02:56 AM
Andrew Green's Avatar
Andrew Green Andrew Green is offline
 
Join Date: Nov 2005
Location: Winnipeg, MB
Posts: 996
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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();
?>
Reply With Quote
  #3  
Old 08-03-2009, 03:09 AM
LifesGreatestGift's Avatar
LifesGreatestGift LifesGreatestGift is offline
 
Join Date: Jul 2009
Location: Louisville, KY USA
Posts: 885
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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 //
Reply With Quote
  #4  
Old 08-03-2009, 03:17 AM
Andrew Green's Avatar
Andrew Green Andrew Green is offline
 
Join Date: Nov 2005
Location: Winnipeg, MB
Posts: 996
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

cookies aren't going to work across different domains like that.
Reply With Quote
  #5  
Old 08-03-2009, 03:21 AM
LifesGreatestGift's Avatar
LifesGreatestGift LifesGreatestGift is offline
 
Join Date: Jul 2009
Location: Louisville, KY USA
Posts: 885
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

Its on the same server
Reply With Quote
  #6  
Old 08-03-2009, 03:24 AM
Andrew Green's Avatar
Andrew Green Andrew Green is offline
 
Join Date: Nov 2005
Location: Winnipeg, MB
Posts: 996
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yes, you also don't need the full path for the chdir and require, the relative paths in my example should work.
Reply With Quote
  #7  
Old 08-03-2009, 03:28 AM
LifesGreatestGift's Avatar
LifesGreatestGift LifesGreatestGift is offline
 
Join Date: Jul 2009
Location: Louisville, KY USA
Posts: 885
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #8  
Old 08-03-2009, 03:32 AM
Andrew Green's Avatar
Andrew Green Andrew Green is offline
 
Join Date: Nov 2005
Location: Winnipeg, MB
Posts: 996
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

PHP Code:
chdir ("../"); 
Reply With Quote
  #9  
Old 08-03-2009, 03:36 AM
LifesGreatestGift's Avatar
LifesGreatestGift LifesGreatestGift is offline
 
Join Date: Jul 2009
Location: Louisville, KY USA
Posts: 885
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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>
Reply With Quote
  #10  
Old 08-03-2009, 03:39 AM
Andrew Green's Avatar
Andrew Green Andrew Green is offline
 
Join Date: Nov 2005
Location: Winnipeg, MB
Posts: 996
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:16 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.09630 seconds
  • Memory Usage 2,268KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (6)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete