function sgang_app_accept() { global $gvars; if (!gang_auth_all($gvars->userid, array('pres', 'vice'))) { echo "<h3>You are not authorized to access this portion of the staff panel.</h3>"; gang_go_back('yourgang.php?action=sgang_home'); return; } if (!isset($_REQUEST['app_id']) or intval($_REQUEST['app_id']) < 1) { echo "<h3>Which application are you accepting?</h3>"; gang_go_back('yourgang.php?action=sgang_apps'); return; } $app_id = intval($_REQUEST['app_id']); $q_count = sprintf('select count(*) from users where gang = %d', $gvars->ir['gang']); list($num_members) = mysql_fetch_row(mysql_query($q_count)); $max_members = $gvars->data['gangCAPACITY']; if ($num_members >= $gvars->data['gangCAPACITY']) { echo "<h3>The {$gvars->name_sl} cannot hold any more members.</h3>"; gang_go_back('yourgang.php?action=sgang_apps'); return; } // appID, appUSER, appGANG, appTEXT <<< $q_get = sprintf('select a.appUSER, u.username from applications as a left join users as u on a.appUSER = u.userid where a.appGANG = %d and a.appID = %d', $gvars->ir['gang'], $app_id); $q_get = mysql_query($q_get); if (!$q_get or mysql_num_rows($q_get) < 1) { echo "<h3>This application does not exist.</h3>"; gang_go_back('yourgang.php?action=sgang_apps'); return; } list($them_id, $them_name) = mysql_fetch_array($q_get); $q_del = sprintf('delete from applications where appGANG = %d and appID = %d', $gvars->ir['gang'], $app_id); mysql_query($q_del); if (mysql_affected_rows() < 1) { echo "<h3>The application could not be accepted.</h3>"; } else { $q_set = sprintf('update users set gang = %d where userid = %d and gang = 0', $gvars->ir['gang'], $them_id); mysql_query($q_set); if (mysql_affected_rows() < 1) { echo "<h3>The application could not be accepted.</h3>"; } else { echo "<h3>The application was accepted.</h3>"; $them_p = gang_get_profile_link($them_id, $them_name); $us_p = gang_get_profile_link($gvars->ir['userid'], $gvars->ir['username']); gang_new_event($gvars->ir['gang'], sprintf('%s accepted an application from %s', $us_p, $them_p), 'escape'); event_add($them_id, sprintf('%s accepted your application to %s', $us_p, $gvars->data['gangNAME']), $gvars->c); } } gang_go_back('yourgang.php?action=sgang_apps'); }
function gang_app2() { global $gvars; if ($gvars->ir['gang']) { echo "<h3>You are in a {$gvars->name_sl}!</h3>"; _gang_auto_clear_user($gvars->ir['userid'], $gvars->ir['gang']); return; } if (!isset($_REQUEST['gang_id']) or intval($_REQUEST['gang_id']) < 1) { echo "<h3>Which {$gvars->name_sl} are you applying to?</h3>"; return; } $gang_id = intval($_REQUEST['gang_id']); if (!isset($_REQUEST['reason']) or strlen($_REQUEST['reason']) < 1) { $reason = 'N\\A'; } else { $reason = $_REQUEST['reason']; } // appID, appUSER, appGANG, appTEXT <<< applications $q_check = sprintf('select count(*) from applications where appUSER = %d', $gvars->userid); list($num_apps) = mysql_fetch_row(mysql_query($q_check)); if ($num_apps >= $gvars->max_apps) { echo "<h3>You are allowed to have a maximum of {$gvars->max_apps} applications pending.</h3>"; return; } $q_get = sprintf('select g.gangNAME, g.gangDESC, g.gangRESPECT, g.gangPRESIDENT, g.gangVICEPRES, g.gangCAPACITY from gangs as g where g.gangID = %d', $gang_id); $q_get = mysql_query($q_get); if (!$q_get or mysql_num_rows($q_get) < 1) { echo "<h3>The {$gvars->name_sl} you selected could not be found.</h3>"; return; } list($gang_name, $desc, $respect, $pres_id, $vice_id, $capacity) = mysql_fetch_row($q_get); $q_set = sprintf('insert into applications (appUSER, appGANG, appTEXT) values (%d, %d, "%s")', $gvars->userid, $gang_id, $gvars->clean($reason)); mysql_query($q_set); if (mysql_affected_rows() < 1) { echo "<h3>The application submission failed.</h3>"; } else { $gang_link = gang_get_gang_link($gang_id, $gang_name); echo "<h3>Your application to {$gang_link} has been submitted.</h3>"; $us_p = gang_get_profile_link($gvars->ir['userid'], $gvars->ir['username']); gang_new_event($gang_id, "{$us_p} submitted an application.", 'escape'); } gang_go_back('gangs.php?action=gang_view&gang_id=' . $gang_id); }
function ygang_leave2() { global $gvars; if ($gvars->userid == $gvars->data['gangPRESIDENT']) { echo "<h3>You cannot leave the {$gvars->name_sl} while you are still the {$gvars->name_sl} {$gvars->pres}.</h3>"; return; } if ($gvars->userid == $gvars->data['gangVICEPRES']) { $q_set = sprintf('update gangs set gangVICEPRES = 0 where gangID = %d', $gvars->ir['gang']); mysql_query($q_set); } $us_p = gang_get_profile_link($gvars->ir['userid'], $gvars->ir['username']); gang_new_event($gvars->ir['gang'], "{$us_p} has left the {$gvars->name_sl}.", 'escape'); $q_set = sprintf('update users set gang = 0 where userid = %d', $gvars->userid); mysql_query($q_set); echo "<h3>You have left the {$gvars->name_sl}.</h3>"; }