Esempio n. 1
0
 function board_comments_moderation($pModerationInfo)
 {
     if ($pModerationInfo['type'] == 'comment_post') {
         $storeComment = new LibertyComment(NULL, $pModerationInfo['content_id']);
         $storeComment->load();
         $comments_return_url = '';
         $root_id = $storeComment->mInfo['root_id'];
         global $gContent;
         $board = new BitBoard(NULL, $root_id);
         $board->load();
         $boardSync = $board->getPreference('board_sync_list_address');
         $code = $storeComment->getPreference('board_confirm_code');
         $approved = $board->getPreference('boards_mailing_list_password');
         // Possible race. Did we beat the cron?
         if (empty($code)) {
             require_once BOARDS_PKG_PATH . 'admin/boardsync_inc.php';
             // Try to pick up the message!
             board_sync_run(TRUE);
         }
         if (!empty($code) && !empty($boardSync) && !empty($approved)) {
             $boardSync = str_replace('@', '-request@', $boardSync);
             $code = 'confirm ' . $code;
             require_once KERNEL_PKG_PATH . 'BitMailer.php';
             $mailer = new BitMailer();
             if ($pModerationInfo['last_status'] == MODERATION_DELETE) {
                 // Send a reject message
                 $mailer->sendEmail($code, '', $boardSync, array('sender' => BitBoard::getBoardSyncInbox()));
             } else {
                 // Send an accept message
                 $mailer->sendEmail($code, '', $boardSync, array('sender' => BitBoard::getBoardSyncInbox(), 'x_headers' => array('Approved' => $approved)));
             }
         }
     }
 }
