diff --git a/9781590591680.jpg b/9781590591680.jpg new file mode 100644 index 0000000..49018d7 Binary files /dev/null and b/9781590591680.jpg differ diff --git a/Chapter10.sit b/Chapter10.sit new file mode 100644 index 0000000..e53cf30 Binary files /dev/null and b/Chapter10.sit differ diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..a5ce953 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,27 @@ +Freeware License, some rights reserved + +Copyright (c) 2003 Steve Webster and Scott Mebberson + +Permission is hereby granted, free of charge, to anyone obtaining a copy +of this software and associated documentation files (the "Software"), +to work with the Software within the limits of freeware distribution and fair use. +This includes the rights to use, copy, and modify the Software for personal use. +Users are also allowed and encouraged to submit corrections and modifications +to the Software for the benefit of other users. + +It is not allowed to reuse, modify, or redistribute the Software for +commercial use in any way, or for a user’s educational materials such as books +or blog articles without prior permission from the copyright holder. + +The above copyright notice and this permission notice need to be included +in all copies or substantial portions of the software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS OR APRESS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + diff --git a/README.md b/README.md new file mode 100644 index 0000000..71b9348 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +#Apress Source Code + +This repository accompanies [*Foundation Flash MX Applications*](http://www.apress.com/9781590591680) by Steve Webster and Scott Mebberson (Apress, 2003). + +![Cover image](9781590591680.jpg) + +Download the files as a zip using the green button, or clone the repository to your machine using Git. + +##Releases + +Release v1.0 corresponds to the code in the published book, without corrections or updates. + +##Contributions + +See the file Contributing.md for more information on how you can contribute to this repository. diff --git a/chapter03.sit b/chapter03.sit new file mode 100644 index 0000000..ee66d29 Binary files /dev/null and b/chapter03.sit differ diff --git a/chapter03/Chapter 03/flashblog files/fake_message_data.xml b/chapter03/Chapter 03/flashblog files/fake_message_data.xml new file mode 100644 index 0000000..83d8afa --- /dev/null +++ b/chapter03/Chapter 03/flashblog files/fake_message_data.xml @@ -0,0 +1,35 @@ + + + + + + + Scott + Mebberson + + + Flash and XML go hand in hand! + This a test message that we'll use to create an XML parsing engine. + + + + + Scott + Mebberson + + + www.friendsofed.com + Visit the friends of ED site for information on their range of books. + + + + + Anthony + Stevens + + + www.pixelogic.org + Pixelog is Scott's personal site. + + + \ No newline at end of file diff --git a/chapter03/Chapter 03/flashblog files/flashblog.fla b/chapter03/Chapter 03/flashblog files/flashblog.fla new file mode 100644 index 0000000..f97c37f Binary files /dev/null and b/chapter03/Chapter 03/flashblog files/flashblog.fla differ diff --git a/chapter03/Chapter 03/flashblog files/markup.fla b/chapter03/Chapter 03/flashblog files/markup.fla new file mode 100644 index 0000000..356fb58 Binary files /dev/null and b/chapter03/Chapter 03/flashblog files/markup.fla differ diff --git a/chapter03/Chapter 03/flashblog files/message_template.xml b/chapter03/Chapter 03/flashblog files/message_template.xml new file mode 100644 index 0000000..03430b6 --- /dev/null +++ b/chapter03/Chapter 03/flashblog files/message_template.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/chapter03/Chapter 03/tutorial files/XMLparsing.fla b/chapter03/Chapter 03/tutorial files/XMLparsing.fla new file mode 100644 index 0000000..64a32bd Binary files /dev/null and b/chapter03/Chapter 03/tutorial files/XMLparsing.fla differ diff --git a/chapter03/Chapter 03/tutorial files/XMLparsing_code.txt b/chapter03/Chapter 03/tutorial files/XMLparsing_code.txt new file mode 100644 index 0000000..30c7475 --- /dev/null +++ b/chapter03/Chapter 03/tutorial files/XMLparsing_code.txt @@ -0,0 +1,98 @@ +// Fix whitespace big +XML.prototype.ignoreWhite = true; + +// Create XML object and load file +my_xml = new XML(); +my_xml.onLoad = parsePurchaseXML; +my_xml.load("purchase_history.xml"); + + +// Functions ///////////////////////////////////////////////////// + +function parsePurchaseXML(success) { + // Error check - file loaded? + if (success == false) { + trace("purchase_history.xml failed to load"); + return; + } + + // Error check - file okay? + if (this.status != 0) { + trace("The XML file was loaded, but was not well formed"); + return; + } + + // Error check - xml data okay? + if (this.firstChild.nodeName.toLowerCase() != "purchasehistory") { + trace("Unexpected XML data: " + this.firstChild.nodeName); + return; + } + + // Extract purchase nodes to array + purchases_arr = this.firstChild.childNodes; + + // For each purchase node... + for (var count = 0; count < purchases_arr.length; count++) { + // Extract and output purchase details + var purchaseID = purchases_arr[count].attributes.id; + var purchaseTime = purchases_arr[count].attributes.time; + trace("--- Purchase " + purchaseID + " @ " + purchaseTime + " -------------"); + + // Parse purchase node + parsePurchaseNode(purchases_arr[count].childNodes); + + trace("--- End Purchase ------------------"); + trace(""); + } +} + +function parsePurchaseNode(purchase_arr) { + // For each node in purchase array + for (var count = 0; count < purchase_arr.length; count++) { + // Extract node name + var nodeName = purchase_arr[count].nodeName.toLowerCase(); + + // Is items node? + if (nodeName == "items") { + // Parse items node + parseItemsNode(purchase_arr[count].childNodes); + + // Is client node? + } else if (nodeName == "client") { + // Parse client node + parseClientNode(purchase_arr[count].childNodes); + } + } +} + +function parseItemsNode(items_arr) { + // For each item node in array + for (var count = 0; count < items_arr.length; count++) { + trace("---- Item " + items_arr[count].attributes.id); + + // Parse item node + parseItemNode(items_arr[count].childNodes); + + trace("---- End Item"); + } +} + +function parseItemNode(item_arr) { + // For each detail node in item details array + for (var count = 0; count < item_arr.length; count++) { + // Output node name and value + trace(" " + item_arr[count].nodeName + ": " + item_arr[count].firstChild.nodeValue); + } +} + +function parseClientNode(client_arr) { + trace("---- Client Information"); + + // For each detail node in client details array + for (var count = 0; count < client_arr.length; count++) { + // Output node name and value + trace(" " + client_arr[count].nodeName + ": " + client_arr[count].firstChild.nodeValue); + } + + trace("---- End Client Information"); +} diff --git a/chapter03/Chapter 03/tutorial files/carClass.fla b/chapter03/Chapter 03/tutorial files/carClass.fla new file mode 100644 index 0000000..ad5746d Binary files /dev/null and b/chapter03/Chapter 03/tutorial files/carClass.fla differ diff --git a/chapter03/Chapter 03/tutorial files/purchase_history.xml b/chapter03/Chapter 03/tutorial files/purchase_history.xml new file mode 100644 index 0000000..670a81f --- /dev/null +++ b/chapter03/Chapter 03/tutorial files/purchase_history.xml @@ -0,0 +1,44 @@ + + + + + + GB9983 + 1 + 89.95 + + + BGH112-9 + 2 + 16.25 + + + + John + Doe +
123 Easy St
+ Beverly Hills + 90210 + 456-445-2236 + Credit +
+
+ + + + SF9985-96 + 1 + 115.22 + + + + July + Spencer +
100 Some St
+ Birmingham + BGH123 + 219-767-1936 + Money Order +
+
+
\ No newline at end of file diff --git a/chapter03/Chapter 03/tutorial files/purchase_xml_code.as b/chapter03/Chapter 03/tutorial files/purchase_xml_code.as new file mode 100644 index 0000000..1e99abf --- /dev/null +++ b/chapter03/Chapter 03/tutorial files/purchase_xml_code.as @@ -0,0 +1,75 @@ +function parsePurchaseXML (success) { + + if(success == false) { + trace("purchase_history.xml failed to load"); + return; + } + + if (this.status != 0) { + trace("The XML file was loaded, but was not well formed"); + return; + } + + if (this.firstChild.nodeName.toLowerCase() != "purchasehistory") { + trace("Unexpected XML data"); + return; + } + + history_arr = this.firstChild.childNodes; + + for (var count = 0; count < purchaseHistoryNodes.length; count++) { + var purchaseID = history_arr[count].attributes.id; + var purchaseTime = history_arr[count].attributes.time; + + trace("--Purchase " + purchaseID + " @ " + purchaseTime + " -------------"); + + parsePurchaseNodes(history_arr[count].childNodes); + + trace("-----------------------------------------"); + } +} + + +function parsePurchaseNodes(purchase_arr) { + + for (var count = 0; count < purchase_arr.length; count++) { + var nodeName = purchase_arr[count].nodeName.toLowerCase(); + + if(nodeName == "items") { + parseItemsNode(purchase_arr[count].childNodes); + } else if (nodeName == "client") { + parseClientNode(purchase_arr[count].childNodes); + } + } + +} + + +function parseClientNode(client_arr) { + + trace("---- Client Information"); + + for (var count = 0; count < client_arr.length; count++) { + trace(" " + client_arr[count].nodeName + ": " + client_arr[count].nodeValue); + } + + trace("---- End Client Information"); +} + + +function parseItemsNode(items_arr) { + + for(var count = 0; count < items_arr.length; count++) { + trace("---- Item " + items_arr[count].attributes.id); + parseItemNode(items_arr[count].childNodes); + trace("---- End Item"); + } +} + + +function parseItemNode(item_arr) { + + for (var count = 0; count < item_arr.length; count++) { + trace(" " + item_arr[count].nodeName + ": " + item_arr[count].nodeValue); + } +} diff --git a/chapter03/Chapter 03/tutorial files/xmlloading.fla b/chapter03/Chapter 03/tutorial files/xmlloading.fla new file mode 100644 index 0000000..af334fe Binary files /dev/null and b/chapter03/Chapter 03/tutorial files/xmlloading.fla differ diff --git a/chapter03/Chapter 03/tutorial files/xmlparsing_level1.fla b/chapter03/Chapter 03/tutorial files/xmlparsing_level1.fla new file mode 100644 index 0000000..8043a1e Binary files /dev/null and b/chapter03/Chapter 03/tutorial files/xmlparsing_level1.fla differ diff --git a/chapter03/Chapter 03/tutorial files/xmlparsing_level2.fla b/chapter03/Chapter 03/tutorial files/xmlparsing_level2.fla new file mode 100644 index 0000000..4ebe01e Binary files /dev/null and b/chapter03/Chapter 03/tutorial files/xmlparsing_level2.fla differ diff --git a/chapter03/Chapter 03/tutorial files/xmlparsing_level3a.fla b/chapter03/Chapter 03/tutorial files/xmlparsing_level3a.fla new file mode 100644 index 0000000..23c852e Binary files /dev/null and b/chapter03/Chapter 03/tutorial files/xmlparsing_level3a.fla differ diff --git a/chapter03/Chapter 03/tutorial files/xmlparsing_level3b.fla b/chapter03/Chapter 03/tutorial files/xmlparsing_level3b.fla new file mode 100644 index 0000000..c4f49d0 Binary files /dev/null and b/chapter03/Chapter 03/tutorial files/xmlparsing_level3b.fla differ diff --git a/chapter03/Chapter 03/tutorial files/xmlparsing_level4.fla b/chapter03/Chapter 03/tutorial files/xmlparsing_level4.fla new file mode 100644 index 0000000..a81b9d3 Binary files /dev/null and b/chapter03/Chapter 03/tutorial files/xmlparsing_level4.fla differ diff --git a/chapter03/Chapter 03/tutorial files/xmlvalidating.fla b/chapter03/Chapter 03/tutorial files/xmlvalidating.fla new file mode 100644 index 0000000..02a6da4 Binary files /dev/null and b/chapter03/Chapter 03/tutorial files/xmlvalidating.fla differ diff --git a/chapter04.sit b/chapter04.sit new file mode 100644 index 0000000..84aec26 Binary files /dev/null and b/chapter04.sit differ diff --git a/chapter04/Chapter 04/flashblog files/template.fla b/chapter04/Chapter 04/flashblog files/template.fla new file mode 100644 index 0000000..fbe4098 Binary files /dev/null and b/chapter04/Chapter 04/flashblog files/template.fla differ diff --git a/chapter04/Chapter 04/flashblog files/template_graphics.fla b/chapter04/Chapter 04/flashblog files/template_graphics.fla new file mode 100644 index 0000000..13ad2c2 Binary files /dev/null and b/chapter04/Chapter 04/flashblog files/template_graphics.fla differ diff --git a/chapter04/Chapter 04/tutorial files/Object_object.fla b/chapter04/Chapter 04/tutorial files/Object_object.fla new file mode 100644 index 0000000..f456d30 Binary files /dev/null and b/chapter04/Chapter 04/tutorial files/Object_object.fla differ diff --git a/chapter04/Chapter 04/tutorial files/textfield_autosize_end.fla b/chapter04/Chapter 04/tutorial files/textfield_autosize_end.fla new file mode 100644 index 0000000..c6f952d Binary files /dev/null and b/chapter04/Chapter 04/tutorial files/textfield_autosize_end.fla differ diff --git a/chapter04/Chapter 04/tutorial files/textfield_autosize_start.fla b/chapter04/Chapter 04/tutorial files/textfield_autosize_start.fla new file mode 100644 index 0000000..2ee4584 Binary files /dev/null and b/chapter04/Chapter 04/tutorial files/textfield_autosize_start.fla differ diff --git a/chapter04/Chapter 04/tutorial files/textfield_text.fla b/chapter04/Chapter 04/tutorial files/textfield_text.fla new file mode 100644 index 0000000..0f32633 Binary files /dev/null and b/chapter04/Chapter 04/tutorial files/textfield_text.fla differ diff --git a/chapter05.sit b/chapter05.sit new file mode 100644 index 0000000..4601727 Binary files /dev/null and b/chapter05.sit differ diff --git a/chapter05/Chapter 05/flashblog files/ch05_markup_book_final.fla b/chapter05/Chapter 05/flashblog files/ch05_markup_book_final.fla new file mode 100644 index 0000000..b160c61 Binary files /dev/null and b/chapter05/Chapter 05/flashblog files/ch05_markup_book_final.fla differ diff --git a/chapter05/Chapter 05/flashblog files/ch05_markup_book_final.swf b/chapter05/Chapter 05/flashblog files/ch05_markup_book_final.swf new file mode 100644 index 0000000..7822bd3 Binary files /dev/null and b/chapter05/Chapter 05/flashblog files/ch05_markup_book_final.swf differ diff --git a/chapter05/Chapter 05/flashblog files/ch05_markup_book_start.fla b/chapter05/Chapter 05/flashblog files/ch05_markup_book_start.fla new file mode 100644 index 0000000..010fe50 Binary files /dev/null and b/chapter05/Chapter 05/flashblog files/ch05_markup_book_start.fla differ diff --git a/chapter05/Chapter 05/flashblog files/fake_message_data.xml b/chapter05/Chapter 05/flashblog files/fake_message_data.xml new file mode 100644 index 0000000..83d8afa --- /dev/null +++ b/chapter05/Chapter 05/flashblog files/fake_message_data.xml @@ -0,0 +1,35 @@ + + + + + + + Scott + Mebberson + + + Flash and XML go hand in hand! + This a test message that we'll use to create an XML parsing engine. + + + + + Scott + Mebberson + + + www.friendsofed.com + Visit the friends of ED site for information on their range of books. + + + + + Anthony + Stevens + + + www.pixelogic.org + Pixelog is Scott's personal site. + + + \ No newline at end of file diff --git a/chapter05/Chapter 05/flashblog files/template.swf b/chapter05/Chapter 05/flashblog files/template.swf new file mode 100644 index 0000000..c063035 Binary files /dev/null and b/chapter05/Chapter 05/flashblog files/template.swf differ diff --git a/chapter05/Chapter 05/tutorial files/CH05_D~1.FLA b/chapter05/Chapter 05/tutorial files/CH05_D~1.FLA new file mode 100644 index 0000000..b99e48c Binary files /dev/null and b/chapter05/Chapter 05/tutorial files/CH05_D~1.FLA differ diff --git a/chapter05/Chapter 05/tutorial files/CH05_D~2.FLA b/chapter05/Chapter 05/tutorial files/CH05_D~2.FLA new file mode 100644 index 0000000..d1ef1fc Binary files /dev/null and b/chapter05/Chapter 05/tutorial files/CH05_D~2.FLA differ diff --git a/chapter05/Chapter 05/tutorial files/ch05_loadMovie.fla b/chapter05/Chapter 05/tutorial files/ch05_loadMovie.fla new file mode 100644 index 0000000..bee277e Binary files /dev/null and b/chapter05/Chapter 05/tutorial files/ch05_loadMovie.fla differ diff --git a/chapter05/Chapter 05/tutorial files/meandering.fla b/chapter05/Chapter 05/tutorial files/meandering.fla new file mode 100644 index 0000000..abc40c7 Binary files /dev/null and b/chapter05/Chapter 05/tutorial files/meandering.fla differ diff --git a/chapter05/Chapter 05/tutorial files/meandering.swf b/chapter05/Chapter 05/tutorial files/meandering.swf new file mode 100644 index 0000000..5d7b6f3 Binary files /dev/null and b/chapter05/Chapter 05/tutorial files/meandering.swf differ diff --git a/chapter06.sit b/chapter06.sit new file mode 100644 index 0000000..87efc86 Binary files /dev/null and b/chapter06.sit differ diff --git a/chapter06/Chapter 06/flashblog files/ch06_flashblog_final.fla b/chapter06/Chapter 06/flashblog files/ch06_flashblog_final.fla new file mode 100644 index 0000000..46bec7e Binary files /dev/null and b/chapter06/Chapter 06/flashblog files/ch06_flashblog_final.fla differ diff --git a/chapter06/Chapter 06/flashblog files/ch06_flashblog_skin_final.fla b/chapter06/Chapter 06/flashblog files/ch06_flashblog_skin_final.fla new file mode 100644 index 0000000..d08d703 Binary files /dev/null and b/chapter06/Chapter 06/flashblog files/ch06_flashblog_skin_final.fla differ diff --git a/chapter06/Chapter 06/flashblog files/ch06_flashblog_skin_start.fla b/chapter06/Chapter 06/flashblog files/ch06_flashblog_skin_start.fla new file mode 100644 index 0000000..8e2a715 Binary files /dev/null and b/chapter06/Chapter 06/flashblog files/ch06_flashblog_skin_start.fla differ diff --git a/chapter06/Chapter 06/flashblog files/ch06_flashblog_start.fla b/chapter06/Chapter 06/flashblog files/ch06_flashblog_start.fla new file mode 100644 index 0000000..7d54c63 Binary files /dev/null and b/chapter06/Chapter 06/flashblog files/ch06_flashblog_start.fla differ diff --git a/chapter06/Chapter 06/flashblog files/fake_message_data.xml b/chapter06/Chapter 06/flashblog files/fake_message_data.xml new file mode 100644 index 0000000..83d8afa --- /dev/null +++ b/chapter06/Chapter 06/flashblog files/fake_message_data.xml @@ -0,0 +1,35 @@ + + + + + + + Scott + Mebberson + + + Flash and XML go hand in hand! + This a test message that we'll use to create an XML parsing engine. + + + + + Scott + Mebberson + + + www.friendsofed.com + Visit the friends of ED site for information on their range of books. + + + + + Anthony + Stevens + + + www.pixelogic.org + Pixelog is Scott's personal site. + + + \ No newline at end of file diff --git a/chapter06/Chapter 06/flashblog files/markup.swf b/chapter06/Chapter 06/flashblog files/markup.swf new file mode 100644 index 0000000..7822bd3 Binary files /dev/null and b/chapter06/Chapter 06/flashblog files/markup.swf differ diff --git a/chapter06/Chapter 06/flashblog files/template.swf b/chapter06/Chapter 06/flashblog files/template.swf new file mode 100644 index 0000000..c063035 Binary files /dev/null and b/chapter06/Chapter 06/flashblog files/template.swf differ diff --git a/chapter06/Chapter 06/tutorial files/ch06_ScrollPane_api.fla b/chapter06/Chapter 06/tutorial files/ch06_ScrollPane_api.fla new file mode 100644 index 0000000..82ca958 Binary files /dev/null and b/chapter06/Chapter 06/tutorial files/ch06_ScrollPane_api.fla differ diff --git a/chapter06/Chapter 06/tutorial files/ch06_ScrollPane_final.fla b/chapter06/Chapter 06/tutorial files/ch06_ScrollPane_final.fla new file mode 100644 index 0000000..4955443 Binary files /dev/null and b/chapter06/Chapter 06/tutorial files/ch06_ScrollPane_final.fla differ diff --git a/chapter06/Chapter 06/tutorial files/ch06_ScrollPane_start.fla b/chapter06/Chapter 06/tutorial files/ch06_ScrollPane_start.fla new file mode 100644 index 0000000..62ad8cd Binary files /dev/null and b/chapter06/Chapter 06/tutorial files/ch06_ScrollPane_start.fla differ diff --git a/chapter06/Chapter 06/tutorial files/ch06_button_component.fla b/chapter06/Chapter 06/tutorial files/ch06_button_component.fla new file mode 100644 index 0000000..3db4c70 Binary files /dev/null and b/chapter06/Chapter 06/tutorial files/ch06_button_component.fla differ diff --git a/chapter06/Chapter 06/tutorial files/ch06_xp_silver.fla b/chapter06/Chapter 06/tutorial files/ch06_xp_silver.fla new file mode 100644 index 0000000..8697c46 Binary files /dev/null and b/chapter06/Chapter 06/tutorial files/ch06_xp_silver.fla differ diff --git a/chapter06/Chapter 06/tutorial files/ch06_xp_silver_elements.fla b/chapter06/Chapter 06/tutorial files/ch06_xp_silver_elements.fla new file mode 100644 index 0000000..76ab99f Binary files /dev/null and b/chapter06/Chapter 06/tutorial files/ch06_xp_silver_elements.fla differ diff --git a/chapter06/Chapter 06/tutorial files/sm_background.jpg b/chapter06/Chapter 06/tutorial files/sm_background.jpg new file mode 100644 index 0000000..8dfbb29 Binary files /dev/null and b/chapter06/Chapter 06/tutorial files/sm_background.jpg differ diff --git a/chapter07.sit b/chapter07.sit new file mode 100644 index 0000000..14faba0 Binary files /dev/null and b/chapter07.sit differ diff --git a/chapter07/Chapter 07/flashblog files/ch05_markup_book_final.fla b/chapter07/Chapter 07/flashblog files/ch05_markup_book_final.fla new file mode 100644 index 0000000..b160c61 Binary files /dev/null and b/chapter07/Chapter 07/flashblog files/ch05_markup_book_final.fla differ diff --git a/chapter07/Chapter 07/flashblog files/fake_message_data.xml b/chapter07/Chapter 07/flashblog files/fake_message_data.xml new file mode 100644 index 0000000..83d8afa --- /dev/null +++ b/chapter07/Chapter 07/flashblog files/fake_message_data.xml @@ -0,0 +1,35 @@ + + + + + + + Scott + Mebberson + + + Flash and XML go hand in hand! + This a test message that we'll use to create an XML parsing engine. + + + + + Scott + Mebberson + + + www.friendsofed.com + Visit the friends of ED site for information on their range of books. + + + + + Anthony + Stevens + + + www.pixelogic.org + Pixelog is Scott's personal site. + + + \ No newline at end of file diff --git a/chapter07/Chapter 07/flashblog files/flashblog.fla b/chapter07/Chapter 07/flashblog files/flashblog.fla new file mode 100644 index 0000000..d08d703 Binary files /dev/null and b/chapter07/Chapter 07/flashblog files/flashblog.fla differ diff --git a/chapter07/Chapter 07/flashblog files/flashblog.swf b/chapter07/Chapter 07/flashblog files/flashblog.swf new file mode 100644 index 0000000..9a927d0 Binary files /dev/null and b/chapter07/Chapter 07/flashblog files/flashblog.swf differ diff --git a/chapter07/Chapter 07/flashblog files/index.html b/chapter07/Chapter 07/flashblog files/index.html new file mode 100644 index 0000000..aca62e4 --- /dev/null +++ b/chapter07/Chapter 07/flashblog files/index.html @@ -0,0 +1,16 @@ + + + +flashblog + + + + + + + + + diff --git a/chapter07/Chapter 07/flashblog files/markup.fla b/chapter07/Chapter 07/flashblog files/markup.fla new file mode 100644 index 0000000..8319b94 Binary files /dev/null and b/chapter07/Chapter 07/flashblog files/markup.fla differ diff --git a/chapter07/Chapter 07/flashblog files/markup.swf b/chapter07/Chapter 07/flashblog files/markup.swf new file mode 100644 index 0000000..84835ac Binary files /dev/null and b/chapter07/Chapter 07/flashblog files/markup.swf differ diff --git a/chapter07/Chapter 07/flashblog files/retrieve_posts.php b/chapter07/Chapter 07/flashblog files/retrieve_posts.php new file mode 100644 index 0000000..dfc25ff --- /dev/null +++ b/chapter07/Chapter 07/flashblog files/retrieve_posts.php @@ -0,0 +1,31 @@ +Couldn't open fake_message_data.xml."; + exit; + +} + +$xmlDoc = ""; + +while ($data = fread($file, 4096)) { + + $xmlDoc .= $data; + +} + +if ($xmlDoc == "") { + + echo "There are currently no posts."; + +} else { + + echo $xmlDoc; + +} + +?> \ No newline at end of file diff --git a/chapter07/Chapter 07/flashblog files/template.swf b/chapter07/Chapter 07/flashblog files/template.swf new file mode 100644 index 0000000..c063035 Binary files /dev/null and b/chapter07/Chapter 07/flashblog files/template.swf differ diff --git a/chapter07/Chapter 07/tutorial files/ab_add.php b/chapter07/Chapter 07/tutorial files/ab_add.php new file mode 100644 index 0000000..2544182 --- /dev/null +++ b/chapter07/Chapter 07/tutorial files/ab_add.php @@ -0,0 +1,41 @@ + + + + + Address Book - Add Contact + + +

