Updated debug client to work with live server

pull/41/head
Laurent Cozic 2017-01-11 11:46:04 +01:00
parent a1bffbb5e5
commit ad3c59577e
3 changed files with 20 additions and 9 deletions

View File

@ -73,3 +73,8 @@ td {
width: 300px;
display: inline-block;
}
.debug {
color: #777;
font-family: monospace;
}

View File

@ -11,8 +11,11 @@ function initialize() {
}
function config($name) {
$host = $_SERVER['HTTP_HOST'];
$config = array(
'baseUrl' => 'http://joplin.local',
'host' => $host,
'baseUrl' => $host == 'joplinclient.local' ? 'http://joplin.local' : 'https://joplin.cozic.net',
'clientId' => 'E3E3E3E3E3E3E3E3E3E3E3E3E3E3E3E3',
);
if (isset($config[$name])) return $config[$name];
@ -53,6 +56,7 @@ function execRequest($method, $path, $query = array(), $data = null) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
if ($data) curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
if ($method != 'GET' && $method != 'POST') {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
@ -131,6 +135,7 @@ if (isset($_POST['update_folder'])) $action = 'update_folder';
$pageParams = array(
'title' => ucfirst($action),
'contentHtml' => '',
'baseUrl' => config('baseUrl'),
);
switch ($action) {
@ -180,12 +185,6 @@ switch ($action) {
}
echo renderView('page', $pageParams);
$pageParams['curlCommands'] = isset($_SESSION['curlCommands']) ? $_SESSION['curlCommands'] : array();
echo '<pre style="color: #777; font-family: monospace;">';
$curlCommands = isset($_SESSION['curlCommands']) ? $_SESSION['curlCommands'] : array();
for ($i = count($curlCommands) - 1; $i >= 0; $i--) {
$cmd = $curlCommands[$i];
echo $cmd . "\n";
}
echo '</pre>';
echo renderView('page', $pageParams);

View File

@ -8,5 +8,12 @@
<a href="/">Home</a>
<h1><?php echo htmlentities($title); ?></h1>
<?php echo $contentHtml; ?>
<hr/>
<div class="debug">
<p>Base URL: <?php echo htmlentities($baseUrl); ?></p>
<?php for ($i = count($curlCommands) - 1; $i >= 0; $i--): $cmd = $curlCommands[$i]; ?>
<?php echo $cmd; ?><br/>
<?php endfor; ?>
</div>
</body>
</head>