We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Question, Addons, Members

Members Area - Listing files in a secure bucket

Is there away to list all the files in a secure bucket?

I have uploaded the files and setup the bucket in the bucket.php. Rather than adding the files to a page manually is there a away to do this programmatically through perch?

I am using the latest version of Perch 2 downloaded last week. Perch: 2.8.34.

Many thanks

Dennis Pickworth

Dennis Pickworth 0 points

  • 1 year ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You could display the region using a template that only outputs the file details.

Hi Drew,

Thanks for the reply. How do I get the file details? Is this just some basic php?

Dennis

Drew McLellan

Drew McLellan 2638 points
Perch Support

No, just a Perch template. What does the template for uploading your files look like at the moment?

Hi Drew,

My templates looks like this

<a href="<perch:content id="file" type="file" label="File" order="2" bucket="secure">">
        <perch:content type="text" id="desc" label="Title" order="1" required title>
    </a>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, so you'd be able to get a list of the files by displaying the region using that template, wouldn't you?

Hi Drew,

It appears to not be working.

The gutts of the members page looks like this

        <?php
                if (perch_member_logged_in()) {
            ?>  
                <ul>
                    <li><a href="members/logout.php">Log out</a></li>
                </ul>

            <?php
                }else{
                    perch_members_login_form(); 
                }
            ?>
            </div>
        </div>

        <?php
            perch_content('Download Files');
        ?>

and the template I have used for the 'Download Files' is

<a href="<perch:content id="file" type="file" label="File" order="2" bucket="secure">">
        <perch:content type="text" id="desc" label="Title" order="1" required title>
</a>

so what you are saying is that this should list the files on my members page?

System Diagnostics


