num_rows != 0) { date_default_timezone_set("America/New_York"); $d = date("Y-m-d H:i:s", strtotime("now")); $sql = "UPDATE " . $tn1 . " SET `activity` = '" . $d . "', `away` = 'active' WHERE `ID` ='" . $_SESSION['userid'] . "'"; if (mysqli_query($con, $sql)) { } else { } } else { } if ( ( $row['setup'] != "Complete" ) && ( $row['setup'] != "Skip" ) ) { header('Location: https://www.filterish.com/setup.htm'); } // Create New Post if (isset($_POST['postbutton'])) { // Construct Filter Syntax $filterconstr = "general"; $cba = $_POST['filterval']; $atleast = 0; // Check # of Applied Filters foreach($cba as $checkbox){ if(isset($checkbox)){ if ($atleast == 0) { if( strpos( $checkbox, ":" ) !== false) { $splitter = explode(':',$checkbox); $result = mysqli_query($con,"SELECT * FROM " . $tn7 . " WHERE `sub` ='" . $splitter[0] . "' AND `filter` = '" . $checkbox . "'"); if($result->num_rows == 0) { $sql = "INSERT INTO " . $tn7 . " (sub,filter,posts) VALUES ('" . $splitter[0] . "','" . $checkbox . "','1')"; if (mysqli_query($con, $sql)) { } else { } } else { $sql = "UPDATE " . $tn7 . " SET posts = posts+1 WHERE `sub` ='" . $splitter[0] . "' AND `filter` = '" . $checkbox . "'"; if (mysqli_query($con, $sql)) { $sql = "UPDATE " . $tn7 . " SET posts = posts+1 WHERE `sub` ='Main' AND `filter` = '" . $splitter[0] . "'"; if (mysqli_query($con, $sql)) { } else { } } else { } } if( strpos( $filterconstr, $splitter[0] ) !== false) { $filterconstr = $checkbox; } else { $filterconstr = $splitter[0] . "," . $checkbox; } } else { $filterconstr = $checkbox; } } else { if( strpos( $checkbox, ":" ) !== false) { $splitter = explode(':',$checkbox); $result = mysqli_query($con,"SELECT * FROM " . $tn7 . " WHERE `sub` ='" . $splitter[0] . "' AND `filter` = '" . $checkbox . "'"); if($result->num_rows == 0) { $sql = "INSERT INTO " . $tn7 . " (sub,filter,posts) VALUES ('" . $splitter[0] . "','" . $checkbox . "','1')"; if (mysqli_query($con, $sql)) { } else { } } else { $sql = "UPDATE " . $tn7 . " SET posts = posts+1 WHERE `sub` ='" . $splitter[0] . "' AND `filter` = '" . $checkbox . "'"; if (mysqli_query($con, $sql)) { $sql = "UPDATE " . $tn7 . " SET posts = posts+1 WHERE `sub` ='Main' AND `filter` = '" . $splitter[0] . "'"; if (mysqli_query($con, $sql)) { } else { } } else { } } if( strpos( $filterconstr, $splitter[0] ) !== false) { $filterconstr = $filterconstr . "," . $checkbox; } else { $filterconstr = $filterconstr . "," . $splitter[0] . "," . $checkbox; } } else { $filterconstr = $filterconstr . "," . $checkbox; } } $atleast++; } } $sanitized = filter_var($_POST['postcontent'], FILTER_SANITIZE_STRING); $pclined = nl2br($sanitized); if ($_SESSION['postuploads'] != "") { // Create Image Post $sql = "INSERT INTO " . $tn2 . " (poster,postcontent,filters,attachments) VALUES ('" . $_SESSION['userid'] . "','" . $pclined . "','" . $filterconstr . "','" . $_SESSION['postuploads'] . "')"; } else { // Create No-Attachment Post $sql = "INSERT INTO " . $tn2 . " (poster,postcontent,filters) VALUES ('" . $_SESSION['userid'] . "','" . $pclined . "','" . $filterconstr . "')"; } if (mysqli_query($con, $sql)) { $_SESSION['postuploads'] = ""; header('Location: index.htm'); } else { } } if (isset($_POST['removepic'])) { $_SESSION['postuploads'] = ""; header('Location: index.htm'); } if (isset($_POST['filterchoice'])) { // Update Filter Choice $sql = "UPDATE " . $tn1 . " SET `currentfilter` = '" . $_POST['filterchoice'] . "' WHERE `ID` ='" . $_SESSION['userid'] . "'"; if (mysqli_query($con, $sql)) { // Update Account Display $result = mysqli_query($con,"SELECT * FROM " . $tn1 . " WHERE `ID` ='" . $_SESSION['userid'] . "'"); $row = mysqli_fetch_array($result); } else { } header('Location: index.htm'); } // Set Filter Option List $filterpossible = array(); $filterq = mysqli_query($con,"SELECT * FROM " . $tn7 . " WHERE `sub` = 'Main'"); while($filrow = mysqli_fetch_array($filterq)) { $filterpossible[] = $filrow['filter']; } // Custom Filter Settings if (isset($_POST['customfilterchoice'])) { // Update Filter Choice $sql = "UPDATE " . $tn1 . " SET `filterchoice` = '" . $_POST['customfilterchoice'] . "' WHERE `ID` ='" . $_SESSION['userid'] . "'"; if (mysqli_query($con, $sql)) { // Update Account Display $result = mysqli_query($con,"SELECT * FROM " . $tn1 . " WHERE `ID` ='" . $_SESSION['userid'] . "'"); $row = mysqli_fetch_array($result); } else { } // Save Custom Filter Layout $customlayout = ""; $z = 0; $marker = 0; $custarr = $_POST['customfilter1']; while ( $z < count($filterpossible) ) { if($custarr[$marker] == $z ) { $customlayout = $customlayout . "checked"; $marker++; } else { $customlayout = $customlayout . "unchecked"; } $z++; if ( $z < count($filterpossible) ) { $customlayout = $customlayout . "."; } } // Update Filter Config $sql = "UPDATE " . $tn1 . " SET `filterconfig` = '" . $customlayout . "' WHERE `ID` ='" . $_SESSION['userid'] . "'"; if (mysqli_query($con, $sql)) { // Update Account Display $result = mysqli_query($con,"SELECT * FROM " . $tn1 . " WHERE `ID` ='" . $_SESSION['userid'] . "'"); $row = mysqli_fetch_array($result); } else { } header('Location: index.htm'); } if (isset($_POST['submitimg'])) { include 'imguploader.php'; $_SESSION['postuploads'] = $target_file; header('Location: index.htm'); } if (isset($_POST['galleryselection'])) { $_SESSION['postuploads'] = $_POST['galleryselection']; header('Location: index.htm'); } if (isset($_POST['closegallery'])) { header('Location: index.htm'); } } ?>