示例#1
0
文件: query.php 项目: villa7/kibbyte
        print "An error occurred: " . $e->getMessage();
    }
}
function getFilesInFolder($folder)
{
    checkToken();
    $params = array('maxResults' => '1000', 'orderBy' => 'title', 'q' => "'" . $folder . "' in parents");
    $results = getDriveService()->files->listFiles($params);
    if (count($results->getItems()) == 0) {
        //return "No files found.";
        return file_get_contents('includes/json/filenotfound.json');
    } else {
        return json_encode($results->getItems());
    }
}
//getFilesInFolder('root');
if (isset($_GET['file'])) {
    echo getFilesInFolder($_GET['file']);
}
if (isset($_POST['get_folder_contents'])) {
    echo getFilesInFolder($_POST['get_folder_contents']);
}
if (isset($_POST['get_file_contents'])) {
    echo downloadFile($_POST['get_file_contents']);
}
if (isset($_POST['set_file_contents'])) {
    updateFileContent($_POST['set_file_contents'], $_POST['content']);
}
/*if (isset($_GET['set_file_contents'])) {
    updateFileContent($_GET['set_file_contents'], $_GET['content']);
}*/
示例#2
0
 if (isset($_POST["command"]) && !empty($_POST["command"]) && $_POST["command"] == "files") {
     $configs = $GLOBALS["configs"];
     // Get root directories
     $rootDir = $configs["root_upload_dirs"]["upload_data"];
     $thumbDir = $configs["root_upload_dirs"]["upload_data_thumb"];
     if (!file_exists($rootDir) || !file_exists($thumbDir)) {
         echo json_encode(array('state' => "error", 'content' => "Error, a root directory does not exist"));
         exit;
     }
     $dataPath = $rootDir . sanitize($_POST["path"]);
     $thumbPath = $thumbDir . sanitize($_POST["path"]);
     if (!file_exists($dataPath) || !file_exists($thumbPath)) {
         echo json_encode(array('state' => "error", 'content' => "Error, new path does not exist"));
         exit;
     }
     $files = getFilesInFolder($dataPath, $thumbPath);
     $jsonFiles = json_encode($files);
     if ($jsonFiles != null) {
         echo json_encode(array('state' => "success", 'content' => $jsonFiles));
     } else {
         echo json_encode(array('state' => "error", 'content' => "Error, unable to get files"));
     }
 } else {
     if (isset($_POST["command"]) && !empty($_POST["command"]) && $_POST["command"] == "newFolder") {
         $configs = $GLOBALS["configs"];
         // Get root directories
         $rootDir = $configs["root_upload_dirs"]["upload_data"];
         $thumbDir = $configs["root_upload_dirs"]["upload_data_thumb"];
         if (!file_exists($rootDir) || !file_exists($thumbDir)) {
             echo json_encode(array('state' => "error", 'content' => "Error, a root directory does not exist"));
             exit;