[ Index ] |
PHP Cross Reference of Textpattern 4.0.8 |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 $HeadURL: https://textpattern.googlecode.com/svn/releases/4.0.8/source/textpattern/lib/txplib_admin.php $ 5 $LastChangedRevision: 3047 $ 6 */ 7 8 //------------------------------------------------------------- 9 10 function send_password($RealName, $name, $email, $password) 11 { 12 global $sitename; 13 14 require_privs('admin.edit'); 15 16 $message = gTxt('greeting').' '.$RealName.','. 17 18 n.n.gTxt('you_have_been_registered').' '.$sitename. 19 20 n.n.gTxt('your_login_is').': '.$name. 21 n.gTxt('your_password_is').': '.$password. 22 23 n.n.gTxt('log_in_at').': '.hu.'textpattern/index.php'; 24 25 return txpMail($email, "[$sitename] ".gTxt('your_login_info'), $message); 26 } 27 28 // ------------------------------------------------------------- 29 30 function send_new_password($password, $email, $name) 31 { 32 global $txp_user, $sitename; 33 34 if ( empty( $name)) $name = $txp_user; 35 36 $message = gTxt('greeting').' '.$name.','. 37 38 n.n.gTxt('your_password_is').': '.$password. 39 40 n.n.gTxt('log_in_at').': '.hu.'textpattern/index.php'; 41 42 return txpMail($email, "[$sitename] ".gTxt('your_new_password'), $message); 43 } 44 45 // ------------------------------------------------------------- 46 47 function send_reset_confirmation_request($name) 48 { 49 global $sitename; 50 51 $rs = safe_row('email, nonce', 'txp_users', "name = '".doSlash($name)."'"); 52 53 if ($rs) 54 { 55 extract($rs); 56 57 $confirm = bin2hex(pack('H*', substr(md5($nonce), 0, 10)).$name); 58 59 $message = gTxt('greeting').' '.$name.','. 60 61 n.n.gTxt('password_reset_confirmation').': '. 62 n.hu.'textpattern/index.php?confirm='.$confirm; 63 64 if (txpMail($email, "[$sitename] ".gTxt('password_reset_confirmation_request'), $message)) 65 { 66 return gTxt('password_reset_confirmation_request_sent'); 67 } 68 else 69 { 70 return gTxt('could_not_mail'); 71 } 72 } 73 74 else 75 { 76 return gTxt('unknown_author', array('{name}' => htmlspecialchars($name))); 77 } 78 } 79 80 // ------------------------------------------------------------- 81 82 function generate_password($length = 10) 83 { 84 $pass = ''; 85 $chars = '23456789abcdefghijkmnopqrstuvwxyz'; 86 $i = 0; 87 88 while ($i < $length) 89 { 90 $char = substr($chars, mt_rand(0, strlen($chars)-1), 1); 91 92 if (!strstr($pass, $char)) 93 { 94 $pass .= $char; 95 $i++; 96 } 97 } 98 99 return $pass; 100 } 101 102 // ------------------------------------------------------------- 103 104 function reset_author_pass($name) 105 { 106 $email = safe_field('email', 'txp_users', "name = '".doSlash($name)."'"); 107 $new_pass = doSlash(generate_password(6)); 108 109 $rs = safe_update('txp_users', "pass = password(lower('$new_pass'))", "name = '".doSlash($name)."'"); 110 111 if ($rs) 112 { 113 if (send_new_password($new_pass, $email, $name)) 114 { 115 return(gTxt('password_sent_to').' '.$email); 116 } 117 118 else 119 { 120 return(gTxt('could_not_mail').' '.$email); 121 } 122 } 123 124 else 125 { 126 return(gTxt('could_not_update_author').' '.htmlspecialchars($name)); 127 } 128 } 129 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu May 21 23:03:01 2009 | Cross-referenced by PHPXref 0.7 |