-if (isset($_POST['ok']))
-{
- // Check if category and number of receivers is okay
- $CAT_TABS = "%s"; $CAT_WHERE = ""; $cat = "";
- if ($_POST['cat'] > 0)
- {
- // Select category
- $CAT_TABS = "LEFT JOIN "._MYSQL_PREFIX."_user_cats AS c ON d.userid=c.userid";
- $cat = bigintval($_POST['cat']);
- $CAT_WHERE = " AND c.cat_id=%s";
- }
- if (GET_EXT_VERSION("holiday") >= "0.1.3")
- {
- // Add something for the holiday extension
- $CAT_WHERE .= " AND d.holiday_active='N'";
- }
-
- if (($EXT_HTML) && ($_GET['mode'] == "html"))
- {
- // Only include HTML receivers
- $result = SQL_QUERY_ESC("SELECT d.userid FROM "._MYSQL_PREFIX."_user_data AS d ".$CAT_TABS." WHERE d.status='CONFIRMED' AND d.html='Y'".$CAT_WHERE." ORDER BY d.%s %s LIMIT %s",
- array($cat, $_CONFIG['order_select'], $_CONFIG['order_mode'], bigintval($_POST['receiver'])), __FILE__, __LINE__);
- }
- else
- {
- // Include all
- $result = SQL_QUERY_ESC("SELECT d.userid FROM "._MYSQL_PREFIX."_user_data AS d ".$CAT_TABS." WHERE d.status='CONFIRMED'".$CAT_WHERE." ORDER BY d.%s %s LIMIT %s",
- array($cat, $_CONFIG['order_select'], $_CONFIG['order_mode'], bigintval($_POST['receiver'])), __FILE__, __LINE__);
- }
- if ((SQL_NUMROWS($result) == $_POST['receiver']) && ($_POST['receiver'] > 0))
- {
- $RECEIVER = "";
- while (list($REC) = SQL_FETCHROW($result))
- {
- // Add receiver when not empty
- if (!empty($REC)) $RECEIVER .= ";".$REC;
- }
-
- // Free memory
- SQL_FREERESULT($result);
- $RECEIVER = substr($RECEIVER, 1);
-
- // Gettings points is oka, so we can add $USED later from
- if ($EXT_HTML)
- {
- $HTML = "N";
- if ($_GET['mode'] == "html") $HTML = "Y";
- $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_bonus
-(subject, text, receivers, points, time, data_type, timestamp, url, cat_id, target_send, mails_sent, html_msg)
-VALUES ('%s', '%s', '%s', '%s', '%s', 'NEW', UNIX_TIMESTAMP(), '%s', '%s', '%s', '%s', '%s')",
- array(
- $_POST['subject'],
- addslashes($_POST['text']),
- $RECEIVER,
- $_POST['points'],
- $_POST['seconds'],
- $_POST['url'],
- $cat,
- SELECTION_COUNT(explode(";", $RECEIVER)),
- bigintval($_POST['receiver']),
- $HTML
-), __FILE__, __LINE__);
- }
- else
- {
- $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_bonus
-(subject, text, receivers, points, time, data_type, timestamp, url, cat_id, target_send, mails_sent)
-VALUES ('%s', '%s', '%s', '%s', '%s', 'NEW', UNIX_TIMESTAMP(), '%s', '%s', '%s', '%s')",
- array(
- $_POST['subject'],
- addslashes($_POST['text']),
- $RECEIVER,
- $_POST['points'],
- $_POST['seconds'],
- $_POST['url'],
- $cat,
- SELECTION_COUNT(explode(";", $RECEIVER)),
- bigintval($_POST['receiver']),
-), __FILE__, __LINE__);
- }
-
- // Mail inserted into bonus pool
- LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_BONUS_SEND);
- }
- else
- {
- // More entered than can be reached!
- LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_MORE_SELECTED);
- }
- if (!empty($URL))
- {
- // Redirect to requested URL
- LOAD_URL($URL);
- }