This commit is contained in:
2025-09-18 21:00:20 -06:00
parent 0e2d3152e9
commit d7f2b5d1d6
18 changed files with 327 additions and 162 deletions

105
irpg-web/admincomms.php Normal file
View File

@@ -0,0 +1,105 @@
<?php
include("config.php");
$irpg_page_title = "Admin Game Info";
$irpg_page_desc = "IdleRPG Game Info for Admins";
include("header.php");
?>
<h1>Idle RPG</h1>
<h2>Admin Commands</h2>
<p>This is not the full list of commands for the Idle RPG bot, but only
the list of admin commands.</p>
<dl>
<dt>INFO</dt>
<dd>retrieve some fairly useless stats about the bot.</dd>
<dt>DIE</dt>
<dd>kills the bot.</dd>
<dt>HOG</dt>
<dd>summon the Hand of God spell. See the main help file.</dd>
<dt>RESTART</dt>
<dd>restarts the bot.</dd>
<dt>CHPASS &lt;char name&gt; &lt;new password&gt;</dt>
<dd>change a character&apos;s pass in the IRPG.</dd>
<dt>CHCLASS &lt;char name&gt; &lt;new class name&gt;</dt>
<dd>change a character&apos;s class in the IRPG.</dd>
<dt>CHUSER &lt;char name&gt; &lt;new char name&gt;</dt>
<dd>change a character&apos;s username in the IRPG.
Please only use in very special circumstances; otherwise, have them
form a new player and DEL the old one. This should not let you
overwrite an existing account, but is untested.</dd>
<dt>PUSH &lt;char name&gt; &lt;seconds&gt;</dt>
<dd>push a player toward his goal by subtracting time
from his next time to level. Please use this only if bot has mistakenly
penalized someone. You could also use this to punish a user by setting
the number of seconds to a negative number. Don&apos;t do that.</dd>
<dt>DEL &lt;char name&gt;</dt>
<dd>remove a user&apos;s account.</dd>
<dt>JUMP &lt;server[:port]&gt;</dt>
<dd>move the bot to another server.</dd>
<dt>SILENT &lt;mode&gt;</dt>
<dd>switch bot between 4 modes of silence.
<ul>
<li>mode 0, bot sends all privmsgs.</li>
<li>mode 1, only chanmsg() is disabled.</li>
<li>mode 2, only privmsg()/notice() to non-channels is disabled.</li>
<li>mode 3, privmsgs/notices to users and channels are disabled.</li>
</ul>
</dd>
<dt>BACKUP</dt>
<dd>tell bot to copy $opts{&apos;dbfile&apos;} to .dbbackup/$opts{&apos;dbfile&apos;}TIMESTAMP</dd>
<dt>RELOADDB</dt>
<dd>force bot to reload player database file, rewriting all memory.
RELOADDB can only be used while in pause mode.</dd>
<dt>PAUSE</dt>
<dd>toggle pause mode.</dd>
<dt>PEVAL &lt;code&gt;</dt>
<dd>execute arbitrary argument as Perl code. Queues output &gt; 3 lines
or &gt; 1k of text. Some useful PEVAL commands:
<ul>
<li>Delete all accounts not logged in in 4 weeks (See also: DELOLD):<br />
<code>
/msg bot PEVAL delete $rps{$_} for grep { time()-$rps{$_}{lastlogin} &gt; 3600*24*7*4 && !$rps{$_}{online} } keys %rps;
</code>
</li>
<li>Remove one hour from everyone&apos;s clocks:<br />
<code>
/msg bot PEVAL $rps{$_}{next} -= 3600 for keys %rps;
</code>
</li>
<li>List all online users, separated by commas:<br />
<code>
/msg bot PEVAL join(&apos;, &apos;,grep { $rps{$_}{online} } keys %rps);
</code>
</li>
<li>View contents of a file on remote host:<br />
<code>
/msg bot PEVAL `cat file`
</code>
</li>
<li>Turn on debug mode:<br />
<code>
/msg bot PEVAL $opts{debug}=1;
</code>
</li>
<li>Force write-out of database:<br />
<code>
/msg bot PEVAL writedb();
</code>
</li>
</ul>
</dd>
<dt>DELOLD &lt;days&gt;</dt>
<dd>remove all non-logged-in accounts inactive in the last &lt;days&gt;
days.</dd>
<dt>CLEARQ</dt>
<dd>clear the outgoing message queue. Useful to use if someone floods
the bot with a lot of text that it plans to respond to.</dd>
<dt>MKADMIN &lt;username&gt;</dt>
<dd>set the isadmin flag for a given username.</dd>
</dl>
<?php
include("footer.php");
?>

