root/dev/mods/mail_editor/settings.php @ 491

Revision 370, 10.1 KB (checked in by kovell, 11 years ago)

- SQL queries optimised for speed and error protection.
- feed syndication optimised
- front page includes optional clock and optional kill/loss display
- mysqli support added
- transaction protection of kills added where supported (mysqli and InnoDB)
- summary tables and contracts show total destroyed value instead of ship value
- html errors reduced
- related kill calculation improved
- query caching errors reduced
- minor bugfixes
- Smarty 2.6.25 added
- apoc fitting mod added and modded
- code optimisations
- code comments added (doxygen format)
- conflicting mods are now identified

Line 
1<?php
2require_once( "common/admin/admin_menu.php" );
3require_once( "common/includes/class.kill.php" );
4require_once( "common/includes/class.pilot.php");
5require_once( "common/includes/class.corp.php");
6require_once( "common/includes/class.alliance.php");
7require_once( "common/includes/class.ship.php");
8require_once( "common/includes/class.item.php");
9require_once( "common/includes/class.db.php");
10require_once( "helper_functions.php");
11
12define ("ME_VER", "0.9.1");
13
14$page = new Page( "Mail Editor v". ME_VER ." by FriedRoadKill");
15$page->setAdmin();
16$html = ""; //set's the string for easy abuse later
17
18$html .= "<form id=options name=options method=post action=?a=settings_mail_editor>";
19$kiddie = 0;
20
21//top or bottom set of controls used?
22$old_kid = $_POST['hidden_kid'];
23
24if(isset($_POST['enter_0'])) {
25    if(strlen($_POST['kid_0'] > 0))
26        $kiddie = $_POST['kid_0'];
27    $old_kid = $kiddie;
28}
29else if(isset($_POST['enter_1'])) {
30    if(strlen($_POST['kid_1'] > 0))
31        $kiddie = $_POST['kid_1'];
32   $old_kid = $kiddie;
33} else $kiddie = $old_kid;
34
35if(isset($_POST['hidden_date_stamp'])) {
36        if($_POST['hidden_date_stamp'] > $_POST['date_stamp'])
37            $date = $_POST['hidden_date_stamp'];
38        else $date = $_POST['date_stamp'];
39}
40
41//responses and their ilk - there will be boatloads
42if(isset($_POST['kadoef'])) {
43    $errors = "";
44    $hidden = $_POST['hidden_kid']; //lookup hidden children before the ninjas find them!
45
46    if($_POST['date_stamp'])
47        $errors.= setDateTime($_POST['date_stamp'], $hidden);
48
49    if(($_POST['vic_name'] != "") || ($_POST['vic_corp'] != "") || ($_POST['vic_all'] != "")) {
50        $errors .= setVictimEnt($_POST['vic_name'], $_POST['vic_corp'], $_POST['vic_all'],
51            $hidden, $_POST['old_vn'], $_POST['old_vc'], $_POST['old_va'], $date);
52    }
53
54    if($_POST['vic_shp']  != "")
55        $errors .= setVictimShip($_POST['vic_shp'], $hidden);
56
57    if($_POST['system']  != "")
58        $errors .= setSolarSystem($_POST['system'], $hidden);
59
60    if($_POST['vic_dmg']  != "")
61        $errors .= setDamageTaken($_POST['vic_dmg'], $hidden);
62
63    $invc = $_POST['hidden_invc']; //because we want the highest id for 'em
64    if(isset($_POST['hidden_fb'])) {
65        $slot = getFBSlot($_POST['hidden_fb'], $hidden);
66    }
67    else $slot = 0;
68    $i = 0;
69
70    while($i < $invc) {
71        if($_POST['inv_p_'.$i]  != "" || $_POST['inv_c_'.$i]  != "" || $_POST['inv_a_'.$i]  != "") {
72            $errors .= setInvEnt($_POST['inv_p_'.$i], $_POST['inv_c_'.$i], $_POST['inv_a_'.$i],
73                $hidden, $i,$_POST['old_p_'.$i], $_POST['old_c_'.$i], $_POST['old_a_'.$i], $date, $slot);
74        }
75
76        if($_POST['inv_shp_'.$i]  != "")
77            $errors .= setInvShip($_POST['inv_shp_'.$i], $hidden, $i);
78
79        if($_POST['inv_sec_'.$i] != "")
80            $errors .= setInvSec($_POST['inv_sec_'.$i], $hidden, $i);
81
82        if($_POST['inv_w_'.$i] != "")
83            $errors .= setInvWep($_POST['inv_w_'.$i], $hidden, $i);
84
85        if($_POST['inv_d_'.$i] != "")
86            $errors .= setInvDmg($_POST['inv_d_'.$i], $hidden, $i);
87         
88        $i++;
89    }
90    recalcInvData($hidden); //retally which corps and alliances are on a kill - very important
91
92    //items next
93    //destroyed
94    $itmd = $_POST['hidden_destroyed_count'];
95    $i = 0;
96
97    while($i < $itmd) {
98        if($_POST['itm_destroyed'.$i])
99            $errors .= setItm($_POST['itm_destroyed'.$i], $hidden, $i, 'destroyed', $_POST['hidden_itm_destroyed'.$i]);
100           
101        $i++;
102    }
103
104    $itmd = $_POST['hidden_dropped_count'];
105    $i = 0;
106    //dropped items now
107    while($i < $itmd) {
108        if($_POST['itm_dropped'.$i])
109            $errors .= setItm($_POST['itm_dropped'.$i], $hidden, $i, 'dropped', $_POST['hidden_itm_dropped'.$i]);
110
111        $i++;
112    }
113}
114//help thing
115if(isset($_POST['help'])) {
116    $html .= "<table class=\"kb-table\" cellpadding=\"0\" cellspacing=\"1\" border=\"0\" width=\"100%\">";
117    $html .= "<tr class=\"kb-table-header\"><td valign=\"left\" width=\"100%\"><b>Help</b></td></tr>";
118    $html .= "<tr class=\"kb-table-row-even\"><td>";
119    $html .= getHelp();
120    $html .= "</td></tr></table><br/><br/>";
121}
122
123//error drawing thing
124if(strlen($errors) > 0) {
125    $html .= "<table class=\"kb-table\" cellpadding=\"0\" cellspacing=\"1\" border=\"0\" width=\"100%\">";
126    $html .= "<tr class=\"kb-table-header\"><td valign=\"left\" width=\"100%\"><b>Errors</b></td></tr>";
127    $html .= "<tr class=\"kb-table-row-even\"><td>";
128    $html .= $errors;
129    $html .= "</td></tr></table><br/><br/>";
130}
131//form related drawing stuff
132if (is_numeric($kiddie) > 0 || (is_numeric($old_kid) > 0)) {
133    if ($old_kid > 0)
134        $kill = new Kill($old_kid);
135        else $kill = new Kill($kiddie);
136    if (!$kill->exists())
137    {
138        $html .= "That kill doesn't exist.<br/><br/>";
139    }
140    else {
141        //pre header var declaration
142        $ship = $kill->getVictimShip();
143        $system = $kill->getSystem();
144
145        $html .= selectorThinger($kiddie, 0)."<br/><br/>";
146        //header
147        $html .= "<input type=hidden name=hidden_kid value=\"".$kiddie."\">"; //hidden children - hope the ninjas don't find them first!
148        $html .= "<input type=hidden name=hidden_invc value=\"".count($kill->involvedparties_)."\">";
149        $html .= "<input type=hidden name=hidden_fb value=\"".$kill->getFBPilotID()."\">";
150        $html .= "<table class=\"kb-table\" cellpadding=\"0\" cellspacing=\"1\" border=\"0\" width=\"100%\">";
151        $html .= "<tr class=\"kb-table-header\"><td valign=\"left\" width=\"90%\"><b>Mail - Kill #".$kiddie."</b></td><td><b>New Value</b></td></tr>";
152        $html .= "<tr class=\"kb-table-row-even\"><td>".$kill->getTimeStamp()
153            ."</td><td><input type=text name=date_stamp></td><input type=hidden name=hidden_date_stamp value=\""
154            .$kill->getTimeStamp()."\"></td></tr>";
155        $html .= "<tr height=\"18px\"><td></td><td></td></tr>";
156        $html .= "<tr class=\"kb-table-row-even\"><td>Victim: ".$kill->getVictimName()."</td><td><input type=text name=vic_name><input type=hidden name=old_vn value=\"".$kill->getVictimID()."\"></td></tr>";
157        $html .= "<tr class=\"kb-table-row-odd\"><td>Corp: ".$kill->getVictimCorpName()."</td><td><input type=text name=vic_corp><input type=hidden name=old_vc value=\"".$kill->getVictimCorpID()."\"></td></tr>";
158        $html .= "<tr class=\"kb-table-row-even\"><td>Alliance: ".$kill->getVictimAllianceName()."</td><td><input type=text name=vic_all><input type=hidden name=old_va value=\"".$kill->getVictimAllianceID()."\"></td></tr>";
159        $html .= "<tr class=\"kb-table-row-odd\" height=\"18px\"><td>Faction: NONE</td><td></tr>";
160        $html .= "<tr class=\"kb-table-row-even\"><td>Destroyed: ".$ship->getName()."</td><td><input type=text name=vic_shp></td></tr>";
161        $html .= "<tr class=\"kb-table-row-odd\"><td>System: ".$system->getName()."</td><td><input type=text name=system></td></tr>";
162        $html .= "<tr class=\"kb-table-row-even\" height=\"18px\"><td>Security: ".$system->getSecurity(true)."</td><td></td></tr>";
163        $html .= "<tr class=\"kb-table-row-odd\"><td>Damage Taken: ".$kill->VictimDamageTaken."</td><td><input type=text name=vic_dmg></td></tr>";
164        $html .= "<tr height=\"18px\"><td></td><td align=right><input type=submit name=kadoef value=\"Change!\"></td></tr>";
165        $html .= "<tr class=\"kb-table-row-even\" height=\"18px\"><td><b>Involved parties:</b></td><td></td></tr>";
166
167        //involved parties
168        $i = 0;
169        foreach($kill->involvedparties_ as $inv) {
170            //stuff some pre-loaded bras, err, values
171            $pilot = new Pilot($inv->getPilotID());
172            $corp = new Corporation($inv->getCorpID());
173            $all = new Alliance($inv->getAllianceID());
174            $ship = $inv->getShip();
175            $weapon = $inv->getWeapon();
176            $final = $kill->getFBPilotName();
177            $pname = $pilot->getName();
178            $number = $i +1;
179
180            if($pname == $final)
181                $html .= "<tr class=\"kb-table-row-odd\"><td>Name #".$number.": ".$pilot->getName()." (Final Blow)"."</td><td><input type=text name=inv_p_".$i."><input type=hidden name=old_p_".$i." value=\"".$pilot->getID()."\"></td></tr>";
182            else $html .= "<tr class=\"kb-table-row-odd\"><td>Name #".$number.": ".$pilot->getName()."</td><td><input type=text name=inv_p_".$i."><input type=hidden name=old_p_".$i." value=\"".$pilot->getID()."\"></td></tr>";
183            $html .= "<tr class=\"kb-table-row-even\"><td>Security: ".$inv->getSecStatus()."</td><td><input type=text name=inv_sec_".$i."></td></tr>";
184            $html .= "<tr class=\"kb-table-row-odd\"><td>Corp: ".$corp->getName()."</td><td><input type=text name=inv_c_".$i."><input type=hidden name=old_c_".$i." value=\"".$corp->getID()."\"></td></tr>";
185            $html .= "<tr class=\"kb-table-row-even\"><td>Alliance: ".$all->getName()."</td><td><input type=text name=inv_a_".$i."><input type=hidden name=old_a_".$i." value=\"".$all->getID()."\"></td></tr>";
186            $html .= "<tr class=\"kb-table-row-odd\" height=\"18px\"><td>Faction: NONE</td><td></td></tr>";
187            $html .= "<tr class=\"kb-table-row-even\"><td>Ship: ".$ship->getName()."</td><td><input type=text name=inv_shp_".$i."></td></tr>";
188            $html .= "<tr class=\"kb-table-row-odd\"><td>Weapon: ".$weapon->getName()."</td><td><input type=text name=inv_w_".$i."></td></tr>";
189            $html .= "<tr class=\"kb-table-row-even\"><td>Damage done: ".$inv->dmgdone_."</td><td><input type=text name=inv_d_".$i."></td></tr>";
190            $html .= "<tr height=\"18px\"><td></td><td align=right><input type=submit name=kadoef value=\"Change!\"></td></tr>";
191            $i++;
192        }
193        $html .= itemThinger("destroyed", $kiddie);
194        $html .= itemThinger("dropped", $kiddie);
195        $html .= "</table><br/><br/>"; 
196    }
197}
198else {
199    $html .= "You need to enter in digits already!<br/><br/>"; //that means you...
200}
201
202$html .= selectorThinger($kiddie, 1);
203$html .= "</form>";
204$page->setContent( $html );
205$page->addContext( $menubox->generate() );
206$page->generate();
207?>
Note: See TracBrowser for help on using the browser.