Armenian Knowledge Base  

Go Back   Armenian Knowledge Base > Technical sections > Webmaster Zone > Web Development
Register

Reply
 
LinkBack Thread Tools
Old 23.04.2003, 19:01   #1
Младенец
 
no1's Avatar
 
Join Date: 04 2003
Location: Nobody from nowhere
Posts: 18
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Default Tragediya veka

PHP Code:
<?php
  
if(!isset($PHP_AUTH_USER)) {
    
Header("WWW-Authenticate: Basic realm=\"My Realm\"");
    
Header("HTTP/1.0 401 Unauthorized");
    .............
    exit;
  } else {
    .............
  }
?>
Posle etogo on zapominaet parol v brauzere..kak likvidirovat ego (ne zakrivaya brauzer), (programnim sposobom)..podrobnee konkretnoy funkciey ili header() -om (na PHP)
Reply With Quote
Old 23.04.2003, 20:36   #2
Moderator
 
Join Date: 03 2002
Location: Russia
Posts: 123
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Default

Вот пример:
PHP Code:
<?php

    
function authenticate()
    {
        
header('WWW-Authenticate: Basic realm="Test Authentication System"');
        
header('HTTP/1.0 401 Unauthorized');
        echo 
"You must enter a valid login ID and password to access this resource\n";
        exit;
    }

    if ( !isset(
$_SERVER['PHP_AUTH_USER']) || ($_POST['SeenBefore'] == && $_POST['OldAuth'] == $_SERVER['PHP_AUTH_USER']))
    {
        unset(
$_SERVER['PHP_AUTH_USER']);
        
authenticate();
    }
    else
    {
        echo 
"<p>Welcome: {$_SERVER['PHP_AUTH_USER']}<br>";
        echo 
"Old: {$_REQUEST['OldAuth']}";
        echo 
"<form action='{$_SERVER['PHP_SELF']}' METHOD='POST'>\n";
        echo 
"<input type='hidden' name='SeenBefore' value='1'>\n";
        echo 
"<input type='hidden' name='OldAuth' value='{$_SERVER['PHP_AUTH_USER']}'>\n";
        echo 
"<input type='submit' value='Re Authenticate'>\n";
        echo 
"</form></p>\n";
    }
?>
Reply With Quote
Old 24.04.2003, 09:38   #3
Младенец
 
no1's Avatar
 
Join Date: 04 2003
Location: Nobody from nowhere
Posts: 18
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Default

esli chesno skazat' eto to chto mne absolutno ne nujno a imenno predlojenniy kod ne puskaet dva raza zaloginitsya odim i tem je loginom a mne nujen skoree vsego header kotoriy stiral bi iz pamyati web browsera informaciyu o logine ne zakrivaya browser ....
Reply With Quote
Old 24.04.2003, 11:25   #4
Moderator
 
Join Date: 03 2002
Location: Russia
Posts: 123
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Default

Да, это не то что тебе надо - это немного переделаный пример из мануала.
Но то что тебе надо, в нем есть. А именно, при новой авторизации, старая не сохраняется.
Перед тем как делать новую авторизацию тебе надо сделать следующее unset($_SERVER['PHP_AUTH_USER']);
Мне кажется из кода это видно.
Reply With Quote
Old 24.04.2003, 14:56   #5
Младенец
 
no1's Avatar
 
Join Date: 04 2003
Location: Nobody from nowhere
Posts: 18
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Default

vot kod po kotoromu ya testiroval

PHP Code:
<?php
  
if($cmd=="kill") unset($PHP_AUTH_USER);

  if(!isset(
$PHP_AUTH_USER)) {
    
Header("WWW-Authenticate: Basic realm=\"My Realm\"");
    
Header("HTTP/1.0 401 Unauthorized");
    exit;
  } else {
  
?>
  <a href="?cmd=kill">link</a>
  <?
  
}
?>
results:

posle togo kak ya najal na link i potom vozvratilsya na this.php (a ne this.php?cmd=kill) menya bol'she bowser ne prosit zaloginits'ya

krome togo function unset likvediruet peremennuyu na servere a ne v browsere (i kak ti ponimaesh po etoy prichine v sleduyushiy raz u menya' neprosit login & pass)
__________________
Obyektno-ozabochennie programmisty vsex stran..Inkapsuliruytes!!!
Reply With Quote
Old 24.04.2003, 16:10   #6
Moderator
 
Join Date: 03 2002
Location: Russia
Posts: 123
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Default

Нади ОДНО отличие.
У тебя - unset($PHP_AUTH_USER);
У меня - unset($_SERVER['PHP_AUTH_USER']);
Reply With Quote
Old 24.04.2003, 16:28   #7
Младенец
 
no1's Avatar
 
Join Date: 04 2003
Location: Nobody from nowhere
Posts: 18
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Default

esli ti dumaesh chto cod protestirovaniy v etom variante
PHP Code:
<?php
  
if($cmd=="kill") unset($_SERVER['PHP_AUTH_USER']);

  if(!isset(
$_SERVER['PHP_AUTH_USER'])) {
    
Header("WWW-Authenticate: Basic realm=\"My Realm\"");
    
Header("HTTP/1.0 401 Unauthorized");
    exit;
  } else {
  
?>
  <a href="?cmd=kill">link</a>
  <?
  
}
?>
kakie to drugie resultati to ti oshibaeshs'ya (no ya vsyotaki oprobval i tak - chem chyort ne shutit)

i krome kogo $PHP_AUTH_USER i $_SERVER['PHP_AUTH_USER'] abolyutno identichni esli v php.ini
register_globals = On
Reply With Quote
Old 24.04.2003, 18:35   #8
freelancer
 
Yerkanian's Avatar
 
Join Date: 06 2002
Location: the same place
Posts: 592
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Default

eto ne budet rabotat'....
pomenyay Auth-realm, dobav' k imeni skazhem time()
Reply With Quote
Old 25.04.2003, 03:51   #9
Младенец
 
no1's Avatar
 
Join Date: 04 2003
Location: Nobody from nowhere
Posts: 18
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Default

neznayu ya shas' napisal vsyo na session a auth ispil'zuyu kak opiknavenuyu formu ....
Reply With Quote
Sponsored Links
Reply

Thread Tools


На правах рекламы:
реклама

All times are GMT. The time now is 10:09.


Powered by vBulletin® Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.