Changeset 1204026
- Timestamp:
- 07/22/2015 03:19:29 PM (11 years ago)
- Location:
- media-from-ftp/trunk
- Files:
-
- 6 edited
-
inc/MediaFromFtp.php (modified) (2 diffs)
-
mediafromftp.php (modified) (2 diffs)
-
mediafromftpcmd.php (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
-
req/MediaFromFtpAdmin.php (modified) (3 diffs)
-
req/MediaFromFtpCron.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
media-from-ftp/trunk/inc/MediaFromFtp.php
r1184254 r1204026 305 305 $ext = end($exts); 306 306 $suffix_file = '.'.$ext; 307 $new_url = site_url('/').str_replace(ABSPATH, '', $file); 307 $file = str_replace('\\', '/', $file); 308 $wordpress_path = str_replace('\\', '/', ABSPATH); 309 $upload_path = str_replace('\\', '/', MEDIAFROMFTP_PLUGIN_UPLOAD_DIR); 310 if ( strstr($file, $wordpress_path) ) { 311 $new_url = site_url('/').str_replace($wordpress_path, '', $file); 312 } else { 313 $new_url = MEDIAFROMFTP_PLUGIN_UPLOAD_URL.str_replace($upload_path, '', $file); 314 } 308 315 $new_titles = explode('/', $new_url); 309 316 $new_title = str_replace($suffix_file, '', end($new_titles)); … … 487 494 } 488 495 496 /* ================================================== 497 * @param string $base 498 * @param string $relationalpath 499 * @return string realurl 500 * @since 7.7 501 */ 502 function realurl( $base, $relationalpath ){ 503 $parse = array( 504 "scheme" => null, 505 "user" => null, 506 "pass" => null, 507 "host" => null, 508 "port" => null, 509 "query" => null, 510 "fragment" => null 511 ); 512 $parse = parse_url( $base ); 513 514 if( strpos($parse["path"], "/", (strlen($parse["path"])-1)) !== false ){ 515 $parse["path"] .= "."; 516 } 517 518 if( preg_match("#^https?://#", $relationalpath) ){ 519 return $relationalpath; 520 }else if( preg_match("#^/.*$#", $relationalpath) ){ 521 return $parse["scheme"] . "://" . $parse["host"] . $relationalpath; 522 }else{ 523 $basePath = explode("/", dirname($parse["path"])); 524 $relPath = explode("/", $relationalpath); 525 foreach( $relPath as $relDirName ){ 526 if( $relDirName == "." ){ 527 array_shift( $basePath ); 528 array_unshift( $basePath, "" ); 529 }else if( $relDirName == ".." ){ 530 array_pop( $basePath ); 531 if( count($basePath) == 0 ){ 532 $basePath = array(""); 533 } 534 }else{ 535 array_push($basePath, $relDirName); 536 } 537 } 538 $path = implode("/", $basePath); 539 return $parse["scheme"] . "://" . $parse["host"] . $path; 540 } 541 542 } 543 489 544 } 490 545 -
media-from-ftp/trunk/mediafromftp.php
r1184254 r1204026 3 3 Plugin Name: Media from FTP 4 4 Plugin URI: http://wordpress.org/plugins/media-from-ftp/ 5 Version: 7. 65 Version: 7.7 6 6 Description: Register to media library from files that have been uploaded by FTP. 7 7 Author: Katsushi Kawamori … … 31 31 define("MEDIAFROMFTP_PLUGIN_BASE_DIR", dirname(__FILE__)); 32 32 define("MEDIAFROMFTP_PLUGIN_URL", plugins_url($path='',$scheme=null).'/media-from-ftp'); 33 34 include_once MEDIAFROMFTP_PLUGIN_BASE_DIR.'/inc/MediaFromFtp.php'; 35 $mediafromftp = new MediaFromFtp(); 33 36 $wp_uploads = wp_upload_dir(); 37 38 $relation_path_true = strpos($wp_uploads['baseurl'], '../'); 39 if ( $relation_path_true > 0 ) { 40 $relationalpath = substr($wp_uploads['baseurl'], $relation_path_true); 41 $basepath = substr($wp_uploads['baseurl'], 0, $relation_path_true); 42 $upload_url = $mediafromftp->realurl($basepath, $relationalpath); 43 define("MEDIAFROMFTP_PLUGIN_UPLOAD_DIR", realpath($wp_uploads['basedir'])); 44 } else { 45 $upload_url = $wp_uploads['baseurl']; 46 define("MEDIAFROMFTP_PLUGIN_UPLOAD_DIR", $wp_uploads['basedir']); 47 } 48 unset($mediafromftp); 49 34 50 if(is_ssl()){ 35 define("MEDIAFROMFTP_PLUGIN_UPLOAD_URL", str_replace('http:', 'https:', $ wp_uploads['baseurl']));51 define("MEDIAFROMFTP_PLUGIN_UPLOAD_URL", str_replace('http:', 'https:', $upload_url)); 36 52 } else { 37 define("MEDIAFROMFTP_PLUGIN_UPLOAD_URL", $ wp_uploads['baseurl']);53 define("MEDIAFROMFTP_PLUGIN_UPLOAD_URL", $upload_url); 38 54 } 39 define("MEDIAFROMFTP_PLUGIN_UPLOAD_DIR", $wp_uploads['basedir']); 40 define("MEDIAFROMFTP_PLUGIN_UPLOAD_PATH", str_replace(site_url('/'), '', MEDIAFROMFTP_PLUGIN_UPLOAD_URL)); 55 if ( $relation_path_true > 0 ) { 56 define("MEDIAFROMFTP_PLUGIN_UPLOAD_PATH", $relationalpath); 57 } else { 58 define("MEDIAFROMFTP_PLUGIN_UPLOAD_PATH", str_replace(site_url('/'), '', MEDIAFROMFTP_PLUGIN_UPLOAD_URL)); 59 } 41 60 define("MEDIAFROMFTP_PLUGIN_TMP_URL", MEDIAFROMFTP_PLUGIN_UPLOAD_URL.'/media-from-ftp-tmp'); 42 61 define("MEDIAFROMFTP_PLUGIN_TMP_DIR", MEDIAFROMFTP_PLUGIN_UPLOAD_DIR.'/media-from-ftp-tmp'); -
media-from-ftp/trunk/mediafromftpcmd.php
r1160562 r1204026 67 67 define("MEDIAFROMFTP_PLUGIN_BASE_DIR", dirname(__FILE__)); 68 68 $wp_uploads = wp_upload_dir(); 69 include_once MEDIAFROMFTP_PLUGIN_BASE_DIR.'/inc/MediaFromFtp.php'; 70 $mediafromftp = new MediaFromFtp(); 71 $wp_uploads = wp_upload_dir(); 72 $relation_path_true = strpos($wp_uploads['baseurl'], '../'); 73 if ( $relation_path_true > 0 ) { 74 $relationalpath = substr($wp_uploads['baseurl'], $relation_path_true); 75 $basepath = substr($wp_uploads['baseurl'], 0, $relation_path_true); 76 $upload_url = $mediafromftp->realurl($basepath, $relationalpath); 77 define("MEDIAFROMFTP_PLUGIN_UPLOAD_DIR", realpath($wp_uploads['basedir'])); 78 } else { 79 $upload_url = $wp_uploads['baseurl']; 80 define("MEDIAFROMFTP_PLUGIN_UPLOAD_DIR", $wp_uploads['basedir']); 81 } 82 unset($mediafromftp); 83 69 84 if(is_ssl()){ 70 define("MEDIAFROMFTP_PLUGIN_UPLOAD_URL", str_replace('http:', 'https:', $ wp_uploads['baseurl']));85 define("MEDIAFROMFTP_PLUGIN_UPLOAD_URL", str_replace('http:', 'https:', $upload_url)); 71 86 } else { 72 define("MEDIAFROMFTP_PLUGIN_UPLOAD_URL", $ wp_uploads['baseurl']);87 define("MEDIAFROMFTP_PLUGIN_UPLOAD_URL", $upload_url); 73 88 } 74 define("MEDIAFROMFTP_PLUGIN_UPLOAD_DIR", $wp_uploads['basedir']);75 89 } 76 90 -
media-from-ftp/trunk/readme.txt
r1184254 r1204026 5 5 Requires at least: 3.6.0 6 6 Tested up to: 4.2 7 Stable tag: 7. 67 Stable tag: 7.7 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 47 47 == Changelog == 48 48 49 = 7.7 = 50 Supported moving uploads folder. Please edit the [wp-config.php](http://codex.wordpress.org/Editing_wp-config.php#Moving_uploads_folder). Please do not use other methods. 51 49 52 = 7.6 = 50 53 Add thumbnails cache remove to uninstall script. … … 309 312 == Upgrade Notice == 310 313 314 = 7.7 = 311 315 = 7.6 = 312 316 = 7.5 = -
media-from-ftp/trunk/req/MediaFromFtpAdmin.php
r1184254 r1204026 407 407 echo '<div class="updated"><ul><li>'.__('Settings saved.').'</li></ul></div>'; 408 408 } 409 if (!empty($_POST['searchdir'])){410 $searchdir = urldecode($_POST['searchdir']);411 }412 409 413 410 $scriptname = admin_url('admin.php?page=mediafromftp-search-register'); 414 411 415 $document_root = ABSPATH.$searchdir; 412 $document_root = realpath(ABSPATH.$searchdir); 413 416 414 if( get_option('WPLANG') === 'ja' ) { 417 415 mb_language('Japanese'); … … 444 442 $dirs = $mediafromftp->scan_dir(MEDIAFROMFTP_PLUGIN_UPLOAD_DIR); 445 443 $linkselectbox = NULL; 444 $wordpress_path = str_replace("\\", "/", ABSPATH); 446 445 foreach ($dirs as $linkdir) { 447 $linkdirenc = mb_convert_encoding(str_replace(ABSPATH, "", $linkdir), "UTF-8", "auto"); 446 if ( strstr($linkdir, $wordpress_path ) ) { 447 $linkdirenc = mb_convert_encoding(str_replace($wordpress_path, '', $linkdir), "UTF-8", "auto"); 448 } else { 449 $linkdirenc = MEDIAFROMFTP_PLUGIN_UPLOAD_PATH.mb_convert_encoding(str_replace(MEDIAFROMFTP_PLUGIN_UPLOAD_DIR, "", $linkdir), "UTF-8", "auto"); 450 } 448 451 if( $searchdir === $linkdirenc ){ 449 452 $linkdirs = '<option value="'.urlencode($linkdirenc).'" selected>'.$linkdirenc.'</option>'; … … 888 891 } else { 889 892 $searchdir = $mediafromftp_settings['searchdir']; 893 if ( !strstr(realpath(ABSPATH.$searchdir),realpath(MEDIAFROMFTP_PLUGIN_UPLOAD_DIR)) ) { 894 $searchdir = MEDIAFROMFTP_PLUGIN_UPLOAD_PATH; 895 } 890 896 } 891 897 if (!empty($_POST['ext2type'])){ -
media-from-ftp/trunk/req/MediaFromFtpCron.php
r1160562 r1204026 107 107 108 108 $yearmonth_folders = get_option('uploads_use_yearmonth_folders'); 109 $document_root = ABSPATH.$searchdir;109 $document_root = realpath(ABSPATH.$searchdir); 110 110 111 111 if( get_option('WPLANG') === 'ja' ) {
Note: See TracChangeset
for help on using the changeset viewer.