Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> haslo dla adminow i uzytkownika
trucksweb
post 20.02.2005, 17:27:35
Post #1





Grupa: Zarejestrowani
Postów: 1 199
Pomógł: 31
Dołączył: 22.03.2004
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


mam taki oto skrypt ktory wysyla utworzone przez uzytkownika dane i do uzytkownika i admina serwisu. chcialbym zrobic aby wysylal do admina takze haslo nowego uzytkownika, ale niestety ten to skrypt je koduje, a nastepnie wysyla. jak przerobic kod aby wysylal normalne haslo??


  1. <?php
  2. /**
  3. * @version $Id: registration.php,v 1.19 2004/09/22 00:12:41 prazgod Exp $
  4. * @package Mambo_4.5.1
  5. * @copyright (C) 2000 - 2004 Miro International Pty Ltd
  6. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
  7. * Mambo is Free Software
  8. */
  9.  
  10. /** ensure this file is being included by a parent file */
  11. defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
  12.  
  13. $task = mosGetParam( $_REQUEST, 'task', &#092;"\" );
  14. require_once( $mainframe->getPath( 'front_html' ) );
  15.  
  16. switch( $task ) {
  17. case &#092;"lostPassword\":
  18. lostPassForm( $option );
  19. break;
  20.  
  21. case &#092;"sendNewPass\":
  22. sendNewPass( $option );
  23. break;
  24.  
  25. case &#092;"register\":
  26. registerForm( $option, $mosConfig_useractivation );
  27. break;
  28.  
  29. case &#092;"saveRegistration\":
  30. saveRegistration( $option );
  31. break;
  32.  
  33. case &#092;"activate\":
  34. activate( $option );
  35. break;
  36. }
  37.  
  38. function lostPassForm( $option ) {
  39. global $mainframe;
  40. $mainframe->SetPageTitle(_PROMPT_PASSWORD);
  41. HTML_registration::lostPassForm($option);
  42. }
  43.  
  44. function sendNewPass( $option ) {
  45. global $database, $Itemid;
  46. global $mosConfig_live_site, $mosConfig_sitename;
  47.  
  48. $_live_site = $mosConfig_live_site;
  49. $_sitename = $mosConfig_sitename;
  50.  
  51. // ensure no malicous sql gets past
  52. $checkusername = trim( mosGetParam( $_POST, 'checkusername', '') );
  53. $checkusername = $database->getEscaped( $checkusername );
  54. $confirmEmail = trim( mosGetParam( $_POST, 'confirmEmail', '') );
  55. $confirmEmail = $database->getEscaped( $confirmEmail );
  56.  
  57. $database->setQuery( &#092;"SELECT id FROM #__users\"
  58. . &#092;"nWHERE username='$checkusername' AND email='$confirmEmail'\"
  59. );
  60.  
  61. if (!($user_id = $database->loadResult()) || !$checkusername || !$confirmEmail) {
  62. mosRedirect( &#092;"index.php?option=$option&task=lostPassword&mosmsg=\"._ERROR_PASS );
  63. }
  64.  
  65. $database->setQuery( &#092;"SELECT name, email FROM #__users\"
  66. . &#092;"n WHERE usertype='superadministrator'\" );
  67. $rows = $database->loadObjectList();
  68. foreach ($rows AS $row) {
  69. $adminName = $row->name;
  70. $adminEmail = $row->email;
  71. }
  72.  
  73. $newpass = mosMakePassword();
  74. $message = _NEWPASS_MSG;
  75. eval (&#092;"$message = \"$message\";\");
  76. $subject = _NEWPASS_SUB;
  77. eval (&#092;"$subject = \"$subject\";\");
  78.  
  79. mosMail($mosConfig_mailfrom, $mosConfig_fromname, $confirmEmail, $subject, $message);
  80.  
  81. $newpass = md5( $newpass );
  82. $sql = &#092;"UPDATE #__users SET password='$newpass' WHERE id='$user_id'\";
  83. $database->setQuery( $sql );
  84. if (!$database->query()) {
  85. die(&#092;"SQL error\" . $database->stderr(true));
  86. }
  87.  
  88. mosRedirect( &#092;"index.php?Itemid=$Itemid&mosmsg=\"._NEWPASS_SENT );
  89. }
  90.  
  91. function registerForm( $option, $useractivation ) {
  92. global $mainframe, $database, $my, $acl;
  93.  
  94. if (!$mainframe->getCfg( 'allowUserRegistration' )) {
  95. mosNotAuth();
  96. return;
  97. }
  98.  
  99.  
  100. $mainframe->SetPageTitle(_REGISTER_TITLE);
  101. HTML_registration::registerForm($option, $useractivation);
  102. }
  103.  
  104. function saveRegistration( $option ) {
  105. global $database, $my, $acl;
  106. global $mosConfig_sitename, $mosConfig_live_site, $mosConfig_useractivation, $mosConfig_allowUserRegistration;
  107. global $mosConfig_mailfrom, $mosConfig_fromname, $mosConfig_mailfrom, $mosConfig_fromname;
  108.  
  109. if ($mosConfig_allowUserRegistration==&#092;"0\") {
  110. mosNotAuth();
  111. return;
  112. }
  113.  
  114. $row = new mosUser( $database );
  115.  
  116. if (!$row->bind( $_POST, &#092;"usertype\" )) {
  117. echo &#092;"<script> alert('\".$row->getError().\"'); window.history.go(-1); </script>n\";
  118. exit();
  119. }
  120.  
  121. mosMakeHtmlSafe($row);
  122.  
  123. $row->id = 0;
  124. $row->usertype = '';
  125. $row->gid = $acl->get_group_id('Registered','ARO');
  126.  
  127. if ($mosConfig_useractivation==&#092;"1\") {
  128. $row->activation = md5( mosMakePassword() );
  129. $row->block = &#092;"1\";
  130. }
  131.  
  132. if (!$row->check()) {
  133. echo &#092;"<script> alert('\".$row->getError().\"'); window.history.go(-1); </script>n\";
  134. exit();
  135. }
  136.  
  137. $pwd = $row->password;
  138. $row->password = md5( $row->password );
  139. $row->registerDate = date(&#092;"Y-m-d H:i:s\");
  140.  
  141. if (!$row->store()) {
  142. echo &#092;"<script> alert('\".$row->getError().\"'); window.history.go(-1); </script>n\";
  143. exit();
  144. }
  145. $row->checkin();
  146.  
  147. $name = $row->name;
  148. $email = $row->email;
  149. $username = $row->username;
  150.  
  151. $subject = sprintf (_SEND_SUB, $name, $mosConfig_sitename);
  152. $subject = html_entity_decode($subject, ENT_QUOTES);
  153. if ($mosConfig_useractivation==&#092;"1\"){
  154. $message = sprintf (_USEND_MSG_ACTIVATE, $name, $mosConfig_sitename, $mosConfig_live_site.&#092;"/index.php?option=com_registration&task=activate&activation=\".$row->activation, $mosConfig_live_site, $username, $pwd);
  155. } else {
  156. $message = sprintf (_USEND_MSG, $name, $mosConfig_sitename, $mosConfig_live_site);
  157. }
  158.  
  159. $message = html_entity_decode($message, ENT_QUOTES);
  160. // Send email to user
  161. if ($mosConfig_mailfrom != &#092;"\" && $mosConfig_fromname != \"\") {
  162. $adminName2 = $mosConfig_fromname;
  163. $adminEmail2 = $mosConfig_mailfrom;
  164. } else {
  165. $database->setQuery( &#092;"SELECT name, email FROM #__users\"
  166. .&#092;"n WHERE usertype='superadministrator'\" );
  167. $rows = $database->loadObjectList();
  168. $row2 = $rows[0];
  169. $adminName2 = $row2->name;
  170. $adminEmail2 = $row2->email;
  171. }
  172.  
  173. mosMail($adminEmail2, $adminName2, $email, $subject, $message);
  174.  
  175. // Send notification to all administrators
  176. $subject2 = sprintf (_SEND_SUB, $name, $mosConfig_sitename);
  177. $message2 = sprintf (_ASEND_MSG, $adminName2, $mosConfig_sitename, $row->name, $email, $username, $pwd = $row->password);
  178. $subject2 = html_entity_decode($subject2, ENT_QUOTES);
  179. $message2 = html_entity_decode($message2, ENT_QUOTES);
  180.  
  181. // get superadministrators id
  182. $admins = $acl->get_group_objects( 25, 'ARO' );
  183.  
  184. foreach ( $admins['users'] AS $id ) {
  185. $database->setQuery( &#092;"SELECT email, sendEmail FROM #__users\"
  186. .&#092;"n WHERE id='$id'\" );
  187. $rows = $database->loadObjectList();
  188.  
  189. $row = $rows[0];
  190.  
  191. if ($row->sendEmail) {
  192. mosMail($adminEmail2, $adminName2, $row->email, $subject2, $message2);
  193. }
  194. }
  195.  
  196. if ( $mosConfig_useractivation == &#092;"1\" ){
  197. echo _REG_COMPLETE_ACTIVATE;
  198. } else {
  199. echo _REG_COMPLETE;
  200. }
  201.  
  202. }
  203.  
  204. function activate( $option ) {
  205. global $database;
  206.  
  207. $activation = trim( mosGetParam( $_REQUEST, 'activation', '') );
  208.  
  209. $database->setQuery( &#092;"SELECT id FROM #__users\"
  210. .&#092;"n WHERE activation='$activation' AND block='1'\" );
  211. $result = $database->loadResult();
  212.  
  213. if ($result) {
  214. $database->setQuery( &#092;"UPDATE #__users SET block='0', activation='' WHERE activation='$activation' AND block='1'\" );
  215. if (!$database->query()) {
  216. echo &#092;"SQL error\" . $database->stderr(true);
  217. }
  218. echo _REG_ACTIVATE_COMPLETE;
  219. } else {
  220. echo _REG_ACTIVATE_NOT_FOUND;
  221. }
  222. }
  223.  
  224. function is_email($email){
  225. $rBool=false;
  226.  
  227. if(preg_match(&#092;"/[w.-]+@w+[w.-]*?.w{1,4}/\", $email)){
  228. $rBool=true;
  229. }
  230. return $rBool;
  231. }
  232. ?>


Ten post edytował trucksweb 21.02.2005, 10:36:01


--------------------
Rozmawia dwóch dyrektorów:
- Jaki jest twój ideał sekretarki?
- 20-letnia dziewczyna z 30-letnim doświadczeniem.
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 19.07.2025 - 07:46