-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
executable file
·238 lines (218 loc) · 9.92 KB
/
index.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<?php
include_once plugin_dir_path(__FILE__) . "/functions.php";
$options = get_option("astrk_options");
if (!isset($options['order_id']) || ($options['order_id'] != 0 && $options['order_id'] != 1)) {
$options['order_id'] = 1;
}
if (!isset($options['cart_content']) || ($options['cart_content'] != 0 && $options['cart_content'] != 1)) {
$options['cart_content'] = 1;
}
$canlogin = true;
if (!isset($options['conversion_points'])) {
$options['conversion_points'] = array();
}
function astrk_is_woocommerce_activated()
{
return class_exists('woocommerce');
}
function debug_to_console($data)
{
$output = $data;
if (is_array($output))
$output = implode(',', $output);
echo "<script>console.log('Debug Objects: " . $output . "' );</script>";
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$options = get_option("astrk_options");
if (isset($_GET['action']) && sanitize_text_field($_GET['action']) == 'order_id') {
if (isset($_POST["orderIDCheckbox"])) {
$options['order_id'] = 1;
} else {
$options['order_id'] = 0;
}
}
if (isset($_GET['action']) && sanitize_text_field($_GET['action']) == 'cart_content') {
if (isset($_POST["cartCheckbox"])) {
$options['cart_content'] = 1;
} else {
$options['cart_content'] = 0;
}
}
update_option('astrk_options', $options);
}
if (isset($_GET['action']) && sanitize_text_field($_GET['action']) == 'logout') {
$options['uid'] = null;
$options['token'] = null;
update_option('astrk_options', $options);
}
// Login submit
if ($_POST && isset($_POST['username']) && isset($_POST['password'])) {
list($uid, $logintoken) = astrk_get_login_token(sanitize_text_field($_POST['username']), sanitize_text_field($_POST['password']));
if ($uid && $logintoken) {
$options['uid'] = $uid;
$options['token'] = $logintoken;
$canlogin = true;
} else {
$canlogin = false;
}
}
$login = astrk_check_login($options);
global $wp;
if ($login) {
update_option('astrk_options', $options);
?>
<body style="background-color: #f1f1f1;">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<?php if (astrk_is_woocommerce_activated()) : ?>
<div class="custom-card">
<div style="justify-content: space-between; display: flex; align-items: center;">
<Label class="header">
Tracking Enabled
</Label>
<img src="<?php echo esc_url(plugins_url('/images/logo.svg', __FILE__)); ?>" class="logo" alt="logo" style="width: 20%;">
</div>
<!-- <div class="form-group">
<label class="sub-header pb-1 required" for="checkout">
Checkout Page
</label>
<select id="checkout" style="width: 100%; max-width: 100%;">
<?php print $pages_select ?>
</select>
<label for="checkout" class="grey-text">
Select the page where a purchase/action is confirmed (This is required)
</label>
</div> -->
<p>
Run a test conversion to test the functionality before launching the campaign.
<br>
The ideal method of testing is described <a target='_blank' href="https://wiki.adservice.com/en/client/tracking-test"> here.</a>
<br>
<br>
If you have questions or concerns you can contact us at <a href="mailto:[email protected]">[email protected]</a>
</p>
<button type="submit" class="btn btn-primary" style="max-width: max-content;" onclick="window.location.href='?page=adservice-affiliate-network-tracking%2Findex.php&action=logout'">Logout</button>
<p>
<a class="grey-text" data-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample" id="advancedSettings">
Advanced Settings
<i class="fas fa-chevron-up" style="font-size: 10px;" id="advancedArrow"></i>
</a>
</p>
<div class="collapse custom-collapse" id="collapseExample">
<p>
For more reliable tracking both options are recommended to be enabled
</p>
<div>
<form id="order_id" form method="post" action="?page=adservice-affiliate-network-tracking%2Findex.php&action=order_id">
<div style="align-items: center;">
<input type="checkbox" style="vertical-align: bottom;" id="orderIDCheckbox" name="orderIDCheckbox" <?php echo $options['order_id'] == 1 ? 'checked' : ''; ?>>
<label class="mt-0">Order ID</label>
</div>
</form>
<label class="grey-text" style="padding-left: 1.5rem;">
Share the orderID. Used for comparing sales in Shopify with tracked sales in adservice
</label>
</div>
<div>
<form id="cart_content" form method="post" action="?page=adservice-affiliate-network-tracking%2Findex.php&action=cart_content">
<div style="align-items: center;">
<input type="checkbox" style="vertical-align: bottom;" id="cartCheckbox" name="cartCheckbox" <?php echo $options['cart_content'] ? 'checked' : ''; ?>>
<label class="mt-0">Cart Content</label>
</div>
</form>
<label class="grey-text" style="padding-left: 1.5rem;">
Share the contents of the shopping cart. Mandatory when having different pricing/cost on different products.
</label>
</div>
</div>
</div>
<?php else : ?>
<div class="custom-card">
<div style="justify-content: space-between; display: flex; align-items: center;">
<Label class="header">
Could not enable tracking
</Label>
<img src="<?php echo esc_url(plugins_url('/images/logo.svg', __FILE__)); ?>" class="logo" alt="logo" style="width: 20%;">
</div>
<p>
Woocommerce not installed. Plugin tracking is only supported with woocommerce at this time.
</p>
<button type="submit" class="btn btn-primary" style="max-width: max-content;" onclick="window.location.href='?page=adservice-affiliate-network-tracking%2Findex.php&action=logout'">Logout</button>
<?php endif ?>
<?php
} else {
?>
<body style="background-color: #f1f1f1;">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<div class="custom-card">
<div style="justify-content: space-between; display: flex; align-items: center;">
<label class="header">
Login
</label>
<img src="<?php echo esc_url(plugins_url('/images/logo.svg', __FILE__)); ?>" class="logo" alt="logo" style="width: 20%;">
</div>
<form form method="post" action="?page=adservice-affiliate-network-tracking%2Findex.php">
<div class="form-layout">
<div class="form-group">
<label class="pb-1" for="username">Username</label>
<input type="text" class="form-control" id="username" name="username" aria-describedby="emailHelp" placeholder="Enter your username">
</div>
<div class="form-group">
<label class="pb-1" for="password">Password</label>
<input type="password" class="form-control" id="password" name="password" placeholder="Enter your password">
</div>
<?php if (!$canlogin) : ?>
<span class="my-3" style="display: block" id="alertmessage">⚠ Your login credentials are incorrect.</span>
<?php endif ?>
<div style="justify-content: space-between; display: flex; align-items: center;">
<button type="submit" class="btn btn-primary">Login</button>
<a href="https://client.adservice.com/forgot-password" target="_blank" rel="noopener noreferrer">
I've forgotten my password
</a>
</div>
</div>
</form>
</div>
<div class="custom-card">
<label class="header">
New to Adservice?
</label>
<p>
Start advertising today within 15 minutes.
<br />
Sign up here!
</p>
<button class="btn btn-primary" onclick="window.location.href='https://www.adservice.com/en/advertiser/?utm_source=woocommerce';">
Create Account
</button>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
<?php
}
?>
<script type="text/javascript">
var advancedSettings = document.getElementById("advancedSettings");
advancedSettings.addEventListener("click", function() {
var arrow = document.getElementById("advancedArrow");
if (arrow.classList == "fas fa-chevron-down") {
arrow.classList = "fas fa-chevron-up";
} else {
arrow.classList = "fas fa-chevron-down";
}
});
document.getElementById("orderIDCheckbox").addEventListener("click", function() {
document.getElementById("order_id").submit();
});
document.getElementById("cartCheckbox").addEventListener("click", function() {
document.getElementById("cart_content").submit();
});
</script>