Exemplo n.º 1
0
function delete_thread_uri($itemuri, $uid)
{
    $messages = q("SELECT `id` FROM `item` WHERE uri ='%s' AND uid=%d", dbesc($itemuri), intval($uid));
    if (count($messages)) {
        foreach ($messages as $message) {
            delete_thread($message["id"]);
        }
    }
}
 /**
  * Deletes a thread
  *
  * @param	boolean	Whether to consider updating post counts, regardless of forum's settings
  * @param	boolean	Whether to physically remove the thread from the database
  * @param	array	Array of information for a soft delete
  * @param	boolean	Whether to add an entry to the moderator log
  *
  * @return	mixed	The number of affected rows
  */
 function delete($countposts = true, $physicaldel = true, $delinfo = NULL, $dolog = true)
 {
     if ($threadid = $this->existing['threadid']) {
         require_once DIR . '/includes/functions_databuild.php';
         ($hook = vBulletinHook::fetch_hook('threaddata_delete')) ? eval($hook) : false;
         // note: the skip_moderator_log is the inverse of the $dolog argument
         return delete_thread($threadid, $countposts, $physicaldel, $delinfo, $this->info['skip_moderator_log'] !== null ? !$this->info['skip_moderator_log'] : $dolog, $this->existing);
     }
     return false;
 }
