From 40b30392180f09fab913c27b15eba7a7ae831e87 Mon Sep 17 00:00:00 2001
From: Karl Hudgell <karl@k-world.me.uk>
Date: Mon, 11 Jan 2016 14:54:06 +0000
Subject: [PATCH] added chat switch, fix configtool bugs

---
 Update.bat        | 16 ++++++++++++++++
 config/set1.php   |  3 ++-
 config/write1.php | 13 +++++++------
 config/write5.php |  2 +-
 konvoschat.php    | 45 +++++++++++++++++++++++++++++++++++++++++++
 main.php          | 49 +++++------------------------------------------
 6 files changed, 76 insertions(+), 52 deletions(-)
 create mode 100644 konvoschat.php

diff --git a/Update.bat b/Update.bat
index 7a1c135..24e0cc6 100644
--- a/Update.bat
+++ b/Update.bat
@@ -124,4 +124,20 @@ findstr "kodivisible" config.php >nul 2>&1
 	 goto END
    :END
    
+      rem Add KonvosChat
+findstr "konvoschat" config.php >nul 2>&1
+   if errorlevel 1 goto ONE
+   if errorlevel 0 goto ZERO
+   goto END
+   :ZERO
+     echo KonvosChat Already Updated
+	 goto END
+   :ONE
+     echo ^<?php >>config.php
+	 echo $konvoschat = "1"; >> config.php
+	 echo ^?^> >> config.php
+     echo KonvosChat Updated
+	 goto END
+   :END
+   
 PAUSE
\ No newline at end of file
diff --git a/config/set1.php b/config/set1.php
index ebbf4c9..4779dc5 100644
--- a/config/set1.php
+++ b/config/set1.php
@@ -11,7 +11,8 @@
 	Services Widget Enabled:  <input name="servicesvisible" id="id" type="checkbox" <?php if($servicesvisible > "0")  echo "checked=checked; "; ?> /><br />
 	Clock Widget Enabled:  <input name="clockvisible" id="id" type="checkbox" <?php if($clockvisible > "0")  echo "checked=checked; "; ?> /><br />
 	KKnowledge Widget Enabled:  <input name="kknowledgefeedvisible" id="id" type="checkbox" <?php if($kknowledgefeedvisible > "0")  echo "checked=checked; "; ?> /><br />
-	Klips Widget Enabled:  <input name="webclipfeedvisible" id="id" type="checkbox" <?php if($webclipfeedvisible > "0")  echo "checked=checked; "; ?> /><br />
+	Klips Widget Enabled:  <input name="webclipfeedvisible" id="id" type="checkbox" <?php if($webclipfeedvisible > "0")  echo "checked=checked; "; ?> /><br /><br />
+	Konvos Chatbox Enabled:  <input name="konvoschat" id="id" type="checkbox" <?php if($konvoschat > "0")  echo "checked=checked; "; ?> /><br />
 	Konvos Widget Enabled:  <input name="konvosvisible" id="id" type="checkbox" <?php if($konvosvisible > "0")  echo "checked=checked; "; ?> /><br />
 	<br />
 	Enable Kodi (MovieLib):  <input name="kodivisible" id="id" type="checkbox" <?php if($kodivisible > "0")  echo "checked=checked; "; ?> /><br />
diff --git a/config/write1.php b/config/write1.php
index 22213d8..41e8229 100644
--- a/config/write1.php
+++ b/config/write1.php
@@ -7,6 +7,7 @@ $servicesvisible1 = $_POST['servicesvisible'];
 $clockvisible1 = $_POST['clockvisible'];
 $kknowledgefeedvisible1 = $_POST['kknowledgefeedvisible'];
 $webclipfeedvisible1 = $_POST['webclipfeedvisible'];
+$konvoschat1 = $_POST['konvoschat'];
 $konvosvisible1 = $_POST['konvosvisible'];
 $kodivisible1 = $_POST['kodivisible'];
 
