Hi..
Code:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /usr/export/www/hosting/cityguardde/scan.php on line 41
PHP-Code:
<?
$require_login=TRUE;
include ('global.php');
include ('dead.php');
$db=new SQLDB('mysql',$dbServer,$dbLogin,$dbPassword);
$db->select_db($dbName);
$db->query("SELECT users.*,ships.* FROM users,ships WHERE users.user_id='".addslashes($HTTP_SESSION_VARS['userID'])."' AND users.current_ship=ships.ship_id");
$playerinfo=$db->fetch_array();
$db->query("SELECT users.*,ships.* FROM users,ships WHERE ships.ship_id='".addslashes($HTTP_GET_VARS['ship'])."' AND users.user_id=ships.user_id");
$targetinfo=$db->fetch_array();
$sector=$targetinfo['sector_id'];
$playerscore = gen_score($playerinfo['user_id'],$db);
$targetscore = gen_score($targetinfo['user_id'],$db);
$player=($playerinfo['user_name']);
extract($targetinfo,EXTR_PREFIX_ALL,'target');
$name=$targetinfo['ship_name'];
if ($playerinfo['user_id']==$targetinfo['user_id'])
$_errorMsg="You do not need to scan your own ships";
if ($playerinfo['sector_id']!=$targetinfo['sector_id'] || $playerinfo['universe_id']!=$targetinfo['universe_id'])
$_errorMsg="You can only scan ships the are located in the same sector as you";
elseif ($playerinfo['turns']<1)
$_errorMsg="You do not have turns";
else
{
$success=SCAN_SUCCESS($playerinfo['sensors'], $targetinfo['cloak']);
if($success < 5)
{
$success = 5;
}
if($success > 95)
{
$success = 95;
}
$roll = rand(1, 100);
if($roll > $success)
{
$_errorMsg="Unsuccessful scan";
playerlog($targetinfo['user_id'], LOG_SHIP_SCAN_FAIL, $player"|".$sector."|"$name);
// Flag new message
$db->query("UPDATE users SET flag=1 WHERE user_id="$targetinfo['user_id']);
}
else
{
playerlog($targetinfo['user_id'], LOG_SHIP_SCAN, $player."|".$sector."|".$name);
// Flag new message
$db->query("UPDATE users SET flag=1 WHERE user_id=$targetinfo['user_id']");
$sc_error=SCAN_ERROR($playerinfo[sensors],$targetinfo[cloak]);
$levels=array('Hull'=>'hull','Engines'=>'engines','Power'=>'power','Computer'=>'computer','Sensors'=>'sensors','Beams'=>'beams','Torpedo Launchers'=>'torp_launchers','Shileds'=>'shields','Armour'=>'armour','Cloak'=>'cloak');
foreach($levels as $k=>$v)
{
if (rand(1,100)<$success)
$levels[$k]=round($targetinfo[$v]*$sc_error/100);
else
$levels[$k]='???';
}
$devices=array();
$other=array();
$db->query("SELECT bag.quantity,resource_types.name,resource_types.category FROM bag,resource_types WHERE bag.resource_id=resource_types.resource_id AND resource_types.category<>'ship' AND bag.bag_type='ship' AND bag.bag_id=".$targetinfo['ship_id']." ORDER BY category");
while ($a=$db->fetch_array())
{
if (rand(1,100)<$success)
$q=round($a['quantity']*$sc_error/100);
else
$q='???';
if ($a['category']=='device')
$devices[$a['name']]=$q;
else
$other[$a['name']]=$q;
}
}
$db->query("UPDATE users SET turns=turns-1, turns_used=turns_used+1 WHERE user_id=".$playerinfo['user_id']);
}
function customTag($tag, $counters, &$result)
{
global $_errorMsg,$levels,$devices,$other;
switch ($tag)
{
case 'error':
$result=$_errorMsg;
return TRUE;
case 'levels':
if ($counters[$tag]==0) $result=reset($levels);
else $result=each($levels);
return TRUE;
case 'level_name':
$result=key($levels);
return TRUE;
case 'level_value':
$result=current($levels);
return TRUE;
case 'devices':
if ($counters[$tag]==0) $result=reset($devices);
else $result=each($devices);
return TRUE;
case 'device_name':
$result=key($devices);
return TRUE;
case 'device_value':
$result=current($devices);
return TRUE;
case 'cargo':
if ($counters[$tag]==0) $result=reset($other);
else $result=each($other);
return TRUE;
case 'cargo_name':
$result=key($other);
return TRUE;
case 'cargo_value':
$result=current($other);
return TRUE;
}
return FALSE;
}
$templateParser = new HTMLTemplate('customTag','');
echo $header->parse();
echo $templateParser->parse();
echo $footer->parse();
$db->disconnect();
?>
Kommentar