Topic: integration with coppermine....$define_user issue

Sorry in advance as this is not really punbb's problem but I think this forum may be more helpful than coppermines.

So I have bridged coppermine with punbb and it works fine they share a cookie etc....however I get trouble when:

to include php code in the header of coppermine you must put it in a file named theme.php (for those of you unfamiliar with coppermine).  So I have put a loginbox in that file and it works fine without any parse errors but there is a 'if' and 'else' statement in the loginbox php code and it refers to $define_user.  So what is happening is that it always comes back as guest no matter what....even if I am logged into coppermine and punbb.


By the way the same loginbox works fine as a standalone .php file in the same directory as theme.php its just when I try and merge them that it breaks and the cookie starts only returning guest.

I know this is probably not punbb's problem but I am just wondering if anyone has any idea what I am doing wrong.

Thanks


Nick

Punbb w/coppermine and wordpress integrated

see my hack to integrate punbb with wordpress comment system.
Illustration Community

Re: integration with coppermine....$define_user issue

Post your code. Remember that your code is being included from within a function so you may have issues with variable scope.

Re: integration with coppermine....$define_user issue

Thanks for the reply.

I have spent so f***ing long on this I just went for a compromise which works well enough and shouldn't compromise the ease of use of the site too much (which is what this is all about a social networking site for artists).  I being one of the artists who will use this site have very little knowledge of programming or scripting...but hey I press on.

I traced the problem to something to do with the database bridge of coppermine and punbb and not being able to call punbb functions from within coppermines theme file.   Well I think that was it....!

I'm going for a drink   smile

Punbb w/coppermine and wordpress integrated

see my hack to integrate punbb with wordpress comment system.
Illustration Community

Re: integration with coppermine....$define_user issue

Hi

Yes you are right I think it is a problem of scope....I am trying to use global $db from within a function so it is not actually global.

I have to use it within a function though....this is the nature of coppermine.  Is there a superglobal for $db something like $GLOBALS[db] that might work?

here is the code :

function pageheader($section, $meta = '')
{
   global $CONFIG, $THEME_DIR;
   global $template_header, $lang_charset, $lang_text_dir;

   if(empty($custom_header)){
  
define('PUN_ROOT', 'pathe to pun root/');


global $db;
global $pun_user;
 
include 'path to /common.php';


if ($pun_user['is_guest']) {


echo '<a>Username  &  Password</a>';
  echo "<form id=\"login\" method=\"post\" action=\"/pun/login.php?action=in\" onsubmit=\"return process_form(this)\">
<input type=\"hidden\" name=\"form_sent\" value=\"1\" />
<input type=\"hidden\" name=\"redirect_url\" value=\"".$_SERVER['SCRIPT_NAME']."\" />
<input type=\"text\" name=\"req_username\" size=\"25\" maxlength=\"25\" />
<input type=\"password\" name=\"req_password\" size=\"16\" maxlength=\"16\" />
<input type=\"submit\" name=\"login\" value=\"Login\" />
</form>";

echo '<a href="/pun/register.php">Want an account?</a>';
echo '<a>                    </a>';echo '<a>         or          </a>';echo '<a>                   </a>';
echo '<a href="/pun/login.php?action=forget">Forgot your password?</a>';
}
else {
echo "Logged in as: ".pun_htmlspecialchars($pun_user['username'])."
<br>Click <a href=\"/pun/login.php?action=out&id=".$pun_user['id']."&location_out=".$_SERVER['SCRIPT_NAME']."\">here</a> to log out.</div>";
}
Punbb w/coppermine and wordpress integrated

see my hack to integrate punbb with wordpress comment system.
Illustration Community

Re: integration with coppermine....$define_user issue

If you're bridged then it would be easier to use Coppermine's login constant USER_ID. If that is 0 then the user is not logged in, otherwise it has the punbb userid.