Esempio n. 2
0
function migrate_phpbb()
{
    global $gBitDb, $gBitSystem, $gLibertySystem, $db;
    if (!$gLibertySystem->isPluginActive('bbcode')) {
        $gLibertySystem->setActivePlugin('bbcode');
        $gLibertySystem->scanAllPlugins();
        if (!class_exists('HTML_BBCodeParser')) {
            print "bbcode format plugin is not active. make sure you have installed Pear Text_Wiki_BBCode with: <br/><code>pear install Text_Wiki_BBCode-alpha</code>";
            die;
        }
    }
    require_once LIBERTY_PKG_PATH . 'plugins/format.bithtml.php';
    if (ini_get('max_execution_time') < 300) {
        print "Your max_execution_time in your php.ini is set to " . ini_get('max_execution_time') . " seconds. We recommend you increase that.";
    }
    if (empty($_POST['Migrate'])) {
        print '<form method="POST"><input type="submit" name="Migrate" value="Migrate"/></form>';
        die;
    }
    $gBitDb->StartTrans();
    if ($forumList = $gBitDb->getAssoc("SELECT `forum_id`,`forum_name`, `forum_desc`,`content_id` FROM " . FORUMS_TABLE . " bbf LEFT JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON (lc.`content_type_guid`='bitboard' AND bbf.`forum_name`=lc.`title`) ORDER BY bbf.forum_id")) {
        vd($forumList);
        flush();
        foreach (array_keys($forumList) as $forumId) {
            print "Migrating forum {$forumId}<br/>\n";
            flush();
            if (empty($forumList[$forumId]['content_id'])) {
                $forumStore = array();
                $forumStore['user_id'] = ROOT_USER_ID;
                $forumStore['title'] = $forumList[$forumId]['forum_name'];
                $forumStore['edit'] = $forumList[$forumId]['forum_desc'];
                $forumStore['migrate_board_id'] = $forumId;
                $forumStore['format_guid'] = 'bbcode';
                $newBoard = new BitBoard();
                if ($newBoard->store($forumStore)) {
                    $contentId = $newBoard->mContentId;
                    if ($gBitSystem->isPackageActive('pigeonholes')) {
                        // add board to pigeonhole category that should already be created...
                    }
                } else {
                    vd($newBoard->mErrors);
                }
            } else {
                $contentId = $forumList[$forumId]['content_id'];
            }
            if (!empty($contentId)) {
                migrate_phpbb_forum($forumId, $contentId);
            } else {
                vd("NO content_id for forum {$forumId}");
            }
        }
    }
    $gBitDb->CompleteTrans();
}
Esempio n. 3
0
     case 'bitboard':
     default:
         // board specific
         if ($gBitUser->isRegistered()) {
             if (!empty($feed['track']['on']) && $feed['track']['mod']) {
                 $item->title = "[NEW] " . $item->title;
             }
         }
         if (!empty($feed['th_sticky'])) {
             $item->title = "[!] " . $item->title;
         }
         if (!empty($feed['th_locked'])) {
             $item->title = "[#] " . $item->title;
         }
         $item->link = 'http://' . $_SERVER['HTTP_HOST'] . $feed['url'];
         $data = BitBoard::getBoard($feed['llc_content_id']);
         $item->description = $data['data'];
         //TODO allow proper sort order
         //$item->date = ( int )$feed['event_date'];
         $item->date = (int) $feed['llc_last_modified'];
         $user = new BitUser($feed['llc_user_id']);
         break;
 }
 $user->load();
 $item->author = $user->getDisplayName();
 //$gBitUser->getDisplayName( FALSE, array( 'user_id' => $feed['modifier_user_id'] ) );
 $item->authorEmail = $user->mInfo['email'];
 $item->descriptionTruncSize = $gBitSystem->getConfig('rssfeed_truncate', 1000);
 $item->descriptionHtmlSyndicated = FALSE;
 /*
 	var_dump($item);
Esempio 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;
}
Esempio n. 5
0
// Is package installed and enabled
$gBitSystem->verifyPackage('boards');
// Look up Topic (lookup_inc is universal, gContent == BitBoardTopic)
require_once BOARDS_PKG_PATH . 'lookup_inc.php';
// Make sure topic exists since we only run through here for existing topics. New topics are created via comment system.
if (!$gContent->isValid()) {
    $gBitSystem->fatalError('No topic specified');
}
// Load up the Topic's board - we'll respect its permissions
$board = new BitBoard($gContent->mInfo['board_id']);
$board->load();
$board->verifyAdminPermission();
if (isset($_REQUEST["target"])) {
    // Check the user's ticket
    $gBitUser->verifyTicket();
    $targetBoard = new BitBoard(null, $_REQUEST["target"]);
    $targetBoard->load();
    if (!$targetBoard->hasAdminPermission()) {
        $gBitSystem->fatalError('You do not have permission to move topics to the Board' . $targetBoard->mInfo['title']);
    }
    if ($gContent->moveTo($_REQUEST["target"])) {
        bit_redirect($gContent->getDisplayUrl());
    } else {
        $gBitSystem->fatalError("There was an error moving the topic: " . vc($gContent->mErrors));
    }
}
// get list of boards we can move the topic to
$boards = $board->getBoardSelectList();
$gBitSmarty->assignByRef('boards', $boards);
$gBitSmarty->assign('fromBoardId', $board->mContentId);
$gBitSystem->display('bitpackage:boards/topic_move.tpl', tra('Move Topic') . ':' . $gContent->getTitle(), array('display_mode' => 'display'));
Esempio n. 6
0
 * Copyright (c) 2004 bitweaver Messageboards
 * All Rights Reserved. See below for details and a complete list of authors.
 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details.
 * @package boards
 * @subpackage functions
 */
/**
 * required setup
 */