Perch: 2.8.34 Production mode: Production (100) Installed apps: content (2.8.34), assets (2.8.34), categories (2.8.34), perch_blog (5.0), perch_forms (1.8.3), perch_gallery (2.8.6), perch_members (1.5) DB driver: PDO DB tables: perch2_categories (0), perch2_category_counts (0), perch2_category_sets (0), perch2_content_index (186), perch2_content_items (54), perch2_content_regions (20), perch2_members (1), perch2_members_forms (0), perch2_members_member_tags (0), perch2_members_sessions (1), perch2_members_tags (0), perch2_navigation (1), perch2_navigation_pages (10), perch2_page_templates (7), perch2_pages (11), perch2_resource_log (82), perch2_resource_tags (0), perch2_resources (23), perch2_resources_to_tags (0), perch2_settings (26), perch2_user_passwords (0), perch2_user_privileges (27), perch2_user_role_privileges (16), perch2_user_roles (2), perch2_users (1) Users: 1 PHPMailer: 5.2.21 App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_blog', 'perch_forms', 'perch_gallery', 'perch_members', ); Scheduled tasks for perch_blog: delete_spam_comments (1440 mins) Editor plug-ins: markitup, ckeditor, redactor H1: 46d0672d4f4cf313d7af558935fc1885 L1: 3ec184ad70d6540a1f95608a4f2c7ea2 F1: 6a33f95eca3667f9e0c39bf5ca2980fe headerColour: #ffffff content_singlePageEdit: 1 helpURL: siteURL: / hideBranding: 1 content_collapseList: 1 lang: en-gb update_2.8.34: done latest_version: 2.8.15 on_sale_version: headerScheme: light perch_blog_site_name: perch_blog_post_url: /blog/post.php?s={postSlug} perch_blog_slug_format: %Y-%m-%d-{postTitle} perch_blog_akismet_key: perch_blog_max_spam_days: 0 perch_members_login_page: /members/login.php?r={returnURL} perch_gallery_bucket_mode: dynamic perch_gallery_bucket: default dashboard: 0 hide_pwd_reset: 0 content_hideNonEditableRegions: 0 content_frontend_edit: 0 perch_blog_comment_notify: 0 perch_gallery_basicUpload: 0 perch_members_update: 1.4 PERCH_DEVELOPMENT: 10 PERCH_STAGING: 50 PERCH_PRODUCTION: 100 PERCH_DB_USERNAME: develop1_iksac PERCH_DB_SERVER: 10.169.0.173 PERCH_DB_DATABASE: develop1_iksac PERCH_DB_PREFIX: perch2_ PERCH_TZ: Europe/London PERCH_EMAIL_FROM: developer@develop101.co.uk PERCH_EMAIL_FROM_NAME: Dennis Pickworth PERCH_LOGINPATH: /perch PERCH_PATH: /var/sites/i/iksac.develop101.co.uk/public_html/perch PERCH_CORE: /var/sites/i/iksac.develop101.co.uk/public_html/perch/core PERCH_RESFILEPATH: /var/sites/i/iksac.develop101.co.uk/public_html/perch/resources PERCH_RESPATH: /perch/resources PERCH_HTML5: 1 PERCH_RUNWAY: PERCH_ERROR_MODE: DIE PERCH_DATE_LONG: %d %B %Y PERCH_DATE_SHORT: %d %b %Y PERCH_TIME_SHORT: %H:%M PERCH_TIME_LONG: %H:%M:%S PERCH_RUNWAY_ROUTED: PERCH_STRONG_PASSWORDS: PERCH_DEBUG: PERCH_PREVIEW_ARG: preview PERCH_TEMPLATE_PATH: /var/sites/i/iksac.develop101.co.uk/public_html/perch/templates PERCH_DEFAULT_DOC: index.php PERCH_DEFAULT_EXT: .php PERCH_PRODUCTION_MODE: 100 PERCH_RWD: PERCH_HTML_ENTITIES: PERCH_SSL: PERCH_STRIPSLASHES: PERCH_PROGRESSIVE_FLUSH: 1 PERCH_PARANOID: PERCH_FORCE_SECURE_COOKIES: PERCH_PASSWORD_MIN_LENGTH: 6 PERCH_MAX_FAILED_LOGINS: 10 PERCH_AUTH_LOCKOUT_DURATION: 1 HOUR PERCH_VERIFY_UPLOADS: PERCH_AUTH_PLUGIN: PERCH_DB_CHARSET: utf8 PERCH_DB_PORT: PERCH_DB_SOCKET: PERCH_SESSION_TIMEOUT_MINS: 20 Hosting settings PHP: 5.6.22 Zend: 2.6.0 OS: Linux SAPI: cgi-fcgi Safe mode: not detected MySQL client: mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $ MySQL server: 5.7.16 Free disk space: 33.11 TB Extensions: Core, date, ereg, libxml, openssl, pcre, sqlite3, zlib, bcmath, calendar, ctype, curl, dom, hash, fileinfo, filter, ftp, gd, gettext, SPL, iconv, session, intl, json, ldap, mbstring, mcrypt, mssql, standard, mysql, mysqlnd, mysqli, PDO, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, Phar, posix, Reflection, imap, SimpleXML, soap, sockets, exif, tidy, tokenizer, xml, xmlreader, xmlrpc, xmlwriter, xsl, zip, cgi-fcgi, memcached, memcache, mhash, ionCube Loader, Zend Guard Loader GD: Yes ImageMagick: No PHP max upload size: 100M PHP max form post size: 100M PHP memory limit: 128M Total max uploadable file size: 100M Resource folder writeable: Yes Session timeout: 240 minutes Native JSON: Yes Filter functions: Yes Transliteration functions: Yes DOCUMENT_ROOT: /var/sites/i/iksac.develop101.co.uk/public_html GATEWAY_INTERFACE: CGI/1.1 HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 HTTP_ACCEPT_ENCODING: gzip, deflate HTTP_ACCEPT_LANGUAGE: en-GB,en;q=0.5 HTTP_CONNECTION: close HTTP_COOKIE: cmsa=1; p_m=073206499d9ed098aa606cdba677de27960d5d35; PHPSESSID=c4832133bec11c8a55a941487c74ab33 HTTP_DNT: 1 HTTP_HOST: iksac.develop101.co.uk HTTP_REFERER: http://iksac.develop101.co.uk/perch/core/settings/diagnostics/ HTTP_UPGRADE_INSECURE_REQUESTS: 1 HTTP_USER_AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:61.0) Gecko/20100101 Firefox/61.0 HTTP_X_FORWARDED_FOR: 82.10.212.128 PATH: /bin QUERY_STRING: extended REDIRECT_STATUS: 200 REMOTE_ADDR: 82.10.212.128 REMOTE_PORT: 49065 REQUEST_METHOD: GET REQUEST_URI: /perch/core/settings/diagnostics/?extended SCRIPT_FILENAME: /var/sites/i/iksac.develop101.co.uk/public_html/perch/core/settings/diagnostics/index.php SCRIPT_NAME: /perch/core/settings/diagnostics/index.php SERVER_ADDR: 10.170.0.19 SERVER_ADMIN: you@example.com SERVER_NAME: iksac.develop101.co.uk SERVER_PORT: 80 SERVER_PROTOCOL: HTTP/1.1 SERVER_SOFTWARE: Apache PHP_SELF: /perch/core/settings/diagnostics/index.php REQUEST_TIME_FLOAT: 1532453718.02 REQUEST_TIME: 1532453718 argc: 1

Dennis

Duncan Revell

Duncan Revell 78 points
Registered Developer

Hi Dennis,

the file field type lets you upload a file (to a bucket) and then display the path to that file on your page output. If you want to upload multiple files to display on your page, you would need multiple file fields - possibly in a repeater.

How did you upload the files to your bucket?

I upload the files through the back office. The template I use is just one off the documentation.

Just confused as to why the files are not being listed in the members area. I agree that I possible need a repeater there as I will need to upload multiple files.

Duncan Revell

Duncan Revell 78 points
Registered Developer

Your template snippet certainly looks OK.

Have you enabled debug on the members page - it may help pinpoint what is happening during output.

I have enabled debug and the extract looks like this;

