# QUICK SETUP GUIDE - Centralized Config System

## 🎯 What Changed?

**OLD WAY (Bad):**
- ❌ Passwords hardcoded in each script
- ❌ Update passwords in 5+ places
- ❌ Easy to commit passwords to git
- ❌ Maintenance nightmare

**NEW WAY (Good):**
- ✅ Single config file with all accounts
- ✅ Update password once, all scripts get it
- ✅ Config file automatically git-ignored
- ✅ Easy to maintain

---

## ⚡ Quick Start (5 Minutes)

### Step 1: Create Config Directory

```bash
cd C:\xampp\htdocs\HSLG
mkdir config
```

### Step 2: Copy Your Real Config File

**You already have `warmup_accounts_config.php` with your real passwords!**

Copy it to the config directory:

```bash
copy warmup_accounts_config.php config\warmup_accounts_config.php
```

### Step 3: Copy Updated Scripts

Replace your old scripts with these new ones:

```bash
# Test script (uses centralized config)
copy test_warmup_accounts_FIXED.php test_warmup_accounts.php

# Warmup monitor (uses centralized config)
copy warmup_monitor_FIXED.php warmup_monitor.php

# Copy .gitignore to protect passwords
copy .gitignore .gitignore
```

### Step 4: Test It!

```bash
php test_warmup_accounts.php
```

**Should see:**
```
Loaded 22 accounts from config
Testing: waszuppmail@gmail.com (gmail)... ✓ SUCCESS
Testing: rodcaverly@yahoo.com (yahoo)... ✓ SUCCESS
...
✓✓✓ ALL ACCOUNTS WORKING! ✓✓✓
```

---

## 📁 Final File Structure

```
HSLG/
├── config/
│   ├── warmup_accounts_config.php        ← YOUR REAL PASSWORDS (git-ignored)
│   ├── warmup_accounts_config.EXAMPLE.php ← Template (safe to commit)
│   ├── config.php                        ← Brevo SMTP config
│   └── database.php                      ← Database config
│
├── warmup_monitor.php                    ← Uses config/warmup_accounts_config.php
├── warmup_reply_sender.php               ← Uses config/warmup_accounts_config.php
├── test_warmup_accounts.php              ← Uses config/warmup_accounts_config.php
│
├── .gitignore                            ← Protects warmup_accounts_config.php
└── README.md
```

---

## 🔒 Security Check

### Verify .gitignore is Working:

```bash
cd C:\xampp\htdocs\HSLG
git status
```

**Should NOT see:**
- ❌ `config/warmup_accounts_config.php`
- ❌ `warmup_accounts_config.php`

**Should see (safe to commit):**
- ✅ `config/warmup_accounts_config.EXAMPLE.php`
- ✅ `.gitignore`
- ✅ `test_warmup_accounts.php`
- ✅ `warmup_monitor.php`

---

## 🔧 How Scripts Load Config

### In any script:

```php
// Load accounts from centralized config
$accounts = require __DIR__ . '/config/warmup_accounts_config.php';

// Now use $accounts array
foreach ($accounts as $account) {
    echo $account['email'];
    // Connect using $account['password']
}
```

### Benefits:

✅ **Update once** - Change password in config file
✅ **All scripts update** - Automatically use new password
✅ **No duplication** - Single source of truth
✅ **Git-safe** - Real config never committed

---

## 📝 Updating Passwords

### When Gmail App Password changes:

1. **Edit config file:**
   ```bash
   notepad config\warmup_accounts_config.php
   ```

2. **Find the account:**
   ```php
   [
       'email' => 'waszuppmail@gmail.com',
       'password' => 'OLD PASSWORD HERE',  // ← Change this
       // ...
   ],
   ```

3. **Update password:**
   ```php
   [
       'email' => 'waszuppmail@gmail.com',
       'password' => 'NEW PASSWORD HERE',  // ← New password
       // ...
   ],
   ```

4. **Save file**

5. **All scripts automatically use new password!**

No need to update warmup_monitor.php, test_warmup_accounts.php, etc. They all load from the same config!

---

## ✅ Migration Checklist

If you have old scripts with hardcoded passwords:

- [ ] Create `config/` directory
- [ ] Move `warmup_accounts_config.php` to `config/`
- [ ] Copy `.gitignore` to root directory
- [ ] Replace old scripts with FIXED versions
- [ ] Test with: `php test_warmup_accounts.php`
- [ ] Verify git status (config should be ignored)
- [ ] Delete old scripts with hardcoded passwords
- [ ] Update cron jobs to use new script paths

