Changeset 1509023
- Timestamp:
- 10/05/2016 11:50:05 PM (9 years ago)
- Location:
- os-media/trunk
- Files:
-
- 6 edited
-
OSmedia-functions.php (modified) (3 diffs)
-
classes/OSmedia-post-admin.php (modified) (9 diffs)
-
classes/OSmedia-post-frontend.php (modified) (3 diffs)
-
javascript/OSmedia.js (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
views/OSmedia-postmeta/metabox.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
os-media/trunk/OSmedia-functions.php
r1297200 r1509023 1 <?php ////////////////////////////////////2 1 <?php 2 // OS media WP plugin FUNCTIONS ///////////////////////////////////////////////////////////////////////// 3 3 4 4 if ( ! function_exists( 'OSmedia_video' ) ) : … … 21 21 } 22 22 endif; 23 24 23 25 24 //////////////////////////////////////////////////////////////////////////////////////////////////////// … … 111 110 112 111 } 113 114 /*//////////////////////////////////////////////////////////////////////////////////////////////////////////////115 PRESO DA :116 http://stackoverflow.com/questions/157318/resumable-downloads-when-using-php-to-send-the-file/4451376#4451376117 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////118 119 function serve_file_resumable ($file, $contenttype = 'application/octet-stream') {120 121 // Avoid sending unexpected errors to the client - we should be serving a file,122 // we don't want to corrupt the data we send123 @error_reporting(0);124 125 // Make sure the files exists, otherwise we are wasting our time126 if (!file_exists($file)) {127 header("HTTP/1.1 404 Not Found");128 exit;129 }130 131 // Get the 'Range' header if one was sent132 if (isset($_SERVER['HTTP_RANGE'])) $range = $_SERVER['HTTP_RANGE']; // IIS/Some Apache versions133 else if ($apache = apache_request_headers()) { // Try Apache again134 $headers = array();135 foreach ($apache as $header => $val) $headers[strtolower($header)] = $val;136 if (isset($headers['range'])) $range = $headers['range'];137 else $range = FALSE; // We can't get the header/there isn't one set138 } else $range = FALSE; // We can't get the header/there isn't one set139 140 // Get the data range requested (if any)141 $filesize = filesize($file);142 if ($range) {143 $partial = true;144 list($param,$range) = explode('=',$range);145 if (strtolower(trim($param)) != 'bytes') { // Bad request - range unit is not 'bytes'146 header("HTTP/1.1 400 Invalid Request");147 exit;148 }149 $range = explode(',',$range);150 $range = explode('-',$range[0]); // We only deal with the first requested range151 if (count($range) != 2) { // Bad request - 'bytes' parameter is not valid152 header("HTTP/1.1 400 Invalid Request");153 exit;154 }155 if ($range[0] === '') { // First number missing, return last $range[1] bytes156 $end = $filesize - 1;157 $start = $end - intval($range[0]);158 } else if ($range[1] === '') { // Second number missing, return from byte $range[0] to end159 $start = intval($range[0]);160 $end = $filesize - 1;161 } else { // Both numbers present, return specific range162 $start = intval($range[0]);163 $end = intval($range[1]);164 if ($end >= $filesize || (!$start && (!$end || $end == ($filesize - 1)))) $partial = false; // Invalid range/whole file specified, return whole file165 }166 $length = $end - $start + 1;167 } else $partial = false; // No range requested168 169 // Send standard headers170 header("Content-Type: $contenttype");171 header("Content-Length: $filesize");172 header('Content-Disposition: attachment; filename="'.basename($file).'"');173 header('Accept-Ranges: bytes');174 175 // if requested, send extra headers and part of file...176 if ($partial) {177 header('HTTP/1.1 206 Partial Content');178 header("Content-Range: bytes $start-$end/$filesize");179 if (!$fp = fopen($file, 'r')) { // Error out if we can't read the file180 header("HTTP/1.1 500 Internal Server Error");181 exit;182 }183 if ($start) fseek($fp,$start);184 while ($length) { // Read in blocks of 8KB so we don't chew up memory on the server185 $read = ($length > 8192) ? 8192 : $length;186 $length -= $read;187 print(fread($fp,$read));188 }189 fclose($fp);190 } else readfile($file); // ...otherwise just send the whole file191 192 // Exit here to avoid accidentally sending extra content on the end of the file193 exit;194 195 }196 */197 198 ?> -
os-media/trunk/classes/OSmedia-post-admin.php
r1300766 r1509023 294 294 $s3 = new S3($OSmedia_s3access, $OSmedia_s3secret); 295 295 $s3_array = $s3->getBucket($OSmedia_s3bucket); 296 if($s3_array) $monitor_server['s3'] = 'ok'; elseif(!$s3_url) $monitor_server['s3'] = 'unset'; else $monitor_server['s3'] = 'error'; 296 if($s3_array) $monitor_server['s3'] = 'ok'; 297 elseif(!$s3_url) $monitor_server['s3'] = 'unset'; 298 else $monitor_server['s3'] = 'error'; 299 297 300 if( $s3_array ) { 298 301 // array forma [file]=>path_file … … 300 303 $file = str_replace( $OSmedia_s3dir, '', $vv['name']); // toglie la directory s3 dal nome del file 301 304 // $file = preg_replace( '/\.[^.]+$/', '', $file ); // SANITIZE 302 if( $file ) $s3_list[$file] = $s3_url;305 if( $file ) $s3_list[$file] = 3; 303 306 } 304 307 … … 317 320 // $value = preg_replace( '/\.[^.]+$/', '', $value ); 318 321 // if ( $value != '.' && $value != '..' ) 319 $path_list[$value] = ''; // $dir /*. $value*/;322 $path_list[$value] = 1; // $dir /*. $value*/; 320 323 } 321 324 $monitor_server['path'] = 'ok'; … … 340 343 preg_match_all("/(a href\=\")([^\?\"]*)(\")/i", $content, $res); 341 344 // array forma [file]=>path_file senza ext 342 // DA VERIFICARE !!!!!!343 345 foreach ($res[2] as $val) { 344 // $value = preg_replace( '/\.[^.]+$/', '', $value );345 if ( $val != '.' && $val != '..' ) $url_list[$val] = $url/*. $val*/;346 $val = pathinfo($val)['basename']; 347 if ( $val != '.' && $val != '..' ) $url_list[$val] = 2 /*. $val*/; 346 348 } 347 349 $monitor_server['url'] = 'ok'; … … 355 357 // unisce i 3 risultati 356 358 $file_list = $s3_list; 357 if( !empty($path_list) ) foreach( $path_list as $k2 => $v2 ) $file_list[$k2] = $v2; 358 if( !empty($url_list) ) foreach( $url_list as $k3 => $v3 ) $file_list[$k3] = $v3; 359 if( !empty($path_list) ) 360 foreach( $path_list as $k2 => $v2 ) $file_list[$k2] = $v2; 361 if( !empty($url_list) ) 362 foreach( $url_list as $k3 => $v3 ) $file_list[$k3] = $v3; 359 363 360 364 // SANITIZE … … 392 396 393 397 $result['monitor_server'] = $monitor_server; 394 395 // echo 'ARRAY_S3: <pre>'; print_r($monitor_server); echo '</pre>'; // MONITOR 396 // echo 'ARRAY_PATH: <pre>'; print_r($path_list); echo '</pre>'; // MONITOR 397 // echo 'ARRAY_URL: <pre>'; print_r($url_list); echo '</pre>'; // MONITOR 398 // echo 'RESULT: <pre>'; print_r($result); echo '</pre>'; // MONITOR 398 // MONITOR 399 // echo 'OPTIONS: <pre>'; print_r($options); echo '</pre>'; 400 // echo 'ARRAY_S3: <pre>'; print_r($monitor_server); echo '</pre>'; 401 // echo 'ARRAY_PATH: <pre>'; print_r($path_list); echo '</pre>'; 402 // echo 'ARRAY_URL: <pre>'; print_r($url_list); echo '</pre>'; 403 // echo 'RESULT: <pre>'; print_r($result); echo '</pre>'; 399 404 400 405 return $result; … … 435 440 if ( array_key_exists($k, $meta_values ) ) 436 441 $out[$k] = $meta_values[$k]; 437 //else $out[$k] = $v;442 else $out[$k] = $v; 438 443 } 439 444 // carica i POSTMETA di questo plugin, aggiungo i valori con chiavi che NON ci sono già in $out.. … … 449 454 } 450 455 451 // echo ' <pre> DATA_MODEL: post_id->'.$post_id.' ';var_dump($out); echo '</pre>'; // MONITOR456 // echo 'post_id->'.$post_id.'<br>DATA_MODEL: <pre>'; print_r($out); echo '</pre>'; // MONITOR 452 457 return $out; 453 458 } … … 516 521 ///////////////// MONITOR 517 522 // foreach ($variables as $mon_k => $mon_atts) if( $mon_atts !='' ) $mon[$mon_k] = $mon_atts; // nasconde valori nulli 518 // echo '<pre style="font-size:12px"> --->post_type: '.get_post_type($post->ID).' -->GET_POSTMETA: '; var_dump($variables); echo '</pre>';523 // echo '<pre style="font-size:12px"> --->post_type: '.get_post_type($post->ID).' -->GET_POSTMETA: '; print_r($variables); echo '</pre>'; 519 524 // echo '<br>--------- max upload file size ----->'.ini_get('post_max_size'); 520 525 ///////////////////////// -
os-media/trunk/classes/OSmedia-post-frontend.php
r1300766 r1509023 165 165 // FILE controller (HTML5) 166 166 if ( isset($atts['file']) && $atts['file'] != '' ) $file = $atts['file']; else $file = ''; 167 if ( isset($atts['fileurl']) && $atts['fileurl'] != '' ) $url = OSmedia_path_sanitize($atts['fileurl']); else $url = ''; 168 169 if( $file != '' && $url == '' ) // local file 170 $filepath = plugins_url( OSmedia_FOLDER ) . "/videostream.php?file="; 171 elseif( $file != '' && $url != '' ) // remote file 172 $filepath = $url; 173 else // no filepath (direct url) 174 $filepath = ''; 167 168 switch ($atts['fileurl']) { 169 case 1: 170 if(isset($options['OSmedia_path']) && $options['OSmedia_path'] != ''){ 171 $url_img = OSmedia_path_sanitize($options['OSmedia_path']); 172 $filepath = plugins_url( OSmedia_FOLDER ) . "/videostream.php?file="; 173 }else{ 174 $filepath = $url_img = OSmedia_path_sanitize($options['OSmedia_url']); 175 } 176 break; 177 case 2: 178 if(isset($options['OSmedia_url']) && $options['OSmedia_url'] != ''){ 179 $filepath = $url_img = OSmedia_path_sanitize($options['OSmedia_url']); 180 }else{ 181 $url_img = OSmedia_path_sanitize($options['OSmedia_path']); 182 $filepath = plugins_url( OSmedia_FOLDER ) . "/videostream.php?file="; 183 } 184 break; 185 case 3: 186 $s3_url = $url_img = $options['OSmedia_s3server'] . $options['OSmedia_s3bucket'] . '/' . $options['OSmedia_s3dir']; 187 $filepath = $url_img = OSmedia_path_sanitize($s3_url); 188 break; 189 default: 190 // RETROCOMPATIBILITA' 191 if( substr($atts['fileurl'], 0, 7) == 'http://' || substr($atts['fileurl'], 0, 8) == 'https://'){ // caso 2 e 3 192 $filepath = $url_img = OSmedia_path_sanitize($atts['fileurl']); 193 }elseif( !isset($atts['fileurl']) || $atts['fileurl'] == '' ){ // caso 1 194 $filepath = plugins_url( OSmedia_FOLDER ) . "/videostream.php?file="; 195 $url_img = OSmedia_path_sanitize($options['OSmedia_path']); 196 } 197 } 175 198 176 199 if( $file && $filepath ) { … … 203 226 // CPT 204 227 if( $cpt_flag ){ 228 // if(isset($url_img)) $filepath = $url_img; 205 229 // if ( $file && $filepath && $file != '' && $filepath != '' && @getimagesize($filepath . $file . ".jpg") ) $atts['img'] = $filepath . $file. ".jpg"; 206 230 $post_thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); … … 249 273 $atts['flag_cpt'] = $cpt_flag; 250 274 275 // echo '<br><br><br>'.$filepath; 276 // echo '<pre> ATTS:'; var_dump($atts); echo '</pre>'; 251 277 // return apply_filters( 'OSmedia_validate_shortcode_attributes', $atts ); 252 278 return $atts; -
os-media/trunk/javascript/OSmedia.js
r1297200 r1509023 28 28 */ 29 29 registerEventHandlers: function () { 30 30 31 // flag input change SELECT/INPUT for video file selection 32 $('#flag_input').change(function() { 33 if($("select#OSmedia_file").is(":visible")){ 34 $('select#OSmedia_file').hide(); 35 $('select#OSmedia_file').prop('disabled', true); 36 $('input#OSmedia_file').show(); 37 $('input#OSmedia_file').prop('disabled', false); 38 }else{ 39 $('input#OSmedia_file').hide(); 40 $('input#OSmedia_file').prop('disabled', true); 41 $('select#OSmedia_file').show(); 42 $('select#OSmedia_file').prop('disabled', false); 43 } 44 }); 45 // selezione server 31 46 $("#OSmedia_file").change(function() { 32 sel_url = $(this).find(':selected').attr('data-url'); 33 $("#OSmedia_fileurl").val(sel_url); 47 if($("select#OSmedia_file").is(":visible")) { 48 var sel_url = $(this).find(':selected').attr('data-url'); 49 $("#OSmedia_fileurl").val(sel_url); 50 } 34 51 }); 52 35 53 $( '#gen_shortcode' ).click( OSmedia.genShortcode ); 36 54 $( '#reset_btn' ).click( OSmedia.resetForm ); … … 51 69 52 70 var shortcode = '['+shortcode_name; 71 // selezione file 72 if($("select#OSmedia_file").is(":visible")){ 73 name_file = $('select#OSmedia_file').val(); 74 }else if($("input#OSmedia_file").is(":visible")){ 75 name_file = $('input#OSmedia_file').val(); 76 $("#OSmedia_fileurl").val(2); // input manuale fa riferimento sempre al server 2 77 } 53 78 // input items 54 79 var input_items = { 55 file: $('#OSmedia_file').val(),80 file: name_file, 56 81 fileurl: $('#OSmedia_fileurl').val(), 57 82 mp4: $('#OSmedia_mp4').val(), -
os-media/trunk/readme.txt
r1305099 r1509023 4 4 Plugin URI: http://www.mariomarino.eu/en/os-media-wordpress-video-plugin/ 5 5 Tested up to: 4.4 6 Stable tag: 2. 16 Stable tag: 2.2 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 79 79 == Changelog == 80 80 81 = 2.2 = 82 * dinamically URL select from setting. 83 * add manual video-file input for extenal server. 84 * fixed bug in file url external server 85 81 86 = 2.1 = 82 87 * Optimized OS-media theme integration. -
os-media/trunk/views/OSmedia-postmeta/metabox.php
r1297200 r1509023 8 8 9 9 <ul class="server-monitor-list"> 10 <li><b> OSmedia File Server Monitor:</b></li>11 <li class="<?php echo $monitor_server['path'] ?>"> 1 - local video path: <span><?php echo $monitor_server['path'] ?></span></li>12 <li class="<?php echo $monitor_server['url'] ?>"> 2 - video server url: <span><?php echo $monitor_server['url'] ?></span></li>13 <li class="<?php echo $monitor_server['s3'] ?>"> 3 - S3 server: <span><?php echo $monitor_server['s3'] ?></span></li>10 <li><b>FILE SERVER:</b></li> 11 <li class="<?php echo $monitor_server['path'] ?>"><b>1</b> - local (path): <span><?php echo $monitor_server['path'] ?></span></li> 12 <li class="<?php echo $monitor_server['url'] ?>"><b>2</b> - remote (url): <span><?php echo $monitor_server['url'] ?></span></li> 13 <li class="<?php echo $monitor_server['s3'] ?>"><b>3</b> - Amazon S3: <span><?php echo $monitor_server['s3'] ?></span></li> 14 14 </ul> 15 15 16 16 <table class="metabox_table"> 17 17 <thead></thead> 18 <th>video identification</th>19 <th>on-fly local upload (MAX upload file-size: <?php echo ini_get('post_max_size') ?>)</th>18 <th>video identification</th> 19 <th>on-fly local upload (MAX upload file-size: <?php echo ini_get('post_max_size') ?>)</th> 20 20 <tr> 21 <td>21 <td> 22 22 23 <?php if ( !empty($video_list) ) : ; // $file_explode = explode('|', $OSmedia_file); ?> 23 <?php if ( (!empty($video_list) && array_key_exists($OSmedia_file, $video_list)) || $OSmedia_file == '' ) : ?> 24 25 <p class="metacheck"> 26 <input id="flag_input" type="checkbox" /> 27 <label for="OSmedia_yt_related"><?php _e('manual name-file input (only for server 2)', 'OSmedia_player') ?></label> 28 </p> 24 29 25 <select id="OSmedia_file" name="OSmedia_file"> 30 <select id="OSmedia_file" name="OSmedia_file"> 31 <option class="default_opt" value="" <?php if( !array_key_exists($OSmedia_file, $video_list)) echo " selected='selected' "; ?>> </option> 32 <?php foreach ($video_list as $key => $value) : ?> 33 <option value="<?php echo $key ?>" <?php if( $OSmedia_file == $key ) echo " selected='selected' "; ?> data-url="<?php echo $value ?>"><?php echo $key ?></option> 34 <?php endforeach ?> 35 </select> 36 37 <input id="OSmedia_file" name="OSmedia_file" style="display:none" type="text" size="15" placeholder="file without ext" value="<?php echo $OSmedia_file; ?>" /> 26 38 27 <option class="default_opt" value="" <?php if( !array_key_exists($OSmedia_file, $video_list)) echo " selected='selected' "; ?>> </option> 28 <?php foreach ($video_list as $key => $value) : ?> 29 <option value="<?php echo $key ?>" <?php if( $OSmedia_file == $key ) echo " selected='selected' "; ?> data-url="<?php echo $value ?>"> 30 <?php echo $key ?> 31 </option> 32 <?php endforeach ?> 39 <?php elseif( (!empty($video_list) && !in_array($OSmedia_file, $video_list)) || empty($video_list) ) : ?> 40 41 <p class="metacheck"> 42 <input id="flag_input" type="checkbox" checked="on" /> 43 <label for="OSmedia_yt_related"><?php _e('manual name-file input (only for server 2)', 'OSmedia_player') ?></label> 44 </p> 45 46 <select id="OSmedia_file" name="OSmedia_file" style="display:none"> 47 <option class="default_opt" value="" <?php if( !array_key_exists($OSmedia_file, $video_list)) echo " selected='selected' "; ?>> </option> 48 <?php foreach ($video_list as $key => $value) : ?> 49 <option value="<?php echo $key ?>" <?php if( $OSmedia_file == $key ) echo " selected='selected' "; ?> data-url="<?php echo $value ?>"><?php echo $key ?></option> 50 <?php endforeach ?> 51 </select> 52 53 <input id="OSmedia_file" name="OSmedia_file" type="text" size="15" placeholder="file without ext" value="<?php echo $OSmedia_file; ?>" /> 54 55 <?php endif ?> 33 56 34 </select> 35 36 <?php else : ?> 37 38 <input id="OSmedia_file" name="OSmedia_file" type="text" size="15" placeholder="file without ext" value="<?php echo $OSmedia_file; ?>" /> 39 40 <?php endif ?> 41 42 <laber for="OSmedia_file"><?php _e( 'file', 'OSmedia_player' ) ?> <?php if( isset($server_no) ) echo "(server {$server_no})" ?></label> 57 <laber for="OSmedia_file"><?php _e( 'file', 'OSmedia_player' ) ?> <?php // if( isset($server_no) ) echo "(server {$server_no})" ?></label> 43 58 44 59 <input id="OSmedia_fileurl" name="OSmedia_fileurl" type="hidden" value="<?php if( isset($OSmedia_fileurl) ) echo $OSmedia_fileurl ?>" />
Note: See TracChangeset
for help on using the changeset viewer.