Add Contact

+ $newName, "phone"=>$newPhone, "email"=>$newEmail); + saveContacts(); + + } else { + + echo "
\n"; + echo "Name:
\n"; + echo "Phone:
\n"; + echo "Email:

\n"; + echo "
\n"; + echo "
\n"; + + } + + ?> + + View Contacts + + Add New Contact + + + diff --git a/chapter07/Chapter 07/tutorial files/ab_common.php b/chapter07/Chapter 07/tutorial files/ab_common.php new file mode 100644 index 0000000..28faec8 --- /dev/null +++ b/chapter07/Chapter 07/tutorial files/ab_common.php @@ -0,0 +1,142 @@ +$personName, "phone"=>$phone, "email"=>$email); + break; + + } + + + } + + + function loadContacts() { + // Create the XML parser + $parser = xml_parser_create(); + + + // Register the start and end element handlers + xml_set_element_handler($parser, "startElementHandler", "endElementHandler"); + + // Register the character data parser + xml_set_character_data_handler($parser, "charDataHandler"); + + + // Open the XML file + $file = @fopen("xml_document.xml", "r"); + + if (!$file) { + echo "Could not open xml_document.xml.
\n"; + exit; + } + + while ($data = fread($file, 4096)) { + if (!xml_parse($parser, $data, feof($file))) { + echo "There was an error in the XML document
\n"; + echo " line: " . xml_get_current_line_number($parser) . "
\n"; + echo " position: " . xml_get_current_column_number($parser) . "
\n"; + exit; + } + } + + // OK, free the XML parser + xml_parser_free($parser); + + } + + function saveContacts() { + global $contacts; + + $xmlStr = "\n\n"; + + for ($i = 0; $i < count($contacts); $i++) { + + $xmlStr .= "\t\n"; + + $xmlStr .= "\t\t" . $contacts[$i]['name'] . "\n"; + $xmlStr .= "\t\t" . $contacts[$i]['phone'] . "\n"; + $xmlStr .= "\t\t" . $contacts[$i]['email'] . "\n"; + + $xmlStr .= "\t\n"; + + } + + $xmlStr .= ""; + + $file = @fopen("xml_document.xml", "w"); + + if(!$file) { + + print "Unable to open xml_document.xml for writing
\n"; + + } else { + + fwrite($file, $xmlStr); + fclose($file); + echo "Contact details successfully saved.
\n"; + + } + + } + +?> diff --git a/chapter07/Chapter 07/tutorial files/ab_edit.php b/chapter07/Chapter 07/tutorial files/ab_edit.php new file mode 100644 index 0000000..df62fa4 --- /dev/null +++ b/chapter07/Chapter 07/tutorial files/ab_edit.php @@ -0,0 +1,44 @@ + + + + + Address Book - Edit Contact + + +

Edit Contact

+ \n"; + + + echo "\n"; + echo "Name:
\n"; + + echo "Phone:
\n"; + echo "Email:

\n"; + + echo "
\n"; + + echo "\n"; + + } else { + + echo "This is not a valid contact ID.
\n"; + + } + + ?> + + View Contacts + + + diff --git a/chapter07/Chapter 07/tutorial files/ab_index.php b/chapter07/Chapter 07/tutorial files/ab_index.php new file mode 100644 index 0000000..ef5ebb0 --- /dev/null +++ b/chapter07/Chapter 07/tutorial files/ab_index.php @@ -0,0 +1,50 @@ + + + + + + Address Book - View Contacts + + +

View Contacts

+ + 0) { + + + for ($i = 0; $i < count($contacts); $i++) { + + echo "Name: " . $contacts[$i]["name"] . "
\n"; + echo "Phone: " . $contacts[$i]["phone"] . "
\n"; + + echo "Email: " . $contacts[$i]["email"] . "
\n"; + + echo "Edit
\n"; + + + echo "
\n"; + + + + } + + + + } else { + echo "There are no contacts in the contacts book.
\n"; + } + ?> + + + Add New Contact + + + + diff --git a/chapter07/Chapter 07/tutorial files/ab_save.php b/chapter07/Chapter 07/tutorial files/ab_save.php new file mode 100644 index 0000000..67b9ba5 --- /dev/null +++ b/chapter07/Chapter 07/tutorial files/ab_save.php @@ -0,0 +1,36 @@ + + + + + Address Book - Save Contact + + +

Save Contact

+ \n"; + + } + + + ?> + Continue + + diff --git a/chapter07/Chapter 07/tutorial files/edit_contacts_start.php b/chapter07/Chapter 07/tutorial files/edit_contacts_start.php new file mode 100644 index 0000000..14a96bf --- /dev/null +++ b/chapter07/Chapter 07/tutorial files/edit_contacts_start.php @@ -0,0 +1,144 @@ +$personName,"phone"=>$phone,"email"=>$email); + + } + +} + +?> + + + + +Address Book + + + +\n"; + exit; + +} + + + +while ($data = fread($file, 4096)) { + + if (!xml_parse($parser, $data, feof($file))) { + + exit("There was an error in the XML in line " . xml_get_current_line_number($parser) . " at position " . xml_get_current_column_number($parser) . ".
 
\n\n"); + + } + + +} + +// OK, finished parsing the XML +xml_parser_free($parser); + +if (count($contacts) > 0) { + + echo "
\n"; + + for ($i = 0; $i < count($contacts); $i++) { + + echo "Name: " . $contacts[$i]["name"] . "
\n"; + echo "Phone: " . $contacts[$i]["phone"] . "
\n"; + echo "Email: " . $contacts[$i]["email"] . "
\n"; + echo "
\n"; + + } + +} else { + + echo "There are no contacts in your contacts book.
\n"; + +} + +echo "View Contacts | Edit Contacts
\n"; + + +?> + + + diff --git a/chapter07/Chapter 07/tutorial files/general_usage.php b/chapter07/Chapter 07/tutorial files/general_usage.php new file mode 100644 index 0000000..c77faa5 --- /dev/null +++ b/chapter07/Chapter 07/tutorial files/general_usage.php @@ -0,0 +1,38 @@ + + + General PHP Exercise - Foundation Flash MX Applications + + + + \n"; + + // If statements + if (isset($name)) { + echo "My name is $name.
\n"; + + // Comparison operator + if ($name == "Scott") { + echo "Would you like to search @ google\n"; + } + + // The for loop in PHP + if (isset($age) && $age > 18) { + echo "My age is $age.
\n"; + echo "
\n"; + for ($count = 0; $count < $age; $count++) { + echo "Hello $name!
\n"; + } + + } else { + + echo "
\n"; + echo "$name, you are not old enough to visit this page. Please come back in " . (18-$age) . " years."; + } + + } + ?> + + + \ No newline at end of file diff --git a/chapter07/Chapter 07/tutorial files/load_xml_final.php b/chapter07/Chapter 07/tutorial files/load_xml_final.php new file mode 100644 index 0000000..ffb7cb2 --- /dev/null +++ b/chapter07/Chapter 07/tutorial files/load_xml_final.php @@ -0,0 +1,45 @@ + + + +Address Book + + + +\n"; + exit; + +} + + +$xmlDoc = ""; + +while ($data = fread($file, 4096)) { + + $xmlDoc .= $data; + +} + + + +if ($xmlDoc == "") { + + echo "Failed to load the XML doc."; + +} else { + + echo "The XML document has completely loaded:
 
\n\n
" . htmlentities($xmlDoc) . "
"; + +} + +?> + + + diff --git a/chapter07/Chapter 07/tutorial files/login.fla b/chapter07/Chapter 07/tutorial files/login.fla new file mode 100644 index 0000000..79eb1a4 Binary files /dev/null and b/chapter07/Chapter 07/tutorial files/login.fla differ diff --git a/chapter07/Chapter 07/tutorial files/login.html b/chapter07/Chapter 07/tutorial files/login.html new file mode 100644 index 0000000..efb25fc --- /dev/null +++ b/chapter07/Chapter 07/tutorial files/login.html @@ -0,0 +1,16 @@ + + + +login + + + + + + + + + diff --git a/chapter07/Chapter 07/tutorial files/login.php b/chapter07/Chapter 07/tutorial files/login.php new file mode 100644 index 0000000..8233543 --- /dev/null +++ b/chapter07/Chapter 07/tutorial files/login.php @@ -0,0 +1,70 @@ +"; + + } else { + echo ""; + + } + +?> diff --git a/chapter07/Chapter 07/tutorial files/login.swf b/chapter07/Chapter 07/tutorial files/login.swf new file mode 100644 index 0000000..64909e3 Binary files /dev/null and b/chapter07/Chapter 07/tutorial files/login.swf differ diff --git a/chapter07/Chapter 07/tutorial files/login_final.fla b/chapter07/Chapter 07/tutorial files/login_final.fla new file mode 100644 index 0000000..6c09ebf Binary files /dev/null and b/chapter07/Chapter 07/tutorial files/login_final.fla differ diff --git a/chapter07/Chapter 07/tutorial files/login_final.swf b/chapter07/Chapter 07/tutorial files/login_final.swf new file mode 100644 index 0000000..e7b99c3 Binary files /dev/null and b/chapter07/Chapter 07/tutorial files/login_final.swf differ diff --git a/chapter07/Chapter 07/tutorial files/login_start.fla b/chapter07/Chapter 07/tutorial files/login_start.fla new file mode 100644 index 0000000..e28b319 Binary files /dev/null and b/chapter07/Chapter 07/tutorial files/login_start.fla differ diff --git a/chapter07/Chapter 07/tutorial files/parse_xml_final.php b/chapter07/Chapter 07/tutorial files/parse_xml_final.php new file mode 100644 index 0000000..14a96bf --- /dev/null +++ b/chapter07/Chapter 07/tutorial files/parse_xml_final.php @@ -0,0 +1,144 @@ +$personName,"phone"=>$phone,"email"=>$email); + + } + +} + +?> + + + + +Address Book + + + +\n"; + exit; + +} + + + +while ($data = fread($file, 4096)) { + + if (!xml_parse($parser, $data, feof($file))) { + + exit("There was an error in the XML in line " . xml_get_current_line_number($parser) . " at position " . xml_get_current_column_number($parser) . ".
 
