Moved extended privacy information to a page that is created activation.
authorChuck Scott <cscott@gaslightmedia.com>
Tue, 3 Sep 2019 21:08:26 +0000 (17:08 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Tue, 3 Sep 2019 21:08:26 +0000 (17:08 -0400)
Privacy page now is created on activation and contains standard text.
Added short-code to permit placement of managed contact information
for the privacy page. More work continuing...

activate.php
defines.php
models/frontCookiePopUp.php
setup/commonHooks.php

index 162f78a..e67ffde 100755 (executable)
@@ -20,6 +20,8 @@ if (!defined('ABSPATH')) {
     die();
 }
 
+require_once 'defines.php';
+
 /*
  * This class performs all necessary additional work when this
  * plugin is activated.
@@ -46,8 +48,96 @@ class glmServerStatsPluginActivate
             die();
         }
 
+        global $wpdb;
+        $this->wpdb = $wpdb;
+
+        // Setup required policy page - Check if slug for page matches existing post
+        $policyPageSlug = sanitize_title(GLM_SERVERSTATS_PLUGIN_POLICY_PAGE);
+        $existingSlug = $this->verify_post_slug($policyPageSlug);
+        if (!$existingSlug) {
+
+trigger_error("*** SLUG NOT FOUND ***", E_USER_NOTICE);
+
+            $pageContent = "
+<hr>
+<a href=\"#cookies\">Cookies and Privacy</a><br>
+<a href=\"#additional\">Additional Privacy Information</a><br>
+<hr>
+<div style=\"display:inline-block\">
+    <a name=\"cookies\"><h2>Cookies and Privacy</h2></a>
+    <p>This site uses temporary \"Cookies\" to store limited information that's required to provide you with a consistent user experience. We don't store personally identifying or other sensitive information in these Cookies and these Cookies are erased when you close your Web Browser unless otherwise stated when you click \"Show more\".</p>
+    <p>If you're on a public computer, be sure to close all Web Browsers when you're done!</p>
+</div>
+<div style=\"display:inline-block\">
+    <a name=\"additional\"></a><h2>Additional Privacy Information</h2>
+    <p><b>GDPR:</b> The EU GDPR legislation obligates us to tell you how we use information you supply through this Website. We intentionally limit the information we ask you to supply to what is absolutely necessary to provide the service you request. Unless otherwise stated, we don't share any supplied information with any other person or organization other than as required and as authorized by you. Payment related information you supply will only be used to complete a transaction and will not be stored on our systems.</p>
+    <p><b>ACCESS LOGS:</b> We retain access logs entries for a certain period of time for the sole purpose of ensuring security of our systems and compliance of acceptable use by users of this site. We don't share log entries with anyone unless obligated to do so by way of a lawful request from a law enforcement agency or court with appropriate jurisdiction.</p>
+    <p><b>PERMANENT COOKIES:</b> This Website uses \"Permanent Cookies\" that are retained by your Web Browser. This type of Cookie is used to help you when you return to this Website at a later time. If you're using a public computer, be sure to delete all cookies before closing the Browser.</p>
+    <p><b>TRACKING:</b> We may track where you go within this site. This helps us provide you with relevant information and to evaluate how we may improve the site. We don't share this tracking information with anyone unless otherwise stated here.</p>
+    <p><b>SHARED TRACKING:</b> This site may contain third-party shared tracking features. These features may collect and share tracking information with affiliated Websites and advertisers to help them provide you with more relevant information. This site may also contain third-party shared tracking features that permit a third-party to collect and report traffic statistics to the owner of this site. We don't permit shared tracking to include personal information of any user.</p>
+    <p><b>HTTPS:</b> This Website uses the secure \"HTTPS\" protocol for all pages and content. This makes it very difficult for anyone who may tap into Internet traffic to read what you submit and what is being sent back to you. If you feel that the possibility of someone intercepting information you submit or knowledge of the pages you access presents a significant risk to you, please don't use this Website.</p>
+    <p><b>LOGGED IN USERS:</b> We don't store passwords you use to log in as plain text, instead they're encrypted before being stored in our systems. When you enter that password again to log in, we encrypt that and and match it to the encrypted password that had been stored. There is no way to decrypt the stored passwords, but it may be possilbe for others to guess simple passwords. You should always use more complex passwords that don't include words or names people would associate with you. You should also try to avoid using the same password for everything you log into and should not make those passwords easily accessible to anyone else.</p>
+    <p><b>FORMS:</b> Personal information requested in forms on this site is limited to what is required to provide you with the information and services you request. Please don't provide additional personal information in these forms that is not requested. If you are uncomfortable with submitting any requested information, please call or write to us directly using the address and phone numbers on this site. We don't supply any of the information you provide to any other individual or organization unless you check a box in the submission form specifically authorizing us to do so.</p>
+    <p><b>PAYMENT INFORMATION:</b> We only use the payment information you provide to complete a paid transaction. We don't retain any payment information beyond that point. If you check a box asking us to store credit card or similar information for future use, we pass that request on to the credit card processing service and they store that information on their systems. All we store on our systems is a \"token\" that can only be used to process another authorized transaction on your behalf through this Website with the same credit card processing service.</p>
+</div>
+<center>
+<p><i>If you have any questions or would like additional information, please contact us using the following information.</i></p>
+<p>[policy_contact]</p>
+</center>
+            ";
+
+            $policyPage = [
+                'post_title' => GLM_SERVERSTATS_PLUGIN_POLICY_PAGE,
+                'post_content' => $pageContent,
+                'post_type' => 'page',
+                'post_author' => 1,
+                'post_status' => 'publish',
+                'comment_status' => 'closed',
+                'ping_status' => 'closed'
+            ];
+            $pageId = wp_insert_post($policyPage);
+            if( is_wp_error($pageId) ) {
+                trigger_error("Create Policy Page Failed: ".$pageId->get_error_message(), E_USER_NOTICE);
+            } else {
+                trigger_error("Create Policy Page Success: ID = $pageId", E_USER_NOTICE);
+            }
+
+        } else {
+            trigger_error("*** SLUG FOUND ***",E_USER_NOTICE);
+        }
+
+    }
+
+    public function insertReqPage($pTitle = '--bad page--', $pContent = '', $pPublish = 'publish', $pType = 'page', $pAuthor = '1', $pTemplate = 'index.php', $pParent = '0')
+    {
+        $new_page = array(
+            'post_title' => $pTitle,
+            'post_content' => $pContent,
+            'post_status' => $pPublish,
+            'post_type' => $pType,
+            'post_author' => $pAuthor,
+            'page_template' => $pTemplate ,
+            'post_parent' => $pParent
+        );
+        return wp_insert_post($new_page);
     }
 
+    public function get_post_data($needle = 1, $valueField = 'post_name', $needleField = 'ID')
+    {
+        $value = $this->wpdb->get_var("SELECT $valueField FROM ".$this->wpdb->posts." WHERE $needleField = '".$needle."'");
+        return $value;
+    }
 
+    public function verify_post_slug($postName)
+    {
+        $value = $this->wpdb->get_var("SELECT post_name FROM ".$this->wpdb->posts." WHERE post_name = '".$postName."'");
+        return $value;
+    }
+
+    public function get_post_id_by_slug($postName)
+    {
+        $value = $this->wpdb->get_var("SELECT ID FROM ". $this->wpdb->posts." WHERE post_name = '" . $postName."'");
+        return $value;
+    }
 
 }
index 533c72d..bf0c2d9 100755 (executable)
@@ -10,7 +10,7 @@ define('GLM_SERVERSTATS_PROVIDER_1', '192.168.44.82');
 define('GLM_SERVERSTATS_PROVIDER_2', 'www.gaslightmedia.com');
 
 
-define('GLM_SERVERSTATS_CONTACT_EMAIL', "plugins.gaslightmedia.com");
+define('GLM_SERVERSTATS_CONTACT_EMAIL', "plugins@gaslightmedia.com");
 
 // Set to true to add more debug messages to the error log
 define('GLM_SERVERSTATS_PLUGIN_DEBUG', true);
@@ -45,6 +45,9 @@ if (trim($host) == '') {
 }
 define('GLM_SERVERSTATS_PLUGIN_HOST', $host);
 
+// Define policy page title
+define('GLM_SERVERSTATS_PLUGIN_POLICY_PAGE', 'Website User Privacy and Policies');
+
 // Determine current http/https protocol
 $pageProtocol = 'http';
 if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443') {
index 562c69d..0d0f250 100755 (executable)
@@ -1,6 +1,8 @@
 <?php
 // Get Configuration for Cookie info popup
 $serverstatsConfig = get_option(GLM_SERVERSTATS_PLUGIN_CONFIG_OPTION);
+$policyPageSlug = sanitize_title(GLM_SERVERSTATS_PLUGIN_POLICY_PAGE);
+$moreInfoURL = GLM_SERVERSTATS_SITE_BASE_URL."/".$policyPageSlug;
 ?>
 <style>
     #cookieNoticeBox {
@@ -45,89 +47,9 @@ $serverstatsConfig = get_option(GLM_SERVERSTATS_PLUGIN_CONFIG_OPTION);
     <div class="title">Please read!<br></div>
 <?php if ($serverstatsConfig['cookie_message'] != '') { echo '<p>'.nl2br($serverstatsConfig['cookie_message']).'</p>'; }  ?>
     <p>
-        <a id="showMorePrivacyInfo" class="button">Show more</a>
-        <a id="cookieNoticeBoxClose" class="button">Got it!</a>
+        <a class="cookieMoreInfo button">Show more</a>
+        <a class="cookieNoticeBoxClose button">Got it!</a>
     </p>
-    <div id="cookieMoreInfo" style="display: none; font-size: .8rem;">
-<?php if ($serverstatsConfig['cookie_opt_gdpr']) { ?>
-        <p>
-            <b>GDPR:</b> The EU GDPR legislation obligates us to tell you how we use information you supply through
-            this Website. We intentionally limit the information we ask you to supply to what is absolutely
-            necessary to provide the service you request. Unless otherwise stated, we don't share any supplied information
-            with any other person or organization other than as required and as authorized by you. Payment related
-            information you supply will only be used to complete a transaction and will not be stored on our systems.
-        </p>
-<?php } ?>
-<?php if ($serverstatsConfig['cookie_opt_access_logs']) { ?>
-        <p>
-            <b>ACCESS LOGS:</b> We retain access logs entries for a certain period of time for the sole purpose of
-            ensuring security of our systems and compliance of acceptable use by users of this site. We don't share
-            log entries with anyone unless obligated to do so by way of a lawful request from a law enforcement
-            agency or court with appropriate jurisdiction.
-        </p>
-<?php } ?>
-<?php if ($serverstatsConfig['cookie_opt_permanent']) { ?>
-        <p>
-            <b>PERMANENT COOKIES:</b> This Website uses "Permanent Cookies" that are retained by your Web Browser.
-            This type of Cookie is used to help you when you return to this Website at a later time. If you're using
-            a public computer, be sure to delete all cookies before closing the Browser.
-        </p>
-<?php } ?>
-<?php if ($serverstatsConfig['cookie_opt_tracking']) { ?>
-        <p>
-            <b>TRACKING:</b> We may track where you go within this site. This helps us provide you with relevant
-            information and to evaluate how we may improve the site. We don't share this tracking information with anyone
-            unless otherwise stated here.
-        </p>
-<?php } ?>
-<?php if ($serverstatsConfig['cookie_opt_shared_tracking']) { ?>
-        <p>
-            <b>SHARED TRACKING:</b> This site may contain third-party shared tracking features. These features may
-            collect and share tracking information with affiliated Websites and advertisers to help them provide you with more relevant
-            information. This site may also contain third-party shared tracking features that permit a third-party
-            to collect and report traffic statistics to the owner of this site. We don't permit shared tracking
-            to include personal information of any user.
-        </p>
-<?php } ?>
-<?php if ($serverstatsConfig['cookie_opt_https']) { ?>
-        <p>
-            <b>HTTPS:</b> This Website uses the secure "HTTPS" protocol for all pages and content. This makes it very
-            difficult for anyone who may tap into Internet traffic to read what you submit and what is being sent
-            back to you. If you feel that the possibility of someone intercepting information you submit or knowledge
-            of the pages you access presents a significant risk to you, please don't use this Website.
-        </p>
-<?php } ?>
-<?php if ($serverstatsConfig['cookie_opt_logged_in']) { ?>
-        <p>
-            <b>LOGGED IN USERS:</b> We don't store passwords you use to log in as plain text, instead they're encrypted
-            before being stored in our systems. When you enter that password again to log in, we encrypt that and and
-            match it to the encrypted password that had been stored. There is no way to decrypt the stored passwords,
-            but it may be possilbe for others to guess simple passwords. You should always use more complex passwords
-            that don't include words or names people would associate with you. You should also try to avoid using the
-            same password for everything you log into and should not make those passwords easily accessible to anyone else.
-        </p>
-<?php } ?>
-<?php if ($serverstatsConfig['cookie_opt_forms']) { ?>
-        <p>
-            <b>FORMS:</b> Personal information requested in forms on this site is limited to what is required to provide
-            you with the information and services you request. Please don't provide additional personal information in
-            these forms that is not requested. If you are uncomfortable with submitting any requested information, please
-            call or write to us directly using the address and phone numbers on this site. We don't supply any of the
-            information you provide to any other individual or organization unless you check a box in the submission form
-            specifically authorizing us to do so.
-        </p>
-<?php } ?>
-<?php if ($serverstatsConfig['cookie_opt_payment']) { ?>
-        <p>
-            <b>PAYMENT INFORMATION:</b> We only use the payment information you provide to complete a paid transaction.
-             We don't retain any payment information beyond that point. If you check a box asking us to store credit
-             card or similar information for future use, we pass that request on to the credit card processing service
-             and they store that information on their systems. All we store on our systems is a "token" that can only
-             be used to process another authorized transaction on your behalf through this Website with the same credit
-             card processing service.
-         </p>
-<?php } ?>
-     </div>
 </div>
 
 <script type="text/javascript">
@@ -159,22 +81,16 @@ $serverstatsConfig = get_option(GLM_SERVERSTATS_PLUGIN_CONFIG_OPTION);
             $("#cookieNoticeBox").show();
         }
 
-        // Do show/hide of additional information
-        var showMorePrivacyInfo = false;
-        $("#showMorePrivacyInfo").on('click', function() {
-            if (showMorePrivacyInfo) {
-                $('#cookieMoreInfo').hide();
-                $('#showMorePrivacyInfo').html('Show more');
-                showMorePrivacyInfo = false;
-            } else {
-                $('#cookieMoreInfo').show();
-                $('#showMorePrivacyInfo').html('Show less');
-                showMorePrivacyInfo = true;
-            }
+        // If user clicks "Got It!" then set the cookie to now show it again for a while.
+        $(".cookieMoreInfo").on('click', function() {
+            $("#cookieNoticeBox").hide();
+            setPopupCookie(popupTimeout);
+            window.location.href = "<?php echo $moreInfoURL; ?>";
+            return false;
         });
 
         // If user clicks "Got It!" then set the cookie to now show it again for a while.
-        $("#cookieNoticeBoxClose").on('click', function() {
+        $(".cookieNoticeBoxClose").on('click', function() {
             $("#cookieNoticeBox").hide();
             setPopupCookie(popupTimeout);
         });
index c68b514..6daf8d8 100644 (file)
@@ -42,3 +42,19 @@ add_filter('glm-serverstats-is-provider', function() {
     10,
     2
 );
+
+/*
+ * Shortcode to output contact information for the bottom of the cookie and policy page created by this plugin.
+ */
+function policy_contact_shortcode( $atts ){
+    return "
+        --- NEED TO GET THIS INFORMATION FROM DATABASE FOR EACH WEBSITE ---<br>
+        Gaslight Media<br>
+        120 E. Lake St.<br>
+        Petoskey, MI 49770<br>
+        <br>
+        E-Mail: info@gaslightmedia.com<br>
+        Phone: 231-487-0692
+    ";
+}
+add_shortcode( 'policy_contact', 'policy_contact_shortcode' );