0

我有这个不是我写的 Perl 脚本(我也不会写 Perl),如果你登录了,它会插入一个注销链接:

sub print_loginform {
  $web_content .= qq{


                 </form>
  };
}

if ($logged_in_as) {
  $addlink = '<a href="/logout">Logout</a><a href="/account/">My Account</a>';

}
$web_content .= qq{
        <div id="menu">
                <div id="menuheader">Menu</div>
                <a href="/">Home</a>
                <a href="/online/">Who's online?</a>
                <a href="/highscores/">Highscores</a>
                <a href="/rules/">Rules</a>
          <a href="/about/">About</a>
                <a href="/guilds/">Guilds</a>
                <a href="/houses/">Houses</a>
          <a href="/shop/">Donations</a>
          <a href="/forum/">Forum</a>
                <a href="/lost-password/">Lost Password</a>
                <a href="/create-account/">Create Account</a>$addlink
        <div id="menufooter"></div>




};

if (!$logged_in_as) {
  &print_loginform();
}
$web_content .= "</div>";

当用户登录做一些非常hacky的事情并且只是登录面板时,是否有一种方法可以添加一些内联css display:none

我试过这个:

if ($logged_in_as) {
      $addlink = '<a href="/logout">Logout</a><a href="/account/">My Account</a>';
       $removelogin = '<style type="text/css" media="screen">.loginpanel:display:none;</style>';
    }

可以肯定地说它没有用,但由于我不是 Perl 程序员,我无法真正弄清楚这一点,这对我来说完全是在黑暗中拍摄,我什至觉得有点像菜鸟一样来问求助。我试图在 Perl 上找到的文档充其量也很少。

这是马修的代码,这不起作用(可能是我的错)

sub print_loginform {
  $web_content .= qq{


                 </form>
  };
}

if ($logged_in_as) {
      $addlink = '<a href="/logout">Logout</a><a href="/account/">My Account</a>';

    }
$web_content .= qq{
        <div id="menu">
                <div id="menuheader">Menu</div>
                <a href="/">Home</a>
                <a href="/online/">Who's online?</a>
                <a href="/highscores/">Highscores</a>
                <a href="/rules/">Rules</a>
          <a href="/about/">About RealOTS</a>
                <a href="/guilds/">Guilds</a>
                <a href="/houses/">Houses</a>
          <a href="/shop/">Donations</a>
          <a href="/forum/">Forum</a>
                <a href="/lost-password/">Lost Password</a>
                <a href="/create-account/">Create Account</a>$addlink
        <div id="menufooter"></div>

        <div class="loginpanel">
                     <form action="" method="POST">
                  <input type="hidden" name="auth" value="1">
                        Account Number:
                        <input type="text" name="user" value="" size=15>
                        Password:
                        <input type="password" name="pass" value="" size=15>
                        <input type="submit" name="submit" value="Login">
            </div>            


                        <form method="POST" action="/character/">
                                <input type="hidden" name="page" value="character">
                                Character Search<input type="text" name="searchchar" value="" size=15><br><br>
                                <input type="submit" value="Look up">
                        </form>

};

if (!$logged_in_as) {
  &print_loginform();
  $web_content .= qq{<div class="loginpanel">
                 <form action="" method="POST">
              <input type="hidden" name="auth" value="1">
                    Account Number:
                    <input type="text" name="user" value="" size=15>
                    Password:
                    <input type="password" name="pass" value="" size=15>
                    <input type="submit" name="submit" value="Login">
        </div>  
  };
}
$web_content .= "</div>";
4

3 回答 3

0

现在删除这个块:

    <div class="loginpanel">
                 <form action="" method="POST">
              <input type="hidden" name="auth" value="1">
                    Account Number:
                    <input type="text" name="user" value="" size=15>
                    Password:
                    <input type="password" name="pass" value="" size=15>
                    <input type="submit" name="submit" value="Login">
        </div>            

只有出现在下面的那个:

<div id="menufooter"></div>

最后反转这部分:

$web_content .= qq{<div class="loginpanel">
             <form action="" method="POST">
          <input type="hidden" name="auth" value="1">
                Account Number:
                <input type="text" name="user" value="" size=15>
                Password:
                <input type="password" name="pass" value="" size=15>
                <input type="submit" name="submit" value="Login">
    </div>  
 };
 &print_loginform();

尽管此时您不妨删除 print_loginform ...

于 2013-05-09T06:14:27.173 回答
0

而不是破解 css,也许你可以修改$webcontent.

if ($logged_in_as) {
      $addlink = '<a href="/logout">Logout</a><a href="/account/">My Account</a>';

}
$web_content .= qq{
        <div id="menu">
                <div id="menuheader">Menu</div>
                <a href="/">Home</a>
                <a href="/online/">Who's online?</a>
                <a href="/highscores/">Highscores</a>
                <a href="/rules/">Rules</a>
          <a href="/about/">About RealOTS</a>
                <a href="/guilds/">Guilds</a>
                <a href="/houses/">Houses</a>
          <a href="/shop/">Donations</a>
          <a href="/forum/">Forum</a>
                <a href="/lost-password/">Lost Password</a>
                <a href="/create-account/">Create Account</a>$addlink
        <div id="menufooter"></div>
};

if (!$logged_in_as) {
   $web_content .= qq{<div class="loginpanel">
                 <form action="" method="POST">
              <input type="hidden" name="auth" value="1">
                    Account Number:
                    <input type="text" name="user" value="" size=15>
                    Password:
                    <input type="password" name="pass" value="" size=15>
                    <input type="submit" name="submit" value="Login">
        </form></div>  
  };
}
$web_content .= "</div>";

我认为您可以省略该print_loginform功能

于 2013-05-09T05:34:40.053 回答
0

那么这不是正确的CSS:

<style type="text/css" media="screen">.loginpanel{display:none;}</style>

你也可以考虑把登录面板

   <div class="loginpanel">
                 <form action="" method="POST">
              <input type="hidden" name="auth" value="1">
                    Account Number:
                    <input type="text" name="user" value="" size=15>
                    Password:
                    <input type="password" name="pass" value="" size=15>
                    <input type="submit" name="submit" value="Login">
        </div>   

在这条线以下

if (!$logged_in_as) {
  &print_loginform();

像这样:

if (!$logged_in_as) {
  &print_loginform();
  $web_content .= qq{<div class="loginpanel">
                 <form action="" method="POST">
              <input type="hidden" name="auth" value="1">
                    Account Number:
                    <input type="text" name="user" value="" size=15>
                    Password:
                    <input type="password" name="pass" value="" size=15>
                    <input type="submit" name="submit" value="Login">
        </div>  
  };
}
于 2013-05-09T05:31:44.793 回答