<?php

require_once "consumirReddit.php";
?>

<?php 
$the_title = 'Home';
$the_content = postToString($redditPosts->item($postNumber));
global $the_title, $the_content;
include 'single.php';
?>

Example #2
0
{
    $query_string = "";
    if ($_POST) {
        $kv = array();
        foreach ($_POST as $key => $value) {
            $kv[] = "{$key}={$value}";
        }
        $query_string = join("&", $kv);
    } else {
        $query_string = $_SERVER['QUERY_STRING'];
    }
    return $query_string;
}
$url = $_GET['url'];
$postData = str_replace('\\', "", $_GET['post']);
error_log("WORKING on: {$url} and _POST: " . postToString() . " postData: " . $postData);
if (!$url) {
    // Passed url not specified.
    $contents = 'ERROR: url not specified';
    $status = array('http_code' => 'ERROR');
} else {
    if (!preg_match($valid_url_regex, $url)) {
        // Passed url doesn't match $valid_url_regex.
        $contents = 'ERROR: invalid url';
        $status = array('http_code' => 'ERROR');
    } else {
        $ch = curl_init($url);
        if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
            $arr = array();
            array_push($arr, 'Content-Type: application/json; charset=utf-8');
            curl_setopt($ch, CURLOPT_HTTPHEADER, $arr);