From dbed08926baf869bb9a71776cf315eab1212a794 Mon Sep 17 00:00:00 2001 From: deepend Date: Tue, 23 Jan 2024 00:56:21 -0700 Subject: [PATCH 1/6] fix forum --- src/forum/recent.php | 142 ++++++++++++++++++++--------------------- src/forum/unread.php | 147 ++++++++++++++++++++++--------------------- 2 files changed, 146 insertions(+), 143 deletions(-) diff --git a/src/forum/recent.php b/src/forum/recent.php index 32b473b9..261ada8e 100644 --- a/src/forum/recent.php +++ b/src/forum/recent.php @@ -13,100 +13,100 @@ */ // Config File -$prevFolder = "../"; + $prevFolder = "../"; -require_once($prevFolder."_setup.php"); + require_once($prevFolder . "_setup.php"); -$breadcrumbObj->setTitle("Recent Posts"); -$breadcrumbObj->addCrumb("Home", MAIN_ROOT); -$breadcrumbObj->addCrumb("Forum", MAIN_ROOT."forum"); -$breadcrumbObj->addCrumb("Recent Posts"); + $breadcrumbObj->setTitle("Recent Posts"); + $breadcrumbObj->addCrumb("Home", MAIN_ROOT); + $breadcrumbObj->addCrumb("Forum", MAIN_ROOT . "forum"); + $breadcrumbObj->addCrumb("Recent Posts"); -$PAGE_NAME = "Recent Forum Posts - "; + $PAGE_NAME = "Recent Forum Posts - "; -require_once(BASE_DIRECTORY."forum/templates/_header.php"); + require_once(BASE_DIRECTORY . "forum/templates/_header.php"); -$NUM_PER_PAGE = $websiteInfo['forum_postsperpage']; -if($member->select($_SESSION['btUsername']) && $member->authorizeLogin($_SESSION['btPassword'])) { - $memberInfo = $member->get_info_filtered(); - $LOGGED_IN = true; - $NUM_PER_PAGE = $memberInfo['postsperpage']; -} - -if($NUM_PER_PAGE == 0) { - $NUM_PER_PAGE = 25; -} - + $NUM_PER_PAGE = $websiteInfo['forum_postsperpage']; + if ($member->select($_SESSION['btUsername']) && $member->authorizeLogin($_SESSION['btPassword'])) { + $memberInfo = $member->get_info_filtered(); + $LOGGED_IN = true; + $NUM_PER_PAGE = $memberInfo['postsperpage']; + } -$accessableTopicsSQL = "SELECT forumtopic_id, forumboard_id FROM ".$dbprefix."forum_topic"; -$result = $mysqli->query($accessableTopicsSQL); -while($row = $result->fetch_assoc()) { - $boardObj->select($row['forumboard_id']); - if($boardObj->memberHasAccess($memberInfo)) { - $arrTopics[] = $row['forumtopic_id']; + if ($NUM_PER_PAGE == 0) { + $NUM_PER_PAGE = 25; } -} -$topicsFilterSQL = "('".implode("','", $arrTopics)."')"; + $arrTopics = []; -$totalPostsSQL = $mysqli->query("SELECT COUNT(*) as totalPosts FROM ".$dbprefix."forum_post WHERE forumtopic_id IN ".$topicsFilterSQL." ORDER BY dateposted"); -$totalPosts = $totalPostsSQL->fetch_assoc(); -$totalPosts = $totalPosts['totalPosts']; + $accessableTopicsSQL = "SELECT forumtopic_id, forumboard_id FROM " . $dbprefix . "forum_topic"; + $result = $mysqli->query($accessableTopicsSQL); + while ($row = $result->fetch_assoc()) { + $boardObj->select($row['forumboard_id']); + if ($boardObj->memberHasAccess($memberInfo)) { + $arrTopics[] = $row['forumtopic_id']; + } + } -if(!isset($_GET['pID']) || !is_numeric($_GET['pID'])) { - $intOffset = 0; - $_GET['pID'] = 1; -} -else { - $intOffset = $NUM_PER_PAGE*($_GET['pID']-1); -} + $topicsFilterSQL = "('" . implode("','", $arrTopics) . "')"; + $totalPostsSQL = $mysqli->query("SELECT COUNT(*) as totalPosts FROM " . $dbprefix . "forum_post WHERE forumtopic_id IN " . $topicsFilterSQL . " ORDER BY dateposted"); + $totalPosts = $totalPostsSQL->fetch_assoc(); + $totalPosts = $totalPosts['totalPosts']; + if (!isset($_GET['pID']) || !is_numeric($_GET['pID'])) { + $intOffset = 0; + $_GET['pID'] = 1; + } else { + $intOffset = $NUM_PER_PAGE * ($_GET['pID'] - 1); + } // Count Pages -$NUM_OF_PAGES = ceil($totalPosts/$NUM_PER_PAGE); + $NUM_OF_PAGES = ceil($totalPosts / $NUM_PER_PAGE); + + if ($NUM_OF_PAGES == 0) { + $NUM_OF_PAGES = 1; + } -if($NUM_OF_PAGES == 0) { - $NUM_OF_PAGES = 1; -} + $pageSelector = new PageSelector(); + $pageSelector->setPages($NUM_OF_PAGES); + $pageSelector->setCurrentPage($_GET['pID']); + $pageSelector->setLink(MAIN_ROOT . "forum/recent.php?pID="); -$pageSelector = new PageSelector(); -$pageSelector->setPages($NUM_OF_PAGES); -$pageSelector->setCurrentPage($_GET['pID']); -$pageSelector->setLink(MAIN_ROOT."forum/recent.php?pID="); + echo "
"; + $pageSelector->show(); + echo "
"; -echo "
"; -$pageSelector->show(); -echo "
"; + if ($NUM_OF_PAGES == 1) { + echo "

"; + } -if($NUM_OF_PAGES == 1) { echo "

"; } + $query = "SELECT * FROM " . $dbprefix . "forum_post WHERE forumtopic_id IN " . $topicsFilterSQL . " ORDER BY dateposted DESC LIMIT " . $intOffset . ", " . $NUM_PER_PAGE; + $result = $mysqli->query($query); -$query = "SELECT * FROM ".$dbprefix."forum_post WHERE forumtopic_id IN ".$topicsFilterSQL." ORDER BY dateposted DESC LIMIT ".$intOffset.", ".$NUM_PER_PAGE; -$result = $mysqli->query($query); + $count = 0; + while ($row = $result->fetch_assoc()) { + $count++; + $boardObj->objPost->select($row['forumpost_id']); + $topicInfo = $boardObj->objPost->getTopicInfo(true); + $boardObj->select($topicInfo['forumboard_id']); -$count = 0; -while($row = $result->fetch_assoc()) { - $count++; - $boardObj->objPost->select($row['forumpost_id']); - $topicInfo = $boardObj->objPost->getTopicInfo(true); - $boardObj->select($topicInfo['forumboard_id']); + echo "
" . $boardObj->getLink(true) . " - " . $boardObj->objPost->getLink(true) . "
"; + $boardObj->objPost->show(true); - echo "
".$boardObj->getLink(true)." - ".$boardObj->objPost->getLink(true)."
"; - $boardObj->objPost->show(true); - - if($count != $result->num_rows) { - echo "

