I can’t seem to get this module to work. I always get the same error, “Invalid URI”. I believe I have done everything properly.
Here’s my code:
{exp:weblog:entries weblog="clients" rdf="off" category="18" paginate="bottom" limit="5" username="CURRENT_USER"}
{title}
<h3>{title}</h3>
{if logged_in}<a href="http://{exp:download_lock:link">Download</a>
{if:else}You must be logged in to download.{/if}
{/exp:weblog:entries}
The field name is correct, I even tried it without the brackets, the file exists in the directory. I’ve placed the file in the custom field in the publish panel using https://ellislab.com/asset/images/showcase/stine.jpg.zip. My file upload settings should be correct (I attached a screen cap to this post). And my custom field is named “downloads”. Could it not work with EE 1.6?
Mod Edit Moved to the appropriate forum for third party modules.
Yep- I recently ran into this one myself. I can’t remember if it’s due to 1.6 or not- I think so. Basically, IIRC, it happens when you have two fields with the same field name- because it’s grabbing the field for the file name based on that. Don’t have a fix up on the site- but did hack it into the one I’m using. Haven’t had time to fully think on it- but this is working on the current 1.6 sites. Need to edit mod.download_lock.php around line 158.
bad:
else
{
$query = $DB->query("SELECT d.*, field_id, group_id FROM exp_weblog_fields f, exp_weblog_data d WHERE entry_id = $id AND field_name = '$field_id' LIMIT 1");
if ( $query->num_rows == 0)
{
$data['content'] = $LANG->line('invalid_link').'3';
return $OUT->show_message($data);
}
$field_group = $query->row['group_id'];
$field = 'field_id_'.$query->row['field_id'];
$temp_filename = $query->row[$field];
$weblog_id = $query->row['weblog_id'];
good:
else
{
$query = $DB->query("SELECT d.*, field_id, f.group_id FROM exp_weblog_fields f, exp_weblog_data d, exp_weblogs w WHERE entry_id = $id AND field_name = '$field_id' AND f.group_id = w.field_group AND w.weblog_id = d.weblog_id LIMIT 1");
if ( $query->num_rows == 0)
{
$data['content'] = $LANG->line('invalid_link').'3';
return $OUT->show_message($data);
}
$field_group = $query->row['group_id'];
$field = 'field_id_'.$query->row['field_id'];
$temp_filename = $query->row[$field];
$weblog_id = $query->row['weblog_id'];
I really need to ponder on it a bit more before I decide it’s a universal fix. But it worked for me now. Give it a try, let me know if you still run into an issue.
Hi Robin,
Well I inserted the fix but could not get it to work. Could the fact that I have to set “Force URL query strings” to yes have anything to do with it? The server where this site is on does not support the PATH_INFO variable.
If not, do you have any other ideas?
Thanks for all your help!
Hi Robin,
I still haven’t been able to get this to work. You had mentioned you had a possible fix for this
<
blockquote>… Because the query string is the issue- I know because I fixed it once for someone else. But haven’t dug up the code to figure out where to tweak it. Thought I already had in truth.
This generates the link:
$link = ‘Download File {if:else}You must be logged in to download.{/if}
<a href="http://{path=logout}">Log out</a>
{paginate}
<table class="pagination_table" id="full" cellspacing="0">
<tr>
<td id="previous_page">
{if previous_page}
<a href="http://{auto_path}">(• Previous Entry</a>
{/if}
</td>
<td id="center_footer">
<h1 id="clients_title"> Client Access </h1>
</td>
<td id="next_page">
{if next_page}
<a href="http://{auto_path}">Next Entry •)</a>
{/if}
</td>
</tr>
</table>
{/paginate}
{/exp:weblog:entries}[/code]
aquaadmin, it happens I was working on another use of a (modified) Download_lock this afternoon, and came across your trail trying to get help here.
As I’ve modified my copy of Robin’s basic extension, I can’t give you a full copy of it. But I looked at your problem, and have a fix that may be appropriate.
I tried turning on Force URL Query Strings here, and with that get the same bad URI message as you do, on trying to download.
looking at the Download link that Download_lock generated, it has two ‘?’ in it, while Force_etc. should cause only one. That’s the problem.
I’ve made and tested a solution, as follows.
If you edit the code in mod.download_lock.php, the extension, you should see the following, somewhere around line 340 or so. Sorry I can’t be more precise, as I have extra lines in my modified version, but it should be clear once you find it.
if ($show_message == 'yes')
{
if ($SESS->userdata('member_id') == 0)
{
return $LANG->line('must_be_logged_in');
}
if ($entry_id == '')
{
return $LANG->line('no_entry_specified');
}
}
if ($link_url_only == 'yes')
{
$link = $FNS->fetch_site_index(0, 0).'?ACT='.$insert_action.'&ID;='.$entry_id.$field_name;
return $link;
}
else
{
$link = '<a >fetch_site_index(0, 0).'?ACT='.$insert_action.'&ID;='.$entry_id.$field_name.'">Download</a>';
return $link;
}
return;
}
now, the fix needs to be done in the last if and else blocks of that code. Notice there is question mark before the term ACT in both cases. We have to do something else, because looking at the code for fetch_site_index, it is already putting a question mark in for ‘force query etc.’. This makes doubled question marks, and the problem.
here is how you fix it. Make the code look like the following.
Notice that I have added a test and set a variable called act_string to have the ACT only or the ?ACT text, depending on whether the ‘force query string’ is set or not.
Notice also that in both places ‘?ACT’ was used, I’ve replaced that text with the $act_string variable. Be very careful about the punctuations, including the periods. You should in fact probably just cut and paste this code.
Watch out also to get all the code, as the forum doesn’t wrap - select all the way to the right.
if ($show_message == 'yes')
{
if ($SESS->userdata('member_id') == 0)
{
return $LANG->line('must_be_logged_in');
}
if ($entry_id == '')
{
return $LANG->line('no_entry_specified');
}
}
if ($PREFS->ini('force_query_string') == 'y') {
$act_string = 'ACT=';
}
else {
$act_string = '?ACT=';
}
if ($link_url_only == 'yes')
{
$link = $FNS->fetch_site_index(0, 0).$act_string.$insert_action.'&ID;='.$entry_id.$field_name;
return $link;
}
else
{
$link = '<a >fetch_site_index(0, 0).$act_string.$insert_action.'&ID;='.$entry_id.$field_name.'">Download</a>';
return $link;
}
return;
}
Ok, that should do it. Let us know how it works for you. I can’t imagine why this was let without answer, and hope you get this early enough to do you some good.
Kind regards, Clive
Thank you so much for helping me on this issue Clive!! I was getting pretty stressed and frustrated. It seemed such an easy fix and was so close. I’ll try it out this evening and let you know if it works or not. Hopefully the next person who runs into this issue will be able to get help from this thread. Once again thank you!
Well, wishing you good luck on this once you edit the fix lines in.
It should be simple, and you are always protected, since you can redownload and/or reinstall the original Download_lock files.
Maybe you are not realising this is for the special case of Force_Query_String?
Regards, Clive
Late here, Victor, so maybe I’m mistaking your meaning. Or maybe Rob has had several versions of the plugin, and you have one which doesn’t have the problem?
I can assure you after looking over the code in the ‘latest 1.6 Build’ which I also run, that there has to be a fix for the Download_lock version that I and apparently aquaadmin have.
The problem shows, and the fix works.
Maybe you are not realising this is for the special case of Force_URL_query_strings being turned on?
Regards, Clive
Sorry for the delinquent re-post, but I still can’t get this module to work on my client’s site. I ended up recommending this site go live without this feature and tackling it later. Considering all the help I’ve gotten on this thread (thanks a million) I think it may be how they are hosting their site. I don’t know that much about server configs, but they have the site set up in an FTP directory, which makes the URL begin with ftp.theirsite.com as opposed to www. I don’t know if this has anything to do with anything but after trying everything to no avail, it seems that maybe this has something to do with it. In any case maybe when it is live and not on a test server it might work.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.