|
@@ -170,8 +170,10 @@ switch($_['action']){
|
|
|
require_once(__DIR__.SLASH.'Resource.class.php');
|
|
|
require_once(__DIR__.SLASH.'ResourceType.class.php');
|
|
|
$item = Resource::provide('id',1);
|
|
|
-
|
|
|
$sketch = $item->join('sketch');
|
|
|
+ if( !is_object($sketch) || $sketch->id==0){
|
|
|
+ $sketch = Sketch::getById($_['sketch']);
|
|
|
+ }
|
|
|
if($sketch->creator != $myUser->login) throw new Exception("Permissions insuffisantes",403);
|
|
|
|
|
|
if(!isset($_['type']) && $item->id!=0) $_['type'] = $item->type;
|
|
@@ -276,6 +278,11 @@ switch($_['action']){
|
|
|
$row = File::move(File::temp().$file['path'],str_replace(File::dir(),'',$folder).SLASH.$name);
|
|
|
$row['url'] = 'action.php?action=hackpoint_download_file&file='.base64_encode('sketch'.SLASH.$resource->sketch.SLASH.$resource->id.SLASH.rawurlencode($file['name']));
|
|
|
$row['oldPath'] = $file['path'];
|
|
|
+
|
|
|
+ if(!in_array( getExt($file['name']), array('jpg','jpeg','png','bmp','svg'))){
|
|
|
+ $row['icon'] = $file['icon'];
|
|
|
+ }
|
|
|
+
|
|
|
$response['files'][] = $row;
|
|
|
}
|
|
|
|
|
@@ -383,7 +390,9 @@ switch($_['action']){
|
|
|
case 'hackpoint_download_file':
|
|
|
Action::write(function(&$response){
|
|
|
global $myUser,$_;
|
|
|
- $file = str_replace(array('..'),array(''),base64_decode($_['file']));
|
|
|
+ $file = str_replace(array('..'),array(''),urldecode(base64_decode($_['file'])));
|
|
|
+
|
|
|
+
|
|
|
$file = File::dir().'hackpoint'.SLASH.$file;
|
|
|
File::downloadFile($file);
|
|
|
});
|