login  Naam:   Wachtwoord: 
Registreer je!
 Scripts:

Scripts > PHP > Upload systemen > Uploadscript (img/paginas/bewerk/show)

Uploadscript (img/paginas/bewerk/show)

Auteur: delta_004 - 23 februari 2006 - 20:41 - Gekeurd door: FangorN - Hits: 7844 - Aantal punten: 2.13 (8 stemmen)


Gewoon een upload script voor paginas en afbeeldingen.
Wel nog een beetje slordig

Code:

  1. <?
  2. function getExt($filename)
  3. {
  4. $atemp = explode('.', $filename);
  5. return strtolower($atemp[sizeof($atemp) - 1]);
  6. }
  7. $bestand = "sima.php"; // naam van dit bestand
  8.  
  9. $seeimgmax = "430"; // de maximale breedte van de foto als je hem helemaal wilt zien
  10. $thumbimgmax = "120"; // de maximale breedte van de foto's bij het weergeven van ze allemaal, de thumnails.
  11. $imgmap = "testimg"; // map waar de upgeload fotos komen
  12.  
  13. $paginamap = "testmap"; // map waar de upgeloade paginas komen.
  14.  
  15. if(isset($_GET['seeimg']))
  16. {
  17. if(file_exists($imgmap.'/'.$_GET['seeimg']))
  18. {
  19.  
  20. $size = getimagesize($imgmap.'/'.$_GET['seeimg']);
  21. $breedte = $size[0];
  22. $hoogte = $size[1];
  23.  
  24. if($size[0] > $seeimgmax)
  25. {
  26. $breedte = 'width="'.$seeimgmax.'"';
  27. }
  28. ?>
  29. <table cellpadding="0" cellspacing="0" width="50%">
  30. <tr>
  31. <td align="center">
  32. <?
  33.  
  34. if(isset($_GET['delete']))
  35. {
  36. if($_GET['seeimg'] == $_GET['delete'])
  37. {
  38. @unlink($imgmap.'/'.$_GET['seeimg']);
  39. header("Location: ".$bestand."?img=show");
  40. }
  41. }
  42.  
  43. echo '<a href="'.$bestand.'?seeimg='.$_GET['seeimg'].'&delete='.$_GET['seeimg'].'">[Verwijder deze afbeelding]</a>';
  44. ?><br><img border="0" <?=$breedte?> src="<?=$imgmap.'/'.$_GET['seeimg']?>"><br><br></td>
  45. </tr>
  46. </table>
  47. <table cellpadding="0" cellspacing="0">
  48. <tr>
  49. <td>&nbsp;</td>
  50. </tr>
  51. </table>
  52. <?
  53. }
  54. else
  55. {
  56. echo 'Dit bestand bestaat niet.';
  57. }
  58. }
  59. elseif(isset($_GET['seepage']))
  60. {
  61. ?>
  62. <script language="JavaScript">
  63. function popUp(URL) {
  64. day = new Date();
  65. id = day.getTime();
  66. eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,left = 0,top = 0');");
  67. }
  68. popUp("<?=$paginamap.'/'.$_GET['seepage']?>");
  69. window.location = '<?=$bestand?>?page=show';
  70. </script>
  71. <?
  72. }
  73. elseif(isset($_GET['img']))
  74. {
  75. if(!is_dir($imgmap))
  76. {
  77. mkdir($imgmap, 0755);
  78. }
  79.  
  80. if($_GET['img'] == 'show')
  81. {
  82. $files = array();
  83. $handle = opendir($imgmap.'/');
  84.  
  85. while(($read = readdir($handle)) !== false)
  86. {
  87. if($read != '.' && $read != '..')
  88. {
  89. $ex = explode('.', $read);
  90. $ext = strtolower(array_pop($ex));
  91.  
  92. $file_info = array($read, $ext);
  93. $files[$read] = $file_info;
  94. }
  95. }
  96. ?>
  97. <table cellpadding="0" cellspacing="0" width="50%">
  98. <tr>
  99. <td>Image-Dump</td>
  100. </tr>
  101. </table>
  102. <table cellpadding="0" cellspacing="0" width="50%">
  103. <tr>
  104. <td align="center">
  105. <a href="<?=$bestand?>?img=post">Klik hier voor een foto toevoegen.</a><br>
  106. <br>
  107. <?
  108. $aantal = count($files);
  109. foreach($files as $file)
  110. {
  111. $size = getimagesize($imgmap.'/'.$file[0]);
  112. $breedte = $size[0];
  113. $hoogte = $size[1];
  114.  
  115. if($size[0] > $thumbimgmax)
  116. {
  117. $breedte = 'width="'.$thumbimgmax.'"';
  118. }
  119. ?>
  120. <a href="<?=$bestand?>?seeimg=<?=$file[0]?>"><img border="0" <?=$breedte?> src="<?=$imgmap.'/'.$file[0]?>"></a>&nbsp;
  121. <?
  122. echo ($i++ % 3) ? "" : "<br>";
  123. ;
  124. }
  125. ?><br><br>
  126. </td>
  127. </tr>
  128. </table>
  129. <table cellpadding="0" cellspacing="0">
  130. <tr>
  131. <td>&nbsp;</td>
  132. </tr>
  133. </table>
  134. <?
  135. }
  136. elseif($_GET['img'] == 'post')
  137. {
  138. $err = '';
  139. if(isset($_POST['uploadenn']))
  140. {
  141. if(file_exists($imgmap.'/'.$_FILES['upload']['name']))
  142. {
  143. $err .= 'Het bestand <b>'.$_FILES['upload']['name'].'</b> bestaat al.<br\>';
  144. }
  145. if (!eregi('\.(gif|jpg|png)$', $_FILES['upload']['name']))
  146. {
  147. $err .= $_FILES['upload']['tmp_naam'].'Het bestand heeft niet de extensie gif, jpg of png maar '.getExt($_FILES['upload']['name']).'.<br\>';
  148. }
  149.  
  150. if($err != '')
  151. {
  152. echo $err;
  153. }
  154. else
  155. {
  156. @move_uploaded_file( $_FILES['upload']['tmp_name'], $imgmap.'/'.$_FILES['upload']['name'] );
  157. ?>
  158. <table cellpadding="0" cellspacing="0" width="50%">
  159. <tr>
  160. <td>Upload Toevoegen</td>
  161. </tr>
  162. </table>
  163. <table cellpadding="0" cellspacing="0" width="50%">
  164. <tr>
  165. <td align="center">Uw bestand is geupload.<br>Klik <a href="<?=$bestand?>?seeimg=<?=$_FILES['upload']['name']?>">hier op het te bekijken.</td>
  166. </tr>
  167. </table>
  168. <table cellpadding="0" cellspacing="0">
  169. <tr>
  170. <td>&nbsp;</td>
  171. </tr>
  172. </table>
  173. <?
  174. }
  175. }
  176. else
  177. {
  178. ?>
  179. <table cellpadding="0" cellspacing="0" width="50%">
  180. <tr>
  181. <td>Upload Toevoegen</td>
  182. </tr>
  183. </table>
  184. <table cellpadding="0" cellspacing="0" width="50%">
  185. <tr>
  186. <td align="center">
  187. <form style="margin: 0px; margin-bottom: 2px; padding: 0px;" method="post" enctype="multipart/form-data" name="upload">
  188. <input style="font-size: 10px;" type="file" name="upload" id="upload"><br>
  189. <input style="font-size: 10px;" type="submit" name="uploadenn" value="uploaden">
  190. </form>
  191. </td>
  192. </tr>
  193. </table>
  194. <table cellpadding="0" cellspacing="0">
  195. <tr>
  196. <td>&nbsp;</td>
  197. </tr>
  198. </table>
  199. <?
  200. }
  201. }
  202. }
  203. elseif(isset($_GET['page']))
  204. {
  205. if(!is_dir($paginamap))
  206. {
  207. mkdir($paginamap, 0755);
  208. }
  209.  
  210. if($_GET['page'] == 'show')
  211. {
  212. $files = array();
  213. $handle = opendir($paginamap.'/');
  214.  
  215. while(($read = readdir($handle)) !== false)
  216. {
  217. if($read != '.' && $read != '..')
  218. {
  219. $ex = explode('.', $read);
  220. $ext = strtolower(array_pop($ex));
  221.  
  222. $file_info = array($read, $ext);
  223. $files[$read] = $file_info;
  224. }
  225. }
  226. ?>
  227. <table cellpadding="0" cellspacing="0" width="50%">
  228. <tr>
  229. <td>Pagina-Dump</td>
  230. </tr>
  231. </table>
  232. <table cellpadding="0" cellspacing="0" width="50%">
  233. <tr>
  234. <td align="center">
  235.  
  236. '<a href="<?=$bestand?>?page=post">Klik hier voor een pagina toevoegen.</a><br>
  237. <br>
  238. <?
  239. $aantal = count($files);
  240. foreach($files as $file)
  241. {
  242.  
  243. if(isset($_GET['delete']))
  244. {
  245. @unlink($paginamap.'/'.$_GET['delete']);
  246. header("Location: ".$bestand."?page=show");
  247. }
  248.  
  249. echo '[<a href="'.$bestand.'?page=show&delete='.$file[0].'">x</a>]';
  250.  
  251. ?>
  252. &nbsp;<font color="#ffcc33">-</font>&nbsp;<a href="<?=$bestand?>?seepage=<?=$file[0]?>"><?=$file[0]?></a>&nbsp;<font color="#ffcc33">-</font><br>
  253. <?
  254. }
  255. ?>
  256. </td>
  257. </tr>
  258. </table>
  259. <table cellpadding="0" cellspacing="0">
  260. <tr>
  261. <td>&nbsp;</td>
  262. </tr>
  263. </table>
  264. <?
  265. }
  266. elseif($_GET['page'] == 'post')
  267. {
  268. $err = '';
  269. if(isset($_POST['uploadenn']))
  270. {
  271. if(file_exists($paginamap.'/'.$_FILES['upload']['name']))
  272. {
  273. $err .= 'Het bestand <b>'.$_FILES['upload']['name'].'</b> bestaat al.<br\>';
  274. }
  275. if (!eregi('\.(htm|html|php|css|js|txt)$', $_FILES['upload']['name']))
  276. {
  277. $err .= $_FILES['upload']['tmp_naam'].'Het bestand heeft niet de extensie html, htm, php, cdd, txt, of js maar '.getExt($_FILES['upload']['name']).'.<br\>';
  278. }
  279.  
  280. if($err != '')
  281. {
  282. echo $err;
  283. }
  284. else
  285. {
  286. @move_uploaded_file( $_FILES['upload']['tmp_name'], $paginamap.'/'.$_FILES['upload']['name'] );
  287. ?>
  288. <table cellpadding="0" cellspacing="0" width="50%">
  289. <tr>
  290. <td>Upload Toevoegen</td>
  291. </tr>
  292. </table>
  293. <table cellpadding="0" cellspacing="0" width="50%">
  294. <tr>
  295. <td align="center">Uw bestand is geupload.<br>Klik <a href="<?=$bestand?>?seepage=<?=$_FILES['upload']['name']?>">hier op het te bekijken.</td>
  296. </tr>
  297. </table>
  298. <table cellpadding="0" cellspacing="0">
  299. <tr>
  300. <td>&nbsp;</td>
  301. </tr>
  302. </table>
  303. <?
  304. }
  305. }
  306. else
  307. {
  308. ?>
  309. <table cellpadding="0" cellspacing="0" width="50%">
  310. <tr>
  311. <td>Upload Toevoegen</td>
  312. </tr>
  313. </table>
  314. <table cellpadding="0" cellspacing="0" width="50%">
  315. <tr>
  316. <td align="center">
  317. <form style="margin: 0px; margin-bottom: 2px; padding: 0px;" method="post" enctype="multipart/form-data" name="upload">
  318. <input style="font-size: 10px;" type="file" name="upload" id="upload"><br>
  319. <input style="font-size: 10px;" type="submit" name="uploadenn" value="uploaden">
  320. </form>
  321. </td>
  322. </tr>
  323. </table>
  324. <table cellpadding="0" cellspacing="0">
  325. <tr>
  326. <td>&nbsp;</td>
  327. </tr>
  328. </table>
  329. <?
  330. }
  331. }
  332. }
  333. else
  334. {
  335. ?>
  336. <table cellpadding="0" cellspacing="0" width="50%">
  337. <tr>
  338. <td>Upload-dump</td>
  339. </tr>
  340. </table>
  341. <table cellpadding="0" cellspacing="0" width="50%">
  342. <tr>
  343. <td align="center">
  344. &nbsp;<font color="#ffcc33">-</font>&nbsp;<a href="<?=$bestand?>?img=show">Image-Dump</a>&nbsp;<font color="#ffcc33">-</font><br/>
  345. &nbsp;<font color="#ffcc33">-</font>&nbsp;<a href="<?=$bestand?>?page=show">Pagina-Dump</a>&nbsp;<font color="#ffcc33">-</font></td>
  346. </tr>
  347. </table>
  348. <table cellpadding="0" cellspacing="0">
  349. <tr>
  350. <td>&nbsp;</td>
  351. </tr>
  352. </table>
  353. <?
  354. }
  355. ?>

Download code! Download code (.txt)

 Stemmen
Niet ingelogd

 Reacties
Post een reactie
Lees de reacties  ( 8 )
© 2002-2012 Sitemasters.be - Regels - Gehost door: Vircon - Laadtijd: 0.122s