Changeset 44
- Timestamp:
- 11/01/06 23:56:02 (16 years ago)
- Location:
- dev
- Files:
-
- 71 added
- 14 modified
Legend:
- Unmodified
- Added
- Removed
-
dev/common/admin_sync.php
r39 r44 4 4 require_once("class.contract.php"); 5 5 require_once("admin_menu.php"); 6 require_once('class.http.php'); 6 7 7 8 $page = new Page(); … … 21 22 { 22 23 $content_file .= '!'.$data['plt_name'].'|'.$data['plt_externalid'].'-'; 23 //$data_array[$data['plt_name']] = $data['plt_externalid'];24 24 } 25 25 26 $url = parse_url(KB_SYNCURL); 27 //$url = parse_url('http://exi.ath.cx/eve/?a=sync_server'); 28 $fp = fsockopen($url["host"], 80, $errno, $errstr, 15); 26 $http = new http_request(KB_SYNCURL); 27 $fp = $http->connect(); 29 28 if (!$fp) 30 29 { 31 $html .= " Error occured with fsockopen: $errstr ($errno)<br>\n";30 $html .= "Could not connect to Server<br>\n"; 32 31 } 33 32 } 34 33 if ($do_sync && $fp) 35 34 { 36 $content_type = 'text/plain';37 $boundary = "-----".substr(md5(rand(0,32000)),0,10);38 35 $content_file = gzdeflate(&$content_file); 39 36 40 $header = "POST {$url['path']}?{$url['query']} HTTP/1.0\r\n". 41 "User-Agent: EVE-KB SYNC (VER ".KB_VERSION.")\r\n". 42 "Host: {$url['host']}\r\n". 43 "Content-Type: multipart/form-data, boundary=$boundary\r\n". 44 "Connection: close\r\n"; 45 $data .="--$boundary\r\n"; 46 $data .="Content-Disposition: form-data; name=\"data\"; filename=\"upload_".rand(0,01000).".txt\"\r\n"; 47 $data .= "Content-Type: $content_type\r\n\r\n"; 48 $data .= $content_file."\r\n"; 49 $data .="--$boundary\r\n"; 50 $header .= "Content-Length: " . strlen(&$data) . "\r\n\r\n"; 37 $http->set_postdata('data', &$content_file); 38 $http->set_useragent("EVE-KB SYNC (VER ".KB_VERSION.")"); 39 $file = $http->get_content(); 40 $header = $http->get_header(); 51 41 52 // send data 53 fputs($fp, $header.$data); 54 $sended = strlen(&$header)+strlen(&$data); 55 56 // wait for response 57 $header = true; 58 while ($line = fgets($fp, 4096)) 59 { 60 if ($header) 61 { 62 $http_header .= $line; 63 if (strstr($line, 'X-KBVersion:')) 64 { 65 $tmp = explode(':', $line); 66 $version = explode('.', trim($tmp[1])); 67 } 68 } 69 else 70 { 71 $file .= $line; 72 } 73 if ($line == "\r\n") 74 { 75 $header = 0; 76 } 77 } 78 $recv = strlen(&$http_header)+strlen(&$file); 42 preg_match("/X-KBVersion: (.*)/", $header, $match); 43 $version = explode('.', trim($match[1])); 44 $recv = $http->get_recv(); 45 $sended = $http->get_sent(); 79 46 80 47 // the response ($file) contains ids new to us 81 // we get a $_FILES, process82 48 $data = @gzinflate(&$file); 83 49 if ($data == false) -
dev/common/alliance_detail.php
r38 r44 10 10 require_once("class.toplist.php"); 11 11 12 $alliance = new Alliance( $_GET['all_id']);12 $alliance = new Alliance(intval($_GET['all_id'])); 13 13 $klist = new KillList(); 14 14 $klist->setOrdered(false); … … 28 28 $html .= "<table class=kb-table width=\"100%\" border=\"0\" cellspacing=1><tr class=kb-table-row-even><td rowspan=8 width=128 align=center>"; 29 29 30 if (file_exists("img/alliances/".$alliance->get ID().".jpg"))30 if (file_exists("img/alliances/".$alliance->getUnique().".png")) 31 31 { 32 $html .= "<img src=\"".IMG_URL."/alliances/".$alliance->get ID().".jpg\" border=\"0\"></td>";32 $html .= "<img src=\"".IMG_URL."/alliances/".$alliance->getUnique().".png\" border=\"0\"></td>"; 33 33 } 34 34 else … … 81 81 82 82 $list = new KillList(); 83 $list->setOrdered(true); 83 84 $list->setLimit(10); 84 85 $list->setPodsNoobships(true); -
dev/common/autoupgrade.php
r16 r44 8 8 if ($result) 9 9 { 10 check_commenttablerow(); 10 11 return; 11 12 } … … 15 16 `comment` TEXT NOT NULL , 16 17 `name` TINYTEXT NOT NULL , 18 `posttime` TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, 17 19 PRIMARY KEY ( `ID` ) 18 20 ) TYPE = MYISAM'; … … 20 22 } 21 23 24 function check_commenttablerow() 25 { 26 $qry = new DBQuery(); 27 $query = 'select count(posttime) from kb3_comments'; 28 $result = mysql_query($query); 29 if ($result) 30 { 31 check_commenttablerow(); 32 return; 33 } 34 $query = 'ALTER TABLE `kb3_comments` ADD `posttime` TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL'; 35 $qry->execute($query); 36 } 22 37 ?> -
dev/common/cc_detail.php
r10 r44 61 61 $summary->setVerbose(true); 62 62 $summary->setBreak(12); 63 $summary->set Filter(false);63 $summary->setView('combined'); 64 64 65 65 $html .= "<br><div class=kb-contract-target-header>Target " . $target->getType() . " - " . $target->getName() . "</div>"; … … 144 144 145 145 $pagesplitter = new PageSplitter($llist->getCount(), 30); 146 $llist->setPageSplitter($pagesplitter); 147 $table = new KillListTable($llist); 148 $table->setDayBreak(false); 149 $html .= $table->generate(); 150 $html .= $pagesplitter->generate(); 151 break; 152 case "combined": 153 $html .= "<div class=kb-kills-header>All kills</div>"; 154 155 $contract = new Contract($ctr_id); 156 $list = $contract->getKillList(); 157 $list->setOrdered(true); 158 if ($_GET['scl_id']) 159 $list->addVictimShipClass(new ShipClass($_GET['scl_id'])); 160 161 $pagesplitter = new PageSplitter($list->getCount(), 20); 162 $list->setPageSplitter($pagesplitter); 163 $table = new KillListTable($list); 164 $table->setDayBreak(false); 165 $html .= $table->generate(); 166 $html .= $pagesplitter->generate(); 167 168 $html .= "<div class=kb-losses-header>All losses</div>"; 169 170 $contract = new Contract($ctr_id); 171 $llist = $contract->getLossList(); 172 $llist->setOrdered(true); 173 if ($_GET['scl_id']) 174 $llist->addVictimShipClass(new ShipClass($_GET['scl_id'])); 175 176 $pagesplitter = new PageSplitter($llist->getCount(), 20); 146 177 $llist->setPageSplitter($pagesplitter); 147 178 $table = new KillListTable($llist); -
dev/common/class.alliance.php
r2 r44 1 <? 2 require_once( "db.php");1 <?php 2 require_once("db.php"); 3 3 4 class Alliance { 4 class Alliance 5 { 6 function Alliance($id = null) 7 { 8 $this->id_ = $id; 9 $this->qry_ = new DBQuery(); 5 10 6 function Alliance( $id = NULL ) 7 { 8 $this->id_ = $id; 9 $this->qry_ = new DBQuery(); 10 11 $this->sql_ = "select * 12 from kb3_alliances 13 where all_id = ".$this->id_; 11 $this->sql_ = "select * from kb3_alliances where all_id = " . $this->id_; 14 12 } 15 13 16 14 function getID() 17 15 { 18 return $this->id_; 16 return $this->id_; 17 } 18 19 function getUnique() 20 { 21 return preg_replace('/[^a-zA-Z0-9]/', '', $this->getName()); 19 22 } 20 23 21 24 function getName() 22 25 { 23 $this->execQuery();24 return $this->row_['all_name'];26 $this->execQuery(); 27 return $this->row_['all_name']; 25 28 } 26 29 27 30 function execQuery() 28 31 { 29 if ( !$this->qry_->executed_ ) { 30 $this->qry_->execute( $this->sql_ ); 31 $this->row_ = $this->qry_->getRow(); 32 } 32 if (!$this->qry_->executed_) 33 { 34 $this->qry_->execute($this->sql_); 35 $this->row_ = $this->qry_->getRow(); 36 } 33 37 } 34 38 35 function add( $name)39 function add($name) 36 40 { 37 $qry = new DBQuery(); 38 $qry->execute( "select * 39 from kb3_alliances 40 where all_name = '".slashfix( $name )."'" ); 41 42 if ( $qry->recordCount() == 0 ) { 43 $qry->execute( "insert into kb3_alliances values ( null, 44 '".slashfix( $name )."', 45 'default' )" ); 46 $this->id_ = $qry->getInsertID(); 47 } 48 else { 49 $row = $qry->getRow(); 50 $this->id_ = $row['all_id']; 51 } 41 $qry = new DBQuery(); 42 $qry->execute("select * from kb3_alliances where all_name = '".slashfix($name)."'"); 43 44 if ($qry->recordCount() == 0) 45 { 46 $qry->execute("insert into kb3_alliances values ( null,'".slashfix($name)."','default' )"); 47 $this->id_ = $qry->getInsertID(); 48 } 49 else 50 { 51 $row = $qry->getRow(); 52 $this->id_ = $row['all_id']; 53 } 52 54 } 53 54 } 55 } 55 56 ?> -
dev/common/class.kill.php
r42 r44 396 396 { 397 397 $qry = new DBQuery(); 398 $sql = "SELECT * FROM kb3_comments WHERE kll_id = '$kll_id'";398 $sql = "SELECT * FROM kb3_comments WHERE kll_id = '$kll_id'"; 399 399 $count = $qry->execute($sql); 400 400 $count = $qry->recordCount(); -
dev/common/class.killlisttable.php
r33 r44 104 104 } 105 105 106 if ($ this->kill_list_->qry_->recordCount()> 0)106 if ($c > 0) 107 107 $html .= "</table>\n"; 108 108 else -
dev/common/class.killsummarytable.php
r2 r44 1 <? 2 require_once( "db.php");3 require_once( "class.page.php");4 require_once( "class.ship.php");5 require_once( "class.profiler.php");6 7 8 9 function KillSummaryTable( $klist, $llist)10 { 11 $this->klist_ = $klist;12 $this->llist_ = $llist;13 14 $this->verbose_ = false;15 $this->filter_ = true;16 } 17 18 function setBreak( $break)19 { 20 $this->break_ = $break;21 } 22 23 function setVerbose( $verbose)24 { 25 $this->verbose_ = $verbose;26 } 27 28 function setFilter( $filter)29 { 30 $this->filter_ = $filter;1 <?php 2 require_once("db.php"); 3 require_once("class.page.php"); 4 require_once("class.ship.php"); 5 require_once("class.profiler.php"); 6 7 class KillSummaryTable 8 { 9 function KillSummaryTable($klist, $llist) 10 { 11 $this->klist_ = $klist; 12 $this->llist_ = $llist; 13 14 $this->verbose_ = false; 15 $this->filter_ = true; 16 } 17 18 function setBreak($break) 19 { 20 $this->break_ = $break; 21 } 22 23 function setVerbose($verbose) 24 { 25 $this->verbose_ = $verbose; 26 } 27 28 function setFilter($filter) 29 { 30 $this->filter_ = $filter; 31 31 } 32 32 33 33 function getTotalKills() 34 34 { 35 return $this->tkcount_;35 return $this->tkcount_; 36 36 } 37 37 38 38 function getTotalLosses() 39 39 { 40 return $this->tlcount_;40 return $this->tlcount_; 41 41 } 42 42 43 43 function getTotalKillPoints() 44 44 { 45 return $this->tkpoints_;45 return $this->tkpoints_; 46 46 } 47 47 48 48 function getTotalLossPoints() 49 49 { 50 return $this->tlpoints_;51 } 52 50 return $this->tlpoints_; 51 } 52 53 53 function getTotalKillISK() 54 54 { 55 return $this->tkisk_;55 return $this->tkisk_; 56 56 } 57 57 58 58 function getTotalLossISK() 59 59 { 60 return $this->tlisk_; 61 } 60 return $this->tlisk_; 61 } 62 63 function setView($string) 64 { 65 $this->view_ = $string; 66 } 62 67 63 68 function generate() 64 69 { 65 // build array66 $sql = "select scl_id, scl_class70 // build array 71 $sql = "select scl_id, scl_class 67 72 from kb3_ship_classes 68 73 where scl_class not in ( 'Drone', 'Unknown' ) 69 74 order by scl_class"; 70 71 $qry = new DBQuery(); 72 $qry->execute( $sql ) or die( $qry->getErrorMsg() ); 73 while ( $row = $qry->getRow() ) { 74 if ( !$row['scl_id'] ) 75 continue; 76 77 $shipclass = new ShipClass( $row['scl_id'] ); 78 $shipclass->setName( $row['scl_class'] ); 79 80 $entry[$shipclass->getName()]['id'] = $row['scl_id']; 81 $entry[$shipclass->getName()]['kills'] = 0; 82 $entry[$shipclass->getName()]['kills_isk'] = 0; 83 $entry[$shipclass->getName()]['losses'] = 0; 84 $entry[$shipclass->getName()]['losses_isk'] = 0; 85 } 86 87 // kills 88 while ( $kill = $this->klist_->getKill() ) { 89 $classname = $kill->getVictimShipClassName(); 90 $entry[$classname]['kills']++; 91 $entry[$classname]['kills_isk']+= $kill->getVictimShipValue(); 92 $this->tkcount_++; 93 $this->tkisk_ += $kill->getVictimShipValue(); 94 } 95 96 // losses 97 while ( $kill = $this->llist_->getKill() ) { 98 $classname = $kill->getVictimShipClassName(); 99 $entry[$classname]['losses']++; 100 $entry[$classname]['losses_isk']+= $kill->getVictimShipValue(); 101 $this->tlcount_++; 102 $this->tlisk_ += $kill->getVictimShipValue(); 103 } 104 105 $odd = false; 106 $prevdate = ""; 107 $html .= "<table class=kb-subtable width=\"100%\" border=\"0\" cellspacing=0>"; 108 if ( $this->break_ ) 109 $html .= "<tr><td valign=top><table class=kb-table cellspacing=\"1\" width=\"100%\">"; 110 $counter = 1; 111 112 if ( $this->verbose_ ) { 113 $header = "<tr class=kb-table-header><td class=kb-table-cell width=110>Ship class</td><td class=kb-table-cell width=60 align=center>Kills</td><td class=kb-table-cell width=60 align=center>ISK (M)</td><td class=kb-table-cell width=60 align=center>Losses</td><td class=kb-table-cell width=60 align=center>ISK (M)</td></tr>"; 114 } 115 else { 116 $header = "<tr class=kb-table-header><td class=kb-table-cell width=110>Ship class</td><td class=kb-table-cell width=30 align=center>K</td><td class=kb-table-cell width=30 align=center>L</td></tr>"; 117 } 118 $html .= $header; 119 120 foreach ( $entry as $k => $v ) { 121 if ( !$v['id'] || $v['id'] == 3 ) 122 continue; 123 if ( $this->break_ && $counter > $this->break_ ) { 124 $html .= "</table></td>"; 125 $html .= "<td valign=top><table class=kb-table cellspacing=\"1\">"; 126 $html .= $header; 127 $counter = 1; 128 } 129 130 131 if ( !$odd ) { 132 $odd = true; 133 $class = 'kb-table-row-odd'; 134 } 135 else { 136 $odd = false; 137 $class = 'kb-table-row-even'; 138 } 139 140 if ( $_GET['scl_id'] != "" && $v['id'] == $_GET['scl_id'] ) 141 $highlight="-hl"; 142 else 143 $highlight=""; 144 145 if ( $v['kills'] == 0 ) 146 $kclass = "kl-kill-null"; 75 76 $qry = new DBQuery(); 77 $qry->execute($sql) or die($qry->getErrorMsg()); 78 while ($row = $qry->getRow()) 79 { 80 if (!$row['scl_id']) 81 continue; 82 83 $shipclass = new ShipClass($row['scl_id']); 84 $shipclass->setName($row['scl_class']); 85 86 $entry[$shipclass->getName()]['id'] = $row['scl_id']; 87 $entry[$shipclass->getName()]['kills'] = 0; 88 $entry[$shipclass->getName()]['kills_isk'] = 0; 89 $entry[$shipclass->getName()]['losses'] = 0; 90 $entry[$shipclass->getName()]['losses_isk'] = 0; 91 } 92 // kills 93 while ($kill = $this->klist_->getKill()) 94 { 95 $classname = $kill->getVictimShipClassName(); 96 $entry[$classname]['kills']++; 97 $entry[$classname]['kills_isk'] += $kill->getVictimShipValue(); 98 $this->tkcount_++; 99 $this->tkisk_ += $kill->getVictimShipValue(); 100 } 101 // losses 102 while ($kill = $this->llist_->getKill()) 103 { 104 $classname = $kill->getVictimShipClassName(); 105 $entry[$classname]['losses']++; 106 $entry[$classname]['losses_isk'] += $kill->getVictimShipValue(); 107 $this->tlcount_++; 108 $this->tlisk_ += $kill->getVictimShipValue(); 109 } 110 111 $odd = false; 112 $prevdate = ""; 113 $html .= "<table class=kb-subtable width=\"100%\" border=\"0\" cellspacing=0>"; 114 if ($this->break_) 115 $html .= "<tr><td valign=top><table class=kb-table cellspacing=\"1\" width=\"100%\">"; 116 $counter = 1; 117 118 if ($this->verbose_) 119 { 120 $header = "<tr class=kb-table-header><td class=kb-table-cell width=110>Ship class</td><td class=kb-table-cell width=60 align=center>Kills</td><td class=kb-table-cell width=60 align=center>ISK (M)</td><td class=kb-table-cell width=60 align=center>Losses</td><td class=kb-table-cell width=60 align=center>ISK (M)</td></tr>"; 121 } 147 122 else 148 $kclass = "kl-kill"; 149 150 if ( $v['losses'] == 0 ) 151 $lclass = "kl-loss-null"; 152 else 153 $lclass = "kl-loss"; 154 155 if ( $this->verbose_ ) { 156 $kclass .= "-bg"; 157 $lclass .= "-bg"; 158 } 159 160 $html .= "<tr class=".$class.">"; 161 162 $qrystring = preg_replace( "/&scl_id=([0-9]?[0-9])/", "", $_SERVER['QUERY_STRING'] ); 163 $qrystring = preg_replace( "/&page=([0-9]?[0-9])/", "", $qrystring ); 164 $html .= "<td class=kb-table-cell><b>"; 165 166 if ( $this->filter_ ) $html .= "<a class=kb-shipclass".$highlight." href=\"?".$qrystring."&scl_id=".$v['id']."\">"; 167 168 $html .= $k; 169 170 if ( $this->filter_ ) $html .= "</a>"; 171 172 $html .= "</b></td>"; 173 174 $html .= "<td class=".$kclass." align=center>".$v['kills']."</td>"; 175 if ( $this->verbose_ ) 176 $html .= "<td class=".$kclass." align=center>".$v['kills_isk']."</td>"; 177 $html .= "<td class=".$lclass." align=center>".$v['losses']."</td>"; 178 if ( $this->verbose_ ) 179 $html .= "<td class=".$lclass." align=center>".$v['losses_isk']."</td>"; 180 181 $html .= "</tr>"; 182 183 $counter++; 184 $this->tkcount_ += $kcount; 185 $this->tlcount_ += $lcount; 186 $this->tkisk_ += $kisk; 187 $this->tlisk_ += $lisk; 188 $this->tkpoints_ += $kpoints; 189 $this->tlpoints_ += $lpoints; 190 } 191 if ( $this->break_ ) 192 $html .= "</table></td>"; 193 194 $html .= "</tr></table>"; 195 196 if ( $_GET['scl_id'] != "" ) { 197 $html .= "<table align=center><tr><td align=center valign=top class=weeknav>"; 198 $qrystring = preg_replace( "/&scl_id=([0-9]?[0-9])/", "", $_SERVER['QUERY_STRING'] ); $html .= "[<a href=\"?".$qrystring."\">clear filter</a>]</td></tr></table>"; 199 } 200 201 return $html; 202 203 } 204 } 205 123 { 124 $header = "<tr class=kb-table-header><td class=kb-table-cell width=110>Ship class</td><td class=kb-table-cell width=30 align=center>K</td><td class=kb-table-cell width=30 align=center>L</td></tr>"; 125 } 126 $html .= $header; 127 128 foreach ($entry as $k => $v) 129 { 130 if (!$v['id'] || $v['id'] == 3) 131 continue; 132 if ($this->break_ && $counter > $this->break_) 133 { 134 $html .= "</table></td>"; 135 $html .= "<td valign=top><table class=kb-table cellspacing=\"1\">"; 136 $html .= $header; 137 $counter = 1; 138 } 139 140 if (!$odd) 141 { 142 $odd = true; 143 $class = 'kb-table-row-odd'; 144 } 145 else 146 { 147 $odd = false; 148 $class = 'kb-table-row-even'; 149 } 150 151 if ($_GET['scl_id'] != "" && $v['id'] == $_GET['scl_id']) 152 $highlight = "-hl"; 153 else 154 $highlight = ""; 155 156 if ($v['kills'] == 0) 157 $kclass = "kl-kill-null"; 158 else 159 $kclass = "kl-kill"; 160 161 if ($v['losses'] == 0) 162 $lclass = "kl-loss-null"; 163 else 164 $lclass = "kl-loss"; 165 166 if ($this->verbose_) 167 { 168 $kclass .= "-bg"; 169 $lclass .= "-bg"; 170 } 171 172 $html .= "<tr class=" . $class . ">"; 173 174 $qrystring = preg_replace("/&scl_id=([0-9]?[0-9])/", "", $_SERVER['QUERY_STRING']); 175 $qrystring = preg_replace("/&page=([0-9]?[0-9])/", "", $qrystring); 176 if ($this->view_) 177 { 178 $qrystring .= '&view='.$this->view_; 179 } 180 $html .= "<td class=kb-table-cell><b>"; 181 182 if ($this->filter_) $html .= "<a class=kb-shipclass" . $highlight . " href=\"?" . $qrystring . "&scl_id=" . $v['id'] . "\">"; 183 184 $html .= $k; 185 186 if ($this->filter_) $html .= "</a>"; 187 188 $html .= "</b></td>"; 189 190 $html .= "<td class=" . $kclass . " align=center>" . $v['kills'] . "</td>"; 191 if ($this->verbose_) 192 $html .= "<td class=" . $kclass . " align=center>" . $v['kills_isk'] . "</td>"; 193 $html .= "<td class=" . $lclass . " align=center>" . $v['losses'] . "</td>"; 194 if ($this->verbose_) 195 $html .= "<td class=" . $lclass . " align=center>" . $v['losses_isk'] . "</td>"; 196 197 $html .= "</tr>"; 198 199 $counter++; 200 $this->tkcount_ += $kcount; 201 $this->tlcount_ += $lcount; 202 $this->tkisk_ += $kisk; 203 $this->tlisk_ += $lisk; 204 $this->tkpoints_ += $kpoints; 205 $this->tlpoints_ += $lpoints; 206 } 207 if ($this->break_) 208 $html .= "</table></td>"; 209 210 $html .= "</tr></table>"; 211 212 if ($_GET['scl_id'] != "") 213 { 214 $html .= "<table align=center><tr><td align=center valign=top class=weeknav>"; 215 $qrystring = preg_replace("/&scl_id=([0-9]?[0-9])/", "", $_SERVER['QUERY_STRING']); 216 $html .= "[<a href=\"?" . $qrystring . "\">clear filter</a>]</td></tr></table>"; 217 } 218 219 return $html; 220 } 221 } 206 222 ?> -
dev/common/comments.php
r41 r44 56 56 57 57 $qry = new DBQuery(); 58 $qry->execute("SELECT id, name, commentFROM kb3_comments WHERE `kll_id` = $kll_id");58 $qry->execute("SELECT * FROM kb3_comments WHERE `kll_id` = $kll_id"); 59 59 if ($qry->recordCount() == 0) 60 60 { … … 68 68 $name = $data['name']; 69 69 $comment = $data['comment']; 70 $html .= "<div class=\"comment-text\"><a href=\"?a=search&searchtype=pilot&searchphrase=".$name."\">".$name."</a>:<p>".$comment."</p>"; 70 $html .= "\n<div class=\"comment-text\" style=\"position: relative;\"><a href=\"?a=search&searchtype=pilot&searchphrase=".$name."\">".$name."</a>:"; 71 if ($data['posttime'] && $data['posttime'] != '0000-00-00 00:00:00') 72 { 73 $html .= '<span style="position:absolute; right: 0px;">'.$data['posttime'].'</span>'; 74 } 75 $html .= "<p>".$comment."</p>"; 71 76 if ($page->isAdmin()) 72 77 { 73 78 $html .= "<a href=\"javascript:openWindow('?a=comments_delete&c_id=".$data['id']."', null, 480, 350, '' );\">Delete Comment</a>"; 74 79 } 75 $html .= "</div> <br/>";80 $html .= "</div>"; 76 81 } 77 82 } -
dev/common/corp_detail.php
r10 r44 10 10 require_once("class.toplist.php"); 11 11 12 $corp = new Corporation( $_GET['crp_id']);12 $corp = new Corporation(intval($_GET['crp_id'])); 13 13 $alliance = $corp->getAlliance(); 14 14 -
dev/common/db.php
r2 r44 1 <? 2 require_once( "config.php");3 require_once( "globals.php");4 5 class DBConnection { 6 1 <?php 2 require_once("config.php"); 3 require_once("globals.php"); 4 5 class DBConnection 6 { 7 7 function DBConnection() 8 8 { 9 if ( !$this->id_ = mysql_pconnect( DB_HOST, DB_USER, DB_PASS ) ) 10 die( "Unable to connect to mysql database." ); 11 12 mysql_selectdb( DB_NAME ); 13 } 14 15 function id() { return $this->id_; } 9 if (!$this->id_ = mysql_pconnect(DB_HOST, DB_USER, DB_PASS)) 10 die("Unable to connect to mysql database."); 11 12 mysql_selectdb(DB_NAME); 13 } 14 15 function id() 16 { 17 return $this->id_; 18 } 16 19 17 20 function affectedRows() 18 21 { 19 return mysql_affected_rows( $this->id_);20 } 21 22 23 class DBQuery { 24 22 return mysql_affected_rows($this->id_); 23 } 24 } 25 26 class DBQuery 27 { 25 28 function DBQuery() 26 29 { 27 $this->executed_ = false; 28 $this->dbconn_ = new DBConnection; 29 } 30 31 function execute( $sql ) 32 { 33 $t1 = strtok(microtime(), ' ') + strtok(''); 34 35 $this->resid_ = mysql_query( $sql, $this->dbconn_->id() ); 36 37 if ( !$this->resid_ ) { 38 echo "Database error: ".mysql_error( $this->dbconn_->id() )."<br>"; 39 echo "SQL: ".$sql."<br>"; 40 exit; 41 } 42 43 $this->exectime_ = strtok(microtime(), ' ') + strtok('') - $t1; 44 $this->executed_ = true; 45 46 if ( KB_PROFILE == 2 ) { 47 file_put_contents ( '/tmp/profile.lst', $sql."\nExecution time: ".$this->exectime_."\n", FILE_APPEND ); 48 } 49 50 return true; 30 $this->executed_ = false; 31 $this->dbconn_ = new DBConnection; 32 } 33 34 function execute($sql) 35 { 36 $t1 = strtok(microtime(), ' ') + strtok(''); 37 38 $this->resid_ = mysql_query($sql, $this->dbconn_->id()); 39 40 if (!$this->resid_) 41 { 42 if (defined(DB_HALTONERROR) && DB_HALTONERROR) 43 { 44 echo "Database error: " . mysql_error($this->dbconn_->id()) . "<br>"; 45 echo "SQL: " . $sql . "<br>"; 46 exit; 47 } 48 else 49 { 50 return false; 51 } 52 } 53 54 $this->exectime_ = strtok(microtime(), ' ') + strtok('') - $t1; 55 $this->executed_ = true; 56 57 if (KB_PROFILE == 2) 58 { 59 file_put_contents('/tmp/profile.lst', $sql . "\nExecution time: " . $this->exectime_ . "\n", FILE_APPEND); 60 } 61 62 return true; 51 63 } 52 64 53 65 function recordCount() 54 66 { 55 return mysql_num_rows( $this->resid_);67 return mysql_num_rows($this->resid_); 56 68 } 57 69 58 70 function getRow() 59 71 { 60 $row = mysql_fetch_assoc( $this->resid_);61 62 return $row;72 $row = mysql_fetch_assoc($this->resid_); 73 74 return $row; 63 75 } 64 76 65 77 function rewind() 66 78 { 67 @mysql_data_seek ( $this->resid_, 0);79 @mysql_data_seek($this->resid_, 0); 68 80 } 69 81 70 82 function getInsertID() 71 83 { 72 return mysql_insert_id();84 return mysql_insert_id(); 73 85 } 74 86 75 87 function execTime() 76 88 { 77 return $this->exectime_;89 return $this->exectime_; 78 90 } 79 91 80 92 function executed() 81 93 { 82 return $this->executed_;94 return $this->executed_; 83 95 } 84 96 85 97 function getErrorMsg() 86 98 { 87 $msg = $this->sql_."<br>"; 88 $msg .= "Query failed. ".mysql_error( $this->dbconn_->id() ); 89 90 return $msg; 91 } 92 } 93 94 class DBAction 95 { 96 99 $msg = $this->sql_ . "<br>"; 100 $msg .= "Query failed. " . mysql_error($this->dbconn_->id()); 101 102 return $msg; 103 } 104 } 105 106 class DBAction 107 { 97 108 function DBAction() 98 109 { 99 $this->dbconn_ = new DBConnection(); 100 } 101 102 function setDateTime( $timestamp ) 103 { 104 $this->timestamp_ = $timestamp; 105 } 106 107 function addPilot( $pilot, $corpid, $timestamp ) 108 { 109 $sql = "select * from kb3_pilots where plt_name = '".addslashes( stripslashes( $pilot ) )."'"; 110 $qry = new DBQuery( $this->dbconn_, $sql ); 111 $qry->execute() or die( $qry->getErrorMsg() ); 112 113 if ( $qry->recordCount() == 0 ) { 114 $sql = "insert into kb3_pilots values ( null, '".addslashes( stripslashes( $pilot ) )."', ".$corpid.", 0, 0, 0, date_format('".$timestamp."', '%Y.%m.%d %H:%i:%s') )"; 115 $qry = new DBQuery( $this->dbconn_, $sql ) or die ( $qry->getErrorMsg() ); 116 $qry->execute() or die( $qry->getErrorMsg() ); 117 $pilotid = $qry->getInsertID(); 118 } 119 else { 110 $this->dbconn_ = new DBConnection(); 111 } 112 113 function setDateTime($timestamp) 114 { 115 $this->timestamp_ = $timestamp; 116 } 117 118 function addPilot($pilot, $corpid, $timestamp) 119 { 120 $sql = "select * from kb3_pilots where plt_name = '" . addslashes(stripslashes($pilot)) . "'"; 121 $qry = new DBQuery($this->dbconn_, $sql); 122 $qry->execute() or die($qry->getErrorMsg()); 123 124 if ($qry->recordCount() == 0) 125 { 126 $sql = "insert into kb3_pilots values ( null, '" . addslashes(stripslashes($pilot)) . "', " . $corpid . ", 0, 0, 0, date_format('" . $timestamp . "', '%Y.%m.%d %H:%i:%s') )"; 127 $qry = new DBQuery($this->dbconn_, $sql) or die ($qry->getErrorMsg()); 128 $qry->execute() or die($qry->getErrorMsg()); 129 $pilotid = $qry->getInsertID(); 130 } 131 else 132 { 133 $row = $qry->getRow(); 134 $pilotid = $row['plt_id']; 135 $dbaction = new DBAction(); 136 137 if ($dbaction->isPilotUpdatable($pilotid, $timestamp) && $$row['plt_crp_id'] != $corpid) 138 { 139 $qry = new DBQuery($this->dbconn_, "update kb3_pilots set plt_crp_id = " . $corpid . ", plt_updated = date_format('" . $timestamp . "', '%Y.%m.%d %H:%i:%s') where plt_id = " . $pilotid); 140 $qry->execute() or die($qry->getErrorMsg()); 141 } 142 } 143 144 return $pilotid; 145 } 146 147 function setCharacterId($pilotid, $charid) 148 { 149 $sql = "update kb3_pilots set plt_externalid = " . $charid . " where plt_id = " . $pilotid; 150 151 $qry = new DBQuery($this->dbconn_, $sql); 152 $qry->execute(); 153 } 154 155 function addAlliance($alliance) 156 { 157 $sql = "select * from kb3_alliances where all_name = '" . addslashes(stripslashes($alliance)) . "'"; 158 $qry = new DBQuery($this->dbconn_, $sql); 159 $qry->execute() or die($qry->getErrorMsg()); 160 161 if ($qry->recordCount() == 0) 162 { 163 $sql = "insert into kb3_alliances values ( null, '" . addslashes(stripslashes($alliance)) . "', 'default' )"; 164 $qry = new DBQuery($this->dbconn_, $sql); 165 $qry->execute() or die($qry->getErrorMsg()); 166 $allianceid = $qry->getInsertID(); 167 } 168 else 169 { 170 $row = $qry->getRow(); 171 $allianceid = $row['all_id']; 172 } 173 174 return $allianceid; 175 } 176 177 function addCorp($corp, $allianceid, $timestamp) 178 { 179 $sql = "select * from kb3_corps where crp_name = '" . addslashes(stripslashes($corp)) . "'"; 180 $qry = new DBQuery($this->dbconn_, $sql); 181 $qry->execute() or die($qry->getErrorMsg()); 182 183 if ($qry->recordCount() == 0) 184 { 185 $sql = "insert into kb3_corps values ( null, '" . addslashes(stripslashes($corp)) . "', " . $allianceid . ", 0, date_format('" . $timestamp . "', '%Y.%m.%d %H:%i:%s') )"; 186 $qry = new DBQuery($this->dbconn_, $sql); 187 $qry->execute() or die($qry->getErrorMsg()); 188 $corpid = $qry->getInsertID(); 189 } 190 else 191 { 192 $row = $qry->getRow(); 193 $corpid = $row['crp_id']; 194 195 $dbaction = new DBAction(); 196 197 if ($dbaction->isCorpUpdatable($corpid, $timestamp) && $row['crp_all_id'] != $allianceid && $row['crp_trial'] != 1) 198 { 199 $sql = "update kb3_corps set crp_all_id = " . $allianceid . ", crp_updated = date_format('" . $timestamp . "', '%Y.%m.%d %H:%i:%s') 200 where crp_id = " . $corpid; 201 $qry = new DBQuery($this->dbconn_, $sql); 202 $qry->execute() or die($qry->getErrorMsg()); 203 } 204 } 205 206 return $corpid; 207 } 208 209 function addShip($ship, $description, $baseprice) 210 { 211 $sql = "select * from kb3_ships where shp_name = '" . addslashes(stripslashes($ship)) . "'"; 212 $qry = new DBQuery($this->dbconn_, $sql); 213 $qry->execute(); 214 215 if ($qry->recordCount() == 0) 216 { 217 $sql = "insert into kb3_ships values ( null, '" . addslashes(stripslashes($ship)) . "', 0, 0, 0, null, 0 )"; 218 $qry = new DBQuery($this->dbconn_, $sql); 219 $qry->execute(); 220 $shipid = $qry->getInsertID(); 221 } 222 else 223 { 224 $row = $qry->getRow(); 225 $shipid = $row['shp_id']; 226 if ($description != "") 227 { 228 $sql = "update kb3_ships set shp_description = '" . addslashes(stripslashes($description)) . "', shp_baseprice = " . $baseprice . " where shp_id = " . $shipid; 229 $qry = new DBQuery($this->dbconn_, $sql) or die($qry->getErrorMsg()); 230 $qry->execute(); 231 } 232 } 233 234 return $shipid; 235 } 236 237 function addItem($item, $description, $volume, $type, $icon) 238 { 239 $sql = "select * from kb3_items where itm_name = '" . addslashes(stripslashes($item)) . "'"; 240 $qry = new DBQuery($this->dbconn_, $sql) or die ($qry->getErrorMsg()); 241 $qry->execute(); 242 243 if ($qry->recordCount() == 0) 244 { 245 $sql = "insert into kb3_items values ( null, '" . addslashes(stripslashes($item)) . "', '" . addslashes(stripslashes($description)) . "', " . $volume . ", " . $type . ", null, 1, '" . $icon . "' )"; 246 $qry = new DBQuery($this->dbconn_, $sql); 247 $qry->execute() or die ($qry->getErrorMsg()); 248 $itemid = $qry->getInsertID(); 249 return -1; 250 } 251 else 252 { 253 $row = $qry->getRow(); 254 $itemid = $row['itm_id']; 255 if ($description != "") 256 { 257 $sql = "update kb3_items set itm_description = '" . addslashes(stripslashes($description)) . "', itm_volume = " . $volume . ", itm_type = " . $type . ", itm_icon = '" . $icon . "' where itm_id = " . $itemid; 258 $qry = new DBQuery($this->dbconn_, $sql); 259 $qry->execute() or die ($qry->getErrorMsg()); 260 } 261 } 262 263 return $itemid; 264 } 265 266 function setIcon($itemid, $icon) 267 { 268 $sql = "update kb3_items set itm_icon = '" . $icon . "' where itm_id = " . $itemid; 269 $qry = new DBQuery($this->dbconn_, $sql); 270 $qry->execute(); 271 } 272 273 function addSystem($system, $systemsec) 274 { 275 $sql = "select * from kb3_systems where sys_name = '" . addslashes(stripslashes($system)) . "'"; 276 $qry = new DBQuery($this->dbconn_, $sql); 277 $qry->execute() or die ($qry->getErrorMsg()); 278 279 if ($qry->recordCount() == 0) 280 { 281 $sql = "insert into kb3_systems values ( null, '" . addslashes(stripslashes($system)) . "', '" . $systemsec . "', 0 )"; 282 $qry = new DBQuery($this->dbconn_, $sql); 283 $qry->execute() or die ($qry->getErrorMsg()); 284 $systemid = $qry->getInsertID(); 285 } 286 else 287 { 288 $row = $qry->getRow(); 289 $systemid = $row['sys_id']; 290 } 291 292 return $systemid; 293 } 294 295 function addInvolved($killid, $pilotid, $secstatus, $allianceid, $corpid, $shipid, $weaponid, $finalblow, $order) 296 { 297 $sql = "insert into _" . KB_SITE . "_involved values ( " . $killid . ", " . $pilotid . ", '" . $secstatus . "', " . $allianceid . ", " . $corpid . ", " . $shipid . ", " . $weaponid . ", " . $finalblow . ", " . $order . " )"; 298 $qry = new DBQuery($this->dbconn_, $sql); 299 $qry->execute() or die ($qry->getErrorMsg()); 300 } 301 302 function addDestroyedItem($killid, $itemid, $quantity, $location) 303 { 304 $qry = new DBQuery($this->dbconn_, "select itl_id from kb3_item_locations where itl_location = '" . $location . "'"); 305 $qry->execute() or die($qry->getErrorMsg()); 120 306 $row = $qry->getRow(); 121 $pilotid = $row['plt_id']; 122 $dbaction = new DBAction(); 123 124 if ( $dbaction->isPilotUpdatable( $pilotid, $timestamp ) && $$row['plt_crp_id'] != $corpid ) { 125 $qry = new DBQuery( $this->dbconn_, "update kb3_pilots set plt_crp_id = ".$corpid.", plt_updated = date_format('".$timestamp."', '%Y.%m.%d %H:%i:%s') where plt_id = ".$pilotid ); 126 $qry->execute() or die( $qry->getErrorMsg() ); 127 } 128 } 129 130 return $pilotid; 131 } 132 133 function setCharacterId( $pilotid, $charid ) 134 { 135 $sql = "update kb3_pilots set plt_externalid = ".$charid." where plt_id = ".$pilotid; 136 137 $qry = new DBQuery( $this->dbconn_, $sql ); 138 $qry->execute(); 139 } 140 141 function addAlliance( $alliance ) 142 { 143 $sql = "select * from kb3_alliances where all_name = '".addslashes( stripslashes($alliance ) )."'"; 144 $qry = new DBQuery( $this->dbconn_, $sql ); 145 $qry->execute() or die( $qry->getErrorMsg() ); 146 147 if ( $qry->recordCount() == 0 ) { 148 $sql = "insert into kb3_alliances values ( null, '".addslashes( stripslashes( $alliance ) )."', 'default' )"; 149 $qry = new DBQuery( $this->dbconn_, $sql ); 150 $qry->execute() or die( $qry->getErrorMsg() ); 151 $allianceid = $qry->getInsertID(); 152 } 153 else { 154 $row = $qry->getRow(); 155 $allianceid = $row['all_id']; 156 } 157 158 return $allianceid; 159 } 160 161 function addCorp( $corp, $allianceid, $timestamp ) 162 { 163 $sql = "select * from kb3_corps where crp_name = '".addslashes( stripslashes( $corp ) )."'"; 164 $qry = new DBQuery( $this->dbconn_, $sql ); 165 $qry->execute() or die( $qry->getErrorMsg() ); 166 167 if ( $qry->recordCount() == 0 ) { 168 $sql = "insert into kb3_corps values ( null, '".addslashes( stripslashes($corp ) )."', ".$allianceid.", 0, date_format('".$timestamp."', '%Y.%m.%d %H:%i:%s') )"; 169 $qry = new DBQuery( $this->dbconn_, $sql ); 170 $qry->execute() or die( $qry->getErrorMsg() ); 171 $corpid = $qry->getInsertID(); 172 } 173 else { 174 $row = $qry->getRow(); 175 $corpid = $row['crp_id']; 176 177 $dbaction = new DBAction(); 178 179 180 if ( $dbaction->isCorpUpdatable( $corpid, $timestamp ) && $row['crp_all_id'] != $allianceid && $row['crp_trial'] != 1 ) { 181 $sql = "update kb3_corps set crp_all_id = ".$allianceid.", crp_updated = date_format('".$timestamp."', '%Y.%m.%d %H:%i:%s') 182 where crp_id = ".$corpid; 183 $qry = new DBQuery( $this->dbconn_, $sql ); 184 $qry->execute() or die( $qry->getErrorMsg() ); 185 } 186 } 187 188 return $corpid; 189 } 190 191 function addShip( $ship, $description, $baseprice ) 192 { 193 $sql = "select * from kb3_ships where shp_name = '".addslashes( stripslashes($ship ) )."'"; 194 $qry = new DBQuery( $this->dbconn_, $sql ); 195 $qry->execute(); 196 197 if ( $qry->recordCount() == 0 ) { 198 $sql = "insert into kb3_ships values ( null, '".addslashes( stripslashes($ship ) )."', 0, 0, 0, null, 0 )"; 199 $qry = new DBQuery( $this->dbconn_, $sql ); 200 $qry->execute(); 201 $shipid = $qry->getInsertID(); 202 } 203 else { 204 $row = $qry->getRow(); 205 $shipid = $row['shp_id']; 206 if ( $description != "" ) { 207 $sql = "update kb3_ships set shp_description = '".addslashes( stripslashes( $description ) )."', shp_baseprice = ".$baseprice." where shp_id = ".$shipid; 208 $qry = new DBQuery( $this->dbconn_, $sql ) or die( $qry->getErrorMsg() ); 209 $qry->execute(); 210 } 211 } 212 213 return $shipid; 214 } 215 216 function addItem( $item, $description, $volume, $type, $icon ) 217 { 218 $sql = "select * from kb3_items where itm_name = '".addslashes( stripslashes($item ) )."'"; 219 $qry = new DBQuery( $this->dbconn_, $sql ) or die ( $qry->getErrorMsg() ); 220 $qry->execute(); 221 222 if ( $qry->recordCount() == 0 ) { 223 $sql = "insert into kb3_items values ( null, '".addslashes( stripslashes($item ) )."', '".addslashes( stripslashes($description ) )."', ".$volume.", ".$type.", null, 1, '".$icon."' )"; 224 $qry = new DBQuery( $this->dbconn_, $sql ); 225 $qry->execute() or die ( $qry->getErrorMsg() ); 226 $itemid = $qry->getInsertID(); 227 return -1; 228 } 229 else { 230 $row = $qry->getRow(); 231 $itemid = $row['itm_id']; 232 if ( $description != "" ) { 233 $sql = "update kb3_items set itm_description = '".addslashes( stripslashes( $description ) )."', itm_volume = ".$volume.", itm_type = ".$type.", itm_icon = '".$icon."' where itm_id = ".$itemid; 234 $qry = new DBQuery( $this->dbconn_, $sql ); 235 $qry->execute() or die ( $qry->getErrorMsg() ); 236 } 237 } 238 239 return $itemid; 240 } 241 242 function setIcon( $itemid, $icon ) 243 { 244 $sql = "update kb3_items set itm_icon = '".$icon."' where itm_id = ".$itemid; 245 $qry = new DBQuery( $this->dbconn_, $sql ); 246 $qry->execute(); 247 } 248 249 function addSystem( $system, $systemsec ) 250 { 251 $sql = "select * from kb3_systems where sys_name = '".addslashes( stripslashes($system ) )."'"; 252 $qry = new DBQuery( $this->dbconn_, $sql ); 253 $qry->execute() or die ( $qry->getErrorMsg() ); 254 255 if ( $qry->recordCount() == 0 ) { 256 $sql = "insert into kb3_systems values ( null, '".addslashes( stripslashes( $system ) )."', '".$systemsec."', 0 )"; 257 $qry = new DBQuery( $this->dbconn_, $sql ); 258 $qry->execute() or die ( $qry->getErrorMsg() ); 259 $systemid = $qry->getInsertID(); 260 } 261 else { 262 $row = $qry->getRow(); 263 $systemid = $row['sys_id']; 264 } 265 266 return $systemid; 267 } 268 269 function addInvolved( $killid, $pilotid, $secstatus, $allianceid, $corpid, $shipid, $weaponid, $finalblow, $order ) 270 { 271 $sql = "insert into _".KB_SITE."_involved values ( ".$killid.", ".$pilotid.", '".$secstatus."', ".$allianceid.", ".$corpid.", ".$shipid.", ".$weaponid.", ".$finalblow.", ".$order." )"; 272 $qry = new DBQuery( $this->dbconn_, $sql ); 273 $qry->execute() or die ( $qry->getErrorMsg() ); 274 } 275 276 function addDestroyedItem( $killid, $itemid, $quantity, $location ) 277 { 278 $qry = new DBQuery( $this->dbconn_, "select itl_id from kb3_item_locations where itl_location = '".$location."'" ); 279 $qry->execute() or die( $qry->getErrorMsg() ); 280 $row = $qry->getRow(); 281 if ( $row['itl_id'] != "" ) 282 $locationid = $row['itl_id']; 283 else 284 $locationid = 0; 285 286 $sql = "insert into _".KB_SITE."_items_destroyed values ( ".$killid.", ".$itemid.", ".$quantity.", ".$locationid." )"; 287 $qry = new DBQuery( $this->dbconn_, $sql ); 288 $qry->execute() or die ( $qry->getErrorMsg() ); 289 } 290 291 function addKill( $timestamp, $victimid, $allianceid, $corpid, $shipid, $systemid ) 292 { 293 $killid = 0; 294 // check if the killmail already exists 295 $sql = "select * from _".KB_SITE."_kills where kll_timestamp = date_format('".$timestamp."', '%Y.%m.%d %H:%i:%s') and kll_victim_id = ".$victimid." and kll_ship_id = ".$shipid; 296 $qry = new DBQuery( $this->dbconn_, $sql ); 297 $qry->execute(); 298 299 if ( $qry->recordCount() == 0 ) { 300 $sql = "insert into _".KB_SITE."_kills values ( null, date_format('".$timestamp."', '%Y.%m.%d %H:%i:%s'), ".$victimid.", ".$allianceid.", ".$corpid.", ".$shipid.", ".$systemid." )"; 301 $qry = new DBQuery( $this->dbconn_, $sql ); 302 $qry->execute() or die ( $qry->getErrorMsg() ); 303 $killid = $qry->getInsertID(); 304 305 // log entry 306 //$sql = "insert into kb3_log values ( ".$killid.", '".$_SERVER['REMOTE_ADDR']."', now() )"; 307 //$qry = new DBQuery( $this->dbconn_, $sql ); 308 //$qry->execute() or die ( $qry->getErrorMsg() ); 309 } 310 311 return $killid; 312 } 313 314 function rollback( $killid ) 315 { 316 $qry = new DBQuery( $this->dbconn_, "delete from _".KB_SITE."_kills where kll_id = ".$killid ); 317 $qry->execute(); 318 319 $qry = new DBQuery( $this->dbconn_, "delete from _".KB_SITE."_involved where inv_kll_id = ".$killid ); 320 $qry->execute(); 321 322 $qry = new DBQuery( $this->dbconn_, "delete from _".KB_SITE."_items_destroyed where itd_kll_id = ".$killid ); 323 $qry->execute(); 324 } 325 326 function getRawMail( $killid, $site = "" ) 327 { 328 if ( $site == "" ) 329 $site = KB_SITE; 330 $sql = "select kll.kll_timestamp, plt.plt_id, plt.plt_name, plt.plt_externalid, crp.crp_id, crp.crp_name, ali.all_id, ali.all_name, shp.shp_name, shp.shp_externalid, scl.scl_class, sys.sys_name, sys.sys_sec, kll.kll_system_id 331 from _".$site."_kills kll, kb3_pilots plt, kb3_corps crp, 307 if ($row['itl_id'] != "") 308 $locationid = $row['itl_id']; 309 else 310 $locationid = 0; 311 312 $sql = "insert into _" . KB_SITE . "_items_destroyed values ( " . $killid . ", " . $itemid . ", " . $quantity . ", " . $locationid . " )"; 313 $qry = new DBQuery($this->dbconn_, $sql); 314 $qry->execute() or die ($qry->getErrorMsg()); 315 } 316 317 function addKill($timestamp, $victimid, $allianceid, $corpid, $shipid, $systemid) 318 { 319 $killid = 0; 320 // check if the killmail already exists 321 $sql = "select * from _" . KB_SITE . "_kills where kll_timestamp = date_format('" . $timestamp . "', '%Y.%m.%d %H:%i:%s') and kll_victim_id = " . $victimid . " and kll_ship_id = " . $shipid; 322 $qry = new DBQuery($this->dbconn_, $sql); 323 $qry->execute(); 324 325 if ($qry->recordCount() == 0) 326 { 327 $sql = "insert into _" . KB_SITE . "_kills values ( null, date_format('" . $timestamp . "', '%Y.%m.%d %H:%i:%s'), " . $victimid . ", " . $allianceid . ", " . $corpid . ", " . $shipid . ", " . $systemid . " )"; 328 $qry = new DBQuery($this->dbconn_, $sql); 329 $qry->execute() or die ($qry->getErrorMsg()); 330 $killid = $qry->getInsertID(); 331 // log entry 332 // $sql = "insert into kb3_log values ( ".$killid.", '".$_SERVER['REMOTE_ADDR']."', now() )"; 333 // $qry = new DBQuery( $this->dbconn_, $sql ); 334 // $qry->execute() or die ( $qry->getErrorMsg() ); 335 } 336 337 return $killid; 338 } 339 340 function rollback($killid) 341 { 342 $qry = new DBQuery($this->dbconn_, "delete from _" . KB_SITE . "_kills where kll_id = " . $killid); 343 $qry->execute(); 344 345 $qry = new DBQuery($this->dbconn_, "delete from _" . KB_SITE . "_involved where inv_kll_id = " . $killid); 346 $qry->execute(); 347 348 $qry = new DBQuery($this->dbconn_, "delete from _" . KB_SITE . "_items_destroyed where itd_kll_id = " . $killid); 349 $qry->execute(); 350 } 351 352 function getRawMail($killid, $site = "") 353 { 354 if ($site == "") 355 $site = KB_SITE; 356 $sql = "select kll.kll_timestamp, plt.plt_id, plt.plt_name, plt.plt_externalid, crp.crp_id, crp.crp_name, ali.all_id, ali.all_name, shp.shp_name, shp.shp_externalid, scl.scl_class, sys.sys_name, sys.sys_sec, kll.kll_system_id 357 from _" . $site . "_kills kll, kb3_pilots plt, kb3_corps crp, 332 358 kb3_alliances ali, kb3_ships shp, kb3_ship_classes scl, 333 359 kb3_systems sys 334 where kll.kll_id = " .$killid."360 where kll.kll_id = " . $killid . " 335 361 and plt.plt_id = kll.kll_victim_id 336 362 and crp.crp_id = kll.kll_crp_id … … 339 365 and sys.sys_id = kll.kll_system_id 340 366 and scl.scl_id = shp.shp_class"; 341 342 $qry = new DBQuery();343 if ( !$qry->execute( $sql ) ) die( $qry->getErrorMsg());344 $row = $qry->getRow();345 346 $mail .= substr( str_replace( '-', '.' , $row['kll_timestamp'] ), 0, 16 )."\r\n\r\n";347 $mail .= "Victim: ".$row['plt_name']."\r\n";348 $mail .= "Alliance: ".$row['all_name']."\r\n";349 $mail .= "Corp: ".$row['crp_name']."\r\n";350 $mail .= "Destroyed: ".$row['shp_name']."\r\n";351 $mail .= "System: ".$row['sys_name']."\r\n";352 $mail .= "Security: ".roundsec( $row['sys_sec'] )."\r\n\r\n";353 $mail .= "Involved parties:\r\n\r\n";354 355 $sql = "select plt.plt_id, plt.plt_name, plt.plt_externalid, crp.crp_name, ali.all_name, shp.shp_name, shp.shp_externalid, scl.scl_class,367 368 $qry = new DBQuery(); 369 if (!$qry->execute($sql)) die($qry->getErrorMsg()); 370 $row = $qry->getRow(); 371 372 $mail .= substr(str_replace('-', '.' , $row['kll_timestamp']), 0, 16) . "\r\n\r\n"; 373 $mail .= "Victim: " . $row['plt_name'] . "\r\n"; 374 $mail .= "Alliance: " . $row['all_name'] . "\r\n"; 375 $mail .= "Corp: " . $row['crp_name'] . "\r\n"; 376 $mail .= "Destroyed: " . $row['shp_name'] . "\r\n"; 377 $mail .= "System: " . $row['sys_name'] . "\r\n"; 378 $mail .= "Security: " . roundsec($row['sys_sec']) . "\r\n\r\n"; 379 $mail .= "Involved parties:\r\n\r\n"; 380 381 $sql = "select plt.plt_id, plt.plt_name, plt.plt_externalid, crp.crp_name, ali.all_name, shp.shp_name, shp.shp_externalid, scl.scl_class, 356 382 inv.inv_final_blow, itm.itm_name, inv.inv_sec_status 357 from _" .$site."_involved inv, kb3_pilots plt, kb3_corps crp, kb3_alliances ali,383 from _" . $site . "_involved inv, kb3_pilots plt, kb3_corps crp, kb3_alliances ali, 358 384 kb3_ships shp, kb3_ship_classes scl, kb3_items itm 359 where inv.inv_kll_id = " .$killid."385 where inv.inv_kll_id = " . $killid . " 360 386 and plt.plt_id = inv.inv_plt_id 361 387 and crp.crp_id = inv.inv_crp_id … … 365 391 and itm.itm_id = inv.inv_wep_id 366 392 order by inv.inv_order"; 367 368 $qry = new DBQuery();369 $qry->execute( $sql);370 371 while ( $row = $qry->getRow())372 {373 $mail .= "Name: ".$row['plt_name'];374 if ( $row['inv_final_blow'] == 1)375 $mail .= " (laid the final blow)";376 $mail .= "\r\n";377 378 $mail .= "Security: ".$row['inv_sec_status']."\r\n";379 $mail .= "Alliance: ".$row['all_name']."\r\n";380 $mail .= "Corp: ".$row['crp_name']."\r\n";381 $mail .= "Ship: ".$row['shp_name']."\r\n";382 $mail .= "Weapon: ".$row['itm_name']."\r\n\r\n";383 }384 385 $sql = "select itd_quantity, itm.itm_name, itd.itd_itl_id386 from _" .$site."_items_destroyed itd, kb3_items itm387 where itd.itd_kll_id = " .$killid."393 394 $qry = new DBQuery(); 395 $qry->execute($sql); 396 397 while ($row = $qry->getRow()) 398 { 399 $mail .= "Name: " . $row['plt_name']; 400 if ($row['inv_final_blow'] == 1) 401 $mail .= " (laid the final blow)"; 402 $mail .= "\r\n"; 403 404 $mail .= "Security: " . $row['inv_sec_status'] . "\r\n"; 405 $mail .= "Alliance: " . $row['all_name'] . "\r\n"; 406 $mail .= "Corp: " . $row['crp_name'] . "\r\n"; 407 $mail .= "Ship: " . $row['shp_name'] . "\r\n"; 408 $mail .= "Weapon: " . $row['itm_name'] . "\r\n\r\n"; 409 } 410 411 $sql = "select itd_quantity, itm.itm_name, itd.itd_itl_id 412 from _" . $site . "_items_destroyed itd, kb3_items itm 413 where itd.itd_kll_id = " . $killid . " 388 414 and itm.itm_id = itd.itd_itm_id 389 415 order by itd.itd_itl_id"; 390 391 $qry = new DBQuery(); 392 $qry->execute( $sql ) or die( $qry->getErrorMsg() ); 393 394 if ( $qry->recordCount() ) { 395 $mail .= "\r\nDestroyed items:\r\n\r\n"; 396 397 while ( $row = $qry->getRow() ) 398 { 399 $mail .= $row['itm_name']; 400 if ( $row['itd_quantity'] > 1 ) 401 $mail .= ", Qty: ".$row['itd_quantity']; 402 if ( $row['itd_itl_id'] == 4 ) // cargo 403 $mail .= " (Cargo)"; 404 if ( $row['itd_itl_id'] == 6 ) // drone 405 $mail .= " (Drone Bay)"; 406 $mail .= "\r\n"; 407 } 408 } 409 410 return $mail; 416 417 $qry = new DBQuery(); 418 $qry->execute($sql) or die($qry->getErrorMsg()); 419 420 if ($qry->recordCount()) 421 { 422 $mail .= "\r\nDestroyed items:\r\n\r\n"; 423 424 while ($row = $qry->getRow()) 425 { 426 $mail .= $row['itm_name']; 427 if ($row['itd_quantity'] > 1) 428 $mail .= ", Qty: " . $row['itd_quantity']; 429 if ($row['itd_itl_id'] == 4) // cargo 430 $mail .= " (Cargo)"; 431 if ($row['itd_itl_id'] == 6) // drone 432 $mail .= " (Drone Bay)"; 433 $mail .= "\r\n"; 434 } 435 } 436 437 return $mail; 411 438 } 412 439 413 440 function getPostPassword() 414 441 { 415 $qry = new DBQuery( $this->dbconn_, "select cfg_value from kb3_config where cfg_site = '".KB_SITE."' and cfg_key = 'post_password'");416 $qry->execute();417 $row = $qry->getRow();418 419 return $row['cfg_value'];442 $qry = new DBQuery($this->dbconn_, "select cfg_value from kb3_config where cfg_site = '" . KB_SITE . "' and cfg_key = 'post_password'"); 443 $qry->execute(); 444 $row = $qry->getRow(); 445 446 return $row['cfg_value']; 420 447 } 421 448 422 449 function getPostMailto() 423 450 { 424 $qry = new DBQuery( $this->dbconn_, "select cfg_value from kb3_config where cfg_site = '".KB_SITE."' and cfg_key = 'post_mailto'" ); 425 $qry->execute(); 426 $row = $qry->getRow(); 427 428 return $row['cfg_value']; 429 } 430 431 function setPostPassword( $password ) 432 { 433 $qry = new DBQuery( $this->dbconn_, "update kb3_config set cfg_value = '".$password."' where cfg_site = '".KB_SITE."' and cfg_key = 'post_password'" ); 434 $qry->execute(); 435 } 436 437 function setPostMailto( $mailto ) 438 { 439 $qry = new DBQuery( $this->dbconn_, "update kb3_config set cfg_value = '".$mailto."' where cfg_site = '".KB_SITE."' and cfg_key = 'post_mailto'" ); 440 $qry->execute(); 441 } 442 443 function isCorpUpdatable( $crp_id, $timestamp ) 444 { 445 $qry = new DBQuery( $this->dbconn_, 446 "select crp_id from kb3_corps 447 where crp_id = ".$crp_id." 448 and ( crp_updated < date_format('".$timestamp."', '%Y.%m.%d %H:%i') or crp_updated is null )" ); 449 $qry->execute() or die( $qry->getErrorMsg() ); 450 return $qry->recordCount(); 451 } 452 453 function isPilotUpdatable( $plt_id, $timestamp ) 454 { 455 $qry = new DBQuery( $this->dbconn_, 456 "select plt_id from kb3_pilots 457 where plt_id = ".$plt_id." 458 and ( plt_updated < date_format('".$timestamp."', '%Y.%m.%d %H:%i') or plt_updated is null )" ); 459 $qry->execute() or die( $qry->getErrorMsg() ); 460 461 return $qry->recordCount(); 462 } 463 } 464 451 $qry = new DBQuery($this->dbconn_, "select cfg_value from kb3_config where cfg_site = '" . KB_SITE . "' and cfg_key = 'post_mailto'"); 452 $qry->execute(); 453 $row = $qry->getRow(); 454 455 return $row['cfg_value']; 456 } 457 458 function setPostPassword($password) 459 { 460 $qry = new DBQuery($this->dbconn_, "update kb3_config set cfg_value = '" . $password . "' where cfg_site = '" . KB_SITE . "' and cfg_key = 'post_password'"); 461 $qry->execute(); 462 } 463 464 function setPostMailto($mailto) 465 { 466 $qry = new DBQuery($this->dbconn_, "update kb3_config set cfg_value = '" . $mailto . "' where cfg_site = '" . KB_SITE . "' and cfg_key = 'post_mailto'"); 467 $qry->execute(); 468 } 469 470 function isCorpUpdatable($crp_id, $timestamp) 471 { 472 $qry = new DBQuery($this->dbconn_, 473 "select crp_id from kb3_corps 474 where crp_id = " . $crp_id . " 475 and ( crp_updated < date_format('" . $timestamp . "', '%Y.%m.%d %H:%i') or crp_updated is null )"); 476 $qry->execute() or die($qry->getErrorMsg()); 477 return $qry->recordCount(); 478 } 479 480 function isPilotUpdatable($plt_id, $timestamp) 481 { 482 $qry = new DBQuery($this->dbconn_, 483 "select plt_id from kb3_pilots 484 where plt_id = " . $plt_id . " 485 and ( plt_updated < date_format('" . $timestamp . "', '%Y.%m.%d %H:%i') or plt_updated is null )"); 486 $qry->execute() or die($qry->getErrorMsg()); 487 488 return $qry->recordCount(); 489 } 490 } 465 491 ?> -
dev/common/globals.php
r14 r44 2 2 // current version: major.minor.sub 3 3 // unpair numbers for minor = development version 4 define('KB_VERSION', '1.1. 0');4 define('KB_VERSION', '1.1.44'); 5 5 6 6 // set the running-server for id-syncs here -
dev/common/portrait.php
r14 r44 2 2 require_once("db.php"); 3 3 4 $id = $_GET['id'];5 $size = $_GET['size'];4 $id = intval($_GET['id']); 5 $size = intval($_GET['size']); 6 6 7 7 $portrait = "cache/portraits/".$id."_".$size.".jpg"; 8 9 8 if (file_exists($portrait)) 10 9 { 11 10 header("Content-Type: image/jpeg"); 12 11 readfile($portrait); 12 exit; 13 } 14 15 // check for a valid, known external id 16 $qry = new DBQuery(); 17 $qry->execute("select plt_externalid from kb3_pilots where plt_externalid = ".$id." limit 1"); 18 $row = $qry->getRow(); 19 if (!$id = $row['plt_externalid']) 20 { 21 $portrait = "cache/portraits/0_".$size.".jpg"; 22 if (file_exists($portrait)) 23 { 24 header("Content-Type: image/jpeg"); 25 readfile($portrait); 26 exit; 27 } 28 } 29 30 if (file_exists("cache/portraits/".$id."_512.jpg")) 31 { 32 $img = imagecreatefromjpeg("cache/portraits/".$id."_512.jpg"); 13 33 } 14 34 else 15 35 { 16 // check for a valid, known external id 17 $qry = new DBQuery(); 18 $qry->execute("select plt_externalid from kb3_pilots where plt_externalid = ".$id." limit 1"); 19 $row = $qry->getRow(); 20 $id = $row['plt_externalid']; 21 if ($id == "") exit; 22 23 if (file_exists("cache/portraits/".$id."_512.jpg")) 36 $file = @file_get_contents("http://img.eve.is/serv.asp?s=512&c=".$id); 37 if ($img = imagecreatefromstring($file)) 24 38 { 25 $img = imagecreatefromjpeg("cache/portraits/".$id."_512.jpg"); 39 $fp = fopen("cache/portraits/".$id."_512.jpg", "w"); 40 fwrite($fp, $file); 41 fclose($fp); 26 42 } 27 43 else 28 44 { 29 $img = @imagecreatefromjpeg("http://img.eve.is/serv.asp?s=512&c=".$id); 30 if ($img) 45 // try alternative access via fsockopen 46 // happens if allow_url_fopen wrapper is false 47 require_once("class.http.php"); 48 49 $url = "http://img.eve.is/serv.asp?s=512&c=".$id; 50 $http = new http_request($url); 51 $file = $http->get_content(); 52 53 if ($img = imagecreatefromstring($file)) 31 54 { 32 55 $fp = fopen("cache/portraits/".$id."_512.jpg", "w"); 33 fwrite($fp, file_get_contents("http://img.eve.is/serv.asp?s=512&c=".$id)); 34 fclose($fp); 56 fwrite($fp, $file); 35 57 } 36 58 } 59 } 37 60 38 if (!$img) 39 { 40 // try alternative access via fsockopen 41 // 10s connect timeout, 5s data-read timeout 42 $url = "http://img.eve.is/serv.asp?s=512&c=".$id; 43 $url = parse_url($url); 61 if ($img) 62 { 63 $newimg = imagecreatetruecolor($size, $size); 64 imagecopyresampled($newimg, $img, 0, 0, 0, 0, $size, $size, 512, 512); 65 imagejpeg($newimg, $portrait); 66 header("Content-Type: image/jpeg"); 67 readfile($portrait); 68 exit; 69 } 44 70 45 $fp = fsockopen($url["host"], 80, $errno, $errstr, 10); 46 if (!$fp) 47 { 48 echo "Error occured with fsockopen: $errstr ($errno)<br>\n"; 49 exit; 50 } 51 52 $request_string = "GET {$url['path']}?{$url['query']} HTTP/1.0\r\n" . 53 "Accept-Language: en\r\n" . 54 "User-Agent: Mozilla/4.0 (compatible)\r\n" . 55 "Host: {$url['host']}\r\n". 56 "\r\n"; 57 fputs($fp, $request_string); 58 $header = 1; 59 socket_set_timeout($fp, 5); 60 while ($line = fgets($fp, 4096)) 61 { 62 if ($header) 63 { 64 $http_header .= $line; 65 } 66 else 67 { 68 $file .= $line; 69 } 70 if ($line == "\r\n") 71 { 72 $header = 0; 73 } 74 } 75 fclose($fp); 76 $fp = fopen("cache/portraits/".$id."_512.jpg", "w"); 77 fwrite($fp, $file); 78 79 $img = imagecreatefromjpeg("cache/portraits/".$id."_512.jpg"); 80 } 81 if ($img) 82 { 83 $newimg = imagecreatetruecolor($size, $size); 84 imagecopyresampled($newimg, $img, 0, 0, 0, 0, $size, $size, 512, 512); 85 imagejpeg($newimg, $portrait); 86 header("Content-Type: image/jpeg"); 87 readfile($portrait); 88 } 71 // last try, we could not get a valid picture from the server 72 // so output a '!' 73 $portrait = "cache/portraits/0_".$size.".jpg"; 74 if (file_exists($portrait)) 75 { 76 header("Content-Type: image/jpeg"); 77 readfile($portrait); 78 exit; 89 79 } 90 80 ?> -
dev/common/sync_server.php
r39 r44 22 22 } 23 23 24 // check if we got a file supplied with the request24 // check if we got a file named 'data' supplied with the request 25 25 if (!file_exists($_FILES['data']['tmp_name'])) 26 26 { 27 echo "malformed request<br>\n"; 27 var_dump($_FILES); 28 echo "malformed request, expecting data-file<br>\n"; 28 29 return; 29 30 } 30 31 31 // we g et afile, process32 // we got our file, process 32 33 $data = gzinflate(file_get_contents($_FILES['data']['tmp_name'])); 33 34