CS602 Final Examination
Instructions: Answer all questions as best you can. No partial credit will be awarded. Your solutions must function correctly. Each solution should be tested and include the tests you ran that validate your answer, unless the question does not need testing.
If you have questions during the exam time, email There will be no Zoom meeting during the exam.
. This question is worth 10 points
Copyright By PowCoder代写 加微信 powcoder
Demonstrate how you properly implement callbacks when opening and reading the contents of a simple text le using a route de ned as “/readTestFile. (Create a small text le with at least 2 sentences.) Use the console.log() to show your callback successfully reading in the le contents.
. This question is worth 10 points.
Fix any error(s) you see in the code. Do not simply delete lines of code. You need to x all the code. Deleting code is not the answer I am expecting.
. This question is worth 10 points.
Assume you have to create an route called, “/beginQuote.php”. Data will be stored using the session. Assume there are 2 values in the session:
sessionToken
Using PHP, show how you would get the values assigned to these parameters and assign them to local variables:
quote_v session_v
. This question is worth 10 points.
Using Node, show how you implement each of the following situations. You can use 3 source les to answer each part of this question.
Read in and console.log() these command line argument names and value (both the name and the value) that was used. Assume you have the following command line: node index.js –user=root –pswd=hackme123 — baseline=10 –max_mem=2048 –min_mem=1024
Find and console.log() the value that is assigned an environmental variable called “MAX_FILESIZE_LIMIT”. The value it has is: 1875
Discover the type of Operating System the Node process is running in and console.log() it.
. This question is worth 10 points.
Using PHP and Node, show how you properly send back JSON to an HTML client using these values below. I expect is see a .php le and a .js in your solution for this question.
Charles Summer
Website https://www.test.com
Not Disclosed
@copy; All Rights Reserved
. This question is worth 10 points.
Using a Socket API of your choice, create an application that will successfully broadcast anything sent in to all connected clients. Make sure all the clients see everyone’s messages. You should use incognito mode with multiple tabs to test it.
. This question is worth 10 points.
Show how you execute the following SQL statements using both Node and PHP using a de ned route called “http://localhost/ nal/exam/testSql” for Node and use “http://localhost/ nal/exam/testSql.php” for PHP.
Do not use the deprecated mysql_connect() or it’s related functions.
The SQL to use is: insert into users(email, password) values ‘test_pswd’)
. This question is worth 10 points.
Create a PHP interface called Executor.interface.php. It has one method, called execute(). No return value, no parameters. Create a PHP class called BatchExecutor.class.php that implements that interface. In the body of the implementing function, echo back “Executing batch commands. [systimestamp goes here]”
. This question is worth 10 points.
Show how you should handle SQL Injection with PHP. Assume a route exists called “/testInjection.php”. Ensure no user can submit data that has SQL tokens like these:
“select” “delete” “update” “insert”
When you evaluate the data and it does have one or more of these values, then immediately response with a status header code of 400 (Bad Request). Assume the data comes into the page with named POST data element of “userData”
. This question is worth 10 points.
Part 1. Using Express and MongoDB with Mongoose, create a web page that will send a string value to be saved in a MongoDB collection called “News”. The MongoDB collection is de ned below:
Part 2. Create a route that will update a document in your collection. You can update the caption or the article, but not the news_id.
news_id (int)
This the key to article
The MongoDB “News” Collection Schema caption (String)
article (String)
This is the caption that goes with the article
This is the article/news
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com