Exemplo n.º 1
0
function mrename_go()
{
    global $list, $options, $PHP_SELF;
    if ($_POST["yes"] && @trim($_POST['extension'])) {
        $_POST['extension'] = @trim($_POST['extension']);
        while ($_POST['extension'][0] == '.') {
            $_POST['extension'] = substr($_POST['extension'], 1);
        }
        if ($_POST[extension]) {
            for ($i = 0; $i < count($_POST["files"]); $i++) {
                $file = $list[$_POST["files"][$i]];
                if (file_exists($file["name"])) {
                    $filetype = '.' . strtolower($_POST['extension']);
                    if (is_array($options['forbidden_filetypes']) && in_array('.' . strtolower($_POST['extension']), $options['forbidden_filetypes'])) {
                        printf(lang(82), $filetype);
                        echo '<br /><br />';
                    } else {
                        if (@rename($file["name"], fixfilename($file["name"] . ".{$_POST['extension']}"))) {
                            printf(lang(194) . '<br />', basename($file['name']), fixfilename(basename($file["name"] . ".{$_POST['extension']}")));
                            $list[$_POST["files"][$i]]["name"] .= '.' . $_POST['extension'];
                            $list[$_POST["files"][$i]]["name"] = fixfilename($list[$_POST["files"][$i]]["name"]);
                        } else {
                            printf(lang(193), basename($file['name']));
                            echo '<br />';
                        }
                    }
                } else {
                    printf(lang(145), basename($file['name']));
                    echo '<br />';
                }
            }
            if (!updateListInFile($list)) {
                echo lang(146) . "<br />";
            }
        }
    } else {
        ?>
<script type="text/javascript">location.href="<?php 
        echo substr($PHP_SELF, 0, strlen($PHP_SELF) - strlen(strstr($PHP_SELF, "?"))) . "?act=files";
        ?>
";</script>
<?php 
    }
}
Exemplo n.º 2
0
function mrename_go()
{
    global $list, $options, $PHP_SELF, $L;
    if ($_POST["yes"] && @trim($_POST['extension'])) {
        $_POST['extension'] = @trim($_POST['extension']);
        while ($_POST['extension'][0] == '.') {
            $_POST['extension'] = substr($_POST['extension'], 1);
        }
        if ($_POST[extension]) {
            for ($i = 0; $i < count($_POST["files"]); $i++) {
                $file = $list[$_POST["files"][$i]];
                if (file_exists($file["name"])) {
                    $filetype = '.' . strtolower($_POST['extension']);
                    if (is_array($options['forbidden_filetypes']) && in_array('.' . strtolower($_POST['extension']), $options['forbidden_filetypes'])) {
                        echo $L->sprintf($L->say['forbidden_rename'], $filetype) . '<br /><br />';
                    } else {
                        if (@rename($file["name"], fixfilename($file["name"] . ".{$_POST['extension']}"))) {
                            echo $L->sprintf($L->say['_renamed_to'] . '<br />', basename($file['name']), fixfilename(basename($file["name"] . ".{$_POST['extension']}")));
                            $list[$_POST["files"][$i]]["name"] .= '.' . $_POST['extension'];
                            $list[$_POST["files"][$i]]["name"] = fixfilename($list[$_POST["files"][$i]]["name"]);
                        } else {
                            echo $L->sprintf($L->say['_error_ren'], basename($file['name'])) . '<br />';
                        }
                    }
                } else {
                    echo $L->sprintf($L->say['not_found'], basename($file['name'])) . '<br />';
                }
            }
            if (!updateListInFile($list)) {
                echo "<b class=\"r\">" . $L->say['error_upd_list'] . "</b><br />";
            }
        }
    } else {
        ?>
<script type="text/javascript">location.href="<?php 
        echo $PHP_SELF . "?act=files";
        ?>
";</script>
<?php 
    }
}