User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 374,006 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,849 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 302 | Replies: 2
Reply
Join Date: Jul 2006
Posts: 3
Reputation: davethedope is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
davethedope davethedope is offline Offline
Newbie Poster

Help Having a bit of trouble figuring out my image upload script

  #1  
Jan 23rd, 2008
Having a bit of trouble figuring out my image upload script. I have modified this a bit, but I am stuck as to how I can get all the links to be output into one space.

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <title><?=$site_name?></title>
  5. <style type="text/css">
  6. <!--
  7. .tbl {
  8. border-style:solid;
  9. border-width:1px;
  10. border-color:#CCCCCC;
  11. }
  12. -->
  13. </style>
  14. <LINK href="images/style.css" type=text/css rel=stylesheet>
  15. <title>Photo Uploaded</title>
  16. </head>
  17. <script language="JavaScript" type="text/javascript">
  18. var gl1=1;
  19. var gl2=1;
  20. var gl3=1;
  21. var gl4=1;
  22. var gl5=1;
  23. var gl6=1;
  24. var gl7=1;
  25. var gl8=1;
  26. var gl9=1;
  27. var gl10=1;
  28. </script>
  29. <body>
  30.  
  31. <script language="JavaScript" type="text/javascript">
  32.  
  33. function check()
  34.  
  35. {
  36.  
  37. if (document.getElementById("to").value=="") {alert("You did not enter an e-mail address!"); return false; }
  38.  
  39. else {
  40.  
  41. if (document.getElementById("from").value=="") {alert("You did not enter your name/nickname!"); return false; }
  42.  
  43. }
  44.  
  45. }
  46.  
  47. </script>
  48.  
  49. <p>&nbsp;</p>
  50. <center>
  51. <div align="center"></div>
  52. <table width="741" height="323" border="0" align="center" cellpadding="0" cellspacing="0" class="table">
  53.  
  54. <tr>
  55.  
  56. <td width="739" height="299"><div align="center">
  57.  
  58. <p><span class="text">
  59.  
  60. <?php require("header.inc.php"); ?>
  61.  
  62. </span><br>
  63.  
  64. </p>
  65.  
  66. <table width="601" border="0">
  67.  
  68. <tr>
  69.  
  70. <td width="581" class="admintext"><p align="left" class="moreLink style1 style1">You will see the &quot;Download Link&quot; and &quot;Removal Link&quot; below this page.<br>
  71.  
  72. <br>
  73.  
  74. Give the download link to your friends and families worldwide and they can access your file by hitting the link. If you want to remove the image anytime later, please keep the removal link. Hitting the link will result in deleting the image from our server. </p>
  75.  
  76. </td>
  77.  
  78. </tr>
  79.  
  80. </table>
  81.  
  82. <?php
  83.  
  84. function ImageCreateFromBMP($filename)
  85.  
  86. {
  87. if (! $f1 = fopen($filename,"rb")) return FALSE;
  88. $FILE = unpack("vfile_type/Vfile_size/Vreserved/Vbitmap_offset", fread($f1,14));
  89. if ($FILE['file_type'] != 19778) return FALSE;
  90. $BMP = unpack('Vheader_size/Vwidth/Vheight/vplanes/vbits_per_pixel'.
  91. '/Vcompression/Vsize_bitmap/Vhoriz_resolution'.
  92. '/Vvert_resolution/Vcolors_used/Vcolors_important', fread($f1,40));
  93. $BMP['colors'] = pow(2,$BMP['bits_per_pixel']);
  94. if ($BMP['size_bitmap'] == 0) $BMP['size_bitmap'] = $FILE['file_size'] - $FILE['bitmap_offset'];
  95. $BMP['bytes_per_pixel'] = $BMP['bits_per_pixel']/8;
  96. $BMP['bytes_per_pixel2'] = ceil($BMP['bytes_per_pixel']);
  97. $BMP['decal'] = ($BMP['width']*$BMP['bytes_per_pixel']/4);
  98. $BMP['decal'] -= floor($BMP['width']*$BMP['bytes_per_pixel']/4);
  99. $BMP['decal'] = 4-(4*$BMP['decal']);
  100. if ($BMP['decal'] == 4) $BMP['decal'] = 0;
  101. $PALETTE = array();
  102. if ($BMP['colors'] < 16777216)
  103. {
  104. $PALETTE = unpack('V'.$BMP['colors'], fread($f1,$BMP['colors']*4));
  105. }
  106. $IMG = fread($f1,$BMP['size_bitmap']);
  107. $VIDE = chr(0);
  108. $res = imagecreatetruecolor($BMP['width'],$BMP['height']);
  109. $P = 0;
  110. $Y = $BMP['height']-1;
  111. while ($Y >= 0)
  112. {
  113. $X=0;
  114. while ($X < $BMP['width'])
  115. {
  116. if ($BMP['bits_per_pixel'] == 24)
  117. $COLOR = unpack("V",substr($IMG,$P,3).$VIDE);
  118. elseif ($BMP['bits_per_pixel'] == 16)
  119. {
  120. $COLOR = unpack("n",substr($IMG,$P,2));
  121. $COLOR[1] = $PALETTE[$COLOR[1]+1];
  122. }
  123. elseif ($BMP['bits_per_pixel'] == 8)
  124. {
  125. $COLOR = unpack("n",$VIDE.substr($IMG,$P,1));
  126. $COLOR[1] = $PALETTE[$COLOR[1]+1];
  127. }
  128. elseif ($BMP['bits_per_pixel'] == 4)
  129. {
  130. $COLOR = unpack("n",$VIDE.substr($IMG,floor($P),1));
  131. if (($P*2)%2 == 0) $COLOR[1] = ($COLOR[1] >> 4) ; else $COLOR[1] = ($COLOR[1] & 0x0F);
  132. $COLOR[1] = $PALETTE[$COLOR[1]+1];
  133. }
  134. elseif ($BMP['bits_per_pixel'] == 1)
  135. {
  136. $COLOR = unpack("n",$VIDE.substr($IMG,floor($P),1));
  137. if (($P*8)%8 == 0) $COLOR[1] = $COLOR[1] >>7;
  138. elseif (($P*8)%8 == 1) $COLOR[1] = ($COLOR[1] & 0x40)>>6;
  139. elseif (($P*8)%8 == 2) $COLOR[1] = ($COLOR[1] & 0x20)>>5;
  140. elseif (($P*8)%8 == 3) $COLOR[1] = ($COLOR[1] & 0x10)>>4;
  141. elseif (($P*8)%8 == 4) $COLOR[1] = ($COLOR[1] & 0x8)>>3;
  142. elseif (($P*8)%8 == 5) $COLOR[1] = ($COLOR[1] & 0x4)>>2;
  143. elseif (($P*8)%8 == 6) $COLOR[1] = ($COLOR[1] & 0x2)>>1;
  144. elseif (($P*8)%8 == 7) $COLOR[1] = ($COLOR[1] & 0x1);
  145. $COLOR[1] = $PALETTE[$COLOR[1]+1];
  146. }
  147. else
  148. return FALSE;
  149. imagesetpixel($res,$X,$Y,$COLOR[1]);
  150. $X++;
  151. $P += $BMP['bytes_per_pixel'];
  152. }
  153. $Y--;
  154. $P+=$BMP['decal'];
  155. }
  156. fclose($f1);
  157.  
  158. return $res;
  159.  
  160. }
  161. $mxx=1;
  162. while ($mxx<11)
  163. {
  164. $ext="";
  165. $id1="";
  166. $id2="";
  167. $uploaddir="";
  168. $uploadfile="";
  169. unset($width);
  170. unset($max_x);
  171. unset($height);
  172. unset($max_y);
  173. unset($percent);
  174. unset($newx);
  175. unset($newy);
  176. unset($ext);
  177. unset($uploadfile);
  178. unset($newimage);
  179. unset($img);
  180. unset($size);
  181. unset($sz);
  182. unset($tmax_x);
  183. unset($tmax_y);
  184. unset($ww);
  185. unset($hh);
  186. unset($resx);
  187. unset($resy);
  188. unset($thumbnail);
  189. unset($tmax_x);
  190. unset($tmax_y);
  191. unset($xxx);
  192. unset($yyy);
  193. unset($black);
  194. unset($white);
  195. unset($text);
  196. unset($resx);
  197. unset($resy);
  198. unset($size);
  199. unset($percent);
  200. unset($newx);
  201. unset($newy);
  202. unset($allowed);
  203. unset($text);
  204. unset($result);
  205. unset($uselink);
  206. unset($uselink2);
  207. unset($remlink);
  208. unset($thumblink);
  209. unset($rft);
  210. unset($mhost);
  211. if ($mxx!="1") {$imageident='userimg'.$mxx;} else {$imageident='userimg';}
  212. if (isset($_FILES[$imageident]['name']) && $_FILES[$imageident]['name']!="") {
  213. require("includes/connect.inc.php");
  214.  
  215. $query="SELECT slogan FROM img_admin WHERE 1";
  216. $result=mysql_query($query);
  217. $slogan=@mysql_result($result,0);
  218.  
  219. $query="SELECT websites FROM img_admin WHERE 1";
  220. $result=mysql_query($query);
  221. $websites=@mysql_result($result,0);
  222.  
  223. $query="SELECT hotlink1 FROM img_admin WHERE 1";
  224. $result=mysql_query($query);
  225. $hotlink1=@mysql_result($result,0);
  226.  
  227. $query="SELECT hotlink2 FROM img_admin WHERE 1";
  228. $result=mysql_query($query);
  229. $hotlink2=@mysql_result($result,0);
  230.  
  231. $query="SELECT hotlink3 FROM img_admin WHERE 1";
  232. $result=mysql_query($query);
  233. $hotlink3=@mysql_result($result,0);
  234.  
  235. $query="SELECT websites FROM img_admin WHERE 1";
  236. $result=mysql_query($query);
  237. $websites=@mysql_result($result,0);
  238.  
  239. $query="SELECT regularlink FROM img_admin WHERE 1";
  240. $result=mysql_query($query);
  241. $regularlink=@mysql_result($result,0);
  242.  
  243. $query="SELECT directlink FROM img_admin WHERE 1";
  244. $result=mysql_query($query);
  245. $directlink=@mysql_result($result,0);
  246.  
  247. $query="SELECT forums1 FROM img_admin WHERE 1";
  248. $result=mysql_query($query);
  249. $forums1=@mysql_result($result,0);
  250.  
  251. $query="SELECT forums2 FROM img_admin WHERE 1";
  252. $result=mysql_query($query);
  253. $forums2=@mysql_result($result,0);
  254.  
  255. $query="SELECT max_x FROM img_admin WHERE 1";
  256. $result=mysql_query($query);
  257. $max_x=@mysql_result($result,0);
  258.  
  259. $query="SELECT max_y FROM img_admin WHERE 1";
  260. $result=mysql_query($query);
  261. $max_y=@mysql_result($result,0);
  262.  
  263. $query="SELECT jpeg FROM img_files WHERE 1";
  264. $result=mysql_query($query);
  265. $jpeg=@mysql_result($result,0);
  266.  
  267. $query="SELECT jpg FROM img_files WHERE 1";
  268. $result=mysql_query($query);
  269. $jpg=@mysql_result($result,0);
  270.  
  271. $query="SELECT png FROM img_files WHERE 1";
  272. $result=mysql_query($query);
  273. $png=@mysql_result($result,0);
  274.  
  275. $query="SELECT gif FROM img_files WHERE 1";
  276. $result=mysql_query($query);
  277. $gif=@mysql_result($result,0);
  278.  
  279. $query="SELECT bmp FROM img_files WHERE 1";
  280. $result=mysql_query($query);
  281. $bmp=@mysql_result($result,0);
  282.  
  283. $query="SELECT tif FROM img_files WHERE 1";
  284. $result=mysql_query($query);
  285. $tif=@mysql_result($result,0);
  286.  
  287. $query="SELECT tiff FROM img_files WHERE 1";
  288. $result=mysql_query($query);
  289. $tiff=@mysql_result($result,0);
  290.  
  291. $ext = strtolower(substr(strrchr(basename($_FILES[$imageident]['name']), '.'), 1));
  292. if ($ext!="jpeg" && $ext!="jpg" && $ext!="png" && $ext!="gif" && $ext!="bmp" && $ext!="tiff" && $ext!="tif") {
  293. echo("<br><b>ERROR IN IMAGE</b><br>");//die("<META HTTP-EQUIV=\"refresh\" content=\"0;URL=../index.php?error=10\">");
  294. }
  295.  
  296. if ($ext=="jpeg" && $jpeg=="no") {die("<META HTTP-EQUIV=\"refresh\" content=\"0;URL=../index.php?error=10\">");}
  297.  
  298. if ($ext=="jpg" && $jpg=="no") {die("<META HTTP-EQUIV=\"refresh\" content=\"0;URL=../index.php?error=10\">");}
  299.  
  300. if ($ext=="png" && $png=="no") {die("<META HTTP-EQUIV=\"refresh\" content=\"0;URL=../index.php?error=10\">");}
  301.  
  302. if ($ext=="gif" && $gif=="no") {die("<META HTTP-EQUIV=\"refresh\" content=\"0;URL=../index.php?error=10\">");}
  303.  
  304. if ($ext=="bmp" && $bmp=="no") {die("<META HTTP-EQUIV=\"refresh\" content=\"0;URL=../index.php?error=10\">");}
  305.  
  306. if ($ext=="tiff" && $tiff=="no") {die("<META HTTP-EQUIV=\"refresh\" content=\"0;URL=../index.php?error=10\">");}
  307.  
  308. if ($ext=="tif" && $tif=="no") {die("<META HTTP-EQUIV=\"refresh\" content=\"0;URL=../index.php?error=10\">");}
  309.  
  310.  
  311. $id1 = md5(uniqid(rand(), true));
  312. $id2 = md5(uniqid(rand(), true));
  313. $uploaddir = 'temp/';
  314. $uploadfile = $uploaddir . $id1;
  315.  
  316. $rft=basename($_FILES[$imageident]['name']);
  317. $thumbnail="img/$id1/"."t".$rft;
  318.  
  319. if (move_uploaded_file($_FILES[$imageident]['tmp_name'], $uploadfile)) {
  320. if (!@getimagesize($uploadfile)) {unlink($uploadfile); /*die("<META HTTP-EQUIV=\"refresh\" content=\"0;URL=../index.php?error=13\">");*/
  321. $wrong="yes";
  322. } else {$wrong="no";}
  323.  
  324. if ($wrong!="yes")
  325. {
  326. $day=StrFTime('%d');
  327. $month=StrFTime('%m');
  328. $year=StrFTime('%Y');
  329. $minute=StrFTime('%M');
  330. $hour=StrFTime('%H');
  331. list($width, $height, $type, $attr) = getimagesize($uploadfile);
  332.  
  333. if ($_POST['rightclick']=="yes") {$rightclick="yes";} else {$rightclick="no";}
  334. if ($_POST['watermark']=="yes") {$watermark="yes";} else {$watermark="no";}
  335.  
  336. if ($mxx=="1") {$comment=$_POST['comment'];} else {$comment=$_POST['comment'.$mxx];}
  337.  
  338. if ($_POST['rating']=="yes") {$rating="yes";} else {$rating="no";}
  339. $rates=0;
  340. $rnumber=0;
  341.  
  342. if (getenv(HTTP_X_FORWARDED_FOR)) {
  343. $ipaddress=getenv(HTTP_X_FORWARDED_FOR)."(".GetHostByName(getenv(HTTP_X_FORWARDED_FOR)).")";
  344. } else {
  345. $ipaddress=getenv(REMOTE_ADDR)." (".GetHostByName(getenv(REMOTE_ADDR)).")";
  346. }
  347.  
  348. if ($ipaddress=="") {$ipaddress="Unknown";}
  349.  
  350. //---------image size check------------
  351.  
  352. if ($width>$max_x || $height>$max_y)
  353. {
  354. if ($width>$max_x && ($width>$height || $width==$height)){
  355. $percent=((100*$max_x)/$width);
  356. $newx=ceil($width-(((100-$percent)/100)*$width));
  357. $newy=ceil($height-(((100-$percent)/100)*$height));
  358. if ($newx<1) {$newx=1;}
  359. if ($newy<1) {$newy=1;}
  360.  
  361. if (strtolower($ext)=="bmp") {unlink($uploadfile); die("<META HTTP-EQUIV=\"refresh\" content=\"0;URL=../index.php?error=12\">");}
  362.  
  363. if (strtolower($ext)=="jpg" || strtolower($ext)=="jpeg") {if ($img=imagecreatefromjpeg($uploadfile)) {} else {unlink($uploadfile); die("<META HTTP-EQUIV=\"refresh\" content=\"0;URL=../index.php?error=12\">");}}
  364.  
  365. if (strtolower($ext)=="png") {if ($img=imagecreatefrompng($uploadfile)) {} else {unlink($uploadfile); die("<META HTTP-EQUIV=\"refresh\" content=\"0;URL=../index.php?error=12\">");}}
  366.  
  367. if (strtolower($ext)=="tiff" || strtolower($ext)=="gif") {die("<META HTTP-EQUIV=\"refresh\" content=\"0;URL=../index.php?error=12\">");}
  368. $newimage=imagecreatetruecolor($newx,$newy);
  369. imagecopyresampled($newimage,$img,0,0,0,0,$newx,$newy,$width,$height);
  370. imagedestroy($img);
  371. if (strtolower($ext)=="jpg") {imagejpeg($newimage, $uploadfile);}
  372. if (strtolower($ext)=="png") {imagepng($newimage, $uploadfile);}
  373. imagedestroy($newimage);
  374. $size=filesize($uploadfile);
  375. }
  376.  
  377. if ($height>$max_y && $width<$height){
  378.  
  379. $percent=((100*$max_y)/$height);
  380. $newx=ceil($width-(((100-$percent)/100)*$width));
  381. $newy=ceil($height-(((100-$percent)/100)*$height));
  382. if ($newx<1) {$newx=1;}
  383. if ($newy<1) {$newy=1;}
  384.  
  385. if (strtolower($ext)=="bmp") {unlink($uploadfile); die("<META HTTP-EQUIV=\"refresh\" content=\"0;URL=../index.php?error=12\">");}
  386.  
  387. if (strtolower($ext)=="jpg" || strtolower($ext)=="jpeg") {if ($img=imagecreatefromjpeg($uploadfile)) {} else {unlink($uploadfile); die("<META HTTP-EQUIV=\"refresh\" content=\"0;URL=../index.php?error=12\">");}}
  388.  
  389. if (strtolower($ext)=="png") {if ($img=imagecreatefrompng($uploadfile)) {} else {unlink($uploadfile); die("<META HTTP-EQUIV=\"refresh\" content=\"0;URL=../index.php?error=12\">");}}
  390.  
  391. if (strtolower($ext)=="tiff" || strtolower($ext)=="gif") {die("<META HTTP-EQUIV=\"refresh\" content=\"0;URL=../index.php?error=12\">");}
  392.  
  393. $newimage=imagecreatetruecolor($newx,$newy);
  394. imagecopyresampled($newimage,$img,0,0,0,0,$newx,$newy,$width,$height);
  395. imagedestroy($img);
  396. if (strtolower($ext)=="jpg") {imagejpeg($newimage, $uploadfile);}
  397. if (strtolower($ext)=="png") {imagepng($newimage, $uploadfile);}
  398. imagedestroy($newimage);
  399. $size=filesize($uploadfile);
  400. }
  401. }
  402.  
  403. if ($size=="") {$size=filesize($uploadfile);}
  404. if ($size != -1 && $size!="") {
  405. if ($size<1024){$sz="$size Bytes";}
  406. if ($size>=1024 && $size<1024*1024) {$sz=round($size/1024,1); $sz="$sz KB";}
  407. if ($size>=1024*1024 && $size<1024*1024*1024) {$sz=round(($size/1024)/1024,1); $sz="$sz MB";}
  408. if ($size>=1024*1024*1024 && $size<1024*1024*1024*1024) {$sz=round((($size/1024)/1024)/1024,1); $sz="$sz GB";}
  409. if ($size>=1024*1024*1024*1024 && $size<1024*1024*1024*1024*1024) {$sz=round(((($size/1024)/1024)/1024)/1024,1); $sz="$sz TB";}
  410. } else {
  411. $sz="-";
  412. }
  413. $size=$sz;
  414. //-------------------------------------
  415.  
  416. @mkdir("img/$id1", 0777);
  417.  
  418. //--------------------------------------------------------------------------
  419. //--------------------------------------------------------------------------
  420. //--------------------------------------------------------------------------
  421. if (strtolower(strtolower($ext))=="bmp" || strtolower(strtolower($ext))=="jpg" || strtolower(strtolower($ext))=="jpeg" || strtolower(strtolower($ext))=="png")
  422. {
  423. //--------------------------------------------------------------------------
  424. //------------------------Thumbnail works-----------------------------------
  425. //--------------------------------------------------------------------------
  426.  
  427. $tmax_x=175;
  428. $tmax_y=130;
  429. list($ww, $hh) = getimagesize($uploadfile);
  430. $resx=$ww;
  431. $resy=$hh;
  432.  
  433. if ($newx!="") {$width=$newx;};
  434. if ($newy!="") {$height=$newy;};
  435.  
  436. if ($width<$tmax_x && $height<$tmax_y) {
  437. if (strtolower($ext)=="bmp") {if ($img=ImageCreateFromBMP($uploadfile)) {} else {unlink($thumbnail); die("<META HTTP-EQUIV=\"refresh\" content=\"0;URL=../index.php?error=12\">");}}
  438. if (strtolower($ext)=="jpg" || strtolower($ext)=="jpeg") {if ($img=imagecreatefromjpeg($uploadfile)) {} else {unlink($thumbnail); die("<META HTTP-EQUIV=\"refresh\" content=\"0;URL=../index.php?error=12\">");}}
  439. if (strtolower($ext)=="png") {if ($img=imagecreatefrompng($uploadfile)) {} else {unlink($thumbnail); die("<META HTTP-EQUIV=\"refresh\" content=\"0;URL=../index.php?error=12\">");}}
  440. if (strtolower($ext)=="tiff" || strtolower($ext)=="gif") {$allowed="false";}
  441. $newimage=imagecreatetruecolor($tmax_x,$tmax_y+10);
  442. $xxx=ceil((175/2)-($width/2));
  443. $yyy=ceil((140/2)-($height/2));
  444. imagecopyresampled($newimage,$img,$xxx,$yyy+9,0,0,$width,$height,$width,$height);
  445. imagedestroy($img);
  446. $black = ImageColorAllocate ($newimage, 0, 0, 0);
  447. $white = ImageColorAllocate ($newimage, 255, 255, 255);
  448. $text="$resx"."x"."$resy - $size";
  449. imagefilledrectangle($newimage,0,0,$tmax_x,10,$black);
  450. imagerectangle($newimage,0,0,$tmax_x-1,$tmax_y+9,$black);
  451. imagestring($newimage, 1, 2, 1, "$text",$white);
  452. imagejpeg($newimage, $thumbnail);
  453. imagedestroy($newimage);
  454. $resx=$width; $resy=$height;
  455. } else {
  456. if ($width>$height || $width==$height){
  457. $percent=((100*$tmax_x)/$width);
  458. $newx=ceil($width-(((100-$percent)/100)*$width));
  459. $newy=ceil($height-(((100-$percent)/100)*$height));
  460.  
  461. if ($newx<1) {$newx=1;}
  462. if ($newy<1) {$newy=1;}
  463.  
  464. if (strtolower($ext)=="bmp") {if ($img=ImageCreateFromBMP($uploadfile)) {} else {unlink($thumbnail); die("<META HTTP-EQUIV=\"refresh\" content=\"0;URL=../index.php?error=12\">");}}
  465.  
  466. if (strtolower($ext)=="jpg" || strtolower($ext)=="jpeg") {if ($img=imagecreatefromjpeg($uploadfile)) {} else {unlink($thumbnail); die("<META HTTP-EQUIV=\"refresh\" content=\"0;URL=../index.php?error=12\">");}}
  467.  
  468. if (strtolower($ext)=="png") {if ($img=imagecreatefrompng($uploadfile)) {} else {unlink($thumbnail); die("<META HTTP-EQUIV=\"refresh\" content=\"0;URL=../index.php?error=12\">");}}
  469.  
  470. if (strtolower($ext)=="tiff" || strtolower($ext)=="gif") {$allowed="false";}
  471. if ($allowed!="false"){
  472. $newimage=imagecreatetruecolor($tmax_x,$tmax_y+10);
  473. $xxx=ceil((175/2)-($newx/2));
  474. $yyy=ceil((140/2)-($newy/2));
  475. imagecopyresampled($newimage,$img,$xxx,$yyy+9,0,0,$newx,$newy,$width,$height);
  476. imagedestroy($img);
  477. $black = ImageColorAllocate ($newimage, 0, 0, 0);
  478. $white = ImageColorAllocate ($newimage, 255, 255, 255);
  479. $text="$resx"."x"."$resy - $size";
  480. imagefilledrectangle($newimage,0,0,$tmax_x,10,$black);
  481. imagerectangle($newimage,0,0,$tmax_x-1,$tmax_y+9,$black);
  482. imagestring($newimage, 1, 2, 1, "$text",$white);
  483. imagejpeg($newimage, $thumbnail);
  484. imagedestroy($newimage);
  485. }
  486. }
  487. if ($width<$height){
  488. $percent=((100*$tmax_y)/$height);
  489. $newx=ceil($width-(((100-$percent)/100)*$width));
  490. $newy=ceil($height-(((100-$percent)/100)*$height));
  491. if ($newx<1) {$newx=1;}
  492. if ($newy<1) {$newy=1;}
  493.  
  494. if (strtolower($ext)=="bmp") {if ($img=ImageCreateFromBMP($uploadfile)) {} else {unlink($thumbnail); die("<META HTTP-EQUIV=\"refresh\" content=\"0;URL=../index.php?error=12\">");}}
  495.  
  496. if (strtolower($ext)=="jpg" || strtolower($ext)=="jpeg") {if ($img=imagecreatefromjpeg($uploadfile)) {} else {unlink($thumbnail); die("<META HTTP-EQUIV=\"refresh\" content=\"0;URL=../index.php?error=12\">");}}
  497.  
  498. if (strtolower($ext)=="png") {if ($img=imagecreatefrompng($uploadfile)) {} else {unlink($thumbnail); die("<META HTTP-EQUIV=\"refresh\" content=\"0;URL=../index.php?error=12\">");}}
  499. if (strtolower($ext)=="tiff" || strtolower($ext)=="gif") {$allowed="false";}
  500. if ($allowed!="false"){
  501. $newimage=imagecreatetruecolor($tmax_x,$tmax_y+10);
  502. $xxx=ceil((175/2)-($newx/2));
  503. $yyy=ceil((140/2)-($newy/2));
  504. imagecopyresampled($newimage,$img,$xxx,$yyy,0,0,$newx,$newy,$width,$height);
  505. $black = ImageColorAllocate ($newimage, 0, 0, 0);
  506. $white = ImageColorAllocate ($newimage, 255, 255, 255);
  507. $text="$resx"."x"."$resy - $size";
  508. imagefilledrectangle($newimage,0,0,$width,10,$black);
  509. imagerectangle($newimage,0,0,$tmax_x-1,$tmax_y+9,$black);
  510. imagestring($newimage, 1, 2, 1, "$text",$white);
  511. imagedestroy($img);
  512. imagejpeg($newimage, $thumbnail);
  513. imagedestroy($newimage);
  514. }}
  515.  
  516. //--------------------------------------------------------------------------
  517. //--------------------------------------------------------------------------
  518. }} else {$resx=$width; $resy=$height;}
  519. //--------------------------------------------------------------------------
  520. //--------------------------------------------------------------------------
  521. //--------------------------------------------------------------------------
  522.  
  523. if ($newx=="") {$newx=$width;} if ($newy=="") {$newy=$height;}
  524.  
  525. $query = "INSERT INTO `img_images` (`realfilename`, `size_width`, `size_height`, `allow_rc`, `watermark`, `comment`, `rating`, `rates`, `rnumber`, `ip`, `minute`, `hour`, `day`, `month`, `year`, `lminute`, `lhour`, `lday`, `lmonth`, `lyear`, `id1`, `id2`, `feedback`) VALUES ('$rft', '$resx', '$resy', '$rightclick', '$watermark', '$comment', '$rating', '$rates', '$rnumber', '$ipaddress', '$minute', '$hour', '$day', '$month', '$year', '$minute', '$hour', '$day', '$month', '$year', '$id1', '$id2', '')";
  526.  
  527. $result=mysql_query($query);
  528.  
  529. @copy($uploadfile,"img/$id1/$rft");
  530. @unlink($uploadfile);
  531. }
  532. //} else {die("<META HTTP-EQUIV=\"refresh\" content=\"0;URL=../index.php?error=4\">");}
  533.  
  534. require("includes/disconnect.inc.php");
  535.  
  536.  
  537. $uselink="http://";
  538. $uselink=$uselink.$_SERVER['HTTP_HOST'];
  539. $uselink=$uselink.dirname($_SERVER['PHP_SELF']);
  540.  
  541. if (strrpos(dirname($_SERVER['PHP_SELF']), "\\") != strlen(dirname($_SERVER['PHP_SELF']))-1 || strrpos(dirname($_SERVER['PHP_SELF']), "/") != strlen(dirname($_SERVER['PHP_SELF']))-1) {$uselink=$uselink."/";}
  542.  
  543. $uselink2=$uselink."view.php?img=$id1";
  544. $uselink2 = str_replace('\\','/',$uselink2);
  545. $uselink = str_replace('\\','/',$uselink);
  546. $remlink=$uselink."remove.php?img=$id2";
  547. $thumblink=$uselink."img/$id1/t$rft";
  548. $uselink=$uselink."img/$id1/$rft";
  549. $mhost=$_SERVER['HTTP_HOST'];
  550. $mhost=str_replace('\\\\','\\',$mhost);
  551. $mhost=str_replace("http://","",$mhost);
  552. $mhost="http://".$mhost;
  553. $uselinks.="\n".$uselink2;
  554.  
  555. ?>
  556.  
  557. <p class="ttl"> <span class="style2">
  558. <?php if ((strtolower(strtolower($ext))=="bmp" || strtolower(strtolower($ext))=="jpg" || strtolower(strtolower($ext))=="jpeg" || strtolower(strtolower($ext))=="png") && $wrong!="yes") {echo("<p class=\"ttl\"><span class=\"footer\">Thumbnail preview (opens in new window)</span><br><a href=\"$uselink2\" target=\"_blank\"><img src=\"$thumbnail\" border=\"0\"></a></p>");} ?>
  559. <?php if ($wrong!="yes") {echo $_FILES[$imageident]['name'];} ?>
  560. </span><br>
  561. <?php if ($wrong!="yes") { ?>
  562. <a href="#0" onclick="shide<?php echo $mxx; ?>(); return false;">Show/hide links and options for this image</a>
  563. <?php } ?>
  564. </p>
  565. <script language="JavaScript" type="text/javascript">
  566. function check<?php echo($mxx); ?>()
  567. { if (document.getElementById("email<?php echo($mxx); ?>").value==""){alert("You did not enter your e-mail address at e-mail field No. <?php echo($mxx); ?>!"); return false; }
  568. }
  569.  
  570. function shide<?php echo $mxx; ?>()
  571. {
  572. if (gl<?php echo($mxx); ?>==1)
  573. {
  574. gl<?php echo($mxx); ?>=0;
  575. document.getElementById("ui<?php echo($mxx); ?>").innerHTML='<p class="heading1">Use these links to share your picture: </p> <span class="style2"> <?php if ($hotlink3=="yes") {echo(" <p class=\"text\">Show image to friends: <br> <input name=\"textfield222\" type=\"text\" class=\"box\" value=\"$uselink2\" size=\"100\" onClick=\"select();\"></p>"); } ?><?php if ($hotlink1=="yes") {echo("<p class=\"text\">Hotlink for forums 1: <br><input name=\"textfield\" type=\"text\" class=\"box\" value=\"[url=$mhost][IMG]"); echo($uselink); echo("[/IMG][/url]\" size=\"100\" onClick=\"select();\"></p>"); } ?> <?php if ($hotlink2=="yes") {echo("<p class=\"text\">Hotlink for forums 2: <br> <input name=\"textfield2\" type=\"text\" class=\"box\" value=\"[url=$mhost][img=$uselink][/url]\" size=\"100\" onClick=\"select();\"></p>"); } ?><?php if (strtolower(strtolower($ext))=="bmp" || strtolower(strtolower($ext))=="jpg" || strtolower(strtolower($ext))=="jpeg" || strtolower(strtolower($ext))=="png"){if ($forums1=="yes" ) {echo(" <p class=\"text\">Thumbnail for forums 1: <br><input name=\"textfieldx\" type=\"text\" class=\"box\" value=\"[url=$uselink2][IMG]"); echo($thumblink); echo("[/IMG][/url]\" size=\"100\" onClick=\"select();\"></p>"); }} ?><?php if (strtolower(strtolower($ext))=="bmp" || strtolower(strtolower($ext))=="jpg" || strtolower(strtolower($ext))=="jpeg" || strtolower(strtolower($ext))=="png"){if ($forums2=="yes" ) {echo(" <p class=\"text\">Thumbnail for forums 2: <br> <input name=\"textfieldx1\" type=\"text\" class=\"box\" value=\"[url=$uselink2][img=$thumblink][/url]\" size=\"100\" onClick=\"select();\"></p>"); }} ?> <?php if ($websites=="yes") {echo(" <p class=\"text\">Hotlink for websites: <br> <input name=\"textfield22\" type=\"text\" class=\"box\" value=\'<a href=\"$mhost\"><img src=\"$uselink;\" border=\"0\" width=\"250\" alt=\"$slogan\" /></a>\' size=\"100\" onClick=\"select();\"> </p>"); } ?><?php if ($directlink=="yes") {echo(" <p class=\"text\">Direct link to image: <br> <input name=\"textfield223\" type=\"text\" class=\"box\" value=\"$uselink\" size=\"100\" onClick=\"select();\"></p>"); } ?> </span><p class="heading1">Use this link to remove this image from our server: </p><form action="remmail.php" method="post" name="form<?php echo $mxx; ?>" target="email2" class="style2" onsubmit="window.open(\'remmail.php\', \'email2\', \'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=265,left = 287,top = 209\');"><input name="link" type="hidden" id="link" value="<?php echo $uselink2; ?>"><input name="link" type="hidden" id="link" value="<?php echo $remlink; ?>"><input name="filen" type="hidden" id="filen" value="<?php echo $rft; ?>"><?php echo("<p class=\"text\"><input name=\"textfield223\" type=\"text\" class=\"box\" value=\"$remlink\" size=\"100\" onClick=\"select();\"></p>"); ?> <table width="525" border="0"> <tr> <td width="519" background="../audio/images/middleline.jpg">&nbsp;</td></tr> </table> <p><span class="heading1"><strong>E-mail me the &quot;show image to friends&quot; and the image removal link:</strong></span></p> <p><span class="heading1"><strong></strong></span><span class="text"> <input name="email" type="text" id="email<?php echo($mxx); ?>"> <input name="Submit2" type="submit" class="smallbutton" value="Submit" onClick="return check<?php echo $mxx; ?>()"> </span></p> </form> <table width="525" border="0"> <tr> <td width="519" background="../audio/images/middleline.jpg">&nbsp;</td> </tr></table>';
  576. }
  577. else
  578. {
  579. gl<?php echo($mxx); ?>=1;
  580. document.getElementById("ui<?php echo($mxx); ?>").innerHTML='';
  581. }
  582. }
  583. </script>
  584. <div id="ui<?php echo $mxx; ?>" name="0"></div>
  585. <p class="text style2">&nbsp;</p>
  586. <?php }} $mxx++;} ?>
  587. <table width="241" border="0">
  588.  
  589. <tr>
  590.  
  591. <td width="67" class="text style2"><img src="images/mail.jpg"></td>
  592.  
  593. <td width="164" class="style2 ttl"><strong class="heading1">E-mail image(s):</strong></td>
  594.  
  595. </tr>
  596.  
  597. </table>
  598.  
  599. <form name="form1" method="post" action="mail.php" target="email" onSubmit="window.open('mail.php', 'email', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=265,left = 287,top = 209');">
  600.  
  601. <table width="618" border="0" class="tbl">
  602.  
  603. <tr>
  604.  
  605. <td width="272" bgcolor="#F7F7F7" class="style1"><span class="text">To (e-mail):</span>
  606.  
  607. <input name="to" type="text" id="to">
  608.  
  609. <input name="id" type="hidden" id="id" value="<?php echo($uselinks); ?>"></td>
  610.  
  611. <td width="334" bgcolor="#F7F7F7" class="style1"><span class="text">From (your name or nickame):</span>
  612.  
  613. <input name="from" type="text" id="from"></td>
  614.  
  615. </tr>
  616. <center>
  617. <tr bgcolor="#F7F7F7">
  618.  
  619. <td colspan="2" class="style2"><p align="center" class="text style2 style3">Optional message: <br>
  620.  
  621. <textarea name="message" cols="65" rows="5" id="message"></textarea>
  622.  
  623. </p>
  624. <p align="center" class="text style2 style3">
  625. <input name="Submit" type="submit" class="submit" value="Send" onClick="return check()">
  626. </p></td>
  627.  
  628. </tr>
  629.  
  630. </table>
  631.  
  632. </form>
  633.  
  634. <br><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  635.  
  636. <tr>
  637.  
  638. <td height="67" valign="top"><div align="left"> <a href="/test2/"><img src="images/bck.jpg" width="60" height="42" border="0"></a></div>
  639.  
  640. <div align="center"></div>
  641.  
  642. <div align="right"></div></td>
  643.  
  644. </tr>
  645.  
  646. </table>
  647.  
  648. <table width="98%" border="0" cellpadding="0" cellspacing="0">
  649.  
  650. <tr>
  651.  
  652. <td width="7%"><div align="right"><img src="images/leftline.jpg" width="54" height="14"></div></td>
  653.  
  654. <td width="100%"><img src="images/middleline.jpg" width="100%" height="14"></td>
  655.  
  656. <td width="6%"><img src="images/rightline.jpg" width="40" height="14"></td>
  657.  
  658. </tr>
  659.  
  660. </table>
  661.  
  662. <div align="center"><span class="footer"> <br>
  663.  
  664. <?php include("footer.inc.php"); ?>
  665.  
  666. </span></div>
  667.  
  668. </div></td>
  669.  
  670. </tr>
  671.  
  672. </table>
  673.  
  674. <div align="center"></div>
  675.  
  676. <p>&nbsp;</p>
  677.  
  678. </body>
  679.  
  680. </html>
  681.  
  682. <?php
  683.  
  684.  
  685.  
  686. $yourdir="temp";
  687.  
  688.  
  689.  
  690. $dh = @opendir($yourdir) or die ("Could not open your directory!");
  691.  
  692. while (false!== ($file = @readdir($dh)))
  693.  
  694. {
  695.  
  696. if ($file!= "." && $file!= "..")
  697.  
  698. {
  699.  
  700. @unlink("$yourdir/$file");
  701.  
  702. }}
  703.  
  704.  
  705.  
  706. ?>


