- Timestamp:
- 11/25/06 16:25:57 (14 years ago)
- Location:
- dev
- Files:
-
- 9 added
- 1 removed
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
dev/common/admin.php
r71 r89 1 1 <?php 2 require_once("db.php"); 3 require_once("class.killboard.php"); 4 require_once("class.page.php"); 5 require_once("class.tabbedform.php"); 6 require_once("admin_menu.php"); 2 require_once('db.php'); 3 require_once('class.killboard.php'); 4 require_once('class.page.php'); 5 require_once('class.tabbedform.php'); 6 require_once('admin_menu.php'); 7 require_once('autoupgrade.php'); 7 8 8 9 $killboard = new Killboard(KB_SITE); 9 $page = new Page( "Administration - Generic");10 $page = new Page('Administration - Generic (Current version: '.KB_VERSION.' Build '.SVN_REV.')'); 10 11 $page->setAdmin(); 11 require_once('autoupgrade.php'); 12 13 // check tables for validity and fields 14 // todo: tidy this mess up!!!!! 15 check_pilots(); 12 16 check_invdetail(); 17 check_contracts(); 18 check_index(); 19 check_tblstrct1(); 20 check_tblstrct2(); 21 check_tblstrct3(); 22 check_tblstrct4(); 13 23 14 24 if ($_POST['submit']) … … 21 31 $config->checkCheckbox('ship_values'); 22 32 $config->checkCheckbox('least_active'); 33 $config->checkCheckbox('adapt_items'); 23 34 24 35 if ($config->checkCheckbox('comments')) … … 52 63 $html .= "<tr><td width=120><b>Banner:</b></td><td><select id=style_banner name=style_banner>"; 53 64 54 $dir = "img/ banners/";65 $dir = "img/logo/"; 55 66 if (is_dir($dir)) 56 67 { … … 60 71 { 61 72 $file = substr($file, 0, strpos($file, ".")); 62 if (!is_dir($dir .$file))73 if (!is_dir($dir.$file)) 63 74 { 64 $html .= "<option value=\"" . $file ."\"";65 if ($file == $config->get StyleBanner())75 $html .= "<option value=\"".$file."\""; 76 if ($file == $config->getConfig('style_banner')) 66 77 { 67 78 $html .= " selected=\"selected\""; 68 79 } 69 $html .= ">" . $file ."</option>";80 $html .= ">".$file."</option>"; 70 81 } 71 82 } … … 73 84 } 74 85 } 75 $html .= "<option value=\"custom\""; 76 if ($config->getStyleBanner() == "custom") 77 { 78 $html .= " selected=\"selected\""; 79 } 80 $html .= ">custom</option></select></td></tr>"; 86 $html .= "</td></tr>"; 81 87 $html .= "<tr><td width=120><b>Style:</b></td><td><select id=style_name name=style_name>"; 82 88 … … 88 94 while (($file = readdir($dh)) !== false) 89 95 { 90 if (is_dir($dir .$file))96 if (is_dir($dir.$file)) 91 97 { 92 98 if ($file == "." || $file == ".." || $file == ".svn") … … 94 100 continue; 95 101 } 96 $html .= "<option value=\"" . $file ."\"";97 if ($file == $config->get StyleName())102 $html .= "<option value=\"".$file."\""; 103 if ($file == $config->getConfig('style_name')) 98 104 { 99 105 $html .= " selected=\"selected\""; 100 106 } 101 $html .= ">" . $file ."</option>";107 $html .= ">".$file."</option>"; 102 108 } 103 109 } … … 150 156 $html .= "<table class=kb-subtable>"; 151 157 152 $html .= "<tr><td width=120><b>Post password:</b></td><td><input type=text name=post_password id=post_password size=20 maxlength=20 value=\"" . $config->getPostPassword() ."\"></td></tr>";153 $html .= "<tr><td width=120><b>Killmail CC:</b></td><td><input type=text name=post_mailto id=post_mailto size=20 maxlength=80 value=\"" . $config->getPostMailto() ."\"> (e-mail address)</td></tr>";158 $html .= "<tr><td width=120><b>Post password:</b></td><td><input type=text name=post_password id=post_password size=20 maxlength=20 value=\"".$config->getPostPassword()."\"></td></tr>"; 159 $html .= "<tr><td width=120><b>Killmail CC:</b></td><td><input type=text name=post_mailto id=post_mailto size=20 maxlength=80 value=\"".$config->getPostMailto()."\"> (e-mail address)</td></tr>"; 154 160 $html .= "<tr><td width=120><b>Mailhost:</b></td><td><input type=text name=post_mailhost id=post_mailhost size=20 maxlength=80 value=\"".$config->getConfig('mail_host')."\"></td></tr>"; 155 $html .= "<tr><td width=120><b>Disallow any killmails before:</b></td><td>" . dateSelector($config->getConfig('filter_apply'), $config->getConfig('filter_date')) . "</td></tr>"; 161 $html .= "<tr><td width=120><b>Disallow any killmails before:</b></td><td>".dateSelector($config->getConfig('filter_apply'), $config->getConfig('filter_date'))."</td></tr>"; 162 $html .= "<tr><td width=120><b>Enable auto-addition of unknown Items:</b></td><td><input type=checkbox name=adapt_items id=adapt_items"; 163 if ($config->getConfig('adapt_items')) 164 { 165 $html .= " checked=\"checked\""; 166 } 167 $html .= "> (This is in case we can't supply a dump with the new items when Kali goes live)</td></tr>"; 156 168 $html .= "</table>"; 157 169 -
dev/common/autoupgrade.php
r71 r89 16 16 `comment` TEXT NOT NULL , 17 17 `name` TINYTEXT NOT NULL , 18 `posttime` TIMESTAMP DEFAULT CURRENT_TIMESTAMPNOT NULL,18 `posttime` TIMESTAMP DEFAULT \'0000-00-00 00:00:00\' NOT NULL, 19 19 PRIMARY KEY ( `ID` ) 20 20 ) TYPE = MYISAM'; … … 25 25 { 26 26 $qry = new DBQuery(); 27 $query = 'select count(posttime) from kb3_comments';27 $query = 'select posttime from kb3_comments limit 1'; 28 28 $result = mysql_query($query); 29 29 if ($result) … … 33 33 return; 34 34 } 35 $query = 'ALTER TABLE `kb3_comments` ADD `posttime` TIMESTAMP DEFAULT CURRENT_TIMESTAMPNOT NULL';35 $query = 'ALTER TABLE `kb3_comments` ADD `posttime` TIMESTAMP DEFAULT \'0000-00-00 00:00:00\' NOT NULL'; 36 36 $qry->execute($query); 37 37 } … … 52 52 ) TYPE = MYISAM ;'; 53 53 $qry->execute($query); 54 $qry->execute('ALTER TABLE `kb3_ships_values` ADD PRIMARY KEY ( `shp_id` ) '); 54 55 $qry->execute('UPDATE kb3_ships set shp_class = 8 WHERE shp_id=257 limit 1'); 55 56 $qry->execute('UPDATE kb3_ships set shp_class = 8 WHERE shp_id=252 limit 1'); … … 59 60 $qry->execute('UPDATE kb3_ships set shp_class = 4 WHERE shp_id=246 limit 1'); 60 61 $qry->execute('UPDATE kb3_ships set shp_class = 4 WHERE shp_id=249 limit 1'); 62 $qry->execute('UPDATE kb3_ships set shp_techlevel = 2 where shp_class = 22'); 61 63 } 62 64 … … 69 71 if ($len == 4) 70 72 { 71 $query = 'ALTER TABLE `kb3_inv_detail` CHANGE `ind_sec_status` `ind_sec_status` VARCHAR( 5)';73 $query = 'ALTER TABLE `kb3_inv_detail` CHANGE `ind_sec_status` `ind_sec_status` VARCHAR(5)'; 72 74 $qry->execute($query); 73 75 } 74 76 } 77 78 function check_pilots() 79 { 80 $qry = new DBQuery(); 81 $query = 'select plt_name from kb3_pilots limit 1'; 82 $qry->execute($query); 83 $len = mysql_field_len($qry->resid_,0); 84 if ($len == 32) 85 { 86 $query = 'ALTER TABLE `kb3_pilots` CHANGE `plt_name` `plt_name` VARCHAR(64) NOT NULL'; 87 $qry->execute($query); 88 } 89 } 90 91 function check_contracts() 92 { 93 $qry = new DBQuery(); 94 $query = 'select ctd_sys_id from kb3_contract_details limit 1'; 95 $result = mysql_query($query); 96 if ($result) 97 { 98 return; 99 } 100 $qry->execute('ALTER TABLE `kb3_contract_details` ADD `ctd_sys_id` INT(11) NOT NULL DEFAULT \'0\''); 101 $qry->execute('ALTER TABLE `kb3_contract_details` ADD INDEX (`ctd_ctr_id`) '); 102 } 103 function check_index() 104 { 105 $qry = new DBQuery(); 106 $qry->execute('SHOW columns from kb3_item_types like \'itt_id\''); 107 $arr = $qry->getRow(); 108 if ($arr['Key'] == 'PRI') 109 { 110 return; 111 } 112 $qry->execute('ALTER TABLE `kb3_item_types` ADD PRIMARY KEY ( `itt_id` ) '); 113 } 114 function check_tblstrct1() 115 { 116 $qry = new DBQuery(); 117 $query = 'select shp_description from kb3_ships limit 1'; 118 $result = mysql_query($query); 119 if (!$result) 120 { 121 return; 122 } 123 $query = 'ALTER TABLE `kb3_ships` DROP `shp_description`'; 124 $qry->execute($query); 125 } 126 function check_tblstrct2() 127 { 128 $qry = new DBQuery(); 129 $query = 'select itm_description from kb3_items limit 1'; 130 $result = mysql_query($query); 131 if (!$result) 132 { 133 return; 134 } 135 $query = 'ALTER TABLE `kb3_items` DROP `itm_description`'; 136 $qry->execute($query); 137 } 138 function check_tblstrct3() 139 { 140 $qry = new DBQuery(); 141 $query = 'select Value from kb3_items limit 1'; 142 $result = mysql_query($query); 143 if ($result) 144 { 145 $query = 'ALTER TABLE `kb3_items` CHANGE `Value` `itm_value` INT( 11 ) NOT NULL DEFAULT \'0\''; 146 $qry->execute($query); 147 } 148 } 149 function check_tblstrct4() 150 { 151 $qry = new DBQuery(); 152 $query = 'select itm_value from kb3_items limit 1'; 153 $result = mysql_query($query); 154 if ($result) 155 { 156 return; 157 } 158 $query = 'ALTER TABLE `kb3_items` ADD `itm_value` INT( 11 ) NOT NULL DEFAULT \'0\''; 159 $qry->execute($query); 160 $qry->execute('ALTER TABLE `kb3_items` CHANGE `itm_externalid` `itm_externalid` INT( 11 ) NOT NULL DEFAULT \'0\''); 161 } 75 162 ?> -
dev/common/class.item.php
r56 r89 1 <? 2 require_once( "db.php");1 <?php 2 require_once("db.php"); 3 3 4 class Item { 5 6 function Item( $id = 0)4 class Item 5 { 6 function Item($id = 0) 7 7 { 8 $this->id_ = $id; 9 $this->qry_ = new DBQuery(); 10 8 $this->id_ = $id; 9 $this->qry_ = new DBQuery(); 11 10 } 12 11 13 12 function getID() 14 13 { 15 return $this->id_;14 return $this->id_; 16 15 } 17 16 18 17 function getName() 19 18 { 20 $this->execQuery();21 return $this->row_['itm_name'];19 $this->execQuery(); 20 return $this->row_['itm_name']; 22 21 } 23 22 24 function getIcon( $size = 32)23 function getIcon($size = 32) 25 24 { 26 $this->execQuery(); 27 // return IMG_URL."/items/".$size."_".$size."/".$this->row_['itm_icon'].".png"; 28 $html .= "<td class=item-icon width=\"30\" height=\"34\" background=\"".IMG_URL."/items/".$size."_".$size."/".$this->row_['itm_icon'].".png\" valign=top>"; 29 if ( substr( $this->getName(), strlen( $this->getName() ) - 2, 2 ) == "II" ) 30 $html .= "<img src=\"".IMG_URL."/items/32_32/t2.gif\" border=\"0\">"; 31 else 32 $html .= "<img src=\"".IMG_URL."/items/32_32/blank.gif\" border=\"0\">"; 25 $this->execQuery(); 26 // if (strstr($this->row_['itt_name'], 'Drone')) 27 // { 28 // $html .= "<td class=item-icon width=\"30\" height=\"34\" background=\"".IMG_URL."/drones/".$size."_".$size."/".$this->row_['itm_externalid'].".png\" valign=top>"; 29 // } 30 // else 31 // { 32 $html .= "<td class=item-icon width=\"30\" height=\"34\" background=\"".IMG_URL."/items/".$size."_".$size."/".$this->row_['itm_icon'].".png\" valign=top>"; 33 // } 34 // return IMG_URL."/items/".$size."_".$size."/".$this->row_['itm_icon'].".png"; 33 35 34 $hmtl .= "</td>"; 36 if (substr($this->getName(), strlen($this->getName()) - 2, 2) == "II") 37 $html .= "<img src=\"".IMG_URL."/items/32_32/t2.gif\" border=\"0\">"; 38 else 39 $html .= "<img src=\"".IMG_URL."/items/32_32/blank.gif\" border=\"0\">"; 35 40 36 return $html; 41 $hmtl .= "</td>"; 42 43 return $html; 37 44 } 38 45 39 46 function getSlot() 40 47 { 41 $this->execQuery();42 return $this->row_['itt_slot'];48 $this->execQuery(); 49 return $this->row_['itt_slot']; 43 50 } 44 51 45 52 function execQuery() 46 53 { 47 if ( !$this->qry_->executed_ ) { 48 $this->sql_ = "select * 49 from kb3_items, kb3_item_types 50 where itm_id = ".$this->id_." 51 and itm_type = itt_id"; 52 $this->qry_->execute( $this->sql_ ) or die( $this->qry_->getErrorMsg() ); 53 $this->row_ = $this->qry_->getRow(); 54 } 54 if (!$this->qry_->executed_) 55 { 56 $this->sql_ = "select * 57 from kb3_items, kb3_item_types 58 where itm_id = ".$this->id_." 59 and itm_type = itt_id"; 60 $this->qry_->execute($this->sql_) or die($this->qry_->getErrorMsg()); 61 $this->row_ = $this->qry_->getRow(); 62 } 55 63 } 56 64 57 function lookup( $name)65 function lookup($name) 58 66 { 59 $qry = new DBQuery(); 60 $qry->execute( "select * 61 from kb3_items itm 62 where itm_name = '".slashfix( $name )."'" ); 63 64 $row = $qry->getRow(); 65 $this->id_ = $row['itm_id']; 67 $qry = new DBQuery(); 68 $qry->execute("select * from kb3_items itm 69 where itm_name = '".slashfix($name)."'"); 70 $row = $qry->getRow(); 71 if (!isset($row['itm_id'])) 72 { 73 global $config; 74 if ($config->getConfig('adapt_items')) 75 { 76 // if the item is a tec2 we likely have the tec1 77 if (substr($name, -2, 2) == 'II') 78 { 79 $qry->execute("select * from kb3_items itm 80 where itm_name = '".slashfix(substr($name,0,-1))."'"); 81 $row = $qry->getRow(); 82 $qry->execute("INSERT INTO kb3_items (itm_name,itm_volume,itm_type,itm_externalid,itm_techlevel, itm_icon) 83 VALUES ('".slashfix($name)."','".$row['itm_volume']."','".$row['itm_type']."','".$row['itm_externalid']."','2','".$row['itm_icon']."')"); 84 $this->id_ = $qry->getInsertID(); 85 } 86 else 87 { 88 // no idea what this is, insert as 'Temp' 89 $qry->execute("INSERT INTO kb3_items (itm_name,itm_type) 90 VALUES ('".slashfix($name)."','721')"); 91 $this->id_ = $qry->getInsertID(); 92 } 93 } 94 } 95 $this->id_ = $row['itm_id']; 66 96 } 67 68 97 98 function get_item_id($name) 69 99 { 70 100 $qry = new DBQuery(); 71 101 $qry->execute("select * 72 102 from kb3_items 73 where itm_name = '" . slashfix($name) ."'");103 where itm_name = '".slashfix($name)."'"); 74 104 75 105 $row = $qry->getRow(); 76 106 if ($row['itm_id']) return $row['itm_id']; 77 107 } 78 108 } 79 109 ?>