User:RFC posting script/source: Difference between revisions

Content deleted Content added
( )
m Replaced deprecated <source> tags with <syntaxhighlight> (via WP:JWB)
 
(9 intermediate revisions by 3 users not shown)
Line 1:
'''postingtool.php'''
{{beerware|Messedrocker|(Or cash equivalent)}}
 
<syntaxhighlight lang=php>
'''postingscript.php'''
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>RfC posting tool</title>
<style type="text/css">
<!--
.style2 {
color: #FFFFFF;
font-family: Arial, Helvetica, sans-serif;
font-size: 36px;
}
.style3 {
font-size: 45px;
font-family: "Trebuchet MS";
font-weight: bold;
}
.style6 {font-size: 27px}
.style7 {font-size: 42px}
.style8 {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
-->
</style>
</head>
 
<body>
<source lang=php>
<div class="style2 style3" style="height:90px; padding:3px; background-image:url('./bg.png'); width:100%; margin-left:auto; margin-right:auto; text-align:left;"> <span class="style7">Requests for comment</span><br />
<span class="style6">RfC posting tool</span></div>
<br />
<div style="padding: 3px; border: 2px dashed #0000FF; font: 15px Arial, Helvetica, sans-serif">
<?php
$connect = mysql_connect('sql', $sqluser, $sqlpass);
if (!$connect)
die("Error: database connection failed.");
mysql_select_db($database);
 
 
ini_set("display_errors", 1);
error_reporting(E_ALL ^ E_NOTICE);
include("./botclasses.php");
 
$userrfctype = mysql_real_escape_string($_GET['userrfctype']);
$categorypage = mysql_real_escape_string($_GET['categorypage']);
$pagesection = mysql_real_escape_string($_GET['pagesection']);
$sectionreason = mysql_real_escape_string($_GET['sectionreason']);
$reason =mysql_real_escape_string( $_GET['reason']);
$id = md5(time());
 
if (isset($_GET['submit'])) {
if (($_GET['user'] != "") && ($_GET['categoryrfctype'] != "") && ($_GET['page'] != "") && ($_GET['section'] != "") && ($_GET['reason'] != "")) {
$rfctype = "";
switch ($category) {
case "Biographies":
$rfctype = "RFCbio";
break;
case "Economy, trade, and companies":
$rfctype = "RFCecon";
break;
case "History and geography":
$rfctype = "RFChist";
break;
case "Language and linguistics":
$rfctype = "RFClang";
break;
case "Maths, science, and technology":
$rfctype = "RFCsci";
break;
case "Art, architecture, literature and media":
$rfctype = "RFCart";
break;
case "Politics":
$rfctype = "RFCpol";
break;
case "Religion and philosophy":
$rfctype = "RFCreli";
break;
case "Society, sports, law, and sex":
$rfctype = "RFCsoc";
break;
case "Wikipedia style, referencing, layout and WikiProjects":
$rfctype = "RFCstyle";
break;
case "Wikipedia policies, guidelines and proposals":
$rfctype = "RFCpolicy";
break;
}
$query = "INSERT INTO `u_messedrocker_reqs`.`rfcposter` (`id`, `section`, `reason`, `page`, `user`, `rfctype`) VALUES ('$id', '$section', '$reason', '$page', '$user', '$rfctype')";
$query = mysql_query($query);
echo "<b>You are almost done.</b> Click the \"Go to Wikipedia\" button, where you will be sent to an edit window with your RfC prepared.<br />";
$subject = "Confirm your RFC request";
echo "<form name='middleform' method='post' action='http://en.wikipedia.org/w/index.php?action=submit'>\n";
$msg = "Please confirm that you entered an RFC request for the page $page by visiting this URL: http://toolserver.org/~messedrocker/confirm.php?id=$id\n\nIf you did not enter an RFC request, please disregard this e-mail.";
echo "<input type='hidden' name='title' id='title' value=\"" . $page . "\" />\n";
$objwiki = new wikipedia();
echo "<input type='hidden' name='wpSummary' id='wpSummary' value=\"" . $section . "\" />\n";
$objwiki->login($botuser, $botpass);
echo "<input type='hidden' name='wpTextbox1' id='wpTextbox1' value=\"{{rfctag|" . $rfctype . "}}\n\n" . $reason . "\" />\n";
$objwiki->email($user,$subject,$msg);
echo "<input type='hidden' name='wpSave' id='wpSave' value='' />\n";
echo "<input type='hidden' name='wpSection' id='wpSection' value='new' />\n";
echo "You have been sent an e-mail to confirm your request. Please enter or click on the URL in the e-mail.";
echo "<input type='hidden' name='wpStarttime' id='wpStarttime' value='" . date("YmdHis", time()) . "' />\n";
echo "<input type='submit' name='submit' id='submit' value='Go to Wikipedia' />\n";
echo "</form>";
}
else {
Line 76 ⟶ 63:
}
else {
echo "<form id=\"form1postingtool\" name=\"form1postingtool\" method=\"get\" action=\"postingscriptpostingtool.php\">\n";
echo "<strong>Your username:</strong>\n";
echo "<label>\n";
echo "<input name=\"user\" type=\"text\" id=\"user\" size=\"50\" />\n";
echo "</label>\n";
echo "<em>Do not prefix with \"User:\"<br />\n";
echo "</em>This tool will only work if you are <strong>registered</strong> and you have a <strong>confirmed e-mail address</strong> registered via <a href='http://en.wikipedia.org/wiki/Special:Preferences'>Special:Preferences</a>!<br />\n";
echo "<br />\n";
echo "<strong>Page for RFC discussion: </strong>\n";
echo "<label>\n";
echo "<input name=\"page\" type=\"text\" id=\"page\" value=\"Talk:\" size=\"4340\" />\n";
echo "</label>\n";
echo "<em>Do not forget \"Talk:\" if you are posting to a talk page. Only write the page title, not the full URL.<br />\n";
echo "</em><strong>RFC category:\n";
echo "<select name=\"categoryrfctype\" id=\"categoryrfctype\">\n";
echo "<option selected=\"selected\" value='RFCbio'>Biographies</option>\n";
echo "<option value='Economy, trade, and companiesecon'>Economy, trade, and companies</option>\n";
echo "<option value='History and geographyhist'>History and geography</option>\n";
echo "<option value='Language and linguisticslang'>Language and linguistics</option>\n";
echo "<option value='Maths, science, and technologysci'>Maths, science, and technology</option>\n";
echo "<option value='Art, architecture, literature and mediaart'>Art, architecture, literature, and media</option>\n";
echo "<option value='Politicspol'>Politics, government, and law</option>\n";
echo "<option value='Religion and philosophyreli'>Religion and philosophy</option>\n";
echo "<option value='Society, sports, law, and sexsoc'>Society, sports, law, and sexculture</option>\n";
echo "<option value='Wikipedia style, referencing, layout and WikiProjects'>Wikipedia style, referencing, layout and WikiProjectsnaming</option>\n";
echo "<option value='Wikipedia policies, guidelines and proposalspolicy'>Wikipedia policies, guidelines, and proposalsguidelines</option>\n";
echo "<option value='proj'>WikiProjects and collaborations</option>\n";
echo "<option value='prop'>Wikipedia proposals</option>\n";
echo "</select>\n";
echo "</strong><br />\n";
Line 109 ⟶ 91:
echo "</label>\n";
echo "</strong> <em>This is the name of the new discussion section that will be created<br />\n";
echo "</em><strong>Description:</strong> <em>Keep it short and to the point. OneDon't paragraphforget only;to yousign canwith elaboratefour oncetildes: the RFC is posted.~~~~</em><br />\n";
echo "<input type=\"text\" size=\"80\"textarea name=\"reason\" id=\"reason\" cols=\"70\" rows=\"7\"></textarea>\n";
echo "<label></label>\n";
echo "</strong><br />\n";
Line 121 ⟶ 103:
}
?>
</sourcediv>
<br />
 
<span class="style8">Copyright &copy; 2009 James Hare.
----
</body>
 
</html>
'''confirm.php'''
</syntaxhighlight>
 
<source lang=php>
<?php
ini_set("display_errors", 1);
error_reporting(E_ALL ^ E_NOTICE);
include("./botclasses.php");
 
$sqlpass = "PDp#_dMewp\$AUjNt";
$connect = mysql_connect('sql', $sqluser, $sqlpass);
if (!$connect)
die("Error: database connection failed.");
mysql_select_db($database);
 
 
if (isset($_GET['id'])) {
$id = mysql_real_escape_string($_GET['id']);
$query = "SELECT * FROM rfcposter WHERE id = '" . $id . "';";
$query = mysql_query($query);
if (!$query)
die("Error: Query failed " . mysql_error());
$row = mysql_fetch_assoc($query);
$page = $row['page'];
$user = $row['user'];
$section = $row['section'];
$reason = $row['reason'];
$rfctype = $row['rfctype'];
$rfc = '{{'.$rfctype.' | section='.$section.' !! reason='.$reason.' !! time=~~~~~ }}'."\n";
$objwiki = new wikipedia();
$objwiki->login($botuser, $botpass);
$origpage = $objwiki->getpage($page);
$newpage = $origpage . "\n\n==" . $section . "==\n" . $rfc . "\n\n" . $reason . " &mdash;[[User:$user|" . $user . "]] <small>(via [[User:RFC posting script|posting script]])</small> ~~~~~";
$objwiki->edit($page,$newpage,"Adding RFC on behalf of $user",false,true);
$query = "DELETE FROM rfcposter WHERE id = '$id'";
$query = mysql_query($query);
echo "Your RFC has been posted at <a href='http://en.wikipedia.org/wiki/$page'>$page</a>";
}
else {
echo "id not entered.";
}
?>
</source>