Posts by jsphpndr

    Hey Muscateer,


    If you need some help, I'll be available later today. It'd be interesting to see what's going on.


    Curiousity has gotten hold of me. haha


    Can I ask why you're usingshort_open_tags in production?


    PHP
    1. <? include "file.php"; ?>
    2. VS
    3. <?php include "file.php"; ?>

    Mikeymu, you're in luck... if you're willing to make some adjustments to Perch's core files.

    This is part of my CSP and should provide you everything you need for the login and dashboard.

    I'm generating nonces in .htaccess but you can modify the below to whatever your situation is.

    Once you've done this, go to the /perch/config/config.php and define a constant with the nonce value:

    Code
    1. define('SECURITY_NONCE', $_SERVER[X_HTTP_NONCE]);

    Then you're going to go into /perch/core/ and you're going to modify those inline <script> and <style> tags in /perch/core/layout/top.php and /perch/core/layout/login/top.php adding the nonce attribute and echoing your constant:

    PHP
    1. <style nonce="<?php echo(SECURITY_NONCE); ?>"></style>
    2. <script nonce="<?php echo(SECURITY_NONCE); ?>"></script>

    There is a caveat in that anytime there's an update you will have to make these modifications again. Hopefully, this helps. If you have any questions, don't hesitate.

    Gareth S

    Another request that I have while trying to create a filter is realizing that the editors' default image button/shortcode does not include the image width and height. Can we add these attributes and their values to these image outputs generated by the editors.


    Code
    1. This:
    2. [cms:asset 18 title="This is an image"]
    3. Renders:
    4. <img title="This is an image" src="https://example.com/uploads/this-is-an-image.jpg" alt="This is an image">
    5. What it should be to meet current web standards:
    6. <img title="This is an image" src="https://example.com/uploads/this-is-an-image.jpg" width="1920" height="1080" alt="This is an image">

    Gareth S,

    To a point I made earlier with regard to nonces for Perch, there doesn't seem to be much in the way of work for this. I just recently made an adjustment to the core templates using a constant in the config file and just echoing it out. This is problematic, because when there's a new update, I'll have to go back and update it again.

    Maybe something like this can be done...


    The developer can choose how they wish to generate nonces and the CMS will work with or without a CSP.

    Gareth S, there are some things that I'm sure are not coming to mind right now, but for sure, upgrades to the UI and security.


    First the UI needs some work, whether on desktop or mobile. More importantly, there are lots of internal scripts and styles used that are disallowed with a strong CSP. I would ask for a way to ensure that the backend can have a strong CSP enforced with nonces and hashes (if needed). Perhaps a constant like:


    Code
    1. define("PERCH_NONCE", $_SERVER['HTTP_X_NONCE']);


    This way it could be used on the front and backend.

    Is there a way to change the webmentions filepath in Perch?

    The default code...

    Code
    1. perch_blog_post_webmention_endpoint(perch_get('s'));


    currently, returns the following:

    Code
    1. <link href="/perch/addons/apps/perch_blog/endpoint/?pid=16" rel="webmention">


    I don't think this is the best approach. Is there anyway we could modify this path to something like:

    Code
    1. <link href="/blog/endpoint/?pid=16" rel="webmention">


    Something of this nature which basically doesn't expose backend directory structure.

    Any help is greatly appreciated, even if the answer is "no". At least, I'll know not to use it.

    This isn't PHP related, but Perch related and having to do with updates. The present Dashboard isn't adapted for a strong Content-Security-Policy.

    As of right now, the CSP requires and unsafe-inline directive to permit inline styles and scripts. This defeats the whole purpose of the CSP.


    It's just a wishlist item. I would've loved to have carried on with Perch in other projects. Sad to see it go.

    So, apparently, this is due to an obscure white space issue in Perch's templating engine.

    Indents in the template code were reflected in the rendered HTML. I only needed to remove all indents in the template code and it rendered as it was supposed to.

    Code
    1. <!--* HTML Block — START *-->
    2. <perch:block type="html" label="HTML">
    3. <pre class="snippet language-html">
    4. <code>
    5. <perch:blog id="htmlBlock" type="textarea" markdown striptags editor="simplemde" size="xl" help="To render code, tab or indent four spaces.">
    6. </code>
    7. </pre>
    8. </perch:block>
    9. <!--* HTML Block — END *-->


    I found this out by using the Developer Console and looking at the actual source and not the Element Inspector. This also revealed a white space issue with blocks as well. Template comments(<!--* *-->) seem to alleviate this spacing issue to some degree, as found on the old forum.

    While I don't like that I cannot maintain indentation in the actual source code, I am happy that everything is now displayed as it should be.

    I'm using blocks to add chunks of example code to posts and pages.

    The default editors seem a little wonky to me when it comes to code blocks, else I would have just used them. To overcome the wonkiness, I thought to just make the <code> element a part of the block and use striptags to remove any default tags(<p>) from the output. I've not had a problem with striptags adding an indent before, but yeah. I also checked the CSS and JS to see if it might be there, even though it works fine in the template, but alas, I can see no reason why this should occur.

    Not exactly sure what, I'm missing here.

    Here's the code:



    This is the input in the editor:

    perch-html.png

    And here's the output:

    perch-as-rendered.png

    So, this was figured out.


    I hadn't realized that I had been adding regions to blog pages up to this point. I've been adding Regions so long, that I forgot when you didn't have one, it doesn't matter what other items are pulled in from the CMS, a region is still required for navigation.

    Problem solved. :S

    So, I'm rewriting URLS to make blog posts more friendly. The redirects work fine with one exception, I can type url/blog/anything-that-is-not-a-real-post and I don't get a 404 returned but instead an empty post. Top level pages(i.e. url/anything-that-is-not-a-real-page) all return the 404 error. Redirects to actual posts and archive, category, tag pages all work fine.

    Below is my .htaccess configuration. I'm not sure what may be affecting what in terms of the blog redirect, so hopefully someone can help.


    Here's my settings:

    perch-settings.png

    This is the first time I have had this issue, but the perch_pages_breadcrumbs() function isn't working in sub-directories. I'm presently applying it to /blog/index.php and I set up a test/index.php to see if it was any sub-directory(it is) to no avail. Works fine on all pages in the root directory.


    PHP
    1. <?php
    2. perch_pages_breadcrumbs(array(
    3. 'hide-extensions' => true,
    4. 'hide-default-doc' => false,
    5. 'template' => 'breadcrumbs.html',
    6. 'skip-template' => false
    7. ));
    8. ?>



    I'm using debug on the page, but the function isn't even being called, neither the template listed nor any links on my page. This is strange. How can it be right and wrong at the same time.


    perch-debug.png

    Here is the code.

    This warning can be seen at https://cliftonheritage.net. Everything seemed fine until I uploaded to the live server.


    Warning: array_key_exists(): The first argument should be either a string or an integer in /home/cliftonheritage/public_html/cms/core/lib/PerchTemplate.class.php on line 1074

    The above error is what appeared above my perch_content_custom() listings:

    error.png


    PHP
    1. <?php
    2. perch_content_custom('Attraction Content',[
    3. 'count' => 5,
    4. 'sort-order' => 'RAND',
    5. 'page' => '/plan-your-visit/places-to-go/*',
    6. 'template' => '_places-to-go.html',
    7. 'each' => function($item) { $item['title'] = perch_page_attribute('pageTitle', ['_id' => $item['_pageID']], true); return $item; }
    8. ]) ?>


    This is what I get from debug. It's on my MAMP server, but nothing's printing out to the screen.

    Code
    1. Array
    2. ( [type] => 2 [message] => array_key_exists(): The first argument should be either a string or an integer [file] => /home/cliftonheritage/public_html/cms/core/lib/PerchTemplate.class.php [line] => 1074
    3. )