COLLABORATOR CHANNELS
YOUCOURSE - COURSES FROM BEST UNIVERSITYS IN THE WORLD - https://www.youtube.com/@YouCourse
ARQUITECTURAS - ARCHITECTURE CHANNEL, DOCUMENTALS AND MORE - https://www.youtube.com/@ArquitecturasYT
CADESIGNERS - SOFTWARE CHANNEL AND MODELS - https://www.youtube.com/@CADesigners
UNDERGROUND - Subscribe! Free Music - Creative Commons - https://www.youtube.com/@UndergroundMC
FACEBOOK GROUPS
ARQUITECTURAS - ARCHITECTURE CHANNEL - https://www.facebook.com/groups/arquitecturasyt
YOUCOURSE - COURSES FROM BEST UNIVERSITYS IN THE WORLD - https://www.facebook.com/groups/youcourse/
CADESIGNERS - SOFTWARE DESIGN CHANNEL - https://www.facebook.com/groups/cadesignersyt
UNDERGROUND - Free Music - Creative Commons - https://www.facebook.com/groups/undergroundyt
Facebook - https://www.facebook.com/YouCourseYT
Twitter - https://twitter.com/YouCourseYT
Tik Tok - https://www.tiktok.com/@youcourseyt
Kwai - YouCourse - @yourcourse
Thank's For Support!
University of Michigan
The mission of the University of Michigan is to serve the people of Michigan and the world through preeminence in creating, communicating, preserving and applying knowledge, art, and academic values, and in developing leaders and citizens who will challenge the present and enrich the future.
About this Specialization
This Specialization is an introduction to building web applications for anybody who already has a basic understanding of responsive web design with JavaScript, HTML, and CSS. Web Applications for Everybody is your introduction to web application development. You will develop web and database applications in PHP, using SQL for database creation, as well as functionality in JavaScript, jQuery, and JSON.
Over the course of this Specialization, you will create several web apps to add to your developer portfolio. This Specialization (and its prerequisites) will prepare you, even if you have little to no experience in programming or technology, for entry level web developer jobs in PHP.
You’ll demonstrate basic concepts, like database design, while working on assignments that require the development of increasing challenging web apps. From installing a text editor to understanding how a web browser interacts with a web server to handling events with JQuery, you’ll gain a complete introductory overview of web application development.
About this Course
In this course, you'll explore the basic structure of a web application, and how a web browser interacts with a web server. You'll be introduced to the request/response cycle, including GET/POST/Redirect. You'll also gain an introductory understanding of Hypertext Markup Language (HTML), as well as the basic syntax and data structures of the PHP language, variables, logic, iteration, arrays, error handling, and superglobal variables, among other elements. An introduction to Cascading Style Sheets (CSS) will allow you to style markup for webpages. Lastly, you'll gain the skills and knowledge to install and use an integrated PHP/MySQL environment like XAMPP or MAMP.
Assignment Specification: Request-Response Cycle
The title tag must contain your name or the string indicated by the autograder.
Autograder: HyperText Markup Language (HTML)
You will build and submit a valid HTML page that passes the W3C HTML Validator at https://validator.w3.org/nu/ that has your name in the title tag.
HTML Sample Code (Browse)
HTML Sample Code (Download)
Other Resources
Please install the Web Developer Toolkit for your browser from Chris Pedrick and know how to use it to disable CSS styles.
CSS Sample Code (Browse)
CSS Sample Code Zip (Download)
Take this file and copy/paste the contents into index.htm. Do not edit this file.
Take this file and copy/paste the contents into blocks.css in the same folder as the above file.
Edit the blocks.css and add the CSS rules so the HTML file looks like the above image when you view the index.htm file in your browser
The four boxes have five pixel borders with different colors and five pixels of margin and padding. It is probably simplest to use fixed positioning to get the boxes to be "sticky" to the corners of the screen even when you resize. Make the boxes width be 25% so the width changes as you resize your browser.
Center the link at the top of the page. Use your developer console / inspect element feature of your browser to visit https://www.brainyquote.com/ and find the nav element as shown. There are 2 rules, the 1st starts with a color hint of #f, and the 2nd with #35. Use the full values for the colors and apply them to the link color & background in your index.htm.
Your CSS must pass the validator at: https://jigsaw.w3.org/css-validator
For this assignment you will submit
- Image (JPG or PNG) of your index.htm with the styling applied, not the HTML source code
- Image (JPG or PNG) of the source code of your blocks.css file
- Image (JPG or PNG) of your blocks.css passing the W3 CSS validator
- Image (JPG or PNG) of your browser viewing www.brainyquote.com with all styles turned off
- Image (JPG or PNG) of your browser at www.brainyquote.com inspecting the navigation element to find the colors used in the 2 rules as shown in the sample below for your link background and text colors. Remember to add these to the CSS before taking screenshot 1.
Using inspect element on the https://www.brainyquote.com/
In this page, you will install a programmer text editor, install a bundled all-in-one PHP/MySql application, and explore that application briefly.
You should only install 1 of these XAMPP or MAMP.
We have separate pages for each of the commonly used Operating Systems:
- Setting up the MAMP PHP/MySql Environment on a Macintosh
- Setting up the MAMP PHP/MySql Environment on a Windows
- Setting up the XAMPP PHP/MySql Environment in Microsoft Windows
Please note, MySQL Workbench is not supported for this specialization.
Note - You only need to install one of MAMP or XAMPP. Do not install both as they use the same port settings. They are both all-in-one installers for the same thing - Apache Web Server, MySQL, PHP, phpMyAdmin.
In this page, you will install a programmer text editor, install a bundled all-in-one PHP/MySql application, and explore that application briefly.
We have separate pages for each of the commonly used Operating Systems:
- Setting up the MAMP PHP/MySql Environment on a Macintosh
- Setting up the MAMP PHP/MySql Environment on a Windows
- Setting up the XAMPP PHP/MySql Environment in Microsoft Windows
A simple approach is to search for "How to install LAMP on Ubuntu" - put your variant of Linux in the search - You should find lots of pages. If we find good guides, we will list them here:
In this assignment you will install software that will be used during the course. This software includes a programming text editor and a PHP and MySQL Environment. Also as part of this assignment you will learn how to take screenshots and make them into images. The deliverables this the assignment are two peer-graded images of your running software.
If you follow the instructions carefully and look at the handouts and watch the podcasts, this assignment should be pretty straightforward and take less than an hour.
Note: As you install on Windows, you may be asked for permission to open ports or to allow an application through the firewall - say 'yes' to these dialog boxes if they are popping up when you first install or first start your PHP environment.
If you get stuck on this assignment - feel free to get assistance from anyone who can help. All we want is that you have successfully installed the software and can use it on your system. This is not intended as a difficult or challenging assignment.
You should practice taking a few screen shots on your computer and saving them as PNG or JPG files.
Install a programming text editor if you don't already have one. I recommend Atom, but you can use NotePad++ (Windows) or TextWrangler (Macintosh). You can use any editor you like but TextEdit (Mac), NotePad(Win), and Microsoft Word at *not* acceptable as program editors.
I suggest XAMPP for Windows and MAMP for Macintosh. They all function very similar. But all the course examples will be with MAMP and the course staff will be most familiar with problem arising when you use MAMP so if you choose another environment you should be prepared to do your own tech support.
Navigate to the phpMyAdmin application select the "SQL" tab and type
SELECT 'January 3, 2017'
Do not use the example date, 'January 3, 2017', replace it by the date you are taking the screen shot, press the "GO" button and then take a screen shot of the resulting page.
Following the instructions in the installation documents, make sure that display_errors = On in your php.ini file. Make the screen shot to show you did it as follows:
- For MAMP, go to the phpinfo page in your environment and scroll down until you can take a screen shot showing that your php.ini is correct and take a screen shot
- For XAMPP, go to Apache / Config and open the php.ini file and scroll down to show that display_errors = On and take a screen shot.
- For Linux, use any editor to open your php.ini file and take a screen shot showing display_errors = On.
Submit those two screen shots in the peer-graded assignment.
The first screen shot for the peer-graded portion of the assignment is the phpMyAdmin as follows:
Assignment Specification: Our First PHP Application
In this next assignment, your application will be a single index.php file with some elements in HTML and some elements in PHP. This also verifies that you can do basic HTML and know how to use the 'pre' tag as well as understand how to switch between PHP and HTML when writing a PHP script. Make sure to save your screen shots JPG or PNG files and keep them less than 1MB. You must include the URL bar in all of your screen shots and the software must be running in your PHP server (i.e. file:// urls will not be accepted)
- Your name must be in the <title> tag like 'Charles Severance PHP'
- There should be an <h1> tag with your name and text like 'Charles Severance PHP'
- You should use a <pre> tag to create ASCII art of the first letter of your name four spaces in from the left margin
- Your code should use PHP to compute the SHA256 of your name and print it out like the sample application. You must compute this in your index.php file. The PHP code to achieve this for 'Charles Severance' is:
- Open this file and copy-paste its contents into a file named fail.php in the same folder as your index.php. Do not alter this file - do not fix the mistake in the code in this file. The goal is to trigger an error to verify that we see errors in the browser.
- Open this file and copy-paste in the contents into a file named check.php in the same folder as your index.php. Do not alter this file - do not fix the mistake in the code in this file. The goal is to trigger an error to verify that we see errors in the browser.
You must run these files in your PHP server. Make a folder under your htdocs folder and then place your files in that folder. The htdocs folder is in different locations depending on your web server:
Windows XAMPP: c:\xampp\htdocs and MAMP: C:\MAMP\htdocs
MAC MAMP: /Applications/MAMP/htdocs
You may see other options without an htdocs folder, for different operating systems & applications, when an all-in-one installer like MAMP or XAMPP is not used, like Linux.
Ubuntu: /var/www
Raspberry Pi: /var/www/html
You can check the htdocs (a.k.a. DOCUMENT_ROOT) value for your server by scrolling down in your PHPInfo output. You may have changed a setting in your PHP server to move the DOCUMENT_ROOT to another location and that is OK as well.
Just make sure all the files are in a folder somewhere within DOCUMENT_ROOT and that all your testing uses localhost URLs like:
http://localhost:8888/wa4e/php/index.php
If you turn in screen shots with file URLs, like file://, /folder/file, or c:/folder/file, you will get zero points for the assignment.
What To Hand In
For this assignment you will hand in:
- Image of your application showing the URL bar and the rest of the output.
- Image of your application showing the URL bar and output of fail.php
- Image of your application showing the URL bar output of check.php
- Source code of your index.php
You can explore a sample solution for this problem at https://www.wa4e.com/solutions/php/
Please do your reviews of the other students submissions carefully. The actual points you award are less important than useful comments about what might be wrong and need fixing. You cannot re-submit your assignment unless the instructor allows you to resubmit.
The total number of points for this assignment is 10. You will get up to 5 points from your instructor. You will get up to 3 points from your peers. You will get 1 for each peer assignment you assess. You need to grade a minimum of 2 peer assignments. You can grade up to 5 peer assignments if you like.
Copyright Creative Commons Attribution 3.0 - Charles R. Severance
Starting with this assignment, some of the auto graders will need to contact your application to test it over the Internet. Since your computer normally has a firewall to block incoming connections from the Internet (a very good thing), we need a special program to temporarily "make a tunnel" through your firewall so the auto grader can contact the Apache server running on your local computer.
You can use NGrok to make this tunnel through your firewall. We provide documentation on how to use this application below as well as video walkthroughs both on YouTube and Coursera.
In this assignment you will write a simple guessing game in PHP. You will use a tunnel program like NGROK to turn in your assignment.
Assignment: https://www.wa4e.com/assn/guess/
Solution : https://www.wa4e.com/code/arrays/guess.php?guess=12
NGrok
NGrok is a tool to create temporary secure tunnels from a local server to the Internet. You will use this to submit this assignment to the autograder.
A Note on External Hosting:
External hosting may work for this assignment, however different hosts add scripts to code which may stop the assignment from being graded. It is recommended to use NGrok to submit assignments.
http://php.net/manual/en/function.sort.php
PHP - Variable Scope
http://php.net/manual/en/language.variables.scope.ph
http://php.net/manual/en/language.variables.superglobals.php
http://php.net/manual/en/function.array-key-exists.php
PHP - Modularity
https://github.com/csev/wa4e
Assignment Specification: Reversing an MD5 hash (password cracking)
In this next assignment, we'll build code to reverse an MD5 hash using a brute force technique where we simply 'forward hash' all possible combinations of characters in strings. This would be similar to a situation where an e-commerce site stored hashed passwords in its database and we somehow have gotten our hands on the database contents and we want to take the hashed password and determine the actual plaintext passwords.
This following is a list of people, and their hashed PIN values.
pin | hash_pin | |
|---|---|---|
csev@umich.edu | ???? | 0bd65e799153554726820ca639514029 |
nabgilby@umich.edu | ???? | aa36c88c27650af3b9868b723ae15dfc |
pconway@umich.edu | ???? | 1ca906c1ad59db8f11643829560bab55 |
font@umich.edu | ???? | 1d8d70dddf147d2d92a634817f01b239 |
collemc@umich.edu | ???? | acf06cdd9c744f969958e1f085554c8b |
The simplest brute force approach generally is done by writing a series of nested loops that go through all possible combinations of characters. This is one of the reasons that password policies specify that you include uppper case, lower case, numbers, and punctuation in passwords is to make brute force cracking more difficult. Significantly increasing the length of the password to something like 20-30 characters is a very good to make brute force cracking more difficult.
You can play with the 2 letter code version of this application at https://www.wa4e.com/code/crack/ and download a ZIP of the starter code at https://www.wa4e.com/code/crack.zip.
You can explore a sample solution using the 4 digit PIN at https://www.wa4e.com/solutions/crack/
Your application will take an MD5 value like "81dc9bdb52d04dc20036dbd8313ed055" (the MD5 for the string "1234") and check all combinations of four-digit "PIN" numbers to see if any of those PINs produce the given hash.
You will present the user with a form where they can enter an MD5 string and request that you reverse-hash the string. If you can reverse hash the string, print out the PIN:
PIN: 1234
If the string does not reverse hash to a four digit number simply put out a message like:
PIN: Not found
You must check all four-digit combinations. You must have the value as a string not as an integer. For this shows the right and wrong way to check the has for "1234":
$check = hash('md5', '1234'); // Correct - hashing a string
$check = hash('md5', 1234); // Incorrect - hashing an integer
You should also print out the first 15 attempts to reverse-hash including both the MD5 value and PIN that you were testing. You should also print out the elapsed time for your computation as shown in the sample application.Consistency Details
In order to make the assignments more consistent, please follow these technical guidelines:
- Put all of your code to do the cracking in your "index.php" so you can hand in one file. You can have other files (like in the sample solution) that you do not have to hand in.
- Name the form field where you pass the MD5 into your application "md5"
- Use the GET method on your form (i.e. not POST)
For this assignment you will hand in:
- A screen shot of one of the MD5's from the list above/in the spec that you can successfully crack. Include the URL of your page in the screen shot so we can see your GET parameter.
- One of the MD5's list above/in the spec does not crack. Using your code, figure out which MD5 in the list does *NOT* crack and show your application not finding the PIN for the MD5. Include the URL of your page in the screen shot so we can see your GET parameter.
- Source code of your index.php
Please review carefully. The actual points are less important than useful comments about what might be wrong and need fixing. You cannot re-submit your assignment unless the instructor allows you to resubmit.
This section is entirely optional and is here in case you want to explore a bit more deeply and test your code skillz.
Here are some possible improvements:
- For fun, crack all of the pins at the top of this document and figure out why each person chose their PIN.
- You can crack some but not all more complex hashed values using a site like: CrackStation.net. For fun, use this site to crack all the above hash values.
- Make your application test a more complex character set like, upper case letters, lower case letters, numbers, and common punctuation.
- Change the code so when it finds a match, it breaks out of all four of the nested loops. So if the PIN turned out to be 1234 it would only run that many times. Hint: Make a logical variable that you set to true when you get a match and then as soon as that becomes true, break out of the outer loops.
- Make your program handle longer strings - say six characters. At some point when you increase the number of characters and alphabet, it will take longer to reverse crack the string.
- Change the debug output to print an attempt every 0.1 second instead of only the first 15 attempts.
- Super Advanced: Make your program handle variable length strings - perhaps looking for a string from 3-7 characters long. At some point just making more nested loops produces too much code and you should switch to a more complex but compact approach that uses a few arrays and a while loop. But this can be tricky to construct and prone to infinite loops if you are not careful. This is probably best not attempted unless you have some background in Algorithms and Data Structures.
At some point you might run into a time out where PHP decides that your code is running too long and blows up your application. You can check the variable max_execution_time in your PHPInfo screen to see how many seconds PHP will let your code run before aborting it.
Copyright Creative Commons Attribution 3.0 - Charles R. Severance
http://www.wa4e.com/code/forms/form1.php
Using GET and POST with Forms
http://www.wa4e.com/code/forms/form3.php
HTML Input Types
http://www.wa4e.com/code/forms/more.php
HTML5 Input Types
http://www.wa4e.com/code/forms/html5.php
Processing Form Data and HTML Injection
http://www.wa4e.com/code/forms/form4.php
http://www.wa4e.com/code/forms/form5.php
Guessing Game
http://www.wa4e.com/code/forms/guess.php?guess=200
Model View Controller (MVC)
http://www.wa4e.com/code/forms/guess_mvc.php
The following modules will be helpful in understanding the aspects of PHP used in this application.
- Arrays
- Functions
- Forms and POST Data
Documentation on how one web page redirects to another in HTTP and PHP.
Documentation from PHP on how the header() function works.
NGROK - A tool to create temporary secure tunnels from a local server to the Internet. You will use this to submit this assignment to the autograder.
A Note on External Hosting:
- External hosting may work for this assignment, however different hosts add scripts to code which may stop the assignment from being graded. It is recommended to use ngrok to submit assignments.
You can begin by using the starter code for an incomplete/broken version of this application from: https://www.wa4e.com/code/rps.zip
You can play with the broken sample code at https://www.wa4e.com/code/rps/
You can explore a sample solution for this problem at https://www.wa4e.com/solutions/rps/
Requirements for the Login Screen
The login.php should be a login screen should present a field for the person's name (name="who") and their password (name="pass"). Your form should have a button labeled "Log In" that submits the form data using method="POST" (i.e. these should not be GET parameters).
The login screen needs to have some error checking on its input data. If either the name or the password field is blank, you should put up a message of the form:
User name and password are required
If the password is non-blank and incorrect, you should put up a message of the form:
Incorrect password
If there are errors, you should come back to the login screen (login.php) and show the error with blank input fields (i.e. don't carry over the values for name="who" and name="pass" fields from the previous post).
You are to use a "salted hash" for the password. The "plaintext" of the password is not to be present in your application source code except in comments. For this assignment, we will be using the following values for the salt and stored hash:
$salt = 'XyZzy12*_';
$stored_hash = '1a52e17fa899cf40fb04cfc42e6352f1';
Note that the sample code is using a different salted hash so you should change the sample code to use this hash.The stored_hash is the MD5 of the salt concatenated with the plaintext of php123 - which is the password. This is computed using the following PHP:
$md5 = hash('md5', 'XyZzy12*_php123');
In order to check an incoming password you must concatenate the salt plus password together and then run that through the hash() function and compare it to the stored_hash.
If the incoming password, properly hashed matches the stored stored_hash value, the user's browser is redirected to the game.php page with the user's name as a GET parameter using:
header("Location: game.php?name=".urlencode($_POST['who']));
In order to protect the game from being played without the user properly logging in, the game.php must first check the session to see if the user's name is set and if the user's name is not set in the session the game.php must stop immediately using the PHP die() function:
die("Name parameter missing");
To test, navigate to game.php manually without logging in - it should fail with "Name parameter missing".
If the user is logged in, they should be presented with a drop-down menu showing the options Rock, Paper, Scissors, and Test as well as buttons labeled "Play" and "Logout".
header('Location: index.php');
If the user selects, Rock, Paper, or Scissors and presses "Play", the game chooses random computer throw, and scores the game and prints out the result of the game:
Your Play=Paper Computer Play=Paper Result=Tie
The computation as to whether the user wins, loses, or ties is to be done in a function named check() that returns a string telling the user what happened:
// This function takes as its input the computer and human play
// and returns "Tie", "You Lose", "You Win" depending on play
// where "You" is the human being addressed by the computer
function check($computer, $human) {
...
return "Tie";
...
return "You Win";
...
return "You Lose";
...
}
The "Test" option requires that you write two nested for loops that tests all combinations of possible human and computer play combinations:
for($c=0;$c<3;$c++) {
for($h=0;$h<3;$h++) {
$r = check($c, $h);
print "Human=$names[$h] Computer=$names[$c] Result=$r\n";
}
}
The $names variable contains the strings "Rock", "Paper", and "Scissors" in this example. The output of this should look look as follows:This will allow you to make sure that your check() function properly handles all combinations of the possible plays properly without having to play for a long time as the computer makes random plays.
For this assignment you will hand in:
- A screen shot (with URL) of your login.php rejecting an incorrect password
- A screen shot (with URL) of your game.php correctly showing the 'Name parameter missing' error
- A screen shot (with URL) of your game.php doing a normal play with the computer making a choice other than Rock
- A screen shot (with URL) of your game.php doing a correct test run
- Source code of login.php
- Source code of game.php
Please review carefully. The most important aspect of peer-grading is useful comments about what might be wrong and need fixing. You cannot re-submit your assignment unless the instructor allows you to resubmit.
This section is entirely optional and is here in case you want to explore a bit more deeply and test your code skillz.
Here are some possible improvements:
- Instead of using a series of if-elseif-else statements in the check() function, try to compute the win/lose aspect of the game with a simple arithmetic computation using remainder operator ( % )
- Add some images to the output. Don't replace the required output with images - simply add some images to make it prettier.
In this assignment we will create a two page web application to play rock, paper, scissors http://en.wikipedia.org/wiki/Rock-paper-scissors - We will only allow logged in users to play the game.
Assignment: https://www.wa4e.com/assn/rps/















No hay comentarios:
Publicar un comentario