function __construct($connector, $pdo, $sm)
 {
     $this->db =& $connector;
     $this->pdo =& $pdo;
     $this->sm =& $sm;
     DEBUG("AdminLogin: Constructed.");
 }
 function executeQuery($sql_commands)
 {
     if (!pg_send_query($this->link, $sql_commands)) {
         throw new DatabaseException("PostgreSQL database query failed on following query:\n{$sql_commands}");
     }
     $this->res = pg_get_result($this->link);
     DEBUG("DB: Query was: <em>{$sql_commands}</em>");
     $this->executedQueries++;
     return true;
 }
 function CLinkClass($url, $description, $category, $createdTimestamp, $lastVisitedTimestamp, $visitCount, $index)
 {
     DEBUG("in CLinkClass constructor (\n  {$url},\n  {$description},\n  {$category},\n  {$createdTimestamp},\n  {$lastVisitedTimestamp},\n  {$visitCount},\n  {$index}\n)\n");
     $this->url = $url ? $url : '';
     $this->description = $description ? $description : 'New link';
     $this->category = $category ? $category : 'Unfiled';
     $this->createdTimestamp = $createdTimestamp ? $createdTimestamp : time();
     $this->lastVisitedTimestamp = $lastVisitedTimestamp ? $lastVisitedTimestamp : 0;
     $this->visitCount = $visitCount ? $visitCount : 0;
     $this->index = $index ? $index : 0;
 }
Esempio n. 4
0
                        }
                    }
                }
            }
        }
    }
}
list($browser_agent, $browser_version) = getBrowser();
if ($browser_agent == 'opera') {
    $attachmentMIME = 'application/kml';
} else {
    if ($browser_agent != 'ie' && $browser_agent != 'netscape' && $browser_agent != 'mozilla') {
        $attachmentMIME = "application/octet-stream";
    }
}
DEBUG("DL", 1, "browser_agent={$browser_agent}, browser version={$browser_version}<BR>");
// to debug
//	DEBUG_END();exit;
if (!headers_sent()) {
    /// martin jursa 19.6.2008
    header("Pragma: public");
    // required
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: private", false);
    // required for certain browsers
    header("Content-type: {$attachmentMIME}");
    //header("Content-Disposition: attachment; filename=\"$kml_file_name\"", true);
    header('Content-Disposition: inline; filename="' . htmlspecialchars($file_name) . '"');
    header("Content-Transfer-Encoding: binary");
    $size = strlen($xml);
Esempio n. 5
0
$config = session::global_get('config');
/* Language setup */
$lang = $config->get_cfg_value("core", "language");
if ($lang == "") {
    $lang = get_browser_language();
}
$lang .= ".UTF-8";
putenv("LANGUAGE=");
putenv("LANG={$lang}");
setlocale(LC_ALL, $lang);
$GLOBALS['t_language'] = $lang;
$GLOBALS['t_gettext_message_dir'] = $BASE_DIR . '/locale/';
$domain = 'messages';
bindtextdomain($domain, LOCALE_DIR);
textdomain($domain);
@DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $lang, "Setting language to");
$smarty->compile_dir = $config->get_cfg_value("core", "templateCompileDirectory");
$smarty->assign("title", "GOsa - " . _("Help browser"));
/* HELP management starts here ...
 */
/* Generate helpobject */
if (session::global_is_set('helpobject')) {
    $helpobject = session::global_get('helpobject');
} else {
    $plist = session::global_get('plist');
    $helpobject['lang'] = $lang;
    $helpobject['helpconf'] = array();
    $helpobject['currentplug'] = "";
    $helpobject['file'] = "index.html";
    $helpobject['helpconf'] = $plist->gen_headlines();
}
function ReadCoords($Text) { 
  $Text=strtolower($Text);
  // DEBUG("checkAirspace",128,"ReadCoords: Text=$Text");
  // 53:26:09 N 009:45:46 E
  if ( ! preg_match("/(\d+):(\d+):(\d+) +([ns]) +(\d+):(\d+):(\d+) +([we])/",$Text,$matches) ) {
  
    if ( ! preg_match("/(\d+):(\d+)\.(\d+) +([ns]) +(\d+):(\d+)\.(\d+) +([we])/",$Text,$matches) ) {    
		DEBUG("checkAirspace",128,"ReadCoords2: #$Text# Not match ");
		return array(0,0,0);
	}
	$Ydeg=$matches[1];
	$Ymin=$matches[2];
	$Ysec=$matches[3];
	$Y =  ($Ymin+ $Ysec/pow(10,strlen($Ysec)) ) / 60 + $Ydeg;
	if ($matches[4]=='s')   $Y = -$Y ;
	
	$Xdeg=$matches[5];
	$Xmin=$matches[6];
	$Xsec=$matches[7];
	$X = ( $Xmin+ $Xsec/pow(10,strlen($Xsec) ))/60 + $Xdeg;
	if ($matches[8]=='w')   $X = -$X ;	
	// DEBUG("checkAirspace",128,"ReadCoords: Text=$Text , X=$X, Y=$Y<BR>");
	return array(1,$X,$Y);
	
  } 

  $Ydeg=$matches[1];
  $Ymin=$matches[2];
  $Ysec=$matches[3];
  $Y = $Ysec/3600 + $Ymin/60 + $Ydeg;
  if ($matches[4]=='s')   $Y = -$Y ;

  $Xdeg=$matches[5];
  $Xmin=$matches[6];
  $Xsec=$matches[7];
  $X = $Xsec/3600 + $Xmin/60 + $Xdeg;
  if ($matches[8]=='w')   $X = -$X ;

  // DEBUG("checkAirspace",128,"ReadCoords: Text=$Text , X=$X, Y=$Y");
  return array(1,$X,$Y);

}
Esempio n. 7
0
function getAirspaceFromDB($min_lon, $max_lon, $min_lat, $max_lat)
{
    global $AirspaceArea, $NumberOfAirspaceAreas, $db, $airspaceTable;
    $AirspaceArea = array();
    $query = "SELECT * FROM {$airspaceTable} WHERE disabled=0 AND \n\t\t\t\t NOT ( maxx< {$min_lon} OR minx>{$max_lon} ) AND\t NOT ( maxy< {$min_lat} OR miny>{$max_lat} ) ";
    $res = $db->sql_query($query);
    if (!$res) {
        echo "Error in gettig airspace from DB: {$query} <BR>";
        return 0;
    }
    $i = 0;
    while ($row = mysql_fetch_assoc($res)) {
        if ($row['Shape'] == 1) {
            $shape = "Area";
        } else {
            $shape = "Circle";
        }
        DEBUG("getAirspaceFromDB", 1, "Found {$shape} => " . $row['Name'] . '<BR>');
        $AirspaceArea[$i]->id = $row['id'];
        $AirspaceArea[$i]->Name = $row['Name'];
        $AirspaceArea[$i]->Type = $row['Type'];
        $AirspaceArea[$i]->Shape = $row['Shape'];
        $AirspaceArea[$i]->Comments = $row['Comments'];
        $AirspaceArea[$i]->minx = $row['minx'];
        $AirspaceArea[$i]->miny = $row['miny'];
        $AirspaceArea[$i]->maxx = $row['maxx'];
        $AirspaceArea[$i]->maxy = $row['maxy'];
        $AirspaceArea[$i]->Base = unserialize($row['Base']);
        $AirspaceArea[$i]->Top = unserialize($row['Top']);
        if ($row['Shape'] == 1) {
            // area
            $AirspaceArea[$i]->Points = unserialize($row['Points']);
            //	DEBUG("getAirspaceFromDB",1, "Area first point :  ".$AirspaceArea[$i]->Points[0]->Latitude.",".
            //			$AirspaceArea[$i]->Points[0]->Longitude.
            //			" last point :  ".$AirspaceArea[$i]->Points[count($AirspaceArea[$i]->Points)-1]->Latitude.",".
            //			$AirspaceArea[$i]->Points[count($AirspaceArea[$i]->Points)-1]->Longitude."<BR>");
            if ($AirspaceArea[$i]->Points[0] != $AirspaceArea[$i]->Points[count($AirspaceArea[$i]->Points) - 1]) {
                //DEBUG("getAirspaceFromDB",1, "Adding Last point == first point<BR>");
                $AirspaceArea[$i]->Points[] = $AirspaceArea[$i]->Points[0];
            }
            $AirspaceArea[$i]->NumPoints = count($AirspaceArea[$i]->Points);
        } else {
            $AirspaceArea[$i]->Radius = $row['Radius'];
            $AirspaceArea[$i]->Latitude = $row['Latitude'];
            $AirspaceArea[$i]->Longitude = $row['Longitude'];
        }
        // DEBUG("getAirspaceFromDB",1,"<pre>".print_r($AirspaceArea[$i],1). "</pre><BR>");
        $i++;
    }
    $NumberOfAirspaceAreas = count($AirspaceArea);
}
Esempio n. 8
0
function igc2kmz($file, $outputFile, $timezone, $flightID)
{
    global $CONF, $CONF_tables_prefix, $baseInstallationPath, $db;
    $str = "";
    $version = $CONF['googleEarth']['igc2kmz']['version'];
    $kmzFile = $outputFile . ".{$version}.kmz";
    deleteOldKmzFiles($outputFile, $version);
    // exit;
    if (is_file($kmzFile)) {
        return $version;
    }
    $python = $CONF['googleEarth']['igc2kmz']['python'];
    putenv('PYTHON_EGG_CACHE=' . dirname(__FILE__) . '/data/tmp');
    // put some env for python2.5?
    // putenv("PATH=".$CONF['googleEarth']['igc2kmz']['python'] );
    putenv("PATH=/usr/local/bin/");
    $path = realpath($CONF['googleEarth']['igc2kmz']['path']);
    if (!defined('SQL_LAYER')) {
        define('SQL_LAYER', 'mysql');
    }
    global $phpbb3AbsPath, $dbhost, $dbname, $dbuser, $dbpasswd;
    $dbpasswdCon = $dbpasswd;
    if (!$dbpasswdCon) {
        $dbpasswdCon = $db->password;
    }
    $dbhostCon = $dbhost;
    if (!$dbhostCon) {
        $dbhostCon = $db->server;
    }
    if (!$dbhostCon) {
        $dbhostCon = 'localhost';
    }
    $engine = SQL_LAYER . "://" . $db->user . ':' . $dbpasswdCon . '@' . $dbhostCon . '/' . $db->dbname;
    $cmd = "{$python} {$path}/bin/leonardo2kmz.py";
    $cmd .= " --engine '{$engine}'";
    $cmd .= " --table-prefix={$CONF_tables_prefix}";
    $cmd .= " --directory '" . realpath(dirname(__FILE__)) . "'";
    // $cmd.=" --igcpath '".dirname(__FILE__).'/'.$CONF['paths']['intermediate']."'";
    // $cmd.=" --directory '".realpath(dirname(__FILE__).'/../..')."'";
    $cmd .= " --url 'http://" . $_SERVER['SERVER_NAME'] . "{$baseInstallationPath}'";
    // 	$cmd.=" --icon '$baseInstallationPath/templates/basic/tpl/leonardo_logo.gif' ";
    //	$cmd.=" --photos_path '".$CONF['paths']['photos']."' ";
    //	$cmd.=" --photos_url '$baseInstallationPath/'".$CONF['paths']['photos']."'' ";
    //DEFAULT_PHOTOS_PATH = 'data/flights/photos/%YEAR%/%PILOTID%'
    //DEFAULT_PHOTOS_URL = '/modules/leonardo/data/flights/photos/%YEAR%/%PILOTID%'
    $cmd .= " --output '{$kmzFile}'";
    $cmd .= " --tz-offset {$timezone}";
    $cmd .= " --igc-path=" . $CONF['paths']['intermediate'] . " ";
    // data/flights/intermediate/%YEAR%/%PILOTID%
    $cmd .= " {$flightID}";
    DEBUG('igc2kmz', 1, "igc2kmz: {$cmd} <BR>");
    exec($cmd, $res);
    if (0) {
        //echo "timezone: $timezone<br>";
        echo "cmd: {$cmd}<BR>";
        print_r($res);
        //print_r($db);
        //echo "$dbhost ,	$dbname ,$dbuser ,$dbpasswd @";
        exit;
    }
    return $version;
}
Esempio n. 9
0
 function getAlt($lat, $lon)
 {
     global $CONF_DEMpath, $openDEMfiles, $missingDEMfiles;
     if ($lat >= 0) {
         $latSouth = floor($lat);
         //$latNorth=$latSouth+1;
         $latD = 1 - $lat + $latSouth;
         $latStr = "N";
     } else {
         $latSouth = ceil(abs($lat));
         // $latNorth=$latSouth-1;
         $latD = -$lat - $latSouth + 1;
         $latStr = "S";
     }
     if ($lon >= 0) {
         $lonWest = floor($lon);
         //$lonEast=$lonWest+1;
         $lonD = $lon - $lonWest;
         $lonStr = "E";
     } else {
         $lonWest = ceil(abs($lon));
         //$lonEast=$lonWest-1;
         $lonD = $lonWest + $lon;
         $lonStr = "W";
     }
     // find the file to use!
     // $demFile="N40E023";
     $demFile = sprintf("%s%02d%s%03d.hgt.zip", $latStr, $latSouth, $lonStr, $lonWest);
     $demZipFile = $CONF_DEMpath . '/' . $demFile;
     if ($missingDEMfiles[$demFile]) {
         return -9999;
     }
     // see if it already open
     if (!$openDEMfiles[$demFile]) {
         if (!is_file($demZipFile)) {
             $missingDEMfiles[$demFile] = 1;
             return -9999;
         }
         //	$openDEMfiles[$demFile]=file_get_contents($CONF_DEMpath.$demFile);
         require_once dirname(__FILE__) . '/lib/pclzip/pclzip.lib.php';
         $archive = new PclZip($demZipFile);
         $list = $archive->extract(PCLZIP_OPT_EXTRACT_AS_STRING);
         if ($list == 0) {
             DEBUG("DEM", 255, "DEM::getAlt : " . $archive->errorInfo(true) . "<BR>");
             return -9999;
             // die("Error : ".$archive->errorInfo(true));
         } else {
             $openDEMfiles[$demFile] = $list[0]['content'];
         }
     }
     // find x,y inside the file
     // 1 degree is 1201 points
     $x = floor($lonD * 1201);
     $y = floor($latD * 1201);
     // point offeset in file
     $pointOffset = ($x + $y * 1201) * 2;
     $alt = ord($openDEMfiles[$demFile][$pointOffset]) * 256 + ord($openDEMfiles[$demFile][$pointOffset + 1]);
     if ($alt > 10000) {
         $alt = 0;
     }
     DEBUG("DEM", 255, "{$latD} {$lonD} {$x} {$y}  {$pointOffset} alt={$alt}");
     return $alt;
 }
