// ttFileHelper class is used for attachment handling.
class ttFileHelper {
- var $errors = null; // Errors go here. Set in constructor by reference.
+ var $errors = null; // Errors go here. Set in constructor by reference.
+ var $storage_uri = null;
+ var $site_id = null;
+ var $site_key = null;
// Constructor.
function __construct(&$errors) {
$this->errors = &$errors;
+
+ if (isset($GLOBALS['FILE_STORAGE_PARAMS']) && is_array($GLOBALS['FILE_STORAGE_PARAMS'])) {
+ $params = $GLOBALS['FILE_STORAGE_PARAMS'];
+ $this->storage_uri = $params['uri'];
+ $this->site_id = $params['site_id'];
+ $this->site_key = $params['site_key'];
+ }
}
// putFile - puts uploaded file in remote storage.
- function putFile() {
+ function putFile($description) {
+
+ $url = $this->storage_uri;
+ $fields = array('description' => urlencode($description),
+// 'fname' => urlencode($_POST['first_name']),
+// 'title' => urlencode($_POST['title']),
+// 'company' => urlencode($_POST['institution']),
+// 'age' => urlencode($_POST['age']),
+// 'email' => urlencode($_POST['email']),
+// 'phone' => urlencode($_POST['phone'])
+ );
+
+ // url-ify the data for the POST.
+ foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
+ $fields_string = rtrim($fields_string, '&');
+
+ // Open connection.
+ $ch = curl_init();
+
+ // Set the url, number of POST vars, POST data.
+ curl_setopt($ch, CURLOPT_URL, $url);
+ curl_setopt($ch, CURLOPT_POST, count($fields));
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+
+ // Execute a post rewuest.
+ $result = curl_exec($ch);
+
+ // Close connection.
+ curl_close($ch);
+
+ if ($result) {
+ $result_array = json_decode($result, true);
+ $file_id = $mdb2->quote($result_array['id']);
+ }
unlink($_FILES['newfile']['tmp_name']);
return false; // Not implemented.
return false;
}
- // The getInactiveOrgs is a maintenance function that returns an array of inactive organization ids (max 10 for now).
+ // The getInactiveOrgs is a maintenance function that returns an array of inactive organization ids (max 25 for now).
static function getInactiveOrgs() {
$inactive_orgs = array();
$mdb2 = getConnection();
$cutoff_timestamp = $mdb2->quote(date('Y-m-d', strtotime('-1 year')));
$sql = "select org_id from".
" (select max(accessed) as last_access, org_id from tt_users where org_id > 0 group by org_id order by last_access, org_id) as t".
- " where last_access is null or last_access < $cutoff_timestamp limit 10"; // Max 10 orgs at a time for now...
+ " where last_access is null or last_access < $cutoff_timestamp limit 25"; // Max 25 orgs at a time for now...
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
while ($val = $res->fetchRow()) {
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.18.59.4872 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.18.59.4873 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
<a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
<a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
<a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>
if (!ttValidString($cl_description, true)) $err->add($i18n->get('error.field'), $i18n->get('label.description'));
// Finished validating user input.
- $fileHelper = new ttFileHelper($err);
- $fileHelper->putFile();
+ if ($err->no()) {
+ $fileHelper = new ttFileHelper($err);
+ $fileHelper->putFile($cl_description);
+ }
// if ($err->no()) $msg->add($i18n->get('form.import.success'));
} // isPost