<? require("S2ajax.php"); $s2ajax_request_type = "GET"; // Note that exported methods are static! s2ajax_export('TypeTester$return_array', 'TypeTester$return_object'); s2ajax_method_export(TypeTester, return_string); s2ajax_export(array(TypeTester, return_int), array(TypeTester, return_float)); // And now, let's handle the user's request s2ajax_handle_client_request(); class MyObj { var $name, $age; function MyObj($name, $age) { $this->name = $name; $this->age = $age; } } class TypeTester { static function return_array() { return array("name" => "Tom", "age" => 26); } static function return_object() { $o = new MyObj("Tom", 26); return $o; }
<?php // // The world's least efficient wall implementation // require "S2ajax.php"; $s2ajax_request_type = "GET"; // Note that exported methods are static! s2ajax_method_export(Wall, add_line); s2ajax_method_export(Wall, server_refresh); // And now, let's handle the user's request s2ajax_handle_client_request(); class Wall { function __construct() { } function colorify_ip($ip) { $parts = explode(".", $ip); $color = sprintf("%02s", dechex($parts[1])) . sprintf("%02s", dechex($parts[2])) . sprintf("%02s", dechex($parts[3])); return $color; } static function add_line($msg) { $f = fopen("/tmp/wall.html", "a"); $dt = date("Y-m-d h:i:s"); $msg = strip_tags(stripslashes($msg)); $remote = $_SERVER["REMOTE_ADDR"]; // generate unique-ish color for IP $color = self::colorify_ip($remote);