cvs: pearweb /public_html/channels add.php

From: Date: Sun, 27 Aug 2006 17:27:28 +0000
Subject: cvs: pearweb /public_html/channels add.php
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-core+get-4918@lists.php.net to get a copy of this message
cellog Sun Aug 27 17:27:28 2006 UTC Modified files: /pearweb/public_html/channels add.php Log: eliminate channel submission spam - require channel.xml to be a valid channel.xml file - require that it refer to the site that is hosting the channel.xml file that oughta do it, at least for the lazy spammers. If they get really smart, we can validate at random any portion of REST, but that hopefully won't be necessary. http://cvs.php.net/viewvc.cgi/pearweb/public_html/channels/add.php?r1=1.5&r2=1.6&diff_format=u Index: pearweb/public_html/channels/add.php diff -u pearweb/public_html/channels/add.php:1.5 pearweb/public_html/channels/add.php:1.6 --- pearweb/public_html/channels/add.php:1.5 Wed Dec 21 12:44:00 2005 +++ pearweb/public_html/channels/add.php Sun Aug 27 17:27:28 2006 @@ -15,7 +15,7 @@ +----------------------------------------------------------------------+ | Authors: Martin Jansen <mj@php.net> | +----------------------------------------------------------------------+ - $Id: add.php,v 1.5 2005/12/21 12:44:00 mj Exp $ + $Id: add.php,v 1.6 2006/08/27 17:27:28 cellog Exp $ */ response_header("Channels :: Add"); @@ -83,32 +83,99 @@ echo "<div class=\"errors\">The submitted URL does not "; echo "appear to point to a valid channel site. You will "; echo "have to make sure that <tt>/channel.xml</tt> at least "; - echo "exists. If you think that this mechanism does not work "; + echo "exists and is valid. If you think that this mechanism does not work "; echo "properly, please drop a mail to the "; echo "<a href=\"mailto:pear-webmaster@lists.php.net\">webmasters</a>."; echo "</div>"; $form->display(); - } else { - $text = sprintf("[Channels] Please add %s (%s) to the channel index.", - $form->exportValue("project[name]"), - $form->exportValue("project[link]")); - $from = sprintf('"%s" <%s>', - $form->exportValue("name"), - $form->exportValue("email")); - - $logger = new Damblan_Log; - - $observer = new Damblan_Log_Mail; - $observer->setRecipients("pear-webmaster@lists.php.net"); - $observer->setHeader("From", $from); - $observer->setHeader("Subject", "Channel link submission"); - $logger->attach($observer); + } elseif (!$req->getResponseBody()) { + // channel.xml is empty - spam spam spam + echo "<div class=\"errors\">The submitted URL does not "; + echo "appear to point to a valid channel site. You will "; + echo "have to make sure that <tt>/channel.xml</tt> at least "; + echo "exists and is valid. If you think that this mechanism does not work "; + echo "properly, please drop a mail to the "; + echo "<a href=\"mailto:pear-webmaster@lists.php.net\">webmasters</a>."; + echo "</div>"; - $logger->log($text); + $form->display(); + } elseif (strlen($req->getResponseBody()) > 100000) { + // channel.xml is huge - possible DoS attack + echo "<div class=\"errors\">The submitted URL does not "; + echo "appear to point to a valid channel site. You will "; + echo "have to make sure that <tt>/channel.xml</tt> at least "; + echo "exists and is not huge. If you think that this mechanism does not work "; + echo "properly, please drop a mail to the "; + echo "<a href=\"mailto:pear-webmaster@lists.php.net\">webmasters</a>."; + echo "</div>"; - echo "<div class=\"success\">Thanks for your submission. It will "; - echo "be reviewed as soon as possible.</div>\n"; + $form->display(); + } else { + do { + // poor man's try/catch + require_once 'PEAR/ChannelFile.php'; + $chan = new PEAR_ChannelFile; + if (!$chan->fromXmlString($req->getResponseBody())) { + // channel.xml is invalid xml - spam spam spam + echo "<div class=\"errors\">The submitted URL does not "; + echo "appear to point to a valid channel site. You will "; + echo "have to make sure that <tt>/channel.xml</tt> at least "; + echo "exists and is valid. If you think that this mechanism does not work "; + echo "properly, please drop a mail to the "; + echo "<a href=\"mailto:pear-webmaster@lists.php.net\">webmasters</a>."; + echo "</div>"; + + $form->display(); + break; + } + if (!$chan->validate()) { + // channel.xml is invalid channelfile xml - spam spam spam + echo "<div class=\"errors\">The submitted URL does not "; + echo "appear to point to a valid channel site. You will "; + echo "have to make sure that <tt>/channel.xml</tt> at least "; + echo "exists and is valid. If you think that this mechanism does not work "; + echo "properly, please drop a mail to the "; + echo "<a href=\"mailto:pear-webmaster@lists.php.net\">webmasters</a>."; + echo "</div>"; + + $form->display(); + break; + } + if ($url->host != $chan->getServer()) { + // channel.xml refers to different site - spam spam spam + echo "<div class=\"errors\">The submitted URL does not "; + echo "appear to point to a valid channel site. You will "; + echo "have to make sure that <tt>/channel.xml</tt> at least "; + echo "exists and is valid. In addition, it must refer to "; + echo "your channel. If you think that this mechanism does not work "; + echo "properly, please drop a mail to the "; + echo "<a href=\"mailto:pear-webmaster@lists.php.net\">webmasters</a>."; + echo "</div>"; + + $form->display(); + break; + } + $text = sprintf("[Channels] Please add %s (%s) to the channel index.", + $form->exportValue("project[name]"), + $form->exportValue("project[link]")); + $from = sprintf('"%s" <%s>', + $form->exportValue("name"), + $form->exportValue("email")); + + $logger = new Damblan_Log; + + $observer = new Damblan_Log_Mail; + $observer->setRecipients("pear-webmaster@lists.php.net"); + $observer->setHeader("From", $from); + $observer->setHeader("Subject", "Channel link submission"); + $logger->attach($observer); + + $logger->log($text); + + echo "<div class=\"success\">Thanks for your submission. It will "; + echo "be reviewed as soon as possible.</div>\n"; + } while (false); } } else { $form->display();

« previous php.pear.core (#4918) next »