Exemplo n.º 3
0
function diaspora_signed_retraction($importer, $xml, $msg)
{
    $guid = notags(unxmlify($xml->target_guid));
    $diaspora_handle = notags(unxmlify($xml->sender_handle));
    $type = notags(unxmlify($xml->target_type));
    $sig = notags(unxmlify($xml->target_author_signature));
    $parent_author_signature = $xml->parent_author_signature ? notags(unxmlify($xml->parent_author_signature)) : '';
    $contact = diaspora_get_contact_by_handle($importer['uid'], $diaspora_handle);
    if (!$contact) {
        logger('diaspora_signed_retraction: no contact ' . $diaspora_handle . ' for ' . $importer['uid']);
        return;
    }
    $signed_data = $guid . ';' . $type;
    $key = $msg['key'];
    /* How Diaspora performs relayable_retraction signature checking:
    
    	   - If an item has been sent by the item author to the top-level post owner to relay on
    	     to the rest of the contacts on the top-level post, the top-level post owner checks
    	     the author_signature, then creates a parent_author_signature before relaying the item on
    	   - If an item has been relayed on by the top-level post owner, the contacts who receive it
    	     check only the parent_author_signature. Basically, they trust that the top-level post
    	     owner has already verified the authenticity of anything he/she sends out
    	   - In either case, the signature that get checked is the signature created by the person
    	     who sent the salmon
    	*/
    if ($parent_author_signature) {
        $parent_author_signature = base64_decode($parent_author_signature);
        if (!rsa_verify($signed_data, $parent_author_signature, $key, 'sha256')) {
            logger('diaspora_signed_retraction: top-level post owner verification failed');
            return;
        }
    } else {
        $sig_decode = base64_decode($sig);
        if (!rsa_verify($signed_data, $sig_decode, $key, 'sha256')) {
            logger('diaspora_signed_retraction: retraction owner verification failed.' . print_r($msg, true));
            return;
        }
    }
    if ($type === 'StatusMessage' || $type === 'Comment' || $type === 'Like') {
        $r = q("select * from item where guid = '%s' and uid = %d and not file like '%%[%%' limit 1", dbesc($guid), intval($importer['uid']));
        if (count($r)) {
            if (link_compare($r[0]['author-link'], $contact['url'])) {
                q("update item set `deleted` = 1, `edited` = '%s', `changed` = '%s', `body` = '' , `title` = '' where `id` = %d", dbesc(datetime_convert()), dbesc(datetime_convert()), intval($r[0]['id']));
                delete_thread($r[0]['id'], $r[0]['parent-uri']);
                // Now check if the retraction needs to be relayed by us
                //
                // The first item in the `item` table with the parent id is the parent. However, MySQL doesn't always
                // return the items ordered by `item`.`id`, in which case the wrong item is chosen as the parent.
                // The only item with `parent` and `id` as the parent id is the parent item.
                $p = q("select origin from item where parent = %d and id = %d limit 1", $r[0]['parent'], $r[0]['parent']);
                if (count($p)) {
                    if ($p[0]['origin'] && !$parent_author_signature) {
                        q("insert into sign (`retract_iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ", $r[0]['id'], dbesc($signed_data), dbesc($sig), dbesc($diaspora_handle));
                        // the existence of parent_author_signature would have meant the parent_author or owner
                        // is already relaying.
                        logger('diaspora_signed_retraction: relaying relayable_retraction');
                        proc_run('php', 'include/notifier.php', 'drop', $r[0]['id']);
                    }
                }
            }
        }
    } else {
        logger('diaspora_signed_retraction: unknown type: ' . $type);
    }
    return 202;
    // NOTREACHED
}
Exemplo n.º 4
0
function drop_item($id, $interactive = true)
{
    $a = get_app();
    // locate item to be deleted
    $r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1", intval($id));
    if (!count($r)) {
        if (!$interactive) {
            return 0;
        }
        notice(t('Item not found.') . EOL);
        goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
    }
    $item = $r[0];
    $owner = $item['uid'];
    $cid = 0;
    // check if logged in user is either the author or owner of this item
    if (is_array($_SESSION['remote'])) {
        foreach ($_SESSION['remote'] as $visitor) {
            if ($visitor['uid'] == $item['uid'] && $visitor['cid'] == $item['contact-id']) {
                $cid = $visitor['cid'];
                break;
            }
        }
    }
    if (local_user() == $item['uid'] || $cid || !$interactive) {
        // Check if we should do HTML-based delete confirmation
        if ($_REQUEST['confirm']) {
            // <form> can't take arguments in its "action" parameter
            // so add any arguments as hidden inputs
            $query = explode_querystring($a->query_string);
            $inputs = array();
            foreach ($query['args'] as $arg) {
                if (strpos($arg, 'confirm=') === false) {
                    $arg_parts = explode('=', $arg);
                    $inputs[] = array('name' => $arg_parts[0], 'value' => $arg_parts[1]);
                }
            }
            return replace_macros(get_markup_template('confirm.tpl'), array('$method' => 'get', '$message' => t('Do you really want to delete this item?'), '$extra_inputs' => $inputs, '$confirm' => t('Yes'), '$confirm_url' => $query['base'], '$confirm_name' => 'confirmed', '$cancel' => t('Cancel')));
        }
        // Now check how the user responded to the confirmation query
        if ($_REQUEST['canceled']) {
            goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
        }
        logger('delete item: ' . $item['id'], LOGGER_DEBUG);
        // delete the item
        $r = q("UPDATE `item` SET `deleted` = 1, `title` = '', `body` = '', `edited` = '%s', `changed` = '%s' WHERE `id` = %d", dbesc(datetime_convert()), dbesc(datetime_convert()), intval($item['id']));
        create_tags_from_item($item['id']);
        create_files_from_item($item['id']);
        delete_thread($item['id'], $item['parent-uri']);
        // clean up categories and tags so they don't end up as orphans
        $matches = false;
        $cnt = preg_match_all('/<(.*?)>/', $item['file'], $matches, PREG_SET_ORDER);
        if ($cnt) {
            foreach ($matches as $mtch) {
                file_tag_unsave_file($item['uid'], $item['id'], $mtch[1], true);
            }
        }
        $matches = false;
        $cnt = preg_match_all('/\\[(.*?)\\]/', $item['file'], $matches, PREG_SET_ORDER);
        if ($cnt) {
            foreach ($matches as $mtch) {
                file_tag_unsave_file($item['uid'], $item['id'], $mtch[1], false);
            }
        }
        // If item is a link to a photo resource, nuke all the associated photos
        // (visitors will not have photo resources)
        // This only applies to photos uploaded from the photos page. Photos inserted into a post do not
        // generate a resource-id and therefore aren't intimately linked to the item.
        if (strlen($item['resource-id'])) {
            q("DELETE FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d ", dbesc($item['resource-id']), intval($item['uid']));
            // ignore the result
        }
        // If item is a link to an event, nuke the event record.
        if (intval($item['event-id'])) {
            q("DELETE FROM `event` WHERE `id` = %d AND `uid` = %d", intval($item['event-id']), intval($item['uid']));
            // ignore the result
        }
        // If item has attachments, drop them
        foreach (explode(",", $item['attach']) as $attach) {
            preg_match("|attach/(\\d+)|", $attach, $matches);
            q("DELETE FROM `attach` WHERE `id` = %d AND `uid` = %d", intval($matches[1]), local_user());
            // ignore the result
        }
        // clean up item_id and sign meta-data tables
        /*
        // Old code - caused very long queries and warning entries in the mysql logfiles:
        
        $r = q("DELETE FROM item_id where iid in (select id from item where parent = %d and uid = %d)",
        	intval($item['id']),
        	intval($item['uid'])
        );
        
        $r = q("DELETE FROM sign where iid in (select id from item where parent = %d and uid = %d)",
        	intval($item['id']),
        	intval($item['uid'])
        );
        */
        // The new code splits the queries since the mysql optimizer really has bad problems with subqueries
        // Creating list of parents
        $r = q("select id from item where parent = %d and uid = %d", intval($item['id']), intval($item['uid']));
        $parentid = "";
        foreach ($r as $row) {
            if ($parentid != "") {
                $parentid .= ", ";
            }
            $parentid .= $row["id"];
        }
        // Now delete them
        if ($parentid != "") {
            $r = q("DELETE FROM item_id where iid in (%s)", dbesc($parentid));
            $r = q("DELETE FROM sign where iid in (%s)", dbesc($parentid));
        }
        // If it's the parent of a comment thread, kill all the kids
        if ($item['uri'] == $item['parent-uri']) {
            $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s', `body` = '' , `title` = ''\n\t\t\t\tWHERE `parent-uri` = '%s' AND `uid` = %d ", dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc($item['parent-uri']), intval($item['uid']));
            create_tags_from_itemuri($item['parent-uri'], $item['uid']);
            create_files_from_itemuri($item['parent-uri'], $item['uid']);
            delete_thread_uri($item['parent-uri'], $item['uid']);
            // ignore the result
        } else {
            // ensure that last-child is set in case the comment that had it just got wiped.
            q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ", dbesc(datetime_convert()), dbesc($item['parent-uri']), intval($item['uid']));
            // who is the last child now?
            $r = q("SELECT `id` FROM `item` WHERE `parent-uri` = '%s' AND `type` != 'activity' AND `deleted` = 0 AND `uid` = %d ORDER BY `edited` DESC LIMIT 1", dbesc($item['parent-uri']), intval($item['uid']));
            if (count($r)) {
                q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d", intval($r[0]['id']));
            }
            // Add a relayable_retraction signature for Diaspora.
            store_diaspora_retract_sig($item, $a->user, $a->get_baseurl());
        }
        $drop_id = intval($item['id']);
        // send the notification upstream/downstream as the case may be
        proc_run('php', "include/notifier.php", "drop", "{$drop_id}");
        if (!$interactive) {
            return $owner;
        }
        goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
        //NOTREACHED
    } else {
        if (!$interactive) {
            return 0;
        }
        notice(t('Permission denied.') . EOL);
        goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
        //NOTREACHED
    }
}
Exemplo n.º 5
0
        redirect('viewforum.php?id=' . $cur_comment['fid']);
    } else {
        // Reset just this one comment
        $db->query('UPDATE ' . $db->prefix . 'comments SET soft = 0 WHERE id=' . $id) or error('Unable to soft delete comment', __FILE__, __LINE__, $db->error());
        update_forum($cur_comment['fid']);
        // Redirect towards the comment
        redirect('thread.php?pid=' . $id . '#p' . $id);
    }
}
if (isset($_POST['delete'])) {
    // Make sure they got here from the site
    confirm_referrer('delete.php');
    require LUNA_ROOT . 'include/search_idx.php';
    if ($is_thread_comment) {
        // Delete the thread and all of its comments
        delete_thread($cur_comment['tid'], "hard");
        update_forum($cur_comment['fid']);
        redirect('viewforum.php?id=' . $cur_comment['fid']);
    } else {
        // Delete just this one comment
        delete_comment($id, $cur_comment['tid'], $cur_comment['commenter_id']);
        update_forum($cur_comment['fid']);
        // Redirect towards the previous comment
        $result = $db->query('SELECT id FROM ' . $db->prefix . 'comments WHERE thread_id=' . $cur_comment['tid'] . ' AND id < ' . $id . ' ORDER BY id DESC LIMIT 1') or error('Unable to fetch comment info', __FILE__, __LINE__, $db->error());
        $comment_id = $db->result($result);
        redirect('thread.php?pid=' . $comment_id . '#p' . $comment_id);
    }
}
$page_title = array(luna_htmlspecialchars($luna_config['o_board_title']), __('Delete comment', 'luna'));
define('LUNA_ACTIVE_PAGE', 'delete');
require LUNA_ROOT . 'include/parser.php';
Exemplo n.º 6
0
function ostatus_completion($conversation_url, $uid, $item = array())
{
    $a = get_app();
    $item_stored = -1;
    $conversation_url = ostatus_convert_href($conversation_url);
    // If the thread shouldn't be completed then store the item and go away
    if (intval(get_config('system', 'ostatus_poll_interval')) == -2 and count($item) > 0) {
        //$arr["app"] .= " (OStatus-NoCompletion)";
        $item_stored = item_store($item, true);
        return $item_stored;
    }
    // Get the parent
    $parents = q("SELECT `id`, `parent`, `uri`, `contact-id`, `type`, `verb`, `visible` FROM `item` WHERE `id` IN\n\t\t\t(SELECT `parent` FROM `item` WHERE `id` IN\n\t\t\t\t(SELECT `oid` FROM `term` WHERE `uid` = %d AND `otype` = %d AND `type` = %d AND `url` = '%s'))", intval($uid), intval(TERM_OBJ_POST), intval(TERM_CONVERSATION), dbesc($conversation_url));
    if ($parents) {
        $parent = $parents[0];
    } elseif (count($item) > 0) {
        $parent = $item;
        $parent["type"] = "remote";
        $parent["verb"] = ACTIVITY_POST;
        $parent["visible"] = 1;
    } else {
        // Preset the parent
        $r = q("SELECT `id` FROM `contact` WHERE `self` AND `uid`=%d", $uid);
        if (!$r) {
            return -2;
        }
        $parent = array();
        $parent["id"] = 0;
        $parent["parent"] = 0;
        $parent["uri"] = "";
        $parent["contact-id"] = $r[0]["id"];
        $parent["type"] = "remote";
        $parent["verb"] = ACTIVITY_POST;
        $parent["visible"] = 1;
    }
    $conv = str_replace("/conversation/", "/api/statusnet/conversation/", $conversation_url) . ".as";
    $pageno = 1;
    $items = array();
    logger('fetching conversation url ' . $conv . ' for user ' . $uid);
    do {
        $conv_arr = z_fetch_url($conv . "?page=" . $pageno);
        // If it is a non-ssl site and there is an error, then try ssl or vice versa
        if (!$conv_arr["success"] and substr($conv, 0, 7) == "http://") {
            $conv = str_replace("http://", "https://", $conv);
            $conv_as = fetch_url($conv . "?page=" . $pageno);
        } elseif (!$conv_arr["success"] and substr($conv, 0, 8) == "https://") {
            $conv = str_replace("https://", "http://", $conv);
            $conv_as = fetch_url($conv . "?page=" . $pageno);
        } else {
            $conv_as = $conv_arr["body"];
        }
        $conv_as = str_replace(',"statusnet:notice_info":', ',"statusnet_notice_info":', $conv_as);
        $conv_as = json_decode($conv_as);
        if (@is_array($conv_as->items)) {
            $items = array_merge($items, $conv_as->items);
        } else {
            break;
        }
        $pageno++;
    } while (true);
    logger('fetching conversation done. Found ' . count($items) . ' items');
    if (!sizeof($items)) {
        if (count($item) > 0) {
            //$arr["app"] .= " (OStatus-NoConvFetched)";
            $item_stored = item_store($item, true);
            if ($item_stored) {
                logger("Conversation " . $conversation_url . " couldn't be fetched. Item uri " . $item["uri"] . " stored: " . $item_stored, LOGGER_DEBUG);
                ostatus_store_conversation($item_id, $conversation_url);
            }
            return $item_stored;
        } else {
            return -3;
        }
    }
    $items = array_reverse($items);
    $r = q("SELECT `nurl` FROM `contact` WHERE `uid` = %d AND `self`", intval($uid));
    $importer = $r[0];
    foreach ($items as $single_conv) {
        // Test - remove before flight
        //$tempfile = tempnam(get_temppath(), "conversation");
        //file_put_contents($tempfile, json_encode($single_conv));
        $mention = false;
        if (isset($single_conv->object->id)) {
            $single_conv->id = $single_conv->object->id;
        }
        $plink = ostatus_convert_href($single_conv->id);
        if (isset($single_conv->object->url)) {
            $plink = ostatus_convert_href($single_conv->object->url);
        }
        if (@(!$single_conv->id)) {
            continue;
        }
        logger("Got id " . $single_conv->id, LOGGER_DEBUG);
        if ($first_id == "") {
            $first_id = $single_conv->id;
            // The first post of the conversation isn't our first post. There are three options:
            // 1. Our conversation hasn't the "real" thread starter
            // 2. This first post is a post inside our thread
            // 3. This first post is a post inside another thread
            if ($first_id != $parent["uri"] and $parent["uri"] != "") {
                $new_parents = q("SELECT `id`, `parent`, `uri`, `contact-id`, `type`, `verb`, `visible` FROM `item` WHERE `id` IN\n\t\t\t\t\t\t\t(SELECT `parent` FROM `item`\n\t\t\t\t\t\t\t\tWHERE `uid` = %d AND `uri` = '%s' AND `network` IN ('%s','%s')) LIMIT 1", intval($uid), dbesc($first_id), dbesc(NETWORK_OSTATUS), dbesc(NETWORK_DFRN));
                if ($new_parents) {
                    if ($new_parents[0]["parent"] == $parent["parent"]) {
                        // Option 2: This post is already present inside our thread - but not as thread starter
                        logger("Option 2: uri present in our thread: " . $first_id, LOGGER_DEBUG);
                        $first_id = $parent["uri"];
                    } else {
                        // Option 3: Not so good. We have mixed parents. We have to see how to clean this up.
                        // For now just take the new parent.
                        $parent = $new_parents[0];
                        $first_id = $parent["uri"];
                        logger("Option 3: mixed parents for uri " . $first_id, LOGGER_DEBUG);
                    }
                } else {
                    // Option 1: We hadn't got the real thread starter
                    // We have to clean up our existing messages.
                    $parent["id"] = 0;
                    $parent["uri"] = $first_id;
                    logger("Option 1: we have a new parent: " . $first_id, LOGGER_DEBUG);
                }
            } elseif ($parent["uri"] == "") {
                $parent["id"] = 0;
                $parent["uri"] = $first_id;
            }
        }
        $parent_uri = $parent["uri"];
        // "context" only seems to exist on older servers
        if (isset($single_conv->context->inReplyTo->id)) {
            $parent_exists = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s' AND `network` IN ('%s','%s') LIMIT 1", intval($uid), dbesc($single_conv->context->inReplyTo->id), dbesc(NETWORK_OSTATUS), dbesc(NETWORK_DFRN));
            if ($parent_exists) {
                $parent_uri = $single_conv->context->inReplyTo->id;
            }
        }
        // This is the current way
        if (isset($single_conv->object->inReplyTo->id)) {
            $parent_exists = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s' AND `network` IN ('%s','%s') LIMIT 1", intval($uid), dbesc($single_conv->object->inReplyTo->id), dbesc(NETWORK_OSTATUS), dbesc(NETWORK_DFRN));
            if ($parent_exists) {
                $parent_uri = $single_conv->object->inReplyTo->id;
            }
        }
        $message_exists = q("SELECT `id`, `parent`, `uri` FROM `item` WHERE `uid` = %d AND `uri` = '%s' AND `network` IN ('%s','%s') LIMIT 1", intval($uid), dbesc($single_conv->id), dbesc(NETWORK_OSTATUS), dbesc(NETWORK_DFRN));
        if ($message_exists) {
            logger("Message " . $single_conv->id . " already existed on the system", LOGGER_DEBUG);
            if ($parent["id"] != 0) {
                $existing_message = $message_exists[0];
                // We improved the way we fetch OStatus messages, this shouldn't happen very often now
                // To-Do: we have to change the shadow copies as well. This way here is really ugly.
                if ($existing_message["parent"] != $parent["id"]) {
                    logger('updating id ' . $existing_message["id"] . ' with parent ' . $existing_message["parent"] . ' to parent ' . $parent["id"] . ' uri ' . $parent["uri"] . ' thread ' . $parent_uri, LOGGER_DEBUG);
                    // Update the parent id of the selected item
                    $r = q("UPDATE `item` SET `parent` = %d, `parent-uri` = '%s' WHERE `id` = %d", intval($parent["id"]), dbesc($parent["uri"]), intval($existing_message["id"]));
                    // Update the parent uri in the thread - but only if it points to itself
                    $r = q("UPDATE `item` SET `thr-parent` = '%s' WHERE `id` = %d AND `uri` = `thr-parent`", dbesc($parent_uri), intval($existing_message["id"]));
                    // try to change all items of the same parent
                    $r = q("UPDATE `item` SET `parent` = %d, `parent-uri` = '%s' WHERE `parent` = %d", intval($parent["id"]), dbesc($parent["uri"]), intval($existing_message["parent"]));
                    // Update the parent uri in the thread - but only if it points to itself
                    $r = q("UPDATE `item` SET `thr-parent` = '%s' WHERE (`parent` = %d) AND (`uri` = `thr-parent`)", dbesc($parent["uri"]), intval($existing_message["parent"]));
                    // Now delete the thread
                    delete_thread($existing_message["parent"]);
                }
            }
            // The item we are having on the system is the one that we wanted to store via the item array
            if (isset($item["uri"]) and $item["uri"] == $existing_message["uri"]) {
                $item = array();
                $item_stored = 0;
            }
            continue;
        }
        if (is_array($single_conv->to)) {
            foreach ($single_conv->to as $to) {
                if ($importer["nurl"] == normalise_link($to->id)) {
                    $mention = true;
                }
            }
        }
        $actor = $single_conv->actor->id;
        if (isset($single_conv->actor->url)) {
            $actor = $single_conv->actor->url;
        }
        $contact = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `network` != '%s'", $uid, normalise_link($actor), NETWORK_STATUSNET);
        if (count($contact)) {
            logger("Found contact for url " . $actor, LOGGER_DEBUG);
            $contact_id = $contact[0]["id"];
        } else {
            logger("No contact found for url " . $actor, LOGGER_DEBUG);
            // Adding a global contact
            // To-Do: Use this data for the post
            $global_contact_id = get_contact($actor, 0);
            logger("Global contact " . $global_contact_id . " found for url " . $actor, LOGGER_DEBUG);
            $contact_id = $parent["contact-id"];
        }
        $arr = array();
        $arr["network"] = NETWORK_OSTATUS;
        $arr["uri"] = $single_conv->id;
        $arr["plink"] = $plink;
        $arr["uid"] = $uid;
        $arr["contact-id"] = $contact_id;
        $arr["parent-uri"] = $parent_uri;
        $arr["created"] = $single_conv->published;
        $arr["edited"] = $single_conv->published;
        $arr["owner-name"] = $single_conv->actor->displayName;
        if ($arr["owner-name"] == '') {
            $arr["owner-name"] = $single_conv->actor->contact->displayName;
        }
        if ($arr["owner-name"] == '') {
            $arr["owner-name"] = $single_conv->actor->portablecontacts_net->displayName;
        }
        $arr["owner-link"] = $actor;
        $arr["owner-avatar"] = $single_conv->actor->image->url;
        $arr["author-name"] = $arr["owner-name"];
        $arr["author-link"] = $actor;
        $arr["author-avatar"] = $single_conv->actor->image->url;
        $arr["body"] = add_page_info_to_body(html2bbcode($single_conv->content));
        if (isset($single_conv->status_net->notice_info->source)) {
            $arr["app"] = strip_tags($single_conv->status_net->notice_info->source);
        } elseif (isset($single_conv->statusnet->notice_info->source)) {
            $arr["app"] = strip_tags($single_conv->statusnet->notice_info->source);
        } elseif (isset($single_conv->statusnet_notice_info->source)) {
            $arr["app"] = strip_tags($single_conv->statusnet_notice_info->source);
        } elseif (isset($single_conv->provider->displayName)) {
            $arr["app"] = $single_conv->provider->displayName;
        } else {
            $arr["app"] = "OStatus";
        }
        //$arr["app"] .= " (Conversation)";
        $arr["object"] = json_encode($single_conv);
        $arr["verb"] = $parent["verb"];
        $arr["visible"] = $parent["visible"];
        $arr["location"] = $single_conv->location->displayName;
        $arr["coord"] = trim($single_conv->location->lat . " " . $single_conv->location->lon);
        // Is it a reshared item?
        if (isset($single_conv->verb) and $single_conv->verb == "share" and isset($single_conv->object)) {
            if (is_array($single_conv->object)) {
                $single_conv->object = $single_conv->object[0];
            }
            logger("Found reshared item " . $single_conv->object->id);
            // $single_conv->object->context->conversation;
            if (isset($single_conv->object->object->id)) {
                $arr["uri"] = $single_conv->object->object->id;
            } else {
                $arr["uri"] = $single_conv->object->id;
            }
            if (isset($single_conv->object->object->url)) {
                $plink = ostatus_convert_href($single_conv->object->object->url);
            } else {
                $plink = ostatus_convert_href($single_conv->object->url);
            }
            if (isset($single_conv->object->object->content)) {
                $arr["body"] = add_page_info_to_body(html2bbcode($single_conv->object->object->content));
            } else {
                $arr["body"] = add_page_info_to_body(html2bbcode($single_conv->object->content));
            }
            $arr["plink"] = $plink;
            $arr["created"] = $single_conv->object->published;
            $arr["edited"] = $single_conv->object->published;
            $arr["author-name"] = $single_conv->object->actor->displayName;
            if ($arr["owner-name"] == '') {
                $arr["author-name"] = $single_conv->object->actor->contact->displayName;
            }
            $arr["author-link"] = $single_conv->object->actor->url;
            $arr["author-avatar"] = $single_conv->object->actor->image->url;
            $arr["app"] = $single_conv->object->provider->displayName . "#";
            //$arr["verb"] = $single_conv->object->verb;
            $arr["location"] = $single_conv->object->location->displayName;
            $arr["coord"] = trim($single_conv->object->location->lat . " " . $single_conv->object->location->lon);
        }
        if ($arr["location"] == "") {
            unset($arr["location"]);
        }
        if ($arr["coord"] == "") {
            unset($arr["coord"]);
        }
        // Copy fields from given item array
        if (isset($item["uri"]) and ($item["uri"] == $arr["uri"] or $item["uri"] == $single_conv->id)) {
            $copy_fields = array("owner-name", "owner-link", "owner-avatar", "author-name", "author-link", "author-avatar", "gravity", "body", "object-type", "object", "verb", "created", "edited", "coord", "tag", "title", "attach", "app", "type", "location", "contact-id", "uri");
            foreach ($copy_fields as $field) {
                if (isset($item[$field])) {
                    $arr[$field] = $item[$field];
                }
            }
            //$arr["app"] .= " (OStatus)";
        }
        $newitem = item_store($arr);
        if (!$newitem) {
            logger("Item wasn't stored " . print_r($arr, true), LOGGER_DEBUG);
            continue;
        }
        if (isset($item["uri"]) and $item["uri"] == $arr["uri"]) {
            $item = array();
            $item_stored = $newitem;
        }
        logger('Stored new item ' . $plink . ' for parent ' . $arr["parent-uri"] . ' under id ' . $newitem, LOGGER_DEBUG);
        // Add the conversation entry (but don't fetch the whole conversation)
        ostatus_store_conversation($newitem, $conversation_url);
        if ($mention) {
            $u = q("SELECT `notify-flags`, `language`, `username`, `email` FROM user WHERE uid = %d LIMIT 1", intval($uid));
            $r = q("SELECT `parent` FROM `item` WHERE `id` = %d", intval($newitem));
            notification(array('type' => NOTIFY_TAGSELF, 'notify_flags' => $u[0]["notify-flags"], 'language' => $u[0]["language"], 'to_name' => $u[0]["username"], 'to_email' => $u[0]["email"], 'uid' => $uid, 'item' => $arr, 'link' => $a->get_baseurl() . '/display/' . urlencode(get_item_guid($newitem)), 'source_name' => $arr["author-name"], 'source_link' => $arr["author-link"], 'source_photo' => $arr["author-avatar"], 'verb' => ACTIVITY_TAG, 'otype' => 'item', 'parent' => $r[0]["parent"]));
        }
        // If the newly created item is the top item then change the parent settings of the thread
        // This shouldn't happen anymore. This is supposed to be absolote.
        if ($arr["uri"] == $first_id) {
            logger('setting new parent to id ' . $newitem);
            $new_parents = q("SELECT `id`, `uri`, `contact-id`, `type`, `verb`, `visible` FROM `item` WHERE `uid` = %d AND `id` = %d LIMIT 1", intval($uid), intval($newitem));
            if ($new_parents) {
                $parent = $new_parents[0];
            }
        }
    }
    if ($item_stored < 0 and count($item) > 0) {
        //$arr["app"] .= " (OStatus-NoConvFound)";
        $item_stored = item_store($item, true);
        if ($item_stored) {
            logger("Uri " . $item["uri"] . " wasn't found in conversation " . $conversation_url, LOGGER_DEBUG);
            ostatus_store_conversation($item_stored, $conversation_url);
        }
    }
    return $item_stored;
}
Exemplo n.º 7
0
function m_delete_post_func($xmlrpc_params)
{
    global $input, $post, $thread, $forum, $pid, $tid, $fid, $modlogdata, $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups, $moderation, $parser;
    $input = Tapatalk_Input::filterXmlInput(array('post_id' => Tapatalk_Input::INT, 'mode' => Tapatalk_Input::INT, 'reason_text' => Tapatalk_Input::STRING), $xmlrpc_params);
    // Load global language phrases
    $lang->load("editpost");
    $plugins->run_hooks("editpost_start");
    // No permission for guests
    if (!$mybb->user['uid']) {
        error_no_permission();
    }
    // Get post info
    $pid = intval($input['post_id']);
    $query = $db->simple_select("posts", "*", "pid='{$pid}'");
    $post = $db->fetch_array($query);
    if (!$post['pid']) {
        error($lang->error_invalidpost);
    }
    // Get thread info
    $tid = $post['tid'];
    $thread = get_thread($tid);
    if (!$thread['tid']) {
        error($lang->error_invalidthread);
    }
    // Get forum info
    $fid = $post['fid'];
    $forum = get_forum($fid);
    if (!$forum || $forum['type'] != "f") {
        error($lang->error_closedinvalidforum);
    }
    if ($forum['open'] == 0 || $mybb->user['suspendposting'] == 1) {
        error_no_permission();
    }
    $forumpermissions = forum_permissions($fid);
    if (!is_moderator($fid, "candeleteposts")) {
        if ($thread['closed'] == 1) {
            error($lang->redirect_threadclosed);
        }
        if ($forumpermissions['candeleteposts'] == 0) {
            error_no_permission();
        }
        if ($mybb->user['uid'] != $post['uid']) {
            error_no_permission();
        }
    }
    // Check if this forum is password protected and we have a valid password
    check_forum_password($forum['fid']);
    $plugins->run_hooks("editpost_deletepost");
    $modlogdata['fid'] = $fid;
    $modlogdata['tid'] = $tid;
    $query = $db->simple_select("posts", "pid", "tid='{$tid}'", array("limit" => 1, "order_by" => "dateline", "order_dir" => "asc"));
    $firstcheck = $db->fetch_array($query);
    if ($firstcheck['pid'] == $pid) {
        if ($forumpermissions['candeletethreads'] == 1 || is_moderator($fid, "candeletethreads")) {
            delete_thread($tid);
            mark_reports($tid, "thread");
            log_moderator_action($modlogdata, $lang->thread_deleted);
        } else {
            error_no_permission();
        }
    } else {
        if ($forumpermissions['candeleteposts'] == 1 || is_moderator($fid, "candeleteposts")) {
            // Select the first post before this
            delete_post($pid, $tid);
            mark_reports($pid, "post");
            log_moderator_action($modlogdata, $lang->post_deleted);
        } else {
            error_no_permission();
        }
    }
    $response = new xmlrpcval(array('result' => new xmlrpcval(true, 'boolean'), 'is_login_mod' => new xmlrpcval(true, 'boolean'), 'result_text' => new xmlrpcval("", 'base64')), 'struct');
    return new xmlrpcresp($response);
}
Exemplo n.º 8
0
 /**
  * Delete a user in the database
  *
  * @param integer $thread Thread ID
  * @return boolean
  */
 function removeThread($thread)
 {
     $tid = intval($thread);
     $this->lang->load('editpost');
     $deleted = delete_thread($tid);
     mark_reports($tid, "thread");
     $modlogdata['tid'] = $tid;
     $this->logModeratorAction($modlogdata, $this->lang->thread_deleted);
     return $deleted;
 }
        if ($forum->parent_type != 0) {
            error_page("No");
        }
        $fid = post_int('forumid');
        $new_forum = BoincForum::lookup_id($fid);
        $result = move_thread($thread, $forum, $new_forum);
        $action_name = "moved from {$forum->title} to {$new_forum->title}";
        break;
    case "title":
        $new_title = post_str('newtitle');
        $title = BoincDb::escape_string($new_title);
        $result = $thread->update("title='{$title}'");
        $action_name = "renamed from '{$thread->title}' to '{$new_title}'";
        break;
    case "delete":
        delete_thread($thread, $forum);
        page_head("Thread deleted");
        echo "Thread successfully deleted.\n        <p>\n        <a href=forum_forum.php?id={$forum->id}>Return to forum</a>\n    ";
        page_tail();
        exit;
    default:
        error_page("Unknown action");
}
if (!$result) {
    error_page("Moderation failed");
}
$reason = post_str('reason', true);
if (!$reason) {
    $reason = "None given";
}
send_thread_moderation_email($forum, $thread, $reason, $action_name, $explanation);
Exemplo n.º 10
0
 /**
  * Deletes a thread
  *
  * @param	boolean	Whether to consider updating post counts, regardless of forum's settings
  * @param	boolean	Whether to physically remove the thread from the database
  * @param	array	Array of information for a soft delete
  * @param	boolean	Whether to add an entry to the moderator log
  *
  * @return	mixed	The number of affected rows
  */
 function delete($countposts = true, $physicaldel = true, $delinfo = NULL, $dolog = true)
 {
     if ($threadid = $this->existing['threadid']) {
         require_once DIR . '/includes/functions_databuild.php';
         require_once DIR . "/vb/search/core.php";
         ($hook = vBulletinHook::fetch_hook('threaddata_delete')) ? eval($hook) : false;
         // Search index maintenance
         if ($physicaldel) {
             require_once DIR . '/includes/class_taggablecontent.php';
             $content = vB_Taggable_Content_Item::create($this->registry, "vBForum_Thread", $threadid);
             $content->delete_tag_attachments();
             //don't queue this, it needs to run before the thread records are deleted.
             $indexcontroller = vB_Search_Core::get_instance()->get_index_controller('vBForum', 'Post');
             $indexcontroller->delete_thread($threadid);
         }
         // note: the skip_moderator_log is the inverse of the $dolog argument
         return delete_thread($threadid, $countposts, $physicaldel, $delinfo, $this->info['skip_moderator_log'] !== null ? !$this->info['skip_moderator_log'] : $dolog, $this->existing);
     }
     return false;
 }
