Nejste přihlášeni
Zdravím,
Mám problém s jedním programem na reportování letů z Flight Simulátoru.
Píše to: ERROR Sending log Data base error.
@define ("MYSQL_CONNECT_INCLUDE", "connect_db.php");
@define ("REPORT_FILE_URL", "http://www.fl1ght3r.4fan.cz/ACARS");
@define ("REPORT_FILE_PATH", "fl1ght3r.4fan.cz/web/ACARS/reports/");
@define ("ERROR_LOG_PATH", "fl1ght3r.4fan.cz/web/ACARS/errors/");
v connect_db.php je:
$hostName = "localhost";
$userName = "fsacars";
$password = "*****";
$dbName = "acars";
Je to správně ?
Offline
no v subore connect_db.php by si mal ty vediet, ci su udaje spravne, ale Flight Simulator na webu som este nevidel. A kedze taky program som ani nevidel tak uryvok tohto kodu aspon mne nepomoze. Skus najsť funkciu mysql_connect() alebo DB:connect alebo infu funkciu na pripojenie
Portfólio
E-mail: eduard(at)karpiel.sk
Offline
To budou jen jakoby odletěné lety ;-) zobrazené např v google earth.
Ten connect:
mysql_connect($hostName, $userName, $password) or die("Unable to connect to host $hostName");
mysql_select_db($dbName) or die("Unable to select database $dbName");
@define ("REPORT_FILE_PATH", "fl1ght3r.4fan.cz/web/ACARS/reports/");
@define ("ERROR_LOG_PATH", "fl1ght3r.4fan.cz/web/ACARS/errors/");
tady do těch dvou, se budou ukládat soubory.
Offline
username, pass mám dobře...
a tomu druhému nerozumím...pls napiš postup:-)
Offline
Chod na FTP cez TC (Total Commander)
Pripoj sa
Chod tam, kde máš tie zložky kde sa majú ukladať súbory ale neotváraj ich
Drž CTRL a ľavým tlačídlom klikni na tie zložky
Hore v TC máš Súbor -> zmeniť atribúty a tam kde máš políčko na text napíš 777 a daj enter
Portfólio
E-mail: eduard(at)karpiel.sk
Offline
Udělal jsem, nepomohlo :-(
Už asi vím čím to je, ono se to uploaduje přes php soubor který je na ftp. Ale do toho ftp se vloží reklama :-(.
A on to pak přečte chybně.
Zkoušel jsem to s jiným programem a ten to odeslal, a vyskočila chyba a ve znění té chyby bylo : Neodymové magnety,......)
Dá se to nějak obejít ?
Offline
<?php
/**
* PIREP Service for XAcars
*
*/
// ----------------------------------------------------------------------------
// In functions.php the database is connected as used to
require("db.inc.php");
// ----------------------------------------------------------------------------
// General Constants
define("ACARS_UNKNOWN", 0);
define("ACARS_XACARS", 3);
define("ACARS_XACARS_MSFS", 4);
define("ONLINE_VATSIM", 1);
define("ONLINE_IVAO", 2);
define("ONLINE_FPI", 3);
define("ONLINE_OTHER", 0);
// ----------------------------------------------------------------------------
// PIREP Class
Class acarsPirep
{
var $pirepID = 0;
var $timeReport = 0;
var $acarsID = ACARS_UNKNOWN;
var $userID = 0;
var $flightRot = 0;
var $acICAO = '';
var $flightType = 'IFR';
var $departure = '';
var $destination = '';
var $alternate = '';
var $depTime = '00:00';
var $blockTime = 0;
var $blockFuel = 0;
var $flightTime = 0;
var $flightFuel = 0;
var $cruise = 0;
var $pax = 0;
var $cargo = 0;
var $online = 0;
var $message = '';
function doInsert()
{
$sql = 'INSERT INTO acars_pirep (timereport, acarsid, iduser, flightrot, acicao,
flighttype, departure, destination, alternate, deptime, blocktime, blockfuel, flighttime,
flightfuel, cruise, pax, cargo, online, message) VALUES ( '
. $this->timeReport . ', '
. $this->acarsID . ', '
. $this->userID . ', '
. "'{$this->flightRot}', "
. "'{$this->acICAO}', "
. "'{$this->flightType}', "
. "'{$this->departure}', "
. "'{$this->destination}', "
. "'{$this->alternate}', "
. $this->depTime . ', '
. $this->blockTime . ', '
. $this->blockFuel . ', '
. $this->flightTime . ', '
. $this->flightFuel . ', '
. $this->cruise . ', '
. $this->pax . ', '
. $this->cargo . ', '
. $this->online . ', '
. "'{$this->message}');";
if(!mysql_query($sql))
die('0|SQL query failed (INSERT acars pirep) ' . $sql);
$this->pirepID = mysql_insert_id();
return 1;
}
}
// ----------------------------------------------------------------------------
// Functions
function testUserLogin($pid, $pw)
{
$q_user = @mysql_query("SELECT id FROM user WHERE isactive=1 and username = '$pid' and password = '$pw' LIMIT 1");
if(@mysql_num_rows($q_user) <= 0)
{
return -1;
}
else
{
$user = @mysql_fetch_array($q_user);
return $user['id'];
}
}
function CheckXAcarsVersion($DATA1)
{
if( (strcmp($DATA1, "XACARS|1.0")==0)
|| (strcmp($DATA1, "XACARS|1.1")==0)
|| (strcmp($DATA1, "XACARS|2.0")==0)
|| (strcmp($DATA1, "XACARS|2.5")==0)
|| (strcmp($DATA1, "XACARS|3.0")==0) )
return ACARS_XACARS;
elseif( (strcmp($DATA1, "XACARS_MSFS|1.0")==0)
|| (strcmp($DATA1, "XACARS_MSFS|1.1")==0)
|| (strcmp($DATA1, "XACARS_MSFS|2.0")==0)
|| (strcmp($DATA1, "XACARS_MSFS|2.5")==0)
|| (strcmp($DATA1, "XACARS_MSFS|3.0")==0) )
return ACARS_XACARS_MSFS;
else
return ACARS_UNKNOWN;
}
Function data2Int( $data, $default )
{
if( !empty($data) || (isset($data) && $data == '0') )
return( (integer)$data );
else
return $default;
}
Function data2Str( $data, $default, $allowTags, $stripSql = True )
{
if( !empty($data) )
{
if( $stripSql == True)
$str = mysqlclean($data, -1);
else
$str = $data;
if( $allowTags == True )
return( strip_tags($str, ALLOWABLE_TAGS) );
else
return( strip_tags($str) );
}
else
return $default;
}
Function time2min( $time )
{
if( !empty($time) )
return( substr($time,0,2)*60 + substr($time,3,2) );
else
return 0;
}
Function lbs2kg( $lbs )
{
return( $lbs / 2.204622915 );
}
// ----------------------------------------------------------------------------
// Decoding ACARS Message
if (!isset($_REQUEST['DATA1'])) die('0|Invalid Data1');
if (!isset($_REQUEST['DATA2'])) die('0|Invalid Data2');
if (($version = CheckXAcarsVersion($_REQUEST['DATA1'])) <= 0)
die('0|ERROR: Unknown XAcars version!');
$data2 = $_REQUEST['DATA2'];
$data = split("~", $data2);
$uid = testUserLogin($data[0], $data[1]);
if( $uid == -1 )
die('0|ERROR: Invalid login!');
// ----------------------------------------------------------------------------
// Parameterlist:
// DATA1=XACARS|1.0&DATA2=username~password~flightnumber~aircrafticao~altitudeorFL~flightrules~depicao~desticao~alticao~deptime(dd.mm.yyyy hh:mm)~blocktime(hh:mm)~flighttime(hh:mm)~blockfuel~flightfuel~pax~cargo~online(VATSIM|ICAO|FPI|[other])
$pirep = new acarsPirep();
$pirep->timeReport = time();
$pirep->acarsID = $version;
$pirep->userID = $uid;
$pirep->flightRot = $data[2];
$pirep->acICAO = $data[3];
$pirep->flightType = $data[5];
$pirep->departure = substr($data[6], 0,4);
$pirep->destination = substr($data[7], 0,4);
$pirep->alternate = substr($data[8], 0,4);
// Reading timestamp "25.02.2006 12:18"
$pirep->depTime = strtotime( substr($data[9],3,2) . '/' . substr($data[9],0,2) . '/' . substr($data[9],6));
$pirep->blockTime = time2min($data[10]);
$pirep->blockFuel = lbs2kg(data2Int($data[12],0));
$pirep->flightTime = time2min($data[11]);
$pirep->flightFuel = lbs2kg(data2Int($data[13],0));
if( $data[4] <> '' )
$pirep->cruise = data2Int(substr($data[4],2),0) * 100;
$pirep->pax = data2Int($data[14],0);
$pirep->cargo = lbs2kg(data2Int($data[15],0));
if( strtoupper($data[16]) == 'VATSIM' )
$pirep->online = ONLINE_VATSIM;
else if( strtoupper($data[16]) == 'IVAO' )
$pirep->online = ONLINE_IVAO;
else if( strtoupper($data[16]) == 'FPI' )
$pirep->online = ONLINE_FPI;
else
$pirep->online = ONLINE_OTHER;
$rc = $pirep->doInsert();
if ($rc)
echo "1|PIREP ACCEPTED";
else echo "0|ERROR";
?>
A v programu se zobrazí chyba a znění chyby je 1|PIREP ACCEPTED a text reklamy
PIREP se sice odeslal ale program hází chybu
Offline
Nebo ještě jedna věc. jak bude znít ta adresa té složky ? fl1ght3r.4fan.cz/acars/reports
Do téhle složky chci aby se data ukládala. mám /home/users/fl1ght3r/fl1ght3r.4fan.cz/web/reports je to dobře ?
Offline
A ten kód či si vypísal, že ti napísalo 1 | Pirep accepted nie je vlastne chyba, má to byť oznamovacia správa:
if ($rc)
echo "1|PIREP ACCEPTED";
else echo "0|ERROR";
Keby to bola chyba, vypísalo by ti to 0 | ERROR. Tá reklama čo sa ti tam zobrazí vôbec nezasahuje do PHP, to je endorou, len ti to zasahuje do designu. Tá cesta k zložke je správna, ktorú napísal Fačkovec: /home/users/fl1ght3r/fl1ght3r.4fan.cz/web/acars/reports
Ak nerozumieš ceste proste musíš za zložku web (tým otvoriš koreňový adresár webu) vytvoriť zložku acars a tam dať zložku reports. Ak tak už máš vytvorené a tú cestu si opísal z PHP súbora, tak len tú cestu prepíš
Portfólio
E-mail: eduard(at)karpiel.sk
Offline
No ono se to odešle v pořádku, ale ten program kontroluje odeslaní podle toho výpisu z webu, očekává to 1|Pirep accepted, a místo toho tam je Neodymové magnety a bůh ví co ještě, a pak za tim 1|pirep accepted. A vyhodnotí to jako chybu. A uživateli toho programu napíše chybu...
Offline
Reklama tam byť musí, a ona ten PHP kód vôbec nezničí a ani doň nezasahuje. Ukáž web kde sa to deje
BTW: čo pozerám na ten kód, nevidím tam žiadnu funkciu na odoslanie súboru na serveru len vkládanie dát do DB
Portfólio
E-mail: eduard(at)karpiel.sk
Offline
Takže jediné řešení je Plus účet.
Tohle je jiný soubor.
<?php
/*
* You may not remove this header!
*
* -----------------------------------------------------------------------------------------------------------------------
* 'receive_pirep.php' script code was made by Paulo Correia - FSAcars Team (©)2003
* It's part of the FSAcars 2 for VA's package
*
* This script assumes that the VA has PHP support and a MySQL database on it's site
* A DDL file to create the following tables is provided: 'pilots', 'reports'
*
* The 'reports' table as the following columns:
* pilot_id,date,time,callsign,origin_id,destination_id,registration,equipment,duration,fuel,distance,fsacars_rep_url
* ----------------------------------------------------------------------------------------------------------------------
*
* FSACARS is distributed freely.
*
* Disclaimer
* Although this product has been intensively tested, the authors accepts no responsibility for any damages caused by the use or misuse of this
* software. This software is distributed 'as is' with no warranty expressed or implied. The authors will not be responsible for any losses incurred, either directly or indirectly, by the use of this software.
* Use this software entirely at your own risk. If you do not agree to these terms then you must not use this software.
*
* Copyright
* This software is a copyrighted program. AIBridge is a copyright of José Oliveira. FSACARS coding is a copyright of José Oliveira. FSACARS concept was idealized by Pedro Sousa.
* It is protected by international copyright laws.
*/
/*
* Change this constants according to your configuration */
@define ("MYSQL_CONNECT_INCLUDE", "connect_db.php"); // MySQL database connection (a sample file is included)
@define ("REPORT_FILE_URL", "http://www.fl1ght3r.4fan.cz/acars/"); // URL where the complete FSAcars reports will be stored
@define ("REPORT_FILE_PATH", "/home/users/fl1ght3r/fl1ght3r.4fan.cz/web/acars/reports"); // Folder where the complete FSAcars reports will be stored
@define ("ERROR_LOG_PATH", "/home/users/fl1ght3r/fl1ght3r.4fan.cz/web/acars/errors/error.log"); // Folder and filename where the error log is located
/*
* Error messages */
@define ("ERROR_OPENING_REPORT_FILE","Error opening report file");
@define ("ERROR_WRITING_REPORT_FILE","Error writing report file");
@define ("PILOT_NOT_FOUND","Pilot not found");
@define ("ERROR_IN_PILOT_QUERY","Pilot query error");
@define ("ERROR_INSERTING_PIREP","Error inserting report");
function CheckFSAcarsInfo() {
// Verify input
if (!isset($_GET['pilot'])) { return 0; }
// Request is not empty
return 1;
}
function GetFSAcarsInfo() {
/* ************************************************************************************************
@GetFSAcarsInfo
Receives inputs sent by FSAcars program and returns an array containing that information
Inputs: N/A
Outputs: string array
************************************************************************************************ */
// DO NOT EDIT THIS FUNCTION - THIS FIELDS ARE SENT BY FSACARS
$fsacars_pirep = array (
"pilot" => $_GET['pilot'],
"date" => $_GET['date'],
"time" => $_GET['time'],
"callsign" => $_GET['callsign'],
"reg" => $_GET['reg'],
"origin" => $_GET['origin'],
"dest" => $_GET['dest'],
"equipment" => $_GET['equipment'],
"fuel" => $_GET['fuel'],
"duration" => $_GET['duration'],
"distance" => $_GET['distance'],
"rep_url" => "Dummy",
"more" => $_GET['more'],
"fsacars_log" => $_GET['log'] // Get complete FSAcars log
);
/* DEBUG CODE - Write request to log file
*/
$fe = fopen (ERROR_LOG_PATH, "a");
fwrite($fe, "[DEBUG ".date("d.m.y H:i:s")."] PILOT: ".$_GET['pilot']." DATE: ".$_GET['date']." TIME: ".$_GET['time']." CALLSIGN: ".$_GET['callsign']." REG: ".$_GET['reg']." ORIG: ".$_GET['origin']." DEST: ".$_GET['dest']." EQUIP: ".$_GET['equipment']." FUEL: ".$_GET['fuel']." DURATION: ".$_GET['duration']." DIST: ".$_GET['distance']." MORE: ".$_GET['more']." LOG: ".$_GET['log']."\n");
fclose($fe);
return $fsacars_pirep;
}
function SavePIREPFile($pirep_array) {
/* ************************************************************************************************
@SavePIREPFile
Receives a string array with FSAcars pireps and creates or appends information to pirep file
Inputs: string array
Outputs: 1 sucess, 0 error
************************************************************************************************ */
/* Build report filename and URL */
$filename=$pirep_array['pilot'].str_replace("/","",$pirep_array['date']).str_replace(":","",$pirep_array['time']).".txt";
$pirep_array['rep_url']=REPORT_FILE_URL.$pirep_array['pilot']."/".$filename;
/* Parse FsAcars log */
$fsacars_log_lines_array = explode("*",$pirep_array['fsacars_log']);
/* Create or Append FSAcars report file */
$fp = fopen (REPORT_FILE_PATH."/".$pirep_array['pilot']."/".$filename, "a");
if (!$fp) {
/* Error opening file */
$fe = fopen (ERROR_LOG_PATH, "a");
fwrite($fe, "[ERROR ".date("d.m.y H:i:s")."] PILOT: ".$pirep_array['pilot']." - ".ERROR_OPENING_REPORT_FILE." - ".$filename."\n");
fclose($fe);
return 0;
}
/*
* Write all log lines received from FSAcars */
for($i=0;$i<count($fsacars_log_lines_array);$i++) {
if (!fwrite($fp, $fsacars_log_lines_array[$i] . "\n")) {
/* Error writing to file */
$fe = fopen (ERROR_LOG_PATH, "a");
fwrite($fe, "[ERROR ".date("d.m.y H:i:s")."] PILOT".$pirep_array['pilot']." - ".ERROR_WRITING_REPORT_FILE." - ".$filename."\n");
fclose($fe);
return 0;
}
}
/* Close file */
fclose($fp);
return 1;
}
function InsertReportIntoDB($pirep_array) {
/* ************************************************************************************************
@InsertReportIntoDB
Receives a string array with FSAcars pireps and inserts summary into reports table
Inputs: string array
Outputs: 1 sucess, 0 error
************************************************************************************************ */
/* If this is the first chunk insert PIREP on database */
if ($pirep_array['more']=="0") {
/* connect to database */
include(MYSQL_CONNECT_INCLUDE);
/*
* Verify pilot identity (From VA Pilots table) */
$the_pilot = $pirep_array['pilot'];
$stmt = "select pilot_id from pilots where pilot_num='$the_pilot'";
$result = mysql_query($stmt);
/* mysql error */
if (!$result) {
$fe = fopen (ERROR_LOG_PATH, "a");
fwrite($fe, "[ERROR ".date("d.m.y H:i:s")."] ".ERROR_IN_PILOT_QUERY." - Pilot ".$pirep_array['pilot']." - ".mysql_error()." SQL: ".$stmt."\n");
fclose($fe);
return 0;
}
if (mysql_num_rows($result) == 0) {
/* Pilot not found */
$fe = fopen (ERROR_LOG_PATH, "a");
fwrite($fe, "[ERROR ".date("d.m.y H:i:s")."] ".PILOT_NOT_FOUND." - Pilot ".$pirep_array['pilot']."\n");
fclose($fe);
return 0;
} else {
/* Pilot found */
$pilot_id = mysql_result($result,0,"pilot_id");
/* Insert info on reports table */
$values = $pilot_id.",'".$pirep_array['date']."','".$pirep_array['time']."','".$pirep_array['callsign']."','".$pirep_array['origin']."','".$pirep_array['dest']."','".$pirep_array['reg']."','".$pirep_array['equipment']."','".$pirep_array['duration']."',".$pirep_array['fuel'].",".$pirep_array['distance'].",'".$pirep_array['rep_url']."'";
$stmt = "INSERT INTO reports (pilot_id,date,time,callsign,origin_id,destination_id,registration,equipment,duration,fuel,distance,fsacars_rep_url) VALUES ($values)";
$result = mysql_query($stmt);
if (!$result) {
$fe = fopen (ERROR_LOG_PATH, "a");
fwrite($fe, "[ERROR ".date("d.m.y H:i:s")."] ".ERROR_INSERTING_PIREP." - Pilot ".$pirep_array['pilot']." - ".mysql_error()." SQL: ".$stmt."\n");
fclose($fe);
return 0;
}
/* Close the database connection */
mysql_close();
}
}
return 1;
}
function main() {
/* ************************************************************************************************
@main
Inputs: N/A
Outputs: "OK" sucess, "NOTOK" error
************************************************************************************************ */
$res = CheckFSAcarsInfo();
if ($res == 0) {
return "NOTOK";
}
$a = GetFSAcarsInfo();
$res = SavePIREPFile(&$a);
if ($res == 0) {
return "NOTOK";
}
$res = InsertReportIntoDB($a);
if ($res == 0) {
return "NOTOK";
}
// Report sucessfully received
return "OK";
}
/* receive_pirep.php return to FSACARS */
$out = main();
echo $out;
?>
Offline
Každý zvlášť generovaný súbor má na jeho konci pred tágom </body> vloženú reklamu alebo na mieste špecifikovanom majiteľom danej domény. Pokiaľ používaš AJAX na dočítavanie podstránok tak reklamu na danom mieste zamaskuj aby na stránke nebola zobrazená viac ako 1 krát. To samé sa jedná o načítavanie pomocou FLASHu, jedna reklama je povinná, ostatné dočítavania reklám môžu byť maskované.
Offline
No do programu zasáhnout nemůžu, a ta reklama jde skrýt ? Je to soubor do kterého nikdo přímo neleze, je to jen jakoby prostředník přenosu informací. PHP soubor.
Offline
Offline
To nechápu. Prostě program zaznamenává průběh letů v Flight Simulatoru. Po ukončení letu pilot odešle tzv. PIREP. Ten se odesílá přes ten php soubor, a ten ho pak zanáší do DB a vytváří ten soubor
Offline
URL na ten soubor je http://www.fl1ght3r.4fan.cz/acars/receive_pirep.php
Obsah toho souboru uz jsem sem dával...:-(
Offline
Parse error: syntax error, unexpected $end, expecting T_VARIABLE or T_DOLLAR_OPEN_CURLY_BRACES or T_CURLY_OPEN in /home/users/fl1ght3r/fl1ght3r.4fan.cz/web/acars/receive_pirep.php on line 83
tak prvá príčina prečo to nejde. Tento error sa často vyskytuje vtedy ak chýba ukončovacia zátvorka
Portfólio
E-mail: eduard(at)karpiel.sk
Offline
$fe = fopen (ERROR_LOG_PATH, "a");
fwrite($fe, "[DEBUG ".date("d.m.y H:i:s")."] PILOT: ".$_GET['pilot']." DATE: ".$_GET['date']." TIME: ".$_GET['time']." CALLSIGN: ".$_GET['callsign']." REG: ".$_GET['reg']." ORIG: ".$_GET['origin']." DEST: ".$_GET['dest']." EQUIP: ".$_GET['equipment']." FUEL: ".$_GET['fuel']." DURATION: ".$_GET['duration']." DIST: ".$_GET['distance']." MORE: ".$_GET['more']." LOG: ".$_GET['log']."\n");
fclose($fe);
Toto je na řádce 82-84
Offline
Tak umiestni v tom výstupnom súbore reklamu niekde o pár riadkov dole a ten program nastav tak aby ignoroval ten spodný riadok reklamy, aby ho zaujímal len povedzme prvý riadok. Prípadne si zriaď program PLUS, napr na kratšie obdobie aby si to vyskúšal a nemusel sa trápiť s preprogramovaním.
Offline
Ten program není můj, nemám k němu ani kod. :-(
A tu reklamu umístím jak ? někam napíšu <endora> že ?
Offline