\n\n"); + + } + + +} + +// OK, finished parsing the XML +xml_parser_free($parser); + +if (count($contacts) > 0) { + + echo "
\n"; + + for ($i = 0; $i < count($contacts); $i++) { + + echo "Name: " . $contacts[$i]["name"] . "
\n"; + echo "Phone: " . $contacts[$i]["phone"] . "
\n"; + echo "Email: " . $contacts[$i]["email"] . "
\n"; + echo "
\n"; + + } + +} else { + + echo "There are no contacts in your contacts book.
\n"; + +} + +echo "View Contacts | Edit Contacts
\n"; + + +?> + + + diff --git a/chapter07/Chapter 07/tutorial files/parse_xml_start.php b/chapter07/Chapter 07/tutorial files/parse_xml_start.php new file mode 100644 index 0000000..ffb7cb2 --- /dev/null +++ b/chapter07/Chapter 07/tutorial files/parse_xml_start.php @@ -0,0 +1,45 @@ + + + +Address Book + + + +\n"; + exit; + +} + + +$xmlDoc = ""; + +while ($data = fread($file, 4096)) { + + $xmlDoc .= $data; + +} + + + +if ($xmlDoc == "") { + + echo "Failed to load the XML doc."; + +} else { + + echo "The XML document has completely loaded:
 
\n\n
" . htmlentities($xmlDoc) . "
"; + +} + +?> + + + diff --git a/chapter07/Chapter 07/tutorial files/raw_post_data_check.php b/chapter07/Chapter 07/tutorial files/raw_post_data_check.php new file mode 100644 index 0000000..967b33f --- /dev/null +++ b/chapter07/Chapter 07/tutorial files/raw_post_data_check.php @@ -0,0 +1,21 @@ +off by default.
\n"; + +} else if ($value == false) { + + echo "Failed to set the always_populate_raw_post_data directive.
\n Unable to determine default settings.
\n"; + echo "Please look beflow for more information on PHP configuration:
 
\n\n"; + phpinfo(); + +} else { + + echo "The always_populate_raw_post_data directive is on by default.
\n"; + +} + +?> \ No newline at end of file diff --git a/chapter07/Chapter 07/tutorial files/xml_document.xml b/chapter07/Chapter 07/tutorial files/xml_document.xml new file mode 100644 index 0000000..f9bdc22 --- /dev/null +++ b/chapter07/Chapter 07/tutorial files/xml_document.xml @@ -0,0 +1,18 @@ + + + + Phillip Jackson + +44 (0)121 678 100 + phillipj@friendsofed.com + + + + Arnold Blog + + 09 9552 6626 + + + + arnold@blog.com + + \ No newline at end of file diff --git a/chapter08.sit b/chapter08.sit new file mode 100644 index 0000000..096b4f0 Binary files /dev/null and b/chapter08.sit differ diff --git a/chapter08/Chapter 08/flashblog files/Chapter 8 Case Study Start/ch08_flashblog_start.fla b/chapter08/Chapter 08/flashblog files/Chapter 8 Case Study Start/ch08_flashblog_start.fla new file mode 100644 index 0000000..d08d703 Binary files /dev/null and b/chapter08/Chapter 08/flashblog files/Chapter 8 Case Study Start/ch08_flashblog_start.fla differ diff --git a/chapter08/Chapter 08/flashblog files/Chapter 8 Case Study Start/flashblog.swf b/chapter08/Chapter 08/flashblog files/Chapter 8 Case Study Start/flashblog.swf new file mode 100644 index 0000000..9a927d0 Binary files /dev/null and b/chapter08/Chapter 08/flashblog files/Chapter 8 Case Study Start/flashblog.swf differ diff --git a/chapter08/Chapter 08/flashblog files/Chapter 8 Case Study Start/index.html b/chapter08/Chapter 08/flashblog files/Chapter 8 Case Study Start/index.html new file mode 100644 index 0000000..aca62e4 --- /dev/null +++ b/chapter08/Chapter 08/flashblog files/Chapter 8 Case Study Start/index.html @@ -0,0 +1,16 @@ + + + +flashblog + + + + + + + + + diff --git a/chapter08/Chapter 08/flashblog files/Chapter 8 Case Study Start/markup.swf b/chapter08/Chapter 08/flashblog files/Chapter 8 Case Study Start/markup.swf new file mode 100644 index 0000000..84835ac Binary files /dev/null and b/chapter08/Chapter 08/flashblog files/Chapter 8 Case Study Start/markup.swf differ diff --git a/chapter08/Chapter 08/flashblog files/Chapter 8 Case Study Start/template.swf b/chapter08/Chapter 08/flashblog files/Chapter 8 Case Study Start/template.swf new file mode 100644 index 0000000..c063035 Binary files /dev/null and b/chapter08/Chapter 08/flashblog files/Chapter 8 Case Study Start/template.swf differ diff --git a/chapter08/Chapter 08/flashblog files/config.xml b/chapter08/Chapter 08/flashblog files/config.xml new file mode 100644 index 0000000..1fa52eb --- /dev/null +++ b/chapter08/Chapter 08/flashblog files/config.xml @@ -0,0 +1,6 @@ + + + 15 + SWF/ + template.swf + \ No newline at end of file diff --git a/chapter08/Chapter 08/flashblog files/database.php b/chapter08/Chapter 08/flashblog files/database.php new file mode 100644 index 0000000..a598364 --- /dev/null +++ b/chapter08/Chapter 08/flashblog files/database.php @@ -0,0 +1,26 @@ +falseAn error occured while connecting to the MySQL server.database_mysql_server"; + exit; + +} + +// Select the database, if an error occurs return an error message and exit the script +if(!@mysql_select_db($db_name, $db)) { + + echo "falseAn error occurred while selecting the databse.database_connecting"; + exit; + +} + +?> \ No newline at end of file diff --git a/chapter08/Chapter 08/flashblog files/drop_db.php b/chapter08/Chapter 08/flashblog files/drop_db.php new file mode 100644 index 0000000..2d48481 --- /dev/null +++ b/chapter08/Chapter 08/flashblog files/drop_db.php @@ -0,0 +1,29 @@ +\n"); +} + +// Select the database, if an error occurs return an error message and exit the script +if(!@mysql_select_db($db_name, $db)) { + exit("Unable to select the database $db_name.
\nError #" . mysql_errno($db) . ": " . mysql_error($db) . "
\n"); +} + +$result = mysql_query("DROP DATABASE $db_name"); + +if (!$result) { + + exit("Unable to DROP $db_name.
\nError #" . mysql_errno($db) . ": " . mysql_error($db) . "
\n"); + +} + +echo "The database $db_name has been dropped.
\n"; + +?> \ No newline at end of file diff --git a/chapter08/Chapter 08/flashblog files/flashblog.fla b/chapter08/Chapter 08/flashblog files/flashblog.fla new file mode 100644 index 0000000..981a0b7 Binary files /dev/null and b/chapter08/Chapter 08/flashblog files/flashblog.fla differ diff --git a/chapter08/Chapter 08/flashblog files/flashblog.swf b/chapter08/Chapter 08/flashblog files/flashblog.swf new file mode 100644 index 0000000..9554333 Binary files /dev/null and b/chapter08/Chapter 08/flashblog files/flashblog.swf differ diff --git a/chapter08/Chapter 08/flashblog files/index.html b/chapter08/Chapter 08/flashblog files/index.html new file mode 100644 index 0000000..6acf0d1 --- /dev/null +++ b/chapter08/Chapter 08/flashblog files/index.html @@ -0,0 +1,16 @@ + + + +flashblog + + + + + + + + + diff --git a/chapter08/Chapter 08/flashblog files/populate_flashblog_db.php b/chapter08/Chapter 08/flashblog files/populate_flashblog_db.php new file mode 100644 index 0000000..69e19eb --- /dev/null +++ b/chapter08/Chapter 08/flashblog files/populate_flashblog_db.php @@ -0,0 +1,71 @@ + "admin", + "password" => "admin", + "first_name" => "default", + "last_name" => "default", + "user_type" => "administrator"); + +$users[] = array("username" => "user1", + "password" => "user1", + "first_name" => "default1", + "last_name" => "user1", + "user_type" => "user"); + +$users[] = array("username" => "user2", + "password" => "user2", + "first_name" => "default2", + "last_name" => "user2", + "user_type" => "user"); + +$posts = array(); + +// Enter the fake posts here +$posts[] = array("user_id" => "1", + "subject" => "Subject here", + "body" => "Body here", + "timestamp" => "2002,11,21,0,00"); + +// Connect to the mysql server, if an error occurs, return an error message and exit the script +if(!$db=@mysql_connect($db_host, $db_user, $db_password)) { + exit("An error occured while connecting to the MySQL server.
\n"); +} + +// Select the database, if an error occurs return an error message and exit the script +if(!mysql_select_db($db_name, $db)) { + exit("Unable to select the database $db_name.
\n"); +} + +echo "Now populating the database with users:
 
