<?php
class SiteDetector {

  public static function detectFromUrl($url) {

    $html = @file_get_contents($url);
    if (!$html) return null;

    $detected = [
      'base_url' => $url,
      'cms' => 'static',
      'publish_dir' => '/public_html/',
      'posts_index_path' => '/posts.json'
    ];

    if (strpos($html, 'wp-content') !== false) {
      $detected['cms'] = 'wordpress';
      $detected['publish_dir'] = '/wp-content/uploads/';
    }

    if (strpos($html, '<meta name="generator" content="WordPress') !== false) {
      $detected['cms'] = 'wordpress';
    }

    return $detected;
  }
}
