View Single Post
  #1  
Old 08-25-2002, 05:33 PM
isman isman is offline
 
Join Date: Nov 2001
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default What's wrong with this code?

This little tidbit of code is part of the IB3 import script. It's supposed to email the imported users their new password but the username and password fields are blank.

I've been racking my brain on this for two days and can't figure it out. I was hoping a fresh pair of eyes might be able to spot it.
Code:
if ($action == "passwords") {
$emailmessage =
"Hello,

Today $bbtitle has been upgraded blah blah blah. Your new password is below:

Username: \$username
Password: \$password

You can change the password at this address:

$bburl/usercp.php

Thank you for your co-operation, and apologies for any inconvenience caused.

Best Regards,

$bbtitle Team";

	doformheader("bbimport_ib3", "dopasswords");
	maketableheader("Step 8: Update User Passwords");
	makehiddenfields();
	makedescription("Ikonboard uses a non-reversible password encryption blah blah blah");
	maketextareacode("Email Subject", "emailsubject", "$bbtitle Password Update");
	maketextareacode("Email To Send", "emailmessage", stripslashes($emailmessage));
	makeinputcode("Number of users to email per cycle:","perpage","25");
	makeyesnocode("Send Emails (set to no if you are testing)", "reallysend", "1");
	makedescription("If you want to skip this step, please click ".makelinkcode("here", "bbimport_ib3.php?action=cleanup"));
	doformfooter("Send Emails");
}

if ($action == "dopasswords") {
	if ($startat=="") {
		$startat = 0;
	}

	$users = $DB_site->query("SELECT * FROM user WHERE importuserid <> '' LIMIT $startat,$perpage");
	if ($DB_site->num_rows($users)) {

		while ($user = $DB_site->fetch_array($users)) {
			
			// make random number
			mt_srand ((double) microtime() * 1000000);
			$newpassword=mt_rand(0,100000000);

			$DB_site->query("UPDATE user SET password='$newpassword' WHERE userid='$user[userid]'");
			echo("User <i>$user[username]</i> updated...<br>");
			
			$sendmessage = str_replace("\$username",$user[username],$emailmessage);
			$sendmessage = str_replace("\$password",$newpassword,$emailmessage);
			
			if ($reallysend == 1) {
				mail($user[email], $emailsubject, $emailmessage, "From: \"$bbtitle Mailer\" <$webmasteremail>");
				echo("Mail sent to <i>$user[username]</i>...<br><br>");
			}
		}
		$startat+=$perpage;


			doformheader("bbimport_ib3","dopasswords");
			maketableheader("Update User Passwords");
			makehiddenfields();
			makehiddencode("emailmessage", $emailmessage);
			makehiddencode("emailsubject", $emailsubject);
			makehiddencode("startat", $startat);
			makehiddencode("perpage", $perpage);
			makehiddencode("reallysend", $reallysend);
			doformfooter("Do Next Page",0);
	} else {
		makedescription("Password update complete.");
		$action = "cleanup";
	}
}
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01198 seconds
  • Memory Usage 1,773KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete