예제 #1
0
 /**
  * Aktualisiert Dateiindex in Datenbank
  * @param int $userId
  */
 public function updateFileIndex($userId)
 {
     $folderFiles = $this->getFolderList();
     $dbFiles = $this->getDatabaseList();
     if (!$folderFiles || !count($folderFiles) || count($folderFiles) == count($dbFiles)) {
         return;
     }
     foreach ($folderFiles as $folderFile) {
         if (isset($dbFiles[$folderFile])) {
             continue;
         }
         $image = new \fpcm\model\files\image(basename($folderFile), '', '', false, true);
         $image->setFiletime(time());
         $image->setUserid($userId);
         if (!in_array($image->getMimetype(), image::$allowedTypes) || !in_array(strtolower($image->getExtension()), image::$allowedExts)) {
             trigger_error("Filetype not allowed in \"{$folderFile}\".");
             continue;
         }
         if (!$image->exists(true) && !$image->save()) {
             trigger_error("Unable to save image \"{$folderFile}\" to database.");
         }
     }
     foreach ($dbFiles as $dbFile) {
         if (!$dbFile->existsFolder() && !$dbFile->delete()) {
             trigger_error("Unable to remove image \"{$folderFile}\" from database.");
         }
     }
     $this->createFilemanagerThumbs($folderFiles);
 }
예제 #2
0
 /**
  * Controller-Processing
  */
 public function process()
 {
     parent::process();
     $filename = $this->getRequestVar('file');
     $id = $this->getRequestVar('id');
     $db = $this->initDatabase();
     if (!$db) {
         die('0');
     }
     $file = $db->fetch($db->select('uploads', '*', "id = {$id} AND filename = '{$filename}'"));
     if (!$file) {
         usleep(500000);
         die('0');
     }
     $img = new \fpcm\model\files\image($file->filename);
     $img->setFiletime($file->uploadtime);
     $img->setUserid($file->uploaderid);
     if (!$img->save()) {
         usleep(500000);
         die('0');
     }
     $src = $this->fpcm2Path . '/data/upload/' . $file->filename;
     $dest = \fpcm\classes\baseconfig::$uploadDir . $file->filename;
     if (!file_exists($src)) {
         trigger_error("Unable to copy smiley file {$src} to {$dest}, source file not found...");
         die('0');
     }
     if (file_exists($dest)) {
         trigger_error("Unable to copy smiley file {$src} to {$dest}, destination file already exists...");
         die('0');
     }
     if (!copy($src, $dest)) {
         trigger_error("Unable to copy smiley file {$src} to {$dest}...");
         die('0');
     }
     usleep(750000);
     die('1');
 }