require_once '../kernel/setup_inc.php';
// Is package installed and enabled
$gBitSystem->verifyPackage('boards');
// if we're getting a migrate id then lets move on right away
if (@BitBase::verifyId($_REQUEST['migrate_board_id'])) {
    require_once BOARDS_PKG_PATH . 'BitBoard.php';
    if ($_REQUEST['b'] = BitBoard::lookupByMigrateBoard($_REQUEST['migrate_board_id'])) {
        bit_redirect(BOARDS_PKG_URL . 'index.php?b=' . $_REQUEST['b']);
    }
}
// Load up the board
require_once BOARDS_PKG_PATH . 'lookup_inc.php';
if (!$gContent->isValid()) {
    $gBitSystem->fatalError("The board you requested could not be found. <a href='" . BOARDS_PKG_URL . "'>View all boards</a>", NULL, NULL, HttpStatusCodes::HTTP_GONE);
}
// approve or reject ananymous comments
if (!empty($_REQUEST['action'])) {
    // Check edit perms on the group
    $gContent->verifyUpdatePermission();
    // Check the ticket
    $gBitUser->verifyTicket();
    // Load up the comment as a board post
Esempio n. 7
0
            foreach ($content_ids as $content_id => $remove) {
                if ($remove) {
                    $b->removeContent($content_id);
                }
            }
        } else {
            // @TODO assign error and report back to user which were not processed
        }
    }
}
if (!empty($_REQUEST['assign']) && @BitBase::verifyId($_REQUEST['to_board_id'])) {
    $b = new BitBoard($_REQUEST['to_board_id']);
    $b->load();
    if ($b->verifyUpdatePermission()) {
        foreach ($_REQUEST['assign'] as $content_id) {
            $b->addContent($content_id);
        }
    }
}
if (!empty($_REQUEST['integrity'])) {
    $board_id = $_REQUEST['integrity'];
    $b = new BitBoard($board_id);
    $b->load();
    if ($b->verifyUpdatePermission()) {
        $b->fixContentMap();
    }
}
$data = BitBoard::getAllMap();
$gBitSmarty->assignByRef('data', $data);
// Display the template
$gBitSystem->display('bitpackage:boards/board_assign.tpl', tra('Assign content to Board'), array('display_mode' => 'display'));
Esempio n. 8
0
 private function UpdateCastlingBitmaps()
 {
     $this->nCalls++;
     $this->n64WhiteCastle->set_value('0x0');
     $this->n64BlackCastle->set_value('0x0');
     // If white king or black king are in check, then castling isn't possible;
     if ($this->PlayerTurn == 0 && $this->nStatus == CHESS_BOARD_STATUS::CHECK) {
         $this->n64WhiteCastle->set_value('0x0');
         return;
     } else {
         if ($this->PlayerTurn == 1 && $this->nStatus == CHESS_BOARD_STATUS::CHECK) {
             $this->n64BlackCastle->set_value('0x0');
             return;
         }
     }
     // NOTE: Limit to updating the castling bitboards to the next side to move because these bitboards
     // are only valid for the next move.
     // Need to check columns 2,3 and 5,6 for ranks 0 and 7 to see if they are empty and not attacked.
     if ($this->fCastleWQueenside) {
         if (BitBoard::_AND_($this->n64All, $this->n64WhiteCastleQFree)->is_zero()) {
             $bitmap = $this->FindAttacksToTile(0, 2)->_AND($this->n64BAll);
             if ($bitmap->is_zero()) {
                 $bitmap = $this->FindAttacksToTile(0, 3)->_AND($this->n64BAll);
                 if ($bitmap->is_zero()) {
                     $this->n64WhiteCastle->_OR($this->Tiles[2]);
                 }
             }
         }
     }
     if ($this->fCastleWKingside) {
         if (BitBoard::_AND_($this->n64All, $this->n64WhiteCastleKFree)->is_zero()) {
             $bitmap = $this->FindAttacksToTile(0, 5)->_AND($this->n64BAll);
             if ($bitmap->is_zero()) {
                 $bitmap = $this->FindAttacksToTile(0, 6)->_AND($this->n64BAll);
                 if ($bitmap->is_zero()) {
                     $this->n64WhiteCastle->_OR($this->Tiles[6]);
                 }
             }
         }
     }
     if ($this->fCastleBQueenside) {
         if (BitBoard::_AND_($this->n64All, $this->n64BlackCastleQFree)->is_zero()) {
             $bitmap = $this->FindAttacksToTile(7, 2)->_AND($this->n64WAll);
             if ($bitmap->is_zero()) {
                 $bitmap = $this->FindAttacksToTile(7, 3)->_AND($this->n64WAll);
                 if ($bitmap->is_zero()) {
                     $this->n64BlackCastle->_OR($this->Tiles[58]);
                 }
             }
         }
     }
     if ($this->fCastleBKingside) {
         if (BitBoard::_AND_($this->n64All, $this->n64BlackCastleKFree)->is_zero()) {
             $bitmap = $this->FindAttacksToTile(7, 5)->_AND($this->n64WAll);
             if ($bitmap->is_zero()) {
                 $bitmap = $this->FindAttacksToTile(7, 6)->_AND($this->n64WAll);
                 if ($bitmap->is_zero()) {
                     $this->n64BlackCastle->_OR($this->Tiles[62]);
                 }
             }
         }
     }
 }
Esempio n. 9
0
<?php

