]> git.mxchange.org Git - friendica-addons.git/blob - jappixmini/jappix/php/post-store.php
jappixmini: include jappix source
[friendica-addons.git] / jappixmini / jappix / php / post-store.php
1 <?php
2
3 /*
4
5 Jappix - An open social platform
6 This is the store configuration POST handler (manager)
7
8 -------------------------------------------------
9
10 License: AGPL
11 Author: Vanaryon
12 Last revision: 28/12/10
13
14 */
15
16 // Someone is trying to hack us?
17 if(!defined('JAPPIX_BASE'))
18         exit;
19
20 // Music upload?
21 if(isset($_POST['upload'])) {
22         // Get the file path
23         $name_music = $_FILES['music_file']['name'];
24         $temp_music = $_FILES['music_file']['tmp_name'];
25         
26         // Any special name submitted?
27         if(isset($_POST['music_title']) && !empty($_POST['music_title'])) {
28                 // Add a form var
29                 $music_title = $_POST['music_title'];
30                 
31                 // Get the file extension
32                 $ext_music = getFileExt($name_music);
33                 
34                 // New name
35                 $name_music = '';
36                 
37                 // Add the artist name?
38                 if(isset($_POST['music_artist']) && !empty($_POST['music_artist'])) {
39                         // Add a form var
40                         $music_artist = $_POST['music_artist'];
41                         
42                         // Add the current POST var to the global string
43                         $name_music .= $_POST['music_artist'].' - ';
44                 }
45                 
46                 // Add the music title
47                 $name_music .= $_POST['music_title'];
48                 
49                 // Add the album name?
50                 if(isset($_POST['music_album']) && !empty($_POST['music_album'])) {
51                         // Add a form var
52                         $music_album = $_POST['music_album'];
53                         
54                         // Add the current POST var to the global string
55                         $name_music .= ' ['.$_POST['music_album'].']';
56                 }
57                 
58                 // Add the extension
59                 $name_music .= '.'.$ext_music;
60         }
61         
62         // Music path with new name
63         $path_music = JAPPIX_BASE.'/store/music/'.$name_music;
64         
65         // An error occured?
66         if(!isSafe($name_music) || $_FILES['music_file']['error'] || !move_uploaded_file($temp_music, $path_music)) { ?>
67         
68                 <p class="info smallspace fail"><?php _e("The music could not be received, please retry!"); ?></p>
69         
70         <?php }
71         
72         // Bad extension?
73         else if(!preg_match('/^(.+)(\.(og(g|a)|mp3|wav))$/i', $name_music)) {
74                 // Remove the image file
75                 if(file_exists($path_music))
76                         unlink($path_music);
77         ?>
78         
79                 <p class="info smallspace fail"><?php _e("This is not a valid music file, please encode in Ogg Vorbis, MP3 or WAV!"); ?></p>
80         
81         <?php }
82         
83         // The file has been sent
84         else { ?>
85         
86                 <p class="info smallspace success"><?php _e("Your music has been added!"); ?></p>
87         
88         <?php
89                 // Reset the form vars
90                 $music_title = '';
91                 $music_artist = '';
92                 $music_album = '';
93         }
94 }
95
96 // File deletion?
97 else if(isset($_POST['remove']))
98         removeElements();
99
100 ?>