Skip to main content

Auto Password Change and Email Notification

This script will change your .htpasswd password to a new random password (with encryption) and send an email to notify your users of the change.  You can run this script automatically using cron at what ever interval you like, or run it manually.

- - Start Script Here - -
<?php
$username 
= "XXXXXXX"; // the username specified in the .htaccess file$length = "10"; // length of the password$emailaddress = "mailinglist@yourdomain.com"; // email address that forwards to your mailing list
// generate password
$spec_charset = array("!","@","#","$","%","^","&","*","_","+"."?","=");$chars = array();$pass = "";
for (
$i = 1; $i <= $length; $i++) {
  for (
$i = 48; $i <= 57;   $i++) { $chars[] = chr($i); } // numbers
  
for ($i = 65; $i <= 90;   $i++) { $chars[] = chr($i); } // upper
  
for ($i = 97; $i <= 122; $i++) { $chars[] = chr($i); }  // lower
  
foreach ($spec_charset as $i)    { $chars[] = $i; }  // special
  
for ($i = 1; $i <= $length; $i++) { $pass .= $chars[rand(0, count($chars)-1)]; } 
}
$encrypted = crypt($pass);// build & write .htpasswd file$ht_pass = "$username:$encrypted\n";$filename = "/www/X/XXXXXX/.htpasswd";$handle = fopen($filename,"w");fwrite($handle,"$ht_pass");fclose($handle);// notify$message = "The password has been changed to $pass\n";mail($emailaddress, "Password Notification" , $message, "From: Website <>");?> 

- - End Script Here - -

Auto generate .htpasswd file
This php script reads a MySQL database, encrypts the passwords and writes an htpasswd file.  Using this script you can maintain a database of users and generate an .htpasswd file from the database.

- - Start Script Here - -
<?php
$host
="host";     // database host address$dbuser="user";                    // database user name$dbpswd="password";             // database password$mysqldb="db_name";             // name of database$table="passwd_table";          // name of tablemysql_connect("$host", "$dbuser", "$dbpswd");mysql_select_db ("$mysqldb");$query = mysql_query("SELECT * FROM $table");
while (
$row = mysql_fetch_array($query)) {
  
$user = $row['user'];
  
$pass = $row['password'];
  
$encrypted = crypt($pass);
  
$record .= "$user:$encrypted\r\n";
}
$filename = "your htpasswd file name - complete unix path - or relative to this script";$handle = fopen($filename,"w");fwrite($handle,"$record");fclose($handle);?>

- - End Script Here - -


Passing user authentication information to PHP
The best way to protect your directory is with htaccess/htpasswd protection.  But you may also want to pass the user information to your php scripts so you can do custom processing based on who logged in.  You can retrieve the current authenticated user with one php line.  Put this in the target script in the protected directory (used in the script after authentication).

- - Start Script Here - -
<?php
$user 
= $_SERVER['REMOTE_USER'];?>

- - End Script Here - -

Comments

Popular posts from this blog

links

0.  https://michael67654.qowap.com/64523001/new-pos-technique-to-perk-up-your-company 1.  https://johnnydinqr.blog2learn.com/52856602/new-pos-system-to-perk-up-your-company 2.  http://edwinsqgcu.onesmablog.com/New-POS-Process-to-Perk-Up-Your-company-43309737 3.  http://chloe69246.bloguetechno.com/New-POS-Process-to-Perk-Up-Your-Business-39814721 4.  http://jacob87541.pointblog.net/New-POS-Technique-to-Perk-Up-Your-online-business-43741223 5.  http://arlette53302.thezenweb.com/New-POS-System-to-Perk-Up-Your-online-business-41464611 6.  http://devinpixna.tinyblogging.com/New-POS-Program-to-Perk-Up-Your-online-business-46354577 7.  https://rylanevsom.blog5.net/46759651/new-pos-program-to-perk-up-your-small-business 8.  https://mariowoesh.affiliatblogger.com/56515206/new-pos-system-to-perk-up-your-organization 9.  https://liam66429.diowebhost.com/60164326/new-pos-procedure-to-perk-up-your-company 10.  https://henry19219.fitnell.com/4557...

Raisonnement, la résolution de problèmes

Les chercheurs ont d'abord développé des algorithmes mimétiques raisonnement humain étapes que les gens utilisent pour résoudre le casse-tête ou faire méthode d'exclusion logique. [2] Dans les années 1980 et 1990 fin, l'étude de la grippe aviaire a développé des méthodes de traitement de l'information incertaine ou incomplète, en utilisant des concepts de probabilité et de l'économie. [3] Pour ces problèmes, les algorithmes requis matériel assez puissant pour effectuer des calculs de géant - à subir « combinaisons d'explosion »: la quantité de mémoire et le temps de calcul peut devenir invisible prendre si la résolution d'un problème difficile. La plus haute priorité est l'algorithme de recherche pour résoudre le problème.  Les gens utilisent généralement les jugements rapides et intuitifs plutôt que pas de déduction que les chercheurs en IA d'origine peuvent simuler. [5] Amnesty International a progressé en utilisant la résolution de problèmes « c...

21 "teure" Arbeitsplätze in der Zukunft, vielversprechend und nur schwer durch künstliche Intelligenz zu ersetzen

Bei der Suche nach einem Arbeitsplatz sind die beiden Top-Belange, die Sie oft in Betracht ziehen,: Gehalt und Aussichten für die Zukunft. Vor kurzem hat das Bureau of Labor Statistics eine Zweijahresprognose der Entwicklung von Hunderten von Karrieren zwischen 2016 und 2026 veröffentlicht. Auf der Grundlage der Prognosen und Schätzungen des durchschnittlichen Jahreseinkommens dieser Arbeitsplätze haben Forscher eine Rangliste der teuersten Berufe in der Zukunft veröffentlicht. Hier werden 21 Stellen mit den höchsten Gehältern in den kommenden Jahrzehnten erwartet. 21. Landwirte, Viehzüchter, landwirtschaftliche Manager 20 Hauptaufgaben: Planen, verwalten, betreiben Sie den Betrieb, Gewächshaus, Aquakultur, Baumschule, Wald oder andere landwirtschaftliche Anlagen. Anzahl der offenen Stellen im Jahr 2026: 68.700. Durchschnittliches Einkommen im Jahr 2016: 66.360 USD. Voraussetzungen: Abitur oder gleichwertig. Computersystem-Analysator Hau...