"; + if ($count != $result->num_rows) { + echo "

"; + } } -} -echo "
"; -$pageSelector->show(); -echo "
"; + echo "
"; + $pageSelector->show(); + echo "
"; -if($result->num_rows == 0) { + if ($result->num_rows == 0) { - echo " + echo "

@@ -115,7 +115,7 @@

"; - -} -require_once(BASE_DIRECTORY."forum/templates/_footer.php"); \ No newline at end of file + } + + require_once(BASE_DIRECTORY . "forum/templates/_footer.php"); \ No newline at end of file diff --git a/src/forum/unread.php b/src/forum/unread.php index 32116401..bd3c4c88 100644 --- a/src/forum/unread.php +++ b/src/forum/unread.php @@ -1,4 +1,4 @@ -setTitle("Unread Posts"); -$breadcrumbObj->addCrumb("Home", MAIN_ROOT); -$breadcrumbObj->addCrumb("Forum", MAIN_ROOT."forum"); -$breadcrumbObj->addCrumb("Unread Posts"); + $breadcrumbObj->setTitle("Unread Posts"); + $breadcrumbObj->addCrumb("Home", MAIN_ROOT); + $breadcrumbObj->addCrumb("Forum", MAIN_ROOT . "forum"); + $breadcrumbObj->addCrumb("Unread Posts"); -$PAGE_NAME = "Recent Forum Posts - "; + $PAGE_NAME = "Recent Forum Posts - "; -require_once(BASE_DIRECTORY."forum/templates/_header.php"); + require_once(BASE_DIRECTORY . "forum/templates/_header.php"); + + $memberInfo = array("member_id" => 0); + $NUM_PER_PAGE = $websiteInfo['forum_postsperpage']; + if ($member->select($_SESSION['btUsername']) && $member->authorizeLogin($_SESSION['btPassword'])) { + $memberInfo = $member->get_info_filtered(); + $LOGGED_IN = true; + $NUM_PER_PAGE = $memberInfo['postsperpage']; + } -$memberInfo = array("member_id" => 0); -$NUM_PER_PAGE = $websiteInfo['forum_postsperpage']; -if($member->select($_SESSION['btUsername']) && $member->authorizeLogin($_SESSION['btPassword'])) { - $memberInfo = $member->get_info_filtered(); - $LOGGED_IN = true; - $NUM_PER_PAGE = $memberInfo['postsperpage']; -} + if ($NUM_PER_PAGE == 0) { + $NUM_PER_PAGE = 25; + } -if($NUM_PER_PAGE == 0) { - $NUM_PER_PAGE = 25; -} + $seenTopicsSQL = "SELECT forumtopic_id FROM " . $dbprefix . "forum_topicseen WHERE member_id = '" . $memberInfo['member_id'] . "'"; -$seenTopicsSQL = "SELECT forumtopic_id FROM ".$dbprefix."forum_topicseen WHERE member_id = '".$memberInfo['member_id']."'"; + $arrTopics = []; -$accessableTopicsSQL = "SELECT forumtopic_id, forumboard_id FROM ".$dbprefix."forum_topic WHERE forumtopic_id NOT IN (".$seenTopicsSQL.")"; -$result = $mysqli->query($accessableTopicsSQL); -while($row = $result->fetch_assoc()) { - $boardObj->select($row['forumboard_id']); - if($boardObj->memberHasAccess($memberInfo)) { - $arrTopics[] = $row['forumtopic_id']; + $accessableTopicsSQL = "SELECT forumtopic_id, forumboard_id FROM " . $dbprefix . "forum_topic WHERE forumtopic_id NOT IN (" . $seenTopicsSQL . ")"; + $result = $mysqli->query($accessableTopicsSQL); + while ($row = $result->fetch_assoc()) { + $boardObj->select($row['forumboard_id']); + if ($boardObj->memberHasAccess($memberInfo)) { + $arrTopics[] = $row['forumtopic_id']; + } } -} -$topicsFilterSQL = "('".implode("','", $arrTopics)."')"; + $topicsFilterSQL = "('" . implode("','", $arrTopics) . "')"; -$totalPostsSQL = $mysqli->query("SELECT COUNT(*) as totalPosts FROM ".$dbprefix."forum_post WHERE forumtopic_id IN ".$topicsFilterSQL." ORDER BY dateposted"); -$totalPosts = $totalPostsSQL->fetch_assoc(); -$totalPosts = $totalPosts['totalPosts']; + $totalPostsSQL = $mysqli->query("SELECT COUNT(*) as totalPosts FROM " . $dbprefix . "forum_post WHERE forumtopic_id IN " . $topicsFilterSQL . " ORDER BY dateposted"); + $totalPosts = $totalPostsSQL->fetch_assoc(); + $totalPosts = $totalPosts['totalPosts']; -if(!isset($_GET['pID']) || !is_numeric($_GET['pID'])) { - $intOffset = 0; - $_GET['pID'] = 1; -} -else { - $intOffset = $NUM_PER_PAGE*($_GET['pID']-1); -} + if (!isset($_GET['pID']) || !is_numeric($_GET['pID'])) { + $intOffset = 0; + $_GET['pID'] = 1; + } else { + $intOffset = $NUM_PER_PAGE * ($_GET['pID'] - 1); + } // Count Pages -$NUM_OF_PAGES = ceil($totalPosts/$NUM_PER_PAGE); + $NUM_OF_PAGES = ceil($totalPosts / $NUM_PER_PAGE); -if($NUM_OF_PAGES == 0) { - $NUM_OF_PAGES = 1; -} + if ($NUM_OF_PAGES == 0) { + $NUM_OF_PAGES = 1; + } -$pageSelector = new PageSelector(); -$pageSelector->setPages($NUM_OF_PAGES); -$pageSelector->setCurrentPage($_GET['pID']); -$pageSelector->setLink(MAIN_ROOT."forum/recent.php?pID="); + $pageSelector = new PageSelector(); + $pageSelector->setPages($NUM_OF_PAGES); + $pageSelector->setCurrentPage($_GET['pID']); + $pageSelector->setLink(MAIN_ROOT . "forum/recent.php?pID="); -echo "
"; -$pageSelector->show(); -echo "
"; + echo "
"; + $pageSelector->show(); + echo "
"; -if($NUM_OF_PAGES == 1) { echo "

"; } + if ($NUM_OF_PAGES == 1) { + echo "

"; + } -$query = "SELECT * FROM ".$dbprefix."forum_post WHERE forumtopic_id IN ".$topicsFilterSQL." ORDER BY dateposted DESC LIMIT ".$intOffset.", ".$NUM_PER_PAGE; -$result = $mysqli->query($query); + $query = "SELECT * FROM " . $dbprefix . "forum_post WHERE forumtopic_id IN " . $topicsFilterSQL . " ORDER BY dateposted DESC LIMIT " . $intOffset . ", " . $NUM_PER_PAGE; + $result = $mysqli->query($query); -$count = 0; -while($row = $result->fetch_assoc()) { - $count++; - $boardObj->objPost->select($row['forumpost_id']); - $topicInfo = $boardObj->objPost->getTopicInfo(true); - $boardObj->select($topicInfo['forumboard_id']); + $count = 0; + while ($row = $result->fetch_assoc()) { + $count++; + $boardObj->objPost->select($row['forumpost_id']); + $topicInfo = $boardObj->objPost->getTopicInfo(true); + $boardObj->select($topicInfo['forumboard_id']); - echo "
".$boardObj->getLink(true)." - ".$boardObj->objPost->getLink(true)."
"; - $boardObj->objPost->show(true); - - if($count != $result->num_rows) { - echo "