/**
 * @package boards
 * @subpackage functions
 */
/**
 * required setup
 */
require_once BOARDS_PKG_PATH . 'BitBoardTopic.php';
require_once BOARDS_PKG_PATH . 'BitBoardPost.php';
require_once BOARDS_PKG_PATH . 'BitBoard.php';
// if t supplied, use that
if (@BitBase::verifyId($_REQUEST['t'])) {
    $gContent = new BitBoardTopic($_REQUEST['t']);
    // if p supplied, use that
} elseif (@BitBase::verifyId($_REQUEST['p'])) {
    $gContent = new BitBoardPost($_REQUEST['p']);
} elseif (@BitBase::verifyId($_REQUEST['b'])) {
    $gContent = new BitBoard($_REQUEST['b']);
} elseif (isset($_REQUEST['p'])) {
    $gContent = new BitBoardPost();
    // otherwise create new object
} elseif (isset($_REQUEST['t']) || isset($_REQUEST['migrate_topic_id']) || isset($_REQUEST['migrate_post_id'])) {
    $gContent = new BitBoardTopic();
} else {
    $gContent = new BitBoard();
}
$gContent->load();
$gBitSmarty->assignByRef("gContent", $gContent);
Esempio n. 10
0
 function getAllMap()
 {
     $b = new BitBoard();
     $listHash = array();
     $l = $b->getList($listHash);
     $ret = array();
     foreach ($l as $k => $boardd) {
         $board = new BitBoard($boardd['board_id']);
         $board->mInfo = $boardd;
         $ret['map'][$k] = $boardd;
         $ret['map'][$k]['map'] = $board->getMap();
         $ret['map'][$k]['integrity'] = $board->verifyIntegrity();
     }
     // reorganise unmapped content for better display
     $umapped = $b->getUnMapped();
     foreach ($umapped as $key => $content) {
         $umap[$content['content_name']][$key] = $content;
     }
     $ret['umap'] = $umap;
     return $ret;
 }
Esempio n. 11
0
                }
            }
        }
        $ns[] = $d_o;
    }
}
// get our boards list
$ret = array();
if ($gBitSystem->isPackageActive('pigeonholes')) {
    //	$ret['data']['title']="Uncategorised Boards";
} else {
    //	$ret['data']['title']="Board List";
}
$ret['children'] = array();
$listHash = array('nboards' => $board_all_cids, 'paginationOff' => 'y');
$board = new BitBoard();
$ret['members'] = $board->getList($listHash);
if (count($ret['members']) == 1) {
    $_REQUEST['b'] = $ret['members'][0]['board_id'];
    require BOARDS_PKG_PATH . 'view_board_inc.php';
    die;
} elseif (count($ret['members']) > 0) {
    $ns[] = $ret;
}
$gBitSmarty->assignByRef('ns', $ns);
// this might be for getting a count of nested boards - not entirely sure, if you figure it out please clarify this comment.
function countBoards(&$a)
{
    $s = count($a['members']);
    foreach ($a['children'] as $k => $c) {
        $n = countBoards($a['children'][$k]);
Esempio n. 12
0
            //Moderate
            $comment->loadMetaData();
            $comment->modWarn($_REQUEST['warning_message']);
        default:
            break;
    }
}
// Finally - load up our topic
$thread = new BitBoardTopic($_REQUEST['t']);
$thread->load();
if (!$thread->isValid()) {
    $gBitSystem->fatalError(tra("Unknown discussion"), NULL, NULL, HttpStatusCodes::HTTP_GONE);
}
$thread->verifyViewPermission();
// load up the root board we need it
$gBoard = new BitBoard(null, $thread->mInfo['board_content_id']);
$gBoard->load();
$gBitSmarty->assignByRef('board', $gBoard);
// force root board to be gContent
$gContent =& $gBoard;
$gBitSmarty->assignByRef('gContent', $gContent);
// if you know what this is please comment it
if (empty($thread->mInfo['th_root_id'])) {
    if ($_REQUEST['action'] == 3) {
        //Invalid as a result of rejecting the post, redirect to the board
        bit_redirect($gBoard->getDisplayUrl());
    } else {
        $gBitSystem->fatalError(tra("Invalid topic selection."), NULL, NULL, HttpStatusCodes::HTTP_GONE);
    }
}
// Invoke services
Esempio n. 13
0
 */
