T.ME/BIBIL_0DAY
CasperSecurity


Server : Apache/2
System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64
User : gositeme ( 1004)
PHP Version : 8.2.29
Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Directory :  /home/gositeme/domains/lavocat.quebec/private_html/scripts/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/gositeme/domains/lavocat.quebec/private_html/scripts/fetch-adw-webp-pictures.js
/**
 * FETCH ADW AVOCATS WEBP PROFILE PICTURES SCRIPT
 * ===============================================
 * 
 * Purpose: Download actual WebP profile pictures from ADW Avocats website and convert to JPG
 * 
 * What it does:
 * 1. Downloads WebP images from ADW Avocats website
 * 2. Converts them to JPG format
 * 3. Uploads them to the platform's file storage
 * 4. Updates user profiles with the profile picture URLs
 * 
 * Usage:
 * node scripts/fetch-adw-webp-pictures.js
 * 
 * Dependencies:
 * - Prisma client
 * - axios (for HTTP requests)
 * - sharp (for image conversion)
 * - fs (for file operations)
 * - path (for file paths)
 * 
 * Created: 2024-01-27
 */

const { PrismaClient } = require('@prisma/client');
const axios = require('axios');
const sharp = require('sharp');
const fs = require('fs');
const path = require('path');

const prisma = new PrismaClient();

// ADW Avocats team members with their actual WebP profile picture URLs
const adwTeamWebpPictures = {
  'justin.wee@adwavocats.com': {
    name: 'Justin Wee',
    pictureUrl: 'https://www.adwavocats.com/wp-content/uploads/2024/12/Justin-1-2-700x461.jpg.webp'
  },
  'alain.arsenault@adwavocats.com': {
    name: 'Alain Arsenault',
    pictureUrl: 'https://www.adwavocats.com/wp-content/uploads/2024/12/Alain-1-2-700x461.jpg.webp'
  },
  'virginie.dufresne-lemire@adwavocats.com': {
    name: 'Virginie Dufresne-Lemire',
    pictureUrl: 'https://www.adwavocats.com/wp-content/uploads/2024/12/Virginie-1-2-700x461.jpg.webp'
  },
  'jerome.aucoin@adwavocats.com': {
    name: 'Jérôme Aucoin',
    pictureUrl: 'https://www.adwavocats.com/wp-content/uploads/2024/12/Jerome-1-2-700x461.jpg.webp'
  },
  'audrey.labrecque@adwavocats.com': {
    name: 'Audrey Labrecque',
    pictureUrl: 'https://www.adwavocats.com/wp-content/uploads/2024/12/Audrey-1-2-700x461.jpg.webp'
  },
  'ivan.lazarov@adwavocats.com': {
    name: 'Ivan Lazarov',
    pictureUrl: 'https://www.adwavocats.com/wp-content/uploads/2024/12/Ivan-1-2-700x461.jpg.webp'
  },
  'yalda.machouf-khadir@adwavocats.com': {
    name: 'Yalda Machouf Khadir',
    pictureUrl: 'https://www.adwavocats.com/wp-content/uploads/2024/12/Yalda-1-2-700x461.jpg.webp'
  },
  'olivia.malenfant@adwavocats.com': {
    name: 'Olivia Malenfant',
    pictureUrl: 'https://www.adwavocats.com/wp-content/uploads/2024/12/Olivia-1-2-700x461.jpg.webp'
  },
  'imane.melab@adwavocats.com': {
    name: 'Imane Melab',
    pictureUrl: 'https://www.adwavocats.com/wp-content/uploads/2024/12/Imane-1-2-700x461.jpg.webp'
  },
  'justine.monty@adwavocats.com': {
    name: 'Justine Monty',
    pictureUrl: 'https://www.adwavocats.com/wp-content/uploads/2024/12/Justine-1-2-700x461.jpg.webp'
  },
  'mmah.nora.toure@adwavocats.com': {
    name: 'M\'Mah Nora Touré',
    pictureUrl: 'https://www.adwavocats.com/wp-content/uploads/2024/12/MMah-Nora-1-2-700x461.jpg.webp'
  }
};

async function fetchADWWebpPictures() {
  console.log('🖼️ Starting WebP profile picture fetch and conversion...\n');

  const uploadDir = path.join(__dirname, '../public/uploads/profiles');
  
  // Create directory if it doesn't exist
  if (!fs.existsSync(uploadDir)) {
    fs.mkdirSync(uploadDir, { recursive: true });
  }

  let successCount = 0;
  let failCount = 0;

  for (const [email, member] of Object.entries(adwTeamWebpPictures)) {
    try {
      console.log(`📥 Processing ${member.name}...`);
      console.log(`  Downloading from: ${member.pictureUrl}`);
      
      // Generate filename
      const filename = `${email.replace('@', '_').replace(/\./g, '_')}.jpg`;
      const filepath = path.join(uploadDir, filename);
      
      // Download WebP image
      const response = await axios({
        method: 'GET',
        url: member.pictureUrl,
        responseType: 'arraybuffer'
      });

      // Convert WebP to JPG using sharp
      await sharp(response.data)
        .resize(300, 300, { fit: 'cover', position: 'center' })
        .jpeg({ quality: 85 })
        .toFile(filepath);
      
      // Update user profile in database
      const publicUrl = `/uploads/profiles/${filename}`;
      await prisma.user.update({
        where: { email: email },
        data: { profilePicture: publicUrl }
      });
      
      console.log(`  ✅ Successfully updated ${member.name} with profile picture: ${publicUrl}`);
      successCount++;
      
    } catch (error) {
      console.log(`  ❌ Failed to process ${member.name}: ${error.message}`);
      failCount++;
      continue;
    }
  }

  console.log('\n🎉 WebP profile picture fetch and conversion completed!');
  console.log(`📊 Summary: ${successCount} successful, ${failCount} failed`);
  console.log(`📈 Success rate: ${Math.round((successCount / Object.keys(adwTeamWebpPictures).length) * 100)}%`);

  await prisma.$disconnect();
}

// Run the script
fetchADWWebpPictures().catch(console.error); 

CasperSecurity Mini