示例#1
0
<?php

// Init owncloud
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
// Get the params
$dir = isset($_POST['dir']) ? stripslashes($_POST['dir']) : '';
$foldername = isset($_POST['foldername']) ? stripslashes($_POST['foldername']) : '';
if (trim($foldername) == '') {
    OCP\JSON::error(array("data" => array("message" => "Empty Foldername")));
    exit;
}
if (strpos($foldername, '/') !== false) {
    OCP\JSON::error(array("data" => array("message" => "Invalid Foldername")));
    exit;
}
if (OC_Files::newFile($dir, stripslashes($foldername), 'dir')) {
    OCP\JSON::success(array("data" => array()));
    exit;
}
OCP\JSON::error(array("data" => array("message" => "Error when creating the folder")));
<?php

// Init owncloud
require_once '../../lib/base.php';
OC_JSON::checkLoggedIn();
// Get the params
$dir = isset($_GET['dir']) ? $_GET['dir'] : '';
$foldername = isset($_GET['foldername']) ? $_GET['foldername'] : '';
if ($foldername == '') {
    OC_JSON::error(array("data" => array("message" => "Empty Foldername")));
    exit;
}
if (defined("DEBUG") && DEBUG) {
    error_log('try to create ' . $foldername . ' in ' . $dir);
}
if (OC_Files::newFile($dir, $foldername, 'dir')) {
    OC_JSON::success(array("data" => array()));
    exit;
}
OC_JSON::error(array("data" => array("message" => "Error when creating the folder")));
    OCP\JSON::error(array("data" => array("message" => "Invalid Filename")));
    exit;
}
if ($source) {
    if (substr($source, 0, 8) != 'https://' and substr($source, 0, 7) != 'http://') {
        OCP\JSON::error(array("data" => array("message" => "Not a valid source")));
        exit;
    }
    $sourceStream = fopen($source, 'rb');
    $target = $dir . '/' . $filename;
    $result = OC_Filesystem::file_put_contents($target, $sourceStream);
    if ($result) {
        $mime = OC_Filesystem::getMimetype($target);
        OCP\JSON::success(array("data" => array('mime' => $mime)));
        exit;
    } else {
        OCP\JSON::error(array("data" => array("message" => "Error while downloading " . $source . ' to ' . $target)));
        exit;
    }
} else {
    if ($content) {
        if (OC_Filesystem::file_put_contents($dir . '/' . $filename, $content)) {
            OCP\JSON::success(array("data" => array('content' => $content)));
            exit;
        }
    } elseif (OC_Files::newFile($dir, $filename, 'file')) {
        OCP\JSON::success(array("data" => array('content' => $content)));
        exit;
    }
}
OCP\JSON::error(array("data" => array("message" => "Error when creating the file")));
示例#4
0
             $msg = "File already exists!";
         } else {
             $msg = "File has been modified since opening!";
         }
         OC_JSON::error(array("data" => array("message" => $msg)));
         //OC_Log::write('files_svgedit',"File: ".$path." modified since opening.",OC_Log::ERROR);
         exit;
     }
 } else {
     // file doesn't exist yet, so let's create it!
     if ($file == '') {
         OC_JSON::error(array("data" => array("message" => "Empty Filename")));
         exit;
     }
     OC_Files::newFile($dir, '', 'dir');
     if (!OC_Files::newFile($dir, $file, 'file')) {
         OC_JSON::error(array("data" => array("message" => "Error when creating new file!")));
         OC_Log::write('files_svgedit', "Failed to create file: " . $path, OC_Log::ERROR);
         exit;
     }
 }
 // file should be existing now
 if (method_exists('OC_Filesystem', 'is_writable')) {
     $writable = OC_Filesystem::is_writable($path);
 } else {
     $writable = OC_Filesystem::is_writeable($path);
 }
 if ($writable) {
     if ($b64encoded) {
         $b64prefix = 'data:' . $b64type . ';base64,';
         if (strpos($filecontents, $b64prefix) === 0) {