\n\n"; + +for ($i = 0; $i < count($users); $i++) { + + $stmt = "INSERT INTO fb_user (username, password, first_name, last_name, user_type) VALUES ('" . $users[$i]['username'] . "', '" . $users[$i]['password'] . "', '" . $users[$i]['first_name'] . "', '" . $users[$i]['last_name'] . "', '" . $users[$i]['user_type'] . "')"; + + $result = mysql_query($stmt, $db); + + echo "$stmt
\n"; + +} + +echo "
Now populating the database with posts:
 
\n\n"; + +for ($i = 0; $i < count($posts); $i++) { + + $stmt = "INSERT INTO fb_posts (user_id, subject, body, timestamp) VALUES ('" . $posts[$i]['user_id'] . "', '" . $posts[$i]['subject'] . "', '" . $posts[$i]['body'] . "', '" . $posts[$i]['timestamp'] . "')"; + + $result = mysql_query($stmt, $db); + + echo "$stmt
\n"; + +} + +?> \ No newline at end of file diff --git a/chapter08/Chapter 08/flashblog files/retrieve_posts.php b/chapter08/Chapter 08/flashblog files/retrieve_posts.php new file mode 100644 index 0000000..8e8596f --- /dev/null +++ b/chapter08/Chapter 08/flashblog files/retrieve_posts.php @@ -0,0 +1,51 @@ +SQL query failed. Please try again."; + exit; + +} + +// Find the number of rows returned (i.e. the number of posts) +$numRows = @mysql_num_rows($result); + +// Were there any rows? +if ($numRows <= 0) { + + // No rows were returned, there mustn't be any entries + echo "There are currently no entries in the database."; + exit; + +} + +// Open the XML document +$XMLString = ""; + +// Loop through each row and create the node with all the correct information +for ($i = 0; $i < $numRows; $i++) { + + $row = @mysql_fetch_array($result); + + $XMLString .= "" . $row['first_name'] . "" . $row['last_name'] . "" . urlencode($row['subject']) . "" . urlencode($row['body']) . ""; + +} + +// Finish the XML document +$XMLString .= ""; + +// Return the XML to Flash +echo $XMLString; + +?> \ No newline at end of file diff --git a/chapter08/Chapter 08/flashblog files/setup_flashblog_db.php b/chapter08/Chapter 08/flashblog files/setup_flashblog_db.php new file mode 100644 index 0000000..92572e1 --- /dev/null +++ b/chapter08/Chapter 08/flashblog files/setup_flashblog_db.php @@ -0,0 +1,72 @@ +\n"); +} + +// Select the database, if an error occurs return an error message and exit the script +if(!mysql_select_db($db_name, $db)) { + echo "Unable to select the database $db_name.
\n I will attempt to create it.
 
