Browse Source

Fixing the mp3 add process + adds possibility to upload 10Mb mp3 files

Cebabonet 7 years ago
parent
commit
4161a79b86

+ 2 - 2
admin/bm.php View File

149
                             } ?>
149
                             } ?>
150
 					</ul>
150
 					</ul>
151
 					<p>&nbsp;</p>
151
 					<p>&nbsp;</p>
152
-					<form action="bm.php" method="post" <?php echo (isset($_GET["new"]) && $_GET["new"]=="photo") ? "enctype=\"multipart/form-data\"" : ""?> name="frmAdd" class="newpost">
152
+					<form action="bm.php" method="post" <?php echo (isset($_GET["new"]) && ($_GET["new"]=="photo" || $_GET["new"]=="mp3")) ? "enctype=\"multipart/form-data\"" : ""?> name="frmAdd" class="newpost">
153
 						<fieldset>
153
 						<fieldset>
154
 <?php
154
 <?php
155
                             $date = time();
155
                             $date = time();
191
                                     $input = array("{type}", "{date}", "{id_user}", "{editUrl}", "{editBody}");
191
                                     $input = array("{type}", "{date}", "{id_user}", "{editUrl}", "{editBody}");
192
                                     $output = array("7", $date, $_SESSION['user_id'], $url, $body);
192
                                     $output = array("7", $date, $_SESSION['user_id'], $url, $body);
193
 
193
 
194
-                                    $template->cargarPlantilla($input, $output, "template_add_mp3");
194
+                                    $template->cargarPlantilla($input, $output, "template_add_mp3_bm");
195
                                     $template->mostrarPlantilla();
195
                                     $template->mostrarPlantilla();
196
                                     break;
196
                                     break;
197
                             } ?>
197
                             } ?>

+ 16 - 8
admin/index.php View File

60
         }
60
         }
61
 
61
 
62
         if ($_POST["type"]=="7") { // is MP3 type
62
         if ($_POST["type"]=="7") { // is MP3 type
63
-                        set_time_limit(300);
64
-            $mp3Name = $util_class->getFileName($_POST["url"]);
65
-            if (!$tumble->saveMP3($_POST["url"])) {
66
-                header("Location: ".$conf->urlSorbet."/admin/index.php?mp3=false");
67
-                die();
68
-            }
69
-            if ($util_class->isMP3($remoteFileName)) {
70
-                $_POST["url"] = $conf->urlSorbet."/uploads/".$mp3Name;
63
+                            set_time_limit(300);
64
+                        if (isset($_POST["url"]) && $_POST["url"]!="") {
65
+                            $mp3Name = $util_class->getFileName($_POST["url"]);
66
+                            if (!$tumble->saveMP3($_POST["url"])) {
67
+                                header("Location: ".$conf->urlSorbet."/admin/index.php?mp3=false");
68
+                                die();
69
+                            }
70
+                            $_POST["url"] = $conf->urlSorbet."/uploads/".$mp3Name;
71
+                        }
72
+
73
+            if (move_uploaded_file($_FILES['mp3']['tmp_name'], "../uploads/".$util_class->sanitizeName($_FILES['mp3']['name']))) {
74
+                $_POST["url"] = $conf->urlSorbet."/uploads/".$util_class->sanitizeName($_FILES['mp3']['name']);
71
             }
75
             }
76
+
77
+            unset($_POST["mp3"]);
78
+            unset($_POST["MAX_FILE_SIZE"]);
72
         }
79
         }
73
 
80
 
74
         if (!get_magic_quotes_gpc()) {
81
         if (!get_magic_quotes_gpc()) {
178
             $_GET['new'] = 'post';
185
             $_GET['new'] = 'post';
179
         }
186
         }
180
 
187
 
188
+
181
         $form = new themes;
189
         $form = new themes;
182
         $form->set('date', $date);
190
         $form->set('date', $date);
183
         $form->set('id_user', $_SESSION['user_id']);
191
         $form->set('id_user', $_SESSION['user_id']);

+ 1 - 1
admin/themes/admin/index.htm View File

70
 					{if $action.deleted or $action.modified or $action.added}<div class="exito" id="divMessages">{exito}</div>{/if}
70
 					{if $action.deleted or $action.modified or $action.added}<div class="exito" id="divMessages">{exito}</div>{/if}
71
 					{if $error}<div class="error"><strong>{error}</div>{/if}
