Skip to content

Commit

Permalink
upload
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesmannerheim committed Aug 19, 2013
0 parents commit b59df00
Show file tree
Hide file tree
Showing 37 changed files with 16,371 additions and 0 deletions.
95 changes: 95 additions & 0 deletions API.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php

/* · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
· ·
· ·
· Q V I T T E R ·
· ·
· http://github.com/hannesmannerheim/qvitter ·
· ·
· ·
· <o) ·
· /_//// ·
· (____/ ·
· (o< ·
· o> \\\\_\ ·
· \\) \____) ·
· ·
· ·
· ·
· Qvitter is free software: you can redistribute it and / or modify it ·
· under the terms of the GNU Affero General Public License as published by ·
· the Free Software Foundation, either version three of the License or (at ·
· your option) any later version. ·
· ·
· Qvitter is distributed in hope that it will be useful but WITHOUT ANY ·
· WARRANTY; without even the implied warranty of MERCHANTABILTY or FITNESS ·
· FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for ·
· more details. ·
· ·
· You should have received a copy of the GNU Affero General Public License ·
· along with Qvitter. If not, see <http://www.gnu.org/licenses/>. ·
· ·
· Contact h@nnesmannerhe.im if you have any questions. ·
· ·
· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */

include 'settings.php';

header("Content-type: application/json; charset=utf-8");
if(substr($apiroot,-1) != '/') { $apiroot .= '/'; } // add slash if missing

// post requests
if(isset($_POST['postRequest'])) {
$query = http_build_query($_POST, '', '&');
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $apiroot.urldecode($_POST['postRequest']));
curl_setopt($ch, CURLOPT_USERPWD, $_POST['username'].":".$_POST['password']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
session_write_close(); // fix problem with curling to local
$reply=curl_exec($ch);
curl_close($ch);
session_start();

// force ssl on our domain
if($forcessl) {
$reply = str_replace('http://'.$siterootdomain,'https://'.$siterootdomain,$reply);
}

print $reply;
}

// get requests
elseif(isset($_POST['getRequest'])) {
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $apiroot.$_POST['getRequest']);

if(isset($_POST['username'])) {
curl_setopt($ch, CURLOPT_USERPWD, $_POST['username'].":".$_POST['password']);
}

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
session_write_close();
$reply=curl_exec($ch);
curl_close($ch);
session_start();

// force ssl on our domain
if($forcessl) {
$reply = str_replace('http:\/\/'.$siterootdomain,'https:\/\/'.$siterootdomain,$reply);
}

print $reply;
}



/* · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
· ·
· (o> >o) ·
· \\\\_\ /_//// .
· \____) (____/ ·
· ·
· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */?>
Loading

0 comments on commit b59df00

Please sign in to comment.