Skip to content

Instantly share code, notes, and snippets.

@trk
trk / location.main-before.processwire.conf
Created July 25, 2023 14:34
ProcessWire-RunCloud-Nginx-Custom-Config
# Block access to any file or directory that begins with a period
location ~ /\. {
deny all;
}
# Block access to any software identifying txt files
location ~ /(COPYRIGHT|LICENSE|README|htaccess)\.txt {
deny all;
}
# Block access to protected assets directories
location ~ ^/site(-[^/]+)?/assets/(.*\.php|backups|cache|config|install|logs|sessions|tmp) {
@trk
trk / ProcessWireValetDriver.php
Created March 16, 2023 11:12
Valet 4 Driver for ProcessWire v3
<?php
namespace Valet\Drivers\Custom;
use Valet\Drivers\ValetDriver;
class ProcessWireValetDriver extends ValetDriver
{
private array $possiblePaths = ['', '/public_html', '/web'];
@trk
trk / FileFinder.php
Created February 18, 2021 12:17
PHP FileFinder
<?php
class FileFinder
{
/**
* Glob files with braces support.
*
* @param string $pattern
* @param int $flags
*
@trk
trk / Image.php
Last active March 13, 2020 13:04
ProcessWire responsive image class
<?php
namespace ProcessWire;
/**
* HOOKS : IMAGE
*/
foreach (["array", "json", "alt", "srcset", "sizes", "thumbnail"] as $index => $hook) {
wire()->addHookProperty("Pageimage::{$hook}", function(HookEvent $event) use($hook) {
if ($event->object instanceof Pageimage) {
<?php
class UbiquityValetDriver extends BasicValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
@trk
trk / ConfigurableValetDriver.php
Created June 4, 2018 16:11
ConfigurableValetDriver (currently in use with ProcessWire)
<?php
/**
* Class ConfigurableValetDriver
*
* You can change paths and files arrays via creating a config file under your site path ".valet/index.php"
*
* This files must return an array like example.
*
* return ["paths" => ["foo", "bar"], "files" => ["bar.php", "foo.php"]];
@trk
trk / ProcessString.php
Last active October 15, 2017 20:00
ProcessWire String processing class
<?php
class ProcessString {
public static $allowedFunctions = [
"pages", "page", "config", "modules", "user", "users",
"session", "fields", "templates", "database", "permissions", "roles",
"sanitizer", "datetime", "files", "cache", "languages", "input",
"inputGet", "inputPost", "inputCookie", "urls", "paths", "profiler", "region",
"label", "description", "notes"
];
@trk
trk / AvbMarkupOutput.php
Last active December 21, 2015 16:20
AvbMarkupOutput is a helper for use less html elements on your php codes!
<?php
/**
* AvbMarkupOutput
*
* @param array $configs
* @param null $page
* @return string
*/
function AvbMarkupOutput($configs=array(), $page=null) {
$output = "";
/**
* Get last modified page modified date from given $id, $parent_id, $templates_id or from all
*
* @param bool $id
* @param bool $parent_id
* @param bool $templates_id
* @return mixed|string
*/
function getLastModified($id=false, $parent_id=false, $templates_id=false) {
if(!is_null($id)) {