require_once("init.inc");
nav_play();
title("Command");
int_register("BannerID");
string_register( "bannerName" );
if (!$Character->checkPosition('Ruler')) Error( "You aren't a ruler; what are you doing here?" );
if ($Character->getRealm()->getStatus()=='NPC'&&$Character->getMainclass()!='NPC') Error( "You cannot change the banner of this realm. You will have to leave that to a higher power." );
$upload_dir = SPREFIX."/var/upload/";
$banner_dir = "/icons/";
if (isset($BannerID)) {
if ($MyLocation->getRealm() != $Character->getRealm()) Error("You must be within your realm if you want to change the very symbol of your realm.");
// This is checking to see if the government system has been changed in the last week, has to exist for longer than that first
if ($Character->getRealm()->getDaysExisting()>7 &&
$Character->getRealm()->getLastChange() &&
$Character->getRealm()->getLastChange()->diff(new \DateTime('now'))->days<7) {
Error( "You cannot make changes so often; it confuses the people." );
}
$Banner = DoctrineMainEM()->getRepository('App\Entity\Main\Banner')->find($BannerID);
if ( $Banner->getWorldId() || $Banner->getRealmId() ) {
Error( "This banner is already in use on world ID {$Banner->getWorldId()}, in realm ID {$Banner->getRealmId()}." );
} else if ( $Banner->getStatus() != "normal" ) {
Error( "You cannot select this banner for use." );
}
$RealmBanner = $Character->getRealm()->findRealmBanner();
if ( $RealmBanner ) {
$RealmBanner->setWorldId(null)
->setRealmId(null);
}
$Banner->setWorldId($World);
$Banner->setRealmId($Character->getRealm()->getId());
$Character->getRealm()->setBanner($Banner->getBannerFile())
->setIcon($Banner->getIconFile());
DoctrineWorldEM()->flush();
DoctrineMainEM()->flush();
echo "
You have now set the banner and icon for your realm.
";
} else if ( isset( $bannerName ) ) {
//$UploadBanner = new Array();
//$UploadIcon = new Array();
$uploadBanner['name'] = $_FILES['UploadBanner']['name'][0];
$uploadIcon['name'] = $_FILES['UploadBanner']['name'][1];
$uploadBanner['type'] = $_FILES['UploadBanner']['type'][0];
$uploadIcon['type'] = $_FILES['UploadBanner']['type'][1];
$uploadBanner['tmp_name'] = $_FILES['UploadBanner']['tmp_name'][0];
$uploadIcon['tmp_name'] = $_FILES['UploadBanner']['tmp_name'][1];
$uploadBanner['size'] = $_FILES['UploadBanner']['size'][0];
$uploadIcon['size'] = $_FILES['UploadBanner']['size'][1];
if ( !is_uploaded_file( $uploadBanner['tmp_name'] ) || !is_uploaded_file( $uploadIcon['tmp_name'] ) ) {
Error( "Trying to do something sneaky, are you? Tom doesn't like that..." );
// TODO: Log security breach attempt?
}
$newbfile = $upload_dir.$uploadBanner['name'];
$newifile = $upload_dir.$uploadIcon['name'];
if ( !copy($uploadBanner['tmp_name'],$newbfile) ) {
Error( "Could not copy the uploaded banner file to the upload directory." );
// TODO: Log error
}
if ( !copy($uploadIcon['tmp_name'],$newifile) ) {
Error( "Could not copy the uploaded icon file to the upload directory." );
// TODO: Log error
}
$NewBanner = \App\Entity\Main\Banner::Create($bannerName);
$NewBanner->setBannerFile($uploadBanner['name'])
->setIconFile($uploadIcon['name'])
->setStatus('submitted')
->setWorldId($World)
->setRealmId($Character->getRealm()->getId())
->setWidth(200)
->setHeight(200);
DoctrineMainEM()->persist($NewBanner);
DoctrineMainEM()->flush();
$mailmsg = "A new banner has been uploaded by {$Character->getName()}, ruler of realm {$Character->getRealm()->getId()} ({$Character->getRealm()->getName()}) on world $World, for you to review. It is currently at $newbfile, with the associated icon file at $newifile. You can view all the banners in the system, approve uploaded banners, and check for orphaned banners, at http://admin.battlemaster.org/bannerlist.php";
require_once("post_to_forum.php");
post_to_forum("New Banner Uploaded", $mailmsg, 18, 6409);
echo "The Admins have been informed of the new banner, and they will hopefully review your new banner shortly.";
} else {
?>
Banner Select
Choose a new banner from the list below, which lists all currently
unused banners available. You can also submit your own banners - see
below for
rules on banners
before you make your own.
Just click on the icon to preview its associated banner below, then
click "Set Banner" to choose it for your realm.
=$bannerTable?>
Banners can be of any size, but you should not exceed 200 pixels in
either direction, or they may be refused. Please use the PNG format and
make them have a transparent background.
Icons are 24x24, gif or (indexed, not RGB) png. Remember to use
transparency when creating them.
It would also be great if you could follow the rules of heraldry a
little and use heraldic banners and not just any picture or such. You
should especially care about the colours you use. For example, the
colour you set as your realm colour should be the primary colour of your
banner.
Here are some links to heraldic webpages and software that you can use
to create banners:
Upload Banner
If you have already created a new banner that you wish to upload for
consideration by Tom for your realm, you can do so here.
}
status(); ?>