예제 #1
0
function sgang_war_surrender2()
{
    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['war_id']) or intval($_REQUEST['war_id']) < 1) {
        echo "<h3>Which war are you surrendering?</h3>";
        gang_go_back('yourgang.php?action=sgang_war');
        return;
    }
    $war_id = intval($_REQUEST['war_id']);
    if (!isset($_REQUEST['msg']) or strlen($_REQUEST['msg']) < 1) {
        echo "<h3>Please submit a message with your surrender.</h3>";
        gang_go_back('yourgang.php?action=sgang_war');
        return;
    }
    $msg = $_REQUEST['msg'];
    // warID, warDECLARER, warDECLARED, warTIME <<< gangwars
    // surID, surWAR, surWHO, surTO, surMSG <<< surrenders
    $q_get = sprintf('select warDECLARER, warDECLARED from gangwars
		where warID = %d and %d in (warDECLARER, warDECLARED)', $war_id, $gvars->ir['gang']);
    $q_get = mysql_query($q_get);
    if (!$q_get or mysql_num_rows($q_get) < 1) {
        echo "<h3>The war you selected could not be found.</h3>";
        gang_go_back('yourgang.php?action=sgang_war');
        return;
    }
    list($us_id, $them_id) = mysql_fetch_row($q_get);
    if ($gvars->ir['gang'] == $them_id) {
        $other_id = $us_id;
    } else {
        $other_id = $them_id;
    }
    $q_get = sprintf('select gangNAME from gangs where gangID = %d', $other_id);
    $q_get = mysql_query($q_get);
    if (!$q_get or mysql_num_rows($q_get) < 1) {
        echo "<h3>The {$gvars->name_sl} you are warring does not exist. The war will be canceled.</h3>";
        mysql_query(sprintf('delete from gangwars where %d in (warDECLARER, warDECLARED)', $other_id));
        gang_go_back('yourgang.php?action=sgang_war');
        return;
    }
    list($other_name) = mysql_fetch_row($q_get);
    $other_p = gang_get_gang_link($other_id, $other_name);
    $q_get = sprintf('select count(*) from surrenders
		where surWAR = %d and %d in (surWHO, surTO)', $war_id, $gvars->ir['gang']);
    $q_get = mysql_query($q_get);
    list($has_surrendered) = mysql_fetch_row($q_get);
    if ($has_surrendered) {
        echo "<h3>A surrender has already been offered in this war.</h3>";
        gang_go_back('yourgang.php?action=sgang_war');
        return;
    }
    $q_set = sprintf('insert into surrenders (surWAR, surWHO, surTO, surMSG)
		values (%d, %d, %d, "%s")', $war_id, $gvars->ir['gang'], $other_id, $gvars->clean($msg));
    mysql_query($q_set);
    if (mysql_affected_rows() < 1) {
        echo "<h3>The surrender could not be submitted.</h3>";
    } else {
        echo "<h3>The surrender was submitted.</h3>";
        $us_p = gang_get_profile_link($gvars->ir['userid'], $gvars->ir['username']);
        $us_gang__p = gang_get_profile_link($gvars->ir['gang'], $gvars->data['gangNAME']);
        gang_new_event($gvars->ir['gang'], sprintf('%s asked for a surrender from %s.', $us_p, $other_p), 'escape');
        gang_new_event($other_id, sprintf('%s asked for a surrender.', $us_gang__p), 'escape');
    }
    gang_go_back('yourgang.php?action=sgang_war');
}
예제 #2
0
function gang_app_cancel()
{
    global $gvars;
    if (!isset($_REQUEST['app_id']) or intval($_REQUEST['app_id']) < 1) {
        echo "<h3>Which application are you cancelling?</h3>";
        gang_go_back('gangs.php?action=gang_my_apps');
        return;
    }
    $app_id = intval($_REQUEST['app_id']);
    // appID, appUSER, appGANG, appTEXT <<< applications
    $q_get = sprintf('select a.appID, g.gangID, g.gangNAME from applications as a
		left join gangs as g on a.appGANG = g.gangID
		where appUSER = %d and appID = %d', $gvars->userid, $app_id);
    $q_get = mysql_query($q_get);
    if (!$q_get or mysql_num_rows($q_get) < 1) {
        echo "<h3>Which application are you cancelling?</h3>";
        gang_go_back('gangs.php?action=gang_my_apps');
        return;
    }
    list($app_id, $gang_id, $gang_name) = mysql_fetch_row($q_get);
    $gang_name = gang_get_gang_link($gang_id, $gang_name);
    $q_del = sprintf('delete from applications where appUSER = %d and appID = %d', $gvars->userid, $app_id);
    mysql_query($q_del);
    if (mysql_affected_rows() < 1) {
        echo "<h3>The application could not be deleted.</h3>";
    } else {
        $gang_link = gang_get_gang_link($gang_id, $gang_name);
        echo "<h3>Your application to {$gang_link} has been deleted.</h3>";
    }
    gang_go_back('gangs.php?action=gang_my_apps');
}
예제 #3
0
function ygang_attack_logs()
{
    global $gvars;
    // log_id, attacker, attacked, result, time, stole, attacklog <<< attacklogs
    //Attack Logs - The last 50 attacks involving someone in your gang
    $q_get = sprintf('select l.attacker, a.username, l.attacked, b.username, l.result, l.time, l.stole
		from attacklogs as l
		left join users as a on l.attacker = a.userid
		left join users as b on l.attacked = b.userid
		where %d in (a.gang, b.gang)
		order by l.time desc
		limit 50
	', $gvars->ir['gang']);
    $q_get = mysql_query($q_get);
    if (!$q_get or mysql_num_rows($q_get) < 1) {
        $logs = <<<EOT
\t\t\t<tr>
\t\t\t\t<td class="center bold" colspan="5">
\t\t\t\tThere have been no attacks on members of your {$gvars->name_sl}.
\t\t\t\t</td>
\t\t\t</tr>

EOT;
    } else {
        $logs = '';
        while (list($a_id, $a_name, $b_id, $b_name, $result, $time, $stole) = mysql_fetch_row($q_get)) {
            $ap = gang_get_gang_link($a_id, $a_name);
            $bp = gang_get_gang_link($b_id, $b_name);
            if ($result === 'won') {
                $result = $a_name;
            } else {
                if ($result === 'lost') {
                    $result = $b_name;
                } else {
                    $result = 'draw';
                }
            }
            $time = gang_time_format($time);
            $stole = '$' . number_format($stole);
            $logs .= <<<EOT
\t\t\t<tr>
\t\t\t\t<td>
\t\t\t\t{$ap}
\t\t\t\t</td>
\t\t\t\t<td>
\t\t\t\t{$bp}
\t\t\t\t</td>
\t\t\t\t<td>
\t\t\t\t{$result}
\t\t\t\t</td>
\t\t\t\t<td>
\t\t\t\t{$stole}
\t\t\t\t</td>
\t\t\t\t<td>
\t\t\t\t{$time}
\t\t\t\t</td>
\t\t\t</tr>

EOT;
        }
    }
    echo <<<EOT
\t<h2>Attack Logs</h2>
\t<p class="center bold">The last 50 attacks involving someone in your {$gvars->name_sl}.</p>
\t<table style="width: 500">
\t\t<tr>
\t\t\t<th>
\t\t\tAttacker
\t\t\t</th>
\t\t\t<th>
\t\t\tDefender
\t\t\t</th>
\t\t\t<th>
\t\t\tWinner
\t\t\t</th>
\t\t\t<th>
\t\t\tLoot
\t\t\t</th>
\t\t\t<th>
\t\t\tTime
\t\t\t</th>
\t\t</tr>
{$logs}
\t</table>
EOT;
}