// transaction stage // if (!empty($_POST['do_synctopics'])) { set_time_limit(0); $synctopics_start = intval(@$_POST['synctopics_start']); $synctopics_num = empty($_POST['synctopics_num']) ? 100 : intval($_POST['synctopics_num']); // sync topics $trs = $db->query("SELECT topic_id FROM " . $db->prefix($mydirname . "_topics") . " WHERE topic_id>={$synctopics_start} AND topic_id<" . ($synctopics_start + $synctopics_num)); $topic_counter = 0; while (list($topic_id) = $db->fetchRow($trs)) { $topic_counter++; $topic_id = intval($topic_id); // sync posts from post_votes $prs = $db->query("SELECT post_id FROM " . $db->prefix($mydirname . "_posts") . " WHERE topic_id={$topic_id}"); while (list($post_id) = $db->fetchRow($prs)) { d3forum_sync_post_votes($mydirname, $post_id, false); } d3forum_sync_topic_votes($mydirname, $topic_id, false); d3forum_sync_topic($mydirname, $topic_id, false); } $_SESSION[$mydirname . '_synctopics_start'] = $synctopics_start + $synctopics_num; $_SESSION[$mydirname . '_synctopics_num'] = $synctopics_num; redirect_header(XOOPS_URL . "/modules/{$mydirname}/admin/index.php?page=advanced_admin", 3, sprintf(_MD_A_D3FORUM_FMT_SYNCTOPICSDONE, $topic_counter)); exit; } if (!empty($_POST['do_syncforums'])) { set_time_limit(0); // sync all forums $result = $db->query("SELECT forum_id FROM " . $db->prefix($mydirname . "_forums")); while (list($forum_id) = $db->fetchRow($result)) { d3forum_sync_forum($mydirname, $forum_id, false);
if ($point4vote < 0 || $point4vote > 10) { die(_MD_D3FORUM_ERR_VOTEINVALID . __LINE__); } // check double voting $sql = "SELECT COUNT(*) FROM " . $db->prefix($mydirname . "_post_votes") . " WHERE post_id={$post_id} AND ({$useridentity4select})"; if (!($result = $db->query($sql))) { die(_MD_D3FORUM_ERR_SQL . __LINE__); } list($count) = $db->fetchRow($result); if ($count > 0) { // delete previous post $sql = "DELETE FROM " . $db->prefix($mydirname . "_post_votes") . " WHERE post_id={$post_id} AND ({$useridentity4select}) LIMIT 1"; if (!$db->queryF($sql)) { die(_MD_D3FORUM_ERR_SQL . __LINE__); } } // transaction stage $sql = "INSERT INTO " . $db->prefix($mydirname . "_post_votes") . " SET post_id={$post_id}, vote_point={$point4vote}, vote_time=UNIX_TIMESTAMP(), {$useridentity4insert}"; if (!$db->queryF($sql)) { die(_MD_D3FORUM_ERR_SQL . __LINE__); } require_once dirname(dirname(__FILE__)) . '/include/transact_functions.php'; d3forum_sync_post_votes($mydirname, $post_id); $allowed_identifiers = array('post_id', 'topic_id'); if (in_array(@$_GET['ret_name'], $allowed_identifiers)) { $ret_request = $_GET['ret_name'] . '=' . intval(@$_GET['ret_val']); } else { $ret_request = "post_id={$post_id}"; } redirect_header(XOOPS_URL . "/modules/{$mydirname}/index.php?{$ret_request}", 0, _MD_D3FORUM_MSG_VOTEACCEPTED); exit;