* A set of reference lists
*/
class IRCList {
- static $cmodes =
+
+ public static $cmodes =
[
"a" => [
"name" => "Admin",
"description" => "Prevents users from sending CTCP's to the channel",
"requires" => "HalfOp"
],
+ "d" => [
+ "name" => "Delay Join",
+ "description" => "Delay showing joins until someone actually speaks.",
+ "requires" => "Operator"
+ ],
"e" => [
"name" => "Ban Exemption",
"description" => "Marks an exemption from channel bans",
"requires" => "Server"
]
];
+ static function setmodes($modes)
+ {
+ $g = [];
+ if (is_array($modes))
+ {
+ self::$uplink = $modes;
+ return;
+ }
+ else if (!strstr($modes,","))
+ $g = [$modes];
+ else $g = split($g,",");
+ self::$uplink = $g;
+ }
+ static $uplink = [];
+
}
\ No newline at end of file
<?php
require_once "../common.php";
require_once "../header.php";
-require_once "../misc/channel-lookup-misc.php";
+if ($uplink = $rpc->server()->get())
+ IRCList::setmodes($uplink->server->features->chanmodes);
$title = "Channel Lookup";
$channel = "";
$channame = "";
</div>
<!-- Modal for Add Ban Exceptions -->
-<div class="modal fade" id="except" tabindex="-1" role="dialog" aria-labelledby="add_except_modal" aria-hidden="true">
+<div class="modal fade" id="except" tabindex="-1" role="dialog" aria-labelledby="except" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
- <h5 class="modal-title" id="add_except_modal">Add New Channel Ban Exception</h5>
+ <h5 class="modal-title" >Add New Channel Ban Exception</h5>
<div type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</div>
</div>
</div>
+<!-- Modal for Edit Channel Modes -->
+<div class="modal fade" id="editchmodes" tabindex="-1" role="dialog" aria-labelledby="editchmodes" aria-hidden="true">
+ <div class="modal-dialog modal-dialog-centered" role="document">
+ <div class="modal-content">
+ <div class="modal-header">
+ <h5 class="modal-title" id="editchmodes">Edit Channel Modes</h5>
+ <div type="button" class="close" data-dismiss="modal" aria-label="Close">
+ <span aria-hidden="true">×</span>
+ </div>
+ </div>
+ <div class="modal-body">
+ <form method="post">
+
+ <?php generate_edit_chmodes($channelObj); ?>
+
+ </div>
+ <div class="modal-footer">
+ <input type="hidden" id="server" name="add_chex" value="e"></input>
+ <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
+ <button type="submit" action="post" class="btn btn-danger">Update</button>
+ </form>
+ </div>
+ </div>
+ </div>
+</div>
+
<br>
<h6>
Topic:<br></h6>
<div class="tab-content">
- <div role="tabpanel" class="tab-pane fade in" id="chanmodes">
- <p class="card-text"><?php generate_html_chansettings($channelObj); ?></p>
- </div>
-
- <div role="tabpanel" class="tab-pane fade in" id="chanbans">
- <p class="card-text"><?php generate_chanbans_table($channelObj); ?></p>
- </div>
- <div role="tabpanel" class="tab-pane fade in" id="chaninv">
- <p class="card-text"><?php generate_chaninvites_table($channelObj); ?></p>
- </div>
- <div role="tabpanel" class="tab-pane fade in" id="chanex">
- <p class="card-text"><?php generate_chanexcepts_table($channelObj); ?></p>
- </div>
+ <div role="tabpanel" class="tab-pane fade in" id="chanmodes">
+ <p class="card-text"><?php generate_html_chansettings($channelObj); ?></p>
+ </div>
+
+ <div role="tabpanel" class="tab-pane fade in" id="chanbans">
+ <p class="card-text"><?php generate_chanbans_table($channelObj); ?></p>
+ </div>
+ <div role="tabpanel" class="tab-pane fade in" id="chaninv">
+ <p class="card-text"><?php generate_chaninvites_table($channelObj); ?></p>
+ </div>
+ <div role="tabpanel" class="tab-pane fade in" id="chanex">
+ <p class="card-text"><?php generate_chanexcepts_table($channelObj); ?></p>
+ </div>
+ <div role="tabpanel" class="tab-pane fade in" id="chanmodes_edit">
+ <p class="card-text"><?php /* insert hacks here */ ?></p>
+ </div>
</div>
</div>
"source": {
"type": "git",
"url": "https://github.com/unrealircd/unrealircd-rpc-php.git",
- "reference": "1446a5db1b55608472c42aea7c5dc0a4c66558f1"
+ "reference": "249f865d50d543087288a4fae426a444fd39ec24"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/unrealircd/unrealircd-rpc-php/zipball/1446a5db1b55608472c42aea7c5dc0a4c66558f1",
- "reference": "1446a5db1b55608472c42aea7c5dc0a4c66558f1",
+ "url": "https://api.github.com/repos/unrealircd/unrealircd-rpc-php/zipball/249f865d50d543087288a4fae426a444fd39ec24",
+ "reference": "249f865d50d543087288a4fae426a444fd39ec24",
"shasum": ""
},
"require": {
"issues": "https://github.com/unrealircd/unrealircd-rpc-php/issues",
"source": "https://github.com/unrealircd/unrealircd-rpc-php/tree/main"
},
- "time": "2023-03-27T08:42:38+00:00"
+ "time": "2023-03-27T11:36:49+00:00"
}
],
"packages-dev": [],
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
- "plugin-api-version": "2.3.0"
+ "plugin-api-version": "2.2.0"
}
<?php
-
function generate_chanbans_table($channel)
{
global $rpc;
<thead class="table-info">
<th><input type="checkbox" label='selectall' onClick="toggle_checkbox(this)" /></th>
<th>Name</th>
- <th>Host</th>
<th>Status</th>
+ <th>Host</th>
</thead>
<tbody>
<?php
$m = sort_user_list($channel->members);
+
+ $i = 0;
foreach ($m as $member)
{
$lvlstring = "";
}
}
}
+
echo "<tr>";
?><form method="post" action=""><?php
$disabled = (current_user_can(PERMISSION_EDIT_CHANNEL_USER)) ? "" : "disabled";
$disabledcolor = ($disabled) ? "btn-secondary" : "btn-primary";
echo "<td scope=\"row\"><input type=\"checkbox\" value='$member->id' name=\"checkboxes[]\"></td>";
echo "<td><a href=\"".BASE_URL."users/details.php?nick=$member->id\">".htmlspecialchars($member->name)."</a></td>";
- echo "<td><code>".(property_exists($member, 'hostname') ? htmlspecialchars($member->hostname) : "")."</code></td>";
echo "<td class='text-right'>$lvlstring</td>";
+ echo "<td><code>".((property_exists($member, 'hostname')) ? htmlspecialchars($member->hostname) : "")."</code></td>";
echo "</tr>";
}
function generate_html_chansettings($channel)
{
- global $rpc;
?>
-
+
+ <p><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#editchmodes" <?php echo (current_user_can(PERMISSION_EDIT_CHANNEL)) ? "" : "disabled"; ?>>
+ Edit
+ </button></p>
<table class="table-sm table-responsive caption-top table-hover">
<tbody>
<?php
$tok = split($fmodes);
$modes = $tok[0];
$params = rparv($fmodes);
- $uplink = $rpc->server()->get();
- if (!$uplink) // whaaaa?!¿
- die("Could not find our uplink. Weird and should not have happened");
-
- $groups = $uplink->server->features->chanmodes;
for ($i=0; ($mode = (isset($modes[$i])) ? $modes[$i] : NULL); $i++)
{
$modeinfo = IRCList::$cmodes[$mode];
+ if (!$modeinfo)
+ continue;
?>
<tr>
<th><?php echo $modeinfo['name']; ?></th>
<?php
}
+function generate_edit_chmodes($chan)
+{
+ ?>
+
+ <table class="table-sm table-responsive caption-top table-hover">
+ <tbody>
+ <?php
+ if (!isset($chan->modes))
+ {
+ echo "No modes set";
+ return;
+ }
+ $fmodes = $chan->modes;
+ $tok = split($fmodes);
+ $modes = $tok[0];
+ $params = rparv($fmodes);
+ $paramed_modes = sort_paramed_modes($modes, $params);
+ foreach (IRCList::$uplink as $m)
+ for ($i=0; ($mode = (isset($m[$i])) ? $m[$i] : NULL); $i++)
+ {
+ $group = get_chmode_group($mode);
+ if (!$group || $group == 1)
+ continue;
+ $modeinfo = (isset(IRCList::$cmodes[$mode])) ? IRCList::$cmodes[$mode] : ['name' => "Unknown mode", 'description' => "Unknown mode +$mode"];
+ $checked = (strstr($modes,$mode)) ? "checked" : "";
+ $disabled = "";
+ switch($mode)
+ {
+ case "Z":
+ case "d":
+ $disabled = "disabled";
+ }
+ ?>
+ <tr><th scope="row"><input <?php echo $checked." ".$disabled; ?> type="checkbox" value='$mode' name="newmodes[]"></th>
+ <th data-toggle="tooltip" data-placement="top" title="<?php echo htmlspecialchars($modeinfo['description']); ?>"><?php echo htmlspecialchars($modeinfo['name'])." (<code>+$mode</code>)"; ?></th>
+ <td>
+ <?php
+
+ if ($group == 2 || $group == 3)
+ {
+ ?><input type="text" class="form-control" name="<?php echo $mode; ?>" id="<?php echo $mode; ?>" value="<?php echo ($checked) ? htmlspecialchars($paramed_modes[$mode]) : ""; ?>"><?php
+ }
+ ?>
+ </td>
+ </tr>
+ <?php
+ }
+
+
+ ?>
+ </tbody>
+ </table>
+
+ <?php
+}
+
+function get_chmode_group(string $mode) : int
+{
+ foreach(IRCList::$uplink as $i => $grp)
+ if (strstr($grp,$mode))
+ return $i + 1;
+
+ return 0; // invalid
+}
+
/**
* Force loading of a particular modal by name
*/
<?php
}
+/**
+ * Returns an array of parametered modes and their params
+ */
+function sort_paramed_modes($modes, $params) : array
+{
+ $m = [];
+ for ($i=0; isset($modes[$i]) && $mode = $modes[$i]; $i++)
+ {
+ $group = get_chmode_group($mode);
+ if ($group != 2 && $group != 3)
+ continue;
+ $p = split($params);
+ $m[$mode] = $p[0];
+ $p[0] = NULL;
+ $params = glue($p);
+ }
+ return $m;
+}
function _do_chan_item_delete($chan, string $type, array $list, array &$errors) : bool
{
--- /dev/null
+<?php
+
+/**
+ * PHPMailer - PHP email creation and transport class.
+ * PHP Version 5.5.
+ *
+ * @see https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
+ *
+ * @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
+ * @author Jim Jagielski (jimjag) <jimjag@gmail.com>
+ * @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
+ * @author Brent R. Matzelle (original founder)
+ * @copyright 2012 - 2023 Marcus Bointon
+ * @copyright 2010 - 2012 Jim Jagielski
+ * @copyright 2004 - 2009 Andy Prevost
+ * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
+ * @note This program is distributed in the hope that it will be useful - WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+namespace PHPMailer\PHPMailer;
+
+/**
+ * Configure PHPMailer with DSN string.
+ *
+ * @see https://en.wikipedia.org/wiki/Data_source_name
+ *
+ * @author Oleg Voronkovich <oleg-voronkovich@yandex.ru>
+ */
+class DSNConfigurator
+{
+ /**
+ * Create new PHPMailer instance configured by DSN.
+ *
+ * @param string $dsn DSN
+ * @param bool $exceptions Should we throw external exceptions?
+ *
+ * @return PHPMailer
+ */
+ public static function mailer($dsn, $exceptions = null)
+ {
+ static $configurator = null;
+
+ if (null === $configurator) {
+ $configurator = new DSNConfigurator();
+ }
+
+ return $configurator->configure(new PHPMailer($exceptions), $dsn);
+ }
+
+ /**
+ * Configure PHPMailer instance with DSN string.
+ *
+ * @param PHPMailer $mailer PHPMailer instance
+ * @param string $dsn DSN
+ *
+ * @return PHPMailer
+ */
+ public function configure(PHPMailer $mailer, $dsn)
+ {
+ $config = $this->parseDSN($dsn);
+
+ $this->applyConfig($mailer, $config);
+
+ return $mailer;
+ }
+
+ /**
+ * Parse DSN string.
+ *
+ * @param string $dsn DSN
+ *
+ * @throws Exception If DSN is malformed
+ *
+ * @return array Configuration
+ */
+ private function parseDSN($dsn)
+ {
+ $config = $this->parseUrl($dsn);
+
+ if (false === $config || !isset($config['scheme']) || !isset($config['host'])) {
+ throw new Exception(
+ sprintf('Malformed DSN: "%s".', $dsn)
+ );
+ }
+
+ if (isset($config['query'])) {
+ parse_str($config['query'], $config['query']);
+ }
+
+ return $config;
+ }
+
+ /**
+ * Apply configuration to mailer.
+ *
+ * @param PHPMailer $mailer PHPMailer instance
+ * @param array $config Configuration
+ *
+ * @throws Exception If scheme is invalid
+ */
+ private function applyConfig(PHPMailer $mailer, $config)
+ {
+ switch ($config['scheme']) {
+ case 'mail':
+ $mailer->isMail();
+ break;
+ case 'sendmail':
+ $mailer->isSendmail();
+ break;
+ case 'qmail':
+ $mailer->isQmail();
+ break;
+ case 'smtp':
+ case 'smtps':
+ $mailer->isSMTP();
+ $this->configureSMTP($mailer, $config);
+ break;
+ default:
+ throw new Exception(
+ sprintf(
+ 'Invalid scheme: "%s". Allowed values: "mail", "sendmail", "qmail", "smtp", "smtps".',
+ $config['scheme']
+ )
+ );
+ }
+
+ if (isset($config['query'])) {
+ $this->configureOptions($mailer, $config['query']);
+ }
+ }
+
+ /**
+ * Configure SMTP.
+ *
+ * @param PHPMailer $mailer PHPMailer instance
+ * @param array $config Configuration
+ */
+ private function configureSMTP($mailer, $config)
+ {
+ $isSMTPS = 'smtps' === $config['scheme'];
+
+ if ($isSMTPS) {
+ $mailer->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
+ }
+
+ $mailer->Host = $config['host'];
+
+ if (isset($config['port'])) {
+ $mailer->Port = $config['port'];
+ } elseif ($isSMTPS) {
+ $mailer->Port = SMTP::DEFAULT_SECURE_PORT;
+ }
+
+ $mailer->SMTPAuth = isset($config['user']) || isset($config['pass']);
+
+ if (isset($config['user'])) {
+ $mailer->Username = $config['user'];
+ }
+
+ if (isset($config['pass'])) {
+ $mailer->Password = $config['pass'];
+ }
+ }
+
+ /**
+ * Configure options.
+ *
+ * @param PHPMailer $mailer PHPMailer instance
+ * @param array $options Options
+ *
+ * @throws Exception If option is unknown
+ */
+ private function configureOptions(PHPMailer $mailer, $options)
+ {
+ $allowedOptions = get_object_vars($mailer);
+
+ unset($allowedOptions['Mailer']);
+ unset($allowedOptions['SMTPAuth']);
+ unset($allowedOptions['Username']);
+ unset($allowedOptions['Password']);
+ unset($allowedOptions['Hostname']);
+ unset($allowedOptions['Port']);
+ unset($allowedOptions['ErrorInfo']);
+
+ $allowedOptions = \array_keys($allowedOptions);
+
+ foreach ($options as $key => $value) {
+ if (!in_array($key, $allowedOptions)) {
+ throw new Exception(
+ sprintf(
+ 'Unknown option: "%s". Allowed values: "%s"',
+ $key,
+ implode('", "', $allowedOptions)
+ )
+ );
+ }
+
+ switch ($key) {
+ case 'AllowEmpty':
+ case 'SMTPAutoTLS':
+ case 'SMTPKeepAlive':
+ case 'SingleTo':
+ case 'UseSendmailOptions':
+ case 'do_verp':
+ case 'DKIM_copyHeaderFields':
+ $mailer->$key = (bool) $value;
+ break;
+ case 'Priority':
+ case 'SMTPDebug':
+ case 'WordWrap':
+ $mailer->$key = (int) $value;
+ break;
+ default:
+ $mailer->$key = $value;
+ break;
+ }
+ }
+ }
+
+ /**
+ * Parse a URL.
+ * Wrapper for the built-in parse_url function to work around a bug in PHP 5.5.
+ *
+ * @param string $url URL
+ *
+ * @return array|false
+ */
+ protected function parseUrl($url)
+ {
+ if (\PHP_VERSION_ID >= 50600 || false === strpos($url, '?')) {
+ return parse_url($url);
+ }
+
+ $chunks = explode('?', $url);
+ if (is_array($chunks)) {
+ $result = parse_url($chunks[0]);
+ if (is_array($result)) {
+ $result['query'] = $chunks[1];
+ }
+ return $result;
+ }
+
+ return false;
+ }
+}