From: <wel...@us...> - 2009-05-17 08:06:14
|
Revision: 3711 http://planeshift.svn.sourceforge.net/planeshift/?rev=3711&view=rev Author: weltall2 Date: 2009-05-17 08:06:09 +0000 (Sun, 17 May 2009) Log Message: ----------- Various fixes and more checks for item use in the database patch by ravna Modified Paths: -------------- www/webconsole-new/crafting/process.php www/webconsole-new/items/listitems.php www/webconsole-new/items/locateitem.php www/webconsole-new/quests/validatequest.php Modified: www/webconsole-new/crafting/process.php =================================================================== --- www/webconsole-new/crafting/process.php 2009-05-17 03:47:04 UTC (rev 3710) +++ www/webconsole-new/crafting/process.php 2009-05-17 08:06:09 UTC (rev 3711) @@ -4,9 +4,8 @@ if (checkaccess('crafting', 'read')) { /* - Notice: skill '0' is sword skill, however, this is the only table that does that, also the database seems to use '0' as - "NONE" as well, so here we have a bug most likely. Currently it does *not* show anything when the ID is '0', so it shows - swords (skill id 0) as no skill too. (although it does have a min/max, so that will in turn cause it to work fine in engine.) + Notice: skill '0' is sword skill, however, this is the only table that does that, I don't believe this is "good", but for now + there is not too much that can be done about it. -1 is "none". */ $query = "SELECT t.process_id, t.subprocess_number, t.name, t.animation, t.render_effect, t.workitem_id, i.name AS workitem_name, i.category_id AS work_cat_id, t.equipment_id, ii.name AS equipment_name, ii.category_id AS equipment_cat_id, t.constraints, t.garbage_id, iii.name AS garbage_name, iii.category_id AS garbage_cat_id, t.garbage_qty, t.primary_skill_id, s.name AS primary_skill_name, t.primary_min_skill, t.primary_max_skill, t.primary_practice_points, t.primary_quality_factor, t.secondary_skill_id, ss.name AS secondary_skill_name, t.secondary_min_skill, t.secondary_max_skill, t.secondary_practice_points, t.secondary_quality_factor, t.description FROM trade_processes as t LEFT JOIN skills AS s ON t.primary_skill_id=s.skill_id LEFT JOIN skills AS ss ON t.secondary_skill_id=ss.skill_id LEFT JOIN item_stats AS i ON i.id=t.workitem_id LEFT JOIN item_stats AS ii ON ii.id=t.equipment_id LEFT JOIN item_stats AS iii ON iii.id=t.garbage_id ORDER BY s.name, t.primary_min_skill, ss.name, t.secondary_min_skill, t.name, t.process_id, t.subprocess_number"; $result = mysql_query2($query); @@ -184,13 +183,11 @@ $garbage_id = ($garbage_id == '' ? 0 : $garbage_id); $garbage_qty = mysql_real_escape_string($_POST['garbage_qty']); $primary_skill_id = mysql_real_escape_string($_POST['primary_skill_id']); - $primary_skill_id = ($primary_skill_id == -1 ? 0 : $primary_skill_id); $primary_min_skill = mysql_real_escape_string($_POST['primary_min_skill']); $primary_max_skill = mysql_real_escape_string($_POST['primary_max_skill']); $primary_practice_points = mysql_real_escape_string($_POST['primary_practice_points']); $primary_quality_factor = mysql_real_escape_string($_POST['primary_quality_factor']); $secondary_skill_id = mysql_real_escape_string($_POST['secondary_skill_id']); - $secondary_skill_id = ($secondary_skill_id == -1 ? 0 : $secondary_skill_id); // change id to 0 if it is not provided by user (-1) $secondary_min_skill = mysql_real_escape_string($_POST['secondary_min_skill']); $secondary_max_skill = mysql_real_escape_string($_POST['secondary_max_skill']); $secondary_practice_points = mysql_real_escape_string($_POST['secondary_practice_points']); @@ -259,13 +256,11 @@ $garbage_id = ($garbage_id == '' ? 0 : $garbage_id); $garbage_qty = mysql_real_escape_string($_POST['garbage_qty']); $primary_skill_id = mysql_real_escape_string($_POST['primary_skill_id']); - $primary_skill_id = ($primary_skill_id == -1 ? 0 : $primary_skill_id); $primary_min_skill = mysql_real_escape_string($_POST['primary_min_skill']); $primary_max_skill = mysql_real_escape_string($_POST['primary_max_skill']); $primary_practice_points = mysql_real_escape_string($_POST['primary_practice_points']); $primary_quality_factor = mysql_real_escape_string($_POST['primary_quality_factor']); $secondary_skill_id = mysql_real_escape_string($_POST['secondary_skill_id']); - $secondary_skill_id = ($secondary_skill_id == -1 ? 0 : $secondary_skill_id); // change id to 0 if it is not provided by user (-1) $secondary_min_skill = mysql_real_escape_string($_POST['secondary_min_skill']); $secondary_max_skill = mysql_real_escape_string($_POST['secondary_max_skill']); $secondary_practice_points = mysql_real_escape_string($_POST['secondary_practice_points']); Modified: www/webconsole-new/items/listitems.php =================================================================== --- www/webconsole-new/items/listitems.php 2009-05-17 03:47:04 UTC (rev 3710) +++ www/webconsole-new/items/listitems.php 2009-05-17 08:06:09 UTC (rev 3711) @@ -459,14 +459,14 @@ echo '<p>No Resources are using this item.</p>'; } - // NPC inventory + // Item instances $query = "SELECT COUNT(id) FROM item_instances WHERE item_stats_id_standard=$id"; $result = mysql_query2($query); $row = mysql_fetch_row($result); if (($num = $row[0]) > 0) { $item_is_used = true; - $button = (checkaccess('items', 'read') ? '<br>Please click the button below if you wish to see a full overview of all instances of this item. <form action="./index.php?do=finditem" method="post"><input type="hidden" name="itemid" value="'.$id.'"><input type="submit" name="search" value="Find Items"/></form>' : ''); + $button = (checkaccess('items', 'read') ? '<br>Please click the button below if you wish to see a full overview of all instances of this item. <form action="./index.php?do=finditem" method="post"><input type="hidden" name="itemid" value="'.$id.'"><input type="submit" name="search" value="Find Items"/> <input type="submit" name="search" value="Find Merchants"/> </form>' : ''); echo '<p> There are '.$num.' instances of this item in the database. '.$button.'</p>'; } else @@ -474,6 +474,30 @@ echo '<p>There are no instances of this item.</p>'; } + // Loot tables + $query = "SELECT DISTINCT lr.name, lrd.loot_rule_id FROM loot_rule_details AS lrd LEFT JOIN loot_rules AS lr ON lr.id=lrd.loot_rule_id WHERE lrd.item_stat_id=$id"; + $result = mysql_query2($query); + if (mysql_num_rows($result) > 0) { + $item_is_used = true; + if (checkaccess('npcs', 'read')) { + echo '<p>The following loot rules use this item: </p>'; + echo '<table border="1">'; + while($row = mysql_fetch_array($result)) + { + echo '<tr><td><a href="./index.php?do=listloot&id='.$row['loot_rule_id'].'">'.$row['name'].'</a></tr></td>'; + } + echo '</table>'; + } + else + { + echo '<p>You do not have permission to view Loot Rules, but they do use this item.</p>'; + } + } + else + { + echo '<p>This item is not in any loot rule.</p>'; + } + // quests // REGEXP queries match case-insensitive. To do this on a "blob" field, we first need to convert the data to a charset. (SQL supports REGEXP on binary data, but it'll become case sensitive, so we don't want that.) // in a regexp, you can make a character group (in our case \n (with an additional \ to escape it in the PHP string)) by placing something between []. Modified: www/webconsole-new/items/locateitem.php =================================================================== --- www/webconsole-new/items/locateitem.php 2009-05-17 03:47:04 UTC (rev 3710) +++ www/webconsole-new/items/locateitem.php 2009-05-17 08:06:09 UTC (rev 3711) @@ -67,6 +67,22 @@ echo '<td>'.$row['flags'].'</td></tr>'."\n"; } echo '</table>'; + }else if ($_POST['search'] == "Find Merchants"){ + $itemid = mysql_real_escape_string($_POST['itemid']); // Don't make "is" "iss" (like it should logically be) since "is" is a reserved keyword in mysql. + $query = "SELECT DISTINCT c.id, c.name, c.lastname, iss.name AS item_name FROM merchant_item_categories AS m LEFT JOIN characters AS c ON c.id=m.player_id LEFT JOIN item_instances AS i ON i.char_id_owner=m.player_id LEFT JOIN item_stats AS iss ON iss.id=i.item_stats_id_standard WHERE i.location_in_parent > '15' AND i.item_stats_id_standard='$itemid' AND iss.category_id=m.category_id ORDER BY iss.name"; + $result = mysql_query2($query); + if (mysql_num_rows($result) == 0) + { + echo '<p class="error">No vendors found for this item.</p>'; + return; + } + $row = mysql_fetch_array($result, MYSQL_ASSOC); + echo '<p class="bold">Displaying vendors for '.$row['item_name'].' </p>'; + echo '<table>'; + do { + echo '<tr><td><a href="./index.php?do=npc_details&sub=main&npc_id='.$row['id'].'">'.$row['name'].' '.$row['lastname'].'</a></td></tr>'; + } while ($row = mysql_fetch_array($result, MYSQL_ASSOC)); + echo '</table>'; } }else{ echo '<form action="./index.php?do=finditem" method="post">'; @@ -75,7 +91,8 @@ echo DrawSelectBox('items', $itemresult, 'itemid', ''). '<input type="submit" name="search" value="Find Items"/><br/>'; echo 'Locate Instance ID: <input type="text" name="iid" /><input type="submit" name="search" value="Find Instance" /><br/>'; $Sectors = PrepSelect('sectorid'); - echo 'Locate All Items on floor (Limit to Sector: '.DrawSelectBox('sectorid', $Sectors, 'sectorid', '', true).') <input type="submit" name="search" value="Droped Items" />'; + echo 'Locate All Items on floor (Limit to Sector: '.DrawSelectBox('sectorid', $Sectors, 'sectorid', '', true).') <input type="submit" name="search" value="Droped Items" /><br/>'; + echo 'Find all vendors of item: '.DrawSelectBox('items', $itemresult, 'itemid', ''). '<input type="submit" name="search" value="Find Merchants"/><br/>'; echo '</form>'; } }else{ Modified: www/webconsole-new/quests/validatequest.php =================================================================== --- www/webconsole-new/quests/validatequest.php 2009-05-17 03:47:04 UTC (rev 3710) +++ www/webconsole-new/quests/validatequest.php 2009-05-17 08:06:09 UTC (rev 3711) @@ -36,7 +36,7 @@ { parseScripts($id, $show_lines); } - append_log('<a href="./index.php?do=editquest&id='.$id.'">Edit this script2</a>'); + append_log('<a href="./index.php?do=editquest&id='.$id.'">Edit this script</a>'); append_log(''); } echo $parse_log; @@ -277,12 +277,16 @@ $pos = 0; while (($pos = stripos($line, $trigger, $pos)) !== false) { - if (strlen($trigger) > 3) //check if this is not some "S:" type NPC shortname, can't check those. + if (strcasecmp($trigger, "menu:") === 0) //if we check a menu trigger, check next ones for exact grammar. { - $trigger_without_colon = substr($trigger, 0, strlen($trigger)-1); // in all other cases, check if the second "menu:" or "name:" has a colon following it. - if (stripos($line, $trigger_without_colon, $pos + strlen($trigger)) !== false) + $trigger_without_colon = substr($trigger, 0, strlen($trigger)-1); //check if the second "menu:" has a colon following it. + if (($temp_pos = stripos($line, $trigger_without_colon, $pos + strlen($trigger))) !== false) { - append_log("Warning, no ':' after '$trigger_without_colon' found on line $line_number, please make sure this is intended."); + $temp_pos2 = stripos($line, $trigger, $pos + strlen($trigger)); + if ($temp_pos != $temp_pos2) // it's only a mismatch if "trigger" and "trigger_without_colon" are not starting at the same place. + { + append_log("Warning, no ':' after '$trigger_without_colon' found on line $line_number, please make sure this is intended."); + } } } $next_pos = stripos($line, $trigger, $pos + strlen($trigger)); //check if there is another one This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |