# External Integrations — rank24.pl

## DataForSEO API (Primary — Active)

- **Purpose**: Google SERP rank checking — replaces direct Google scraping
- **Client v2**: `autoload/RestClient.php`
- **Client v3**: `autoload/RestClient3.php`
- **Credentials**: hardcoded in `autoload/class.Cron.php` (lines ~160, ~262, ~354) — `pyziak84@gmail.com`
- **Usage**: `\Cron::post_phrases_positions_dfs3()` submits tasks; `\Cron::get_phrases_positions_dfs3()` retrieves results
- **Auth**: HTTP Basic Auth over HTTPS

## Majestic (Active)

- **Purpose**: Domain authority metrics — TF (Trust Flow), CF (Citation Flow), backlinks, RefDomains
- **Data stored in**: `pro_rr_sites_majestic` table
- **Refresh interval**: `$config['site']['majestic_interval']` = 7 days
- **Integration point**: `api.php` + relevant factory methods

## SEMstorm (Active)

- **Purpose**: Keyword traffic / visibility data
- **Refresh interval**: `$config['site']['semstorm_interval']` = 1 day
- **Integration point**: `api.php`

## Proxy Providers (Disabled)

| Provider | API endpoint (stored in config) | Config key | Status |
|---------|-------------------------------|-----------|--------|
| ProxyMarket | `http://www.proxymarket.pl/api/get/...` | `proxymarket-api` | disabled |
| Proxy.Adding.pl | `http://proxy.adding.pl/apiproxy/...` | `adding-api` | disabled |

Active proxies are managed internally in the `pro_proxy_servers` DB table.

## Internal Proxy Pool

- **Table**: `pro_proxy_servers` (columns: `id`, `proxy`, `bg`, `bgd`, `used`, `enabled`)
- **Rotation logic**: `ORDER BY used ASC LIMIT 1` (least-recently-used)
- **Backoff**: failed proxy gets `bgd = NOW() + (bg * 15 minutes)` cooldown
- **Validation**: `\Cron::check_proxy()` pings each proxy, marks invalid ones disabled
- **Config**: `$config['proxy']['sv-check']` = 2, `$config['proxy']['ht-check']` = 4, `$config['proxy']['s-version']` = 1.218

## Direct Google Scraping (Legacy — still in codebase)

- **Classes**: `autoload/class.GoogleScraper.php`, `autoload/class.GoogleRank.php`, `autoload/class.GoogleSite.php`
- `GoogleScraper` — cURL-based scraper with 24 rotating user agents, proxy support, cookie handling
- `GoogleRank` — orchestrates proxy selection → scrape → parse position → store result
- Block detection: checks for `"Our systems have detected unusual traffic"`, `"Forbidden"`, etc.
- Status: likely superseded by DataForSEO but classes remain

## PHPMailer / SMTP Email

- **Library**: `resources/phpmailer/` (v5.2.15)
- **Credentials**: SMTP hardcoded in `autoload/class.S.php` (lines ~293-300) — `biuro@project-pro.pl`
- **Usage**: transactional emails, notifications, organizer email: `poczta@project-dc.pl`

## mPDF — PDF Reports

- **Library**: `resources/mpdf60/` (v6.0)
- **Usage**: PDF report generation, rendered via `templates/*/reports-pdf.php`

## xajax — AJAX Framework

- **Library**: `resources/xajax/`
- **Handler files**: `functions/xajax-*.php`
- **Entry point**: `ajax.php`

## FTP/SFTP Deployment

- **Tool**: VS Code FTP-KR extension
- **Host**: `host700513.hostido.net.pl`
- **Remote path**: `/public_html/`
- **Config files**: `.vscode/ftp-kr.json`, `.vscode/sftp.json` (credentials stored in plaintext)
