-
Notifications
You must be signed in to change notification settings - Fork 0
/
ga-get-profile.php
95 lines (83 loc) · 2.7 KB
/
ga-get-profile.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
include_once('modules/config.php');
if(!loggedIn()):
echo '<script> window.location="login.php"; </script> ';
else:
$query = $coll->findOne(array('username' => $_SESSION["username"]));
$refresh_token = $query['ga_refresh_token'];
if (!isset($query['ga_refresh_token'])):
echo '<script> window.location="' . $get_ga_code_url . '"; </script> ';
else:
$access_token = getAccessToken($refresh_token);
//Get web properties for account
if(isset($access_token)):
$result_properties = getWebProperties($access_token);
foreach ($result_properties['items'] as $obj_add):
$dropdown_add .= "<option value='" . $obj_add['id'] . "*" . $obj_add['name'] . "'>" . $obj_add['name'] . "</option>";
endforeach;
foreach ($query['ga_web_property'] as $obj_delete):
$dropdown_delete .= "<option value='" . $obj_delete['ga_property_id'] . "'>" . $obj_delete['ga_property_name'] . "</option>";
endforeach;
endif;
endif;
if(isset($_POST['property_add'])):
$try = explode('*',$_POST['property_add']);
$ga_property_id = $try[0];
$ga_property_name = $try[1];
setWebProperty($query['username'], $ga_property_id, $ga_property_name);
echo '<script>parent.window.location.reload(true);</script>';
endif;
if(isset($_POST['property_delete'])):
$ga_property_id = $_POST['property_delete'];
deleteWebProperty($query['username'], $ga_property_id);
echo '<script>parent.window.location.reload(true);</script>';
endif;
endif;
?>
<html>
<head>
<title>Select a Web Property</title>
</head>
<body>
<form action="<?=$_SERVER["PHP_SELF"];?>" method="POST">
<table>
<tr>
<td>
Select a Web Property:
</td>
</tr>
<tr>
<td>
<select name="property_add">
<?php echo $dropdown_add;?>
</select>
</td>
<td>
<input name="submit_select" type="submit" value="Add Property">
</select>
</td>
</tr>
</table>
</form>
<form action="<?=$_SERVER["PHP_SELF"];?>" method="POST">
<table>
<tr>
<td>
Delete a Web Property:
</td>
</tr>
<tr>
<td>
<select name="property_delete">
<?php echo $dropdown_delete;?>
</select>
</td>
<td>
<input name="submit_delete" type="submit" value="Delete Property">
</select>
</td>
</tr>
</table>
</form>
</body>
</html>