From 006fb5a9dd30bdbfcf47b599c489fa51da289b8d Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Fri, 13 Jan 2023 15:26:17 -0500
Subject: linhes-web: cleanup for lh 9

---
 linhes/linhes-web/PKGBUILD                       |  4 +-
 linhes/linhes-web/website/contents/calllog.py    | 66 ------------------
 linhes/linhes-web/website/contents/calllog.shtml | 19 ------
 linhes/linhes-web/website/contents/count.py      | 85 ++++++++++++------------
 linhes/linhes-web/website/contents/docs.html     | 11 +--
 linhes/linhes-web/website/contents/fe_status.py  |  2 +-
 linhes/linhes-web/website/contents/header.html   | 11 ++-
 linhes/linhes-web/website/contents/home.shtml    |  4 +-
 8 files changed, 60 insertions(+), 142 deletions(-)
 delete mode 100644 linhes/linhes-web/website/contents/calllog.py
 delete mode 100644 linhes/linhes-web/website/contents/calllog.shtml

diff --git a/linhes/linhes-web/PKGBUILD b/linhes/linhes-web/PKGBUILD
index 0bb2824..cb68780 100644
--- a/linhes/linhes-web/PKGBUILD
+++ b/linhes/linhes-web/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=linhes-web
 pkgver=9.0.0
-pkgrel=3
+pkgrel=4
 conflicts=()
 pkgdesc="LinHES local website"
 depends=('lighttpd' 'php-cgi')
