Plugin Directory

Changeset 1021481


Ignore:
Timestamp:
11/07/2014 12:18:39 PM (11 years ago)
Author:
aueda
Message:

media-file-manager_1.3.1pre2

Location:
media-file-manager/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • media-file-manager/trunk/media-relocator.js

    r1011291 r1021481  
    596596        }
    597597        if (that.check_invalid_chr(result)) {
    598             alert("The name is not valid.");
     598            alert("You cannot use the following characters and whitespace:  " + that.invalid_chr_msg());
    599599            return;
    600600        }
     
    639639}
    640640
     641
     642var invalid_chr = ["\\", "/", ":", "*", "?", "+", "\"", "<", ">", "|", "%", "&", "'", " ", "!", "#", "$", "(", ")", "{", "}"];
     643
    641644// function name: MrlInputTextClass::invalid_chr
    642645// description : check if invalid character exists in the name.
     
    645648MrlInputTextClass.prototype.check_invalid_chr = function(str)
    646649{
    647     var chr = ["\\", "/", ":", "*", "?", "\"", "<", ">", "|", "%", "&"];
    648650    var i;
    649     for (i=0; i<chr.length; i++) {
    650         if (str.indexOf(chr[i]) >= 0) {
     651    for (i=0; i<invalid_chr.length; i++) {
     652        if (str.indexOf(invalid_chr[i]) >= 0) {
    651653            return true;
    652654        }
    653655    }
    654656    return false;
     657}
     658
     659MrlInputTextClass.prototype.invalid_chr_msg = function()
     660{
     661    var msg = "";
     662    for (i=0; i<invalid_chr.length; i++) {
     663        msg += invalid_chr[i] + " ";
     664    }
     665    return msg;
    655666}
    656667
  • media-file-manager/trunk/media-relocator.php

    r1011291 r1021481  
    44Plugin URI: http://tempspace.net/plugins/?page_id=111
    55Description: You can make sub-directories in the upload directory, and move files into them. At the same time, this plugin modifies the URLs/path names in the database. Also an alternative file-selector is added in the editing post/page screen, so you can pick up media files from the subfolders easily.
    6 Version: 1.3.1pre
     6Version: 1.3.1pre2
    77Author: Atsushi Ueda
    88Author URI: http://tempspace.net/plugins/
     
    158158    global $mrelocator_uploaddir;
    159159
     160    $local_post_dir = stripslashes($_POST['dir']);
    160161    $errflg = false;
    161162
    162     $dir = mrl_adjpath($mrelocator_uploaddir . "/" . $_POST['dir'], true);
     163    $dir = mrl_adjpath($mrelocator_uploaddir . "/" . $local_post_dir, true);
    163164    $dir0=array();
    164165    mrelocator_getdir($dir, $dir0);
     
    318319    global $wpdb;
    319320    global $mrelocator_uploaddir;
     321   
     322    $local_post_dir = stripslashes($_POST['dir']);
     323    $local_post_newdir = stripslashes($_POST['newdir']);
     324   
    320325    ini_set("track_errors",true);
    321326
    322     $dir = mrl_adjpath($mrelocator_uploaddir."/".$_POST['dir'], true);
    323     $newdir = $_POST['newdir'];
    324 
     327    $dir = mrl_adjpath($mrelocator_uploaddir."/".$local_post_dir, true);
     328    $newdir = $local_post_newdir;
     329   
    325330    $res = chdir($dir);
    326331    if (!$res) die($php_errormsg);
     
    371376
    372377    $wpdb->show_errors();
    373 
    374     $dir = mrl_adjpath($mrelocator_uploaddir."/".$_POST['dir'], true);
     378   
     379    $local_post_dir = stripslashes($_POST['dir']);
     380    $local_post_from = stripslashes($_POST['from']);
     381    $local_post_to = stripslashes($_POST['to']);
     382
     383    $dir = mrl_adjpath($mrelocator_uploaddir."/".$local_post_dir, true);
    375384    $subdir = substr($dir, strlen($mrelocator_uploaddir));
    376385
    377     $old[0] = $_POST['from'];
    378     $new[0] = $_POST['to'];
     386    $old[0] = $local_post_from;
     387    $new[0] = $local_post_to;
    379388    if ($old[0] == $new[0]) die("Success");
    380389
     
    425434                $newp .= "/";
    426435            }
    427             $oldu = $mrelocator_uploadurl . ltrim($_POST['dir'],"/") . $old[$i].(is_dir($newp)?"/":""); //old url
    428             $newu = $mrelocator_uploadurl . ltrim($_POST['dir'],"/") . $new[$i].(is_dir($newp)?"/":""); //new url
     436            $oldu = $mrelocator_uploadurl . ltrim($local_post_dir,"/") . $old[$i].(is_dir($newp)?"/":"");   //old url
     437            $newu = $mrelocator_uploadurl . ltrim($local_post_dir,"/") . $new[$i].(is_dir($newp)?"/":"");   //new url
    429438            $olda = $subdir.$old[$i];   //old attachment file name (subdir+basename)
    430439            $newa = $subdir.$new[$i];   //new attachment file name (subdir+basename)
     
    487496    ini_set("track_errors",true);
    488497
     498
    489499    global $mrelocator_uploaddir;
    490500    global $mrelocator_uploadurl;
    491     $dir_from = mrl_adjpath($mrelocator_uploaddir."/".$_POST['dir_from'], true);
    492     $dir_to = mrl_adjpath($mrelocator_uploaddir."/".$_POST['dir_to'], true);
     501   
     502    $local_post_dir_from = stripslashes($_POST['dir_from']);
     503    $local_post_dir_to = stripslashes($_POST['dir_to']);
     504    $local_post_items = stripslashes($_POST['items']);
     505
     506   
     507    $dir_from = mrl_adjpath($mrelocator_uploaddir."/".$local_post_dir_from, true);
     508    $dir_to = mrl_adjpath($mrelocator_uploaddir."/".$local_post_dir_to, true);
    493509    $dir_to_list = array();
    494510    mrelocator_getdir($dir_to, $dir_to_list);
    495511   
    496     $items0 = $_POST['items'];
     512    $items0 = $local_post_items;
    497513    $items = explode("/",$items0);
    498514   
     
    539555                $isdir=true;
    540556            }
    541             $oldu = mrl_adjpath( $mrelocator_uploadurl."/".$_POST['dir_from']."/".$items[$i] ); //old url
    542             $newu = mrl_adjpath( $mrelocator_uploadurl."/".$_POST['dir_to']."/".$items[$i] );   //new url
     557            $oldu = mrl_adjpath( $mrelocator_uploadurl."/".$local_post_dir_from."/".$items[$i] );   //old url
     558            $newu = mrl_adjpath( $mrelocator_uploadurl."/".$local_post_dir_to."/".$items[$i] ); //new url
    543559
    544560            if ($wpdb->query("update $wpdb->posts set post_content=replace(post_content, '" . $oldu . "','" . $newu . "') where post_content like '%".$oldu."%'")===FALSE) {throw new Exception('1');}
     
    588604{
    589605    global $mrelocator_uploaddir;
    590     $dir = mrl_adjpath($mrelocator_uploaddir."/".$_POST['dir']."/".$_POST['name'], true);
     606   
     607    $local_post_dir = stripslashes($_POST['dir']);
     608    $local_post_name = stripslashes($_POST['name']);
     609
     610    $dir = mrl_adjpath($mrelocator_uploaddir."/".$local_post_dir."/".$local_post_name, true);
     611   
     612    if (strstr($local_post_name,"\\")) {
     613        $dir = substr($dir,0,strlen($dir)-strlen($local_post_name)-1).$local_post_name."/";
     614    }
     615   
    591616    if (!@rmdir($dir)) {
    592617        $error = error_get_last();
Note: See TracChangeset for help on using the changeset viewer.