Exemple #1
0
function user_tagging_send_pm($subject, $msg, $toname, $fromid)
{
    require_once MYBB_ROOT . "inc/datahandlers/pm.php";
    global $db, $mybb, $lang;
    $pm_handler = new PMDataHandler();
    $pm_handler->admin_override = true;
    $pm = array("subject" => $subject, "message" => $msg, "fromid" => $fromid, "options" => array("savecopy" => "0"));
    $pm['to'] = array($toname);
    $pm_handler->set_data($pm);
    if (!$pm_handler->validate_pm()) {
        //bad pm. oops. lol
    } else {
        $pm_handler->insert_pm();
    }
}
function create_message_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups, $pminfo, $pm;
    $input = Tapatalk_Input::filterXmlInput(array('user_name' => Tapatalk_Input::RAW, 'subject' => Tapatalk_Input::STRING, 'text_body' => Tapatalk_Input::STRING, 'action' => Tapatalk_Input::INT, 'pm_id' => Tapatalk_Input::INT), $xmlrpc_params);
    $lang->load("private");
    $parser = new postParser();
    if ($mybb->settings['enablepms'] == 0) {
        return xmlrespfalse($lang->pms_disabled);
    }
    if ($mybb->user['uid'] == '/' || $mybb->user['uid'] == 0 || $mybb->usergroup['canusepms'] == 0) {
        return tt_no_permission();
    }
    if (!$mybb->user['pmfolders']) {
        $mybb->user['pmfolders'] = "1**\$%%\$2**\$%%\$3**\$%%\$4**";
        $sql_array = array("pmfolders" => $mybb->user['pmfolders']);
        $db->update_query("users", $sql_array, "uid = " . $mybb->user['uid']);
    }
    $rand = my_rand(0, 9);
    if ($rand == 5) {
        update_pm_count();
    }
    if ($mybb->usergroup['cansendpms'] == 0) {
        return tt_no_permission();
    }
    $pmhandler = new PMDataHandler();
    $pm = array("subject" => $input['subject'], "message" => $input['text_body'], "icon" => 0, "fromid" => $mybb->user['uid'], "do" => $input['action'] == 1 ? 'reply' : 'forward', "pmid" => $input['pm_id']);
    $pm['to'] = array_map("trim", $input['user_name']);
    $pm['options'] = array("signature" => 0, "disablesmilies" => 0, "savecopy" => 1, "readreceipt" => 0);
    $pmhandler->set_data($pm);
    if (!$pmhandler->validate_pm()) {
        $pm_errors = $pmhandler->get_friendly_errors();
        return xmlrespfalse(implode(" :: ", $pm_errors));
    } else {
        $pminfo = $pmhandler->insert_pm();
        $plugins->run_hooks("private_do_send_end");
    }
    return xmlresptrue();
}
function deny($userid, $username)
{
    global $mybb, $db, $cache;
    $group = new UserGroup($mybb, $db, $cache);
    $group->initialize(Groups::MEMBER);
    $group->add_member($userid);
    if (!empty($mybb->settings['rpgsuite_approval_denypm'])) {
        $pm_handler = new PMDataHandler();
        $pm_handler->admin_override = true;
        $pm = array("subject" => $mybb->settings['rpgsuite_approval_denypm_subj'], "message" => $mybb->settings['rpgsuite_approval_denypm'], "fromid" => Accounts::ADMIN, "options" => array("savecopy" => "0"));
        $pm['to'] = array($username);
        $pm_handler->set_data($pm);
        if (!$pm_handler->validate_pm()) {
            //bad pm. oops. lol
        } else {
            $pm_handler->insert_pm();
        }
    }
}
Exemple #4
0
$templatelist .= ",private_archive,private_quickreply,private_pmspace,private_limitwarning,postbit_groupimage,postbit_offline,postbit_www,postbit_replyall_pm,postbit_signature,postbit_classic,postbit_gotopost,postbit_userstar,postbit_reputation_formatted_link,postbit_icon";
$templatelist .= ",private_archive_folders_folder,private_archive_folders,postbit_warninglevel,postbit_author_user,postbit_reply_pm,postbit_forward_pm,private_messagebit_icon,private_jump_folders_folder,private_advanced_search_folders";
$templatelist .= ",private_jump_folders,postbit_avatar,postbit_warn,postbit_rep_button,postbit_email,postbit_reputation,private_move,private_read_action,postbit_away,postbit_pm,usercp_nav_messenger_tracking,postbit_find,private_emptyexportlink";
require_once "../forum/global.php";
require_once MYBB_ROOT . "../forum/inc/functions_post.php";
require_once MYBB_ROOT . "../forum/inc/functions_user.php";
require_once MYBB_ROOT . "../forum/inc/class_parser.php";
$parser = new postParser();
// Load global language phrases
$lang->load("private");
$plugins->run_hooks("private_start");
$send_errors = '';
$balance = floatval($_GET['balance']);
$sujet = "Votre facture scrapbookartetpassion.com";
$message = "Bonjour, vous avez une balance à payer de {$balance}\$. \n\nConsultez le site pour le détail de votre commande. \n\n\nmerci!";
$touser = $_GET['user'];
// send method
$plugins->run_hooks("private_send_do_send");
$to = array_map("trim", explode(",", $touser));
require_once MYBB_ROOT . "../forum/inc/datahandlers/pm.php";
$pmhandler = new PMDataHandler();
$pm = array("subject" => $sujet, "message" => $message, "icon" => -1, "fromid" => $mybb->user['uid'], "do" => "", "pmid" => 0, "ipaddress" => $session->packedip);
$pm['to'] = $to;
$pm['options'] = array();
$pm['options']['signature'] = 0;
$pm['options']['savecopy'] = 0;
$pmhandler->set_data($pm);
$pmhandler->validate_pm();
$pminfo = $pmhandler->insert_pm();
$plugins->run_hooks("private_do_send_end");
echo "msg sent ok!";
/**
 * Send reported content to moderators
 *
 * @param array Array of reported content
 * @return bool True if PM sent
 */