Esempio n. 10
0
function ReadAltitude($Text, $field)
{
    global $TempArea;
    DEBUG("checkAirspace", 128, "ReadAltitude: {$Text} \n");
    $fHasUnit = 0;
    $Text = trim(strtoupper($Text));
    $Text = str_replace("\t", "", $Text);
    preg_match("/(\\d*)([ =]*)([A-Z]*)([ =]*)(\\d*)([ =]*)([A-Z]*)([ =]*)/", $Text, $parts);
    //print_r($parts);
    //echo "<HR>";
    DEBUG("checkAirspace", 128, print_r($parts, 1) . "<BR>\n");
    $TempArea->{$field}->Altitude = 0;
    $TempArea->{$field}->FL = 0;
    $TempArea->{$field}->Base = abUndef;
    for ($i = 1; $i < count($parts); $i++) {
        $pToken = $parts[$i];
        if (!$pToken || $pToken == ' ') {
            continue;
        }
        if (is_numeric($pToken)) {
            if ($TempArea->{$field}->Base == abFL) {
                $TempArea->{$field}->FL = $pToken;
                $TempArea->{$field}->Altitude = AltitudeToQNHAltitude($TempArea->{$field}->FL * 100 / TOFEET);
            } else {
                $TempArea->{$field}->Altitude = $pToken;
            }
        } else {
            if ($pToken == 'SFC' || $pToken == 'GND' && !$TempArea->{$field}->Altitude) {
                $TempArea->{$field}->Base = abAGL;
                $TempArea->{$field}->FL = 0;
                $TempArea->{$field}->Altitude = 0;
                $fHasUnit = 1;
            } else {
                if ($pToken == 'FL') {
                    // this parses "FL=150" and "FL150"
                    $TempArea->{$field}->Base = abFL;
                    $fHasUnit = true;
                } else {
                    if ($pToken == 'FT' || $pToken == 'F') {
                        $TempArea->{$field}->Altitude = $TempArea->{$field}->Altitude / TOFEET;
                        $fHasUnit = true;
                    } else {
                        if ($pToken == 'M') {
                            $fHasUnit = true;
                        } else {
                            if ($pToken == 'MSL') {
                                $TempArea->{$field}->Base = abMSL;
                            } else {
                                if ($pToken == 'AGL' || $pToken == 'GND' && $TempArea->{$field}->Altitude > 0) {
                                    $TempArea->{$field}->Base = abAGL;
                                } else {
                                    if ($pToken == 'STD') {
                                        if ($TempArea->{$field}->Base != abUndef) {
                                            // warning! multiple base tags
                                        }
                                        $TempArea->{$field}->Base = abFL;
                                        $TempArea->{$field}->FL = $TempArea->{$field}->Altitude * TOFEET / 100;
                                        $TempArea->{$field}->Altitude = AltitudeToQNHAltitude($TempArea->{$field}->FL * 100 / TOFEET);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    // end while
    if (!$fHasUnit && $TempArea->{$field}->Base != abFL) {
        // ToDo warning! no unit defined use feet or user alt unit
        // Alt->Altitude = Units::ToSysAltitude(Alt->Altitude);
        $TempArea->{$field}->Altitude = $TempArea->{$field}->Altitude / TOFEET;
    }
    if ($TempArea->{$field}->Base == abUndef) {
        // ToDo warning! no base defined use MSL
        $TempArea->{$field}->Base = abMSL;
    }
    DEBUG("checkAirspace", 128, "ReadAltitude: FL=" . $TempArea->{$field}->FL . ", Alt:" . $TempArea->{$field}->Altitude . ", Base:" . $TempArea->{$field}->Base . "<BR>\n");
    //  return $Alt;
}
Esempio n. 11
0
 function drawFlight()
 {
     global $gradientMap, $gradient_colors_num;
     global $minAlt, $maxAlt;
     $size = 1;
     $startSize = 10;
     $pointColor = imagecolorallocate($this->img, 255, 0, 0);
     $startColor = imagecolorallocate($this->img, 0, 250, 0);
     $endColor = imagecolorallocate($this->img, 252, 250, 66);
     // yellow
     $shadowColor = imagecolorallocate($this->img, 0, 0, 0);
     $lines = file($this->IGCfilename);
     $points = 0;
     $minAlt = 10000;
     $maxAlt = 0;
     //first pass to find min/max
     foreach ($lines as $line) {
         $line = trim($line);
         if (strlen($line) == 0) {
             continue;
         }
         if ($line[0] == 'B') {
             $thisPoint = new gpsPoint($line);
             $thisAlt = $thisPoint->getAlt();
             if ($thisAlt < $minAlt) {
                 $minAlt = $thisAlt;
             }
             if ($thisAlt > $maxAlt) {
                 $maxAlt = $thisAlt;
             }
         }
     }
     // Make shadow first
     foreach ($lines as $line) {
         // $line=trim($line);
         if (strlen($line) == 0) {
             continue;
         }
         if ($line[0] == 'B') {
             $thisPoint = new gpsPoint($line);
             $thisColor = $gradientMap[floor(($gradient_colors_num - 1) * $altRelPos)];
             list($ptX, $ptY) = $this->lonlat2xy(-$thisPoint->lon, $thisPoint->lat);
             //DEBUG("MAP",8,"lon:".$thisPoint->lon." lat:".$thisPoint->lat." -> X:$ptX, Y:$ptY <br>");
             $ptY = $this->pixelHeight - $ptY;
             if ($points == 0) {
                 $firstPoint = new gpsPoint($line);
             } else {
                 list($lastptX, $lastptY) = $this->lonlat2xy(-$lastPoint->lon, $lastPoint->lat);
                 $lastptY = $this->pixelHeight - $lastptY;
                 imageline($this->img, $lastptX - 1, $lastptY - 1, $ptX - 1, $ptY - 1, $shadowColor);
                 imageline($this->img, $lastptX, $lastptY - 1, $ptX, $ptY - 1, $shadowColor);
                 imageline($this->img, $lastptX + 1, $lastptY - 1, $ptX + 1, $ptY - 1, $shadowColor);
                 imageline($this->img, $lastptX - 1, $lastptY, $ptX - 1, $ptY, $shadowColor);
                 //					imageline($this->img,$lastptX,$lastptY,$ptX,$ptY,$shadowColor);
                 imageline($this->img, $lastptX + 1, $lastptY, $ptX + 1, $ptY, $shadowColor);
                 imageline($this->img, $lastptX - 1, $lastptY + 1, $ptX - 1, $ptY + 1, $shadowColor);
                 imageline($this->img, $lastptX, $lastptY + 1, $ptX, $ptY + 1, $shadowColor);
                 imageline($this->img, $lastptX + 1, $lastptY + 1, $ptX + 1, $ptY + 1, $shadowColor);
             }
             $lastPoint = new gpsPoint($line);
             $points++;
         }
     }
     DEBUG("MAP", 8, "<hr>");
     $points = 0;
     foreach ($lines as $line) {
         // $line=trim($line);
         if (strlen($line) == 0) {
             continue;
         }
         if ($line[0] == 'B') {
             $thisPoint = new gpsPoint($line);
             if ($maxAlt - $minAlt) {
                 $altRelPos = ($thisPoint->getAlt() - $minAlt) / ($maxAlt - $minAlt);
             } else {
                 $altRelPos = 0;
             }
             $thisColor = $gradientMap[floor(($gradient_colors_num - 1) * $altRelPos)];
             list($ptX, $ptY) = $this->lonlat2xy(-$thisPoint->lon, $thisPoint->lat);
             $ptY = $this->pixelHeight - $ptY;
             if ($points == 0) {
                 $firstPoint = new gpsPoint($line);
             } else {
                 list($lastptX, $lastptY) = $this->lonlat2xy(-$lastPoint->lon, $lastPoint->lat);
                 $lastptY = $this->pixelHeight - $lastptY;
                 imageline($this->img, $lastptX, $lastptY, $ptX, $ptY, $thisColor);
                 imageline($this->img, $lastptX, $lastptY + 1, $ptX, $ptY + 1, $thisColor);
                 // leave this for extra line width + shadow
                 // imageline($this->img,$lastptX+1,$lastptY,$ptX+1,$ptY,$shadowColor);
             }
             $lastPoint = new gpsPoint($line);
             $points++;
         }
     }
     list($ptX, $ptY) = $this->lonlat2xy(-$firstPoint->lon, $firstPoint->lat);
     $ptY = $this->pixelHeight - $ptY;
     imagearc($this->img, $ptX, $ptY, $startSize, $startSize, 0, 360, $startColor);
     imagearc($this->img, $ptX, $ptY, $startSize - 1, $startSize - 1, 0, 360, $startColor);
     list($ptX, $ptY) = $this->lonlat2xy(-$lastPoint->lon, $lastPoint->lat);
     $ptY = $this->pixelHeight - $ptY;
     imagearc($this->img, $ptX + 1, $ptY + 1, $startSize, $startSize, 0, 360, $shadowColor);
     imagearc($this->img, $ptX + 1, $ptY + 1, $startSize - 1, $startSize - 1, 0, 360, $shadowColor);
     imagearc($this->img, $ptX, $ptY, $startSize, $startSize, 0, 360, $endColor);
     imagearc($this->img, $ptX, $ptY, $startSize - 1, $startSize - 1, 0, 360, $endColor);
 }
Esempio n. 12
0
            // portait style
            DEBUG("MAP", 1, "Portait style <BR>");
            DEBUG("MAP", 1, "totalWidth: {$totalWidth}, totalHeight: {$totalHeight}, totalWidth/totalHeight: " . $totalWidth / $totalHeight . "<br>");
            if ($totalWidth / $totalHeight < 3 / 4) {
                $totalWidth = 3 / 4 * $totalHeight;
            }
        }
        $marginHor = 2000 + floor($totalWidth / 20000) * 1000 + ($totalWidth - $totalWidth_initial) / 2;
        //in meters
        $marginVert = 1000 + floor($totalHeight / 20000) * 1000 + ($totalHeight - ($MAP_TOP - $MAP_BOTTOM)) / 2;
        //in meters
        if ($marginHor > $marginVert) {
            // landscape style ...
            if ($marginVert / $marginHor < 3 / 4) {
                $marginVert = 3 / 4 * $marginHor;
            }
        } else {
            // portait style
            if ($marginHor / $marginVert < 3 / 4) {
                $marginHor = 3 / 4 * $marginVert;
            }
        }
        DEBUG("MAP", 1, "marginHor: {$marginHor}, marginVert:{$marginVert} <br>");
        $flMap = new flightMap($UTMzone, $UTMlatZone, $MAP_TOP + $marginVert, $MAP_LEFT - $marginHor, $UTMzone2, $UTMlatZone2, $MAP_BOTTOM - $marginVert, $MAP_RIGHT + $marginHor, 600, 800, "", "", 0);
        DEBUG("MAP", 1, "MAP Required m/pixel = " . $flMap->metersPerPixel . "<br>");
        $flMap->showTrack = 0;
        $flMap->showWaypoints = 0;
        header('Content-Type: image/jpeg');
        $flMap->drawFlightMap();
    }
}
 function __construct($connector, $pdo)
 {
     $this->db = $connector;
     $this->pdo = $pdo;
     DEBUG("AdminOverview: Constructed.");
 }
Esempio n. 14
0
function exitPage($exitNow=1){
   global $opMode,$noFooterMenu,$moduleRelPath,$PREFS,$CONF_use_own_template,$CONF;
   global $sqlQueriesTime ,$sqlQueriesNum,$sqlFetchTime,$sqlFetchNum;
   global $pageStart,$DBGlvl;
   global $RUN;


   echo "<br>";
   if (!$noFooterMenu ) {
   	 if ($RUN['view']!='print') {
	 	echo "<br><div class='main_text' align=center><a href='#top_of_page'>"._RETURN_TO_TOP."</a></div>";
   	 }
   }
   echo "</div>";

   $pageEnd=leo_getmicrotime();
   $pageTime=$pageEnd-$pageStart;
   DEBUG("MAIN",1,"PAGE CREATION: $pageTime secs<BR>");
   DEBUG_END();


   require_once dirname(__FILE__)."/BLOCKS_end.php";
	
   if ($opMode==1) {
		CloseTable();
		include("footer.php");
   } else if (0 && ($opMode==3 || $opMode==4 || $opMode==6 || ($opMode==5 &&  $CONF_use_own_template ))  ) {
		require_once dirname(__FILE__)."/GUI_footer.php";
   }  else if ($opMode==3 || $opMode==4 || $opMode==6 || ($opMode==5 &&  $CONF_use_own_template ) ) {
	    global $Ltemplate;
		$Ltemplate->set_filenames(array('overall_footer' => 'tpl/overall_footer.html'));
		$Ltemplate->assign_vars(array(
			'SIDE_BLOCKS_HTML' => $side_blocks_html,
			'CUSTOM_FOOTER_CODE'=> 	$CONF['footer']['custom_code'],
		) );
		$Ltemplate->pparse('overall_footer');
		
		// Close our DB connection.
		//$db->sql_close();

   } 
	if ($DBGlvl) {
		// db execution time

		echo "<div class='debugBoxTop'>";
		printf("DB query: <b>%.4f</b> secs in %d queries <hr>",$sqlQueriesTime ,$sqlQueriesNum);

		printf("DB fetch: <b>%.4f</b> secs in %d fetches <hr>",$sqlFetchTime,$sqlFetchNum);
		printf("DB Total: <b>%.5f</b> secs<hr>",($sqlQueriesTime + $sqlFetchTime )) ;
		printf("Page Total: <b>%.5f</b> secs<hr>",$pageTime) ;
		echo "</div>";
		// end db
	}

   statsLogger::Log($pageTime);

   if ($exitNow) exit;
}
Esempio n. 15
0
function bootstrap()
{
    global $CONFIG, $SYSTEM_INFO, $output_started, $body_started, $console, $profiler, $ALLOWED_MGMT_FUNCS;
    header("Content-type: application/xhtml+xml\r");
    $console = new SystemConsole();
    DEBUG("<strong>This is 29o3 " . $SYSTEM_INFO['SystemVersion'] . " Codename " . $SYSTEM_INFO['SystemCodename'] . "</strong>");
    DEBUG("SYS: Bootstrapping started...");
    $connector = new DatabaseConnector();
    $connector->setupConnection($CONFIG['DatabaseHost'], $CONFIG['DatabaseUser'], $CONFIG['DatabasePassword'], $CONFIG['DatabaseName'], $CONFIG['DatabasePort']);
    DEBUG("DB: Connected to database.");
    $request = new PageRequest($connector);
    $request->parseRequest();
    // instanciate new cache object
    $co = new cacheObject($connector, $request->getRequestedSite(), $request->getRequestedPage());
    // check if we have content for current page cached
    $cacheContent = $co->getCached();
    if ($cacheContent === false) {
        // construct header and body objects
        $header = new XHTMLHeader();
        $body = new XHTMLBody();
        $pdo = new pageDescriptionObject($header, $body, $connector, $request->getWantAdmin(), $request->getAdminFuncParam());
        $connector->executeQuery("SELECT * FROM " . mktablename("pages") . " WHERE name='" . $request->getRequestedPage() . "'");
        /* lets see what the admin wants */
        if ($request->getWantAdmin()) {
            if ($request->getRequestedPage() == "overview") {
            }
        }
        $pageInfo = $connector->fetchArray();
        $pdo->setPageDescriptionA($pageInfo, $request->getRequestedSite());
        $header->setTitle($pdo->getContent("title"));
        if ($pdo->getContent("description") != "") {
            $header->addMetaDCDescription($pdo->getContent('description'));
        }
        if ($pdo->getContent("subject") != "") {
            $header->addMetaDCSubject($pdo->getContent("subject"));
        }
        if ($pdo->getContent("date") != 0) {
            $header->addMetaDCDate(strftime("%Y-%m-%d", $pdo->getContent('date')));
        }
        if ($pdo->getContent("creator") != "") {
            $header->addMetaDCCreator($pdo->getContent("creator"));
        }
        if ($pdo->getContent("contributors") != "") {
            $c_arr = explode(";", $pdo->getContent('contributors'));
            for ($i = 0; $i <= count($c_arr) - 1; $i++) {
                $header->addMetaDCContributor($c_arr[$i]);
            }
        }
        if ($pdo->getContent("type") != "") {
            $header->addMetaDCType($pdo->getContent("type"));
        }
        if ($pdo->getContent("sources") != "") {
            $sources_array = explode(";", $pdo->getContent('sources'));
            for ($i = 0; $i <= count($sources_array) - 1; $i++) {
                $header->addMetaDCSource($sources_array[$i]);
            }
        }
        /*
        !!!	FIXME: 	THE FOLLOWING CODE CAUSES A RACE CONDITION ON BOTH APACHE2/PHP
        !!!		AND PHP-CLI. 
        !!!	SEV:   	(5) - Causes server process to fill RAM and swap -> kill
        !!!	RES:	Currently no resolution, commented out because of this.
        !!!		I'd say it has got something to do with the database for
        !!!		I cannot find an error elsewhere.
        >!<	*** FIXED ***
        >!<	F**K YOU F**K YOU DAMN CODER!!!! F**K YOU!!!
        */
        if ($pdo->getContent("language") != "") {
            $header->addMetaDCLanguage($pdo->getContent('language'));
        }
        if ($pdo->getContent('copyright') != "") {
            $header->addMetaDCRights($pdo->getContent("copyright"));
        }
        // this is the r0x0r1ng stylesheet which controls how system messages (errors, etc.) appear
        $pdo->scheduleInsertion_ExternalStylesheet("n_style.css");
        if ($pdo->getContent('no_cache') == 1) {
            $co->setScheduleCaching(false);
            DEBUG("CACHE: Caching deactivated on request.");
        }
        // now, get the page's stylesheet; it might be empty, but we'll add it if not :)
        if ($request->getWantAdmin() <= 1) {
            if ($request->getWantAdmin() == 1) {
                $co->setScheduleCaching(false);
                DEBUG("CACHE: Admin wanted, caching deactivated.");
            }
            $layoutManager = new LayoutManager($pdo);
            $pdo->getAvailableBoxes();
            $connector->executeQuery("SELECT * FROM " . mktablename("layouts") . " WHERE lname='" . $pageInfo['layout'] . "'");
            if ($connector->getNumRows() != 0) {
                $currentLayout = $connector->fetchArray();
                $layoutManager->setLayoutFile($currentLayout['file']);
                $layoutManager->parseLayout();
            } else {
                throw new GeneralException("No layout found. 29o3 cannot continue.");
            }
            if ($request->getWantAdmin()) {
                require_once $CONFIG['LibDir'] . 'admin/adminFuncs.php';
                $af = new adminFuncs($pdo, $request);
                $pdo->scheduleInsertion_ExternalStylesheet($af->getAdminStylesheet());
            }
            DEBUG("DB: " . $connector->getExecutedQueries() . " queries executed.");
            $connector->closeConnection();
            DEBUG("DB: Connection closed.");
            $profiler->addBreakpoint();
            DEBUG("SYS: Resource usage,  sys:" . $profiler->getBreakpointGrandSysDifference() . "&micro;s usr:"******"&micro;s");
            DEBUG("SYS: Exiting normally.");
            // print the buffer of the header since we're done with it :)
            $pdo->doInsertions();
            // we have everything at this point... start caching procedure
            $co->doCache($pdo->getBuffers());
            if ($CONFIG['Developer_Debug'] == true) {
                if ($body) {
                    $body->eyecandyConsole($console);
                } else {
                    $console->printBuffer();
                }
            }
            if ($pdo->getBrandingState() == true) {
                $pdo->insertBodyDiv("Powered by <a href=\"http://twonineothree.berlios.de\">29o3</a> " . $SYSTEM_INFO["SystemVersion"] . " Codename " . $SYSTEM_INFO["SystemCodename"], "poweredBy", "poweredBy_Banner", "Powered by 29o3");
            }
            printf('<?xml version="1.0" encoding="UTF-8"?>');
            printf('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">%s', "\n");
            printf('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">%s', "\n");
            $pdo->printHeaderBuffer();
            $header_started = true;
            // destruct the header object
            $pdo->destroyHeaderObject();
            $body_started = true;
            // print out the body buffer
            $pdo->printBodyBuffer();
            printf('</html>');
            // exit normally.
            exit(0);
        } else {
            $co->setScheduleCaching(false);
            $pdo->setOmitBranding(true);
            DEBUG("CACHE: Admin wanted, caching deactivated.");
            require_once $CONFIG['LibDir'] . 'admin/adminFuncs.php';
            $co->setScheduleCaching(false);
            $af = new adminFuncs($pdo, $request);
            $pdo->scheduleInsertion_ExternalStylesheet($af->getAdminStylesheet());
            //			$pdo->insertBodyDiv("<img src=\"lib/images/adminlogotop.png\" style=\"vertical-align: top; text-align: left; border: 0; padding: 0; margin: 0;\" /><span class=\"adminMenu\" style=\"width: 100%;\">" . $af->getAdminMenu() . "</span>", "adminStripe", "2mc_menu", "29o3 management console");
            // this part is for the admin scripts which require
            // are not fetched from database
            DEBUG("SYS: Skipping normal layout and box fetching procedures");
            $header->setTitle("29o3 management console");
            $ao = NULL;
            $func = $request->getWantedAdminFunc();
            if (!array_search($func, $ALLOWED_MGMT_FUNCS)) {
                $func = "Overview";
            }
            // administration needs admin logged in
            $sm = new sessionManager($connector);
            if ($sm->checkSession() == false) {
                DEBUG("MGMT: Admin not logged in.");
                $func = "Login";
            }
            if ($func == "Logout") {
                $sm->invalidateSession();
                header("Location: " . mksyslink("?"));
            }
            require_once $CONFIG["LibDir"] . 'admin/admin' . $func . '.php';
            $name = "Admin" . $func;
            $ao = new $name($connector, $pdo, $sm);
            $ao->doPreBodyJobs();
            $pdo->insertIntoBodyBuffer($af->getAdminMenu());
            $ao->doBodyJobs();
            DEBUG("DB: " . $connector->getExecutedQueries() . " queries executed.");
            $profiler->addBreakpoint();
            DEBUG("SYS: Resource usage,  sys:" . $profiler->getBreakpointGrandSysDifference() . "&micro;s usr:"******"&micro;s");
            $connector->closeConnection();
            DEBUG("DB: Connection closed.");
            DEBUG("SYS: Exiting normally.");
            if ($CONFIG['Developer_Debug'] == true) {
                if ($body) {
                    $body->eyecandyConsole($console);
                } else {
                    $console->printBuffer();
                }
            }
            //			$pdo->insertBodyDiv("Powered by <a href=\"http://twonineothree.berlios.de\">29o3</a> " . $SYSTEM_INFO["SystemVersion"] . " Codename " . $SYSTEM_INFO["SystemCodename"], "poweredBy", "poweredBy_Banner", "Powered by 29o3");
            // print the buffer of the header since we're done with it :)
            printf('<?xml version="1.0" encoding="UTF-8"?>');
            printf('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">%s', "\n");
            printf('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">%s', "\n");
            $pdo->doInsertions();
            $pdo->printHeaderBuffer();
            $header_started = true;
            // destruct the header object
            $pdo->destroyHeaderObject();
            $body_started = true;
            // print out the body buffer
            $pdo->printBodyBuffer();
            printf('</html>');
            // exit normally
            exit(0);
        }
    } else {
        echo $co->getCacheContent();
        DEBUG("DB: " . $connector->getExecutedQueries() . " queries executed.");
        $profiler->addBreakpoint();
        DEBUG("SYS: Resource usage,  sys:" . $profiler->getBreakpointGrandSysDifference() . "&micro;s usr:"******"&micro;s");
        $connector->closeConnection();
        DEBUG("DB: Connection closed.");
        DEBUG("SYS: Exiting normally.");
        if ($CONFIG['Developer_Debug'] == true) {
            echo '<center><div class="eyecandyConsole">' . $console->getBuffer() . '</div></center>';
        }
        echo "\n</body>\n</html>";
        // exit normally
        exit(0);
    }
    // never reached
}
Esempio n. 16
0
} else {
    $old_plugin_dir = "";
}
$plist->gen_menu();
/* check if we are using account expiration */
$smarty->assign("hideMenus", FALSE);
if ($config->get_cfg_value("handleExpiredAccounts") == "TRUE") {
    $expired = $ui->expired_status();
    if ($expired == POSIX_WARN_ABOUT_EXPIRATION && !session::is_set('POSIX_WARN_ABOUT_EXPIRATION__DONE')) {
        @DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $expired, "This user account (" . $ui->uid . ") is about to expire");
        // The users password is about to xpire soon, display a warning message.
        new log("security", "fusiondirectory", "", array(), "password for user '" . $ui->uid . "' is about to expire");
        msg_dialog::display(_("Password change"), _("Your password is about to expire, please change your password!"), INFO_DIALOG);
        session::set('POSIX_WARN_ABOUT_EXPIRATION__DONE', TRUE);
    } elseif ($expired == POSIX_FORCE_PASSWORD_CHANGE) {
        @DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $expired, "This user account expired");
        // The password is expired, we are now going to enforce a new one from the user.
        // Hide the FusionDirectory menus to avoid leaving the enforced password change dialog.
        $smarty->assign("hideMenus", TRUE);
        $plug = isset($_GET['plug']) ? $_GET['plug'] : NULL;
        // Search for the 'password' class and set its id as active plug.
        foreach ($plist->dirlist as $key => $value) {
            if (preg_match("/\\bpassword\\b/i", $value)) {
                if ($plug != $key) {
                    $_GET['plug'] = $key;
                }
                break;
            }
        }
    }
}
Esempio n. 17
0
    				$cont.=$line;
    				$ii++;
    		}	
    */
    if (!($handle = fopen($igcFilename, 'w'))) {
        exit;
    }
    if (!fwrite($handle, $cont)) {
        exit;
    }
    fclose($handle);
    @chmod($path . "/olc", 0755);
    $cmd = $path . "/olc " . $igcFilename;
    DEBUG("cmd={$cmd}");
    exec($cmd, $res);
    DEBUG("result has " . count($res) . " lines");
    foreach ($res as $line) {
        DEBUG($line);
        if (substr($line, 0, 4) == "OUT ") {
            echo substr($line, 4) . "\n";
        }
    }
    @unlink($igcFilename);
}
function DEBUG($msg)
{
    global $debugActive;
    if ($debugActive) {
        echo ">>{$msg}*<br>";
    }
}
 function __construct($connector, $pdo)
 {
     $this->db = $connector;
     $this->pdo = $pdo;
     DEBUG("AdminAccounts: Constructed.");
 }
/**
 * parseLinkFile
 *   Extract a list of CLinkClass objects from a HTML bookmark file
 */
function parseLinkFile($linkFileName)
{
    $links = array();
    $index = 0;
    if (!($linkFile = file_get_contents($linkFileName))) {
        showFatalError("Cannot open link file '{$linkFileName}'");
    }
    $openBracePos = strpos($linkFile, '<');
    $closeBracePos = strpos($linkFile, '>', $openBracePos);
    $done = $closeBracePos == 0 || $linkFile[$openBracePos] != '<';
    while (!$done) {
        if ($linkFile[$openBracePos + 1] == '/') {
            $closeTag = strtolower(substr($linkFile, $openBracePos + 2, $closeBracePos - $openBracePos - 2));
            DEBUG("closing tag '{$closeTag}' detected.\n");
            if ($closeTag == $openTag) {
                $tagElementEnd = $openBracePos;
                $tagElement = substr($linkFile, $tagElementStart, $tagElementEnd - $tagElementStart);
                DEBUG("tag element = '{$tagElement}'\n");
            }
            switch ($closeTag) {
                case "h2":
                    $category = trim($tagElement);
                    break;
                case "a":
                    $description = trim($tagElement);
                    break;
                case "li":
                    DEBUG("creating new link ({$url}, {$description}, {$category})\n");
                    array_push($links, new CLinkClass($url, $description, $category, $createdTimestamp, $lastVisitedTimestamp, $visitCount, $index));
                    $index++;
                    break;
            }
        } else {
            $openTag = substr($linkFile, $openBracePos + 1, $closeBracePos - $openBracePos - 1);
            $tagElementStart = $closeBracePos + 1;
            preg_match_all('/\\s(\\S*)\\s*=\\s*"([^"]*)"/', $openTag, $matches, PREG_SET_ORDER);
            // 	array_shift($matches);
            foreach ($matches as $match) {
                $attributes[strtolower($match[1])] = $match[2];
                DEBUG("Set attrib[{$match['1']}] = '{$match['2']}'\n");
            }
            $spacePos = strpos($openTag, ' ');
            if ($spacePos > 0) {
                $openTag = substr($openTag, 0, $spacePos);
            }
            $openTag = strtolower($openTag);
            DEBUG("opening tag '{$openTag}' detected\n");
            switch ($openTag) {
                case 'a':
                    $url = $attributes['href'];
                    $createdTimestamp = $attributes['createdtimestamp'];
                    $lastVisitedTimestamp = $attributes['lastvisitedtimestamp'];
                    $visitCount = $attributes['visitcount'];
                    break;
            }
        }
        if (!($openBracePos = strpos($linkFile, '<', $closeBracePos))) {
            DEBUG("done (no more open braces found).\n");
            $done = TRUE;
        }
        if (!($closeBracePos = strpos($linkFile, '>', $openBracePos))) {
            DEBUG("done (no more close braces found).\n");
            $done = TRUE;
        }
    }
    return $links;
}
Esempio n. 20
0
 function computeSecondPass($file)
 {
     DEBUG("SCORE", 1, "Making igc file with points around the Turnpoints");
     $tmpFile = $this->makeSecondPassFile($file);
     DEBUG("SCORE", 1, "Scoring file : {$tmpFile}");
     $results = $this->getScore($tmpFile, 1);
     $this->parseScore($results);
     @unlink($tmpFile);
 }
Esempio n. 21
0
        DEBUG($line);
    }
    if ($valArray['ok_result'] == 9999) {
        // search for string instead
        if (trim($output[0] == $valArray['ok_string'])) {
            $ok = 1;
            break;
        }
    } else {
        // ok found the correct val program
        if ($res == $valArray['ok_result']) {
            $ok = 1;
            break;
        }
    }
}
DEBUG("</pre>");
@unlink($igcFilename);
if ($ok) {
    echo "VALI:OK\n{$valProgram}";
} else {
    echo "VALI:NOK";
}
echo $dbgStr;
function DEBUG($msg)
{
    global $debugActive, $dbgStr;
    if ($debugActive) {
        $dbgStr .= "{$msg}<br>\n";
    }
}
Esempio n. 22
0
                    flush2Browser();
                    $flight->checkAirspace(1);
                    echo " Checked: " . $flight->airspaceCheckMsg . "<BR>";
                    flush2Browser();
                }
                $i++;
                if ($i > $airspaceChunk) {
                    break;
                }
            }
        }
        echo "<BR><br><BR>DONE !!!<BR>";
    } else {
        if ($_GET['importFile']) {
            $fileToImport = $_GET['importFile'];
            DEBUG('AdminAirspace', 1, "Importing file {$fileToImport}<BR>");
            require_once dirname(__FILE__) . '/FN_airspace_admin.php';
            ReadAirspace($airspaceDir . '/' . $fileToImport);
            if (!putAirspaceToDB()) {
                echo "<BR><BR>Problem in Importing airspace to DB<BR><BR>";
            }
        }
    }
}
?>
 <table class='simpleTable' width="100%" border=0 cellpadding="2" cellspacing="0">
   <tr>
     <td colspan="3"><strong>Actions :: <a href="<?php 
