From: Valerie Pond Date: Sun, 25 Jun 2023 11:39:16 +0000 (+0100) Subject: IMPORTANT - Please read X-Git-Tag: 0.9~17 X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-webpanel.git/commitdiff_plain/4074d0d1de874693d331ce32700f1277de0b36aa IMPORTANT - Please read The PHPMailer (and example plugin) are being moved out of source and into the contrib repo. This means when you update past this point, your emails will stop working and you'll have to wait for an update of the plugin in order for it to work. --- diff --git a/Classes/class-plugin-git.php b/Classes/class-plugin-git.php index a4300de..f88c7ea 100644 --- a/Classes/class-plugin-git.php +++ b/Classes/class-plugin-git.php @@ -72,7 +72,7 @@ $counter = 0; - foreach($this->data as $p) + foreach($this->data->list as $p) { $installed = in_array($p->name, $config['plugins']) ? true : false; diff --git a/api/plugin.php b/api/plugin.php index 11a3710..0e3e46b 100644 --- a/api/plugin.php +++ b/api/plugin.php @@ -4,7 +4,6 @@ session_start(); if (!isset($_SESSION['id'])) die("Access denied"); require_once('common_api.php'); - header("Content-type: application/json; charset=utf-8"); if (!current_user_can(PERMISSION_MANAGE_PLUGINS)) @@ -95,7 +94,8 @@ function install_plugin($name) function get_plugin_install_path_from_name($name) { global $config; - foreach($config['third-party-plugins']['data'] as $p) + $list = $config['third-party-plugins']['data']->list; + foreach($list as $p) { if (!strcmp($p->name,$name)) return $p->download_link; diff --git a/plugins/example_plugin/example.php b/plugins/example_plugin/example.php deleted file mode 100644 index 011cdb0..0000000 --- a/plugins/example_plugin/example.php +++ /dev/null @@ -1,4 +0,0 @@ -SMTPDebug = 2; - $mail->isSMTP(); // Send using SMTP - $mail->Host = get_config("smtp::host"); // Set the SMTP server to send through - $mail->SMTPAuth = true; // Enable SMTP authentication - $mail->Username = get_config("smtp::username"); // SMTP username - $mail->Password = get_config("smtp::password"); // SMTP password - $mail->SMTPSecure = get_config("smtp::encryption"); // Enable implicit TLS encryption - $mail->Port = get_config("smtp::port"); // TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS` - - //Recipients - $mail->setFrom(get_config("smtp::username"), get_config("smtp::from_name")); - $mail->addAddress($to['email'], $to['name']); // Add a recipient - - //Content - $mail->isHTML(true); // Set email format to HTML - $mail->Subject = $subject; - $mail->Body = $body . "

Thank you for using UnrealIRCd!"; - $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; - - $mail->send(); - } catch (Exception $e) { - die("Could not send mail:". $e); - } - } - - /** - * Send a login notification to the admin (note-to-self) - * @param mixed $user - * @return void - */ - public static function user_login_notif($user) - { - self::send_mail( - ["email" => get_config("smtp::username"), "name" => get_config("smtp::from_name")], - "New login to Unreal Admin Panel", - "There was a new login to the admin panel.
User: \"$user->username\"
IP: \"".$_SERVER['REMOTE_ADDR']."\" (".$_SERVER['HTTP_CF_IPCOUNTRY'].")
". - "User Agent: ".$_SERVER['HTTP_USER_AGENT'] - ); - - if ($user->email) - self::send_mail( - ["email" => $user->email, "name" => $user->first_name . " " . $user->last_name], - "New login to your account", - "Dear $user->first_name,

". - "There was a new login to account: \"$user->username\"

". - "Details:
". - "IP: ".$_SERVER['REMOTE_ADDR']." (".$_SERVER['HTTP_CF_IPCOUNTRY'].")
". - "User Agent: ".$_SERVER['HTTP_USER_AGENT']."

". - "If this was not you, please contact your Panel Administrator." - ); - } - public static function user_login_fail_notif($fail) - { - self::send_mail( - ["email" => get_config("smtp::username"), "name" => get_config("smtp::from_name")], - "Failed login attempt - Unreal Admin Panel", - "There was a failed login attempt to the admin panel.
User: \"".$fail['login']."\"
IP: \"".$fail['IP']."\"" - ); - $user = new PanelUser($fail['login']); - if ($user->email) - self::send_mail( - ["email" => $user->email, "name" => $user->first_name . " " . $user->last_name], - "Failed login attempt to your account", - "Dear $user->first_name,

". - "There was failed login attempt to your account: \"$user->username\"

". - "Details:
". - "IP: ".$_SERVER['REMOTE_ADDR']." (".$_SERVER['HTTP_CF_IPCOUNTRY'].")
". - "User Agent: ".$_SERVER['HTTP_USER_AGENT']."

". - "If this was not you, please contact your Panel Administrator." - ); - } -} \ No newline at end of file diff --git a/settings/add-plugin.php b/settings/add-plugin.php index fd26571..adc0016 100644 --- a/settings/add-plugin.php +++ b/settings/add-plugin.php @@ -34,7 +34,6 @@ $p = new PluginRepo(); const ibtns = document.querySelectorAll(".btn-install-plugin"); ibtns.forEach((ib) => { ib.addEventListener('click', (e) => { - console.log("Button clicked! " +ib.innerHTML); if (ib.innerHTML !== "Install" && ib.innerHTML !== "Uninstall") // some point between, don't do anything {} else if (ib.innerHTML == "Install") // install button pressed! @@ -121,13 +120,13 @@ $p = new PluginRepo(); fetch(BASE_URL + 'api/plugin.php') .then(response => response.json()) // Parse the response as JSON .then(data => { - for (let i = 0; data[i]; i++) + for (let i = 0; data.list[i]; i++) { - if (data[i].name == modname) + if (data.list[i].name == modname) { const modal = bsModal( - "Information about " + data[i].title + "", // title - "
", + "Information about " + data.list[i].title + "", // title + "
", "
Close
", null, true, true, false ); let modalclose = document.getElementById(modal); @@ -136,7 +135,7 @@ $p = new PluginRepo(); }); console.log(modal + '-body'); boobs = document.getElementById(modal + '-body'); - boobs.innerHTML = data[i].description; + boobs.innerHTML = data.list[i].description; } } })