]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - connection.php
Merge pull request #16 from PeGaSuS-Coder/patch-4
[irc/unrealircd/unrealircd-webpanel.git] / connection.php
index be01f48afa134cb3fc1984f4282ee997efb90a5e..38bfaaf606bf63ac9e3278921e34d9de2e8877f4 100644 (file)
@@ -1,9 +1,12 @@
 <?php
 
+if (!defined('UPATH'))
+               die("Access denied");
+
 if (!defined('UNREALIRCD_RPC_USER') ||
-        !defined('UNREALIRCD_RPC_PASSWORD') ||
-        !defined('UNREALIRCD_HOST') ||
-        !defined('UNREALIRCD_PORT')
+               !defined('UNREALIRCD_RPC_PASSWORD') ||
+               !defined('UNREALIRCD_HOST') ||
+               !defined('UNREALIRCD_PORT')
 ) die("Unable to find RPC credentials in your config.php");
 
 $tls_verify = (defined('UNREALIRCD_SSL_VERIFY')) ? UNREALIRCD_SSL_VERIFY : true;
@@ -11,9 +14,18 @@ $api_login = UNREALIRCD_RPC_USER.":".UNREALIRCD_RPC_PASSWORD;
 
 /* Connect now */
 try {
-        $rpc = new UnrealIRCd\Connection("wss://".UNREALIRCD_HOST.":".UNREALIRCD_PORT,
-                                         $api_login,
-                                         Array("tls_verify"=>$tls_verify));
-} catch (Exception $e) {
-        die("Unable to connect to UnreaIRCd<br>");
+               $rpc = new UnrealIRCd\Connection
+               (
+                       "wss://".UNREALIRCD_HOST.":".UNREALIRCD_PORT,
+                       $api_login,
+                       ["tls_verify" => $tls_verify]
+               );
+}
+catch (Exception $e)
+{
+       echo "Unable to connect to UnrealIRCd: ".$e->getMessage() . "<br><br>";
+       echo "Verify your connection details in config.php (rpc user, rpc password, host) and ".
+            "verify your UnrealIRCd configuration (listen block with listen::options::rpc and ".
+            "an rpc-user block with the correct IP allowed and the correct username and password).";
+       throw $e;
 }