View File

@@ -1,64 +0,0 @@
This is not the full list of commands for the Idle RPG bot, but only the list
of admin commands.
INFO, retrieve some fairly useless stats about the bot.
DIE, kills the bot.
HOG, summon the Hand of God spell. See the main help file.
RESTART, restarts the bot.
CHPASS <char name> <new password>, change a character's pass in the IRPG.
CHCLASS <char name> <new class name>, change a character's class in the IRPG.
CHUSER <char name> <new char name>, change a character's username in the IRPG.
Please only use in very special circumstances; otherwise, have them form
a new player and DEL the old one. This should not let you overwrite an
existing account, but is untested.
PUSH <char name> <seconds>, push a player toward his goal by subtracting time
from his next time to level. Please use this only if bot has mistakenly
penalized someone. You could also use this to punish a user by setting
the number of seconds to a negative number. Don't do that.
DEL <char name>, remove a user's account.
JUMP <server[:port]>, move the bot to another server.
SILENT <mode>, switch bot between 4 modes of silence.
- mode 0, bot sends all privmsgs.
- mode 1, only chanmsg() is disabled.
- mode 2, only privmsg()/notice() to non-channels is disabled.
- mode 3, privmsgs/notices to users and channels are disabled.
BACKUP, tell bot to copy $opts{'dbfile'} to .dbbackup/$opts{'dbfile'}TIMESTAMP
RELOADDB, force bot to reload player database file, rewriting all memory.
RELOADDB can only be used while in pause mode.
PAUSE, toggle pause mode.
PEVAL <code>, execute arbitrary argument as Perl code. Queues output > 3 lines
or >1k of text. Some useful PEVAL commands:
- Delete all accounts not logged in in 4 weeks (See also: DELOLD):
/msg bot PEVAL delete $rps{$_} for grep { time()-$rps{$_}{lastlogin} > 3600*24*7*4 && !$rps{$_}{online} } keys %rps;
- Remove one hour from everyone's clocks:
/msg bot PEVAL $rps{$_}{next} -= 3600 for keys %rps;
- List all online users, separated by commas:
/msg bot PEVAL join(', ',grep { $rps{$_}{online} } keys %rps);
- View contents of a file on remote host:
/msg bot peval `cat file`
- Turn on debug mode:
/msg bot peval $opts{debug}=1;
- Force write-out of database:
/msg bot peval writedb();
DELOLD <days>, remove all non-logged-in accounts inactive in the last <days>
days.
CLEARQ, clear the outgoing message queue. Useful to use if someone floods the
bot with a lot of text that it plans to respond to.
MKADMIN <username>, set the isadmin flag for a given username.

50
irpg-web/captchaimage.php Normal file
View File

@@ -0,0 +1,50 @@
<?php
session_start();
// Create a blank image
$width = 52;
$height = 16;
$image = imagecreate($width, $height);
$backgroundColor = imagecolorallocate($image, 212, 255, 226);
imagefilledrectangle($image, 0, 0, $width, $height, $backgroundColor);
// Add some text
$captchaString = "";
$allowedChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$charColor = imagecolorallocate($image, 64, 64, 64);
$numChars = 5;
for ($i=0; $i<$numChars; $i++)
{
$char = $allowedChars[rand(0, strlen($allowedChars)-1)];
imagestring($image, 5, 2+($i*10), 0, $char, $charColor);
$captchaString .= $char;
}
// Save the text to a session variable.
$_SESSION['captchaString'] = $captchaString;
// Add some lines
$lineColor = imagecolorallocate($image, 234, 132, 13);
$numLines = rand(2,2);
for($i=0; $i<$numLines; $i++)
{
imageline($image, 0, rand()%16, 52, rand()%16, $lineColor);
}
// Add some pixels
$pixelColor = imagecolorallocate($image, 11, 213, 142);
$numPixels = rand(38,40);
for($i=0; $i<$numPixels; $i++)
{
imagesetpixel($image, rand()%52, rand()%16, $pixelColor);
}
// Set the content type header - in this case image/jpeg
header('Content-type: image/jpeg');
// Output the image
imagejpeg($image);
// Free up memory
imagedestroy($image);
?>

