$query .= "to_uri = '" . $to . "', "; $query .= "name = '" . $name . "', "; $query .= "pic = '" . $pic . "', "; $query .= "msg = ' " . $msg . "'"; $result = mysql_query($query); if (!$result) { // Database error, return a proper HTTP response code with error $ret .= header("HTTP/1.1 500 Internal Error"); $ret .= header("Status: 500 Internal Error"); $ret .= "<html><body>\n"; $ret .= "Internal error: could not deliver the ping (database error).\n"; $ret .= "</body></html>\n"; } else { mysql_free_result($result); // Send a mail too if the receiving user allows it if (is_subscribed_email($to)) { $person = new MyProfile(trim($_POST['target']), BASE_URI, SPARQL_ENDPOINT); $person->load(); $to_name = $person->get_name(); $to_email = $person->get_email(); $from = 'MyProfile Notification System <' . SMTP_USERNAME . '>'; $to = '"' . $to_name . '" <' . clean_mail($to_email) . '>'; $subject = 'You have received a new personal message!'; $headers = array('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array('host' => SMTP_SERVER, 'auth' => SMTP_AUTHENTICATION, 'username' => SMTP_USERNAME, 'password' => SMTP_PASSWORD)); $message = '<html><body>'; $message .= '<p>Hello ' . $to_name . ',</p>'; $message .= '<p>You have just received a new message from ' . $name . '! '; $message .= '<a href="' . BASE_URI . '/messages">Click here</a> to see it.</p>'; $message .= '<br/><p><small>You are receiving this email because you enabled Semantic Pingback notification '; $message .= '(with email as notification mechanism) for your Personal Profile on <a href="' . BASE_URI . '">' . BASE_URI . '</a>. ';
function unsubscribe_email() { // unsubscribe only if we are already subscribed if (is_subscribed_email($this->webid) == true) { $query = "UPDATE pingback SET email='0' WHERE webid='" . mysql_real_escape_string($this->webid) . "'"; $result = mysql_query($query); if (!$result) { return error('Unable to connect to the database!'); } else { mysql_free_result($result); return success('You have unsubscribed from receiving email notifications.'); } } }
} } // display form if we are not registered if (!is_subscribed($_SESSION['webid'])) { $ret .= "<h2><strong>Manage notifications</strong></h2>\n"; $ret .= "<form name=\"manage\" method=\"post\">\n"; $ret .= "<input type=\"hidden\" name=\"subscribe\" value=\"1\">\n"; $ret .= "<table border=\"0\">\n"; $ret .= "<tr><td>Would you like to register in order to receive notifications?</td></tr>\n"; $ret .= "<tr><td><br/><input class=\"btn btn-primary\" type=\"submit\" name=\"submit\" value=\"Register\"></td></tr>\n"; $ret .= "</table>\n"; $ret .= "</form>\n"; } else { $ret .= "<h1>The URI for your Wall is <a href=\"" . $base_uri . "/wall?user="******"\">" . $base_uri . "/wall?user="******"</a></h1>\n"; $check_email = ''; if (is_subscribed_email($_SESSION['webid']) == true) { $check_email = 'checked'; } $check_subscription = 'checked'; $ret .= "<h2><strong>Manage notifications</strong></h2>\n"; $ret .= "<form method=\"post\">\n"; $ret .= "<table>\n"; $ret .= "<tr><td><input type=\"checkbox\" name=\"subscription\" " . $check_subscription . " /> Receive notifcations. (<strong>Warning!</strong> Unsubscribing removes all exisiting messages and wall posts!)</td></tr>\n"; $ret .= "<tr><td><input type=\"checkbox\" name=\"email\" " . $check_email . " /> Receive notifications through email.</td></tr>\n"; $ret .= "<tr><td><br /><input class=\"btn margin-5\" type=\"submit\" name=\"submit\" value=\" Modify \"></td></tr>\n"; $ret .= "</table>\n"; $ret .= "</form>\n"; } if (isset($_REQUEST['recovery_email'])) { $email = $_REQUEST['recovery_email']; } else {