Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.75 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. include("db-info.php");
  5. $link = mysql_connect($server, $user, $pass);
  6. if(!mysql_select_db($database)) die(mysql_error());
  7.  
  8. include("session.inc.php");
  9. include("loadsettings.inc.php");
  10. ?>
  11.  
  12.  
  13.  
  14. <html>
  15.  
  16. <head>
  17.  
  18. <title><? echo $webtitle; ?> - Online sajt za vase slike</title>
  19. <link rel="stylesheet" href="style.css" type="text/css" />
  20.  
  21. <meta name="description" content="<? echo $description; ?>" />
  22. <meta name="keywords" content="<? echo $keywords; ?>" />
  23.  
  24.  
  25. <script language="JavaScript">
  26.  
  27. function showWindow(id) {
  28. window.open("show-fullsize.php?id=" + id,"FullsizeImage","menubar=no,width=800,height=600,scrollbars=yes,status=yes,resizable=yes");
  29. }
  30.  
  31. </script>
  32.  
  33. </head>
  34.  
  35.  
  36. <body link=#336699 vlink=#336699 alink=#336699>
  37. <?php include("header.php"); ?>
  38.  
  39. <center>
  40. <div class="content-container">
  41.  
  42.  
  43. <!-- ######################################################################################### -->
  44.  
  45. <?php
  46.  
  47.  
  48. if (isset($_GET["id"])) {
  49.  
  50. $id = $_GET["id"];
  51. if ($id == "") die("Please specify an image id!");
  52.  
  53. $result = mysql_query("SELECT * FROM `images` WHERE id='$id'");
  54. $number = mysql_num_rows($result);
  55. $row = mysql_fetch_array($result);
  56. if (!$number) die("Izvini ! Ova slika je izbrisana ili su prekrsena nasa pravila koriscenja <a href='terms.php'>Uslovi koriscenja</a> !");
  57.  
  58. $type = $row['type'];
  59.  
  60.  
  61. //IF IMAGE TYPE IS PRIVATE THEN SHOW THE PASSWORD FORM
  62. if ($type == "member-private") {
  63.  
  64. if ($row['userid'] != $userid) {
  65. echo "Ova slika je privatna. Unesi sifru da bih je video<br><br>";
  66. echo "<form action='show-image.php' method='POST'>
  67. <LABEL id='title'>Sifra:</LABEL> <input type='password' name='password' maxlength='30'>";
  68. echo "<input type='hidden' name='id' value='$id'> <input type='hidden' name='image' value='member'> ";
  69. echo "&nbsp; &nbsp; <input type='submit' value='View'></form>";
  70. }
  71. else show();
  72.  
  73. }
  74.  
  75.  
  76. //IF THE IMAGE TYPE IS MEMBER PUBLIC THEN SHOW IT!
  77. if ($type == "member-public") {
  78. show();
  79. }
  80.  
  81.  
  82. //IF THE IMAGE TYPE IS ANONYMOUS PUBLIC THEN SHOW IT!
  83. if ($type == "public") {
  84. show();
  85. }
  86.  
  87.  
  88. //IF THE IMAGE IS OF A GALLERY THEN:
  89. if ($type == "gallery") {
  90.  
  91. $q = "SELECT galleryid FROM `images` WHERE id = '$id'";
  92. if(!($result_set = mysql_query($q))) die(mysql_error());
  93. $row = mysql_fetch_row($result_set);
  94. $galleryid = $row[0];
  95.  
  96.  
  97. //CHECK IF THE GALLERY IN WHICH THE IMAGE IS PRESENT IS PUBLIC OR PRIVATE
  98. $result_set = mysql_query("SELECT * FROM `galleries` WHERE id = '$galleryid'");
  99. $row = mysql_fetch_array($result_set);
  100. $type1 = $row['type'];
  101. $imguserid = $row['userid'];
  102.  
  103.  
  104. //IF PRIVATE THEN SHOW THE PASSWORD FORM
  105. if ($type1 == "private") {
  106.  
  107. if ($imguserid == $userid) {
  108. show();
  109. } else {
  110.  
  111. if (isset($_SESSION['gallery' . $galleryid]))
  112. show();
  113. else {
  114. echo "Ova slika je privatna. Unesi sifru da bih je video<br><br>";
  115. echo "<form action='show-image.php' method='POST'>Sifra: <input type='password' name='password' maxlength='30'>";
  116. echo "<input type='hidden' name='id' value='$id'> <input type='hidden' name='image' value='gallery'>";
  117. echo "&nbsp; &nbsp; <input type='submit' value='View'></form>";
  118. }
  119. }
  120.  
  121. }
  122. else
  123. show();
  124.  
  125. }
  126.  
  127.  
  128.  
  129.  
  130.  
  131. //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
  132.  
  133.  
  134. }
  135. else {
  136.  
  137. //IF PASSWORD IS SUBMITTED
  138. if (isset($_POST["password"])) {
  139.  
  140. $id = $_POST["id"];
  141. $image = $_POST["image"];
  142.  
  143. //GET THE ASSOCIATIVE USER ID
  144. $imguserid = getUserId($id);
  145.  
  146. //EXTRACT HIS USER PASS
  147. $r = mysql_query("SELECT userpass FROM `members` WHERE id = '$imguserid'");
  148. $row1 = mysql_fetch_row($r);
  149. $userpass = $row1[0];
  150.  
  151. //THEN CHECK IT.. IF CORRECT THEN SHOW
  152. if ($_POST["password"] != $userpass)
  153. echo "Izvini ! Uneo si pogresnu sifru.";
  154. else
  155. show();
  156. }
  157.  
  158. }
  159.  
  160.  
  161.  
  162.  
  163. //THIS FUNCTION DISPLAYS THE IMAGE
  164. function show() {
  165.  
  166. global $id; global $session; global $userid;
  167.  
  168. include("loadsettings.inc.php");
  169.  
  170.  
  171. $q = "SELECT * FROM `images` WHERE id = '$id'";
  172. if(!($result_set = mysql_query($q))) die(mysql_error());
  173. $row = mysql_fetch_array($result_set);
  174.  
  175. $thumb = $row['thumb'];
  176. $image = $row['image'];
  177.  
  178. //UPDATE VIEWS COUNT AND LAST ACCESS DATE
  179. $views = $row['views'] + 1;
  180. $access = date("y-m-d");
  181. $r = mysql_query("UPDATE `images` SET views = '$views', access = '$access' WHERE id = '$id' ");
  182.  
  183.  
  184. $imguserid = getUserId($id);
  185.  
  186. $own = false;
  187. if ($imguserid != -1) {
  188.  
  189. if ($userid == $imguserid)
  190. $own = true;
  191.  
  192. $r = mysql_query("SELECT username FROM `members` WHERE id = '$imguserid'");
  193. $row1 = mysql_fetch_row($r);
  194. $username = $row1[0];
  195. }
  196. else $username = "Anonymous";
  197.  
  198.  
  199.  
  200. echo "<center>";
  201. echo "<br><LABEL id='title'>Pregleda:</LABEL> $views";
  202. echo "<br><LABEL id='title'>Datum dodate slike:</LABEL> {$row['date']}";
  203.  
  204.  
  205. //***********************************************************************************
  206.  
  207. //Check if image size is bigger than 800 X 800 then make it small to atleast 800 but proportionally
  208. $img = imagecreatefromunknown($image);
  209.  
  210. $mainWidth = imagesx($img);
  211. $mainHeight = imagesy($img);
  212.  
  213. if (($mainWidth > 800) || ($mainHeight > 800))
  214. {
  215. $a = ($mainWidth >= $mainHeight) ? $mainWidth : $mainHeight;
  216. $div = $a / 800;
  217. $mainWidth = intval($mainWidth / $div);
  218. $mainHeight = intval($mainHeight / $div);
  219.  
  220. echo "<br><br><a href='$image' title='Klikni ovde da vidis punu velicinu slike' target='_blank'>
  221. <img src='$image' border=1 width='$mainWidth' height='$mainHeight'>
  222. </a>";
  223. }
  224. else {
  225. echo "<br><br><img src='$image' border='1'>";
  226. }
  227.  
  228. //***********************************************************************************
  229.  
  230.  
  231.  
  232. echo "<br><br><LABEL id='title'>Detalji:</LABEL> {$row['details']}";
  233. echo "<br><LABEL id='title'>Dodao:</LABEL> $username";
  234. echo "<br><br><LABEL id='title'>Tag:</LABEL><br>{$row['tags']}";
  235.  
  236. echo "<br><br><br><br>";
  237.  
  238. echo "<div class='emailBox'>
  239. <form method='POST' action='email.php'>
  240. <LABEL id='title'>Posalji sliku prijateljima putem e-mail.:</LABEL><br> &nbsp; <input type='text' size='20' name='email'>&nbsp; &nbsp;
  241. <input type='submit' value='Send' name='emailImage'>
  242. <input type='hidden' name='id' value='$id'>
  243. <br>Separate multiple emails by commas (,)
  244. </form></div>";
  245.  
  246. echo "<br><br><a href='report.php?id=$id'><img src='images/abuse.png' border=0></a>";
  247.  
  248. if ($session == true)
  249. echo "&nbsp; <a href='addfavourite.php?id=$id'><img src='images/favourites.png' border=0></a>";
  250.  
  251.  
  252. echo "<br><br><br><hr color='#42679c'><br>";
  253.  
  254. //*****************************************************************************************************
  255.  
  256.  
  257. if ($imguserid != -1) {
  258.  
  259. $r = mysql_query("SELECT * FROM `comments` WHERE imageid = '$id' ORDER BY id DESC");
  260. $n = mysql_num_rows($r);
  261.  
  262.  
  263. echo "<div style='FLOAT: left; WIDTH: 500px; TEXT-ALIGN: left; BORDER-RIGHT: #42679c 2px solid;
  264. PADDING-LEFT: 20px; PADDING-RIGHT: 20px; HEIGHT: 300px; MARGIN-RIGHT: 20px'>";
  265. echo "<h2><u>Komentari</u></h2>";
  266.  
  267. if ($n) {
  268.  
  269. $ccount = -1;
  270. while ($row1 = mysql_fetch_array($r)) {
  271. $comment = str_replace("\n", "<br>", $row1['comment']);
  272.  
  273. $ccount++;
  274. if ($ccount == 5)
  275. echo "<br><a href='#' style='FONT-SIZE: 16px'
  276. onclick=\"getElementById('allcomments').style.display='block'; this.style.display='none'\">
  277. Pogledaj sve komentare</a>
  278. <div style='display: none' id='allcomments'>";
  279.  
  280. echo "<div class='commentbox'> $comment ";
  281. if ($own == true)
  282. echo "<br><a href='deletecomment.php?id={$row1['id']}'>Delete</a>";
  283. echo "</div>";
  284. }
  285. if ($ccount > 4) echo "</div>";
  286.  
  287. }
  288. else
  289. echo "<div class='commentbox'>Ova slika nema komentare !</div>";
  290.  
  291.  
  292. if ($session == true) {
  293.  
  294. echo "<form method='POST' action='postcomment.php'>
  295. <br><h2>Dodaj komentar</h2>
  296. <textarea cols=40 rows=4 name='comment'></textarea><br>
  297. <input type='hidden' name='id' value='$id'>
  298. <input type='submit' value='Post Comment' name='postcomment'>
  299. </form> <b>Max karaktera: 200</b>
  300. ";
  301. }
  302. echo "</div>";
  303.  
  304. }
  305.  
  306.  
  307. //********************************************************************************************************
  308.  
  309. echo "<div style='TEXT-ALIGN: left'>
  310. <h2><u>Kodovi:</u> </h2>";
  311. echo "<table style='border-collapse: collapse'><tr><td>";
  312.  
  313. echo "<LABEL id='title'>HTML:</LABEL><br><input type='text' size=60 onclick=\"this.select();\" value=\"<a href='{$website}/show-image.php?id=$id'> <img src='{$website}/{$thumb}' alt='Image Hosting' border='0'> </a>\">";
  314. echo "<br><br>";
  315.  
  316.  
  317. echo "<LABEL id='title'>BB Kod:</LABEL><br><input type='text' size=60 onclick=\"this.select();\" value=\"[URL={$website}/show-image.php?id={$id}] [IMG]{$website}/{$thumb}[/IMG][/URL]\">";
  318. echo "<br><br>";
  319.  
  320.  
  321. echo "<LABEL id='title'>Diretan Link Slike (HTML):</LABEL><br><input type='text' size=60 onclick=\"this.select();\" value=\"<a href='{$website}'> <img src='{$website}/{$image}'> </a>\">";
  322. echo "<br><br>";
  323.  
  324.  
  325. echo "<LABEL id='title'>Direktan Link Slike (BB Kod):</LABEL><br><input type='text' size=60 onclick=\"this.select();\" value=\"[URL={$website}] [IMG]{$website}/{$image}[/IMG][/URL]\">";
  326. echo "<br><br>";
  327.  
  328. echo "<LABEL id='title'>Samo link slike:</LABEL><br><input type='text' size=60 onclick=\"this.select();\" value=\"{$website}/{$image}\">";
  329.  
  330. echo "</td></tr></table></div>";
  331.  
  332.  
  333.  
  334. //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
  335.  
  336. echo "<p style='CLEAR: both'>";
  337.  
  338.  
  339.  
  340. }
  341.  
  342.  
  343.  
  344. // Returns the userid of image.. if its a gallery image it retrieves the userid from the galleries table
  345. function getUserId($id) {
  346.  
  347. $userid = "";
  348. $result = mysql_query("SELECT * FROM `images` WHERE id='$id'");
  349. $row = mysql_fetch_array($result);
  350. $type = $row['type'];
  351.  
  352. if ($type == "gallery") {
  353.  
  354. $q = "SELECT galleryid FROM `images` WHERE id = '$id'";
  355. if(!($result_set = mysql_query($q))) die(mysql_error());
  356. $row = mysql_fetch_row($result_set);
  357. $galleryid = $row[0];
  358.  
  359. $result_set = mysql_query("SELECT userid FROM `galleries` WHERE id = '$galleryid'");
  360. $row = mysql_fetch_row($result_set);
  361. $userid = $row[0];
  362. }
  363. else {
  364.  
  365. $q = "SELECT userid FROM `images` WHERE id = '$id'";
  366. if(!($result_set = mysql_query($q))) die(mysql_error());
  367. $row = mysql_fetch_row($result_set);
  368. $userid = $row[0];
  369. }
  370.  
  371.  
  372. return $userid;
  373.  
  374. }
  375.  
  376.  
  377.  
  378.  
  379.  
  380. function findExtension ($filename)
  381. {
  382. $filename = strtolower($filename) ;
  383. $exts = split("[/\\.]", $filename) ;
  384. $n = count($exts)-1;
  385. $exts = $exts[$n];
  386. return $exts;
  387. }
  388.  
  389.  
  390. function imagecreatefromunknown($path) {
  391.  
  392. $ext = findExtension($path);
  393.  
  394. switch ($ext) {
  395. case "jpg":
  396. $img = imagecreatefromjpeg($path);
  397. break;
  398. case "gif":
  399. $img = imagecreatefromgif($path);
  400. break;
  401. case "png":
  402. $img = imagecreatefrompng($path);
  403. break;
  404. }
  405.  
  406. return $img;
  407. }
  408.  
  409.  
  410.  
  411.  
  412.  
  413. ?>
  414.  
  415. <!-- ######################################################################################### -->
  416.  
  417. <?php include("footer.php"); ?>
  418.  
  419.  
  420. </div>
  421. </center>
  422. </body>
  423. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement