Skip to content

Commit

Permalink
Added In Game Mail Support
Browse files Browse the repository at this point in the history
Added ability to send in game mail to characters.
Fixed bug in remote access send() function.
Moved Tiny MCE initalization to email page so it is not available for in
game mail (plain text only allowed).
  • Loading branch information
paintballrefjosh committed Jan 30, 2017
1 parent 3f729c6 commit 3a729a8
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 54 deletions.
2 changes: 1 addition & 1 deletion core/SDL/class.rasocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public function executeCommand($type, $shost, $remote, $command)
// Check for error logging
if($this->debug == TRUE)
{
$this->debugLog[] = 'Got Command: '.$cmd;
$this->debugLog[] = 'Got Command: '.$command;
}

fwrite($this->handle, $command."\n");
Expand Down
6 changes: 3 additions & 3 deletions core/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function output_message($type, $text, $file='', $line='')
{
if($file)$text .= "\n<br>in file: $file";
if($line)$text .= "\n<br>on line: $line";
echo "<div class=\"".$type."\">".$text."</div>";
echo "<div class=\"".$type."\"><b>".$text."</b></div>";
}

// ************************************************************
Expand Down Expand Up @@ -346,7 +346,7 @@ function check_for_symbols($string, $space_check = 0)
{
//$space_check=1 means space is not allowed
$len=strlen($string);
$allowed_chars="abcdefghijklmnopqrstuvwxyzæøåABCDEFGHIJKLMNOPQRSTUVWXYZÆØÅ0123456789";
$allowed_chars="abcdefghijklmnopqrstuvwxyz���ABCDEFGHIJKLMNOPQRSTUVWXYZ���0123456789";
if(!$space_check)
{
$allowed_chars .= " ";
Expand Down Expand Up @@ -376,7 +376,7 @@ function add_pictureletter($text)
{
global $Template;
$letter = substr($text, 0, 1);
$imageletter = strtr(strtolower($letter),"ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ",
$imageletter = strtr(strtolower($letter),"���������������������������������������������������������������������",
"sozsozyyuaaaaaaaceeeeiiiidnoooooouuuuysaaaaaaaceeeeiiiionoooooouuuuyy");
if (strpos("abcdefghijklmnopqrstuvwxyz", $imageletter) === false)
{
Expand Down
47 changes: 3 additions & 44 deletions inc/admin/body_header.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,50 +33,6 @@
<!-- TinyMCE Module -->
<script type="text/javascript" src="modules/tiny_mce/tiny_mce.js"></script>

<script type="text/javascript">
tinyMCE.init({
// General options
mode : "textareas",
theme : "advanced",
plugins : "style,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist",

// Theme options
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,image,|,insertdate,inserttime,preview,|,forecolor",
theme_advanced_buttons3 : "hr,|,charmap,emotions,iespell,|,fullscreen",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,

// Example content CSS (should be your site CSS)
content_css : "css/content.css",

// Drop lists for link/image/media/template dialogs
template_external_list_url : "lists/template_list.js",
external_link_list_url : "lists/link_list.js",
external_image_list_url : "lists/image_list.js",
media_external_list_url : "lists/media_list.js",

// Style formats
style_formats : [
{title : 'Bold text', inline : 'b'},
{title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},
{title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},
{title : 'Example 1', inline : 'span', classes : 'example1'},
{title : 'Example 2', inline : 'span', classes : 'example2'},
{title : 'Table styles'},
{title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}
],

// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});
</script>

<!-- Include the functions.js for cookie setting of realms etc etc -->
<script type="text/javascript">
<!--
Expand All @@ -86,6 +42,9 @@
-->
</script>
<script src="inc/admin/js/functions.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
</head>

<body>
Expand Down
43 changes: 43 additions & 0 deletions inc/admin/script_files/admin.sendgamemail.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,47 @@
echo "Not Included!"; exit;
}
//=======================//

if(isset($_GET['action']))
{
// jquery / ajax character name lookup
if($_GET['action'] == "search")
{
$characters = $CDB->select("SELECT guid, name FROM characters WHERE name LIKE '%".$_GET['term']."%'");
foreach($characters as $row)
{
$json[]=array(
'value' => $row['name'],
'id' => $row['guid']
);
}

die(json_encode($json));
}
}

function sendCharacterMail()
{
include('core/SDL/class.rasocket.php');
$RA = new RA;

$command = "send mail ".$_POST['mail_to']." \"".$_POST['subject']."\" \"".$_POST['msg']."\"";

$response = $RA->send($command, $GLOBALS['cur_selected_realm']);
if($response == 1)
{
output_message('error', 'Error: Unable to connect to server via remote access / SOAP.');
}
elseif($response == 2)
{
output_message('error', 'Error: You are not authorized to perform this command.');
}
else
{
output_message('success', 'Success: Your in game message has been sent to '.$_POST['mail_to'].'.');
}

$RA = null;
}

?>
4 changes: 2 additions & 2 deletions inc/admin/template_files/admin.chartools.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,13 @@
echo "<a href=\"javascript:setcookie('cur_selected_realm', '". $Rlm['id'] ."'); window.location.reload();\">";
if($user['cur_selected_realm'] == $Rlm['id'])
{
echo "<b>".$Rlm['name']."</b>";
echo "<b><font color=green>".$Rlm['name']."</font></b>";
}
else
{
echo $Rlm['name'];
}
echo "</a> |";
echo "</a> | ";
}
?>
</td>
Expand Down
44 changes: 44 additions & 0 deletions inc/admin/template_files/admin.email.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,50 @@
/****************************************************************************/

?>
<script type="text/javascript">
tinyMCE.init({
// General options
mode : "textareas",
theme : "advanced",
plugins : "style,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist",

// Theme options
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,image,|,insertdate,inserttime,preview,|,forecolor",
theme_advanced_buttons3 : "hr,|,charmap,emotions,iespell,|,fullscreen",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,

// Example content CSS (should be your site CSS)
content_css : "css/content.css",

// Drop lists for link/image/media/template dialogs
template_external_list_url : "lists/template_list.js",
external_link_list_url : "lists/link_list.js",
external_image_list_url : "lists/image_list.js",
media_external_list_url : "lists/media_list.js",

// Style formats
style_formats : [
{title : 'Bold text', inline : 'b'},
{title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},
{title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},
{title : 'Example 1', inline : 'span', classes : 'example1'},
{title : 'Example 2', inline : 'span', classes : 'example2'},
{title : 'Table styles'},
{title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}
],

// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
});
</script>

<div class="content">
<div class="content-header">
<h4><a href="?p=admin">Main Menu</a> / Send Email</h4>
Expand Down
67 changes: 63 additions & 4 deletions inc/admin/template_files/admin.sendgamemail.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,70 @@
/****************************************************************************/

?>
<div class="content">
<script type="text/javascript">
$(document).ready(function(){$("#mail_to").autocomplete({source:'?p=admin&sub=sendgamemail&action=search', minLength:2});});
</script>

<div class="content">
<div class="content-header">
<h4><a href="?p=admin">Main Menu</a> / Send in-game Mail</h4>
<h4><a href="?p=admin">Main Menu</a> / Send In Game Mail</h4>
</div> <!-- .content-header -->
<div class="main-content">
<br /><font color="red"><center><b>Under Construction</b><br />Remember, this is just a preview, and not everything is finished yet!</center></font>
<div class="main-content">
<?php
if(isset($_POST['msg']))
{
sendCharacterMail();
}
?>
<form method="POST" class="form label-inline">
<input type="hidden" name="send_ingamemail">
<h2><center>Send In Game Mail</center></h2>
<table>
<tr>
<td align='center'> <b><?php echo $lang['realm']; ?>:</b><br />|
<?php
$Realms = getRealmlist('0');
foreach($Realms as $Rlm)
{
echo "<a href=\"javascript:setcookie('cur_selected_realm', '". $Rlm['id'] ."'); window.location.reload();\">";
if($user['cur_selected_realm'] == $Rlm['id'])
{
echo "<b><font color=green>".$Rlm['name']."</font></b>";
}
else
{
echo $Rlm['name'];
}
echo "</a> | ";
}
?>
</td>
<tr>
</table>
<?php
if(!isset($_POST['mail_to']))
$_POST['mail_to'] = "";
if(!isset($_POST['subject']))
$_POST['subject'] = "";
if(!isset($_POST['msg']))
$_POST['msg'] = "";
?>
<div class="field">
<label for="mail_to">Mail To: </label>
<input id="mail_to" name="mail_to" size="20" type="text" class="medium" value="<?= $_POST['mail_to'];?>" />
</div>
<div class="field">
<label for="subject">Mail Subject: </label>
<input id="subject" name="subject" size="20" type="text" class="medium" value="<?= $_POST['subject'];?>" />
</div>
<div class="field">
<label for="msg">Message: </label>
<textarea id="msg" name="msg" rows="15" cols="78" class="large"><?= $_POST['msg'];?></textarea>
</div>
<br />
<div class="buttonrow-border">
<center><button><span>Send Message</span></button></center>
</div>
</form>
</div>
</div>

0 comments on commit 3a729a8

Please sign in to comment.