<?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: 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: Google Logo(8KB GIF)
<?php Readfile($_SERVER['DOCUMENT_ROOT'] . '/link/common/page.html');?>
Readfile is a function that is used to share the contents of one file on mulitple 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 everytime 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:
Note: 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 (initialism 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 that you use to start a template page. There are a few news lines that need to be added to the beginning. 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']);
$version=1;
$windowtitle='Contact Us - Minnesota State University, Mankato';
$headertitle='Contact Us';
$breadcrumbs='MSU[http://www.mnsu.edu/]^ Contact Us[/contact/]';
$contentcolumns=1;
$leftmenu[]='* Home[/home/]';
$leftmenu[]='*About[/about/]';
$leftmenu[]='*Contact Us[/contact/]{selected}';
$owner=Contact[/contact/]';
place('header');
place('menucolumn');
place('menucolumn-end');
place('content');
Next enter the if statements to determine which button was pushed and what should be done:
If the Submit button was pushed on the CAPTCHA page it will make sure the user typed in the right letters. If they did not type in the right letters it will display the CAPTCHA page with an error.
if (isset($_POST['send'])) {
if ($php_captcha == strtoupper($confirm)) {
do_send(); }
else {
$errors['confirm'] = "<span class='error eleven'>Please type in the right letters</span>";
do_present_verify(); }
} else {
If the Submit button was pushed on the form page it will verify that the person has entered in all the required fields and send them to the CAPTCHA page. If they have not entered in all the required fields it will display errors on the form.
if (isset($_POST['verify'])) {
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>');
$names = array('firstname', 'firstname', 'lastname', 'lastname', 'email', 'email', 'comment');
$types = array('letters', 'required', 'letters', 'required', 'email', 'required', 'required');
$values = $_POST;
$results = ValidateControls($names, $types, $values);
$return = $results['return'];
$errors = $results['errors'];
if($return) {
do_present_verify();
} else {
do_present_query($_GET['name']); }
} else {
If no button was pushed it will display the form.
if (!isset($_GET['name'])) {
do_present_query($_GET['name']);
} else {
do_present_query($_GET['name']);
}
}
}
Insert the place statements that end a template page.
place('content-end');
place('footer');
exit;
Next insert the functions that display the Form Submitted screen, the CAPTCHA screen, and the Form screen.
This function sends the form and displays a message that it was sent.
function do_send() {
$values = $_POST;
$email = $_POST['email'];
ob_start();
eval(enable_blockprint('message.smbl'));
$message = ob_get_contents();
ob_end_clean();
SendEmail2($email, 'firstname.lastname@mnsu.edu', 'Contact Form', $message);
print <<<EOF
<h2>Form Submitted</h2>
<p><strong>First name:</strong> {$values['firstname']}
<strong>Last name:</strong> {$values['lastname']}
<strong>Email:</strong> {$values['email']}
<strong>At MSU:</strong> {$values['status']} {$values['otherspecify']}
<strong>Comment:</strong> {$values['comment']}</p>
<p class="gray1">Please do not reload this page to avoid duplicate messages.</p>
EOF
;
}
This function displays the image with letters and a form field to type in those letters.
function do_present_verify() {
global $errors;
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$status = $_POST['status'];
$otherspecify = $_POST['otherspecify'];
$comment = $_POST['comment'];
print <<<EOF
<div>
<p><img src="http://{$URIHOST}/util/captcha/visual-captcha.php"alt="Visual CAPTCHA" /></p>
<p><a href="http://{$URIHOST}/util/captcha/audio-captcha.php">Can't see the image? Click for
audible version</a></p>
</div>
<hr/>
<form id="subscribe" method="post" action="/security/contact.php">
<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><input name="firstname" type="hidden" value="{$firstname}" />
<input name="lastname" type="hidden" value="{$lastname}" />
<input name="email" type="hidden" value="{$email}" />
<input name="status" type="hidden" value="{$status}" />
<input name="otherspecify" type="hidden" value="{$otherspecify}" />
<input name="comment" type="hidden" value="{$comment}" />
</div>
<p class="floatnone clearboth"><input name="send" type="submit" value="Submit" /></p>
</div>
EOF
;
}
Note: If you are trying to use CAPTCHA on a server besides www you will have change "http://{$URIHOST}" to the server you are on. An example would be if you were trying to use it on the SBS server the url linked to captcha would be "http://sbs.mnsu.edu/util/captcha/visual-captcha.php" and "http://sbs.mnsu.edu/util/captcha/audio-captcha.php"
This function displays the Form.
function do_present_query($icon) {
global $errors;
print <<<EOF
<h2>Contact Form</h2>
<form id="subscribe" method="post" action="/contact/">
<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>Whats your relationship with MSU?</strong><br />
<input type="radio" name="status" value="Student" id="student" /><label for="student">Student</label>
<input type="radio" name="status" value="Alumni" id="alumni" /><label for="alumni">Alumni</label>
<input type="radio" name="status" value="Employee" id="employee" /><label for="employee">Employee</label>
<input type="radio" name="status" value="Other" id="other" /><label for="other">Other</label>: <input type="text" id="role" name="otherspecify"
value="{$_POST['otherspecify']}" style="width: 130px;" /></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>
<input name="verify" type="submit" value="Submit" /></div>
</form>
EOF
;
}