Article

  • 1 year

    1 year

    YetiShare / Core

    715

How to limit download tokens by IP address

For IP address restriction on download tokens, it can be enabled by following this guidance:

IMPORTANT: This will stop the Document Viewer Plugin from working as Google Docs will no longer be able to access the files, you should disable this plugin via the admin area.

In /core/includes/file.class.php, change this:

// check token
// $tokenData = $db->getRow('SELECT id, user_id, ip_address, file_id, download_speed, max_threads FROM download_token WHERE file_id = ' . $db->escape($this->id) . ' AND ip_address=' . $db->quote(coreFunctions::getUsersIPAddress()) . ' AND token = ' . $db->quote($downloadToken) . ' LIMIT 1'); $tokenData = $db->getRow('SELECT id, user_id, ip_address, file_id, download_speed, max_threads FROM download_token WHERE file_id = ' . $db->escape($this->id) . ' AND  token = ' . $db->quote($downloadToken) . ' LIMIT 1');

To:

// check token
$tokenData = $db->getRow('SELECT id, user_id, ip_address, file_id, download_speed, max_threads FROM download_token WHERE file_id = ' . $db->escape($this->id) . ' AND ip_address=' . $db->quote(coreFunctions::getUsersIPAddress()) . ' AND token = ' . $db->quote($downloadToken) . ' LIMIT 1'); //$tokenData = $db->getRow('SELECT id, user_id, ip_address, file_id, download_speed, max_threads FROM download_token WHERE file_id = ' . $db->escape($this->id) . ' AND  token = ' . $db->quote($downloadToken) . ' LIMIT 1');