Skip to content
Browse files

Merge branch 'mod-comments' of http://github.com/Sessine/Improbable-I…

  • Loading branch information...
2 parents 41285f2 + b5238af commit d29f88555068a2f5e665726e9296fdb415083f5b @CavemanJoe committed
Showing with 385 additions and 421 deletions.
  1. +4 −4 lib/commentary.php
  2. +312 −385 moderate.php
  3. +66 −32 modules/iitems_trader.php
  4. +3 −0 modules/rail_ironhorse.php
View
8 lib/commentary.php
@@ -748,7 +748,7 @@ function viewcommentary($section,$message="Interject your own commentary?",$limi
commentaryfooter($section,$message,$limit,$talkline,$schema);
}
} else {
- debug($rowcount);
+// output("There are no comments in this area.");
}
if (!$skiprecentupdate){
@@ -809,7 +809,7 @@ function commentaryfooter($section,$message="Interject your own commentary?",$li
}
addnav("",$nlink);
- output("`n`n`0Jump to commentary page:");
+ output("`n`n`0Jump to commentary page: ");
for ($i=$val; $i>=0; $i--){
$nlink = buildcommentarylink("&comscroll=".$i."&refresh=1");
$ndisp = 1+$val-$i;
@@ -820,9 +820,9 @@ function commentaryfooter($section,$message="Interject your own commentary?",$li
output_notl("`@$ndisp`0 ",true);
}
}
- output_notl("`n`n");
+ output_notl("`n");
if ($moderating){
- output("`bLast Comment ID shown on this page: %s`b`n",number_format($bottomcid));
+// output("`bLast Comment ID shown on this page: %s`b`n",number_format($bottomcid));
} else {
modulehook("commentaryoptions");
}
View
697 moderate.php 100755 → 100644
@@ -1,13 +1,11 @@
<?php
-// translator ready
-// addnews ready
-// mail ready
+
require_once("common.php");
require_once("lib/commentary.php");
require_once("lib/sanitize.php");
require_once("lib/http.php");
-tlschema("moderate");
+// tlschema("moderate");
addcommentary();
@@ -16,391 +14,320 @@
global $moderating;
$moderating=1;
+page_header("Comment Moderation");
+
+// First, set up the left column navs. These don't change.
require_once("lib/superusernav.php");
superusernav();
-
-page_header("Commentary");
-
-// rawoutput("<form action='moderate.php' method='POST'>");
-// output("View all commentary since:`n");
-// rawoutput("<input name='viewsince' value=\"\" size='46'>");
-// output("`nThis uses php's strtotime function. Enter something in the box above like 'yesterday' or '-10 minutes' or 'last thursday' or '5th june 2010' - PHP will, in most cases, know what to do.`n`n");
-// rawoutput("<input type='submit' class='button' value='Go'>");
-// rawoutput("</form>");
-// addnav("","moderate.php");
-
-addnav("B?Player Bios","bios.php");
-
-addnav("View modes");
-addnav("Separate","moderate.php?viewmode=separate");
-addnav("All","moderate.php?viewmode=all");
-addnav("More and better viewing modes coming soon, guys...","");
-
-$sql = "SELECT DISTINCT section FROM ".db_prefix("commentary")." WHERE section NOT LIKE 'dwelling%' AND section NOT LIKE 'clan%' AND section NOT LIKE 'pet-%'";
-$result = db_query($sql);
-$locations = array();
-addnav("Section-Specific");
-while ($row=db_fetch_assoc($result)){
- $locations[]=$row['section'];
- addnav($row['section'],"moderate.php?viewmode=single&section=".$row['section']);
-}
-
-switch (httpget("viewmode")){
- case "separate":
- foreach($locations AS $key=>$loc){
- output("`b%s`b`n",$loc);
- viewcommentary($loc);
+addnav("B?Player Bios","bios.php");
+
+addnav("Overviews");
+addnav("Recent Comments","moderate.php");
+addnav("Natters","moderate.php?op=bio");
+
+addnav("Lookups");
+addnav("Dwellings","moderate.php?op=dwell");
+addnav("World Map","moderate.php?op=map");
+// addnav("Natters","moderate.php?op=bio");
+
+// Get section and display names from other modules with chat spaces
+$mods = array();
+$mods = modulehook("moderate", $mods);
+reset($mods);
+
+// One of the outposts is "village" and the rest are from race modules
+// Let's get them all into one array.
+$cities = array();
+$vname = getsetting("villagename", LOCATION_FIELDS);
+$cities['village']['auxarea'] = "village-aux";
+$cities['village']['name'] = $vname;
+
+foreach ($mods AS $area=>$name) {
+ // strncmp returns 0 if equal
+ if (!strncmp($name,"City of ", 8)){
+ // move outposts from the $mods array to a $cities array
+ $cities[$area]['auxarea'] = $area . "-aux";
+ $cities[$area]['name'] = substr($name, 8);
+ unset($mods[$area]);
+ }
+}
+reset($mods);
+
+// First get the old names in, the ones that aren't supplied by modules
+$iname = getsetting("innname", LOCATION_INN);
+$locs = array(
+ "gardens" => "Common Ground",
+ "shade" => "Failboat",
+ "inn" => $iname,
+ "hunterlodge" => "Hunter's Lodge",
+ "veterans" => "Veterans Club",
+ "grassyfield" => "Grassy Field",
+ "waiting" => "Clan Hall Waiting Area",
+ "motd" => "Message of the Day",
+);
+if ($session['user']['superuser'] & ~SU_DOESNT_GIVE_GROTTO) {
+ $locs["superuser"] = "Superuser Grotto";
+}
+// Now add in the remaining non-city locations from what's left of the $mods array
+foreach ($mods as $area=>$name) {
+ $locs[$area] = $name;
+}
+reset($locs);
+
+addnav("Outposts");
+foreach ($cities AS $area=>$citydet){
+ addnav(array("%s",$citydet['name']),"moderate.php?op=dual&area=".$area);
+}
+reset($cities);
+
+addnav("Other Locations");
+foreach ($locs as $area=>$name) {
+ addnav($name, "moderate.php?op=sect&area=$area");
+}
+reset($locs);
+
+addnav("Raw View Modes");
+addnav("Separate","moderate.php?op=raw&viewmode=separate");
+addnav("All","moderate.php?op=raw&viewmode=all");
+
+$op = httpget('op');
+switch ($op){
+ case "":
+ foreach ($cities AS $area=>$citydet){
+ output("`b");
+ rawoutput("<a href=\"moderate.php?op=dual&area=$area\">".$citydet['name']."</a>");
+ output("`b`n`0");
+ addnav("","moderate.php?op=dual&area=$area");
+ dualcommentary($area,"X",25);
+ rawoutput("<hr style=\"border-bottom: 1px dotted #333333; border-top: 0; border-left: 0; border-right: 0;\" />");
+ }
+
+ foreach ($locs AS $area=>$name){
+ output("`b");
+ rawoutput("<a href=\"moderate.php?op=sect&area=$area\">".$name."</a>");
+ output("`b`n`0");
+ addnav("","moderate.php?op=sect&area=$area");
+ viewcommentary($area,"X",25);
+ rawoutput("<hr style=\"border-bottom: 1px dotted #333333; border-top: 0; border-left: 0; border-right: 0;\" />");
+ }
+ break;
+
+ case "bio":
+ output("`bNatter Overview`b`n`n");
+ $sql = "SELECT DISTINCT section FROM ".db_prefix("commentary")." WHERE section LIKE 'bio%' ORDER BY section DESC";
+ $result = db_query($sql);
+ $locations = array();
+ while ($row=db_fetch_assoc($result)){
+ $locations[]=$row['section'];
}
- break;
- case "all":
- output("Trying to post to \"all\" is a Bad Idea!`n`n");
- viewcommentary("all");
- break;
- case "technical":
- rawoutput("<form action='moderate.php' method='POST'>");
- output("View all commentary since: ");
- rawoutput("<input name='viewsince' value=\"indifferent\" size='46'> (strtotime field)");
- output("(strtotime field)");
- output("From player: ");
- rawoutput("<input name='author' value=\"indifferent\" size='46'> (player's acctid) <input name='name' value=\"indifferent\" size='46'> (player's name)");
- output("Where section is like: ");
- rawoutput("<input name='section' value=\"indifferent\" size='46'>");
- output("Where the comment contains the word or phrase: ");
- rawoutput("<input name='search' value=\"indifferent\" size='46'>");
- output("And the commentid is greater than: ");
- rawoutput("<input name='commentid' value=\"indifferent\" size='46'>");
- rawoutput("<input type='submit' class='button' value='Go'>");
- rawoutput("</form>");
- addnav("","moderate.php");
- break;
- case "single":
- $sec = httpget("section");
- viewcommentary($sec);
- break;
-}
-
-
-//viewcommentary("all","",100,"says",false,true);
-
-
-
-// if ($session['user']['superuser'] & SU_AUDIT_MODERATION){
- // addnav("Audit Moderation","moderate.php?op=audit");
-// }
-
-// if (httpget('deletecomment')){
- // $del = httpget('deletecomment');
- // $sql = "DELETE FROM ".db_prefix("commentary")." WHERE commentid=$del";
- // db_query($sql);
- // output("Deleted commentid %s",$del);
-// }
-
-// $viewsince = httppost('viewsince');
-// $section = httpget('section');
-// if (!$viewsince){
- // $viewsince = httpget('viewsince');
-// }
-// if ($viewsince){
- // $since = strtotime($viewsince);
- // $since = date("Y-m-d H:i:s",$since);
- // output("Viewing commentary since %s`n`n",$since);
- // if (!$section){
- // $sql = "SELECT * FROM ".db_prefix("commentary")." WHERE postdate > '$since' AND section NOT LIKE 'dwelling%' AND section NOT LIKE 'clan%' AND section NOT LIKE 'pet-%'";
- // } else {
- // $sql = "SELECT * FROM ".db_prefix("commentary")." WHERE postdate > '$since' AND section = '$section'";
- // }
- // $result = db_query($sql);
- // $sections = array();
- // while ($row = db_fetch_assoc($result)){
- // output_notl("%s: [<a href=\"moderate.php?deletecomment=".$row['commentid']."&viewsince=$since\">DEL</a>][".$row['section']."]%s`0: %s`0`n",$row['postdate'],$row['name'],$row['comment'],true);
- // addnav("","moderate.php?deletecomment=".$row['commentid']."&viewsince=$since");
- // $sections[$row['section']]+=1;
- // }
- // $sections = arsort($sections);
- // foreach($sections AS $section => $count){
- // addnav("Filter by Section");
- // addnav(array("%s (%s)",$section,$count),"moderate.php?viewsince=$viewsince&section=$section");
- // }
-// } else {
- // $sql = "SELECT * FROM ".db_prefix("commentary")." WHERE postdate > '$since' AND section NOT LIKE 'dwelling%' AND section NOT LIKE 'clan%' AND section NOT LIKE 'pet-%'";
- // $result = db_query($sql);
- // $sections = array();
- // while ($row = db_fetch_assoc($result)){
- // $sections[$row['section']]+=1;
- // }
- // $sections = arsort($sections);
- // if (count($sections)<2){
- // $sql = "SELECT * FROM ".db_prefix("commentary")." WHERE section NOT LIKE 'dwelling%' AND section NOT LIKE 'clan%' AND section NOT LIKE 'pet-%'";
- // $result = db_query($sql);
- // $sections = array();
- // while ($row = db_fetch_assoc($result)){
- // $sections[$row['section']]+=1;
- // }
- // }
- // foreach($sections AS $section => $count){
- // addnav("Filter by Section");
- // addnav(array("%s (%s)",$section,$count),"moderate.php?viewsince=$viewsince&section=$section");
- // }
-// }
-
-// $op = httpget("op");
-// if ($op=="commentdelete"){
- // $comment = httppost('comment');
- // if (httppost('delnban')>''){
- // $sql = "SELECT DISTINCT uniqueid,author FROM " . db_prefix("commentary") . " INNER JOIN " . db_prefix("accounts") . " ON acctid=author WHERE commentid IN ('" . join("','",array_keys($comment)) . "')";
- // $result = db_query($sql);
- // $untildate = date("Y-m-d H:i:s",strtotime("+3 days"));
- // $reason = httppost("reason");
- // $reason0 = httppost("reason0");
-
- // // *** DRAGONBG.COM CORE PATCH START ***
- // $default = translate_inline("Banned for comments you posted.");
- // // *** DRAGONBG.COM CORE PATCH END ***
-
- // if ($reason0 != $reason && $reason0 != $default) $reason = $reason0;
- // if ($reason=="") $reason = $default;
- // while ($row = db_fetch_assoc($result)){
- // $sql = "SELECT * FROM " . db_prefix("bans") . " WHERE uniqueid = '{$row['uniqueid']}'";
- // $result2 = db_query($sql);
- // $sql = "INSERT INTO " . db_prefix("bans") . " (uniqueid,banexpire,banreason,banner) VALUES ('{$row['uniqueid']}','$untildate','$reason','".addslashes($session['user']['name'])."')";
- // $sql2 = "UPDATE " . db_prefix("accounts") . " SET loggedin=0 WHERE acctid={$row['author']}";
- // if (db_num_rows($result2)>0){
- // $row2 = db_fetch_assoc($result2);
- // if ($row2['banexpire'] < $untildate){
- // //don't enter a new ban if a longer lasting one is
- // //already here.
- // db_query($sql);
- // db_query($sql2);
- // }
- // }else{
- // db_query($sql);
- // db_query($sql2);
- // }
- // }
- // }
- // if (!isset($comment) || !is_array($comment)) $comment = array();
- // $sql = "SELECT " .
- // db_prefix("commentary").".*,".db_prefix("accounts").".name,".
- // db_prefix("accounts").".login, ".db_prefix("accounts").".clanrank,".
- // db_prefix("clans").".clanshort FROM ".db_prefix("commentary").
- // " INNER JOIN ".db_prefix("accounts")." ON ".
- // db_prefix("accounts").".acctid = " . db_prefix("commentary").
- // ".author LEFT JOIN ".db_prefix("clans")." ON ".
- // db_prefix("clans").".clanid=".db_prefix("accounts").
- // ".clanid WHERE commentid IN ('".join("','",array_keys($comment))."')";
- // $result = db_query($sql);
- // $invalsections = array();
- // while ($row = db_fetch_assoc($result)){
- // $sql = "INSERT LOW_PRIORITY INTO ".db_prefix("moderatedcomments").
- // " (moderator,moddate,comment) VALUES ('{$session['user']['acctid']}','".date("Y-m-d H:i:s")."','".addslashes(serialize($row))."')";
- // db_query($sql);
- // $invalsections[$row['section']] = 1;
- // }
- // $sql = "DELETE FROM " . db_prefix("commentary") . " WHERE commentid IN ('" . join("','",array_keys($comment)) . "')";
-
- // db_query($sql);
- // $return = httpget('return');
- // $return = cmd_sanitize($return);
- // $return = substr($return,strrpos($return,"/")+1);
- // if (strpos($return,"?")===false && strpos($return,"&")!==false){
- // $x = strpos($return,"&");
- // $return = substr($return,0,$x-1)."?".substr($return,$x+1);
- // }
- // foreach($invalsections as $key=>$dummy) {
- // invalidatedatacache("comments-$key");
- // }
- // //update moderation cache
-// // *** DRAGONBG.COM CORE PATCH START ***
- // invalidatedatacache("comments-");
-// // *** DRAGONBG.COM CORE PATCH END ***
- // redirect($return);
-// }
-
-// $seen = httpget("seen");
-// if ($seen>""){
- // $session['user']['recentcomments']=$seen;
-// }
-
-// page_header("Comment Moderation");
-
-
-// if ($op=="audit"){
- // $subop = httpget("subop");
- // if ($subop=="undelete") {
- // $unkeys = httppost("mod");
- // if ($unkeys && is_array($unkeys)) {
- // $sql = "SELECT * FROM ".db_prefix("moderatedcomments")." WHERE modid IN ('".join("','",array_keys($unkeys))."')";
- // $result = db_query($sql);
- // while ($row = db_fetch_assoc($result)){
- // $comment = unserialize($row['comment']);
- // $id = addslashes($comment['commentid']);
- // $postdate = addslashes($comment['postdate']);
- // $section = addslashes($comment['section']);
- // $author = addslashes($comment['author']);
- // $comment = addslashes($comment['comment']);
- // $sql = "INSERT LOW_PRIORITY INTO ".db_prefix("commentary")." (commentid,postdate,section,author,comment) VALUES ('$id','$postdate','$section','$author','$comment')";
- // db_query($sql);
- // invalidatedatacache("comments-$section");
- // }
- // $sql = "DELETE FROM ".db_prefix("moderatedcomments")." WHERE modid IN ('".join("','",array_keys($unkeys))."')";
- // db_query($sql);
- // } else {
- // output("No items selected to undelete -- Please try again`n`n");
- // }
- // }
- // $sql = "SELECT DISTINCT acctid, name FROM ".db_prefix("accounts").
- // " INNER JOIN ".db_prefix("moderatedcomments").
- // " ON acctid=moderator ORDER BY name";
- // $result = db_query($sql);
- // addnav("Commentary");
- // addnav("Sections");
- // addnav("Modules");
- // addnav("Clan Halls");
- // addnav("Review by Moderator");
- // tlschema("notranslate");
- // while ($row = db_fetch_assoc($result)){
- // addnav(" ?".$row['name'],"moderate.php?op=audit&moderator={$row['acctid']}");
- // }
- // tlschema();
- // addnav("Commentary");
- // output("`c`bComment Auditing`b`c");
- // $ops = translate_inline("Ops");
- // $mod = translate_inline("Moderator");
- // $when = translate_inline("When");
- // $com = translate_inline("Comment");
- // $unmod = translate_inline("Unmoderate");
- // rawoutput("<form action='moderate.php?op=audit&subop=undelete' method='POST'>");
- // addnav("","moderate.php?op=audit&subop=undelete");
- // rawoutput("<table border='0' cellpadding='2' cellspacing='0'>");
- // rawoutput("<tr class='trhead'><td>$ops</td><td>$mod</td><td>$when</td><td>$com</td></tr>");
- // $limit = "75";
- // $where = "1=1 ";
- // $moderator = httpget("moderator");
- // if ($moderator>"") $where.="AND moderator=$moderator ";
- // $sql = "SELECT name, ".db_prefix("moderatedcomments").
- // ".* FROM ".db_prefix("moderatedcomments")." LEFT JOIN ".
- // db_prefix("accounts").
- // " ON acctid=moderator WHERE $where ORDER BY moddate DESC LIMIT $limit";
- // $result = db_query($sql);
- // $i=0;
-
-// // *** DRAGONBG.COM CORE PATCH START ***
- // $clanrankcolors=array(CLAN_APPLICANT=>"`!",CLAN_MEMBER=>"`#",CLAN_OFFICER=>"`^",CLAN_LEADER=>"`&", CLAN_FOUNDER=>"`\$");
- // $args = modulehook("clanrankcolors", array("clanrankcolors"=>$clanrankcolors, "clanid"=>$session['user']['clanid']));
- // $clanrankcolors = $args['clanrankcolors'];
-// // *** DRAGONBG.COM CORE PATCH END ***
-
- // while ($row = db_fetch_assoc($result)){
- // $i++;
- // rawoutput("<tr class='".($i%2?'trlight':'trdark')."'>");
- // rawoutput("<td><input type='checkbox' name='mod[{$row['modid']}]' value='1'></td>");
- // rawoutput("<td>");
- // output_notl("%s", $row['name']);
- // rawoutput("</td>");
- // rawoutput("<td>");
- // output_notl("%s", $row['moddate']);
- // rawoutput("</td>");
- // rawoutput("<td>");
- // $comment = unserialize($row['comment']);
- // output_notl("`0(%s)", $comment['section']);
-
-// // *** DRAGONBG.COM CORE PATCH START ***
- // if ($comment['clanrank']>0)
- // output_notl("%s<%s%s>`0", $clanrankcolors[$comment['clanrank']],
- // $comment['clanshort'],
- // $clanrankcolors[$comment['clanrank']]);
-// // *** DRAGONBG.COM CORE PATCH END ***
-
- // output_notl("%s", $comment['name']);
- // output_notl("-");
- // output_notl("%s", comment_sanitize($comment['comment']));
- // rawoutput("</td>");
- // rawoutput("</tr>");
- // }
- // rawoutput("</table>");
- // rawoutput("<input type='submit' class='button' value='$unmod'>");
- // rawoutput("</form>");
-// }
-
-
-// addnav("Sections");
-// tlschema("commentary");
-// $vname = getsetting("villagename", LOCATION_FIELDS);
-// addnav(array("%s Square", $vname), "moderate.php?area=village");
-
-// if ($session['user']['superuser'] & ~SU_DOESNT_GIVE_GROTTO) {
- // addnav("Grotto","moderate.php?area=superuser");
-// }
-
-// addnav("Land of the Shades","moderate.php?area=shade");
-// addnav("Grassy Field","moderate.php?area=grassyfield");
-
-// $iname = getsetting("innname", LOCATION_INN);
-// // the inn name is a proper name and shouldn't be translated.
-// tlschema("notranslate");
-// addnav($iname,"moderate.php?area=inn");
-// tlschema();
-
-// addnav("MotD","moderate.php?area=motd");
-// addnav("Veterans Club","moderate.php?area=veterans");
-// addnav("Hunter's Lodge","moderate.php?area=hunterlodge");
-// addnav("Gardens","moderate.php?area=gardens");
-// addnav("Clan Hall Waiting Area","moderate.php?area=waiting");
-
-// if (getsetting("betaperplayer", 1) == 1 && @file_exists("pavilion.php")) {
- // addnav("Beta Pavilion","moderate.php?area=beta");
-// }
-// tlschema();
-
-// if ($session['user']['superuser'] & SU_MODERATE_CLANS){
- // addnav("Clan Halls");
- // $sql = "SELECT clanid,clanname,clanshort FROM " . db_prefix("clans") . " ORDER BY clanid";
- // $result = db_query($sql);
- // // these are proper names and shouldn't be translated.
- // tlschema("notranslate");
- // while ($row=db_fetch_assoc($result)){
- // addnav(array("<%s> %s", $row['clanshort'], $row['clanname']),
- // "moderate.php?area=clan-{$row['clanid']}");
- // }
- // tlschema();
-// } elseif ($session['user']['superuser'] & SU_EDIT_COMMENTS &&
- // getsetting("officermoderate", 0)) {
- // // the CLAN_OFFICER requirement was chosen so that moderators couldn't
- // // just get accepted as a member to any random clan and then proceed to
- // // wreak havoc.
- // // although this isn't really a big deal on most servers, the choice was
- // // made so that staff won't have to have another issue to take into
- // // consideration when choosing moderators. the issue is moot in most
- // // cases, as players that are trusted with moderator powers are also
- // // often trusted with at least the rank of officer in their respective
- // // clans.
- // if (($session['user']['clanid'] != 0) &&
- // ($session['user']['clanrank'] >= CLAN_OFFICER)) {
- // addnav("Clan Halls");
- // $sql = "SELECT clanid,clanname,clanshort FROM " . db_prefix("clans") . " WHERE clanid='" . $session['user']['clanid'] . "'";
- // $result = db_query($sql);
- // // these are proper names and shouldn't be translated.
- // tlschema("notranslate");
- // if ($row=db_fetch_assoc($result)){
- // addnav(array("<%s> %s", $row['clanshort'], $row['clanname']),
- // "moderate.php?area=clan-{$row['clanid']}");
- // } else {
- // debug ("There was an error while trying to access your clan.");
- // }
- // tlschema();
- // }
-// }
-// addnav("Modules");
-// $mods = array();
-// $mods = modulehook("moderate", $mods);
-// reset($mods);
+
+ foreach($locations AS $key=>$loc){
+ $acctid = substr($loc,4);
+ $login = moderate_getlogin($acctid);
+ if ($login == "Unknown"){
+ output("`b%s`b`n",$loc);
+ } else {
+// output("`b%s`0`b`n",$login);
+ $link = "bio.php?char=".$acctid ."&ret=".URLEncode($_SERVER['REQUEST_URI']);
+ output("<a href=\"$link\">`b$login`b`n</a>",true);
+ addnav("",$link);
+ }
+ viewcommentary($loc, "Intervene:", 25);
+ rawoutput("<hr style=\"border-bottom: 1px dotted #333333; border-top: 0; border-left: 0; border-right: 0;\" />");
+ }
+ break;
+
+ case "dwell":
+ output("`bDwellings Lookup`b`n`n");
+ output("Enter map coordinates:`n");
+ rawoutput("<form action='moderate.php?op=listdwell' method='POST'>");
+ // Note: Width 2 means a 2-digit number. Set the default location to 13,11 Improbable Central.
+ rawoutput("X = <input name='mapX' width='2'> , Y = <input name='mapY' width='2'><br/><br/>");
+// rawoutput("X = <input name='mapX' width='2'> , Y = <input name='mapY' width='2'>, Z = <input name='mapZ' width='2' value='1'><br/><br/>");
+ rawoutput("<input type='submit' class='button' value='".translate_inline("List Dwellings")."'>");
+ rawoutput("</form>");
+ addnav("","moderate.php?op=listdwell");
+ break;
+
+ case "listdwell":
+ $x = httppost("mapX");
+ $y = httppost("mapY");
+// $z = httppost("mapZ");
+ $x = ereg_replace("[^0-9]", "", $x);
+ $y = ereg_replace("[^0-9]", "", $y);
+ // make sure they entered values that are in range for the size of the map.
+ $sizeX = get_module_setting("worldmapsizeX","worldmapen");
+ $sizeY = get_module_setting("worldmapsizeY","worldmapen");
+ // Reminder: If/when Z ever becomes a real dimension, this code will need adapting.
+ // Not going to do it now, because... who knows how things will change?
+ if ($x <= 0 || $x > $sizeX || $y <= 0 || $y > $sizeY) {
+ output("`bOff the Map!`b`n`n");
+ output("You entered: x = %s, y = %s.`n", $x, $y);
+ output("Valid map coordinates are: x = 1 to %s, and y = 1 to %s. Please try again.", $sizeX, $sizeY);
+ }else{
+ addnav("","moderate.php?op=dwellmap&x=$x&y=$y");
+ redirect("moderate.php?op=dwellmap&x=$x&y=$y");
+ }
+ break;
+
+ case "dwellchat":
+ require_once "modules/improbablehousing/lib/lib.php";
+ $hid = httpget('hid');
+ $rid = httpget('rid');
+ $x = httpget('x');
+ $y = httpget('y');
+ $room = "dwelling-".$hid."-".$rid;
+ $maploc = $x.",".$y.",1";
+ $house = improbablehousing_gethousedata($hid);
+ $hdg = $house['data']['name'].": ".$house['data']['rooms'][$rid]['name'];
+ output("`b%s`0`n`n", $hdg);
+ rawoutput("<a href=\"moderate.php?op=dwellchat&hid=$hid&rid=$rid&x=$x&y=$y\">".$room."</a>");
+ addnav("","moderate.php?op=dwellchat&hid=$hid&rid=$rid&x=$x&y=$y");
+ rawoutput(" | <a href=\"moderate.php?op=dwellmap&x=$x&y=$y\">");
+ output("Accessible Dwellings at %s",$maploc);
+ rawoutput("</a>");
+ addnav("","moderate.php?op=dwellmap&x=$x&y=$y");
+ output("`b`n");
+ viewcommentary($room,"Intervene:",100);
+ break;
+
+ case "dwellmap":
+ $x = httpget('x');
+ $y = httpget('y');
+ $maploc = $x.",".$y.",1";
+ require_once "modules/improbablehousing/lib/lib.php";
+ global $session;
+ $list = improbablehousing_getnearbyhouses($maploc);
+ $nlist = count($list);
+ output("`bAccessible Dwellings at %s`b`n", $maploc);
+ if ($nlist){
+ for ($i=0; $i<$nlist; $i++){
+ $house = $list[$i];
+ $house = improbablehousing_canenter_house($house);
+ if ($house['canenter']){
+ // assemble dwelling code here
+ $nrooms = count($house['data']['rooms']);
+ if ($nrooms){
+ output("`n%s`0 (owner: %s)`n",$house['data']['name'], moderate_getlogin($house['ownedby']));
+ $hid = $house['id'];
+ foreach ($house['data']['rooms'] AS $rid => $roomdet){
+ if (improbablehousing_canenter_room($house,$rid)){
+ rawoutput("<a href=\"moderate.php?op=dwellchat&hid=$hid&rid=$rid&x=$x&y=$y\">"."[Mod]"."</a>");
+ addnav("","moderate.php?op=dwellchat&hid=$hid&rid=$rid&x=$x&y=$y");
+ output(" %s`n",$roomdet['name']);
+ }
+ }
+ }
+ }
+ }
+ }
+ break;
+
+ case "map";
+ output("`bWorld Map Lookup`b`n`n");
+ output("Enter map coordinates:`n");
+ rawoutput("<form action='moderate.php?op=maplook' method='POST'>");
+ // Note: Width 2 means a 2-digit number. Set the default location to 13,11 Improbable Central.
+ rawoutput("X = <input name='mapX' width='2'> , Y = <input name='mapY' width='2'><br/><br/>");
+// rawoutput("X = <input name='mapX' width='2'> , Y = <input name='mapY' width='2'>, Z = <input name='mapZ' width='2' value='1'><br/><br/>");
+ rawoutput("<input type='submit' class='button' value='".translate_inline("Moderate!")."'>");
+ rawoutput("</form>");
+ addnav("","moderate.php?op=maplook");
+ break;
+
+ case "maplook":
+ $x = httppost("mapX");
+ $y = httppost("mapY");
+// $z = httppost("mapZ");
+ $x = ereg_replace("[^0-9]", "", $x);
+ $y = ereg_replace("[^0-9]", "", $y);
+ // make sure they entered values that are in range for the size of the map.
+ $sizeX = get_module_setting("worldmapsizeX","worldmapen");
+ $sizeY = get_module_setting("worldmapsizeY","worldmapen");
+ // Reminder: If/when Z ever becomes a real dimension, this code will need adapting.
+ // Not going to do it now, because... who knows how things will change?
+ if ($x <= 0 || $x > $sizeX || $y <= 0 || $y > $sizeY) {
+ output("`bOff the Map!`b`n`n");
+ output("You entered: x = %s, y = %s.`n", $x, $y);
+ output("Valid map coordinates are: x = 1 to %s, and y = 1 to %s. Please try again.", $sizeX, $sizeY);
+ }else{
+ $square = "worldmap-".$x.",".$y.",1";
+ addnav("","moderate.php?op=mapreload&area=$square");
+ redirect("moderate.php?op=mapreload&area=$square");
+ }
+ break;
+
+ case "mapreload":
+ $square = httpget('area');
+ output("`b");
+ rawoutput("<a href=\"moderate.php?op=mapreload&area=$square\">".$square."</a>");
+ output("`b`n`0");
+ addnav("","moderate.php?op=mapreload&area=$square");
+ viewcommentary($square,"Intervene:",100);
+ break;
+
+ case "dual":
+ $area = httpget('area');
+ output("`b");
+ rawoutput("<a href=\"moderate.php?op=dual&area=$area\">".$cities[$area]['name']."</a>");
+ output("`b`0");
+ addnav("","moderate.php?op=dual&area=$area");
+// output("`b%s`b", $cities[$area]['name']);
+ dualcommentary($area,"Intervene:",100);
+ break;
+
+ case "sect":
+ $area = httpget('area');
+ $locname = (isset($locs[$area]) ? $locs[$area] : $cities[$area]['name']);
+ output("`b");
+ rawoutput("<a href=\"moderate.php?op=sect&area=$area\">".$locname."</a>");
+ output("`b`n`0");
+ addnav("","moderate.php?op=sect&area=$area");
+ viewcommentary($area,"Intervene:",100);
+ break;
+
+ case "raw":
+ $viewmode = httpget('viewmode');
+// output("Raw mode '%s':`n", $viewmode);
+
+ switch ($viewmode){
+ case "separate":
+ output("`bBy Section Name`b`n`n");
+ $sql = "SELECT DISTINCT section FROM ".db_prefix("commentary")." WHERE section NOT LIKE 'dwelling%' AND section NOT LIKE 'bio%' AND section NOT LIKE 'clan%' AND section NOT LIKE 'pet-%'";
+ $result = db_query($sql);
+ $locations = array();
+ while ($row=db_fetch_assoc($result)){
+ $locations[]=$row['section'];
+ }
+
+ foreach($locations AS $key=>$loc){
+ output("`b%s`b`n",$loc);
+ viewcommentary($loc, "Intervene:", 25);
+ rawoutput("<hr style=\"border-bottom: 1px dotted #333333; border-top: 0; border-left: 0; border-right: 0;\" />");
+ }
+ break;
+
+ case "all";
+ output("`bAll Comments`b`n");
+ viewcommentary("all", "X", 200);
+ break;
+ }
+ break;
+}
+
+function moderate_getlogin($acctid){
+ $sql = "SELECT login FROM " . db_prefix("accounts") . " WHERE acctid = " . $acctid;
+ $searchresult = db_query($sql);
+ if (db_num_rows($searchresult) != 1) {
+ $login = "Unknown";
+ } else {
+ $i=0;
+ $row=db_fetch_assoc($searchresult);
+ $login = $row['login'];
+ }
+ return $login;
+}
-// // These are already translated in the module.
-// tlschema("notranslate");
-// foreach ($mods as $area=>$name) {
- // addnav($name, "moderate.php?area=$area");
-// }
-// tlschema();
page_footer();
?>
View
98 modules/iitems_trader.php
@@ -3,12 +3,13 @@
function iitems_trader_getmoduleinfo(){
$info=array(
"name"=>"IItems - Player Trading",
- "version"=>"2010-06-17",
+ "version"=>"2010-09-24",
"author"=>"Sylvia Li",
"category"=>"IItems",
"download"=>"",
"prefs"=>array(
"hastraded"=>"User has performed at least one trade,int|0",
+ "shuffle"=>"Current item display sequence,int|1",
),
);
return $info;
@@ -16,7 +17,6 @@ function iitems_trader_getmoduleinfo(){
function iitems_trader_install(){
module_addhook("biostat");
- module_addhook("iitems-give-item");
return true;
}
@@ -24,6 +24,45 @@ function iitems_trader_uninstall(){
return true;
}
+function itemcompare($a, $b){
+ return -strnatcmp($a['item'], $b['item']);
+}
+
+function qtyitemcompare($a, $b){
+ return strnatcmp($a['quantity'].$a['item'], $b['quantity'].$b['item']);
+}
+
+function get_tradables(){
+ global $inventory;
+ if (!isset($inventory)){
+ load_inventory();
+ }
+ $sortorder = get_module_pref('shuffle');
+// debug($sortorder);
+ $tradables = array();
+ $found = false;
+ $itemsheld = group_items($inventory);
+ foreach ($itemsheld AS $key => $itemdetails){
+ if (isset($itemdetails['tradable'])){
+ $tradables[] = $itemdetails;
+ $found = true;
+ }
+ }
+ if ($found){
+ switch ($sortorder){
+ case 0:
+ usort($tradables,'itemcompare');
+ break;
+ case 1:
+ usort($tradables,'qtyitemcompare');
+ break;
+ }
+ return $tradables;
+ } else {
+ return false;
+ }
+}
+
function iitems_trader_dohook($hookname,$args){
global $session;
// global $module_prefs;
@@ -31,10 +70,10 @@ function iitems_trader_dohook($hookname,$args){
case "biostat":
$id = $args['acctid'];
$ret = rawurlencode($args['return_link']);
- require_once "modules/iitems/lib/lib.php";
- $tradables = iitems_has_property("tradable",true,true,false,false,"all");
+ $tradables = get_tradables();
if (is_array($tradables)){
if ($id <> $session['user']['acctid']){
+ // do a simple alt-check
$sql = "SELECT uniqueid FROM ".db_prefix('accounts')." WHERE acctid = ".$id;
$result = db_query($sql);
$altcheck = db_fetch_assoc($result);
@@ -51,24 +90,19 @@ function iitems_trader_dohook($hookname,$args){
addnav("Recent Trade History","runmodule.php?module=iitems_trader&op=history&id=$id&ret=$ret");
}
break;
- case "iitems-give-item":
- if(isset($args['master']['feature'])){
- $args['player']['feature'] = $args['master']['feature'];
- }
- break;
} //end $hookname switch
return $args;
}
function iitems_trader_run(){
global $session;
- global $module_prefs;
- require_once "modules/iitems/lib/lib.php";
+// global $module_prefs;
$op = httpget('op');
$id = httpget('id');
$ret = httpget('ret');
$return = rawurlencode($ret);
- $tradables = iitems_has_property("tradable",true,true,false,false,"all");
+ $tradables = get_tradables();
+ // debug($tradables);
$sql = "SELECT uniqueid, acctid, name, sex FROM ".db_prefix('accounts')." WHERE acctid = ".$id;
$result = db_query($sql);
$tradewith = db_fetch_assoc($result);
@@ -108,6 +142,8 @@ function iitems_trader_run(){
$cantrade = false;
break;
case 1:
+ // I know, this isn't quite accurate. Should be 'one type of item' -
+ // but that's programmer-speak. Let's stick to English as much as we can.
$phrase = "one item";
break;
default:
@@ -128,7 +164,7 @@ function iitems_trader_run(){
}
$phrase .= $hookargs['specialdesc'];
}
- output("Searching through your possessions, you find you have %s you could give to %s.`n`n",$phrase,$bioname);
+ output("Searching through your possessions, you find you have %s you could trade to %s.`n`n",$phrase,$bioname);
// debug($tradables);
if ($cantrade){
addnav("Trade");
@@ -139,23 +175,18 @@ function iitems_trader_run(){
}
break;
case "tradewarn":
- $item = httpget('item');
+ $tradableskey = httpget('item');
if (!get_module_pref('hastraded')){
- output("Ah, so you're interested in trading your `b%s`b to someone. All right, that could be a very good move, but listen. You only get to control your own actions. What other people do is up to them. Either... make sure you've agreed on the trade beforehand and `b%s`b is someone you trust to give you whatever you're trading this item for... or think of yourself as a kind philanthropist who's generously giving things away.`n`nNo, seriously. Trading is between you and the other person. Talk to %s, negotiate with %s, haggle with %s, conclude the deal. If %s doesn't deliver the goods this time, hey, you'll know who %s is. You don't have to deal with %s again. The admin and game mods are not police and `iwill not`i intervene, so don't even ask.`n`nWith that obligatory warning out of the way...`0`n`n",$tradables[$item]['verbosename'],$bioname, $obj,$obj,$obj,$subj,$subj,$obj);
+ output("Ah, so you're interested in trading your `b%s`b to someone. All right, that could be a very good move, but listen. You only get to control your own actions. What other people do is up to them. Either... make sure you've agreed on the trade beforehand and `b%s`b is someone you trust to give you whatever you're trading this item for... or think of yourself as a kind philanthropist who's generously giving things away.`n`nNo, seriously. Trading is between you and the other person. Talk to %s, negotiate with %s, haggle with %s, conclude the deal. If %s doesn't deliver the goods this time, hey, you'll know who %s is. You don't have to deal with %s again. The admin and game mods are not police and `iwill not`i intervene, so don't even ask.`n`nWith that obligatory warning out of the way...`0`n`n",$tradables[$tradableskey]['verbosename'],$bioname, $obj,$obj,$obj,$subj,$subj,$obj);
}
- output("You're quite sure you want to trade your %s to %s?`n`n",$tradables[$item]['verbosename'],$bioname);
+ output("You're quite sure you want to trade your %s to %s?`n`n",$tradables[$tradableskey]['verbosename'],$bioname);
addnav("Trade");
- addnav("Yes, do it!","runmodule.php?module=iitems_trader&op=tradefinal&id=$id&item=$item&ret=$return");
+ addnav("Yes, do it!","runmodule.php?module=iitems_trader&op=tradefinal&id=$id&item=$tradableskey&ret=$return");
addnav("Wait, no, not that...","runmodule.php?module=iitems_trader&op=trade&id=$id&ret=$return");
break;
case "tradefinal":
- $item = httpget('item');
- $inventory = iitems_get_player_inventory();
- foreach($inventory AS $ikey => $details){
- if ($details['itemid'] == $tradables[$item]['itemid']){
- $itemkey = $ikey;
- }
- }
+ $tradableskey = httpget('item');
+ $itemid = $tradables[$tradableskey]['itemid'];
// This hook is to allow special handling of the transfer for collectibles that need to get fancy.
// (Example - marbles.) When using this hook, you'll have to:
@@ -167,19 +198,21 @@ function iitems_trader_run(){
$hookargs['specialhandling'] = 0;
// debug("before iitems_tradables-final hook:");
// debug($hookargs);
- $hookargs = modulehook("iitems_tradable-final",$hookargs);
+ $hookargs = modulehook("iitems_tradables-final",$hookargs);
// debug("after iitems_tradables-final hook:");
// debug($hookargs);
$tradables = $hookargs['tradables'];
if (!isset($hookargs['specialdesc'])){
- iitems_give_item($tradables[$item]['itemid'],$id);
- debug($itemkey);
- debug($inventory);
- iitems_discard_item($itemkey);
- $message = $tradables[$item]['feature'].": ".$tradables[$item]['itemid']." (".$tradables[$item]['verbosename'].") to ".$bioname.".";
+ change_item_owner($itemid,$id);
+ $message = $tradables[$tradableskey]['feature'].": ".$tradables[$tradableskey]['itemid']." (".$tradables[$tradableskey]['verbosename'].") to ".$bioname.".";
debuglog($message,$id,false,"trade");
- output("Mission accomplished! %s now has your %s.",$bioname,$tradables[$item]['verbosename']);
+ output("Mission accomplished! %s now has your %s.",$bioname,$tradables[$tradableskey]['verbosename']);
+ // send a distraction to tell the other player what they just received.
+ require_once "lib/systemmail.php";
+ $subj = $tradables[$tradableskey]['verbosename']." for your collection";
+ $body = $session['user']['name']." has just traded you a valuable ".$tradables[$tradableskey]['verbosename']."! Awesome!";
+ systemmail($id,$subj,$body);
}
set_module_pref("hastraded",1);
break;
@@ -251,4 +284,5 @@ function iitems_trader_run(){
page_footer();
return true;
}
-?>
+
+?>
View
3 modules/rail_ironhorse.php
@@ -236,6 +236,9 @@ function rail_ironhorse_run(){
page_header("First Class has its privileges!");
$x = httppost("stopX");
$y = httppost("stopY");
+ // strip out any non-numeric characters that got entered by mistake
+ $x = ereg_replace("[^0-9]", "", $x);
+ $y = ereg_replace("[^0-9]", "", $y);
// make sure they entered values that are in range for the size of the map.
$sizeX = get_module_setting("worldmapsizeX","worldmapen");
$sizeY = get_module_setting("worldmapsizeY","worldmapen");

0 comments on commit d29f885

Please sign in to comment.
Something went wrong with that request. Please try again.