Advanced search  

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]

Pages: [1]   Go Down

Author Topic: Move login form  (Read 6713 times)

0 Members and 1 Guest are viewing this topic.

hydroplane

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 23
Move login form
« on: October 14, 2006, 10:30:23 pm »

How do I go from this to this?
I'm using the classic theme and my template.html is attached to this post.
« Last Edit: October 16, 2006, 09:17:43 am by GauGau »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Move login form
« Reply #1 on: October 15, 2006, 01:43:04 pm »

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}).
Logged

hydroplane

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 23
Re: Move login form
« Reply #2 on: October 15, 2006, 08:43:24 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?
Logged

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: Move login form
« Reply #3 on: October 15, 2006, 11:45:08 pm »

Copy this to your theme.php just before ?>

Code: [Select]
// ------------------------------------------------------------------------- //
// 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 ;))
« Last Edit: October 15, 2006, 11:52:59 pm by Sami »
Logged
‍I don't answer to PM with support question
Please post your issue to related board

hydroplane

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 23
Re: Move login form
« Reply #4 on: October 16, 2006, 09:13:33 am »

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

hydroplane

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 23
Re: Move login form
« Reply #5 on: January 07, 2007, 10:14:47 pm »

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?
Code: [Select]
// 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);
}
Logged

Sami

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 3686
  • BMossavari
    • My Project
Re: Move login form
« Reply #6 on: January 14, 2007, 05:39:44 am »

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

chris.h

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 38
    • Zookx Design
Re: Move login form
« Reply #7 on: September 05, 2007, 03:10:07 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.
Logged

afg89

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
    • Free PSP Wallpapers
Re: Move login form
« Reply #8 on: January 14, 2008, 03:58:57 am »

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

Nibbler

  • Guest
Re: Move login form
« Reply #9 on: January 14, 2008, 04:18:58 am »

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

Code: [Select]
global $total_upload, $total_comments, $regdate; // Mod for Custom statistics
Logged

afg89

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
    • Free PSP Wallpapers
Re: Move login form
« Reply #10 on: January 15, 2008, 12:47:10 am »

Thanks
Logged
Pages: [1]   Go Up
 

Page created in 0.02 seconds with 20 queries.