---

## 🚀 Your Scripts

### Files You Use:

| File | Purpose | Uses Config? |
|------|---------|--------------|
| `config/warmup_accounts_config.php` | Stores all passwords | - |
| `test_warmup_accounts.php` | Tests IMAP connections | ✅ Yes |
| `warmup_monitor.php` | Monitors emails, schedules replies | ✅ Yes |
| `warmup_reply_sender.php` | Sends scheduled replies | ✅ Yes |

### Files to Commit to Git:

| File | Commit? | Why |
|------|---------|-----|
| `config/warmup_accounts_config.php` | ❌ NO | Real passwords |
| `config/warmup_accounts_config.EXAMPLE.php` | ✅ YES | Template only |
| `.gitignore` | ✅ YES | Protects passwords |
| `warmup_monitor.php` | ✅ YES | No passwords in it |
| `test_warmup_accounts.php` | ✅ YES | No passwords in it |

---

## 🎓 Common Questions

### Q: "Where do I put my real passwords now?"
**A:** In `config/warmup_accounts_config.php` (you already did this!)

### Q: "What if I need to add a new account?"
**A:** Edit `config/warmup_accounts_config.php`, add a new array element. All scripts automatically see it!

### Q: "Can I delete the old test_22accounts.php?"
**A:** Yes! Use `test_warmup_accounts.php` instead (same thing, but uses centralized config)

### Q: "Do I need to update my cron jobs?"
**A:** Only if the filenames changed. If you replaced the files in place, cron jobs work as-is.

### Q: "What if git shows warmup_accounts_config.php in changes?"
**A:** Make sure `.gitignore` contains: `config/warmup_accounts_config.php`

### Q: "Can I keep a backup of my passwords?"
**A:** Yes! Backup `config/warmup_accounts_config.php` to a USB drive or encrypted cloud storage. Keep it safe!

---

## 📊 Before vs After

### BEFORE (Multiple Hardcoded Passwords):

```
test_22accounts.php:
    $accounts = [
        ['email' => 'test@gmail.com', 'password' => 'abc123'],
        // ...
    ];

warmup_monitor.php:
    $accounts = [
        ['email' => 'test@gmail.com', 'password' => 'abc123'],
        // ...
    ];

warmup_reply_sender.php:
    $accounts = [
        ['email' => 'test@gmail.com', 'password' => 'abc123'],
        // ...
    ];
```

**Problems:**
- Password in 3 places
- Change password = update 3 files
- Easy to miss one
- Risk of committing to git

---

### AFTER (Centralized Config):

```
config/warmup_accounts_config.php:
    return [
        ['email' => 'test@gmail.com', 'password' => 'abc123'],
        // ...
    ];

test_warmup_accounts.php:
    $accounts = require 'config/warmup_accounts_config.php';

warmup_monitor.php:
    $accounts = require 'config/warmup_accounts_config.php';

warmup_reply_sender.php:
    $accounts = require 'config/warmup_accounts_config.php';
```

**Benefits:**
- Password in 1 place
- Change password = update 1 file
- All scripts auto-update
- Config file git-ignored (safe)

---

## ✅ You're Done!

Your system now uses centralized config. Benefits:

✅ **Easier to manage** - Update passwords in one place
✅ **More secure** - Config file automatically git-ignored
✅ **Less error-prone** - No duplicate password entries
✅ **Better organized** - Clear separation of config vs code

**Next:** Run your warmup system as normal! Everything works the same, just better organized! 🚀

---

## 🆘 Troubleshooting

### Error: "Config file not found"

```
ERROR: Config file not found at: /path/to/config/warmup_accounts_config.php
```

**Fix:** 
```bash
# Make sure file is in correct location
copy warmup_accounts_config.php config\warmup_accounts_config.php
```

---

### Error: "Config did not return valid array"

```
ERROR: Config file did not return a valid accounts array!
```

**Fix:** Make sure config file has `return [` at the top:
```php
<?php
return [  // ← Must have this!
    [
        'email' => '...',
        // ...
    ],
];
```

---

### Git still shows config file in changes

```bash
git status
# Shows: config/warmup_accounts_config.php
```

**Fix:** Update .gitignore:
```bash
echo config/warmup_accounts_config.php >> .gitignore
git add .gitignore
git commit -m "Ignore password config"
```

---

**All set! Your centralized config system is ready to go!** 🎉