Mainly I want this

<?php if ($hotlink1=="yes") {echo("<p class=\"text\">Hotlink for forums 1: <br><input name=\"textfield\" type=\"text\" class=\"box\" value=\"[IMG]"); echo($uselink); echo("[/IMG]\" size=\"100\" onClick=\"select();\"></p>"); } ?>

to be output in a text field for all the images uploaded.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2007
Location: Budapest
Posts: 251
Reputation: fatihpiristine has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 12
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: Having a bit of trouble figuring out my image upload script

  #2  
Jan 24th, 2008
be more specific pls!
Do a favour, leave me alone
Reply With Quote  
Join Date: Jul 2006
Posts: 3
Reputation: davethedope is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
davethedope davethedope is offline Offline
Newbie Poster

Re: Having a bit of trouble figuring out my image upload script

  #3  
Jan 24th, 2008
Well, what I know is that

$mxx is the code for the pictures

and this is the actual working script that outputs the thumbnnails of the uploaded photos along with their links.

  1. <script language="JavaScript" type="text/javascript">
  2. function check<?php echo($mxx); ?>()
  3. { if (document.getElementById("email<?php echo($mxx); ?>").value==""){alert("You did not enter your e-mail address at e-mail field No. <?php echo($mxx); ?>!"); return false; }
  4. }
  5.  
  6. function shide<?php echo $mxx; ?>()
  7. {
  8. if (gl<?php echo($mxx); ?>==1)
  9. {
  10. gl<?php echo($mxx); ?>=0;
  11. document.getElementById("ui<?php echo($mxx); ?>").innerHTML='<p class="heading1">Use these links to share your picture: </p> <span class="style2"> <?php if ($hotlink3=="yes") {echo(" <p class=\"text\">Show image to friends: <br> <input name=\"textfield222\" type=\"text\" class=\"box\" value=\"$uselink2\" size=\"100\" onClick=\"select();\"></p>"); } ?><?php if ($hotlink1=="yes") {echo("<p class=\"text\">Hotlink for forums 1: <br><input name=\"textfield\" type=\"text\" class=\"box\" value=\"[url=$mhost][IMG]"); echo($uselink); echo("[/IMG][/url]\" size=\"100\" onClick=\"select();\"></p>"); } ?> <?php if ($hotlink2=="yes") {echo("<p class=\"text\">Hotlink for forums 2: <br> <input name=\"textfield2\" type=\"text\" class=\"box\" value=\"[url=$mhost][img=$uselink][/url]\" size=\"100\" onClick=\"select();\"></p>"); } ?><?php if (strtolower(strtolower($ext))=="bmp" || strtolower(strtolower($ext))=="jpg" || strtolower(strtolower($ext))=="jpeg" || strtolower(strtolower($ext))=="png"){if ($forums1=="yes" ) {echo(" <p class=\"text\">Thumbnail for forums 1: <br><input name=\"textfieldx\" type=\"text\" class=\"box\" value=\"[url=$uselink2][IMG]"); echo($thumblink); echo("[/IMG][/url]\" size=\"100\" onClick=\"select();\"></p>"); }} ?><?php if (strtolower(strtolower($ext))=="bmp" || strtolower(strtolower($ext))=="jpg" || strtolower(strtolower($ext))=="jpeg" || strtolower(strtolower($ext))=="png"){if ($forums2=="yes" ) {echo(" <p class=\"text\">Thumbnail for forums 2: <br> <input name=\"textfieldx1\" type=\"text\" class=\"box\" value=\"[url=$uselink2][img=$thumblink][/url]\" size=\"100\" onClick=\"select();\"></p>"); }} ?> <?php if ($websites=="yes") {echo(" <p class=\"text\">Hotlink for websites: <br> <input name=\"textfield22\" type=\"text\" class=\"box\" value=\'<a href=\"$mhost\"><img src=\"$uselink;\" border=\"0\" width=\"250\" alt=\"$slogan\" /></a>\' size=\"100\" onClick=\"select();\"> </p>"); } ?><?php if ($directlink=="yes") {echo(" <p class=\"text\">Direct link to image: <br> <input name=\"textfield223\" type=\"text\" class=\"box\" value=\"$uselink\" size=\"100\" onClick=\"select();\"></p>"); } ?> </span><p class="heading1">Use this link to remove this image from our server: </p><form action="remmail.php" method="post" name="form<?php echo $mxx; ?>" target="email2" class="style2" onsubmit="window.open(\'remmail.php\', \'email2\', \'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=265,left = 287,top = 209\');"><input name="link" type="hidden" id="link" value="<?php echo $uselink2; ?>"><input name="link" type="hidden" id="link" value="<?php echo $remlink; ?>"><input name="filen" type="hidden" id="filen" value="<?php echo $rft; ?>"><?php echo("<p class=\"text\"><input name=\"textfield223\" type=\"tex