Gå til innhold

Passord på link i html


Anbefalte innlegg

hei, jeg holder på å lage en amatør hjemmeside, så har jeg laga en shoutbox med ip ban osv... men får å komme der hvor jeg må ha ip ban så må jeg følge en link videre til den side. denne linken vil jeg ha passord på.. går det ann? har søkt på google og i Ws3school men fant ikke noe jeg skjønte noe av :S så kansje en av dere er så snille å guide meg? :)

 

Takk

 

 

 

 

Fant denne da:

 

 

<?php
session_start();
header("Cache-control: private");

/*
SIMPLE LOGIN - Access Protection Script
http://new-place.org/scripts/

This is a simple password protection script that requires very little setup.  This single file can protect multiple pages with just a small include at the top of each PHP file you want to protect.  It uses sessions so you only have to enter your password once each time you open your browser, and you can view any number of protected pages without having to login for each page.  THIS SCRIPT CAN ONLY PROTECT PHP FILES and is not compatible with pages that already use sessions.  The default login form is valid XHTML 1.0 Transitional.

I release this script in good faith, but no data stored online can be guaranteed 100% secure.  By using SimpleLogin, you agree to indemnify me from any liability that might arise during its use.  If you encounter any security problems with this script, please report them to me and I will fix or discontinue SimpleLogin as necessary.

SETUP
1. Set your username and password in the config below.
2. Upload this file to your site.
3. Put the following code at the ABSOLUTE VERY TOP of each page you want to password protect:

  <?php require('access.php'); ?>

Important!  Make sure the files you are protecting are in the same directory as this file.  You can still protect files in other directories, but you will need to adjust the include code to add the path to this file.

CUSTOMIZATION
You can customize the login form in the code below (scroll down, it's commented), but do not change any PHP code or the field names.  To make the login page match your site, DO NOT include access.php where you want the form to show up.  It must go at the top of the page you are protecting or the sessions will not work.  Instead, edit the login form below, to add your own header and footer.

NOTES
- Change the name of this file to whatever you want, just make sure to change the filename in the include code.
- You can create a logout from your protected page by linking to page.php?action=logout (link to the protected page, NOT this page).
- If you find this script helpful, a link to my site is appreciated but not required.

UPDATES
May 4, 2006 - Changed include to require to make it safer and added a liability disclaimer.  Removed demo login information I accidentally left in the file.  D'oh!
January 5, 2006 - Tidied up the code a bit, added form input filtering as a security precaution, and added CSS styles to the login page.

*/


//CONFIG
// --------------------------------------------------

// set your username and password
$setusername = 'username';
$setpassword = 'password';


// don't edit below this line
// --------------------------------------------------

if ($_GET['action'] == 'logout') {
$_SESSION = array();
session_destroy();
}

$showform = true;

if ($_POST['action'] == 'login') {

  $replace = array('(' => '(', ')' => ')', '#' => '#');
  $username = strtr(htmlspecialchars(strip_tags($_POST['username'])), $replace);
  $password = strtr(htmlspecialchars(strip_tags($_POST['password'])), $replace);

if (($username != $setusername) || ($password != $setpassword)) {
	$errormsg = true;
} else {	
	$showform = false;
	$_SESSION['username'] = $username;
	$_SESSION['password'] = md5($password);
}

} else {

if (($_SESSION['username'] == $setusername) && ($_SESSION['password'] == md5($setpassword))) {
  $showform = false;
}

}

if ($showform) {

// don't edit above this line
// --------------------------------------------------
?>


<!-- login page -->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<title>Login Required</title>
<style type="text/css">
body, input { color: #000000; font: 12px arial, sans serif; background-color: #ffffff; }
input { border: 1px solid #000000; }
a { color: #666666; text-decoration: none; }
a:hover { color: #333333; }
h1 { font-size: 16px; letter-spacing: 1px;}
p, h1 { margin: 10px 0px; }
.errormsg { color: #FF0000; }
</style>
</head>
<body>

<h1>Login Required</h1>
<form method="post" action="<[i][b]Link"[/b][/i]>
<input type="hidden" name="action" value="login" />

<?php
// don't edit this unless you know what you are doing
if ($errormsg) {
  echo '<p class="errormsg">Invalid login!  Try again.</p>';
}
?>

<p>
Username:<br />
<input type="text" name="username" />
</p>

<p>
Password:<br />
<input type="password" name="password" />
</p>

<p>
<input type="submit" value="Submit" />
</p>

</form>

</body>
</html>

<!-- login page ends -->


<?php
// don't edit below this line
// --------------------------------------------------

exit;
}
?>

 

 

 

men uansett åssen bruker navn jeg setter inn kommer den til den linken :S

Endret av On1Musha
Lenke til kommentar
Videoannonse
Annonse

Jeg har laget et veldig simpelt script uten noe sikkerhet som helst!

Du logger inn med passord (bare passord) og trykker på send inn (submit) så kommer linken til syne.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php  $pass = 'pass2'; //ditt passord her
if ($_POST['submit'] == TRUE) {
$password	= 	$_POST['password'];


if ($password == $pass)
  echo "<a href='linken'>her er linken</a>"
;
}
else
  echo "Passordet er feil";
?>
<form action="" method="post">Passord:<br />
<input id="password" name="password" type="password" /><br /><input name="submit" type="submit" /></form>
</body>
</html>

 

EDIT: Endret koden litt slik at det blir bedre og endre passord

Endret av Famen
Lenke til kommentar

TAKK :D Kjempe kult av deg :D skal testes med en gang! har litt problemer med æøå på servern :s så jeg venter på svar av support på webhotellet mitt... men det får jeg sikkert svar på i morgen :D

 

 

æsj den funka ikke den heller :( bare se selv passorde er test og linken er www.google.com

 

sorry men jeg måtte fjerne linke da jeg ikke liker perversje snokere, som spamer ned gjeste boka mi! send en pm vis du vil se du :p

Endret av On1Musha
Lenke til kommentar

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
  • Hvem er aktive   0 medlemmer

    • Ingen innloggede medlemmer aktive
×
×
  • Opprett ny...