Exemplo n.º 11
0
 /**
 Remove the group's forums from the game
 */
 public function remove_forums()
 {
     if ($this->info['fid']) {
         $forumquery = $this->db->simple_select('forums', '*', 'fid = ' . $this->info['fid']);
         while ($forum = $this->db->fetch_array($forumquery)) {
             //Move prefix to parent board
             $prefixquery = $this->db->simple_select('threadprefixes', '*', 'CONCAT(\',\',forums,\',\') LIKE \'%,' . $this->info['fid'] . ',%\'');
             while ($prefix = $this->db->fetch_array($prefixquery)) {
                 $forums = explode(',', $prefix['forums']);
                 foreach ($forums as $f) {
                     $forumstring .= $f !== $this->info['fid'] ? $f . ',' : $forum['pid'] . ',';
                 }
                 $this->db->update_query('threadprefixes', array('forums' => trim($forumstring, ',')), 'pid = ' . $prefix['pid']);
             }
             //Move threads to parent board
             $threadquery = $this->db->simple_select('threads', '*', 'fid = ' . $this->info['fid']);
             while ($thread = $this->db->fetch_array($threadquery)) {
                 $threadstring .= $thread['tid'];
             }
             if (!empty($threadstring)) {
                 $this->db->update_query('threads', array('fid' => $forum['pid']), 'tid IN (' . $threadstring . ')');
                 $this->db->update_query('posts', array('fid' => $forum['pid']), 'tid IN (' . $threadstring . ')');
                 update_forum_lastpost($forum['pid']);
             }
         }
         //Delete MO forum
         $this->db->query('DELETE FROM ' . TABLE_PREFIX . 'forums WHERE fid = ' . $this->info['mo_fid']);
         $threadquery = $this->db->simple_select('threads', '*', 'fid = ' . $this->info['mo_fid']);
         while ($thread = $this->db->fetch_array($threadquery)) {
             delete_thread($thread['tid']);
         }
         //Delete all permissions
         $this->db->query('DELETE FROM ' . TABLE_PREFIX . 'forumpermissions WHERE fid = ' . $this->info['mo_fid']);
         $this->db->query('DELETE FROM ' . TABLE_PREFIX . 'moderators WHERE fid = ' . $this->info['mo_fid']);
         $this->db->query('DELETE FROM ' . TABLE_PREFIX . 'moderators WHERE fid = ' . $this->info['fid']);
         //Delete forum
         $this->db->query('DELETE FROM ' . TABLE_PREFIX . 'forums WHERE fid = ' . $this->info['fid']);
     }
     $this->cache->update_forums();
     $this->cache->update_moderators();
     $this->cache->update_forumpermissions();
     $this->cache->update_threadprefixes();
 }
