2013-05-09 30 views
0

我有這樣的Perl腳本,我沒有寫(我也不能寫的Perl),插入一個退出鏈接,如果你登錄:插入CSS

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>"; 

會不會有一種方法當用戶登錄時添加一些內聯的css來做一些真正hacky的事情,只是display:none loginpanel?

我嘗試這樣做:

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>"; 

回答

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> 
    }; 
} 
+0

那會怎麼做? – andy 2013-05-09 05:47:52

+0

它會使登錄面板只會在退出鏈接不存在時纔會出現。 – 2013-05-09 05:49:25

+0

它不會工作我害怕,我會編輯我的第一篇文章,我替換 – andy 2013-05-09 06:04:01

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功能

+0

代碼,不會改變任何東西。 – andy 2013-05-09 05:46:47

+0

你可以嘗試打印'$ logged_in_as'的值嗎? – erickb 2013-05-09 06:01:14

+0

我不知道該怎麼做打印。 – andy 2013-05-09 06:06:17

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 ...