<?php filelink('Name of Link[/link/file.pdf]'); ?>
Filelink is a function built into the University Web Template core to standardize and facilite linking of non-web files. It can create links to local files or remote files, with some caveats. In addition to link text, it will automatically display the file type and size after the link.
Filelink only supports:
Bear in mind that filelink should only be used to create links to files you expect a visitor to download - it is not a way to create links to other web pages.
<?php filelink('Printable FAQs[/nursing/faq.pdf]'); ?>
Text on the webpage will look like this: [PDF]Printable FAQs(8KB PDF)
<?php filelink('Google Logo[http://www.google.com/intl/en/images/logo.gif]'); ?>
Text on the webpage will look like this: [GIF]Google Logo(8KB)
<?php Readfile($_SERVER['DOCUMENT_ROOT'] . '/link/common/page.html');?>
Readfile is a function that is used to share the contents of one file on multiple pages.
To use paste the shared content into a blank html page with no Smartbuilder code. We usually save this file in a folder called /common/ in the directory of the website that will be sharing the content. Next, in the content area of the Smartbuilder page you want to share this content, place the Readfile code.
To make sure that the modified date is updated on the Smartbuilder page every time the common page is changed place the $SCRIPTMTIME = filemtime($_SERVER['DOCUMENT_ROOT'] . '/link/common/page.html'); up in the Smartbuilder code. You can place it after $contentcolumns code.
Slideshow is a University Web Template core function designed to easily create a javascript-powered image 'rotater'.
<?php slideshow(' Image's Alt Text [ path to images ]{ navigation options } '); ?>
Where path_to_images is:
Navigation options may contain any combination of the following entries, in any order:
If both {images} and {text} are specified, {text} will be ignored.
A slidefile is a text file (with a .php or .smbl extension) that defines the slides in a slideshow. It is the only method available that supports captions.
You point to a slidefile the same way you'd point to a regular image: a root-relative path. If you wish to use a slidefile, it must be the first and only path provided to the slideshow function.
The contents of a slidefile are similar to the University Web Template $leftmenu definitions. A single line might look like this:
$slide[] = 'Me at the beach - look at that crazy seagull![/trips/oregon/images/seagull.jpg]';
This specifies a caption, and an image to go with it. Note that the $slides[] is mandatory - if you use a different name, or forget the [], it will not work. Any number of slides can be specified this way.
Given a directory /stuff/images/ that contains 5 images, the following code would create a slideshow of all the images inside it, with the alt text "My Slideshow", and VCR-style navigation buttons:
<?php slideshow('My Slideshow[/stuff/images/]{images}'); ?>
This example would create the same slideshow, with one extra picture (located at /other/images/image1.jpg), and using text-based navigation:
<?php slideshow('My Slideshow[/stuff/images/|/other/images/image1.jpg]{text}'); ?>
This code would create a slideshow using slides defined by a slidefile, rotating automatically, with image navigation:
<?php slideshow('My Slideshow[/stuff/slides.php]{images auto}'); ?>
<div class='floatright'> <?php slideshow('New Facilities[/office/facilities-update/images/]{images}'); ?></div>CAPTCHA (acronym for "Completely Automated Public Turing test to tell Computers and Humans Apart") means using distorted images, among other techniques, to prevent spam generation using web page forms.
The CAPTCHA element we have implemented in SMBL asks the person submitting a form to type in the letters they see in the distorted image before the form is submitted. Once a person submits a form it then sends them to the page where they have to type in the letters they see on the screen. This added feature prevents bots from automatically spamming through email forms.
Download a [ZIP] CAPTCHA contact form (2 KiB)
Below is the code you need to implement CAPTCHA into any SMBL form.
First insert the php code to initiate the session. This code also defines errors for invalid entries. See the example:
<?php
$_SERVER['SMARTEDIT'] = '';
ini_set('session.use_cookies', '1');
session_set_cookie_params ( 0 , '/' , '.mnsu.edu');
session_save_path('/tmp/captcha/');
session_start();
require_once($_SERVER['SMARTBUILDER']);
require_once($_SERVER['EMAILSENDER']);
define('ERROR_REQUIRES_VALUE', '<br /><span class="error eleven">Please specify</span>');
define('ERROR_INVALID_EMAIL', '<br /><span class="error eleven">Invalid email</span>');
define('ERROR_INVALID_LETTERS', '<br /><span class="error eleven">Letters only, please</span>');
define('ERROR_INVALID_NUMBERS', '<br /><span class="error eleven">Numbers only, please</span>');
define('ERROR_INVALID_TELEPHONE', '<br /><span class="error eleven">Invalid telephone: 555-555-5555</span>');
Next, insert the code to determine if the entered information is valid:
$postback = count($_POST) ? true : false;
$_POST=form_to_web_array($_POST);
if($postback == true) {
$names = array('firstname', 'firstname', 'lastname', 'lastname', 'email', 'email', 'comment', 'confirm');
$types = array('letters', 'required', 'letters', 'required', 'email', 'required', 'required', 'required');
$values = $_POST;
$results = ValidateControls($names, $types, $values);
$return = $results['return'];
$errors = $results['errors'];
}
$names and $types are parallel arrays containing information on every field in the form that needs to be specified or needs to be of one specific type. In the above code, for example, firstname is the ID of the textbox in the form where the user inputs his/her first name. This field is required, but it also must only contain letters. Therefore, the ID is listed in $names at one index (in this case, 0), and 'letters' is listed in the corresponding index in the array $types. firstname is then listed again, with 'required' in the corresponding index in $types.
This block of code is placed inside the previous if statement after the $errors line. It determines if the user has correctly entered the CAPTCHA letters. If they are correct, this code sends the information from the form to a file called message.smbl. This is then emailed to a specified receiver.
if ($_SESSION['php_captcha'] == strtoupper($_POST['confirm'])) {
if($return == true) {
$email = $_POST['email'];
ob_start();
eval(enable_blockprint('message.smbl'));
$message = ob_get_contents();
ob_end_clean();
SendEmail($email, 'webteam@mnsu.edu', 'Web Services Contact Form', $message);
}
}else{
$errors['confirm'] = "<span class='error eleven'>Please type in the right letters</span>";
}
SendEmail is a function with four parameters: $email, 'email_address', 'subject', and $message.
Contact forms usually have a section entitled "Relationship to MSU", which typically consists of four radio buttons. The last of these is named "Other", and when clicked, a textbox appears. The code that determines the visibility of this textbox is listed below. It is typically placed after the if($postback == true) if statement.
$bodyoptions='onload="javascript:document.getElementById(\'other\').checked ? document.getElementById(\'otherspecify\').style.visibility=\'visible\' : document.getElementById(\'otherspecify\').style.visibility=\'hidden\'"';
After the $bodyoptions section is the typical code for headers and left navigation:
$master='/folder_containing_master_file/';
$version=1;
$contentcolumns=1;
setup('header');
place('header');
place('menucolumn');
place('menucolumn-end');
place('content');
The code enabling the page to use the response.smbl file is shown below.
if(($_SESSION['php_captcha'] == strtoupper($_POST['confirm'])) && ($return == true)){
eval(enable_blockprint('response.smbl'));
}
else{
print<<<END
<!--CONTENT BELOW-->
The following is the code for a typical Contact Form.
<form id="mrcontact" method="post" action="/path_to_form/">
<div class="margin-bottom nopadding clearboth">
<input type="hidden" id="tagType" value="span" />
<p class="floatleft padding-right nomargin-top margin-bottom"><label for="firstname" class="bold">First name:</label><br />
<input type="text" id="firstname" name="firstname" value="{$_POST['firstname']}" style="width: 130px;" />{$errors['firstname']}</p>
<p class="floatleft padding-right nomargin-top margin-bottom"><label for="lastname" class="bold">Last name:</label><br />
<input type="text" id="lastname" name="lastname" value="{$_POST['lastname']}" style="width: 130px;" />{$errors['lastname']}</p>
<p class="floatleft clearright nomargin-top margin-bottom"><label for="email" class="bold">Email:</label><br />
<input type="text" id="email" name="email" value="{$_POST['email']}" style="width: 130px;" />{$errors['email']}</p>
</div>
<div class="margin-top nopadding clearboth">
<p class="nopadding"><strong>What's your relationship with MSU?</strong><br />
<input type="radio" name="status" value="Student" id="student" onclick="javascript:document.getElementById('otherspecify').style.visibility='hidden'" /><label for="student">Student</label>
<input type="radio" name="status" value="Alumni" id="alumni" onclick="javascript:document.getElementById('otherspecify').style.visibility='hidden'" /><label for="alumni">Alumni</label>
<input type="radio" name="status" value="Employee" id="employee" onclick="javascript:document.getElementById('otherspecify').style.visibility='hidden'" /><label for="employee">Employee</label>
<input type="radio" name="status" value="Other" id="other" onclick="javascript:document.getElementById('otherspecify').style.visibility='visible'" /><label for="other">Other</label><span id="otherspecify">:<input type="text" id="role" name="otherspecify" value="{$_POST['otherspecify']}" style="width: 130px;" /></span></p>
</div>
<div class="margin-top nopadding clearboth">
<p class="nopadding"><label for="comment" class="bold">Your comment or question:</label>{$errors['comment']}<br />
<textarea id="comment" name="comment" cols="36" rows="10" style="width: 424px;">{$_POST['comment']}</textarea></p>
</div>
This code is placed immediately before the "Submit" button.
<div class="margin-bottom nopadding clearboth">
<p><img src="/util/captcha/visual-captcha.php" alt="Visual CAPTCHA" /></p>
<p><a href="/util/captcha/audio-captcha.php">Can't see the image? Click for audible version</a></p>
</div>
<div class="margin-bottom nopadding clearboth">
<p class="floatleft padding-right margin-bottom"><label for="confirm" class="bold">Please type in the letters you see.</label><br />
<input type="text" id="confirm" name="confirm" value="{$_POST['confirm']}" style="width: 190px;" /> {$errors['confirm']}</p>
</div>
<div class="margin-bottom nopadding clearboth">
<input id="submit" type="submit" value="Submit" />
</div>
</form>
<!--CONTENT ABOVE-->
END;
}
place('content-end');
place('footer');
?>
The message.smbl file should be placed in the same folder as the form. This file contains the information that will be sent via email to the recipient specified in the SendEmail section of the form code. The message.smbl file should include all of the questions from the form, along with their corresponding answers. For example:
<p><strong>First name:</strong> {$values['firstname']}<br />
<strong>Last name:</strong> {$values['lastname']}<br />
<strong>Email:</strong> {$values['email']}<br />
<strong>At MSU:</strong> {$values['status']} {$values['otherspecify']}<br />
<strong>Comment:</strong> {$values['comment']}</p>
The response.smbl file should also be placed in the same folder as the form. This file displays after the form has been correctly filled out and submitted. Here is an example:
<h2>Form Submitted</h2>
<p><strong>First name:</strong> {$values['firstname']}<br />
<strong>Last name:</strong> {$values['lastname']}<br />
<strong>Email:</strong> {$values['email']}<br />
<strong>At MSU:</strong> {$values['status']} {$values['otherspecify']}<br />
<strong>Comment:</strong> {$values['comment']}</p>
<p class="gray1">Please do not reload this page to avoid duplicate messages.</p>