Exemplo n.º 12
0
 // Verify incoming POST request
 verify_post_check($mybb->input['my_post_key']);
 $plugins->run_hooks("editpost_deletepost");
 if ($mybb->input['delete'] == 1) {
     $query = $db->simple_select("posts", "pid", "tid='{$tid}'", array("limit" => 1, "order_by" => "dateline", "order_dir" => "asc"));
     $firstcheck = $db->fetch_array($query);
     if ($firstcheck['pid'] == $pid) {
         $firstpost = 1;
     } else {
         $firstpost = 0;
     }
     $modlogdata['fid'] = $fid;
     $modlogdata['tid'] = $tid;
     if ($firstpost) {
         if ($forumpermissions['candeletethreads'] == 1 || is_moderator($fid, "candeletethreads")) {
             delete_thread($tid);
             mark_reports($tid, "thread");
             log_moderator_action($modlogdata, $lang->thread_deleted);
             redirect(get_forum_link($fid), $lang->redirect_threaddeleted);
         } else {
             error_no_permission();
         }
     } else {
         if ($forumpermissions['candeleteposts'] == 1 || is_moderator($fid, "candeleteposts")) {
             // Select the first post before this
             delete_post($pid, $tid);
             mark_reports($pid, "post");
             log_moderator_action($modlogdata, $lang->post_deleted);
             $query = $db->simple_select("posts", "pid", "tid='{$tid}' AND dateline <= '{$post['dateline']}'", array("limit" => 1, "order_by" => "dateline", "order_dir" => "desc"));
             $next_post = $db->fetch_array($query);
             if ($next_post['pid']) {
Exemplo n.º 13
0
 $db->query('DELETE FROM ' . $db->prefix . 'thread_subscriptions WHERE user_id=' . $id) or error('Unable to delete thread subscriptions', __FILE__, __LINE__, $db->error());
 $db->query('DELETE FROM ' . $db->prefix . 'forum_subscriptions WHERE user_id=' . $id) or error('Unable to delete forum subscriptions', __FILE__, __LINE__, $db->error());
 // Remove him/her from the online list (if they happen to be logged in)
 $db->query('DELETE FROM ' . $db->prefix . 'online WHERE user_id=' . $id) or error('Unable to remove user from online list', __FILE__, __LINE__, $db->error());
 // Should we delete all comments made by this user?
 if (isset($_POST['delete_comments'])) {
     require LUNA_ROOT . 'include/search_idx.php';
     @set_time_limit(0);
     // Find all comments made by this user
     $result = $db->query('SELECT p.id, p.thread_id, t.forum_id FROM ' . $db->prefix . 'comments AS p INNER JOIN ' . $db->prefix . 'threads AS t ON t.id=p.thread_id INNER JOIN ' . $db->prefix . 'forums AS f ON f.id=t.forum_id WHERE p.commenter_id=' . $id) or error('Unable to fetch comments', __FILE__, __LINE__, $db->error());
     if ($db->num_rows($result)) {
         while ($cur_comment = $db->fetch_assoc($result)) {
             // Determine whether this comment is the "thread comment" or not
             $result2 = $db->query('SELECT id FROM ' . $db->prefix . 'comments WHERE thread_id=' . $cur_comment['thread_id'] . ' ORDER BY commented LIMIT 1') or error('Unable to fetch comment info', __FILE__, __LINE__, $db->error());
             if ($db->result($result2) == $cur_comment['id']) {
                 delete_thread($cur_comment['thread_id']);
             } else {
                 delete_comment($cur_comment['id'], $cur_comment['thread_id'], $id);
             }
             update_forum($cur_comment['forum_id']);
         }
     }
 } else {
     // Set all his/her comments to guest
     $db->query('UPDATE ' . $db->prefix . 'comments SET commenter_id=1 WHERE commenter_id=' . $id) or error('Unable to update comments', __FILE__, __LINE__, $db->error());
 }
 // Delete the user
 $db->query('DELETE FROM ' . $db->prefix . 'users WHERE id=' . $id) or error('Unable to delete user', __FILE__, __LINE__, $db->error());
 // Delete user avatar
 delete_avatar($id);
 // Regenerate the users info cache
    $tr = $db->get_thread($vars['thread_id']);
    $db->delete_thread($vars['thread_id']);
    $t->assign('msg', "Thread deleted");
    $t->assign('link', 'newsletter_threads.php');
    $t->display("admin/newsletter_thread_saved.html");
}
//////////////////// main ////////////////////////////////////////
$vars = get_input_vars();
if ($vars['thread_id']) {
    $t->assign('thread_id', $vars['thread_id']);
}
switch ($vars['action']) {
    case 'new':
        display_form();
        break;
    case 'create':
        create_thread($vars);
        break;
    case 'edit':
        display_edit_form();
        break;
    case 'update':
        update_thread($vars);
        break;
    case 'delete':
        delete_thread();
        break;
    default:
        display_threads_list();
        break;
}