first commit

This commit is contained in:
2024-10-28 22:14:22 +01:00
commit b65352c452
40581 changed files with 5712079 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
drwxr-xr-x 2 30094 users 4 Oct 6 10:16 .
drwxr-xr-x 8 30094 users 21 Oct 6 10:16 ..
-rw-r--r-- 1 30094 users 1812 Aug 31 2021 analytics
-rw-r--r-- 1 30094 users 298 Aug 31 2021 index.php

View File

@@ -0,0 +1,106 @@
#!/usr/bin/env php
<?php
require_once(__DIR__ . '/../lib/Segment.php');
if (in_array('--help', $argv)) {
print(usage());
exit;
}
date_default_timezone_set('UTC');
$options = getopt('', array(
'writeKey::',
'type:',
'userId::',
'event::',
'properties::',
'name::',
'traits::',
'groupId::',
'previousId::'
));
if (empty($options['writeKey'])) {
error('writeKey flag required');
}
Segment::init($options['writeKey']);
switch ($options['type']) {
case 'track':
Segment::track(array(
'userId' => $options['userId'],
'event' => $options['event'],
'properties' => parse_json($options['properties'])
));
break;
case 'identify':
Segment::identify(array(
'userId' => $options['userId'],
'traits' => parse_json($options['traits'])
));
break;
case 'page':
Segment::page(array(
'userId' => $options['userId'],
'name' => $options['name'],
'properties' => parse_json($options['properties'])
));
break;
case 'group':
Segment::identify(array(
'userId' => $options['userId'],
'groupId' => $options['groupId'],
'traits' => parse_json($options['traits'])
));
break;
case 'alias':
Segment::alias(array(
'userId' => $options['userId'],
'previousId' => $options['previousId']
));
break;
default:
error(usage());
break;
}
Segment::flush();
function usage() {
return "\n Usage: analytics --type <track|identify|page|group|alias> [options]\n\n";
}
function error($message) {
print("$message\n\n");
exit(1);
}
function parse_json($input) {
if (empty($input)) {
return null;
}
return json_decode($input);
}
function parse_timestamp($input) {
if (empty($input)) {
return null;
}
return strtotime($input);
}

View File

@@ -0,0 +1,11 @@
<?php
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;