Move login form Move login form
 

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

Move login form

Started by hydroplane, October 14, 2006, 10:30:23 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

hydroplane

How do I go from this to this?
I'm using the classic theme and my template.html is attached to this post.

Joachim Müller

Attached your screenshots to my posting (in case the link goes down at some later stage).
What you're up to does not only involve changes to template.html (because it can only contain static HTML), but theme.php as well, as you certainly only want the login form to appear when the user isn't already logged in.
I recommend taking a look at Stramm's modpack, as it comes with support for a custom login form out of the box.

The alternative to actually come up with the code is to edit theme.php and modify the pageheader function to parse a custom token (e.g. {LOGIN_FORM}).

hydroplane

Quote from: GauGau on October 15, 2006, 01:43:04 PM
The alternative to actually come up with the code is to edit theme.php and modify the pageheader function to parse a custom token (e.g. {LOGIN_FORM}).
Thanks. I like this solution better. Do you have a tutorial for that?

Sami

#3
Copy this to your theme.php just before ?>


// ------------------------------------------------------------------------- //
// BEGIN Mod for Custom login box + statistics                                          //
// ------------------------------------------------------------------------- //
  $query = "SELECT COUNT(OWNER_ID) FROM {$CONFIG['TABLE_PICTURES']} WHERE owner_id = ".USER_ID;
$result = mysql_query($query);
$total_upload = mysql_fetch_assoc($result);
mysql_free_result($result);
 
$query = "SELECT COUNT(author_id) FROM {$CONFIG['TABLE_COMMENTS']} WHERE author_id = ".USER_ID;
$result = mysql_query($query);
$total_comments = mysql_fetch_assoc($result);
mysql_free_result($result);

$query = "SELECT user_regdate FROM {$CONFIG['TABLE_USERS']} WHERE user_id = ".USER_ID;
$result = mysql_query($query);
$regdate = mysql_fetch_assoc($result);
mysql_free_result($result);

$custom_login_box = <<<EOT
<div style="float:right; width:290px; border:1px #CCCCCC solid;" align="left">
<form action="login.php?referer=index.php" method="post" name="loginbox" style="margin:0px;">
<div class="tableh1">Enter your username and password to login</div>
<div style="padding-top:2px;">
<div style="width:100px;float:left;padding-left:10px;">Username</div>
<div><input type="text" class="textinput" name="username" style="width:150px;height:13px;" tabindex="1" /></div>
</div>
<div style="padding-top:2px;">
<div style="width:100px;float:left;padding-left:10px;">Password</div>
<div><input type="password" class="textinput" name="password" style="width: 150px;height:13px;" tabindex="2" /></div>
<div style="">
<div style="float:right; padding-top:2px; padding-right:22px;"><input name="submitted" type="submit" class="button" value="Login" tabindex="4" /></div>
</div>
</div>
<div>
<div style="width:100px;float:left;padding-left:10px;height:13px;"></div><div style="float:left;height:13px;">Remembr Me</div>
<div><input name="remember_me" type="checkbox" value="1" tabindex="3" style="height:13px;width:13px;"/></div>
</div>
<div>
<div style="font-size:9px;padding-left:10px;float:left; width:200px;"><a href="forgot_passwd.php">I forgot my password</a></div>
</div>
</form>
</div>
EOT;
// ------------------------------------------------------------------------- //
// End Mod for Custom login box + statistics                                            //
// ------------------------------------------------------------------------- //

function pageheader($section, $meta = '')
{
    global $CONFIG, $THEME_DIR;
    global $template_header, $lang_charset, $lang_text_dir, $custom_login_box;
global $total_upload, $total_comments, $regdate; // Mod for Custom statistics

    $custom_header = cpg_get_custom_include($CONFIG['custom_header_path']);

    header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
    user_save_profile();
// ------------------------------------------------------------------------- //
// BEGIN Mod for Custom login box + statistics                                         //
// ------------------------------------------------------------------------- //
$custom_username = stripslashes(USER_NAME);
if(USER_ID)
$custom_login_box = <<<EOT
<div style="float:right; width:290px; border:1px #CCCCCC solid;" align="left">
              <div class="tableh1"> Welcome <strong>{$custom_username}</strong> !</div>
  <div style="padding-left:10px; height:15px; margin-top:2px;">Joined at : <span style="color:#993366;">{$regdate['user_regdate']}</span>
  </div>
  <div style="padding-left:10px; height:15px; margin-top:2px;">Total uploaded file by you : <span style="color:#993366;">{$total_upload['COUNT(OWNER_ID)']}</span>
  </div>
  <div style="padding-left:10px; height:15px; margin-top:2px;">Total comment by you : <span style="color:#993366;">{$total_comments['COUNT(author_id)']}</span>
  </div>
  <div style="padding-left:10px; height:15px; margin-top:3px; margin-bottom:2px;"><a href="logout.php?referer=index.php" title="Logout {$custom_username}">Log Out</a>
  </div>
          </div>
EOT;
// ------------------------------------------------------------------------- //
// End Mod for Custom login box + statistics                                            //
// ------------------------------------------------------------------------- //
$template_vars = array('{LANG_DIR}' => $lang_text_dir,
        '{TITLE}' => $CONFIG['gallery_name'] . ' - ' . strip_tags(bb_decode($section)),
        '{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'],
        '{META}' => $meta,
        '{GAL_NAME}' => $CONFIG['gallery_name'],
        '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],
        '{SYS_MENU}' => theme_main_menu('sys_menu'),
        '{SUB_MENU}' => theme_main_menu('sub_menu'),
        '{ADMIN_MENU}' => theme_admin_mode_menu(),
        '{CUSTOM_HEADER}' => $custom_header,
'{CUSTOM_LOGINBOX}'  => $custom_login_box, // Mod for Custom login box + statistics
        );

    echo template_eval($template_header, $template_vars);
}


