Beispiel #1
0
// Init owncloud
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
\OC::$server->getSession()->close();
// Get the params
$dir = isset($_POST['dir']) ? stripslashes($_POST['dir']) : '';
$foldername = isset($_POST['foldername']) ? stripslashes($_POST['foldername']) : '';
$l10n = \OC::$server->getL10N('files');
$result = array('success' => false, 'data' => NULL);
if (trim($foldername) === '') {
    $result['data'] = array('message' => $l10n->t('Folder name cannot be empty.'));
    OCP\JSON::error($result);
    exit;
}
if (!OCP\Util::isValidFileName($foldername)) {
    $result['data'] = array('message' => (string) $l10n->t("Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed."));
    OCP\JSON::error($result);
    exit;
}
if (!\OC\Files\Filesystem::file_exists($dir . '/')) {
    $result['data'] = array('message' => (string) $l10n->t('The target folder has been moved or deleted.'), 'code' => 'targetnotfound');
    OCP\JSON::error($result);
    exit;
}
//TODO why is stripslashes used on foldername here but not in newfile.php?
$target = $dir . '/' . stripslashes($foldername);
if (\OC\Files\Filesystem::file_exists($target)) {
    $result['data'] = array('message' => $l10n->t('The name %s is already used in the folder %s. Please choose a different name.', array($foldername, $dir)));
    OCP\JSON::error($result);
    exit;
Beispiel #2
0
    }
}
$l10n = \OC::$server->getL10N('files');
$result = array('success' => false, 'data' => NULL);
$trimmedFileName = trim($filename);
if ($trimmedFileName === '') {
    $result['data'] = array('message' => (string) $l10n->t('File name cannot be empty.'));
    OCP\JSON::error($result);
    exit;
}
if ($trimmedFileName === '.' || $trimmedFileName === '..') {
    $result['data'] = array('message' => (string) $l10n->t('"%s" is an invalid file name.', $trimmedFileName));
    OCP\JSON::error($result);
    exit;
}
if (!OCP\Util::isValidFileName($filename)) {
    $result['data'] = array('message' => (string) $l10n->t("Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed."));
    OCP\JSON::error($result);
    exit;
}
if (!\OC\Files\Filesystem::file_exists($dir . '/')) {
    $result['data'] = array('message' => (string) $l10n->t('The target folder has been moved or deleted.'), 'code' => 'targetnotfound');
    OCP\JSON::error($result);
    exit;
}
//TODO why is stripslashes used on foldername in newfolder.php but not here?
$target = $dir . '/' . $filename;
if (\OC\Files\Filesystem::file_exists($target)) {
    $result['data'] = array('message' => (string) $l10n->t('The name %s is already used in the folder %s. Please choose a different name.', array($filename, $dir)));
    OCP\JSON::error($result);
    exit;
Beispiel #3
0
    $host = \OCP\Config::getAppValue('ownpad', 'ownpad_ethercalc_host', false);
    $url = sprintf("%s/%s", rtrim($host, "/"), $token);
} elseif ($type === "etherpad") {
    $ext = "pad";
    $host = \OCP\Config::getAppValue('ownpad', 'ownpad_etherpad_host', false);
    $url = sprintf("%s/p/%s", rtrim($host, "/"), $token);
}
$l10n = \OC::$server->getL10N('ownpad');
$l10n_files = \OC::$server->getL10N('files');
$result = ['success' => false, 'data' => NULL];
if ($padname === '' || $padname === '.' || $padname === '..') {
    $result['data'] = array('message' => (string) $l10n->t('Incorrect padname.'));
    OCP\JSON::error($result);
    exit;
}
if (!OCP\Util::isValidFileName($padname)) {
    $result['data'] = array('message' => (string) $l10n_files->t("Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed."));
    OCP\JSON::error($result);
    exit;
}
if (!\OC\Files\Filesystem::file_exists($dir . '/')) {
    $result['data'] = array('message' => (string) $l10n_files->t('The target folder has been moved or deleted.'), 'code' => 'targetnotfound');
    OCP\JSON::error($result);
    exit;
}
// Add the extension only if padname doesn’t contain it
if (substr($padname, -strlen(".{$ext}")) != ".{$ext}") {
    $filename = "{$padname}.{$ext}";
}
$target = $dir . "/" . $filename;
if (\OC\Files\Filesystem::file_exists($target)) {