Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php]Dodawanie mp3
mp3-10
post
Post #1





Grupa: Zarejestrowani
Postów: 22
Pomógł: 0
Dołączył: 21.02.2008

Ostrzeżenie: (0%)
-----


Witam mam taki problem, zamiast skrypt dodawać pliki mp3 wyświetla tylko jeden z 3 możliwych komunikatów. Próbowałem już wielu sposobów, lecz nie mogę znaleść błędu.

skrypt najduje się na www.razit.pl/dodaj_mp3.html

  1. <?php
  2. class panel extends kernel_panel
  3. {
  4.  
  5. var $komunikat;
  6.  
  7.  
  8. function uruchom()
  9. {
  10. $this->komunikat = '';
  11.  
  12.  
  13.  
  14. if ($_GET['op'] == 'dodajmp')
  15. {
  16. $this->dodaj_mp3();
  17. }
  18.  
  19. $a = mysql_query('SELECT count(id) AS ilosc FROM '.DB_PREFIX.'mp3 WHERE user ='.$this->user->getId().' LIMIT 1');
  20. $dane = mysql_fetch_assoc($a);
  21. $ilosc_mp3 = intval($dane['ilosc']);
  22.  
  23.  
  24.  
  25. if ($ilosc_mp3 >= $this->config['max_ilosc_mp3'] && $this->config['max_ilosc_mp3'] != 0)
  26. $this->komunikat = 'Nie możesz dodać więcej fotek ponieważ masz juz '.$this->config['max_ilosc_mp3'].'.';
  27. // else if ($this->user->getPlec() != 'k')
  28. // $this->komunikat = 'mp3 mogą dodawać tylko kobiety';
  29. else
  30. {
  31. $this->szablon->dodaj('formularz', true);
  32. }
  33.  
  34. $this->szablon->dodaj('komunikat', $this->komunikat);
  35. $this->szablon->dodaj('szablon', 'dodaj_mp3');
  36. $this->szablon->dodaj('szablon_dir', 'panel/');
  37. $this->szablon->wyswietl('index');
  38.  
  39. }
  40.  
  41. function dodaj_mp3()
  42. {
  43.  
  44. $a = mysql_query('SELECT count(id) AS ilosc FROM '.DB_PREFIX.'mp3 WHERE user ='.$this->user->getId().' LIMIT 1');
  45. $dane = mysql_fetch_assoc($a);
  46. $ilosc_mp3 = intval($dane['ilosc']);
  47.  
  48.  
  49. $mp3 = $_FILES['mp3'];
  50. $opis = trim($_POST['opis']);
  51. $tag = trim($_POST['tag']);
  52. if ($ilosc_mp3 >= $this->config['max_ilosc_mp3'] && $this->config['max_ilosc_mp3'] != 0)
  53. $this->komunikat = 'Dodałeś już maksymalną liczbę fotek!';
  54. // else if ($this->user->getPlec() != 'k')
  55. // $this->komunikat = 'mp3 mogą dodawać tylko kobiety';
  56. else if ($mp3['tmp_name'] == '')
  57. $this->komunikat = 'Wybierz plik';
  58. else
  59. {
  60. if ($this->config['akceptacja_fotek'] == 'tak')
  61. $stan = 'nowa';
  62. else
  63. $stan = 'ok';
  64.  
  65.  
  66. if (mysql_query('INSERT INTO '.DB_PREFIX.'mp3 VALUES ("", '.$this->user->getId().', "", '.time().', 0.0, 0, 0, "'.addslashes($opis).'", "'.$stan.'")'))
  67. {
  68. $id = mysql_insert_id();
  69. $rozszerzenie = '';
  70. $w = upload($mp3, 'mp3/', $rozszerzenie, array('mp3'), $id.'.{roz}' );
  71.  
  72. if ($w == 6)
  73. {
  74. $this->komunikat = 'Niewłaściwe rozszerzenie';
  75. mysql_query('DELETE FROM '.DB_PREFIX.'mp3 WHERE id = '.$id.' LIMIT 1');
  76. }
  77. else if ($w != 0)
  78. {
  79. $this->komunikat = 'Bład ładowania pliku';
  80. mysql_query('DELETE FROM '.DB_PREFIX.'mp3 WHERE id = '.$id.' LIMIT 1');
  81. }
  82. else if (!mysql_query('UPDATE '.DB_PREFIX.'mp3 SET rozszerzenie = "'.addslashes($rozszerzenie).'" WHERE id ='.$id.' LIMIT 1'))
  83. {
  84. $this->komunikat = 'Bład ładowani pliku';
  85. mysql_query('DELETE FROM '.DB_PREFIX.'mp3 WHERE id = '.$id.' LIMIT 1');
  86. }
  87. else
  88. {
  89. $this->komunikat = 'mp3 została dodana';
  90. if ($this->config['akceptacja_mp3'] == 'tak')
  91. $this->komunikat.='<br />Musi jeszcze zostać zatwierdzona przez admina';
  92. // udalo sie zaladowac
  93. } 
  94.  
  95. }
  96. else
  97. {
  98. $this->komunikat = 'Nie udało się dodać wpisu do bazy';
  99. }
  100. }
  101. }
  102.  
  103. }
  104. ?>


Ten post edytował mp3-10 21.02.2008, 21:01:58
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 24.08.2025 - 08:17