[PHP] problems creating a png image from an array{HELP}

2001-01-18 Thread Nikos Tahos

I have a txt file as input.This file has the coordinates for a gas
network.With php I am creating an array with the above coordinates and then
I create from the array the image from the network.When the txt file is
>21Kb there is no image, else all works perfect{with a smaller txt file).I
am using php4,apache(sometimes my system hangs with this server) or OMNI
httpd(works fine).
If anybody know sth PLEASE HELP ME
I am newbie in php programming



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] problems creating a png image from an array{HELP} with the source code

2001-01-19 Thread Nikos Tahos

convert.php
";
$id=1;
$i=1;
echo "?? ?? $filename ?? ? ETNA";
if ($fp=fopen($filename, "r"))
{
  while (!feof($fp))
  {
$trimmed_line=trim($line=fgets($fp, 80));
if (strstr($trimmed_line, "Handle"))
{
  $handle=substr($trimmed_line, 9, 4);
  $trimmed_line=trim($line=fgets($fp, 80));
  if (!strstr($trimmed_line, "from point"))
$trimmed_line=trim($line=fgets($fp, 80));
  $from_x=trim(substr($trimmed_line, 14, 9));
  $from_y=trim(substr($trimmed_line, 27, 9));
  $trimmed_line=trim($line=fgets($fp, 80));
  if (!strstr($trimmed_line, "to point"))
$trimmed_line=trim($line=fgets($fp, 80));
  $to_x=trim(substr($trimmed_line, 12, 9));
  $to_y=trim(substr($trimmed_line, 25, 9));
  $pipes[$i][0]=($from_x);
  $pipes[$i++][1]=($from_y);
  $pipes[$i][0]=($to_x);
  $pipes[$i++][1]=($to_y);
  $id++;
}
  }
}

$nodes=array_values(array_unique($pipes));
for ($i=0;$i";
}
echo "-1//";
$temp_pipes=$pipes;

$i=sizeof($temp_pipes);
$size=$i;
$pipe_id=1;
while(!empty($temp_pipes))
{
  $current_node=array_shift($temp_pipes);
  reset($nodes);
  while((current($nodes))!=$current_node)
  {next($nodes);}
  $pipes_nodes[$size-$i+1][0]=key($nodes)+1;
  echo ($pipe_id++).",$ECODE,".$pipes_nodes[$size-$i+1][0];

  $current_node=array_shift($temp_pipes);
  reset($nodes);
  while((current($nodes))!=$current_node)
  {next($nodes);}
  $pipes_nodes[$size-$i+1][1]=key($nodes)+1;

  echo ",".$pipes_nodes[$size-$i+1][1]."/";
}
echo "-1//";
if (!isset($pressure_drop_nodes))
{
echo "";
echo "";
echo 
"  ";
echo "  ?? ? ??? ??? ?
??:";
echo "  ";
echo "  ";
echo "  ";
echo "   ";
echo "  (?? ?? ?? ?? ?? ?, ?.?.
'1,2,12,5')";
echo "  ";
echo "  ";
echo "  ?? ??? ??:";
echo "  1,".sizeof($nodes).",1,'ELD','DI',,'RK',";
echo "  ";
echo "  ";
echo "   ";
echo "   ";
echo "  ";
echo "  ";
echo "  ";
echo "  ";
echo "  ";
echo "";
echo "  ";
}
// -

file://phpinfo();
if (isset($pressure_drop_nodes))
{
echo "1/";
$individual_nodes=explode(",", $pressure_drop_nodes);
for($i=0;$i";
}
echo "-1//";
echo
"1,".sizeof($nodes).",1,'ELD','DI',".$diameter.",'RK',".$traxitita."/";
}
echo "-1//";
echo "-1/";
echo "-1/";
echo "-1/";
echo "-1/";
echo "1,0/";

