<?php
#######################################################|#
#|                    HabboMCMS - TheRox
#|                    Powered by HoloCMS 
#|            Copyright 2011-2012 ALL RIGHTS RESERVED
#######################################################|#

require_once('../global.php');
require_once('../INC/class.session.php');

$refer = $_SERVER['HTTP_REFERER']; $pos = strrpos($refer, "group_profile.php"); if ($pos === false) { exit; }
$groupid = Filter($_POST['groupId']);
$targets = Filter($_POST['targetIds']);

$targets = explode(",", $targets);
if(!is_numeric($groupid)){ exit; }

$check = mysql_query("SELECT * FROM groups_details WHERE id = '".$groupid."' LIMIT 1") or die(mysql_error());
$valid = mysql_num_rows($check);
if($valid < 1){ exit; }

// Loop through all the members
foreach($targets as $member){
        if(is_numeric($member)){
                $valid = mysql_evaluate("SELECT COUNT(*) FROM users WHERE id = '".$member."' LIMIT 1");
                if($valid > 0){
                        mysql_query("UPDATE groups_memberships SET is_pending = '0' WHERE userid = '".$member."' AND groupid = '".$groupid."' LIMIT 1") or die(mysql_error());
                }
        }
}

echo "OK"; exit;

?>