diff --git a/api_application/models/table_ocs_downloads.php b/api_application/models/table_ocs_downloads.php index 1becb3b..4402896 100644 --- a/api_application/models/table_ocs_downloads.php +++ b/api_application/models/table_ocs_downloads.php @@ -1,70 +1,70 @@ . **/ class table_ocs_downloads extends BaseModel { public function __construct(&$db) { parent::__construct($db, $db->getTableConfig()); $this->setName('stat_file_downloads'); $this->setPrimaryInsert(true); } public function __set($key, $value) { $value = $this->_convertArrayToObject($value); parent::__set($key, $value); } public function save($value) { $ipRemoteV6 = filter_var($this->_getIp(), FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) ? $this->_getIp() : null; $ipRemoteV4 = filter_var($this->_getIp(), FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) ? $this->_getIp() : null; $ipClientv6 = filter_var($value['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) ? $value['ip'] : $ipRemoteV6; $ipClientv4 = filter_var($value['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) ? $value['ip'] : $ipRemoteV4; $sql = ("INSERT IGNORE INTO `stat_object_download` (`seen_at`, `ip_inet`, `object_type`, `object_id`, `ipv4`, `ipv6`, `fingerprint`, `user_agent`, `member_id_viewer`) VALUES (:seen, :ip_inet, :object_type, :product_id, :ipv4, :ipv6, :fp, :ua, :member)"); $ip_inet = isset($value['ip']) ? $value['ip'] : $this->_getIp(); $time = (round(time() / 300)) * 300; $seen_at = date('Y-m-d H:i:s', $time); $this->_db->addStatementLog($sql); $stmt = $this->getDb()->prepare($sql); $stmt->execute(array( 'seen' => $seen_at, 'ip_inet' => inet_pton($ip_inet), 'object_type' => 40, 'product_id' => $value['file_id'], 'ipv6' => $ipClientv6, 'ipv4' => $ipClientv4, 'fp' => $value['fp'] ? $value['fp'] : null, 'ua' => $_SERVER['HTTP_USER_AGENT'] ? $_SERVER['HTTP_USER_AGENT'] : null, - 'member' => isset($vaue['u']) ? $value['u'] : null + 'member' => isset($value['u']) ? $value['u'] : null )); $stmt->closeCursor(); $stmt = null; } }