Ejemplo n.º 1
0
 /**
  * @param array pParams hash of values that will be used to store the page
  * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why
  * @access public
  **/
 function store(&$pParamHash)
 {
     if ($this->verify($pParamHash)) {
         $this->mDb->StartTrans();
         $storeComment = new LibertyComment(@BitBase::verifyId($pParamHash['comment_id']) ? $pParamHash['comment_id'] : NULL);
         if ($this->verifyId($storeComment->mCommentId)) {
             $this->mDb->query("DELETE FROM `" . BIT_DB_PREFIX . "itags_image_areas` WHERE `attachment_id`=? and `comment_id`=?", array($this->mAttachmentId, $storeComment->mCommentId));
         }
         if ($storeComment->storeComment($pParamHash['comment'])) {
             // store successful
             $storeComment->loadComment();
             $this->mDb->query("INSERT INTO `" . BIT_DB_PREFIX . "itags_image_areas` ( `attachment_id`, `comment_id`, `itag_top`, `itag_left`, `itag_width`, `itag_height` )\n\t\t\t\t\tVALUES ( ?, ?, ?, ?, ?, ? )", array($this->mAttachementId, $storeComment->mCommentId, $pParamHash['top'], $pParamHash['left'], $pParamHash['width'], $pParamHash['height']));
         }
         $this->mDb->CompleteTrans();
         $this->load();
     }
     return count($this->mErrors) == 0;
 }
Ejemplo n.º 2
0
}
if (!empty($moduleParams['module_rows'])) {
    $listHash['max_records'] = $moduleParams['module_rows'];
} elseif (!empty($moduleParams['module_params']['max_records'])) {
    $listHash['max_records'] = $moduleParams['module_params']['max_records'];
}
if (!empty($moduleParams['module_params']['user_id'])) {
    $listHash['user_id'] = $moduleParams['module_params']['user_id'];
} else {
    $listHash['user_id'] = $gQueryUser->mUserId;
}
$statuses = feed_get_status($listHash);
$_template->tpl_vars['statuses'] = new Smarty_variable($statuses);
foreach ($statuses as $status) {
    $commentContentId = 'comment_' . $status['content_id'];
    if (!empty($_REQUEST[$commentContentId])) {
        //then there is a reply to this comment and break, we only handle one at a time
        $reply = new LibertyComment();
        $pParamHash['root_id'] = $status['content_id'];
        $pParamHash['parent_id'] = $status['content_id'];
        $pParamHash['comment_data'] = $_REQUEST[$commentContentId];
        $pParamHash['title'] = substr($_REQUEST[$commentContentId], 0, 20);
        $reply->storeComment($pParamHash);
        $statuses = feed_get_status($listHash);
        $_template->tpl_vars['statuses'] = new Smarty_variable($statuses);
        break;
    }
}
?>

Ejemplo n.º 3
0
 /**
  * This function moves a topic to a new messageboard
  */
 function moveTo($board_id)
 {
     // start transaction
     $this->StartTrans();
     // create a new comment letting people know it has beem moved
     $lcom = new LibertyComment();
     $lcom_hash['edit'] = "The comments from: {$this->mInfo['title']} ({$this->mRootId}) have been is_moved to {$board_id}";
     $lcom_hash['title'] = $this->mInfo['title'];
     $lcom_hash['parent_id'] = $this->mInfo['th_root_id'];
     $lcom_hash['root_id'] = $this->mInfo['th_root_id'];
     $lcom_hash['created'] = $this->mInfo['flc_created'];
     $lcom_hash['last_modified'] = $this->mInfo['flc_last_modified'];
     $lcom->storeComment($lcom_hash);
     // map the move to the topic table
     $data = array();
     $data['parent_id'] = $lcom->mContentId;
     $data['is_moved'] = $this->mRootId;
     $this->mDb->associateInsert(BIT_DB_PREFIX . "boards_topics", $data);
     // move the comment we want to move to the target board
     $query = "UPDATE `" . BIT_DB_PREFIX . "liberty_comments` SET `root_id` = ?, `parent_id` = ?\n\t\t\t\t  WHERE `thread_forward_sequence` LIKE '" . sprintf("%09d.", $this->mRootId) . "%' AND `root_id`=`parent_id`";
     $result = $this->mDb->query($query, array($board_id, $board_id));
     $query = "UPDATE `" . BIT_DB_PREFIX . "liberty_comments` SET `root_id` = ?\n\t\t\t\t  WHERE `thread_forward_sequence` LIKE '" . sprintf("%09d.", $this->mRootId) . "%'";
     $result = $this->mDb->query($query, array($board_id));
     // end transaction
     $this->CompleteTrans();
     return TRUE;
 }
