| | |
| Stránka: 1 z 1
| [ Príspevok: 1 ] | |
Autor | Správa |
---|
Registrovaný: 01.05.05 Príspevky: 13348 Témy: 1496 Bydlisko: Bratislava | Napísal JanoF: 14.10.2006 15:17 | |
|
Generácia súboru .htaccess v 1.0
Kód: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1250" /> <title>HTACCES</title> <style> body { font-family: Arial, Helvetica; color: #000000; font-size: 12px; } TD { font-size: 12px; } </style> </head> <body> <h3>Generování .htaccess a .htpasswd</h3> <?php $submit = $_REQUEST['submit']; if (isset ($submit)) { $nazev = $_REQUEST['nazev']; $jmeno = $_REQUEST['jmeno']; $heslo = $_REQUEST['heslo']; $heslo_crp = crypt($heslo); $cesta = substr($_SERVER['SCRIPT_FILENAME'], 0, strlen($_SERVER['SCRIPT_FILENAME']) - strlen($PHP_SELF)); if (crypt($heslo, $heslo_crp) == $heslo_crp) { $hta = 'AuthUserFile '.$cesta.'/.htpasswd'."\n".'AuthName "'.$nazev.'"'."\n".'AuthType Basic'."\n".'require valid-user'; ?> <p>Přihlašovací jméno: <strong><?php echo $jmeno; ?></strong><br /> Přihlašovací heslo: <strong><?php echo $heslo; ?></strong></p> <p> Obsah souboru <strong>.htaccess</strong><br /> <textarea cols="50" rows="5"><?php echo $hta; ?></textarea> </p> <p> Obsah souboru <strong>.htpasswd</strong><br /> <textarea cols="50" rows="2"><?php echo $jmeno.':'.$heslo_crp; ?></textarea> </p> <?php } else { echo '<p>Došlo k chybě při šifrování hesla.</p>'; } echo '<hr />'; }
?> <form action="<?php echo $PHP_SELF ?>" method="post"> <table border="0" cellspacing="2" cellpadding="2"> <tr> <td>Přihlašovací hlavička: </td> <td><input type="text" name="nazev" value="Administrace" /></td> </tr> <tr> <td>Jméno:</td> <td><input type="text" name="jmeno" value="admin" /></td> </tr> <tr> <td>Heslo:</td> <td><input type="text" name="heslo" value="" /></td> </tr> <tr> <td> </td> <td><input type="submit" name="submit" value="Odeslat" /></td> </tr> <table> </form> </body> </html> Generácia súboru .htaccess v2.0Kód: <?php // Userliste $userlist = ( isset($_POST['userlist']) ) ? $_POST['userlist'] : '';
if ( isset( $_POST['add'] ) && $_POST['name'] != '' && $_POST['pw'] != '' ) { $userlist.= $_POST['name'] . ":" . crypt( $_POST['pw'] ) . "\n"; }
// htpasswd $pw_file = ".htpasswd";
// htaccess $path = $_SERVER['SCRIPT_FILENAME']; $path = ereg_replace('/access.php', '', $path); $acc_start = "AuthUserFile $path/$pw_file\nAuthName Privat\nAuthType Basic\nrequire valid-user";
$acc_file = "./.htaccess"; $access = ( isset($_POST['access']) ) ? $_POST['access'] : $acc_start;
if ( isset( $_POST['save'] ) && $userlist != '' && $access != '' && !( file_exists("./$pw_file") ) && !( file_exists($acc_file) ) ) { // htpasswd $file = fopen("./$pw_file", "w+"); if(!fwrite($file, $userlist)) $error = TRUE; fclose($file);
// htaccess $file = fopen($acc_file, "w+"); if(!fwrite($file, $access)) $error = TRUE; fclose($file); } ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>htaccess Creator</title> </head>
<body> <form method="post" action="access.php" name="post"> <table border="0" cellspacing="0" cellpadding="5"> <tr> <td><b>.htaccess</b>:</td> </tr> <tr> <td colspan="5"><textarea name="access" rows="7" cols="35" wrap="virtual" style="width:100%" class="post"><?php echo($access) ?></textarea></td> </tr> <tr> <td><b>.htpasswd</b>:</td> </tr> <tr> <td>Name:</td> <td><input type="text" name="name" maxlength="80" style="width:200px" /></td> <td>Passwort:</td> <td><input type="text" name="pw" maxlength="80" style="width:200px" /></td> <td><input type="submit" name="add" value="Hinzufügen" /></td> </tr> <tr> <td colspan="5"><textarea name="userlist" rows="7" cols="35" wrap="virtual" style="width:100%" class="post"><?php echo($userlist) ?></textarea></td> </tr> <tr> <td colspan="5" align="center"><input type="submit" name="save" value="Speichern" /></td> </tr> </table> </form>
_________________ Streacom DA2 | SilverStone Titanium SX800-LTI 800W | ASRock X299E-ITX/ac | Intel Core i9-9980XE & be quiet! Dark Rock TF | Kingston HyperX Impact 64 GB DDR4 2666 MHz | NVIDIA Titan RTX 24 GB | Intel SSD Optane 905P 480 GB NVMe U.2 & Intel SSD 750 1,2 TB NVMe U.2 & Intel SSD 660p 2 TB NVMe M.2 & Seagate BackUp Plus Portable 56 TB USB | 55" 4K OLED Dell Alienware AW5520QF & 24" LCD EIZO FlexScan EV2451 | Ergotron LX Wall Mount Keyboard Arm | Logitech Craft | Logitech G603 | Logitech F710 | Harman Kardon Sabre SB 35 & Sennheiser RS 175 | Microsoft Windows 7 Ultimate | APC Back-UPS ES 700 | Lenovo ThinkPad X250 | iPhone X 256 GB & Pitaka Aramid | SilverStone ML05B Milo | Corsair SF600 SFX 600W | ASRock X99E-ITX/ac | Intel Xeon E5-2683 v4 & NOCTUA NH-L12S | Kingston HyperX Savage 32 GB DDR4 2400 MHz | NVIDIA GeForce GT 710 1 GB | Intel SSD Optane Memory 32 GB NVMe M.2 & Intel SSD 730 240 GB SATA | Ubuntu Server |
|
| Stránka: 1 z 1
| [ Príspevok: 1 ] | |
| Nemôžete zakladať nové témy v tomto fóre Nemôžete odpovedať na témy v tomto fóre Nemôžete upravovať svoje príspevky v tomto fóre Nemôžete mazať svoje príspevky v tomto fóre
|
|