Ejemplo n.º 1
0
function printDir($request)
{
    $dir = BASE_PATH . $request;
    $uri = BASE_URI . $request;
    $html = "";
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
            if (interestingFile($file, $bla)) {
                if (is_dir($dir . '/' . $file)) {
                    $html .= "<div>\n" . '<a class="title" href="' . $uri . "/" . $file . '/">' . $file . "</a>\n";
                    $html .= listContent($dir . '/' . $file, $uri . $file . "/");
                    //printEntryLink($file);
                    $html .= "</div>\n";
                } else {
                    //file : print it
                    $html .= printPost($dir, $file, $uri . substr($file, 0, -5));
                }
            }
        }
    }
    return $html;
    closedir($dh);
}
Ejemplo n.º 2
0
        //$image_source = $crawl["data"]["children"][$i]["data"]["preview"]["images"][0]["resolutions"][0]["url"];
        //check if url already exists in our database
        $query = "SELECT * FROM `reddit-listener`.log WHERE url='{$permalink}'";
        //TODO use prepared statements
        //echo $query;
        $result = mysqli_query($conn, $query);
        //var_dump($result);
        if (mysqli_num_rows($result) != 0) {
            break;
        }
        mysqli_free_result($result);
        //add url to database (if this point is reached, there's no copy in database)
        $query = "INSERT INTO `reddit-listener`.log (url, updated_at) VALUES ('{$permalink}', " . time() . ")";
        //echo $query;
        mysqli_query($conn, $query);
        printPost($title, $domain, $url, $permalink, $author, $num_comments);
    }
}
/*
else //Grace period has not passed.
{
	$lastTimestamp = $_GET['last'];
	//$lastTimestamp = 1435800234;
	
	//get all posts after last update (up to 10)
	$query = //[omitted]
	$result = mysqli_query($conn, $query);
	
	while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
		//print	?>
		<div class="tracker_entry_wrapper" id="<?=time()?>">
Ejemplo n.º 3
0
$json = [];
//var_dump($matches);
for ($i = 0; $i < count($matches[0]); $i++) {
    $name = $matches[1][$i];
    $date = $matches[2][$i];
    //    var_dump($date);
    $post = $matches[3][$i];
    $likes = $matches[4][$i];
    $comments = $matches[5][$i];
    $json[] = ['name' => $name, 'date' => $date, 'post' => $post, 'likes' => $likes, 'comments' => $comments];
}
usort($json, function ($x, $y) {
    return strtotime($x['date']) < strtotime($y['date']);
});
foreach ($json as $post) {
    printPost($post);
}
function printPost($json)
{
    $name = $json['name'];
    $date = date('j F Y', strtotime($json['date']));
    $post = $json['post'];
    $likes = $json['likes'];
    $comments = $json['comments'];
    $hasComments = false;
    if ($comments !== '') {
        $comments = preg_split('/\\//', $comments, null, PREG_SPLIT_NO_EMPTY);
        $hasComments = true;
        //        var_dump($comments);
    }
    echo "<article><header><span>" . htmlspecialchars($name) . "</span><time>" . htmlspecialchars($date) . "</time></header>";
Ejemplo n.º 4
0
function printFile($dir, $file, $uri)
{
    $fileUri = guessBlogUri($uri, $dir . $file);
    $titlePrefix = printTitle($notSet, $file, $uri);
    $html = printPost($dir, $file, $fileUri, $titlePrefix);
    return $html;
}
Ejemplo n.º 5
0
function displayBlog($dbh, $queryResults, $ref, $value)
{
    while ($row = $queryResults->fetchRow(MDB2_FETCHMODE_ASSOC)) {
        $user = $row['user'];
        $time = $row['entered'];
        $image = $row['entry'];
        $entry = $row['caption'];
        $title = $row['title'];
        $id = $row['entry_id'];
        $hrefid = "#" . "div" . $id;
        $divid = "div" . $id;
        $modalhrefid = "#" . "modaldiv" . $id;
        $modaldivid = "modaldiv" . $id;
        $commentshrefid = "#" . "commentsdiv" . $id;
        $commentsdivid = "commentsdiv" . $id;
        $refid = $ref . "?entry_id={$id}&posting_user={$user}";
        printPost($title, $time, "toBlog.php?user={$user}", $user, $image, $entry);
        printLikeButton($dbh, $id, $modalhrefid, $refid, $user, $value);
        printCommentModal($modaldivid, $ref, $id, $user);
        printViewComments($commentshrefid, $commentsdivid, $dbh, $id);
        printViewLikes($hrefid, $divid, $dbh, $id);
    }
}
Ejemplo n.º 6
0
function printProjects($dir, $uri)
{
    if ($uri == PROJECTS_DIR) {
        return listProjects(BASE_PATH . $uri, "", BASE_URI . PROJECTS_DIR);
    }
    $file = getFileFromRequest($uri);
    $f = "";
    ////////////
    $html = "";
    if ($dir[strlen($dir) - 1] == '/') {
        $noSlash = substr($dir, 0, -1);
        //$html.= "base : $base last position of / =". strripos($noSlash,'/')."<br>\n";
        $f = substr($noSlash, strripos($noSlash, '/') + 1);
        //$html.= "base : $f<br>";
        if (strlen($f) > 0) {
            $file = $f . TEXTENSION;
        }
    }
    ////////////
    if (strlen($file) > 0 && file_exists($noSlash . TEXTENSION)) {
        //is a probably a draft
        $dirF = substr($noSlash, 0, -strlen($f));
        $html .= printPost($dirF, $file, BASE_URI . $uri);
    }
    if (is_dir($dir)) {
        //$html.= "is a directory $dir !!!!!!<br/>";
        if (preg_match("/projects\\/drafts\\//", $uri)) {
            $html .= "<div class=\"draft title\"><h1>Drafts</h1></div><div><i><b>This posts are draft for non currently developed projects : either old or futur projects</b></i></div>\n";
            if ($dh = opendir($dir)) {
                while (($file = readdir($dh)) !== false) {
                    if (interestingFile($file, $searchRegexp)) {
                        $uriPost = $uri . substr($file, 0, -5) . "/";
                        $html .= printPost($dir, $file, BASE_URI . $uriPost);
                    }
                }
            }
            return $html;
        } else {
            //is it an actual project ????
            if (file_exists($dir . $file)) {
                $close = printHierarchie($dir, $file, $uri);
                $html .= $close[0];
                $html .= printPost($dir, $file, BASE_URI . $uri);
                $html .= $close[1];
            } else {
                //list projects
                $html .= '<div class="dir"><a href="' . BASE_URI . $uri . '" class="title">' . $f . '</a>' . "\n";
                $html .= listProjects(BASE_PATH . $uri, "", BASE_URI . PROJECTS_DIR . $f . "/");
                $html .= "</div>\n";
            }
        }
        //remove any edit suffix.
        //check if the
        //isProjectDirectory ? :
        //$parts=strtok($dir,'/');
        //if($lastPart="drafts"
        //if is proejct dir proint project
        //if drafts dir $html.= drafts
        //if language $html.= projects
    } else {
        //$html.= "===== $dir is not a directory<br/>";
    }
    return $html;
}