summaryrefslogtreecommitdiff
path: root/includes/jobs/UpdateContactMethods.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/jobs/UpdateContactMethods.php')
-rw-r--r--includes/jobs/UpdateContactMethods.php61
1 files changed, 0 insertions, 61 deletions
diff --git a/includes/jobs/UpdateContactMethods.php b/includes/jobs/UpdateContactMethods.php
deleted file mode 100644
index cbd0239..0000000
--- a/includes/jobs/UpdateContactMethods.php
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php
-
-$options = json_decode($argv[1], true);
-$_SERVER['DOCUMENT_ROOT'] = "/_ch";
-require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/composer/vendor/autoload.php';
-use ColorThief\ColorThief;
-
-echo("Loading...\n");
-
-$app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true);
-$id = $options["contact"];
-
-$methods = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/contactmethods.json"), true);
-$contacts = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/addressbook/contacts.json"), true);
-$cache = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/addressbook/saved.json"), true);
-
-echo("Processing for contact $id\n");
-
-if (!isset($contacts[$id])) {
- echo("Contact was deleted since then, aborting\n");
- die();
-}
-
-$contact = $contacts[$id];
-
-foreach ($methods as $name => $method) {
- if (isset($contacts[$id][$name])) {
- echo("Contact makes use of $name, gathering information\n");
-
- if (!isset($cache[$name])) $cache[$name] = [];
- if (!isset($cache[$name][$contacts[$id][$name]])) $cache[$name][$contacts[$id][$name]] = [
- "data" => null,
- "update" => 0
- ];
-
- if (time() - $cache[$name][$contacts[$id][$name]]["update"] > 86400 || isset($cache[$name][$contacts[$id][$name]]["data"]["error"])) {
- echo(" Information is out of date, updating it\n");
-
- $return = [];
- $cmd = "cd \"$_SERVER[DOCUMENT_ROOT]/includes/external/addressbook\" && node \"$_SERVER[DOCUMENT_ROOT]/includes/external/addressbook/$name.js\" \"" . str_replace('"', "''", $contacts[$id][$name]) . "\"";
-
- exec("nice -n 19 " . $cmd, $return);
- $json = trim(implode("\n", $return));
-
- $cache[$name][$contacts[$id][$name]] = [
- "data" => json_decode($json),
- "update" => time()
- ];
-
- echo(" Information updated\n");
- } else {
- echo(" Information is up to date, not updating it\n");
- }
- } else {
- echo("Contact does not makes use of $name\n");
- }
-}
-
-echo("Done!\n");
-
-file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/addressbook/saved.json", json_encode($cache)); \ No newline at end of file