Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/20/2019 in all areas

  1. This week I was catching up with client work after traveling last week, but some of that work overlapped with a focus on WireMail modules. As a result, this week I’ve released two new WireMail modules, and also have information in this blog post on how you can configure two existing WireMail modules (WireMailSmtp and WireMailPHPMailer) to use Gmail as the SMTP sender— https://processwire.com/blog/posts/wiremail-modules-and-gmail/
    4 points
  2. @mr-fan What granularity of data do you need for things that are 5 years old? Do you need to drill down to get the exact temperature given a date and time from 5 years in the past? Or would an average do? If an average would be enough, then have a look at RRDTool. All you'd need to do is feed the data into it, then link the graphs it generates into your PW driven site. Although I've not used RRDTool for about 9 years, I ran it on a Raspberry Pi A (IIRC) to profile my house's thermal performance. I did this by collecting 1 minute temperature samples from a network of 8 x 1-wire temperature sensors I installed in the property. I ran this over a period of about 2 years, and all that data got squished into a fix-sized on-disk DB of a few megabytes. I used a cron job to pull the images from the graph generator and cache them on disk with fixed filenames. I had nginx serve a simple html webpage that referenced the images by name. Worked really nicely on my local network, but the output graphs aren't the prettiest. You might be able to feed the results into grafana or Bernhard's tool if nicer output is needed. If you do need high granularity of the old data, RRDTool isn't the tool for you. @dragan ESPs are a family of Wifi/Cellular capable microcontrollers. Very popular with electronics/systems makers. Example.
    3 points
  3. Over six months into the project and I have, touch wood, had a great experience moving from traditional hosting to Amazon EC2 for hosting around 10 sites. I still plan to write this up, but just wanted to share one little tip I found, probably something any DBA would instantly know but that I had to learn the hard way. I modified a script to export all databases and set it via cron to run at midnight. This worked AOK for 6 months, then I found service `httpd` was down one morning. The reason was simply that the day before I had added one more database to my EC2 and that had tipped the backup process over the brink as far as server load went. Each db was backed up, one after the other, and cumulatively this added to too much intense load. The solution I used was simply to add a 5min pause in the loop in the backup script, between databases. Fixed. Hope this helps someone ?
    2 points
  4. Wondering how to get that A+ rating on Mozilla Observatory? Now you can with ⭐⭐⭐MarkupContentSecurityPolicy⭐⭐⭐ Of course, MarkupContentSecurityPolicy does not guarantee an A+ rating, but it does help you implement a Content Security Policy for your ProcessWire website. Markup Content Security Policy Configure and implement a Content Security Policy for all front-end HTML pages. This module should only be used in production once it has been fully tested in development. Implementing a Content Security Policy on a site without testing will almost certainly break something! Overview Website Security Auditing Tools such as Mozilla Observatory will only return a high score if a Content Security Policy is implemented. It is therefore desirable to implement one. A common way of adding the Content-Security-Policy header would be to add it to the .htaccess file in the site's root directory. However, this means the policy would also cover the ProcessWire admin, and this limits the level of security policy you can add. The solution is to use the <meta> element to configure a policy, for example: <meta http-equiv="Content-Security-Policy" content="default-src 'self'; img-src https://*; child-src 'none';">. MarkupContentSecurityPolicy places this element with your configured policy at the beginning of the <head> element on each HTML page of your site. There are some limitations to using the <meta> element: Not all directives are allowed. These include frame-ancestors, report-uri, and sandbox. The Content-Security-Policy-Report-Only header is not supported, so is not available for use by this module. Configuration To configure this module, go to Modules > Configure > MarkupContentSecurityPolicy. Directives The most commonly used directives are listed, with a field for each. The placeholder values given are examples, not suggestions, but they may provide a useful starting point. You will almost certainly need to use 'unsafe-inline' in the style-src directive as this is required by some modules (e.g. TextformatterVideoEmbed) or frameworks such as UIkit. Should you wish to add any other directives not listed, you can do so by adding them in Any other directives. Please refer to these links for more information on how to configure your policy: https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy https://scotthelme.co.uk/content-security-policy-an-introduction/ https://developers.google.com/web/fundamentals/security/csp/ Violation Reporting Because the report-uri directive is not available, when Violation Reporting is enabled a script is added to the <head>which listens for a SecurityPolicyViolationEvent. This script is based on https://developer.mozilla.org/en-US/docs/Web/API/SecurityPolicyViolationEvent and POSTs the generated report to ?csp-violations=1. The module then logs the violation report to csp-violations. Unfortunately, most of the violations that are reported are false positives, and not actual attempts to violate the policy. These are most likely from browser extensions and are not easy to determine and filter. For this reason, there is no option for the report to be emailed when a policy is violated. Instead, you can specify an endpoint for the report to be sent to. This allows you to handle additional reporting in a way that meets your needs. For example, you may want to log all reports in a central location and send out an email once a day to an administrator notifying them of all sites with violations since the last email. Retrieving the Report To retrieve the report at your endpoint, the following can be used: $report = file_get_contents("php://input"); if(!empty($report)) { $report = json_decode($report, 1); if(isset($report) && is_array($report) && isset($report["documentURI"])) { // Do something } } Debug Mode When this is enabled, a range of information is logged to markup-content-security-policy. This is probably most useful when debugging a reporting endpoint. Additional .htaccess Rules To get an A+ score on Mozilla Observatory, besides using HTTPS and enabling the HSTS header, you can also place the following prior to ProcessWire's htaccess directives: Header set Content-Security-Policy "frame-ancestors 'self'" Header set Referrer-Policy "no-referrer-when-downgrade" Installation Download the zip file at Github or clone the repo into your site/modules directory. If you downloaded the zip file, extract it in your sites/modules directory. In your admin, go to Modules > Refresh, then Modules > New, then click on the Install button for this module. ProcessWire >= 3.0.123 is required to use this module.
    1 point
  5. DEPRECATED! I'll release a commercial module "RockGrid" in 2023/2024. If you are interested please write me a PM ? ---------------------------------------- This module is (or will be) the successor of RockGrid. It uses http://tabulator.info/ as grid library that is completely open sourced (MIT, no commercial extensions) and as far as I've seen so far at least as powerful as ag-grid, which RockGrid is using. GOALS: Support various data sources (RockFinder, JS, PHP, SQL) Supported only in PW Backend + Uikit Easy setup of new fields DOCS: Currently the readme is terrible, sorry for that. But you get lots of examples after installing the module! From simple tabulators to more complex ones. INSTALLATION: Just install the main module. RockMarkup is a required dependency. Please also have a look at the RockMarkup examples before jumping into RockTabulator! STATUS: The module is early alpha and can be downloaded from github: https://github.com/BernhardBaumrock/RockTabulator It took me two weeks of rewriting RockMarkup/RockTabulator to get where I am now and I think I'm quite happy with the setup. There might be some breaking changes though in the near future. At the moment the main features that should be working properly are: Data sources: SQL, PHP, JS Sandbox for easy setup Multilang This means basically everything that is possible with Tabulator is also possible with RockTabulator. Though, there are no custom helpers/plugins yet. That's the next step and whoever is willing to help, please give me a shout ? If you have any questions or ideas please let me know ?
    1 point
  6. This is a profile based on the Uikit3 framework and features from the regular site profile. Requires the latest version processwire 3.0.127 Download from this link: https://github.com/rafaoski/site-uk3-minimal Live Example: https://uk3-min.templatek.pl/ Basic Info: Most of the profile settings and translates are in the _init.php file. Functions can be found in the _func.php, _uikit.php file. The entire view is rendered in the _main.php file that uses markup regions. You can easily add hooks using the ready.php file. Options page added with the new “Unique” status, which you can use in this simple way like: pages('options')->site_name pages->get('options')->site_name The Author's website's blog entries use URL segments (/ authors / {author-name} /), see views/blog/blog.php for more info. This profile has additional functions (_uikit.php) from the regular uikit3 profile, which is located in the basic ProcessWire installer ( there are minor changes, such as adding translations from _init.php ) Screnshoots:
    1 point
  7. I experimented with my weather station some with InfluxDB (https://www.influxdata.com/). Great for big time series data. But if you need the data in PW you will have some extra work ?
    1 point
  8. err, I should have googled this before answering... (I had no idea what ESP means). So it's data from one single weather station only? My above post was based on the assumption that you get weather infos from all over the world via some 3rd-party API and you update your site via cron jobs. It's been said time and again that a big number of PW pages will scale well, but a combination of (too many) fields, templates, and pages - plus complex queries - can seriously impact speed. In your case, the setup seems to be quite simple though, so I would go the "native PW route". However: When it comes to loading huge data-sets and visualise them (aggregate a 5-year-span of weather data and create statistics or curve diagrams), I would surely look for RockTabulator or some such. You can fake a future situation yourself with simply creating thousands of dummy data-sets.
    1 point
  9. Linode (Linode 4GB): Contabo (VPS S SSD): By the way, updated my previous message. Didn't remember that I took the tiniest SSD package, not the medium one – so the price is not half but actually around a quarter of the Linode VPS. Admittedly this may be a bit small for some needs, but it should run all my sites just fine ?
    1 point
  10. Hi @Juergen, what about the following: $y = new Y(); echo $y->addText()->setText(' A B C D '); class X { protected $text = ''; public function setText(string $value = null) { $this->text = trim($value); return $this->text; } } class Y { protected $x; public function __construct() { $this->x = new X(); } public function addText() { return $this->x; } } I have tested it and it is working, however I did not thought about it too much, it may be possible to do something smarter. Wish you a nice week end.
    1 point
  11. For regular users there are usually cheaper (and quite likely easier) options than AWS. For an example I'd like to host my sites on AWS – the tech is fun, and it'd be useful experience overall from a professional point of view – but the pricing is really high compared to regular VPS solutions. Not to mention that in most cases I really do just need a VPS, so I wouldn't benefit much from the full AWS stack ? I'm currently hosting my sites on Linode as well ($20/month), but also experimenting with Contabo. So far so good, and the pricing is a quarter of what I've been paying for Linode – in fact even less, considering that my test server has more horsepower than the one at Linode.
    1 point
  12. Update to 0.0.2 Deploy mode (only enable for superuser when off) Define params to exclude from reporting (e.g. originalPolicy) Filtering of selected false positive patterns Improvements to HTML page check
    1 point
  13. Here is another snippet that I use to get rid of unwanted table properties: // Remove unwanted attributes from tables CKEDITOR.on('dialogDefinition', function(ev) { var dialogName = ev.data.name; var dialogDefinition = ev.data.definition; if (dialogName == 'table') { var info = dialogDefinition.getContents('info'); info.remove('txtWidth'); info.remove('txtHeight'); info.remove('txtBorder'); info.remove('txtCellPad'); info.remove('txtSummary'); info.remove('txtCellSpace'); info.remove('cmbAlign'); var advanced = dialogDefinition.getContents('advanced'); advanced.remove('advStyles'); advanced.remove('advId'); //Id attribute advanced.remove('advLangDir'); // writing direction advanced.get('advCSSClasses')['default'] = 'uk-table'; //set default class for table } Put this code inside your custom config.js Best regards
    1 point
  14. ProCache should cover almost all of what they offer (mostly caching). I'd say it's a cash grab. You said you were hosting your websites on a managed VPS, how is your linux skills? Try switching to another hoster. I am a happy user of Vultr and DigitalOcean, and never had problems with them. They bill (IIRC) hourly, so you can try it for a few days for a few bucks and see if it works out for you. Managing your own VPS isn't too difficult. As long as you dont keep many ports open (80, 443 for web and 22 or a different port for SSH), set up a fail2ban and you'd be mostly OK in terms of security, and you get to extend your skillset along the way.
    1 point
  15. Well, your code runs slow because: You have multiple nested loops, each of which is querying pages, which would be slow by definition. Inside every loop you're getting, resizing images, which is even slower than querying pages (on the first request, at least) You seem to use repeater fields to store metadata for images, and each repeater item has page reference fields, which slows down your code even more Points for improvement: Use Image Extra module instead of repeaters for saving extra data with images Use WireCache a lot Check out this thread Not a speed improvement, but escape long spreads of HTML from PHP, you don't have to write all of your HTML into strings http://php.net/manual/en/language.basic-syntax.phpmode.php Look up ternary operators and elvis operator Instead of writing CSS into HTML elements, use CSS classes and separate your CSS from HTML. You can refactor $bgcolor as .bg-white and .bg-gray, for example That said, here's an reformatted/rewritten version of your code: <?php namespace ProcessWire; ?> <style> .bg-white { background-color: #fff; } .bg-gray { background-color: #e4e4e4; } .group { min-height: 110px; } .prod-list-category-label { font-size: .7em; } .list-headline { font-size: .8em; } .featured-icons-list { margin: 2em .5em; } </style> <div class='span_12_of_12'> <?php foreach ($products as $p): ?> <?php // $bgcolor = $sum % 2 == 0 ? '#fff' : '#e4e4e4'; $bgClass = $sum % 2 == 0 ? 'bg-white' : 'bg-gray'; $par = $p->parent; $img = $p->prod_image; $thumb = $img->pim2Load('squarethumb100')->canvas(100,100,array(0,0,0,0),'north',0)->pimSave()->url; ?> <?php // Replace inline styles with classes ?> <div class="section group <?= $bgClass ?>"> <div class="col span_2_of_12 hide" data-match-height="<?= $p->title ?>"> <a href="<?= $p->url ?>"><span class="product-image-box"><img src="<?= $thumb ?>" alt="<?= $p->title ?>" title="<?= $p->title ?>"></span></a> </div> <div class="col span_6_of_12" data-match-height="<?= $p->title ?>"> <div class="prod-list-name-label"><a href="<?= $p->url ?>"><?= $p->title ?></a></div> <?php if ($page != $par): ?> <?php // Replace inline styles with classes ?> <div class='prod-list-category-label'>Category: <a href='<?= $par->url ?>'><?= $par->title ?></a></div> <?php endif; ?> <?php // Replace inline styles with classes ?> <div class="list-headline"><?= $p->headline ?></div> <div class="learn-more-buttons-sm"> <a href='<?= $p->url ?>' title='Product Specs and Documentation'><span class='find-out-more-button' style='font-size: .8em;'><i style='font-size: .8em;' class='fa fa-lightbulb-o' ></i> Learn More</span></a> </div> </div> <div data-match-height='<?= $p->title ?>' class='col span_4_of_12'> <?php if ($p->prod_feat_imgs->count > 0): ?> <div class='featured-icons-list'> <?php foreach ($p->prod_feat_imgs as $feat) { $icon = $pages->get("$feat->prod_featicon_pages"); if ($icon->image) { // Loop up Elvis operator $icontitle = $feat->prod_feat_textlang ?: $icon->title; $out .= "<img src='" . $icon->image->size(35, 35, $imgOptions)->url . "' alt='" . $icontitle . "' title='" . $icontitle . "' class='listing-feat-icon' style='margin-right: .5em;' />"; } } ?> </div> <?php if($p->prod_product_line){ foreach($p->prod_product_line as $pline) if($pline->image) { $out .= "<div style='height: 35px;'>\n"; $out .= "<img src='{$pline->image->size(75,35,$imgOptions)->url}' alt='{$pline->title}' />"; $out .= "</div>"; } } ?> <?php endif; ?> </div> </div> <?php endforeach; ?> </div>
    1 point
×
×
  • Create New...