• R/O
  • SSH
  • HTTPS

ogup:


File Info

修訂. 32
大小 2,118 bytes
時間 2021-12-04 23:43:08
作者 mateuszviste
Log Message

reworded a few phrases and other minor improvements

Content

<?php

$serv = '';
if (!empty($_SERVER['QUERY_STRING_SEARCH'])) {
  $serv = strtolower(trim($_SERVER['QUERY_STRING_SEARCH']));
}

// no query? output default screen

if (empty($serv)) {
  echo "i\r\n";
  echo "iThe Observable Gopherspace Universe Project actively scans the universe\r\n";
  echo "ilooking for new gopher nodes, but it still may miss some. Help us by\r\n";
  echo "iproviding suggestions!\r\n";
  echo "i\r\n";
  echo "iSubmitting a new gopher server suggestion is easy: use the form below to\r\n";
  echo "ienter the address of the server you'd like to add to the OGUP database.\r\n";
  echo "iThat's it! Within a couple of hours OGUP will verify and it add to the\r\n";
  echo "ilist of known servers.\r\n";
  echo "i\r\n";
  echo "7Submit a gopher server to the OGUP (format: \"gopher.example.net\")\t?\r\n";
  echo "i\r\n";
  echo "iNotes:\r\n";
  echo "i * Only suggestions for server names or IP addresses are accepted (no paths).\r\n";
  echo "i * For a gopher server to be accepted, it must present at least one link in\r\n";
  echo "i   its main menu that points to a self-hosted page.\r\n";
} else {

  // process submission

  sleep(2); // just to avoid someone hammers the server with some stupid script

  echo "iYou have submitted the following input: \"{$serv}\"\r\n";
  echo "i\r\n";

  if ((preg_match('/[a-z0-9][a-z0-9.:]*/', $serv) != 1) || (preg_match('/.*\..*/', $serv) != 1)) {
    echo "3ERROR: INVALID INPUT.\r\n";
    echo "i\r\n";
    echo "iSubmissions:\r\n";
    echo "i - must not contain characters other than a-z, 0-9, '.' and ':'.\r\n";
    echo "i - must start with either an a-z or 0-9 character\r\n";
    echo "i - must contain at least one dot\r\n";
  } else {
    $fname = md5($serv);
    if (file_exists('/tmp/ogup/' . $fname)) {
      echo "3ERROR: This entry has been already submitted.\r\n";
    } else {
      mkdir('/tmp/ogup'); // create if does not exist yet
      file_put_contents('/tmp/ogup/' . $fname, $serv);
      echo "iYour submission has been accepted. Thank you!\r\n";
    }
  }

}

echo "i\r\n";
echo "1Go back to OGUP main screen\t../\r\n";

?>
Show on old repository browser