Another Snippet from Trinity Entertainment this time from Koreans custom management panel
This allows users to manage their clans you can combine this with your existing player management panel very easily with a few tweaks it allows users to control many aspects of their clan or even create a clan
GetInfo.php(It's an include)
Andd clan.phpPHP Code:<?php
$getcharnames = odbc_exec($connection, "
SELECT Name
FROM Character
WHERE AID = '$_SESSION[AID]' AND Deleteflag = '0'
");
$CN1 = odbc_result($getcharnames, 1);
$getcharnames = odbc_exec($connection, "
SELECT Name
FROM Character
WHERE AID = '$_SESSION[AID]' AND Deleteflag = '0' AND Name != '$CN1'
");
$CN2 = odbc_result($getcharnames, 1);
$getcharnames = odbc_exec($connection, "
SELECT Name
FROM Character
WHERE AID = '$_SESSION[AID]' AND Deleteflag = '0' AND Name != '$CN1' AND Name != '$CN2'
");
$CN3 = odbc_result($getcharnames, 1);
$getcharnames = odbc_exec($connection, "
SELECT Name
FROM Character
WHERE AID = '$_SESSION[AID]' AND Deleteflag = '0' AND Name != '$CN1' AND Name != '$CN2' AND Name != '$CN3'
");
$CN4 = odbc_result($getcharnames, 1);
$getcid = odbc_exec($connection, "
SELECT CID
FROM Character
WHERE AID = '$_SESSION[AID]' AND Deleteflag = '0'
");
$CID1 = odbc_result($getcid, 1);
$getcid = odbc_exec($connection, "
SELECT CID
FROM Character
WHERE AID = '$_SESSION[AID]' AND Deleteflag = '0' AND CID != '$CID1'
");
$CID2 = odbc_result($getcid, 1);
$getcid = odbc_exec($connection, "
SELECT CID
FROM Character
WHERE AID = '$_SESSION[AID]' AND Deleteflag = '0' AND CID != '$CID1' AND CID != '$CID2'
");
$CID3 = odbc_result($getcid, 1);
$getcid = odbc_exec($connection, "
SELECT CID
FROM Character
WHERE AID = '$_SESSION[AID]' AND Deleteflag = '0' AND CID != '$CID1' AND CID != '$CID2' AND CID != '$CID3'
");
$CID4 = odbc_result($getcid, 1);
$getclan = odbc_exec($connection, "
SELECT Name
FROM Clan
WHERE MasterCID = '$CID1' AND Deleteflag = '0'
");
$CLAN1 = odbc_result($getclan, 1);
$getclan = odbc_exec($connection, "
SELECT Name
FROM Clan
WHERE MasterCID = '$CID2' AND Deleteflag = '0'
");
$CLAN2 = odbc_result($getclan, 1);
$getclan = odbc_exec($connection, "
SELECT Name
FROM Clan
WHERE MasterCID = '$CID3' AND Deleteflag = '0'
");
$CLAN3 = odbc_result($getclan, 1);
$getclan = odbc_exec($connection, "
SELECT Name
FROM Clan
WHERE MasterCID = '$CID4' AND Deleteflag = '0'
");
$CLAN4 = odbc_result($getclan, 1);
$getclan = odbc_exec($connection, "
SELECT CLID
FROM Clan
WHERE MasterCID = '$CID1' AND Deleteflag = '0'
");
$CLID1 = odbc_result($getclan, 1);
$getclan = odbc_exec($connection, "
SELECT CLID
FROM Clan
WHERE MasterCID = '$CID2' AND Deleteflag = '0'
");
$CLID2 = odbc_result($getclan, 1);
$getclan = odbc_exec($connection, "
SELECT CLID
FROM Clan
WHERE MasterCID = '$CID3' AND Deleteflag = '0'
");
$CLID3 = odbc_result($getclan, 1);
$getclan = odbc_exec($connection, "
SELECT CLID
FROM Clan
WHERE MasterCID = '$CID4' AND Deleteflag = '0'
");
$CLID4 = odbc_result($getclan, 1);
?>
PHP Code:<div align="center">
<script type="text/javascript">
function confirmunassign(){
msg = "Confirm this action?";
return confirm(msg);
}
</script>
<?php
include "getinfo.php";
if( $CN1 == '' )
{
$_SESSION[MSG] = 'You do not have any characters.';
redirect("index.php");
die();
}
?>
<table>
<?php
if( $CLAN1 == '' && $CLAN2 == '' && $CLAN3 == '' && $CLAN4 == '' )
{ ?>
<tr><td colspan=2><center><b>Clan Management Tools</center></b></td></tr>
<tr><td colspan=2><center>Create Clan</center></td></tr>
<form method="post" action="index.php?account=clan">
<tr>
<td colspan=2><center>
<select name="character">
<?php
if( $CN1 == '' )
{
}
else
{
?>
<option value="1"><?php echo $CN1; ?></option>
<?php } ?>
<?php
if( $CN2 == '' )
{
}
else
{
?>
<option value="2"><?php echo $CN2; ?></option>
<?php } ?>
<?php
if( $CN3 == '' )
{
}
else
{
?>
<option value="3"><?php echo $CN3; ?></option>
<?php } ?>
<?php
if( $CN4 == '' )
{
}
else
{
?>
<option value="4"><?php echo $CN4; ?></option>
<?php } ?>
</select>
<input type="text" name="newclan" MAXLENGTH=14/> <input type="submit" name="createclan" value="Create" />
</center>
</td>
</tr>
</form>
<?php
}
else{
?>
<tr><td colspan=2><center><b>Clan Management Tools</center></b></td></tr>
<tr><td colspan=2><center>Create Clan</center></td></tr>
<form method="post" action="index.php?account=clan">
<tr>
<td colspan=2><center>
<select name="character">
<?php
if( $CN1 == '' )
{
}
else
{
?>
<option value="1"><?php echo $CN1; ?></option>
<?php } ?>
<?php
if( $CN2 == '' )
{
}
else
{
?>
<option value="2"><?php echo $CN2; ?></option>
<?php } ?>
<?php
if( $CN3 == '' )
{
}
else
{
?>
<option value="3"><?php echo $CN3; ?></option>
<?php } ?>
<?php
if( $CN4 == '' )
{
}
else
{
?>
<option value="4"><?php echo $CN4; ?></option>
<?php } ?>
</select>
<input type="text" name="newclan" MAXLENGTH=14/> <input type="submit" name="createclan" value="Create" />
</center>
</td>
</tr>
<tr><td> </td></tr>
<tr><td> </td></tr>
</form>
<tr><td colspan=2><center>Clan Selection</center></td></tr>
<form enctype="multipart/form-data" onsubmit="return confirmunassign();" action="index.php?account=clan" method="post">
<tr>
<td colspan=2><center>
<select name="clanselect">
<?php
if( $CLAN1 == '' )
{
}
else
{
?>
<option value="1"><?php echo $CLAN1; echo ' // '; echo $CN1; ?></option>
<?php } ?>
<?php
if( $CLAN2 == '' )
{
}
else
{
?>
<option value="2"><?php echo $CLAN2; echo ' // '; echo $CN2; ?></option>
<?php } ?>
<?php
if( $CLAN3 == '' )
{
}
else
{
?>
<option value="3"><?php echo $CLAN3; echo ' // '; echo $CN3; ?></option>
<?php } ?>
<?php
if( $CLAN4 == '' )
{
}
else
{
?>
<option value="4"><?php echo $CLAN4; echo ' // '; echo $CN4; ?></option>
<?php } ?>
</select>
</center>
</td>
</tr>
<tr><td> </td></tr>
<tr><td colspan=2><center>Reset Clan Score</center></td></tr>
<tr><td colspan=2><center><input type="submit" name="resetclan" value="Reset"></center></td></tr>
<tr><td> </td></tr>
<tr><td colspan=2><center>Delete Clan</center></td></tr>
<tr><td colspan=2><center><input type="submit" name="deleteclan" value="Delete"></center></td></tr>
<tr><td> </td></tr>
<tr><td colspan=2><center>Upload Emblem</center></td></tr>
<tr><td colspan=2><center><input name="uploaded" type="file" /> <input type="submit" name="emblemupload" value="Upload" /></td></tr>
</form>
<?php } ?>
</table>
<br><br>
</div>
<?php
$character = CorrectString($_POST['character']);
if ( $character == 1 )
{
$usecid = $CID1;
}
if ( $character == 2 )
{
$usecid = $CID2;
}
if ( $character == 3 )
{
$usecid = $CID3;
}
if ( $character == 4 )
{
$usecid = $CID4;
}
$clanselect = CorrectString($_POST['clanselect']);
if ( $clanselect == 1 )
{
$useclan = $CLAN1;
$useclid = $CLID1;
}
if ( $clanselect == 2 )
{
$useclan = $CLAN2;
$useclid = $CLID2;
}
if ( $clanselect == 3 )
{
$useclan = $CLAN3;
$useclid = $CLID3;
}
if ( $clanselect == 4 )
{
$useclan = $CLAN4;
$useclid = $CLID4;
}
if( isset($_POST['createclan']) )
{
$checkexist = odbc_exec($connection, "SELECT CLID FROM ClanMember WHERE CID = '$usecid'");
$clanname = CorrectString($_POST['newclan']);
if (preg_match("/^[a-zA-Z0-9| ]{3,}+$/", $clanname))
{
$query01 = odbc_exec($connection, "SELECT CLID FROM Clan WHERE Name = '$clanname'");
if( num_rows($checkexist) != 0 )
{
{
$_SESSION[MSG] = 'That character is a member of another clan.';
redirect("index.php?account=clan");
die();
}
}
elseif( num_rows($query01) != 0 )
{
$_SESSION[MSG] = 'That clan name is taken.';
redirect("index.php?account=clan");
die();
}
else
{
odbc_exec($connection, "
INSERT INTO Clan (Name, MasterCID, RegDate)
VALUES ('$clanname', '$usecid', GETDATE())");
$getclid = odbc_exec($connection, "SELECT CLID FROM Clan WHERE Name = '$clanname' AND MasterCID = '$usecid'");
odbc_fetch_row($getclid);
$clid = odbc_result($getclid, 1);
odbc_exec($connection, "
INSERT INTO ClanMember (CLID, CID, Grade, RegDate)
VALUES ('$clid', '$usecid', 1, GETDATE())");
logclancreate( $clanname, $usecid );
$_SESSION[MSG] = 'Clan creation successful.';
redirect("index.php?account=clan");
die();
}
}
else
{
$_SESSION[MSG] = 'Invalid name format. Please try again.';
redirect("index.php?account=clan");
die();
}
}
elseif( isset($_POST['deleteclan']) )
{
if( $useclan = "" )
{
$_SESSION[MSG] = 'Please fill in all of the fields.';
redirect("index.php?account=clan");
die();
}
else
{
$query01 = odbc_exec($connection, "SELECT CLID, Name FROM Clan WHERE CLID = '$useclid'");
}
if( num_rows($query01) != 1 )
{
$_SESSION[MSG] = 'That clan does not exist.';
redirect("index.php?account=clan");
die();
}
else
{
odbc_fetch_row($query01);
$clid = odbc_result($query01, 1);
$name = odbc_result($query01, 2);
odbc_exec($connection, "DELETE FROM ClanMember WHERE CLID = '$clid'");
odbc_exec($connection, "UPDATE Clan SET Name = NULL, DeleteFlag = 1, Point = 0, DeleteName = '$name' WHERE CLID = '$clid'");
logclandelete( $name );
$_SESSION[MSG] = 'Clan deletion successful.';
redirect("index.php?account=clan");
die();
}
}
elseif( isset($_POST['resetclan']) )
{
$query01 = odbc_exec($connection, "SELECT CLID, Name FROM Clan WHERE CLID = '$useclid'");
if( $useclan == "" )
{
$_SESSION[MSG] = 'Please fill in all of the fields.';
redirect("index.php?account=clan");
die();
}
if( num_rows($query01) != 1 )
{
$_SESSION[MSG] = 'That clan does not exist.';
redirect("index.php?account=clan");
die();
}
else
{
odbc_fetch_row($query01);
$clid = odbc_result($query01, 1);
$name = odbc_result($query01, 2);
odbc_exec($connection, "
UPDATE Clan SET Ranking = 0, Wins=0, Losses=0, Point=1000,
RankIncrease=0, LastDayRanking=0 WHERE CLID = '$clid'");
logclanreset( $name );
$_SESSION[MSG] = 'The clan score has been successfully reset.';
redirect("index.php?account=clan");
die();
}
}
elseif( isset($_POST['emblemupload'] ) ) {
$emblem = CorrectString($_POST['uploaded']) ;
$target = "../emblems/upload/upload/";
$target = $target . basename( $_FILES['uploaded']['name']);
$ok=1;
if ($_FILES['uploaded']['size'] > '15000')
{
$_SESSION[MSG] = 'The file size is too large.';
redirect("index.php?account=clan");
die();
if(($_FILES['uploaded']['type'] != "image/jpeg"))
{
$ok=0;
}
if(($_FILES['uploaded']['type'] != "image/GIF"))
{
$ok=0;
}
if(($_FILES['uploaded']['type'] != "image/PNG"))
{
$ok=0;
}
}
else {$ok=1;}
if ($ok==0)
{
$_SESSION[MSG] = 'Please recheck your image size or format.';
redirect("index.php?account=clan");
die();
}
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
$target = 'upload/' . basename( $_FILES['uploaded']['name']);
odbc_exec($connection, "UPDATE Clan SET EmblemChecksum = EmblemChecksum + 1 WHERE CLID = '$useclid'");
odbc_exec($connection, "UPDATE Clan SET EmblemUrl = 'upload/".$target."' WHERE CLID = '$useclid'");
$_SESSION[MSG] = 'Your emblem has been uploaded. Please allow 12-48 hours for your emblem to appear in-game.';
redirect("index.php?account=clan");
die();
}
else
{
$_SESSION[MSG] = 'There was an unexpected error.';
redirect("index.php?account=clan");
die();
}
}
}
?>
Again, sorry this isn't just a drag and drop work, but it will save some PHP devs plenty of time if they plan on making their own clan management from scrap they can just take a looksi loo here and do some "shortcuts"


Reply With Quote


