public function importMedia(stdClass $media, $userId, WordPressAccess $wordPressAccess, PHPBoostAccess $phpBoostAccess) { $src = $wordPressAccess->getPath() . 'wp-content/uploads/' . $media->path; $dest = $phpBoostAccess->getPath() . FILESYSTEM_IMPORT_LOCATION . $media->path; if (!is_dir(dirname($dest))) { mkdir(dirname($dest), 0777, true); } if (!file_exists($dest) && file_exists($src)) { copy($src, $dest); $file = pathinfo($dest); // Ajout dans la base de données $insert = $phpBoostAccess->getSql()->prepare(' INSERT IGNORE INTO ' . $phpBoostAccess->getPrefix() . 'upload(name, path, user_id, size, type, timestamp) VALUES (:name, :path, :user_id, :size, :type, :timestamp) '); $insert->execute(array('name' => $file['basename'], 'path' => str_replace('upload/', '', FILESYSTEM_IMPORT_LOCATION . $media->path), 'user_id' => $userId, 'size' => round(filesize($dest) / 1024), 'type' => $file['extension'], 'timestamp' => filemtime($dest))); return true; } return false; }