Hallo hab ich doch bei Re6: schon gesagt dass es funktioniert die datei mit Hello World zu erstellen
Dies wäre der Code der in der neuen PHP stehen soll.
Jedoch wird beim erstellen der datei schon in line4 frühzeitig $content beendet durch die ". Jetzt möchte ich wissen, wie ich der Regestrierung am leichtesten beibringe dass er diesen Script nicht ausführt.
<?PHP if ('POST' == $_SERVER['REQUEST_METHOD']) {
include("db.php");
$Username = $\_POST[Nachname].' '.$\_POST[Vorname];
$datei = $\_POST[Nachname].' '.$\_POST[Vorname].'.'.php;
// check if Username exist already
if($query = "SELECT UserName FROM user\_profile WHERE UserName='$Username' order by UserName asc")
$result=@mysql\_query($query);if(!$result){echo "SQL Error - ".mysql\_error();return;}
$NrUsers=mysql\_num\_rows($result);
if($NrUsers\>0)
{
echo '
Benutzer Existiert bereits.
';
echo '';
return;
}
// Check if E-Mail exist already
else if($query = "SELECT Email FROM user\_profile WHERE Email='$\_POST[Email]' order by Email asc")
$result=@mysql\_query($query);if(!$result){echo "SQL Error - ".mysql\_error();return;}
$NrUsers=mysql\_num\_rows($result);
if($NrUsers\>0)
{
echo '
E-Mail wird schon verwendet benutze Passwort Vergessen.
';
echo '';
return;
}
// check ob alle felder beschrieben sind
else if($\_POST['Nachname']==""||$\_POST['Vorname']==""||$\_POST['Password1']==""||$\_POST['Password2']==""||$\_POST['Email1']==""||$\_POST['Email2']=="")
{
echo '
Bitte Füllen Sie alle Felder aus.
';
echo '';
return;
}
// check ob die Passwoerter uebereinstimmen
else if($\_POST['Password1']!=$\_POST['Password2'])
{
echo '
Die Passwörter stimmen nicht überein.
';
echo '';
return;
}
else if($\_POST['Email1']!=$\_POST['Email2'])
{
echo '
Die E-Mails stimmen nicht überein.
';
echo '';
return;
}
else
{
$query = "INSERT INTO user\_profile (id,UserName,Password,Email) VALUES('','$Username','$\_POST[Password1]','$\_POST[Email1]')";
$result=@mysql\_query($query);if(!$result){echo "SQL Error - ".mysql\_error();return;}
$file = $datei;
$f = fopen($file,'w');
$content = '<?php echo <?php /* GLOBAL PARAMETERS FOR FsPlistflight.php */
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// the following arrays list the columns and the corresponding database field-names showing up in the table //
// you can add more columns/fields or remove those you don't wish to display or sort them in a different way //
// Note: the two arrays must have the same number of values; values must be separated by comma //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
$tableColumns = 'Flight Nr,Date,Pilot,From,To,PAX,Type,Time,Result,Bonus,Penalty';
$dataFields = 'FlightId,FlightDate,PilotName,DepartureIcaoName,ArrivalIcaoName,NbrPassengers,
AircraftType,TotalBlockTime,FlightResult,BonusPoints,PenalityPoints';
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////// GLOBAL PARAMETERS CHANGE THESE AS YOU LIKE //////////////////////////////////////
$pageLines = 25; // sets the number of rows displayed on each page
$tableWidth = '800'; // width of the main table - change according to number of columns
$defaultSort = 'datestamp desc'; // default sorting column if no other option is selected
// you can set this to 'FlightDate', 'CompanyName' or whatever you like,
// add 'desc' to sort the data in descending order
# colors
$oddColor = '#000000'; // 1st background color of alternating table rows
$evenColor = '#333333'; // 2nd background color of alternating table rows
$linkColor = '#000099'; // font color for linked items (in this case just "FlightId")
# misc data formats
$dateFormat = 0; // sets the default YYYY-MM-DD format for the Flight Date
$dateSeparator = '-'; // you can set it to '1' to use DD.MM.YYYY instead
// you can also change the separator character (e.g. '.')
# Headline on top of page
$PageTitle ="Weineis Patrick";
# set a start date (referring to upload-date) for the records to be displayed, starting with that date
# this is optional, leave it empty (default) to display all records in the database
$startDate = ''; // if not empty, the date must be entered in a given format
// (YYYY-MM-DD) and it has to be valid - ex.: '2005-05-30'
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////NEEDED STUFF USUALLY YOU WILL NOT NEED TO CHANGE THIS///////////////////////////////////
define("FSP", 1);
# setting.php contains MySQL database settings and other settings; it contains also the FSP UNIT SETTING
require("FsPadmin/setting.php");
# common.php do the connection to MySQL the value $databaseconnexion is set to true if the connection is okay
require("FsPadmin/common.php");
// the value "$databaseconnexion" is set to true in common.php if the connexion is ok
if($databaseconnexion==FALSE){echo "Error - unable to connect to mySQL database;";return;}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// get the header-variables GET / POST
$listflight = $\_GET['listflight']; // ID of a single selected flight
$s = $\_GET['s']; // sorting option (column)
$d = $\_GET['d']; // sorting direction (ASCENDING or DESCENDING)
$p = $\_GET['p']; // actual page to display
// create the arrays for the column names and database fields from config.php
$columnNames = explode(",",$tableColumns);
$dbFieldNames = explode(",",$dataFields);
for($i=0;$i $dbFieldNames[$i] = trim($dbFieldNames[$i]);
}
// set the sql condition for start date selected, if any
$condition = '';
$andCondition = '';
if($startDate != '')
{
$startMsg = ' since '.$startDate;
$startDate .= ' 00:00:00';
$condition = "where datestamp\>=str\_to\_date('".$startDate."','%Y-%m-%d %H:%i:%s')";
$andCondition = "and datestamp\>=str\_to\_date('".$startDate."','%Y-%m-%d %H:%i:%s')";
}
// avoid invalid options for $d
if ($d!=1) $d=0;
// SORTING ////////////////////////////////////////////////////////////////////////////////////////////////////
if($s=="")
{
$sortColumn = $defaultSort;
} else {
$sortColumn = $s;
if($d==1) $sortColumn .= ' desc';
$sortOptions[$sortColumn] = !$sortOptions[$sortColumn];
if($sortColumn!='id desc' && $sortColumn!='id')
{
$sortColumn .= ', id desc';
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////// EDIT THE TABLE DESIGN HERE //////////////////////////////////////////////////////////////
$ListStart ='';
$TDTitStyle ='';
$TableTitle ='';
// loop to create the column headers
for ($i=0;$i'.$columnNames[$i].''.chr(13);
}
$TDListOdd =''; // define here background and font colors of
$TDListEven =''; // the alternating rows
$TRList ='';
$ListStop ='';
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////// THIS IS THE LIST OVERVIEW //////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
if(!isset($listflight))
{
// ------------------------------ INTRO-TEXT -----------------------------------------------------
// delete or edit as you like ...
echo '
'.$PageTitle.'
A demonstration of FsPassenger\'s VA database interface
';
// ------------------------------------------------------------------------------------------------
/////////////////////////////////////// INTRO-TEXT FSP VA /////////////////////////////////////////
/\*
echo '
WARNING !!! This shows only the abilities of FsP to export and record data in a SQL database,
I don\'t have time yet to make a nice page so the data are displayed "right out of the box".
See this topic in the forum about export features:
[Exporting flight log online to VA](http://www.fspassengers.com/forum/read.php?f=1&i=1150&t=1150) (screenshots)
';
echo '
';
\*/
///////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////// STATISTICS /////////////////////////////////////////
/// Get the total number of flights, total flight time, total passengers & total cargo weight //
///////////////////////////////////////////////////////////////////////////////////////////////////
$query = "SELECT sec\_to\_time(sum(time\_to\_sec(TotalBlockTime))) FROM flights WHERE UserName = 'Weineis Patrick' ".$condition;
$result=mysql\_query($query);
$flighttime = number\_format(mysql\_result($result,0));
$query = "select ranking FROM rank WHERE hours \>= $flighttime limit 1".$condition;
$result = mysql\_query($query);
$ranking = mysql\_result($result,0);
$query = "select count(\*) from flights WHERE UserName = 'Weineis Patrick' ".$condition;
$result=mysql\_query($query);
if(!$result){echo "SQL Error - ".mysql\_error()."
".$query;return;}
$NrfFlights=mysql\_result($result,0);
# total flight time / block time
$query = "SELECT sec\_to\_time(sum(time\_to\_sec(TotalBlockTime))) FROM flights WHERE UserName = 'Weineis Patrick' ".$condition;
$result=mysql\_query($query);
$TFT = number\_format(mysql\_result($result,0));
# total passengers
$query = "SELECT sum(NbrPassengers) FROM flights WHERE UserName = 'Weineis Patrick' ".$condition;
$result=mysql\_query($query);
$TPC = number\_format(mysql\_result($result,0));
$query = "SELECT sum(BonusPoints) - sum(PenalityPoints) FROM flights WHERE UserName = 'Weineis Patrick' ".$condition;
$result=mysql\_query($query);
$Point = number\_format(mysql\_result($result,0));
# total cargo weight // there might be units of lbs as well as kg in one database
// therefor each sum has to be read separately.
// we compute the total weight in one unit first and
// display both units in the stats
$query = "SELECT sum(CargoWeight) FROM flights where right(CargoWeight,2)='kg' AND UserName = 'Weineis Patrick' ".$andCondition;
$result=mysql\_query($query);
$TCKG = mysql\_result($result,0);
$query = "SELECT sum(CargoWeight) FROM flights where right(CargoWeight,3)='lbs' AND UserName = 'Weineis Patrick' ".$andCondition;
$result=mysql\_query($query);
$TCLB = mysql\_result($result,0);
$TCW = getWeight($TCKG,$TCLB); // see function at end of script
echo '
'.$TDListOdd.
" Weineis Patrick Statistic
".
"Rang".$startMsg.": $ranking
Total flights: $NrfFlights
Total flight time: $TFT h
Total passengers carried: $TPC
Total Cargo carried: $TCW
Total Points: $Point ".
$ListStop;
echo "
";
//////////////////////////////////////////////////////////////////////////////////////////////////
// ------------------------------ COMMENTS -------------------------------------------------------
// delete or edit as you like ...
echo 'Click on Flight-Nr to show the details of one flight. Click on the column headers to sort the data by columns.
';
// ------------------------------------------------------------------------------------------------
// PAGING /////////////////////////////////////////////////////////////////////////////////////////
//
// set max page numbers displayed at a time (to avoid line breaks in the paging)
$maxPage = 20;
$pageStep = 10;
$pStart = 0;
if ($NrfFlights\>0)
{
$pages = ceil($NrfFlights/$pageLines);
if(isset($p) && $p$NrfFlights) $pEnd=$NrfFlights;
// reduce the nbr of pages displayed at a time
if($pages \> $maxPage)
{
$pageFrom = $thisPage-$pageStep;
if($pageFrom $pages) $pageTo = $pages;
}
else
{
$pageTo = $pages;
}
// create the for the paging
$paging\_Html = ''.chr(13);
$paging\_Html .= 'Page ';
for ($i=$pageFrom;$i'.($i+1).' '.chr(13);
} else {
$paging\_Html .= '['.($i+1).'](?action=va&s='.%2524s.'&d='.%2524d.'&p='.%2524i.') '.chr(13);
}
}
if ($thisPage+1!=$pages)
{
$paging\_Html .= '[next »](?action=va&s='.%2524s.'&d='.%2524d.'&p='.(%2524thisPage+1).')';
}
$paging\_Html .= '
Displaying Flight '.($pStart+1).' to '.$pEnd.' of a total '.$NrfFlights.'';
$paging\_Html .= '';
// main sql-query :
$query = "SELECT \* FROM flights WHERE UserName = 'Weineis Patrick' ".$condition." ORDER BY $sortColumn LIMIT $pStart,$pageLines";
if(!$result=mysql\_query($query))
{
// if any invalid sort parameters are transmitted, the sorting defaults to 'id'
$query = "SELECT \* FROM flights ".$condition." ORDER BY $defaultSort LIMIT $pStart,$pageLines";
if(!$result=mysql\_query($query))
{
echo "SQL Error - ".mysql\_error()."
".$query;
return;
}
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////// LIST TABLE OUTPUT ///////////////////////////////////////////////////////////////
echo $paging\_Html;
echo $ListStart.$TableTitle;
if ($NrfFlights\>0) {
$Line=0;
// loop to display all rows
while ($row = mysql\_fetch\_assoc($result))
{
echo $TRList;
// loop to display all columns using function "makeTD()"
for($i=0;$i';
$Line=!$Line;
}
}
else
{
echo '
There are no flights recorded.';
}
echo $ListStop;
echo $paging\_Html;
///////////////////////////////////////////////////////////////////////////////////////////////////////
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if(!isset($listflight))return;
///////////////////// THIS IS THE SINGLE FLIGHT OUTPUT ///////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$query = "SELECT \* FROM flights WHERE id=$listflight";
$result=mysql\_query($query);
if(!$result){echo "SQL Error - ".mysql\_error();return;}
$NrfFlights=mysql\_num\_rows($result);
if($NrfFlights==0){echo "No flights to display";return;}
$Line=0;
$row = mysql\_fetch\_assoc($result);
echo '';
echo 'Company: '.$row["CompanyName"].' Flight Id: '.$row["FlightId"].' Flight Date: '.$row["FlightDate"].' Pilot: '.$row["PilotName"]."";
echo 'Aircraft Name:'.$row["AircraftName"]."";
echo 'Aircraft Type:'.$row["AircraftType"]."";
echo 'Departure:'.$row["DepartureIcaoName"]."";
echo 'Arrival:'.$row["ArrivalIcaoName"]."";
echo 'Departure Time:'.$row["DepartureLocalHour"]." (".$row["DepartureGmtHour"]." GMT)";
echo 'Arrival Time:'.$row["ArrivalLocalHour"]." (".$row["ArrivalGmtHour"]." GMT)
";
echo 'Passengers:'.$row["NbrPassengers"]."";
echo 'Cargo:'.$row["CargoWeight"]."";
echo 'Flight Result:'.$row["FlightResult"]."";
echo 'Take-Off Weight:'.$row["StartAircraftWeight"]."";
echo 'Landing Weight:'.$row["EndAircraftWeight"]."";
echo 'Take-Off fuel:'.$row["StartFuelQuantity"]."";
echo 'Landing Fuel:'.$row["EndFuelQuantity"]."";
echo 'TotalBlockTime:'.$row["TotalBlockTime"]."";
echo 'TotalBlockTimeNight:'.$row["TotalBlockTimeNight"]."";
echo 'TotalAirbornTime:'.$row["TotalAirbornTime"]."";
echo 'TotalTimeOnGround:'.$row["TotalTimeOnGround"]."";
echo 'MaxAltitude:'.$row["MaxAltitude"]."";
if($row["CruiseTimeStopSec"]\>0)
{
echo 'CruiseSpeed:'.$row["CruiseSpeed"]."";
echo 'CruiseMachSpeed:'.$row["CruiseMachSpeed"]."";
}
if($row["LandingSpeed"]\>0)
{
echo 'LandingSpeed:'.$row["LandingSpeed"]."";
echo 'LandingPitch:'.$row["LandingPitch"]."°";
}
echo 'TouchDownVertSpeedFt:'.$row["TouchDownVertSpeedFt"]." ft/mn";
echo 'CaptainSentMayday:'.$row["CaptainSentMayday"]."";
echo 'CrashFlag:'.$row["CrashFlag"]."";
echo 'PassengersOpinion:'.$row["PassengersOpinion"]."%";
echo 'PassengersOpinionText:-'.$row["PassengersOpinionText"]." ";
echo 'FailureText:-'.$row["FailureText"]."";
echo 'CasualtiesText:-'.$row["CasualtiesText"]." ";
echo 'Pilot Bonus:'.$row["BonusPoints"]." ";
echo 'PilotBonusText:-'.$row["PilotBonusText"]." ";
echo 'Pilot Penality:'.$row["PenalityPoints"]." ";
echo 'PilotPenalityText:-'.$row["PilotPenalityText"]." ";
echo '[« back](javascript:history.back())';
echo '';
echo '
';
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/
// Functions
/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/
// this function generates the HTML for one cell (TD) in a table row
function makeTD($data,$fieldName,$evenodd,$rowID=-1)
{ global $linkColor;
global $evenColor;
global $oddColor;
global $dateFormat;
global $dateSeparator;
// set alternating background-colors
if($evenodd==1) {$bgColor = $evenColor;} else {$bgColor = $oddColor;}
// automatic right-align for numeric values
if(is\_numeric($data) && $fieldName!='FlightId') {$tdalign = 'align="right" ';} else {$tdalign = '';}
// reformat the FlightDate from YYYY-MM-DD to DD-MM-YYYY (only if the global parameter is set to '1')
if($dateFormat == 1 && $fieldName == 'FlightDate' && strlen($data) == 10) {
$data = reDate($data,$dateSeparator);
}
// short departure/arrival ICAO names (delete the following line to show long names)
if(strstr($fieldName,'IcaoName')) $data=substr($data,0,4);
// link through Flight-ID?
if($rowID\>-1) $data = '['.$data.'](?listflight='.%2524rowID.')';
// return the HTML
$tdList = ''.$data.''.chr(13);
return $tdList;
}
// this function takes the accumulated kg and lbs weights,
// puts them together and returns the total cargo in both units
function getWeight($kg,$lb)
{
$LBtoKG = 0.4535924;
$totalKG = $kg+($lb\*$LBtoKG);
$totalLB = $totalKG/$LBtoKG;
$cwStr = number\_format($totalKG,0).' kg / '.number\_format($totalLB,0).' lbs';
return $cwStr;
}
// changes the format of a given date from YYYY-MM-DD to DD-MM-YYYY
// the second parameter defines the separator used
function reDate($dt,$sep) {
$nDate = "";
if(strstr($dt,'-')) {
$tmpArr = explode("-",$dt);
for($i=count($tmpArr)-1;$i\>=0;$i--) {
$nDate .= $tmpArr[$i].$sep;
}
$nDate = substr($nDate,0,strlen($nDate)-1);
}
return $nDate;
}
// this adds two hours of FsP and returns them in hour format
// ( 12:30:45 + 02:05:06 = 14:35:51 for example)
// --- not used in this script ---
function AddTime($Time1,$Time2)
{
$timea=explode(":",$Time1);
$timeb=explode(":",$Time2);
$secondes=($timea[0]+$timeb[0])\*3600;
$secondes+=($timea[1]+$timeb[1])\*60;
$secondes+=$timea[2]+$timeb[2];
$hours = floor($secondes / 3600);
$minute = floor(($secondes - ($hours \* 3600)) / 60);
$secconde = $secondes - ($hours \* 3600) - ($minute \* 60);
return sprintf("%02d:%02d:%02d", $hours, $minute, $secconde);
}
?\>?\>';
fwrite($f,$content,strlen($content));
fclose($f);
echo '
Benutzer Erfolgreich hinzugefügt.
';
echo '
[zurück zum Start](hauptframe.htm).
';
echo '';
return;
}
return;
?\>
Die Daten wurden eingetragen
[neuer Eintrag](insert.php)
[zur Übersicht](fetcharr.php)
<?PHP } else { ?>
Nachname:
Vorname:
Passwort:
Passwortbestätigung :
E-Mail:
E-Mail:
<?PHP } ?>
mfg
Weineis Patrick