View File

@@ -5,6 +5,9 @@ $admin_nick="admin";
// admin email
$admin_email="admin@mynet.org";
// web version
$irpg_version = "0.0.4";
// your game's bot nickname
$irpg_bot="IdleBot";
@@ -20,6 +23,12 @@ $irpg_irc_network_name="MyNet IRC Network";
// your server's network address advertisement
$irpg_irc_network_address="ircs://irc.mynet.org:7000";
// your server's network info advertisement
// leave this empty if you don't have any special info or notes
// $irpg_irc_network_info="* This IRC Network requires SASL authentication using".
// " your forum username and password";
$irpg_irc_network_info="";
// base directory of your game's url
// my site is https://www.mynet.org/irpg/, so it's "/irpg/"
$irpg_base_dir="/irpg/";

View File

@@ -1,8 +1,17 @@
<?php
session_start();
include("config.php");
$irpg_page_title = "Contact";
$irpg_page_desc = "IdleRPG Contact";
include("header.php");
if (!$_SESSION['captchaString'] || $_SESSION['captchaString'] == "") {
$numA = rand(0, 9);
$numB = rand(0, 9);
$numC = rand(0, 9);
$numD = rand(0, 9);
$numE = rand(0, 9);
$_SESSION['captchaString'] = $numA.$numB.$numC.$numD.$numE;
}
echo "<h1>Contact</h1>";
if (!$irpg_site_email) {
@@ -11,35 +20,57 @@
else if ($irpg_site_email == "disabled") {
echo " <blockquote>Email is disabled.</blockquote>\n";
}
else if ($irpg_site_email == "php" && $_POST['from'] && $_POST['text']) {
$to = $admin_email;
$subject = "IdleRPG: ".$_POST['from'];
$message = "Name: ".$_POST['name']."\nE-mail: ".$_POST['from']."\n\n".$_POST['text'];
$additional_headers = "From: ".$_POST['from']."\r\n";
mail($to, $subject, $message, $additional_headers);
echo " <blockquote>Thanks for your submission.</blockquote>\n";
else if ($irpg_site_email == "php" && $_POST['from_email'] && $_POST['message'] && $_POST['captchaString']) {
if (strtolower($_POST['captchaString']) != strtolower($_SESSION['captchaString'])) { echo " <blockquote>Your CAPTCHA didn't match.</blockquote>\n"; }
else if (!filter_var($_POST['from_email'], FILTER_VALIDATE_EMAIL)) { echo " <blockquote>Your email address isn't valid.</blockquote>\n"; }
else {
$to = $admin_email;
$subject = "IdleRPG: Contact Form";
$message = "Name: ".$_POST['from_name']."\nEmail: ".$_POST['from_email']."\n\n".$_POST['message'];
$additional_headers = "From: ".$_POST['from_name']." <".$_POST['from_email'].">\r\n";
mail($to, $subject, $message, $additional_headers);
echo " <blockquote>Thanks for your submission.</blockquote>\n";
$_SESSION['captchaString'] = "";
}
}
else if ($irpg_site_email == "smtp" && $_POST['from'] && $_POST['text']) {
echo " <blockquote>SMTP Email is under construction. Your submission was not submitted.</blockquote>\n";
else if ($irpg_site_email == "smtp" && $_POST['from_email'] && $_POST['message'] && $_POST['captchaString']) {
echo " <blockquote>SMTP Email is under construction.</blockquote>\n";
}
else {
echo " <form method=\"post\" action=\"contact.php\">\n".
" <table border=\"0\">\n".
" <tr>\n".
" <th align=\"left\"><label for=\"from\">Your e-mail address</label>:</th>\n".
" <th align=\"left\"><label for=\"from_name\">Your Name:</label></th>\n".
" <td align=\"right\">\n".
" <input type=\"text\" size=\"20\" maxlength=\"50\" name=\"from\" id=\"from\" />\n".
" <input type=\"text\" size=\"20\" maxlength=\"50\" name=\"from_name\" id=\"from_name\" />\n".
" </td>\n".
" </tr>\n".
" <tr>\n".
" <th align=\"left\"><label for=\"name\">Your name</label>:</th>\n".
" <th align=\"left\"><label for=\"from_email\">Your Email Address:</label></th>\n".
" <td align=\"right\">\n".
" <input type=\"text\" size=\"20\" maxlength=\"50\" name=\"name\" id=\"name\" />\n".
" <input type=\"text\" size=\"20\" maxlength=\"50\" name=\"from_email\" id=\"from_email\" />\n".
" </td>\n".
" </tr>\n".
" <tr>\n".
" <th align=\"left\"><label for=\"captchaImage\">CAPTCHA:</label></th>\n".
" <td align=\"right\">\n".
" <img id='captchaImage' src='captchaimage.php' alt='CAPTCHA' />\n".
" </td>\n".
" </tr>\n".
" <tr>\n".
" <th align=\"left\"><label for=\"captchaString\">CAPTCHA:</label></th>\n".
" <td align=\"right\">\n".
" <input type=\"text\" size=\"20\" maxlength=\"5\" name=\"captchaString\" id=\"captchaString\" />\n".
" </td>\n".
" </tr>\n".
" <tr>\n".
" <th align=\"left\" colspan=\"2\">\n".
" <label for=\"message\">Your Message: (Please be detailed)</label>\n".
" </th>\n".
" </tr>\n".
" <tr>\n".
" <td colspan=\"2\">\n".
" <textarea name=\"text\" rows=\"6\" cols=\"44\"></textarea><br />\n".
" <textarea name=\"message\" rows=\"6\" cols=\"44\"></textarea>\n".
" </td>\n".
" </tr>\n".
" <tr>\n".

View File

@@ -4,9 +4,9 @@
Questions? Comments? Suggestions? Bugs? Naked pics?
<?php
if ($irpg_site_email != null && $irpg_site_email != "disabled") {
echo " <a href=\"contact.php\">$admin_email</a> or\n";
echo " Contact <a href=\"contact.php\">".$admin_nick."</a> or\n";
}
echo " ".$admin_nick."@IRC.\n";
echo " ".$admin_nick."@IRC\n";
?>
<?php
$hits = file("hits.db");
@@ -14,13 +14,13 @@
$thispage = explode("/",$_SERVER['PHP_SELF']);
$thispage = array_pop($thispage);
if ($fp == false) {
echo " Error: could not open file hits.db.";
echo " &bull; Error: could not open file hits.db";
}
foreach ($hits as $line) {
list($page,$numhits,$date) = explode("\t",trim($line));
if ($page == $thispage) {
++$numhits;
echo " $numhits hits since $date\n";
echo " &bull; $numhits hits since $date\n";
$found = 1;
}
if ($fp) {
@@ -32,6 +32,9 @@
fwrite($fp,$thispage."\t1\t".date("M j, Y",time())."\n");
}
fclose($fp);
?>
<?php
echo " &bull; IdleRPG Web v".$irpg_version."\n";
?>
</p>
</div>

View File

@@ -19,8 +19,8 @@
$topbarurl = array(
'Game Info' => $irpg_base_dir . 'index.php',
'Player Info' => $irpg_base_dir . 'players.php',
'World Map' => $irpg_base_dir . 'worldmap.php',
'Quest Info' => $irpg_base_dir . 'quest.php',
'World Map' => $irpg_base_dir . 'worldmap.php',
);
if ($irpg_site_email && $irpg_site_email != "disabled") {

View File

@@ -20,6 +20,11 @@
in the channel
<a href="<?php echo $irpg_irc_network_address; ?>/<?php echo $irpg_chan; ?>"><?php echo $irpg_chan; ?></a>.
</p>
<?php
if ($irpg_irc_network_info != null && !empty($irpg_irc_network_info)) {
echo " <p><i>$irpg_irc_network_info</i></p>\n";
}
?>
<h2>Registering</h2>
<p>To register, simply:</p>

View File

@@ -1,6 +1,4 @@
<?php
include("config.php");
// use sessions to generate only one map / person / 20s
session_start();
if (isset($_SESSION['time']) && time()-$_SESSION['time'] < 20) {
@@ -9,6 +7,8 @@
}
$_SESSION['time']=time();
include("config.php");
$map = imageCreate(500,500);
$user = substr($_GET['player'],0,30);
$stringx=$stringy=-1;