if (!isset($pressure_drop_nodes))
{
echo "";
echo "  ";
echo "  ?? ??:";
echo "  ";
echo "  "; 
$y=0;
for($i=0;$i\n";
echo "  $y\n";
echo "  \n";
echo "  $y,,1,'\n";
echo "  \n";
echo "  PRE\n";
echo "  DIS\n";
echo "  ',\n";
echo "  '\n";
echo "  BAR\n";
echo "  M3/H\n";
echo "  ',\n";
echo "  \n";
echo "  \n";
echo "  \n";
}
echo "  ";
echo "  ";
echo "   ";
echo "  ";
echo "  ";
echo "";
echo "";
}
else if (isset($pressure_drop_nodes))
{

  for ($i=1;$i<=$no_of_loads;$i++)
  {
$to_node='to_node'.$i;
$type='type'.$i;
$units='units'.$i;
$value='pre_dis'.$i;
$to_node =$HTTP_POST_VARS[$to_node];
$type=$HTTP_POST_VARS[$type];
$units   =$HTTP_POST_VARS[$units];
$value   =$HTTP_POST_VARS[$value];

if ($type=='PRE')
{
if($to_node!='')
{
echo "$i, $to_node, $type, $units, $value\n";
$temp=$to_node;
}
else if ($to_node!=='')
{
if ($i<=$temp)
{
  echo "$i, $i, $type, $units, $value\n";
}
}
}
  }

  for ($i=1;$i<=$no_of_loads;$i++)
  {
$to_node='to_node'.$i;
$type='type'.$i;
$units='units'.$i;
$value='pre_dis'.$i;
$to_node =$HTTP_POST_VARS[$to_node];
$type=$HTTP_POST_VARS[$type];
$units   =$HTTP_POST_VARS[$units];
$value   =$HTTP_POST_VARS[$value];

if ($type=='DIS')
{
if($to_node!='')
{
echo "$i, $to_node, $type, $units, $value\n";
$temp=$to_node;
}
else if ($to_node!=='')
{
if ($i<=$temp)
{
  echo "$i, $i, $type, $units, $value\n";
}
}
 }
  }

}


echo "-1/";
echo "-1/";
echo "-1/";

for ($i=1;$i<=sizeof($nodes);$i++)
{
  $temp1[2*($i-1)]=$nodes[$i][0];
  $temp2[2*($i-1)]=$nodes[$i][1];
}
$merged=array_merge($temp1, $temp2);
$max=max($merged);
$min=min($merged);
$points=$pipes;
for ($i=1;$i<=sizeof($points);$i++)
{
  $points[$i][0]=floor( ($points[$i][0]*($size_x-10)/$max) );
  $points[$i][1]=floor( ($points[$i][1]*($size_y-10)/$max) );
}