After that you just need to put {CUSTOM_LOGINBOX} to template.html where ever you want custom login box show
- This will give you a login box and when user login, this will give some statistics about that user ....
- You can change the color and login box structure by editing $custom_login_box (orginal colors comes from one of my custom theme ;))
‍I don't answer to PM with support question
Please post your issue to related board

hydroplane

Thank you!! This is even better than what I was looking for. :D

hydroplane

I had to change the code of template.html and now {CUSTOM_LOGINBOX} appears after {GALLERY} so I modified your code. Everything works but the user stats don't show up anymore. What am I doing wrong?
// Mod for custom login box + statistics

$query = "SELECT COUNT(OWNER_ID) FROM {$CONFIG['TABLE_PICTURES']} WHERE owner_id = ".USER_ID;
$result = mysql_query($query);
$total_upload = mysql_fetch_assoc($result);
mysql_free_result($result);
 
$query = "SELECT COUNT(author_id) FROM {$CONFIG['TABLE_COMMENTS']} WHERE author_id = ".USER_ID;
$result = mysql_query($query);
$total_comments = mysql_fetch_assoc($result);
mysql_free_result($result);

$query = "SELECT user_regdate FROM {$CONFIG['TABLE_USERS']} WHERE user_id = ".USER_ID;
$result = mysql_query($query);
$regdate = mysql_fetch_assoc($result);
mysql_free_result($result);

$custom_login_box = <<<EOT
<form action="login.php?referer=index.php" method="post" name="loginbox" style="margin: 0;"></p>
<p>Username<br /><input type="text" class="login_field" name="username" style="width:115px; height:18px;" tabindex="1" /></p>
<p>Password<br /><input type="password" class="login_field" name="password" style="width:115px; height:18px;" tabindex="2" /></p>
<p><input type="submit"  name="submitted" value="Login" tabindex="4" /> <input name="remember_me" type="checkbox" value="1" tabindex="3"

/>remember me</p></p>
<p><a href="forgot_passwd.php">I forgot my password</p>
</form>

EOT;

function pagefooter()
{
    global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_SERVER_VARS;
    global $USER, $USER_DATA, $ALBUM_SET, $CONFIG, $time_start, $query_stats, $queries;;
    global $template_footer, $custom_login_box;

    if ($CONFIG['debug_mode']==1 || ($CONFIG['debug_mode']==2 && GALLERY_ADMIN_MODE)) {
    cpg_debug_output();
    }


// Mod for custom login box + statistics -  Begin
$custom_username = stripslashes(USER_NAME);
if(USER_ID)
$custom_login_box = <<<EOT
<span>Welcome {$custom_username}</span><br />
Member since <span >{$regdate['user_regdate']}</span><br />
<span>{$total_upload['COUNT(OWNER_ID)']}</span> files uploaded<br />
<span>{$total_comments['COUNT(author_id)']}</span> comments<br />
EOT;
// Mod for custom login box + statistics -  End


$template_vars = array(
'{CUSTOM_LOGINBOX}'  => $custom_login_box, // Mod for Custom login box + statistics
        );

    echo template_eval($template_footer, $template_vars);
}

Sami

attach your theme.php (rename it to theme.txt ) to this thread
‍I don't answer to PM with support question
Please post your issue to related board

chris.h

Quote from: Sami on October 15, 2006, 11:45:08 PM
Copy this to your theme.php just before ?>
After that you just need to put {CUSTOM_LOGINBOX} to template.html where ever you want custom login box show
- This will give you a login box and when user login, this will give some statistics about that user ....
- You can change the color and login box structure by editing $custom_login_box (orginal colors comes from one of my custom theme ;))

Worked a treat for me with water_drop theme. Cheers.

afg89

How to show the form {CUSTOM_LOGINBOX} AFTER The Gallery ? It just show up the code.

Nibbler

Use the code posted above by hydroplane and add in the missing global

global $total_upload, $total_comments, $regdate; // Mod for Custom statistics

afg89