Skip to content
This repository has been archived by the owner on Dec 6, 2019. It is now read-only.

Commit

Permalink
vacentral default type to json, modifieddate column for pireps
Browse files Browse the repository at this point in the history
  • Loading branch information
Nabeel Shahzad committed Apr 12, 2011
1 parent defd986 commit ce48396
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 33 deletions.
2 changes: 1 addition & 1 deletion core/app.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@
Config::Set('VACENTRAL_DEBUG_DETAIL', 0);
Config::Set('VACENTRAL_API_SERVER', 'http://api.phpvms.net');
Config::Set('VACENTRAL_API_KEY', '');
Config::Set('VACENTRAL_DATA_FORMAT', 'xml');
Config::Set('VACENTRAL_DATA_FORMAT', 'json');

/**
* Constants
Expand Down
20 changes: 12 additions & 8 deletions core/common/CentralData.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,14 @@ private static function sendToCentral() {
$api_server = Config::Get('PHPVMS_API_SERVER');
}

# ob_start();
ob_start();
$web_service = new CodonWebService();
$web_service->setOptions(array(CURLOPT_USERAGENT => 'phpVMS ('.PHPVMS_VERSION.')'));

if(self::$type == 'xml') {
$data = self::$xml->asXML();
} else {
$data = json_encode(self::$json);
echo '<pre>';
print_r(self::$json);
echo '</pre>';
}

self::$xml_response = $web_service->post($api_server . '/update', $data);
Expand All @@ -98,7 +95,12 @@ private static function sendToCentral() {
return false;
}

self::$response = @simplexml_load_string(self::$xml_response);
if(self::$type == 'xml') {
self::$response = @simplexml_load_string(self::$xml_response);
} else {
self::$response = json_decode(self::$xml_response);
}

ob_end_clean();

if (!is_object(self::$response)) {
Expand Down Expand Up @@ -153,10 +155,11 @@ protected static function startBody($method) {

# Determine the type
self::$type = strtolower(trim(Config::Get('VACENTRAL_DATA_FORMAT')));
if(self::$type !== 'xml' || self::$type !== 'json') {
if(self::$type !== 'xml' && self::$type !== 'json') {
self::$type = 'xml';
}


if(self::$type == 'xml') {
self::$xml = new SimpleXMLElement('<vacentral/>');
} elseif(self::$type == 'json') {
Expand Down Expand Up @@ -413,7 +416,7 @@ public static function send_pilots() {
foreach ($allpilots as $pilot) {
$pc = self::addElement(null, 'pilot', null, array(
'pilotid' => PilotData::GetPilotCode($pilot->code, $pilot->pilotid),
'pilotname' => $pilot->firstname . ' ' . $pilot->lastname,
'pilotname' => $pilot->firstname.' '.$pilot->lastname,
'location' => $pilot->location,
));
}
Expand All @@ -439,7 +442,7 @@ public static function send_all_pireps() {
}

$allpireps = PIREPData::findPIREPS(array(
'DATE_SUB(CURDATE(), INTERVAL 6 MONTH) <= p.submitdate'
'DATE_SUB(CURDATE(), INTERVAL 3 MONTH) <= p.submitdate'
));

if (!$allpireps) {
Expand Down Expand Up @@ -522,6 +525,7 @@ protected static function get_pirep_xml($pirep) {
'registration' => $pirep->registration,
'flighttime' => $pirep->flighttime_stamp,
'submitdate' => $pirep->submitdate,
'modifieddate' => $pirep->modifieddate,
'flighttype' => $pirep->flighttype,
'load' => $pirep->load,
'fuelused' => $pirep->fuelused,
Expand Down
2 changes: 1 addition & 1 deletion core/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.1.934-93-gb9440a5
v2.1.934-95-gdefd986
8 changes: 4 additions & 4 deletions install/hashlist
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ c500b8b76e204f1adcb0e6562f7f4277 *./install/checkinstall.php
4f93058c2e74d9852ef20e0b681b0300 *./install/includes/loader.inc.php
cedea63e288808e6b85422abf21b2049 *./install/includes/Installer.class.php
d41d8cd98f00b204e9800998ecf8427e *./install/index.php
feca187733f80495d66720e114a1daae *./install/sql/install.sql
e6d1e149c2321fdb690e6761938aab43 *./install/sql/install.sql
131e6ba03639fe73943bf0c9a407d06f *./install/dbtest.php
c2ac2bc16449a6c3d601357caefc78aa *./install/fixtures/update.sql
98645f25a6917b5922becfd8181eaef4 *./install/fixtures/install.sql
Expand All @@ -23,7 +23,7 @@ d609f74eeaea0e4849d90b1c9a48943a *./install/checkdb.php
71c7531e4b713e67d84e310e354ddc47 *./install/install.php
a177b8656fca431cc0b6d53ac301c537 *./core/lang/en.lang.php
a5e10c076798685fd1f8e84a7115fb74 *./core/common/MaintenanceData.class.php
7dbacbcbaf8a7ee6615a16e703b3372e *./core/common/PIREPData.class.php
9f66c1350caed20e0261969d1744ab6f *./core/common/PIREPData.class.php
e61e61593cae4813c33914be562701ae *./core/common/Auth.class.php
596033119a76e293a7ead1d29978fd97 *./core/common/jqgrid.class.php
be3826eab064935f32bbd498df3c7253 *./core/common/RegistrationData.class.php
Expand All @@ -50,7 +50,7 @@ fbf1d94494b20f35987fe7800e00aafe *./core/common/SiteData.class.php
b7cb7e11da8f135f2012aaedcda956d8 *./core/common/OperationsData.class.php
a0eaecd33abf5726c36087c1c488e0cd *./core/common/CronData.class.php
17f388a37506a1664dd1281f237f2f56 *./core/common/OFCharts.class.php
455aeca8119fa7bcd26b4d1534a96ea1 *./core/common/CentralData.class.php
779c649b71b4e258b1c2dd67c6cf3860 *./core/common/CentralData.class.php
ad22d5c59925bc27a300dd27675a2ff8 *./core/templates/profile_badge.tpl
0600b921789561619e2a4a83385ff5ec *./core/templates/email_registrationdenied.tpl
08223291dd07074c31efc018645d8ad5 *./core/templates/schedule_results.tpl
Expand Down Expand Up @@ -159,7 +159,7 @@ c5464e3a9e0079bd8229a1b1aa27379d *./core/classes/ezdb/ezdb_oracle.class.php
c56b2790383f5891808777c40c03e269 *./core/hooks/system/postmoduleload.php.1
d41d8cd98f00b204e9800998ecf8427e *./core/index.php
d41d8cd98f00b204e9800998ecf8427e *./core/pages/index.php
4da63abda43eac763353f8d3dd8c00e2 *./core/app.config.php
71d789005f5bc09e1f3c6d9633a1495f *./core/app.config.php
c26d9878cab6959c8e58a14fc31fb614 *./core/modules/Schedules/Schedules.php
e58ee78f8e857ad150badae9ba04dddc *./core/modules/news/news.php
935862c6f2d8c067c49c4af2797abebd *./core/modules/XML/XML.php
Expand Down
35 changes: 18 additions & 17 deletions install/sql/structure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
<key Table="phpvms_groupmembers" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="id" Collation="A" Cardinality="2" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_groupmembers" Non_unique="1" Key_name="phpvms_groupmembers_ibfk_1" Seq_in_index="1" Column_name="groupid" Collation="A" Cardinality="2" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_groupmembers" Non_unique="1" Key_name="phpvms_groupmembers_ibfk_2" Seq_in_index="1" Column_name="pilotid" Collation="A" Cardinality="2" Null="" Index_type="BTREE" Comment="" />
<options Name="phpvms_groupmembers" Engine="InnoDB" Version="10" Row_format="Compact" Rows="2" Avg_row_length="8192" Data_length="16384" Max_data_length="0" Index_length="32768" Data_free="11534336" Auto_increment="173" Create_time="2011-03-23 18:46:35" Collation="latin1_swedish_ci" Create_options="" Comment="" />
<options Name="phpvms_groupmembers" Engine="InnoDB" Version="10" Row_format="Compact" Rows="2" Avg_row_length="8192" Data_length="16384" Max_data_length="0" Index_length="32768" Data_free="11534336" Auto_increment="176" Create_time="2011-03-23 18:46:35" Collation="latin1_swedish_ci" Create_options="" Comment="" />
</table_structure>
<table_structure name="phpvms_groups">
<field Field="groupid" Type="int(11)" Null="NO" Key="PRI" Extra="auto_increment" />
Expand Down Expand Up @@ -283,17 +283,17 @@
<key Table="phpvms_pilots" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="pilotid" Collation="A" Cardinality="1" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_pilots" Non_unique="1" Key_name="code" Seq_in_index="1" Column_name="code" Collation="A" Cardinality="1" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_pilots" Non_unique="1" Key_name="rank" Seq_in_index="1" Column_name="rank" Collation="A" Cardinality="1" Null="" Index_type="BTREE" Comment="" />
<options Name="phpvms_pilots" Engine="InnoDB" Version="10" Row_format="Compact" Rows="1" Avg_row_length="16384" Data_length="16384" Max_data_length="0" Index_length="32768" Data_free="11534336" Auto_increment="196" Create_time="2011-03-23 18:46:35" Collation="latin1_swedish_ci" Create_options="" Comment="" />
<options Name="phpvms_pilots" Engine="InnoDB" Version="10" Row_format="Compact" Rows="1" Avg_row_length="16384" Data_length="16384" Max_data_length="0" Index_length="32768" Data_free="11534336" Auto_increment="199" Create_time="2011-03-23 18:46:35" Collation="latin1_swedish_ci" Create_options="" Comment="" />
</table_structure>
<table_structure name="phpvms_pirepcomments">
<field Field="id" Type="int(11)" Null="NO" Key="PRI" Extra="auto_increment" />
<field Field="pirepid" Type="int(11)" Null="NO" Key="MUL" Extra="" />
<field Field="pilotid" Type="int(11)" Null="NO" Key="" Extra="" />
<field Field="comment" Type="text" Null="NO" Key="" Extra="" />
<field Field="postdate" Type="datetime" Null="NO" Key="" Extra="" />
<key Table="phpvms_pirepcomments" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="id" Collation="A" Cardinality="79" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_pirepcomments" Non_unique="1" Key_name="phpvms_pirepcomments_ibfk_1" Seq_in_index="1" Column_name="pirepid" Collation="A" Cardinality="79" Null="" Index_type="BTREE" Comment="" />
<options Name="phpvms_pirepcomments" Engine="InnoDB" Version="10" Row_format="Compact" Rows="79" Avg_row_length="207" Data_length="16384" Max_data_length="0" Index_length="16384" Data_free="11534336" Auto_increment="339" Create_time="2011-03-23 18:46:35" Collation="latin1_swedish_ci" Create_options="" Comment="" />
<key Table="phpvms_pirepcomments" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="id" Collation="A" Cardinality="88" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_pirepcomments" Non_unique="1" Key_name="phpvms_pirepcomments_ibfk_1" Seq_in_index="1" Column_name="pirepid" Collation="A" Cardinality="88" Null="" Index_type="BTREE" Comment="" />
<options Name="phpvms_pirepcomments" Engine="InnoDB" Version="10" Row_format="Compact" Rows="88" Avg_row_length="186" Data_length="16384" Max_data_length="0" Index_length="16384" Data_free="11534336" Auto_increment="348" Create_time="2011-03-23 18:46:35" Collation="latin1_swedish_ci" Create_options="" Comment="" />
</table_structure>
<table_structure name="phpvms_pirepfields">
<field Field="fieldid" Type="int(11)" Null="NO" Key="PRI" Extra="auto_increment" />
Expand All @@ -320,6 +320,7 @@
<field Field="distance" Type="smallint(6)" Null="NO" Key="" Default="0" Extra="" />
<field Field="landingrate" Type="float" Null="NO" Key="" Default="0" Extra="" />
<field Field="submitdate" Type="datetime" Null="NO" Key="" Default="0000-00-00 00:00:00" Extra="" />
<field Field="modifieddate" Type="datetime" Null="NO" Key="" Extra="" />
<field Field="accepted" Type="smallint(6)" Null="NO" Key="" Default="0" Extra="" />
<field Field="log" Type="text" Null="NO" Key="" Extra="" />
<field Field="load" Type="int(11)" Null="NO" Key="" Extra="" />
Expand All @@ -337,8 +338,8 @@
<field Field="source" Type="varchar(25)" Null="NO" Key="" Extra="" />
<field Field="exported" Type="tinyint(4)" Null="NO" Key="" Extra="" />
<field Field="rawdata" Type="text" Null="NO" Key="" Extra="" />
<key Table="phpvms_pireps" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="pirepid" Collation="A" Cardinality="81" Null="" Index_type="BTREE" Comment="" />
<options Name="phpvms_pireps" Engine="InnoDB" Version="10" Row_format="Compact" Rows="81" Avg_row_length="3438" Data_length="278528" Max_data_length="0" Index_length="0" Data_free="11534336" Auto_increment="292" Create_time="2011-03-23 18:46:35" Collation="latin1_swedish_ci" Create_options="" Comment="" />
<key Table="phpvms_pireps" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="pirepid" Collation="A" Cardinality="88" Null="" Index_type="BTREE" Comment="" />
<options Name="phpvms_pireps" Engine="InnoDB" Version="10" Row_format="Compact" Rows="86" Avg_row_length="3810" Data_length="327680" Max_data_length="0" Index_length="0" Data_free="11534336" Auto_increment="301" Create_time="2011-04-12 19:05:07" Collation="latin1_swedish_ci" Create_options="" Comment="" />
</table_structure>
<table_structure name="phpvms_pirepvalues">
<field Field="id" Type="int(11)" Null="NO" Key="PRI" Extra="auto_increment" />
Expand Down Expand Up @@ -384,21 +385,21 @@
<field Field="notes" Type="text" Null="NO" Key="" Extra="" />
<field Field="enabled" Type="int(11)" Null="NO" Key="" Default="1" Extra="" />
<field Field="bidid" Type="int(11)" Null="NO" Key="" Default="0" Extra="" />
<key Table="phpvms_schedules" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="id" Collation="A" Cardinality="144" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_schedules" Non_unique="1" Key_name="depicao" Seq_in_index="1" Column_name="depicao" Collation="A" Cardinality="1" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_schedules" Non_unique="1" Key_name="flightnum" Seq_in_index="1" Column_name="flightnum" Collation="A" Cardinality="3" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_schedules" Non_unique="1" Key_name="depicao_arricao" Seq_in_index="1" Column_name="depicao" Collation="A" Cardinality="1" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_schedules" Non_unique="1" Key_name="depicao_arricao" Seq_in_index="2" Column_name="arricao" Collation="A" Cardinality="1" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_schedules" Non_unique="1" Key_name="code" Seq_in_index="1" Column_name="code" Collation="A" Cardinality="1" Null="" Index_type="BTREE" Comment="" />
<options Name="phpvms_schedules" Engine="InnoDB" Version="10" Row_format="Compact" Rows="153" Avg_row_length="10387" Data_length="1589248" Max_data_length="0" Index_length="65536" Data_free="11534336" Auto_increment="147" Create_time="2011-03-23 18:46:35" Collation="latin1_swedish_ci" Create_options="" Comment="" />
<key Table="phpvms_schedules" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="id" Collation="A" Cardinality="153" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_schedules" Non_unique="1" Key_name="depicao" Seq_in_index="1" Column_name="depicao" Collation="A" Cardinality="2" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_schedules" Non_unique="1" Key_name="flightnum" Seq_in_index="1" Column_name="flightnum" Collation="A" Cardinality="4" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_schedules" Non_unique="1" Key_name="depicao_arricao" Seq_in_index="1" Column_name="depicao" Collation="A" Cardinality="2" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_schedules" Non_unique="1" Key_name="depicao_arricao" Seq_in_index="2" Column_name="arricao" Collation="A" Cardinality="2" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_schedules" Non_unique="1" Key_name="code" Seq_in_index="1" Column_name="code" Collation="A" Cardinality="2" Null="" Index_type="BTREE" Comment="" />
<options Name="phpvms_schedules" Engine="InnoDB" Version="10" Row_format="Compact" Rows="143" Avg_row_length="11113" Data_length="1589248" Max_data_length="0" Index_length="65536" Data_free="11534336" Auto_increment="150" Create_time="2011-03-23 18:46:35" Collation="latin1_swedish_ci" Create_options="" Comment="" />
</table_structure>
<table_structure name="phpvms_sessions">
<field Field="id" Type="int(11)" Null="NO" Key="PRI" Extra="auto_increment" />
<field Field="pilotid" Type="int(11)" Null="NO" Key="" Extra="" />
<field Field="ipaddress" Type="varchar(25)" Null="NO" Key="" Extra="" />
<field Field="logintime" Type="datetime" Null="NO" Key="" Extra="" />
<key Table="phpvms_sessions" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="id" Collation="A" Cardinality="2" Null="" Index_type="BTREE" Comment="" />
<options Name="phpvms_sessions" Engine="MyISAM" Version="10" Row_format="Dynamic" Rows="2" Avg_row_length="42" Data_length="616" Max_data_length="281474976710655" Index_length="2048" Data_free="532" Auto_increment="318" Create_time="2011-03-23 18:46:35" Update_time="2011-04-12 15:48:18" Collation="latin1_swedish_ci" Create_options="" Comment="" />
<key Table="phpvms_sessions" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="id" Collation="A" Cardinality="5" Null="" Index_type="BTREE" Comment="" />
<options Name="phpvms_sessions" Engine="MyISAM" Version="10" Row_format="Dynamic" Rows="5" Avg_row_length="39" Data_length="616" Max_data_length="281474976710655" Index_length="2048" Data_free="420" Auto_increment="322" Create_time="2011-03-23 18:46:35" Update_time="2011-04-12 19:23:24" Collation="latin1_swedish_ci" Create_options="" Comment="" />
</table_structure>
<table_structure name="phpvms_settings">
<field Field="id" Type="int(11)" Null="NO" Key="PRI" Extra="auto_increment" />
Expand All @@ -417,7 +418,7 @@
<field Field="lastupdate" Type="datetime" Null="NO" Key="" Extra="" />
<key Table="phpvms_updates" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="id" Collation="A" Cardinality="9" Null="" Index_type="BTREE" Comment="" />
<key Table="phpvms_updates" Non_unique="1" Key_name="name" Seq_in_index="1" Column_name="name" Collation="A" Null="" Index_type="BTREE" Comment="" />
<options Name="phpvms_updates" Engine="MyISAM" Version="10" Row_format="Dynamic" Rows="9" Avg_row_length="33" Data_length="300" Max_data_length="281474976710655" Index_length="3072" Data_free="0" Auto_increment="10" Create_time="2011-03-23 18:46:34" Update_time="2011-04-12 15:48:18" Collation="latin1_swedish_ci" Create_options="" Comment="" />
<options Name="phpvms_updates" Engine="MyISAM" Version="10" Row_format="Dynamic" Rows="9" Avg_row_length="33" Data_length="300" Max_data_length="281474976710655" Index_length="3072" Data_free="0" Auto_increment="10" Create_time="2011-03-23 18:46:34" Update_time="2011-04-12 19:23:24" Collation="latin1_swedish_ci" Create_options="" Comment="" />
</table_structure>
</database>
</mysqldump>
12 changes: 10 additions & 2 deletions unittest/utils/vac_diag.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,16 @@

<h3>Sent Data</h3>
<pre><?php
$xml = CentralData::$xml->asXML();
echo htmlentities(formatXmlString($xml)); ?>
if(CentralData::$type == 'xml') {
$xml = CentralData::$xml->asXML();
echo htmlentities(formatXmlString($xml));
} elseif(CentralData::$type == 'json') {
echo '<pre>';
print_r(CentralData::$json);
echo '</pre>';
}

?>
</pre>
</td>
</tr>
Expand Down

0 comments on commit ce48396

Please sign in to comment.