echo CONF_MODULE_ARG;
?>
&op=admin_airspace&act=delete_all">Delete all airspace entries in the DB</a> :: 
 function setOmitBranding($choose)
 {
     if ($choose == true) {
         $this->doBrand = false;
         DEBUG("PDO: Branding deactivated.");
         return;
     }
     $this->doBrand = true;
 }
Esempio n. 24
0
function addFlightFromFile($filename, $calledFromForm, $userIDstr, $argArray = array())
{
    global $CONF_default_cat_add, $CONF_photosPerFlight, $CONF;
    global $CONF_NAC_list, $CONF_use_NAC, $CONF_use_validation, $CONF_airspaceChecks, $CONF_server_id;
    global $userID, $CONF_new_flights_submit_window;
    global $flightsTable;
    set_time_limit(120);
    global $CONF_server_id;
    list($thisServerID, $userIDforFlight) = splitServerPilotStr($userIDstr);
    if (!$thisServerID) {
        $thisServerID = $CONF_server_id;
    }
    require_once dirname(__FILE__) . '/CL_actionLogger.php';
    $log = new Logger();
    $log->userID = $userID + 0;
    // the userId that is logged in , not the one that the flight will be atrributed to
    $log->ItemType = 1;
    // flight;
    $log->ItemID = 0;
    // 0 at start will fill in later if successfull
    $log->ServerItemID = $thisServerID;
    $log->ActionID = 1;
    //1  => add  2  => edit;
    $log->ActionXML = '';
    $log->Modifier = 0;
    $log->ModifierID = 0;
    $log->ServerModifierID = 0;
    $log->Result = 0;
    $log->ResultDescription = "";
    if (!$filename) {
        $log->ResultDescription = getAddFlightErrMsg(ADD_FLIGHT_ERR_YOU_HAVENT_SUPPLIED_A_FLIGHT_FILE, 0);
        if (!$log->put()) {
            echo "Problem in logger<BR>";
        }
        return array(ADD_FLIGHT_ERR_YOU_HAVENT_SUPPLIED_A_FLIGHT_FILE, 0);
    }
    // now is the time to remove bad chars from the filename!
    $newFilename = str_replace("'", " ", $filename);
    $newFilename = toLatin1($newFilename);
    if ($newFilename != $filename) {
        rename($filename, $newFilename);
        $filename = $newFilename;
    }
    if (!is_file($filename)) {
        $log->ResultDescription = getAddFlightErrMsg(ADD_FLIGHT_ERR_NO_SUCH_FILE, 0);
        if (!$log->put()) {
            echo "Problem in logger<BR>";
        }
        return array(ADD_FLIGHT_ERR_NO_SUCH_FILE, 0);
    }
    if (strtolower(substr($filename, -4)) != ".igc") {
        $log->ResultDescription = getAddFlightErrMsg(ADD_FLIGHT_ERR_FILE_DOESNT_END_IN_IGC, 0);
        if (!$log->put()) {
            echo "Problem in logger<BR>";
        }
        return array(ADD_FLIGHT_ERR_FILE_DOESNT_END_IN_IGC, 0);
    }
    $tmpIGCPath = $filename;
    $flight = new flight();
    if ($thisServerID != $CONF_server_id) {
        $flight->userServerID = $thisServerID;
    }
    $flight->userID = $userIDforFlight;
    /*
    	$flight->cat=$gliderCat;
    	$flight->private=$is_private;
    	$flight->category=$category;
    	$flight->comments=$comments;
    	$flight->glider=$glider;
    	$flight->linkURL=$linkURL;
    */
    foreach ($argArray as $varName => $varValue) {
        if ($varName == 'NACclubID' || $varName == 'NACid' || $varName == 'comments') {
            continue;
        }
        $flight->{$varName} = $varValue;
    }
    $comments = $argArray['comments'];
    if ($comments) {
        $flight->commentsNum = 1;
    }
    if (strtolower(substr($flight->linkURL, 0, 7)) == "http://") {
        $flight->linkURL = substr($flight->linkURL, 7);
    }
    if ($flight->cat == -1) {
        $flight->cat = $CONF_default_cat_add;
    }
    # martin jursa 22.06.2008:
    # in case the glider is not given otherwise, try to extract it from the IGC file
    if (empty($flight->glider)) {
        $flight->glider = extractGlider($lines);
    }
    // if no brand was given , try to detect
    $flight->checkGliderBrand();
    //  we must cope with some cases here
    //  1. more flights in the igc
    //  2. garmin saved paths -> zero time difference -> SOLVED!
    if (!$flight->getFlightFromIGC($tmpIGCPath)) {
        $log->ResultDescription = getAddFlightErrMsg(ADD_FLIGHT_ERR_THIS_ISNT_A_VALID_IGC_FILE, 0);
        if (!$log->put()) {
            echo "Problem in logger<BR>";
        }
        return array(ADD_FLIGHT_ERR_THIS_ISNT_A_VALID_IGC_FILE, 0);
    }
    // Compute hash now
    $lines = file($tmpIGCPath);
    $hash = md5(implode('', $lines));
    $flight->hash = $hash;
    unset($lines);
    // check for mac newlines -> NOT USED NOW
    // we now use auto_detect_line_endings=true;
    /*
    	if ( count ($lines)==1) {
    		if ($lines[0]=preg_replace("/\r([^\n])/","\r\n\\1",$lines[0])) {		
    			DEBUG('addFlightFromFile',1,"addFlightFromFile: MAC newlines found<BR>");
    			if (!$handle = fopen($tmpIGCPath, 'w')) { 
    				print "Cannot open file ($filename)"; 
    				exit; 
    			} 
    			if (!fwrite($handle, $lines[0])) { 
    			   print "Cannot write to file ($filename)"; 
    			   exit; 
    			} 
    			fclose($handle); 
    		} 
    	}
    */
    // echo $flight->DATE	." >  ". date("Y-m-d",time()+3600*10) ."<BR>";
    // check for dates in the furure
    if ($flight->DATE > date("Y-m-d", time() + 3600 * 10)) {
        @unlink($flight->getIGCFilename(1));
        @unlink($tmpIGCPath . ".olc");
        @unlink($tmpIGCPath);
        $log->ResultDescription = getAddFlightErrMsg(ADD_FLIGHT_ERR_DATE_IN_THE_FUTURE, 0);
        if (!$log->put()) {
            echo "Problem in logger<BR>";
        }
        return array(ADD_FLIGHT_ERR_DATE_IN_THE_FUTURE, 0);
    }
    // Two week time limit check - P.Wild
    /// Modification martin jursa 08.05.2007 cancel the upload if flight is too old
    if ($CONF_new_flights_submit_window > 0) {
        if (!L_auth::isAdmin($userID)) {
            if ($flight->DATE < date("Y-m-d", time() - $CONF_new_flights_submit_window * 24 * 3600)) {
                @unlink($flight->getIGCFilename(1));
                @unlink($tmpIGCPath . ".olc");
                @unlink($tmpIGCPath);
                $log->ResultDescription = getAddFlightErrMsg(ADD_FLIGHT_ERR_OUTSIDE_SUBMIT_WINDOW, 0);
                if (!$log->put()) {
                    echo "Problem in logger<BR>";
                }
                return array(ADD_FLIGHT_ERR_OUTSIDE_SUBMIT_WINDOW, 0);
            }
        }
    }
    // end martin / peter
    $sameFilenameID = $flight->findSameFilename(basename($filename));
    if ($sameFilenameID > 0) {
        if ($flight->allowDuplicates) {
            while (is_file($flight->getIGCFilename())) {
                $flight->filename = '_' . $flight->filename;
            }
        } else {
            @unlink($flight->getIGCFilename(1));
            @unlink($tmpIGCPath . ".olc");
            @unlink($tmpIGCPath);
            $log->ResultDescription = getAddFlightErrMsg(ADD_FLIGHT_ERR_SAME_FILENAME_FLIGHT, 0);
            if (!$log->put()) {
                echo "Problem in logger<BR>";
            }
            return array(ADD_FLIGHT_ERR_SAME_FILENAME_FLIGHT, $sameFilenameID);
        }
    }
    $sameFlightsArray = $flight->findSameTime();
    if (count($sameFlightsArray) > 0) {
        if ($flight->allowDuplicates) {
            // we allow duplicates if they are from another server
            $dupFound = 0;
            foreach ($sameFlightsArray as $k => $fArr) {
                if ($fArr['serverID'] == $flight->serverID) {
                    // if a same flight from this server is present we dont re-insert
                    $dupFound = 1;
                    break;
                } else {
                    // fill in ids of flights to 'disable'
                    $disableFlightsList[$fArr['ID']]++;
                }
            }
        } else {
            $dupFound = 1;
        }
        if ($dupFound) {
            @unlink($flight->getIGCFilename(1));
            @unlink($tmpIGCPath . ".olc");
            @unlink($tmpIGCPath);
            $log->ResultDescription = getAddFlightErrMsg(ADD_FLIGHT_ERR_SAME_DATE_FLIGHT, 0);
            if (!$log->put()) {
                echo "Problem in logger<BR>";
            }
            //	return  array( ADD_FLIGHT_ERR_SAME_DATE_FLIGHT,$sameFlightsArray[0]['serverID'].'_'. $sameFlightsArray[0]['ID']);
            return array(ADD_FLIGHT_ERR_SAME_DATE_FLIGHT, $sameFlightsArray[0]['ID']);
        } else {
            DEBUG("FLIGHT", 1, "addFlightFromFile: Duplicate DATE/TIME flight will be inserted<br>");
        }
    }
    $sameFlightsArray = $flight->findSameHash($hash);
    if (count($sameFlightsArray) > 0) {
        if ($flight->allowDuplicates) {
            // we allow duplicates if they are from another server
            //echo "searching in dups ";
            //print_r($sameFlightsArray);
            $dupFound = 0;
            $flightPilot = new pilot($flight->userServerID + 0, $flight->userID + 0);
            $flightPilotMapTable = $flightPilot->pilotMapping();
            // print_r($flightPilotMapTable);
            foreach ($sameFlightsArray as $k => $fArr) {
                if ($fArr['serverID'] == $flight->serverID) {
                    // if a same flight from this server is present we dont re-insert
                    $dupFound = 1;
                    break;
                } else {
                    // check that the existing flight belongs to a pilot that is 'mapped' to
                    // $flight->userID + $flight->userServerID
                    if (!$flightPilotMapTable[$fArr['userServerID']][$fArr['userID']]) {
                        DEBUG("FLIGHT", 1, "addFlightFromFile: Same hash from external Server BUT from the pilot was not mapped into local <br>");
                        // We allow the flight to be submitted but then we must check and disable all duplicates but one
                        //$dupFound=1;
                        //break;
                    }
                    // fill in ids of flights to 'disable'
                    $disableFlightsList[$fArr['ID']]++;
                }
            }
        } else {
            // echo "no dups allowesd";
            $dupFound = 1;
        }
        if ($dupFound) {
            @unlink($flight->getIGCFilename(1));
            @unlink($tmpIGCPath . ".olc");
            @unlink($tmpIGCPath);
            $log->ResultDescription = getAddFlightErrMsg(ADD_FLIGHT_ERR_SAME_HASH_FLIGHT, 0);
            if (!$log->put()) {
                echo "Problem in logger<BR>";
            }
            return array(ADD_FLIGHT_ERR_SAME_HASH_FLIGHT, $sameFlightsArray[0]['ID']);
        } else {
            DEBUG("FLIGHT", 1, "addFlightFromFile: Duplicate HASH flight will be inserted<br>");
            // echo "addFlightFromFile: Duplicate HASH flight will be inserted<br>";
        }
    }
    // print_r($disableFlightsList);
    /*
    	if ( ! $flight->allowDuplicates ) {
    		$sameHashIDArray=$flight->findSameHash( $hash );
    		if (count($sameHashIDArray)>0) 	 {
    			@unlink($flight->getIGCFilename(1));
    			@unlink($tmpIGCPath.".olc");
    			@unlink($tmpIGCPath);
    			$log->ResultDescription=getAddFlightErrMsg(ADD_FLIGHT_ERR_SAME_HASH_FLIGHT,0);
    			if (!$log->put()) echo "Problem in logger<BR>";
    			return array(ADD_FLIGHT_ERR_SAME_HASH_FLIGHT,$sameHashIDArray[0]['serverID'].'_'.$sameHashIDArray[0]['ID']);	
    		}
    	}
    */
    //******************************************************
    // PASSED ALL TESTS , NOW DO SOME WORK WITH OUR FLIGHT
    //******************************************************
    // move the flight to corresponding year
    $flight->checkDirs();
    //$yearPath=$flightsAbsPath."/".$userIDstr."/flights/".$flight->getYear();
    //$maps_dir=$flightsAbsPath."/".$userIDstr."/maps/".$flight->getYear();
    //$charts_dir=$flightsAbsPath."/".$userIDstr."/charts/".$flight->getYear();
    //$photos_dir=$flightsAbsPath."/".$userIDstr."/photos/".$flight->getYear();
    //if (!is_dir($yearPath))  	mkdir($yearPath,0755);
    //if (!is_dir($maps_dir))  	mkdir($maps_dir,0755);
    //if (!is_dir($charts_dir))	mkdir($charts_dir,0755);
    //if (!is_dir($photos_dir))	mkdir($photos_dir,0755);
    /**
     * Martin Jursa; to avoid error log flooding
     */
    if (file_exists($tmpIGCPath)) {
        @rename($tmpIGCPath, $flight->getIGCFilename());
    }
    // in case an olc file was created too
    if (file_exists($tmpIGCPath . ".olc")) {
        @rename($tmpIGCPath . ".olc", $flight->getIGCFilename() . ".olc");
    }
    // these commands seem redundant:
    //@unlink($tmpIGCPath.".olc");
    //@unlink($tmpIGCPath);
    /*old:	@rename($tmpIGCPath, $flight->getIGCFilename() );
    	// in case an olc file was created too
    	@rename($tmpIGCPath.".olc", $flight->getIGCFilename().".olc" );
    	@unlink($tmpIGCPath.".olc");
    	@unlink($tmpIGCPath);
    */
    // if we use NACclubs
    // get the NACclubID for userID
    // and see if the flight is in the current year (as defined in the NAclist array
    if ($CONF_use_NAC) {
        require_once dirname(__FILE__) . "/CL_NACclub.php";
        list($pilotNACID, $pilotNACclubID) = NACclub::getPilotClub($userIDforFlight);
        DEBUG("FLIGHT", 1, "addFlightFromFile: pilotNACID:{$pilotNACID}, pilotNACclubID: {$pilotNACclubID}<br>");
        if ($CONF_NAC_list[$pilotNACID]['use_clubs']) {
            DEBUG("FLIGHT", 1, "addFlightFromFile: use_clubs is on<br>");
            if ($argArray['NACclubID'] > 0 && $argArray['NACid'] > 0) {
                $flight->NACclubID = $argArray['NACclubID'];
                $flight->NACid = $argArray['NACid'];
                DEBUG("FLIGHT", 1, "addFlightFromFile: using arguments NACclubID NACid<br>");
            } else {
                DEBUG("FLIGHT", 1, "addFlightFromFile: calculating  NACclubID NACid<br>");
                // check year -> we only put the club for the current season , so that results for previous seasons cannot be affected
                $currSeasonYear = $CONF_NAC_list[$pilotNACID]['current_year'];
                DEBUG("FLIGHT", 1, "addFlightFromFile: currSeasonYear:  {$currSeasonYear}<br>");
                if ($CONF_NAC_list[$pilotNACID]['periodIsNormal']) {
                    $seasonStart = $currSeasonYear - 1 . "-12-31";
                    $seasonEnd = $currSeasonYear . "-12-31";
                } else {
                    $seasonStart = $currSeasonYear - 1 . $CONF_NAC_list[$pilotNACID]['periodStart'];
                    $seasonEnd = $currSeasonYear . $CONF_NAC_list[$pilotNACID]['periodStart'];
                }
                DEBUG("FLIGHT", 1, "addFlightFromFile: seasonStart:{$seasonStart} , seasonEnd:{$seasonEnd}<br>");
                if ($flight->DATE > $seasonStart && $flight->DATE <= $seasonEnd) {
                    DEBUG("FLIGHT", 1, "addFlightFromFile: inside Season !!<br>");
                    $flight->NACclubID = $pilotNACclubID;
                    $flight->NACid = $pilotNACID;
                }
            }
        }
    }
    if ($CONF_use_validation) {
        $ok = $flight->validate(0);
        // dont update DB
    }
    if ($CONF_airspaceChecks) {
        $flight->checkAirspace(0);
        // dont update DB
    }
    $flight->putFlightToDB(0);
    // now do the photos
    if ($calledFromForm) {
        require_once dirname(__FILE__) . "/CL_flightPhotos.php";
        $flightPhotos = new flightPhotos($flight->flightID);
        // $flightPhotos->getFromDB();
        $j = 0;
        for ($i = 0; $i < $CONF_photosPerFlight; $i++) {
            $var_name = "photo" . $i . "Filename";
            $photoName = $_FILES[$var_name]['name'];
            $photoFilename = $_FILES[$var_name]['tmp_name'];
            if ($photoName) {
                if (CLimage::validJPGfilename($photoName) && CLimage::validJPGfile($photoFilename)) {
                    // $newPhotoName=toLatin1($photoName);
                    // Fix for same photo filenames 2009.02.03
                    //global $flightsAbsPath;
                    global $CONF;
                    $newPhotoName = flightPhotos::getSafeName(LEONARDO_ABS_PATH . '/' . str_replace("%PILOTID%", $flight->getPilotID(), str_replace("%YEAR%", $flight->getYear(), $CONF['paths']['photos'])), $photoName);
                    //$flightsAbsPath.'/'.$flight->getPilotID()."/photos/".$flight->getYear() ,
                    //$photoName	) ;
                    $phNum = $flightPhotos->addPhoto($j, $flight->getPilotID() . "/photos/" . $flight->getYear(), $newPhotoName, $description);
                    $photoAbsPath = $flightPhotos->getPhotoAbsPath($j);
                    if (move_uploaded_file($photoFilename, $photoAbsPath)) {
                        CLimage::resizeJPG($CONF['photos']['thumbs']['max_width'], $CONF['photos']['thumbs']['max_height'], $photoAbsPath, $photoAbsPath . ".icon.jpg", $CONF['photos']['compression']);
                        CLimage::resizeJPG($CONF['photos']['normal']['max_width'], $CONF['photos']['normal']['max_height'], $photoAbsPath, $photoAbsPath, $CONF['photos']['compression']);
                        $flight->hasPhotos++;
                        $j++;
                    } else {
                        //upload not successfull
                        $flightPhotos->deletePhoto($j);
                    }
                }
            }
        }
        // also try to get geotag info
        $flightPhotos->computeGeoInfo();
    }
    // took care of photos
    // tkae care of comments
    if ($comments) {
        global $lang2isoGoogle, $currentlang;
        $flightComments = new flightComments($flight->flightID);
        $commentInsertResult = $flightComments->addComment(array('parentID' => 0, 'userID' => $flight->userID + 0, 'userServerID' => $flight->userServerID + 0, 'guestName' => '', 'guestPass' => '', 'guestEmail' => '', 'text' => $comments, 'languageCode' => $lang2isoGoogle[$currentlang]), 0);
    }
    // now is a good time to disable duplicate flights we have found from other servers
    // AND are from the same user (using pilot's mapping table to find that out)
    global $db;
    if (0) {
        foreach ($disableFlightsList as $dFlightID => $num) {
            $query = "UPDATE {$flightsTable} SET private = private | 0x02 WHERE  ID={$dFlightID} ";
            $res = $db->sql_query($query);
            # Error checking
            if ($res <= 0) {
                echo "<H3> Error in query: {$query}</H3>\n";
            }
        }
    }
    //or
    $flight->hideSameFlights();
    set_time_limit(200);
    $flight->computeScore();
    $flight->updateTakeoffLanding();
    //	echo "TakeoffID:".$flight->takeoffID."<BR>";
    if (in_array($flight->takeoffID, $CONF['takeoffs']['private'])) {
        $flight->private = 1;
    }
    $flight->putFlightToDB(1);
    // update
    return array(1, $flight->flightID);
    // ALL OK;
}
 function __construct($connector, $pdo)
 {
     $this->db = $connector;
     $this->pdo = $pdo;
     DEBUG("AdminAppearance: Constructed.");
 }
