/** update all statistics for the view of page $node_id * * this is a place for future extension. This routine is called once for every * page view. It can be used to record relevant data in a table, for future * reference, e.g. * - the IP-address of the visitor * - the $node_id * - the current date/time * - the number of views of node $node_id from the visitor's IP-address * - etc. etc. * * Note that the table holding this information can quickly become very large. * That requires some form of logrotate or condensing the data. This feature * has yet to be developed. * * @param int $node_id the page (node) that was viewed * @return void we assume that everything goes well and if it doesn't: too bad. * @todo maybe extend this routine to actually store more statistics information * in a separate table */ function update_statistics($node_id) { update_view_count($node_id); // // additional statistics code can go here // }
<?php include 'get_connection.php'; try { if (PHP_SAPI === 'cli') { $poll_id = $argv[1]; } else { $poll_id = $_GET['poll_id']; } update_view_count($conn, $poll_id); } catch (PDOException $e) { echo "Connection failed: " . $e->getMessage(); return; } $conn = null; function update_view_count($conn, $poll_id) { $stmt = $conn->prepare("UPDATE polls SET views = (views + 1) WHERE id = :poll_id"); $stmt->bindparam(':poll_id', $poll_id); $stmt->execute(); }
<?php include 'get_connection.php'; try { if (PHP_SAPI === 'cli') { $post_id = $argv[1]; } else { $post_id = $_GET['post_id']; } update_view_count($conn, $post_id); } catch (PDOException $e) { echo "Connection failed: " . $e->getMessage(); return; } $conn = null; function update_view_count($conn, $post_id) { $stmt = $conn->prepare("UPDATE posts SET views = (views + 1) WHERE id = :post_id"); $stmt->bindparam(':post_id', $post_id); $stmt->execute(); }
} else { echo "404 - Video Not Found "; } ?> - tynime</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> <?php addSiteReqs(); ?> </head> <body> <?php showSiteNavigation(); if ($info != false) { // add one to our view counter variable update_view_count($_GET["v"]); // if they are logged in, add this video to their history if (isset($_SESSION['loggedin']) && $_SESSION['loggedin']) { add_video_to_history($_GET["v"]); } $links = create_links($info["seriesName"], $info["seriesPos"], $info["name"]); $prev_and_next_links = get_prev_and_next_links($info["seriesName"], $info["seriesPos"]); ?> <div class="video-container"> <h2><?php echo $info["seriesName"]; ?> <br /> <?php echo "Episode " . $info["seriesPos"] . ": " . $info["name"]; ?> </h2>