Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //index.php : lignes 006 à 075
- //like.php : lignes 078 à 093
- //styles-res.css : lignes 096 à 127
- //index.php
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>LIFAchan</title>
- <link rel="stylesheet" type="text/css" href="style-res.css">
- </head>
- <body>
- <div class="menu"><center><h1>LIFAchan</h1></center></div>
- <div class="contenu">
- <form enctype="multipart/form-data" method="post" action="index.php">
- <div class="nouveau_post">
- <input type="text" name="author" placeholder="Entrez un nom"><br>
- <input type="file" name="post_img"><br>
- <textarea name="post_msg" style="width: 90%; height: 400px" placeholder="Entrez du texte..."><?php if (isset($_GET["id"])) { ?><a href="<?=$_GET["id"];?>">#<?=$_GET["id"];?></a><?php print "\n"; } ?><<?="";?>/textarea><br>
- <input type="submit" name="action" value="Poster">
- </div>
- </form><?php
- function extension($name) {
- $yeet = "";
- $i = strlen($name) - 1;
- while ($name[$i] != ".") {
- $yeet = $name[$i].$yeet;
- $i--;
- }
- return ".$yeet";
- }
- function show ($file = [], $name) {
- if ($file[1] == "") $author = "Anon"; else $author = $file[1];
- print "\n <div class=\"affiche_post\" style=\"text-align : left\" id=\"$name\"><table><tr><td>$author<td width='10px'><td>".$file[2]."\n <tr><td>";
- if (file_exists($name.$file[0]) and $file[0] != "") print "<a href='".$name.$file[0]."' target='_blank'><img height='100px' src='".$name.$file[0]."'></a>";
- print "<td><td>";
- for ($i = 4; $i < count($file); $i++) {
- if ($file[$i][0] == ">") {
- print "\n <span style='color: green'>".$file[$i]."</span><br>";
- } else {
- print "\n ".$file[$i]."<br>";
- }
- }
- print "\n </table><br><form method='post' action='like.php'><input type='submit' name='$name' value='Like'> (".$file[3]." likes)</form>"
- . "\n <a href='index.php?id=$name#$name'><button>Répondre</button></a>";
- print "</div>";
- }
- $dir = scandir(".",1);
- if (isset($_POST["post_msg"])) {
- $str = "";
- if ($_FILES["post_img"]["name"] != "") {
- $f = file_get_contents($_FILES["post_img"]["tmp_name"]);
- unlink($_FILES["post_img"]["tmp_name"]);
- file_put_contents(count($dir).extension($_FILES["post_img"]["name"]),$f);
- $str = extension($_FILES["post_img"]["name"]);
- }
- file_put_contents(count($dir),$str
- ."\n".$_POST["author"]
- ."\n".date("H:i:s Y/m/d")
- ."\n"."0"
- ."\n".$_POST["post_msg"]);
- }
- $dir = scandir(".",1);
- $files = [];
- foreach ($dir as $index => $content) {
- if (is_numeric($content)) {
- show(str_replace(["\n","\r"],"",file($content)),$content);
- }
- }
- ?>
- </div>
- </body>
- </html>
- //like.php
- <?php
- foreach ($_POST as $index => $content) {
- if ($content = "Like") {
- $name = $index;
- $f = str_replace(["\r","\n"],"",file($index));
- $f[3]++;
- $str = "";
- for ($i = 0; $i < count($f); $i++) {
- $str .= $f[$i]."\n";
- }
- file_put_contents($index,$str);
- }
- }
- ?>
- Patientez un instant...
- <meta http-equiv="refresh" content="1; index.php#<?=$name;?>">
- //style-res.css
- div.menu {
- background-color: red;
- position: fixed;
- left: 0px;
- top: 0px;
- width: 180px;
- float: left;
- padding: 10px;
- height: 100%;
- }
- div.contenu {
- background-color: blue;
- float: right;
- width: 70%;
- padding: 10px;
- margin: 10px;
- }
- div.nouveau_post { background-color: pink }
- div.affiche_post { background-color: orange }
- div.nouveau_post, div.affiche_post {
- height: auto;
- width: auto;
- padding: 10px;
- margin: 10px;
- text-align: center;
- }
- * {
- font-family: Arial
- }
- td {
- text-align: left
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement