1 (edited by ihavenoidea 2003-11-04 15:55)

Topic: im gona get threw this

ok so i integrated this board with the login for the rest of my site.  http://www.fatalthugs.com

if you give /ROOT a peep you can see the login box at the bottom of the screen.  if a user types his forum name and password into there everyting works nicely and they get a little list of options.

the only thing now is having to retype the password even if your logged into the forum is becoming a pain.

if i could just pull the username and password out of the cookie for punbb then im pretty confident that i wouldnt have much trouble getting users logged in automaticly.

heres what ive tried so far.

<?php include("siteheader.php"); ?>


asdf

<?php

// We add the forums directory to the PHP path so that PHP can find the scripts we include later
ini_set('include_path', ini_get('include_path').'/forums');

@include 'config.php';

// If PUN isn't defined, config.php is missing or corrupt
if (!defined('PUN'))
    exit('config.php doesn\'t exist or is corrupt. Please run install.php to install PunBB first.');

// The next line tells PunBB to not update the cookie of the visiting user
// A visit to the front page shouldn't affect stuff like new post indicators
define('PUN_DONT_UPDATE_COOKIE', 1);
require 'include/common.php';

?>

asdfasdf



<?php include("sitefooter.php"); ?>

however i get the error message

asdf config.php doesn't exist or is corrupt. Please run install.php to install PunBB first.

its pulling the siteheader and sitefooter includes just fine.  so i guess that means that its setting the path incorrectly.

all im looking for is the bare minimum code that pulls out the username and password.  if i could get this working them im pretty sure ill be able to understand the rest just fine.

thanks for the help everybody.

oh btw, this is sporkit.  heh, i must have forgotten to change the password on my other account and i think the password rest function is broken.  oh well smile


EDIT: oh yea and if we need im putting this all in a file called cookie.php on my site for testing.  you can check it out here...  http://www.fatalthugs.com/cookie.php

Re: im gona get threw this

I think it's related to the path. Are you sure your forums are located in /forums? Isn't it /forum? Have a look at the following row:

ini_set('include_path', ini_get('include_path').'/forums');

What it does is add the path /forums to the PHP include path. You can check what your current path is by running:

exit(ini_get('include_path'));

Edit: Regarding sporkit. There are two users: sporkit and sporkit150. The first of them has a bullshit address and the other has a yahoo.com address. Did you enter the yahoo adress in the "Forgot password?" form?

Edit2: I just tried the password recovery feature and it works for me.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: im gona get threw this

hmm about the password thing.  i messed it up the first time then it took a little while for me to get the second password email back.  lol, here i am trying to mod thi board and i cant even register right.

anyway, i tried the command you showed me.

exit(ini_get('include_path'));

i used this code.

asdf

<?php

// We add the forums directory to the PHP path so that PHP can find the scripts we include later
ini_set('include_path', ini_get('include_path').'\forum');



@include 'config.php';

exit(ini_get('include_path'));

// If PUN isn't defined, config.php is missing or corrupt
if (!defined('PUN'))
    exit('config.php doesn\'t exist or is corrupt. Please run install.php to install PunBB first.');

// The next line tells PunBB to not update the cookie of the visiting user
// A visit to the front page shouldn't affect stuff like new post indicators
define('PUN_DONT_UPDATE_COOKIE', 1);
require 'include/common.php';


exit(ini_get('include_path'));

?>

asdfasdf

and got this message

asdf .;c:\php\includes\forum

oh and i also was using :..\forum without the s.  that was just a typo.  hmm i also went ahead and tried to think of other combinations like ..\forum ect ect.

anywas thanks for the help so far.  big_smile

however thats definatly not where i have my website stored.  its actually on the d: drive in a folder called fatalthugs.com site or something.  maybe i need to modify php.ini?

Re: im gona get threw this

I must have been drinking when I gave you that line of code. Try this:

ini_set('include_path', ini_get('include_path').';\forum');

"Programming is like sex: one mistake and you have to support it for the rest of your life."

5 (edited by ihavenoidea 2003-11-06 06:09)

Re: im gona get threw this

asdf

<?php

// We add the forums directory to the PHP path so that PHP can find the scripts we include later
ini_set('include_path', ini_get('include_path').';.\forum');




include 'config.php';



// If PUN isn't defined, config.php is missing or corrupt
if (!defined('PUN'))
    exit('config.php doesn\'t exist or is corrupt. Please run install.php to install PunBB first.');

// The next line tells PunBB to not update the cookie of the visiting user
// A visit to the front page shouldn't affect stuff like new post indicators
define('PUN_DONT_UPDATE_COOKIE', 1);
require 'include/common.php';




?>

asdfasdf

woohoo

asdf
asdfasdf

hot damn.  i think that might have done it.  i took the @ character off the include so it wouldnt suppress any error messages and eveyrthing seems good.

haha, uhh ok now what do i do.

jk,  i used that little command you showed me in an email.  dump($cookie);  and i think now i have what i need to work with.  big_smile