71
 					{if $error}<div class="error"><strong>{error}</div>{/if}
72
 
72
 
73
-					<form action="index.php" method="post" {if $new=='photo'}enctype="multipart/form-data"{/if} name="frmAdd" id="autosave" class="newpost">
73
+					<form action="index.php" method="post" {if $new=='photo' || $new=='mp3'}enctype="multipart/form-data"{/if} name="frmAdd" id="autosave" class="newpost">
74
 						<fieldset>
74
 						<fieldset>
75
 							{if $postId}<input type="hidden" name="id_post" id="id_post" value="{postId}" />{/if}
75
 							{if $postId}<input type="hidden" name="id_post" id="id_post" value="{postId}" />{/if}
76
 							{form}
76
 							{form}

+ 63 - 22
admin/themes/admin/template_add_mp3.htm View File

1
-									
2
-		<div>
3
-			<label for="url">MP3 URL</label>			
4
-			<br /><input class="txt" type="text" name="url" id="url" value="{editUrl}" size="80" />
5
-			<div style="color: rgb(136, 136, 136); margin-bottom: 5px; font-size: 11px; font-weight: bold;">
6
-				This is the MP3 file URL or a GoEar URL or an Odeo URL.<br>
7
-				<span style="font-size: 10px; font-weight: normal;">(ie. http://www.goear.com/listen.php?v=c0a2c85)</span>
8
-			</div>
9
-		</div>								
10
-		<div>
11
-			<label for="description">Caption <span class="option">(optional)</span></label><br />
12
-			<textarea rows="12" cols="84" name="description" id="description" tabindex="2">{editBody}</textarea>											
1
+
2
+
3
+	<div id="mp3_upload">
4
+		<label for="description">MP3</label>
5
+		<br /><input type="file" name="mp3" id="mp3" enctype="multipart/form-data"/>
6
+		<div style="font-size:11px; color:#666; margin-top:5px;">
7
+			Supports MP3.&nbsp; <strong>Max size is 10 MB.</strong>
8
+		</div>
9
+		<div style="font-size:11px; color:#666; margin-top:5px;">
10
+			<a href="#" class="linkFrm">Use a URL instead</a>
13
 		</div>
11
 		</div>
12
+	</div>
13
+
14
+	<div id="mp3_url">
15
+		<label for="description">MP3 URL</label>
16
+		<br /><input class="input-text" type="text" name="url" id="url" value="{editUrl}" style="width:400px"/>
17
+		<div style="font-size:11px; color:#666; margin-top:5px;">
18
+			<a href="#" class="linkFrm">Use a upload form instead</a>
19
+		</div>
20
+	</div>
21
+
22
+	<div>
23
+		<label for="description" style="display:block;">Caption <span class="option">(optional)</span></label>
24
+		<textarea rows="12" cols="84" name="description" id="description">{editBody}</textarea>
25
+	</div>
26
+
27
+	<input type="hidden" name="title" id="title" value="" />
28
+	<input type="hidden" name="MAX_FILE_SIZE" value="10485760" />
29
+	<input type="hidden" name="type" id="type" value="{type}" />
30
+	<input type="hidden" name="date" id="date" value="{date}" />
31
+	<input type="hidden" name="id_user" id="id_user" value="{id_user}" />
32
+
14
 
33
 
15
-		<input type="hidden" name="title" id="title" value="" />
16
-		<input type="hidden" name="type" id="type" value="{type}" />
17
-		<input type="hidden" name="date" id="date" value="{date}" />
18
-		<input type="hidden" name="id_user" id="id_user" value="{id_user}" />
19
 
34
 
20
 
35
 
21
 	<script>
36
 	<script>
37
+		$('#mp3_url').css('display','none');
22
 		$("#autosave").validate({
38
 		$("#autosave").validate({
23
 			rules: {
39
 			rules: {
24
-				url: {
25
-					required: true,
40
+				mp3: {
41
+					required:  function() {
42
+ 						return ($('#mp3_upload').css('display')!= 'none') ? true : false;
43
+  					},
44
+					accept: "(mp3)"
45
+				},
46
+ 				url: {
47
+					required:  function() {
48
+ 						return ($('#mp3_url').css('display')!= 'none') ? true : false;
49
+  					},
26
 					url: true
50
 					url: true
27
 				}
51
 				}
28
 			},
52
 			},
29
 			errorElement: "span",
53
 			errorElement: "span",
30
-			errorClass: "validate_span", 
31
-			errorPlacement: function(label, element) { 
54
+			errorClass: "validate_span",
55
+			errorPlacement: function(label, element) {
32
 				label.prependTo(element.prev())
56
 				label.prependTo(element.prev())
33
-			} 
57
+			}
34
 		});
58
 		});
35
-	</script>
59
+
60
+		$("#mp3_upload a.linkFrm").click( function() {
61
+				$('#mp3_upload').css('display','none');
62
+				$('#mp3_url').css('display','block');
63
+				$('#mp3').val('');
64
+				return false;
65
+			}
66
+		);
67
+
68
+		$("#mp3_url a.linkFrm").click( function() {
69
+				$('#mp3_url').css('display','none');
70
+				$('#mp3_upload').css('display','block');
71
+				$('#url').val('');
72
+				return false;
73
+			}
74
+		);
75
+
76
+	</script>

+ 68 - 0
admin/themes/admin/template_add_mp3_bm.htm View File

1
+
2
+<div id="mp3_upload">
3
+
4
+</div>
5
+
6
+<div id="mp3_url">
7
+<label for="description">MP3 URL</label>
8
+<br /><input class="input-text" type="text" name="url" id="url" value="{editUrl}" style="width:400px"/>
9
+<div style="font-size:11px; color:#666; margin-top:5px;">
10
+	<a href="#" class="linkFrm">Use a upload form instead</a>
11
+</div>
12
+</div>
13
+
14
+<div>
15
+<label for="description" style="display:block;">Caption <span class="option">(optional)</span></label>
16
+<textarea rows="12" cols="84" name="description" id="description">{editBody}</textarea>
17
+</div>
18
+
19
+<input type="hidden" name="title" id="title" value="" />
20
+<input type="hidden" name="MAX_FILE_SIZE" value="10485760" />
21
+<input type="hidden" name="type" id="type" value="{type}" />
22
+<input type="hidden" name="date" id="date" value="{date}" />
23
+<input type="hidden" name="id_user" id="id_user" value="{id_user}" />
24
+
25
+
26
+
27
+
28
+<script>
29
+$('#mp3_url').css('display','none');
30
+$("#autosave").validate({
31
+	rules: {
32
+		mp3: {
33
+			required:  function() {
34
+				return ($('#mp3_upload').css('display')!= 'none') ? true : false;
35
+				},
36
+			accept: "(mp3)"
37
+		},
38
+		url: {
39
+			required:  function() {
40
+				return ($('#mp3_url').css('display')!= 'none') ? true : false;
41
+				},
42
+			url: true
43
+		}
44
+	},
45
+	errorElement: "span",
46
+	errorClass: "validate_span",
47
+	errorPlacement: function(label, element) {
48
+		label.prependTo(element.prev())
49
+	}
50
+});
51
+
52
+$("#mp3_upload a.linkFrm").click( function() {
53
+		$('#mp3_upload').css('display','none');
54
+		$('#mp3_url').css('display','block');
55
+		$('#mp3').val('');
56
+		return false;
57
+	}
58
+);
59
+
60
+$("#mp3_url a.linkFrm").click( function() {
61
+		$('#mp3_url').css('display','none');
62
+		$('#mp3_upload').css('display','block');
63
+		$('#url').val('');
64
+		return false;
65
+	}
66
+);
67
+
68
+</script>

+ 5 - 2
classes/sorbet.class.php View File

155
 
155
 
156
     public function saveMP3($remoteFileName)
156
     public function saveMP3($remoteFileName)
157
     {
157
     {
158
+        $util_class = new util();
158
         if ($util_class->getMP3File($remoteFileName)) {
159
         if ($util_class->getMP3File($remoteFileName)) {
159
             return true;
160
             return true;
160
         } else {
161
         } else {
164
 
165
 
165
     public function savePhoto($remoteFileName)
166
     public function savePhoto($remoteFileName)
166
     {
167
     {
168
+        $util_class = new util();
167
         if ($util_class->getPhotoFile($remoteFileName)) {
169
         if ($util_class->getPhotoFile($remoteFileName)) {
168
             return true;
170
             return true;
169
         } else {
171
         } else {
201
     }
203
     }
202
     public function getMp3Player($url)
204
     public function getMp3Player($url)
203
     {
205
     {
206
+        $util_class = new util();
207
+        $global_url = $this->conf->urlSorbet;
204
         if ($util_class->isMP3($url)) {
208
         if ($util_class->isMP3($url)) {
205
-            $playerUrl = $conf->urlSorbet."/admin/scripts/player.swf?soundFile=".$url;
206
-            return "\t\t\t<object type=\"application/x-shockwave-flash\" data=\"" . $playerUrl . "\" width=\"290\" height=\"24\"><param name=\"movie\" value=\"" . $playerUrl . "\" /><param name=\"quality\" value=\"high\" /><param name=\"menu\" value=\"false\" /><param name=\"wmode\" value=\"transparent\" /></object>\n";
209
+            return "\t\t\t<audio src=\"".$url."\" title=\"Track Name\" data-artist=\"Artist\" controls>Your browser does not support the <code>audio</code> element.</audio>\n";
207
         } elseif ($util_class->isGoEar($url)) {
210
         } elseif ($util_class->isGoEar($url)) {
208
             return "\t\t\t<object type=\"application/x-shockwave-flash\" data=\"http://www.goear.com/files/external.swf\" width=\"366\" height=\"130\"><param name=\"movie\" value=\"http://www.goear.com/files/external.swf\" /><param name=\"quality\" value=\"high\" /><param name=\"FlashVars\" value=\"file=".$util_class->getGoEarCode($url)."\" /><param name=\"wmode\" value=\"transparent\" /></object>\n";
211
             return "\t\t\t<object type=\"application/x-shockwave-flash\" data=\"http://www.goear.com/files/external.swf\" width=\"366\" height=\"130\"><param name=\"movie\" value=\"http://www.goear.com/files/external.swf\" /><param name=\"quality\" value=\"high\" /><param name=\"FlashVars\" value=\"file=".$util_class->getGoEarCode($url)."\" /><param name=\"wmode\" value=\"transparent\" /></object>\n";
209
         } elseif ($util_class->isOdeo($url)) {
212
         } elseif ($util_class->isOdeo($url)) {

+ 1 - 1
themes/SorbetDark/index.htm View File

185
       <footer style="text-align:center;margin:20px">
185
       <footer style="text-align:center;margin:20px">
186
           <a href="{URL_Tumble}/archive.php">{__("Archive")}</a> &nbsp;/&nbsp;
186
           <a href="{URL_Tumble}/archive.php">{__("Archive")}</a> &nbsp;/&nbsp;
187
           {__("Subscribe via")} <a href="{URL_Tumble}/rss.php">RSS</a> &nbsp;/&nbsp;
187
           {__("Subscribe via")} <a href="{URL_Tumble}/rss.php">RSS</a> &nbsp;/&nbsp;
188
-          {__("Powered by")} Sorbet CMS
188
+          {__("Powered by")} <a href="https://framagit.org/sorbetcms/sorbetcms">Sorbet CMS</a>
189
       </footer>
189
       </footer>
190
     </div>
190
     </div>
191
     <script type="text/javascript" src="{URL_Tumble}/admin/scripts/jquery.js"></script>
191
     <script type="text/javascript" src="{URL_Tumble}/admin/scripts/jquery.js"></script>

+ 1 - 1
themes/SorbetLight/index.htm View File

185
       <footer style="text-align:center;margin:20px">
185
       <footer style="text-align:center;margin:20px">
186
           <a href="{URL_Tumble}/archive.php">{__("Archive")}</a> &nbsp;/&nbsp;
186
           <a href="{URL_Tumble}/archive.php">{__("Archive")}</a> &nbsp;/&nbsp;
187
           {__("Subscribe via")} <a href="{URL_Tumble}/rss.php">RSS</a> &nbsp;/&nbsp;
187
           {__("Subscribe via")} <a href="{URL_Tumble}/rss.php">RSS</a> &nbsp;/&nbsp;
188
-          {__("Powered by")} Sorbet CMS
188
+          {__("Powered by")} <a href="https://framagit.org/sorbetcms/sorbetcms">Sorbet CMS</a>
189
       </footer>
189
       </footer>
190
     </div>
190
     </div>
191
     <script type="text/javascript" src="{URL_Tumble}/admin/scripts/jquery.js"></script>
191
     <script type="text/javascript" src="{URL_Tumble}/admin/scripts/jquery.js"></script>