├── .sandstorm ├── stack ├── build.sh ├── pgp-keyring ├── pgp-signature ├── screenshot1.png ├── screenshot2.png ├── .gitignore ├── .gitattributes ├── setup.sh ├── changeLog.md ├── description.md ├── launcher.sh ├── app-graphics │ ├── wordpress-150.svg │ ├── wordpress-24.svg │ └── wordpress-128.svg ├── global-setup.sh ├── sandstorm-pkgdef.capnp └── Vagrantfile ├── read-only-plugins ├── sqlite-integration │ ├── index.php │ ├── js │ │ ├── index.php │ │ ├── sqlite.min.js │ │ └── sqlite.js │ ├── styles │ │ ├── index.php │ │ ├── coffee.min.css │ │ ├── ocean.min.css │ │ ├── ectoplasm.min.css │ │ ├── sunrise.min.css │ │ ├── blue.min.css │ │ ├── midnight.min.css │ │ ├── light.min.css │ │ ├── coffee.css │ │ ├── ocean.css │ │ ├── sunrise.css │ │ ├── ectoplasm.css │ │ ├── blue.css │ │ ├── light.css │ │ ├── midnight.css │ │ ├── style.min.css │ │ └── style.css │ ├── languages │ │ ├── index.php │ │ ├── sqlite-integration-ja.mo │ │ └── sqlite-integration-es_ES.mo │ ├── utilities │ │ ├── index.php │ │ ├── documentation.php │ │ └── patch.php │ ├── ChangeLog │ ├── BUGS │ ├── install.php │ ├── schema.php │ ├── db.php │ ├── readme-ja.txt │ ├── pdodb.class.php │ ├── readme.txt │ ├── sqlite-integration.php │ └── query_create.class.php └── mu-plugins │ └── sandstorm.php ├── etc ├── passwd ├── hosts └── nginx │ ├── scgi_params │ ├── uwsgi_params │ ├── nginx.conf │ ├── fastcgi_params │ ├── fastcgi.conf │ ├── koi-win │ ├── koi-utf │ ├── win-utf │ └── mime.types ├── README.md ├── sandstorm-port-notes.txt ├── start.sh ├── sandstorm ├── Makefile └── getPublicId.c++ ├── continue.sh ├── publish-it.sh ├── Makefile ├── wp-config.php └── LICENSE /.sandstorm/stack: -------------------------------------------------------------------------------- 1 | diy 2 | -------------------------------------------------------------------------------- /read-only-plugins/sqlite-integration/index.php: -------------------------------------------------------------------------------- 1 | /var/www/index.html <<__EOF__ 10 |
11 |This WordPress site has been set up successfully, but no content has 12 | been published. Go click the "Rebuild Public Site" button!
13 | 14 | __EOF__ 15 | 16 | cp -r /wordpress-read-only/wp-content-read-only/* /var/wordpress/wp-content 17 | 18 | ./continue.sh 19 | 20 | -------------------------------------------------------------------------------- /read-only-plugins/sqlite-integration/styles/coffee.min.css: -------------------------------------------------------------------------------- 1 | @import url('./style.min.css');@CHARSET "UTF-8";#sqlite-admin-wrap h2,#sqlite-admin-side-wrap h2{background:#59524c;color:#fff;padding-left:5px}.menu-item{font-size:20px;display:inline;min-width:150px;height:50px;margin-left:0;margin-right:10px;padding:5px;border:.5px solit #000;background:#59524c;color:#fff;line-height:40px}.menu-selected{font-size:20px;display:inline;min-width:150px;height:50px;margin-left:0;margin-right:10px;padding:5px;background:#c7a589;color:#fff}.menu-item a{text-decoration:none;color:#fff} -------------------------------------------------------------------------------- /read-only-plugins/sqlite-integration/styles/ocean.min.css: -------------------------------------------------------------------------------- 1 | @import url('./style.min.css');@CHARSET "UTF-8";#sqlite-admin-wrap h2,#sqlite-admin-side-wrap h2{background:#738e96;color:#fff;padding-left:5px}.menu-item{font-size:20px;display:inline;min-width:150px;height:50px;margin-left:0;margin-right:10px;padding:5px;border:.5px solit #000;background:#738e96;color:#fff;line-height:40px}.menu-selected{font-size:20px;display:inline;min-width:150px;height:50px;margin-left:0;margin-right:10px;padding:5px;background:#9ebaa0;color:#fff}.menu-item a{text-decoration:none;color:#fff} -------------------------------------------------------------------------------- /read-only-plugins/sqlite-integration/styles/ectoplasm.min.css: -------------------------------------------------------------------------------- 1 | @import url('./style.min.css');@CHARSET "UTF-8";#sqlite-admin-wrap h2,#sqlite-admin-side-wrap h2{background:#523f6d;color:#fff;padding-left:5px}.menu-item{font-size:20px;display:inline;min-width:150px;height:50px;margin-left:0;margin-right:10px;padding:5px;border:.5px solit #000;background:#523f6d;color:#fff;line-height:40px}.menu-selected{font-size:20px;display:inline;min-width:150px;height:50px;margin-left:0;margin-right:10px;padding:5px;background:#a3b745;color:#fff}.menu-item a{text-decoration:none;color:#fff} -------------------------------------------------------------------------------- /read-only-plugins/sqlite-integration/styles/sunrise.min.css: -------------------------------------------------------------------------------- 1 | @import url('./style.min.css');@CHARSET "UTF-8";#sqlite-admin-wrap h2,#sqlite-admin-side-wrap h2{background:#cf4944;color:#fff;padding-left:5px}.menu-item{font-size:20px;display:inline;min-width:150px;height:50px;margin-left:0;margin-right:10px;padding:5px;border:.5px solit #000;background:#cf4944;color:#fff;line-height:40px}.menu-selected{font-size:20px;display:inline;min-width:150px;height:50px;margin-left:0;margin-right:10px;padding:5px;background:#dd823b;color:#100100100}.menu-item a{text-decoration:none;color:#fff} -------------------------------------------------------------------------------- /.sandstorm/changeLog.md: -------------------------------------------------------------------------------- 1 | ### v2016.06.07 (4.4.2) 2 | - Fix bug where image uploads would fail to show up in the published site. 3 | ### v2016.04.11 (4.4.2) 4 | - Update to upstream version 4.4.2. 5 | - Use X-Sandstorm-User-Picture for avatars. 6 | ### v2015.10.21 (4.3.2-alpha) 7 | - Update to upstream version 4.3.2-alpha. 8 | - Metadata: adjust action title and noun phrase to avoid repeitition. 9 | ### v2015.08.23 (4.3) 10 | - Add to the description a paragraph about static publishing. 11 | ### v2015.08.22 (4.3) 12 | - Add metadata. 13 | - Update to upstream version 4.3. 14 | -------------------------------------------------------------------------------- /read-only-plugins/sqlite-integration/styles/blue.min.css: -------------------------------------------------------------------------------- 1 | @import url('./style.min.css');@CHARSET "UTF-8";#sqlite-admin-wrap h2,#sqlite-admin-side-wrap h2{background:#4796b3;color:#fff;padding-left:5px}.menu-item{font-size:20px;display:inline;min-width:150px;height:50px;margin-left:0;margin-right:10px;padding:5px;border:.5px solit #000;background:#4796b3;color:(255,255,255);line-height:40px}.menu-selected{font-size:20px;display:inline;min-width:150px;height:50px;margin-left:0;margin-right:10px;padding:5px;border:.5px solit #000;background:#096484;color:#fff}.menu-item a{text-decoration:none;color:#fff} -------------------------------------------------------------------------------- /read-only-plugins/sqlite-integration/styles/midnight.min.css: -------------------------------------------------------------------------------- 1 | @import url('./style.min.css');@CHARSET "UTF-8";#sqlite-admin-wrap h2,#sqlite-admin-side-wrap h2{background:#363b3f;color:#fff;padding-left:5px}.menu-item{font-size:20px;display:inline;min-width:150px;height:50px;margin-left:0;margin-right:10px;padding:5px;border:.5px solit #000;background:#363b3f;color:#fff;line-height:40px}.menu-selected{font-size:20px;display:inline;min-width:150px;height:50px;margin-left:0;margin-right:10px;padding:5px;background:#e14d43;color:#fff}.menu-item a{text-decoration:none;color:#fff}.menu-item{background:#363b3f;color:#fff} -------------------------------------------------------------------------------- /read-only-plugins/sqlite-integration/styles/light.min.css: -------------------------------------------------------------------------------- 1 | @import url('./style.min.css');@CHARSET "UTF-8";#sqlite-admin-wrap h2,#sqlite-admin-side-wrap h2{background:#e5e5e5;color:#373737;padding-left:5px}.menu-item{font-size:20px;display:inline;min-width:150px;height:50px;margin-left:0;margin-right:10px;padding:5px;border:.5px solit #000;background:#e5e5e5;color:#373737;border-bottom-color:whitesmoke;line-height:40px}.menu-selected{font-size:20px;display:inline;min-width:150px;height:50px;margin-left:0;margin-right:10px;padding:5px;background:#888;color:#fff;border-bottom-color:whitesmoke}.menu-item a{text-decoration:none;color:#373737} -------------------------------------------------------------------------------- /etc/nginx/scgi_params: -------------------------------------------------------------------------------- 1 | 2 | scgi_param REQUEST_METHOD $request_method; 3 | scgi_param REQUEST_URI $request_uri; 4 | scgi_param QUERY_STRING $query_string; 5 | scgi_param CONTENT_TYPE $content_type; 6 | 7 | scgi_param DOCUMENT_URI $document_uri; 8 | scgi_param DOCUMENT_ROOT $document_root; 9 | scgi_param SCGI 1; 10 | scgi_param SERVER_PROTOCOL $server_protocol; 11 | scgi_param HTTPS $https if_not_empty; 12 | 13 | scgi_param REMOTE_ADDR $remote_addr; 14 | scgi_param REMOTE_PORT $remote_port; 15 | scgi_param SERVER_PORT $server_port; 16 | scgi_param SERVER_NAME $server_name; 17 | -------------------------------------------------------------------------------- /etc/nginx/uwsgi_params: -------------------------------------------------------------------------------- 1 | 2 | uwsgi_param QUERY_STRING $query_string; 3 | uwsgi_param REQUEST_METHOD $request_method; 4 | uwsgi_param CONTENT_TYPE $content_type; 5 | uwsgi_param CONTENT_LENGTH $content_length; 6 | 7 | uwsgi_param REQUEST_URI $request_uri; 8 | uwsgi_param PATH_INFO $document_uri; 9 | uwsgi_param DOCUMENT_ROOT $document_root; 10 | uwsgi_param SERVER_PROTOCOL $server_protocol; 11 | uwsgi_param HTTPS $https if_not_empty; 12 | 13 | uwsgi_param REMOTE_ADDR $remote_addr; 14 | uwsgi_param REMOTE_PORT $remote_port; 15 | uwsgi_param SERVER_PORT $server_port; 16 | uwsgi_param SERVER_NAME $server_name; 17 | -------------------------------------------------------------------------------- /sandstorm/Makefile: -------------------------------------------------------------------------------- 1 | # You may override the following vars on the command line to suit 2 | # your config. 3 | CXX=clang++ 4 | CXXFLAGS=-O2 -Wall 5 | 6 | # You generally should not modify these. 7 | CXXFLAGS2=-std=c++1y -Itmp $(CXXFLAGS) 8 | 9 | .PHONY: all clean 10 | 11 | all: bin/getPublicId 12 | 13 | clean: 14 | rm -rf bin tmp 15 | 16 | bin/getPublicId: tmp/genfiles getPublicId.c++ 17 | mkdir -p bin 18 | $(CXX) getPublicId.c++ tmp/sandstorm/*.capnp.c++ -o bin/getPublicId -static $(CXXFLAGS2) `pkg-config capnp-rpc --cflags --libs` 19 | 20 | tmp/genfiles: /opt/sandstorm/latest/usr/include/sandstorm/*.capnp 21 | mkdir -p tmp 22 | capnp compile --src-prefix=/opt/sandstorm/latest/usr/include -oc++:tmp /opt/sandstorm/latest/usr/include/sandstorm/*.capnp 23 | touch tmp/genfiles 24 | -------------------------------------------------------------------------------- /continue.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | /usr/sbin/php5-fpm --fpm-config /etc/php/php-fpm.conf -c /etc/php/php.ini 4 | echo "started php-fpm. status code:" $? 5 | 6 | CGICONF=/var/fastcgi.conf 7 | rm -f $CGICONF; 8 | fastcgi_param () { 9 | echo "fastcgi_param $1 `base64 /dev/urandom | head -c 60`;" >> $CGICONF 10 | } 11 | 12 | fastcgi_param WORDPRESS_AUTH_KEY; 13 | fastcgi_param WORDPRESS_SECURE_AUTH_KEY; 14 | fastcgi_param WORDPRESS_LOGGED_IN_KEY; 15 | fastcgi_param WORDPRESS_NONCE_KEY; 16 | fastcgi_param WORDPRESS_AUTH_SALT; 17 | fastcgi_param WORDPRESS_SECURE_AUTH_SALT; 18 | fastcgi_param WORDPRESS_LOGGED_IN_SALT; 19 | fastcgi_param WORDPRESS_NONCE_SALT; 20 | 21 | 22 | /usr/sbin/nginx -g "pid /var/run/nginx.pid;" 23 | echo "started nginx. status code:" $? 24 | 25 | 26 | sleep infinity 27 | 28 | -------------------------------------------------------------------------------- /etc/nginx/nginx.conf: -------------------------------------------------------------------------------- 1 | 2 | #user html; 3 | worker_processes 4; 4 | 5 | events { 6 | worker_connections 1024; 7 | } 8 | 9 | http { 10 | include mime.types; 11 | default_type application/octet-stream; 12 | 13 | access_log off; 14 | 15 | sendfile on; 16 | #tcp_nopush on; 17 | 18 | keepalive_timeout 65; 19 | 20 | 21 | server { 22 | listen 10000; 23 | 24 | root /wordpress-read-only; 25 | 26 | location / { 27 | index index.html index.htm index.php; 28 | 29 | try_files $uri $uri/ /index.php; 30 | } 31 | 32 | location /wp-content/database/ { 33 | deny all; 34 | } 35 | 36 | location ~ \.php$ { 37 | try_files $uri = 404; 38 | fastcgi_pass 127.0.0.1:9000; 39 | fastcgi_index index.php; 40 | fastcgi_read_timeout 5m; 41 | include fastcgi.conf; 42 | include /var/fastcgi.conf; 43 | } 44 | 45 | client_max_body_size 1000M; 46 | } 47 | 48 | 49 | } 50 | 51 | 52 | -------------------------------------------------------------------------------- /read-only-plugins/sqlite-integration/styles/coffee.css: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is a part of SQLite Integration. 3 | * 4 | * @package SQLite Integration 5 | * @author Kojima Toshiyasu 6 | */ 7 | @import url('./style.min.css'); 8 | @CHARSET "UTF-8"; 9 | #sqlite-admin-wrap h2, 10 | #sqlite-admin-side-wrap h2 { 11 | background: #59524c; 12 | color: rgb(255, 255, 255); 13 | padding-left: 5px; 14 | } 15 | .menu-item { 16 | font-size: 20px; 17 | display: inline; 18 | min-width: 150px; 19 | height: 50px; 20 | margin-left: 0; 21 | margin-right: 10px; 22 | padding: 5px; 23 | border: .5px solit #000; 24 | background: #59524c; 25 | color: rgb(255, 255, 255); 26 | line-height: 40px; 27 | } 28 | .menu-selected { 29 | font-size: 20px; 30 | display: inline; 31 | min-width: 150px; 32 | height: 50px; 33 | margin-left: 0; 34 | margin-right: 10px; 35 | padding: 5px; 36 | background: #c7a589; 37 | color: rgb(255, 255, 255); 38 | } 39 | .menu-item a { 40 | text-decoration: none; 41 | color: rgb(255, 255, 255); 42 | } 43 | -------------------------------------------------------------------------------- /read-only-plugins/sqlite-integration/styles/ocean.css: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is a part of SQLite Integration. 3 | * 4 | * @package SQLite Integration 5 | * @author Kojima Toshiyasu 6 | */ 7 | @import url('./style.min.css'); 8 | @CHARSET "UTF-8"; 9 | #sqlite-admin-wrap h2, 10 | #sqlite-admin-side-wrap h2 { 11 | background: #738e96; 12 | color: rgb(255, 255, 255); 13 | padding-left: 5px; 14 | } 15 | .menu-item { 16 | font-size: 20px; 17 | display: inline; 18 | min-width: 150px; 19 | height: 50px; 20 | margin-left: 0; 21 | margin-right: 10px; 22 | padding: 5px; 23 | border: .5px solit #000; 24 | background: #738e96; 25 | color: rgb(255, 255, 255); 26 | line-height: 40px; 27 | } 28 | .menu-selected { 29 | font-size: 20px; 30 | display: inline; 31 | min-width: 150px; 32 | height: 50px; 33 | margin-left: 0; 34 | margin-right: 10px; 35 | padding: 5px; 36 | background: #9ebaa0; 37 | color: rgb(255, 255, 255); 38 | } 39 | .menu-item a { 40 | text-decoration: none; 41 | color: rgb(255, 255, 255); 42 | } 43 | -------------------------------------------------------------------------------- /read-only-plugins/sqlite-integration/styles/sunrise.css: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is a part of SQLite Integration. 3 | * 4 | * @package SQLite Integration 5 | * @author Kojima Toshiyasu 6 | */ 7 | @import url('./style.min.css'); 8 | @CHARSET "UTF-8"; 9 | #sqlite-admin-wrap h2, 10 | #sqlite-admin-side-wrap h2 { 11 | background: #cf4944; 12 | color: rgb(255, 255, 255); 13 | padding-left: 5px; 14 | } 15 | .menu-item { 16 | font-size: 20px; 17 | display: inline; 18 | min-width: 150px; 19 | height: 50px; 20 | margin-left: 0; 21 | margin-right: 10px; 22 | padding: 5px; 23 | border: .5px solit #000; 24 | background: #cf4944; 25 | color: rgb(255, 255, 255); 26 | line-height: 40px; 27 | } 28 | .menu-selected { 29 | font-size: 20px; 30 | display: inline; 31 | min-width: 150px; 32 | height: 50px; 33 | margin-left: 0; 34 | margin-right: 10px; 35 | padding: 5px; 36 | background: #dd823b; 37 | color: rgb(256, 256, 256); 38 | } 39 | .menu-item a { 40 | text-decoration: none; 41 | color: rgb(255, 255, 255); 42 | } 43 | -------------------------------------------------------------------------------- /read-only-plugins/sqlite-integration/styles/ectoplasm.css: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is a part of SQLite Integration. 3 | * 4 | * @package SQLite Integration 5 | * @author Kojima Toshiyasu 6 | */ 7 | @import url('./style.min.css'); 8 | @CHARSET "UTF-8"; 9 | #sqlite-admin-wrap h2, 10 | #sqlite-admin-side-wrap h2 { 11 | background: #523f6d; 12 | color: rgb(255, 255, 255); 13 | padding-left: 5px; 14 | } 15 | .menu-item { 16 | font-size: 20px; 17 | display: inline; 18 | min-width: 150px; 19 | height: 50px; 20 | margin-left: 0; 21 | margin-right: 10px; 22 | padding: 5px; 23 | border: .5px solit #000; 24 | background: #523f6d; 25 | color: rgb(255, 255, 255); 26 | line-height: 40px; 27 | } 28 | .menu-selected { 29 | font-size: 20px; 30 | display: inline; 31 | min-width: 150px; 32 | height: 50px; 33 | margin-left: 0; 34 | margin-right: 10px; 35 | padding: 5px; 36 | background: #a3b745; 37 | color: rgb(255, 255, 255); 38 | } 39 | .menu-item a { 40 | text-decoration: none; 41 | color: rgb(255, 255, 255); 42 | } 43 | -------------------------------------------------------------------------------- /publish-it.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | STATICDIR=/var/www 3 | TMPDIR=/var/www_`date +%s%N` 4 | URL=http://this_will_be_replaced_by_sandstorm:10000 5 | REPLACE_URL=$URL 6 | 7 | rm -rf $TMPDIR 8 | wget --mirror -p --convert-links -np -nH -e robots=off -X /wp-admin/ -P $TMPDIR $URL 9 | for q in `find $TMPDIR -name '*\?*'`; do 10 | if [ -f ${q%\?*} ]; then 11 | echo 'removing $q'; 12 | rm $q; 13 | else 14 | echo 'renaming $q'; 15 | mv $q ${q%\?*}; 16 | fi; 17 | done 18 | 19 | # make anying relative that wget failed to clean up 20 | find $TMPDIR -type f -exec sed -i "s|${REPLACE_URL}/|/|g" {} \; 21 | find $TMPDIR -type f -exec sed -i "s|${REPLACE_URL}|/|g" {} \; # URLs without a trailing / need to be changed to point the index 22 | 23 | # Make sure to copy over all of the uploads. This is necessary because the current release of wget 24 | # does not yet support srcset in img tags. 25 | cp -r /var/wordpress/wp-content/uploads $TMPDIR/wp-content/ 26 | 27 | mv $STATICDIR ${STATICDIR}_tmp 28 | mv $TMPDIR $STATICDIR 29 | rm -rf ${STATICDIR}_tmp 30 | -------------------------------------------------------------------------------- /read-only-plugins/sqlite-integration/styles/blue.css: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is a part of SQLite Integration. 3 | * 4 | * @package SQLite Integration 5 | * @author Kojima Toshiyasu 6 | */ 7 | @import url('./style.min.css'); 8 | @CHARSET "UTF-8"; 9 | #sqlite-admin-wrap h2, 10 | #sqlite-admin-side-wrap h2 { 11 | background: #4796b3; 12 | color: rgb(255, 255, 255); 13 | padding-left: 5px; 14 | } 15 | .menu-item { 16 | font-size: 20px; 17 | display: inline; 18 | min-width: 150px; 19 | height: 50px; 20 | margin-left: 0; 21 | margin-right: 10px; 22 | padding: 5px; 23 | border: .5px solit #000; 24 | background: #4796b3; 25 | color: (255, 255, 255); 26 | line-height: 40px; 27 | } 28 | .menu-selected { 29 | font-size: 20px; 30 | display: inline; 31 | min-width: 150px; 32 | height: 50px; 33 | margin-left: 0; 34 | margin-right: 10px; 35 | padding: 5px; 36 | border: .5px solit #000; 37 | background: #096484; 38 | color: rgb(255, 255, 255); 39 | } 40 | .menu-item a { 41 | text-decoration: none; 42 | color: rgb(255, 255, 255); 43 | } 44 | -------------------------------------------------------------------------------- /etc/nginx/fastcgi_params: -------------------------------------------------------------------------------- 1 | 2 | fastcgi_param QUERY_STRING $query_string; 3 | fastcgi_param REQUEST_METHOD $request_method; 4 | fastcgi_param CONTENT_TYPE $content_type; 5 | fastcgi_param CONTENT_LENGTH $content_length; 6 | 7 | fastcgi_param SCRIPT_NAME $fastcgi_script_name; 8 | fastcgi_param REQUEST_URI $request_uri; 9 | fastcgi_param DOCUMENT_URI $document_uri; 10 | fastcgi_param DOCUMENT_ROOT $document_root; 11 | fastcgi_param SERVER_PROTOCOL $server_protocol; 12 | fastcgi_param HTTPS $https if_not_empty; 13 | 14 | fastcgi_param GATEWAY_INTERFACE CGI/1.1; 15 | fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; 16 | 17 | fastcgi_param REMOTE_ADDR $remote_addr; 18 | fastcgi_param REMOTE_PORT $remote_port; 19 | fastcgi_param SERVER_ADDR $server_addr; 20 | fastcgi_param SERVER_PORT $server_port; 21 | fastcgi_param SERVER_NAME $server_name; 22 | 23 | # PHP only, required if PHP was built with --enable-force-cgi-redirect 24 | fastcgi_param REDIRECT_STATUS 200; 25 | -------------------------------------------------------------------------------- /read-only-plugins/sqlite-integration/styles/light.css: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is a part of SQLite Integration. 3 | * 4 | * @package SQLite Integration 5 | * @author Kojima Toshiyasu 6 | */ 7 | @import url('./style.min.css'); 8 | @CHARSET "UTF-8"; 9 | #sqlite-admin-wrap h2, 10 | #sqlite-admin-side-wrap h2 { 11 | background: #e5e5e5; 12 | color: rgb(55, 55, 55); 13 | padding-left: 5px; 14 | } 15 | .menu-item { 16 | font-size: 20px; 17 | display: inline; 18 | min-width: 150px; 19 | height: 50px; 20 | margin-left: 0; 21 | margin-right: 10px; 22 | padding: 5px; 23 | border: .5px solit #000; 24 | background: #e5e5e5; 25 | color: rgb(55, 55, 55); 26 | border-bottom-color: whitesmoke; 27 | line-height: 40px; 28 | } 29 | .menu-selected { 30 | font-size: 20px; 31 | display: inline; 32 | min-width: 150px; 33 | height: 50px; 34 | margin-left: 0; 35 | margin-right: 10px; 36 | padding: 5px; 37 | background: #888888; 38 | color: rgb(255, 255, 255); 39 | border-bottom-color: whitesmoke; 40 | } 41 | .menu-item a { 42 | text-decoration: none; 43 | color: rgb(55, 55, 55); 44 | } 45 | -------------------------------------------------------------------------------- /read-only-plugins/sqlite-integration/styles/midnight.css: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is a part of SQLite Integration. 3 | * 4 | * @package SQLite Integration 5 | * @author Kojima Toshiyasu 6 | */ 7 | @import url('./style.min.css'); 8 | @CHARSET "UTF-8"; 9 | #sqlite-admin-wrap h2, 10 | #sqlite-admin-side-wrap h2 { 11 | background: #363b3f; 12 | color: rgb(255, 255, 255); 13 | padding-left: 5px; 14 | } 15 | .menu-item { 16 | font-size: 20px; 17 | display: inline; 18 | min-width: 150px; 19 | height: 50px; 20 | margin-left: 0; 21 | margin-right: 10px; 22 | padding: 5px; 23 | border: .5px solit #000; 24 | background: #363b3f; 25 | color: rgb(255, 255, 255); 26 | line-height: 40px; 27 | } 28 | .menu-selected { 29 | font-size: 20px; 30 | display: inline; 31 | min-width: 150px; 32 | height: 50px; 33 | margin-left: 0; 34 | margin-right: 10px; 35 | padding: 5px; 36 | background: #e14d43; 37 | color: rgb(255, 255, 255); 38 | } 39 | .menu-item a { 40 | text-decoration: none; 41 | color: rgb(255, 255, 255); 42 | } 43 | .menu-item { 44 | background: #363b3f; 45 | color: rgb(255, 255, 255); 46 | } 47 | -------------------------------------------------------------------------------- /etc/nginx/fastcgi.conf: -------------------------------------------------------------------------------- 1 | 2 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 3 | fastcgi_param QUERY_STRING $query_string; 4 | fastcgi_param REQUEST_METHOD $request_method; 5 | fastcgi_param CONTENT_TYPE $content_type; 6 | fastcgi_param CONTENT_LENGTH $content_length; 7 | 8 | fastcgi_param SCRIPT_NAME $fastcgi_script_name; 9 | fastcgi_param REQUEST_URI $request_uri; 10 | fastcgi_param DOCUMENT_URI $document_uri; 11 | fastcgi_param DOCUMENT_ROOT $document_root; 12 | fastcgi_param SERVER_PROTOCOL $server_protocol; 13 | fastcgi_param HTTPS $https if_not_empty; 14 | 15 | fastcgi_param GATEWAY_INTERFACE CGI/1.1; 16 | fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; 17 | 18 | fastcgi_param REMOTE_ADDR $remote_addr; 19 | fastcgi_param REMOTE_PORT $remote_port; 20 | fastcgi_param SERVER_ADDR $server_addr; 21 | fastcgi_param SERVER_PORT $server_port; 22 | fastcgi_param SERVER_NAME $server_name; 23 | 24 | # PHP only, required if PHP was built with --enable-force-cgi-redirect 25 | fastcgi_param REDIRECT_STATUS 200; 26 | -------------------------------------------------------------------------------- /.sandstorm/description.md: -------------------------------------------------------------------------------- 1 | The popular WordPress blogging platform, adapted as a Sandstorm app. 2 | 3 | Publish content to any domain you control, 4 | add collaborators through Sandstorm's 5 | [sharing interface](https://blog.sandstorm.io/news/2015-05-05-delegation-is-the-cornerstone-of-civilization.html), 6 | install arbitrary themes and plugins, 7 | and rest assured that Sandstorm's 8 | [security features](https://docs.sandstorm.io/en/latest/using/security-practices/) 9 | seriously limit the damage that an evil person or plugin could cause. 10 | 11 | This app has a few quirks that distinguish it from a standard WordPress install. 12 | Probably the first you'll notice is that it only publishes *static* content. 13 | Unlike a standard WordPress setup, where the published content and the admin panel 14 | get served from the same domain by the same server, in this app 15 | published content can only be static and gets served by Sandstorm's web publishing feature, 16 | while the WordPress admin panel is only accessible to authorized users through the Sandstorm shell. 17 | This has advantages for your site's speed and security, though it does mean that WordPress's Comments feature 18 | will not work on your published site. 19 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | wordpress_repo = https://github.com/dwrensha/wordpress.git 2 | wordpress_repo_branch = sandstorm-app 3 | git_repo_dir = /home/vagrant 4 | 5 | 6 | .PHONY: all clean 7 | 8 | all: wordpress-read-only sandstorm/bin/getPublicId 9 | 10 | clean: 11 | rm -rf wordpress-read-only 12 | 13 | $(git_repo_dir)/wordpress/.git: 14 | git clone ${wordpress_repo} $(git_repo_dir)/wordpress && cd $(git_repo_dir)/wordpress && git checkout ${wordpress_repo_branch} 15 | 16 | wordpress-read-only: $(git_repo_dir)/wordpress/.git 17 | cp -r $(git_repo_dir)/wordpress wordpress-read-only 18 | rm -rf wordpress-read-only/.git 19 | cp wp-config.php wordpress-read-only/ 20 | mv wordpress-read-only/wp-content wordpress-read-only/wp-content-read-only 21 | ln -s /var/wordpress/wp-content wordpress-read-only/wp-content 22 | cp read-only-plugins/sqlite-integration/db.php wordpress-read-only/wp-content-read-only/ 23 | 24 | 25 | sandstorm/bin/getPublicId: /usr/local/bin/capnp 26 | (cd sandstorm && make CXX=g++) 27 | 28 | $(git_repo_dir)/capnproto/.git: 29 | git clone https://github.com/sandstorm-io/capnproto $(git_repo_dir)/capnproto 30 | 31 | /usr/local/bin/capnp: $(git_repo_dir)/capnproto/.git 32 | (cd $(git_repo_dir)/capnproto/c++ && autoreconf -i && ./configure && make && sudo make install) 33 | -------------------------------------------------------------------------------- /.sandstorm/launcher.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | # This script is run every time an instance of our app - aka grain - starts up. 4 | # This is the entry point for your application both when a grain is first launched 5 | # and when a grain resumes after being previously shut down. 6 | # 7 | # This script is responsible for launching everything your app needs to run. The 8 | # thing it should do *last* is: 9 | # 10 | # * Start a process in the foreground listening on port 8000 for HTTP requests. 11 | # 12 | # This is how you indicate to the platform that your application is up and 13 | # ready to receive requests. Often, this will be something like nginx serving 14 | # static files and reverse proxying for some other dynamic backend service. 15 | # 16 | # Other things you probably want to do in this script include: 17 | # 18 | # * Building folder structures in /var. /var is the only non-tmpfs folder 19 | # mounted read-write in the sandbox, and when a grain is first launched, it 20 | # will start out empty. It will persist between runs of the same grain, but 21 | # be unique per app instance. That is, two instances of the same app have 22 | # separate instances of /var. 23 | # * Preparing a database and running migrations. As your package changes 24 | # over time and you release updates, you will need to deal with migrating 25 | # data from previous schema versions to new ones, since users should not have 26 | # to think about such things. 27 | # * Launching other daemons your app needs (e.g. mysqld, redis-server, etc.) 28 | 29 | # By default, this script does nothing. You'll have to modify it as 30 | # appropriate for your application. 31 | cd /opt/app 32 | exit 0 33 | -------------------------------------------------------------------------------- /.sandstorm/app-graphics/wordpress-150.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 27 | -------------------------------------------------------------------------------- /.sandstorm/global-setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | # Set options for curl. Since we only want to show errors from these curl commands, we also use 5 | # 'cat' to buffer the output; for more information: 6 | # https://github.com/sandstorm-io/vagrant-spk/issues/158 7 | 8 | CURL_OPTS="--silent --show-error" 9 | echo localhost > /etc/hostname 10 | hostname localhost 11 | 12 | # The following line copies stderr through stderr to cat without accidentally leaving it in the 13 | # output file. Be careful when changing. See: https://github.com/sandstorm-io/vagrant-spk/pull/159 14 | curl $CURL_OPTS https://install.sandstorm.io/ 2>&1 > /host-dot-sandstorm/caches/install.sh | cat 15 | 16 | SANDSTORM_CURRENT_VERSION=$(curl $CURL_OPTS -f "https://install.sandstorm.io/dev?from=0&type=install") 17 | SANDSTORM_PACKAGE="sandstorm-$SANDSTORM_CURRENT_VERSION.tar.xz" 18 | if [[ ! -f /host-dot-sandstorm/caches/$SANDSTORM_PACKAGE ]] ; then 19 | echo -n "Downloading Sandstorm version ${SANDSTORM_CURRENT_VERSION}..." 20 | curl $CURL_OPTS --output "/host-dot-sandstorm/caches/$SANDSTORM_PACKAGE.partial" "https://dl.sandstorm.io/$SANDSTORM_PACKAGE" 2>&1 | cat 21 | mv "/host-dot-sandstorm/caches/$SANDSTORM_PACKAGE.partial" "/host-dot-sandstorm/caches/$SANDSTORM_PACKAGE" 22 | echo "...done." 23 | fi 24 | if [ ! -e /opt/sandstorm/latest/sandstorm ] ; then 25 | echo -n "Installing Sandstorm version ${SANDSTORM_CURRENT_VERSION}..." 26 | bash /host-dot-sandstorm/caches/install.sh -d -e "/host-dot-sandstorm/caches/$SANDSTORM_PACKAGE" >/dev/null 27 | echo "...done." 28 | fi 29 | modprobe ip_tables 30 | # Make the vagrant user part of the sandstorm group so that commands like 31 | # `spk dev` work. 32 | usermod -a -G 'sandstorm' 'vagrant' 33 | # Bind to all addresses, so the vagrant port-forward works. 34 | sudo sed --in-place='' \ 35 | --expression='s/^BIND_IP=.*/BIND_IP=0.0.0.0/' \ 36 | /opt/sandstorm/sandstorm.conf 37 | sudo service sandstorm restart 38 | # Enable apt-cacher-ng proxy to make things faster if one appears to be running on the gateway IP 39 | GATEWAY_IP=$(ip route | grep ^default | cut -d ' ' -f 3) 40 | if nc -z "$GATEWAY_IP" 3142 ; then 41 | echo "Acquire::http::Proxy \"http://$GATEWAY_IP:3142\";" > /etc/apt/apt.conf.d/80httpproxy 42 | fi 43 | # Configure apt to retry fetching things that fail to download. 44 | echo "APT::Acquire::Retries \"10\";" > /etc/apt/apt.conf.d/80sandstorm-retry 45 | -------------------------------------------------------------------------------- /.sandstorm/app-graphics/wordpress-24.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 38 | -------------------------------------------------------------------------------- /read-only-plugins/sqlite-integration/js/sqlite.min.js: -------------------------------------------------------------------------------- 1 | jQuery(document).ready(function($){function stripe(arg){$(arg).find("tr.alt").removeClass("alt");var $args=arg+" tbody";$($args).each(function(){$(this).children(":visible").has("td").filter(function(index){return 1==index%2}).addClass("alt")})}var $table=null,$headers=null;null!=document.getElementById("sqlite-table")?($table=$("#sqlite-table"),$headers=$table.find("thead th").slice(0,2)):null!=document.getElementById("plugins-table")?($table=$("#plugins-table"),$headers=$table.find("thead th").slice(0)):null!=document.getElementById("patch-files")?($table=$("#patch-files"),$headers=$table.find("thead th").slice(1)):null!=document.getElementById("backup-files")&&($table=$("#backup-files"),$headers=$table.find("thead th").slice(1)),$headers.wrapInner('').addClass("sort");var rows=$table.find("tbody > tr").get();$headers.bind("click",function(event){event.preventDefault();var $header=$(this),sortKey=$header.data("sort").key,sortDirection=1;$header.hasClass("sorted-asc")&&(sortDirection=-1),rows.sort(function(a,b){var keyA=$(a).data("table")[sortKey],keyB=$(b).data("table")[sortKey];return keyB>keyA?-sortDirection:keyA>keyB?sortDirection:0}),$headers.removeClass("sorted-asc sortd-desc"),$headers.addClass(1==sortDirection?"sorted-asc":"sorted-desc"),$.each(rows,function(index,row){$table.children("tbody").append(row)}),stripe("#plugins-table"),stripe("#sqlite-table"),stripe("#patch-files")}),stripe("#plugins-table"),stripe("#sys-info"),stripe("#sqlite-table"),stripe("#status"),stripe("#patch-files")}),jQuery(document).ready(function($){function stripe(arg){$(arg).find("tr.alt").removeClass("alt");var $args=arg+" tbody";$($args).each(function(){$(this).children(":visible").has("td").filter(function(index){return 1==index%2}).addClass("alt")})}var $table=$("#plugins-info"),$headers=$table.find("thead th").slice(0);$headers.wrapInner('').addClass("sort");var rows=$table.find("tbody > tr").get();$headers.bind("click",function(event){event.preventDefault();var $header=$(this),sortKey=$header.data("sort").key,sortDirection=1;$header.hasClass("sorted-asc")&&(sortDirection=-1),rows.sort(function(a,b){var keyA=$(a).data("table")[sortKey],keyB=$(b).data("table")[sortKey];return keyB>keyA?-sortDirection:keyA>keyB?sortDirection:0}),$headers.removeClass("sorted-asc sortd-desc"),$headers.addClass(1==sortDirection?"sorted-asc":"sorted-desc"),$.each(rows,function(index,row){$table.children("tbody").append(row)}),stripe("#plugins-info")}),stripe("#plugins-info")}); -------------------------------------------------------------------------------- /.sandstorm/app-graphics/wordpress-128.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 34 | -------------------------------------------------------------------------------- /etc/nginx/koi-win: -------------------------------------------------------------------------------- 1 | 2 | charset_map koi8-r windows-1251 { 3 | 4 | 80 88 ; # euro 5 | 6 | 95 95 ; # bullet 7 | 8 | 9A A0 ; # 9 | 10 | 9E B7 ; # · 11 | 12 | A3 B8 ; # small yo 13 | A4 BA ; # small Ukrainian ye 14 | 15 | A6 B3 ; # small Ukrainian i 16 | A7 BF ; # small Ukrainian yi 17 | 18 | AD B4 ; # small Ukrainian soft g 19 | AE A2 ; # small Byelorussian short u 20 | 21 | B0 B0 ; # ° 22 | 23 | B3 A8 ; # capital YO 24 | B4 AA ; # capital Ukrainian YE 25 | 26 | B6 B2 ; # capital Ukrainian I 27 | B7 AF ; # capital Ukrainian YI 28 | 29 | B9 B9 ; # numero sign 30 | 31 | BD A5 ; # capital Ukrainian soft G 32 | BE A1 ; # capital Byelorussian short U 33 | 34 | BF A9 ; # (C) 35 | 36 | C0 FE ; # small yu 37 | C1 E0 ; # small a 38 | C2 E1 ; # small b 39 | C3 F6 ; # small ts 40 | C4 E4 ; # small d 41 | C5 E5 ; # small ye 42 | C6 F4 ; # small f 43 | C7 E3 ; # small g 44 | C8 F5 ; # small kh 45 | C9 E8 ; # small i 46 | CA E9 ; # small j 47 | CB EA ; # small k 48 | CC EB ; # small l 49 | CD EC ; # small m 50 | CE ED ; # small n 51 | CF EE ; # small o 52 | 53 | D0 EF ; # small p 54 | D1 FF ; # small ya 55 | D2 F0 ; # small r 56 | D3 F1 ; # small s 57 | D4 F2 ; # small t 58 | D5 F3 ; # small u 59 | D6 E6 ; # small zh 60 | D7 E2 ; # small v 61 | D8 FC ; # small soft sign 62 | D9 FB ; # small y 63 | DA E7 ; # small z 64 | DB F8 ; # small sh 65 | DC FD ; # small e 66 | DD F9 ; # small shch 67 | DE F7 ; # small ch 68 | DF FA ; # small hard sign 69 | 70 | E0 DE ; # capital YU 71 | E1 C0 ; # capital A 72 | E2 C1 ; # capital B 73 | E3 D6 ; # capital TS 74 | E4 C4 ; # capital D 75 | E5 C5 ; # capital YE 76 | E6 D4 ; # capital F 77 | E7 C3 ; # capital G 78 | E8 D5 ; # capital KH 79 | E9 C8 ; # capital I 80 | EA C9 ; # capital J 81 | EB CA ; # capital K 82 | EC CB ; # capital L 83 | ED CC ; # capital M 84 | EE CD ; # capital N 85 | EF CE ; # capital O 86 | 87 | F0 CF ; # capital P 88 | F1 DF ; # capital YA 89 | F2 D0 ; # capital R 90 | F3 D1 ; # capital S 91 | F4 D2 ; # capital T 92 | F5 D3 ; # capital U 93 | F6 C6 ; # capital ZH 94 | F7 C2 ; # capital V 95 | F8 DC ; # capital soft sign 96 | F9 DB ; # capital Y 97 | FA C7 ; # capital Z 98 | FB D8 ; # capital SH 99 | FC DD ; # capital E 100 | FD D9 ; # capital SHCH 101 | FE D7 ; # capital CH 102 | FF DA ; # capital hard sign 103 | } 104 | -------------------------------------------------------------------------------- /sandstorm/getPublicId.c++: -------------------------------------------------------------------------------- 1 | // Sandstorm - Personal Cloud Sandbox 2 | // Copyright (c) 2014 Sandstorm Development Group, Inc. and contributors 3 | // 4 | 5 | // Hack around stdlib bug with C++14. 6 | #include'; 72 | echo $server_message; 73 | echo '
31 | * define('USE_MYSQL', false);
32 | *
33 | */
34 | if (defined('USE_MYSQL') && USE_MYSQL) return;
35 |
36 | function pdo_log_error($message, $data = null) {
37 | if (strpos($_SERVER['SCRIPT_NAME'], 'wp-admin') !== false) {
38 | $admin_dir = '';
39 | } else {
40 | $admin_dir = 'wp-admin/';
41 | }
42 | die(<<
45 |
46 |
47 | 
$message
54 |$data
55 | 56 | 57 | 58 | HTML 59 | ); 60 | } 61 | 62 | if (version_compare( PHP_VERSION, '5.2.4', '<')) { 63 | pdo_log_error('PHP version on this server is too old.', sprinf("Your server is running PHP version %d but this version of WordPress requires at least 5.2.4", phpversion())); 64 | } 65 | 66 | if (!extension_loaded('pdo')) { 67 | pdo_log_error('PHP PDO Extension is not loaded.', 'Your PHP installation appears to be missing the PDO extension which is required for this version of WordPress.'); 68 | } 69 | 70 | if (!extension_loaded('pdo_sqlite')) { 71 | pdo_log_error('PDO Driver for SQLite is missing.', 'Your PHP installtion appears not to have the right PDO drivers loaded. These are required for this version of WordPress and the type of database you have specified.'); 72 | } 73 | 74 | /* 75 | * Notice: 76 | * Your scripts have the permission to create directories or files on your server. 77 | * If you write in your wp-config.php like below, we take these definitions. 78 | * define('DB_DIR', '/full_path_to_the_database_directory/'); 79 | * define('DB_FILE', 'database_file_name'); 80 | */ 81 | 82 | /* 83 | * PDODIR is SQLite Integration installed directory. 84 | */ 85 | if (defined('WP_PLUGIN_DIR')) { 86 | define('PDODIR', WP_PLUGIN_DIR . '/sqlite-integration/'); 87 | } else { 88 | if (defined('WP_CONTENT_DIR')) { 89 | define('PDODIR', WP_CONTENT_DIR . '/plugins/sqlite-integration/'); 90 | } else { 91 | define('PDODIR', ABSPATH . 'wp-content/plugins/sqlite-integration/'); 92 | } 93 | } 94 | /* 95 | * FQDBDIR is a directory where the sqlite database file is placed. 96 | * If DB_DIR is defined, it is used as FQDBDIR. 97 | */ 98 | if (defined('DB_DIR')) { 99 | if (substr(DB_DIR, -1, 1) != '/') { 100 | define('FQDBDIR', DB_DIR . '/'); 101 | } else { 102 | define('FQDBDIR', DB_DIR); 103 | } 104 | } else { 105 | if (defined('WP_CONTENT_DIR')) { 106 | define('FQDBDIR', WP_CONTENT_DIR . '/database/'); 107 | } else { 108 | define('FQDBDIR', ABSPATH . 'wp-content/database/'); 109 | } 110 | } 111 | /* 112 | * FQDB is a database file name. If DB_FILE is defined, it is used 113 | * as FQDB. 114 | */ 115 | if ( defined('DB_FILE' )) { 116 | define('FQDB', FQDBDIR . DB_FILE); 117 | } else { 118 | define('FQDB', FQDBDIR . '.ht.sqlite'); 119 | } 120 | /* 121 | * UDF_FILE is a file that contains user defined functions. 122 | */ 123 | if (version_compare(PHP_VERSION, '5.3', '<')) { 124 | define('UDF_FILE', PDODIR . 'functions-5-2.php'); 125 | } elseif (version_compare(PHP_VERSION, '5.3', '>=')) { 126 | define('UDF_FILE', PDODIR . 'functions.php'); 127 | } 128 | 129 | require_once PDODIR . 'pdodb.class.php'; 130 | ?> -------------------------------------------------------------------------------- /.sandstorm/sandstorm-pkgdef.capnp: -------------------------------------------------------------------------------- 1 | @0xaecd42915acc793f; 2 | 3 | using Spk = import "/sandstorm/package.capnp"; 4 | 5 | const pkgdef :Spk.PackageDefinition = ( 6 | id = "aax9j672p6z8n7nyupzvj2nmumeqd4upa0f7mgu8gprwmy53x04h", 7 | 8 | manifest = ( 9 | appTitle = (defaultText = "WordPress"), 10 | appVersion = 10, 11 | appMarketingVersion = (defaultText = "2016.06.07 (4.4.2)"), 12 | 13 | metadata = ( 14 | icons = ( 15 | appGrid = (svg = embed "app-graphics/wordpress-128.svg"), 16 | grain = (svg = embed "app-graphics/wordpress-24.svg"), 17 | market = (svg = embed "app-graphics/wordpress-150.svg"), 18 | ), 19 | website = "https://wordpress.org/", 20 | codeUrl = "https://github.com/dwrensha/wordpress-sandstorm", 21 | license = (openSource = gpl2), 22 | categories = [webPublishing,], 23 | author = ( 24 | upstreamAuthor = "WordPress Project", 25 | contactEmail = "david@sandstorm.io", 26 | pgpSignature = embed "pgp-signature", 27 | ), 28 | pgpKeyring = embed "pgp-keyring", 29 | description = (defaultText = embed "description.md"), 30 | shortDescription = (defaultText = "Content management"), 31 | screenshots = [(width = 448, height = 346, png = embed "screenshot1.png"), 32 | (width = 448, height = 348, png = embed "screenshot2.png")], 33 | changeLog = (defaultText = embed "changeLog.md"), 34 | ), 35 | 36 | 37 | 38 | actions = [ 39 | ( title = (defaultText = "New site"), 40 | nounPhrase = (defaultText = "site"), 41 | command = .startCommand 42 | ) 43 | ], 44 | 45 | continueCommand = .continueCommand 46 | ), 47 | 48 | sourceMap = ( 49 | searchPath = [ 50 | ( sourcePath = "."), # Search this directory first. 51 | ( sourcePath = "/opt/app" ), 52 | ( sourcePath = "/", # Then search the system root directory. 53 | hidePaths = [ "home", "proc", "sys", 54 | "etc/nsswitch.conf", "etc/localtime", 55 | "etc/host.conf", "etc/resolv.conf"] 56 | ) 57 | ] 58 | ), 59 | 60 | fileList = "sandstorm-files.list", 61 | 62 | alwaysInclude = ["wordpress-read-only", "read-only-plugins"], 63 | 64 | bridgeConfig = ( 65 | viewInfo = ( 66 | permissions = [(name = "admin", title = (defaultText = "admin"), 67 | description = (defaultText = "allows administrative actions")), 68 | (name = "editor", title = (defaultText = "editor"), 69 | description = (defaultText = "allows publishing of posts of others")), 70 | (name = "author", title = (defaultText = "author"), 71 | description = (defaultText = "allows publishing of own posts")), 72 | (name = "contributor", title = (defaultText = "contributor"), 73 | description = (defaultText = "allows writing of posts")), 74 | (name = "subscriber", title = (defaultText = "subscriber"), 75 | description = (defaultText = "allows profile customization"))], 76 | roles = [(title = (defaultText = "admin"), 77 | permissions = [true, true, true, true, true], 78 | verbPhrase = (defaultText = "can do anything")), 79 | (title = (defaultText = "editor"), 80 | permissions = [false, true, true, true, true], 81 | verbPhrase = (defaultText = "can publish posts of others")), 82 | (title = (defaultText = "author"), 83 | permissions = [false, false, true, true, true], 84 | verbPhrase = (defaultText = "can publish own posts")), 85 | (title = (defaultText = "contributor"), 86 | permissions = [false, false, false, true, true], 87 | verbPhrase = (defaultText = "can write posts"), 88 | default = true), 89 | (title = (defaultText = "subscriber"), 90 | permissions = [false, false, false, false, true], 91 | verbPhrase = (defaultText = "can customize profile"))] 92 | ) 93 | ) 94 | ); 95 | 96 | const startCommand :Spk.Manifest.Command = ( 97 | # Here we define the command used to start up your server. 98 | argv = ["/sandstorm-http-bridge", "10000", "--", "/start.sh"], 99 | environ = [ 100 | # Note that this defines the *entire* environment seen by your app. 101 | (key = "PATH", value = "/usr/local/bin:/usr/bin:/bin") 102 | ] 103 | ); 104 | 105 | const continueCommand :Spk.Manifest.Command = ( 106 | argv = ["/sandstorm-http-bridge", "10000", "--", "/continue.sh"], 107 | environ = [ 108 | (key = "PATH", value = "/usr/local/bin:/usr/bin:/bin") 109 | ] 110 | ); 111 | -------------------------------------------------------------------------------- /.sandstorm/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # Guess at a reasonable name for the VM based on the folder vagrant-spk is 5 | # run from. The timestamp is there to avoid conflicts if you have multiple 6 | # folders with the same name. 7 | VM_NAME = File.basename(File.dirname(File.dirname(__FILE__))) + "_sandstorm_#{Time.now.utc.to_i}" 8 | 9 | # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! 10 | VAGRANTFILE_API_VERSION = "2" 11 | 12 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 13 | # Base on the Sandstorm snapshots of the official Debian 8 (jessie) box. 14 | config.vm.box = "sandstorm/debian-jessie64" 15 | 16 | if Vagrant.has_plugin?("vagrant-vbguest") then 17 | # vagrant-vbguest is a Vagrant plugin that upgrades 18 | # the version of VirtualBox Guest Additions within each 19 | # guest. If you have the vagrant-vbguest plugin, then it 20 | # needs to know how to compile kernel modules, etc., and so 21 | # we give it this hint about operating system type. 22 | config.vm.guest = "debian" 23 | end 24 | 25 | # We forward port 6080, the Sandstorm web port, so that developers can 26 | # visit their sandstorm app from their browser as local.sandstorm.io:6080 27 | # (aka 127.0.0.1:6080). 28 | config.vm.network :forwarded_port, guest: 6080, host: 6080 29 | 30 | # Use a shell script to "provision" the box. This installs Sandstorm using 31 | # the bundled installer. 32 | config.vm.provision "shell", inline: "sudo bash /opt/app/.sandstorm/global-setup.sh", keep_color: true 33 | # Then, do stack-specific and app-specific setup. 34 | config.vm.provision "shell", inline: "sudo bash /opt/app/.sandstorm/setup.sh", keep_color: true 35 | 36 | # Shared folders are configured per-provider since vboxsf can't handle >4096 open files, 37 | # NFS requires privilege escalation every time you bring a VM up, 38 | # and 9p is only available on libvirt. 39 | 40 | # Calculate the number of CPUs and the amount of RAM the system has, 41 | # in a platform-dependent way; further logic below. 42 | cpus = nil 43 | total_kB_ram = nil 44 | 45 | host = RbConfig::CONFIG['host_os'] 46 | if host =~ /darwin/ 47 | cpus = `sysctl -n hw.ncpu`.to_i 48 | total_kB_ram = `sysctl -n hw.memsize`.to_i / 1024 49 | elsif host =~ /linux/ 50 | cpus = `nproc`.to_i 51 | total_kB_ram = `grep MemTotal /proc/meminfo | awk '{print $2}'`.to_i 52 | elsif host =~ /mingw/ 53 | # powershell may not be available on Windows XP and Vista, so wrap this in a rescue block 54 | begin 55 | cpus = `powershell -Command "(Get-WmiObject Win32_Processor -Property NumberOfLogicalProcessors | Select-Object -Property NumberOfLogicalProcessors | Measure-Object NumberOfLogicalProcessors -Sum).Sum"`.to_i 56 | total_kB_ram = `powershell -Command "Get-CimInstance -class cim_physicalmemory | % $_.Capacity}"`.to_i / 1024 57 | rescue 58 | end 59 | end 60 | # Use the same number of CPUs within Vagrant as the system, with 1 61 | # as a default. 62 | # 63 | # Use at least 512MB of RAM, and if the system has more than 2GB of 64 | # RAM, use 1/4 of the system RAM. This seems a reasonable compromise 65 | # between having the Vagrant guest operating system not run out of 66 | # RAM entirely (which it basically would if we went much lower than 67 | # 512MB) and also allowing it to use up a healthily large amount of 68 | # RAM so it can run faster on systems that can afford it. 69 | if cpus.nil? or cpus.zero? 70 | cpus = 1 71 | end 72 | if total_kB_ram.nil? or total_kB_ram < 2048000 73 | assign_ram_mb = 512 74 | else 75 | assign_ram_mb = (total_kB_ram / 1024 / 4) 76 | end 77 | # Actually apply these CPU/memory values to the providers. 78 | config.vm.provider :virtualbox do |vb, override| 79 | vb.cpus = cpus 80 | vb.memory = assign_ram_mb 81 | vb.name = VM_NAME 82 | vb.customize ["modifyvm", :id, "--nictype1", "Am79C973"] 83 | 84 | # /opt/app and /host-dot-sandstorm are used by vagrant-spk 85 | override.vm.synced_folder "..", "/opt/app" 86 | override.vm.synced_folder ENV["HOME"] + "/.sandstorm", "/host-dot-sandstorm" 87 | # /vagrant is not used by vagrant-spk; we need this line so it gets disabled; if we removed the 88 | # line, vagrant would automatically insert a synced folder in /vagrant, which is not what we want. 89 | override.vm.synced_folder "..", "/vagrant", disabled: true 90 | end 91 | config.vm.provider :libvirt do |libvirt, override| 92 | libvirt.cpus = cpus 93 | libvirt.memory = assign_ram_mb 94 | libvirt.default_prefix = VM_NAME 95 | 96 | # /opt/app and /host-dot-sandstorm are used by vagrant-spk 97 | override.vm.synced_folder "..", "/opt/app", type: "9p", accessmode: "passthrough" 98 | override.vm.synced_folder ENV["HOME"] + "/.sandstorm", "/host-dot-sandstorm", type: "9p", accessmode: "passthrough" 99 | # /vagrant is not used by vagrant-spk; we need this line so it gets disabled; if we removed the 100 | # line, vagrant would automatically insert a synced folder in /vagrant, which is not what we want. 101 | override.vm.synced_folder "..", "/vagrant", type: "9p", accessmode: "passthrough", disabled: true 102 | end 103 | end 104 | -------------------------------------------------------------------------------- /read-only-plugins/sqlite-integration/styles/style.css: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is a part of SQLite Integration. 3 | * 4 | * @package SQLite Integration 5 | * @author Kojima Toshiyasu 6 | */ 7 | @CHARSET "UTF-8"; 8 | #sqlite-admin-wrap h2, 9 | #sqlite-admin-side-wrap h2 { 10 | background: rgb(34, 34, 34); 11 | color: rgb(255, 255, 255); 12 | padding-left: 5px; 13 | } 14 | h3 { 15 | clear: both; 16 | } 17 | .navigation { 18 | display: block; 19 | margin-top: 0; 20 | margin-bottom: 0; 21 | min-height: 20px; 22 | } 23 | .navi-menu { 24 | margin-left: 0; 25 | } 26 | .menu-item { 27 | font-size: 20px; 28 | display: inline; 29 | min-width: 150px; 30 | height: 50px; 31 | margin-left: 0; 32 | margin-right: 10px; 33 | padding: 5px; 34 | border: .5px solit #000; 35 | background: rgb(51, 51, 51); 36 | color: (255, 255, 255); 37 | line-height: 40px; 38 | } 39 | .menu-selected { 40 | font-size: 20px; 41 | display: inline; 42 | min-width: 150px; 43 | height: 50px; 44 | margin-left: 0; 45 | margin-right: 10px; 46 | padding: 5px; 47 | border: .5px solit #000; 48 | background: rgb(46, 162, 204); 49 | color: rgb(255, 255, 255); 50 | } 51 | .menu-item a { 52 | text-decoration: none; 53 | color: rgb(255, 255, 255); 54 | } 55 | #sqlite-admin-wrap { 56 | color: #1d1d1d; 57 | font-size: 11pt; 58 | border: 1px solid #ddd; 59 | background: rgb(255, 255, 255); 60 | -webkit-border-bottom-right-radius: 6px; 61 | -webkit-border-bottom-left-radius: 6px; 62 | -moz-border-radius-bottomright: 6px; 63 | -moz-border-radius-bottomleft: 6px; 64 | border-bottom-right-radius: 6px; 65 | border-bottom-left-radius: 6px; 66 | -webkit-border-top-right-radius: 6px; 67 | -webkit-border-top-left-radius: 6px; 68 | -moz-border-radius-topright: 6px; 69 | -moz-border-radius-topleft: 6px; 70 | border-top-right-radius: 6px; 71 | border-top-left-radius: 6px; 72 | display: block; 73 | float: left; 74 | min-height: 100%; 75 | position: relative; 76 | width: 58%; 77 | margin-top: 10px; 78 | padding: 5px; 79 | box-shadow: 5px 5px 5px #eee; 80 | z-index: 1; 81 | } 82 | #wpbody-content > .single { 83 | width: 95%; 84 | } 85 | #sqlite-admin-side-wrap { 86 | color: #1d1d1d; 87 | font-size: 11pt; 88 | border: 1px solid #ddd; 89 | background: rgb(255, 255, 255); 90 | /* border-top: 0; */ 91 | -webkit-border-bottom-right-radius: 6px; 92 | -webkit-border-bottom-left-radius: 6px; 93 | -moz-border-radius-bottomright: 6px; 94 | -moz-border-radius-bottomleft: 6px; 95 | border-bottom-right-radius: 6px; 96 | border-bottom-left-radius: 6px; 97 | -webkit-border-top-right-radius: 6px; 98 | -webkit-border-top-left-radius: 6px; 99 | -moz-border-radius-topright: 6px; 100 | -moz-border-radius-topleft: 6px; 101 | border-top-right-radius: 6px; 102 | border-top-left-radius: 6px; 103 | display: block; 104 | float: left; 105 | min-height: 100%; 106 | position: relative; 107 | width: 35%; 108 | margin-top: 10px; 109 | padding: 5px 5px 5px 5px; 110 | box-shadow: 5px 5px 5px #eee; 111 | z-index: 1; 112 | } 113 | p { 114 | text-indent: 15px; 115 | line-height: 160%; 116 | font-size: 11pt; 117 | margin-left: 10px; 118 | margin-right: 10px; 119 | } 120 | li { 121 | line-height: 130%; 122 | } 123 | table#sys-info{ 124 | /* width: 600px; */ 125 | width: 80%; 126 | } 127 | table#status { 128 | width: 100%; 129 | } 130 | table#sqlite-table { 131 | /* width: 700px; */ 132 | width: 100%; 133 | } 134 | th.tbl-name { 135 | width: 25%; 136 | } 137 | th.tbl_owner { 138 | width: 25%; 139 | } 140 | th.tbl_index { 141 | width: 50%; 142 | } 143 | td.system { 144 | color: rgb(153, 0, 0); 145 | } 146 | td.user { 147 | color: rgb(0, 0, 255); 148 | } 149 | td.menu-title { 150 | width: 95px; 151 | } 152 | table.statement { 153 | width: 500px; 154 | } 155 | ul.in-body-list { 156 | margin-left: 20px; 157 | } 158 | ol { 159 | margin-left: 40px; 160 | } 161 | pre.code { 162 | padding: 5px 5px 5px 5px; 163 | margin-left: 15px; 164 | margin-right: 10px; 165 | background: #eee; 166 | white-space: pre-wrap; 167 | word-wrap: break-word; 168 | overflow: auto; 169 | } 170 | tr.incompatible { 171 | background: rgb(251, 229, 221); 172 | } 173 | tr.workaround { 174 | background: rgb(217, 232, 237); 175 | } 176 | tr.compatible { 177 | } 178 | th.active-plugins { 179 | width: 20%; 180 | } 181 | th.compatible { 182 | width: 30%; 183 | } 184 | input.button-primary { 185 | display: block; 186 | clear: both; 187 | width: 100px; 188 | } 189 | .alt { 190 | background: rgb(247, 254, 236); 191 | } 192 | .em { 193 | font-weight: bold; 194 | text-transform: capitalize; 195 | } 196 | table#patch-files .item, 197 | table#backup-files .item { 198 | width: 150px; 199 | } 200 | .alert { 201 | color: rgb(255, 0, 0); 202 | } 203 | div.alert { 204 | display: block; 205 | width: 95%; 206 | text-align: center; 207 | margin: 0 auto; 208 | color: rgb(255, 0, 0); 209 | text-transform: capitalize; 210 | } 211 | blockquote.caution { 212 | display: block; 213 | width: 95%; 214 | border: 3px double rgb(0, 0, 0); 215 | margin: 0 auto; 216 | padding: 5px; 217 | } 218 | blockquote.caution > p { 219 | margin: 5px; 220 | padding: 0; 221 | } 222 | #errorlog, 223 | #dbfile { 224 | width: 100%; 225 | } 226 | /* 227 | * Media Query 228 | */ 229 | @media screen and (max-width: 600px) { 230 | #sqlite-admin-wrap { 231 | width: 95%; 232 | } 233 | #sqlite-admin-side-wrap { 234 | width: 95%; 235 | } 236 | #sqlite-admin-wrap > table#sys-info{ 237 | width: 100%; 238 | } 239 | table#sys-info th.item { 240 | width: 50% 241 | } 242 | #sqlite-admin-wrap > table#status { 243 | width: 100%; 244 | } 245 | table#status th { 246 | width: 50%; 247 | } 248 | table#sqlite-table { 249 | width: 100%; 250 | } 251 | th.tbl-name { 252 | width: 25%; 253 | } 254 | th.tbl_owner { 255 | width: 25%; 256 | } 257 | th.tbl_index { 258 | width: 50%; 259 | } 260 | #sqlite-admin-side-wrap table#plugins-info { 261 | width: 100%; 262 | } 263 | th.installed-plugins { 264 | width: 50%; 265 | } 266 | th.active-plugins { 267 | width: 20%; 268 | } 269 | th.compatible { 270 | width: 30%; 271 | } 272 | #sqlite-admin-side-wrap > table#plugins-table { 273 | width: 100%; 274 | } 275 | #sqlite-admin-side-wrap > table#plugins-table th.item { 276 | width: 30%; 277 | } 278 | #sqlite-admin-side-wrap > table#plugins-table th.compat { 279 | width: 20%; 280 | } 281 | #sqlite-admin-side-wrap > table#plugins-table th.reason { 282 | width: 50%; 283 | } 284 | } 285 | @media screen and (max-width: 782px) { 286 | #sqlite-admin-wrap { 287 | width: 95%; 288 | } 289 | #sqlite-admin-side-wrap { 290 | width: 95%; 291 | } 292 | table#plugins-info { 293 | width: 480px; 294 | } 295 | table#sqlite-table { 296 | width: 100%; 297 | } 298 | th.tbl-name { 299 | width: 25%; 300 | } 301 | th.tbl_owner { 302 | width: 25%; 303 | } 304 | th.tbl_index { 305 | width: 50%; 306 | } 307 | #plugins-table { 308 | width: 500px; 309 | } 310 | } 311 | @media screen and (max-width: 900px) { 312 | #sqlite-admin-wrap { 313 | width: 95%; 314 | } 315 | #sqlite-admin-side-wrap { 316 | width: 95%; 317 | } 318 | table#plugins-info { 319 | width: 480px; 320 | } 321 | table#sqlite-table { 322 | width: 100%; 323 | } 324 | th.tbl-name { 325 | width: 25%; 326 | } 327 | th.tbl_owner { 328 | width: 25%; 329 | } 330 | th.tbl_index { 331 | width: 50%; 332 | } 333 | #plugins-table { 334 | width: 500px; 335 | } 336 | } 337 | @media screen and (max-width: 1169px) { 338 | #sqlite-admin-wrap { 339 | width: 95%; 340 | } 341 | #sqlite-admin-side-wrap { 342 | width: 95%; 343 | } 344 | table#plugins-info { 345 | width: 480px; 346 | } 347 | table#sys-info { 348 | width: 460px; 349 | } 350 | table#status { 351 | width: 460px; 352 | } 353 | table#sqlite-table { 354 | width: 100%; 355 | } 356 | th.tbl-name { 357 | width: 25%; 358 | } 359 | th.tbl_owner { 360 | width: 25%; 361 | } 362 | th.tbl_index { 363 | width: 50%; 364 | } 365 | #plugins-table { 366 | width: 500px; 367 | } 368 | } -------------------------------------------------------------------------------- /read-only-plugins/mu-plugins/sandstorm.php: -------------------------------------------------------------------------------- 1 | $sandstorm_user_id, 34 | 'user_pass' => 'garply', 35 | 'nickname' => $username, 36 | 'display_name' => $username, 37 | 'role' => get_option('default_role'), 38 | 'user_email' => ($sandstorm_user_id . '@example.com'))); 39 | } else { 40 | $user_id = $user->ID; 41 | } 42 | 43 | $user_role=''; 44 | if (in_array('admin', $permissionsArray)) { 45 | $user_role = 'administrator'; 46 | } else if (in_array('editor', $permissionsArray)) { 47 | $user_role = 'editor'; 48 | } else if (in_array('author', $permissionsArray)) { 49 | $user_role = 'author'; 50 | } else if (in_array('contributor', $permissionsArray)) { 51 | $user_role = 'contributor'; 52 | } else if (in_array('subscriber', $permissionsArray)) { 53 | $user_role = 'subscriber'; 54 | } 55 | 56 | if ($user_role) { 57 | wp_update_user( array( 'ID' => $user_id, 58 | 'role' => $user_role)); 59 | } 60 | 61 | if ($headers['X-Sandstorm-User-Picture']) { 62 | update_user_meta( $user_id, 'sandstorm_user_picture', $headers['X-Sandstorm-User-Picture']); 63 | } 64 | 65 | wp_set_current_user($user_id, $sandstorm_user_id); 66 | wp_set_auth_cookie($user_id); 67 | do_action('wp_login', $sandstorm_user_id); 68 | } 69 | } 70 | } 71 | add_action('init', 'auto_login'); 72 | 73 | function sandstorm_refuse_login() { 74 | wp_redirect(wp_guess_url() . '/index.php'); 75 | die(); 76 | } 77 | 78 | add_action('login_init', 'sandstorm_refuse_login'); 79 | 80 | function sandstorm_publish() { 81 | $result = shell_exec('/publish-it.sh'); 82 | } 83 | 84 | 85 | function sandstorm_publishing_info() { 86 | $headers = apache_request_headers(); 87 | $lines = array(); 88 | $result = exec('/sandstorm/bin/getPublicId ' . $headers['X-Sandstorm-Session-Id'], $lines); 89 | 90 | echo "Your public site is available at: $lines[2]
"; 91 | 92 | ?> 93 | 94 |95 | To rebuild your public site, click the below button. 96 | Note that you must click this button after making any changes 97 | in order for those changes to become visible on the public site. 98 |
99 | 100 | 108 | 109 | 110 | If you weren't using a demo account, you could additionally publish the site to an arbitrary domain you control."; 114 | return; 115 | } 116 | 117 | ?> 118 | 119 | To set up your domain to point at your public site,
120 | add the following DNS records to your domain. Replace host.example.com with your site's hostname.
121 |
131 | Note: If your site may get a lot of traffic, consider putting it behind a CDN. 132 | CloudFlare, for example, can do this for free. 133 |
134 | 135 | '. 191 | ''. 192 | ''. 193 | ''. 194 | ''; 197 | return $form; 198 | } 199 | } 200 | 201 | add_filter('editable_roles', 'sandstorm_editable_roles'); 202 | function sandstorm_editable_roles($orig) { 203 | // None should be editable because Sandstorm handles role assignment. 204 | return array(); 205 | } 206 | 207 | 208 | add_filter('get_avatar', 'sandstorm_get_avatar', 1, 5); 209 | function sandstorm_get_avatar($avatar, $id_or_email, $size, $default, $alt) { 210 | if (is_numeric($id_or_email)) { 211 | $avatar_url = get_user_meta($id_or_email, 'sandstorm_user_picture', True); 212 | if ($avatar_url) { 213 | $avatar = "40 | SQLite Integration page.', $domain);?> 41 |
42 |43 | 44 |
45 | 46 | 47 |48 | PDO for WordPress, which enabled WordPress to use SQLite for its database. But PDO for WordPress doesn\'t seem to be maintained any more only to be outdated. SQLite Integration makes use of the basic ideas and framework of PDO for WordPress, adds some new features and updates it to be able to work with the newest version of WordPress(3.8.1).', $domain); ?> 49 |
50 |51 | SQLite Web Page says — SQLite is a "software library that implements selfcontained, serverless, zero-configuration, transactional SQL database engine". It is "a good choice for small to medium size websites". It\'s small and portable, and you don\'t need any database server system.', $domain); ?> 52 |
53 |54 | 55 |
56 |57 | 58 |
59 |68 | 69 |
70 | 71 | 72 |73 | 74 |
75 |82 | Support Forum.', $domain);?> 83 |
84 | 85 |86 | 87 |
88 |89 | 90 |
91 | 92 | 93 |94 | 95 |
96 |101 | 102 |
103 |109 | 110 |
111 |112 | System Info page. To see more details, please visit the Plugin Page.', $domain), $utils->show_parent());?> 113 |
114 | 115 |WordPress database error: [$str]
174 | $query
We have been unable to connect to the specified database.
The error message received was %s"), $this->dbh->errorInfo()));
212 | return;
213 | }
214 | $is_enabled_foreign_keys = @$this->get_var('PRAGMA foreign_keys');
215 | if ($is_enabled_foreign_keys == '0') @$this->query('PRAGMA foreign_keys = ON');
216 | $this->has_connected = true;
217 | $this->ready = true;
218 | }
219 | /**
220 | * Method to dummy out wpdb::check_connection()
221 | *
222 | */
223 | public function check_connection($allow_bail=true) {
224 | return true;
225 | }
226 | /**
227 | * Method to execute the query.
228 | *
229 | * This overrides wpdb::query(). In fact, this method does all the database
230 | * access jobs.
231 | *
232 | * @see wpdb::query()
233 | */
234 | public function query($query) {
235 | if (!$this->ready)
236 | return false;
237 |
238 | $query = apply_filters('query', $query);
239 |
240 | $return_val = 0;
241 | $this->flush();
242 |
243 | $this->func_call = "\$db->query(\"$query\")";
244 |
245 | $this->last_query = $query;
246 |
247 | if (defined('SAVEQUERIES') && SAVEQUERIES)
248 | $this->timer_start();
249 |
250 | $this->result = $this->dbh->query($query);
251 | $this->num_queries++;
252 |
253 | if (defined('SAVEQUERIES') && SAVEQUERIES)
254 | $this->queries[] = array($query, $this->timer_stop(), $this->get_caller());
255 |
256 | if ($this->last_error = $this->dbh->get_error_message()) {
257 | if (defined('WP_INSTALLING') && WP_INSTALLING) {
258 | //$this->suppress_errors();
259 | } else {
260 | $this->print_error($this->last_error);
261 | return false;
262 | }
263 | }
264 |
265 | if (preg_match('/^\\s*(create|alter|truncate|drop|optimize)\\s*/i', $query)) {
266 | //$return_val = $this->result;
267 | $return_val = $this->dbh->get_return_value();
268 | } elseif (preg_match('/^\\s*(insert|delete|update|replace)\s/i', $query)) {
269 | $this->rows_affected = $this->dbh->get_affected_rows();
270 | if (preg_match('/^\s*(insert|replace)\s/i', $query)) {
271 | $this->insert_id = $this->dbh->get_insert_id();
272 | }
273 | $return_val = $this->rows_affected;
274 | } else {
275 | $this->last_result = $this->dbh->get_query_results();
276 | $this->num_rows = $this->dbh->get_num_rows();
277 | $return_val = $this->num_rows;
278 | }
279 | return $return_val;
280 | }
281 | /**
282 | * Method for future use?
283 | *
284 | * WordPress 3.9 separated the method to execute real query from query() function.
285 | * This is for the restoration from the case that nothing returns from database.
286 | * But this is necessary because we aleady did error manipulations in
287 | * pdoengine.class.php. So we don't use this function.
288 | *
289 | * @access private
290 | */
291 | private function _do_query($query) {
292 | if (defined('SAVEQUERIES') && SAVEQUERIES) {
293 | $this->timer_start();
294 | }
295 | $this->result = $this->dbh->query($query);
296 | $this->num_queries++;
297 | if (defined('SAVEQUERIES') && SAVEQUERIES) {
298 | $this->queries[] = array($query, $this->timer_stop(), $this->get_caller());
299 | }
300 | }
301 | /**
302 | * Method to set the class variable $col_info.
303 | *
304 | * This overrides wpdb::load_col_info(), which uses a mysql function.
305 | *
306 | * @see wpdb::load_col_info()
307 | * @access protected
308 | */
309 | protected function load_col_info() {
310 | if ($this->col_info)
311 | return;
312 | $this->col_info = $this->dbh->get_columns();
313 | }
314 |
315 | /**
316 | * Method to return what the database can do.
317 | *
318 | * This overrides wpdb::has_cap() to avoid using MySQL functions.
319 | * SQLite supports subqueries, but not support collation, group_concat and set_charset.
320 | *
321 | * @see wpdb::has_cap()
322 | */
323 | public function has_cap($db_cap) {
324 | switch(strtolower($db_cap)) {
325 | case 'collation':
326 | case 'group_concat':
327 | case 'set_charset':
328 | return false;
329 | case 'subqueries':
330 | return true;
331 | default:
332 | return false;
333 | }
334 | }
335 | /**
336 | * Method to return database version number.
337 | *
338 | * This overrides wpdb::db_version() to avoid using MySQL function.
339 | * It returns mysql version number, but it means nothing for SQLite.
340 | * So it return the newest mysql version.
341 | *
342 | * @see wpdb::db_version()
343 | */
344 | public function db_version() {
345 | //global $required_mysql_version;
346 | //return $required_mysql_version;
347 | return '5.5';
348 | }
349 | }
350 |
351 | /*
352 | * Initialize $wpdb with PDODB class
353 | */
354 | if (!isset($wpdb)) {
355 | global $wpdb;
356 | $wpdb = new PDODB();
357 | }
358 | ?>
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
--------------------------------------------------------------------------------
/read-only-plugins/sqlite-integration/readme.txt:
--------------------------------------------------------------------------------
1 | === SQLite Integration ===
2 | Contributors: kjmtsh
3 | Plugin Name: SQLite Integration
4 | Plugin URI: http://dogwood.skr.jp/wordpress/sqlite-integration/
5 | Tags: database, SQLite, PDO
6 | Author: Kojima Toshiyasu
7 | Author URI: http://dogwood.skr.jp/
8 | Requires at least: 3.3
9 | Tested up to: 4.0
10 | Stable tag: 1.7
11 | License: GPLv2
12 | License URI: http://www.gnu.org/licenses/gpl-2.0.html
13 |
14 | SQLite Integration is the plugin that enables WordPress to use SQLite. If you want to build a WordPress website with it, this plugin is for you.
15 |
16 | == Description ==
17 |
18 | This plugin enables you to create WordPress based web sites without MySQL database server. All you've got to prepare is the Apache web server or the like and PHP with PDO extension. WordPress archive and this plugin in hand, you can build a WordPress web site out of the box.
19 |
20 | SQLite Integration is a successor to [PDO for WordPress](http://wordpress.org/extend/plugins/pdo-for-wordpress) plugin, which unfortunately enough, doesn't seem to be maintained any more. SQLite Integration uses the basic idea and structures of that plugin and adds some utilities with more features.
21 |
22 | = Features =
23 |
24 | SQLite Integration is a database access engine program. So it's not like the other plugins. It must be used to install WordPress. Please read the install section. And see more detailed instruction in the [SQLite Integration Page](http://dogwood.skr.jp/wordpress/sqlite-integration/).
25 |
26 | Once you succeed in installing WordPress, you can use it just like the other systems using MySQL. Optionally, this plugin provides the feature to temporarily change the database to MySQL and come back to SQLite, which may help developers test their sites on the local machines without MySQL.
27 |
28 | After you finish installing, you can activate this plugin (this is optional but I recommend you to). And you can see some instructions and useful information on your server or your installed plugins.
29 |
30 | = System Requirements =
31 |
32 | * PHP 5.2 or newer with PDO extension (PHP 5.3 or newer is better).
33 | * PDO SQLite driver must be loaded.
34 |
35 | = Backward Compatibility =
36 |
37 | If you are using 'PDO for WordPress', you can migrate your database to this plugin. Please check the install section.
38 |
39 | = Support =
40 |
41 | Please contact us with the methods below:
42 |
43 | 1. Post to [Support Forum](http://wordpress.org/support/plugin/sqlite-integration/).
44 | 2. Visit the [SQLite Integration Page](http://dogwood.skr.jp/wordpress/sqlite-integration/)(in English) or [SQLite Integration(ja) Page](http://dogwood.skr.jp/wordpress/sqlite-integration-ja/)(in Japanese) and leave a message there.
45 |
46 | = Notes about Support =
47 |
48 | WordPress.org doesn't officially support using any other database than MySQL. So you will have no supports from WordPress.org. Even if you post to the general Forum, you'll have few chances to get the answer. And if you use patched plugins, you will have no support from the plugin author(s), eithter. I will help you as much as I can, but take your own risk, please.
49 |
50 | = Translation =
51 |
52 | Documentation is written in English. If you translate it into your language, please let me know.
53 |
54 | * Japanese (kjmtsh)
55 | * Spanish (Pablo Laguna)
56 |
57 | == Installation ==
58 |
59 | For more detailed instruction, please visit [SQLite Integration](http://dogwood.skr.jp/wordpress/sqlite-integration/).
60 |
61 | = Preparation =
62 |
63 | 1. Download the latest WordPress archive and this plugin. And expand them on your machine.
64 | 2. Move sqlite-integration folder to wordpress/wp-content/plugins folder.
65 | 3. Copy db.php file in sqlite-integratin folder to wordpress/wp-content folder.
66 | 4. Rename wordpress/wp-config-sample.php to wordpress/wp-config.php.
67 |
68 | = Basic settings =
69 |
70 | Open wp-config.php and edit the section below:
71 |
72 | * Authentication Unique keys and Salts
73 | * WordPress Database Table prefix
74 | * WordPress Localized Language
75 |
76 | See also [Editing wp-config.php](http://codex.wordpress.org/Editing_wp-config.php) in the Codex. Note that you don't have to write your database server, user name, user password or etc...
77 |
78 | = Less than 5 minutes installation =
79 |
80 | Upload everything (keeping the directory structure) to your server and access the wp-admin/install.php with your favorite browser, and WordPress installation process will begin. Enjoy your blogging!
81 |
82 | = Optional settings =
83 |
84 | You can change some default settings with the directives in wp-config.php.If you change the SQLite database file name (default is .ht.sqlite) to others, add the next line in your wp-config.php.
85 |
86 | `define('DB_FILE', 'your_database_name');`
87 |
88 | If you change the directory where the SQLite database is put, add the next line in your wp-config.php.
89 |
90 | `define('DB_DIR', '/home/youraccount/database_directory/');`
91 |
92 | You can change either of them or both of them.
93 |
94 | = Use MySQL without uninstalling this plugins =
95 |
96 | If you want to use MySQL, add the next line in your wp-config.php.
97 |
98 | `define('USE_MYSQL', true);`
99 |
100 | Of course, this is not enough. You must give your database server address, user name, passowrd or etc... in the same file. After you add that line and access your web site for the first time, WordPress installer will begin. Then you must finish setting MySQL database. As you know, data in the SQLite database is not automatically migrated to MySQL.
101 |
102 | If you want to use SQLite again, change the line in wp-config.php as below or just remove this line.
103 |
104 | `define('USE_MYSQL', false);`
105 |
106 | = For PDO for WordPress users =
107 |
108 | If you are using PDO for WordPress now, you can migrate your database to SQLite Integration. I recommend the way below. See more detailed instruction [SQLite Integration](http://dogwood.skr.jp/wordpress/sqlite-integration/).
109 |
110 | 1. Export your data from current database.
111 | 2. Install latest WordPress with SQLite Integration.
112 | 3. Import the old data.
113 |
114 | If export or import fails for some reason, please visit our site and try another way described there.
115 |
116 | == Frequently Asked Questions ==
117 |
118 | = Install stops with 'Error establishing a database connection' =
119 |
120 | It is required that you should prepare wp-config.php manually. If you try to make WordPress create wp-config.php, you'll get that message and can't continue install process.
121 |
122 | = Database file is not created =
123 |
124 | The reason of failure in creating directory or files is often that PHP is not allowed to craete them. Please check your server setting or ask the administrator.
125 |
126 | = Such and such plugins can't be activated or doesn't seem to work properly =
127 |
128 | Some of the plugins, especially cache plugins or database maintenace plugins, are not compatible with this plugin. Please activate SQLite Integration and see the known limitations section in this document or visit the [SQLite Integration](http://dogwood.skr.jp/wordpress/sqlite-integration/) for more detailed information.
129 |
130 | = I don't want the admin menu and documentation =
131 |
132 | Just deactivate the plugin, and you can remove them. Activation and deactivation affect only admin menu. If you want to remove all the plugin files, just delete it.
133 |
134 | == Screenshots ==
135 |
136 | 1. System Information tells you your database status and installed plugins compatibility.
137 |
138 | == Known Limitations ==
139 |
140 | Many of the other plugins will work fine with this plugin. But there are some you can't use. Generally speaking, the plugins that manipulate database not with WordPress' APIs but with MySQL or MySQLi native drivers from PHP might cause the problem.
141 |
142 | These are some examples:
143 |
144 | You can't use these plugins because they create the same file that this plugin uses.
145 |
146 | * W3 Total Cache
147 | * DB Cache Reloaded Fix
148 | * HyperDB
149 |
150 | You may be able to use 'WP Super Cache' or 'Quick Cache' instead of them. I don't mean to recommend them and give no warranty at all.
151 |
152 | You can't use these plugins, because they are using MySQL specific features that SQLite Integration can't emulate.
153 |
154 | * Yet Another Related Posts
155 | * Better Related Posts
156 |
157 | You may be able to use 'WordPress Related Posts' or 'Related Posts' instead of them. Probably there are more, I'm afraid. If you find one, please let me know.
158 |
159 | There are some among the incompatible plugins, which work fine by rewriting some codes. I give information about them and provide the patch files on [Plugins](http://dogwood.skr.jp/wordpress/plugins/).
160 |
161 | This plugin doesn't support 'WP_PLUGIN_URL' constant.
162 |
163 | == Upgrade Notice ==
164 |
165 | WordPress 4.0 compatibility is checked and some bugs are fixed. Upgrade is recommended. When auto upgrading fails, please try manual upgrade via FTP.
166 |
167 | == Changelog ==
168 |
169 | = 1.7 (2014-09-05) =
170 | * Fixed the bug about changing the order of the attachment file in the editor screen.
171 | * Fixed the bug about the manipulation of CREATE query.
172 | * Added an 128x128 icon and 256x256 icon.
173 | * Change for checking the user defined value of pcre.backtrack_limit and using it.
174 | * WordPress 4.0 compatibilitiy checked.
175 |
176 | = 1.6.3 (2014-05-10) =
177 | * Fixed the bug about manipulating meta query with BETWEEN comparison.
178 | * Added the Spanish langugae support.
179 | * WordPress 3.9.1 compatibility checked.
180 |
181 | = 1.6.2 (2014-05-05) =
182 | * Fixed some bugs for the regular expression.
183 | * Fixed the documents on the admin dashboard.
184 |
185 | = 1.6.1 (2014-04-22) =
186 | * Fixed some bugs for using with WP Slimstat plugin.
187 | * Display admin notice when not replacing the old db.php with the new one (when necessary).
188 | * Add the feature for replacing the old db.php file with the button click.
189 | * Fixed the Japanese translation catalog file.
190 |
191 | = 1.6 (2014-04-17) =
192 | * Fixed the bug of error messaging control for the unknown query.
193 | * Fixed the bug for 'SQL_CALC_FOUND_ROW' statement. This is for the main query, WP_Query class and WP_Meta_Query concerning paging information.
194 | * Fixed the bug that the back quote in the comments was removed.
195 | * Added the feature to download a backup file to a local machine.
196 | * Revised all the doc strings in the sourcse code for PHP documentor.
197 | * Changed the documentation.
198 | * Fixed minor bugs and typos.
199 | * Tested to install WordPress 3.8.2 and 3.9 beta.
200 | * Augumented the plugin compatibility list.
201 | * Some functions in wp-db.php, which was disabled by the plugin, is enabled and can be used.
202 | * Some more user defined functions are added.
203 |
204 | = 1.5 (2013-12-17) =
205 | * Tested WordPress 3.8 installation and compatibility.
206 | * Add the optional feature to change the database from SQLite to MySQL.
207 | * Changed the install instruction in the readme.txt.
208 | * Add the code to check if the SQLite library was compiled with the option 'ENABLE_UPDATE_DELETE_LIMIT'.
209 | * Changed the admin panel style to fit for WordPress 3.8.
210 | * Restricted the direct access to the files that works in the global namespace.
211 |
212 | = 1.4.2 (2013-11-06) =
213 | * Fixed some minor bugs about the information in the dashboard.
214 | * Changed the screenshot.
215 | * Tested WordPress 3.7.1 installation.
216 |
217 | = 1.4.1 (2013-09-27) =
218 | * Fixed the rewriting process of BETWEEN function. This is a critical bug. When your newly created post contains 'between A and B' phrase, it is not published and disappears.
219 | * Fixed the admin dashboard display when using MP6.
220 | * Fixed the Japanese catalog.
221 | * Added the procedure for returning the dummy data when using SELECT version().
222 | * Added the procedure for displaying column informatin of WordPress tables when WP_DEBUG enabled.
223 |
224 | = 1.4 (2013-09-12) =
225 | * Added the database maintenance utility for fixing the database malfunction of the upgraded WordPress installation.
226 | * Changed the manipulation of SHOW INDEX query with WHERE clause.
227 | * Fixed the bug of the manipulation of ALTER TABLE query.
228 |
229 | = 1.3 (2013-09-04) =
230 | * Added the backup utility that creates the zipped archive of the current snapshot of the database file.
231 | * Changed the dashboard style to match MP6 plugin.
232 | * Changed the way of putting out the error messages when language catalogs are not loaded.
233 | * Modified the _rewrite_field_types() in query_create.class.php for the dbDelta() function to work properly.
234 | * Added the support for BETWEEN statement.
235 | * Changed the regular expression to remove all the index hints from the query string.
236 | * Fixed the manipulation of ALTER TABLE CHANGE COLUMN query for NewStatPress plugin to work.
237 | * Fixed minor bugs.
238 |
239 | = 1.2.1 (2013-08-04) =
240 | * Removed wpdb::real_escape property following the change of the wpdb.php file which makes the plugin compatible with Wordpress 3.6.
241 |
242 | = 1.2 (2013-08-03) =
243 | * Fixed the date string format and its quotation for calendar widget.
244 | * Fixed the patch utility program for using on the Windows machine.
245 | * Fixed the textdomain error in utilities/patch.php file when uploading the patch file.
246 | * Changed the manipulation of the query with ON DUPLICATE KEY UPDATE.
247 | * Fixed the typos in readme.txt and readme-ja.txt.
248 |
249 | = 1.1 (2013-07-24) =
250 | * Fixed the manipulation of DROP INDEX query.
251 | * Removed destruct() from shutdown_hook.
252 | * Enabled LOCATE() function in the query string.
253 |
254 | = 1.0 (2013-07-07) =
255 | * First release version of the plugin.
256 |
--------------------------------------------------------------------------------
/read-only-plugins/sqlite-integration/sqlite-integration.php:
--------------------------------------------------------------------------------
1 | blogid;
142 | $blog_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
143 | foreach ($blog_ids as $blog_id) {
144 | switch_to_blog($blog_id);
145 | $this->_install();
146 | }
147 | switch_to_blog($old_blog);
148 | return;
149 | } else {
150 | $this->_install();
151 | return;
152 | }
153 | }
154 |
155 | /**
156 | * Method to install something.
157 | *
158 | * We have nothing to do for now.
159 | * We show menu and documents only to the network administrator.
160 | *
161 | * @param no parameter is provided.
162 | * @return no return values.
163 | */
164 | function _install() {
165 | }
166 |
167 | /**
168 | * Method to uninstall plugin.
169 | *
170 | * This will remove wp-content/db.php and wp-content/patches direcotry.
171 | * If you migrate the site to the sever with MySQL, you have only to
172 | * migrate the data in the database.
173 | *
174 | * @param no parameter is provided.
175 | * @return no return values.
176 | */
177 | function uninstall() {
178 | // remove patch files and patch directory
179 | if (file_exists(SQLitePatchDir) && is_dir(SQLitePatchDir)) {
180 | $dir_handle = opendir(SQLitePatchDir);
181 | while (($file_name = readdir($dir_handle)) !== false) {
182 | if ($file_name != '.' && $file_name != '..') {
183 | unlink(SQLitePatchDir.'/'.$file_name);
184 | }
185 | }
186 | rmdir(SQLitePatchDir);
187 | }
188 | // remove wp-content/db.php
189 | if (defined('WP_CONTENT_DIR')) {
190 | $target = WP_CONTENT_DIR . 'db.php';
191 | } else {
192 | $target = ABSPATH . 'wp-content/db.php';
193 | }
194 | if (file_exists($target)) {
195 | unlink($target);
196 | }
197 | }
198 |
199 | /**
200 | * Method to manipulate the admin panel, stylesheet and JavaScript.
201 | *
202 | * We use class method to show pages and want to load style files and script
203 | * files only in our plugin documents, so we need add_submenu_page with parent
204 | * slug set to null. This means that menu items are added but hidden from the
205 | * users.
206 | *
207 | * @param no parameter is provided.
208 | * @return no return values.
209 | */
210 | function add_pages() {
211 | global $utils, $doc, $patch_utils, $maintenance;
212 | if (function_exists('add_options_page')) {
213 | $welcome_page = add_options_page(__('SQLite Integration'), __('SQLite Integration'), 'manage_options', 'sqlite-integration', array($utils, 'welcome'));
214 | $util_page = add_submenu_page(null, 'System Info', 'System Info', 'manage_options', 'sys-info', array($utils, 'show_utils'));
215 | $edit_db = add_submenu_page(null, 'Setting File', 'Setting File', 'manage_options', 'setting-file', array($utils, 'edit_db_file'));
216 | $doc_page = add_submenu_page(null, 'Documentation', 'Documentation', 'manage_options', 'doc', array($doc, 'show_doc'));
217 | $patch_page = add_submenu_page(null, 'Patch Utility', 'Patch Utility', 'manage_options', 'patch', array($patch_utils, 'show_patch_page'));
218 | $maintenance_page = add_submenu_page(null, 'DB Maintenance', 'DB Maintenance', 'manage_options', 'maintenance', array($maintenance, 'show_maintenance_page'));
219 | add_action('admin_print_styles-'.$welcome_page, array($this, 'add_style_sheet'));
220 | add_action('admin_print_styles-'.$util_page, array($this, 'add_style_sheet'));
221 | add_action('admin_print_styles-'.$edit_db, array($this, 'add_style_sheet'));
222 | add_action('admin_print_styles-'.$doc_page, array($this, 'add_style_sheet'));
223 | add_action('admin_print_styles-'.$patch_page, array($this, 'add_style_sheet'));
224 | add_action('admin_print_scripts-'.$util_page, array($this, 'add_sqlite_script'));
225 | add_action('admin_print_scripts-'.$doc_page, array($this, 'add_sqlite_script'));
226 | add_action('admin_print_scripts-'.$patch_page, array($this, 'add_sqlite_script'));
227 | add_action('admin_print_scripts-'.$edit_db, array($this, 'add_sqlite_script'));
228 | add_action('admin_print_styles-'.$maintenance_page, array($this, 'add_style_sheet'));
229 | }
230 | }
231 |
232 | /**
233 | * Method to manipulate network admin panel.
234 | *
235 | * Capability is set to manage_network_options.
236 | *
237 | * @param no parameter is provided.
238 | * @return no return values.
239 | */
240 | function add_network_pages() {
241 | global $utils, $doc, $patch_utils, $maintenance;
242 | if (function_exists('add_options_page')) {
243 | $welcome_page = add_submenu_page('settings.php', __('SQLite Integration'), __('SQLite Integration'), 'manage_network_options', 'sqlite-integration', array($utils, 'welcome'));
244 | $util_page = add_submenu_page(null, 'System Info', 'System Info', 'manage_network_options', 'sys-info', array($utils, 'show_utils'));
245 | $edit_db = add_submenu_page(null, 'Setting File', 'Setting File', 'manage_network_options', 'setting-file', array($utils, 'edit_db_file'));
246 | $doc_page = add_submenu_page(null, 'Documentation', 'Documentation', 'manage_network_options', 'doc', array($doc, 'show_doc'));
247 | $patch_page = add_submenu_page(null, 'Patch Utility', 'Patch Utility', 'manage_network_options', 'patch', array($patch_utils, 'show_patch_page'));
248 | $maintenance_page = add_submenu_page(null, 'DB Maintenance', 'DB Maintenance', 'manage_network_options', 'maintenance', array($maintenance, 'show_maintenance_page'));
249 | add_action('admin_print_styles-'.$welcome_page, array($this, 'add_style_sheet'));
250 | add_action('admin_print_styles-'.$util_page, array($this, 'add_style_sheet'));
251 | add_action('admin_print_styles-'.$edit_db, array($this, 'add_style_sheet'));
252 | add_action('admin_print_styles-'.$doc_page, array($this, 'add_style_sheet'));
253 | add_action('admin_print_styles-'.$patch_page, array($this, 'add_style_sheet'));
254 | add_action('admin_print_scripts-'.$util_page, array($this, 'add_sqlite_script'));
255 | add_action('admin_print_scripts-'.$doc_page, array($this, 'add_sqlite_script'));
256 | add_action('admin_print_scripts-'.$patch_page, array($this, 'add_sqlite_script'));
257 | add_action('admin_print_scripts-'.$edit_db, array($this, 'add_sqlite_script'));
258 | add_action('admin_print_styles-'.$maintenance_page, array($this, 'add_style_sheet'));
259 | }
260 | }
261 |
262 | /**
263 | * Method to initialize textdomain.
264 | *
265 | * Japanese catalog is only available.
266 | *
267 | * @param no parameter is provided.
268 | * @return no return values.
269 | */
270 | function textdomain_init() {
271 | global $utils;
272 | //$current_locale = get_locale();
273 | //if (!empty($current_locale)) {
274 | // $moFile = dirname(__FILE__) . "/languages/sqlite-wordpress-" . $current_locale . ".mo";
275 | // if(@file_exists($moFile) && is_readable($moFile)) load_textdomain('sqlite-wordpress', $moFile);
276 | //}
277 | load_plugin_textdomain($utils->text_domain, false, SQLiteDir.'/languages/');
278 | }
279 |
280 | /**
281 | * Method to initialize stylesheet on the admin panel.
282 | *
283 | * This determines which stylesheet to use depending on the users' choice
284 | * of admin_color. Each stylesheet imports style.css and change the color
285 | * of the admin dashboard.
286 | *
287 | * @param no parameter is provided.
288 | * @return no return values.
289 | */
290 | function add_style_sheet() {
291 | global $current_user;
292 | get_currentuserinfo();
293 | $admin_color = get_user_meta($current_user->ID, 'admin_color', true);
294 | if ($admin_color == 'fresh') {
295 | $stylesheet_file = 'style.min.css';
296 | } else {
297 | $stylesheet_file = $admin_color . '.min.css';
298 | }
299 | $style_url = SQLiteUrl . '/styles/' . $stylesheet_file;
300 | $style_file = SQLiteFilePath . '/styles/' . $stylesheet_file;
301 | if (file_exists($style_file)) {
302 | wp_enqueue_style('sqlite_integration_stylesheet', $style_url);
303 | }
304 | }
305 | /**
306 | * Method to register the JavaScript file.
307 | *
308 | * To register the JavaScript file. It's only for the admin dashboard.
309 | * It won't included in web pages.
310 | *
311 | * @param no parameter is provided.
312 | * @return no return value.
313 | */
314 | function add_sqlite_script() {
315 | $script_url = SQLiteUrl . '/js/sqlite.min.js';
316 | $script_file = SQLiteFilePath . '/js/sqlite.min.js';
317 | if (file_exists($script_file)) {
318 | wp_enqueue_script('sqlite-integration', $script_url, 'jquery');
319 | }
320 | }
321 | }
322 |
323 | /* this is enough for initialization */
324 | new SQLiteIntegration;
325 | ?>
--------------------------------------------------------------------------------
/read-only-plugins/sqlite-integration/query_create.class.php:
--------------------------------------------------------------------------------
1 | _query = $query;
59 | $this->_errors [] = '';
60 | if (preg_match('/^CREATE\\s*(UNIQUE|FULLTEXT|)\\s*INDEX/ims', $this->_query, $match)) {
61 | // we manipulate CREATE INDEX query in PDOEngine.class.php
62 | // FULLTEXT index creation is simply ignored.
63 | if (isset($match[1]) && stripos($match[1], 'fulltext') !== false) {
64 | return 'SELECT 1=1';
65 | } else {
66 | return $this->_query;
67 | }
68 | } elseif (preg_match('/^CREATE\\s*(TEMP|TEMPORARY|)\\s*TRIGGER\\s*/im', $this->_query)) {
69 | // if WordPress comes to use foreign key constraint, trigger will be needed.
70 | // we don't use it for now.
71 | return $this->_query;
72 | }
73 | $this->strip_backticks();
74 | $this->get_table_name();
75 | $this->rewrite_comments();
76 | $this->rewrite_field_types();
77 | $this->rewrite_character_set();
78 | $this->rewrite_engine_info();
79 | $this->rewrite_unsigned();
80 | $this->rewrite_autoincrement();
81 | $this->rewrite_primary_key();
82 | $this->rewrite_foreign_key();
83 | $this->rewrite_unique_key();
84 | $this->rewrite_enum();
85 | $this->rewrite_set();
86 | $this->rewrite_key();
87 | $this->add_if_not_exists();
88 |
89 | return $this->post_process();
90 | }
91 | /**
92 | * Method to get table name from the query string.
93 | *
94 | * 'IF NOT EXISTS' clause is removed for the easy regular expression usage.
95 | * It will be added at the end of the process.
96 | *
97 | * @access private
98 | */
99 | private function get_table_name(){
100 | // $pattern = '/^\\s*CREATE\\s*(TEMP|TEMPORARY)?\\s*TABLE\\s*(IF NOT EXISTS)?\\s*([^\(]*)/imsx';
101 | $pattern = '/^\\s*CREATE\\s*(?:TEMP|TEMPORARY)?\\s*TABLE\\s*(?:IF\\s*NOT\\s*EXISTS)?\\s*([^\(]*)/imsx';
102 | if (preg_match($pattern, $this->_query, $matches)) {
103 | $this->table_name = trim($matches[1]);
104 | }
105 | }
106 | /**
107 | * Method to change the MySQL field types to SQLite compatible types.
108 | *
109 | * Order of the key value is important. Don't change it.
110 | *
111 | * @access private
112 | */
113 | private function rewrite_field_types(){
114 | $array_types = array (
115 | 'bit' => 'integer', 'bool' => 'integer',
116 | 'boolean' => 'integer', 'tinyint' => 'integer',
117 | 'smallint' => 'integer', 'mediumint' => 'integer',
118 | 'int' => 'integer', 'integer' => 'integer',
119 | 'bigint' => 'integer', 'float' => 'real',
120 | 'double' => 'real', 'decimal' => 'real',
121 | 'dec' => 'real', 'numeric' => 'real',
122 | 'fixed' => 'real', 'date' => 'text',
123 | 'datetime' => 'text', 'timestamp' => 'text',
124 | 'time' => 'text', 'year' => 'text',
125 | 'char' => 'text', 'varchar' => 'text',
126 | 'binary' => 'integer', 'varbinary' => 'blob',
127 | 'tinyblob' => 'blob', 'tinytext' => 'text',
128 | 'blob' => 'blob', 'text' => 'text',
129 | 'mediumblob' => 'blob', 'mediumtext' => 'text',
130 | 'longblob' => 'blob', 'longtext' => 'text'
131 | );
132 | foreach ($array_types as $o=>$r){
133 | $pattern = "/\\b(?_query)) {
135 | ;
136 | } else {
137 | $this->_query = preg_replace($pattern, " $r ", $this->_query);
138 | }
139 | }
140 | }
141 | /**
142 | * Method for stripping the comments from the SQL statement.
143 | *
144 | * @access private
145 | */
146 | private function rewrite_comments(){
147 | $this->_query = preg_replace("/# --------------------------------------------------------/","-- ******************************************************",$this->_query);
148 | $this->_query = preg_replace("/#/","--",$this->_query);
149 | }
150 | /**
151 | * Method for stripping the engine and other stuffs.
152 | *
153 | * TYPE, ENGINE and AUTO_INCREMENT are removed here.
154 | * @access private
155 | */
156 | private function rewrite_engine_info(){
157 | $this->_query = preg_replace("/\\s*(TYPE|ENGINE)\\s*=\\s*.*(?_query);
158 | $this->_query = preg_replace("/ AUTO_INCREMENT\\s*=\\s*[0-9]*/ims",'',$this->_query);
159 | }
160 | /**
161 | * Method for stripping unsigned.
162 | *
163 | * SQLite doesn't have unsigned int data type. So UNSIGNED INT(EGER) is converted
164 | * to INTEGER here.
165 | *
166 | * @access private
167 | */
168 | private function rewrite_unsigned(){
169 | $this->_query = preg_replace('/\\bunsigned\\b/ims', ' ', $this->_query);
170 | }
171 | /**
172 | * Method for rewriting primary key auto_increment.
173 | *
174 | * If the field type is 'INTEGER PRIMARY KEY', it is automatically autoincremented
175 | * by SQLite. There's a little difference between PRIMARY KEY and AUTOINCREMENT, so
176 | * we may well convert to PRIMARY KEY only.
177 | *
178 | * @access private
179 | */
180 | private function rewrite_autoincrement(){
181 | $this->_query = preg_replace('/\\bauto_increment\\s*primary\\s*key\\s*(,)?/ims', ' PRIMARY KEY AUTOINCREMENT \\1', $this->_query, -1, $count);
182 | $this->_query = preg_replace('/\\bauto_increment\\b\\s*(,)?/ims', ' PRIMARY KEY AUTOINCREMENT $1', $this->_query, -1, $count);
183 | if ($count > 0){
184 | $this->has_primary_key = true;
185 | }
186 | }
187 | /**
188 | * Method for rewriting primary key.
189 | *
190 | * @access private
191 | */
192 | private function rewrite_primary_key(){
193 | if ($this->has_primary_key) {
194 | $this->_query = preg_replace('/\\s*primary key\\s*.*?\([^\)]*\)\\s*(,|)/i', ' ', $this->_query);
195 | } else {
196 | // If primary key has an index name, we remove that name.
197 | $this->_query = preg_replace('/\\bprimary\\s*key\\s*.*?\\s*(\(.*?\))/im', 'PRIMARY KEY \\1', $this->_query);
198 | }
199 | }
200 | /**
201 | * Method for rewriting foreign key.
202 | *
203 | * @access private
204 | */
205 | private function rewrite_foreign_key() {
206 | $pattern = '/\\s*foreign\\s*key\\s*(|.*?)\([^\)]+?\)\\s*references\\s*.*/i';
207 | if (preg_match_all($pattern, $this->_query, $match)) {
208 | if (isset($match[1])) {
209 | $this->_query = str_ireplace($match[1], '', $this->_query);
210 | }
211 | }
212 | }
213 | /**
214 | * Method for rewriting unique key.
215 | *
216 | * @access private
217 | */
218 | private function rewrite_unique_key(){
219 | $this->_query = preg_replace_callback('/\\bunique key\\b([^\(]*)(\(.*\))/im', array($this, '_rewrite_unique_key'), $this->_query);
220 | }
221 | /**
222 | * Callback method for rewrite_unique_key.
223 | *
224 | * @param array $matches an array of matches from the Regex
225 | * @access private
226 | */
227 | private function _rewrite_unique_key($matches){
228 | $index_name = trim($matches[1]);
229 | $col_name = trim($matches[2]);
230 | $tbl_name = $this->table_name;
231 | if (preg_match('/\(\\d+?\)/', $col_name)) {
232 | $col_name = preg_replace('/\(\\d+?\)/', '', $col_name);
233 | }
234 | $_wpdb = new PDODB();
235 | $results = $_wpdb->get_results("SELECT name FROM sqlite_master WHERE type='index'");
236 | $_wpdb = null;
237 | if ($results) {
238 | foreach ($results as $result) {
239 | if ($result->name == $index_name) {
240 | $r = rand(0, 50);
241 | $index_name = $index_name . "_$r";
242 | break;
243 | }
244 | }
245 | }
246 | $index_name = str_replace(' ', '', $index_name);
247 | $this->index_queries[] = "CREATE UNIQUE INDEX $index_name ON " . $tbl_name .$col_name;
248 | return '';
249 | }
250 | /**
251 | * Method for handling ENUM fields.
252 | *
253 | * SQLite doesn't support enum, so we change it to check constraint.
254 | *
255 | * @access private
256 | */
257 | private function rewrite_enum(){
258 | $pattern = '/(,|\))([^,]*)enum\((.*?)\)([^,\)]*)/ims';
259 | $this->_query = preg_replace_callback($pattern, array($this, '_rewrite_enum'), $this->_query);
260 | }
261 | /**
262 | * Call back method for rewrite_enum() and rewrite_set().
263 | *
264 | * @access private
265 | */
266 | private function _rewrite_enum($matches){
267 | $output = $matches[1] . ' ' . $matches[2]. ' TEXT '. $matches[4].' CHECK ('.$matches[2].' IN ('.$matches[3].')) ';
268 | return $output;
269 | }
270 | /**
271 | * Method for rewriting usage of set.
272 | *
273 | * It is similar but not identical to enum. SQLite does not support either.
274 | *
275 | * @access private
276 | */
277 | private function rewrite_set(){
278 | $pattern = '/\b(\w)*\bset\\s*\((.*?)\)\\s*(.*?)(,)*/ims';
279 | $this->_query = preg_replace_callback($pattern, array($this, '_rewrite_enum'), $this->_query);
280 | }
281 | /**
282 | * Method for rewriting usage of key to create an index.
283 | *
284 | * SQLite cannot create non-unique indices as part of the create query,
285 | * so we need to create an index by hand and append it to the create query.
286 | *
287 | * @access private
288 | */
289 | private function rewrite_key(){
290 | $this->_query = preg_replace_callback('/,\\s*(KEY|INDEX)\\s*(\\w+)?\\s*(\(.*(?_query);
291 | }
292 | /**
293 | * Callback method for rewrite_key.
294 | *
295 | * @param array $matches an array of matches from the Regex
296 | * @access private
297 | */
298 | private function _rewrite_key($matches){
299 | $index_name = trim($matches[2]);
300 | $col_name = trim($matches[3]);
301 | if (preg_match('/\([0-9]+?\)/', $col_name, $match)) {
302 | $col_name = preg_replace_callback('/\([0-9]+?\)/', array($this, '_remove_length'), $col_name);
303 | }
304 | $tbl_name = $this->table_name;
305 | $_wpdb = new PDODB();
306 | $results = $_wpdb->get_results("SELECT name FROM sqlite_master WHERE type='index'");
307 | $_wpdb = null;
308 | if ($results) {
309 | foreach ($results as $result) {
310 | if ($result->name == $index_name) {
311 | $r = rand(0, 50);
312 | $index_name = $index_name . "_$r";
313 | break;
314 | }
315 | }
316 | }
317 | $this->index_queries[] = 'CREATE INDEX '. $index_name . ' ON ' . $tbl_name . $col_name ;
318 | return '';
319 | }
320 | /**
321 | * Call back method to remove unnecessary string.
322 | *
323 | * This method is deprecated.
324 | *
325 | * @param string $match
326 | * @return string whose length is zero
327 | * @access private
328 | */
329 | private function _remove_length($match) {
330 | return '';
331 | }
332 | /**
333 | * Method to assemble the main query and index queries into an array.
334 | *
335 | * It return the array of the queries to be executed separately.
336 | *
337 | * @return array
338 | * @access private
339 | */
340 | private function post_process() {
341 | $mainquery = $this->_query;
342 | do{
343 | $count = 0;
344 | $mainquery = preg_replace('/,\\s*\)/imsx',')', $mainquery, -1, $count);
345 | } while ($count > 0);
346 | do {
347 | $count = 0;
348 | $mainquery = preg_replace('/\(\\s*?,/imsx', '(', $mainquery, -1, $count);
349 | } while ($count > 0);
350 | $return_val[] = $mainquery;
351 | $return_val = array_merge($return_val, $this->index_queries);
352 | return $return_val;
353 | }
354 | /**
355 | * Method to add IF NOT EXISTS to query string.
356 | *
357 | * This adds IF NOT EXISTS to every query string, which prevent the exception
358 | * from being thrown.
359 | *
360 | * @access private
361 | */
362 | private function add_if_not_exists(){
363 | $pattern_table = '/^\\s*CREATE\\s*(TEMP|TEMPORARY)?\\s*TABLE\\s*(IF NOT EXISTS)?\\s*/ims';
364 | $this->_query = preg_replace($pattern_table, 'CREATE $1 TABLE IF NOT EXISTS ', $this->_query);
365 | $pattern_index = '/^\\s*CREATE\\s*(UNIQUE)?\\s*INDEX\\s*(IF NOT EXISTS)?\\s*/ims';
366 | for ($i = 0; $i < count($this->index_queries); $i++) {
367 | $this->index_queries[$i] = preg_replace($pattern_index, 'CREATE $1 INDEX IF NOT EXISTS ', $this->index_queries[$i]);
368 | }
369 | }
370 | /**
371 | * Method to strip back quotes.
372 | *
373 | * @access private
374 | */
375 | private function strip_backticks(){
376 | $this->_query = str_replace('`', '', $this->_query);
377 | foreach ($this->index_queries as &$query) {
378 | $query = str_replace('`', '', $query);
379 | }
380 | }
381 | /**
382 | * Method to remove the character set information from within mysql queries.
383 | *
384 | * This removes DEFAULT CHAR(ACTER) SET and COLLATE, which is meaningless for
385 | * SQLite.
386 | *
387 | * @access private
388 | */
389 | private function rewrite_character_set(){
390 | $pattern_charset = '/\\b(default\\s*character\\s*set|default\\s*charset|character\\s*set)\\s*(?_query = preg_replace($patterns, '', $this->_query);
395 | }
396 | }
397 | ?>
--------------------------------------------------------------------------------
/read-only-plugins/sqlite-integration/utilities/patch.php:
--------------------------------------------------------------------------------
1 | text_domain;
50 | $installed_plugins = array();
51 | $file_names = array();
52 | $output = array();
53 | $retval = 0;
54 | $patch_results = array();
55 | $message = '';
56 | if (isset($_POST['plugin_checked'])) {
57 | $file_names = $_POST['plugin_checked'];
58 | } else {
59 | return false;
60 | }
61 | if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
62 | exec('where patch 2>&1', $out, $val);
63 | } else {
64 | exec('which patch 2>&1', $out, $val);
65 | }
66 | if ($val != 0) {
67 | $patch_results['error'] = __('Patch command is not found', $domain);
68 | return $patch_results;
69 | } elseif (!is_executable(trim($out[0]))) {
70 | $patch_results['error'] = __('Patch command is not executable', $domain);
71 | return $patch_results;
72 | } else {
73 | $patch_command = trim($out[0]) . ' -s -N -p1';
74 | }
75 | $installed_plugins = get_plugins();
76 | foreach ($file_names as $file) {
77 | if (preg_match('/_(.*)\.patch/i', $file, $match)) {
78 | $plugin_version = trim($match[1]);
79 | $plugin_basename = preg_replace('/_.*\.patch$/i', '', $file);
80 | foreach (array_keys($installed_plugins) as $key) {
81 | if (stripos($key, $plugin_basename) !== false) {
82 | $installed_plugin_version = $installed_plugins[$key]['Version'];
83 | break;
84 | }
85 | }
86 | } else {
87 | $patch_results['error'] = __('Patch file name is invalid', $domain);
88 | break;
89 | }
90 | if (version_compare($installed_plugin_version, $plugin_version, '!=')) {
91 | $patch_results['error'] = __('Patch file version does not match with that of your plugin.', $domain);
92 | break;
93 | }
94 | $plugin_dir = WP_PLUGIN_DIR.'/'.$plugin_basename;
95 | $patch_file = SQLitePatchDir.'/'.$file;
96 | $command = $patch_command.' <'.$patch_file.' 2>&1';
97 | if (chdir($plugin_dir)) {
98 | exec("$command", $output, $retval);
99 | } else {
100 | $patch_results[$file] = __('Error! Plugin directory is not accessible.', $domain);
101 | }
102 | if ($retval == 0) {
103 | $patch_results[$file] = __('is patched successfully.', $domain);
104 | } else {
105 | foreach ($output as $val) {
106 | $message .= $val.'
';
107 | }
108 | $patch_results[$file] = sprintf(__('Error! Messages: %s', $domain), $message);
109 | }
110 | }
111 | return $patch_results;
112 | }
113 | /**
114 | * Method to remove patch file(s) from the server.
115 | *
116 | * It deletes uploaded patch file(s).
117 | * If patch file(s) is not selected, returns false.
118 | * Or else returns array contains messages.
119 | *
120 | * @return boolean|array
121 | * @access private
122 | */
123 | private function delete_patch_files() {
124 | global $utils;
125 | $domain = $utils->text_domain;
126 | $file_names = array();
127 | $rm_results = array();
128 | if (isset($_POST['plugin_checked'])) {
129 | $file_names = $_POST['plugin_checked'];
130 | } else {
131 | return false;
132 | }
133 | if (chdir(SQLitePatchDir)) {
134 | foreach ($file_names as $file) {
135 | if (unlink($file)) {
136 | $rm_results[$file] = sprintf(__('File %s is deleted.', $domain), $file);
137 | } else {
138 | $rm_results[$file] = sprintf(__('Error! File %s is not deleted.', $domain), $file);
139 | }
140 | }
141 | } else {
142 | $rm_results[$file] = __('Error!: patches directory is not accessible.', $domain);
143 | }
144 | return $rm_results;
145 | }
146 | /**
147 | * Method to upload patch file(s) to the server.
148 | *
149 | * It uploads a patch file to the server. You must have the permission to write to the
150 | * temporary directory. If there isn't SQLitePatchDir, this method will create it and
151 | * set the permission to 0707.
152 | *
153 | * No return values.
154 | *
155 | * @return boolean
156 | * @access private
157 | */
158 | private function upload_file() {
159 | global $utils;
160 | $domain = $utils->text_domain;
161 | if (!file_exists(SQLitePatchDir) || !is_dir(SQLitePatchDir)) {
162 | if (!mkdir(SQLitePatchDir, 0707, true)) {
163 | $message = __('Unable to create a patch directory.', $domain);
164 | echo '
307 | Plugin Page about how to apply a patch file to the plugin. But the command line interface sometimes embarrasses some people, especially newbies.', $domain);?> 308 |
309 |310 | 311 |
312 |319 | 320 |
321 |322 | 323 |
324 |331 | 332 |
333 | 334 | 335 |342 | 343 |
344 || 356 | | 357 | 367 | | 368 |
|---|---|
| 371 | | 372 | 402 | | 403 |
413 |417 |414 | 415 |
416 |