\n\n"; +} + +// Create the database +if (!$result=@mysql_query("CREATE DATABASE $db_name", $db)) { + + exit("Unable to create database $db_name.
\nError #" . mysql_errno($db) . ": " . mysql_error($db) . "
\n"); + +} + +echo "The database $db_name has been created.
\n I will attempt to create the necessary tables.
 
\n\n"; + +// Select the database, if an error occurs return an error message and exit the script +if(!mysql_select_db($db_name, $db)) { + exit("Unable to select the database $db_name
\n."); +} + +echo "Selected database $db_name.
 
\n\n"; + +// The SQL statement to create the fb_posts table +$create_fbposts = "CREATE TABLE fb_posts ( + id INT(4) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, + user_id INT(4), + subject VARCHAR(200), + body TEXT, + timestamp VARCHAR(24))"; + +if (!$result=@mysql_query($create_fbposts, $db)) { + + echo "Unable to create the table fb_posts
\nError #" . mysql_errno($db) . ": " . mysql_error($db) . "
\nAttempting to create the next table
 
\n\n"; + +} else { + + echo "Successfully created the fb_posts table.
\n"; + +} + +$create_fbuser = "CREATE TABLE fb_user ( + id int(4) NOT NULL AUTO_INCREMENT PRIMARY KEY, + username varchar(12), + password varchar(12), + first_name varchar(12) NOT NULL default 'Firstname', + last_name varchar(26) NOT NULL default 'Lastname', + user_type varchar(13) NOT NULL default 'user', + session_id varchar(32) NOT NULL default '0')"; + +if (!$result=@mysql_query($create_fbuser, $db)) { + + echo "Unable to create the table fb_user
\nError #" . mysql_errno($db) . ": " . mysql_error($db) . "
\n"; + +} else { + + echo "Successfully created the fb_user table.
\n"; + +} + +?> \ No newline at end of file diff --git a/chapter08/Chapter 08/tutorial files/add_user_db.php b/chapter08/Chapter 08/tutorial files/add_user_db.php new file mode 100644 index 0000000..350cc4b --- /dev/null +++ b/chapter08/Chapter 08/tutorial files/add_user_db.php @@ -0,0 +1,27 @@ + + +Creating a user table + + + + +
+ +username*
+
+ +password*
+
+ +real name*
+
+ +email*
+
+ + + +
+ + + diff --git a/chapter08/Chapter 08/tutorial files/connecting_db.php b/chapter08/Chapter 08/tutorial files/connecting_db.php new file mode 100644 index 0000000..711737d --- /dev/null +++ b/chapter08/Chapter 08/tutorial files/connecting_db.php @@ -0,0 +1,30 @@ + + + + + Creating a MySQL Database + + +\n"); + +if (!mysql_select_db($database, $mysql_connection)) { + + echo "Failed to connect to database: $database.
\n"; + echo "Error information: " . mysql_errno($mysql_connection) . " " . mysql_error($mysql_connection) . "
\n"; + + exit; +} + +echo "Successfully connected to database: $database.
\n"; + +?> + + + diff --git a/chapter08/Chapter 08/tutorial files/create_table_db.php b/chapter08/Chapter 08/tutorial files/create_table_db.php new file mode 100644 index 0000000..eaeab72 --- /dev/null +++ b/chapter08/Chapter 08/tutorial files/create_table_db.php @@ -0,0 +1,45 @@ + + + + + Creating a MySQL Database + + + +\n"); + +if (!mysql_select_db($database, $mysql_connection)) { + + echo "Failed to connect to database: $database.
\n"; + echo "Error information: " . mysql_errno($mysql_connection) . " " . mysql_error($mysql_connection) . "
\n"; + exit; +} + +$create_table = "CREATE TABLE users ( + uid INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, + username VARCHAR(16), + userpass VARCHAR(16), + realname VARCHAR(200), + email VARCHAR(200))"; + +if (!$result=mysql_query($create_table, $mysql_connection)) { + + echo "An error occured while creating the users table.
\n"; + echo "Error information: " . mysql_errno($mysql_connection) . " " . + mysql_error($mysql_connection) . "
\n"; + exit; +} + +echo "The users table on $database has successfully been created.
\n"; + +?> + + + diff --git a/chapter08/Chapter 08/tutorial files/creating_db.php b/chapter08/Chapter 08/tutorial files/creating_db.php new file mode 100644 index 0000000..42da032 --- /dev/null +++ b/chapter08/Chapter 08/tutorial files/creating_db.php @@ -0,0 +1,32 @@ + + + + +Creating a MySQL Database + + + +\n"); + + if (!mysql_create_db($database, $mysql_connection)) { + + echo "Failed to create the new database $database.
\n"; + echo "Error #" . mysql_errno($mysql_connection) . ": " . mysql_error($mysql_connection); + +} else { + + echo "Successfully created the database $database.
\n"; + +} + +?> + + + diff --git a/chapter08/Chapter 08/tutorial files/db_details.php b/chapter08/Chapter 08/tutorial files/db_details.php new file mode 100644 index 0000000..4e8da09 --- /dev/null +++ b/chapter08/Chapter 08/tutorial files/db_details.php @@ -0,0 +1,8 @@ + diff --git a/chapter08/Chapter 08/tutorial files/login.fla b/chapter08/Chapter 08/tutorial files/login.fla new file mode 100644 index 0000000..6c09ebf Binary files /dev/null and b/chapter08/Chapter 08/tutorial files/login.fla differ diff --git a/chapter08/Chapter 08/tutorial files/login.html b/chapter08/Chapter 08/tutorial files/login.html new file mode 100644 index 0000000..efb25fc --- /dev/null +++ b/chapter08/Chapter 08/tutorial files/login.html @@ -0,0 +1,16 @@ + + + +login + + + + + + + + + diff --git a/chapter08/Chapter 08/tutorial files/login.php b/chapter08/Chapter 08/tutorial files/login.php new file mode 100644 index 0000000..9958781 --- /dev/null +++ b/chapter08/Chapter 08/tutorial files/login.php @@ -0,0 +1,99 @@ +"; + exit(); + +} + +// Ok, finished parsing the XML +xml_parser_free($parser); + +$mysql_connection = mysql_connect($hostname, $username, $password); + +if (!$mysql_connection) { + + exit(""); + +} else { + + if (!mysql_select_db($database, $mysql_connection)) { + + $err = "An error occured while connecting to the database: " . mysql_errno($mysql_connection) . " " . mysql_error($mysql_connection); + + exit(""); + + } else { + + $add_user = "SELECT * FROM users"; + + $result = mysql_query($add_user, $mysql_connection); + + if (!$result) { + + $err = "An error occured while querying the database: " . mysql_errno($mysql_connection) . " " . mysql_error($mysql_connection); + exit(""); + + } else { + + $numRows = mysql_num_rows($result); + + for ($i = 0; $i < $numRows; $i++) { + + $row = mysql_fetch_array($result); + + if ($row["username"] == $user_username && $row["userpass"] == $user_password) { + + exit(""); + + } + + } + + exit(""); + + } + + } + +} + +?> \ No newline at end of file diff --git a/chapter08/Chapter 08/tutorial files/login.swf b/chapter08/Chapter 08/tutorial files/login.swf new file mode 100644 index 0000000..e7b99c3 Binary files /dev/null and b/chapter08/Chapter 08/tutorial files/login.swf differ diff --git a/chapter08/Chapter 08/tutorial files/save_user_db.php b/chapter08/Chapter 08/tutorial files/save_user_db.php new file mode 100644 index 0000000..246e563 --- /dev/null +++ b/chapter08/Chapter 08/tutorial files/save_user_db.php @@ -0,0 +1,74 @@ + + + + + + Populating the database + + + +\n"; + +} else if (!isset($pass_word) && $pass_word == "") { + + $error = true; + $errorMsg .= "No password was supplied
\n"; + +} else if (!isset($real_name) && $real_name == "") { + + $error = true; + $errorMsg .= "A real name was not supplied
\n"; + +} else if (!isset($email) && $email == "") { + + $error = true; + $errorMsg .= "An email address was not supplied
\n"; + +} + +if ($error == true) { + + echo "An error has occurred:
\n $errorMsg"; + exit; + +} + +$mysql_connection = @mysql_connect($hostname, $username, $password) + or exit("Failed to connect to the MySQL server.
\n"); + +if (!mysql_select_db($database, $mysql_connection)) { + + echo "Failed to connect to database: $database.
\n"; + echo "Error information: " . mysql_errno($mysql_connection) . " " . + mysql_error($mysql_connection) . "
\n"; + exit; +} + +$add_user = "INSERT INTO users (username, userpass, realname, email) + VALUES ('$user_name', '$pass_word', '$real_name', '$email')"; + +if (!$result=mysql_query($add_user, $mysql_connection)) { + echo "An error occurred while adding the user: $user_name.
\n"; + echo "Error information: " . mysql_errno($mysql_connection) . " " . + mysql_error($mysql_connection) . "
\n"; + exit; +} + +echo "The user $user_name was successfully added to the database.
\n"; + +?> + + + diff --git a/chapter08/Chapter 08/tutorial files/view_users_db.php b/chapter08/Chapter 08/tutorial files/view_users_db.php new file mode 100644 index 0000000..745053a --- /dev/null +++ b/chapter08/Chapter 08/tutorial files/view_users_db.php @@ -0,0 +1,52 @@ + + + + + Creating a MySQL Database + + + +\n"); + +if (!mysql_select_db($database, $mysql_connection)) { + + echo "Failed to connect to database: $database.
\n"; + echo "Error information: " . mysql_errno($mysql_connection) . " " . + mysql_error($mysql_connection) . "
\n"; + exit; + +} + +$add_user = "SELECT * FROM users"; + +if (!$result = mysql_query($add_user, $mysql_connection)) { + + echo "An error occurred while retrieving user information.
\n"; + echo "Error information: " . mysql_errno($mysql_connection) . " " . + mysql_error($mysql_connection) . "
\n"; + exit; + +} + +$numRows = mysql_num_rows($result); + +for ($i = 0; $i < $numRows; $i++) { + + $row = mysql_fetch_array($result); + echo "username: " . $row["username"] . " (" . $row["realname"] . ")
\n"; + echo "email: " . $row["email"] . "
\n"; + echo "
"; + +} + +?> + + + diff --git a/chapter09.sit b/chapter09.sit new file mode 100644 index 0000000..b3a4e78 Binary files /dev/null and b/chapter09.sit differ diff --git a/chapter09/Chapter 09/flashblog files/FL08F2~1.FLA b/chapter09/Chapter 09/flashblog files/FL08F2~1.FLA new file mode 100644 index 0000000..3657a6e Binary files /dev/null and b/chapter09/Chapter 09/flashblog files/FL08F2~1.FLA differ diff --git a/chapter09/Chapter 09/flashblog files/ch09_flashblog_final.fla b/chapter09/Chapter 09/flashblog files/ch09_flashblog_final.fla new file mode 100644 index 0000000..0bb57f6 Binary files /dev/null and b/chapter09/Chapter 09/flashblog files/ch09_flashblog_final.fla differ diff --git a/chapter09/Chapter 09/flashblog files/ch09_flashblog_start.fla b/chapter09/Chapter 09/flashblog files/ch09_flashblog_start.fla new file mode 100644 index 0000000..981a0b7 Binary files /dev/null and b/chapter09/Chapter 09/flashblog files/ch09_flashblog_start.fla differ diff --git a/chapter09/Chapter 09/flashblog files/ch09_markup_start.fla b/chapter09/Chapter 09/flashblog files/ch09_markup_start.fla new file mode 100644 index 0000000..8319b94 Binary files /dev/null and b/chapter09/Chapter 09/flashblog files/ch09_markup_start.fla differ diff --git a/chapter09/Chapter 09/flashblog files/flashblog_ci_finish.fla b/chapter09/Chapter 09/flashblog files/flashblog_ci_finish.fla new file mode 100644 index 0000000..27798c3 Binary files /dev/null and b/chapter09/Chapter 09/flashblog files/flashblog_ci_finish.fla differ diff --git a/chapter09/Chapter 09/flashblog files/flashblog_ci_start.fla b/chapter09/Chapter 09/flashblog files/flashblog_ci_start.fla new file mode 100644 index 0000000..fb0c13c Binary files /dev/null and b/chapter09/Chapter 09/flashblog files/flashblog_ci_start.fla differ diff --git a/chapter09/Chapter 09/flashblog files/flashblog_hk_start.fla b/chapter09/Chapter 09/flashblog files/flashblog_hk_start.fla new file mode 100644 index 0000000..bf23de3 Binary files /dev/null and b/chapter09/Chapter 09/flashblog files/flashblog_hk_start.fla differ diff --git a/chapter09/Chapter 09/flashblog files/flashblog_hka_start.fla b/chapter09/Chapter 09/flashblog files/flashblog_hka_start.fla new file mode 100644 index 0000000..722e496 Binary files /dev/null and b/chapter09/Chapter 09/flashblog files/flashblog_hka_start.fla differ diff --git a/chapter09/Chapter 09/flashblog files/flashblog_mdm_start.fla b/chapter09/Chapter 09/flashblog files/flashblog_mdm_start.fla new file mode 100644 index 0000000..3e4f0a3 Binary files /dev/null and b/chapter09/Chapter 09/flashblog files/flashblog_mdm_start.fla differ diff --git a/chapter09/Chapter 09/flashblog files/flashblog_pi_start.fla b/chapter09/Chapter 09/flashblog files/flashblog_pi_start.fla new file mode 100644 index 0000000..24b4cc1 Binary files /dev/null and b/chapter09/Chapter 09/flashblog files/flashblog_pi_start.fla differ diff --git a/chapter09/Chapter 09/flashblog files/markup.fla b/chapter09/Chapter 09/flashblog files/markup.fla new file mode 100644 index 0000000..a60ace3 Binary files /dev/null and b/chapter09/Chapter 09/flashblog files/markup.fla differ diff --git a/chapter09/Chapter 09/flashblog files/markup.swf b/chapter09/Chapter 09/flashblog files/markup.swf new file mode 100644 index 0000000..896b4fb Binary files /dev/null and b/chapter09/Chapter 09/flashblog files/markup.swf differ diff --git a/chapter09/Chapter 09/flashblog files/markup2_start.fla b/chapter09/Chapter 09/flashblog files/markup2_start.fla new file mode 100644 index 0000000..807a1c6 Binary files /dev/null and b/chapter09/Chapter 09/flashblog files/markup2_start.fla differ diff --git a/chapter09/Chapter 09/flashblog files/markup_finish.fla b/chapter09/Chapter 09/flashblog files/markup_finish.fla new file mode 100644 index 0000000..9ab14ec Binary files /dev/null and b/chapter09/Chapter 09/flashblog files/markup_finish.fla differ diff --git a/chapter09/Chapter 09/flashblog files/markup_mdm_start.fla b/chapter09/Chapter 09/flashblog files/markup_mdm_start.fla new file mode 100644 index 0000000..c9dd9c2 Binary files /dev/null and b/chapter09/Chapter 09/flashblog files/markup_mdm_start.fla differ diff --git a/chapter09/Chapter 09/flashblog files/save_config.php b/chapter09/Chapter 09/flashblog files/save_config.php new file mode 100644 index 0000000..f3f676d --- /dev/null +++ b/chapter09/Chapter 09/flashblog files/save_config.php @@ -0,0 +1,166 @@ +false$str"; + exit; + +} + +// Ok, finished parsing the XML +xml_parser_free($parser); + +if (!isset($blogLimit) || $blogLimit == "") { + + echo "falseXML packet failed, the blog limit was null."; + exit; + +} else if (!isset($sessionID) || $sessionID == "") { + + echo "falseXML packet failed, there was no session id. Are you logged in?"; + exit; + +} else if (!isset($templatePath) || $templatePath == "") { + + echo "falseXML packet failed, the template path was undefined."; + exit; + +} else if (!isset($templateFilename) || $templateFilename == "") { + + echo "falseXML packet failed, the template filename was undefined."; + exit; + +} + +// Check to see if the user is logged in +if (!checkLogin($username, $sessionID)) { + + echo "falseYou are not logged in."; + exit; + +} + +// Write the information to config.xml +$content = "$blogLimit" . urldecode($templatePath) . "" . urldecode($templateFilename) . ""; + +$path = "/www/s/smebberson/htdocs/flashblog/XML"; +$filename = "/config.xml"; + +$fp = @fopen($path . $filename, "w"); +$write = @fwrite($fp, $content); + +if ($write == -1) { + + echo "falseFailed while writing config.xml."; + exit; + +} else { + + echo "trueThe configuration file was successfully updated."; + +} + +?> \ No newline at end of file diff --git a/chapter09/Chapter 09/flashblog files/save_post.php b/chapter09/Chapter 09/flashblog files/save_post.php new file mode 100644 index 0000000..01256cf --- /dev/null +++ b/chapter09/Chapter 09/flashblog files/save_post.php @@ -0,0 +1,213 @@ +false$str"; + exit; + +} + +// Ok, finished parsing the POST XML +xml_parser_free($parser); + +// Now load and parse the config.xml file +$configParser = xml_parser_create(); +xml_set_element_handler($configParser, "startElementHandler", "endElementHandler"); +xml_set_character_data_handler($configParser, "cdataHandler"); + +if (!$fp = @fopen("XML/config.xml", "r")) { + + echo "falseFailed to open the configuration file."; + exit; + +} + +while ($data = fread($fp, 4096)) { + + if (!xml_parse($configParser, $data, feof($fp))) { + + $err = "There was an error in the XML in line " . xml_get_current_line_number($configParser) . " at position " . xml_get_current_column_number($configParser); + + echo "false$err"; + exit; + + } +} + +if (!isset($username) || $username == "") { + + echo "falseThe user is not logged in."; + exit; + +} else if (!isset($time) || $time == "") { + + echo "falseThe time was missing."; + exit; + +} else if (!isset($subject) || $subject == "") { + + echo "falseThe subject was missing."; + exit; + +} else if (!isset($body) || $body == "") { + + echo "falseThe body was missing."; + exit; + +} else if (!isset($blogLimit) || $blogLimit == "") { + + echo "falseThere was an error in the configuration directives."; + exit; + +} + +$stmt = "INSERT INTO fb_posts (user_id, subject, body, timestamp) VALUES(1, '" . urldecode($subject) . "', '" . urldecode($body) . "', '$time')"; + +$result = @mysql_query($stmt, $db); + +if ($result == 0) { + + $str = echo "Error #" . mysql_errno($db) . ": " . mysql_error($db); + echo "falseDatabase update failed: " . $str . ""; + exit; + +} + +$stmt = "SELECT id FROM fb_posts ORDER BY id DESC LIMIT $blogLimit"; +$result = @mysql_query($stmt, $db); + +if ($result == 0) { + + $str = echo "Error #" . mysql_errno($db) . ": " . mysql_error($db); + echo "falseEntry was added, but the database failed while deleting old posts."; + exit; + +} + +$numRows = @mysql_num_rows($result); + +for ($i = 0; $i < $numRows; $i++) { + + $row = @mysql_fetch_array($result); + $lastID = $row['id']; + +} + +$stmt = "DELETE FROM fb_posts WHERE id < $lastID"; +$result = @mysql_query($stmt, $db); + +if ($result == 0) { + + echo "falseEntry was added, but the database failed while deleting old posts."; + exit; + +} + +echo "trueYour post was saved to the database."; + + +?> \ No newline at end of file diff --git a/chapter09/Chapter 09/graphics/Thumbs.db b/chapter09/Chapter 09/graphics/Thumbs.db new file mode 100644 index 0000000..39992c8 Binary files /dev/null and b/chapter09/Chapter 09/graphics/Thumbs.db differ diff --git a/chapter09/Chapter 09/graphics/bttn.png b/chapter09/Chapter 09/graphics/bttn.png new file mode 100644 index 0000000..2eba713 Binary files /dev/null and b/chapter09/Chapter 09/graphics/bttn.png differ diff --git a/chapter09/Chapter 09/graphics/config_title.png b/chapter09/Chapter 09/graphics/config_title.png new file mode 100644 index 0000000..c2bda72 Binary files /dev/null and b/chapter09/Chapter 09/graphics/config_title.png differ diff --git a/chapter09/Chapter 09/graphics/footer.png b/chapter09/Chapter 09/graphics/footer.png new file mode 100644 index 0000000..bdd4bc2 Binary files /dev/null and b/chapter09/Chapter 09/graphics/footer.png differ diff --git a/chapter09/Chapter 09/graphics/header.png b/chapter09/Chapter 09/graphics/header.png new file mode 100644 index 0000000..3edba7b Binary files /dev/null and b/chapter09/Chapter 09/graphics/header.png differ diff --git a/chapter09/Chapter 09/graphics/main_menu_title.png b/chapter09/Chapter 09/graphics/main_menu_title.png new file mode 100644 index 0000000..3786a5d Binary files /dev/null and b/chapter09/Chapter 09/graphics/main_menu_title.png differ diff --git a/chapter09/Chapter 09/graphics/nav_bar.png b/chapter09/Chapter 09/graphics/nav_bar.png new file mode 100644 index 0000000..79748e7 Binary files /dev/null and b/chapter09/Chapter 09/graphics/nav_bar.png differ diff --git a/chapter09/Chapter 09/graphics/new_post_title.png b/chapter09/Chapter 09/graphics/new_post_title.png new file mode 100644 index 0000000..bd79289 Binary files /dev/null and b/chapter09/Chapter 09/graphics/new_post_title.png differ diff --git a/chapter09/Chapter 09/graphics/read_posts_title.png b/chapter09/Chapter 09/graphics/read_posts_title.png new file mode 100644 index 0000000..e186e73 Binary files /dev/null and b/chapter09/Chapter 09/graphics/read_posts_title.png differ diff --git a/chapter09/Chapter 09/graphics/sm.bmp b/chapter09/Chapter 09/graphics/sm.bmp new file mode 100644 index 0000000..dbaef09 Binary files /dev/null and b/chapter09/Chapter 09/graphics/sm.bmp differ diff --git a/chapter09/Chapter 09/graphics/square_bttn.png b/chapter09/Chapter 09/graphics/square_bttn.png new file mode 100644 index 0000000..46541bb Binary files /dev/null and b/chapter09/Chapter 09/graphics/square_bttn.png differ diff --git a/chapter09/Chapter 09/tutorial files/PixelogicComponent.mxp b/chapter09/Chapter 09/tutorial files/PixelogicComponent.mxp new file mode 100644 index 0000000..31b4f85 Binary files /dev/null and b/chapter09/Chapter 09/tutorial files/PixelogicComponent.mxp differ diff --git a/chapter09/Chapter 09/tutorial files/access.php b/chapter09/Chapter 09/tutorial files/access.php new file mode 100644 index 0000000..55a7973 --- /dev/null +++ b/chapter09/Chapter 09/tutorial files/access.php @@ -0,0 +1,25 @@ + + + PHP Access logger + + + \n"; + + if (!$fp = fopen("access.log", "a")) { + exit("Failed to open access.log.
\n"); + } + + if (!fwrite($fp, $str)) { + exit("Failed to write to file.
\n"); + } + + fclose($fp); + echo "Accessed logged.
\n"; + + + ?> + + + diff --git a/chapter09/Chapter 09/tutorial files/messageBox_API.fla b/chapter09/Chapter 09/tutorial files/messageBox_API.fla new file mode 100644 index 0000000..f2bb898 Binary files /dev/null and b/chapter09/Chapter 09/tutorial files/messageBox_API.fla differ diff --git a/chapter09/Chapter 09/tutorial files/messageBox_parameters.fla b/chapter09/Chapter 09/tutorial files/messageBox_parameters.fla new file mode 100644 index 0000000..d0faf19 Binary files /dev/null and b/chapter09/Chapter 09/tutorial files/messageBox_parameters.fla differ diff --git a/chapter09/Chapter 09/tutorial files/progressBarPlus_finish.fla b/chapter09/Chapter 09/tutorial files/progressBarPlus_finish.fla new file mode 100644 index 0000000..e4d3da2 Binary files /dev/null and b/chapter09/Chapter 09/tutorial files/progressBarPlus_finish.fla differ diff --git a/chapter09/Chapter 09/tutorial files/progressBarPlus_start.fla b/chapter09/Chapter 09/tutorial files/progressBarPlus_start.fla new file mode 100644 index 0000000..f640cb6 Binary files /dev/null and b/chapter09/Chapter 09/tutorial files/progressBarPlus_start.fla differ diff --git a/chapter09/Chapter 09/tutorial files/viewer.php b/chapter09/Chapter 09/tutorial files/viewer.php new file mode 100644 index 0000000..12f436d --- /dev/null +++ b/chapter09/Chapter 09/tutorial files/viewer.php @@ -0,0 +1,18 @@ + + + PHP Access Log Reader + + + + \n"); + } + + fpassthru($fp); + + ?> + + + diff --git a/chapter10/Chapter 10/Graphics/Thumbs.db b/chapter10/Chapter 10/Graphics/Thumbs.db new file mode 100644 index 0000000..7bc9e6d Binary files /dev/null and b/chapter10/Chapter 10/Graphics/Thumbs.db differ diff --git a/chapter10/Chapter 10/Graphics/login_title.png b/chapter10/Chapter 10/Graphics/login_title.png new file mode 100644 index 0000000..f66827a Binary files /dev/null and b/chapter10/Chapter 10/Graphics/login_title.png differ diff --git a/chapter10/Chapter 10/Graphics/logout_title.png b/chapter10/Chapter 10/Graphics/logout_title.png new file mode 100644 index 0000000..20e39d6 Binary files /dev/null and b/chapter10/Chapter 10/Graphics/logout_title.png differ diff --git a/chapter10/Chapter 10/flashblog files/check_login.php b/chapter10/Chapter 10/flashblog files/check_login.php new file mode 100644 index 0000000..3eafeff --- /dev/null +++ b/chapter10/Chapter 10/flashblog files/check_login.php @@ -0,0 +1,132 @@ +falseXML packet was invalid. Please try again."; + exit; + +} + +// OK, finished parsing the XML +xml_parser_free($parser); + +// Query the database +$stmt = "SELECT session_id, user_type FROM fb_user WHERE username='$username'"; +$result = @mysql_query($stmt, $db); + +if ($result == 0) { + + echo "falseThis is a restricted area. You need to login before you can continue. Please enter your username and password."; + exit; + +} + +if (@mysql_num_rows($result) <= 0) { + + echo "falseThis is a restricted area. You need to login before you can continue. Please enter your username and password."; + return; + +} + +$row = @mysql_fetch_array($result); + +if ($row['session_id'] == $sessionID) { + + if ($level == "user") { + + echo "trueUser is logged in."; + exit; + + } + + if ($row['user_type'] != "administrator") { + + echo "falseYou must be an Administrator to edit FlashBlog's configuration."; + exit; + + } + + echo "trueUser is logged in."; + exit; + +} + +echo "falseThis is a restricted area. You need to login before you can continue. Please enter your username and password."; + +?> diff --git a/chapter10/Chapter 10/flashblog files/flashblog_li_start.fla b/chapter10/Chapter 10/flashblog files/flashblog_li_start.fla new file mode 100644 index 0000000..9b0f08b Binary files /dev/null and b/chapter10/Chapter 10/flashblog files/flashblog_li_start.fla differ diff --git a/chapter10/Chapter 10/flashblog files/flashblog_login_finish.fla b/chapter10/Chapter 10/flashblog files/flashblog_login_finish.fla new file mode 100644 index 0000000..53d1a6a Binary files /dev/null and b/chapter10/Chapter 10/flashblog files/flashblog_login_finish.fla differ diff --git a/chapter10/Chapter 10/flashblog files/flashblog_login_finish.swf b/chapter10/Chapter 10/flashblog files/flashblog_login_finish.swf new file mode 100644 index 0000000..c403b48 Binary files /dev/null and b/chapter10/Chapter 10/flashblog files/flashblog_login_finish.swf differ diff --git a/chapter10/Chapter 10/flashblog files/flashblog_logout_finish.fla b/chapter10/Chapter 10/flashblog files/flashblog_logout_finish.fla new file mode 100644 index 0000000..a956a22 Binary files /dev/null and b/chapter10/Chapter 10/flashblog files/flashblog_logout_finish.fla differ diff --git a/chapter10/Chapter 10/flashblog files/flashblog_logout_start.fla b/chapter10/Chapter 10/flashblog files/flashblog_logout_start.fla new file mode 100644 index 0000000..0f52bf1 Binary files /dev/null and b/chapter10/Chapter 10/flashblog files/flashblog_logout_start.fla differ diff --git a/chapter10/Chapter 10/flashblog files/flashblog_secure3_start.fla b/chapter10/Chapter 10/flashblog files/flashblog_secure3_start.fla new file mode 100644 index 0000000..f6c9fe6 Binary files /dev/null and b/chapter10/Chapter 10/flashblog files/flashblog_secure3_start.fla differ diff --git a/chapter10/Chapter 10/flashblog files/flashblog_secure_start.fla b/chapter10/Chapter 10/flashblog files/flashblog_secure_start.fla new file mode 100644 index 0000000..cf8ba9c Binary files /dev/null and b/chapter10/Chapter 10/flashblog files/flashblog_secure_start.fla differ diff --git a/chapter10/Chapter 10/flashblog files/login.php b/chapter10/Chapter 10/flashblog files/login.php new file mode 100644 index 0000000..6f846e7 --- /dev/null +++ b/chapter10/Chapter 10/flashblog files/login.php @@ -0,0 +1,131 @@ +falseXML packet was invalid. Please try again."; + exit; + +} + +// OK, finished parsing the XML +xml_parser_free($parser); + +// Query the database for the username and password +$result = @mysql_query("SELECT username, password FROM fb_user WHERE username='$username';", $db); + +// Check the query, send an error message if the query failed and then exit the script +if ($result == 0) { + + echo "falseThe username was incorrect. Please try again."; + exit; + +} + +// Check that at least one row was returned, if it wasn't, inform the SWF of an error +if (@mysql_num_rows($result) <= 0) { + + echo "falseThe username was incorrect. Please try again."; + exit; + +} + +// Retrieve the row from the database +$row = @mysql_fetch_array($result); + +// Compare the username and password from the XML to the username and password from the database +if ($password == $row['password']) { + + // Generate the session id - with username, password and time in an MD5 hash + $sessionID = md5($username . $password . microtime()); + + // Update the session_id field with the new session id + $result = @mysql_query("UPDATE fb_user SET session_id='$sessionID' WHERE username='$username';", $db); + + // Check the result + if ($result == 0) { + + // The database failed while updating the session id + echo "falseDatabase failed. Please try again."; + + } else { + + // All is OK, the user has now logged in + echo "trueYou've successfully logged in.$sessionID"; + + } + +} else { + + echo "falseThe password was incorrect. Please try again."; + +} + + +?> diff --git a/chapter10/Chapter 10/flashblog files/logout.php b/chapter10/Chapter 10/flashblog files/logout.php new file mode 100644 index 0000000..835ff90 --- /dev/null +++ b/chapter10/Chapter 10/flashblog files/logout.php @@ -0,0 +1,91 @@ +falseXML packet was invalid. Please try again."; + exit; + +} + +// Ok, finished parsing the XML, free the parser +xml_parser_free($parser); + +if ($username == "") { + + // The username didn't exist, but we need it to user in the query + echo "falseAn error occured while removing you from the system. Please close the browser window."; + exit; + +} + +// Update the database +$stmt = "UPDATE fb_user SET session_id=0 WHERE username='$username'"; +$result = @mysql_query($stmt, $db); + +// Check the query was successful +if ($result == 0) { + + // Query failed, return a message + echo "falseAn error occured while removing you from the system. Please close the browser window."; + exit; + +} + +// All is ok, the user has been logged out of the system +echo "trueYou've been logged out of the system."; + +?> \ No newline at end of file diff --git a/chapter10/Chapter 10/tutorial files/checkBox_final.fla b/chapter10/Chapter 10/tutorial files/checkBox_final.fla new file mode 100644 index 0000000..32fbb24 Binary files /dev/null and b/chapter10/Chapter 10/tutorial files/checkBox_final.fla differ diff --git a/chapter10/Chapter 10/tutorial files/checkBox_start.fla b/chapter10/Chapter 10/tutorial files/checkBox_start.fla new file mode 100644 index 0000000..e68ba74 Binary files /dev/null and b/chapter10/Chapter 10/tutorial files/checkBox_start.fla differ diff --git a/chapter10/Chapter 10/tutorial files/fonts_final.fla b/chapter10/Chapter 10/tutorial files/fonts_final.fla new file mode 100644 index 0000000..719e322 Binary files /dev/null and b/chapter10/Chapter 10/tutorial files/fonts_final.fla differ diff --git a/chapter10/Chapter 10/tutorial files/fonts_start.fla b/chapter10/Chapter 10/tutorial files/fonts_start.fla new file mode 100644 index 0000000..0194d60 Binary files /dev/null and b/chapter10/Chapter 10/tutorial files/fonts_start.fla differ diff --git a/chapter10/Chapter 10/tutorial files/shared_objects_final.fla b/chapter10/Chapter 10/tutorial files/shared_objects_final.fla new file mode 100644 index 0000000..eef31fb Binary files /dev/null and b/chapter10/Chapter 10/tutorial files/shared_objects_final.fla differ diff --git a/chapter10/Chapter 10/tutorial files/shared_objects_start.fla b/chapter10/Chapter 10/tutorial files/shared_objects_start.fla new file mode 100644 index 0000000..6c9c68b Binary files /dev/null and b/chapter10/Chapter 10/tutorial files/shared_objects_start.fla differ diff --git a/chapter11.sit b/chapter11.sit new file mode 100644 index 0000000..4e20ff8 Binary files /dev/null and b/chapter11.sit differ diff --git a/chapter11/Chapter 11/comments.xml b/chapter11/Chapter 11/comments.xml new file mode 100644 index 0000000..b6c1490 --- /dev/null +++ b/chapter11/Chapter 11/comments.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/chapter11/Chapter 11/drawing_curves.fla b/chapter11/Chapter 11/drawing_curves.fla new file mode 100644 index 0000000..5533834 Binary files /dev/null and b/chapter11/Chapter 11/drawing_curves.fla differ diff --git a/chapter11/Chapter 11/drawing_lines.fla b/chapter11/Chapter 11/drawing_lines.fla new file mode 100644 index 0000000..80a0305 Binary files /dev/null and b/chapter11/Chapter 11/drawing_lines.fla differ diff --git a/chapter11/Chapter 11/flash_images.fla b/chapter11/Chapter 11/flash_images.fla new file mode 100644 index 0000000..027ebb9 Binary files /dev/null and b/chapter11/Chapter 11/flash_images.fla differ diff --git a/chapter11/Chapter 11/flash_images_2.fla b/chapter11/Chapter 11/flash_images_2.fla new file mode 100644 index 0000000..82bbfa1 Binary files /dev/null and b/chapter11/Chapter 11/flash_images_2.fla differ diff --git a/chapter11/Chapter 11/loadtest.fla b/chapter11/Chapter 11/loadtest.fla new file mode 100644 index 0000000..285ffd5 Binary files /dev/null and b/chapter11/Chapter 11/loadtest.fla differ diff --git a/chapter11/Chapter 11/loadtest.swf b/chapter11/Chapter 11/loadtest.swf new file mode 100644 index 0000000..2606b87 Binary files /dev/null and b/chapter11/Chapter 11/loadtest.swf differ diff --git a/chapter11/Chapter 11/test.txt b/chapter11/Chapter 11/test.txt new file mode 100644 index 0000000..702027c --- /dev/null +++ b/chapter11/Chapter 11/test.txt @@ -0,0 +1 @@ +&message=Hello from the text file \ No newline at end of file diff --git a/contributing.md b/contributing.md new file mode 100644 index 0000000..f6005ad --- /dev/null +++ b/contributing.md @@ -0,0 +1,14 @@ +# Contributing to Apress Source Code + +Copyright for Apress source code belongs to the author(s). However, under fair use you are encouraged to fork and contribute minor corrections and updates for the benefit of the author(s) and other readers. + +## How to Contribute + +1. Make sure you have a GitHub account. +2. Fork the repository for the relevant book. +3. Create a new branch on which to make your change, e.g. +`git checkout -b my_code_contribution` +4. Commit your change. Include a commit message describing the correction. Please note that if your commit message is not clear, the correction will not be accepted. +5. Submit a pull request. + +Thank you for your contribution! \ No newline at end of file diff --git a/fdn_app.sit b/fdn_app.sit new file mode 100644 index 0000000..af004f0 Binary files /dev/null and b/fdn_app.sit differ diff --git a/fdn_app.zip b/fdn_app.zip new file mode 100644 index 0000000..93267bc Binary files /dev/null and b/fdn_app.zip differ