use '?random=jpg' to get an URL of a random file
							parent
							
								
									3b1de93cc4
								
							
						
					
					
						commit
						46714bff6b
					
				| 
						 | 
					@ -614,7 +614,20 @@ function main($path)
 | 
				
			||||||
            } else return output(json_encode($exts['img']),400);
 | 
					            } else return output(json_encode($exts['img']),400);
 | 
				
			||||||
        } else return output('',401);
 | 
					        } else return output('',401);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $files = list_files($path);
 | 
					    $files = list_files($path);
 | 
				
			||||||
 | 
					    //echo json_encode(array_keys($files['children']), JSON_PRETTY_PRINT);
 | 
				
			||||||
 | 
					    if ($_GET['random']!=='') {
 | 
				
			||||||
 | 
					        if ($_SERVER['ishidden']<4) {
 | 
				
			||||||
 | 
					            $tmp = [];
 | 
				
			||||||
 | 
					            foreach (array_keys($files['children']) as $filename) {
 | 
				
			||||||
 | 
					                if (strtolower(splitlast($filename,'.')[1])==strtolower($_GET['random'])) $tmp[$filename] = $files['children'][$filename]['@microsoft.graph.downloadUrl'];
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            $tmp = array_values($tmp);
 | 
				
			||||||
 | 
					            if (count($tmp)>0) return output($tmp[rand(0,count($tmp)-1)],200);
 | 
				
			||||||
 | 
					            else return output('',404);
 | 
				
			||||||
 | 
					        } else return output('',401);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    if (isset($files['file']) && !$_GET['preview']) {
 | 
					    if (isset($files['file']) && !$_GET['preview']) {
 | 
				
			||||||
        // is file && not preview mode
 | 
					        // is file && not preview mode
 | 
				
			||||||
        if ( $_SERVER['ishidden']<4 || (!!getConfig('downloadencrypt')&&$files['name']!=getConfig('passfile')) ) return output('', 302, [ 'Location' => $files['@microsoft.graph.downloadUrl'] ]);
 | 
					        if ( $_SERVER['ishidden']<4 || (!!getConfig('downloadencrypt')&&$files['name']!=getConfig('passfile')) ) return output('', 302, [ 'Location' => $files['@microsoft.graph.downloadUrl'] ]);
 | 
				
			||||||
| 
						 | 
					@ -927,6 +940,13 @@ function fetch_files($path = '/')
 | 
				
			||||||
                    $files=fetch_files_children($files, $path1, $page);
 | 
					                    $files=fetch_files_children($files, $path1, $page);
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
                // files num < 200 , then cache
 | 
					                // files num < 200 , then cache
 | 
				
			||||||
 | 
					                    if (isset($files['children'])) {
 | 
				
			||||||
 | 
					                        $tmp = [];
 | 
				
			||||||
 | 
					                        foreach ($files['children'] as $file) {
 | 
				
			||||||
 | 
					                            $tmp[$file['name']] = $file;
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                        $files['children'] = $tmp;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                    savecache('path_' . $path, $files);
 | 
					                    savecache('path_' . $path, $files);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					@ -938,6 +958,7 @@ function fetch_files($path = '/')
 | 
				
			||||||
            $files = json_decode( '{"unknownError":{ "stat":'.$arr['stat'].',"message":"'.$arr['body'].'"}}', true);
 | 
					            $files = json_decode( '{"unknownError":{ "stat":'.$arr['stat'].',"message":"'.$arr['body'].'"}}', true);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return $files;
 | 
					    return $files;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue