authenticate("U_Favorites,U_Groups"); $html = new html; if (!$user['U_Username']) { $html -> not_right ($ubbt_lang['NO_AUTH'],$Cat); } // ------------------------------------------------------ // Let's find out what Groups we are dealing with $Board_q = addslashes($Board); $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 .= ")"; // -------------------------------------------- // Let's find out if they should be here or not $query = " SELECT Bo_Title,Bo_Number FROM {$config['tbprefix']}Boards WHERE Bo_Keyword = '$Board_q' $groupquery "; $sth = $dbh -> do_query($query); list($title,$fnumber) = $dbh -> fetch_array($sth); if (!$title) { $html -> not_right($ubbt_lang['NO_PERM'],$Cat); } // ------------------------- // We have an 83 forum limit if (strlen($user['U_Favorites'] == 249)) { $html -> not_right($ubbt_lang['TOO_MANY'],$Cat); } // ----------------------------------------------- // Let's make sure this isn't already in our list // If it is then we remove it from the fav list if (stristr($user['U_Favorites'],"-$fnumber-") ) { $user['U_Favorites'] = str_replace("-$fnumber-","-",$user['U_Favorites']); $Owner_q = addslashes($user['U_Username']); $query = " UPDATE {$config['tbprefix']}Users SET U_Favorites = '{$user['U_Favorites']}' WHERE U_Username = '$Owner_q' "; $dbh -> do_query($query); $heading = $ubbt_lang['FORUM_OUT']; $forumconfirm = $ubbt_lang['FORUMOUT_CONFIRM']; } else { // ------------------------------------------------------ // Insert the details into the database $user['U_Favorites'] .="$fnumber-"; $Owner_q = addslashes($user['U_Username']); $query = " UPDATE {$config['tbprefix']}Users SET U_Favorites = '{$user['U_Favorites']}' WHERE U_Username = '$Owner_q' "; $dbh -> do_query($query); $heading = $ubbt_lang['FORUM_IN']; $forumconfirm = $ubbt_lang['FORUM_CONFIRM']; } // ------------------------------------------ // Give confirmation and return to the thread $html -> send_header($heading,$Cat,"",$user); // --------------------- // Grab the tablewrapper list($tbopen,$tbclose) = $html -> table_wrapper(); // -------------------- // Include the template if (!$debug) { include ("$thispath/templates/$tempstyle/addfavforum.tmpl"); } $html -> send_footer(); ?>