· 7 years ago · Jan 23, 2019, 08:14 PM
1Order as it happens.
2
3cc_clicklist.php
4
5 $statid = $_GET['statid'];
6
7 //creating table to capture what the user clicks
8 $create = $conn->prepare("create table if not exists `$statid`(`links` varchar(45) NOT NULL, `dateclicked` DATETIME NOT NULL) DEFAULT CHARSET=utf8 COLLATE utf8_bin ");
9
10 //This fetches the links to be clicked and also checks user for links
11 $stmt = $conn->prepare("select `recruitid` from `clicklist` where `recruitid` not in (select `links` from `$statid` where `dateclicked` >= DATE_SUB(NOW(),INTERVAL 23 HOUR) group by `links` having count(*) >= 1) GROUP BY `recruitid` ORDER BY RAND()");
12
13
14
15------------------------------------------------------------------------
16yarstats2.php
17
18 //This one gets total clicks
19 $totalClicks = $conn->prepare("select count(`links`) from `$id`");
20 $totalClicks->execute();
21 $totFetch = $totalClicks->fetchColumn();
22 echo $totFetch;
23 echo ",";
24
25 //This one tells how many clicks for past 23 hours
26 $dailyins = $conn->prepare("INSERT INTO clicktotal (`name`, `total`) VALUES ('$id', '$totFetch') ON DUPLICATE KEY UPDATE `total`='$totFetch'");//erebus
27 $dailyins->execute();
28 $todayClicks = $conn->prepare("select count(`links`) from `$id` WHERE `dateclicked` >= DATE_SUB(NOW(),INTERVAL 23 HOUR)");
29 echo $result;
30 echo ",";
31
32 //These next querys tells how many is left to click. providing that there inserted.
33 $clicksList = $conn->prepare("select count(`recruitid`) from `clicklist` ");
34 $clicksList->execute();
35 $list = $clicksList->fetchColumn();
36
37 $clicked = $conn->prepare("select count(`links`) from `$id` where `dateclicked` >= DATE_SUB(NOW(),INTERVAL 23 HOUR)");// had " = CURDATE() "
38 $clicked->execute();
39 $clickedlist = $clicked->fetchColumn();
40 $left = $list-$clickedlist;
41 echo $left;
42
43
44------------------------------------------------------------------------------
45cc_submitclicks.php
46
47
48 //This one does the inserting of each link clicked
49 $links = explode(',', $links);
50 array_shift($links);
51 foreach($links as $link){
52 //for ($i=0; $i<count($links); $i++) {
53 $query = $conn->prepare("INSERT INTO $_POST['statid'] ( links, dateclicked ) VALUES( $link, NOW() )");
54 $query->execute();
55 $linkage = $query->fetchAll(PDO::FETCH_ASSOC);
56 echo $linkage;
57 echo "<br>";
58
59
60 $stmt = $conn->prepare("SELECT COUNT(*) FROM `'".$statid."'` ORDER BY dateclicked ");//("SELECT sum(`total`) FROM `clicktotal` WHERE `name` in (select `name` from `salt`.`stats` where stats.id = '$id')");
61 $stmt->execute();
62 //$newTotal = $stmt->fetchColumn();
63 //$rowCount = $stmt->rowCount();
64 $get = $stmt->fetch();
65 $newTotal = $get['COUNT(*)'];
66
67 //after counting inserted links, will now insert info about $user into another table with total amount and lastclicked which is clicks during a session
68 if($newTotal == 0){
69 //$insZero = 0;
70 //this way for firstuse
71 $insrtFirst = $conn->prepare("INSERT INTO clicktotal (`statid`, `lastclicked`) VALUES ('".$statid."', '".$clicked."')");//erebus
72 $insrtFirst->execute();
73 } else {
74 $insrtSec = $conn->prepare("INSERT INTO clicktotal (`statid`, `lastclicked`) VALUES ('".$statid."', '".$clicked."') ON DUPLICATE KEY UPDATE `lastclicked`='".$clicked."'");//erebus
75 $insrtSec->execute();
76 }