Debug Message
[1] SELECT * FROM perch2_pages WHERE pagePath='/members-area.php' LIMIT 1
[26] SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
[1] SELECT * FROM perch2_members WHERE memberAuthType='native' AND memberPassword IS NOT NULL AND memberEmail='developer@develop101.co.uk' AND memberStatus='active' AND (memberExpires IS NULL OR memberExpires>'2018-07-26 16:27:54') LIMIT 1
Password is ok.
[1] SELECT * FROM perch2_members WHERE memberAuthType='native' AND memberAuthID='1' LIMIT 1
log them in
[0] SELECT t.tag FROM perch2_members_tags t, perch2_members_member_tags mt WHERE t.tagID=mt.tagID AND mt.memberID='1' AND (mt.tagExpires IS NULL OR mt.tagExpires>'2018-07-26 16:27:00')
INSERT INTO perch2_members_sessions(sessionID,sessionExpires,sessionHttpFootprint,memberID,sessionData) VALUES('d0a691ca50db9829a894c19d92d4a63df48ffed3','2018-07-31 16:27:54','4095a3f8cd8d8cdca3022adf1992be3133aea95d','1','{\"first_name\":\"IKSAC\",\"last_name\":\"SCUBA\",\"memberID\":\"1\",\"memberAuthType\":\"native\",\"memberAuthID\":\"1\",\"memberEmail\":\"developer@develop101.co.uk\",\"memberStatus\":\"active\",\"memberCreated\":\"2018-07-23 20:01:03\",\"memberExpires\":null,\"tags\":[],\"token\":\"630e6a8486b2b42e32f936c2cb453d983fd790de\"}')
DELETE FROM perch2_members_sessions WHERE sessionExpires < '2018-07-26 16:27:54'
[1] SELECT * FROM perch2_members_sessions WHERE sessionID='d0a691ca50db9829a894c19d92d4a63df48ffed3' AND sessionHttpFootprint='4095a3f8cd8d8cdca3022adf1992be3133aea95d' AND sessionExpires>'2018-07-26 16:27:54' LIMIT 1
User is logged in
------------------------------ here mem ------------------------------
[10] SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageDepth >=0 AND pageDepth<=2 ORDER BY pageTreePosition ASC
[1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/members-area.php' LIMIT 1
[1] SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-007', '000') ORDER BY pageTreePosition DESC
Using template: /templates/navigation/level1.html
[6] Using template: /templates/navigation/level2.html
[3] SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/members-area.php' OR regionPage='*' ORDER BY regionPage DESC
[1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/members-area.php' OR pageSortPath='/members-area.php' LIMIT 1
[1] SELECT * FROM perch2_pages WHERE pageHidden=0 AND pageNew=0 AND pageTreePosition IN ('000-007', '000') ORDER BY pageTreePosition
[1] Using template: /templates/navigation/breadcrumbs.html

Does it help? I cannot see anything obvious

Duncan Revell

Duncan Revell 78 points
Registered Developer

I can see where it's calling your menu templates

Using template: /templates/navigation/level1.html 
Using template: /templates/navigation/level2.html

and a breadcrumbs template

Using template: /templates/navigation/breadcrumbs.html

But I can't see where it's calling another template - your Download Files template.

Maybe reduce members-area.php to only a simple call to Download Files and try and debug that...

Hi, I have deleted the page, re added it, reduced the page to just call the 'Secure Download' but still no debug info for the template.

Debug Message
[1] SELECT * FROM perch2_members_sessions WHERE sessionID='eacf0bb63cfc306fa6e7fdb973c105201674cf31' AND sessionHttpFootprint='05fd8e060be12d19f3227c6bfdb58ed2432edce3' AND sessionExpires>'2018-07-30 18:42:24' LIMIT 1
User is logged in
[1] SELECT * FROM perch2_pages WHERE pagePath='/members-area.php' LIMIT 1
[26] SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
------------------------------ here mem ------------------------------
[10] SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageDepth >=0 AND pageDepth<=2 ORDER BY pageTreePosition ASC
[1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/members-area.php' LIMIT 1
[1] SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-007', '000') ORDER BY pageTreePosition DESC
Using template: /templates/navigation/level1.html
[6] Using template: /templates/navigation/level2.html
[3] SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/members-area.php' OR regionPage='*' ORDER BY regionPage DESC
[1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/members-area.php' OR pageSortPath='/members-area.php' LIMIT 1
[1] SELECT * FROM perch2_pages WHERE pageHidden=0 AND pageNew=0 AND pageTreePosition IN ('000-007', '000') ORDER BY pageTreePosition
[1] Using template: /templates/navigation/breadcrumbs.html

Anymore ideas?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Have you added these files to a content region, or are they just in Assets as library items?

Sorry Drew, Spent so much time looking at this is has made me thick? I do not understand what you mean. The items are added to the secure bucket via the template above. Not sure what you mean about the region.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Your template uses a <perch:content> tag, so presumably it's either used by a content region or a collection. Is that not the case?