Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisaaroland committed Jul 7, 2016
0 parents commit 53547d9
Show file tree
Hide file tree
Showing 273 changed files with 33,267 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*~
.vagrant
www/include/config_dev.php
www/include/secrets_dev.php
www/include/secrets*.php
tests/coverage.state
coverage/
1 change: 1 addition & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Options -Indexes
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
templates:
php -q ./bin/compile-templates.php

secret:
php -q ./bin/generate_secret.php

setup:
ubuntu/setup-ubuntu.sh
ubuntu/setup-flamework.sh
ubuntu/setup-certified.sh
sudo ubuntu/setup-certified-ca.sh
sudo ubuntu/setup-certified-certs.sh
bin/configure_secrets.sh .
ubuntu/setup-db.sh wof_api wof_api
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# whosonfirst-www-api

1 change: 1 addition & 0 deletions apache/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.conf
3 changes: 3 additions & 0 deletions apache/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Order Allow,Deny
Allow from none
Deny from all
81 changes: 81 additions & 0 deletions apache/whosonfirst-www-api.conf.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<VirtualHost *:80>

# RewriteEngine on
# RewriteCond "%{HTTPS}" "!=on"
# RewriteRule "." "-" [F]

DocumentRoot __PROJECT_ROOT__/www

<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

<Directory __PROJECT_ROOT__/www>
Options FollowSymLinks Indexes
AllowOverride All

Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

LogLevel warn

</VirtualHost>

# What follows assumes you have run the following:
# ubuntu/setup-certified.sh
# ubuntu/setup-certified-ca.sh
# ubuntu/setup-certified-certs.sh
# If you have you own SSL keys/certs you will need to
# update things accordingly

# See als:
# https://wiki.mozilla.org/Security/Server_Side_TLS
# https://wiki.mozilla.org/Security/Server_Side_TLS#Apache
# https://wiki.mozilla.org/Security/Server_Side_TLS#Modern_compatibility

<VirtualHost *:443>

SSLEngine on
SSLCertificateFile "__PROJECT_ROOT__/certified/db/__PROJECT_NAME__.crt"
SSLCertificateKeyFile "__PROJECT_ROOT__/certified/db/__PROJECT_NAME__.key"

SSLProtocol all -SSLv2 -SSLv3
SSLCipherSuite CDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK

SSLHonorCipherOrder on
SSLCompression off

SSLUseStapling on
SSLStaplingResponderTimeout 5
SSLStaplingReturnResponderErrors off

# On Apache 2.4+, SSLStaplingCache must be set *outside* of the VirtualHost
# SSLStaplingCache shmcb:/var/run/ocsp(128000)
Header add Strict-Transport-Security "max-age=15768000"

DocumentRoot __PROJECT_ROOT__/www

<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

<Directory __PROJECT_ROOT__/www>
Options FollowSymLinks Indexes
AllowOverride All
Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

LogLevel warn

</VirtualHost>

# See above
SSLStaplingCache shmcb:/var/run/ocsp(128000)
3 changes: 3 additions & 0 deletions bin/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Order Allow,Deny
Allow from none
Deny from all
22 changes: 22 additions & 0 deletions bin/compile-templates.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

include("init_local.php");

# http://www.smarty.net/docs/en/api.compile.all.templates.tpl (version 3)
# $GLOBALS['smarty']->compileAllTemplates('.txt', true);

$pattern = "{$GLOBALS['cfg']['smarty_template_dir']}/*.txt";
$templates = array();

foreach (glob($pattern) as $f){
$templates[] = basename($f);
}

$GLOBALS['smarty']->force_compile = true;

foreach ($templates as $t){
$GLOBALS['smarty']->fetch($t);
}

exit();
?>
10 changes: 10 additions & 0 deletions bin/generate_secret.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

include("init_local.php");
loadlib("random");

$length = 32;

echo random_string($length) . "\n";
exit();
?>
8 changes: 8 additions & 0 deletions bin/init_local.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

$root = dirname(dirname(__FILE__));
ini_set("include_path", "{$root}/www:{$root}/www/include");

include("include/init.php");

# the end
22 changes: 22 additions & 0 deletions extras/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Extras
--

## lib_cache_memcache.php

In order to use the `memcache` plugin you will need to make sure that you have
installed the `php5-memcache` client.

You will also need to add a `memcache_pool` config to your `config.php`
file. Memcache can bucket cache requests across a number of hosts hence the list
of lists. For example:

$GLOBALS['cfg']['memcache_pool'] = array(
array('host' => 'localhost', 'port' => 11211)
);

You will need to explicitly load the `cache_memcache` library in your code or
enabled it using the `autoload_lib` array in your config file. Like this:

$GLOBALS['cfg']['autoload_libs'] = array(
'cache_memcache',
);
42 changes: 42 additions & 0 deletions extras/lib_base58.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

# http://darklaunch.com/2009/08/07/base58-encode-and-decode-using-php-with-example-base58-encode-base58-decode

#################################################################

function base58_encode($num) {
$alphabet = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ';
$base_count = strlen($alphabet);
$encoded = '';

while ($num >= $base_count) {
$div = $num / $base_count;
$mod = ($num - ($base_count * intval($div)));
$encoded = $alphabet[$mod] . $encoded;
$num = intval($div);
}

if ($num) {
$encoded = $alphabet[$num] . $encoded;
}

return $encoded;
}

#################################################################

function base58_decode($num) {
$alphabet = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ';
$len = strlen($num);
$decoded = 0;
$multi = 1;

for ($i = $len - 1; $i >= 0; $i--) {
$decoded += $multi * strpos($alphabet, $num[$i]);
$multi = $multi * strlen($alphabet);
}

return $decoded;
}

#################################################################
Loading

0 comments on commit 53547d9

Please sign in to comment.