Esempio n. 26
0
 function hideSameFlights()
 {
     // now is a good time to disable duplicate flights we have found from other servers
     // AND are from the same user (using pilot's mapping table to find that out)
     // addition: 2008/07/21 we search for all flight no only from same user/server
     global $db, $flightsTable;
     $query = "SELECT serverID,ID,externalFlightType, FROM {$flightsTable}\n\t\t\t\t\tWHERE hash='" . $this->hash . "' AND userID=" . $this->userID . " AND userServerID=" . $this->userServerID . " ORDER BY serverID ASC, ID ASC";
     $query = "SELECT serverID,ID,externalFlightType,userID,userServerID FROM {$flightsTable}\n\t\t\tWHERE hash='" . $this->hash . "' ORDER BY serverID ASC, ID ASC";
     // echo $query;
     $res = $db->sql_query($query);
     if ($res <= 0) {
         DEBUG("FLIGHT", 1, "flightData: Error in query: {$query}<br>");
         return array();
         // no duplicate found
     }
     // we must disable all flights BUT one
     // rules:
     // 1. locally submitted flights have priority
     // 2. between external flights , the full synced have priority over simple links
     // 3. between equal cases the first submitted has priority.
     $i = 0;
     while ($row = $db->sql_fetchrow($res)) {
         $fList[$i] = $row;
         $i++;
     }
     if ($i == 0) {
         return array();
         // no duplicate found
     }
     usort($fList, "sameFlightsCmp");
     $i = 0;
     $msg = '';
     foreach ($fList as $i => $fEntry) {
         if (0) {
             echo "<pre>";
             echo "-------------------------<BR>";
             print_r($fEntry);
             echo "-------------------------<BR>";
             echo "</pre>";
         }
         if ($i == 0) {
             // enable
             $msg .= " Enabling ";
             $query = "UPDATE {$flightsTable} SET private = private & (~0x02 & 0xff ) WHERE  ID=" . $fEntry['ID'];
         } else {
             // disable
             $msg .= " Disabling ";
             $query = "UPDATE {$flightsTable} SET private = private | 0x02 WHERE  ID=" . $fEntry['ID'];
         }
         $msg .= " <a href='http://" . $_SERVER['SERVER_NAME'] . getLeonardoLink(array('op' => 'show_flight', 'flightID' => $fEntry['ID'])) . "'>Flight " . $fEntry['ID'] . "</a> from <a href='http://" . $_SERVER['SERVER_NAME'] . getLeonardoLink(array('op' => 'pilot_profile', 'pilotIDview' => $fEntry['userServerID'] . '_' . $fEntry['userID'])) . "'>PILOT " . $fEntry['userServerID'] . '_' . $fEntry['userID'] . "</a><BR>\n";
         $res = $db->sql_query($query);
         # Error checking
         if ($res <= 0) {
             echo "<H3> Error in query: {$query}</H3>\n";
         }
         $i++;
     }
     // now also make a test to see if all flights are from same user (alien mapped  to local)
     // if not , send a mail to admin to warn him and suggest a new mapping
     $pList = array();
     foreach ($fList as $i => $fEntry) {
         $pList[$fEntry['userServerID'] . '_' . $fEntry['userID']]++;
     }
     if (count($pList) > 1) {
         // more than one pilot involved in this
         sendMailToAdmin("Duplicate flights", $msg);
         //echo "Duplicate flights".$msg;
     }
     /*
     		foreach ($disableFlightsList as $dFlightID=>$num) {
     			$query="UPDATE $flightsTable SET private = private | 0x02 WHERE  ID=$dFlightID ";
     			$res= $db->sql_query($query);
     			# Error checking
     			if($res <= 0){
     				echo("<H3> Error in query: $query</H3>\n");
     			}
     		}
     		foreach ($enableFlightsList as $dFlightID=>$num) {
     			$query="UPDATE $flightsTable SET private = private & (~0x02 & 0xff ) WHERE  ID=$dFlightID ";
     			$res= $db->sql_query($query);
     			# Error checking
     			if($res <= 0){
     				echo("<H3> Error in query: $query</H3>\n");
     			}
     		}*/
 }
 function parseRequest()
 {
     global $CONFIG;
     $this->userAgent = $_SERVER['HTTP_USER_AGENT'];
     $this->timestamp = 0;
     $requestString = explode(";", getenv("QUERY_STRING"));
     if ($requestString[0] == "mgmt") {
         $this->wantAdmin = 1;
         // this is needed due to the stylesheets
         // and as we think the admin is "clean" to the users, the console p.e. is not needed
         // removes the key containing "2mc" from the array
         // so that it can be used furthermore.
         DEBUG("PR: Admin wanted.");
         if (isset($requestString[2])) {
             $tmpString = $requestString[2];
             $this->wantedAdminFuncParam = $requestString[2];
             $this->wantedAdminFunc = $requestString[1];
         } else {
             $tmpString = "";
         }
         $this->wantAdmin++;
         DEBUG("PR: Admin non-db page requested: " . $requestString[1]);
         return;
     } else {
         $tmpString = $requestString[0];
     }
     if ($tmpString != "") {
         $tmpString = killScriptKiddies($tmpString);
         $tmpString = explode("/", $tmpString);
         if (count($tmpString) == 1) {
             $this->requestedSite = "default";
             $this->requestedPage = $tmpString[0];
         }
         if (count($tmpString) >= 2) {
             if (strlen($tmpString[1]) == 0) {
                 $this->requestedPage = "home";
             } else {
                 $this->requestedPage = $tmpString[1];
             }
             $this->requestedSite = $tmpString[0];
         }
         $this->connector->executeQuery("SELECT * FROM " . mktablename("sites") . " WHERE name='" . $this->requestedSite . "';");
         $siteArr = $this->connector->fetchArray();
         if ($siteArr !== false) {
             $existingPages = explode(";", $siteArr['members']);
             if (array_search($this->requestedPage, $existingPages) === false) {
                 header("HTTP/1.1 404 Not Found");
                 $orig_page = $this->requestedPage;
                 $this->requestedPage = "404NotFound";
                 DEBUG("PR: Given page not found in database (" . $this->requestedSite . "/" . $orig_page . ")");
                 $this->error = 404;
                 return;
             }
             $this->connector->executeQuery("SELECT * FROM " . mktablename("pages") . " WHERE name='" . $this->requestedPage . "'");
             $pageArr = $this->connector->fetchArray();
             $rm = new rightsManager($pageArr);
             if ($rm->hasUserViewingRights() == false) {
                 header("HTTP/1.1 401 Forbidden");
                 $this->requestedPage = "401Forbidden";
                 DEBUG("PR: Current user has insufficient rights to view this page.");
                 $this->error = 401;
                 return;
             }
         } else {
             header("HTTP/1.1 404 Not Found");
             $or_site = $this->requestedSite;
             $or_page = $this->requestedPage;
             $this->requestedPage = "404NotFound";
             $this->requestedSite = "default";
             DEBUG("PR: Given site does not exist, falling back to " . $this->requestedSite . "/" . $this->requestedPage . ". Requested site/page was: " . $or_site . "/" . $or_page);
             $this->error = 404;
             return;
         }
     } else {
         $homeFound = false;
         $this->connector->executeQuery("SELECT name FROM " . mktablename("pages"));
         while ($arr = $this->connector->fetchArray()) {
             if ($arr["name"] == "home") {
                 $homeFound = true;
             }
         }
         if ($homeFound) {
             $this->requestedPage = "home";
             $this->requestedSite = "default";
             DEBUG("PR: Falling back to default target.");
         } else {
             $this->requestedPage = "InstallationSuccessful";
             $this->requestedSite = "default";
             DEBUG("*** fresh 29o3 installation, defaulting to default/InstallationSuccessful ***");
         }
     }
 }
