Ejemplo n.º 1
0
function mark_pm_unread_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
    $input = Tapatalk_Input::filterXmlInput(array('message_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();
    }
    $foldernames = array();
    $foldersexploded = explode("\$%%\$", $mybb->user['pmfolders']);
    foreach ($foldersexploded as $key => $folders) {
        $folderinfo = explode("**", $folders, 2);
        $folderinfo[1] = get_pm_folder_name($folderinfo[0], $folderinfo[1]);
        $foldernames[$folderinfo[0]] = $folderinfo[1];
    }
    $sql_array = array("status" => 0, "readtime" => 0);
    $db->update_query("privatemessages", $sql_array, "pmid='{$input['message_id']}' AND uid='" . $mybb->user['uid'] . "'");
    update_pm_count();
    return xmlresptrue();
}
Ejemplo n.º 2
0
function get_quote_pm_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
    require_once MYBB_ROOT . $mybb->settings['tapatalk_directory'] . '/emoji/emoji.class.php';
    $input = Tapatalk_Input::filterXmlInput(array('message_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();
    }
    $foldernames = array();
    $foldersexploded = explode("\$%%\$", $mybb->user['pmfolders']);
    foreach ($foldersexploded as $key => $folders) {
        $folderinfo = explode("**", $folders, 2);
        $folderinfo[1] = get_pm_folder_name($folderinfo[0], $folderinfo[1]);
        $foldernames[$folderinfo[0]] = $folderinfo[1];
    }
    if ($mybb->usergroup['cansendpms'] == 0) {
        return tt_no_permission();
    }
    $query = $db->query("\n\t\tSELECT pm.*, u.username AS quotename\n\t\tFROM " . TABLE_PREFIX . "privatemessages pm\n\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=pm.fromid)\n\t\tWHERE pm.pmid='{$input['message_id']}' AND pm.uid='" . $mybb->user['uid'] . "'\n\t");
    $pm = $db->fetch_array($query);
    $message = $pm['message'];
    $subject = $pm['subject'];
    $subject = preg_replace("#(FW|RE):( *)#is", '', $subject);
    $message = "[quote={$pm['quotename']}]\n{$message}\n[/quote]";
    $message = preg_replace('#^/me (.*)$#im', "* " . $pm['quotename'] . " \\1", $message);
    $subject = "Re: {$subject}";
    $result = new xmlrpcval(array('result' => new xmlrpcval(true, 'boolean'), 'result_text' => new xmlrpcval('', 'base64'), 'msg_id' => new xmlrpcval($pm['pmid'], 'string'), 'msg_subject' => new xmlrpcval($subject, 'base64'), 'text_body' => new xmlrpcval(tapatalkEmoji::covertNameToEmoji($message), 'base64')), 'struct');
    return new xmlrpcresp($result);
}
Ejemplo n.º 3
0
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();
}
Ejemplo n.º 4
0
function delete_message_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
    $input = Tapatalk_Input::filterXmlInput(array('message_id' => Tapatalk_Input::INT, 'box_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();
    }
    $foldernames = array();
    $foldersexploded = explode("\$%%\$", $mybb->user['pmfolders']);
    foreach ($foldersexploded as $key => $folders) {
        $folderinfo = explode("**", $folders, 2);
        $folderinfo[1] = get_pm_folder_name($folderinfo[0], $folderinfo[1]);
        $foldernames[$folderinfo[0]] = $folderinfo[1];
    }
    $query = $db->simple_select("privatemessages", "*", "pmid='{$input['message_id']}' AND uid='" . $mybb->user['uid'] . "' AND folder='4'", array('order_by' => 'pmid'));
    if ($db->num_rows($query) == 1) {
        $db->delete_query("privatemessages", "pmid='{$input['message_id']}'");
    } else {
        $sql_array = array("folder" => 4, "deletetime" => TIME_NOW);
        $db->update_query("privatemessages", $sql_array, "pmid='{$input['message_id']}' AND uid='" . $mybb->user['uid'] . "'");
    }
    update_pm_count();
    return xmlresptrue();
}
Ejemplo n.º 5
0
$parser = new postParser();
// Load global language phrases
$lang->load("private");
if ($mybb->settings['enablepms'] == 0) {
    error($lang->pms_disabled);
}
if ($mybb->user['uid'] == '/' || $mybb->user['uid'] == 0 || $mybb->usergroup['canusepms'] == 0) {
    error_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']);
}
// On a random occassion, recount the user's pms just to make sure everything is in sync.
$rand = my_rand(0, 9);
if ($rand == 5) {
    update_pm_count();
}
$mybb->input['fid'] = $mybb->get_input('fid', MyBB::INPUT_INT);
$folder_id = $folder_name = '';
$foldernames = array();
$foldersexploded = explode("\$%%\$", $mybb->user['pmfolders']);
foreach ($foldersexploded as $key => $folders) {
    $folderinfo = explode("**", $folders, 2);
    if ($mybb->input['fid'] == $folderinfo[0]) {
        $sel = ' selected="selected"';
    } else {
        $sel = '';
    }
    $folderinfo[1] = get_pm_folder_name($folderinfo[0], $folderinfo[1]);
Ejemplo n.º 6
0
function get_box_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
    $input = Tapatalk_Input::filterXmlInput(array('box_id' => Tapatalk_Input::INT, 'start_num' => Tapatalk_Input::INT, 'last_num' => Tapatalk_Input::INT), $xmlrpc_params);
    list($start, $limit) = process_page($input['start_num'], $input['last_num']);
    $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();
    }
    $foldernames = array();
    $foldersexploded = explode("\$%%\$", $mybb->user['pmfolders']);
    foreach ($foldersexploded as $key => $folders) {
        $folderinfo = explode("**", $folders, 2);
        $folderinfo[1] = get_pm_folder_name($folderinfo[0], $folderinfo[1]);
        $foldernames[$folderinfo[0]] = $folderinfo[1];
    }
    if (!$input['box_id'] || !array_key_exists($input['box_id'], $foldernames)) {
        $input['box_id'] = 1;
    }
    $folder = $input['box_id'];
    $foldername = $foldernames[$folder];
    $lang->pms_in_folder = $lang->sprintf($lang->pms_in_folder, $foldername);
    if ($folder == 2 || $folder == 3) {
        $sender = $lang->sentto;
    } else {
        $sender = $lang->sender;
    }
    // Do Multi Pages
    $query = $db->simple_select("privatemessages", "COUNT(*) AS total", "uid='" . $mybb->user['uid'] . "' AND folder='{$folder}'");
    $count_total = $db->fetch_field($query, 'total');
    $query = $db->simple_select("privatemessages", "COUNT(*) AS unread", "uid='" . $mybb->user['uid'] . "' AND folder='{$folder}' AND readtime = 0");
    $count_unread = $db->fetch_field($query, 'unread');
    // Get all recipients into an array
    $cached_users = $get_users = array();
    $users_query = $db->simple_select("privatemessages", "recipients", "folder='{$folder}' AND uid='{$mybb->user['uid']}'", array('limit_start' => $start, 'limit' => $limit, 'order_by' => 'dateline', 'order_dir' => 'DESC'));
    while ($row = $db->fetch_array($users_query)) {
        $recipients = unserialize($row['recipients']);
        if (is_array($recipients['to']) && count($recipients['to'])) {
            $get_users = array_merge($get_users, $recipients['to']);
        }
        if (is_array($recipients['bcc']) && count($recipients['bcc'])) {
            $get_users = array_merge($get_users, $recipients['bcc']);
        }
    }
    $get_users = implode(',', array_unique($get_users));
    // Grab info
    if ($get_users) {
        $users_query = $db->simple_select("users", "uid, username, usergroup, displaygroup", "uid IN ({$get_users})");
        while ($user = $db->fetch_array($users_query)) {
            $cached_users[$user['uid']] = $user;
        }
    }
    $user_online = $folder == 1 ? ', fu.lastactive, fu.invisible, fu.lastvisit ' : ', tu.lastactive, tu.invisible, tu.lastvisit ';
    $query = $db->query("\n\t\tSELECT pm.*, fu.username AS fromusername, tu.username as tousername, fu.avatar as favatar, tu.avatar as tavatar {$user_online}\n\t\tFROM " . TABLE_PREFIX . "privatemessages pm\n\t\tLEFT JOIN " . TABLE_PREFIX . "users fu ON (fu.uid=pm.fromid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "users tu ON (tu.uid=pm.toid)\n\t\tWHERE pm.folder='{$folder}' AND pm.uid='" . $mybb->user['uid'] . "'\n\t\tORDER BY pm.dateline DESC\n\t\tLIMIT {$start}, {$limit}\n\t");
    $message_list = array();
    if ($db->num_rows($query) > 0) {
        while ($message = $db->fetch_array($query)) {
            $status = 1;
            if ($message['status'] == 0) {
                $msgalt = $lang->new_pm;
            } elseif ($message['status'] == 1) {
                $msgalt = $lang->old_pm;
                $status = 2;
            } elseif ($message['status'] == 3) {
                $msgalt = $lang->reply_pm;
                $status = 3;
            } elseif ($message['status'] == 4) {
                $msgalt = $lang->fwd_pm;
                $status = 4;
            }
            $msg_from = null;
            $msg_to = array();
            $avatar = "";
            $outboxdisplayuserid = 0;
            // Sent Items or Drafts Folder Check
            $recipients = unserialize($message['recipients']);
            if (count($recipients['to']) > 1 || count($recipients['to']) == 1 && count($recipients['bcc']) > 0) {
                foreach ($recipients['to'] as $uid) {
                    $profilelink = get_profile_link($uid);
                    $user = $cached_users[$uid];
                    if (!empty($user['username'])) {
                        $msg_to[] = new xmlrpcval(array("username" => new xmlrpcval($user['username'], "base64"), "user_id" => new xmlrpcval($uid, "string"), "user_type" => check_return_user_type($user['username'])), "struct");
                    }
                    if (($folder == 2 or $folder == 3) && !$outboxdisplayuserid) {
                        $outboxdisplayuserid = $uid;
                    }
                }
                /*if(is_array($recipients['bcc']) && count($recipients['bcc']))
                		{
                			foreach($recipients['bcc'] as $uid)
                			{
                				$profilelink = get_profile_link($uid);
                				$user = $cached_users[$uid];
                				$msg_to[]=new xmlrpcval($user['username'], "base64");
                			}
                		}*/
            } else {
                if ($message['toid']) {
                    $tofromusername = $message['tousername'];
                    $tofromuid = $message['toid'];
                    if (!empty($tofromusername)) {
                        $msg_to[] = new xmlrpcval(array("username" => new xmlrpcval($tofromusername, "base64"), "user_id" => new xmlrpcval($message['toid'], "string"), "user_type" => check_return_user_type($tofromusername)), "struct");
                    }
                }
            }
            $avatar = $message['tavatar'];
            if ($folder != 2 && $folder != 3) {
                $tofromusername = $message['fromusername'];
                $tofromuid = $message['fromid'];
                if ($tofromuid == 0) {
                    $tofromusername = $lang->mybb_engine;
                }
                if (!$tofromusername) {
                    $tofromuid = 0;
                    $tofromusername = $lang->na;
                }
                $msg_from = $tofromusername;
                $avatar = $message['favatar'];
            } else {
                if ($outboxdisplayuserid) {
                    $outboxdisplayuser = get_user($outboxdisplayuserid);
                    $avatar = $outboxdisplayuser['avatar'];
                }
            }
            if (!trim($message['subject'])) {
                $message['subject'] = $lang->pm_no_subject;
            }
            $is_online = false;
            $timecut = TIME_NOW - $mybb->settings['wolcutoff'];
            if ($message['lastactive'] > $timecut && ($message['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1) && $message['lastvisit'] != $message['lastactive']) {
                $is_online = true;
            }
            $new_message = array('msg_id' => new xmlrpcval($message['pmid'], 'string'), 'msg_state' => new xmlrpcval($status, 'int'), 'sent_date' => new xmlrpcval(mobiquo_iso8601_encode($message['dateline']), 'dateTime.iso8601'), 'msg_to' => new xmlrpcval($msg_to, 'array'), 'icon_url' => new xmlrpcval(absolute_url($avatar), 'string'), 'msg_subject' => new xmlrpcval($message['subject'], 'base64'), 'short_content' => new xmlrpcval(process_short_content($message['message'], $parser), 'base64'), 'is_online' => new xmlrpcval($is_online, 'boolean'));
            if ($msg_from !== null) {
                $new_message['msg_from'] = new xmlrpcval($msg_from, 'base64');
            }
            $message_list[] = new xmlrpcval($new_message, "struct");
        }
    }
    $result = new xmlrpcval(array('result' => new xmlrpcval(true, 'boolean'), 'result_text' => new xmlrpcval('', 'base64'), 'total_message_count' => new xmlrpcval($count_total, 'int'), 'total_unread_count' => new xmlrpcval($count_unread, 'int'), 'list' => new xmlrpcval($message_list, 'array')), 'struct');
    return new xmlrpcresp($result);
}
Ejemplo n.º 7
0
/**
 * Writes text to the image.
 *
 * @param resource $im The image.
 * @param string $string The string to be written
 *
 * @return bool False if string is empty, true otherwise
 */
function draw_string(&$im, $string)
{
    global $use_ttf, $min_size, $max_size, $min_angle, $max_angle, $ttf_fonts, $img_height, $img_width;
    if (empty($string)) {
        return false;
    }
    $spacing = $img_width / my_strlen($string);
    $string_length = my_strlen($string);
    for ($i = 0; $i < $string_length; ++$i) {
        // Using TTF fonts
        if ($use_ttf) {
            // Select a random font size
            $font_size = my_rand($min_size, $max_size);
            // Select a random font
            $font = array_rand($ttf_fonts);
            $font = $ttf_fonts[$font];
            // Select a random rotation
            $rotation = my_rand($min_angle, $max_angle);
            // Set the colour
            $r = my_rand(0, 200);
            $g = my_rand(0, 200);
            $b = my_rand(0, 200);
            $color = imagecolorallocate($im, $r, $g, $b);
            // Fetch the dimensions of the character being added
            $dimensions = imageftbbox($font_size, $rotation, $font, $string[$i], array());
            $string_width = $dimensions[2] - $dimensions[0];
            $string_height = $dimensions[3] - $dimensions[5];
            // Calculate character offsets
            //$pos_x = $pos_x + $string_width + ($string_width/4);
            $pos_x = $spacing / 4 + $i * $spacing;
            $pos_y = ceil($img_height - $string_height / 2);
            // Draw a shadow
            $shadow_x = my_rand(-3, 3) + $pos_x;
            $shadow_y = my_rand(-3, 3) + $pos_y;
            $shadow_color = imagecolorallocate($im, $r + 20, $g + 20, $b + 20);
            imagefttext($im, $font_size, $rotation, $shadow_x, $shadow_y, $shadow_color, $font, $string[$i], array());
            // Write the character to the image
            imagefttext($im, $font_size, $rotation, $pos_x, $pos_y, $color, $font, $string[$i], array());
        } else {
            // Get width/height of the character
            $string_width = imagefontwidth(5);
            $string_height = imagefontheight(5);
            // Calculate character offsets
            $pos_x = $spacing / 4 + $i * $spacing;
            $pos_y = $img_height / 2 - $string_height - 10 + my_rand(-3, 3);
            // Create a temporary image for this character
            if (gd_version() >= 2) {
                $temp_im = imagecreatetruecolor(15, 20);
            } else {
                $temp_im = imagecreate(15, 20);
            }
            $bg_color = imagecolorallocate($temp_im, 255, 255, 255);
            imagefill($temp_im, 0, 0, $bg_color);
            imagecolortransparent($temp_im, $bg_color);
            // Set the colour
            $r = my_rand(0, 200);
            $g = my_rand(0, 200);
            $b = my_rand(0, 200);
            $color = imagecolorallocate($temp_im, $r, $g, $b);
            // Draw a shadow
            $shadow_x = my_rand(-1, 1);
            $shadow_y = my_rand(-1, 1);
            $shadow_color = imagecolorallocate($temp_im, $r + 50, $g + 50, $b + 50);
            imagestring($temp_im, 5, 1 + $shadow_x, 1 + $shadow_y, $string[$i], $shadow_color);
            imagestring($temp_im, 5, 1, 1, $string[$i], $color);
            // Copy to main image
            imagecopyresized($im, $temp_im, $pos_x, $pos_y, 0, 0, 40, 55, 15, 20);
            imagedestroy($temp_im);
        }
    }
    return true;
}
Ejemplo n.º 8
0
function landscape()
{
    global $picType, $steep, $sealevel, $pic, $pic0, $buf2;
    global $LEVEL_UNDEFINED, $LEVEL_WATER, $NUM_TERRAIN_TYPE;
    global $Z1, $Z2, $Z3, $Z4;
    global $XA, $XB, $YA, $YB;
    global $XADD, $YADD;
    $steep = my_rand() / 2 + 0.75;
    $sealevel = round(($NUM_TERRAIN_TYPE * 3 / 2 + 2) * my_rand() - ($NUM_TERRAIN_TYPE / 2 + 1));
    $Z1 = round(($NUM_TERRAIN_TYPE - 1) * my_rand() - $NUM_TERRAIN_TYPE / 2);
    $Z2 = round(($NUM_TERRAIN_TYPE - 1) * my_rand() - $NUM_TERRAIN_TYPE / 2);
    $Z3 = round(($NUM_TERRAIN_TYPE - 1) * my_rand() - $NUM_TERRAIN_TYPE / 2);
    $Z4 = round(($NUM_TERRAIN_TYPE - 1) * my_rand() - $NUM_TERRAIN_TYPE / 2);
    frac($XA, $YA, $XB, $YB, $Z1, $Z2, $Z3, $Z4);
    ksort($pic);
    $min_height = min($pic);
    $max_height = max($pic);
    $height_diff = abs($max_height - $min_height);
    $mod = 0 - $min_height;
    $new_min = $min_height + ($height_diff - $max_height);
    $new_max = $max_height + ($height_diff - $max_height);
    $new_diff = abs($new_max - $newmin);
    $num_els = count($pic);
    foreach ($pic as $key => $value) {
        $pic[$key] = (int) (($pic[$key] - $min_height) * ($NUM_TERRAIN_TYPE - 1) / $height_diff) + 1;
    }
    $min_height = min($pic);
    $max_height = max($pic);
    $height_diff = abs($max_height - $min_height);
    for ($i = 0; $i < $XB; $i++) {
        for ($j = 0; $j < $YB; $j++) {
            $pic0 = $LEVEL_UNDEFINED;
            $loc = $j * $YB + $i;
            if ($picType[$j * $YB + $i] == "l") {
                $pic0 = abs($pic[$j * $YB + $i] - $sealevel);
            }
            if ($picType[$j * $YB + $i] == "s") {
                $pic0 = $LEVEL_WATER;
            }
            $buf2 .= ZColor($pic0);
        }
    }
    return $buf2;
}
Ejemplo n.º 9
0
/**
 * Generates a random string.
 *
 * @param int The length of the string to generate.
 * @return string The random string.
 */
function random_str($length = "8")
{
    $set = array("a", "A", "b", "B", "c", "C", "d", "D", "e", "E", "f", "F", "g", "G", "h", "H", "i", "I", "j", "J", "k", "K", "l", "L", "m", "M", "n", "N", "o", "O", "p", "P", "q", "Q", "r", "R", "s", "S", "t", "T", "u", "U", "v", "V", "w", "W", "x", "X", "y", "Y", "z", "Z", "1", "2", "3", "4", "5", "6", "7", "8", "9");
    $str = '';
    for ($i = 1; $i <= $length; ++$i) {
        $ch = my_rand(0, count($set) - 1);
        $str .= $set[$ch];
    }
    return $str;
}
Ejemplo n.º 10
0
function get_message_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
    $input = Tapatalk_Input::filterXmlInput(array('message_id' => Tapatalk_Input::INT, 'box_id' => Tapatalk_Input::INT, 'return_html' => 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();
    }
    $foldernames = array();
    $foldersexploded = explode("\$%%\$", $mybb->user['pmfolders']);
    foreach ($foldersexploded as $key => $folders) {
        $folderinfo = explode("**", $folders, 2);
        $folderinfo[1] = get_pm_folder_name($folderinfo[0], $folderinfo[1]);
        $foldernames[$folderinfo[0]] = $folderinfo[1];
    }
    $pmid = $input['message_id'];
    $query = $db->query("\n\t\tSELECT pm.*, u.*, f.*, g.title AS grouptitle, g.usertitle AS groupusertitle, g.stars AS groupstars, g.starimage AS groupstarimage, g.image AS groupimage, g.namestyle\n\t\tFROM " . TABLE_PREFIX . "privatemessages pm\n\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=pm.fromid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "userfields f ON (f.ufid=u.uid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "usergroups g ON (g.gid=u.usergroup)\n\t\tWHERE pm.pmid='{$pmid}' AND pm.uid='" . $mybb->user['uid'] . "'\n\t");
    $pm = $db->fetch_array($query);
    if ($pm['folder'] == 3) {
        return xmlrespfalse("Draft PMs are not supported by Tapatalk");
    }
    if (!$pm['pmid']) {
        return xmlrespfalse($lang->error_invalidpm);
    }
    $parser = new Tapatalk_Parser();
    $parser_options = array();
    $parser_options['allow_html'] = false;
    $parser_options['allow_mycode'] = true;
    $parser_options['allow_smilies'] = false;
    $parser_options['allow_imgcode'] = true;
    $parser_options['allow_videocode'] = true;
    $parser_options['nl2br'] = (bool) $input['return_html'];
    $parser_options['filter_badwords'] = 1;
    $pm['message'] = post_bbcode_clean($pm['message']);
    $pm['message'] = $parser->parse_message($pm['message'], $parser_options);
    if ($pm['receipt'] == 1) {
        if ($mybb->usergroup['cantrackpms'] == 1 && $mybb->usergroup['candenypmreceipts'] == 1 && $mybb->input['denyreceipt'] == 1) {
            $receiptadd = 0;
        } else {
            $receiptadd = 2;
        }
    }
    if ($pm['status'] == 0) {
        $time = TIME_NOW;
        $updatearray = array('status' => 1, 'readtime' => $time);
        if (isset($receiptadd)) {
            $updatearray['receipt'] = $receiptadd;
        }
        $db->update_query('privatemessages', $updatearray, "pmid='{$pmid}'");
        // Update the unread count - it has now changed.
        update_pm_count($mybb->user['uid'], 6);
        // Update PM notice value if this is our last unread PM
        if ($mybb->user['unreadpms'] - 1 <= 0 && $mybb->user['pmnotice'] == 2) {
            $updated_user = array("pmnotice" => 1);
            $db->update_query("users", $updated_user, "uid='{$mybb->user['uid']}'");
        }
    }
    $pm['subject'] = $parser->parse_badwords($pm['subject']);
    if ($pm['fromid'] == 0) {
        $pm['username'] = $lang->mybb_engine;
    }
    if (!$pm['username']) {
        $pm['username'] = $lang->na;
    }
    // Fetch the recipients for this message
    $pm['recipients'] = @unserialize($pm['recipients']);
    if (is_array($pm['recipients']['to'])) {
        $uid_sql = implode(',', $pm['recipients']['to']);
        foreach ($pm['recipients']['to'] as $uid) {
            $user = get_user($uid);
            $msg_to_list[] = new xmlrpcval(array('user_id' => new xmlrpcval($user['uid'], 'string'), 'username' => new xmlrpcval(basic_clean($user['username']), 'base64'), 'user_type' => check_return_user_type($user['username'])), 'struct');
            if (($pm['folder'] == 2 or $pm['folder'] == 3) && !$avatar) {
                $avatar = $user['avatar'];
            }
        }
    } else {
        $user = get_user($pm['toid']);
        $msg_to_list[] = new xmlrpcval(array('user_id' => new xmlrpcval($user['uid'], 'string'), 'username' => new xmlrpcval(basic_clean($user['username']), 'base64'), 'user_type' => check_return_user_type($user['username'])), 'struct');
        if ($pm['folder'] == 2 or $pm['folder'] == 3) {
            $avatar = $user['avatar'];
        }
    }
    $show_bcc = 0;
    // If we have any BCC recipients and this user is an Administrator, add them on to the query
    if (count($pm['recipients']['bcc']) > 0 && $mybb->usergroup['cancp'] == 1) {
        foreach ($pm['recipients']['bcc'] as $uid) {
            $user = get_user($uid);
            $msg_to_list[] = new xmlrpcval(array('user_id' => new xmlrpcval($user['uid'], 'string'), 'username' => new xmlrpcval(basic_clean($user['username']), 'base64'), 'user_type' => check_return_user_type($user['username'])), 'struct');
        }
    }
    if (!$avatar) {
        $avatar = $pm['avatar'];
    }
    //$display_user = ($box_id == 'inbox') ? $message['from'] : $msg_to[0];
    $is_online = false;
    $timecut = TIME_NOW - $mybb->settings['wolcutoff'];
    if ($pm['lastactive'] > $timecut && ($pm['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1) && $pm['lastvisit'] != $pm['lastactive']) {
        $is_online = true;
    }
    $result = new xmlrpcval(array('result' => new xmlrpcval(true, 'boolean'), 'result_text' => new xmlrpcval('', 'base64'), 'msg_from' => new xmlrpcval($pm['username'], 'base64'), 'msg_from_id' => new xmlrpcval($pm['fromid'], 'string'), 'msg_to' => new xmlrpcval($msg_to_list, 'array'), 'icon_url' => new xmlrpcval(absolute_url($avatar), 'string'), 'sent_date' => new xmlrpcval(mobiquo_iso8601_encode($pm['dateline']), 'dateTime.iso8601'), 'msg_subject' => new xmlrpcval($pm['subject'], 'base64'), 'text_body' => new xmlrpcval(process_post($pm['message'], $input['return_html']), 'base64'), 'is_online' => new xmlrpcval($is_online, 'boolean'), 'allow_smilies' => new xmlrpcval(true, 'boolean')), 'struct');
    return new xmlrpcresp($result);
}
Ejemplo n.º 11
0
function get_box_info_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
    $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();
    }
    $foldercache = array();
    $folderids = array();
    $folderlist = '';
    $foldersexploded = explode("\$%%\$", $mybb->user['pmfolders']);
    foreach ($foldersexploded as $key => $folders) {
        $folderinfo = explode("**", $folders, 2);
        $foldername = $folderinfo[1];
        $fid = $folderinfo[0];
        $foldername = get_pm_folder_name($fid, $foldername);
        $type = "";
        if ($fid == 1) {
            $type = "INBOX";
        } else {
            if ($fid == 2) {
                $type = "SENT";
            } else {
                continue;
            }
        }
        // return inbox and send box only
        $foldercache[$fid] = array("fid" => $fid, "name" => $foldername, "total" => 0, "unread" => 0, "type" => $type);
        $folderids[] = intval($fid);
    }
    $query = $db->simple_select("privatemessages", "folder, count(*) as total", "FIND_IN_SET(folder, '" . implode(",", $folderids) . "') AND uid='{$mybb->user['uid']}' group by folder");
    while ($folder = $db->fetch_array($query)) {
        $foldercache[$folder['folder']]['total'] = $folder['total'];
    }
    $query = $db->simple_select("privatemessages", "folder, count(*) as unread", "FIND_IN_SET(folder, '" . implode(",", $folderids) . "') AND uid='{$mybb->user['uid']}' AND readtime = 0 group by folder");
    while ($folder = $db->fetch_array($query)) {
        $foldercache[$folder['folder']]['unread'] = $folder['unread'];
    }
    $folder_list = array();
    foreach ($foldercache as $fid => $folder) {
        $folder_list[] = new xmlrpcval(array('box_id' => new xmlrpcval($fid, 'string'), 'box_name' => new xmlrpcval($folder['name'], 'base64'), 'msg_count' => new xmlrpcval($folder['total'], 'int'), 'unread_count' => new xmlrpcval($folder['unread'], 'int'), 'box_type' => new xmlrpcval($folder['type'], 'string')), 'struct');
    }
    $spaceused = 0;
    if ($mybb->usergroup['pmquota'] != '0' && $mybb->usergroup['cancp'] != 1) {
        $query = $db->simple_select("privatemessages", "COUNT(*) AS total", "uid='" . $mybb->user['uid'] . "'");
        $pmscount = $db->fetch_array($query);
        if ($pmscount['total'] > 0) {
            $spaceused = $mybb->usergroup['pmquota'] - $pmscount['total'];
        }
    }
    $result = new xmlrpcval(array('result' => new xmlrpcval(true, 'boolean'), 'result_text' => new xmlrpcval('', 'base64'), 'message_room_count' => new xmlrpcval($mybb->usergroup['cancp'] == 1 ? 100 : $spaceused, 'int'), 'list' => new xmlrpcval($folder_list, 'array')), 'struct');
    return $result;
}
Ejemplo n.º 12
0
        eval("class {$style_name} extends {$default_name} { }");
    }
}
$page = new Page();
$page->style = $cp_style;
// Do not have a valid Admin user, throw back to login page.
if (!$mybb->user['uid'] || $logged_out == true) {
    if ($logged_out == true) {
        $page->show_login($lang->success_logged_out);
    } elseif ($fail_check == 1) {
        $page->show_login($lang->error_invalid_username_password, "error");
    } else {
        $page->show_login($login_message, "error");
    }
}
$rand = my_rand();
if ($rand == 2 || $rand == 5) {
    $stamp = TIME_NOW - 604800;
    $db->delete_query("adminsessions", "lastactive < '{$stamp}'");
}
$page->add_breadcrumb_item($lang->home, "index.php");
// Begin dealing with the modules
$modules_dir = MYBB_ADMIN_DIR . "modules";
$dir = opendir($modules_dir);
while (($module = readdir($dir)) !== false) {
    if (is_dir($modules_dir . "/" . $module) && !in_array($module, array(".", "..")) && file_exists($modules_dir . "/" . $module . "/module_meta.php")) {
        require_once $modules_dir . "/" . $module . "/module_meta.php";
        // Need to always load it for admin permissions / quick access
        $lang->load($module . "_module_meta", false, true);
        $has_permission = false;
        if (function_exists($module . "_admin_permissions")) {
Ejemplo n.º 13
0
/**
 * Generates a random string.
 *
 * @param int $length The length of the string to generate.
 * @param bool $complex Whether to return complex string. Defaults to false
 * @return string The random string.
 */
function random_str($length = 8, $complex = false)
{
    $set = array_merge(range(0, 9), range('A', 'Z'), range('a', 'z'));
    $str = array();
    // Complex strings have always at least 3 characters, even if $length < 3
    if ($complex == true) {
        // At least one number
        $str[] = $set[my_rand(0, 9)];
        // At least one big letter
        $str[] = $set[my_rand(10, 35)];
        // At least one small letter
        $str[] = $set[my_rand(36, 61)];
        $length -= 3;
    }
    for ($i = 0; $i < $length; ++$i) {
        $str[] = $set[my_rand(0, 61)];
    }
    // Make sure they're in random order and convert them to a string
    shuffle($str);
    return implode($str);
}