@@ -21,12 +22,6 @@ $content =   preg_replace( '/\$base = \"(.*?)\";/', '$base = "'.$yb.'";', $conte
 // User/Pass Update
 $content =   preg_replace( '/\$user = \"(.*?)\";/', '$user = "'.$user1.'";', $content);
 $content =   preg_replace( '/\$pass = \"(.*?)\";/', '$pass = "'.$pass1.'";', $content);
-// servicesvisible Settings
- if (empty($sabvis1)) {
-    $content =   preg_replace( '/\$sabvisible = \"(.*?)\";/', '$sabvisible = "0";', $content);
- } else {
- $content =   preg_replace( '/\$sabvisible = \"(.*?)\";/', '$sabvisible = "1";', $content);
- }
  // clockvisible Settings
  if (empty($clockvisible1)) {
     $content =   preg_replace( '/\$clockvisible = \"(.*?)\";/', '$clockvisible = "0";', $content);
@@ -50,6 +45,12 @@ $content =   preg_replace( '/\$pass = \"(.*?)\";/', '$pass = "'.$pass1.'";', $co
     $content =   preg_replace( '/\$konvosvisible = \"(.*?)\";/', '$konvosvisible = "0";', $content);
  } else {
  $content =   preg_replace( '/\$konvosvisible = \"(.*?)\";/', '$konvosvisible = "1";', $content);
+ }
+ // konvoschat Settings
+ if (empty($konvoschat1)) {
+    $content =   preg_replace( '/\$konvoschat = \"(.*?)\";/', '$konvoschat = "0";', $content);
+ } else {
+ $content =   preg_replace( '/\$konvoschat = \"(.*?)\";/', '$konvoschat = "1";', $content);
  }
   // kodivisible Settings
  if (empty($kodivisible1)) {
diff --git a/config/write5.php b/config/write5.php
index 3b18efb..3076ded 100644
--- a/config/write5.php
+++ b/config/write5.php
@@ -87,7 +87,7 @@ if (empty($customfeed1visible1)) {
  $content =   preg_replace( '/\$customfeed1visible = \"(.*?)\";/', '$customfeed1visible = "1";', $content);
  }
 $content =   preg_replace( '/\$customfeed1name = \"(.*?)\";/', '$customfeed1name = "'.$customfeed1name1.'";', $content);
-$content =   preg_replace( '/\$customfeed1name = \"(.*?)\";/', '$customfeed1name = "'.$customfeed1name1.'";', $content);
+$content =   preg_replace( '/\$customfeed1url = \"(.*?)\";/', '$customfeed1url = "'.$customfeed1url1.'";', $content);
 // End of Settigns
 // RSS2 Settings
 // FTP Visible Update
diff --git a/konvoschat.php b/konvoschat.php
new file mode 100644
index 0000000..dd34a0a
--- /dev/null
+++ b/konvoschat.php
@@ -0,0 +1,45 @@
+
+<script>
+    require(['converse'], function (converse) {
+        (function () {
+            /* XXX: This function initializes jquery.easing for the https://conversejs.org
+            * website. This code is only useful in the context of the converse.js
+            * website and converse.js itself is NOT dependent on it.
+            */
+            var $ = converse.env.jQuery;
+            $.extend( $.easing, {
+                easeInOutExpo: function (x, t, b, c, d) {
+                    if (t==0) return b;
+                    if (t==d) return b+c;
+                    if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
+                    return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
+                },
+            });
+
+            $(window).scroll(function() {
+                if ($(".navbar").offset().top > 50) {
+                    $(".navbar-fixed-top").addClass("top-nav-collapse");
+                } else {
+                    $(".navbar-fixed-top").removeClass("top-nav-collapse");
+                }
+            });
+            //jQuery for page scrolling feature - requires jQuery Easing plugin
+            $('.page-scroll a').bind('click', function(event) {
+                var $anchor = $(this);
+                $('html, body').stop().animate({
+                    scrollTop: $($anchor.attr('href')).offset().top
+                }, 700, 'easeInOutExpo');
+                event.preventDefault();
+            });
+        })();
+        converse.initialize({
+            bosh_service_url: 'https://konvos.cf:5281/http-bind', // Please use this connection manager only for testing purposes
+            keepalive: true,
+            message_carbons: true,
+            play_sounds: true,
+            roster_groups: true,
+            show_controlbox_by_default: true,
+            xhr_user_search: false
+        });
+    });
+</script>
\ No newline at end of file
diff --git a/main.php b/main.php
index 1d751a0..092fc59 100644
--- a/main.php
+++ b/main.php
@@ -124,48 +124,9 @@ if ($squeezevisible > "0") {
 </div>
 </div>
 </body>
-<script>
-    require(['converse'], function (converse) {
-        (function () {
-            /* XXX: This function initializes jquery.easing for the https://conversejs.org
-            * website. This code is only useful in the context of the converse.js
-            * website and converse.js itself is NOT dependent on it.
-            */
-            var $ = converse.env.jQuery;
-            $.extend( $.easing, {
-                easeInOutExpo: function (x, t, b, c, d) {
-                    if (t==0) return b;
-                    if (t==d) return b+c;
-                    if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
-                    return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
-                },
-            });
-
-            $(window).scroll(function() {
-                if ($(".navbar").offset().top > 50) {
-                    $(".navbar-fixed-top").addClass("top-nav-collapse");
-                } else {
-                    $(".navbar-fixed-top").removeClass("top-nav-collapse");
-                }
-            });
-            //jQuery for page scrolling feature - requires jQuery Easing plugin
-            $('.page-scroll a').bind('click', function(event) {
-                var $anchor = $(this);
-                $('html, body').stop().animate({
-                    scrollTop: $($anchor.attr('href')).offset().top
-                }, 700, 'easeInOutExpo');
-                event.preventDefault();
-            });
-        })();
-        converse.initialize({
-            bosh_service_url: 'https://konvos.cf:5281/http-bind', // Please use this connection manager only for testing purposes
-            keepalive: true,
-            message_carbons: true,
-            play_sounds: true,
-            roster_groups: true,
-            show_controlbox_by_default: true,
-            xhr_user_search: false
-        });
-    });
-</script>
+<?php
+if ($konvoschat > "0") {
+    require "konvoschat.php";
+ }
+?>
 </html>
\ No newline at end of file