forked from sivavulli/mega_hackathon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Service.php
72 lines (64 loc) · 2.16 KB
/
Service.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
ini_set("error_reporting", E_ALL);
ini_set("display_errors", 1);
session_start();
include('ClickClass.php');
include('ClassSessions.php');
$obj= new ClickClass();
date_default_timezone_set('America/New_York');
if(isset($_SESSION["id"]) && !empty($_SESSION["id"])){
$obj->SessionID=nullif($_SESSION["id"]);
$obj->clickType=nullif($_POST["clickType"]);
$obj->EntryTime=date("Y-m-d H:i:s",time());
$obj->ClickComment=nullif($_POST["ClickComment"]);
$obj->CurrentPage=nullif($_POST["CurrentPage"]);
$obj->clickContent=nullif($_POST["clickContent"]);
$obj->Country=nullif($_POST["Country"]);
$obj->City=nullif($_POST["City"]);
}
else{
$_SESSION["id"]=ClassSessions::sessionSettor();
$obj->SessionID=nullif($_SESSION["id"]);
$obj->clickType=nullif($_POST["clickType"]);
$obj->EntryTime=date("Y-m-d H:i:s",time());
$obj->ClickComment=nullif($_POST["ClickComment"]);
$obj->CurrentPage=nullif($_POST["CurrentPage"]);
$obj->clickContent=nullif($_POST["clickContent"]);
$obj->Country=nullif($_POST["Country"]);
$obj->City=nullif($_POST["City"]);
}
//print_r($obj);
function nullif($var){
if(isset($var) && !empty($var))
{
return $var;
}
else {return null;}
}
/*
$sql = "INSERT INTO tbl_page_click_details".
"(session_id,ip_addr,curr_page_url,click_type,clicked_content,click_time,comments)".
" VALUES ('"
.$obj->SessionID."','".$obj->IPAddress."','".$obj->CurrentPage."','"
.$obj->clickType."','".$obj->clickContent."','".$obj->EntryTime."','"
.$obj->ClickComment."')";
echo $sql;
*/
$con=mysqli_connect("us-cdbr-iron-east-03.cleardb.net","b5cc7e24bc5291","4510e1e2","ad_b0866641ccff844");
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql = "INSERT INTO tbl_page_click_details".
"(session_id,ip_addr,curr_page_url,click_type,clicked_content,click_time,comments,Country,City)".
" VALUES ('"
.$obj->SessionID."','".$obj->IPAddress."','".$obj->CurrentPage."','"
.$obj->clickType."','".$obj->clickContent."','".$obj->EntryTime."','"
.$obj->ClickComment."','".$obj->Country."','".$obj->City."')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
echo "1 record added";
mysqli_close($con);
?>