Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div id="content">
- <?
- function file_extension($filename)
- {
- $path_info = pathinfo($filename);
- return $path_info['extension'];
- }
- if(isset($_GET["i"])){
- $query = "select * from images where FILE = '" . mysql_real_escape_string($_GET["i"]) . "';";
- $result = mysql_query($query) or die("SQL dotaz nešlo provést");
- $num = mysql_num_rows($result);
- if($num == 1){
- $form = false;
- while ($row=mysql_fetch_array($result)){
- echo "<h2>" . $row["NAME"] . "</h2><a href=\"" . $target_path . $row["FILE"] . "\" target=\"_blank\"><img src=\"" . $target_path . $row["FILE"] . "\" style=\"max-width: 600px; max-height: 400px;\"></a><br>";
- ?><table border=0 id="codes">
- <tr><td>Pouze link: </td><td><input type="text" class="code" value='<? echo $adresa . $target_path . $row["FILE"]; ?>'></td></tr>
- <tr><td>HTML kód: </td><td><input type="text" class="code" value='<a href="<? echo $adresa . $target_path . $row["FILE"]; ?>"><img src="<? echo $adresa . $target_path . $row["FILE"]; ?>"></a>'></td></tr>
- <tr><td>BB kód: </td><td><input type="text" class="code" value='[url=<? echo $adresa . $target_path . $row["FILE"]; ?>][img]<? echo $adresa . $target_path . $row["FILE"]; ?>[/img][/url]'></td></tr>
- </table> <?
- }
- }else{
- $form = true;
- echo "<h4>Omlouváme se, ale daný obrázek neexistuje</h4>";
- }
- }
- if(!isset($_GET["i"])){
- if(isset($_POST["send"])){
- switch(file_extension(strtolower($_FILES['file']['name']))){
- case "png":
- case "jpg":
- case "jpeg":
- $name = md5(time() . rand());
- $target_path = $target_path . $name . "." . file_extension(basename( $_FILES['file']['name']));
- $url = $name . "." . file_extension(basename( $_FILES['file']['name']));
- if(move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) {
- $query = "insert into images(NAME, FILE, UPLOADED) values('" . mysql_real_escape_string($_FILES['file']['name']) . "','" . mysql_real_escape_string($url) . "', now());";
- $result = mysql_query($query) or die("SQL dotaz nešlo provést");
- echo " Obrázek byl nahrán<br><h2>" . $_FILES['file']['name'] . "</h2><a href=\"" . $target_path . "\" target=\"_blank\"><img src=\"" . $target_path . "\" style=\"max-width: 600px; max-height: 400px;\"></a><br>";
- ?><table border=0 id="codes">
- <tr><td>Pouze link: </td><td><input type="text" class="code" value='<? echo $adresa . $target_path; ?>'></td></tr>
- <tr><td>HTML kód: </td><td><input type="text" class="code" value='<a href="<? echo $adresa . $target_path; ?>"><img src="<? echo $adresa . $target_path; ?>"></a>'></td></tr>
- <tr><td>BB kód: </td><td><input type="text" class="code" value='[url=<? echo $adresa . $target_path; ?>][img]<? echo $adresa . $target_path; ?>[/img][/url]'></td></tr>
- </table>
- <?
- $form = false;
- } else{
- echo "Při nahrávání došlo k chybě, zkuste to prosím znovu";
- $form = true;
- }
- break;
- default:
- echo "Nahrávat se můžou pouze obrázky s příponami .png; .jpg; .jpeg";
- $form = true;
- break;
- }
- }else{
- $form = true;
- }}
- if($form == true){
- ?>
- <form action="" enctype="multipart/form-data" method="POST">
- Vyber obrázek<br>
- <input type="file" name="file"><br>
- <input type="hidden" name="MAX_FILE_SIZE" value="30000000">
- <input type="submit" name="send" value="Nahrát">
- </form>
- <? } ?>
- <h3>Náhodné obrázky</h3>
- <? $query = "select * from images order by rand() limit 5";
- $result = mysql_query($query) or die("SQL dotaz nešlo provést");
- while ($row=mysql_fetch_array($result)){
- ?><a href="<? echo $adresa . "?i=" . $row["FILE"]; ?>"><div style="position: relative; width: 130px; height: 130px; float: left; margin-left: 18px;display: vertical-align: middle; "><img src="screens/<? echo $row["FILE"]; ?>" style="width: 130px; height: 130px;"></div></a>
- <?
- }
- ?>
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement