Skip to content

Commit

Permalink
Initial commit to new repo (carried over from: https://github.com/rya…
Browse files Browse the repository at this point in the history
  • Loading branch information
ryancramerdesign committed Sep 2, 2016
1 parent cfae5fc commit bac5b0d
Show file tree
Hide file tree
Showing 1,691 changed files with 279,091 additions and 1 deletion.
38 changes: 38 additions & 0 deletions .gitignore
@@ -0,0 +1,38 @@
.DS_Store?
.DS_Store
*.old
*.old/*
*.new
*.new/*
old
old/*
*[a-z].1
*[a-z].1/*
sess_*
*.cache
*.swp
*.swo
site-default/config-dev.php
site-default/assets/logs
site-default/assets/files
site-default/assets/sessions
site-default/assets/cache
site-default/assets/installed.php
site
site-skyscrapers
.htaccess
tmp
upgrade.php
.idea
.svn
.sass-cache
.sass-cache/*
*.css.map
wire/modules/AdminTheme/AdminThemeDefault/styles/sass/*.css
composer.lock
*.min.min.js
wire/modules/Inputfield/InputfieldDatetime/timepicker/i18n/*.min.js
wire/modules/Inputfield/InputfieldDatetime/jquery-ui-timepicker-addon.min.js
wire/modules/Jquery/JqueryFancybox/
wire/modules/Jquery/JqueryTableSorter/JqueryTableSorter.min.js
pwx.php
431 changes: 431 additions & 0 deletions LICENSE.TXT

Large diffs are not rendered by default.

491 changes: 490 additions & 1 deletion README.md

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions composer.json
@@ -0,0 +1,23 @@
{
"name": "processwire/processwire",
"type": "library",
"description": "ProcessWire CMS/CMF",
"keywords": [ "cms","cmf", "content management system" ],
"homepage": "https://processwire.com",
"authors": [
{
"name": "Ryan Cramer",
"email": "ryan@processwire.com",
"homepage": "https://processwire.com",
"role": "Developer"
}
],
"require": {
"php": ">=5.3.8",
"ext-gd": "*"
},
"autoload": {
"files": [ "wire/core/ProcessWire.php" ]
},
"minimum-stability": "dev"
}
226 changes: 226 additions & 0 deletions htaccess.txt
@@ -0,0 +1,226 @@
#################################################################################################
# START PROCESSWIRE HTACCESS DIRECTIVES
# @version 3.0
# @indexVersion 300
#################################################################################################

# -----------------------------------------------------------------------------------------------
# 1. Don't show directory indexes, but do follow symbolic links
# 500 NOTE: Some cloud hosting companies don't allow +FollowSymLinks.
# Uncomment +SymLinksifOwnerMatch and comment +FollowSymLinks if you have 500 errors.
# If that doesn't resolve the error, then set it back to +FollowSymLinks.
# -----------------------------------------------------------------------------------------------

Options -Indexes
Options +FollowSymLinks
# Options +SymLinksifOwnerMatch

# -----------------------------------------------------------------------------------------------
# 2. Let ProcessWire handle 404s
# -----------------------------------------------------------------------------------------------

ErrorDocument 404 /index.php

# -----------------------------------------------------------------------------------------------
# 3. Handle request for missing favicon.ico/robots.txt files (no ending quote for Apache 1.3)
# -----------------------------------------------------------------------------------------------

<Files favicon.ico>
ErrorDocument 404 "The requested file favicon.ico was not found.
</Files>

<Files robots.txt>
ErrorDocument 404 "The requested file robots.txt was not found.
</Files>

# -----------------------------------------------------------------------------------------------
# 4. Protect from XSS with Apache headers
# -----------------------------------------------------------------------------------------------

<IfModule mod_headers.c>
# prevent site from being loaded in an iframe on another site
# you will need to remove this one if you want to allow external iframes
Header always append X-Frame-Options SAMEORIGIN

# to prevent cross site scripting (IE8+ proprietary)
Header set X-XSS-Protection "1; mode=block"

# prevent mime-based attacks via content sniffing (IE+Chrome)
# Header set X-Content-Type-Options "nosniff"
</IfModule>

# -----------------------------------------------------------------------------------------------
# 5. Protect ProcessWire system files
# -----------------------------------------------------------------------------------------------

<FilesMatch "\.(inc|info|info\.json|module|sh|sql)$|^\..*$|composer\.(json|lock)$">
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order allow,deny
</IfModule>
</FilesMatch>

# -----------------------------------------------------------------------------------------------
# 6. Override a few PHP settings that can't be changed at runtime (not required)
# 500 NOTE: Try commenting out this entire section below if getting Apache 500 errors.
# -----------------------------------------------------------------------------------------------

<IfModule mod_php5.c>
php_flag magic_quotes_gpc off
php_flag magic_quotes_sybase off
php_flag register_globals off
</IfModule>

# -----------------------------------------------------------------------------------------------
# 7. Set default directory index files
# -----------------------------------------------------------------------------------------------

DirectoryIndex index.php index.html index.htm

# -----------------------------------------------------------------------------------------------
# 8. ProcessWire requires mod_rewrite
# -----------------------------------------------------------------------------------------------

<IfModule mod_rewrite.c>

RewriteEngine On
AddDefaultCharset UTF-8

# -----------------------------------------------------------------------------------------------
# 9. If you only want to allow HTTPS, uncomment the RewriteCond and RewriteRule lines below.
# -----------------------------------------------------------------------------------------------
# RewriteCond %{HTTPS} off
# RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# -----------------------------------------------------------------------------------------------
# 10. Set an environment variable so the installer can detect that mod_rewrite is active.
# Note that some web hosts don't support this. If you get a 500 error, you might try
# commenting out this SetEnv line below.
# -----------------------------------------------------------------------------------------------

<IfModule mod_env.c>
SetEnv HTTP_MOD_REWRITE On
</IfModule>

# -----------------------------------------------------------------------------------------------
# 11. OPTIONAL: Set a rewrite base if rewrites aren't working properly on your server.
# And if your site directory starts with a "~" you will most likely have to use this.
# -----------------------------------------------------------------------------------------------

# RewriteBase /
# RewriteBase /pw/
# RewriteBase /~user/

# -----------------------------------------------------------------------------------------------
# 12. Access Restrictions: Keep web users out of dirs that begin with a period,
# but let services like Lets Encrypt use the webroot authentication method.
# -----------------------------------------------------------------------------------------------

RewriteRule "(^|/)\.(?!well-known)" - [F]

# -----------------------------------------------------------------------------------------------
# 13. OPTIONAL: Redirect users to the 'www.' version of the site (uncomment to enable).
# For example: http://processwire.com/ would be redirected to http://www.processwire.com/
# -----------------------------------------------------------------------------------------------

# RewriteCond %{HTTP_HOST} !^www\. [NC]
# RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# -----------------------------------------------------------------------------------------------
# 14. OPTIONAL: Send URLs with non-ASCII name-format characters to 404 page (optimization)
# -----------------------------------------------------------------------------------------------

# RewriteCond %{REQUEST_URI} "[^-_.a-zA-Z0-9/~]"
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule ^(.*)$ index.php?it=/http404/ [L,QSA]

# -----------------------------------------------------------------------------------------------
# 15. Access Restrictions: Protect ProcessWire system files
# -----------------------------------------------------------------------------------------------

# Allow screenshot files (for install.php only: this 1 line below may be removed after install)
RewriteCond %{REQUEST_URI} !(^|/)site-[^/]+/install/[^/]+\.(jpg|jpeg|png|gif)$
# Block access to any htaccess files
RewriteCond %{REQUEST_URI} (^|/)\.htaccess$ [NC,OR]
# Block access to protected assets directories
RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/assets/(cache|logs|backups|sessions|config|install|tmp)($|/.*$) [OR]
# Block acceess to the /site/install/ directory
RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/install($|/.*$) [OR]
# Block dirs in /site/assets/ dirs that start with a hyphen
RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/assets.*/-.+/.* [OR]
# Block access to /wire/config.php, /site/config.php, /site/config-dev.php, and /wire/index.config.php
RewriteCond %{REQUEST_URI} (^|/)(wire|site|site-[^/]+)/(config|index\.config|config-dev)\.php$ [OR]
# Block access to any PHP-based files in /templates-admin/
RewriteCond %{REQUEST_URI} (^|/)(wire|site|site-[^/]+)/templates-admin($|/|/.*\.(php|html?|tpl|inc))$ [OR]
# Block access to any PHP or markup files in /site/templates/
RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/templates($|/|/.*\.(php|html?|tpl|inc))$ [OR]
# Block access to any PHP files in /site/assets/
RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/assets($|/|/.*\.php)$ [OR]
# Block access to any PHP files in core or core module directories
RewriteCond %{REQUEST_URI} (^|/)wire/(core|modules)/.*\.(php|inc|tpl|module|info\.json)$ [OR]
# Block access to any PHP files in /site/modules/
RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/modules/.*\.(php|inc|tpl|module|info\.json)$ [OR]
# Block access to any software identifying txt files
RewriteCond %{REQUEST_URI} (^|/)(COPYRIGHT|INSTALL|README|htaccess)\.(txt|md|textile)$ [OR]
# Block all http access to the default/uninstalled site-default directory
RewriteCond %{REQUEST_URI} (^|/)site-default/
# If any conditions above match, issue a 403 forbidden
RewriteRule ^.*$ - [F,L]

# PW-PAGENAME
# -----------------------------------------------------------------------------------------------
# 16a. Ensure that the URL follows the name-format specification required by PW
# See also directive 16b below, you should choose and use either 16a or 16b.
# -----------------------------------------------------------------------------------------------

RewriteCond %{REQUEST_URI} "^/~?[-_.a-zA-Z0-9/]*$"

# -----------------------------------------------------------------------------------------------
# 16b. Alternative name-format specification for UTF8 page name support.
# If used, comment out section 16a above and uncomment the directive below. If you have updated
# your $config->pageNameWhitelist make the characters below consistent with that.
# -----------------------------------------------------------------------------------------------

# RewriteCond %{REQUEST_URI} "^/~?[-_./a-zA-Z0-9æåäßöüđжхцчшщюяàáâèéëêěìíïîõòóôøùúûůñçčćďĺľńňŕřšťýžабвгдеёзийклмнопрстуфыэęąśłżź]*$"

# END-PW-PAGENAME
# -----------------------------------------------------------------------------------------------
# 17. If the request is for a file or directory that physically exists on the server,
# then don't give control to ProcessWire, and instead load the file
# -----------------------------------------------------------------------------------------------

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !(favicon\.ico|robots\.txt)

# -----------------------------------------------------------------------------------------------
# 18. OPTIONAL: Prevent ProcessWire from attempting to serve images or anything in /site/assets/.
# Both of these lines are optional, but can help to reduce server load. However, they
# are not compatible with the $config->pagefileSecure option (if enabled) and they
# may produce an Apache 404 rather than your regular 404. You may uncomment the two lines
# below if you don't need to use the $config->pagefileSecure option.
# -----------------------------------------------------------------------------------------------

# RewriteCond %{REQUEST_FILENAME} !\.(jpg|jpeg|gif|png|ico)$ [NC]
# RewriteCond %{REQUEST_FILENAME} !(^|/)site/assets/

# -----------------------------------------------------------------------------------------------
# 19. Pass control to ProcessWire if all the above directives allow us to this point.
# For regular VirtualHosts (most installs)
# -----------------------------------------------------------------------------------------------
RewriteRule ^(.*)$ index.php?it=$1 [L,QSA]

# -----------------------------------------------------------------------------------------------
# 20. If using VirtualDocumentRoot (500 NOTE): comment out the one above and use this one instead
# -----------------------------------------------------------------------------------------------
# RewriteRule ^(.*)$ /index.php?it=$1 [L,QSA]

</IfModule>

#################################################################################################
# END PROCESSWIRE HTACCESS DIRECTIVES
#################################################################################################

66 changes: 66 additions & 0 deletions index.php
@@ -0,0 +1,66 @@
<?php namespace ProcessWire;

/**
* ProcessWire Bootstrap
*
* This file may be used to bootstrap either the http web accessible
* version, or the command line client version of ProcessWire.
*
* Note: if you happen to change any directory references in here, please
* do so after you have installed the site, as the installer is not informed
* of any changes made in this file.
*
* ProcessWire 3.x, Copyright 2016 by Ryan Cramer
* https://processwire.com
*
* @version 3.0
*
* Index Versions
* ==============
* 300 Moved much of this file to a ProcessWire::buildConfig() method.
* 252 Extract all fuel to local API vars when in external or cli mode.
* 251 Add $config->debugIf option.
* 250 PW 2.5 support.
*
*/

if(!defined("PROCESSWIRE")) define("PROCESSWIRE", 300); // index version
$rootPath = __DIR__;
if(DIRECTORY_SEPARATOR != '/') $rootPath = str_replace(DIRECTORY_SEPARATOR, '/', $rootPath);
$composerAutoloader = $rootPath . '/vendor/autoload.php'; // composer autoloader
if(file_exists($composerAutoloader)) require_once($composerAutoloader);
if(!class_exists("ProcessWire", false)) require_once("$rootPath/wire/core/ProcessWire.php");
$config = ProcessWire::buildConfig($rootPath);

if(!$config->dbName) {
// If ProcessWire is not installed, go to the installer
if(is_file("./install.php") && strtolower($_SERVER['REQUEST_URI']) == strtolower($config->urls->root)) {
require("./install.php");
exit(0);
} else {
header("HTTP/1.1 404 Page Not Found");
echo "404 page not found (no site configuration or install.php available)";
exit(0);
}
}

$process = null;
$wire = null;

try {
// Bootstrap ProcessWire's core and make the API available with $wire
$wire = new ProcessWire($config);
$process = $wire->modules->get('ProcessPageView');
$wire->wire('process', $process);
echo $process->execute($config->internal);
$config->internal ? $process->finished() : extract($wire->wire('all')->getArray());

} catch(\Exception $e) {
// Formulate error message and send to the error handler
if($process) $process->failed($e);
$wire ? $wire->trackException($e) : $config->trackException($e);
$errorMessage = "Exception: " . $e->getMessage() . " (in " . $e->getFile() . " line " . $e->getLine() . ")";
if($config->debug || ($wire && $wire->user && $wire->user->isSuperuser())) $errorMessage .= "\n\n" . $e->getTraceAsString();
trigger_error($errorMessage, E_USER_ERROR);
}

0 comments on commit bac5b0d

Please sign in to comment.