<?php
// emojiicon.php
// RJM Programming
// March, 2025

$usuffix='';
$iponl='';
$rma='';

  function massage($inidea) {
   if (isset($_GET['ididea'])) {
     return str_replace("document.body", "document.getElementById('" . str_replace('+',' ',urldecode($_GET['ididea'])) . "')", $inidea);
   }
   return str_replace('(7 == 7)', '(56 == 67)',$inidea);
  }

  function server_remote_addr() {
    global $iponl, $rma;
    $rma = $_SERVER['REMOTE_ADDR'];
    $ua = strtolower($_SERVER['HTTP_USER_AGENT']);
    // you can add different browsers with the same way ..
    if(preg_match('/(chromium)[ \/]([\w.]+)/', $ua))
            $rma = '000000'.$rma;
    elseif(preg_match('/(chrome)[ \/]([\w.]+)/', $ua))
            $rma = '00000'.$rma;
    elseif(preg_match('/(safari)[ \/]([\w.]+)/', $ua))
            $rma = '0000'.$rma;
    elseif(preg_match('/(opera)[ \/]([\w.]+)/', $ua))
            $rma = '000'.$rma;
    elseif(preg_match('/(msie)[ \/]([\w.]+)/', $ua))
            $rma = '00'.$rma; 
    elseif(preg_match('/(mozilla)[ \/]([\w.]+)/', $ua))
            $rma = '0'.$rma;
    $rma=str_replace(':','_',$rma);
    $iponl=massage(" onload=\" if (window.parent) { if (parent.document.body.outerHTML.split('>')[0].indexOf(' data-ip=') == -1) { if (7 == 7) { parent.document.body.title=('' + parent.document.body.title) + ' +++ _" . $rma . "'; }  parent.document.body.setAttribute('data-ip', '_" . $rma . "');  } } \"");
    return $rma;
  }

  if (isset($_GET['codepoint'])) {
    if (strlen($_GET['codepoint']) > 0) {
     if (isset($_GET['ishex']) || isset($_GET['tohex']) || isset($_GET['hex'])) {
      $usuffix='_' . server_remote_addr();
      file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'emojiicon' . DIRECTORY_SEPARATOR . 'favicon' . $usuffix . '.svg', str_replace('&#x1f1e6;','&#127462;&#127465;','<svg xmlns="http://www.w3.org/2000/svg"><text y="32" font-size="32">&#x' . str_replace(',',';&#x',str_replace(';','',str_replace('&#','',str_replace('+',' ',urldecode($_GET['codepoint']))))) . ';</text></svg>'));
     } else {
      $usuffix='_' . server_remote_addr();
      file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'emojiicon' . DIRECTORY_SEPARATOR . 'favicon' . $usuffix . '.svg', '<svg xmlns="http://www.w3.org/2000/svg"><text y="32" font-size="32">&#' . str_replace(',',';&#',str_replace(';','',str_replace('&#','',str_replace('+',' ',urldecode($_GET['codepoint']))))) . ';</text></svg>');
     }
    } else if (file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'emojiicon' . DIRECTORY_SEPARATOR . 'favicon_' . server_remote_addr() . '.svg')) {
     $usuffix='_' . server_remote_addr();
    } else {
     file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'emojiicon' . DIRECTORY_SEPARATOR . 'favicon' . $usuffix . '.svg', '<svg xmlns="http://www.w3.org/2000/svg"><text y="32" font-size="32">X</text></svg>');
     if ($iponl != '' && file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'emojiicon' . DIRECTORY_SEPARATOR . 'favicon_' . server_remote_addr() . '.svg')) {
      $iponl=massage(" onload=\" if (window.parent) { if (parent.document.body.outerHTML.split('>')[0].indexOf(' data-ip=') == -1) { parent.document.body.setAttribute('data-ip', '_" . $rma . "');  parent.document.body.setAttribute('data-firstip', 'y');  } } \"");
     }
    }
  } else if (file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'emojiicon' . DIRECTORY_SEPARATOR . 'favicon_' . server_remote_addr() . '.svg')) {
    $usuffix='_' . server_remote_addr();
  } else {
    file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'emojiicon' . DIRECTORY_SEPARATOR . 'favicon' . $usuffix . '.svg', '<svg xmlns="http://www.w3.org/2000/svg"><text y="32" font-size="32">X</text></svg>');
    if ($iponl != '' && file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'emojiicon' . DIRECTORY_SEPARATOR . 'favicon_' . server_remote_addr() . '.svg')) {
     $iponl=massage(" onload=\" if (window.parent) { if (parent.document.body.outerHTML.split('>')[0].indexOf(' data-ip=') == -1) { parent.document.body.setAttribute('data-ip', '_" . $rma . "');  parent.document.body.setAttribute('data-firstip', 'y');  } } \"");
    }
  }

echo "<html>
<head>
<link rel='icon' href='/emojiicon/favicon" . $usuffix . ".svg?rand=" . rand(0,3456789) . "' sizes='any' type='image/svg+xml'>
</head>
<body" . $iponl . ">
<h1>Emoji Icon - RJM Programming - March, 2025</h1>
</body>
</html>";
?>