@@ -9,7 +9,7 @@ arch=('x86_64')
 license=('GPL')
 source=('linhes-web.conf' 'website.tar.gz')
 sha256sums=('e39ce02bde5eb3d359f1286b41751aa715961cf2b2d9a1243c7f01d20ed9c993'
-            '6ff99589d225826d86bd1911aa0223f3c9668c02ff15e7bc607e52d90cca20ae')
+            '4d6f1e09b1f9ba5585acf8c15097c296a13b00782ee039809ecb5c6ef83dc805')
 
 package() {
     mkdir -p $pkgdir/data/srv/httpd/htdocs/
diff --git a/linhes/linhes-web/website/contents/calllog.py b/linhes/linhes-web/website/contents/calllog.py
deleted file mode 100644
index 0b2fb22..0000000
--- a/linhes/linhes-web/website/contents/calllog.py
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/usr/bin/python2
-# import MySQL module
-
-import MySQLdb
-import sys
-import getopt
-import socket
-
-
-def main(argv):
-    grandtotal=0
-    grandtotal_current=0
-    db = MySQLdb.connect(host="localhost", user="mythtv", passwd="mythtv", db="ncid")
-    # create a cursor
-    cursor = db.cursor()
-   # execute SQL statement
-   # cursor.execute("select  name,number,count(number) as '# calls'  from cid group by number,name  order by '# calls' DESC  limit 20;")
-   # result = cursor.fetchall()
-
-
-    #Top 20 callers
-    #print '<div id="content"> <p></p>'
-    print '<div> <p></p>'
-    print '<table class="calllog">'
-    print "Top 20 callers"
-    searchstring='''<td> <a href="http://www.google.com/search?q=%s" target="_blank" >  %s  </a> </td> '''
-    cursor.execute("select  name,number,count(number)  from cid group by number,name  order by count(number) DESC  limit 20;")
-    result = cursor.fetchall()
-    for row in result:
-        print "	<tr>"
-        #print "		<td>",row[0],"</td>"
-        print  searchstring  % (row[0], row [0])
-        print "		<td>",row[2],"</td>"
-        #print "		<td>",row[1],"</td>"
-        print  searchstring  % (row[1], row [1])
-        print "	</tr>"
-        #print "%40s %26s %10s" %(row[0],row[2],row[1])
-    print "</table>"
-    print "</div>"
-
-
-    #last 20 calls
-    print '<br>'
-    print '<br>'
-    #print '<div id="content"> <p></p>'
-    print '<div>  <p></p>'
-    print '<table class="calllog">'
-    print "Last 20 calls"
-    print '<br>'
-    cursor.execute("select date,time,name,number from cid order by date(ts) DESC ,time DESC  limit 20 ;" )
-    result = cursor.fetchall()
-    for row in result:
-        print "	<tr>"
-        print "		<td>  %s  </td>" %(row[0])
-        print "		<td>",row[1],"</td>"
-        #print "		<td>",row[2],"</td>"
-        print  searchstring  % (row[2], row [2])
-        #print "		<td>",row[3],"</td>"
-        print  searchstring  % (row[3], row [3])
-        print "	</tr>"
-#        print "%26s %26s %26s %26s " %(row[0],row[1],row[2],row[3])
-    print "</table>"
-    print "</div>"
-
-if __name__ == "__main__":
-    main(sys.argv[1:])
diff --git a/linhes/linhes-web/website/contents/calllog.shtml b/linhes/linhes-web/website/contents/calllog.shtml
deleted file mode 100644
index 5b64dc3..0000000
--- a/linhes/linhes-web/website/contents/calllog.shtml
+++ /dev/null
@@ -1,19 +0,0 @@
-<html>
-<head>
-<style type="text/css">@import "/frame.css";</style>
-</head>
-
-<body>
-        <div id="header">
-                <h1>Phone Call Log</h1>
-                <br>
-        </div>
-
-	<!--#exec cmd="/data/srv/httpd/htdocs/calllog.py" -->
-
-</br>
-</br>
-
-</body>
-</html>
-
diff --git a/linhes/linhes-web/website/contents/count.py b/linhes/linhes-web/website/contents/count.py
index 76d18e8..d5f3259 100644
--- a/linhes/linhes-web/website/contents/count.py
+++ b/linhes/linhes-web/website/contents/count.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python2
+#!/usr/bin/python
 # import MySQL module
 
 import MySQLdb
@@ -9,8 +9,11 @@ import socket
 
 def main(argv):
     #get LinHES version
-    verfile = open('/etc/LinHES-release', 'r')
-    verLH = verfile.read()
+    verfile = open('/etc/os-release', 'r')
+    for line in verfile:
+        if line.startswith('PRETTY_NAME'):
+            verLHlist = line.split('"')
+            verLH = verLHlist[1]
     verfile.close()
 
     grandtotal=0
@@ -18,7 +21,7 @@ def main(argv):
     db = MySQLdb.connect(host="localhost", user="mythtv", passwd="mythtv", db="mythconverg")
     # create a cursor
     cursor = db.cursor()
-   # execute SQL statement
+    # execute SQL statement
     cursor.execute("SELECT unix_timestamp(starttime),unix_timestamp(endtime),title FROM oldrecorded where oldrecorded.recstatus = -3  ORDER by starttime;")
     result = cursor.fetchall()
 
@@ -43,58 +46,58 @@ def main(argv):
     hours_current = grandtotal_current / 60.0
     days_current = hours_current / 24.0
 
-    print '<div id="header">'
-    print "<h3>Welcome to</h3>"
-    print "<h1>" , verLH , "</h1>"
-    print "<h3>on " , socket.gethostname() , "</h3>"
-    print "</br>"
-    print "<table>"
-    print "    <tr>"
-    print "	  <td>Currently there are " , len(result_current) , " recorded programs, with a viewing time of %.2f days or %.2f hours.</td>" %(days_current,hours_current)
-    print "    </tr>"
-    print "</table>"
-    print "</br> "
+    print('<div id="header">')
+    print("<h3>Welcome to</h3>")
+    print("<h1>" , verLH , "</h1>")
+    print("<h3>on " , socket.gethostname() , "</h3>")
+    print("</br>")
+    print("<table>")
+    print("    <tr>")
+    print("	  <td>Currently there are " , len(result_current) , " recorded programs, with a viewing time of %.2f days or %.2f hours.</td>" %(days_current,hours_current))
+    print("    </tr>")
+    print("</table>")
+    print("</br> ")
 
-    print "<table>"
-    print "	<tr>"
-    print "  		<td>Overall there have been " , len(result) , "shows recorded, with a viewing time of %.2f days or %.2f hours.</td>"%(days,hours)
-    print "	</tr>"
-    print "</table>"
-    print '</div>'
-    print "</br> </br> "
+    print("<table>")
+    print("	<tr>")
+    print("  		<td>Overall there have been " , len(result) , "shows recorded, with a viewing time of %.2f days or %.2f hours.</td>"%(days,hours))
+    print("	</tr>")
+    print("</table>")
+    print('</div>')
+    print("</br> </br> ")
 #Top shows
-    print '<div id="content"> <p></p>'
-    print '<table class="sample">'
-    print "Top 20 Shows"
+    print('<div id="content"> <p></p>')
+    print('<table class="sample">')
+    print("Top 20 Shows")
     cursor.execute("select title,count(title),category as numtitle from oldrecorded where oldrecorded.recstatus = -3 group by title having (COUNT(title) > 0 ) order by (COUNT(title)) DESC  limit 20;" )
     result = cursor.fetchall()
     for row in result:
-        print "	<tr>"
-        print "		<td>",row[0],"</td>"
-        print "		<td>",row[2],"</td>"
-        print "		<td>",row[1],"</td>"
-        print "	</tr>"
+        print("	<tr>")
+        print("		<td>",row[0],"</td>")
+        print("		<td>",row[2],"</td>")
+        print("		<td>",row[1],"</td>")
+        print("	</tr>")
        # print "%40s %26s %10s" %(row[0],row[2],row[1])
-    print "</table>"
-    print "</div>"
+    print("</table>")
+    print("</div>")
 #Top categories
 
-    print '<div id="column">'
-    print '<table class="sample">'
-    print "Top 20 Categories"
+    print('<div id="column">')
+    print('<table class="sample">')
+    print("Top 20 Categories")
     cursor.execute("select category,count(category) as numtitle from oldrecorded where oldrecorded.recstatus = -3 group by category having (COUNT(category) > 0 ) order by (COUNT(category)) DESC  limit 20; " )
     result = cursor.fetchall()
     for row in result:
         category = row[0]
         if category == "":
             category = "Unknown"
-        print "	<tr>"
-        print "		<td>",category,"</td>"
-        print "		<td>",row[1],"</td>"
-        print "	</tr>"
+        print("	<tr>")
+        print("		<td>",category,"</td>")
+        print("		<td>",row[1],"</td>")
+        print("	</tr>")
         #print "%16s %16s" %(row[0],row[1])
-    print "</table>"
-    print "</div>"
+    print("</table>")
+    print("</div>")
 
 if __name__ == "__main__":
     main(sys.argv[1:])
diff --git a/linhes/linhes-web/website/contents/docs.html b/linhes/linhes-web/website/contents/docs.html
index dc3a936..d08c32e 100644
--- a/linhes/linhes-web/website/contents/docs.html
+++ b/linhes/linhes-web/website/contents/docs.html
@@ -25,14 +25,15 @@
 <h3>Starting and Stopping Services</h3>
 <div id="navcontainer">
 <ul id="navlist">
+<!--
     <li>sv {stop,start,restart} frontend = This will start/stop the entire X proccess that runs mythfrontend</li>
-    <li>sv {stop,start,restart} mysql</li>
-    <li>sv {stop,start,restart} mythbackend</li>
-    <li>sv {stop,start,restart} remotes</li>
+-->
+    <li>systemctl {stop,start,restart} mariadb.service</li>
+    <li>systemctl {stop,start,restart} mythbackend.service</li>
 </ul>
 <br>
 </div>
-
+<!--
 <h3>Other Notes</h3>
 <div id="navcontainer">
 <ul id="navlist">
@@ -45,7 +46,7 @@
     <li>Adding pkg names to /etc/pkgname.blacklist will stop MythVantage from auto installing a package</li>
 </div>
 <br>
-
+-->
 <h3>MythFrontend Menu Navigation</h3>
 <div id="navcontainer">
 <ul id="navlist">
diff --git a/linhes/linhes-web/website/contents/fe_status.py b/linhes/linhes-web/website/contents/fe_status.py
index c66d8f9..0b400e0 100644
--- a/linhes/linhes-web/website/contents/fe_status.py
+++ b/linhes/linhes-web/website/contents/fe_status.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python2
+#!/usr/bin/python
 
 import urllib2
 import xml.etree.ElementTree as ET
diff --git a/linhes/linhes-web/website/contents/header.html b/linhes/linhes-web/website/contents/header.html
index 831a9d5..cb15bbf 100644
--- a/linhes/linhes-web/website/contents/header.html
+++ b/linhes/linhes-web/website/contents/header.html
@@ -55,9 +55,9 @@ function beStatus()
 <li><a href="fe_status_load.shtml">MythFrontend Status</a></li>
 
 <li><a href="" id="modify-me" target="_blank">MythTV WebFrontend</a></li>
-
+<!--
 <li><a href="xymon/">Health & Maintenance</a></li>
-
+-->
 <li><a href="/logs/" >System &#187;</a>
     <ul>
     <!--    <li><a href="/xymon"  >Health</a></li>-->
@@ -67,18 +67,15 @@ function beStatus()
         <li><a href="/shell/"  >Terminal</a></li>
     </ul>
 </li>
-
+<!--
 <li><a href="calllog.shtml">Utilities &#187;</a>
     <ul>
-<!--        <li><a onClick=r() >MythBackend Status</a></li> -->
-        <li><a href="calllog.shtml">Call Log</a></li>
         <li><a href="mythexport/setup.cgi">MythExport</a></li>
         <li><a href="mythexpress.html" target="_blank">MythExpress</a></li>
-<!--    <li><a href="remyth.html" >ReMyth</a></li> -->
         <li><a href="zm">ZoneMinder</a></li>
     </ul>
 </li>
-
+-->
 <li><a href="docs.html"  >Documentation</a></li>
 
 <li><a href="links.html"  >Links &#187;</a>
diff --git a/linhes/linhes-web/website/contents/home.shtml b/linhes/linhes-web/website/contents/home.shtml
index a2c817e..a2ef7dd 100644
--- a/linhes/linhes-web/website/contents/home.shtml
+++ b/linhes/linhes-web/website/contents/home.shtml
@@ -6,11 +6,13 @@
         <div id="mainContainer">
             <!--#exec cmd="/data/srv/httpd/htdocs/count.py" -->
         </div>
+<!--
         <div id="netContainer">
             <img src="/xymon/gifs/network.png" class="center">
         </div>
+-->
         <div id="footer">
-            <p>Thank you for choosing LinHES</p>
+            <p>Thank you for choosing LinHES!</p>
         </div>
     </body>
 </html>
-- 
cgit v0.12

