• What is wrong with this?

    <?php
    /*
    Plugin Name: A Simple Cookie Persons Visits and Last Visited Shortcode
    Description: This provides a simple and easy shortcode <code>[visits]</code>  that shows each user how many times they have visited the page.
    It can even show the time they last visited <code>[time]</code> , or both <code>[visits_time]</code> .
    */
    <html>
    <head>
    add_shortcode('visitstime','visits_time');
    function visits_time(){
    return
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <script type="text/javascript" language="javascript">
    
    <!--
    now = new Date
    expireDate = new Date
    expireDate.setMonth(expireDate.getMonth()+6)
    
    hitCt = parseInt(cookieVal("pageHit"))
    hitCt++
    lastVisit = cookieVal("pageVisit")
    if (lastVisit == 0) {
    lastVisit = ""
    }
    
    document.cookie = "pageHit="+hitCt+";expires=" + expireDate.toGMTString()
    document.cookie = "pageVisit="+now+";expires=" + expireDate.toGMTString()
    
    function cookieVal(cookieName) {
    thisCookie = document.cookie.split("; ")
    for (i=0; i<thisCookie.length; i++) {
    if (cookieName == thisCookie[i].split("=")[0]) {
    return thisCookie[i].split("=")[1]
    }
    }
    return 0
    }
    -->
    </script>
    </head>
    <body>
    <h2>
    <script type="text/javascript" language="javascript">
    <!--
    document.write("You have visited this page " + hitCt + " time(s).")
    if (lastVisit != "") {
    document.write("<br />Your last  visit was " + lastVisit)
    }
    -->
    </script>
    </h2>
    </body>
    </html>
    }
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘What is wrong with this?’ is closed to new replies.