public function getLatestCommentTime($docId = 0) { $user = JFactory::getUser(); $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('created')->from('#__judownload_comments')->order('id DESC'); if ($docId > 0) { $query->where('doc_id = ' . $docId); } if ($user->id > 0) { $query->where('user_id =' . $user->id); } else { $ipAddress = JUDownloadFrontHelper::getIpAddress(); $query->where('ip_address = "' . $ipAddress . '"'); } $db->setQuery($query, 0, 1); $result = $db->loadResult(); return $result; }
protected function prepareTable($table) { $date = JFactory::getDate(); $user = JFactory::getUser(); if (empty($table->id)) { if (!$table->created) { $table->created = $date->toSql(); } if (!$table->guest_name || !$table->guest_email) { $table->user_id = $user->id; } if (!$table->ip_address) { $table->ip_address = JUDownloadFrontHelper::getIpAddress(); } } else { $table->modified_by = $user->id; $table->modified = $date->toSql(); } }
public static function checkBlackListUserIP() { require_once JPATH_SITE . '/components/com_judownload/libs/ipblocklist.class.php'; $params = JUDownloadHelper::getParams(); $app = JFactory::getApplication(); $is_passed = true; if ($app->isSite() && $params->get('block_ip', 0)) { $ip_address = JUDownloadFrontHelper::getIpAddress(); $ipWhiteList = $params->get('ip_whitelist', ''); $ipBlackList = $params->get('ip_blacklist', ''); $checkIp = new IpBlockList($ipWhiteList, $ipBlackList); $is_passed = $checkIp->ipPass($ip_address); } return $is_passed; }
public function addCommentSubscription($commentId) { $user = JFactory::getUser(); $subscriptionData = array(); $subscriptionData['user_id'] = $user->id; $subscriptionData['type'] = 'comment'; $subscriptionData['name'] = $user->username; $subscriptionData['email'] = $user->email; $subscriptionData['created'] = JHtml::date('now', 'Y-m-d H:i:s', true); $subscriptionData['item_id'] = $commentId; $subscriptionData['ip_address'] = JUDownloadFrontHelper::getIpAddress(); $subscriptionData['published'] = 1; require_once JPATH_SITE . '/components/com_judownload/models/subscribe.php'; JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_judownload/models'); $subcribeModel = JModelLegacy::getInstance('Subscribe', 'JUDownloadModel'); if (!$subcribeModel->add($subscriptionData)) { return false; } return true; }
public function htaccessProtectFile($downloadFilePath, $params) { $folder = dirname($downloadFilePath); $fileHtaccess = $folder . "/.htaccess"; $fileHtaccess = JPath::clean($fileHtaccess); $fileName = basename($downloadFilePath); $buffer = "<Files \"" . $fileName . "\">\n"; if ($params->get('restrict_ip_download_file', 1)) { $ipAddress = JUDownloadFrontHelper::getIpAddress(); $buffer .= "Order deny,allow\n"; $buffer .= "Deny from all\n"; $buffer .= "Allow from " . $ipAddress . "\n"; } else { $buffer .= "Order allow,deny\n"; $buffer .= "Allow from all\n"; } $buffer .= "</Files>\n"; $buffer .= "<FilesMatch \"\\.(?:htaccess|htpasswd|ini|php|phtml|php3|php4|php5|php6|pl|py|jsp|asp|htm|shtml|bat|sh|cgi)$\">\n"; $buffer .= "Order allow,deny\n"; $buffer .= "Deny from all\n"; $buffer .= "</FilesMatch>\n"; $buffer .= "Order allow,deny\n"; $buffer .= "Deny from all\n"; JFile::write($fileHtaccess, $buffer); }