"; + echo "
" . $boardObj->getLink(true) . " - " . $boardObj->objPost->getLink(true) . "
"; + $boardObj->objPost->show(true); + + if ($count != $result->num_rows) { + echo "

"; + } } -} -echo "
"; -$pageSelector->show(); -echo "
"; + echo "
"; + $pageSelector->show(); + echo "
"; -if($result->num_rows == 0) { + if ($result->num_rows == 0) { - echo " + echo "

@@ -120,8 +123,8 @@

"; - -} + + } -require_once(BASE_DIRECTORY."forum/templates/_footer.php"); \ No newline at end of file + require_once(BASE_DIRECTORY . "forum/templates/_footer.php"); \ No newline at end of file From f91357e14102b67bd52a33d5d6a658383519bd0f Mon Sep 17 00:00:00 2001 From: deepend Date: Tue, 23 Jan 2024 00:59:08 -0700 Subject: [PATCH 2/6] fix polls --- src/members/include/polls/createpoll.php | 494 +++++++++--------- .../include/polls/include/addoption.php | 219 ++++---- 2 files changed, 350 insertions(+), 363 deletions(-) diff --git a/src/members/include/polls/createpoll.php b/src/members/include/polls/createpoll.php index 219338fe..e1f1a9d7 100644 --- a/src/members/include/polls/createpoll.php +++ b/src/members/include/polls/createpoll.php @@ -1,128 +1,124 @@ get_info(); - $consoleObj->select($_GET['cID']); - if(!$member->hasAccess($consoleObj)) { + /* + * BlueThrust Clan Scripts + * Copyright 2014 + * + * Author: Bluethrust Web Development + * E-mail: support@bluethrust.com + * Website: http://www.bluethrust.com + * + * License: http://www.bluethrust.com/license.php + * + */ + + if (!isset($member) || substr($_SERVER['PHP_SELF'], -11) != "console.php") { exit(); + } else { + $memberInfo = $member->get_info(); + $consoleObj->select($_GET['cID']); + if (!$member->hasAccess($consoleObj)) { + exit(); + } } -} -require_once("../classes/access.php"); -require_once("../classes/poll.php"); + require_once("../classes/access.php"); + require_once("../classes/poll.php"); -$cID = $_GET['cID']; + $cID = $_GET['cID']; -$dispError = ""; -$countErrors = 0; + $dispError = ""; + $countErrors = 0; + $pollObj = new Poll($mysqli); + $accessObj = $pollObj->objAccess; -$pollObj = new Poll($mysqli); -$accessObj = $pollObj->objAccess; + if (isset($_POST['accessCacheID'])) { + $accessObj->cacheID = $_POST['accessCacheID']; + } -if(isset($_POST['accessCacheID'])) { - $accessObj->cacheID = $_POST['accessCacheID']; -} + $_SESSION['btAccessCacheTables'][$accessObj->cacheID] = json_encode($accessObj->arrAccessTables); + $_SESSION['btAccessCacheTypes'][$accessObj->cacheID] = json_encode($accessObj->arrAccessTypes); -$_SESSION['btAccessCacheTables'][$accessObj->cacheID] = json_encode($accessObj->arrAccessTables); -$_SESSION['btAccessCacheTypes'][$accessObj->cacheID] = json_encode($accessObj->arrAccessTypes); + $arrPostSelected = array(); -$arrPostSelected = array(); + if (!empty($_POST['submit'])) { -if ( ! empty($_POST['submit']) ) { - - // Check Question - if(trim($_POST['pollquestion']) == "") { - $countErrors++; - $dispError .= "   · Your poll question may not be blank.
"; - } - - // Check Access Types - $arrCheckAccessTypes = array("members", "memberslimited", "public"); - if(!in_array($_POST['accesstype'], $arrCheckAccessTypes)) { - $countErrors++; - $dispError .= "   · You selected an invalid access type.
"; - } - + // Check Question + if (trim($_POST['pollquestion']) == "") { + $countErrors++; + $dispError .= "   · Your poll question may not be blank.
"; + } - // Check Result Visibility - $arrCheckVisTypes = array("open", "votedonly", "pollend", "never"); - if(!in_array($_POST['resultvisibility'], $arrCheckVisTypes)) { - $countErrors++; - $dispError .= "   · You selected an invalid result visibility type.
"; - } - - // Check Max Votes - - if($_POST['maxvotes'] != "" && (!is_numeric($_POST['maxvotes']) || $_POST['maxvotes'] < 0)) { - $countErrors++; - $dispError .= "   · Max votes per user must be a value greater than zero.
"; - } - - // Check Poll End - - if($_POST['enddate'] != "forever" && $_POST['enddate'] != "choose") { - $countErrors++; - $dispError .= "   · You selected an invalid poll end date.
"; - } - elseif($_POST['enddate'] == "choose" && (!is_numeric($_POST['realenddate']) || $_POST['realenddate'] <= 0)) { - $countErrors++; - $dispError .= "   · You selected an invalid poll end date.
"; - } - - - - if($countErrors == 0) { - - $setEndDate = 0; - if($_POST['enddate'] == "choose") { - $setEndDate = $_POST['realenddate']/1000; - $tempYear = date("Y", $setEndDate); - $tempMonth = date("n", $setEndDate); - $tempDay = date("j", $setEndDate); - $tempHour = $_POST['endhour']; - if($_POST['endAMPM'] == "PM") { - $tempHour += 12; - } - - $setEndDate = mktime($tempHour, $_POST['endminute'], 0, $tempMonth, $tempDay, $tempYear); + // Check Access Types + $arrCheckAccessTypes = array("members", "memberslimited", "public"); + if (!in_array($_POST['accesstype'], $arrCheckAccessTypes)) { + $countErrors++; + $dispError .= "   · You selected an invalid access type.
"; } - - - $_POST['multivote'] = ($_POST['multivote'] != 1) ? 0 : 1; - $_POST['displayvoters'] = ($_POST['displayvoters'] != 1) ? 0 : 1; - - $arrColumns = array("member_id", "question", "accesstype", "multivote", "displayvoters", "resultvisibility", "maxvotes", "pollend", "dateposted"); - $arrValues = array($memberInfo['member_id'], $_POST['pollquestion'], $_POST['accesstype'], $_POST['multivote'], $_POST['displayvoters'], $_POST['resultvisibility'], $_POST['maxvotes'], $setEndDate, time()); - - if($pollObj->addNew($arrColumns, $arrValues)) { - $pollObj->cacheID = $_POST['pollCacheID']; - $pollObj->savePollOptions(); - - if($_POST['accesstype'] == "memberslimited") { - $accessObj->cacheID = $_POST['accessCacheID']; - $accessObj->arrAccessFor = array("keyName" => "poll_id", "keyValue" => $pollObj->get_info("poll_id")); - $accessObj->saveAccess(); + + + // Check Result Visibility + $arrCheckVisTypes = array("open", "votedonly", "pollend", "never"); + if (!in_array($_POST['resultvisibility'], $arrCheckVisTypes)) { + $countErrors++; + $dispError .= "   · You selected an invalid result visibility type.
"; + } + + // Check Max Votes + + if ($_POST['maxvotes'] != "" && (!is_numeric($_POST['maxvotes']) || $_POST['maxvotes'] < 0)) { + $countErrors++; + $dispError .= "   · Max votes per user must be a value greater than zero.
"; + } + + // Check Poll End + + if ($_POST['enddate'] != "forever" && $_POST['enddate'] != "choose") { + $countErrors++; + $dispError .= "   · You selected an invalid poll end date.
"; + } elseif ($_POST['enddate'] == "choose" && (!is_numeric($_POST['realenddate']) || $_POST['realenddate'] <= 0)) { + $countErrors++; + $dispError .= "   · You selected an invalid poll end date.
"; + } + + + if ($countErrors == 0) { + + $setEndDate = 0; + if ($_POST['enddate'] == "choose") { + $setEndDate = $_POST['realenddate'] / 1000; + $tempYear = date("Y", $setEndDate); + $tempMonth = date("n", $setEndDate); + $tempDay = date("j", $setEndDate); + $tempHour = $_POST['endhour']; + if ($_POST['endAMPM'] == "PM") { + $tempHour += 12; + } + + $setEndDate = mktime($tempHour, $_POST['endminute'], 0, $tempMonth, $tempDay, $tempYear); } - - echo " + + + $_POST['multivote'] = ($_POST['multivote'] != 1) ? 0 : 1; + $_POST['displayvoters'] = ($_POST['displayvoters'] != 1) ? 0 : 1; + + $arrColumns = array("member_id", "question", "accesstype", "multivote", "displayvoters", "resultvisibility", "maxvotes", "pollend", "dateposted"); + $arrValues = array($memberInfo['member_id'], $_POST['pollquestion'], $_POST['accesstype'], $_POST['multivote'], $_POST['displayvoters'], $_POST['resultvisibility'], $_POST['maxvotes'], $setEndDate, time()); + + if ($pollObj->addNew($arrColumns, $arrValues)) { + $pollObj->cacheID = $_POST['pollCacheID']; + $pollObj->savePollOptions(); + + if ($_POST['accesstype'] == "memberslimited") { + $accessObj->cacheID = $_POST['accessCacheID']; + $accessObj->arrAccessFor = array("keyName" => "poll_id", "keyValue" => $pollObj->get_info("poll_id")); + $accessObj->saveAccess(); + } + + echo " "; - + + } else { + $countErrors++; + $dispError .= "   · Unable to save information to the database. Please contact the website administrator.
"; + } } - else { - $countErrors++; - $dispError .= "   · Unable to save information to the database. Please contact the website administrator.
"; + + + if ($countErrors > 0) { + + $_POST = filterArray($_POST); + $_POST['submit'] = false; + + $arrPostSelected['accesstype']['limited'] = ($_POST['accesstype'] == "memberslimited") ? " selected" : ""; + $arrPostSelected['accesstype']['public'] = ($_POST['accesstype'] == "public") ? " selected" : ""; + + $arrPostSelected['multivote'] = (isset($_POST['multivote']) && $_POST['multivote'] == 1) ? " checked" : ""; + $arrPostSelected['displayvoters'] = (isset($_POST['displayvoters']) && $_POST['displayvoters'] == 1) ? " checked" : ""; + + $arrPostSelected['resultvisibility']['votedonly'] = ($_POST['resultvisibility'] == "votedonly") ? " selected" : ""; + $arrPostSelected['resultvisibility']['pollend'] = ($_POST['resultvisibility'] == "pollend") ? " selected" : ""; + $arrPostSelected['resultvisibility']['never'] = ($_POST['resultvisibility'] == "never") ? " selected" : ""; + + $arrPostSelected['pollend']['choose'] = ($_POST['enddate'] == "choose") ? " selected" : ""; + $arrPostSelected['pollend']['forever'] = ($_POST['enddate'] == "forever") ? " selected" : ""; + + $arrPostSelected['endAMPM'] = ($_POST['endAMPM'] == "PM") ? " selected" : ""; + } + + } - - - if($countErrors > 0) { - - $_POST = filterArray($_POST); - $_POST['submit'] = false; - - $arrPostSelected['accesstype']['limited'] = ($_POST['accesstype'] == "memberslimited") ? " selected" : ""; - $arrPostSelected['accesstype']['public'] = ($_POST['accesstype'] == "public") ? " selected" : ""; - - $arrPostSelected['multivote'] = ($_POST['multivote'] == 1) ? " checked" : ""; - $arrPostSelected['displayvoters'] = ($_POST['displayvoters'] == 1) ? " checked" : ""; - - - $arrPostSelected['resultvisibility']['votedonly'] = ($_POST['resultvisibility'] == "votedonly") ? " selected" : ""; - $arrPostSelected['resultvisibility']['pollend'] = ($_POST['resultvisibility'] == "pollend") ? " selected" : ""; - $arrPostSelected['resultvisibility']['never'] = ($_POST['resultvisibility'] == "never") ? " selected" : ""; - - $arrPostSelected['pollend']['choose'] = ($_POST['enddate'] == "choose") ? " selected" : ""; - $arrPostSelected['pollend']['forever'] = ($_POST['enddate'] == "forever") ? " selected" : ""; - - $arrPostSelected['endAMPM'] = ($_POST['endAMPM'] == "PM") ? " selected" : ""; - - } - - -} -$addMenuItemCID = $consoleObj->findConsoleIDByName("Add Menu Item"); -if ( empty($_POST['submit']) ) { - - echo " + $addMenuItemCID = $consoleObj->findConsoleIDByName("Add Menu Item"); + if (empty($_POST['submit'])) { + + echo "
"; - - - if($dispError != "") { + + } + if ($dispError != "") { echo "
Unable to create poll because the following errors occurred:

@@ -187,106 +181,102 @@
"; $pollOptionCacheID = $_POST['pollCacheID']; + } else { + $pollOptionCacheID = md5(time() . uniqid()); + $_SESSION['btPollOptionCache'][$pollOptionCacheID] = array(); } - else { - $pollOptionCacheID = md5(time().uniqid()); - $_SESSION['btPollOptionCache'][$pollOptionCacheID] = array(); - } - - - + + $hourOptions = ""; - for($i=12; $i>=1; $i--) { + for ($i = 12; $i >= 1; $i--) { $tempNum = str_pad($i, 2, "0", STR_PAD_LEFT); $dispSelected = ""; - if(isset($_POST['endhour']) && $_POST['endhour'] == $i) { + if (isset($_POST['endhour']) && $_POST['endhour'] == $i) { $dispSelected = " selected"; } - - $hourOptions .= ""; + + $hourOptions .= ""; } - + $minuteOptions = ""; - for($i=0; $i<=59; $i++) { + for ($i = 0; $i <= 59; $i++) { $tempNum = str_pad($i, 2, "0", STR_PAD_LEFT); - + $dispSelected = ""; - if(isset($_POST['endminute']) && $_POST['endminute'] == $i) { - $dispSelected = " selected"; + if (isset($_POST['endminute']) && $_POST['endminute'] == $i) { + $dispSelected = " selected"; } - - $minuteOptions .= ""; + + $minuteOptions .= ""; } - - + echo " - -
- Use the form below to add a poll. You can display polls in menus by going to the Add Menu Item page. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Question:
Access: - -
Multi-Vote: (?) - -
Display Voters: (?)
Result Visibility: - -
Max votes per user: (?) - -
Run poll until: - - -
+ + Use the form below to add a poll. You can display polls in menus by going to the Add Menu Item page. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Question:
Access: + +
Multi-Vote: (?) + +
Display Voters: (?)
Result Visibility: + +
Max votes per user: (?) + +
Run poll until: + + +
@@ -295,22 +285,22 @@
"; - - $accessObj->rankAccessDiv = "rankAccessList"; - $accessObj->dispSetRankAccess(); - - echo " + + $accessObj->rankAccessDiv = "rankAccessList"; + $accessObj->dispSetRankAccess(); + + echo "
Member Access:

Use this section to set whether a specific member is allowed to access this poll.

"; - - $accessObj->memberAccessDiv = "memberAccessList"; - $accessObj->dispSetMemberAccess(); - - echo " + + $accessObj->memberAccessDiv = "memberAccessList"; + $accessObj->dispSetMemberAccess(); + + echo "
@@ -331,7 +321,7 @@

-
Loading +
Loading

@@ -348,8 +338,8 @@

- - + +
"; - -} \ No newline at end of file diff --git a/src/members/include/polls/include/addoption.php b/src/members/include/polls/include/addoption.php index efcb38ed..62b7dde4 100644 --- a/src/members/include/polls/include/addoption.php +++ b/src/members/include/polls/include/addoption.php @@ -1,105 +1,104 @@ select($_SESSION['btUsername']); + $consoleObj = new ConsoleOption($mysqli); + $member = new Member($mysqli); + $member->select($_SESSION['btUsername']); + $createPollCID = $consoleObj->findConsoleIDByName("Create a Poll"); + $consoleObj->select($createPollCID); + $blnConsoleCheck1 = $member->hasAccess($consoleObj); -$createPollCID = $consoleObj->findConsoleIDByName("Create a Poll"); -$consoleObj->select($createPollCID); -$blnConsoleCheck1 = $member->hasAccess($consoleObj); + $managePollsCID = $consoleObj->findConsoleIDByName("Manage Polls"); + $consoleObj->select($managePollsCID); + $blnConsoleCheck2 = $member->hasAccess($consoleObj); -$managePollsCID = $consoleObj->findConsoleIDByName("Manage Polls"); -$consoleObj->select($managePollsCID); -$blnConsoleCheck2 = $member->hasAccess($consoleObj); + $blnConsoleCheck = $blnConsoleCheck1 || $blnConsoleCheck2; -$blnConsoleCheck = $blnConsoleCheck1 || $blnConsoleCheck2; - -$pollObj = new Poll($mysqli); + $pollObj = new Poll($mysqli); // Check Login -$LOGIN_FAIL = true; -if($member->authorizeLogin($_SESSION['btPassword']) && $blnConsoleCheck) { - - $pollObj->cacheID = $_POST['cacheID']; - - if ( ! empty($_POST['submit']) ) { - - $arrNewOption = array(); - $arrErrors = array(); - $arrReturn = array(); - - - // Check Value - if(trim($_POST['optionValue']) == "") { - $arrErrors[] = "Option value may not be blank."; - } - - - // Check Color - if(trim($_POST['optionColor']) == "") { - $_POST['optionColor'] = "#FFFFFF"; - } - - // Check Display Order - - if(count($_SESSION['btPollOptionCache'][$pollObj->cacheID]) > 0 && (!is_numeric($_POST['optionOrder']) || !isset($_POST['optionOrder']) || ($_POST['optionOrderBeforeAfter'] != "before" && $_POST['optionOrderBeforeAfter'] != "after"))) { - $arrErrors[] = "You selected an invalid display order."; - } - - if(count($arrErrors) == 0) { + $LOGIN_FAIL = true; + if ($member->authorizeLogin($_SESSION['btPassword']) && $blnConsoleCheck) { - $newSortNum = $pollObj->makeCacheRoom($_POST['optionOrderBeforeAfter'], $_POST['optionOrder']); - - $arrReturn['result'] = "success"; - $arrReturn['info'] = $newSortNum; - - $arrNewOption['value'] = $_POST['optionValue']; - $arrNewOption['color'] = $_POST['optionColor']; - - - $_SESSION['btPollOptionCache'][$pollObj->cacheID][$newSortNum] = $arrNewOption; + $pollObj->cacheID = $_POST['cacheID']; - $pollObj->resortCacheOrder(); - - } - - if(count($arrErrors) > 0) { - - $arrReturn['result'] = "fail"; - $arrReturn['errors'] = $arrErrors; - + if (!empty($_POST['submit'])) { + + $arrNewOption = array(); + $arrErrors = array(); + $arrReturn = array(); + + + // Check Value + if (trim($_POST['optionValue']) == "") { + $arrErrors[] = "Option value may not be blank."; + } + + + // Check Color + if (trim($_POST['optionColor']) == "") { + $_POST['optionColor'] = "#FFFFFF"; + } + + // Check Display Order + + if (count($_SESSION['btPollOptionCache'][$pollObj->cacheID]) > 0 && (!is_numeric($_POST['optionOrder']) || !isset($_POST['optionOrder']) || ($_POST['optionOrderBeforeAfter'] != "before" && $_POST['optionOrderBeforeAfter'] != "after"))) { + $arrErrors[] = "You selected an invalid display order."; + } + + if (count($arrErrors) == 0) { + + $newSortNum = $pollObj->makeCacheRoom($_POST['optionOrderBeforeAfter'], $_POST['optionOrder']); + + $arrReturn['result'] = "success"; + $arrReturn['info'] = $newSortNum; + + $arrNewOption['value'] = $_POST['optionValue']; + $arrNewOption['color'] = $_POST['optionColor']; + + + $_SESSION['btPollOptionCache'][$pollObj->cacheID][$newSortNum] = $arrNewOption; + + $pollObj->resortCacheOrder(); + + } + + if (count($arrErrors) > 0) { + + $arrReturn['result'] = "fail"; + $arrReturn['errors'] = $arrErrors; + + } + + header('Content-Type: application/json'); + echo json_encode($arrReturn); } - - - echo json_encode($arrReturn); - } - - - if ( empty($_POST['submit']) ) { - echo " + + + if (empty($_POST['submit'])) { + echo " "; - - $pmFolderObj->resortOrder(); + + $pmFolderObj->resortOrder(); + } else { + $countErrors++; + $dispError .= "   · Unable to save folder to the database. Please contact the website administrator.
"; + } + } - else { - $countErrors++; - $dispError .= "   · Unable to save folder to the database. Please contact the website administrator.
"; + + + if ($countErrors > 0) { + $_POST = filterArray($_POST); + $_POST['submit'] = false; } - - } - - - - if($countErrors > 0) { - $_POST = filterArray($_POST); - $_POST['submit'] = false; - } - - -} -if ( empty($_POST['submit']) ) { - $arrFolders = $pmFolderObj->listFolders($memberInfo['member_id']); - $folderOptions = ""; - foreach($arrFolders as $folderID => $folderName) { - $folderOptions .= ""; - } - - if($folderOptions == "") { - $folderOptions = ""; } - - - echo " -
-
- "; - if($dispError != "") { + if (empty($_POST['submit'])) { + + $arrFolders = $pmFolderObj->listFolders($memberInfo['member_id']); + $folderOptions = ""; + foreach ($arrFolders as $folderID => $folderName) { + $folderOptions .= ""; + } + + if ($folderOptions == "") { + $folderOptions = ""; + } + + echo " + +
+ "; + + if ($dispError != "") { + echo "
Unable to add folder because the following errors occurred:

$dispError
"; - } + } - echo " - Use the form below to add new folder for your private messages. - - - - - - - - - - - - -
Folder Name:
Display Order: -
- -

- -
-
-
- - "; -} \ No newline at end of file + echo " + Use the form below to add new folder for your private messages. + + + + + + + + + + + + +
Folder Name:
Display Order: +
+ +

+ +
+
+
+ +"; + } \ No newline at end of file diff --git a/src/members/privatemessages/compose.php b/src/members/privatemessages/compose.php index e8c229f6..6a567a42 100644 --- a/src/members/privatemessages/compose.php +++ b/src/members/privatemessages/compose.php @@ -12,36 +12,35 @@ * */ -require_once("../../_setup.php"); + require_once("../../_setup.php"); // Delete expired compose list sessions -foreach($_SESSION['btComposeList'] as $key => $arr) { - if(time() > $arr['exptime']) { - unset($_SESSION['btComposeList'][$key]); + foreach ($_SESSION['btComposeList'] as $key => $arr) { + if (time() > $arr['exptime']) { + unset($_SESSION['btComposeList'][$key]); + } } -} // Start Page -$consoleObj = new ConsoleOption($mysqli); - -$cID = $consoleObj->findConsoleIDByName("Private Messages"); -$consoleObj->select($cID); -$consoleInfo = $consoleObj->get_info_filtered(); -$consoleTitle = $consoleInfo['pagetitle']; + $consoleObj = new ConsoleOption($mysqli); + $cID = $consoleObj->findConsoleIDByName("Private Messages"); + $consoleObj->select($cID); + $consoleInfo = $consoleObj->get_info_filtered(); + $consoleTitle = $consoleInfo['pagetitle']; -$member = new Member($mysqli); -$member->select($_SESSION['btUsername']); + $member = new Member($mysqli); + $member->select($_SESSION['btUsername']); -$PAGE_NAME = "Compose Message - ".$consoleTitle." - "; -$dispBreadCrumb = "Home > My Account > ".$consoleTitle." > Compose Message"; -$EXTERNAL_JAVASCRIPT .= " - - + $PAGE_NAME = "Compose Message - " . $consoleTitle . " - "; + $dispBreadCrumb = "Home > My Account > " . $consoleTitle . " > Compose Message"; + $EXTERNAL_JAVASCRIPT .= " + + "; -$prevFolder = "../../"; -require_once(BASE_DIRECTORY."themes/".$THEME."/_header.php"); + $prevFolder = "../../"; + require_once(BASE_DIRECTORY . "themes/" . $THEME . "/_header.php"); -$breadcrumbObj->setTitle("Compose Message"); -$breadcrumbObj->addCrumb("Home", MAIN_ROOT); -$breadcrumbObj->addCrumb("My Account", MAIN_ROOT."members"); -$breadcrumbObj->addCrumb($consoleTitle, MAIN_ROOT."members/console.php?cID=".$cID); -$breadcrumbObj->addCrumb("Compose Message"); -require_once(BASE_DIRECTORY."include/breadcrumb.php"); + $breadcrumbObj->setTitle("Compose Message"); + $breadcrumbObj->addCrumb("Home", MAIN_ROOT); + $breadcrumbObj->addCrumb("My Account", MAIN_ROOT . "members"); + $breadcrumbObj->addCrumb($consoleTitle, MAIN_ROOT . "members/console.php?cID=" . $cID); + $breadcrumbObj->addCrumb("Compose Message"); + require_once(BASE_DIRECTORY . "include/breadcrumb.php"); -$pmObj = new BasicOrder($mysqli, "privatemessages", "pm_id"); -$rankCatObj = new RankCategory($mysqli); -$squadObj = new Squad($mysqli); -$tournamentObj = new Tournament($mysqli); -$multiMemPMObj = new Basic($mysqli, "privatemessage_members", "pmmember_id"); + $pmObj = new BasicOrder($mysqli, "privatemessages", "pm_id"); + $rankCatObj = new RankCategory($mysqli); + $squadObj = new Squad($mysqli); + $tournamentObj = new Tournament($mysqli); + $multiMemPMObj = new Basic($mysqli, "privatemessage_members", "pmmember_id"); -$pmObj->set_assocTableName("privatemessage_members"); -$pmObj->set_assocTableKey("member_id"); + $pmObj->set_assocTableName("privatemessage_members"); + $pmObj->set_assocTableKey("member_id"); // Check Login -$LOGIN_FAIL = true; -if($member->authorizeLogin($_SESSION['btPassword']) && $member->hasAccess($consoleObj)) { - - $memberInfo = $member->get_info_filtered(); - $formObj = new Form(); - - - require_once(BASE_DIRECTORY."members/privatemessages/include/compose_submit.php"); - require_once(BASE_DIRECTORY."members/privatemessages/include/compose_setup.php"); - - $i = 1; - $arrComponents = array( - "tomember" => array( - "type" => "custom", - "display_name" => "To", - "html" => "
+ $LOGIN_FAIL = true; + if ($member->authorizeLogin($_SESSION['btPassword']) && $member->hasAccess($consoleObj)) { + + $memberInfo = $member->get_info_filtered(); + $formObj = new Form(); + + + require_once(BASE_DIRECTORY . "members/privatemessages/include/compose_submit.php"); + require_once(BASE_DIRECTORY . "members/privatemessages/include/compose_setup.php"); + + $i = 1; + $arrComponents = array( + "tomember" => array( + "type" => "custom", + "display_name" => "To", + "html" => "
", - "sortorder" => $i++, - - ), - "subject" => array( - "type" => "text", - "display_name" => "Subject", - "attributes" => array("class" => "formInput textBox bigTextBox"), - "sortorder" => $i++, - "value" => $_POST['subject'] - ), - "message" => array( - "type" => "textarea", - "display_name" => "Message", - "sortorder" => $i++, - "attributes" => array("class" => "formInput textBox", "rows" => "8", "cols" => "50"), - "validate" => array("NOT_BLANK") - ), - "submit" => array( - "type" => "submit", - "value" => "Send Message", - "attributes" => array("class" => "submitButton formSubmitButton"), - "sortorder" => $i++ - ), - "pmsessionid" => array( + "sortorder" => $i++, + + ), + "subject" => array( + "type" => "text", + "display_name" => "Subject", + "attributes" => array("class" => "formInput textBox bigTextBox"), + "sortorder" => $i++, + "value" => isset($_POST['subject']) ? $_POST['subject'] : '' + ), + + "message" => array( + "type" => "textarea", + "display_name" => "Message", + "sortorder" => $i++, + "attributes" => array("class" => "formInput textBox", "rows" => "8", "cols" => "50"), + "validate" => array("NOT_BLANK") + ), + "submit" => array( + "type" => "submit", + "value" => "Send Message", + "attributes" => array("class" => "submitButton formSubmitButton"), + "sortorder" => $i++ + ), + "pmsessionid" => array( + "type" => "hidden", + "value" => $pmSessionID, + "hidden" => true, + "sortorder" => $i++ + ) + + ); + + + if (isset($_GET['threadID']) && is_numeric($_GET['threadID'])) { + $replyPMID = $_GET['threadID']; + } else { + $replyPMID = 0; + } + + + $arrComponents['replypmid'] = array( "type" => "hidden", - "value" => $pmSessionID, + "value" => $replyPMID, "hidden" => true, "sortorder" => $i++ - ) - - ); - - - if(isset($_GET['threadID']) && is_numeric($_GET['threadID'])) { - $replyPMID = $_GET['threadID']; - } - else { - $replyPMID = 0; - } - - - $arrComponents['replypmid'] = array( - "type" => "hidden", - "value" => $replyPMID, - "hidden" => true, - "sortorder" => $i++ - ); - - - // Send as Email - $emailPMCID = $consoleObj->findConsoleIDByName("Email Private Messages"); - $consoleObj->select($emailPMCID); - if($member->hasAccess($consoleObj)) { - - $formObj->addComponentSortSpace(2, $arrComponents); - $arrComponents = $formObj->components; - - $arrComponents['emailpm'] = array( - "type" => "checkbox", - "value" => 1, - "sortorder" => 2, - "display_name" => "Send as E-mail", - "tooltip" => "Checking this box will force an e-mail to be sent to the member(s) as well.", - "attributes" => array("class" => "formInput") ); - + + + // Send as Email + $emailPMCID = $consoleObj->findConsoleIDByName("Email Private Messages"); + $consoleObj->select($emailPMCID); + if ($member->hasAccess($consoleObj)) { + + $formObj->addComponentSortSpace(2, $arrComponents); + $arrComponents = $formObj->components; + + $arrComponents['emailpm'] = array( + "type" => "checkbox", + "value" => 1, + "sortorder" => 2, + "display_name" => "Send as E-mail", + "tooltip" => "Checking this box will force an e-mail to be sent to the member(s) as well.", + "attributes" => array("class" => "formInput") + ); + + } + $consoleObj->select($cID); + + $setupFormArgs = array( + "name" => "console-" . $cID . "-compose", + "components" => $arrComponents, + "saveMessage" => "Successfully Sent Private Message!", + "attributes" => array("action" => MAIN_ROOT . "members/privatemessages/compose.php", "method" => "post"), + "description" => "Use the form below to send a private message.

Extra Information:
You may send private messages in batches to squads, tournaments, or ranks by typing in their associated name. Typing in a squad name, tournament title or rank name will send to that group.

", + "embedJS" => $composePageJS + ); + + + require_once(BASE_DIRECTORY . "members/console.form.php"); + + + } else { + + die(""); + } - $consoleObj->select($cID); - - $setupFormArgs = array( - "name" => "console-".$cID."-compose", - "components" => $arrComponents, - "saveMessage" => "Successfully Sent Private Message!", - "attributes" => array("action" => MAIN_ROOT."members/privatemessages/compose.php", "method" => "post"), - "description" => "Use the form below to send a private message.

Extra Information:
You may send private messages in batches to squads, tournaments, or ranks by typing in their associated name. Typing in a squad name, tournament title or rank name will send to that group.

", - "embedJS" => $composePageJS - ); - - - - require_once(BASE_DIRECTORY."members/console.form.php"); - - -} -else { - - die(""); - -} - - - -require_once(BASE_DIRECTORY."themes/".$THEME."/_footer.php"); \ No newline at end of file + + From 85f879f49d9f30bedc0df399623b6664af02c171 Mon Sep 17 00:00:00 2001 From: deepend Date: Tue, 23 Jan 2024 01:23:37 -0700 Subject: [PATCH 4/6] fix worldclocks --- .../include/worldclocks/manageclocks.php | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/members/include/worldclocks/manageclocks.php b/src/members/include/worldclocks/manageclocks.php index 74292375..16c39ee3 100644 --- a/src/members/include/worldclocks/manageclocks.php +++ b/src/members/include/worldclocks/manageclocks.php @@ -13,33 +13,29 @@ */ - - if(!isset($member) || substr($_SERVER['PHP_SELF'], -11) != "console.php") { + if (!isset($member) || substr($_SERVER['PHP_SELF'], -11) != "console.php") { exit(); - } - else { + } else { $memberInfo = $member->get_info_filtered(); $consoleObj->select($_GET['cID']); - if(!$member->hasAccess($consoleObj)) { + if (!$member->hasAccess($consoleObj)) { exit(); } - + } - - + + $objManageList = new btOrderManageList($clockObj); - $objManageList->strMainListLink = BASE_DIRECTORY."members/include/worldclocks/main.php"; + $objManageList->strMainListLink = BASE_DIRECTORY . "members/include/worldclocks/main.php"; + - - if($_GET['clockID'] != "" && $clockObj->select($_GET['clockID']) && $_GET['action'] == "edit") { + if (isset($_GET['clockID']) && $_GET['clockID'] != "" && $clockObj->select($_GET['clockID']) && isset($_GET['action']) && $_GET['action'] == "edit") { $clockInfo = $clockObj->get_info_filtered(); - require_once(BASE_DIRECTORY."members/include/worldclocks/edit.php"); - } - elseif($_GET['action'] == "delete" && $clockObj->select($_POST['itemID'])) { + require_once(BASE_DIRECTORY . "members/include/worldclocks/edit.php"); + } elseif (isset($_GET['action']) && $_GET['action'] == "delete" && isset($_POST['itemID']) && $clockObj->select($_POST['itemID'])) { $info = $clockObj->get_info_filtered(); $objManageList->strDeleteName = $info['name']; - $objManageList->strDeletePostVarID = "clockID"; - } - elseif($_GET['action'] != "move") { - require_once($objManageList->strMainListLink); + $objManageList->strDeletePostVarID = "clockID"; + } elseif (!isset($_GET['action']) || $_GET['action'] != "move") { + require_once($objManageList->strMainListLink); } \ No newline at end of file From 390f6450c9136165a9a8156a1dee22f58f8758c2 Mon Sep 17 00:00:00 2001 From: deepend Date: Tue, 23 Jan 2024 01:32:38 -0700 Subject: [PATCH 5/6] fix worldclocks --- .../include/worldclocks/manageclocks.php | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/members/include/worldclocks/manageclocks.php b/src/members/include/worldclocks/manageclocks.php index 16c39ee3..e8482ad9 100644 --- a/src/members/include/worldclocks/manageclocks.php +++ b/src/members/include/worldclocks/manageclocks.php @@ -1,16 +1,16 @@ Date: Tue, 23 Jan 2024 01:35:38 -0700 Subject: [PATCH 6/6] fix console managelist --- src/members/console.managelist.list.php | 177 ++++++++++++------------ src/members/console.managelist.php | 164 +++++++++++----------- 2 files changed, 168 insertions(+), 173 deletions(-) diff --git a/src/members/console.managelist.list.php b/src/members/console.managelist.list.php index 4b4c3557..8dd3f0fd 100644 --- a/src/members/console.managelist.list.php +++ b/src/members/console.managelist.list.php @@ -1,129 +1,134 @@ select($_SESSION['btUsername']); - + $consoleObj = new ConsoleOption($mysqli); - if(!$consoleObj->select($setupManageListArgs['console_id'])) { + $setupManageListArgs = json_decode($_POST['listArgs'], true); + + if (!$consoleObj->select($setupManageListArgs['console_id'])) { exit(); } - - if(!$member->authorizeLogin($_SESSION['btPassword']) || !$member->hasAccess($consoleObj)) { - exit(); + + if (!$member->authorizeLogin($_SESSION['btPassword']) || !$member->hasAccess($consoleObj)) { + exit(); + } + +// Ensure that 'actions' key exists and is an array + $actionsWidth = 0; + $titleWidth = 100; + if (isset($setupManageListArgs['actions']) && is_array($setupManageListArgs['actions'])) { + $actionsWidth = count($setupManageListArgs['actions']) * 6; + $titleWidth = 100 - $actionsWidth; } - - $actionsWidth = count($setupManageListArgs['actions'])*6; - $titleWidth = 100-($actionsWidth); } - echo " "; - $counter = 0; - foreach($setupManageListArgs['items'] as $itemInfo) { + $counter = 0; + foreach ($setupManageListArgs['items'] as $itemInfo) { - if($itemInfo['type'] == "listitem") { - - if($counter == 1) { - $addCSS = " alternateBGColor"; - $counter = 0; - } - else { - $addCSS = ""; - $counter = 1; - } - - echo " + if ($itemInfo['type'] == "listitem") { + + if ($counter == 1) { + $addCSS = " alternateBGColor"; + $counter = 0; + } else { + $addCSS = ""; + $counter = 1; + } + + echo " - - - "; - - foreach($setupManageListArgs['actions'] as $actionTypes) { - $dispAction = ""; - switch($actionTypes) { - case "moveup": - $dispAction = !in_array("moveup", $itemInfo['actions']) ? "" : ""; - break; - case "movedown": - $dispAction = !in_array("movedown", $itemInfo['actions']) ? "" : ""; - break; - case "edit": - $dispAction = ""; - break; - case "delete": - $dispAction = ""; - break; - default: - $dispAction = call_user_func_array($actionTypes, array($itemInfo['item_id'])); - } + - echo " - "; + + foreach ($setupManageListArgs['actions'] as $actionTypes) { + $dispAction = ""; + switch ($actionTypes) { + case "moveup": + $dispAction = !in_array("moveup", $itemInfo['actions']) ? "" : ""; + break; + case "movedown": + $dispAction = !in_array("movedown", $itemInfo['actions']) ? "" : ""; + break; + case "edit": + $dispAction = ""; + break; + case "delete": + $dispAction = ""; + break; + default: + $dispAction = call_user_func_array($actionTypes, array($itemInfo['item_id'])); } - - - echo ""; - - } - else { // Category Title - - $dispAddItemToCategory = ($itemInfo['add_to_cat_link'] == "") ? "" : ""; - + echo " + + "; + } + + + echo ""; + + } else { // Category Title + + $dispAddItemToCategory = ($itemInfo['add_to_cat_link'] == "") ? "" : ""; + + echo " - - + + "; - - } + } - + } + echo "
".$itemInfo['display_name']."" . $itemInfo['display_name'] . "".$dispAction."
" . $dispAction . "
".$dispAddItemToCategory."" . $dispAddItemToCategory . "
"; - - if(count($setupManageListArgs['items']) == 0) { - if(substr($setupManageListArgs['item_title'],-1) == ":") { - $noItemName = substr($setupManageListArgs['item_title'], 0, strlen($setupManageListArgs['item_title'])-1); - } - elseif($setupManageListArgs['item_title'] == "") { - $noItemName = "item"; + if (count($setupManageListArgs['items']) == 0) { + + if (substr($setupManageListArgs['item_title'], -1) == ":") { + $noItemName = substr($setupManageListArgs['item_title'], 0, strlen($setupManageListArgs['item_title']) - 1); + } elseif ($setupManageListArgs['item_title'] == "") { + $noItemName = "item"; } - + echo "

- No ".strtolower($noItemName)."s added yet! + No " . strtolower($noItemName) . "s added yet!

"; - + } \ No newline at end of file diff --git a/src/members/console.managelist.php b/src/members/console.managelist.php index 08b3fd02..0962b4c5 100644 --- a/src/members/console.managelist.php +++ b/src/members/console.managelist.php @@ -1,112 +1,103 @@ window.location = '".$MAIN_ROOT."'"); } - - - $actionsWidth = count($setupManageListArgs['actions'])*6; - $titleWidth = 100-($actionsWidth); - - +/* + * BlueThrust Clan Scripts + * Copyright 2014 + * + * Author: Bluethrust Web Development + * E-mail: support@bluethrust.com + * Website: http://www.bluethrust.com + * + * License: http://www.bluethrust.com/license.php + * + */ + + if (!defined("LOGGED_IN") || !LOGGED_IN) { + die(""); + } + + + $actionsWidth = count($setupManageListArgs['actions']) * 6; + $titleWidth = 100 - ($actionsWidth); + + // Setup default values if not given - $actionsTitleName = ($setupManageListArgs['action_title'] == "") ? "Actions:" : $setupManageListArgs['action_title']; - $itemTitleName = ($setupManageListArgs['item_title'] == "") ? "Item:" : $setupManageListArgs['item_title']; - - $dispAddNewLink = (!isset($setupManageListArgs['add_new_link']['url']) || $setupManageListArgs['add_new_link']['url'] == "") ? "" : "» ".$setupManageListArgs['add_new_link']['name']." «"; - - $setupManageListArgs['list_div_name'] = ($setupManageListArgs['list_div_name'] == "") ? "manageListDiv" : $setupManageListArgs['list_div_name']; - - $setupManageListArgs['loading_spiral'] = ($setupManageListArgs['loading_spiral'] == "") ? "manageListLoadingSpiral" : $setupManageListArgs['loading_spiral']; - - - - + $actionsTitleName = $setupManageListArgs['action_title'] ?? "Actions:"; + $itemTitleName = $setupManageListArgs['item_title'] ?? "Item:"; + + $dispAddNewLink = (!isset($setupManageListArgs['add_new_link']['url']) || $setupManageListArgs['add_new_link']['url'] == "") ? "" : "» " . $setupManageListArgs['add_new_link']['name'] . " «"; + + $setupManageListArgs['list_div_name'] = $setupManageListArgs['list_div_name'] ?? "manageListDiv"; + $setupManageListArgs['loading_spiral'] = $setupManageListArgs['loading_spiral'] ?? "manageListLoadingSpiral"; + + // Display Manage List - + echo " - + - - + +
".$dispAddNewLink."

" . $dispAddNewLink . "

".$itemTitleName."".$actionsTitleName."" . $itemTitleName . "" . $actionsTitleName . "
-


Loading...

+


Loading...

-
+
"; - - require_once("console.managelist.list.php"); - + + require_once("console.managelist.list.php"); + $moveLink = $setupManageListArgs['move_link'] ?? "defaultMoveLink.php"; // Replace 'defaultMoveLink.php' with your default link echo "