MyBB Community Forums

Full Version: Exporting Email Addresses
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
How can I get a list of all email addresses of users who have created an account on my forums?
you can use code like below in a php file,
upload it to your MyBB files main folder & visit it with browser & copy the output
<?php
define("IN_MYBB",1);
include("global.php");
$result = $db->query("SELECT * FROM ".TABLE_PREFIX."users");
while ($row = $db->fetch_array($result)) {
echo $row['username'].','.$row['email'].'<br />';
}
Is there a way to make sure the file isn't accessible to the general public?
you can use mybb variable for your uid

like
if ($mybb->user['uid'] = 4){
your code goes here
}
here 4 indicates your user id on your forum. Just make sure to add code after global.php include variable.
Just use SQL to select the email column in the mybb_users table...
(2017-10-08, 02:31 PM)Wires Wrote: [ -> ]Just use SQL to select the email column in the mybb_users table...

I'm a total noob. How would I go about doing that?
(2017-10-08, 02:53 PM)ajkelsey Wrote: [ -> ]I'm a total noob. How would I go about doing that?


(2017-07-06, 03:58 AM).m. Wrote: [ -> ]you can use code like below in a php file,
upload it to your MyBB files main folder & visit it with browser & copy the output
<?php
define("IN_MYBB",1);
include("global.php");
$result = $db->query("SELECT * FROM ".TABLE_PREFIX."users");
while ($row = $db->fetch_array($result)) {
echo $row['username'].','.$row['email'].'<br />';
}
(2017-10-08, 03:01 PM)Dark-Power-Invader Wrote: [ -> ]
(2017-10-08, 02:53 PM)ajkelsey Wrote: [ -> ]I'm a total noob. How would I go about doing that?


(2017-07-06, 03:58 AM).m. Wrote: [ -> ]you can use code like below in a php file,
upload it to your MyBB files main folder & visit it with browser & copy the output
<?php
define("IN_MYBB",1);
include("global.php");
$result = $db->query("SELECT * FROM ".TABLE_PREFIX."users");
while ($row = $db->fetch_array($result)) {
echo $row['username'].','.$row['email'].'<br />';
}

I did that and I tried inserting your suggested addition about the user id. While I did receive the output of email addresses, your suggestion seemed to have no effect on limiting who could use the file.
Change the file with this code:
<?php
define("IN_MYBB",1);
include("global.php");
if ($mybb->user['uid'] == 1) {
    $result = $db->query("SELECT * FROM ".TABLE_PREFIX."users");
    while ($row = $db->fetch_array($result)) {
        echo $row['username'].','.$row['email'].'<br />';
    }
} else {
    error_no_permission();
}
That worked. Thanks!


How do I find my user id? Since my user account is the admin, I guessed it as 1.
Pages: 1 2