oh yea.  there is still however the issue of pulling the password from the database.  how would i run an MD5 hash on a variable in the forum...  $cur_user[password] ?

oh btw: 

ini_set('include_path', ini_get('include_path').';.\forum');

is what finally worked for me.  even after this last post i had to edit the . in front of the \forum.  maybe it would be helpful to others to change that in the other topic i viewed to get this code.

just a thought.


but really thanks for the help.  hopefully well ill be putting some more cool new features in the show off section. big_smile

Re: im gona get threw this

Could you explain exactly why you want to pull the password from the database? I don't understand.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

7 (edited by ihavenoidea 2003-11-06 15:49)

Re: im gona get threw this

Kennel wrote:
Could you explain exactly why you want to pull the password from the database? I don't understand.

well the scirpt i made to controll access to special parts of the site uses sessions.  it checks to see if there is something in the variable $uid and $pwd.  if there isnt it presents them with a form and then checks to see if the exisiting user is in the database.

i could make this script pull the $uid and $pwd from the punbb cookie so itll seem like their always loged in.  if they arnt then ill probably edit it to show a link to the login on your forum or something.

oh and this file is accesscntrl.php which is included at the top of all the pages that i want only registered users to see.

EDIT:  well now that i think of it.  doesnt the password get encrypted by php then that longer code trys to match up with whats in the database?

if thats the case then i think i would probably need to rewrite my script.

Re: im gona get threw this

Yes, all passwords are encrypted. I still don't understand exactly what you want to do though :)

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: im gona get threw this

lol, yea it hit me after a while that the passwords are check as their md5 hashed values. it works pretty well now.

plus keeping my users logged in threw cookies really rocks.  cuts way down on the amount of complaining they do.  big_smile

Re: im gona get threw this

Nice :)

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: im gona get threw this

hello.  rather than start a new topic i thought i would just come back to this one i started a while ago.

as my site expands i find myself having to use this code in different directories.

ini_set('include_path', ini_get('include_path').';.\forum');
include 'config.php';

the problem is i can only get it to work if i place it in the root directory and at the top of whatever page is using the script.  i was wondering if i could get a bit more detail into how this pice of code works.

if my forum is located in /forum and im in /members/list or something like that and i still need that config.php stuff then i have no idea how to setup the code.

Re: im gona get threw this

The ini_set row updates the PHP include_path so that your script can find the file you want to include. What it does is to first get the current include_path and then add ".\forum" to the end of it. What you want to edit is .\forum and change it so that it points to the forum root directory relative to where you are in the directory structure. If your directory structure looks like this:

public_html
public_html\forums
public_html\news

and you want to include PunBB stuff from the news directory, you should run the following command:

ini_set('include_path', ini_get('include_path').';..\forum');

BTW, what version of PunBB are you running? In 1.1 and later, that's not the right way to do it. You should instead define $pun_root and then include common.php.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

13 (edited by ihavenoidea 2004-03-30 18:19)

Re: im gona get threw this

hmm, well my board is currently 1.1.1 and i did try fixing it by using the .. to bring it back to the parent directory. 

$pun_root = './forums/';
include $pun_root.'include/common.php';

i tried other things since i know im two directories ahead of the root (besides using just periods).  im still on a windows server so i tried using the / slashes to see if it helped.  still no luck.

<?php
$pun_root = '../../forums/';
require $pun_root.'include/common.php';
?>

but im still getting this same old error.

Warning: main(../forums/include/common.php): failed to open stream: No such file or directory in C:\Inetpub\fatalthugs site\f8redone\content\index.php on line 3

Fatal error: main(): Failed opening required '../forums/include/common.php' (include_path='.;c:\php4\pear') in C:\Inetpub\fatalthugs site\f8redone\content\index.php on line 3

Re: im gona get threw this

In what directory are you and in what directory are your PunBB files?

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: im gona get threw this

smile

ok.  http://www.fatalthugs.com/f8redone/content/ is where i am right now.

and i need to pull files from.  http://www.fatalthugs.com/forum/include/

this are on my webserver at C:/Inetpub/fatalthugs site/forum/include and C:/Inetpub/fatalthugs site/f8redone/content.

thanks

Re: im gona get threw this

Ok. If you are in "C:/Inetpub/fatalthugs site/f8redone/content" and need to include content from "C:/Inetpub/fatalthugs site/forum/include", your $pun_root should be set to '../../forum/include', i.e. two directories up and then into forum and include. I'm not sure about / vs. \ in Windows, but try the other one if it doesn't work.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: im gona get threw this

heres another problem that rick helped me fix on the #punbb channel.

<?php
define('PUN_TURN_OFF_MAINT', 1);
define('PUN_QUIET_VISIT', 1);

$pun_root = '../../forum/';
include $pun_root.'include/common.php';
?>

i think this is the code to use if your about ver 1.1.  is that right?

anyway its much simplet and works like a charm.