function send_report($report)
{
    global $db, $lang, $forum, $mybb, $post, $thread;
    $nummods = false;
    if (!empty($forum['parentlist'])) {
        $query = $db->query("\n\t\t\tSELECT DISTINCT u.username, u.email, u.receivepms, u.uid\n\t\t\tFROM " . TABLE_PREFIX . "moderators m\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=m.id)\n\t\t\tWHERE m.fid IN (" . $forum['parentlist'] . ") AND m.isgroup = '0'\n\t\t");
        $nummods = $db->num_rows($query);
    }
    if (!$nummods) {
        unset($query);
        switch ($db->type) {
            case "pgsql":
            case "sqlite":
                $query = $db->query("\n\t\t\t\t\tSELECT u.username, u.email, u.receivepms, u.uid\n\t\t\t\t\tFROM " . TABLE_PREFIX . "users u\n\t\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "usergroups g ON (((','|| u.additionalgroups|| ',' LIKE '%,'|| g.gid|| ',%') OR u.usergroup = g.gid))\n\t\t\t\t\tWHERE (g.cancp=1 OR g.issupermod=1)\n\t\t\t\t");
                break;
            default:
                $query = $db->query("\n\t\t\t\t\tSELECT u.username, u.email, u.receivepms, u.uid\n\t\t\t\t\tFROM " . TABLE_PREFIX . "users u\n\t\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "usergroups g ON (((CONCAT(',', u.additionalgroups, ',') LIKE CONCAT('%,', g.gid, ',%')) OR u.usergroup = g.gid))\n\t\t\t\t\tWHERE (g.cancp=1 OR g.issupermod=1)\n\t\t\t\t");
        }
    }
    while ($mod = $db->fetch_array($query)) {
        $emailsubject = $lang->sprintf($lang->emailsubject_reportpost, $mybb->settings['bbname']);
        $emailmessage = $lang->sprintf($lang->email_reportpost, $mybb->user['username'], $mybb->settings['bbname'], $post['subject'], $mybb->settings['bburl'], str_replace('&', '&', get_post_link($post['pid'], $thread['tid']) . "#pid" . $post['pid']), $thread['subject'], $report['reason']);
        if ($mybb->settings['reportmethod'] == "pms" && $mod['receivepms'] != 0 && $mybb->settings['enablepms'] != 0) {
            $pm_recipients[] = $mod['uid'];
        } else {
            my_mail($mod['email'], $emailsubject, $emailmessage);
        }
    }
    if (count($pm_recipients) > 0) {
        $emailsubject = $lang->sprintf($lang->emailsubject_reportpost, $mybb->settings['bbname']);
        $emailmessage = $lang->sprintf($lang->email_reportpost, $mybb->user['username'], $mybb->settings['bbname'], $post['subject'], $mybb->settings['bburl'], str_replace('&', '&', get_post_link($post['pid'], $thread['tid']) . "#pid" . $post['pid']), $thread['subject'], $report['reason']);
        require_once MYBB_ROOT . "inc/datahandlers/pm.php";
        $pmhandler = new PMDataHandler();
        $pm = array("subject" => $emailsubject, "message" => $emailmessage, "icon" => 0, "fromid" => $mybb->user['uid'], "toid" => $pm_recipients, "ipaddress" => $session->packedip);
        $pmhandler->admin_override = true;
        $pmhandler->set_data($pm);
        // Now let the pm handler do all the hard work.
        if (!$pmhandler->validate_pm()) {
            // Force it to valid to just get it out of here
            $pmhandler->is_validated = true;
            $pmhandler->errors = array();
        }
        $pminfo = $pmhandler->insert_pm();
        return $pminfo;
    }
    return false;
}
 function send_pm($pm, $fromid = 0, $admin_override = false, $tids)
 {
     global $mybb;
     if (!$mybb->settings['enablepms']) {
         return false;
     }
     if (!is_array($pm)) {
         return false;
     }
     if (!$pm['subject'] || !$pm['message'] || !$pm['receivepms'] && !$admin_override) {
         return false;
     }
     global $lang, $db, $session;
     $lang->load('messages');
     require_once MYBB_ROOT . "inc/datahandlers/pm.php";
     $pmhandler = new PMDataHandler();
     $pm['touid'] = array();
     $query = $db->simple_select('threads', 'uid', 'uid!=\'0\' AND uid!=\'' . (int) $mybb->user['uid'] . '\' AND tid IN (\'' . implode('\',\'', array_filter(array_map('intval', $tids))) . '\')');
     while ($uid = (int) $db->fetch_field($query, 'uid')) {
         $pm['touid'][$uid] = $uid;
     }
     if (!$pm['touid']) {
         return;
     }
     // Build our final PM array
     $pm = array('subject' => $pm['subject'], 'message' => $lang->sprintf($pm['message'], $mybb->settings['bbname']), 'icon' => -1, 'fromid' => $fromid == 0 ? (int) $mybb->user['uid'] : ($fromid < 0 ? 0 : $fromid), 'toid' => $pm['touid'], 'bccid' => array(), 'do' => '', 'pmid' => '', 'saveasdraft' => 0, 'options' => array('signature' => 0, 'disablesmilies' => 0, 'savecopy' => 0, 'readreceipt' => 0));
     if (isset($mybb->session)) {
         $pm['ipaddress'] = $mybb->session->packedip;
     }
     // Admin override
     $pmhandler->admin_override = (int) $admin_override;
     $pmhandler->set_data($pm);
     if ($pmhandler->validate_pm()) {
         $pmhandler->insert_pm();
         return true;
     }
     return false;
 }
 /**
  * Send a private message from someone to someone
  */
 function sendPrivateMessage($data = array())
 {
     // Let's do default values and check if all required data keys are passed
     $default_data = array('fromid' => 0, 'subject' => '', 'message' => '', 'icon' => 0, 'to_username' => '');
     // Set default values if they are missing!
     foreach ($default_data as $default_data_key => $default_data_val) {
         if (!isset($data[$default_data_key])) {
             $data[$default_data_key] = $default_data_val;
         }
     }
     $this->lang->load('private');
     $this->plugins->run_hooks('private_send_do_send');
     // Attempt to see if this PM is a duplicate or not
     $time_cutoff = TIME_NOW - 5 * 60 * 60;
     $query = $this->db->query("\n\t\t\tSELECT pm.pmid\n\t\t\tFROM " . TABLE_PREFIX . "privatemessages pm\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON(u.uid=pm.toid)\n\t\t\tWHERE u.username='******'to_uername']) . "' AND pm.dateline > {$time_cutoff} AND pm.fromid='{" . $data['fromid'] . "}' AND pm.subject='" . $this->db->escape_string($data['subject']) . "' AND pm.message='" . $this->db->escape_string($data['message']) . "' AND pm.folder!='3'\n\t\t");
     $duplicate_check = $this->db->fetch_field($query, "pmid");
     if ($duplicate_check) {
         return $this->lang->error_pm_already_submitted;
     }
     require_once MYBB_ROOT . "inc/datahandlers/pm.php";
     $pmhandler = new PMDataHandler();
     // Split up any recipients we have
     $data['to'] = explode(",", $data['to_username']);
     $data['to'] = array_map("trim", $data['to']);
     if (!empty($data['bcc'])) {
         $data['bcc'] = explode(",", $data['bcc']);
         $data['bcc'] = array_map("trim", $data['bcc']);
     }
     $data['options'] = array("signature" => isset($data['options']['signature']) ? $data['options']['signature'] : NULL, "disablesmilies" => isset($data['options']['disablesmilies']) ? $data['options']['disablesmilies'] : NULL, "savecopy" => isset($data['options']['savecopy']) ? $data['options']['savecopy'] : NULL, "readreceipt" => isset($data['options']['readreceipt']) ? $data['options']['readreceipt'] : NULL);
     /* Unnecessary
     		if($data['saveasdraft'])
     		{
     			$data['saveasdraft'] = 1;
     		} */
     $pmhandler->set_data($data);
     // Now let the pm handler do all the hard work.
     if (!$pmhandler->validate_pm()) {
         $pm_errors = $pmhandler->get_friendly_errors();
         return inline_error($pm_errors);
     } else {
         $pminfo = $pmhandler->insert_pm();
         $this->plugins->run_hooks("private_do_send_end");
         if (isset($pminfo['draftsaved'])) {
             return $this->lang->redirect_pmsaved;
         } else {
             return $this->lang->redirect_pmsent;
         }
     }
 }
 /**
  * Registers an user with Facebook data
  */
 public function register($user)
 {
     if (!$user) {
         return false;
     }
     global $mybb, $session, $plugins, $lang;
     require_once MYBB_ROOT . "inc/datahandlers/user.php";
     $userhandler = new UserDataHandler("insert");
     $plength = 8;
     if ($mybb->settings['minpasswordlength']) {
         $plength = (int) $mybb->settings['minpasswordlength'];
     }
     $password = random_str($plength);
     $new_user = array("username" => $user['name'], "password" => $password, "password2" => $password, "email" => $user['email'], "email2" => $user['email'], "usergroup" => (int) $mybb->settings['myfbconnect_usergroup'], "regip" => $session->ipaddress, "longregip" => my_ip2long($session->ipaddress), "options" => array("hideemail" => 1));
     /* Registration might fail for custom profile fields required at registration... workaround = IN_ADMINCP defined.
     		Placed straight before the registration process to avoid conflicts with third party plugins messying around with
     		templates (I'm looking at you, PHPTPL) */
     define("IN_ADMINCP", 1);
     $userhandler->set_data($new_user);
     if ($userhandler->validate_user()) {
         $user_info = $userhandler->insert_user();
         $plugins->run_hooks("member_do_register_end");
         // Deliver a welcome PM
         if ($mybb->settings['myfbconnect_passwordpm']) {
             require_once MYBB_ROOT . "inc/datahandlers/pm.php";
             $pmhandler = new PMDataHandler();
             $pmhandler->admin_override = true;
             // Make sure admins haven't done something bad
             $fromid = (int) $mybb->settings['myfbconnect_passwordpm_fromid'];
             if (!$mybb->settings['myfbconnect_passwordpm_fromid'] or !user_exists($mybb->settings['myfbconnect_passwordpm_fromid'])) {
                 $fromid = 0;
             }
             $message = $mybb->settings['myfbconnect_passwordpm_message'];
             $subject = $mybb->settings['myfbconnect_passwordpm_subject'];
             $thingsToReplace = array("{user}" => $user_info['username'], "{password}" => $password);
             // Replace what needs to be replaced
             foreach ($thingsToReplace as $find => $replace) {
                 $message = str_replace($find, $replace, $message);
             }
             $pm = array("subject" => $subject, "message" => $message, "fromid" => $fromid, "toid" => array($user_info['uid']));
             // Some defaults :)
             $pm['options'] = array("signature" => 1);
             $pmhandler->set_data($pm);
             // Now let the PM handler do all the hard work
             if ($pmhandler->validate_pm()) {
                 $pmhandler->insert_pm();
             } else {
                 error($lang->sprintf($lang->myfbconnect_error_report, $pmhandler->get_friendly_errors()));
             }
         }
         // Post a message on the user's wall
         if ($mybb->settings['myfbconnect_postonwall']) {
             $this->post_on_wall($mybb->settings['myfbconnect_postonwall_message']);
         }
         // Finally return our new user data
         return $user_info;
     } else {
         return array('error' => $userhandler->get_friendly_errors());
     }
     return true;
 }
Exemple #9
0
/**
 * Send a Private Message to a user.
 *
 * @param array $pm Array containing: 'subject', 'message', 'touid' and 'receivepms' (the latter should reflect the value found in the users table: receivepms and receivefrombuddy)
 * @param int $fromid Sender UID (0 if you want to use $mybb->user['uid'] or -1 to use MyBB Engine)
 * @param bool $admin_override Whether or not do override user defined options for receiving PMs
 * @return bool True if PM sent
 */
function send_pm($pm, $fromid = 0, $admin_override = false)
{
    global $lang, $mybb, $db, $session;
    if ($mybb->settings['enablepms'] == 0) {
        return false;
    }
    if (!is_array($pm)) {
        return false;
    }
    if (isset($pm['language'])) {
        if ($pm['language'] != $mybb->user['language'] && $lang->language_exists($pm['language'])) {
            // Load user language
            $lang->set_language($pm['language']);
            $lang->load($pm['language_file']);
            $revert = true;
        }
        foreach (array('subject', 'message') as $key) {
            $lang_string = $pm[$key];
            if (is_array($pm[$key])) {
                $num_args = count($pm[$key]);
                for ($i = 1; $i < $num_args; $i++) {
                    $lang->{$pm[$key][0]} = str_replace('{' . $i . '}', $pm[$key][$i], $lang->{$pm[$key][0]});
                }
                $lang_string = $pm[$key][0];
            }
            $pm[$key] = $lang->{$lang_string};
        }
        if (isset($revert)) {
            // Revert language
            $lang->set_language($mybb->user['language']);
            $lang->load($pm['language_file']);
        }
    }
    if (!$pm['subject'] || !$pm['message'] || !$pm['touid'] || !$pm['receivepms'] && !$admin_override) {
        return false;
    }
    $lang->load('messages');
    require_once MYBB_ROOT . "inc/datahandlers/pm.php";
    $pmhandler = new PMDataHandler();
    $subject = $pm['subject'];
    $message = $pm['message'];
    $toid = $pm['touid'];
    // Our recipients
    if (is_array($toid)) {
        $recipients_to = $toid;
    } else {
        $recipients_to = array($toid);
    }
    $recipients_bcc = array();
    // Determine user ID
    if ((int) $fromid == 0) {
        $fromid = (int) $mybb->user['uid'];
    } elseif ((int) $fromid < 0) {
        $fromid = 0;
    }
    // Build our final PM array
    $pm = array("subject" => $subject, "message" => $message, "icon" => -1, "fromid" => $fromid, "toid" => $recipients_to, "bccid" => $recipients_bcc, "do" => '', "pmid" => '');
    if (isset($session)) {
        $pm['ipaddress'] = $session->packedip;
    }
    $pm['options'] = array("signature" => 0, "disablesmilies" => 0, "savecopy" => 0, "readreceipt" => 0);
    $pm['saveasdraft'] = 0;
    // Admin override
    $pmhandler->admin_override = (int) $admin_override;
    $pmhandler->set_data($pm);
    if ($pmhandler->validate_pm()) {
        $pmhandler->insert_pm();
        return true;
    }
    return false;
}
Exemple #10
0
/**
 * Sends a PM to a user
 * 
 * @param array: The PM to be sent; should have 'subject', 'message', 'touid' and 'receivepms'
 * (receivepms is for admin override in case the user has disabled pm's)
 * @param int: from user id (0 if you want to use the uid of the person that sends it. -1 to use MyBB Engine
 * @return bool: true if PM sent
 */
function newpoints_send_pm($pm, $fromid = 0)
{
    global $lang, $mybb, $db;
    if ($mybb->settings['enablepms'] == 0) {
        return false;
    }
    if (!is_array($pm)) {
        return false;
    }
    if (!$pm['subject'] || !$pm['message'] || !$pm['touid'] || !$pm['receivepms']) {
        return false;
    }
    $lang->load('messages');
    require_once MYBB_ROOT . "inc/datahandlers/pm.php";
    $pmhandler = new PMDataHandler();
    $subject = $pm['subject'];
    $message = $pm['message'];
    $toid = $pm['touid'];
    if (is_array($toid)) {
        $recipients_to = $toid;
    } else {
        $recipients_to = array($toid);
    }
    $recipients_bcc = array();
    if (intval($fromid) == 0) {
        $fromid = intval($mybb->user['uid']);
    } elseif (intval($fromid) < 0) {
        $fromid = 0;
    }
    $pm = array("subject" => $subject, "message" => $message, "icon" => -1, "fromid" => $fromid, "toid" => $recipients_to, "bccid" => $recipients_bcc, "do" => '', "pmid" => '');
    $pm['options'] = array("signature" => 0, "disablesmilies" => 0, "savecopy" => 0, "readreceipt" => 0);
    $pm['saveasdraft'] = 0;
    $pmhandler->admin_override = 1;
    $pmhandler->set_data($pm);
    if ($pmhandler->validate_pm()) {
        $pmhandler->insert_pm();
    } else {
        return false;
    }
    return true;
}
Exemple #11
0
function report_post_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
    $input = Tapatalk_Input::filterXmlInput(array('post_id' => Tapatalk_Input::INT, 'reason' => Tapatalk_Input::STRING), $xmlrpc_params);
    $lang->load("report");
    if ($mybb->usergroup['canview'] == 0 || !$mybb->user['uid']) {
        return tt_no_permission();
    }
    $post = get_post($input['post_id']);
    if (!$post['pid']) {
        return xmlrespfalse($lang->error_invalidpost);
    }
    $forum = get_forum($post['fid']);
    if (!$forum) {
        $error = $lang->error_invalidforum;
        eval("\$report_error = \"" . $templates->get("report_error") . "\";");
        output_page($report_error);
        exit;
    }
    tt_check_forum_password($forum['parentlist']);
    $thread = get_thread($post['tid']);
    if (version_compare($mybb->version, '1.8.0', '<')) {
        if ($mybb->settings['reportmethod'] == "email" || $mybb->settings['reportmethod'] == "pms") {
            $query = $db->query("\n\t\t\t\tSELECT DISTINCT u.username, u.email, u.receivepms, u.uid\n\t\t\t\tFROM " . TABLE_PREFIX . "moderators m\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=m.id)\n\t\t\t\tWHERE m.fid IN (" . $forum['parentlist'] . ") AND m.isgroup = '0'\n\t\t\t");
            $nummods = $db->num_rows($query);
            if (!$nummods) {
                unset($query);
                switch ($db->type) {
                    case "pgsql":
                    case "sqlite":
                        $query = $db->query("\n\t\t\t\t\t\t\tSELECT u.username, u.email, u.receivepms, u.uid\n\t\t\t\t\t\t\tFROM " . TABLE_PREFIX . "users u\n\t\t\t\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "usergroups g ON (((','|| u.additionalgroups|| ',' LIKE '%,'|| g.gid|| ',%') OR u.usergroup = g.gid))\n\t\t\t\t\t\t\tWHERE (g.cancp=1 OR g.issupermod=1)\n\t\t\t\t\t\t");
                        break;
                    default:
                        $query = $db->query("\n\t\t\t\t\t\t\tSELECT u.username, u.email, u.receivepms, u.uid\n\t\t\t\t\t\t\tFROM " . TABLE_PREFIX . "users u\n\t\t\t\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "usergroups g ON (((CONCAT(',', u.additionalgroups, ',') LIKE CONCAT('%,', g.gid, ',%')) OR u.usergroup = g.gid))\n\t\t\t\t\t\t\tWHERE (g.cancp=1 OR g.issupermod=1)\n\t\t\t\t\t\t");
                }
            }
            while ($mod = $db->fetch_array($query)) {
                $emailsubject = $lang->sprintf($lang->emailsubject_reportpost, $mybb->settings['bbname']);
                $emailmessage = $lang->sprintf($lang->email_reportpost, $mybb->user['username'], $mybb->settings['bbname'], $post['subject'], $mybb->settings['bburl'], str_replace('&amp;', '&', get_post_link($post['pid'], $thread['tid']) . "#pid" . $post['pid']), $thread['subject'], $input['reason']);
                if ($mybb->settings['reportmethod'] == "pms" && $mod['receivepms'] != 0 && $mybb->settings['enablepms'] != 0) {
                    $pm_recipients[] = $mod['uid'];
                } else {
                    my_mail($mod['email'], $emailsubject, $emailmessage);
                }
            }
            if (count($pm_recipients) > 0) {
                $emailsubject = $lang->sprintf($lang->emailsubject_reportpost, $mybb->settings['bbname']);
                $emailmessage = $lang->sprintf($lang->email_reportpost, $mybb->user['username'], $mybb->settings['bbname'], $post['subject'], $mybb->settings['bburl'], str_replace('&amp;', '&', get_post_link($post['pid'], $thread['tid']) . "#pid" . $post['pid']), $thread['subject'], $input['reason']);
                require_once MYBB_ROOT . "inc/datahandlers/pm.php";
                $pmhandler = new PMDataHandler();
                $pm = array("subject" => $emailsubject, "message" => $emailmessage, "icon" => 0, "fromid" => $mybb->user['uid'], "toid" => $pm_recipients);
                $pmhandler->admin_override = true;
                $pmhandler->set_data($pm);
                // Now let the pm handler do all the hard work.
                if (!$pmhandler->validate_pm()) {
                    // Force it to valid to just get it out of here
                    $pmhandler->is_validated = true;
                    $pmhandler->errors = array();
                }
                $pminfo = $pmhandler->insert_pm();
            }
        } else {
            $reportedpost = array("pid" => $input['post_id'], "tid" => $thread['tid'], "fid" => $thread['fid'], "uid" => $mybb->user['uid'], "dateline" => TIME_NOW, "reportstatus" => 0, "reason" => $db->escape_string(htmlspecialchars_uni($input['reason'])));
            $db->insert_query("reportedposts", $reportedpost);
            $cache->update_reportedposts();
        }
    } else {
        require_once MYBB_ROOT . 'inc/functions_modcp.php';
        $plugins->run_hooks("report_do_report_start");
        $id = $post['pid'];
        $id2 = $post['tid'];
        $id3 = $forum['fid'];
        $report_type = 'post';
        $report_type_db = "(type = 'post' OR type = '')";
        if (!empty($report_type_db)) {
            $query = $db->simple_select("reportedcontent", "*", "reportstatus != '1' AND id = '{$id}' AND {$report_type_db}");
            if ($db->num_rows($query)) {
                // Existing report
                $report = $db->fetch_array($query);
                $report['reporters'] = my_unserialize($report['reporters']);
                if ($mybb->user['uid'] == $report['uid'] || is_array($report['reporters']) && in_array($mybb->user['uid'], $report['reporters'])) {
                    $error = $lang->success_report_voted;
                }
            }
        }
        // Is this an existing report or a new offender?
        if (!empty($report)) {
            // Existing report, add vote
            $report['reporters'][] = $mybb->user['uid'];
            update_report($report);
            //$plugins->run_hooks("report_do_report_end");
        } else {
            // Bad user!
            $new_report = array('id' => $id, 'id2' => $id2, 'id3' => $id3, 'uid' => $mybb->user['uid']);
            // Figure out the reason
            $reason = trim($input['reason']);
            if ($reason == 'other') {
                // Replace the reason with the user comment
                $reason = trim($mybb->get_input('comment'));
            } else {
                $report_reason_string = "report_reason_{$reason}";
                //$reason = "\n".$lang->$report_reason_string;
            }
            if (my_strlen($reason) < 3) {
                $error = $lang->error_report_length;
            }
            if (empty($error)) {
                $new_report['reason'] = $reason;
                add_report($new_report, $report_type);
            } else {
                error($error);
            }
        }
    }
    return xmlresptrue();
}
Exemple #12
0
/**
 * Send a PM about a new assignment
 *
 * @param int The UID of who we're assigning it to now.
 * @param int The FID the thread is in.
 * @param int The TID of the thread.
**/
function mysupport_send_assign_pm($uid, $fid, $tid)
{
    global $mybb, $db, $lang;
    if ($uid == $mybb->user['uid']) {
        //return;
    }
    $uid = intval($uid);
    $fid = intval($fid);
    $tid = intval($tid);
    $user_info = get_user($uid);
    $username = $user_info['username'];
    $forum_url = $mybb->settings['bburl'] . "/" . get_forum_link($fid);
    $forum_info = get_forum($fid);
    $forum_name = $forum_info['name'];
    $thread_url = $mybb->settings['bburl'] . "/" . get_thread_link($tid);
    $thread_info = get_thread($tid);
    $thread_name = $thread_info['subject'];
    $recipients_to = array($uid);
    $recipients_bcc = array();
    $assigned_by_user_url = $mybb->settings['bburl'] . "/" . get_profile_link($mybb->user['uid']);
    $assigned_by = $lang->sprintf($lang->assigned_by, $assigned_by_user_url, htmlspecialchars_uni($mybb->user['username']));
    $message = $lang->sprintf($lang->assign_pm_message, htmlspecialchars_uni($username), $forum_url, htmlspecialchars_uni($forum_name), $thread_url, htmlspecialchars_uni($thread_name), $assigned_by, $mybb->settings['bburl']);
    $pm = array("subject" => $lang->assign_pm_subject, "message" => $message, "icon" => -1, "fromid" => 0, "toid" => $recipients_to, "bccid" => $recipients_bcc, "do" => '', "pmid" => '', "saveasdraft" => 0, "options" => array("signature" => 1, "disablesmilies" => 0, "savecopy" => 0, "readreceipt" => 0));
    require_once MYBB_ROOT . "inc/datahandlers/pm.php";
    $pmhandler = new PMDataHandler();
    $pmhandler->admin_override = 1;
    $pmhandler->set_data($pm);
    if ($pmhandler->validate_pm()) {
        $pmhandler->insert_pm();
    }
}
Exemple #13
0
/**
 * Changes the author of the post.
 *
 *
 */
function accountswitcher_author_change()
{
    global $mybb, $db, $eas;
    // Change action
    if ($mybb->input['action'] == "do_author" && $mybb->request_method == "post" && ($mybb->settings['aj_changeauthor'] == 1 || $mybb->settings['aj_admin_changeauthor'] == 1)) {
        // Verify incoming POST request
        verify_post_check($mybb->get_input('my_post_key'));
        // Get the current author of the post
        $pid = $mybb->get_input('pid', MyBB::INPUT_INT);
        $post = get_post($pid);
        $tid = (int) $post['tid'];
        $forum = get_forum($post['fid']);
        // Get the new user
        if (is_numeric($mybb->input['authorswitch'])) {
            // Input is uid from change author
            $newuid = $mybb->get_input('authorswitch', MyBB::INPUT_INT);
            $newauthor = get_user($newuid);
        } else {
            // Input is username from author moderation
            $newname = htmlspecialchars_uni($mybb->get_input('authorswitch'));
            $newauthor = get_user_by_username($newname);
            $newauthor = get_user((int) $newauthor['uid']);
        }
        // New user doesn't exist? Redirect back to the post without changes
        if ($newauthor['uid'] == 0) {
            redirect(htmlentities($_POST['p_link']));
            return;
        }
        // Subtract from the users post count
        // Update the post count if this forum allows post counts to be tracked
        if ($forum['usepostcounts'] != 0) {
            $db->write_query("UPDATE " . TABLE_PREFIX . "users SET postnum=postnum-1 WHERE uid='" . (int) $post['uid'] . "'");
            $db->write_query("UPDATE " . TABLE_PREFIX . "users SET postnum=postnum+1 WHERE uid='" . (int) $newauthor['uid'] . "'");
        }
        $updated_record = array("uid" => (int) $newauthor['uid'], "username" => $db->escape_string($newauthor['username']));
        if ($db->update_query("posts", $updated_record, "pid='" . (int) $post['pid'] . "'")) {
            global $lang;
            if (!isset($lang->aj_author_change_log)) {
                $lang->load("accountswitcher");
            }
            // Update first/last post info, log moderator action, redirect back to the post
            update_thread_data($tid);
            update_forum_lastpost((int) $post['fid']);
            $lang->aj_author_change_log = $lang->sprintf($lang->aj_author_change_log, (int) $post['pid'], htmlspecialchars_uni($post['username']), htmlspecialchars_uni($newauthor['username']));
            log_moderator_action(array("pid" => $post['pid']), $lang->aj_author_change_log);
            // Send pm to old and new author after moderation
            if ($post['uid'] != $mybb->user['uid'] && $mybb->settings['aj_admin_changeauthor'] == 1) {
                if ($mybb->settings['aj_authorpm'] == 1) {
                    // Send PM
                    require_once MYBB_ROOT . "inc/datahandlers/pm.php";
                    $pmhandler = new PMDataHandler();
                    $lang->aj_author_change_pm_body = $lang->sprintf($lang->aj_author_change_pm_body, htmlspecialchars_uni($mybb->user['username']), $mybb->settings['bburl'] . '/' . htmlentities($_POST['p_link']), htmlspecialchars_uni($post['subject']), htmlspecialchars_uni($post['username']), htmlspecialchars_uni($newauthor['username']));
                    $subject = $lang->aj_author_change_pm_subject;
                    $body = $lang->aj_author_change_pm_body;
                    $pm = array('subject' => $subject, 'message' => $body, 'icon' => '', 'toid' => array($post['uid'], $newauthor['uid']), 'fromid' => $mybb->user['uid'], "do" => '', "pmid" => '');
                    $pm['options'] = array('signature' => '0', 'savecopy' => '0', 'disablesmilies' => '0', 'readreceipt' => '0');
                    $pmhandler->set_data($pm);
                    $valid_pm = $pmhandler->validate_pm();
                    if ($valid_pm) {
                        $pmhandler->insert_pm();
                    }
                }
                // Show alert
                if ($mybb->settings['aj_myalerts'] == 1 && isset($mybb->user['myalerts_disabled_alert_types'])) {
                    $alertType = MybbStuff_MyAlerts_AlertTypeManager::getInstance()->getByCode('accountswitcher_author');
                    $alerts = array();
                    $subject = htmlspecialchars_uni($post['subject']);
                    $alert_old = new MybbStuff_MyAlerts_Entity_Alert((int) $post['uid'], $alertType, $tid);
                    $alert_old->setExtraDetails(array('thread_title' => $subject, 'pid' => $pid, 'tid' => $tid, 'olduser' => htmlspecialchars_uni($post['username']), 'newuser' => htmlspecialchars_uni($newauthor['username'])));
                    $alerts[] = $alert_old;
                    $alert_new = new MybbStuff_MyAlerts_Entity_Alert((int) $newauthor['uid'], $alertType, $tid);
                    $alert_new->setExtraDetails(array('thread_title' => $subject, 'pid' => $pid, 'tid' => $tid, 'olduser' => htmlspecialchars_uni($post['username']), 'newuser' => htmlspecialchars_uni($newauthor['username'])));
                    $alerts[] = $alert_new;
                    if (!empty($alerts)) {
                        MybbStuff_MyAlerts_AlertManager::getInstance()->addAlerts($alerts);
                    }
                }
            }
            $eas->update_accountswitcher_cache();
            redirect(htmlentities($_POST['p_link']));
        }
    } else {
        return;
    }
}
Exemple #14
0
function trader_send_pm($toid, $fid)
{
    global $db, $mybb, $lang;
    $lang->load("tradefeedback");
    require_once MYBB_ROOT . "inc/datahandlers/pm.php";
    $pmhandler = new PMDataHandler();
    $message_url = $mybb->settings['bburl'] . "/tradefeedback.php?action=view&uid={$toid}&fid={$fid}";
    $pmhandler->admin_override = true;
    $pm = array("subject" => $lang->feedback_pm_subject, "message" => $lang->sprintf($lang->feedback_pm_message, $mybb->user['username'], $message_url), "icon" => "-1", "toid" => $toid, "fromid" => $mybb->user['uid'], "do" => '', "pmid" => '');
    $pm['options'] = array("signature" => "0", "disablesmilies" => "0", "savecopy" => "0", "readreceipt" => "0");
    $pmhandler->set_data($pm);
    if (!$pmhandler->validate_pm()) {
        // There some problem sending the PM
    } else {
        $pminfo = $pmhandler->insert_pm();
    }
}
Exemple #15
0
function task_massmail($task)
{
    global $db, $mybb, $lang;
    $query = $db->simple_select("massemails", "*", "senddate <= '" . TIME_NOW . "' AND status IN (1,2)");
    while ($mass_email = $db->fetch_array($query)) {
        if ($mass_email['status'] == 1) {
            $db->update_query("massemails", array('status' => 2), "mid='{$mass_email['mid']}'", 1);
        }
        $sentcount = 0;
        if (!$mass_email['perpage']) {
            $mass_email['perpage'] = 50;
        }
        if (strpos($mass_email['htmlmessage'], '<br />') === false && strpos($mass_email['htmlmessage'], '<br>') === false) {
            $mass_email['htmlmessage'] = nl2br($mass_email['htmlmessage']);
        }
        $mass_email['orig_message'] = $mass_email['message'];
        $mass_email['orig_htmlmessage'] = $mass_email['htmlmessage'];
        // Need to perform the search to fetch the number of users we're emailing
        $member_query = build_mass_mail_query(unserialize($mass_email['conditions']));
        $count_query = $db->simple_select("users u", "COUNT(uid) AS num", $member_query);
        $mass_email['totalcount'] = $db->fetch_field($count_query, "num");
        $query2 = $db->simple_select("users u", "u.uid, u.language, u.pmnotify, u.lastactive, u.username, u.email", $member_query, array('limit_start' => $mass_email['sentcount'], 'limit' => $mass_email['perpage'], 'order_by' => 'u.uid', 'order_dir' => 'asc'));
        while ($user = $db->fetch_array($query2)) {
            $replacement_fields = array("{uid}" => $user['uid'], "{username}" => $user['username'], "{email}" => $user['email'], "{bbname}" => $mybb->settings['bbname'], "{bburl}" => $mybb->settings['bburl'], "[" . $lang->massmail_username . "]" => $user['username'], "[" . $lang->email_addr . "]" => $user['email'], "[" . $lang->board_name . "]" => $mybb->settings['bbname'], "[" . $lang->board_url . "]" => $mybb->settings['bburl']);
            foreach ($replacement_fields as $find => $replace) {
                $mass_email['message'] = str_replace($find, $replace, $mass_email['message']);
                $mass_email['htmlmessage'] = str_replace($find, $replace, $mass_email['htmlmessage']);
            }
            // Private Message
            if ($mass_email['type'] == 1) {
                $pm_handler = new PMDataHandler();
                $pm_handler->admin_override = true;
                $pm = array("subject" => $mass_email['subject'], "message" => $mass_email['message'], "fromid" => $mass_email['uid'], "options" => array("savecopy" => 0));
                $pm['to'] = explode(",", $user['username']);
                $pm_handler->set_data($pm);
                if (!$pm_handler->validate_pm()) {
                    $friendly_errors = implode('\\n', $pm_handler->get_friendly_errors());
                    add_task_log($task, $lang->sprintf($lang->task_massmail_ran_errors, htmlspecialchars_uni($user['username']), $friendly_errors));
                    $friendly_errors = "";
                } else {
                    $pm_handler->insert_pm();
                }
            } else {
                switch ($mass_email['format']) {
                    case 2:
                        $format = "both";
                        $text_message = $mass_email['message'];
                        $mass_email['message'] = $mass_email['htmlmessage'];
                        break;
                    case 1:
                        $format = "html";
                        $text_message = "";
                        $mass_email['message'] = $mass_email['htmlmessage'];
                        break;
                    default:
                        $format = "text";
                        $text_message = "";
                }
                my_mail($user['email'], $mass_email['subject'], $mass_email['message'], "", "", "", false, $format, $text_message);
            }
            ++$sentcount;
            $mass_email['message'] = $mass_email['orig_message'];
            $mass_email['htmlmessage'] = $mass_email['orig_htmlmessage'];
        }
        $update_array = array();
        $update_array['sentcount'] = $mass_email['sentcount'] + $sentcount;
        $update_array['totalcount'] = $mass_email['totalcount'];
        if ($update_array['sentcount'] >= $mass_email['totalcount']) {
            $update_array['status'] = 3;
        }
        $db->update_query("massemails", $update_array, "mid='{$mass_email['mid']}'", 1);
    }
    add_task_log($task, $lang->task_massmail_ran);
}
 function send_pm($pm, $fromid = 0, $admin_override = false)
 {
     global $mybb;
     if (!$mybb->settings['ougc_awards_sendpm'] || !$mybb->settings['enablepms'] || !is_array($pm)) {
         return false;
     }
     if (!$pm['subject'] || !$pm['message'] || !$pm['receivepms'] && !$admin_override) {
         return false;
     }
     global $lang, $db, $session;
     $lang->load((defined('IN_ADMINCP') ? '../' : '') . 'messages');
     require_once MYBB_ROOT . "inc/datahandlers/pm.php";
     $pmhandler = new PMDataHandler();
     // Build our final PM array
     $pm = array('subject' => $pm['subject'], 'message' => $pm['message'], 'icon' => -1, 'fromid' => $fromid == 0 ? (int) $mybb->user['uid'] : ($fromid < 0 ? 0 : $fromid), 'toid' => array($pm['touid']), 'bccid' => array(), 'do' => '', 'pmid' => '', 'saveasdraft' => 0, 'options' => array('signature' => 0, 'disablesmilies' => 0, 'savecopy' => 0, 'readreceipt' => 0));
     if (isset($mybb->session)) {
         $pm['ipaddress'] = $mybb->session->packedip;
     }
     // Admin override
     $pmhandler->admin_override = (int) $admin_override;
     $pmhandler->set_data($pm);
     if ($pmhandler->validate_pm()) {
         $pmhandler->insert_pm();
         return true;
     }
     return false;
 }
Exemple #17
0
     error_no_permission();
 }
 // Verify incoming POST request
 verify_post_check($mybb->get_input('my_post_key'));
 $plugins->run_hooks("private_send_do_send");
 // Attempt to see if this PM is a duplicate or not
 $to = array_map("trim", explode(",", $mybb->get_input('to')));
 $to_escaped = implode("','", array_map(array($db, 'escape_string'), array_map('my_strtolower', $to)));
 $time_cutoff = TIME_NOW - 5 * 60 * 60;
 $query = $db->query("\n\t\tSELECT pm.pmid\n\t\tFROM " . TABLE_PREFIX . "privatemessages pm\n\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON(u.uid=pm.toid)\n\t\tWHERE LOWER(u.username) IN ('{$to_escaped}') AND pm.dateline > {$time_cutoff} AND pm.fromid='{$mybb->user['uid']}' AND pm.subject='" . $db->escape_string($mybb->get_input('subject')) . "' AND pm.message='" . $db->escape_string($mybb->get_input('message')) . "' AND pm.folder!='3'\n\t\tLIMIT 0, 1\n\t");
 $duplicate_check = $db->fetch_field($query, "pmid");
 if ($duplicate_check) {
     error($lang->error_pm_already_submitted);
 }
 require_once MYBB_ROOT . "inc/datahandlers/pm.php";
 $pmhandler = new PMDataHandler();
 $pm = array("subject" => $mybb->get_input('subject'), "message" => $mybb->get_input('message'), "icon" => $mybb->get_input('icon', MyBB::INPUT_INT), "fromid" => $mybb->user['uid'], "do" => $mybb->get_input('do'), "pmid" => $mybb->get_input('pmid', MyBB::INPUT_INT), "ipaddress" => $session->packedip);
 // Split up any recipients we have
 $pm['to'] = $to;
 if (!empty($mybb->input['bcc'])) {
     $pm['bcc'] = explode(",", $mybb->get_input('bcc'));
     $pm['bcc'] = array_map("trim", $pm['bcc']);
 }
 $mybb->input['options'] = $mybb->get_input('options', MyBB::INPUT_ARRAY);
 if (!$mybb->usergroup['cantrackpms']) {
     $mybb->input['options']['readreceipt'] = false;
 }
 $pm['options'] = array();
 if (isset($mybb->input['options']['signature']) && $mybb->input['options']['signature'] == 1) {
     $pm['options']['signature'] = 1;
 } else {
Exemple #18
0
function group_changed()
{
    global $mybb, $user_info, $db;
    //Defines
    //Grab the targeted UserID, email and selected Groupname from the edit user form
    $userid = (int) $mybb->input['uid'];
    $promorank = $mybb->input['usergroup'];
    $email = $mybb->input['email'];
    //Query the DB for the targeted users current usergroup, old user group and username
    $query = $db->query("SELECT oldgroup, username FROM " . TABLE_PREFIX . "users WHERE uid = " . $userid);
    $user = $db->fetch_array($query);
    //Query the DB for the targeted users target group
    $rankquery = $db->query("SELECT usertitle FROM " . TABLE_PREFIX . "usergroups WHERE gid = " . $promorank);
    $rank = $db->fetch_array($rankquery);
    //Query the DB for the targeted users 'steamid'
    $fieldvalue = $db->query("SELECT fid4 FROM " . TABLE_PREFIX . "userfields WHERE ufid = " . $userid);
    $steamid = $db->fetch_array($fieldvalue);
    //Take the array and put it into $steamid2
    $steamid2 = $steamid['fid4'];
    //Convert if needed $clrsteamid is now = to what we need to insert for sourcebans account
    $clrsteamid = oldTextual($steamid2);
    //Thread/Section URL's
    $ts3guide = "THREAD URL HERE";
    $globalleader = "SECTION URL HERE";
    //SB password generation
    $pass = generatePassword(12);
    //Encrypt with the salt that sourcebans uses by default
    $encpass = sha1(sha1("SourceBans" . $pass));
    // connect to local server, authenticate and spawn an object for the virtual server on port 9987
    $ts3_VirtualServer = TeamSpeak3::factory("serverquery://*****:*****@localhost:10011/?server_port=9987");
    if ($promorank == 4) {
        //Sourcebans
        $srvgroup = "z";
        $webperms = "-513";
        $immunity = "100";
        //Teamspeak
        $arr_ServerGroup = $ts3_VirtualServer->serverGroupGetByName("Server Admin");
    } elseif ($promorank == 3) {
        //Sourcebans
        $srvgroup = "abcdjopqrst";
        $webperms = "1880130833";
        $immunity = "100";
        //Teamspeak
        $arr_ServerGroup = $ts3_VirtualServer->serverGroupGetByName("Server Admin");
    } elseif ($promorank == 6) {
        $arr_ServerGroup = $ts3_VirtualServer->serverGroupGetByName("Server Admin");
    }
    // create the privilege key
    $ts3_PrivilegeKey = $arr_ServerGroup->privilegeKeyCreate();
    //Begin array for insertion of SB account
    $sourcebans = array('user' => $user['username'], 'authid' => $clrsteamid, 'password' => $encpass, 'gid' => -1, 'email' => $email, 'extraflags' => $webperms, 'immunity' => $immunity, 'srv_flags' => $srvgroup);
    //PM Arrays
    $promomsg = array('subject' => "Congratulations: " . $user['username'], 'message' => "Congratulations on your promotion to the rank of " . $rank['usertitle'] . ".\n\t\t\tHere's a new privilege key for our Teamspeak server to set you to the rank\n\n\t\t\tTeamspeak key: " . $ts3_PrivilegeKey . " to use this key follow the guide located here " . $ts3guide . "\n\n\t\t\tYour access in Sourcebans has been updated, please allow 15 minutes for this change to take effect.\n\t\t\t \n\t\t\tThanks and once again, congratulations!", 'icon' => -1, 'fromid' => 1, 'toid' => $userid);
    //This will be the message if the user is being promoted, we don't need a sourcebans account to be created here
    $message = array('subject' => "Congratulations: " . $user['username'], 'message' => "Congratulations on your promotion to the rank of " . $rank['usertitle'] . ".\n\t\t\tWe've gone ahead and generated you a privilege key for our teamspeak server along with a sourcebans login and password which is as follows\n\n\t\t\tTeamspeak key: " . $ts3_PrivilegeKey . " to use this key follow the guide located here " . $ts3guide . "\n\n\t\t\tYour sourcebans credentials are the following (Please change your password ASAP)\n\n\n\t\t\t[b]username[/b]: " . $user['username'] . "\n\t\t\t[b]password[/b]: " . $pass . "\n\n\t\t\tTake some time to familiarise yourself with your new access, dont forget to read all the threads in the leadership global section" . $globalleader . "\n\t\t\t \n\t\t\tThanks and once again, congratulations!", 'icon' => -1, 'fromid' => 1, 'toid' => $userid);
    //Begin if/else for usergroup/oldgroup checking
    if ($promorank == 4 && $user['oldgroup'] != 4) {
        if ($user['oldgroup'] == 3 || $user['oldgroup'] == 6) {
            //Check if we're promoting the user from a rank that already has administrative access, if so we need to update their access in SB and send them a different pm
            //TODO: SB connect for updating group perms rather than just creating account
            sourcebansConnect($sourcebans, $clrsteamid, 2);
            $db->query("UPDATE " . TABLE_PREFIX . "users SET oldgroup=" . $promorank . " WHERE uid=" . $userid);
            //Prepare to send PM
            $pmhandler = new PMDataHandler();
            $pmhandler->admin_override = true;
            //Set PM data
            $pmhandler->set_data($promomsg);
            if ($pmhandler->validate_pm()) {
                $pmhandler->insert_pm();
                return true;
            }
            return false;
        } else {
            sourcebansConnect($sourcebans, $clrsteamid, 1);
            //Prepare to send PM
            $db->query("UPDATE " . TABLE_PREFIX . "users SET oldgroup=" . $promorank . " WHERE uid=" . $userid);
            $pmhandler = new PMDataHandler();
            $pmhandler->admin_override = true;
            //Set PM data
            $pmhandler->set_data($message);
            if ($pmhandler->validate_pm()) {
                $pmhandler->insert_pm();
                return true;
            }
            return false;
        }
    } else {
        if ($promorank == 3 && $user['oldgroup'] != 3) {
            if ($user['oldgroup'] != 4) {
                $db->query("UPDATE " . TABLE_PREFIX . "users SET oldgroup=" . $promorank . " WHERE uid=" . $userid);
                sourcebansConnect($sourcebans, $clrsteamid, 1);
                //Prepare to send PM
                $pmhandler = new PMDataHandler();
                $pmhandler->admin_override = true;
                //Set PM data
                $pmhandler->set_data($message);
                if ($pmhandler->validate_pm()) {
                    $pmhandler->insert_pm();
                    return true;
                }
                return false;
            } else {
                $db->query("UPDATE " . TABLE_PREFIX . "users SET oldgroup=" . $promorank . " WHERE uid=" . $userid);
                sourcebansConnect($sourcebans, $clrsteamid, 3);
                //Prepare to send PM
                $pmhandler = new PMDataHandler();
                $pmhandler->admin_override = true;
                //Set PM data
                $pmhandler->set_data($message);
                //TODO: demote msg
                if ($pmhandler->validate_pm()) {
                    $pmhandler->insert_pm();
                    return true;
                }
                return false;
            }
        } else {
            if ($promorank == 6 && $user['oldgroup'] != 6) {
                $db->query("UPDATE " . TABLE_PREFIX . "users SET oldgroup=" . $promorank . " WHERE uid=" . $userid);
                //Prepare to send PM
                $pmhandler = new PMDataHandler();
                $pmhandler->admin_override = true;
                //Set PM data
                $pmhandler->set_data($message);
                if ($pmhandler->validate_pm()) {
                    $pmhandler->insert_pm();
                    return true;
                }
                return false;
            }
        }
    }
}