Example #1
0
function print_msgs2($ar, $msgs)
{
    $keys = array_keys($ar);
    print "<dl style='position:relative; left:0px'><dd>";
    foreach ($keys as $key) {
        print $msgs[$key];
        print "<BR>";
        if (sizeof($ar[$key]) > 0) {
            print_msgs2($ar[$key], $msgs);
        }
    }
    print "</dd></dl>";
}
$result = get_thread($thread_id);
$content = array();
$msgs = print_thread($result, $content);
require 'html_head_inc.php';
?>
<base target="bottom">
</head>
<body>
<!--<table width="95%"><tr>
<td>-->
<!--<h3><?php 
print $title;
?>
</h3>-->
<!--</td>

</tr></table>-->
<?php 
Example #2
0
        }
    }
    $response->setContentType('application/json');
    $response->setJsonContent($data);
    return $response;
});
/**
 * GET /api/threads/[id]
 *
 * Returns one complete thread by ID (subjects only, no bodies), the way topthread.php does them
 */
$app->get('/api/threads/{id:[0-9]+}', function ($id) {
    $result = get_thread($id);
    $content = array();
    $msgs = print_thread($result, $content, function ($row) {
        return $row;
    });
    $response = new Response();
    function print_msgs2($ar, $msgs)
    {
        $messages = array();
        $keys = array_keys($ar);
        foreach ($keys as $key) {
            $row = $msgs[$key];
            $messages[] = array('id' => intval($row['id']), 'status' => intval($row['status']), 'subject' => api_get_subject($row['subject'], $row['status']), 'author' => array('id' => intval($row['auth']), 'name' => $row['username']), 'created' => $row['created'], 'views' => intval($row['views']), 'likes' => intval($row['likes']), 'dislikes' => intval($row['dislikes']), 'page' => intval($row['page']), 'parent' => intval($row['parent']), 'closed' => filter_var($row['post_closed'], FILTER_VALIDATE_BOOLEAN), 'flags' => intval($row['content_flags']), 'answers' => sizeof($ar[$key]) > 0 ? print_msgs2($ar[$key], $msgs) : array());
        }
        return $messages;
    }
    $array = print_msgs2($content, $msgs);
    if (count($array) > 0) {
        $id = array_keys($msgs)[0];