require_once '../kernel/setup_inc.php';
require_once BOARDS_PKG_PATH . 'BitBoardTopic.php';
require_once BOARDS_PKG_PATH . 'BitBoardPost.php';
require_once BOARDS_PKG_PATH . 'BitBoard.php';
require_once BOARDS_PKG_PATH . 'lookup_inc.php';
require_once UTIL_PKG_PATH . 'mailman_lib.php';
// Is package installed and enabled
$gBitSystem->verifyPackage('boards');
// Verify we found a board
if (!$gContent->isValid()) {
    $gBitSystem->fatalError(tra("Error: No such board."));
}
// Now check permissions to access this page
$gContent->verifyViewPermission();
if ($boardSyncInbox = BitBoard::getBoardSyncInbox()) {
    $gBitSmarty->assign('boardSyncInbox', $boardSyncInbox);
}
if (!empty($_REQUEST['create_list'])) {
    //------ Email List ------//
    if (!($error = mailman_newlist(array('listname' => $_REQUEST['boards_mailing_list'], 'admin-password' => $_REQUEST['boards_mailing_list_password'], 'listadmin-addr' => $gBitUser->getField('email'))))) {
        $gContent->storePreference('boards_mailing_list', !empty($_REQUEST['boards_mailing_list']) ? $_REQUEST['boards_mailing_list'] : NULL);
        $gContent->storePreference('boards_mailing_list_password', $_REQUEST['boards_mailing_list_password']);
    } else {
        $gBitSmarty->assign('errorMsg', $error);
    }
    //		if( $gContent->getPreference( 'boards_mailing_list' ) && $_REQUEST['boards_mailing_list'] != $gContent->getPreference( 'boards_mailing_list' ) ) {
    // Name change
    //			groups_mailman_rename( $gContent->getPreference( 'boards_mailing_list' ), $_REQUEST['boards_mailing_list'] );
    //		}
} elseif (!empty($_REQUEST['delete_list'])) {
Esempio n. 14
0
/**
 * required setup
 */
require_once '../kernel/setup_inc.php';
// Is package installed and enabled
$gBitSystem->verifyPackage('boards');
// Look up Topic (lookup_inc is universal, gContent == BitBoardTopic)
require_once BOARDS_PKG_PATH . 'lookup_inc.php';
// Make sure topic exists since we only run through here for existing topics. New topics are created via comment system.
if (!$gContent->isValid()) {
    $gBitSystem->fatalError(tra('No topic specified.'));
}
// Check the user's ticket
$gBitUser->verifyTicket();
// Load up the Topic's board - we'll respect its permissions
$board = new BitBoard($gContent->mInfo['board_id']);
$board->load();
$rslt = false;
// Edit calls
// Set locked or sticky
if (isset($_REQUEST['is_locked']) || isset($_REQUEST['is_sticky'])) {
    // Check permissions to edit this topic
    $board->verifyUpdatePermission();
    if (isset($_REQUEST['is_locked']) && is_numeric($_REQUEST['is_locked'])) {
        $rslt = $gContent->lock($_REQUEST['is_locked']);
    } elseif (isset($_REQUEST['is_sticky']) && is_numeric($_REQUEST['is_sticky'])) {
        $rslt = $gContent->sticky($_REQUEST['is_sticky']);
    }
    // Remove a topic
} elseif (isset($_REQUEST['remove'])) {
    // Check permissions to edit this topic if the root object is the board check its perms, otherwise check general comment admin perms
Esempio n. 15
0
 /**
  * get the group's affiliated baord
  * 
  * get the oldest board associated with the group, which was automagically created when 
  * the group was created. If we ever want to support associating multiple boards 
  * with a group then how to deal with that would have to be handled here.
  */
 function getBoard()
 {
     if ($this->isValid() && !is_object($this->mBoardObj)) {
         $boardId = false;
         if (!empty($this->mInfo['board_id'])) {
             $boardId = $this->mInfo['board_id'];
         } else {
             // exists in case we ever want to allow groups to have more than one board
             // for now load should get the board_id
             $listHash = array("connect_group_content_id" => $this->mContentId, "content_type_guid" => "bitboard", "sort_mode" => "created_asc");
             $boards = $this->getContentList($listHash);
             if ($listHash['cant'] && !empty($boards[0]['board_id'])) {
                 $boardId = $boards[0]['board_id'];
             }
         }
         if ($boardId) {
             require_once BOARDS_PKG_PATH . 'BitBoard.php';
             $board = new BitBoard($boardId);
             $board->load();
             $this->mBoardObj =& $board;
         }
     }
     return $this->mBoardObj;
 }
Esempio n. 16
0
 public function shift_l_($num)
 {
     $bb = new BitBoard();
     $bb->num1 = $this->num1;
     $bb->num2 = $this->num2;
     $bb->num3 = $this->num3;
     $bb->num4 = $this->num4;
     $bb->shift_l($num);
     return $bb;
 }
Esempio n. 17
0
// All Rights Reserved. See below for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details.
// is this used?
//if (isset($_REQUEST["boardset"]) && isset($_REQUEST["homeBitBoards"])) {
//	$gBitSystem->storeConfig("home_bitboard", $_REQUEST["homeBitBoards"]);
//	$gBitSmarty->assign('home_bitboard', $_REQUEST["homeBitBoards"]);
//}
require_once BOARDS_PKG_PATH . 'BitBoard.php';
$formBitBoardsLists = array('boards_thread_track' => array('label' => 'Enable Topic Status Tracking', 'note' => 'Allow users to see what topic have been changed since they last logged on.'), 'boards_thread_notification' => array('label' => 'Enable Topic Reply Notification', 'note' => 'Allow users to be sent emails when topics they are interested in receive replies.'), 'boards_posts_anon_moderation' => array('label' => 'Require Anonymous Post Moderation', 'note' => 'Require that ALL Anonymous posts must be validated before they are shown.'), 'boards_hide_edit_tpl' => array('label' => 'Hide Linked Boards Option', 'note' => 'Hide the <em>Linked Boards</em> option on edit pages to link any given content to a forum thread. If you hide this, you will have to manually assign content to a forum thread if you want to make full use of the boards.'), 'boards_link_by_pigeonholes' => array('label' => 'Link by Pigeonholes', 'note' => 'Link content to boards based on pigeonholes. This is useful when you have only one board in a given pigeonhole and want all content in the same pigeonhole to be shown in the board. Note that you MUST run the following SQL on your database to allow content in more than one board: "alter table boards_map drop constraint boards_map_pkey;" This is therfore a very advanced option.'));
$gBitSmarty->assign('formBitBoardsLists', $formBitBoardsLists);
$formBitBoardsSync = array('boards_sync_mail_server' => array('label' => 'Email Server', 'note' => 'Internet address of your mail server.'), 'boards_sync_user' => array('label' => 'Email Username', 'note' => 'Username used to login to the board sync email account.'), 'boards_sync_password' => array('label' => 'Email Password', 'note' => 'Password used to login to the board sync email account.'));
$gBitSmarty->assign('formBitBoardsSync', $formBitBoardsSync);
$processForm = set_tab();
$formBoardsEmailList = array("boards_email_list" => array('label' => 'Group Email List', 'note' => 'Enable groups to have an associated email list'));
$gBitSmarty->assign('formBoardsEmailList', $formBoardsEmailList);
$formBoardsEmailText = array('boards_email_host', 'boards_email_admin', 'server_mailman_bin', 'server_mailman_cmd', 'server_newaliases_cmd', 'server_aliases_file');
if ($processForm) {
    $bitboardToggles = array_merge($formBitBoardsLists, $formBoardsEmailList);
    foreach ($bitboardToggles as $item => $data) {
        simple_set_toggle($item, BOARDS_PKG_NAME);
    }
    foreach ($formBitBoardsSync as $key => $data) {
        $gBitSystem->storeConfig($key, !empty($_REQUEST[$key]) ? $_REQUEST[$key] : NULL, BOARDS_PKG_NAME);
    }
    foreach ($formBoardsEmailText as $text) {
        $gBitSystem->storeConfig($text, !empty($_REQUEST[$text]) ? trim($_REQUEST[$text]) : NULL, BOARDS_PKG_NAME);
    }
}
$board = new BitBoard();
$boards = $board->getBoardSelectList($_REQUEST);
$gBitSmarty->assignByRef(BOARDS_PKG_NAME, $boards['data']);