├── www ├── root │ ├── test │ │ ├── cert.php │ │ ├── php.php │ │ ├── x509.php │ │ ├── acl_user.pem │ │ ├── webid.php │ │ └── acl_user_key.pem │ ├── webid.js.php │ ├── favicon.ico │ ├── common │ │ ├── images │ │ │ ├── 22 │ │ │ │ ├── acl.png │ │ │ │ ├── edit.png │ │ │ │ ├── delete.png │ │ │ │ ├── refresh.png │ │ │ │ ├── add_file.png │ │ │ │ └── add_folder.png │ │ │ ├── ok.png │ │ │ ├── home.png │ │ │ ├── bitcoin.png │ │ │ ├── cancel.png │ │ │ ├── favicon.ico │ │ │ ├── flattr.png │ │ │ ├── images.png │ │ │ ├── nouser.png │ │ │ ├── paypal.png │ │ │ ├── refresh.png │ │ │ ├── upload.png │ │ │ ├── add_file.png │ │ │ ├── add_folder.png │ │ │ ├── background.png │ │ │ ├── facebiblio.png │ │ │ ├── loginWebID.png │ │ │ ├── rdf_flyer.24.gif │ │ │ ├── load_bigroller.gif │ │ │ ├── loginFacebook.png │ │ │ ├── providers │ │ │ │ ├── aol.png │ │ │ │ ├── gmail.png │ │ │ │ ├── webid.png │ │ │ │ ├── yahoo.png │ │ │ │ └── facebook.gif │ │ │ └── logo.svg │ │ ├── font │ │ │ ├── FontAwesome.otf │ │ │ ├── fontawesome-webfont.eot │ │ │ ├── fontawesome-webfont.ttf │ │ │ └── fontawesome-webfont.woff │ │ └── js │ │ │ └── manage.js │ ├── api │ │ ├── spkac.php │ │ ├── index.php │ │ └── accountStatus.php │ ├── server.html │ ├── proxy.php │ ├── server.coffee │ ├── server.js │ ├── index.php │ ├── runtime.php │ ├── user.js.php │ ├── check_domain.php │ ├── .well-known │ │ ├── host-meta.php │ │ └── webfinger.php │ ├── logout.php │ ├── yadis.php │ ├── rp_auth.php │ ├── s.php │ ├── auth-proxy.php │ ├── rp_callback.php │ ├── login.php │ ├── onboard │ │ ├── style.css │ │ └── signup.html │ └── help.php ├── wildcard │ ├── PATCH.php │ ├── common │ ├── favicon.ico │ ├── .htaccess │ ├── MKCOL.php │ ├── index.php │ ├── if-match.php │ ├── DELETE.php │ ├── input.php │ ├── PUT.php │ ├── ldp.php │ ├── output.php │ ├── SPARQL.php │ ├── runtime.php │ ├── POST.php │ ├── index.rdf.php │ └── GET.php ├── inc │ ├── config.inc.php │ ├── config.php │ ├── arc2 │ │ ├── Makefile │ │ └── parsers │ │ │ ├── ARC2_RDFParser.php │ │ │ ├── ARC2_SPARQLPlusParser.php │ │ │ └── ARC2_MITSPARQLParser.php │ ├── runtime.php │ ├── contrib │ │ └── skin.html.php │ ├── empty.php │ ├── 403-404.php │ ├── 401.php │ ├── webid.lib.php │ ├── footer.php │ ├── header.php │ ├── runtime.inc.php │ ├── webidgen.php │ └── util.lib.php ├── certs │ ├── rww-agent.p12 │ ├── rww-agent.pem │ └── agent.pem └── .htaccess ├── .gitignore ├── conf ├── common.conf ├── php.ini ├── ssl.conf ├── httpd.conf └── worker.conf ├── py ├── wsgevent.py ├── wsgi.py ├── wsgi-debug.py └── pki.py ├── LICENSE └── README.rst /www/root/test/cert.php: -------------------------------------------------------------------------------- 1 | x509.php -------------------------------------------------------------------------------- /www/root/webid.js.php: -------------------------------------------------------------------------------- 1 | user.js.php -------------------------------------------------------------------------------- /www/wildcard/PATCH.php: -------------------------------------------------------------------------------- 1 | POST.php -------------------------------------------------------------------------------- /www/wildcard/common: -------------------------------------------------------------------------------- 1 | ../root/common/ -------------------------------------------------------------------------------- /www/inc/config.inc.php: -------------------------------------------------------------------------------- 1 | glob = true; 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | data 2 | data/* 3 | *.swp 4 | 5 | www/inc/analytics.php 6 | -------------------------------------------------------------------------------- /www/root/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deiu/rww.io/master/www/root/favicon.ico -------------------------------------------------------------------------------- /www/certs/rww-agent.p12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deiu/rww.io/master/www/certs/rww-agent.p12 -------------------------------------------------------------------------------- /www/wildcard/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deiu/rww.io/master/www/wildcard/favicon.ico -------------------------------------------------------------------------------- /www/root/common/images/ok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deiu/rww.io/master/www/root/common/images/ok.png -------------------------------------------------------------------------------- /www/root/common/images/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deiu/rww.io/master/www/root/common/images/home.png -------------------------------------------------------------------------------- /www/root/api/spkac.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /www/root/proxy.php: -------------------------------------------------------------------------------- 1 | linkmeta = false; 5 | 6 | require_once('../wildcard/runtime.php'); 7 | 8 | if (isset($i_uri)) { 9 | $g = new Graph('memory', '', ''); 10 | $g->load($i_uri); 11 | } 12 | 13 | require_once('../wildcard/GET.php'); 14 | -------------------------------------------------------------------------------- /conf/common.conf: -------------------------------------------------------------------------------- 1 | # $Id$ 2 | 3 | 4 | AllowOverride All 5 | 6 | 7 | #FcgidMaxProcessesPerClass 16 8 | #FcgidMaxRequestsPerProcess 10000 9 | IPCCommTimeout 300 10 | MaxRequestLen 1310720 11 | 12 | RewriteEngine On 13 | #SuexecUserGroup data.fm data.fm 14 | -------------------------------------------------------------------------------- /conf/php.ini: -------------------------------------------------------------------------------- 1 | ; $Id$ 2 | 3 | cgi.fix_pathinfo = 1 4 | expose_php = Off 5 | magic_quotes_gpc = Off 6 | magic_quotes_runtime = Off 7 | magic_quotes_sybase = Off 8 | max_execution_time = 120 9 | short_open_tag = On 10 | zlib.output_compression = On 11 | 12 | extension = json.so 13 | extension = redland.so 14 | 15 | [Session] 16 | session.name = SID 17 | -------------------------------------------------------------------------------- /conf/ssl.conf: -------------------------------------------------------------------------------- 1 | # $Id: ssl.conf -1 $ 2 | 3 | SSLEngine on 4 | SSLCertificateFile /etc/apache2/ssl/server.crt 5 | SSLCertificateKeyFile /etc/apache2/ssl/server.key 6 | SSLOptions +StdEnvVars +ExportCertData 7 | SSLVerifyClient optional_no_ca 8 | 9 | 10 | # AuthType WebID 11 | # Require valid-user 12 | # Require everyone 13 | # AuthWebIDAuthoritative off 14 | 15 | -------------------------------------------------------------------------------- /www/root/server.coffee: -------------------------------------------------------------------------------- 1 | rpc = (method, ev) -> 2 | $.ajax "api/"+method, 3 | contentType: "application/json" 4 | data: JSON.stringify(ev.data) 5 | type: "POST" 6 | dataType: "json" 7 | success: (data, textStatus, xhr) -> 8 | ev.source.postMessage data, ev.origin 9 | 10 | window.addEventListener "message", (ev) -> 11 | rpc.call(this, ev.data.method, ev) 12 | -------------------------------------------------------------------------------- /www/.htaccess: -------------------------------------------------------------------------------- 1 | RewriteEngine On 2 | RewriteCond %{REQUEST_FILENAME}.php -f 3 | RewriteRule (.+) $1.php 4 | 5 | php_value upload_max_filesize 10M 6 | 7 | 8 | AddHandler fcgid-script .php 9 | AddHandler fcgid-script .py 10 | DirectoryIndex index.php 11 | 12 | Options +ExecCGI 13 | 14 | 15 | Options +ExecCGI 16 | 17 | 18 | -------------------------------------------------------------------------------- /py/wsgevent.py: -------------------------------------------------------------------------------- 1 | # gunicorn-integration logging hack 2 | 3 | def log_request(self): 4 | return 5 | log = self.server.log 6 | if log: 7 | if hasattr(log, "info"): 8 | log.info(self.format_request()) 9 | else: 10 | log.write(self.format_request()) 11 | 12 | import gevent.pywsgi 13 | gevent.pywsgi.WSGIHandler.log_request = log_request 14 | 15 | from gevent.greenlet import Greenlet 16 | from gevent.queue import Queue 17 | -------------------------------------------------------------------------------- /www/root/server.js: -------------------------------------------------------------------------------- 1 | // Generated by CoffeeScript 1.6.3 2 | (function() { 3 | var rpc; 4 | 5 | rpc = function(method, ev) { 6 | return $.ajax("api/" + method, { 7 | contentType: "application/json", 8 | data: JSON.stringify(ev.data), 9 | type: "POST", 10 | dataType: "json", 11 | success: function(data, textStatus, xhr) { 12 | return ev.source.postMessage(data, ev.origin); 13 | } 14 | }); 15 | }; 16 | 17 | window.addEventListener("message", function(ev) { 18 | return rpc.call(this, ev.data.method, ev); 19 | }); 20 | 21 | }).call(this); 22 | -------------------------------------------------------------------------------- /www/wildcard/.htaccess: -------------------------------------------------------------------------------- 1 | # $Id$ 2 | 3 | RewriteEngine On 4 | 5 | RewriteCond %{REQUEST_METHOD} =GET [OR] 6 | RewriteCond %{REQUEST_METHOD} =HEAD [OR] 7 | RewriteCond %{REQUEST_METHOD} =OPTIONS 8 | RewriteCond %{REQUEST_URI} !/common/ 9 | RewriteRule ^(.*)$ GET.php [L] 10 | 11 | RewriteCond %{REQUEST_METHOD} =MKCOL [OR] 12 | RewriteCond %{REQUEST_METHOD} =PATCH [OR] 13 | RewriteCond %{REQUEST_METHOD} =POST [OR] 14 | RewriteCond %{REQUEST_METHOD} =PUT [OR] 15 | RewriteCond %{REQUEST_METHOD} =DELETE 16 | RewriteRule ^(.*)$ %{REQUEST_METHOD}.php [L] 17 | 18 | # drop all other Apache responses 19 | #RewriteRule .* - [L,R=501] 20 | -------------------------------------------------------------------------------- /www/inc/config.php: -------------------------------------------------------------------------------- 1 | can('Write') == false) 13 | httpStatusExit(403, 'Forbidden'); 14 | 15 | // check quota (avoids making lots of dirs if out of space) 16 | if (check_quota($_root, 10) == false) 17 | httpStatusExit(507, 'Insufficient Storage'); 18 | 19 | // action 20 | @mkdir($_filename, 0777, true); 21 | header("Link: <".$_metabase.$_metaname.">; rel=meta", false); 22 | httpStatusExit(201, 'Created'); 23 | -------------------------------------------------------------------------------- /www/inc/arc2/Makefile: -------------------------------------------------------------------------------- 1 | all: parsers/ARC2_SPARQLPlusParser.php 2 | 3 | parsers/ARC2_SPARQLPlusParser.php: parsers/ARC2_SPARQLParser.php 4 | wget -O $@ https://raw.github.com/semsol/arc2/master/parsers/ARC2_SPARQLPlusParser.php 5 | 6 | parsers/ARC2_SPARQLParser.php: parsers/ARC2_TurtleParser.php 7 | wget -O $@ https://raw.github.com/semsol/arc2/master/parsers/ARC2_SPARQLParser.php 8 | 9 | parsers/ARC2_TurtleParser.php: parsers/ARC2_RDFParser.php 10 | wget -O $@ https://raw.github.com/semsol/arc2/master/parsers/ARC2_TurtleParser.php 11 | 12 | parsers/ARC2_RDFParser.php: ARC2_Class.php parsers 13 | wget -O $@ https://raw.github.com/semsol/arc2/master/parsers/ARC2_RDFParser.php 14 | 15 | parsers: 16 | mkdir -p parsers 17 | 18 | ARC2_Class.php: ARC2.php 19 | wget -O $@ https://raw.github.com/semsol/arc2/master/ARC2_Class.php 20 | 21 | ARC2.php: 22 | wget -O $@ https://raw.github.com/semsol/arc2/master/ARC2.php 23 | -------------------------------------------------------------------------------- /www/root/index.php: -------------------------------------------------------------------------------- 1 | 11 |
12 | Welcome! This Read/Write Linked Data service is free (and open-source) for educational and personal use. 13 |
14 |
15 |
16 |
17 |

 You don't have an account yet? 18 |

19 |
20 | $method, 17 | ); 18 | $r = array(); 19 | 20 | if ($method == 'storageStatus') { 21 | $r['storageName'] = $i_storageName; 22 | $dir = $_ENV['CLOUD_DATA'].'/'.$r['storageName'].'.'.ROOT_DOMAIN; 23 | $files = scandir($dir); 24 | $r['available'] = sizeof($files)<=1; 25 | } 26 | 27 | if ($method == 'accountStatus') { 28 | $r['accountName'] = $i_accountName; 29 | $dir = $_ENV['CLOUD_DATA'].'/'.$r['accountName'].'.'.ROOT_DOMAIN; 30 | $files = scandir($dir); 31 | $r['available'] = sizeof($files)<=1; 32 | } 33 | 34 | $w['status'] = 'success'; 35 | $w['response'] = $r; 36 | echo json_encode($w); 37 | -------------------------------------------------------------------------------- /www/root/api/accountStatus.php: -------------------------------------------------------------------------------- 1 | $method, 17 | ); 18 | $r = array(); 19 | 20 | if ($method == 'storageStatus') { 21 | $r['storageName'] = $i_storageName; 22 | $dir = $_ENV['CLOUD_DATA'].'/'.$r['storageName'].'.'.ROOT_DOMAIN; 23 | $files = scandir($dir); 24 | $r['available'] = sizeof($files)<=1; 25 | } 26 | 27 | if ($method == 'accountStatus') { 28 | $r['accountName'] = $i_accountName; 29 | $dir = $_ENV['CLOUD_DATA'].'/'.$r['accountName'].'.'.ROOT_DOMAIN; 30 | $files = scandir($dir); 31 | $r['available'] = sizeof($files)<=1; 32 | } 33 | 34 | $w['status'] = 'success'; 35 | $w['response'] = $r; 36 | echo json_encode($w); 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2010 2 | by Joe Presbrey , Andrei Sambra 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /www/inc/runtime.php: -------------------------------------------------------------------------------- 1 | 6 | ServerName rww.io 7 | Include /home/rww/rww.io/conf/common.conf 8 | DocumentRoot /home/rww/rww.io/www/root 9 | 10 | 11 | ServerName rww.io 12 | Include /home/rww/rww.io/conf/common.conf 13 | Include /home/rww/rww.io/conf/ssl.conf 14 | DocumentRoot /home/rww/rww.io/www/root 15 | LogLevel info 16 | 17 | 18 | 19 | ServerName www.rww.io 20 | Include /home/rww/rww.io/conf/common.conf 21 | RewriteRule (.*) http://rww.io$1 [R,L] 22 | 23 | 24 | ServerName www.rww.io 25 | Include /home/rww/rww.io/conf/common.conf 26 | Include /home/rww/rww.io/conf/ssl.conf 27 | RewriteRule (.*) https://rww.io$1 [R,L] 28 | 29 | 30 | 31 | ServerName cloud.rww.io 32 | ServerAlias *.rww.io 33 | Include /home/rww/rww.io/conf/common.conf 34 | DocumentRoot /home/rww/rww.io/www/wildcard 35 | 36 | 37 | ServerName cloud.rww.io 38 | ServerAlias *.rww.io 39 | Include /home/rww/rww.io/conf/common.conf 40 | Include /home/rww/rww.io/conf/ssl.conf 41 | DocumentRoot /home/rww/rww.io/www/wildcard 42 | 43 | -------------------------------------------------------------------------------- /www/inc/contrib/skin.html.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | '; 11 | echo ''; 12 | echo ''; 13 | ?> 14 | 31 | 32 | 33 |
34 |
35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /www/root/runtime.php: -------------------------------------------------------------------------------- 1 | 30 | 31 | 29 |
Access to the requested URI is denied or it does not exist.
30 | 5 | Bag Attributes 6 | friendlyName: RWW Agent's WebID ID 7 | localKeyID: A3 3D F1 4F 1F B4 80 00 23 7F 75 10 B1 41 AF F3 05 52 6B 61 8 | subject=/C=US/ST=Some-State/O=WebID/CN=RWW Agent 9 | issuer=/C=US/ST=Some-State/O=WebID/CN=WebID 10 | -----BEGIN CERTIFICATE----- 11 | MIIDAzCCAmygAwIBAgIECtQ59zANBgkqhkiG9w0BAQUFADBCMQswCQYDVQQGEwJV 12 | UzETMBEGA1UECAwKU29tZS1TdGF0ZTEOMAwGA1UECgwFV2ViSUQxDjAMBgNVBAMM 13 | BVdlYklEMB4XDTE0MDUwNjAxMzgxMFoXDTE1MDUwMTAxMzgxMFowRjELMAkGA1UE 14 | BhMCVVMxEzARBgNVBAgMClNvbWUtU3RhdGUxDjAMBgNVBAoMBVdlYklEMRIwEAYD 15 | VQQDEwlSV1cgQWdlbnQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCj 16 | CJ9p2gtzBQkmx4AsSdcXz2gwCnutBnUKt8Q7o5WPcH6JMrVRg4zz2bQ37RMcODil 17 | oTBDx/jmxbrQlKwgmbHxf/yOLk47d//lTztwAqcaPJWQyHJGTaV1VIETuf/uiyBT 18 | TteCPdKff2B85q4uLBhQaQ8yMHdajeZLUKBXK4kiWwgK5Nk740vdVyQLNSh9Szb2 19 | aqBqUkR+vfYAIpga7R+5fErrvcOw2J6qPH2Senhb8r4viKEn3wk/xvjF6b3j4Zf9 20 | dOZiMV7nz2QPkDBCaYQxpOTfYgD0YxF6lgzwDzCFPAa4BcZj48sDUR65pEkwLHuG 21 | /ZsXAdNG02lF1y0FXjg7AgMBAAGjfjB8MAkGA1UdEwQCMAAwLwYDVR0RBCgwJoYk 22 | aHR0cHM6Ly9hZ2VudC5yd3cuaW8vcHJvZmlsZS9jYXJkI21lMB0GA1UdDgQWBBSL 23 | PDR+FDc3/TzbI/CLDRzLs1w+ozAfBgNVHSMEGDAWgBQ96IbAHTditkvWj0lXrpjt 24 | +JrUgjANBgkqhkiG9w0BAQUFAAOBgQAJo9C9GwDjspXSXDiQchx+s5lrkutA6FGp 25 | Hwh/pt8zTdc9xYFuE5wn1FTmVnRqUhH20YpLlqC+VyPYl25bRvT67Dmmse+mgrM6 26 | f9mzkxefKs/qdQbnYCiXn0As6QIQYRmtPOG/Iun0tEqeMpugzqC6YlZ9dctWyzIk 27 | lfI8O/vwJA== 28 | -----END CERTIFICATE----- 29 | -------------------------------------------------------------------------------- /www/root/test/acl_user.pem: -------------------------------------------------------------------------------- 1 | Bag Attributes 2 | friendlyName: ACL Test's MyProfile ID 3 | localKeyID: E0 D0 B0 CB 83 0A 96 8C 34 6B 2A 6B 63 21 09 51 C5 0F 34 36 4 | Key Attributes: 5 | Bag Attributes 6 | friendlyName: ACL Test's MyProfile ID 7 | localKeyID: E0 D0 B0 CB 83 0A 96 8C 34 6B 2A 6B 63 21 09 51 C5 0F 34 36 8 | subject=/CN=ACL Test 9 | issuer=/C=FR/ST=Essonne/O=MyProfile/OU=MyProfile/CN=MyProfile 10 | -----BEGIN CERTIFICATE----- 11 | MIIDJjCCAo+gAwIBAgIJAP/V3sbj4OALMA0GCSqGSIb3DQEBBQUAMFsxCzAJBgNV 12 | BAYTAkZSMRAwDgYDVQQIEwdFc3Nvbm5lMRIwEAYDVQQKEwlNeVByb2ZpbGUxEjAQ 13 | BgNVBAsTCU15UHJvZmlsZTESMBAGA1UEAxMJTXlQcm9maWxlMB4XDTEzMDEyMTE0 14 | MDEwMFoXDTIzMDExOTE0MDEwMFowEzERMA8GA1UEAxMIQUNMIFRlc3QwggEiMA0G 15 | CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC/E8aEKb/WyX823OoeBVqhMVJYCNOx 16 | ssPb2d953IytdmqOjzyhIOBGOR7AADJq+HZ/GrWLJaZeVKhVj/+qqMz8xt+elbYA 17 | 24PuXbfrfqxsPh1QdLhc9N+eDEA479siSx2hdB8p/T0E9TZ59kTgU3MzQxlpsGBL 18 | /PBXar8zqwfYSVaxDNsAFyBbvNp4GBfE9CkwmaIh4K1iV/0NtaC5vhrF2CWllQn3 19 | C0z3nYddT6/RFyZc3tigfWT4piY15axP2BsctYSM1AGF0CfCHNB8UZK7U5mO51qu 20 | njK7yVQvSHZ79JrI6A4xC9JJ5+gnbfjZJ+K43HhQSOpXDCX8LAAnhbn9AgMBAAGj 21 | gbUwgbIwCQYDVR0TBAIwADAsBglghkgBhvhCAQ0EHxYdT3BlblNTTCBHZW5lcmF0 22 | ZWQgQ2VydGlmaWNhdGUwHQYDVR0OBBYEFNMFzxrztM3gMLkEGCrhtkfZ3jlRMB8G 23 | A1UdIwQYMBaAFKZq4zyOOHmXi3eMh/VJbmvLrkUBMDcGA1UdEQQwMC6GLGh0dHBz 24 | Oi8vbXktcHJvZmlsZS5ldS9wZW9wbGUvYWNsdGVzdC9jYXJkI21lMA0GCSqGSIb3 25 | DQEBBQUAA4GBAJop8n0EVl/gIn634aZ0NoXl6OSOENdd1X6Kj1EqhFQ958GDPEYW 26 | /GT9mNMOfG19mmQ+cE3QpUEXmdugXfqz+rWcwykufmVkDq7EQOq+6aG6PnEsn+zn 27 | ZcND6ExbvwaVV7QKu6VAH3gpPNsfGTgOvJdXGyNpVmSgEgY9e6MgP9Vs 28 | -----END CERTIFICATE----- 29 | -------------------------------------------------------------------------------- /www/wildcard/index.php: -------------------------------------------------------------------------------- 1 | exists(); 11 | $etag = is_dir($_filename)?md5_dir($_filename):md5_file($_filename); 12 | } else { 13 | $exists = file_exists($_filename); 14 | if ($exists) { 15 | $etag = is_dir($_filename)?md5_dir($_filename):md5_file($_filename); 16 | if (strlen($etag)) 17 | $etag = trim(array_shift(explode(' ', $etag))); 18 | } else { 19 | $etag = ''; 20 | } 21 | } 22 | //echo "ETag: ".$etag; 23 | //echo "\nExists: ".$exists; 24 | //echo "\nIf-Match: ".$if_match; 25 | //echo "\nIf-None-Match: ".$if_none_match; 26 | 27 | if (strlen($if_match)) { 28 | $fail = (($if_match == '*' && !$exists) || ($if_match != '*' && $if_match != $etag)); 29 | } else { 30 | $fail = (($if_none_match == '*' && $exists) || ($if_none_match != '*' && $if_none_match == $etag)); 31 | } 32 | //echo "\nFail: ".$fail; 33 | //echo "\nMethod: ".$_method_type; 34 | if ($fail) { 35 | if ($_method_type == 'read') { 36 | httpStatusExit(304, 'Not Modified'); 37 | } elseif ($_method_type == 'write') { 38 | header("Link: <".$_base.">; rel=describedby", false); 39 | httpStatusExit(412, 'Precondition Failed'); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /www/root/.well-known/host-meta.php: -------------------------------------------------------------------------------- 1 | '; 27 | ?> 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /www/root/logout.php: -------------------------------------------------------------------------------- 1 | $v) { 26 | sess($k, null); 27 | } 28 | 29 | if (isset($i_next)) { 30 | sess('next', $i_next); 31 | } elseif (isMethod('GET') && isset($_SERVER['HTTP_REFERER'])) { 32 | sess('next', $_SERVER['HTTP_REFERER']); 33 | } 34 | 35 | if (isSess('next')) { 36 | $next = sess('next', null); 37 | $next = str_replace('https://', 'http://', $next); 38 | header('Location: '.$next); 39 | } else { 40 | header('Location: /'); 41 | } 42 | exit; 43 | -------------------------------------------------------------------------------- /www/root/.well-known/webfinger.php: -------------------------------------------------------------------------------- 1 | '; 27 | $i_q = isset($_GET['q']) ? $_GET['q'] : exit(); 28 | if (false !== ($x = strpos($i_q, ':'))) 29 | $i_q = substr($i_q, $x+1); 30 | ?> 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /www/root/yadis.php: -------------------------------------------------------------------------------- 1 | '; 31 | ?> 32 | 36 | 37 | 38 | http://specs.openid.net/auth/2.0/return_to 39 | /rp_callback 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /www/root/test/webid.php: -------------------------------------------------------------------------------- 1 | $g->size(), 37 | 'bindings' => webid_query($elt, $g) 38 | ); 39 | } 40 | 41 | $r = array( 42 | 'claim' => $claim, 43 | 'query' => $query, 44 | 'verified' => webid_verify() 45 | ); 46 | print_r($r); 47 | -------------------------------------------------------------------------------- /py/wsgi.py: -------------------------------------------------------------------------------- 1 | 2 | # websocket pubsub 3 | 4 | listeners = {} 5 | subscriptions = {} 6 | 7 | def cmd_pub(uri, data): 8 | uris = [uri] 9 | if uri[:5] == 'http:': uris.append('https:'+uri[5:]) 10 | elif uri[:6] == 'https:': uris.append('http:'+uri[6:]) 11 | for uri in uris: 12 | msg = ' '.join(('pub', uri, data)) 13 | for k in subscriptions.get(uri, {}).keys(): 14 | if k in listeners: 15 | listeners[k].put_nowait(msg) 16 | else: 17 | del subscriptions[uri][k] 18 | 19 | def proc(msg, sock=None): 20 | if not msg or not ' ' in msg or msg.find(' ', 1+msg.find(' ')) < 0: 21 | return 22 | cmd, uri, data = msg.split(' ', 2) 23 | cmd = cmd.lower() 24 | if cmd == 'pub': 25 | cmd_pub(uri, data) 26 | elif cmd == 'sub': 27 | if not uri in subscriptions: 28 | subscriptions[uri] = {} 29 | subscriptions[uri][sock] = True 30 | 31 | def http(environ, respond): 32 | proc(environ['wsgi.input'].read()) 33 | respond('204 OK', []) 34 | return '' 35 | 36 | from wsgevent import Queue, Greenlet 37 | 38 | def application(environ, respond): 39 | sock = environ.get('wsgi.websocket') 40 | if sock is None: 41 | return http(environ, respond) 42 | 43 | listeners[sock] = out = Queue() 44 | 45 | def sender(): 46 | for msg in out: 47 | sock.send(msg) 48 | 49 | send = Greenlet(sender) 50 | send.start() 51 | 52 | try: 53 | while True: 54 | msg = sock.receive() 55 | if msg is None: 56 | break 57 | elif type(msg) is unicode: 58 | msg = msg.encode('utf-8') 59 | proc(msg, sock) 60 | 61 | except Exception, e: pass 62 | 63 | send.kill() 64 | del listeners[sock] 65 | 66 | -------------------------------------------------------------------------------- /conf/worker.conf: -------------------------------------------------------------------------------- 1 | # lighttpd2 worker.conf 2 | 3 | web_root = "/srv/www/rww.io"; 4 | web_wild = "/srv/www/wildcard.rww.io"; 5 | 6 | setup { 7 | module_load ( 8 | "mod_openssl", 9 | "mod_rewrite", 10 | "mod_fastcgi", 11 | "mod_dirlist", 12 | "mod_status" 13 | ); 14 | openssl [ 15 | "listen" => "0.0.0.0:443", 16 | "pemfile" => "/srv/ssl/default.pem", 17 | "ca-file" => "/srv/ssl/ca.pem", 18 | "verify" => true, 19 | "verify-require" => false, 20 | "verify-depth" => 9, 21 | "verify-any" => true 22 | ]; 23 | 24 | listen "0.0.0.0:80"; 25 | #listen "[::]:80"; 26 | 27 | static.exclude_extensions ( ".php", ".pl", ".fcgi", "~", ".inc" ); 28 | mime_types ( 29 | ".gif" => "image/gif", 30 | ".css" => "text/css; charset=utf-8", 31 | ".jpg" => "image/jpeg", 32 | ".js" => "text/javascript", 33 | ".png" => "image/png", 34 | ".html" => "text/html", 35 | ".n3" => "text/n3", 36 | ".ttl" => "text/turtle", 37 | "" => "text/plain" 38 | ); 39 | } 40 | 41 | php = { 42 | if phys.path =$ ".php" and physical.is_file { 43 | fastcgi "unix:/tmp/php.sock"; 44 | } 45 | }; 46 | 47 | if req.path == "/status" { 48 | status.info; 49 | 50 | } else if req.path == "/ping" { 51 | respond 200=>"pong"; 52 | 53 | } else if req.host == "rww.io" or req.host == "rww.io" { 54 | openssl.setenv ( "client", "client-cert" ); 55 | 56 | # default paths 57 | docroot web_root; 58 | index ( "index.php", "index.html", "index.htm", "default.htm" ); 59 | dirlist; 60 | 61 | # pretty paths 62 | if !phys.exists and phys.path !$ ".php" { 63 | rewrite ( "(.*)" => "$1.php" ); 64 | } 65 | docroot web_root; 66 | 67 | # catch-all 68 | if !phys.exists { 69 | rewrite "/index.php"; 70 | } 71 | docroot web_root; 72 | php; 73 | 74 | } else { 75 | openssl.setenv ( "client", "client-cert" ); 76 | 77 | docroot web_wild; 78 | if !phys.exists or req.path =$ "/" { 79 | rewrite "/index.php"; 80 | } 81 | docroot web_wild; 82 | php; 83 | 84 | } 85 | -------------------------------------------------------------------------------- /www/inc/401.php: -------------------------------------------------------------------------------- 1 | 29 |
30 | You must login to access this URL 31 |
32 | 33 |
34 | If you just installed a new SSL certificate, try restarting your browser to trigger its selection 35 |
36 | 37 |
38 | Firefox 3.5+, currently shipping Safari, IE, and Chrome builds are known to work 39 |
40 | 41 | 5 | -----BEGIN PRIVATE KEY----- 6 | MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC/E8aEKb/WyX82 7 | 3OoeBVqhMVJYCNOxssPb2d953IytdmqOjzyhIOBGOR7AADJq+HZ/GrWLJaZeVKhV 8 | j/+qqMz8xt+elbYA24PuXbfrfqxsPh1QdLhc9N+eDEA479siSx2hdB8p/T0E9TZ5 9 | 9kTgU3MzQxlpsGBL/PBXar8zqwfYSVaxDNsAFyBbvNp4GBfE9CkwmaIh4K1iV/0N 10 | taC5vhrF2CWllQn3C0z3nYddT6/RFyZc3tigfWT4piY15axP2BsctYSM1AGF0CfC 11 | HNB8UZK7U5mO51qunjK7yVQvSHZ79JrI6A4xC9JJ5+gnbfjZJ+K43HhQSOpXDCX8 12 | LAAnhbn9AgMBAAECggEAbsqYoKlUgsXy7WzKkv2nvy9J/6Genbp5tlBuM8qeBzZS 13 | Mrb7ALJ/WDhmjA2RLlVC4BAsk7IQ9UFBGduU8u9NbIQjxWApV/XwWZYdvn6Em36o 14 | oK4M+FlED/AqjNkGxqunUqZyK3aamvVT0QPqi+fXNDID2jRaobTX5tgOZXcV5WIf 15 | vSHqneqH1MTF/9jLJogGc99dw1S+lQJZY0PJHwz2x7hV7UtrlcYMEW62XnWunwkc 16 | uPkY5DQg//q/R1Q9RjTKLG54BSCTmTxyjPZDo6XK7YMbEoCRHtiEaGW6MHkxSmM3 17 | lp0MuAklLtpsuqm+/J9ygi0In/sPJFboGkvdCM7mAQKBgQDs0MXu/Y0vjxjnAIIG 18 | Lehev+gweLAevPHOgIfrz8IWqwxAm3hhCK9KVa0JnWM/wEq0CW9Zueq2Su21sXS6 19 | FZEKBKiQmMNzM8khRZYD8hpEvES9/PtEr5bUG+ujjk89s0fyKgidpWnYPeX7/trr 20 | BrbQRVC6wixSSMGZPW0wQT3YVQKBgQDOjnQkK1s6o8+kGls/1hTdi+y3mRy2CAUu 21 | nxcz+osDbSdQ5hnnw6nt/pDUUt4DfWX3pb9a6sv9xLVRkVor7rQKFFPZMoZPoO3U 22 | u2qN2PJUOdEJV77KOWLA0IS/B+PCg8RAUms4WlVbb0jFGrvXWG8+2YSNt3pgcMUh 23 | YPEZtC+jCQKBgQC2e8YafG2AOW+CCiUnp9aItK6yMz3b4dMfQnH6p3SzTQk6+9KO 24 | S0fwKwcVAp/JL18hTqfsZ1RTNnfoa588CYRjSOWvztfFfSE+r0WDMttFHiKGmFvz 25 | OK8sMXup4+5x6CXHmNZczGs8g64mOePt+ZWD9fXYg+ntWj083VW3On7ypQKBgQCe 26 | NWRl08OTnabMBdgAhCQFMUiFs8PW9Tuq4vXtvSg+3psvjp8m8qo0fThHOJWOTL0O 27 | OyjfJVpLrCBJMrDDV5kU40753IYddaDUwRwzO4kY1BP1OP0MfXnTP6N9gjiEY1Kt 28 | BbPUPPSGDS3KsthPcA/9LrQlq/QS7C1BjLP+wRF/qQKBgQCS7HY96aLNSiwMigwK 29 | FGVKV4FytdtH4qcKUnYAxjKZyEx/qCshIlCzeL19zN4URT2RmTgmX7T8WUHQxdaw 30 | iZNBVKk2dSDl6yfKuadSKfhPj7QOU312XePb6KI/AMpFjIWdmpCmf+VwsMEkNvPE 31 | FxvAo8YIzL7kaL/47feHBIufPw== 32 | -----END PRIVATE KEY----- 33 | -------------------------------------------------------------------------------- /www/wildcard/DELETE.php: -------------------------------------------------------------------------------- 1 | "); 33 | syslog(LOG_INFO, 'User: '.$_user.' -> '.$_filename); 34 | closelog(); 35 | } 36 | // Web Access Control 37 | if (!$_wac->can('Write')) 38 | httpStatusExit(403, 'Forbidden'); 39 | 40 | $any_s = null; 41 | if (strrchr($_SERVER['REQUEST_URI'], '#')) 42 | $any_s = $_SERVER['REQUEST_URI']; 43 | elseif (isset($i_any) && isset($i_any['s'])) 44 | $any_s = $i_any['s']; 45 | elseif (isset($i_s)) 46 | $any_s = $i_s; 47 | 48 | if (!is_null($any_s)) { 49 | $g = new Graph('', $_filename, '', $_SERVER['SCRIPT_URI']); 50 | $r = strlen($any_s) ? $g->remove_any($any_s) : 0; 51 | header('Triples: '.$r); 52 | if ($r) 53 | $g->save(); 54 | exit; 55 | } 56 | 57 | if (is_dir($_filename)) { 58 | if ($_options->recursive) 59 | rrmdir($_filename); 60 | else 61 | rmdir($_filename); 62 | } elseif (file_exists($_filename)) { 63 | unlink($_filename); 64 | } else { 65 | $g = new Graph('', $_filename, '', ''); 66 | if ($g->exists()) { 67 | $g->delete(); 68 | } else { 69 | httpStatusExit(404, 'Not Found'); 70 | } 71 | } 72 | 73 | if (file_exists($_filename)) 74 | httpStatusExit(409, 'Conflict'); 75 | -------------------------------------------------------------------------------- /www/root/rp_auth.php: -------------------------------------------------------------------------------- 1 | $_SERVER['REMOTE_ADDR'], 33 | 'continueUrl' => REQUEST_BASE.'/rp_callback', 34 | 'identifier' => strtolower($i_provider).'.com', 35 | ); 36 | $q = http('POST', $url, json_encode($q)); 37 | if ($q->status == 200) { 38 | $q = json_decode($q->body); 39 | if (isset($q->authUri)) { 40 | header('Location: '.$q->authUri); 41 | exit; 42 | } 43 | } else { 44 | $q = json_decode($q->body); 45 | if (isset($q->error)) 46 | echo $q->error->message; 47 | } 48 | -------------------------------------------------------------------------------- /www/root/s.php: -------------------------------------------------------------------------------- 1 | 'turtle', 36 | '/n3' => 'turtle', 37 | '/nt' => 'ntriples', 38 | '/rdf+n3' => 'turtle', 39 | '/rdf+nt' => 'ntriples', 40 | '/rdf+xml' => 'rdfxml', 41 | '/rdf' => 'rdfxml', 42 | '/html' => 'rdfa', 43 | '/xhtml' => 'rdfa', 44 | '/rss+xml' => 'rss-tag-soup', 45 | '/rss' => 'rss-tag-soup', 46 | '/json' => 'json', 47 | '/json-ld' => 'json-ld', 48 | ); 49 | 50 | // negotiation: process HTTP Content-Type 51 | $_input = ''; 52 | foreach ($_content_type_map as $needle=>$input) { 53 | if (strstr($_content_type, $needle) !== FALSE) { 54 | $_input = $input; 55 | break; 56 | } 57 | } 58 | 59 | -------------------------------------------------------------------------------- /www/root/auth-proxy.php: -------------------------------------------------------------------------------- 1 | linkmeta = false; 4 | 5 | if (isset($_REQUEST['uri'])) { 6 | $url = $_REQUEST['uri']; 7 | $ctype = $_SERVER["HTTP_ACCEPT"]; 8 | $origin = $_SERVER["HTTP_ORIGIN"]; 9 | 10 | // 11 | $cert_file = '../certs/agent.pem'; 12 | $cert_password = '123'; 13 | 14 | $ch = curl_init(); 15 | $options = array( 16 | CURLOPT_HTTPGET => true, 17 | CURLOPT_RETURNTRANSFER => true, 18 | CURLOPT_FOLLOWLOCATION => true, 19 | CURLOPT_MAXREDIRS => 3, 20 | CURLOPT_SSL_VERIFYHOST => false, 21 | CURLOPT_SSL_VERIFYPEER => false, 22 | CURLOPT_HTTPHEADER => array('On-Behalf-Of: '.$_user, 'Accept: '.$ctype, 'Origin: '.$origin), 23 | CURLOPT_USERAGENT => 'RWW Agent', 24 | CURLOPT_URL => $url, 25 | CURLOPT_SSLCERT => $cert_file, 26 | CURLOPT_SSLCERTPASSWD => $cert_password, 27 | //CURLINFO_HEADER_OUT => true, 28 | ); 29 | curl_setopt_array($ch , $options); 30 | 31 | $output = curl_exec($ch); 32 | if (!$output) { 33 | echo "Curl Error : " . curl_error($ch); 34 | } else if (DEBUG) { 35 | //echo "
".htmlentities($output)."
"; 36 | //echo "
".print_r(curl_getinfo($ch), true)."
"; 37 | //var_dump(curl_getinfo($ch,CURLINFO_HEADER_OUT)); 38 | } 39 | 40 | $ctype = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); 41 | $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); 42 | $clen = curl_getinfo($ch , CURLINFO_CONTENT_LENGTH_DOWNLOAD); 43 | 44 | // prepare response 45 | header("Content-Type: ".$ctype); 46 | header("Content-Length: ".$clen); 47 | header('Access-Control-Allow-Origin: '.$origin); 48 | header('Access-Control-Allow-Credentials: true'); 49 | header('User: '.$_user); 50 | echo $output; 51 | exit; 52 | } else { 53 | echo "

To use this WebID-TLS delegated authentication proxy, you need to add the following triple to your WebID profile:

\n"; 54 | echo "
".htmlentities("<#me>   ;")."
"; 55 | echo "

*replace #me with your own fragment idenfier or the graph in which you described yourself.

"; 56 | } 57 | 58 | -------------------------------------------------------------------------------- /py/wsgi-debug.py: -------------------------------------------------------------------------------- 1 | 2 | # websocket pubsub 3 | 4 | from jsonlib2 import dumps 5 | 6 | listeners = {} 7 | subscriptions = {} 8 | 9 | def cmd_pub(uri, data): 10 | uris = [uri] 11 | if uri[:5] == 'http:': uris.append('https:'+uri[5:]) 12 | elif uri[:6] == 'https:': uris.append('http:'+uri[6:]) 13 | for uri in uris: 14 | msg = ' '.join(('pub', uri, data)) 15 | for k in subscriptions.get(uri, {}).keys(): 16 | if k in listeners: 17 | listeners[k].put_nowait(msg) 18 | else: 19 | del subscriptions[uri][k] 20 | 21 | def proc(msg, sock=None): 22 | if not msg or not ' ' in msg or msg.find(' ', 1+msg.find(' ')) < 0: 23 | return 24 | cmd, uri, data = msg.split(' ', 2) 25 | cmd = cmd.lower() 26 | if cmd == 'pub': 27 | cmd_pub(uri, data) 28 | elif cmd == 'sub': 29 | if not uri in subscriptions: 30 | subscriptions[uri] = {} 31 | subscriptions[uri][sock] = True 32 | 33 | def http(environ, respond): 34 | path = environ['PATH_INFO'] or '' 35 | if path and path[0] == '/': 36 | path = path[1:] 37 | path = path.split('/', 1)[0] 38 | 39 | if path == 'debug': 40 | r = { 41 | 'listeners': map(repr, listeners.keys()), 42 | 'subscriptions': subscriptions, 43 | } 44 | respond('200 OK', [('Content-Type', 'text/json')]) 45 | return [dumps(r)] 46 | else: 47 | proc(environ['wsgi.input'].read()) 48 | respond('204 OK', []) 49 | return '' 50 | 51 | from wsgevent import Queue, Greenlet 52 | 53 | def application(environ, respond): 54 | sock = environ.get('wsgi.websocket') 55 | if sock is None: 56 | return http(environ, respond) 57 | 58 | listeners[sock] = out = Queue() 59 | 60 | def sender(): 61 | for msg in out: 62 | sock.send(msg) 63 | 64 | send = Greenlet(sender) 65 | send.start() 66 | 67 | try: 68 | while True: 69 | msg = sock.receive() 70 | if msg is None: 71 | break 72 | elif type(msg) is unicode: 73 | msg = msg.encode('utf-8') 74 | proc(msg, sock) 75 | 76 | except Exception, e: pass 77 | 78 | send.kill() 79 | del listeners[sock] 80 | 81 | -------------------------------------------------------------------------------- /www/wildcard/PUT.php: -------------------------------------------------------------------------------- 1 | can('Append') == false) && ($_wac->can('Write') == false)) 19 | httpStatusExit(403, 'Forbidden'); 20 | } else if ($_wac->can('Write') == false) { 21 | httpStatusExit(403, 'Forbidden'); 22 | } 23 | 24 | // check quota 25 | if (check_quota($_root, $_SERVER["CONTENT_LENGTH"]) == false) 26 | httpStatusExit(507, 'Insufficient Storage'); 27 | 28 | // check if we need to create a dir 29 | if (isset($_SERVER['HTTP_LINK'])) { 30 | $link_header = http_parse_link_header($_SERVER['HTTP_LINK']); 31 | // look for an ldp:Container in the Link header 32 | if (in_array('http://www.w3.org/ns/ldp#Container', $link_header) || in_array('http://www.w3.org/ns/ldp#BasicContainer', $link_header)) { 33 | @mkdir($_filename, 0777, true); 34 | header('Location: '.$_base); 35 | header("Link: <".dirname($_base)."/.meta.".basename($_filename).">; rel=meta", false); 36 | httpStatusExit(201, 'Created'); 37 | 38 | } 39 | } 40 | 41 | // action 42 | $d = dirname($_filename); 43 | if (!file_exists($d)) 44 | mkdir($d, 0777, true); 45 | 46 | $_data = file_get_contents('php://input'); 47 | 48 | if ($_input == 'raw') { 49 | require_once('if-match.php'); 50 | file_put_contents($_filename, $_data); 51 | header("Link: <".dirname($_base)."/.meta.".basename($_filename).">; rel=meta", false); 52 | httpStatusExit(201, 'Created'); 53 | } 54 | 55 | $g = new Graph('', $_filename, '', $_base); 56 | require_once('if-match.php'); 57 | 58 | $g->truncate(); 59 | if (!empty($_input) && $g->append($_input, $_data)) { 60 | librdf_php_last_log_level() && httpStatusExit(400, 'Bad Request', null, librdf_php_last_log_message()); 61 | $g->save(); 62 | header('ETag: "'.md5_file($_filename).'"'); 63 | header('Location: '.$_base); 64 | header("Link: <".dirname($_base)."/".basename($_filename).">; rel=meta", false); 65 | httpStatusExit(201, 'Created'); 66 | } else { 67 | librdf_php_last_log_level() && httpStatusExit(400, 'Bad Request', null, librdf_php_last_log_message()); 68 | header('Accept-Post: '.implode(',', $_content_types)); 69 | header("Link: <".$_base.">; rel=meta", false); 70 | httpStatusExit(406, 'Content-Type ('.$_content_type.') Not Acceptable'); 71 | } 72 | -------------------------------------------------------------------------------- /www/wildcard/ldp.php: -------------------------------------------------------------------------------- 1 | 0) { 13 | $_dir = $slug; 14 | } else { 15 | // try to find a dedicated LDPC prefix first 16 | $p = LDP_get_prefix($_metafile, $_metabase.$_metaname, 'http://ns.rww.io/ldpx#ldpcPrefix'); 17 | // else, try to find a generic prefix 18 | if (!$p) 19 | $p = LDP_get_prefix($_metafile, $_metabase.$_metaname, 'http://ns.rww.io/ldpx#ldprPrefix'); 20 | $prefix = ($p)?$p:LDPC_PREFIX; 21 | $g = glob($_filename.$prefix.'*'); 22 | $id = 0; 23 | foreach ($g as $f) { 24 | $i = substr($f, strlen($_filename.$prefix), strlen($_filename.$f)); 25 | if ((int)$i > $id) 26 | $id = (int)$i; 27 | } 28 | $id++; 29 | $_dir = $prefix.$id; 30 | } 31 | $d = $_filename.$_dir; 32 | // set the filename to the .meta file (we might need to post triples about the container there) 33 | $metafile = '.meta.'.$_dir; 34 | $aclfile = '.acl.'.$_dir; 35 | $_filename = $_filename.$metafile; 36 | $_dir = (strrpos($_dir, '/', -1))?$_dir:$_dir.'/'; // add trailing slash for dirs/containers 37 | $ldp_location = $_base.$_dir; 38 | 39 | if (!file_exists($d)) 40 | mkdir($d, 0777, true); 41 | 42 | $got_resource = false; 43 | } 44 | } 45 | 46 | if ($got_resource) { 47 | if (strlen($slug)> 0) { 48 | $metafile = $slug; 49 | } else { 50 | // generate and autoincrement file ID 51 | $p = LDP_get_prefix($_metafile, $_metabase.$_metaname, 'http://ns.rww.io/ldpx#ldprPrefix'); 52 | $prefix = ($p)?$p:LDPR_PREFIX; 53 | $g = glob($_filename.$prefix.'*'); 54 | $id = 0; 55 | foreach ($g as $f) { 56 | $i = substr($f, strlen($_filename.$prefix), strlen($_filename.$f)); 57 | if ((int)$i > $id) 58 | $id = (int)$i; 59 | } 60 | $id++; 61 | $metafile = $prefix.$id; 62 | } 63 | $aclfile = '.acl.'.$metafile; 64 | $_filename = $_filename.$metafile; 65 | $ldp_location = $_base.$metafile; 66 | } 67 | -------------------------------------------------------------------------------- /www/root/rp_callback.php: -------------------------------------------------------------------------------- 1 | $_SERVER['REMOTE_ADDR']); 32 | $q['requestUri'] = $continueUrl; 33 | $q['postBody'] = $response; 34 | $q = http('POST', 'https://www.googleapis.com/identitytoolkit/v1/relyingparty/verifyAssertion?key='.GAPIKEY, json_encode($q)); 35 | if ($q->status == 200) 36 | return json_decode($q->body, true); 37 | return array(); 38 | } 39 | 40 | $result = verify(REQUEST_URI, @file_get_contents('php://input')); 41 | $email = isset($result['verifiedEmail']) ? strtolower($result['verifiedEmail']) : ''; 42 | $name = isset($result['displayName']) ? $result['displayName'] : ''; 43 | $firstName = isset($result['firstName']) ? $result['firstName'] : ''; 44 | $lastName = isset($result['lastName']) ? $result['lastName'] : ''; 45 | if (strlen($email)) { 46 | sess('u:id', "mailto:$email"); 47 | sess('u:link', "mailto:$email"); 48 | sess('u:name', strlen($name) ? $name : $email); 49 | } 50 | 51 | $next = sess('next', null); 52 | if (!is_string($next) || !strlen($next)) 53 | $next = '/login'; 54 | ?> 55 | 64 | -------------------------------------------------------------------------------- /www/wildcard/output.php: -------------------------------------------------------------------------------- 1 | 'json-ld', 46 | '/json' => 'json', 47 | '/turtle' => 'turtle', 48 | '/n3' => 'turtle', 49 | '/nt' => 'ntriples', 50 | '/rdf+n3' => 'turtle', 51 | '/rdf+nt' => 'ntriples', 52 | '/rdf+xml' => 'rdfxml-abbrev', 53 | '/rdf' => 'rdfxml-abbrev', 54 | '/atom+xml' => 'atom', 55 | '/rss+xml' => 'rss-1.0', 56 | '/rss' => 'rss-1.0', 57 | '/dot' => 'dot', 58 | '/csv' => 'csv', 59 | '/tsv' => 'tsv', 60 | '/tab-separated-values' => 'tsv', 61 | '/html' => 'html' 62 | ); 63 | 64 | $_output = ''; 65 | $_output_type = null; 66 | foreach ($_accept_list as $haystack) { 67 | foreach ($_accept_type_map as $needle=>$output) { 68 | if (strstr($haystack, $needle) !==FALSE) { 69 | $_output = $output; 70 | $_output_type = $haystack; 71 | break; 72 | } 73 | } 74 | if (!empty($_output)) break; 75 | } 76 | if (empty($_output)) 77 | foreach (array_keys($_accept_data) as $haystack) { 78 | foreach ($_accept_type_map as $needle=>$output) { 79 | if (strstr($haystack, $needle) !==FALSE) { 80 | $_output = $output; 81 | $_output_type = $haystack; 82 | break; 83 | } 84 | } 85 | if (!empty($_output)) break; 86 | } 87 | 88 | -------------------------------------------------------------------------------- /www/inc/webid.lib.php: -------------------------------------------------------------------------------- 1 | array()); 5 | if (isset($_SERVER['SSL_CLIENT_CERT'])) { 6 | $pem = $_SERVER['SSL_CLIENT_CERT']; 7 | if ($pem) { 8 | $x509 = openssl_x509_read($pem); 9 | $pubKey = openssl_pkey_get_public($x509); 10 | $keyData = openssl_pkey_get_details($pubKey); 11 | if (isset($keyData['rsa'])) { 12 | if (isset($keyData['rsa']['n'])) 13 | $r['m'] = strtolower(array_pop(unpack("H*", $keyData['rsa']['n']))); 14 | if (isset($keyData['rsa']['e'])) 15 | $r['e'] = hexdec(array_shift(unpack("H*", $keyData['rsa']['e']))); 16 | } 17 | 18 | $d = openssl_x509_parse($x509); 19 | if (isset($d['extensions']) && isset($d['extensions']['subjectAltName'])) { 20 | foreach (explode(', ', $d['extensions']['subjectAltName']) as $elt) { 21 | if (substr($elt, 0, 4) == 'URI:') { 22 | $r['uri'][] = substr($elt, 4); 23 | } 24 | } 25 | } 26 | } 27 | } 28 | return $r; 29 | } 30 | 31 | function webid_query($uri) { 32 | $r = array(); 33 | $g = new Graph('uri', $uri, '', $uri); 34 | 35 | $q = $g->SELECT(sprintf("PREFIX : SELECT ?m ?e WHERE { <%s> :key [ :modulus ?m; :exponent ?e; ] . }", $uri)); 36 | if (isset($q['results']) && isset($q['results']['bindings'])) 37 | $r = $q['results']['bindings']; 38 | 39 | return $r; 40 | } 41 | 42 | function webid_verify($q=null) { 43 | if (is_null($q)) 44 | $q = webid_claim(); 45 | if (isset($q['uri'])) { 46 | foreach ($q['uri'] as $uri) { 47 | foreach (webid_query($uri) as $elt) { 48 | if ($q['e'] == $elt['e']['value'] && $q['m'] == strtolower(preg_replace('/[^0-9a-fA-F]/', '', $elt['m']['value']))) { 49 | return $uri; 50 | } 51 | } 52 | } 53 | } 54 | return ''; 55 | } 56 | 57 | function webid_getinfo($uri) { 58 | $g = new Graph('uri', $uri, '', $uri); 59 | $q = $g->SELECT(sprintf("PREFIX : 60 | SELECT ?name ?pic ?depic FROM <%s> WHERE { 61 | ?s a :Person . 62 | FILTER (?s = <%s>) . 63 | OPTIONAL { ?s :name ?name } . 64 | OPTIONAL { ?s :img ?pic } . 65 | OPTIONAL { ?s :depiction ?depic } . 66 | }", $uri, $uri)); 67 | 68 | if (isset($q['results']) && isset($q['results']['bindings'])) 69 | $r = $q['results']['bindings']; 70 | 71 | if (isset($r) && is_array($r) && sizeof($r) > 0) { 72 | $name = $r[0]['name']['value']; 73 | $pic = $r[0]['pic']['value']; 74 | $depic = $r[0]['depic']['value']; 75 | 76 | if (strlen($name) == 0) 77 | $name = 'No name'; 78 | 79 | if (strlen($pic) == 0) 80 | $pic = (strlen($depic) > 0)?$depic:'/common/images/nouser.png'; 81 | } else { 82 | $name = ''; 83 | $pic = '/common/images/nouser.png'; 84 | } 85 | 86 | return array('name' => $name, 'pic' => $pic); 87 | } 88 | -------------------------------------------------------------------------------- /www/root/login.php: -------------------------------------------------------------------------------- 1 | base_url.'/login'.newQSA()); 43 | exit; 44 | } 45 | } 46 | 47 | if (isset($i_provider)) { 48 | header('Location: '.REQUEST_BASE.'/rp_auth'.newQSA()); 49 | exit; 50 | } 51 | 52 | if (isset($i_display) && $i_display == 'popup') { 53 | $next = newQSA(array('display'=>NULL)); 54 | echo ""; 55 | 56 | } elseif (isset($i_id) && $i_id == 'facebook' && isset($i_session)) { 57 | $i_session = str_replace('\\', '', $i_session); 58 | $session = json_decode($i_session, true); 59 | if (isset($session['access_token'])) { 60 | $q = json_decode(file_get_contents('https://graph.facebook.com/me?fields=id,name,picture,link,username,email&access_token='.$session['access_token']), true); 61 | if (isset($q['id'])) { 62 | sess('f:id', $q['id']); 63 | sess('f:access_expires', $session['expires']); 64 | sess('f:access_token', $session['access_token']); 65 | sess('u:name', $q['name']); 66 | sess('u:link', $q['link']); 67 | $q['id'] = 'https://graph.facebook.com/'.$q['id']; 68 | sess('u:id', $q['id']); 69 | } 70 | } 71 | header('Location: '.REQUEST_BASE.'/login'); 72 | 73 | } elseif (isSess('next')) { 74 | $next = sess('next', null); 75 | header('Location: '.$next); 76 | 77 | } elseif ($_user) { 78 | header('Location: '.REQUEST_BASE.'/'); 79 | 80 | } else { 81 | require_once('401.php'); 82 | } 83 | -------------------------------------------------------------------------------- /www/certs/agent.pem: -------------------------------------------------------------------------------- 1 | Bag Attributes 2 | friendlyName: RWW Agent's WebID ID 3 | localKeyID: A3 3D F1 4F 1F B4 80 00 23 7F 75 10 B1 41 AF F3 05 52 6B 61 4 | Key Attributes: 5 | -----BEGIN PRIVATE KEY----- 6 | MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCjCJ9p2gtzBQkm 7 | x4AsSdcXz2gwCnutBnUKt8Q7o5WPcH6JMrVRg4zz2bQ37RMcODiloTBDx/jmxbrQ 8 | lKwgmbHxf/yOLk47d//lTztwAqcaPJWQyHJGTaV1VIETuf/uiyBTTteCPdKff2B8 9 | 5q4uLBhQaQ8yMHdajeZLUKBXK4kiWwgK5Nk740vdVyQLNSh9Szb2aqBqUkR+vfYA 10 | Ipga7R+5fErrvcOw2J6qPH2Senhb8r4viKEn3wk/xvjF6b3j4Zf9dOZiMV7nz2QP 11 | kDBCaYQxpOTfYgD0YxF6lgzwDzCFPAa4BcZj48sDUR65pEkwLHuG/ZsXAdNG02lF 12 | 1y0FXjg7AgMBAAECggEBAJ1huIn1fDH3fYMa+UdHrMUGajxeEk/QOPI0vdEYtEr4 13 | vJ3y/ogG5u2LjmaijF0khMKXHMGB7GvSGuo5awQ5ekZ4V7RlTQ4pZDTXzLfvR6KT 14 | M4rFhVMKp5vhDI2fc0mysmzZYj8PMSDZVKqeASz/UiVllc7MbJtU+ihgV7huhX5M 15 | OUJ8Qe9NM98xocIYPWLqjLRrgPzeDDWc+BEgWjd5i2XghAdqWxL+IECP8HaG2JzL 16 | iaJjd0E3Ii0p3fAKHyryI3nl9eexFHoAEVIORKx4eKlvvbKuHS5/dKSElupTM0aW 17 | B81O/i5WWw6AcexniIUpo/AckXWKow0n2efpobt8p8ECgYEA1uVeCHhXfar62VUg 18 | dJLa7HBFpgDYORkpTzfwcoCwL7S4f1yyj4sbvJIk7mYcnpkL9LAgM5OGAS2cITTw 19 | Dn8zV85/jLVkKzi9ZhGYU2Ad6mrUlYLGN9cZMTQLUHWZXEZ7iUeveN4nfRDn4teA 20 | RHunz2HpBwSgIioUX33ZhAxt+RsCgYEAwjfCB6PMBKkeTNMaJ85bPBxP6/Xnw6d8 21 | HW+xnhAGEFs2x7HVccDnKvXONXLyrNvtpvgtsejUFD7fYg+rjAPENY6n2mL2LP+v 22 | mMwjOMvr+l3C+vqetSzKxZTCYKTf+kyLi12KxoXPbjjeyD1oMZHRsUwIoYOEOeAx 23 | +2WfffQyz2ECgYEAjJw0NRKZHM89p+s9e0mEGeU0jXRMBsBh+UW+/Q0bO3vipOOA 24 | qs/47CAsLhl+bH/0BL0htN24dxji6g97a+DrNW8Wonkl++n6c8jbhOKFcJdKVjHl 25 | hTAnebx2EsV//ZLYznCrbkjeScVAFXuwoB7RJK8KDN+H8BLclccBBpgjdTUCgYAg 26 | oMFmCyyBM/A1M9nXCiHlrVP37i3rfr2pLFSIm2SJZumDDusu2xt66iSkchU22RPJ 27 | 0zPKCbVnWVCp5rwJH7Dc1oR4eduln6beYp0gM5IHU60oAOacxVOjceRd3BUMtcNT 28 | vHlN9LjuaXtz5G0WtsqloIJqr++M0Y9UDrSGsnm+wQKBgCAOoHoGQx5GKqSuUJ6c 29 | GzMW5QRPR4HGoS/ba1Vrj5qqLHaT3YhU888Y6FSM+MrHJQeCS9dfcchWJsRAY4uY 30 | 5bDPreOViLY9IcpLJLPe9bW7h5Vz6rHnBcyjgFWew5LhTx/Z7zHwzK0IMRwMTn5y 31 | SaI87rkBWozGiZvZ7cQpRKna 32 | -----END PRIVATE KEY----- 33 | Bag Attributes 34 | friendlyName: RWW Agent's WebID ID 35 | localKeyID: A3 3D F1 4F 1F B4 80 00 23 7F 75 10 B1 41 AF F3 05 52 6B 61 36 | subject=/C=US/ST=Some-State/O=WebID/CN=RWW Agent 37 | issuer=/C=US/ST=Some-State/O=WebID/CN=WebID 38 | -----BEGIN CERTIFICATE----- 39 | MIIDAzCCAmygAwIBAgIECtQ59zANBgkqhkiG9w0BAQUFADBCMQswCQYDVQQGEwJV 40 | UzETMBEGA1UECAwKU29tZS1TdGF0ZTEOMAwGA1UECgwFV2ViSUQxDjAMBgNVBAMM 41 | BVdlYklEMB4XDTE0MDUwNjAxMzgxMFoXDTE1MDUwMTAxMzgxMFowRjELMAkGA1UE 42 | BhMCVVMxEzARBgNVBAgMClNvbWUtU3RhdGUxDjAMBgNVBAoMBVdlYklEMRIwEAYD 43 | VQQDEwlSV1cgQWdlbnQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCj 44 | CJ9p2gtzBQkmx4AsSdcXz2gwCnutBnUKt8Q7o5WPcH6JMrVRg4zz2bQ37RMcODil 45 | oTBDx/jmxbrQlKwgmbHxf/yOLk47d//lTztwAqcaPJWQyHJGTaV1VIETuf/uiyBT 46 | TteCPdKff2B85q4uLBhQaQ8yMHdajeZLUKBXK4kiWwgK5Nk740vdVyQLNSh9Szb2 47 | aqBqUkR+vfYAIpga7R+5fErrvcOw2J6qPH2Senhb8r4viKEn3wk/xvjF6b3j4Zf9 48 | dOZiMV7nz2QPkDBCaYQxpOTfYgD0YxF6lgzwDzCFPAa4BcZj48sDUR65pEkwLHuG 49 | /ZsXAdNG02lF1y0FXjg7AgMBAAGjfjB8MAkGA1UdEwQCMAAwLwYDVR0RBCgwJoYk 50 | aHR0cHM6Ly9hZ2VudC5yd3cuaW8vcHJvZmlsZS9jYXJkI21lMB0GA1UdDgQWBBSL 51 | PDR+FDc3/TzbI/CLDRzLs1w+ozAfBgNVHSMEGDAWgBQ96IbAHTditkvWj0lXrpjt 52 | +JrUgjANBgkqhkiG9w0BAQUFAAOBgQAJo9C9GwDjspXSXDiQchx+s5lrkutA6FGp 53 | Hwh/pt8zTdc9xYFuE5wn1FTmVnRqUhH20YpLlqC+VyPYl25bRvT67Dmmse+mgrM6 54 | f9mzkxefKs/qdQbnYCiXn0As6QIQYRmtPOG/Iun0tEqeMpugzqC6YlZ9dctWyzIk 55 | lfI8O/vwJA== 56 | -----END CERTIFICATE----- 57 | -------------------------------------------------------------------------------- /www/inc/footer.php: -------------------------------------------------------------------------------- 1 | 40 |
41 |
42 | 49 | 50 |
51 | 77 | 78 |
79 |
80 |
81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /www/root/onboard/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: "Open Sans", Bitter, sans-serif; 3 | } 4 | .alert { 5 | color: red; 6 | } 7 | #login-links-container { 8 | background:#56565a;color:#fff;padding:3px; 9 | } 10 | .login-links { 11 | color:#fff;font-weight:bold;text-decoration:none; 12 | } 13 | .hide { 14 | display: none; 15 | } 16 | .show { 17 | display: block; 18 | } 19 | #signup-form { 20 | width: 350px; 21 | } 22 | input { 23 | padding: 0.5em; 24 | margin-left: 20px; 25 | } 26 | input.ng-invalid { 27 | border: 1px solid red; 28 | } 29 | input.ng-valid { 30 | border: 1px solid grey; 31 | } 32 | input[type=checkbox] 33 | { 34 | /* Double-sized Checkboxes */ 35 | -ms-transform: scale(1.5); /* IE */ 36 | -moz-transform: scale(1.5); /* FF */ 37 | -webkit-transform: scale(1.5); /* Safari and Chrome */ 38 | -o-transform: scale(1.5); /* Opera */ 39 | padding: 5px; 40 | margin-left: 5px; 41 | } 42 | select { 43 | padding: 0.5em; 44 | } 45 | small.error { 46 | display: block; 47 | padding: 0.375em 0.25em; 48 | margin-top: 0; 49 | margin-bottom: 1em; 50 | font-size: 0.75em; 51 | font-weight: bold; 52 | background: #c60f13; 53 | color: white; 54 | } 55 | button, .button { 56 | border-style: solid; 57 | border-width: 1px; 58 | cursor: pointer; 59 | font-family: inherit; 60 | font-weight: bold; 61 | line-height: normal; 62 | margin: 1em 0 0.5em; 63 | position: relative; 64 | text-decoration: none; 65 | text-align: center; 66 | display: inline-block; 67 | padding-top: 0.5em; 68 | padding-right: 0.65em; 69 | padding-bottom: 0.5em; 70 | padding-left: 0.5em; 71 | font-size: 1em; 72 | border-color: #2284a1; 73 | color: white; 74 | } 75 | 76 | button.disabled { 77 | background-color: #ccc; 78 | } 79 | button.enabled { 80 | background-color: #2ba6cb; 81 | } 82 | button.cancel { 83 | background-color: #fff; 84 | color: #000; 85 | } 86 | button.radius, .button.radius { 87 | -webkit-border-radius: 3px; 88 | border-radius: 3px; 89 | } 90 | .checkboxtext 91 | { 92 | font-size: 110%; 93 | display: inline; 94 | margin-left: 5px; 95 | } 96 | fieldset { 97 | border: 1px groove threedface; 98 | } 99 | .registration { 100 | padding-top: 40px; 101 | } 102 | nav { 103 | font-size: 13px; 104 | padding-left: 5px; 105 | } 106 | .navigation a { 107 | display: block; 108 | position: relative; 109 | float: left; 110 | height: 32px; 111 | box-sizing: border-box; 112 | min-height: 2em; 113 | 114 | margin-right: 2px; 115 | margin-bottom: 5px; 116 | 117 | text-decoration: none; 118 | font-family: sans-serif; 119 | color: #333; 120 | } 121 | .navigation a > .upperArrowElement { 122 | display: block; 123 | width: 100%; 124 | height: 50%; 125 | position: absolute; 126 | -webkit-transform: skewX(35deg); 127 | transform: skewX(35deg); 128 | background-color: #E5E6E8; 129 | } 130 | .navigation a > .lowerArrowElement { 131 | display: block; 132 | width: 100%; 133 | height: 50%; 134 | position: absolute; 135 | bottom: 0; 136 | -webkit-transform: skewX(-35deg); 137 | transform: skewX(-35deg); 138 | background-color: #E5E6E8; 139 | } 140 | .navigation a:hover > .lowerArrowElement, 141 | .navigation a:hover > .upperArrowElement { 142 | background-color: #2ba6cb; 143 | } 144 | .navigation a > .content { 145 | display: block; 146 | padding: 0.5em 1.3em; 147 | position: relative; 148 | top: 0; 149 | left: 0; 150 | } 151 | .navigation a:first-child > .content { 152 | left: -2px; 153 | } 154 | .navigation a:first-child::before { 155 | content: ''; 156 | display: block; 157 | position: absolute; 158 | background-color: #E5E6E8; 159 | height: 100%; 160 | width: 50%; 161 | top: 0; 162 | left: -5px; 163 | z-index: -1; 164 | } 165 | .navigation a:first-child::before { 166 | background-color: #fff; 167 | } 168 | .navigation a:first-child:hover::before { 169 | background-color: #fff; 170 | } 171 | .selected { 172 | background-color: #2ba6cb !important; 173 | } -------------------------------------------------------------------------------- /www/inc/arc2/parsers/ARC2_RDFParser.php: -------------------------------------------------------------------------------- 1 | 6 | * @license http://arc.semsol.org/license 7 | * @homepage 8 | * @package ARC2 9 | * @version 2010-11-16 10 | */ 11 | 12 | ARC2::inc('Class'); 13 | 14 | class ARC2_RDFParser extends ARC2_Class { 15 | 16 | function __construct($a, &$caller) { 17 | parent::__construct($a, $caller); 18 | } 19 | 20 | function __init() {/* proxy_host, proxy_port, proxy_skip, http_accept_header, http_user_agent_header, max_redirects, reader, skip_dupes */ 21 | parent::__init(); 22 | $this->a['format'] = $this->v('format', false, $this->a); 23 | $this->keep_time_limit = $this->v('keep_time_limit', 0, $this->a); 24 | $this->triples = array(); 25 | $this->t_count = 0; 26 | $this->added_triples = array(); 27 | $this->skip_dupes = $this->v('skip_dupes', false, $this->a); 28 | $this->bnode_prefix = $this->v('bnode_prefix', 'arc'.substr(md5(uniqid(rand())), 0, 4).'b', $this->a); 29 | $this->bnode_id = 0; 30 | $this->format = ''; 31 | } 32 | 33 | /* */ 34 | 35 | function setReader(&$reader) { 36 | $this->reader = $reader; 37 | } 38 | 39 | function parse($path, $data = '') { 40 | /* reader */ 41 | if (!isset($this->reader)) { 42 | ARC2::inc('Reader'); 43 | $this->reader = new ARC2_Reader($this->a, $this); 44 | } 45 | $this->reader->activate($path, $data) ; 46 | /* format detection */ 47 | $mappings = array( 48 | 'rdfxml' => 'RDFXML', 49 | 'turtle' => 'Turtle', 50 | 'sparqlxml' => 'SPOG', 51 | 'ntriples' => 'Turtle', 52 | 'html' => 'SemHTML', 53 | 'rss' => 'RSS', 54 | 'atom' => 'Atom', 55 | 'sgajson' => 'SGAJSON', 56 | 'cbjson' => 'CBJSON' 57 | ); 58 | $format = $this->reader->getFormat(); 59 | if (!$format || !isset($mappings[$format])) { 60 | return $this->addError('No parser available for "' . $format . '".'); 61 | } 62 | $this->format = $format; 63 | /* format parser */ 64 | $suffix = $mappings[$format] . 'Parser'; 65 | ARC2::inc($suffix); 66 | $cls = 'ARC2_' . $suffix; 67 | $this->parser = new $cls($this->a, $this); 68 | $this->parser->setReader($this->reader); 69 | return $this->parser->parse($path, $data); 70 | } 71 | 72 | function parseData($data) { 73 | return $this->parse(ARC2::getScriptURI(), $data); 74 | } 75 | 76 | /* */ 77 | 78 | function done() { 79 | } 80 | 81 | /* */ 82 | 83 | function createBnodeID(){ 84 | $this->bnode_id++; 85 | return '_:' . $this->bnode_prefix . $this->bnode_id; 86 | } 87 | 88 | function getTriples() { 89 | return $this->v('parser') ? $this->m('getTriples', false, array(), $this->v('parser')) : array(); 90 | } 91 | 92 | function countTriples() { 93 | return $this->v('parser') ? $this->m('countTriples', false, 0, $this->v('parser')) : 0; 94 | } 95 | 96 | function getSimpleIndex($flatten_objects = 1, $vals = '') { 97 | return ARC2::getSimpleIndex($this->getTriples(), $flatten_objects, $vals); 98 | } 99 | 100 | function reset() { 101 | $this->__init(); 102 | if (isset($this->reader)) unset($this->reader); 103 | if (isset($this->parser)) { 104 | $this->parser->__init(); 105 | unset($this->parser); 106 | } 107 | } 108 | 109 | /* */ 110 | 111 | function extractRDF($formats = '') { 112 | if (method_exists($this->parser, 'extractRDF')) { 113 | return $this->parser->extractRDF($formats); 114 | } 115 | } 116 | 117 | /* */ 118 | 119 | function getEncoding($src = 'config') { 120 | if (method_exists($this->parser, 'getEncoding')) { 121 | return $this->parser->getEncoding($src); 122 | } 123 | } 124 | 125 | /** 126 | * returns the array of namespace prefixes encountered during parsing 127 | * @return array (keys = namespace URI / values = prefix used) 128 | */ 129 | 130 | function getParsedNamespacePrefixes() { 131 | if (isset($this->parser)) { 132 | return $this->v('nsp', array(), $this->parser); 133 | } 134 | return $this->v('nsp', array()); 135 | } 136 | 137 | /* */ 138 | 139 | } 140 | -------------------------------------------------------------------------------- /www/wildcard/SPARQL.php: -------------------------------------------------------------------------------- 1 | ','{','}','"',';'); 14 | $pos = array(); 15 | foreach ($chr as $c) { 16 | $x = 0; 17 | while (FALSE != ($x = strpos($txt, $c, $x+1))) { 18 | if (!isset($pos[$c])) 19 | $pos[$c] = array(); 20 | $pos[$c][] = $x; 21 | } 22 | } 23 | $cidx = array(); 24 | foreach ($pos as $c=>$d) { 25 | foreach ($d as $i) { 26 | $cidx[$i] = $c; 27 | } 28 | } 29 | ksort($cidx, SORT_NUMERIC); 30 | $braces = 0; 31 | $brackd = false; 32 | $quoted = false; 33 | $r = array(); 34 | $i = 0; 35 | foreach ($cidx as $j=>$c) { 36 | switch ($c) { 37 | case ';': 38 | if (!$brackd && !$quoted && $braces < 1) { 39 | $r[] = substr($txt, $i, $j-$i); 40 | $i = $j+1; 41 | } 42 | break; 43 | case '<': 44 | if (!$quoted) 45 | $brackd = true; 46 | break; 47 | case '>': 48 | if ($brackd) 49 | $brackd = false; 50 | break; 51 | case '"': 52 | if (!$brackd) 53 | $quoted = !$quoted; 54 | break; 55 | case '{': 56 | if (!$brackd && !$quoted) 57 | $braces += 1; 58 | break; 59 | case '}': 60 | if (!$brackd && !$quoted) 61 | $braces -= 1; 62 | break; 63 | } 64 | } 65 | $r[] = substr($txt, $i); 66 | return $r; 67 | } 68 | 69 | require_once('arc2/ARC2.php'); 70 | 71 | function queryExecute($query, $g) { 72 | $parser = ARC2::getMITSPARQLParser(); 73 | $parser->parse($query); 74 | if (isset($parser->errors) && count($parser->errors)) 75 | queryError(implode("\n",$parser->errors)); 76 | 77 | $info = $parser->getQueryInfos(); 78 | $query = $info['query']; 79 | 80 | $assure_strings = array('type', 'target_graph'); 81 | $assure_arrays = array('dataset', 'target_graphs', 'construct_triples'); 82 | 83 | foreach ($assure_strings as $k=>$v) 84 | if (!isset($query[$v])) 85 | $query[$v] = ''; 86 | foreach ($assure_arrays as $k=>$v) 87 | if (!isset($query[$v])) 88 | $query[$v] = array(); 89 | foreach ($query as $k=>$v) 90 | if (!in_array($k, $assure_arrays) && !in_array($k, $assure_strings)) 91 | queryError('unsupported query feature: '.$k); 92 | 93 | if (!in_array($query['type'], array('insert', 'delete'))) 94 | queryError('valid query types: insert'); 95 | 96 | if (strlen($_base) && strlen($query['target_graph'])) { 97 | if ($query['target_graph'] != $_base) 98 | queryError('query must target request URI graph (only)'); 99 | if (count($query['target_graphs']) && $query['target_graphs'][0] != $_base) 100 | queryError('query must target request URI graph (only)'); 101 | } 102 | 103 | foreach ($query['construct_triples'] as $elt) 104 | foreach (array('s', 'p', 'o') as $k) 105 | if (!in_array($elt["{$k}_type"], array('uri', 'literal'))) 106 | queryError('unsupported node type: '.$elt[$k].' ('.$elt["{$k}_type"].')'); 107 | 108 | $n = 0; 109 | switch ($query['type']) { 110 | case 'insert': 111 | foreach ($query['construct_triples'] as $elt) { 112 | $g->append_objects($elt['s'], $elt['p'], array(array('type'=>$elt['o_type'], 'value'=>$elt['o']))); 113 | $n += 1; 114 | } 115 | break; 116 | case 'delete': 117 | foreach ($query['construct_triples'] as $elt) { 118 | $g->remove_triple($elt); 119 | $n += 1; 120 | } 121 | break; 122 | } 123 | 124 | return $n; 125 | } 126 | 127 | $n = 0; 128 | foreach (querySplit($_data) as $i=>$query) { 129 | $n += queryExecute($query, $g); 130 | } 131 | 132 | if ($n) 133 | $g->save($_data); 134 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | .. image:: http://fcns.eu/rww-logo.png 2 | :alt: RWW.IO 3 | :align: right 4 | 5 | RWW.IO 6 | ====== 7 | 8 | RWW.IO is a personal Linked Data store, intended to be used as a backend service for your Linked Data applications, and it 9 | supports the latest standards and recommendations: RDF, JSON-LD, SPARQL 1.1 Update, WebID. 10 | 11 | All data stores (endpoints) interpret the HTTP request URI as the base URI for RDF operations and the default-graph URI for SPARQL operations. When using the service as a backend, you need to follow two basic rules: 12 | 13 | - Specify the media type of your request data with a Content-Type HTTP header. 14 | - Specify your response type preference with an Accept HTTP header. 15 | 16 | 17 | Supported request methods: 18 | -------------------------- 19 | 20 | - Read: GET, HEAD, OPTIONS 21 | - Write: PUT, MKCOL, DELETE 22 | - Append: POST 23 | - Update: 24 | - JSON PATCH (application/json) 25 | - SPARQL POST (*/sparql-query) 26 | 27 | 28 | 29 | Supported response types 30 | ------------------------ 31 | 32 | - Web (index.html, style.css, script.js) 33 | - JSON (Accept */json) 34 | - JSON-P (GET ?callback=) 35 | - SPARQL JSON (GET/POST ?query=) 36 | - RSS (Accept */rss+xml) 37 | - Atom (Accept */atom+xml) 38 | 39 | 40 | RDF media types (defaults to text/turtle): 41 | ------------------------------------------ 42 | - JSON: application/json 43 | - NTriples: */rdf+nt, */nt 44 | - RDF/XML: */rdf+xml 45 | - RDFa: */html, */xhtml 46 | - Turtle: */turtle, */rdf+n3, */n3 47 | 48 | 49 | Current LDP support 50 | ------------------- 51 | 52 | - LDPC: 53 | - BasicContainer 54 | - GET, POST, PUT, DELETE, HEAD, OPTIONS 55 | - Full paging through Link headers 56 | - Prefer header 57 | - Accept-Post header 58 | 59 | - LDPR: 60 | - GET, POST, PUT, DELETE, HEAD, OPTIONS 61 | - If-Match and ETag 62 | 63 | - Pending: 64 | - PATCH 65 | - DirectContainer and IndirectContainer 66 | - Ordering/sorting 67 | 68 | 69 | 70 | Misc 71 | ---- 72 | 73 | Currently, the UI is minimal, allowing you to edit RDF documents and set ACL rules. Users can also upload a limited range of images (PNG, JPG and GIF - for all your cat pictures, wee!). 74 | 75 | In case users do not have a WebID, they can create one once they have selected their personal data store (i.e. deiu.example.com). 76 | 77 | This project is currently being developed entirely in my free time, so please consider supporting it. Thank you! 78 | 79 | RWW.IO is live at http://rww.io/ 80 | 81 | Installation 82 | ============ 83 | 84 | :: 85 | 86 | git clone https://github.com/deiu/rww.io.git 87 | 88 | 89 | - Check the apache conf files and change paths to your own server 90 | 91 | - Requires librdf for php 92 | 93 | :: 94 | 95 | sudo apt-get install php5-librdf php5-json librdf0 librdf0-dev raptor2-utils libraptor2-dev libraptor2-0 96 | 97 | 98 | - You need to create a default storage location for your users' personal data stores. If you installed RWW.IO under /var/www/rww.io/, then you have to manually create the /data/ directory under that path (/var/www/rww.io/data/). Don't forget to make the /data/ directory writable by the web server user! 99 | 100 | Possible issues 101 | =============== 102 | 103 | - In case you run into either ``Call to undefined function json_decode()`` or ``Call to undefined function librdf_new_world()``, you may have to add the following lines to your php.ini file: 104 | :: 105 | 106 | extension = json.so 107 | extension = redland.so 108 | 109 | 110 | - If you run into this Apache issue: ``VirtualHost overlap on port 443, the first has precedence``, please open the file /etc/apache2/ports.conf and make sure the ```` directive also contains ``NameVirtualHost *:443`` 111 | 112 | 113 | Documentation 114 | ============= 115 | 116 | At this point, the only existing documentation is the commented code. Until proper documentation will be available, do not hesitate to contact me with questions. 117 | 118 | 119 | License 120 | ======= 121 | MIT (see LICENSE file) 122 | 123 | 124 | Support and donations 125 | ===================== 126 | 127 | You can help with the costs of running the website at http://rww.io/ by donating through the following links: 128 | 129 | - Bitcoin: https://coinbase.com/checkouts/ed957952a941abf15d50696973fa4b92 130 | - Paypal: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YCG7HFRPTVD4A 131 | - Flattr: https://flattr.com/thing/1748916/ 132 | 133 | Every bit of cash helps. Thank you! :-) 134 | 135 | 136 | -------------------------------------------------------------------------------- /www/root/help.php: -------------------------------------------------------------------------------- 1 | 31 | 32 |
33 | 34 | Fork me on GitHub 35 |
36 |

This web data platform supports the latest standards and recommendations:

37 | 41 | 42 |

All endpoints interpret the HTTP request URI as the base URI for RDF operations and the default-graph URI for SPARQL operations.

43 |

Specify the media type of your request data with a Content-Type HTTP header.
44 | Specify your response type preference with an Accept HTTP header.

45 | 46 |
47 |

Request methods:

48 |
    49 |
  • Read: GET, HEAD, OPTIONS
  • 50 |
  • Write: PUT, MKCOL, DELETE
  • 51 |
  • Append: POST
  • 52 |
  • Update: 53 |
      54 |
    • JSON PATCH (application/json)
    • 55 |
    • SPARQL POST (*/sparql-query)
    • 56 |
    57 |
  • 58 |
59 |
60 | 61 |
62 |

Response types:

63 |
    64 |
  • Web (index.html, style.css, script.js)
  • 65 |
  • JSON (Accept */json)
  • 66 |
  • JSON-P (GET ?callback=)
  • 67 |
  • SPARQL JSON (GET/POST ?query=)
  • 68 |
  • RSS (Accept */rss+xml)
  • 69 |
  • Atom (Accept */atom+xml)
  • 70 |
71 |
72 | 73 |
74 |

RDF media types:

75 |
    76 |
  • JSON: application/json
  • 77 |
  • NTriples: */rdf+nt, */nt
  • 78 |
  • RDF/XML: */rdf+xml
  • 79 |
  • RDFa: */html, */xhtml
  • 80 |
  • Turtle: */turtle, */rdf+n3, */n3
  • 81 |
82 | (defaults to Turtle) 83 |
84 | 85 | 86 |
87 |
88 |
*/type
refers to a media type, specified in HTTP header (Accept or Content-Type)
89 |
name.ext
refers to a filename, specified by HTTP request URI
90 |
?k=v
refers to a query string parameter 'k' with value 'v': passed in URL via GET or application/x-www-form-urlencoded via POST
91 |
92 |

Some query string options and response (HTTP Accept) media types are complementary.

93 |
94 | 95 | 96 |
97 |
98 | 99 |

All uses of this service must comply with the MITnet rules of use.

100 | 101 | 102 | 103 | 46 | 47 | 48 | 49 | <?=$_SERVER['SERVER_NAME']?>: <?=$TITLE?> 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 63 | 64 | 65 | 68 | 69 | 70 |
71 | 72 | $v) { 75 | if ($k > 0) { 76 | $plen .= $v; 77 | if (strlen($plen) < 45) { 78 | echo '', urldecode($v), ''; 79 | } else { 80 | echo '...'; 81 | break; 82 | } 83 | } 84 | echo ' / '; 85 | } ?> 86 | 87 | 88 | 91 | 99 | 100 | 105 | 109 |
110 | base_url = ''; 57 | $_options->coderev = true; 58 | $_options->debug = true; 59 | $_options->editui = true; 60 | $_options->glob = false; 61 | $_options->open = true; 62 | $_options->recursive = false; 63 | $_options->sqlite = false; 64 | $_options->linkmeta = true; 65 | $_options->wiki = false; 66 | if (file_exists(dirname(__FILE__).'/config.inc.php')) { 67 | require_once(dirname(__FILE__).'/config.inc.php'); 68 | } 69 | 70 | # init user ID 71 | $_user = $_user_name = ''; 72 | if (!isset($_SERVER['REMOTE_USER'])) $_SERVER['REMOTE_USER'] = ''; 73 | foreach (array($_SERVER['REMOTE_USER'], sess('u:id')) as $_user) { 74 | if (!is_null($_user) && strlen($_user)) 75 | break; 76 | } 77 | 78 | if (isset($_SERVER['SSL_CLIENT_CERT'])) { 79 | require_once('webid.lib.php'); 80 | $q = webid_claim(); 81 | if (isset($q['uri']) && $q['uri'] != $_user) { 82 | $_user = webid_verify($q); 83 | $_webid = webid_getinfo($_user); 84 | 85 | if (DEBUG) { 86 | openlog('RWW.IO', LOG_PID | LOG_ODELAY,LOG_LOCAL4); 87 | syslog(LOG_INFO, 'Authenticated: '.$_user.' / '.$_webid['name']); 88 | closelog(); 89 | } 90 | 91 | //if (!isSess('u:name')) 92 | sess('u:name', $_webid['name']); 93 | //if (!isSess('u:pic')) 94 | sess('u:pic', $_webid['pic']); 95 | 96 | if (strlen($_user) && isset($_SERVER['SSL_CLIENT_S_DN_CN'])) 97 | $_user_name = $_SERVER['SSL_CLIENT_S_DN_CN']; 98 | } 99 | } 100 | 101 | # proper Emails 102 | if (substr($_user, 0, 4) != 'http') 103 | if (substr($_user, 0, 7) != 'mailto:' && stristr($_user,'@')) 104 | $_user = "mailto:$_user"; 105 | 106 | # fallback to DNS 107 | if (empty($_user)) 108 | $_user = 'dns:'.$_SERVER['REMOTE_ADDR']; 109 | elseif (sess('u:id') != $_user) 110 | sess('u:id', $_user); 111 | 112 | foreach (array('HTTP_OPTIONS', 'HTTP_X_OPTIONS') as $k0) 113 | if (isset($_SERVER[$k0])) 114 | foreach (explode(',',$_SERVER[$k0]) as $elt) { 115 | $k = strtolower(trim($elt)); 116 | $v = true; 117 | if ($k[0] == 'n' && $k[1] == 'o') { 118 | $k = substr($k, 2); 119 | $v = false; 120 | } 121 | if (in_array($k, array('open'))) continue; 122 | if (isset($_options->$k)) 123 | $_options->$k = $v; 124 | } 125 | 126 | # ensure user props 127 | if (sess('u:id')) { 128 | if (!isSess('u:link')) sess('u:link', $_user); 129 | if (!isSess('u:name')) { 130 | $_user_name = basename($_user); 131 | $c = strpos($_user_name, ':'); 132 | if ($c > 0) 133 | $_user_name = substr($_user_name, $c+1); 134 | sess('u:name', $_user_name); 135 | } 136 | } 137 | 138 | header("User: $_user"); 139 | 140 | // HTTP Access Control 141 | if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) 142 | header('Access-Control-Allow-Headers: '.$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']); 143 | if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD'])) 144 | header('Access-Control-Allow-Methods: '.$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']); 145 | if (isset($_SERVER['HTTP_ORIGIN'])) { 146 | $t = explode('/', $_SERVER['HTTP_ORIGIN']); 147 | if (count($t) > 2) { 148 | $n = "{$t[0]}//{$t[2]}"; 149 | } else { 150 | $n = '*'; 151 | } 152 | header('Access-Control-Allow-Origin: '.$n); 153 | header('Access-Control-Expose-Headers: User, Triples, Location, Link, Vary, Last-Modified'); 154 | header('Access-Control-Allow-Credentials: true'); 155 | } 156 | 157 | 158 | TAG(__FILE__, __LINE__, '$Id$'); 159 | -------------------------------------------------------------------------------- /www/wildcard/runtime.php: -------------------------------------------------------------------------------- 1 | array('short'=>'font', 'type'=>'font/otf'), 21 | 'css'=>array('short'=>'text', 'type'=>'text/css'), 22 | 'htm'=>array('short'=>'text', 'type'=>'text/htm'), 23 | 'html'=>array('short'=>'text', 'type'=>'text/html'), 24 | 'js'=>array('short'=>'text', 'type'=>'text/javascript'), 25 | 'jpg'=>array('short'=>'image', 'type'=>'image/jpg'), 26 | 'jpeg'=>array('short'=>'image', 'type'=>'image/jpg'), 27 | 'png'=>array('short'=>'image', 'type'=>'image/png'), 28 | 'gif'=>array('short'=>'image', 'type'=>'image/gif'), 29 | 'txt'=>array('short'=>'text', 'type'=>'text/txt'), 30 | 'ttl'=>array('short'=>'turtle', 'type'=>'text/turtle'), 31 | 'n3'=>array('short'=>'n3', 'type'=>'text/n3'), 32 | 'nt'=>array('short'=>'nt', 'type'=>'text/nt'), 33 | ); 34 | 35 | $_content_types = array( 36 | 'text/turtle;charset=utf-8', 37 | 'text/n3;charset=utf-8', 38 | 'text/nt;charset=utf-8', 39 | 'text/css;charset=utf-8', 40 | 'text/html;charset=utf-8', 41 | 'text/javascript;charset=utf-8', 42 | 'text/plain;charset=utf-8', 43 | 'application/rdf+xml;charset=utf-8', 44 | 'application/json;charset=utf-8', 45 | 'multipart/form-data', 46 | 'image/jpeg', 47 | 'image/jpeg', 48 | 'image/png', 49 | 'image/gif', 50 | 'font/otf' 51 | ); 52 | 53 | header("User: $_user"); 54 | 55 | // Cloud 56 | if (!isset($_SERVER['SCRIPT_URL'])) 57 | $_SERVER['SCRIPT_URL'] = isset($_SERVER['REDIRECT_URL']) ? $_SERVER['REDIRECT_URL'] : $_SERVER['REQUEST_URI']; 58 | if (strpos($_SERVER['SCRIPT_URL'], '?')) 59 | $_SERVER['SCRIPT_URL'] = strstr($_SERVER['SCRIPT_URL'], '?', true); 60 | if (!isset($_SERVER['SCRIPT_URI'])) 61 | $_SERVER['SCRIPT_URI'] = REQUEST_BASE.$_SERVER['SCRIPT_URL']; 62 | $_base = $_SERVER['SCRIPT_URI']; 63 | $_domain = $_SERVER['SERVER_NAME']; 64 | $_root = $_ENV['CLOUD_DATA'].'/'.$_SERVER['SERVER_NAME']; 65 | 66 | // Graph 67 | $_filebase = $_ENV['CLOUD_DATA'].'/'.$_SERVER['SERVER_NAME']; 68 | $_filename = $_SERVER['SCRIPT_URL']; 69 | $_filename_ext = strrpos($_filename, '.'); 70 | $_filename_ext = $_filename_ext ? substr($_filename, 1+$_filename_ext) : ''; 71 | if (!strlen($_filename) || $_filename[0] != '/') 72 | $_filename = "/$_filename"; 73 | if (substr($_filename, 0, strlen($_filebase)) != $_filebase) 74 | $_filename = "$_filebase$_filename"; 75 | $_request_path = substr($_filename, strlen($_filebase)); 76 | 77 | // meta 78 | $_metabase = ($_SERVER['SCRIPT_URL'] != '/')?dirname($_base):$_base; 79 | $_metafile = ($_SERVER['SCRIPT_URL'] != '/')?dirname($_filename).'/.meta.'.basename($_SERVER['SCRIPT_URL']):$_filename.'.meta.'.basename($_SERVER['SCRIPT_URL']); 80 | $_metaname = ($_SERVER['SCRIPT_URL'] != '/')?'/.meta.'.basename($_SERVER['SCRIPT_URL']):'.meta'; 81 | 82 | // Web Access Control 83 | $_wac = new WAC($_user, $_filename, $_base, $_options->linkmeta); 84 | 85 | // WebDAV 86 | header('MS-Author-Via: DAV, SPARQL'); 87 | 88 | // HTTP Access Control 89 | if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) 90 | header('Access-Control-Allow-Headers: '.$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']); 91 | if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD'])) 92 | header('Access-Control-Allow-Methods: '.$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']); 93 | if (isset($_SERVER['HTTP_ORIGIN'])) { 94 | $t = explode('/', $_SERVER['HTTP_ORIGIN']); 95 | if (count($t) > 2) { 96 | $n = "{$t[0]}//{$t[2]}"; 97 | } else { 98 | $n = '*'; 99 | } 100 | header('Access-Control-Allow-Origin: '.$n); 101 | header('Access-Control-Expose-Headers: User, Triples, Location, Link, Vary, Last-Modified'); 102 | header('Access-Control-Allow-Credentials: true'); 103 | } 104 | 105 | // HTTP Methods 106 | $_method = ''; 107 | foreach (array('REQUEST_METHOD', 'REDIRECT_REQUEST_METHOD') as $k) { 108 | if (isset($_SERVER[$k])) { 109 | $_method = strtoupper($_SERVER[$k]); 110 | break; 111 | } 112 | } 113 | 114 | // Add default headers 115 | header('Allow: '.METHODS_S); 116 | header('Accept-Patch: application/json'); 117 | header('Accept-Post: '.implode(',', $_content_types)); 118 | 119 | if ($_method == 'OPTIONS') { 120 | header('HTTP/1.1 200 OK'); 121 | 122 | // add LDP types 123 | if (is_dir($_filename) || substr($_filename,-1) == '/') 124 | header("Link: ; rel=type", false); 125 | // always add ldp#Resource 126 | header("Link: ; rel=type", false); 127 | 128 | if (!isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD'])) 129 | header('Access-Control-Allow-Methods: '.METHODS_S); 130 | if (!isset($_SERVER['HTTP_ORIGIN'])) 131 | header('Access-Control-Allow-Origin: *'); 132 | 133 | header('Access-Control-Expose-Headers: User'); 134 | exit; 135 | } 136 | 137 | // HTTP Content Negotiation 138 | require_once('input.php'); 139 | require_once('output.php'); 140 | if (isset($_RAW_EXT[$_filename_ext])) { 141 | if ((substr(basename($_filename), 0, 5) == '.meta') || 142 | (substr(basename($_filename), 0, 4) == '.acl')) { 143 | $_output = 'turtle'; 144 | $_output_type = 'text/turtle'; 145 | } else { 146 | $_input = 'raw'; 147 | $_output = 'raw'; 148 | $_output_type = $_RAW_EXT[$_filename_ext]['type']; 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /www/root/common/images/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 25 | 27 | 34 | 36 | 40 | 44 | 45 | 55 | 56 | 79 | 94 | 95 | 97 | 98 | 100 | image/svg+xml 101 | 103 | icon_cube_green 104 | 2008-05-09 105 | 106 | 107 | Jean-Victor Balin 108 | 109 | 110 | jean.victor.balin@gmail.com 111 | 113 | 114 | 115 | icon 116 | cube 117 | 118 | 119 | 120 | 122 | 124 | 126 | 128 | 129 | 130 | 131 | 136 | 139 | 144 | 147 | 153 | 159 | 165 | 166 | 167 | 168 | 169 | -------------------------------------------------------------------------------- /www/inc/arc2/parsers/ARC2_SPARQLPlusParser.php: -------------------------------------------------------------------------------- 1 | xPrologue($v); 27 | foreach (array('Select', 'Construct', 'Describe', 'Ask', 'Insert', 'Delete', 'Load') as $type) { 28 | $m = 'x' . $type . 'Query'; 29 | if ((list($r, $v) = $this->$m($v)) && $r) { 30 | return array($r, $v); 31 | } 32 | } 33 | return array(0, $v); 34 | } 35 | 36 | /* +3 */ 37 | 38 | function xResultVar($v) { 39 | $aggregate = ''; 40 | /* aggregate */ 41 | if ($sub_r = $this->x('\(?(AVG|COUNT|MAX|MIN|SUM)\s*\(\s*([^\)]+)\)\s+AS\s+([^\s\)]+)\)?', $v)) { 42 | $aggregate = $sub_r[1]; 43 | $result_var = $sub_r[3]; 44 | $v = $sub_r[2] . $sub_r[4]; 45 | } 46 | if ($sub_r && (list($sub_r, $sub_v) = $this->xVar($result_var)) && $sub_r) { 47 | $result_var = $sub_r['value']; 48 | } 49 | /* * or var */ 50 | if ((list($sub_r, $sub_v) = $this->x('\*', $v)) && $sub_r) { 51 | return array(array('var' => $sub_r['value'], 'aggregate' => $aggregate, 'alias' => $aggregate ? $result_var : ''), $sub_v); 52 | } 53 | if ((list($sub_r, $sub_v) = $this->xVar($v)) && $sub_r) { 54 | return array(array('var' => $sub_r['value'], 'aggregate' => $aggregate, 'alias' => $aggregate ? $result_var : ''), $sub_v); 55 | } 56 | return array(0, $v); 57 | } 58 | 59 | /* +4 */ 60 | 61 | function xLoadQuery($v) { 62 | if ($sub_r = $this->x('LOAD\s+', $v)) { 63 | $sub_v = $sub_r[1]; 64 | if ((list($sub_r, $sub_v) = $this->xIRIref($sub_v)) && $sub_r) { 65 | $r = array('type' => 'load', 'url' => $sub_r, 'target_graph' => ''); 66 | if ($sub_r = $this->x('INTO\s+', $sub_v)) { 67 | $sub_v = $sub_r[1]; 68 | if ((list($sub_r, $sub_v) = $this->xIRIref($sub_v)) && $sub_r) { 69 | $r['target_graph'] = $sub_r; 70 | } 71 | } 72 | return array($r, $sub_v); 73 | } 74 | } 75 | return array(0, $v); 76 | } 77 | 78 | /* +5 */ 79 | 80 | function xInsertQuery($v) { 81 | if ($sub_r = $this->x('INSERT\s+', $v)) { 82 | $r = array( 83 | 'type' => 'insert', 84 | 'dataset' => array(), 85 | ); 86 | $sub_v = $sub_r[1]; 87 | /* target */ 88 | if ($sub_r = $this->x('INTO\s+', $sub_v)) { 89 | $sub_v = $sub_r[1]; 90 | if ((list($sub_r, $sub_v) = $this->xIRIref($sub_v)) && $sub_r) { 91 | $r['target_graph'] = $sub_r; 92 | /* CONSTRUCT keyword, optional */ 93 | if ($sub_r = $this->x('CONSTRUCT\s+', $sub_v)) { 94 | $sub_v = $sub_r[1]; 95 | } 96 | /* construct template */ 97 | if ((list($sub_r, $sub_v) = $this->xConstructTemplate($sub_v)) && is_array($sub_r)) { 98 | $r['construct_triples'] = $sub_r; 99 | } 100 | else { 101 | $this->addError('Construct Template not found'); 102 | return array(0, $v); 103 | } 104 | /* dataset */ 105 | while ((list($sub_r, $sub_v) = $this->xDatasetClause($sub_v)) && $sub_r) { 106 | $r['dataset'][] = $sub_r; 107 | } 108 | /* where */ 109 | if ((list($sub_r, $sub_v) = $this->xWhereClause($sub_v)) && $sub_r) { 110 | $r['pattern'] = $sub_r; 111 | } 112 | /* solution modifier */ 113 | if ((list($sub_r, $sub_v) = $this->xSolutionModifier($sub_v)) && $sub_r) { 114 | $r = array_merge($r, $sub_r); 115 | } 116 | return array($r, $sub_v); 117 | } 118 | } 119 | } 120 | return array(0, $v); 121 | } 122 | 123 | /* +6 */ 124 | 125 | function xDeleteQuery($v) { 126 | if ($sub_r = $this->x('DELETE\s+', $v)) { 127 | $r = array( 128 | 'type' => 'delete', 129 | 'target_graphs' => array() 130 | ); 131 | $sub_v = $sub_r[1]; 132 | /* target */ 133 | do { 134 | $proceed = false; 135 | if ($sub_r = $this->x('FROM\s+', $sub_v)) { 136 | $sub_v = $sub_r[1]; 137 | if ((list($sub_r, $sub_v) = $this->xIRIref($sub_v)) && $sub_r) { 138 | $r['target_graphs'][] = $sub_r; 139 | $proceed = 1; 140 | } 141 | } 142 | } while ($proceed); 143 | /* CONSTRUCT keyword, optional */ 144 | if ($sub_r = $this->x('CONSTRUCT\s+', $sub_v)) { 145 | $sub_v = $sub_r[1]; 146 | } 147 | /* construct template */ 148 | if ((list($sub_r, $sub_v) = $this->xConstructTemplate($sub_v)) && is_array($sub_r)) { 149 | $r['construct_triples'] = $sub_r; 150 | /* dataset */ 151 | while ((list($sub_r, $sub_v) = $this->xDatasetClause($sub_v)) && $sub_r) { 152 | $r['dataset'][] = $sub_r; 153 | } 154 | /* where */ 155 | if ((list($sub_r, $sub_v) = $this->xWhereClause($sub_v)) && $sub_r) { 156 | $r['pattern'] = $sub_r; 157 | } 158 | /* solution modifier */ 159 | if ((list($sub_r, $sub_v) = $this->xSolutionModifier($sub_v)) && $sub_r) { 160 | $r = array_merge($r, $sub_r); 161 | } 162 | } 163 | return array($r, $sub_v); 164 | } 165 | return array(0, $v); 166 | } 167 | 168 | /* +7 */ 169 | 170 | function xSolutionModifier($v) { 171 | $r = array(); 172 | if ((list($sub_r, $sub_v) = $this->xGroupClause($v)) && $sub_r) { 173 | $r['group_infos'] = $sub_r; 174 | } 175 | if ((list($sub_r, $sub_v) = $this->xOrderClause($sub_v)) && $sub_r) { 176 | $r['order_infos'] = $sub_r; 177 | } 178 | while ((list($sub_r, $sub_v) = $this->xLimitOrOffsetClause($sub_v)) && $sub_r) { 179 | $r = array_merge($r, $sub_r); 180 | } 181 | return ($v == $sub_v) ? array(0, $v) : array($r, $sub_v); 182 | } 183 | 184 | /* +8 */ 185 | 186 | function xGroupClause($v) { 187 | if ($sub_r = $this->x('GROUP BY\s+', $v)) { 188 | $sub_v = $sub_r[1]; 189 | $r = array(); 190 | do { 191 | $proceed = 0; 192 | if ((list($sub_r, $sub_v) = $this->xVar($sub_v)) && $sub_r) { 193 | $r[] = $sub_r; 194 | $proceed = 1; 195 | if ($sub_r = $this->x('\,', $sub_v)) { 196 | $sub_v = $sub_r[1]; 197 | } 198 | } 199 | } while ($proceed); 200 | if (count($r)) { 201 | return array($r, $sub_v); 202 | } 203 | else { 204 | $this->addError('No columns specified in GROUP BY clause.'); 205 | } 206 | } 207 | return array(0, $v); 208 | } 209 | 210 | } 211 | -------------------------------------------------------------------------------- /www/wildcard/POST.php: -------------------------------------------------------------------------------- 1 | can('Append') || $can = $_wac->can('Write')) 24 | $can = true; 25 | if (DEBUG) { 26 | openlog('RWW.IO', LOG_PID | LOG_ODELAY,LOG_LOCAL4); 27 | foreach($_wac->getDebug() as $line) 28 | syslog(LOG_INFO, $line); 29 | syslog(LOG_INFO, 'Verdict: '.$can.' / '.$_wac->getReason()); 30 | closelog(); 31 | } 32 | if ($can == false) { 33 | if ($_output == 'html') 34 | httpStatusExit(403, 'Forbidden', '403-404.php'); 35 | else 36 | httpStatusExit(403, 'Forbidden'); 37 | } 38 | 39 | // intercept requests for WebID generator 40 | if (isset($_POST['SPKAC'])) { 41 | require_once '../inc/webidgen.php'; 42 | // exit required so it can successfully send the certificate 43 | exit; 44 | } 45 | 46 | // check quota 47 | if (check_quota($_root, $_SERVER["CONTENT_LENGTH"]) == false) 48 | httpStatusExit(507, 'Insufficient Storage'); 49 | 50 | // create dir structure if it doesn't exist 51 | $d = dirname($_filename); 52 | if (!file_exists($d)) 53 | mkdir($d, 0777, true); 54 | 55 | // intercept requests for images 56 | if (isset($_FILES["image"])) { 57 | // Check if the user uploaded a new picture 58 | if ((isset($_FILES['image'])) && ($_FILES['image']['error'] == 0)) { 59 | // Allow only pictures with a size smaller than 5MB 60 | if ($_FILES['image']['size'] <= IMAGE_SIZE) { 61 | // Using getimagesize() to avoid fake mime types 62 | $image_info = exif_imagetype($_FILES['image']['tmp_name']); 63 | switch ($image_info) { 64 | case IMAGETYPE_GIF: 65 | if (!move_uploaded_file($_FILES['image']['tmp_name'], $_filename.$_FILES['image']['name'])) 66 | echo 'Could not copy the picture to the user\'s dir. Please check permissions.'; 67 | break; 68 | case IMAGETYPE_JPEG: 69 | if (!move_uploaded_file($_FILES['image']['tmp_name'], $_filename.$_FILES['image']['name'])) 70 | echo 'Could not copy the picture to the user\'s dir. Please check permissions.'; 71 | break; 72 | case IMAGETYPE_PNG: 73 | if (!move_uploaded_file($_FILES['image']['tmp_name'], $_filename.'/'.$_FILES['image']['name'])) 74 | echo 'Could not copy the picture to the user\'s dir. Please check permissions.'; 75 | break; 76 | default: 77 | echo 'The selected image format is not supported.'; 78 | break; 79 | } 80 | } else { 81 | echo 'The image size is too large. The maximum allowed size is 5MB.'; 82 | httpStatusExit(513, 'Request Entity Too Large'); 83 | } 84 | } 85 | // refresh and exit 86 | header('Location: '.$_SERVER["REDIRECT_SCRIPT_URI"]); 87 | exit; 88 | } 89 | 90 | // check if we post using LDP (by posting to a dir) 91 | if (is_dir($_filename) && $_content_type == 'text/turtle') { 92 | include('ldp.php'); 93 | } else { 94 | $metafile = ''; 95 | $ldp_location = $_base; 96 | } 97 | 98 | $_data = file_get_contents('php://input'); 99 | 100 | if ($_input == 'raw') { 101 | require_once('if-match.php'); 102 | file_put_contents($_filename, $_data, FILE_APPEND | LOCK_EX); 103 | httpStatusExit(201, 'Created'); 104 | } 105 | 106 | $g = new Graph('', $_filename, '', $_base); 107 | require_once('if-match.php'); 108 | 109 | if ($_method == 'PATCH') { 110 | if ($_input == 'json' && ($g->patch_json($_data) || 1)) { 111 | librdf_php_last_log_level() && httpStatusExit(400, 'Bad Request', null, librdf_php_last_log_message()); 112 | $g->save(); 113 | header('Triples: '.$g->size()); 114 | header("Link: <".dirname($_base).'/'.$metafile.">; rel=meta", false); 115 | header('Location: '.$ldp_location); 116 | httpStatusExit(201, 'Created'); 117 | } 118 | } else if (!empty($_input) && ($g->append($_input, $_data) || 1)) { 119 | librdf_php_last_log_level() && httpStatusExit(400, 'Bad Request', null, librdf_php_last_log_message()); 120 | $g->save(); 121 | header("Triples: ".$g->size(), false); 122 | header("Link: <".$_base.$metafile.">; rel=meta", true); 123 | header("Link: <".$_base.$aclfile.">; rel=acl", false); 124 | header('Location: '.$ldp_location); 125 | header('ETag: "'.md5_file($_filename).'"'); 126 | httpStatusExit(201, 'Created'); 127 | } else if ($_content_type == 'multipart/form-data') { 128 | if(isset($_FILES)){ 129 | $errors= array(); 130 | var_dump($_FILES); 131 | foreach($_FILES as $file){ 132 | $file_name = $file['name']; 133 | $file_size = $file['size']; 134 | $file_tmp = $file['tmp_name']; 135 | $file_type = $file['type']; 136 | if($file_size > 10000000){ 137 | $errors[]='File size must be less than 10 MB. Size of '.$file_name.' is: '.$file_size; 138 | httpStatusExit(513, 'Request Entity Too Large'); 139 | } 140 | 141 | echo "Moved to ".$_filename.$file_name."\n"; 142 | if(is_dir($_filename)==false){ 143 | mkdir($_filename, 0700); // Create directory if it does not exist 144 | } 145 | if(is_dir($_filename.$file_name)==false){ 146 | if (!move_uploaded_file($file_tmp,$_filename.$file_name)) { 147 | $errors[]='Cannot move file from '.$file_tmp.' to '.$_filename.$file_name; 148 | } 149 | } 150 | } 151 | if(empty($errors)){ 152 | if (sizeof($_FILES) == 1) { 153 | $file_name = str_replace("+", "%20", urlencode($file_name)); 154 | header("Link: <".$_base.".meta.".$file_name.">; rel=meta", true); 155 | header("Link: <".$_base.".acl.".$file_name.">; rel=acl", false); 156 | header('Location: '.$_base.$file_name); 157 | header('ETag: "'.md5_file($_filename.$file_name).'"'); 158 | } 159 | httpStatusExit(201, 'Created'); 160 | } else { 161 | httpStatusExit(501, print_r($errors)); 162 | } 163 | } else { 164 | echo "Empty FILES var.\n"; 165 | httpStatusExit(501, var_dump($_FILES)); 166 | } 167 | } else if ($_content_type == 'application/sparql-update') { 168 | require_once('SPARQL.php'); 169 | } else { 170 | librdf_php_last_log_level() && httpStatusExit(400, 'Bad Request', null, librdf_php_last_log_message()); 171 | header('Accept-Post: '.implode(',', $_content_types)); 172 | header("Link: <>; rel=meta", true); 173 | httpStatusExit(406, 'Content-Type ('.$_content_type.') Not Acceptable'); 174 | } 175 | -------------------------------------------------------------------------------- /www/wildcard/index.rdf.php: -------------------------------------------------------------------------------- 1 | '; 39 | $mtime = filemtime("$_filename/$item"); 40 | $size = filesize("$_filename/$item"); 41 | $uri = ($is_dir)?$_base.basename($item).'/':$_base.basename($item); 42 | $properties = array( 'resource' => $item_elt, 43 | 'uri' => $uri, 44 | 'type' => $item_type, 45 | 'mtime' => $mtime, 46 | 'size' => $size); 47 | $contents[] = $properties; 48 | } 49 | 50 | // default -> show all 51 | $show_members = true; 52 | $show_containment = true; 53 | $show_empty = false; 54 | 55 | // parse headers to retrieve preferred representation 56 | if (isset($_SERVER['HTTP_PREFER'])) { 57 | $h = array(); 58 | $opts = explode(';', $_SERVER['HTTP_PREFER']); 59 | foreach ($opts as $opt) { 60 | $o = explode('=', trim($opt)); 61 | $v = explode(' ', trim($o[1], '"')); 62 | 63 | $h[$o[0]] = $v; 64 | } 65 | 66 | if (isset($h['omit'])) { 67 | foreach ($h['omit'] as $opt) { 68 | if ($opt == 'http://www.w3.org/ns/ldp#PreferContainment') 69 | $show_containment = false; 70 | else if ($opt == 'http://www.w3.org/ns/ldp#PreferMembership') 71 | $show_members = false; 72 | else if ($opt == 'http://www.w3.org/ns/ldp#PreferEmptyContainer') 73 | $show_empty = true; 74 | } 75 | } 76 | // include takes precedence whatever the case 77 | if (isset($h['include'])) { 78 | $show_members = false; 79 | $show_containment = false; 80 | $show_empty = false; 81 | foreach ($h['include'] as $opt) { 82 | if ($opt == 'http://www.w3.org/ns/ldp#PreferContainment') 83 | $show_containment = true; 84 | else if ($opt == 'http://www.w3.org/ns/ldp#PreferMembership') 85 | $show_members = true; 86 | else if ($opt == 'http://www.w3.org/ns/ldp#PreferEmptyContainer') 87 | $show_empty = true; 88 | } 89 | 90 | } 91 | // return the ack header 92 | header('Preference-Applied: return=representation', false); 93 | } 94 | 95 | // serve LDP by default and beging with the first page 96 | $p = 1; 97 | // page length (number of items on a page) 98 | $pl = 10; 99 | 100 | $complement = $_base.'?p=1'; 101 | header("Link: <".$complement.">; rel='first'", false); 102 | 103 | // split members into pages 104 | $contents_chunks = array_chunk($contents, $pl); 105 | $pages = count($contents_chunks); 106 | 107 | if (isset($_GET['p'])) { 108 | $p = (int) $_GET['p']; 109 | $contents = $contents_chunks[$p-1]; 110 | $complement = '?p='. (string) $p; 111 | } 112 | 113 | // add paging headers 114 | // set last page 115 | header("Link: <".$_base."?p=".(string)($pages).">; rel='last'", false); 116 | 117 | if ($p > 1) 118 | header("Link: <".$_base."?p=".(string)($p-1).">; rel='prev'", false); 119 | if($p < $pages) { 120 | header("Link: <".$_base."?p=".(string)($p+1).">; rel='next'", false); 121 | header("HTTP/1.1 333 Returning Related", false, 333); 122 | } 123 | 124 | 125 | // List LDPC info 126 | $ldpc = "@prefix ldp: . @prefix rdfs: . @prefix p: .". 127 | "<".$_base."> a ldp:Container, ldp:BasicContainer, p:Directory ; ". 128 | "p:mtime ".filemtime($_filename)." ;". 129 | "p:size ".filesize($_filename)." ;"; 130 | $g->append('turtle', $ldpc); 131 | 132 | // add extra LDPC metadata from .meta. 133 | $meta_uri = dirname($_base).'/.meta.'.basename($_base); 134 | $meta_file = dirname($_filename).'/.meta.'.basename($_filename); 135 | $mg = new Graph('', $meta_file, '',$meta_uri); 136 | if ($mg->size() > 0) { 137 | // specific authorization 138 | $q = 'SELECT * WHERE { <'.$_base.'> ?p ?o }'; 139 | $s = $mg->SELECT($q); 140 | $res = $s['results']['bindings']; 141 | 142 | if (isset($res) && count($res) > 0) { 143 | foreach ($res as $t) { 144 | $g->append_objects($_base, $t['p']['value'], array($t['o'])); 145 | } 146 | } 147 | } 148 | 149 | // list each member 150 | foreach($contents as $properties) { 151 | /* 152 | // check ACL for each member resource 153 | $meta_uri = $properties['uri']; 154 | $meta_file = $_filename.basename($properties['resource']); 155 | 156 | // WebACL 157 | $wac = new WAC($_user, $meta_file, $meta_uri); 158 | $can = false; 159 | $can = $wac->can('Read'); 160 | if (DEBUG) { 161 | openlog('RWW.IO', LOG_PID | LOG_ODELAY,LOG_LOCAL4); 162 | foreach($wac->getDebug() as $line) 163 | syslog(LOG_INFO, $line); 164 | syslog(LOG_INFO, 'Verdict: '.$can.' / '.$wac->getReason()); 165 | closelog(); 166 | } 167 | if (!$can) { 168 | //$g->append('turtle', '<'.$properties['resource'].'> .'); 169 | continue; 170 | } 171 | */ 172 | // LDPRs 173 | // add metadata info for each member 174 | if (!$show_empty) { 175 | $g->append('turtle', "@prefix p: . <". 176 | $properties['resource']."> a ". 177 | $properties['type'] ." ; p:mtime ". 178 | $properties['mtime'] ." ; p:size ". 179 | $properties['size'] ." ."); 180 | } 181 | 182 | // add ldp:contains triple to the LDPC 183 | if ($show_containment) 184 | $g->append('turtle', "<".$_base."> <".$properties['resource']."> . "); 185 | 186 | // add resource type from resources containing metadata 187 | if ($properties['type'] != 'p:File') { 188 | if ($properties['type'] == 'p:Directory') { 189 | $meta_uri = dirname($properties['uri']).'/.meta.'.basename($properties['uri']); 190 | $meta_file = $_filename.'.meta.'.basename($properties['resource']); 191 | } else { 192 | $meta_uri = $properties['uri']; 193 | $meta_file = $_filename.basename($properties['resource']); 194 | } 195 | $dg = new Graph('', $meta_file, '',$meta_uri); 196 | if ($dg->size() > 0) { 197 | $q = 'SELECT * WHERE { <'.$properties['resource'].'> ?p ?o }'; 198 | $s = $dg->SELECT($q); 199 | $res = $s['results']['bindings']; 200 | 201 | // add the resource type 202 | if (isset($res) && count($res) > 0) { 203 | foreach ($res as $t) { 204 | if ($t['p']['value'] == 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type') 205 | $g->append_objects($properties['uri'], $t['p']['value'], array($t['o'])); 206 | } 207 | } 208 | } 209 | } 210 | } 211 | 212 | -------------------------------------------------------------------------------- /py/pki.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | CA_CER = ''' 4 | -----BEGIN CERTIFICATE----- 5 | MIICUjCCAbugAwIBAgIJANqd0HpLjwClMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNV 6 | BAYTAlVTMRMwEQYDVQQIDApTb21lLVN0YXRlMQ4wDAYDVQQKDAVXZWJJRDEOMAwG 7 | A1UEAwwFV2ViSUQwHhcNMTIxMTI5MjAyNjE5WhcNMTUxMTI5MjAyNjE5WjBCMQsw 8 | CQYDVQQGEwJVUzETMBEGA1UECAwKU29tZS1TdGF0ZTEOMAwGA1UECgwFV2ViSUQx 9 | DjAMBgNVBAMMBVdlYklEMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC2Gn0j 10 | 5CiJ+UOZCl0HYt6lxwGKh8O2ocxOU3lv4JNAB/fcJBPoMh0G/NxbFayT6W6IEF87 11 | 2TxutCtc+NECHMBfhISRF6tBpnM7ibuRlGNxCjzaH+le/NsWu/+oMUceYI5UHWbL 12 | wj2QwQY7hi9sMKlaEOxsJKdObGhvSxo6C5tNHQIDAQABo1AwTjAdBgNVHQ4EFgQU 13 | PeiGwB03YrZL1o9JV66Y7fia1IIwHwYDVR0jBBgwFoAUPeiGwB03YrZL1o9JV66Y 14 | 7fia1IIwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQB/FSnw2M3TExe6 15 | cwxoGbRI9QM8cK5Uwc3FHUsikQIZyPyq+65pyGw+dRR2jft7fqb/2PIYtsrQjY5V 16 | X1vkIaKUbUOgBF8FjnwsYV3ZqB5MfYRz9Pv2KnTwOHb3Lk84OrYyJY0yv4aLAiqA 17 | pkMUumu6GgjM421AWxUoiibL2NQd+g== 18 | -----END CERTIFICATE----- 19 | ''' 20 | 21 | CA_KEY = ''' 22 | -----BEGIN RSA PRIVATE KEY----- 23 | MIICXgIBAAKBgQC2Gn0j5CiJ+UOZCl0HYt6lxwGKh8O2ocxOU3lv4JNAB/fcJBPo 24 | Mh0G/NxbFayT6W6IEF872TxutCtc+NECHMBfhISRF6tBpnM7ibuRlGNxCjzaH+le 25 | /NsWu/+oMUceYI5UHWbLwj2QwQY7hi9sMKlaEOxsJKdObGhvSxo6C5tNHQIDAQAB 26 | AoGBAI2px6YvLRZAskSRGlPPp1MhoGJLQYaHEe/w4iyVcRfD2x8HdfERYyF3fljh 27 | YJLkapcw3VUqpuecA4vdCINzKHcV0hzQLYqy3FpiVH2sOUD/x+lCZpfCR+LBhKbJ 28 | oVtFaJ/WrvdqPIcAmmndT8ROW/FsT8HdgSTtrreq2q0pqSYBAkEA4eTM8+RKX8rV 29 | kNn6odTKXRQSvPl/LS9gUNAQvn9mhboUEjILE1a8JAxRKgWeqJk/+rxpZkrLIVx/ 30 | DgXhNBlhnQJBAM5fnwLM+NShF1SZvsCr0Y7XW8s9ZFqFYULAo8tVsga5xY7gBefU 31 | B5atbdBDH0CRklwyyBVrmYIXeb+gRR3VgYECQQCWZC3Pcn3RqMjm1zj15SWVMngH 32 | OFRjUNde9icvrMIk5e3W71pQVb6MgWbIA1XOCbl+xVGmuMTkQSCVxXRZq0xBAkEA 33 | tmm+23Lh3tAlFxpuiU9WA7RH5vV05q5OsfokzW4J1fgOr6NElQ3NR1o0Xol17lS9 34 | 0dDxGj3pihvF+aNodF5sAQJAMuRVMUEX+1lqF8jGM+hv6IMrQi6zUdxr1QUPk2Ro 35 | UbshjTjL5qWr+1Q3KgI8cjkhf+r6tffjcGF+5g9ODxaXsg== 36 | -----END RSA PRIVATE KEY----- 37 | ''' 38 | 39 | from OpenSSL import crypto 40 | import time, os 41 | from tempfile import mkstemp 42 | from subprocess import call, Popen, STDOUT, PIPE 43 | import base64 44 | 45 | X509_TRUST_COMPAT = 1 46 | X509_TRUST_SSL_CLIENT = 2 47 | X509_TRUST_SSL_SERVER = 3 48 | X509_TRUST_EMAIL = 4 49 | X509_TRUST_OBJECT_SIGN = 5 50 | X509_TRUST_OCSP_SIGN = 6 51 | X509_TRUST_OCSP_REQUEST = 7 52 | X509v3_KU_DIGITAL_SIGNATURE = 0x0080 53 | X509v3_KU_NON_REPUDIATION = 0x0040 54 | X509v3_KU_KEY_ENCIPHERMENT = 0x0020 55 | X509v3_KU_DATA_ENCIPHERMENT = 0x0010 56 | X509v3_KU_KEY_AGREEMENT = 0x0008 57 | X509v3_KU_KEY_CERT_SIGN = 0x0004 58 | X509v3_KU_CRL_SIGN = 0x0002 59 | X509v3_KU_ENCIPHER_ONLY = 0x0001 60 | X509v3_KU_DECIPHER_ONLY = 0x8000 61 | X509v3_KU_UNDEF = 0xffff 62 | 63 | 64 | CLIENT_EXTENSIONS = ( 65 | crypto.X509Extension('basicConstraints', False, 'CA:FALSE'), 66 | ) 67 | 68 | def _next_serial_number(): 69 | return int(time.time()) - 1217659659 70 | 71 | def asn1date(asn1str): 72 | return time.strptime(asn1str.strip('Z'), '%Y%m%d%H%M%S') 73 | 74 | def asn1time(asn1str): 75 | return time.mktime(asn1date(asn1str)) 76 | 77 | def x509_data(x509): 78 | x509 = crypto.load_certificate(crypto.FILETYPE_PEM, x509) 79 | return {'subject': dict(x509.get_subject().get_components()), 80 | 'issuer': dict(x509.get_issuer().get_components()), 81 | 'serial': x509.get_serial_number(), 82 | 'notBefore': asn1date(x509.get_notBefore()), 83 | 'notAfter': asn1date(x509.get_notAfter()), 84 | 'sha1': x509.digest('sha1')} 85 | 86 | def get_UID_DC(userid): 87 | if userid and len(userid): 88 | m = userid.partition('@') 89 | if m[1] == '@': 90 | DC = m[2].split('.') 91 | if len(DC): 92 | DC.reverse() 93 | UID = m[0] 94 | return UID, DC 95 | 96 | def sign(pkey, p_ca_pem, p_ca_key, commonName, days, emailAddress=None, altName=None, userid=None): 97 | serial = _next_serial_number() 98 | 99 | ca_pem = p_ca_pem and file(p_ca_pem).read() or CA_CER 100 | ca_x509 = crypto.load_certificate(crypto.FILETYPE_PEM, ca_pem) 101 | ca_subj = ca_x509.get_subject() 102 | 103 | ca_pkey = p_ca_key and file(p_ca_key).read() or CA_KEY 104 | ca_key = crypto.load_privatekey(crypto.FILETYPE_PEM, ca_pkey) 105 | 106 | # create client X509 certificate 107 | x509 = crypto.X509() 108 | # 0x0:v1, 0x1:v2, 0x2:v3 109 | x509.set_version(2) 110 | x509.set_serial_number(serial) 111 | x509.set_issuer(ca_subj) 112 | 113 | # overload CAs subject and add extensions 114 | subj = crypto.X509Name(ca_subj) 115 | subj.CN = commonName 116 | 117 | x509.set_subject(subj) 118 | x509.add_extensions(CLIENT_EXTENSIONS) 119 | if altName: 120 | x509.add_extensions(( 121 | crypto.X509Extension('subjectAltName', False, 'URI:' + altName), 122 | )) 123 | 124 | # x509 validity starts at present 125 | x509.gmtime_adj_notBefore(0) 126 | # and ends before CA expires 127 | x509.gmtime_adj_notAfter(days*24*3600) 128 | #if asn1time(x509.get_notAfter()) > asn1time(ca_x509.get_notAfter()): 129 | # x509.set_notAfter(ca_x509.get_notAfter()) 130 | 131 | # insert public key 132 | x509.set_pubkey(pkey) 133 | 134 | # add identifiers 135 | x509.add_extensions(( 136 | crypto.X509Extension('subjectKeyIdentifier', False, 'hash', subject=x509), 137 | crypto.X509Extension('authorityKeyIdentifier', False, 'keyid', issuer=ca_x509), 138 | )) 139 | 140 | # sign with CA private key 141 | x509.sign(ca_key, 'sha1') 142 | return x509 143 | 144 | def sign_spkac(spki, commonName, days, emailAddress=None, altName=None, userid=None): 145 | spki = crypto.NetscapeSPKI(spki) 146 | x509 = sign(spki.get_pubkey(), None, None, commonName, days, emailAddress, altName, userid) 147 | return crypto.dump_certificate(crypto.FILETYPE_PEM, x509) 148 | 149 | def sign_req(pem, p_ca_pem, p_ca_key, commonName, days, emailAddress=None, altName=None, userid=None): 150 | x509 = crypto.load_certificate_request(crypto.FILETYPE_PEM, pem) 151 | pkey = x509.get_pubkey() 152 | x509 = sign(pkey, p_ca_pem, p_ca_key, commonName, days, emailAddress, altName, userid) 153 | return crypto.dump_certificate(crypto.FILETYPE_PEM, x509) 154 | 155 | def sign_new(p_ca_pem, p_ca_key, commonName, days, emailAddress=None, altName=None, userid=None): 156 | pkey = crypto.PKey() 157 | pkey.generate_key(crypto.TYPE_RSA, 1024) 158 | x509 = sign(pkey, p_ca_pem, p_ca_key, commonName, days, emailAddress, altName, userid) 159 | return crypto.dump_privatekey(crypto.FILETYPE_PEM, pkey) + crypto.dump_certificate(crypto.FILETYPE_PEM, x509) 160 | 161 | def x509_pkcs7(pem): 162 | t = mkstemp() 163 | os.write(t[0], pem) 164 | os.close(t[0]) 165 | call(['openssl','crl2pkcs7','-nocrl','-certfile',t[1],'-out',t[1]]) 166 | r = ''.join(file(t[1]).read().strip().split('\n')[1:-1]) 167 | os.unlink(t[1]) 168 | return r 169 | 170 | def x509_pkcs12(pem, password): 171 | p_ssl = Popen(['openssl','pkcs12','-export','-passout','pass:%s' % password], stdin=PIPE, stdout=PIPE) 172 | p_ssl.stdin.write(pem) 173 | p_ssl.stdin.close() 174 | p_ssl.wait() 175 | return base64.encodestring(p_ssl.stdout.read()) 176 | 177 | if __name__ == '__main__': 178 | import argparse 179 | parser = argparse.ArgumentParser(description='Create and sign a WebID certificate based on a Netscape SPKAC request (using the KEYGEN element in HTML).') 180 | 181 | parser.add_argument('-s', '--spkac', help="Netscape SPKAC public key", required=True) 182 | parser.add_argument('-n', '--name', help="Certificate commonName value", required=True) 183 | parser.add_argument('-w', '--webid', help="WebID URI (subjectAltName)", required=True) 184 | parser.add_argument('-d', '--days', help="Certificate validity (in days)", default=360) 185 | 186 | args = parser.parse_args() 187 | print sign_spkac(args.spkac, args.name, args.days, altName=args.webid), 188 | 189 | -------------------------------------------------------------------------------- /www/inc/webidgen.php: -------------------------------------------------------------------------------- 1 | '. $path.' already exists!'); 30 | } else { 31 | // check if the root dir exists and create it (recursively) if it doesn't 32 | if (!mkdir(dirname($webid_file), 0755, true)) 33 | die('Cannot create directory at '.dirname($webid_file).', please check permissions.'); 34 | } 35 | 36 | $BASE = 'https://'.$_POST['username'].'.'.$_SERVER['SERVER_NAME']; // force https 37 | $email = isset($_POST['email'])?$_POST['email']:null; 38 | $pic = isset($_POST['img'])?$_POST['img']:null; 39 | $spkac = str_replace(str_split("\n\r"), '', $_POST['SPKAC']); 40 | $webid = $BASE.'/'.$path; 41 | 42 | // --- Cert --- 43 | $cert_cmd = 'python '.$_ENV['CLOUD_HOME'].'/py/pki.py '. 44 | " -s '$spkac'" . 45 | " -n '$name [RWW.IO]'" . 46 | " -w '$webid'"; 47 | 48 | // Send the certificate back to the user 49 | header('Content-Type: application/x-x509-user-cert'); 50 | 51 | $cert = trim(shell_exec($cert_cmd)); 52 | $ret_cmd = "echo '$cert' | openssl x509 -in /dev/stdin -outform der"; 53 | echo trim(shell_exec($ret_cmd)); 54 | 55 | $mod_cmd = "echo '$cert' | openssl x509 -in /dev/stdin -modulus -noout"; 56 | // remove the Modulus= part 57 | $output = explode('=', trim(shell_exec($mod_cmd))); 58 | $modulus = $output[1]; 59 | 60 | // --- Workspaces --- 61 | // create shared storage space 62 | $storage_uri = $BASE.'/'; 63 | 64 | if (!mkdir($_root.'/public/', 0755, true)) 65 | die('Cannot create public workspace", please check permissions'); 66 | 67 | if (!mkdir($_root.'/private/', 0755, true)) 68 | die('Cannot create public workspace", please check permissions'); 69 | 70 | if (!mkdir($_root.'/family/', 0755, true)) 71 | die('Cannot create public workspace", please check permissions'); 72 | 73 | if (!mkdir($_root.'/friends/', 0755, true)) 74 | die('Cannot create public workspace", please check permissions'); 75 | // end workspaces 76 | 77 | // ------ ACLs ------ 78 | $acls = new Graph('', $_root.'/.acl', '', $BASE.'/.acl'); 79 | if (!$acls) { 80 | echo "Cannot create a new acl graph!"; 81 | exit; 82 | } 83 | 84 | // Owner 85 | $acls->append_objects($BASE.'/.acl#Owner', 86 | 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 87 | array(array('type'=>'uri', 'value'=>'http://www.w3.org/ns/auth/acl#Authorization'))); 88 | $acls->append_objects($BASE.'/.acl#Owner', 89 | 'http://www.w3.org/ns/auth/acl#accessTo', 90 | array(array('type'=>'uri', 'value'=>$BASE.'/'), 91 | array('type'=>'uri', 'value'=>$BASE.'/.acl'))); 92 | $acls->append_objects($BASE.'/.acl#Owner', 93 | 'http://www.w3.org/ns/auth/acl#agent', 94 | array(array('type'=>'uri', 'value'=>$BASE.'/'.$path))); 95 | $acls->append_objects($BASE.'/.acl#Owner', 96 | 'http://www.w3.org/ns/auth/acl#defaultForNew', 97 | array(array('type'=>'uri', 'value'=>$BASE.'/'))); 98 | $acls->append_objects($BASE.'/.acl#Owner', 99 | 'http://www.w3.org/ns/auth/acl#mode', 100 | array(array('type'=>'uri', 'value'=>'http://www.w3.org/ns/auth/acl#Control'), 101 | array('type'=>'uri', 'value'=>'http://www.w3.org/ns/auth/acl#Read'), 102 | array('type'=>'uri', 'value'=>'http://www.w3.org/ns/auth/acl#Write'))); 103 | 104 | // Rest 105 | $acls->append_objects($BASE.'/.acl#Rest', 106 | 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 107 | array(array('type'=>'uri', 'value'=>'http://www.w3.org/ns/auth/acl#Authorization'))); 108 | $acls->append_objects($BASE.'/.acl#Rest', 109 | 'http://www.w3.org/ns/auth/acl#accessTo', 110 | array(array('type'=>'uri', 'value'=>$BASE.'/'))); 111 | $acls->append_objects($BASE.'/.acl#Rest', 112 | 'http://www.w3.org/ns/auth/acl#defaultForNew', 113 | array(array('type'=>'uri', 'value'=>$BASE.'/'))); 114 | $acls->append_objects($BASE.'/.acl#Rest', 115 | 'http://www.w3.org/ns/auth/acl#agentClass', 116 | array(array('type'=>'uri', 'value'=>'http://xmlns.com/foaf/0.1/Agent'))); 117 | $acls->append_objects($BASE.'/.acl#Rest', 118 | 'http://www.w3.org/ns/auth/acl#mode', 119 | array(array('type'=>'uri', 'value'=>'http://www.w3.org/ns/auth/acl#Read'))); 120 | 121 | $acls->save(); 122 | // end ACLs 123 | 124 | // --- Profile --- 125 | // Write the new profile to disk 126 | $document = new Graph('', $webid_file, '', $BASE.'/'.$profile); 127 | if (!$document) { 128 | echo "Cannot create a new profile graph!"; 129 | exit; 130 | } 131 | 132 | // add a PrimaryTopic 133 | $document->append_objects($BASE.'/'.$profile, 134 | 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 135 | array(array('type'=>'uri', 'value'=>'http://xmlns.com/foaf/0.1/PersonalProfileDocument'))); 136 | $document->append_objects($BASE.'/'.$profile, 137 | 'http://xmlns.com/foaf/0.1/primaryTopic', 138 | array(array('type'=>'uri', 'value'=>$webid))); 139 | 140 | // add a foaf:Person 141 | $document->append_objects($webid, 142 | 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 143 | array(array('type'=>'uri', 'value'=>'http://xmlns.com/foaf/0.1/Person'))); 144 | // add name 145 | $document->append_objects($webid, 146 | 'http://xmlns.com/foaf/0.1/name', 147 | array(array('type'=>'literal', 'value'=>$name))); 148 | // add mbox if we have one 149 | if (strlen($email) > 0) { 150 | $document->append_objects($webid, 151 | 'http://xmlns.com/foaf/0.1/mbox', 152 | array(array('type'=>'uri', 'value'=>'mailto:'.$email))); 153 | } 154 | // add avatar if we have one 155 | if (strlen($pic) > 0) { 156 | $document->append_objects($webid, 157 | 'http://xmlns.com/foaf/0.1/img', 158 | array(array('type'=>'uri', 'value'=>$pic))); 159 | } 160 | // ---- Add workspaces ---- 161 | // add shared storage space 162 | $document->append_objects($webid, 163 | 'http://www.w3.org/ns/pim/space#storage', 164 | array(array('type'=>'uri', 'value'=>$storage_uri))); 165 | 166 | // ---- Certificate ---- 167 | // add modulus and exponent as bnode 168 | $document->append_objects($webid, 169 | 'http://www.w3.org/ns/auth/cert#key', 170 | array(array('type'=>'bnode', 'value'=>'_:bnode1'))); 171 | $document->append_objects('_:bnode1', 172 | 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 173 | array(array('type'=>'uri', 'value'=>'http://www.w3.org/ns/auth/cert#RSAPublicKey'))); 174 | 175 | if (isset($modulus)) 176 | $document->append_objects('_:bnode1', 177 | 'http://www.w3.org/ns/auth/cert#modulus', 178 | array(array('type'=>'literal', 'value'=>$modulus, 'datatype'=>'http://www.w3.org/2001/XMLSchema#hexBinary'))); 179 | 180 | $document->append_objects('_:bnode1', 181 | 'http://www.w3.org/ns/auth/cert#exponent', 182 | array(array('type'=>'literal', 'value'=>'65537', 'datatype'=>'http://www.w3.org/2001/XMLSchema#int'))); 183 | 184 | $document->save(); 185 | 186 | // ------ DONE WITH PROFILE ------- 187 | } 188 | 189 | -------------------------------------------------------------------------------- /www/inc/util.lib.php: -------------------------------------------------------------------------------- 1 | size() > 0) { 11 | // specific authorization 12 | $q = 'SELECT ?s, ?prefix WHERE { ?s <'.$type.'> ?prefix }'; 13 | $s = $g->SELECT($q); 14 | $res = $s['results']['bindings']; 15 | 16 | if (isset($res) && count($res) > 0) 17 | return $res[0]['prefix']['value']; 18 | } 19 | } 20 | return null; 21 | } 22 | 23 | function clearSession($i_next) { 24 | foreach ($_SESSION as $k=>$v) { 25 | sess($k, null); 26 | } 27 | 28 | if (isset($i_next)) { 29 | sess('next', $i_next); 30 | } elseif (isMethod('GET') && isset($_SERVER['HTTP_REFERER'])) { 31 | sess('next', $_SERVER['HTTP_REFERER']); 32 | } 33 | 34 | if (isSess('next')) { 35 | $next = sess('next', null); 36 | $next = str_replace('https://', 'http://', $next); 37 | header('Location: '.$next); 38 | } else { 39 | header('Location: /'); 40 | } 41 | exit; 42 | } 43 | 44 | // calculate the md5 of a dir 45 | function md5_dir($dir) { 46 | if (!is_dir($dir)) { 47 | return false; 48 | } 49 | 50 | $filemd5s = array(); 51 | $d = dir($dir); 52 | 53 | while (false !== ($entry = $d->read())) { 54 | if ($entry != '.' && $entry != '..') { 55 | if (is_dir($dir.'/'.$entry)) 56 | $filemd5s[] = md5_dir($dir.'/'.$entry); 57 | else 58 | $filemd5s[] = md5_file($dir.'/'.$entry); 59 | } 60 | } 61 | $d->close(); 62 | return md5(implode('', $filemd5s)); 63 | } 64 | 65 | // parse a given http header 66 | function http_parse_link_header( $header ) { 67 | $retVal = array(); 68 | $elems = explode(';', $header); 69 | foreach ($elems as $v) { 70 | $v = str_replace('<', '', $v); 71 | $v = str_replace('>', '', $v); 72 | array_push($retVal , trim($v)); 73 | } 74 | 75 | return $retVal; 76 | } 77 | 78 | // check if a dir is empty 79 | function is_dir_empty($dir) { 80 | $files = scandir($dir); 81 | if (sizeof($files) > 2) 82 | return false; 83 | else 84 | return true; 85 | } 86 | 87 | // display the file sizes in a human readable format 88 | function human_filesize($bytes, $decimals=2) { 89 | $sz = 'BKMGTP'; 90 | $factor = floor((strlen($bytes) - 1) / 3); 91 | return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$sz[$factor]; 92 | } 93 | 94 | 95 | // get quota for a dir 96 | function get_quota($dir) { 97 | $get_size = '/usr/bin/du -sk '.$dir."|awk '{ print $1; }'"; 98 | $used = trim(shell_exec($get_size)); 99 | $total = DISK_QUOTA * 1000000; // mega to bytes 100 | $used = $used * 1000; // kilo to bytes 101 | 102 | return array('used'=>$used, 'total'=>$total); 103 | } 104 | 105 | // check if the size fits inside the quota 106 | function check_quota($dir, $size) { 107 | $q = get_quota($dir); 108 | $a = $q['total'] - $q['used']; 109 | 110 | return ($size <= $a)?true:false; 111 | } 112 | 113 | // display the quota bar 114 | function display_quota($dir) { 115 | $q = get_quota($dir); 116 | $used = $q['used'] / 1000000; // bytes to mega 117 | $total = $q['total'] / 1000000; // bytes to mega; 118 | 119 | $medium = $total * (70/100); 120 | // at 90% we start to get worried 121 | $high = $total * (90/100); 122 | 123 | if ($used <= $medium) 124 | $bg = 'green'; 125 | else if ($used > $medium && $used <= $high) 126 | $bg = 'yellow'; 127 | else if ($used > $high) 128 | $bg = 'red'; 129 | 130 | $width = ($used *100) / $total; 131 | $width = number_format($width, 2); 132 | 133 | $ret = '
'; 136 | $ret .= '
'; 137 | $ret .= '
'.number_format($used, 2).'MB /'.number_format($total).'MB
'; 138 | $ret .= '
'; 139 | 140 | return $ret; 141 | } 142 | 143 | 144 | function isMethod($method) { return ($_SERVER['REQUEST_METHOD'] == $method); } 145 | function isPost() { return isMethod('POST'); } 146 | function isPostData() { 147 | return isset($_SERVER['REQUEST_METHOD']) && isset($_SERVER['HTTP_CONTENT_LENGTH']) 148 | && $_SERVER['REQUEST_METHOD'] == 'POST' && $_SERVER['HTTP_CONTENT_LENGTH'] > 0; 149 | } 150 | function isSess($id) { return isset($_SESSION[$id]); } 151 | function sess($id,$val=NULL) { 152 | if (func_num_args()==1) { 153 | return (isSess($id)?$_SESSION[$id]:NULL); 154 | } elseif (is_null($val)) { 155 | $r = isset($_SESSION[$id]) ? $_SESSION[$id] : null; 156 | unset($_SESSION[$id]); 157 | return $r; 158 | } else { 159 | $prev = sess($id); 160 | $_SESSION[$id] = $val; 161 | return $prev; 162 | } 163 | } 164 | 165 | function newQS($key, $val=null) { return newQSA(array($key=>$val)); } 166 | function newQSA($array=array()) { 167 | parse_str($_SERVER['QUERY_STRING'], $arr); 168 | $s = count($arr); 169 | foreach($array as $key=>$val) { 170 | $arr[$key] = $val; 171 | if (is_null($val)) 172 | unset($arr[$key]); 173 | } 174 | return (count($arr)||$s)?'?'.http_build_query($arr):''; 175 | } 176 | 177 | function isHTTPS() { return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on'); } 178 | 179 | function timings($query=null) { 180 | global $timingc; 181 | global $timings; 182 | 183 | if(!isset($timings)) { 184 | $timings = array(); 185 | } 186 | 187 | if (!isset($timingc) || empty($timingc)) { 188 | $timingc = 1; 189 | } elseif (!is_null($query)) { 190 | $timingc++; 191 | } 192 | $key = $timingc; 193 | 194 | if (is_null($query)) { 195 | $timings[$key]['time'] = microtime(true)-$timings[$key]['time']; 196 | if (function_exists('mysql_error') && mysql_error()) 197 | $timings[$key]['error'] = mysql_error(); 198 | return true; 199 | } else { 200 | $timings[$key] = array(); 201 | $timings[$key]['time'] = microtime(true); 202 | $timings[$key]['query'] = $query; 203 | return false; 204 | } 205 | } 206 | 207 | function httpStatusExit($status, $message, $require=null, $body=null) { 208 | global $_options, $TAGS; 209 | if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') { 210 | $x_json = json_encode(array('status'=>$status,'message'=>$message)); 211 | } 212 | $status = (string)$status; 213 | header("HTTP/1.1 $status $message"); 214 | if (isset($x_json)) 215 | header('X-JSON: '.$x_json); 216 | if ($require) 217 | require_once($require); 218 | else 219 | echo "

$status $message

\n"; 220 | if ($body) 221 | echo "

$body

\n"; 222 | exit; 223 | } 224 | 225 | $TAGS = array(array( 226 | 'file' => __FILE__, 227 | 'line' => __LINE__, 228 | 'id' => null, 229 | 'time'=>microtime(true) 230 | )); 231 | function TAG($file, $line, $id) { 232 | global $TAGS; 233 | $TAGS[] = array( 234 | 'file' => $file, 235 | 'line' => $line, 236 | 'id' => $id, 237 | 'time' => microtime(true) 238 | ); 239 | } 240 | 241 | function http($method, $uri, $content=null) { 242 | $c = stream_context_create(array('http'=>array( 243 | 'method' => $method, 244 | 'header' =>"Connection: close\r\nContent-Type: application/json\r\nAccept: application/json\r\nReferer: https://{$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}\r\n", 245 | 'content' => $content, 246 | 'ignore_errors' => true, 247 | 'max_redirects' => 0, 248 | ))); 249 | $f = fopen($uri, 'r', false, $c); 250 | $h = stream_get_meta_data($f); 251 | $r = stream_get_contents($f); 252 | fclose($f); 253 | $status = 0; 254 | $header = array(); 255 | if (isset($h['wrapper_data'])) { 256 | $status = array_shift($h['wrapper_data']); 257 | $header['Status'] = $status; 258 | $lst = explode(' ', $status); 259 | if (count($lst) > 1) 260 | $status = (int)$lst[1]; 261 | foreach ($h['wrapper_data'] as $elt) { 262 | $i = strpos($elt, ': '); 263 | $k = substr($elt, 0, $i); 264 | if (!isset($header[$k])) 265 | $header[$k] = array(substr($elt, $i+2)); 266 | //elseif (!is_array($header[$k])) 267 | // $header[$k] = array($header[$k], substr($elt, $i+2)); 268 | else 269 | $header[$k][] = substr($elt, $i+2); 270 | } 271 | } 272 | return (object)array('uri'=>$uri, 'status'=>$status, 'header'=>$header, 'body'=>$r); 273 | } 274 | -------------------------------------------------------------------------------- /www/root/onboard/signup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 67 | 68 | 85 |
86 | 87 |
88 | Getting Started 89 |
90 |

This process will help you get set up with a unique WebID as well as dedicated personal data store (think of it as Dropbox but for Linked Data).

91 |

Since WebID doesn't rely on passwords, every time you login with WebID, a certificate selection dialog will pop up. To login, you just have to select the WebID certificate you want to use.

92 | 93 | 94 |
95 |
96 | 97 |
98 | Sign up for personal storage space & WebID account 99 |
100 |
101 | 102 |

I already have a WebID, I just want storage.

103 |

Name: (2 characters min.)

104 |

Email: (optional)

105 |

https:// .

106 | Your WebID: https://{{account}}.{{storageLocation}}/profile/card#me
107 | Your storage: https://{{account}}.{{storageLocation}}/ 108 |
109 | 110 | 111 | 112 |
113 |
114 | 115 |
116 | 117 |
118 | Login with your new WebID 119 |
120 |

Congratulations! You now have a WebID.

121 |

Click here to view your WebID profile.

122 |

Click here to be redirected to your personal data store. You can also click the button below to close this window.

123 |

Once you close this window, you will be able to log in with your new WebID.

124 |
125 |
126 |

You have not yet completed the singup process. Please click the Back button to return to the previous step.

127 |
128 |
129 | 130 | 131 |
132 |
133 |
134 |
135 | 136 | 137 | -------------------------------------------------------------------------------- /www/wildcard/GET.php: -------------------------------------------------------------------------------- 1 | ; rel=\"type\"", false); 56 | header("Link: ; rel=\"type\"", false); 57 | 58 | $_method_type = "read"; 59 | 60 | // permissions 61 | if (empty($_user)) { 62 | httpStatusExit(401, 'Unauthorized', '401.php'); 63 | } 64 | 65 | // WebACL 66 | $can = false; 67 | $can = $_wac->can('Read'); 68 | if (DEBUG) { 69 | openlog('ldphp', LOG_PID | LOG_ODELAY,LOG_LOCAL4); 70 | foreach($_wac->getDebug() as $line) 71 | syslog(LOG_INFO, $line); 72 | syslog(LOG_INFO, 'Verdict: '.$can.' / '.$_wac->getReason()); 73 | closelog(); 74 | } 75 | if ($can == false) { 76 | if ($_output == 'html') 77 | httpStatusExit(403, 'Forbidden', '403-404.php'); 78 | else 79 | httpStatusExit(403, 'Forbidden'); 80 | } 81 | 82 | // set default output 83 | if (empty($_output)) { 84 | $_output = 'turtle'; 85 | $_output_type = 'text/turtle'; 86 | } 87 | 88 | // directory indexing 89 | if (is_dir($_filename) || substr($_filename,-1) == '/') { 90 | // add meta relation 91 | if ($_options->linkmeta) 92 | header("Link: <".$_metabase.$_metaname.">; rel=meta", false); 93 | 94 | if (substr($_filename, -1) != '/') { 95 | header("Location: $_base/"); 96 | exit; 97 | } elseif (!isset($_output) || empty($_output) || $_output == 'html') { 98 | include_once('index.html.php'); 99 | exit; 100 | } else { 101 | $dirindex = true; 102 | foreach (array('index') as $index) { 103 | if (file_exists("$_filename/$index")) { 104 | $_filename = "$_filename/$index"; 105 | $dirindex = false; 106 | break; 107 | } 108 | } 109 | if ($dirindex) { 110 | include_once('index.rdf.php'); 111 | } 112 | } 113 | } 114 | 115 | // output raw 116 | if ($_output == 'raw') { 117 | if ($_output_type) 118 | header("Content-Type: $_output_type"); 119 | if (!file_exists($_filename)) 120 | httpStatusExit(404, 'Not Found', '403-404.php'); 121 | 122 | // add meta relation 123 | if ($_options->linkmeta) 124 | header("Link: <".$_metabase.$_metaname.">; rel=meta", false); 125 | 126 | // caching for files 127 | $expires = 60*60; // 1 hour 128 | header("Pragma: public"); 129 | header("Cache-Control: max-age=".$expires, true); 130 | header('Expires: '.gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT'); 131 | 132 | if ($_method == 'GET') 133 | readfile($_filename); 134 | exit; 135 | } else { 136 | // always revalidate cache for RDF documents 137 | header("Cache-Control: max-age=0", true); 138 | } 139 | 140 | // *: glob 141 | if ($_options->glob && (strpos($_filename, '*') !== false || strpos($_filename, '{') !== false)) { 142 | $last_mtime = 0; 143 | $glob_md5 = ''; 144 | foreach(glob($_filename, GLOB_BRACE|GLOB_NOSORT) as $item) { 145 | if (!substr($item, 0, strlen($_filebase)) == $_filebase) continue; 146 | $item_ext = strrchr($item, '.'); 147 | if ($item_ext == '.sqlite' || ($item_ext && in_array(substr($item_ext, 1), $_RAW_EXT))) continue; 148 | 149 | // get file mtime and md5 150 | $mtime = filemtime($item); 151 | if ($mtime > $last_mtime) 152 | $last_mtime = $mtime; 153 | $glob_md5 .= md5_file($item); 154 | } 155 | $etag = md5($glob_md5); 156 | $last_modified = $last_mtime; 157 | } else if (is_dir($_filename)) { 158 | $_f = $_filename.'.'; 159 | $etag = md5_dir($_f); 160 | $last_modified = filemtime($_f); 161 | } else { 162 | $_f = $_filename; 163 | $etag = md5_file($_f); 164 | $last_modified = filemtime($_f); 165 | } 166 | 167 | // add ETag and Last-Modified headers 168 | if (strlen($etag)) { 169 | $etag = trim(array_shift(explode(' ', $etag))); 170 | header('ETag: "'.$etag.'"'); 171 | } 172 | 173 | header('Last-Modified: '.gmdate('D, d M Y H:i:s', $last_modified).' GMT', true, 200); 174 | 175 | if (CACHING) { 176 | if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) { 177 | if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $last_modified || 178 | str_replace('"', '', trim($_SERVER['HTTP_IF_NONE_MATCH'])) == $etag) { 179 | header("HTTP/1.1 304 Not Modified"); 180 | exit; 181 | } 182 | } 183 | } 184 | 185 | // tabulator data skin 186 | if ($_output == 'html') { 187 | include_once('contrib/skin.html.php'); 188 | exit; 189 | } 190 | 191 | // allocate RDF 192 | if (!isset($g)) 193 | $g = new Graph('', $_filename, '', $_base); 194 | 195 | // *: glob 196 | if ($_options->glob && (strpos($_filename, '*') !== false || strpos($_filename, '{') !== false)) { 197 | $last_mtime = 0; 198 | $glob_md5 = ''; 199 | $items = array_merge(glob($_filename, GLOB_BRACE|GLOB_NOSORT), glob(dirname($_filename).'/.'.basename($_filename), GLOB_BRACE|GLOB_NOSORT)); 200 | 201 | if (is_dir(dirname($_filename)) && (dirname($_filename) != $_filebase)) { 202 | $metaf = dirname(dirname($_filename)).'/.meta.'.basename(dirname($_filename)); 203 | array_push($items, $metaf); 204 | } 205 | 206 | foreach($items as $item) { 207 | //echo $item."\n"; 208 | if (basename($item) == '.' || basename($item) == '..') continue; 209 | if (!substr($item, 0, strlen($_filebase)) == $_filebase) continue; 210 | $item_ext = strrchr($item, '.'); 211 | if ($item_ext == '.sqlite' || ($item_ext && in_array(substr($item_ext, 1), $_RAW_EXT))) continue; 212 | $item_uri = REQUEST_BASE.substr($item, strlen($_filebase)); 213 | 214 | // get file mtime and md5 215 | $mtime = filemtime($item); 216 | if ($mtime > $last_mtime) 217 | $last_mtime = $mtime; 218 | $glob_md5 .= md5_file($item); 219 | 220 | // WebACL 221 | $wac = new WAC($_user, $item, $item_uri); 222 | if ($wac->can('Read')) 223 | $g->append_file('turtle', "file://$item", $item_uri); 224 | } 225 | } elseif (!empty($_filename) && !$g->exists() && !$g->size()) 226 | if (!$_options->wiki) 227 | header('HTTP/1.1 404 Not Found'); 228 | 229 | // offer ?wait updates (polling) 230 | if (isset($i_wait)) { 231 | $etag = (is_array($i_wait) && isset($i_wait['etag'])) ? $i_wait['etag'] : $g->etag(); 232 | while ($etag == $g->etag()) { 233 | sleep(1); 234 | clearstatcache(); 235 | } 236 | $g->reload(); 237 | } 238 | 239 | // offer WebSocket updates 240 | $updatesVia = isHTTPS() ? 'wss:' : 'ws:'; 241 | $updatesVia .= '//'.$_domain.':'. (1+$_SERVER['SERVER_PORT']); 242 | header('Updates-Via: '.$updatesVia); 243 | 244 | // RDF details 245 | header('Triples: '.$g->size()); 246 | if (isset($i_query)) 247 | header('Query: '.str_replace(array("\r","\n"), '', $i_query)); 248 | 249 | // support JSON-P 250 | if (isset($i_callback)) { 251 | header('Content-Type: text/javascript'); 252 | if ($_method == 'GET') { 253 | if ($_output == 'json' || isset($i_query)) { 254 | echo $i_callback, '('; 255 | register_shutdown_function(function() { echo ');'; }); 256 | } else { 257 | echo $i_callback, '("'; 258 | register_shutdown_function(function() { echo '");'; }); 259 | } 260 | } 261 | } elseif (isset($i_query) || isset($i_any)) { 262 | header('Content-Type: application/json'); 263 | } else { 264 | header("Content-Type: $_output_type"); 265 | } 266 | 267 | // eg. method != OPTIONS 268 | if (in_array($_method, array('GET', 'POST'))) 269 | if (isset($i_any)) { 270 | echo json_encode($g->any( 271 | isset($i_any['s']) ? $i_any['s'] : null, 272 | isset($i_any['p']) ? $i_any['p'] : null 273 | )); 274 | } elseif (isset($i_query)) { 275 | echo $g->query_to_string($i_query, $_output, $_base); 276 | } else { 277 | echo $g->to_string($_output); 278 | } 279 | -------------------------------------------------------------------------------- /www/inc/arc2/parsers/ARC2_MITSPARQLParser.php: -------------------------------------------------------------------------------- 1 | xPrologue($v); 27 | foreach (array('Select', 'Construct', 'Describe', 'Ask', 'InsertData', 'Insert', 'DeleteData', 'Delete', 'Load') as $type) { 28 | $m = 'x' . $type . 'Query'; 29 | if ((list($r, $v) = $this->$m($v)) && $r) { 30 | return array($r, $v); 31 | } 32 | } 33 | return array(0, $v); 34 | } 35 | 36 | /* +3 */ 37 | 38 | function xResultVar($v) { 39 | $aggregate = ''; 40 | /* aggregate */ 41 | if ($sub_r = $this->x('\(?(AVG|COUNT|MAX|MIN|SUM)\s*\(\s*([^\)]+)\)\s+AS\s+([^\s\)]+)\)?', $v)) { 42 | $aggregate = $sub_r[1]; 43 | $result_var = $sub_r[3]; 44 | $v = $sub_r[2] . $sub_r[4]; 45 | } 46 | if ($sub_r && (list($sub_r, $sub_v) = $this->xVar($result_var)) && $sub_r) { 47 | $result_var = $sub_r['value']; 48 | } 49 | /* * or var */ 50 | if ((list($sub_r, $sub_v) = $this->x('\*', $v)) && $sub_r) { 51 | return array(array('var' => $sub_r['value'], 'aggregate' => $aggregate, 'alias' => $aggregate ? $result_var : ''), $sub_v); 52 | } 53 | if ((list($sub_r, $sub_v) = $this->xVar($v)) && $sub_r) { 54 | return array(array('var' => $sub_r['value'], 'aggregate' => $aggregate, 'alias' => $aggregate ? $result_var : ''), $sub_v); 55 | } 56 | return array(0, $v); 57 | } 58 | 59 | /* +4 */ 60 | 61 | function xLoadQuery($v) { 62 | if ($sub_r = $this->x('LOAD\s+', $v)) { 63 | $sub_v = $sub_r[1]; 64 | if ((list($sub_r, $sub_v) = $this->xIRIref($sub_v)) && $sub_r) { 65 | $r = array('type' => 'load', 'url' => $sub_r, 'target_graph' => ''); 66 | if ($sub_r = $this->x('INTO\s+', $sub_v)) { 67 | $sub_v = $sub_r[1]; 68 | if ((list($sub_r, $sub_v) = $this->xIRIref($sub_v)) && $sub_r) { 69 | $r['target_graph'] = $sub_r; 70 | } 71 | } 72 | return array($r, $sub_v); 73 | } 74 | } 75 | return array(0, $v); 76 | } 77 | 78 | /* +5 */ 79 | 80 | function xInsertDataQuery($v) { 81 | if ($sub_r = $this->x('INSERT\s+DATA\s+', $v)) { 82 | $r = array( 83 | 'type' => 'insert', 84 | 'dataset' => array(), 85 | ); 86 | $sub_v = $sub_r[1]; 87 | 88 | $r['target_graph'] = ''; 89 | /* CONSTRUCT keyword, optional */ 90 | if ($sub_r = $this->x('CONSTRUCT\s+', $sub_v)) { 91 | $sub_v = $sub_r[1]; 92 | } 93 | /* construct template */ 94 | if ((list($sub_r, $sub_v) = $this->xConstructTemplate($sub_v)) && is_array($sub_r)) { 95 | $r['construct_triples'] = $sub_r; 96 | } 97 | else { 98 | $this->addError('Construct Template not found'); 99 | return array(0, $v); 100 | } 101 | /* dataset */ 102 | while ((list($sub_r, $sub_v) = $this->xDatasetClause($sub_v)) && $sub_r) { 103 | $r['dataset'][] = $sub_r; 104 | } 105 | /* where */ 106 | if ((list($sub_r, $sub_v) = $this->xWhereClause($sub_v)) && $sub_r) { 107 | $r['pattern'] = $sub_r; 108 | } 109 | /* solution modifier */ 110 | if ((list($sub_r, $sub_v) = $this->xSolutionModifier($sub_v)) && $sub_r) { 111 | $r = array_merge($r, $sub_r); 112 | } 113 | return array($r, $sub_v); 114 | 115 | } 116 | return array(0, $v); 117 | } 118 | 119 | function xInsertQuery($v) { 120 | if ($sub_r = $this->x('INSERT\s+', $v)) { 121 | $r = array( 122 | 'type' => 'insert', 123 | 'dataset' => array(), 124 | ); 125 | $sub_v = $sub_r[1]; 126 | /* target */ 127 | if ($sub_r = $this->x('INTO\s+', $sub_v)) { 128 | $sub_v = $sub_r[1]; 129 | if ((list($sub_r, $sub_v) = $this->xIRIref($sub_v)) && $sub_r) { 130 | $r['target_graph'] = $sub_r; 131 | /* CONSTRUCT keyword, optional */ 132 | if ($sub_r = $this->x('CONSTRUCT\s+', $sub_v)) { 133 | $sub_v = $sub_r[1]; 134 | } 135 | /* construct template */ 136 | if ((list($sub_r, $sub_v) = $this->xConstructTemplate($sub_v)) && is_array($sub_r)) { 137 | $r['construct_triples'] = $sub_r; 138 | } 139 | else { 140 | $this->addError('Construct Template not found'); 141 | return array(0, $v); 142 | } 143 | /* dataset */ 144 | while ((list($sub_r, $sub_v) = $this->xDatasetClause($sub_v)) && $sub_r) { 145 | $r['dataset'][] = $sub_r; 146 | } 147 | /* where */ 148 | if ((list($sub_r, $sub_v) = $this->xWhereClause($sub_v)) && $sub_r) { 149 | $r['pattern'] = $sub_r; 150 | } 151 | /* solution modifier */ 152 | if ((list($sub_r, $sub_v) = $this->xSolutionModifier($sub_v)) && $sub_r) { 153 | $r = array_merge($r, $sub_r); 154 | } 155 | return array($r, $sub_v); 156 | } 157 | } 158 | } 159 | return array(0, $v); 160 | } 161 | 162 | /* +6 */ 163 | 164 | function xDeleteDataQuery($v) { 165 | if ($sub_r = $this->x('DELETE\s+DATA\s+', $v)) { 166 | $r = array( 167 | 'type' => 'delete', 168 | 'target_graphs' => array() 169 | ); 170 | $sub_v = $sub_r[1]; 171 | /* target */ 172 | do { 173 | $proceed = false; 174 | if ($sub_r = $this->x('FROM\s+', $sub_v)) { 175 | $sub_v = $sub_r[1]; 176 | if ((list($sub_r, $sub_v) = $this->xIRIref($sub_v)) && $sub_r) { 177 | $r['target_graphs'][] = $sub_r; 178 | $proceed = 1; 179 | } 180 | } 181 | } while ($proceed); 182 | /* CONSTRUCT keyword, optional */ 183 | if ($sub_r = $this->x('CONSTRUCT\s+', $sub_v)) { 184 | $sub_v = $sub_r[1]; 185 | } 186 | /* construct template */ 187 | if ((list($sub_r, $sub_v) = $this->xConstructTemplate($sub_v)) && is_array($sub_r)) { 188 | $r['construct_triples'] = $sub_r; 189 | /* dataset */ 190 | while ((list($sub_r, $sub_v) = $this->xDatasetClause($sub_v)) && $sub_r) { 191 | $r['dataset'][] = $sub_r; 192 | } 193 | /* where */ 194 | if ((list($sub_r, $sub_v) = $this->xWhereClause($sub_v)) && $sub_r) { 195 | $r['pattern'] = $sub_r; 196 | } 197 | /* solution modifier */ 198 | if ((list($sub_r, $sub_v) = $this->xSolutionModifier($sub_v)) && $sub_r) { 199 | $r = array_merge($r, $sub_r); 200 | } 201 | } 202 | return array($r, $sub_v); 203 | } 204 | return array(0, $v); 205 | } 206 | 207 | function xDeleteQuery($v) { 208 | if ($sub_r = $this->x('DELETE\s+', $v)) { 209 | $r = array( 210 | 'type' => 'delete', 211 | 'target_graphs' => array() 212 | ); 213 | $sub_v = $sub_r[1]; 214 | /* target */ 215 | do { 216 | $proceed = false; 217 | if ($sub_r = $this->x('FROM\s+', $sub_v)) { 218 | $sub_v = $sub_r[1]; 219 | if ((list($sub_r, $sub_v) = $this->xIRIref($sub_v)) && $sub_r) { 220 | $r['target_graphs'][] = $sub_r; 221 | $proceed = 1; 222 | } 223 | } 224 | } while ($proceed); 225 | /* CONSTRUCT keyword, optional */ 226 | if ($sub_r = $this->x('CONSTRUCT\s+', $sub_v)) { 227 | $sub_v = $sub_r[1]; 228 | } 229 | /* construct template */ 230 | if ((list($sub_r, $sub_v) = $this->xConstructTemplate($sub_v)) && is_array($sub_r)) { 231 | $r['construct_triples'] = $sub_r; 232 | /* dataset */ 233 | while ((list($sub_r, $sub_v) = $this->xDatasetClause($sub_v)) && $sub_r) { 234 | $r['dataset'][] = $sub_r; 235 | } 236 | /* where */ 237 | if ((list($sub_r, $sub_v) = $this->xWhereClause($sub_v)) && $sub_r) { 238 | $r['pattern'] = $sub_r; 239 | } 240 | /* solution modifier */ 241 | if ((list($sub_r, $sub_v) = $this->xSolutionModifier($sub_v)) && $sub_r) { 242 | $r = array_merge($r, $sub_r); 243 | } 244 | } 245 | return array($r, $sub_v); 246 | } 247 | return array(0, $v); 248 | } 249 | 250 | /* +7 */ 251 | 252 | function xSolutionModifier($v) { 253 | $r = array(); 254 | if ((list($sub_r, $sub_v) = $this->xGroupClause($v)) && $sub_r) { 255 | $r['group_infos'] = $sub_r; 256 | } 257 | if ((list($sub_r, $sub_v) = $this->xOrderClause($sub_v)) && $sub_r) { 258 | $r['order_infos'] = $sub_r; 259 | } 260 | while ((list($sub_r, $sub_v) = $this->xLimitOrOffsetClause($sub_v)) && $sub_r) { 261 | $r = array_merge($r, $sub_r); 262 | } 263 | return ($v == $sub_v) ? array(0, $v) : array($r, $sub_v); 264 | } 265 | 266 | /* +8 */ 267 | 268 | function xGroupClause($v) { 269 | if ($sub_r = $this->x('GROUP BY\s+', $v)) { 270 | $sub_v = $sub_r[1]; 271 | $r = array(); 272 | do { 273 | $proceed = 0; 274 | if ((list($sub_r, $sub_v) = $this->xVar($sub_v)) && $sub_r) { 275 | $r[] = $sub_r; 276 | $proceed = 1; 277 | if ($sub_r = $this->x('\,', $sub_v)) { 278 | $sub_v = $sub_r[1]; 279 | } 280 | } 281 | } while ($proceed); 282 | if (count($r)) { 283 | return array($r, $sub_v); 284 | } 285 | else { 286 | $this->addError('No columns specified in GROUP BY clause.'); 287 | } 288 | } 289 | return array(0, $v); 290 | } 291 | 292 | } 293 | --------------------------------------------------------------------------------