first commit

This commit is contained in:
dev-chiefworks
2022-05-31 16:21:53 -04:00
commit f76abffdcd
5978 changed files with 1078901 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
<?php
function parseEmail($email_id)
{
global $httpAuthToken,$oauth_api;
$url = $oauth_api."parse/" . $email_id;
$opts = array(
'http' => array(
'method' => "GET",
'timeout' => 60, /* 1 minute */
'header' =>
"Content-Type: application/x-www-form-urlencoded\r\n" .
"Accept: application/json\r\n" .
"Authorization: Server-Token ${httpAuthToken}\r\n",
),
);
$context = stream_context_create($opts);
$body = file_get_contents($url, false, $context);
$geocoded = json_decode($body, true);
if (is_array($geocoded) && is_array($geocoded["data"]) && !isset($geocoded["error"])) {
return $geocoded["data"];
}
return null;
}
function updateParsedEmail($id, $location_start_id, $location_end_id)
{
global $conn;
$q = "UPDATE parsedemail_item SET updated=NOW(), location_start_id=" . $location_start_id . ", location_end_id=" . $location_end_id . "
WHERE id = " . $id . "";
$r = pg_query($conn, $q);
if ($r && pg_num_rows($r) && $f = pg_fetch_assoc($r)) {
return [$f, null];
}
return [null, pg_last_error($conn)];
}