Re: Totally hate: PHP

Date: 2019-10-13 10:57 pm (UTC)
juan_gandhi: (Default)
From: [personal profile] juan_gandhi
Хороший вопрос. Не в гитхабе, но есть. Сюда, что ли, запостить? Вот кусманчик.

<?php

include 'lib.php';
include 'header.php';

  $username = $_POST['keycode'];
  $partner = $_POST['player'];
  $message = $_POST['message'];

  if ($_SERVER["HTTP_X_FORWARDED_FOR"]) {
    $ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
  } else {
    if ($_SERVER["HTTP_CLIENT_IP"]) {
      $ip = $_SERVER["HTTP_CLIENT_IP"];
    } else {
      $ip = $_SERVER["REMOTE_ADDR"];
    }
  }
//echo ("user=\"$username\"  ip=\"$ip\"  ");
  if (isset($message)) {
    mylog($username, "message for $partner:\"$message\"");
  } else {
    mylog($username, "reading chat");
  }

  if (!checkUser($username, $ip)) {
    echo ("error=not logged in");
  } elseif(!isset($partner)) {
    echo ("error=have to specify partner");
  } else {
    $lock = "chat.$username.$partner";
    lock($lock, 10);
    if (isset($message)) {
      if (!mychat($username, $partner, $message)) {
         echo("error=chat with $partner somehow unavailable&");
      }
    }
    echo("contents=" . getchatcontents($username, $partner));
    unlock($lock);
  }
?>
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

June 2025

S M T W T F S
1 2345 6 7
8 9 10 11 121314
15161718 1920 21
22232425262728
2930     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 21st, 2025 03:06 pm
Powered by Dreamwidth Studios