Beispiel #1
0
 /**
  * Process the uploaded file
  * @param {Integer} $id the asset
  * @param {String} $path the path of the uploaded file in the temporary folder
  * @param {String} $message
  * @returns {Boolean} true on success, false otherwise
  */
 static function asset_upload($id, $path, $message)
 {
     switch (model::getKey($id, 'mode')) {
         case '2':
             global $assetsLCL;
             $newid = assets::version_increment2($id, $message);
             if (!$newid) {
                 return false;
             }
             if (!move_uploaded_file($path, $assetsLCL . model::getKey($newid, 'file'))) {
                 return false;
             }
             break;
         case '1':
         default:
             global $assetsLCL;
             if (!file_exists($assetsLCL . assets::getbackupfolder($id))) {
                 if (!mkdir($assetsLCL . assets::getbackupfolder($id), 0755, true)) {
                     return false;
                 }
             }
             if (!is_writable($assetsLCL . assets::getbackupfolder($id))) {
                 return false;
             }
             if (file_exists($assetsLCL . assets::getbackuppath($id))) {
                 return false;
             }
             if (!is_writable($assetsLCL . model::getKey($id, 'file'))) {
                 return false;
             }
             $new_id = assets::version_backup($id);
             if (!$new_id) {
                 return false;
             }
             if (!move_uploaded_file($path, $assetsLCL . model::getKey($id, 'file'))) {
                 unlink($assetsLCL . model::getKey($new_id, 'file'));
                 model::delete($new_id);
                 return false;
             }
             if (!assets::version_increment($id, $message)) {
                 return false;
             }
             break;
     }
     return true;
 }
Beispiel #2
0
         exit;
     }
     if (!is_readable($assetsLCL . $path)) {
         header("HTTP/1.1: 403 Forbidden");
         echo "The file is not readable";
         exit;
     }
     $id = assets::version_backup(arg("id"));
     if (!$id) {
         header('HTTP/1.1: 304 Not Modified Error on create');
         exit;
     }
     echo json_encode(model_json::node($id, 1, $NODE_TAG | $NODE_PRM));
     break;
 case "version_increment":
     if (!assets::version_increment(arg("id"), arg("message"))) {
         header("HTTP/1.1: 304 Not Modified Asset Not updated");
         exit;
     }
     echo json_encode(true);
     break;
 case "version_increment2":
     if (!assets::version_increment2(arg("id"), arg("message"))) {
         header("HTTP/1.1: 304 Not Modified Asset Not updated");
         exit;
     }
     echo json_encode(true);
     break;
 case "recycle":
     if (!DAM::recycle(arg('id'))) {
         header("HTTP/1.1: 304 Not Modified Could not move element to trash");