. class PostData { public $postData = array (); public $remoteAccess = false; public $file; public $replyTo; public $viaAJAX = false; public function __construct () { // Use POST or GET based on whether request is for JSONP $postget = isset ($_GET['jsonp']) ? $_GET : $_POST; // Set status if (isset ($postget['status'])) { $this->postData['status'] = $this->ForceUTF8 ($postget['status']); } // Set name if (isset ($postget['name'])) { $this->postData['name'] = $this->ForceUTF8 ($postget['name']); } // Set password if (isset ($postget['password'])) { $this->postData['password'] = $this->ForceUTF8 ($postget['password']); } // Set e-mail address if (isset ($postget['email'])) { $this->postData['email'] = $this->ForceUTF8 ($postget['email']); } // Set website URL if (isset ($postget['website'])) { $this->postData['website'] = $this->ForceUTF8 ($postget['website']); } // Set comment if (isset ($postget['comment'])) { $this->postData['comment'] = $this->ForceUTF8 ($postget['comment']); } // Set indicator of remote access if (isset ($postget['remote-access'])) { $this->remoteAccess = true; } // Get comment file if (isset ($postget['file'])) { $this->file = $postget['file']; } // Get reply comment file if (isset ($postget['reply-to'])) { $this->replyTo = $postget['reply-to']; } // Set indicator of AJAX requests if (isset ($postget['ajax'])) { $this->viaAJAX = true; } } // Force a string to UTF-8 encoding and acceptable character range protected function ForceUTF8 ($string) { $string = mb_convert_encoding ($string, 'UTF-16', 'UTF-8'); $string = mb_convert_encoding ($string, 'UTF-8', 'UTF-16'); $string = preg_replace ('/[^\x{0009}\x{000A}\x{000D}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF}]/u', '?', $string); return trim ($string, " \r\n\t"); } }