$ret .= 'Query: ' . $query; } } else { if (isset($_REQUEST['reply'])) { $_to = $_REQUEST['to']; $_name = $_REQUEST['name']; } } } } $messages = get_msg_count($_SESSION['webid']); $private_msg = get_msg_count($_SESSION['webid'], 1, 0); } // send a new message using the pingback protocol if (isset($_REQUEST['doit']) && isset($_REQUEST['to'])) { $ret .= sendPing($_REQUEST['to'], $_REQUEST['message'], BASE_URI, true); } // display form to send local messages $ret .= "<div class=\"wall-new r5\">\n"; $ret .= "<form method=\"post\" action=\"messages\">\n"; $ret .= "<input type=\"hidden\" name=\"doit\" value=\"1\" />\n"; $ret .= "<input type=\"hidden\" name=\"to\" id=\"to\" value=\"" . $_to . "\" />\n"; $ret .= "<table border=\"0\">\n"; $ret .= "<tr valign=\"top\">\n"; $ret .= " <td style=\"width: 80px\"><p><a href=\"view?webid=" . urlencode($_SESSION["webid"]) . "\" target=\"_blank\">\n"; $ret .= " <img class=\"r5\" title=\"" . $_SESSION['usr'] . "\" alt=\"" . $_SESSION['usr'] . "\" width=\"64\" src=\"" . $_SESSION['img'] . "\" />\n"; $ret .= " </a></p></td>\n"; $ret .= " <td>\n"; $ret .= " <table border=\"0\">\n"; $ret .= " <tr><td><input size=\"40\" type=\"text\" id=\"name\" name=\"name\" placeholder=\"To: name, nick or WebID\" value=\"" . $_name . "\" /></td></tr>\n"; $ret .= " <tr><td><textarea id=\"message\" name=\"message\" onfocus=\"textAreaResize(this)\" class=\"textarea-msg\" placeholder=\"Your message text...\"></textarea></td></tr>\n";
$query .= "wall='1'"; $result = mysql_query($query); if (!$result) { $ret .= error('Database error while trying to insert new message!'); } else { mysql_free_result($result); // update etags $ret .= update_etags($time, $to_hash); // send a notification to each mentioned user foreach ($webids as $to) { $ping_msg = 'I have just mentioned you in a '; $ping_msg .= $owner_webid != 'local' ? 'private' : 'public'; $ping_msg .= ' wall post. You can see it here: ' . $base_uri . '/wall.php?user='******'webid'] != $to) { sendPing($to, $ping_msg, $base_uri, false); } } } } // Update the message with new text if (isset($_REQUEST['edit'])) { $query = "UPDATE pingback_messages SET "; $query .= "updated='" . $time . "', "; $query .= "msg = '" . mysql_real_escape_string($msg) . "' "; $query .= "WHERE id = '" . mysql_real_escape_string($_REQUEST['edit']) . "' "; $query .= "AND from_uri = '" . mysql_real_escape_string($_SESSION['webid']) . "'"; $result = mysql_query($query); if (!$result) { $ret .= error('Database error while updating post!'); } else {
$ret = 'Invalid query: ' . mysql_error() . "\n"; $ret .= 'Query: ' . $query; } } else { if (isset($_REQUEST['reply'])) { header("Location: messages.php?new=true&to=" . urlencode($_REQUEST['to'])); } } } } $messages = get_msg_count($_SESSION['webid']); $private_msg = get_msg_count($_SESSION['webid'], 1, 0); } // send a new message using the pingback protocol if (isset($_REQUEST['doit']) && isset($_REQUEST['to'])) { $ret .= sendPing($_REQUEST['to'], $_REQUEST['message'], $base_uri, true); } // display form to send local messages if (isset($_REQUEST['new'])) { $ret .= "<div class=\"clear\"><br/><br/></div>\n"; $ret .= "<form name=\"send\" method=\"POST\" action=\"messages.php\">\n"; $ret .= "<input type=\"hidden\" name=\"doit\" value=\"1\">\n"; $ret .= "<table border=\"0\">\n"; $ret .= "<tr valign=\"top\"><td>From WebID: <br/> </td><td><strong>You</strong> <font color=\"grey\"><small>(" . $_SESSION['webid'] . ")</small></font></td></tr>\n"; $ret .= "<tr valign=\"top\"><td>Target WebID: <br/> </td><td><input size=\"30\" type=\"text\" name=\"to\" value=\"" . $_REQUEST['to'] . "\"></td></tr>\n"; $ret .= "<tr valign=\"top\"><td>Short message (256): <br/>(optional)</td><td> <textarea style=\"height: 130px;\" name=\"message\"></textarea></td></tr>\n"; $ret .= "<tr><td><br/><input type=\"submit\" class=\"btn btn-primary\" name=\"submit\" value=\" Send message! \"></td><td></td></tr>\n"; $ret .= "</table>\n"; $ret .= "</form>\n"; $ret .= "<div class=\"clear\"></div>\n"; $ret .= "</div>\n";
<?php // Script that sends the initial ping require_once "pinger.php"; // Constant variables require_once "variables.php"; // The message // This will be encoded as an avro binary, but we can get away with // any encoding as the XFabric will ignore the message and we are // just sending something to our self // Replace the below quote with your message or the empty string $message = array("payload" => "Call me Ishmael"); // If the Send Ping button was clicked ... if (isset($_POST["pinged"])) { // ... send the ping if ($_POST["pinged"] == "true") { sendPing($message); $_POST["pinged"] = "false"; } // Set the POST that will check the log file echo "<form action=\"pingpong.php\" method=\"post\">\n <input type=\"hidden\" name=\"pinged\" value=\"false\">\n <input type=\"hidden\" name=\"checked\" value=\"true\">\n <input type=\"submit\" value=\"Check Status\">\n </form>\n <br />"; // If the Check button was clicked ... if (isset($_POST["checked"]) && $_POST["checked"] == "true") { // ... read the log file ... $contents = file_get_contents($file); // ... and print an empty notice or the log if ($contents == "") { echo "File is empty. <br \\> No logs of pings or pongs"; } else { echo nl2br($contents); } $_POST["checked"] = "false";