Ejemplo n.º 4
0
/**
 * $pMsgHeader is a imap_headerinfo generated array
 **/
function board_sync_process_message($pMbox, $pMsgNum, $pMsgHeader, $pMsgStructure, $pModerate = FALSE, $pLog = FALSE, $pDeliveredTo = NULL)
{
    global $gBitSystem, $gBitDb;
    // vd( $pMsgHeader );
    // Collect a bit of header information
    $message_id = board_sync_get_headerinfo($pMsgHeader, 'message_id');
    // @TODO comment or clean up, not sure why this is here -wjames5
    if (empty($message_id)) {
        $message_id = board_sync_get_headerinfo($pMsgHeader, 'message_id');
    }
    $subject = board_sync_get_headerinfo($pMsgHeader, 'Subject');
    if (empty($message_id)) {
        bit_error_log("Email sync for message: " . $subject . " failed: No Message Id in mail header.");
    } else {
        if ($pLog) {
            print "Processing: " . $message_id . "\n";
        }
        if ($pLog) {
            print "  Subject: " . $subject . "\n";
        }
        $matches = array();
        $toAddresses = array();
        $allRecipients = "";
        if (empty($pDeliveredTo)) {
            if (isset($pMsgHeader->toaddress)) {
                $allRecipients .= $pMsgHeader->toaddress;
                if ($pLog) {
                    print "  To addresses: " . $pMsgHeader->toaddress . "\n";
                }
            }
            if (isset($pMsgHeader->ccaddress)) {
                $allRecipients .= ($allRecipients != "" ? "," : "") . $pMsgHeader->ccaddress;
                if ($pLog) {
                    print "  CC addresses: " . $pMsgHeader->ccaddress . "\n";
                }
            }
            if ($pLog) {
                print "  All Recipients: " . $allRecipients . "\n";
            }
            $allSplit = split(',', $allRecipients);
            foreach ($allSplit as $s) {
                $s = trim($s);
                $matches = array();
                if (strpos($s, '<') !== FALSE) {
                    if (preg_match("/\\s*(.*)\\s*<\\s*(.*)\\s*>/", $s, $matches)) {
                        $toAddresses[] = array('name' => $matches[1], 'email' => $matches[2]);
                    } elseif (preg_match('/<\\s*(.*)\\s*>\\s*(.*)\\s*/', $s, $matches)) {
                        $toAddresses[] = array('email' => $matches[1], 'name' => $matches[2]);
                    }
                } elseif (validate_email_syntax($s)) {
                    $toAddresses[] = array('email' => $s);
                }
            }
        } else {
            foreach ($pDeliveredTo as $address) {
                $toAddresses[] = array('email' => $address);
            }
        }
        if ($pLog) {
            print_r($toAddresses);
        }
        $date = board_sync_get_headerinfo($pMsgHeader, 'Date');
        $from = board_sync_get_headerinfo($pMsgHeader, 'from');
        $fromaddress = $from[0]->mailbox . "@" . $from[0]->host;
        // personal is not always defined.
        if (isset($from[0]->personal)) {
            $personal = ucwords($from[0]->personal);
        } else {
            $personal = null;
        }
        $in_reply_to = board_sync_get_headerinfo($pMsgHeader, 'in_reply_to');
        if ($pLog) {
            print "\n---- " . date("Y-m-d HH:mm:ss") . " -------------------------\nImporting: " . $message_id . "\nDate: " . $date . "\nFrom: " . $fromaddress . "\nTo: " . $allRecipients . "\nSubject: " . $subject . "\nIn Reply To: " . $in_reply_to . "\nName: " . $personal . (is_array($pDeliveredTo) ? "\nDelivered-To:" . implode(", ", $pDeliveredTo) : '') . "\n";
        }
        foreach ($toAddresses as $to) {
            if ($pLog) {
                print "  Processing email: " . strtolower($to['email']) . "\n";
            }
            // get a board match for the email address
            if ($boardContentId = cache_check_content_prefs('board_sync_list_address', strtolower($to['email']), TRUE)) {
                if ($pLog) {
                    print "Found Board Content {$boardContentId} for {$to['email']}\n";
                }
                // Do we already have this message in this board?
                $contentId = NULL;
                if ($message_id != NULL) {
                    $sql = "SELECT `content_id` FROM `" . BIT_DB_PREFIX . "liberty_comments` WHERE `message_guid`=? AND `root_id`=?";
                    $contentId = $gBitDb->getOne($sql, array($message_id, $boardContentId));
                }
                if (empty($contentId)) {
                    if (!empty($in_reply_to)) {
                        if ($parent = $gBitDb->GetRow("SELECT `content_id`, `root_id` FROM `" . BIT_DB_PREFIX . "liberty_comments` WHERE `message_guid`=?", array($in_reply_to))) {
                            $replyId = $parent['content_id'];
                            $rootId = $parent['root_id'];
                        } else {
                            if ($pLog) {
                                print "WARNING: Reply to unfound message: " . $in_reply_to;
                            }
                            $replyId = $boardContentId;
                            $rootId = $boardContentId;
                        }
                        // if no reply to message guid then match on title - this looks dangerous as titles could easily be duplicated -wjames
                    } elseif ($parent = $gBitDb->GetRow("SELECT lcom.`content_id`, lcom.`root_id` FROM `" . BIT_DB_PREFIX . "liberty_comments` lcom INNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON(lcom.`content_id`=lc.`content_id`) WHERE lc.`title`=?", array(preg_replace('/re: /i', '', $subject)))) {
                        $replyId = $parent['content_id'];
                        $rootId = $parent['root_id'];
                        // attach to board as first level comment e.g. new topic
                    } else {
                        $replyId = $boardContentId;
                        $rootId = $boardContentId;
                    }
                    $userInfo = board_sync_get_user($fromaddress);
                    // prep the storage hash
                    $storeRow = array();
                    $storeRow['created'] = strtotime($date);
                    $storeRow['last_modified'] = $storeRow['created'];
                    $storeRow['user_id'] = $userInfo['user_id'];
                    $storeRow['modifier_user_id'] = $userInfo['user_id'];
                    $storeRow['title'] = $subject;
                    $storeRow['message_guid'] = $message_id;
                    if ($userInfo['user_id'] == ANONYMOUS_USER_ID && !empty($personal)) {
                        $storeRow['anon_name'] = $personal;
                    }
                    $storeRow['root_id'] = $rootId;
                    $storeRow['parent_id'] = $replyId;
                    $partHash = array();
                    switch ($pMsgStructure->type) {
                        case '0':
                            if ($pLog) {
                                print "Structure Type: text\n";
                            }
                            board_parse_msg_parts($partHash, $pMbox, $pMsgNum, $pMsgStructure, 1, $pLog);
                            break;
                        case '1':
                            if ($pLog) {
                                print "Structure Type: multipart\n";
                            }
                            if ($pModerate) {
                                $prefix = '2.';
                            } else {
                                $prefix = '';
                            }
                            foreach ($pMsgStructure->parts as $partNum => $part) {
                                board_parse_msg_parts($partHash, $pMbox, $pMsgNum, $part, $prefix . ($partNum + 1), $pLog);
                            }
                            break;
                    }
                    $plainBody = "";
                    $htmlBody = "";
                    foreach (array_keys($partHash) as $i) {
                        if (!empty($partHash[$i]['plain'])) {
                            $plainBody .= $partHash[$i]['plain'];
                        }
                        if (!empty($partHash[$i]['html'])) {
                            $htmlBody .= $partHash[$i]['html'];
                        }
                        if (!empty($partHash[$i]['attachment'])) {
                            $storeRow['_files_override'][] = array('tmp_name' => $partHash[$i]['attachment'], 'type' => $gBitSystem->verifyMimeType($partHash[$i]['attachment']), 'size' => filesize($partHash[$i]['attachment']), 'name' => basename($partHash[$i]['attachment']), 'user_id' => $userInfo['user_id']);
                        }
                    }
                    if (!empty($htmlBody)) {
                        $storeRow['edit'] = $htmlBody;
                        $storeRow['format_guid'] = 'bithtml';
                    } elseif (!empty($plainBody)) {
                        $storeRow['edit'] = nl2br($plainBody);
                        $storeRow['format_guid'] = 'bithtml';
                    }
                    // Nuke all email addresses from the body.
                    if (!empty($storeRow['edit'])) {
                        $storeRow['edit'] = ereg_replace('[-!#$%&\\`*+\\./0-9=?A-Z^_`a-z{|}~]+' . '@' . '(localhost|[-!$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\\.' . '[-!$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+)', '', $storeRow['edit']);
                    }
                    // We trust the user from this source
                    // and count on moderation to handle links
                    global $gBitUser;
                    $gBitUser->setPermissionOverride('p_liberty_trusted_editor', true);
                    // Check to add attachments
                    // NOTE: we temporarily change the gBitUser here!
                    // This is so we can run a proper content permissions check
                    // for attachment permission against the parent
                    // board object. This is sort of a hack to deal
                    // with the fact that LibertyContent does not have a
                    // means to check the permissions of any user except gBitUser -wjames5
                    // Important store a reference so we can switch back when we are done
                    $gBitUserOrg = $gBitUser;
                    // Load the message sending user
                    if ($userInfo['user_id'] != ANONYMOUS_USER_ID) {
                        $userClass = $gBitSystem->getConfig('user_class', 'BitPermUser');
                        $newBitUser = new $userClass($userInfo['user_id']);
                        $newBitUser->load(TRUE);
                    }
                    if (!empty($newBitUser) && $newBitUser->isValid()) {
                        // flip gBitUser to our message sender
                        $gBitUser = $newBitUser;
                    }
                    // Load the parent board
                    $board = new BitBoard(NULL, $boardContentId);
                    $board->load();
                    // Check the permission for the user on the board
                    if ($gBitSystem->isFeatureActive('comments_allow_attachments') && $board->hasUserPermission('p_liberty_attach_attachments')) {
                        // note we grant the permission to the anonymous user which will become gBitUser once again
                        $gBitUserOrg->setPermissionOverride('p_liberty_attach_attachments', true);
                    }
                    // Clear the reference to this board so we dont mistakenly use it later
                    unset($board);
                    // Important: switch gBitUser back!
                    $gBitUser = $gBitUserOrg;
                    // End check to add attachments to comments to the parent board
                    // Check for an empty body
                    // Duplicate subject if we have it
                    if (empty($storeRow['edit'])) {
                        if (!empty($storeRow['title'])) {
                            $storeRow['edit'] = $storeRow['title'];
                        } else {
                            $storeRow['edit'] = ".";
                        }
                    }
                    $storeComment = new LibertyComment(NULL);
                    $gBitDb->StartTrans();
                    if ($storeComment->storeComment($storeRow)) {
                        // undo the attachment permission
                        $gBitUser->setPermissionOverride('p_liberty_attach_attachments', false);
                        // set moderation approval
                        if (!$pModerate && $gBitSystem->isPackageActive('moderation') && $gBitSystem->isPackageActive('modcomments')) {
                            global $gModerationSystem, $gBitUser;
                            $moderation = $gModerationSystem->getModeration(NULL, $storeComment->mContentId);
                            if (!empty($moderation)) {
                                // Allow to moderate
                                $gBitUser->setPermissionOverride('p_admin', TRUE);
                                $gModerationSystem->setModerationReply($moderation['moderation_id'], MODERATION_APPROVED);
                                $gBitUser->setPermissionOverride('p_admin', FALSE);
                            }
                        }
                        if (!empty($storeRow['message_guid'])) {
                            // map the message guid to the comment
                            $storeComment->mDb->query("UPDATE `" . BIT_DB_PREFIX . "liberty_comments` SET `message_guid`=? WHERE `content_id`=?", array($storeRow['message_guid'], $storeComment->mContentId));
                            // Store the confirm code
                            if ($pModerate) {
                                $storeComment->storePreference('board_confirm_code', $pModerate);
                            }
                            // done
                            $gBitDb->CompleteTrans();
                            return TRUE;
                        } else {
                            bit_error_log("Email sync error: Message Id not set. You shouldn't have even gotten this far.");
                            $gBitDb->RollbackTrans();
                            return FALSE;
                        }
                    } else {
                        if (count($storeComment->mErrors) == 1 && !empty($storeComment->mErrors['store']) && $storeComment->mErrors['store'] == 'Duplicate comment.') {
                            return TRUE;
                        } else {
                            foreach ($storeComment->mErrors as $error) {
                                bit_error_log($error);
                            }
                            $gBitDb->RollbackTrans();
                            return FALSE;
                        }
                    }
                } else {
                    if ($pLog) {
                        print "Message Exists: {$contentId} : {$boardContentId} : {$message_id} : {$pModerate}\n";
                    }
                    // If this isn't a moderation message
                    if ($pModerate === FALSE) {
                        // If the message exists it must have been approved via some
                        // moderation mechanism, so make sure it is available
                        if ($gBitSystem->isPackageActive('moderation') && $gBitSystem->isPackageActive('modcomments')) {
                            global $gModerationSystem, $gBitUser;
                            $storeComment = new LibertyComment(NULL, $contentId);
                            $storeComment->loadComment();
                            if ($storeComment->mInfo['content_status_id'] > 0) {
                                if ($pLog) {
                                    print "Already approved: {$contentId}\n";
                                }
                            } else {
                                $moderation = $gModerationSystem->getModeration(NULL, $contentId);
                                //				vd($moderation);
                                if (!empty($moderation)) {
                                    $gBitUser->setPermissionOverride('p_admin', TRUE);
                                    if ($pLog) {
                                        print "Setting approved: {$contentId}\n";
                                    }
                                    $gModerationSystem->setModerationReply($moderation['moderation_id'], MODERATION_APPROVED);
                                    $gBitUser->setPermissionOverride('p_admin', FALSE);
                                    if ($pLog) {
                                        print "Done";
                                    }
                                } else {
                                    if ($pLog) {
                                        print "ERROR: Unable to find moderation to approve for: {$contentId}";
                                    }
                                }
                            }
                        }
                    } else {
                        // Store the approve code;
                        if ($pLog) {
                            print "Storing approval code: " . $contentId . ":" . $pModerate . "\n";
                        }
                        $storeComment = new LibertyComment(NULL, $contentId);
                        $storeComment->storePreference('board_confirm_code', $pModerate);
                    }
                    return TRUE;
                }
            } else {
                if ($pLog) {
                    print "No Board match found for {$to['email']}\n";
                }
            }
        }
    }
    return FALSE;
}
Ejemplo n.º 5
0
 // check for !anon_post before logging in (auto-fill can hork things up)
 if (empty($_REQUEST['anon_post']) && !empty($_REQUEST['login_email']) && !empty($_REQUEST['login_password'])) {
     $gBitUser->login($_REQUEST['login_email'], $_REQUEST['login_password']);
     if (!empty($gBitUser->mErrors['login'])) {
         $formfeedback['error'][] = $gBitUser->mErrors['login'];
     }
 } else {
     if (!empty($_REQUEST['comment_name'])) {
         $_REQUEST['anon_name'] = $_REQUEST['comment_name'];
     }
 }
 // this commentsParentId is some crazy ass business - lets prepare for the day when this can be removed
 // there are references to it in LibertyComments::verifyComments as well
 $_REQUEST['comments_parent_id'] = $commentsParentId;
 $storeComment = new LibertyComment(@BitBase::verifyId($editComment->mCommentId) ? $editComment->mCommentId : NULL);
 if (empty($formfeedback['error']) && $storeComment->storeComment($_REQUEST)) {
     // store successful
     $storeComment->loadComment();
     if (empty($_REQUEST['post_comment_id']) && $gBitSystem->isPackageActive('switchboard')) {
         // A new comment, and we have switchboard to send notifications
         global $gSwitchboardSystem;
         // Draft the message:
         $message['subject'] = tra('New comment on:') . ' ' . $gContent->getTitle() . ' @ ' . $gBitSystem->getConfig('site_title');
         $message['message'] = tra('A new message was posted to ') . ' ' . $gContent->getTitle() . "<br/>\n" . $gContent->getDisplayUri() . "<br/>\n" . '/----- ' . tra('Here is the message') . " -----/<br/>\n<br/>\n" . '<h2>' . $storeComment->getTitle() . "</h2>\n" . tra('By') . ' ' . $gBitUser->getDisplayName() . "\n<p>" . $storeComment->parseData() . '</p>';
         $gSwitchboardSystem->sendEvent('My Content', 'new comment', $gContent->mContentId, $message);
     }
     $postComment = NULL;
 } else {
     // store fails handle errors and preview
     $formfeedback['error'] = array_merge($formfeedback['error'], $storeComment->mErrors);
     $postComment['data'] = !empty($_REQUEST['comment_data']) ? $_REQUEST['comment_data'] : '';
Ejemplo n.º 6
0
function migrate_phpbb_topic($pTopicId, &$pRootComment)
{
    global $db;
    $sql = "SELECT bbp.*, bbpt.* FROM " . POSTS_TABLE . " bbp\n\t\t\t\tINNER JOIN " . POSTS_TEXT_TABLE . " bbpt ON(bbpt.post_id=bbp.post_id)  \n\t\t\t\tINNER JOIN " . TOPICS_TABLE . " bbt ON(bbt.topic_id=bbp.topic_id)  \n\t\t\tWHERE bbp.topic_id={$pTopicId} AND bbp.post_id != bbt.topic_first_post_id\n\t\t\tORDER BY bbp.post_time ";
    if (!($result = $db->sql_query($sql))) {
        message_die(GENERAL_ERROR, "Could not obtain topic/post information.", '', __LINE__, __FILE__, $sql);
    }
    while ($row = $db->sql_fetchrow($result)) {
        print "Migrating Post {$row['post_id']}<br/>\n";
        $commentHash = array();
        $commentHash['root_id'] = $pRootComment->getField('root_id');
        $commentHash['parent_id'] = $pRootComment->getField('content_id');
        $commentHash['anon_name'] = $row['post_username'];
        $commentHash['title'] = $row['post_subject'];
        $commentHash['edit'] = $row['post_text'];
        $commentHash['format_guid'] = 'bbcode';
        $commentHash['created'] = $row['post_time'];
        $commentHash['last_modified'] = $row['post_edit_time'];
        $commentHash['user_id'] = $row['poster_id'];
        $commentHash['modifier_user_id'] = $row['poster_id'];
        $commentHash['ip'] = decode_ip($row['poster_ip']);
        $newComment = new LibertyComment();
        if ($newComment->storeComment($commentHash)) {
            $postHash['migrate_post_id'] = $row['post_id'];
            $newPost = new BitBoardPost($newComment->mCommentId);
            $newPost->store($postHash);
        } else {
            vd($row);
            vd($commentHash);
            vd($newComment->mErrors);
            die;
        }
    }
}
Ejemplo n.º 7
0
function migrate_wp_comments()
{
    global $wpdb, $gBitSystem, $gBitSmarty, $gUserMap, $gErrorMap, $gBlogMap, $gPostMap, $gCommentMap, $gMaxComment;
    //  vd("Blog Map");
    //  vd($gBlogMap);
    //  vd("Post Map");
    //  vd($gPostMap);
    //  vd("User map");
    //  vd($gUserMap);
    $query = "select * from " . $wpdb->table_prefix . "wp_comments WHERE comment_type = '' AND comment_id > {$gMaxComment} ORDER BY comment_id";
    $comments = $wpdb->get_results($query);
    if (!empty($comments)) {
        foreach ($comments as $comment) {
            //    vd($comment);
            $pParamHash = array();
            $pParamHash['edit'] = wptexturize(convert_chars(wpautop($comment->comment_content)));
            if (empty($comment->user_id)) {
                $pParamHash['annon_name'] = $comment->comment_author;
            } else {
                if (empty($gUserMap[$comment->user_id])) {
                    $pParamHash['owner_id'] = 1;
                    $gErrorMap[]['warning'] = "Comment: " . $comment->comment_ID . " author defaulted to Administrator.";
                } else {
                    $pParamHash['owner_id'] = $gUserMap[$comment->user_id];
                    $pParamHash['current_owner_id'] = -1;
                }
            }
            if ($comment->comment_approved) {
                $pParamHash['content_status'] = 50;
            } else {
                $pParamHash['content_status'] = -1;
            }
            $pParamHash['last_modified'] = $gBitSystem->mServerTimestamp->getTimestampFromIso($comment->comment_date_gmt);
            if (!empty($gPostMap[$comment->comment_post_ID])) {
                $pParamHash['root_id'] = $gPostMap[$comment->comment_post_ID];
                $pParamHash['parent_id'] = $gPostMap[$comment->comment_post_ID];
            } else {
                $gErrorMap[]['error'] = "Comment: Unable to map to post_id: " . $comment->comment_ID . " : Post ID: " . $comment->comment_post_ID;
            }
            $c = new LibertyComment();
            $c->storeComment($pParamHash);
            if (!empty($c->mContentId)) {
                $gCommentMap[$comment->comment_ID] = $c->mContentId;
                $query = "UPDATE liberty_content set IP = ?, created = ? WHERE content_id = ?";
                $gBitSystem->mDb->query($query, array($comment->comment_author_IP, $pParamHash['last_modified'], $c->mContentId));
            } else {
                $gErrorMap[]['error'] = "Coment: Unable to store: " . $comment->comment_ID . " : " . implode(", ", $c->mErrors);
            }
        }
    }
    //  vd("Comments Map.");
    //  vd($gCommentMap);
    $sql = "INSERT INTO `" . BIT_DB_PREFIX . "blogs_wp_comments` (`wp_id`, `comment_id`) VALUES (?, ?)";
    foreach ($gCommentMap as $wp_id => $comment_id) {
        if ($wp_id > $gMaxComment) {
            $gBitSystem->mDb->query($sql, array($wp_id, $comment_id));
        }
    }
}