<?php
// what_wordpress_theme_is_that.php
// RJM Programming
// January, 2017
// $_GET[] work is one off run, else will happen in $_POST[]

$thisurl='';
$content='';
$predicate=" is the WordPress theme used by ";

function selit($inu) {
  return "<select onchange=\" location.href=this.value; \"><option value=''>" . $inu . "</option><option value='./what_wordpress_theme_is_that.php'>Another?</option></select>";
}

if (isset($_GET['url'])) {
  $thisurl=urldecode($_GET['url']);
  if ($thisurl != '') {
   $content=@file_get_contents($thisurl);
  }
  $bits=explode("/wp-content/themes/", $content);
  if (sizeof($bits) > 1) {
    $postbits=explode("/", $bits[1]);
    if (strpos($postbits[0], "twenty") !== false) {
     $firstword="Twenty";
     $secword=strtoupper(substr(substr($postbits[0],strlen("twenty")),0,1)) . substr(substr($postbits[0],strlen("twenty")),1) ;
     echo "<!doctype html><html><body><p>" . $firstword . " " . $secword . $predicate  . selit($thisurl) . "</p></body></html>";
     exit;
    } else {
     echo "<!doctype html><html><body><p>" . $postbits[0] . $predicate . selit($thisurl) . "</p></body></html>";
     exit;
    }
  } else {
    echo "<!doctype html><html><body><p>" .  selit($thisurl) . " is not a WordPress webpage</p></body></html>";
    exit;
  }
}
echo "<!doctype html><html><body onload=\" document.getElementById('url').focus(); \" style='background-color:yellow;'><h1>What WordPress Theme is That?</h1><form method='GET' action='./what_wordpress_theme_is_that.php'>Url: <input id='url' name='url' type='text' value='' style='width:350px;'></input>&nbsp;&nbsp;<input type='submit' value='Find Out' style='background-color:orange;'></input></form></body></html>";
?>
