Files
Fedor ac7467f0b4 Major CRM updates: AI Assistant, Court Status API, S3 integration improvements, and extensive file storage system
- Added comprehensive AI Assistant system (aiassist/ directory):
  * Vector search and embedding capabilities
  * Typebot proxy integration
  * Elastic search functionality
  * Message classification and chat history
  * MCP proxy for external integrations

- Implemented Court Status API (GetCourtStatus.php):
  * Real-time court document status checking
  * Integration with external court systems
  * Comprehensive error handling and logging

- Enhanced S3 integration:
  * Improved file backup system with metadata
  * Batch processing capabilities
  * Enhanced error logging and recovery
  * Copy operations with URL fixing

- Added Telegram contact creation API
- Improved error logging across all modules
- Enhanced callback system for AI responses
- Extensive backup file storage with timestamps
- Updated documentation and README files

- File storage improvements:
  * Thousands of backup files with proper metadata
  * Fix operations for broken file references
  * Project-specific backup and recovery systems
  * Comprehensive file integrity checking

Total: 26,461+ files added/modified including AWS SDK, vendor dependencies, and extensive backup system.
2025-10-16 11:17:21 +03:00

123 lines
3.9 KiB
PHP

<?php
/*+***********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
*************************************************************************************/
/**
* Helper methods to work with ShortURLs
*/
class Vtiger_ShortURL_Helper {
/*
* @param options array(
* 'handler_path' => 'path/to/TrackerClass.php',
* 'handler_class' => 'TrackerClass',
* 'handler_function' => 'trackingFunction',
* 'handler_data' => array(
* 'key1' => 'value1',
* 'key2' => 'value2'
* )
* ));
*/
static function generateURL(array $options) {
global $site_URL;
if (!isset($options['onetime'])) $options['onetime'] = 0;
$uid = self::generate($options);
return "$site_URL/shorturl.php?id=" . $uid;
}
static function generate(array $options) {
$db = PearDatabase::getInstance();
// TODO Review the random unique ID generation
$uid = uniqid("", true);
$handlerPath = $options['handler_path'];
$handlerClass= $options['handler_class'];
$handlerFn = $options['handler_function'];
$handlerData = $options['handler_data'];
if (empty($handlerPath) || empty($handlerClass) || empty($handlerFn)) {
throw new Exception("Invalid options for generate");
}
$sql = "INSERT INTO vtiger_shorturls(uid, handler_path, handler_class, handler_function, handler_data, onetime) VALUES (?,?,?,?,?,?)";
$params = array($uid, $handlerPath, $handlerClass, $handlerFn, json_encode($handlerData), $options['onetime']);
$db->pquery($sql, $params);
return $uid;
}
static function handle($uid) {
$db = PearDatabase::getInstance();
$rs = $db->pquery('SELECT * FROM vtiger_shorturls WHERE uid=?', array($uid));
if ($rs && $db->num_rows($rs)) {
$record = $db->fetch_array($rs);
$handlerPath = decode_html($record['handler_path']);
$handlerClass= decode_html($record['handler_class']);
$handlerFn = decode_html($record['handler_function']);
$handlerData = json_decode(decode_html($record['handler_data']), true);
checkFileAccessForInclusion($handlerPath);
require_once $handlerPath;
$handler = new $handlerClass();
// Delete onetime URL
if ($record['onetime']) $db->pquery('DELETE FROM vtiger_shorturls WHERE id=?', array($record['id']));
call_user_func(array($handler, $handlerFn), $handlerData);
} else {
echo '<h3>Link you have used is invalid or has expired. .</h3>';
}
}
/**
* Function will send tracker image of 1X1 pixel transparent Image
*/
static function sendTrackerImage() {
header('Content-Type: image/png');
echo base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=');
}
function getInstance($id) {
$db = PearDatabase::getInstance();
$self = new self();
$rs = $db->pquery('SELECT * FROM vtiger_shorturls WHERE uid=?', array($id));
if ($rs && $db->num_rows($rs)) {
$row = $db->fetch_array($rs);
$self->id = $row['id'];
$self->uid = $row['uid'];
$self->handler_path = $row['handler_path'];
$self->handler_class= $row['handler_class'];
$self->handler_function = $row['handler_function'];
$self->handler_data = json_decode(decode_html($row['handler_data']), true);
}
return $self;
}
function compareEquals($data) {
$valid = true;
if($this->handler_data) {
foreach($this->handler_data as $key => $value) {
if($data[$key] != $value) {
$valid = false;
break;
}
}
} else {
$valid = false;
}
return $valid;
}
function delete() {
$db = PearDatabase::getInstance();
$db->pquery('DELETE FROM vtiger_shorturls WHERE id=?', array($this->id));
}
}