function printResponse($data, $dataKey = null) {
	echo "<ul>";
	
	if (is_array($data) || is_object($data)) {
		echo "<li>";
		if ($dataKey) {
			echo $dataKey;
		}
		if (is_object($data)) {
			$data = get_object_vars($data);
		}
		foreach($data as $key => $value) {
			printResponse($value, $key);
		}
		echo "</li>";
	} else {
		echo '<li>'
			.($dataKey !== null ? $dataKey.' = ' : '')
			.$data
			.'</li>';
	}
	
	echo "</ul>";
}
예제 #2
0
<?php

include_once '../database/connect.php';
include_once 'users.php';
include_once 'json_response.php';
$params = ['username', 'password'];
foreach ($params as $param) {
    if (isset($_POST[$param])) {
        $params[$param] = $_POST[$param];
        continue;
    }
}
if (!register(htmlentities($params['username']), $params['password'])) {
    printResponse("user_exists", "register");
} else {
    printResponse("success", "register");
}
예제 #3
0
파일: sample.php 프로젝트: luoshulin/falcon
function get_object_info($baidu_bcs)
{
    global $bucket, $object;
    $response = $baidu_bcs->get_object_info($bucket, $object);
    printResponse($response);
    var_dump($response->header);
}
예제 #4
0
function checkForExistentFile()
{
    if (!isset($_POST['filePath'])) {
        exit;
    }
    if ($_POST['filePath'] == "") {
        exit;
    }
    $filePath = sanitizeFilePath($_POST['filePath']);
    $fullFilePath = USER_HARD_DISK_ROOT . '/' . $filePath;
    if (file_exists($fullFilePath)) {
        printResponse('EXISTENT_FILE');
    } else {
        printResponse('FILE_NOT_FOUND');
    }
    exit;
}
예제 #5
0
<?php

include_once '../database/connect.php';
include_once 'users.php';
function printResponse($value)
{
    $data = ['search' => $value];
    header('Content-Type: application/json');
    echo json_encode($data);
}
$params = ['search'];
foreach ($params as $param) {
    if (isset($_POST[$param])) {
        $params[$param] = $_POST[$param];
        continue;
    }
}
if (!search($params['search'])) {
    printResponse("wrong_search");
} else {
    printResponse("success");
}
예제 #6
0
$request = $_POST['request'];
switch ($request) {
    case 'get':
        if (getUserGoesToEvent($idUser, $idEvent)) {
            printResponse("going", 'event');
        } elseif (userIsInvited($idUser, $idEvent)) {
            printResponse("not going", 'event');
        } else {
            printResponse("not invited", 'event');
        }
        break;
    case 'attend':
        $state = $_POST['state'];
        switch ($state) {
            case 'true':
                $state = true;
                break;
            case 'false':
                $state = false;
                break;
            default:
                printResponse(false, 'event');
                break;
        }
        $result = setUserGoesToEvent($idUser, $idEvent, $state);
        printResponse($result, "attend");
        break;
    default:
        printResponse(false, 'event');
        break;
}
    printTitle("Testing setTaskNote");
    // commented out to avoid unwanted effect
    // printResponse($plancakeApi->setTaskNote($validTaskId, "this is a note from the API test"));
    printTitle("Testing addTask");
    printResponse($plancakeApi->addTask("this is a task from the API test"));
    printTitle("Testing addTask (misc parameters)");
    //printResponse($plancakeApi->addTask("this is a test", 2, false, false, '2010-11-18', '1930', null, null, null, 'this is a simple note', '1,2'));
    printTitle("Testing editTask");
    // commented out to avoid unwanted effect
    //printResponse($plancakeApi->editTask($validTaskId, "this is a test for the editTask API method"));
    printTitle("Testing editTask (misc parameters)");
    // commented out to avoid unwanted effect
    //printResponse($plancakeApi->editTask(22, "let's change this", 2, null, null, '2011-07-13', null, 10, 13, null, null, "1"));
    printTitle("Testing deleteTask");
    // commented out to avoid unwanted effect
    // printResponse($plancakeApi->deleteTask($validTaskId));
    printTitle("Testing whatHasChanged");
    printResponse($plancakeApi->whatHasChanged($fromTimestamp, $toTimestamp));
    printTitle("This is the token we have used and we can save for later use");
    echo $plancakeApi->token . "\n\n";
} catch (Exception $e) {
    die($e->getMessage() . "\n");
}
function printTitle($msg)
{
    echo "\n >>>>> {$msg} <<<<<\n";
}
function printResponse($response)
{
    echo print_r($response, true);
}