kunzite (kunzite1) wrote in component_help,
kunzite
kunzite1
component_help

login component w/ return

in response to _tumblweed's post.
###################################
#    LOGIN COMPONENT W/ RETURN    #
# kunzite1, component-help/671184 #
# add to print_free_text(Page p)  #
###################################
var Page   k1Lp           = get_page();                         # get a handle for the page
var string k1Lreturn_url  = $k1Lp.journal->base_url() + "/";    # grab the base_url of your journal
var string k1Lhdr_log_in  = "login";                            # header for login box
var string k1Lhdr_log_out = "logout";                           # header for logout box
var string k1Lusername    = "username:";                        # label for username textbox
var string k1Lpassword    = "password:";                        # label for password textbox
var string k1Lforget      = "forget?";                          # link text for forgot password page
var string k1Lexpiration  = "expiration:";                      # label for expiration radio buttons
var string k1Lexp_close   = "onClose();";                       # label for expiring on close of window
var string k1Lexp_never   = "never";                            # label for expiring "never"
var string k1Lbind_ip     = "bind to ip";                       # label for binding to ip radio buttons
var string k1Lbi_yes      = "yes";                              # label for binding to ip
var string k1Lbi_no       = "no";                               # label for not binding to ip
var string k1Lsub_in      = "log in";                           # label for login button
var string k1Lsub_out     = "log out";                          # label for logout button
var string k1Lstandard    = "standard";                         # link text for standard (http) login page
var string k1Lsecure      = "secure";                           # link text for secure (https) login page
var string k1Luserinfo    = $*IMGDIR + "/userinfo.gif";         # url to userinfo image, if to be used
var int    k1Luser_width  = 17;                                 # width of userinfo image, set to -1 if not using an image
var Color  k1Luser_bg     = "#ffffff";                          # bgcolor of username textbox
var Color  k1Luser_fg     = "#0000cc";                          # fgcolor of username textbox

if($k1Luserinfo == "") { $k1Luser_width = -1; }
# inline style for username textbox
var string k1Luser_style  = "style=\"background: url($k1Luserinfo) no-repeat; background-color: $k1Luser_bg; background-position: 0px 1px; padding-left: " + ($k1Luser_width + 1) + "px; color: $k1Luser_fg; font-weight: bold;\"";

var string k1Lheader      = viewer_logged_in() ? $k1Lhdr_log_out : $k1Lhdr_log_in; # get header
var string k1Lform        = "";                                                    # string for form
var string SECUREROOT     = "https" + $*SITEROOT->substr(4, $*SITEROOT->length()); # get secure root

if(not viewer_logged_in()) { # if not logged in, make login form
                             # if return url set, include it
  $k1Lform = $k1Lform + """
  <form action="$*SITEROOT/login.bml" method="post" id="login">
    <table border="0" cellpadding="3">
      <tr>
        <td>
          $k1Lusername
        </td>
        <td>
          <input type="text" value="" name="user" size="15" maxlength="15" $k1Luser_style />
        </td>
      </tr>
      <tr>
        <td valign="top">
          $k1Lpassword
        </td>
        <td>
          <input type="password" name="password" id="xc_password" size="15" maxlength="30" /><br />
          <a href="$*SITEROOT/lostinfo.bml"><font size="1">$k1Lforget</font></a>
        </td>
      </tr>
      <tr valign="top">
        <td>
          $k1Lexpiration
        </td>
        <td>
          <input type="radio" name="expire" value="close"  checked="checked" id="close" /> <label for="close">$k1Lexp_close</label><br />
          <input type="radio" name="expire" value="never"  id="never" /> <label for="never">$k1Lexp_never</label>
        </td>
      </tr>
      <tr valign="top">
        <td>
          $k1Lbind_ip
        </td>
        <td>
          <input type="radio" name="bindip" value="yes"  id="bindyes" /> <label for="bindyes">$k1Lbi_yes</label><br />
          <input type="radio" name="bindip" value="no"  checked="checked" id="bindipno" /> <label for="bindipno">$k1Lbi_no</label>
        </td>
      </tr>
      <tr>
        <td>"""; if($k1Lreturn_url != "") { $k1Lform = $k1Lform + """<input type="hidden" name="ref" value="$k1Lreturn_url" />"""; } $k1Lform = $k1Lform + """</td>
        <td align="left">
          <input name="action:login" type="submit" value="$k1Lsub_in" /><br />
          [ <b>$k1Lstandard</b> | <a href="$SECUREROOT/login.bml">$k1Lsecure</a> ]
        </td>
      </tr>
    </table>
  </form>
  """;
} else { # if not logged in, make logout form
         # havent been able to figure out how to implement return url
  $k1Lform = $k1Lform + """
  <form action="$*SITEROOT/logout.bml" method="post">
    <input type="submit" value="$k1Lsub_out" />
  </form>
  """;
}

print_comp_header($k1Lheader); print $k1Lform; print_comp_footer();
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

  • 2 comments