Example #1
0
function markUpdatesAsRead()
{
    global $_auth, $_config;
    if ($_config["readOnly"]) {
        // Something selected but we're in the read-only mode?
        notice(_READONLY);
        return false;
    }
    reset($_POST);
    foreach ($_POST as $key => $value) {
        if (preg_match('/^upd\\_/', $key)) {
            $str = preg_replace('/^upd\\_/', "", $key);
            list($type, $obj, $user) = preg_split('/\\_/', $str, 3, PREG_SPLIT_NO_EMPTY);
            markAsRead($type, $obj, 0, $user);
        }
        if (preg_match('/^artupd\\_/', $key)) {
            $objid = preg_replace('/^artupd\\_/', "", $key);
            markAsRead(updTypeArt, $objid);
        }
    }
    // Recount the current user's updates.
    recountAllUpdates($_auth["useid"]);
    // No need to call it, for example, for updTypeMessageClub because
    // updTypeMessageClub is already processed within updTypeMessageWatch
    // (see the recountUpdates() function).
    return true;
}
Example #2
0
if ($config->get($mod, 'enable-subscriptions') == '1') {
    $subenabled = true;
} else {
    $subenabled = false;
}
$smarty->assign('hide_number_of_posts', $config->get('board', 'disable-number-of-posts'));
$smarty->assign('isallowed', $isallowed);
$lang->addModSpecificLocalization($mod);
$breadcrumbs->addElement($lang->get('board'), makeURL($mod));
include $mod_dir . "/board.function.php";
$boardid = isset($_GET['boardid']) ? (int) $_GET['boardid'] : 0;
$threadid = isset($_GET['threadid']) ? (int) $_GET['threadid'] : 0;
$postid = isset($_GET['postid']) ? (int) $_GET['postid'] : 0;
$mode = isset($_GET['mode']) ? $_GET['mode'] : '';
if ($mode == 'mark_as_read') {
    markAsRead($boardid);
}
if ($boardid == 0) {
    switch ($mode) {
        case 'board_manage':
            if ($isallowed) {
                $breadcrumbs->addElement($lang->get('board_manage'), makeURL($mod, array('mode' => 'board_manage')));
                $groups = $rights->getAllGroups();
                $smarty->assign('groups', $groups);
                if (isset($_POST['save'])) {
                    $add = trim($_POST['board_new']);
                    $d = trim($_POST['description_new']);
                    if ($add != '') {
                        boardAdd($add, $d, $_POST['assigned_groupid_new']);
                    }
                    $bl = boardList();
Example #3
0
function operationUnfav($objid)
{
    global $_auth;
    $objid = intval($objid);
    if ($objid == 0) {
        return;
    }
    // Remove submission from user's favourites.
    $sql = "SELECT * FROM `objects`, `objExtData`" . dbWhere(array("objid" => $objid, "objEid*" => "objid", "objCreator<>" => $_auth["useid"], "objDeleted" => 0, "objPending" => 0));
    $objResult = sql_query($sql);
    if (!($objData = mysql_fetch_assoc($objResult))) {
        include INCLUDES . "p_notfound.php";
        return;
    }
    $sql = "DELETE FROM `favourites`" . dbWhere(array("favCreator" => $_auth["useid"], "favObj" => $objid));
    sql_query($sql);
    // Remove +fav notification from artist(s)' updates.
    markAsRead(updTypeMessageFav, $objData["objid"], $objData["objCreator"]);
    $collab = $objData["objCollabConfirmed"] ? $objData["objCollab"] : 0;
    if ($collab > 0 && $collab != $_auth["useid"]) {
        markAsRead(updTypeMessageFav, $objData["objid"], $collab);
    }
    updateSubmissionFavs($objid);
}
Example #4
0
}
if (isset($_POST["submitVote"]) && !$alreadyVoted) {
    foreach ($options as $optData) {
        if (isset($_POST["option" . $optData["polOid"]])) {
            sql_query("INSERT INTO `pollVotes`(`pollVUser`,`pollVSelected`) " . "VALUES('" . $_auth["useid"] . "','" . $optData["polOid"] . "')");
            // count the overall number of votes for this option
            $result = sql_query("SELECT COUNT(*) FROM `pollVotes` WHERE `pollVSelected` = '" . $optData["polOid"] . "'");
            $count = mysql_result($result, 0);
            sql_query("UPDATE `pollOptions` SET `polOVotes` = '{$count}' WHERE `polOid` = '" . $optData["polOid"] . "' LIMIT 1");
        }
    }
    // count the total number of votes
    $result = sql_query("SELECT SUM(`polOVotes`) FROM `pollOptions` WHERE `polOPoll` = '{$polid}'");
    $totalCount = mysql_result($result, 0);
    sql_query("UPDATE `polls` SET `polVoted` = '{$totalCount}' WHERE `polid` = '{$polid}' LIMIT 1");
    markAsRead(updTypeJournalPoll, $polid);
    redirect(url("poll/" . $useUsername . "/" . $polid));
}
$_pollUser = 0;
$_documentTitle = $useData["useUsername"] . ": " . _POLL;
?>

<div class="header">
	<div class="f_right mar_left a_center normaltext">
		<?php 
echo getUserAvatar("", $useData["useid"], true);
?>
	</div>
	<div class="f_left header_title">
		<?php 
echo $useData["useUsername"];
Example #5
0
/**
 * Functions reads the POST data and adds a new comment to the database.
 */
function processCommentReply($objid, $objType)
{
    global $_auth, $_config;
    $noEmoticons = isset($_POST["commentNoEmoticons"]) ? 1 : 0;
    $noSig = isset($_POST["commentNoSig"]) ? 1 : 0;
    $noBBCode = isset($_POST["commentNoBBCode"]) ? 1 : 0;
    $root_objid = $objid;
    $root_objType = $objType;
    $parent_objid = $objid;
    $parent_objType = $objType;
    if ($objType == "com") {
        $comResult = sql_query("SELECT `comRootObj`,`comRootObjType`,`comObj`,`comObjType` " . "FROM `comments`" . dbWhere(array("comid" => $objid)));
        if ($comData = mysql_fetch_row($comResult)) {
            $root_objid = $comData[0];
            $root_objType = $comData[1];
            $parent_objid = $comData[2];
            $parent_objType = $comData[3];
        }
        mysql_free_result($comResult);
        if ($parent_objid != $objid && $parent_objid != $root_objid) {
            $comResult = sql_query("SELECT `comObj`,`comObjType` " . "FROM `comments`" . dbWhere(array("comid" => $parent_objid)));
            if ($comData = mysql_fetch_row($comResult)) {
                $parent_objid = $comData[0];
                $parent_objType = $comData[1];
            }
            mysql_free_result($comResult);
        }
    }
    // 16000 characters maximum.
    $commentText = substr($_POST["comment"], 0, 16000);
    $userIp = getHexIp($_SERVER["REMOTE_ADDR"]);
    // Add the comment to the database.
    sql_query("INSERT INTO `comments`" . dbValues(array("comObj" => $objid, "comObjType" => $objType, "comRootObj" => $root_objid, "comRootObjType" => $root_objType, "comCreator" => $_auth["useid"], "comSubmitDate!" => "NOW()", "comComment" => $commentText, "comSubmitIp" => $userIp, "comEditIp" => $userIp, "comNoEmoticons" => $noEmoticons, "comNoSig" => $noSig, "comNoBBCode" => $noBBCode)));
    $comid = mysql_insert_id();
    // Now let's find out who created the parent object for this comment
    // (that would be a user id).
    $parentCreator = 0;
    switch ($objType) {
        case "obj":
            $collab = 0;
            $result = sql_query("SELECT `objCreator`, `objCollab`, `objCollabConfirmed` " . "FROM `objects`, `objExtData`" . dbWhere(array("objid*" => "objEid", "objid" => $objid)));
            if ($data = mysql_fetch_assoc($result)) {
                $parentCreator = $data["objCreator"];
                $collab = $data["objCollabConfirmed"] ? $data["objCollab"] : 0;
                // Also gather Fan-to-Artist statistics...
                $where = array("fanUser" => $_auth["useid"], "fanArtist" => $parentCreator);
                sql_where($where);
                if (sql_count("fans") == 0) {
                    $where["fanNumComments"] = 1;
                    sql_values($where);
                    sql_insert("fans");
                } else {
                    sql_where($where);
                    sql_values(array("fanNumComments!" => "`fanNumComments` + 1"));
                    sql_update("fans");
                }
                if ($collab > 0) {
                    $where = array("fanUser" => $_auth["useid"], "fanArtist" => $collab);
                    sql_where($where);
                    if (sql_count("fans") == 0) {
                        $where["fanNumComments"] = 1;
                        sql_values($where);
                        sql_insert("fans");
                    } else {
                        sql_where($where);
                        sql_values(array("fanNumComments!" => "`fanNumComments` + 1"));
                        sql_update("fans");
                    }
                }
            }
            // If this submission is in user's updates, mark it as viewed
            // automatically.
            markAsRead(updTypeArt, $objid);
            updateSearchCache($objid);
            if ($collab > 0 && $collab != $_auth["useid"]) {
                addUpdate(updTypeComment, $collab, $comid, $_auth["useid"]);
            }
            break;
        case "ext":
            // extra objects
            $result = sql_query("SELECT `objCreator` FROM `extras` " . "WHERE `objid` = '{$objid}' LIMIT 1");
            $parentCreator = mysql_num_rows($result) > 0 ? mysql_result($result, 0) : 0;
            // If this submission is in user's updates, mark it as viewed
            // automatically.
            markAsRead(updTypeArtExtra, $objid);
            break;
        case "com":
            // comments
            $result = sql_query("SELECT `comCreator` FROM `comments` " . "WHERE `comid` = '{$objid}' LIMIT 1");
            $parentCreator = mysql_num_rows($result) > 0 ? mysql_result($result, 0) : 0;
            // If this comment is in user's updates, mark it as read automatically.
            markAsRead(updTypeComment, $objid);
            break;
        case "clu":
            // clubs
            $result = sql_query("SELECT `cluCreator` FROM `cluExtData` " . "WHERE `cluEid` = '{$objid}' LIMIT 1");
            $parentCreator = mysql_num_rows($result) > 0 ? mysql_result($result, 0) : 0;
            break;
        case "jou":
            // journals
            $result = sql_query("SELECT `jouCreator` FROM `journals` " . "WHERE `jouCreatorType` = 'use' AND `jouid` = '{$objid}' LIMIT 1");
            $parentCreator = mysql_num_rows($result) > 0 ? mysql_result($result, 0) : 0;
            if ($parentCreator == 0) {
                // Not found? Maybe that journal is actually an announcement.
                $result = sql_query("SELECT `jouAnnCreator` FROM `journals` " . "WHERE `jouCreatorType` = 'clu' AND `jouid` = '{$objid}' LIMIT 1");
                $parentCreator = mysql_num_rows($result) > 0 ? mysql_result($result, 0) : 0;
            }
            // If this journal/announcement is in user's updates, mark it as read
            // automatically.
            markAsRead(updTypeJournal, $objid);
            break;
        case "pol":
            // polls
            $result = sql_query("SELECT `polCreator` FROM `polls` " . "WHERE `polid` = '{$objid}' LIMIT 1");
            $parentCreator = mysql_num_rows($result) > 0 ? mysql_result($result, 0) : 0;
            // If this poll is in user's updates, mark it as read automatically.
            markAsRead(updTypeJournalPoll, $objid);
            break;
        case "new":
            // news
            // Those who posted news on the front page should not receive
            // comments on that news to their updates.
            $parentCreator = 0;
            break;
        case "use":
            // user pages
            $parentCreator = $objid;
            break;
    }
    // Notify the parent object's creator about the new comment on their creation.
    // If the creator is not the current user, of course.
    if ($parentCreator > 0 && $parentCreator != $_auth["useid"]) {
        addUpdate(updTypeComment, $parentCreator, $comid, $_auth["useid"]);
    }
    // Redirect to the same page to clean up POST variables.
    $focus = "#comment" . ($objType == "com" ? $objid : $comid);
    if (isset($_POST["refererURL"])) {
        if (preg_match('/\\/updates\\//', $_POST["refererURL"])) {
            $focus = "";
        }
        redirect($_POST["refererURL"] . $focus);
    } else {
        redirect(url(".", array("replied" => "yes")) . $focus);
    }
}
Example #6
0
     signOut();
 } else {
     if ($_GET["function"] == "unsubscribe") {
         unsubscribe();
     } else {
         if ($_GET["function"] == "change-email") {
             changeEmail();
         } else {
             if ($_GET["function"] == "set-folder") {
                 setFolder();
             } else {
                 if ($_GET["function"] == "like") {
                     like();
                 } else {
                     if ($_GET["function"] == "mark-as-read") {
                         markAsRead();
                     } else {
                         if ($_GET["function"] == "delete-account") {
                             deleteAccount();
                         } else {
                             if ($_GET["function"] == "count-unread") {
                                 countUnread();
                             } else {
                                 if ($_GET["function"] == "load-featured") {
                                     loadFeatured();
                                 } else {
                                     if ($_GET["function"] == "load-feed") {
                                         loadFeed();
                                     } else {
                                         if ($_GET["function"] == "load-sidebar") {
                                             loadSidebar();