From bdf26f361ae8ee4a77ffed68b39d7578f1a2c34f Mon Sep 17 00:00:00 2001 From: Marcello Stanisci Date: Mon, 25 Jan 2016 14:54:48 +0100 Subject: adapting blog to new specs; still to test --- src/frontend/pay.php | 2 +- src/frontend/util.php | 15 --------------- src/frontend_blog/essay_cc_pay.php | 4 ---- src/frontend_blog/essay_pay.php | 4 +++- src/frontend_lib/util.php | 15 +++++++++++++++ 5 files changed, 19 insertions(+), 21 deletions(-) delete mode 100644 src/frontend/util.php create mode 100644 src/frontend_lib/util.php diff --git a/src/frontend/pay.php b/src/frontend/pay.php index 9fbf5f87..a843bcc9 100644 --- a/src/frontend/pay.php +++ b/src/frontend/pay.php @@ -25,7 +25,7 @@ */ -include 'util.php'; +include '../frontend_lib/util.php'; function respond_success() { $_SESSION['payment_ok'] = true; diff --git a/src/frontend/util.php b/src/frontend/util.php deleted file mode 100644 index a758d113..00000000 --- a/src/frontend/util.php +++ /dev/null @@ -1,15 +0,0 @@ -mod(array ("path" => $path), http\Url::JOIN_PATH|http\URL::SANITIZE_PATH); - return $url->toString(); -} - -// Get a url with a path relative to the -// current script's path. -function url_rel($path) { - return url_join( - $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], - $path); -} -?> diff --git a/src/frontend_blog/essay_cc_pay.php b/src/frontend_blog/essay_cc_pay.php index a0bc8ba8..90cd080f 100644 --- a/src/frontend_blog/essay_cc_pay.php +++ b/src/frontend_blog/essay_cc_pay.php @@ -11,10 +11,6 @@ if (!isset($_SESSION['allowed_articles'])) $_SESSION['allowed_articles'] = array ($article => true); else $_SESSION['allowed_articles'] = array_merge($_SESSION['allowed_articles'], array ($article => true)); http_response_code (301); -// WARNING: the following construct yields non-expected forms when using URL -// parameter in it -//$url = (new http\URL($_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'])) -// ->mod(array ("path" => "essay_fulfillment.php?article=$article"), http\Url::JOIN_PATH); $url = 'http://' . $_SERVER['HTTP_HOST'] . "/essay_fulfillment.php?article=$article"; header("Location: " . $url); echo $url; diff --git a/src/frontend_blog/essay_pay.php b/src/frontend_blog/essay_pay.php index c1515330..1e017428 100644 --- a/src/frontend_blog/essay_pay.php +++ b/src/frontend_blog/essay_pay.php @@ -22,6 +22,7 @@ * 3. forward payment to backend */ include("../frontend_lib/merchants.php"); +include("../frontend_lib/util.php"); include("./blog_lib.php"); session_start(); @@ -57,7 +58,8 @@ $resp = give_to_backend($_SERVER['HTTP_HOST'], "backend/pay", json_encode($complete_deposit_permission, JSON_PRETTY_PRINT)); $status_code = $resp->getResponseCode(); -file_put_contents("/tmp/log", "gotten smth from backend, status: " . $status_code); + + // Our response code is the same we got from the backend: http_response_code ($status_code); // Now generate our body diff --git a/src/frontend_lib/util.php b/src/frontend_lib/util.php new file mode 100644 index 00000000..a758d113 --- /dev/null +++ b/src/frontend_lib/util.php @@ -0,0 +1,15 @@ +mod(array ("path" => $path), http\Url::JOIN_PATH|http\URL::SANITIZE_PATH); + return $url->toString(); +} + +// Get a url with a path relative to the +// current script's path. +function url_rel($path) { + return url_join( + $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], + $path); +} +?> -- cgit v1.2.3