vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   What's wrong with this code? (https://vborg.vbsupport.ru/showthread.php?t=42742)

isman 08-25-2002 05:33 PM

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";
        }
}


Logician 08-26-2002 07:07 AM

1- Remove \ from \$username and \$password..

2- If this does not work insert
echo 'username='.$username.'<br>';
echo 'password='.$password.'<br>';

lines right after

if ($action == "passwords") {

and see if the variables are set correctly before being processed (if not you may need to "globalize" them)

3- Your message would well fit in "Help me Finish" or "PHP" boards rather than requests.. ;)


All times are GMT. The time now is 04:39 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00960 seconds
  • Memory Usage 1,723KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete