Where does the {USER_NAME} get set? Where does the {USER_NAME} get set?
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Where does the {USER_NAME} get set?

Started by dotnetCarpenter, March 06, 2007, 06:03:20 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

dotnetCarpenter

Hi all.

I'm very new to cpg but need to fix this ASAP. I've just implemented a CAPTCHA in cpg which is working great but in my table design (I hate designing with tables but it was how the gallery was build by another company) if the user is logged in, cpg removes (rightly so) some element and it looks like shit. My fix is simply to put the HTML comments (great way to insert templates I might add) away from the HTML and display the name input box. But at least I want to display the user name in the box {USER_NAME} but it's blank. If the user is not logged in it contains "Anonymous" so everything seems to be working. My question in where does the USER_NAME variable get set? I want to set it in login.php but I'll like to know where it's officially set so I don't screw something up.

Thanks in advance! Cheers, Jon.

Joachim Müller

USER_NAME is not a variable though, but a constant. Once it has been set, you can't change it.

Nibbler

The comment output is in theme_html_comments() in the theme system. If your theme.php does not have the function then copy it over from the sample theme and modify your copy.

I think you are referring to {USER_NAME} in $template_add_your_comment

dotnetCarpenter

Thanks for the quick replies!
@GauGau:
Yes I just realized that.
@Nibbler:
I'll check it out and yes it's the {USER_NAME} in $template_add_your_comment.

dotnetCarpenter

Thanks to both of you. I've tried to put some lines in login.php and inserted the theme_html_comments() in my theme.php and did some alterations but to no avail.
In login.php I put one line:

if (isset($_POST['submitted'])) {
    if ( $USER_DATA = $cpg_udb->login( addslashes($_POST['username']), addslashes($_POST['password']), isset($_POST['remember_me']) ) ) {
        $referer=preg_replace("'&'","&",$referer);
        // I put the next line
        $_SESSION['login_user'] = $USER_DATA['user_name'];
        pageheader($lang_login_php['login'], "<META http-equiv=\"refresh\" content=\"3;url=$referer\">");
        msg_box($lang_login_php['login'], sprintf($lang_login_php['welcome'], $USER_DATA['user_name']), $lang_continue, $referer);
        pagefooter();
        exit;
    } else { ...

and in my theme.php this:

$params = array('{ADD_YOUR_COMMENT}' => $lang_display_comments['add_your_comment'],
            // Modified Name and comment field
            '{NAME}' => $lang_display_comments['name'],
            '{COMMENT}' => $lang_display_comments['comment'],
            '{PIC_ID}' => $pid,
            '{USER_NAME}' => strlen($user_name) == 0 ? $_SESSION['login_user'] : $user_name,
            '{MAX_COM_LENGTH}' => $CONFIG['max_com_size'],
            '{OK}' => $lang_display_comments['OK'],
            '{SMILIES}' => '',
            '{WIDTH}' => $CONFIG['picture_table_width'],
            );

I've given up on it but is still interested in a quick fix if someone has one. Thanks for the help!