mirror of
https://github.com/gamaio/UnPS-API.git
synced 2024-12-22 02:02:40 +00:00
Move files and modify private edit
This commit is contained in:
parent
9c7ac938f0
commit
fbbab52a68
@ -213,18 +213,30 @@ class api{
|
|||||||
if(!$result = $apidb->query($apisql)) return 'ERROR: ['.$apidb->error.']';
|
if(!$result = $apidb->query($apisql)) return 'ERROR: ['.$apidb->error.']';
|
||||||
}
|
}
|
||||||
if($canImg != 1) return 'You are not authorized to set images to private';
|
if($canImg != 1) return 'You are not authorized to set images to private';
|
||||||
|
|
||||||
$publink = null;
|
$publink = null;
|
||||||
if($private == 1){
|
|
||||||
$pubLink = substr(number_format(time() * mt_rand(),0,'',''),0,10);
|
|
||||||
$pubLink = base_convert($short, 10, 36);
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = "SELECT * FROM `share` WHERE `name` = '$imgName' AND `username` = '$username';";
|
$sql = "SELECT * FROM `share` WHERE `name` = '$imgName' AND `username` = '$username';";
|
||||||
if($result = $idb->query($sql)){
|
if($result = $idb->query($sql)){}
|
||||||
$sql = "UPDATE `share` SET (private, sharelink) VALUES('$private', '$pubLink') WHERE `name` = '$imgName';";
|
if($private == 1){
|
||||||
if(!$result = $idb->query($sql)) return 'ERROR: ['.$apidb->error.']';
|
$pubLink = substr(number_format(time() * mt_rand(),0,'',''),0,10);
|
||||||
return "Image $imgName edited";
|
$pubLink = base_convert($short, 10, 36);
|
||||||
|
|
||||||
|
$location = "Pictures/Private.png/$uesrname";
|
||||||
|
if(!file_exists($location)) mkdir($location);
|
||||||
|
|
||||||
|
// This /should/ put the files where they belong
|
||||||
|
move_uploaded_file("Pictures/$imgName", "$location/$imgName");
|
||||||
|
move_uploaded_file("thumbs/$imgName", "thumbs/private/$username/$imgName");
|
||||||
|
|
||||||
|
$sql = "UPDATE `share` SET (location, private, sharelink) VALUES('$location', $private', '$pubLink') WHERE `name` = '$imgName';";
|
||||||
|
if(!$result = $idb->query($sql)) return 'ERROR: ['.$apidb->error.']';
|
||||||
|
return "Image $imgName edited";
|
||||||
|
}else{
|
||||||
|
$sql = "UPDATE `share` SET (private, sharelink) VALUES('$private', '$pubLink') WHERE `name` = '$imgName';";
|
||||||
|
if(!$result = $idb->query($sql)) return 'ERROR: ['.$apidb->error.']';
|
||||||
|
return "Image $imgName edited";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return "ERROR: Wrong username or image doesn't exist";
|
return "ERROR: Wrong username or image doesn't exist";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user