Several Perch versions ago in 2.8 something it was suggested that the resources be put outside the public directory in members only section. So we did that but now they will not load and we do not want to have to load all those files in again. Is there a way to move the files to the public html directory and have them work by changing a line of code. There are thousands of these files. https://www.websitename.org/me…=/dachstaedter-george.pdf is one of the links. Is there a way to manually edit the link to point to a resource file in the public directory without loading all the files in again.
Resource Files outside the public directory not loading
- ckfs
- Thread is marked as Resolved.
-
-
For this to work, you need 2 things:
- To set up a resource bucket
- To set up a page to serve the files
It sounds you already have (1) done. The Perch Members app come with an example page for (2) called download.php. You can find the relevant docs here: https://docs.grabaperch.com/ad…mbers/examples/downloads/
-
Having trouble applying the information will show files maybe you can figure out where I went wrong. Also will not log out
-
Here is the diagnostics for the site where the secure folder outside of the public html is not working
- Perch: 3.1.4, PHP: 5.6.40, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $, with PDO
- Server OS: Linux, fpm-fcgi
- Installed apps: content (3.1.4), assets (3.1.4), categories (3.1.4), perch_members (1.3), perch_members (1.6.4)
- App runtimes: <?php $apps_list = [ 'perch_members', ]; ?>
- PERCH_LOGINPATH: /pggs2.8.6_update
- PERCH_PATH: /home/palamger/public_html/pggs2.8.6_update
- PERCH_CORE: /home/palamger/public_html/pggs2.8.6_update/core
- PERCH_RESFILEPATH: /home/palamger/public_html/pggs2.8.6_update/secure
- Image manipulation: GD
- PHP limits: Max upload 128M, Max POST 128M, Memory: 1024M, Total max file upload: 128M
- F1: 3b606135b33e6a102526838f4152a807
- Resource folder writeable: Yes
- HTTP_HOST: http://www.HOST.ORG
~~~
<perch:before>
<table class="responsive" style="border:1px solid #000;width="75%"><tr style="background-color:#fff;font-color:#232376;font-weight:bold;">
<th style="border-right:1px solid #232376;font-color:#232376;">LAST NAME</th><th style="border-right:1px solid #232376;font-color:#232376;">FIRST NAME</th><th style="border-right:1px solid #23237;font-color:#232376;">COMMENTS</th></tr>
</perch:before>
<tr>
<td style="border:1px solid #000;">
<a href="<perch:content id="file" type="file" label="File" order="2" accept="pdf doc" bucket="secure" />">
<perch:content type="text" id="desc" label="lastname" order="1" required="true" title="true" />
</a>
</td>
<td style="border:1px solid #000;"><perch:content id="firstname" type="text" label="First Name"/></td>
<td style="border:1px solid #000;"><perch:content id="comments" type="textblock" label="Comments"/></td>
</tr>
<perch:after>
</table>
<perch:if exists="paging">
<div class="paging">
Page <perch:content id="current_page" type="hidden" /> of <perch:content id="number_of_pages" type="hidden" />
<perch:if exists="not_first_page">
<a href="<perch:content id="prev_url" type="hidden" encode="false" />">Previous</a>
</perch:if>
<perch:content id="page_links" encode="false" />
<perch:if exists="not_last_page">
<a href="<perch:content id="next_url" type="hidden" encode="false" />">Next</a>
</perch:if>
</div>
</perch:if>
</perch:after>
~~~
buckets.php
~~~~
<?php
return array(
'secure' => array(
'web_path' => '/members/download.php?file=',
'file_path' => '/home/palamger/secure',
),
);
?>
~~~
config file redacted
~~~
<?php
define('PERCH_LICENSE_KEY', '#here');
define("PERCH_DB_USERNAME", 'u1');
define("PERCH_DB_PASSWORD", 'pass');
define("PERCH_DB_SERVER", "localhost");
define("PERCH_DB_DATABASE", "dbname");
define("PERCH_DB_PREFIX", "perch2_");
define('PERCH_TZ', 'UTC');
define('PERCH_EMAIL_FROM', 'webmaster@s.org');
define('PERCH_EMAIL_FROM_NAME', 'Name of Organization');
define('PERCH_EMAIL_METHOD', 'pop');
define('PERCH_EMAIL_HOST', 'smtpout.secureserver.net');
define('PERCH_EMAIL_AUTH', true);
define('PERCH_EMAIL_SECURE', 'ssl');
define('PERCH_EMAIL_PORT', 465);
define('PERCH_EMAIL_USERNAME', 'username');
define('PERCH_EMAIL_PASSWORD', 'pa
~~~~
config
define('PERCH_LOGINPATH', '/pggs2.8.6_update');
define('PERCH_PATH', str_replace(DIRECTORY_SEPARATOR.'config', '', __DIR__));
define('PERCH_CORE', PERCH_PATH.DIRECTORY_SEPARATOR.'core');
// define('PERCH_RESFILEPATH', '/home/palamger/public_html/members/resources2015');
//define('PERCH_RESPATH', '/members/resources2015');
define('PERCH_RESFILEPATH', PERCH_PATH . DIRECTORY_SEPARATOR . 'secure');
define('PERCH_RESPATH', PERCH_LOGINPATH . '/secure');
define('PERCH_HTML5', true);
~~~
finally the download.php file
~~~
<?php
include('../pggs2.8.6_update/runtime.php');
// config
$bucket_name = 'secure';
$url_param = 'file';
// By default, deny downloads unless we've proved the member is allowed this file.
$allow_download = false;
// Check a member is logged in
if (perch_member_logged_in()) {
$allow_download = false;
}
/*
Alternatively, you could check for a specific tag, e.g.
*/
if (perch_member_has_tag('member')) {
$allow_download = true;
}
// Deliver the file.
if ($allow_download) {
perch_members_secure_download(perch_get($url_param), $bucket_name, false);
}
exit;
_____
These ARE THE FILES WHERE IS THE PROBLEM?
-
You are only allowing downloads for logged in members that have the tag member. Is this the behaviour you're after? If so, you can remove the first if statement:
Have you tested this with a logged-in member that has the tag member?
-
It is commented out so that shouldn't be effecting anything should it? But it is still not working. Are you saying the coding is correct? Maybe because I can't log out - that started not working also.
-
Ok I commented that out and it is still not working. I can not log out. It takes me to the correct page I have noted but does not log out from the server/website.
-
I did find the extra perch_members file and moved it out of the apps folder but it is still not working. Is there something else I should be doing?
-
Logout works now in incognito window but files still don't show up.
-
Try to isolate the issue. Test the file delivery with no member restriction (in a development/staging environment):
The above should serve the file to any visitor.
-
That works and people can't get there from the internet because you have to login to the site.
-
Ok. Now that you have confirmed that the file delivery functionality is not the issue you can focus on the logic that enables the download.
You had an if statement that checks whether a logged-in member has the tag member:
So I assume you have members that have the tag member. Did you test while logged-in as a member that has the tag member?