|
//
// this function prints out an address and a last modifed line to the open file
// specified by giving the pointer $fp
//
// Variables needed:
// $fp: valid file handle to a file open in write mode
//
// Written by Suzanne Aigrain on 15-Dec-2000
function address_date($fp)
{
$pagemaker="Cambridge XMMSSC team";
$email="wmy@ast.cam.ac.uk";
$st=fputs($fp,"
$pagemaker <$email>\n");
// $filemod = filemtime("~xmmssc/public_html/xidops/fields_status.txt");
$filemod = filemtime("/home/xmmssc/public_html/xidops/fields_status_new.txt");
$filemodtime = date("F j Y h:i:s A", $filemod);
$st=fputs($fp,"Based on: \"~xmmssc/public_html/xidops/fields_status.txt\", last modified $filemodtime \n");
}
?>
// This routine creates a link to the file $file from the file handled by $pt
// checking first if $file exists and if it doesnt it creates it
// with the message: Data not yet processed. etc...
// Returns true if sucessful (ie file was there or copying worked, false
// otherwise
//
// Inputs:
// $full_path: name of file to check (to access it from the program calling
// the links routine)
// $rel_path: path to same file but from the file the link is placed into
// $pt: valid file handle to a file open for writing
// $text: string, containing linked text
//
// Calls:
// ch_page_exists.php
//
// Written by Suzanne Aigrain on 05-Jan-2001
function links($pt,$full_path,$rel_path,$text)
{
// include($PHP_MYLIB."ch_page_exist.php");
if (ch_page_exist($full_path))
{
$try=fputs($pt,"".$text."");
}
else
{
$try=fputs($pt,"".$text."");
}
return $try;
}
// This routine checks if a file exists and if it doesnt it creates it
// with the message: Data not yet processed. etc...
// Returns true if sucessfule (ie file was there or copying worked, false
// otherwise
//
// Inputs:
// $name: name of file to check (full path if required)
//
function ch_page_exist($name)
{
if (! (file_exists($name)))
{
$try=is_numeric("ab");
}
else
{
$try=is_numeric(1.0);
}
return $try;
}
?>
// This function creates an index according to the value of its input
// (sorts by Right Ascension, i-mag, h-mag,f52,f41,LHR)
// Decreasing order if sorting by RA,f52,f41,lhr, but zeros at end.
// Increasing order if sorting by i or h mag or RA
// If 2 fields have the same RA use dec.
//
// Returns the actual lines of the ascii files in the right order
//
// Inputs:
// $sort: what to sort on
// $file: ascii file generated by mkhtml_table.pro with following format:
//
function srt_match_tbl($sort,$file)
{
$no_sort=0;
// Read in data from $file
$fp=fopen($file,"r");
// go past 1st lines which contains headers
$record=fgets($fp,1024);
# $record=fgets($fp,1024);
$j=0;
while (!feof($fp))
{
$record=fgets($fp,1024);
$line[]=$record;
$elem=split(",",$record);
// extract variables necessary for sorting
$radec=split(" ",$elem[2]);
$blank=array_shift($radec);
if ($sort==="RA")
{
$first = $radec[0]*15.0*3600.0 + $radec[1]*60.0 + $radec[2];
$second = $radec[3]*3600.0 + $radec[4]*60.0 + $radec[5];
$st1=SORT_ASC;
}
elseif ($sort === "I-mag")
{
$first = $elem[14];
if ($first === "NM") $first = 35;
if ($first === "OUT") $first = 40;
if ($first == 0.0) $first = 45;
// choose RA as second sorting vector such that if there is no I-mag info it
// is sorted by RA
$second = $radec[0]*15.0*3600.0 + $radec[1]*60.0 + $radec[2];
$st1=SORT_ASC;
}
elseif ($sort === "H-mag")
{
$first = $elem[27];
if ($first === "NM") $first = 35;
if ($first === "OUT") $first = 40;
if ($first == 0.0) $first = 45;
$second = $radec[0]*15.0*3600.0 + $radec[1]*60.0 + $radec[2];
$st1=SORT_ASC;
}
elseif ($sort === "Red-mag")
{
$first = $elem[11];
if ($first === "NM") $first = 35;
if ($first === "OUT") $first = 40;
if ($first == 0.0) $first = 45;
$second = $radec[0]*15.0*3600.0 + $radec[1]*60.0 + $radec[2];
$st1=SORT_ASC;
}
elseif ($sort === "Blue-mag")
{
$first = $elem[12];
if ($first === "NM") $first = 35;
if ($first === "OUT") $first = 40;
if ($first == 0.0) $first = 45;
$second = $radec[0]*15.0*3600.0 + $radec[1]*60.0 + $radec[2];
$st1=SORT_ASC;
}
elseif ($sort === "XMM-No")
{
$first = $elem[0];
$second = $radec[0]*15.0*3600.0 + $radec[1]*60.0 + $radec[2];
$st1=SORT_ASC;
}
elseif ($sort === "F52")
{
$first = $elem[4];
$second = $radec[0]*15.0*3600.0 + $radec[1]*60.0 + $radec[2];
$st1=SORT_DESC;
}
elseif ($sort === "F41")
{
$first = $elem[6];
$second = $radec[0]*15.0*3600.0 + $radec[1]*60.0 + $radec[2];
$st1=SORT_DESC;
}
elseif ($sort === "LHR")
{
$first = $elem[11];
$second = $radec[0]*15.0*3600.0 + $radec[1]*60.0 + $radec[2];
$st1=SORT_DESC;
}
// default is RA sorting
else
{
$first = $elem[2]*15.0 + $elem[3]/60.0 + $elem[4]/3600.0;
$second = $elem[5] + $elem[6]/60.0 + $elem[7]/3600.0;
$st1=SORT_ASC;
$no_sort=1;
}
$ff[]=$first;
$ss[]=$second;
$keys[]=$j;
$st2=SORT_ASC;
$j+=1;
}
// do sorting
array_multisort($ff,$st1,SORT_NUMERIC,$ss,$st2,SORT_NUMERIC,$keys,SORT_ASC,SORT_NUMERIC);
// return lines of the file ordered
if ($no_sort===1)
{
$ll=array_slice($line,0,count($line)-1);
}
else
{
foreach($keys as $kk) $ll[]=$line[$kk];
$zero=array_shift($ll);
}
return $ll;
}
?>