Esempio n. 28
0
function getUTMZoneWidth($lat)
{
    // central meridian of zone ?
    $central = 0;
    $zone_distance = calc_distance($lat, $central, $lat, $central + 6);
    DEBUG("UTM", 64, "Zone_distance at lat: {$lat} = {$zone_distance}<br>");
    return $zone_distance;
}
Esempio n. 29
0
if (!file_exists(CONFIG_DIR . '/' . CONFIG_FILE)) {
    header('location:setup.php');
    exit;
}
/* Check if fusiondirectory.conf (.CONFIG_FILE) is accessible */
if (!is_readable(CONFIG_DIR . '/' . CONFIG_FILE)) {
    msg_dialog::display(_('Configuration error'), sprintf(_('FusionDirectory configuration %s/%s is not readable. Please run fusiondirectory-setup --check-config to fix this.'), CONFIG_DIR, CONFIG_FILE), FATAL_ERROR_DIALOG);
    exit;
}
/* Parse configuration file */
$config = new config(CONFIG_DIR . '/' . CONFIG_FILE, $BASE_DIR);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    session::global_set('DEBUGLEVEL', 0);
} else {
    session::global_set('DEBUGLEVEL', $config->get_cfg_value('DEBUGLEVEL'));
    @DEBUG(DEBUG_CONFIG, __LINE__, __FUNCTION__, __FILE__, $config->data, 'config');
}
/* Set template compile directory */
$smarty->compile_dir = $config->get_cfg_value('templateCompileDirectory', SPOOL_DIR);
/* Check for compile directory */
if (!(is_dir($smarty->compile_dir) && is_writable($smarty->compile_dir))) {
    msg_dialog::display(_('Smarty error'), sprintf(_('Directory "%s" specified as compile directory is not accessible!'), $smarty->compile_dir), FATAL_ERROR_DIALOG);
    exit;
}
/* Check for old files in compile directory */
clean_smarty_compile_dir($smarty->compile_dir);
initLanguage();
$smarty->assign('nextfield', 'username');
if (isset($_POST['server'])) {
    $server = $_POST['server'];
} else {
Esempio n. 30
0
function getTZoffset($TZone, $tm)
{
    $oldTZ = getenv("TZ");
    // echo "old:$oldTZ";
    // DEBUG('getTZoffset',128,"getTZoffset: $TZone  ($tm) [server TZ=$oldTZ] ".date("T/Z/I/O")."<BR>");
    putenv("TZ={$TZone}");
    $offset = date('O', $tm);
    putenv("TZ={$TZone}");
    $offset = date('O', $tm);
    putenv("TZ={$TZone}");
    $offset = date('O', $tm);
    $tTZ = getenv("TZ");
    DEBUG('getTZoffset', 128, "getTZoffset: offset from GMT :{$offset} [getenv TZ= {$tTZ}] " . date("T/Z/I/O") . "<BR>");
    putenv("TZ={$oldTZ}");
    if (preg_match("/([-+])(\\d\\d)(\\d\\d)/", $offset, $matches)) {
        $secs = $matches[2] * 3600 + $matches[3] * 60;
        if ($matches[1] == '-') {
            $secs = -$secs;
        }
    } else {
        echo "FATAL error in flight offset";
        exit;
    }
    DEBUG('getTZoffset', 128, "getTZoffset: {$TZone}  ({$tm}) = " . $secs / 3600 . "<BR>");
    return $secs;
}