$point_ids=$nodes;
for ($i=0;$i";
for ($i=0;$i";
echo "' alt=\"

[PHP] problems creating a png image from an array{HELP} including the source code

2001-01-19 Thread Nikos Tahos

convert.php
";
$id=1;
$i=1;
echo "?? ?? $filename ?? ? ETNA";
if ($fp=fopen($filename, "r"))
{
  while (!feof($fp))
  {
$trimmed_line=trim($line=fgets($fp, 80));
if (strstr($trimmed_line, "Handle"))
{
  $handle=substr($trimmed_line, 9, 4);
  $trimmed_line=trim($line=fgets($fp, 80));
  if (!strstr($trimmed_line, "from point"))
$trimmed_line=trim($line=fgets($fp, 80));
  $from_x=trim(substr($trimmed_line, 14, 9));
  $from_y=trim(substr($trimmed_line, 27, 9));
  $trimmed_line=trim($line=fgets($fp, 80));
  if (!strstr($trimmed_line, "to point"))
$trimmed_line=trim($line=fgets($fp, 80));
  $to_x=trim(substr($trimmed_line, 12, 9));
  $to_y=trim(substr($trimmed_line, 25, 9));
  $pipes[$i][0]=($from_x);
  $pipes[$i++][1]=($from_y);
  $pipes[$i][0]=($to_x);
  $pipes[$i++][1]=($to_y);
  $id++;
}
  }
}

$nodes=array_values(array_unique($pipes));
for ($i=0;$i";
}
echo "-1//";
$temp_pipes=$pipes;

$i=sizeof($temp_pipes);
$size=$i;
$pipe_id=1;
while(!empty($temp_pipes))
{
  $current_node=array_shift($temp_pipes);
  reset($nodes);
  while((current($nodes))!=$current_node)
  {next($nodes);}
  $pipes_nodes[$size-$i+1][0]=key($nodes)+1;
  echo ($pipe_id++).",$ECODE,".$pipes_nodes[$size-$i+1][0];

  $current_node=array_shift($temp_pipes);
  reset($nodes);
  while((current($nodes))!=$current_node)
  {next($nodes);}
  $pipes_nodes[$size-$i+1][1]=key($nodes)+1;

  echo ",".$pipes_nodes[$size-$i+1][1]."/";
}
echo "-1//";
if (!isset($pressure_drop_nodes))
{
echo "";
echo "";
echo 
"
  ";
echo "  ?? ? ??? ??? ?
??:";
echo "  ";
echo "  ";
echo "  ";
echo "   ";
echo "  (?? ?? ?? ?? ?? ?, ?.?.
'1,2,12,5')";
echo "  ";
echo "  ";
echo "  ?? ??? ??:";
echo "  1,".sizeof($nodes).",1,'ELD','DI',,'RK',";
echo "  ";
echo "  ";
echo "   ";
echo "   ";
echo "  ";
echo "  ";
echo "  ";
echo "  ";
echo "  ";
echo "";
echo "  ";
}
// -

file://phpinfo();
if (isset($pressure_drop_nodes))
{
echo "1/";
$individual_nodes=explode(",", $pressure_drop_nodes);
for($i=0;$i";
}
echo "-1//";
echo
"1,".sizeof($nodes).",1,'ELD','DI',".$diameter.",'RK',".$traxitita."/";
}
echo "-1//";
echo "-1/";
echo "-1/";
echo "-1/";
echo "-1/";
echo "1,0/";

if (!isset($pressure_drop_nodes))
{
echo "";
echo "  ";
echo "  ?? ??:";
echo "  ";
echo "  "; 
$y=0;
for($i=0;$i\n";
echo "  $y\n";
echo "  \n";
echo "  $y,,1,'\n";
echo "  \n";
echo "  PRE\n";
echo "  DIS\n";
echo "  ',\n";
echo "  '\n";
echo "  BAR\n";
echo "  M3/H\n";
echo "  ',\n";
echo "  \n";
echo "  \n";
echo "  \n";
}
echo "  ";
echo "  ";
echo "   ";
echo "  ";
echo "  ";
echo "";
echo "";
}
else if (isset($pressure_drop_nodes))
{

  for ($i=1;$i<=$no_of_loads;$i++)
  {
$to_node='to_node'.$i;
$type='type'.$i;
$units='units'.$i;
$value='pre_dis'.$i;
$to_node =$HTTP_POST_VARS[$to_node];
$type=$HTTP_POST_VARS[$type];
$units   =$HTTP_POST_VARS[$units];
$value   =$HTTP_POST_VARS[$value];

if ($type=='PRE')
{
if($to_node!='')
{
echo "$i, $to_node, $type, $units, $value\n";
$temp=$to_node;
}
else if ($to_node!=='')
{
if ($i<=$temp)
{
  echo "$i, $i, $type, $units, $value\n";
}
}
}
  }

  for ($i=1;$i<=$no_of_loads;$i++)
  {
$to_node='to_node'.$i;
$type='type'.$i;
$units='units'.$i;
$value='pre_dis'.$i;
$to_node =$HTTP_POST_VARS[$to_node];
$type=$HTTP_POST_VARS[$type];
$units   =$HTTP_POST_VARS[$units];
$value   =$HTTP_POST_VARS[$value];

if ($type=='DIS')
{
if($to_node!='')
{
echo "$i, $to_node, $type, $units, $value\n";
$temp=$to_node;
}
else if ($to_node!=='')
{
if ($i<=$temp)
{
  echo "$i, $i, $type, $units, $value\n";
}
}
 }
  }

}


echo "-1/";
echo "-1/";
echo "-1/";

for ($i=1;$i<=sizeof($nodes);$i++)
{
  $temp1[2*($i-1)]=$nodes[$i][0];
  $temp2[2*($i-1)]=$nodes[$i][1];
}
$merged=array_merge($temp1, $temp2);
$max=max($merged);
$min=min($merged);
$points=$pipes;
for ($i=1;$i<=sizeof($points);$i++)
{
  $points[$i][0]=floor( ($points[$i][0]*($size_x-10)/$max) );
  $points[$i][1]=floor( ($points[$i][1]*($size_y-10)/$max) );
}

$point_ids=$nodes;
for ($i=0;$i";
for ($i=0;$i";
echo "' alt=\