Beispiel #1
0
 /**
  * Copy the current version to backup folder, preserving mtime
  * @param {Integer} $id the asset
  */
 static function version_backup($id)
 {
     global $assetsLCL;
     $opath = $assetsLCL . model::getKey($id, 'file');
     $bpath = $assetsLCL . assets::getbackuppath($id);
     if (!copy($opath, $bpath)) {
         return false;
     }
     touch($bpath, filemtime($opath));
     return model::create(array('#parent' => $id, 'bytes' => model::getKey($id, 'bytes'), 'file' => assets::getbackuppath($id), 'sha1' => model::getKey($id, 'sha1'), 'text' => model::getKey($id, 'text'), 'time' => model::getKey($id, 'time'), 'type' => 'asset', 'user' => model::getKey($id, 'user'), 'version' => model::getKey($id, 'version') ? model::getKey($id, 'version') : "1"));
 }
Beispiel #2
0
 if (!is_writable($assetsLCL . $dir)) {
     $error_detected = true;
     $msg .= $dir . " is not writable. ";
 }
 if ($id) {
     // replacement checks
     switch (model::getKey($id, 'mode')) {
         case '1':
         default:
             if (!is_writable($assetsLCL . assets::getbackupfolder($id))) {
                 $error_detected = true;
                 $msg .= assets::getbackupfolder($id) . " is not writable. ";
             }
             if (file_exists($assetsLCL . assets::getbackuppath($id))) {
                 $error_detected = true;
                 $msg .= assets::getbackuppath($id) . " exists. ";
             }
             if (!is_writable($assetsLCL . model::getKey($id, 'file'))) {
                 $error_detected = true;
                 $msg .= model::getKey($id, 'file') . " is not writable. ";
             }
             break;
     }
     if (model::getKey($id, 'lock') && model::getKey(arg('id'), 'lock') != getUser()) {
         $error_detected = true;
         $msg .= model::getKey($id, 'file') . " is locked by " . model::getKey($id, 'lock') . ". ";
     }
 }
 if ($error_detected) {
     header("HTTP/1.1: 409 Conflict");
     echo $msg . 'No change made.';