- Timestamp:
- 11/25/06 16:31:50 (14 years ago)
- Location:
- dev
- Files:
-
- 6 added
- 8 modified
Legend:
- Unmodified
- Added
- Removed
-
dev/common/admin_audit.php
r60 r91 1 <? 2 require_once( "class.page.php");3 require_once( "db.php");4 require_once( "admin_menu.php");1 <?php 2 require_once("class.page.php"); 3 require_once("db.php"); 4 require_once("admin_menu.php"); 5 5 6 $page = new Page( "Administration - Audit log");7 8 9 6 $page = new Page("Administration - Audit log"); 7 $page->setAdmin(); 8 9 $sql = "SELECT log_kll_id, log_ip_address, log_timestamp, kll_timestamp, plt_name 10 10 FROM kb3_log log, kb3_kills kll, kb3_pilots plt 11 11 WHERE log.log_kll_id = kll.kll_id … … 13 13 ORDER BY log_timestamp DESC limit 250"; 14 14 15 15 $dbconn = new DBConnection(); 16 16 17 18 $qry->execute( $sql ) or die( $qry->getErrorMsg());17 $qry = new DBQuery(); 18 $qry->execute($sql) or die($qry->getErrorMsg()); 19 19 20 $html .= "<table class=sortable id=audit>"; 21 $html .= "<tr class=kb-table-header><td align=center width=60>ID</td><td width=150>Killmail date</td><td width=150>Posted</td><td width=120>IP Address</td><td width=150>Final Blow</td></tr>"; 22 $odd = false; 23 while ( $row = $qry->getRow() ) { 24 if ( $odd ) { 25 $class = "kb-table-row-even"; 26 $odd = false; 27 } else { 28 $class = "kb-table-row-odd"; 29 $odd = true; 20 $html .= '<table class="kb-table">'; 21 $html .= "<tr class=kb-table-header><td align=center width=60>ID</td><td width=150>Killmail date</td><td width=150>Posted</td><td width=120>IP Address</td><td width=150>Final Blow</td></tr>"; 22 $odd = false; 23 while ($row = $qry->getRow()) 24 { 25 if ($odd) 26 { 27 $class = "kb-table-row-even"; 28 $odd = false; 30 29 } 31 $html .= "<tr class=".$class." onmouseover=\"this.className='kb-table-row-hover';\" onmouseout=\"this.className='".$class."';\" onClick=\"window.location.href='?a=kill_detail&kll_id=".$row['log_kll_id']."';\">"; 32 $html .= "<td align=center><b>".$row['log_kll_id']."</b></td>"; 33 $html .= "<td>".$row['kll_timestamp']."</td>"; 34 $html .= "<td>".$row['log_timestamp']."</td>"; 35 $html .= "<td>".$row['log_ip_address']."</td>"; 36 $html .= "<td>".$row['plt_name']."</td>"; 30 else 31 { 32 $class = "kb-table-row-odd"; 33 $odd = true; 34 } 35 $html .= "<tr class=" . $class . " onmouseover=\"this.className='kb-table-row-hover';\" onmouseout=\"this.className='" . $class . "';\" onClick=\"window.location.href='?a=kill_detail&kll_id=" . $row['log_kll_id'] . "';\">"; 36 $html .= "<td align=center><b>" . $row['log_kll_id'] . "</b></td>"; 37 $html .= "<td>" . $row['kll_timestamp'] . "</td>"; 38 $html .= "<td>" . $row['log_timestamp'] . "</td>"; 39 $html .= "<td>" . $row['log_ip_address'] . "</td>"; 40 $html .= "<td>" . $row['plt_name'] . "</td>"; 37 41 $html .= "</tr>"; 38 39 42 } 43 $html .= "</table>"; 40 44 41 $page->addContext( $menubox->generate());42 $page->setContent( $html);43 45 $page->addContext($menubox->generate()); 46 $page->setContent($html); 47 $page->generate(); 44 48 45 46 49 ?> -
dev/common/admin_cc.php
r43 r91 32 32 { 33 33 $html .= "<tr class=kb-table-row-odd>"; 34 $html .= "<td class=kb-table-cell>" . $contract->getName() ."</td>";35 $html .= "<td class=kb-table-cell>" . substr($contract->getStartDate(), 0, 10) ."</td>";36 $html .= "<td class=kb-table-cell>" . substr($contract->getEndDate(), 0, 10) ."</td>";37 $html .= "<td class=kb-table-cell align=center width=70><a href=\"?a=admin_cc&ctr_id=" . $contract->getID() . "&op=edit&type=" . $type . "\">Edit</a></td><td align=center><a href=\"?a=admin_cc&ctr_id=" . $contract->getID() . "&op=del&type=" . $type ."\">Delete</a></td>";34 $html .= "<td class=kb-table-cell>".$contract->getName()."</td>"; 35 $html .= "<td class=kb-table-cell>".substr($contract->getStartDate(), 0, 10)."</td>"; 36 $html .= "<td class=kb-table-cell>".substr($contract->getEndDate(), 0, 10)."</td>"; 37 $html .= "<td class=kb-table-cell align=center width=70><a href=\"?a=admin_cc&ctr_id=".$contract->getID()."&op=edit&type=".$type."\">Edit</a></td><td align=center><a href=\"?a=admin_cc&ctr_id=".$contract->getID()."&op=del&type=".$type."\">Delete</a></td>"; 38 38 $html .= "</tr>"; 39 39 } 40 40 if ($list->getCount() > 0) 41 41 $html .= "</table><br>"; 42 $html .= "[<a href=\"?a=admin_cc&op=add&type=" . $type . "\">Add " . $type ."</a>]";42 $html .= "[<a href=\"?a=admin_cc&op=add&type=".$type."\">Add ".$type."</a>]"; 43 43 } 44 44 // delete … … 51 51 $contract->remove(); 52 52 53 Header("Location: ?a=admin_cc&op=view&type=" .$_GET['type']);53 Header("Location: ?a=admin_cc&op=view&type=".$_GET['type']); 54 54 } 55 55 else 56 56 { 57 $page->setTitle("Administration - Delete " .$_GET['type']);57 $page->setTitle("Administration - Delete ".$_GET['type']); 58 58 $html .= "Confirm deletion: "; 59 $html .= "<button onClick=\"window.location.href='?a=admin_cc&ctr_id=" . $_GET['ctr_id'] . "&op=del&type=" . $_GET['type'] ."&confirm=yes'\">Yes</button> ";59 $html .= "<button onClick=\"window.location.href='?a=admin_cc&ctr_id=".$_GET['ctr_id']."&op=del&type=".$_GET['type']."&confirm=yes'\">Yes</button> "; 60 60 $html .= "<button onClick=\"window.history.back();\">No</button>"; 61 61 } … … 71 71 $_POST['ctr_started'], $_POST['ctr_ended']); 72 72 73 Header("Location: ?a=admin_cc&op=view&type=" .$_GET['type']);73 Header("Location: ?a=admin_cc&op=view&type=".$_GET['type']); 74 74 } 75 75 … … 88 88 $reg_id = $id; 89 89 break; 90 } 91 $contracttarget = new ContractTarget($contract, $crp_id, 92 $all_id, $reg_id); 90 case "del_system": 91 $sys_id = $id; 92 break; 93 } 94 $contracttarget = new ContractTarget($contract, $crp_id, $all_id, $reg_id, $sys_id); 93 95 $contracttarget->remove(); 94 96 95 Header("Location: ?a=admin_cc&ctr_id=" . $_GET['ctr_id'] . "&op=edit&type=" .$_GET['type']);97 header("Location: ?a=admin_cc&ctr_id=".$_GET['ctr_id']."&op=edit&type=".$_GET['type']); 96 98 } 97 99 … … 110 112 $reg_id = $id; 111 113 break; 112 } 113 $contracttarget = new ContractTarget($contract, $crp_id, 114 $all_id, $reg_id); 114 case 3: 115 $sys_id = $id; 116 break; 117 } 118 $contracttarget = new ContractTarget($contract, $crp_id, $all_id, $reg_id, $sys_id); 115 119 $contracttarget->add(); 116 120 117 Header("Location: ?a=admin_cc&ctr_id=" . $_GET['ctr_id'] . "&op=edit&type=" .$_GET['type']);121 header("Location: ?a=admin_cc&ctr_id=".$_GET['ctr_id']."&op=edit&type=".$_GET['type']); 118 122 } 119 123 if ($_POST['add_name']) … … 129 133 $sql = "select crp.crp_id as id, crp.crp_name as name 130 134 from kb3_corps crp 131 where lower( crp.crp_name ) like '%" . strtolower($_POST['add_name']) ."%'";135 where lower( crp.crp_name ) like '%".strtolower($_POST['add_name'])."%'"; 132 136 break; 133 137 case 1: 134 138 $sql = "select ali.all_id as id, ali.all_name as name 135 139 from kb3_alliances ali 136 where lower( ali.all_name ) like '%" . strtolower($_POST['add_name']) ."%'";140 where lower( ali.all_name ) like '%".strtolower($_POST['add_name'])."%'"; 137 141 break; 138 142 case 2: 139 143 $sql = "select reg_id as id, reg_name as name 140 144 from kb3_regions 141 where lower( reg_name ) like '%" . strtolower($_POST['add_name']) . "%'"; 145 where lower( reg_name ) like '%".strtolower($_POST['add_name'])."%'"; 146 break; 147 case 3: 148 $sql = "select sys_id as id, sys_name as name 149 from kb3_systems 150 where lower( sys_name ) like '%".strtolower($_POST['add_name'])."%'"; 142 151 break; 143 152 } … … 152 161 } 153 162 else 154 $html .= "No matches found for '" . $_POST['add_name'] ."'.";163 $html .= "No matches found for '".$_POST['add_name']."'."; 155 164 156 165 while ($row = $qry->getRow()) … … 160 169 { 161 170 case 0: 162 $html .= "<td><a href=\"?a=corp_detail&crp_id=" . $row['id'] . "\">" . $row['name'] . "</a></td><td align=center><button id=submit name=submit onClick=\"window.location.href='?a=admin_cc&ctr_id=" . $_GET['ctr_id'] . "&op=edit&type=" . $_GET['type'] . "&add_type=" . $_POST['add_type'] . "&add_id=" . $row['id'] ."'\">Select</button></td>";171 $html .= "<td><a href=\"?a=corp_detail&crp_id=".$row['id']."\">".$row['name']."</a></td><td align=center><button id=submit name=submit onClick=\"window.location.href='?a=admin_cc&ctr_id=".$_GET['ctr_id']."&op=edit&type=".$_GET['type']."&add_type=".$_POST['add_type']."&add_id=".$row['id']."'\">Select</button></td>"; 163 172 break; 164 173 case 1: 165 $html .= "<td><a href=\"?a=alliance_detail&all_id=" . $row['id'] . "\">" . $row['name'] . "</a></td><td align=center><button id=submit name=submit onClick=\"window.location.href='?a=admin_cc&ctr_id=" . $_GET['ctr_id'] . "&op=edit&type=" . $_GET['type'] . "&add_type=" . $_POST['add_type'] . "&add_id=" . $row['id'] ."'\">Select</button></td>";174 $html .= "<td><a href=\"?a=alliance_detail&all_id=".$row['id']."\">".$row['name']."</a></td><td align=center><button id=submit name=submit onClick=\"window.location.href='?a=admin_cc&ctr_id=".$_GET['ctr_id']."&op=edit&type=".$_GET['type']."&add_type=".$_POST['add_type']."&add_id=".$row['id']."'\">Select</button></td>"; 166 175 break; 167 176 case 2: 168 $html .= "<td>" . $row['name'] . "</td><td align=center><button id=submit name=submit onClick=\"window.location.href='?a=admin_cc&ctr_id=" . $_GET['ctr_id'] . "&op=edit&type=" . $_GET['type'] . "&add_type=" . $_POST['add_type'] . "&add_id=" . $row['id'] . "'\">Select</button></td>"; 177 $html .= "<td>".$row['name']."</td><td align=center><button id=submit name=submit onClick=\"window.location.href='?a=admin_cc&ctr_id=".$_GET['ctr_id']."&op=edit&type=".$_GET['type']."&add_type=".$_POST['add_type']."&add_id=".$row['id']."'\">Select</button></td>"; 178 break; 179 case 3: 180 $html .= "<td>".$row['name']."</td><td align=center><button id=submit name=submit onClick=\"window.location.href='?a=admin_cc&ctr_id=".$_GET['ctr_id']."&op=edit&type=".$_GET['type']."&add_type=".$_POST['add_type']."&add_id=".$row['id']."'\">Select</button></td>"; 169 181 break; 170 182 } … … 177 189 else 178 190 { 179 $page->setTitle("Administration - Edit " .$_GET['type']);191 $page->setTitle("Administration - Edit ".$_GET['type']); 180 192 181 193 $contract = new Contract($_GET['ctr_id']); … … 183 195 $html .= "<div class=block-header2>Details</div>"; 184 196 185 $html .= "<form id=detail_edit name=detail_edit method=post action=?a=admin_cc&ctr_id=" . $_GET['ctr_id'] . "&op=edit&type=" . $_GET['type'] .">";197 $html .= "<form id=detail_edit name=detail_edit method=post action=?a=admin_cc&ctr_id=".$_GET['ctr_id']."&op=edit&type=".$_GET['type'].">"; 186 198 $html .= "<table class=kb-subtable width=98%>"; 187 199 188 $html .= "<tr><td width=80><b>Name:</b></td><td><input type=text name=ctr_name id=ctr_name size=38 maxlength=38 value=\"" . $contract->getName() ."\"></td></tr>";189 $html .= "<tr><td width=80><b>Start date:</b></td><td><input type=text name=ctr_started id=ctr_started size=10 maxlength=10 value=\"" . substr($contract->getStartDate(), 0, 10) ."\"> (yyyy-mm-dd)</td></tr>";190 $html .= "<tr><td width-80><b>End date:</b></td><td><input type=text name=ctr_ended id=ctr_ended size=10 maxlength=10 value=\"" . substr($contract->getEndDate(), 0, 10) ."\"> (yyyy-mm-dd or blank)</td></tr>";200 $html .= "<tr><td width=80><b>Name:</b></td><td><input type=text name=ctr_name id=ctr_name size=38 maxlength=38 value=\"".$contract->getName()."\"></td></tr>"; 201 $html .= "<tr><td width=80><b>Start date:</b></td><td><input type=text name=ctr_started id=ctr_started size=10 maxlength=10 value=\"".substr($contract->getStartDate(), 0, 10)."\"> (yyyy-mm-dd)</td></tr>"; 202 $html .= "<tr><td width-80><b>End date:</b></td><td><input type=text name=ctr_ended id=ctr_ended size=10 maxlength=10 value=\"".substr($contract->getEndDate(), 0, 10)."\"> (yyyy-mm-dd or blank)</td></tr>"; 191 203 $html .= "<tr><td></td></tr>"; 192 204 $html .= "<tr><td></td><td><input type=submit name=detail_submit value=\"Save\"></td></tr>"; … … 198 210 199 211 $html .= "<table class=kb-table cellspacing=1>"; 200 $html .= "<tr class=kb-table-header><td class=kb-table-cell width=160>Target</td><td class=kb-table-cell width=80 align=center>Corporation</td><td class=kb-table-cell width=80 align=center>Alliance</td><td class=kb-table-cell width=80 align=center>Region</td><td class=kb-table-cell width=80 align=center> Action</td><td</tr>";212 $html .= "<tr class=kb-table-header><td class=kb-table-cell width=160>Target</td><td class=kb-table-cell width=80 align=center>Corporation</td><td class=kb-table-cell width=80 align=center>Alliance</td><td class=kb-table-cell width=80 align=center>Region</td><td class=kb-table-cell width=80 align=center>System</td><td class=kb-table-cell width=80 align=center>Action</td></tr>"; 201 213 202 214 $c = 0; … … 220 232 $name = $region->getName(); 221 233 } 222 223 $html .= "<tr class=kb-table-row-odd><td class=kb-table-cell><b>" . $name . "</b></td><td class=kb-table-cell align=center>"; 234 if ($type == "system") 235 { 236 $system = new SolarSystem($contracttarget->getID()); 237 $name = $system->getName(); 238 } 239 240 $html .= "<tr class=kb-table-row-odd><td class=kb-table-cell><b>".$name."</b></td><td class=kb-table-cell align=center>"; 224 241 if ($type == "corp") 225 242 $html .= "x"; … … 230 247 if ($type == "region") 231 248 $html .= "x"; 249 $html .= "</td><td class=kb-table-cell align=center>"; 250 if ($type == "system") 251 $html .= "x"; 232 252 $html .= "</td>"; 233 253 234 $html .= "<td align=center><a href=\"?a=admin_cc&ctr_id=" . $_GET['ctr_id'] . "&op=edit&type=" . $_GET['type'] . "&sop=del_" . $type . "&id=" . $contracttarget->getID() ."\">delete</a></td></tr>";254 $html .= "<td align=center><a href=\"?a=admin_cc&ctr_id=".$_GET['ctr_id']."&op=edit&type=".$_GET['type']."&sop=del_".$type."&id=".$contracttarget->getID()."\">delete</a></td></tr>"; 235 255 } 236 256 237 257 if ($c < 30) 238 258 { 239 $html .= "<form id=add_target name=add_target method=post action=?a=admin_cc&ctr_id=" . $_GET['ctr_id'] . "&op=edit&type=" . $_GET['type'] .">";259 $html .= "<form id=add_target name=add_target method=post action=?a=admin_cc&ctr_id=".$_GET['ctr_id']."&op=edit&type=".$_GET['type'].">"; 240 260 $html .= "<tr><td></td></tr>"; 241 $html .= "<tr><td><input type=text id=add_name name=add_name size=30 maxlength=30></td><td align=center><input type=radio name=add_type id=add_type value=0 checked></td><td align=center><input type=radio name=add_type id=add_type value=1></td><td align=center><input type=radio name=add_type id=add_type value=2></td><td align=center><input type= submit id=submit name=submit value=Add></td></tr>";261 $html .= "<tr><td><input type=text id=add_name name=add_name size=30 maxlength=30></td><td align=center><input type=radio name=add_type id=add_type value=0 checked></td><td align=center><input type=radio name=add_type id=add_type value=1></td><td align=center><input type=radio name=add_type id=add_type value=2></td><td align=center><input type=radio name=add_type id=add_type value=3></td><td align=center><input type=submit id=submit name=submit value=Add></td></tr>"; 242 262 } 243 263 $html .= "</table>"; … … 251 271 { 252 272 $contract = new Contract(); 253 $contract->add($_POST['ctr_name'], $_GET['type'], 254 $_POST['ctr_started'], $_POST['ctr_ended']); 255 256 Header("Location: ?a=admin_cc&ctr_id=" . $contract->getID() . "&op=edit&type=" . $_GET['type']); 257 } 258 259 $page->setTitle("Administration - Add " . $_GET['type']); 273 $contract->add($_POST['ctr_name'], $_GET['type'], $_POST['ctr_started'], $_POST['ctr_ended']); 274 275 header("Location: ?a=admin_cc&ctr_id=".$contract->getID()."&op=edit&type=".$_GET['type']); 276 } 277 278 $page->setTitle("Administration - Add ".$_GET['type']); 260 279 261 280 $html .= "<div class=block-header2>Details</div>"; 262 281 263 $html .= "<form id=detail_edit name=detail_edit method=post action=?a=admin_cc&ctr_id=" . $_GET['ctr_id'] . "&op=add&type=" . $_GET['type'] .">";282 $html .= "<form id=detail_edit name=detail_edit method=post action=?a=admin_cc&ctr_id=".$_GET['ctr_id']."&op=add&type=".$_GET['type'].">"; 264 283 $html .= "<table class=kb-table width=98%>"; 265 284 266 285 $html .= "<tr><td width=80><b>Name:</b></td><td><input type=text name=ctr_name id=ctr_name size=40 maxlength=40></td></tr>"; 267 $html .= "<tr><td width=80><b>Start date:</b></td><td><input type=text name=ctr_started id=ctr_started size=10 maxlength=10 value=\"" . date("Y-m-d") ."\"> (yyyy-mm-dd)</td></tr>";286 $html .= "<tr><td width=80><b>Start date:</b></td><td><input type=text name=ctr_started id=ctr_started size=10 maxlength=10 value=\"".date("Y-m-d")."\"> (yyyy-mm-dd)</td></tr>"; 268 287 $html .= "<tr><td width-80><b>End date:</b></td><td><input type=text name=ctr_ended id=ctr_ended size=10 maxlength=10> (yyyy-mm-dd or blank)</td></tr>"; 269 288 $html .= "<tr><td></td></tr>"; -
dev/common/admin_menu.php
r60 r91 8 8 $menubox->addOption("Ship Values", "?a=admin_shp_val"); 9 9 $menubox->addOption("Synchronization", "?a=admin_sync"); 10 $menubox->addOption("Map Options", "?a=admin_mapoptions"); 11 $menubox->addOption("Post Permissions", "?a=admin_postperm"); 10 12 $menubox->addOption("Mods", "?a=admin_mods"); 13 $menubox->addOption("Auditing", "?a=admin_audit"); 11 14 $menubox->addOption("Kill Import - files", "?a=kill_import"); 12 15 $menubox->addOption("Kill Import - csv", "?a=kill_import_csv"); 16 $menubox->addOption("Kill Export - files", "?a=kill_export"); 13 17 $menubox->addOption("Kill Export - csv", "?a=kill_export_search"); 14 $menubox->addOption("Auditing", "?a=admin_audit");15 18 ?> -
dev/common/admin_shp_val.php
r50 r91 175 175 { 176 176 $html .= '<form id="search" action="?a=admin_shp_val" method=post>'; 177 $html .= '<table class= kb-tablewidth="99%" align=center cellspacing="1">';177 $html .= '<table class="kb-table" width="99%" align=center cellspacing="1">'; 178 178 $html .= '<input type="hidden" name="opt" value="add"/>'; 179 179 $html .= '<script language="javascript"> -
dev/common/class.contract.php
r43 r91 1 <? 2 require_once( "db.php" ); 3 require_once( "class.killlist.php" ); 4 require_once( "class.graph.php" ); 5 require_once( "class.pagesplitter.php" ); 6 7 class Contract 8 { 9 function Contract( $ctr_id = 0 ) 10 { 11 $this->ctr_id_ = $ctr_id; 12 $this->contracttargets_ = array(); 13 14 // overall kill/losslist 15 $this->klist_ = new KillList(); 16 $this->llist_ = new KillList(); 17 if ( CORP_ID ) { 18 $this->klist_->addInvolvedCorp( new Corporation( CORP_ID ) ); 19 $this->llist_->addVictimCorp( new Corporation( CORP_ID ) ); 20 } 21 if ( ALLIANCE_ID ) { 22 $this->klist_->addInvolvedAlliance( new Alliance( ALLIANCE_ID ) ); 23 $this->llist_->addVictimAlliance( new Alliance( ALLIANCE_ID ) ); 24 } 25 $this->contractpointer_ = 0; 26 $this->qry_ = null; 27 } 28 1 <?php 2 require_once("db.php"); 3 require_once("class.killlist.php"); 4 require_once("class.graph.php"); 5 require_once("class.pagesplitter.php"); 6 7 class Contract 8 { 9 function Contract($ctr_id = 0) 10 { 11 $this->ctr_id_ = $ctr_id; 12 $this->contracttargets_ = array(); 13 14 // overall kill/losslist 15 $this->klist_ = new KillList(); 16 $this->llist_ = new KillList(); 17 if (CORP_ID) 18 { 19 $this->klist_->addInvolvedCorp(new Corporation(CORP_ID)); 20 $this->llist_->addVictimCorp(new Corporation(CORP_ID)); 21 } 22 if (ALLIANCE_ID) 23 { 24 $this->klist_->addInvolvedAlliance(new Alliance(ALLIANCE_ID)); 25 $this->llist_->addVictimAlliance(new Alliance(ALLIANCE_ID)); 26 } 27 $this->contractpointer_ = 0; 28 $this->qry_ = null; 29 } 30 29 31 function execQuery() 30 32 { 31 if ( $this->qry_)32 return;33 34 $this->qry_ = new DBQuery();35 // general36 $sql = "select * from kb3_contracts ctr37 where ctr.ctr_id = ".$this->ctr_id_;38 39 $this->qry_ = new DBQuery();40 if ( !$this->qry_->execute( $sql ))41 die( $this->qry_->getErrorMsg());42 43 $row = $this->qry_->getRow();44 $this->ctr_name_ = $row['ctr_name'];45 $this->ctr_started_ = $row['ctr_started'];46 $this->ctr_ended_ = $row['ctr_ended'];47 $this->campaign_ = ( $row['ctr_campaign'] == "1");48 49 // get corps & alliances for contract50 $sql = "select ctd.ctd_crp_id, ctd.ctd_all_id, ctd.ctd_reg_id33 if ($this->qry_) 34 return; 35 36 $this->qry_ = new DBQuery(); 37 // general 38 $sql = "select * from kb3_contracts ctr 39 where ctr.ctr_id = ".$this->ctr_id_; 40 41 $this->qry_ = new DBQuery(); 42 if (!$this->qry_->execute($sql)) 43 die($this->qry_->getErrorMsg()); 44 45 $row = $this->qry_->getRow(); 46 $this->ctr_name_ = $row['ctr_name']; 47 $this->ctr_started_ = $row['ctr_started']; 48 $this->ctr_ended_ = $row['ctr_ended']; 49 $this->campaign_ = ($row['ctr_campaign'] == "1"); 50 51 // get corps & alliances for contract 52 $sql = "select ctd.ctd_crp_id, ctd.ctd_all_id, ctd.ctd_reg_id, ctd.ctd_sys_id 51 53 from kb3_contract_details ctd 52 where ctd.ctd_ctr_id = ".$row['ctr_id']." 53 order by 3, 2, 1"; 54 55 $caqry = new DBQuery(); 56 $caqry->execute( $sql ) or die( $caqry->getErrorMsg() ); 57 58 while ( $carow = $caqry->getRow() ) { 59 $contracttarget = & new ContractTarget( $this, $carow['ctd_crp_id'], $carow['ctd_all_id'], $carow['ctd_reg_id'] ); 60 array_push( $this->contracttargets_, $contracttarget ); 61 if ( $carow['ctd_crp_id'] ) { 62 $this->klist_->addVictimCorp( new Corporation( $carow['ctd_crp_id'] ) ); 63 $this->llist_->addInvolvedCorp( new Corporation( $carow['ctd_crp_id'] ) ); 64 } elseif ( $carow['ctd_all_id'] ) { 65 $this->klist_->addVictimAlliance( new Alliance( $carow['ctd_all_id'] ) ); 66 $this->llist_->addInvolvedAlliance( new Alliance( $carow['ctd_all_id'] ) ); 67 } elseif ( $carow['ctd_reg_id'] ) { 68 $this->klist_->addRegion( new Region( $carow['ctd_reg_id'] ) ); 69 $this->llist_->addRegion( new Region( $carow['ctd_reg_id'] ) ); 70 } 71 } 72 73 $this->klist_->setStartDate( $this->getStartDate() ); 74 $this->llist_->setStartDate( $this->getStartDate() ); 75 if ( $this->getEndDate() != "" ) { 76 $this->klist_->setEndDate( $this->getEndDate() ); 77 $this->llist_->setEndDate( $this->getEndDate() ); 78 } 79 54 where ctd.ctd_ctr_id = ".$row['ctr_id']." 55 order by 3, 2, 1"; 56 57 $caqry = new DBQuery(); 58 $caqry->execute($sql) or die($caqry->getErrorMsg()); 59 60 while ($carow = $caqry->getRow()) 61 { 62 $contracttarget = &new ContractTarget($this, $carow['ctd_crp_id'], $carow['ctd_all_id'], $carow['ctd_reg_id'], $carow['ctd_sys_id']); 63 array_push($this->contracttargets_, $contracttarget); 64 if ($carow['ctd_crp_id']) 65 { 66 $this->klist_->addVictimCorp(new Corporation($carow['ctd_crp_id'])); 67 $this->llist_->addInvolvedCorp(new Corporation($carow['ctd_crp_id'])); 68 } 69 elseif ($carow['ctd_all_id']) 70 { 71 $this->klist_->addVictimAlliance(new Alliance($carow['ctd_all_id'])); 72 $this->llist_->addInvolvedAlliance(new Alliance($carow['ctd_all_id'])); 73 } 74 elseif ($carow['ctd_reg_id']) 75 { 76 $this->klist_->addRegion(new Region($carow['ctd_reg_id'])); 77 $this->llist_->addRegion(new Region($carow['ctd_reg_id'])); 78 } 79 elseif ($carow['ctd_sys_id']) 80 { 81 $this->klist_->addSystem(new SolarSystem($carow['ctd_sys_id'])); 82 $this->llist_->addSystem(new SolarSystem($carow['ctd_sys_id'])); 83 } 84 } 85 86 $this->klist_->setStartDate($this->getStartDate()); 87 $this->llist_->setStartDate($this->getStartDate()); 88 if ($this->getEndDate() != "") 89 { 90 $this->klist_->setEndDate($this->getEndDate()); 91 $this->llist_->setEndDate($this->getEndDate()); 92 } 80 93 } 81 94 82 95 function getID() 83 96 { 84 return $this->ctr_id_;85 } 86 97 return $this->ctr_id_; 98 } 99 87 100 function getName() 88 101 { 89 $this->execQuery();90 return $this->ctr_name_;91 } 92 102 $this->execQuery(); 103 return $this->ctr_name_; 104 } 105 93 106 function getStartDate() 94 107 { 95 $this->execQuery();96 return $this->ctr_started_;108 $this->execQuery(); 109 return $this->ctr_started_; 97 110 } 98 111 99 112 function getEndDate() 100 113 { 101 $this->execQuery();102 return $this->ctr_ended_;114 $this->execQuery(); 115 return $this->ctr_ended_; 103 116 } 104 117 105 118 function getRunTime() 106 119 { 107 if ( $this->getEndDate() != "")108 $datet = getdate( strtotime( $this->getEndDate() ));109 else110 $datet = getdate( strtotime( date( "Y-m-d" ) ));111 112 $datef = getdate( strtotime( $this->getStartDate() ));113 return $datet['yday']-$datef['yday'];120 if ($this->getEndDate() != "") 121 $datet = getdate(strtotime($this->getEndDate())); 122 else 123 $datet = getdate(strtotime(date("Y-m-d"))); 124 125 $datef = getdate(strtotime($this->getStartDate())); 126 return $datet['yday'] - $datef['yday']; 114 127 } 115 128 116 129 function getCampaign() 117 130 { 118 $this->execQuery();119 return $this->campaign_;131 $this->execQuery(); 132 return $this->campaign_; 120 133 } 121 134 122 135 function getCorps() 123 136 { 124 $this->execQuery();125 return $this->corps_;126 } 127 137 $this->execQuery(); 138 return $this->corps_; 139 } 140 128 141 function getAlliances() 129 142 { 130 $this->execQuery();131 return $this->alliances_;132 } 133 143 $this->execQuery(); 144 return $this->alliances_; 145 } 146 134 147 function getKills() 135 148 { 136 $this->execQuery();137 return $this->klist_->getCount();138 } 139 149 $this->execQuery(); 150 return $this->klist_->getCount(); 151 } 152 140 153 function getLosses() 141 154 { 142 $this->execQuery();143 return $this->llist_->getCount();155 $this->execQuery(); 156 return $this->llist_->getCount(); 144 157 } 145 158 146 159 function getKillISK() 147 160 { 148 $this->execQuery();149 if ( !$this->klist_->getISK()) $this->klist_->getAllKills();150 return $this->klist_->getISK();151 } 152 161 $this->execQuery(); 162 if (!$this->klist_->getISK()) $this->klist_->getAllKills(); 163 return $this->klist_->getISK(); 164 } 165 153 166 function getLossISK() 154 167 { 155 $this->execQuery();156 if ( !$this->llist_->getISK()) $this->llist_->getAllKills();157 return $this->llist_->getISK();158 } 159 168 $this->execQuery(); 169 if (!$this->llist_->getISK()) $this->llist_->getAllKills(); 170 return $this->llist_->getISK(); 171 } 172 160 173 function getEfficiency() 161 174 { 162 $this->execQuery();163 if ( $this->klist_->getISK())164 $efficiency = round( $this->klist_->getISK() / ( $this->klist_->getISK() + $this->llist_->getISK() ) * 100, 2);165 else166 $efficiency = 0;167 168 return $efficiency;169 } 170 175 $this->execQuery(); 176 if ($this->klist_->getISK()) 177 $efficiency = round($this->klist_->getISK() / ($this->klist_->getISK() + $this->llist_->getISK()) * 100, 2); 178 else 179 $efficiency = 0; 180 181 return $efficiency; 182 } 183 171 184 function getKillList() 172 185 { 173 $this->execQuery();174 return $this->klist_;186 $this->execQuery(); 187 return $this->klist_; 175 188 } 176 189 177 190 function getLossList() 178 191 { 179 $this->execQuery();180 return $this->llist_;192 $this->execQuery(); 193 return $this->llist_; 181 194 } 182 195 183 196 function getContractTarget() 184 197 { 185 if ( $this->contractpointer_ > 30 ) 186 return null; 187 188 $target = $this->contracttargets_[$this->contractpointer_]; 189 if ( $target ) 190 $this->contractpointer_++; 191 return $target; 192 } 193 194 function add( $name, $type, $startdate, $enddate = "" ) 195 { 196 $qry = new DBQuery(); 197 if ( $type == "campaign" ) $campaign = 1; else $campaign = 0; 198 if ( $enddate != "" ) $enddate = "'".$enddate."'"; else $enddate = "null"; 199 200 if ( !$this->ctr_id_ ) { 201 $sql = "insert into kb3_contracts values ( null, '".$name."', 202 '".KB_SITE."', ". 203 $campaign.", 198 if ($this->contractpointer_ > 30) 199 return null; 200 201 $target = $this->contracttargets_[$this->contractpointer_]; 202 if ($target) 203 $this->contractpointer_++; 204 return $target; 205 } 206 207 function add($name, $type, $startdate, $enddate = "") 208 { 209 $qry = new DBQuery(); 210 if ($type == "campaign") $campaign = 1; 211 else $campaign = 0; 212 if ($enddate != "") $enddate = "'".$enddate."'"; 213 else $enddate = "null"; 214 215 if (!$this->ctr_id_) 216 { 217 $sql = "insert into kb3_contracts values ( null, '".$name."', 218 '".KB_SITE."', ".$campaign.", 204 219 '".$startdate."', 205 220 ".$enddate." )"; 206 $qry->execute( $sql ) or die( $qry->getErrorMsg() ); 207 $this->ctr_id_ = $qry->getInsertID(); 208 } 209 else { 210 $sql = "update kb3_contracts set ctr_name = '".$name."', 221 $qry->execute($sql) or die($qry->getErrorMsg()); 222 $this->ctr_id_ = $qry->getInsertID(); 223 } 224 else 225 { 226 $sql = "update kb3_contracts set ctr_name = '".$name."', 211 227 ctr_started = '".$startdate."', 212 228 ctr_ended = ".$enddate." 213 229 where ctr_id = ".$this->ctr_id_; 214 $qry->execute( $sql ) or die( $qry->getErrorMsg());215 $this->ctr_id_ = $qry->getInsertID();216 }230 $qry->execute($sql) or die($qry->getErrorMsg()); 231 $this->ctr_id_ = $qry->getInsertID(); 232 } 217 233 } 218 234 219 235 function remove() 220 236 { 221 $qry = new DBQuery();222 223 $qry->execute("delete from kb3_contracts224 where ctr_id = ".$this->ctr_id_ 225 226 $qry->execute("delete from kb3_contract_details227 where ctd_ctr_id = ".$this->ctr_id_ 237 $qry = new DBQuery(); 238 239 $qry->execute("delete from kb3_contracts 240 where ctr_id = ".$this->ctr_id_); 241 242 $qry->execute("delete from kb3_contract_details 243 where ctd_ctr_id = ".$this->ctr_id_); 228 244 } 229 245 230 246 function validate() 231 247 { 232 $qry = new DBQuery();233 234 $qry->execute("select * from kb3_contracts248 $qry = new DBQuery(); 249 250 $qry->execute("select * from kb3_contracts 235 251 where ctr_id = ".$this->ctr_id_." 236 and ctr_site = '".KB_SITE."'" ); 237 return ( $qry->recordCount() > 0 ); 238 } 239 } 240 241 class ContractTarget 242 { 243 function ContractTarget( $contract, $crp_id, $all_id, $reg_id ) 244 { 245 $this->contract_ = $contract; 246 $this->crp_id_ = $crp_id; 247 $this->all_id_ = $all_id; 248 $this->reg_id_ = $reg_id; 249 250 $this->klist_ = & new KillList(); 251 $this->llist_ = & new KillList(); 252 253 if ( $this->crp_id_ ) { 254 $this->type_ = "corp"; 255 $this->klist_->addVictimCorp( new Corporation( $this->crp_id_ ) ); 256 $this->llist_->addInvolvedCorp( new Corporation( $this->crp_id_ ) ); 257 $this->id_ = $this->crp_id_; 258 } elseif ( $this->all_id_ ) { 259 $this->type_ = "alliance"; 260 $this->klist_->addVictimAlliance( new Alliance( $this->all_id_ ) ); 261 $this->llist_->addInvolvedAlliance( new Alliance( $this->all_id_ ) ); 262 $this->id_ = $this->all_id_; 263 } elseif ( $this->reg_id_ ) { 264 $this->type_ = "region"; 265 $this->klist_->addRegion( new Region( $this->reg_id_ ) ); 266 $this->llist_->addRegion( new Region( $this->reg_id_ ) ); 267 $this->id_ = $this->reg_id_; 268 } 269 270 if ( CORP_ID ) { 271 $this->klist_->addInvolvedCorp( new Corporation( CORP_ID ) ); 272 $this->llist_->addVictimCorp( new Corporation( CORP_ID ) ); 273 } 274 if ( ALLIANCE_ID ) { 275 $this->klist_->addInvolvedAlliance( new Alliance( ALLIANCE_ID ) ); 276 $this->llist_->addVictimAlliance( new Alliance( ALLIANCE_ID ) ); 277 } 278 279 $this->klist_->setStartDate( $contract->getStartDate() ); 280 $this->llist_->setStartDate( $contract->getStartDate() ); 281 if ( $contract->getEndDate() != "" ) { 282 $this->klist_->setEndDate( $contract->getEndDate() ); 283 $this->llist_->setEndDate( $contract->getEndDate() ); 284 } 252 and ctr_site = '".KB_SITE."'"); 253 return ($qry->recordCount() > 0); 254 } 255 } 256 257 class ContractTarget 258 { 259 function ContractTarget($contract, $crp_id, $all_id, $reg_id , $sys_id) 260 { 261 $this->contract_ = $contract; 262 $this->crp_id_ = $crp_id; 263 $this->all_id_ = $all_id; 264 $this->reg_id_ = $reg_id; 265 $this->sys_id_ = $sys_id; 266 267 $this->klist_ = &new KillList(); 268 $this->llist_ = &new KillList(); 269 270 if ($this->crp_id_) 271 { 272 $this->type_ = "corp"; 273 $this->klist_->addVictimCorp(new Corporation($this->crp_id_)); 274 $this->llist_->addInvolvedCorp(new Corporation($this->crp_id_)); 275 $this->id_ = $this->crp_id_; 276 } 277 elseif ($this->all_id_) 278 { 279 $this->type_ = "alliance"; 280 $this->klist_->addVictimAlliance(new Alliance($this->all_id_)); 281 $this->llist_->addInvolvedAlliance(new Alliance($this->all_id_)); 282 $this->id_ = $this->all_id_; 283 } 284 elseif ($this->reg_id_) 285 { 286 $this->type_ = "region"; 287 $this->klist_->addRegion(new Region($this->reg_id_)); 288 $this->llist_->addRegion(new Region($this->reg_id_)); 289 $this->id_ = $this->reg_id_; 290 } 291 elseif ($this->sys_id_) 292 { 293 $this->type_ = "system"; 294 $this->klist_->addSystem(new SolarSystem($this->sys_id_)); 295 $this->llist_->addSystem(new SolarSystem($this->sys_id_)); 296 $this->id_ = $this->sys_id_; 297 } 298 if (CORP_ID) 299 { 300 $this->klist_->addInvolvedCorp(new Corporation(CORP_ID)); 301 $this->llist_->addVictimCorp(new Corporation(CORP_ID)); 302 } 303 if (ALLIANCE_ID) 304 { 305 $this->klist_->addInvolvedAlliance(new Alliance(ALLIANCE_ID)); 306 $this->llist_->addVictimAlliance(new Alliance(ALLIANCE_ID)); 307 } 308 309 $this->klist_->setStartDate($contract->getStartDate()); 310 $this->llist_->setStartDate($contract->getStartDate()); 311 if ($contract->getEndDate() != "") 312 { 313 $this->klist_->setEndDate($contract->getEndDate()); 314 $this->llist_->setEndDate($contract->getEndDate()); 315 } 285 316 } 286 317 287 318 function getID() 288 319 { 289 return $this->id_;290 } 291 320 return $this->id_; 321 } 322 292 323 function getName() 293 324 { 294 if ( $this->name_ == "" ) { 325 if ($this->name_ == "") 326 { 327 $qry = new DBQuery(); 328 switch ($this->type_) 329 { 330 case "corp": 331 $qry->execute("select crp_name as name from kb3_corps where crp_id = ".$this->crp_id_); 332 break; 333 case "alliance": 334 $qry->execute("select all_name as name from kb3_alliances where all_id = ".$this->all_id_); 335 break; 336 case "region": 337 $qry->execute("select reg_name as name from kb3_regions where reg_id = ".$this->reg_id_); 338 break; 339 case "system": 340 $qry->execute("select sys_name as name from kb3_systems where sys_id = ".$this->sys_id_); 341 break; 342 } 343 $row = $qry->getRow(); 344 $this->name_ = $row['name']; 345 } 346 return $this->name_; 347 } 348 349 function getType() 350 { 351 return $this->type_; 352 } 353 354 function getKillList() 355 { 356 return $this->klist_; 357 } 358 359 function getLossList() 360 { 361 return $this->llist_; 362 } 363 364 function getEfficiency() 365 { 366 if ($this->klist_->getISK()) 367 $efficiency = round($this->klist_->getISK() / ($this->klist_->getISK() + $this->llist_->getISK()) * 100, 2); 368 else 369 $efficiency = 0; 370 371 return $efficiency; 372 } 373 374 function getKills() 375 { 376 } 377 378 function getLosses() 379 { 380 } 381 382 function add() 383 { 295 384 $qry = new DBQuery(); 296 switch ( $this->type_ ) { 297 case "corp": 298 $qry->execute( "select crp_name as name from kb3_corps where crp_id = ".$this->crp_id_ ); 299 break; 300 case "alliance": 301 $qry->execute( "select all_name as name from kb3_alliances where all_id = ".$this->all_id_ ); 302 break; 303 case "region": 304 $qry->execute( "select reg_name as name from kb3_regions where reg_id = ".$this->reg_id_ ); 305 break; 306 } 307 $row = $qry->getRow(); 308 $this->name_ = $row['name']; 309 } 310 return $this->name_; 311 } 312 313 function getType() 314 { 315 return $this->type_; 316 } 317 318 function getKillList() 319 { 320 return $this->klist_; 321 } 322 323 function getLossList() 324 { 325 return $this->llist_; 326 } 327 328 function getEfficiency() 329 { 330 if ( $this->klist_->getISK() ) 331 $efficiency = round( $this->klist_->getISK() / ( $this->klist_->getISK() + $this->llist_->getISK() ) * 100, 2 ); 332 else 333 $efficiency = 0; 334 335 return $efficiency; 336 } 337 338 function getKills() 339 { 340 } 341 342 function getLosses() 343 { 344 } 345 346 function add() 347 { 348 $qry = new DBQuery(); 349 $sql = "insert into kb3_contract_details 385 $sql = "insert into kb3_contract_details 350 386 values ( ".$this->contract_->getID().","; 351 switch( $this->type_ ) { 352 case "corp": 353 $sql .= $this->id_.", 0, 0 )"; 354 break; 355 case "alliance": 356 $sql .= "0, ".$this->id_.", 0 )"; 357 break; 358 case "region": 359 $sql .= "0, 0, ".$this->id_." )"; 360 break; 361 } 362 $qry->execute( $sql ) or die( $qry->getErrorMsg() ); 387 switch ($this->type_) 388 { 389 case "corp": 390 $sql .= $this->id_.", 0, 0, 0 )"; 391 break; 392 case "alliance": 393 $sql .= "0, ".$this->id_.", 0, 0 )"; 394 break; 395 case "region": 396 $sql .= "0, 0, ".$this->id_.",0 )"; 397 break; 398 case "system": 399 $sql .= "0, 0, 0, ".$this->id_." )"; 400 break; 401 } 402 $qry->execute($sql) or die($qry->getErrorMsg()); 363 403 } 364 404 365 405 function remove() 366 406 { 367 $qry = new DBQuery();368 $sql = "delete from kb3_contract_details407 $qry = new DBQuery(); 408 $sql = "delete from kb3_contract_details 369 409 where ctd_ctr_id = ".$this->contract_->getID(); 370 switch( $this->type_ ) { 371 case "corp": 372 $sql .= " and ctd_crp_id = ".$this->id_; 373 break; 374 case "alliance": 375 $sql .= " and ctd_all_id = ".$this->id_; 376 break; 377 case "region": 378 $sql .= " and ctd_reg_id = ".$this->id_; 379 break; 380 } 381 $qry->execute( $sql ) or die( $qry->getErrorMsg() ); 382 } 383 } 384 385 class ContractList 386 { 410 switch ($this->type_) 411 { 412 case "corp": 413 $sql .= " and ctd_crp_id = ".$this->id_; 414 break; 415 case "alliance": 416 $sql .= " and ctd_all_id = ".$this->id_; 417 break; 418 case "region": 419 $sql .= " and ctd_reg_id = ".$this->id_; 420 break; 421 case "system": 422 $sql .= " and ctd_sys_id = ".$this->id_; 423 break; 424 } 425 $qry->execute($sql) or die($qry->getErrorMsg()); 426 } 427 } 428 429 class ContractList 430 { 387 431 function ContractList() 388 432 { 389 $this->qry_ = new DBQuery();390 $this->active_ = "both";391 $this->contractcounter_ = 1;392 } 393 433 $this->qry_ = new DBQuery(); 434 $this->active_ = "both"; 435 $this->contractcounter_ = 1; 436 } 437 394 438 function execQuery() 395 439 { 396 if ( $this->qry_->executed())397 return;398 399 $sql = "select ctr.ctr_id, ctr.ctr_started, ctr.ctr_ended, ctr.ctr_name440 if ($this->qry_->executed()) 441 return; 442 443 $sql = "select ctr.ctr_id, ctr.ctr_started, ctr.ctr_ended, ctr.ctr_name 400 444 from kb3_contracts ctr 401 445 where ctr.ctr_site = '".KB_SITE."'"; 402 if ( $this->active_ == "yes" ) 403 $sql .= " and ( ctr_ended is null or now() <= ctr_ended )"; 404 elseif ( $this->active_ == "no" ) 405 $sql .= " and ( now() >= ctr_ended )"; 406 407 if ( $this->campaigns_ ) 408 $sql .= " and ctr.ctr_campaign = 1"; 409 else 410 $sql .= " and ctr.ctr_campaign = 0"; 411 412 $sql .= " order by ctr_ended, ctr_started desc"; 413 414 //if ( $this->limit_ ) 415 // $sql .= " limit ".( $this->page_ / $this->limit_ ).", ".$this->limit_; 416 417 $this->qry_ = new DBQuery(); 418 $this->qry_->execute( $sql ) or die( $this->qry_->getErrorMsg() ); 419 } 420 421 function setActive( $active ) 422 { 423 $this->active_ = $active; 424 } 425 426 function setCampaigns( $campaigns ) 427 { 428 $this->campaigns_ = $campaigns; 429 } 430 431 function setLimit( $limit ) 432 { 433 $this->limit_ = $limit; 434 } 435 436 function setPage( $page ) 437 { 438 $this->page_ = $page; 439 $this->offset_ = ( $page * $this->limit_ ) - $this->limit_; 446 if ($this->active_ == "yes") 447 $sql .= " and ( ctr_ended is null or now() <= ctr_ended )"; 448 elseif ($this->active_ == "no") 449 $sql .= " and ( now() >= ctr_ended )"; 450 451 if ($this->campaigns_) 452 $sql .= " and ctr.ctr_campaign = 1"; 453 else 454 $sql .= " and ctr.ctr_campaign = 0"; 455 456 $sql .= " order by ctr_ended, ctr_started desc"; 457 // if ( $this->limit_ ) 458 // $sql .= " limit ".( $this->page_ / $this->limit_ ).", ".$this->limit_; 459 $this->qry_ = new DBQuery(); 460 $this->qry_->execute($sql) or die($this->qry_->getErrorMsg()); 461 } 462 463 function setActive($active) 464 { 465 $this->active_ = $active; 466 } 467 468 function setCampaigns($campaigns) 469 { 470 $this->campaigns_ = $campaigns; 471 } 472 473 function setLimit($limit) 474 { 475 $this->limit_ = $limit; 476 } 477 478 function setPage($page) 479 { 480 $this->page_ = $page; 481 $this->offset_ = ($page * $this->limit_) - $this->limit_; 440 482 } 441 483 442 484 function getContract() 443 485 { 444 //echo "off: ".$this->offset_."<br>"; 445 //echo "cnt: ".$this->contractcounter_."<br>"; 446 //echo "limit: ".$this->limit_."<br>"; 447 $this->execQuery(); 448 if ( $this->offset_ && $this->contractcounter_ < $this->offset_ ) { 449 for ( $i = 0; $i < $this->offset_; $i++ ) { 450 $row = $this->qry_->getRow(); 451 $this->contractcounter_++; 452 } 453 } 454 if ( $this->limit_ && ( $this->contractcounter_ - $this->offset_ ) > $this->limit_ ) 455 return null; 456 457 $row = $this->qry_->getRow(); 458 if ( $row ) { 459 $this->contractcounter_++; 460 return new Contract( $row['ctr_id'] ); 461 } 462 else 463 return null; 486 // echo "off: ".$this->offset_."<br>"; 487 // echo "cnt: ".$this->contractcounter_."<br>"; 488 // echo "limit: ".$this->limit_."<br>"; 489 $this->execQuery(); 490 if ($this->offset_ && $this->contractcounter_ < $this->offset_) 491 { 492 for ($i = 0; $i < $this->offset_; $i++) 493 { 494 $row = $this->qry_->getRow(); 495 $this->contractcounter_++; 496 } 497 } 498 if ($this->limit_ && ($this->contractcounter_ - $this->offset_) > $this->limit_) 499 return null; 500 501 $row = $this->qry_->getRow(); 502 if ($row) 503 { 504 $this->contractcounter_++; 505 return new Contract($row['ctr_id']); 506 } 507 else 508 return null; 464 509 } 465 510 466 511 function getCount() 467 512 { 468 $this->execQuery();469 return $this->qry_->recordCount();513 $this->execQuery(); 514 return $this->qry_->recordCount(); 470 515 } 471 516 472 517 function getActive() 473 518 { 474 return $this->active_;475 } 476 477 478 479 480 function ContractListTable( $contractlist)481 { 482 $this->contractlist_ = $contractlist;483 } 484 485 function paginate( $paginate, $page = 1)486 { 487 if ( !$page) $page = 1;488 $this->paginate_ = $paginate;489 $this->contractlist_->setLimit( $paginate);490 $this->contractlist_->setPage( $page);491 } 492 519 return $this->active_; 520 } 521 } 522 523 class ContractListTable 524 { 525 function ContractListTable($contractlist) 526 { 527 $this->contractlist_ = $contractlist; 528 } 529 530 function paginate($paginate, $page = 1) 531 { 532 if (!$page) $page = 1; 533 $this->paginate_ = $paginate; 534 $this->contractlist_->setLimit($paginate); 535 $this->contractlist_->setPage($page); 536 } 537 493 538 function generate() 494 539 { 495 if ( $this->contractlist_->getCount() ) { 496 $rowid = 0; 497 $html .= "<table class=kb-table width=\"98%\" align=center cellspacing=1>"; 498 $html .= "<tr class=kb-table-header>"; 499 $html .= "<td class=kb-table-cell width=180>Name</td>"; 500 $html .= "<td class=kb-table-cell width=80 align=center>Start date</td>"; 501 if ( $this->contractlist_->getActive() == "no" ) 502 $html .= "<td class=kb-table-cell width=80 align=center>End date</td>"; 503 $html .= "<td class=kb-table-cell width=50 align=center>Kills</td>"; 504 $html .= "<td class=kb-table-cell width=70 align=center>ISK (M)</td>"; 505 $html .= "<td class=kb-table-cell width=50 align=center>Losses</td>"; 506 $html .= "<td class=kb-table-cell width=70 align=center>ISK (M)</td>"; 507 $html .= "<td class=kb-table-cell width=70 align=center colspan=2>Efficiency</td>"; 508 $html .= "</tr>"; 509 510 $odd = false; 511 $rowclass = "kb-table-row-even"; 512 while ( $contract = $this->contractlist_->getContract() ) { 513 if ( $odd ) { 540 if ($this->contractlist_->getCount()) 541 { 542 $rowid = 0; 543 $html .= "<table class=kb-table width=\"98%\" align=center cellspacing=1>"; 544 $html .= "<tr class=kb-table-header>"; 545 $html .= "<td class=kb-table-cell width=180>Name</td>"; 546 $html .= "<td class=kb-table-cell width=80 align=center>Start date</td>"; 547 if ($this->contractlist_->getActive() == "no") 548 $html .= "<td class=kb-table-cell width=80 align=center>End date</td>"; 549 $html .= "<td class=kb-table-cell width=50 align=center>Kills</td>"; 550 $html .= "<td class=kb-table-cell width=70 align=center>ISK (M)</td>"; 551 $html .= "<td class=kb-table-cell width=50 align=center>Losses</td>"; 552 $html .= "<td class=kb-table-cell width=70 align=center>ISK (M)</td>"; 553 $html .= "<td class=kb-table-cell width=70 align=center colspan=2>Efficiency</td>"; 554 $html .= "</tr>"; 555 556 $odd = false; 514 557 $rowclass = "kb-table-row-even"; 515 $odd = false; 516 } 517 else { 518 $rowclass = "kb-table-row-odd"; 519 $odd = true; 520 } 521 522 $html .= "<tr class=".$rowclass." onmouseover=\"this.className='kb-table-row-hover';\" onmouseout=\"this.className='".$rowclass."';\" onClick=\"window.location.href='?a=cc_detail&ctr_id=".$contract->getID()."';\">"; 523 $html .= "<td class=kb-table-cell><b>".$contract->getName()."</b></td>"; 524 $html .= "<td class=kb-table-cell align=center>".substr( $contract->getStartDate(), 0, 10 )."</td>"; 525 if ( $this->contractlist_->getActive() == "no" ) { 526 if ( $contract->getEndDate() == "" ) 527 $ended = "Active"; 528 else 529 $ended = substr( $contract->getEndDate(), 0, 10 ); 530 $html .= "<td class=kb-table-cell align=center>".$ended."</td>"; 531 } 532 if ( $contract->getKills() == 0 ) 533 $kclass = "kl-null"; 534 else 535 $kclass = "kl-kill"; 536 537 if ( $contract->getLosses() == 0 ) 538 $lclass = "kl-null"; 539 else 540 $lclass = "kl-loss"; 541 542 $html .= "<td class=".$kclass." align=center>".$contract->getKills()."</td>"; 543 $html .= "<td class=".$kclass." align=center>".$contract->getKillISK()."</td>"; 544 $html .= "<td class=".$lclass." align=center>".$contract->getLosses()."</td>"; 545 $html .= "<td class=".$lclass." align=center>".$contract->getLossISK()."</td>"; 546 $bar = new BarGraph( $contract->getEfficiency(), 100, 75 ); 547 $html .= "<td class=kb-table-cell align=center width=40><b>".$contract->getEfficiency()."%</b></td>"; 548 $html .= "<td class=kb-table-cell align=left width=75>".$bar->generate()."</td>"; 549 $html .= "</tr>"; 550 } 551 $html .= "</table>"; 552 $pagesplitter = new PageSplitter( $this->contractlist_->getCount(), 10 ); 553 $html .= $pagesplitter->generate(); 554 } 555 else $html .= "None."; 556 557 return $html; 558 } 559 } 560 558 while ($contract = $this->contractlist_->getContract()) 559 { 560 if ($odd) 561 { 562 $rowclass = "kb-table-row-even"; 563 $odd = false; 564 } 565 else 566 { 567 $rowclass = "kb-table-row-odd"; 568 $odd = true; 569 } 570 571 $html .= "<tr class=".$rowclass." onmouseover=\"this.className='kb-table-row-hover';\" onmouseout=\"this.className='".$rowclass."';\" onClick=\"window.location.href='?a=cc_detail&ctr_id=".$contract->getID()."';\">"; 572 $html .= "<td class=kb-table-cell><b>".$contract->getName()."</b></td>"; 573 $html .= "<td class=kb-table-cell align=center>".substr($contract->getStartDate(), 0, 10)."</td>"; 574 if ($this->contractlist_->getActive() == "no") 575 { 576 if ($contract->getEndDate() == "") 577 $ended = "Active"; 578 else 579 $ended = substr($contract->getEndDate(), 0, 10); 580 $html .= "<td class=kb-table-cell align=center>".$ended."</td>"; 581 } 582 if ($contract->getKills() == 0) 583 $kclass = "kl-null"; 584 else 585 $kclass = "kl-kill"; 586 587 if ($contract->getLosses() == 0) 588 $lclass = "kl-null"; 589 else 590 $lclass = "kl-loss"; 591 592 $html .= "<td class=".$kclass." align=center>".$contract->getKills()."</td>"; 593 $html .= "<td class=".$kclass." align=center>".$contract->getKillISK()."</td>"; 594 $html .= "<td class=".$lclass." align=center>".$contract->getLosses()."</td>"; 595 $html .= "<td class=".$lclass." align=center>".$contract->getLossISK()."</td>"; 596 $bar = new BarGraph($contract->getEfficiency(), 100, 75); 597 $html .= "<td class=kb-table-cell align=center width=40><b>".$contract->getEfficiency()."%</b></td>"; 598 $html .= "<td class=kb-table-cell align=left width=75>".$bar->generate()."</td>"; 599 $html .= "</tr>"; 600 } 601 $html .= "</table>"; 602 $pagesplitter = new PageSplitter($this->contractlist_->getCount(), 10); 603 $html .= $pagesplitter->generate(); 604 } 605 else $html .= "None."; 606 607 return $html; 608 } 609 } 561 610 ?> -
dev/common/class.killboard.php
r47 r91 30 30 from kb3_contracts 31 31 where ctr_campaign = 1 32 and ctr_site = '" . $this->site_ ."'";32 and ctr_site = '".$this->site_."'"; 33 33 if ($active) $sql .= " and ctr_ended is null"; 34 34 $qry->execute($sql) or die ($qry->getErrorMessage()); … … 42 42 from kb3_contracts 43 43 where ctr_campaign = 0 44 and ctr_site = '" . $this->site_ ."'";44 and ctr_site = '".$this->site_."'"; 45 45 if ($active) $sql .= " and ( ctr_ended is null or now() <= ctr_ended )"; 46 46 $qry->execute($sql) or die ($qry->getErrorMessage()); … … 58 58 { 59 59 $this->qry_ = new DBQuery(); 60 $this->sql_ = "select * from kb3_config where cfg_site = '" . $site ."'";60 $this->sql_ = "select * from kb3_config where cfg_site = '".$site."'"; 61 61 62 62 $this->site_ = $site; … … 106 106 return $this->config[$key]; 107 107 } 108 return 0;108 return false; 109 109 } 110 110 … … 113 113 $qry = new DBQuery(); 114 114 $qry->execute("select cfg_value from kb3_config 115 where cfg_key = '" . $key ."'116 and cfg_site = '" . $this->site_ ."'");115 where cfg_key = '".$key."' 116 and cfg_site = '".$this->site_."'"); 117 117 if ($qry->recordCount()) 118 118 { 119 119 $sql = "update kb3_config 120 set cfg_value = '" . $value ."'121 where cfg_site = '" . $this->site_ ."'122 and cfg_key = '" . $key ."'";120 set cfg_value = '".$value."' 121 where cfg_site = '".$this->site_."' 122 and cfg_key = '".$key."'"; 123 123 } 124 124 else 125 125 { 126 $sql = "insert into kb3_config values ( '" . $this->site_ ."',127 '" . $key ."',128 '" . $value ."' )";126 $sql = "insert into kb3_config values ( '".$this->site_."', 127 '".$key."', 128 '".$value."' )"; 129 129 } 130 130 $qry->execute($sql) or die($qry->getErrorMsg()); … … 132 132 } 133 133 134 function delConfig($key) 135 { 136 $qry = new DBQuery(); 137 $qry->execute("delete from kb3_config where cfg_key = '".$key."' 138 and cfg_site = '".$this->site_."'"); 139 if (isset($this->config[$key])) 140 { 141 unset($this->config[$key]); 142 } 143 } 144 134 145 function checkCheckbox($name) 135 146 { 136 if ($_POST[$name] == "on")147 if ($_POST[$name] == 'on') 137 148 { 138 149 $this->setConfig($name, '1'); -
dev/common/class.map.php
r10 r91 1 1 <?php 2 require_once( "db.php");3 require_once( "globals.php");2 require_once('db.php'); 3 require_once('globals.php'); 4 4 5 5 class MapView … … 13 13 $this->offset_ = 10; 14 14 // colors 15 /* unused, must have been some kind of painting by security 15 16 $this->sys_colors_[0] = array(200, 20, 48); 16 17 $this->sys_colors_[1] = array(200, 20, 48); … … 24 25 $this->sys_colors_[9] = array(99, 241, 255); 25 26 $this->sys_colors_[10] = array(99, 241, 255); 27 */ 28 26 29 $this->linecolor_ = array(75, 75, 75); 27 30 $this->captioncolor_ = array(110, 110, 110); 28 // $this->normalcolor_ = array( 140, 90, 140);31 $this->bgcolor_ = array(30, 30, 30); 29 32 $this->normalcolor_ = array(81, 103, 146); 30 // $this->normalcolor_ = array( 151, 141, 191 );31 33 $this->hlcolor_ = array(200, 200, 200); 32 34 } 33 35 34 function setBackground() 35 { 36 function setbgcolor($r, $g, $b) 37 { 38 $this->bgcolor_ = array($r, $g, $b); 39 } 40 41 function setlinecolor($r, $g, $b) 42 { 43 $this->linecolor_ = array($r, $g, $b); 44 } 45 46 function setcaptcolor($r, $g, $b) 47 { 48 $this->captioncolor_ = array($r, $g, $b); 49 } 50 51 function setnormalcolor($r, $g, $b) 52 { 53 $this->normalcolor_ = array($r, $g, $b); 54 } 55 56 function sethlcolor($r, $g, $b) 57 { 58 $this->hlcolor_ = array($r, $g, $b); 36 59 } 37 60 … … 65 88 $this->systemid_ = $systemid; 66 89 67 $sql = "select reg.reg_id, reg.reg_name, con.con_id, con.con_name, sys.sys_name, sys.sys_sec90 $sql = 'select reg.reg_id, reg.reg_name, con.con_id, con.con_name, sys.sys_name, sys.sys_sec 68 91 from kb3_regions reg, kb3_constellations con, kb3_systems sys 69 92 where reg.reg_id = con.con_reg_id 70 93 and con.con_id = sys.sys_con_id 71 and sys.sys_id = " .$this->systemid_;94 and sys.sys_id = '.$this->systemid_; 72 95 73 96 $qry = new DBQuery(); 74 $qry->execute($sql) or die($qry->getErrorMsg());97 $qry->execute($sql); 75 98 $row = $qry->getRow(); 76 99 … … 90 113 function generate() 91 114 { 92 $sql = "select sys.sys_x, sys.sys_y, sys.sys_z, sys.sys_sec,93 115 $sql = 'select sys.sys_x, sys.sys_y, sys.sys_z, sys.sys_sec, 116 sys.sys_id, sys.sys_name, sys.sys_eve_id, sjp.sjp_to, con.con_id, 94 117 con.con_name, reg.reg_id, reg.reg_name, 95 reg.reg_x, reg.reg_z96 from kb3_systems sys, kb3_system_jumps sjp,97 kb3_constellations con, kb3_regions reg98 where con.con_id = sys.sys_con_id118 reg.reg_x, reg.reg_z 119 from kb3_systems sys, kb3_system_jumps sjp, 120 kb3_constellations con, kb3_regions reg 121 where con.con_id = sys.sys_con_id 99 122 and reg.reg_id = con.con_reg_id 100 and sjp.sjp_from = sys.sys_eve_id ";123 and sjp.sjp_from = sys.sys_eve_id'; 101 124 102 125 $regioncache = "cache/map/" . $this->regionid_ . "_" . $this->imgwidth_ . ".png"; … … 134 157 $white = imagecolorallocate($img, 255, 255, 255); 135 158 $red = imagecolorallocate($img, 255, 0, 0); 136 $bgcolor = imagecolorallocate($img, 30, 30, 30);159 $bgcolor = imagecolorallocate($img, $this->bgcolor_[0], $this->bgcolor_[1], $this->bgcolor_[2]); 137 160 imagefilledrectangle($img, 0, 0, $this->imgwidth_, $this->imgheight_, $bgcolor); 138 161 … … 198 221 // exit; 199 222 // exit; 200 201 223 // draw lines 202 224 if ($this->showlines_) … … 208 230 $py = $this->offset_ + ($sys[$n][1] - $minz) * $yscale; 209 231 210 $line_col = imagecolorallocate($img, $this->linecolor_[0], 211 $this->linecolor_[1], 212 $this->linecolor_[2]); 232 $line_col = imagecolorallocate($img, $this->linecolor_[0], $this->linecolor_[1], $this->linecolor_[2]); 213 233 214 234 for ($m = 0; $m <= $sys[$n][3]; $m++) … … 289 309 $ed = 5; 290 310 } 291 292 311 // bug compat: imagefilledellipse doesnt draw ellipses with 1px size 293 // 312 // on some installations 294 313 if ($ed < 1) 295 314 { 296 315 imagesetpixel($img, $px, $py, $color); 316 } 317 elseif ($ed < 3) 318 { 319 imagesetpixel($img, $px, $py, $color); 320 imagesetpixel($img, $px+1, $py, $color); 321 imagesetpixel($img, $px-1, $py, $color); 322 imagesetpixel($img, $px, $py-1, $color); 323 imagesetpixel($img, $px, $py+1, $color); 297 324 } 298 325 else … … 307 334 $captioncolor = imagecolorallocate($img, $this->captioncolor_[0], $this->captioncolor_[1], $this->captioncolor_[2]); 308 335 if (strlen($this->title_) > 0) 336 { 309 337 $title = $this->title_ . " " . $caption; 338 } 310 339 else 340 { 311 341 $title = $caption; 342 } 312 343 313 344 imagestring($img, 1, 2, 2, $title, $captioncolor); … … 318 349 // "../fonts/04B_03__.TTF", 319 350 // $title ); 320 if ($this->mode_ == "map" && !$cached) imagepng($img, $regioncache); 351 if ($this->mode_ == "map" && !$cached) 352 { 353 imagepng($img, $regioncache); 354 } 321 355 header("Content-type: image/png"); 322 356 imagepng($img); -
dev/common/mapview.php
r10 r91 2 2 require_once("class.map.php"); 3 3 4 $view = new MapView($_GET['mode'], $_GET['size']); 5 $view->setSystemID($_GET['sys_id']); 4 function checkColors($context) 5 { 6 global $config, $view; 7 8 $a = array('line', 'bg', 'hl', 'normal', 'capt'); 9 foreach ($a as $b) 10 { 11 if ($string = $config->getConfig('map_'.$context.'_cl_'.$b)) 12 { 13 $tmp = explode(',', $string); 14 $function = 'set'.$b.'color'; 15 eval('$view->'.$function.'($tmp[0], $tmp[1], $tmp[2]);'); 16 } 17 } 18 } 19 20 $view = new MapView(slashfix($_GET['mode']), intval($_GET['size'])); 21 $view->setSystemID(intval($_GET['sys_id'])); 6 22 switch ($_GET['mode']) 7 23 { 8 24 case "map": 9 25 $view->setTitle("Region"); 26 $view->showLines($config->getConfig('map_map_showlines')); 27 checkColors('map'); 10 28 break; 11 29 case "region": 12 30 $view->setTitle("Constellation"); 13 $view->showLines( true);31 $view->showLines($config->getConfig('map_reg_showlines')); 14 32 $view->setOffset(25); 33 checkColors('reg'); 15 34 break; 16 35 case "cons": 17 $view->showLines( true);18 $view->showSysNames( true);36 $view->showLines($config->getConfig('map_con_showlines')); 37 $view->showSysNames($config->getConfig('map_con_shownames')); 19 38 $view->setOffset(25); 39 checkColors('con'); 20 40 break; 41 default: exit; 21 42 } 22 43