authenticate("U_Groups"); if (!$user['U_Username']) { $html -> not_right ($ubbt_lang['NO_AUTH'],$Cat); } // ------------------------------------------------------ // Let's find out what Groups we are dealing with $Groups = $user['U_Groups']; if (!$Groups) { $Groups = "-4-"; } // ------------------------------------------------------------------- // We need to format a SQL query to see what boards this user can view $Grouparray = split("-",$Groups); $gsize = sizeof($Grouparray); $groupquery = "AND ("; $g = 0; for ($i=0; $i<$gsize;$i++) { if (!preg_match("/[0-9]/",$Grouparray[$i])) { continue; }; $g++; if ($g > 1) { $groupquery .= " OR "; } $groupquery .= "Bo_Read_Perm LIKE '%-$Grouparray[$i]-%'"; } $groupquery .= ")"; // -------------------------- // What board is this post in $Number = addslashes($Number); $query = " SELECT B_Board FROM {$config['tbprefix']}Posts WHERE B_Number='$Number' "; $sth = $dbh -> do_query($query,__LINE__,__FILE__); list($Board) = $dbh -> fetch_array($sth); $Board_q = addslashes($Board); // -------------------------------------------- // Let's find out if they should be here or not $query = " SELECT Bo_Title FROM {$config['tbprefix']}Boards WHERE Bo_Keyword = '$Board_q' AND Bo_Active='1' $groupquery "; $sth = $dbh -> do_query($query,__LINE__,__FILE__); list($title) = $dbh -> fetch_array($sth); if (!$title) { $html -> not_right($ubbt_lang['NO_PERM'],$Cat); } // ----------------------------------------------------------------------- // Grab the last_post date of this thread and make sure it is a main topic if ($type == "favorite") { $query = " SELECT B_Last_Post,B_Topic FROM {$config['tbprefix']}Posts WHERE B_Number = '$main' "; $sth = $dbh -> do_query($query,__LINE__,__FILE__); list($lastpost,$topic) = $dbh -> fetch_array($sth); if (!$topic) { $html -> not_right($ubbt_lang['MAIN_ONLY'],$Cat); } } // ----------------------------------------------- // Let's make sure this isn't already in our list if ($type == "favorite") { $type = "f"; } else { $type = "r"; } $query = " SELECT F_Number FROM {$config['tbprefix']}Favorites WHERE F_Owner = '{$user['U_Number']}' AND F_Thread = '$main' AND F_Type = '$type' "; $sth = $dbh -> do_query($query,__LINE__,__FILE__); list($check) = $dbh -> fetch_array($sth); if (!$check) { // ------------------------------------------------------ // Insert the details into the database $Board_q = addslashes($Board); if (!isset($lastpost)) { $lastpost = 0; } $query = " INSERT INTO {$config['tbprefix']}Favorites (F_Owner, F_Thread, F_Type, F_LastPost) VALUES ('{$user['U_Number']}', '$main', '$type', '$lastpost') "; $dbh -> do_query($query,__LINE__,__FILE__); $confirm = $ubbt_lang['FAV_CONFIRM']; $header = $ubbt_lang['ENTRY_IN']; } else { $query = " DELETE FROM {$config['tbprefix']}Favorites WHERE F_Owner = '{$user['U_Number']}' AND F_Thread = '$main' AND F_Type = '$type' "; $dbh -> do_query($query,__LINE__,__FILE__); $confirm = $ubbt_lang['REM_FAV']; $header = $ubbt_lang['ENTRY_OUT']; } // ------------------------------------------ // Give confirmation and return to the thread $html -> send_header($ubbt_lang['ENTRY_IN'],$Cat,"",$user); list($tbopen,$tbclose) = $html -> table_wrapper(); if (!$debug) { include("$thispath/templates/$tempstyle/addfav.tmpl"); } $html -> send_footer(); ?>