<?php

require_once './classes/cats.class.php';
$ts = new Cats($db);
#create form object
$cats = new Formitable($db, 'sionapros_categories');
$cats->forceTypes(array('id', 'value'), array('hidden', 'varchar'));
#custom labels
$cats->labelFields(array('value'), array('Category *'));
//set up regular expressions for field validation
$cats->registerValidation("required", ".+", "Field MUST be filled in please.");
//set up fields for validation using regexs above
$cats->validateField("value", "required");
$cats->uniqueField("value", "This Category Name Already Exists");
#set default values
$cats->setDefaultValue('id', $ts->getCatNo());
//set all output to be returned instead of printed
$cats->returnOutput = true;
if (!isset($_POST['submit']) || isset($_POST['submit']) && $cats->submitForm(false) == -1) {
    $catsForm = $cats->printForm();
    $smarty->assign('cats', $catsForm);
} else {
    #$smarty->assign('client_no', $client_no);
    #submit msg
    $smarty->assign('updateMsg', $cats->submitMsg);
    #$content	= $smarty->fetch( "./main/allergy/reg_allergy_group.tpl.html" );
    #unset prevPath
    unset($_SESSION['prevPath']);
}
$content = $smarty->fetch("./cats/main.reg_category.tpl.html");
<?php

require_once './classes/admin.class.php';
$admin = new Admin($db);
#create form object
$opt = new Formitable($db, 'sionapros_pubs');
$opt->forceTypes(array('doc', 'id', 'category'), array('file', 'hidden', 'select'));
#custom labels
$opt->labelFields(array('title', 'doc', 'category', 'pub_date'), array('Document Title *', 'Upload File *', 'Category *', 'Publication Date *'));
//set up regular expressions for field validation
$opt->registerValidation("required", ".+", "Field MUST be filled in please.");
$opt->setDateField('pub_date');
//set up fields for validation using regexs above
$opt->validateField("title", "required");
$opt->validateField("doc", "required");
$opt->validateField("category", "required");
$opt->validateField("pub_date", "validateDate");
#set default value
$opt->setDefaultValue('id', $admin->getId($opt->table));
#set normalized
$opt->normalizedField('category', 'sionapros_categories', 'id', 'value', 'id ASC');
//set all output to be returned instead of printed
$opt->returnOutput = true;
if (isset($_FILES)) {
    //path to upload to (with trailing slash)
    $path = "./docs/";
    //array of filetypes to check against
    $filetypes = array("png", "jpeg", "gif", "PNG", "JPEG", "GIF", "jpg", "JPG", "pdf", "PDF", "ps", "PS");
    //should file be include(ed) or exclude(ed) to be acceptable?
    $filemode = "exclude";
    foreach ($_FILES as $key => $value) {
$profile->getRecord($res[0]['identifier']);
#hide primary key field
$profile->hideField('identifier');
#customiszing form
$profile->hideField('reg_date');
$profile->hideField('identifier');
$profile->hideField('username');
$profile->hideField('password');
$profile->hideField('change_password');
$profile->hideFields(array('account_status'));
#custom labels
$profile->labelFields(array('firstname', 'lastname'), array('First Name *', 'Last Name *'));
//set up regular expressions for field validation
$profile->registerValidation("required", ".+", "Input is required.");
//set up fields for validation using regexs above
$profile->validateField("firstname", "required");
$profile->validateField("lastname", "required");
#set default values
#submit msg
$profile->msg_updateSuccess = "Your Profile was updated successfully.";
//set all output to be returned instead of printed
$profile->returnOutput = true;
//test for last page and no errors to submit form, otherwise start form
if (@$_POST['formitable_multipage'] != "end" || isset($profile->errMsg)) {
    $profileOpen = $profile->openForm();
    $smarty->assign('profileOpen', $profileOpen);
} else {
    $profile->submitForm(false);
}
//first page - test for no submit OR errors set with a field on the first page
if (!isset($_POST['submit']) || isset($profile->errMsg) && isset($_POST['firstname'])) {
$staff->setEncryptionKey("g00D_3nCr4p7");
#set identifier field
$staff->setIdentifier('identifier');
#unique username
$staff->uniqueField('username', "This Username already exists");
$staff->forceTypes(array('identifier', 'password', 'reg_date'), array('hidden', 'password', 'hidden'));
$staff->forceTypes(array('change_password', 'account_status'), array('hidden', 'hidden'));
#custom labels
$staff->labelFields(array('firstname', 'lastname'), array('First Name *', 'Last Name *'));
$staff->labelFields(array('username', 'password'), array('User Name *', 'Password *'));
//set up regular expressions for field validation
$staff->registerValidation("required", ".+", "Field MUST be filled in please.");
#$staff->setDateField('account_expiry_date');
$staff->setPasswordField('password');
//set up fields for validation using regexs above
$staff->validateField("firstname", "required");
$staff->validateField("lastname", "required");
$staff->validateField("username", "required");
$staff->validateField("password", "required");
#set default values
$staff->setDefaultValue('reg_date', date("Y-m-d H:i:s"));
$staff->setDefaultValue('change_password', 'Yes');
$staff->setDefaultValue('account_status', 'Active');
//set all output to be returned instead of printed
$staff->returnOutput = true;
//test for last page and no errors to submit form, otherwise start form
if (@$_POST['formitable_multipage'] != "end" || isset($staff->errMsg)) {
    $staffOpen = $staff->openForm();
    $smarty->assign('staffOpen', $staffOpen);
} else {
    $staff->submitForm(false);
<?php

require_once './classes/security.class.php';
$security = new Security($db);
#create form object
$sec = new Formitable($db, 'sionapros_profiles');
$sec->forceTypes(array('profile_id'), array('hidden'));
#custom labels
$sec->labelField('profile', 'Profile Name *');
$sec->labelField('remarks', 'Remarks i.e Describe the Profile');
//set up regular expressions for field validation
$sec->registerValidation("required", ".+", "Field MUST be filled in please.");
//set up fields for validation using regexs above
$sec->validateField("profile", "required");
$sec->validateField("remarks", "required");
$sec->uniqueField("profile", "This Profile Name Already Exists");
#set default values
$sec->setDefaultValue('profile_id', $security->getProfileId());
#submit msg
$sec->msg_insertSuccess = "A new profile called {$_POST['profile']} was created.";
//set all output to be returned instead of printed
$sec->returnOutput = true;
if (!isset($_POST['submit']) || isset($_POST['submit']) && $sec->submitForm(false) == -1) {
    $secForm = $sec->printForm();
    $smarty->assign('sec', $secForm);
} else {
    $smarty->assign('updateMsg', $sec->submitMsg);
    #unset prevPath
    unset($_SESSION['prevPath']);
}
$content = $smarty->fetch("./security/tm0.security.create_profile.tpl.html");
Example #6
0
$newForm->hideField("ID");
$newForm->forceTypes(array("foods", "day_of_week"), array("checkbox", "radio"));
//get data pairs from another table
$newForm->normalizedField("toon", "formitable_toons", "ID", "name", "pkey ASC");
//set custom field labels
$newForm->labelFields(array("f_name", "l_name", "description", "pets", "foods", "color", "day_of_week", "b_day", "toon"), array("First Name", "Last Name", "About Yourself", "Your Pets", "Favorite Foods", "Favorite Color", "Favorite Day", "Your Birthday", "Favorite Cartoon"));
//set some default values
$newForm->setDefaultValue("pets", "Dog");
$newForm->setDefaultValue("color", "Blue");
$newForm->setDefaultValue("toon", "3");
$newForm->setDefaultValue("foods", "pizza,salad");
$newForm->setDefaultValue("day_of_week", date("l"));
//set up regular expressions for field validation
$newForm->registerValidation("required", ".+", "Input is required.");
//set up a field for validation using regex above
$newForm->validateField("f_name", "required");
//set validation feedback mode
$newForm->feedback = "both";
//retrieve a record for update if GET var set
if (isset($_GET['ID'])) {
    $newForm->getRecord($_GET['ID']);
}
//call submit method if form has been submitted
if (!isset($_POST['submit']) || isset($_POST['submit']) && $newForm->submitForm() == -1) {
    $newForm->printForm();
}
?>

</div>

</center>
$id = $_REQUEST['id'];
#$faq = new Allergy($db);
#create form object
$faq = new Formitable($db, 'sionapros_faqs');
$faq->setPrimaryKey('id');
$faq->getRecord($id);
$faq->forceTypes(array('id', 'done_by', 'reg_date', 'category'), array('hidden', 'hidden', 'hidden', 'select'));
#custom labels
$faq->labelFields(array('faq_qn', 'faq_ans', 'category'), array('Question *', 'Answer *', 'Category *'));
//set up regular expressions for field validation
$faq->registerValidation("required", ".+", "Field MUST be filled in please.");
//set up fields for validation using regexs above
$faq->registerValidation("required", ".+", "Field MUST be filled in please.");
//set up fields for validation using regexs above
$faq->validateField("faq_qn", "required");
$faq->validateField("faq_ans", "required");
$faq->validateField("category", "required");
#set default values
$faq->setDefaultValue('done_by', $_SESSION['loginUsername']);
#normalized field
$faq->normalizedField("category", "sionapros_categories", "id", "value", "id ASC");
//set all output to be returned instead of printed
$faq->returnOutput = true;
if (!isset($_POST['submit']) || isset($_POST['submit']) && $faq->submitForm(false) == -1) {
    $faqForm = $faq->printForm();
    $smarty->assign('faq', $faqForm);
} else {
    $smarty->assign('updateMsg', $faq->submitMsg);
    #unset prevPath
    unset($_SESSION['prevPath']);
$staff->getRecord($_SESSION['upd_no']);
#hide primary key field
$staff->hideField('identifier');
#customiszing form
$staff->hideField('reg_date');
$staff->hideField('identifier');
$staff->hideField('username');
$staff->hideField('password');
$staff->forceTypes(array('account_status', 'change_password'), array('select', 'select'));
#custom labels
$staff->labelFields(array('firstname', 'lastname'), array('First Name *', 'Last Name *'));
$staff->labelFields(array('account_status', 'change_password'), array('Account Status *', 'Change Password *'));
//set up regular expressions for field validation
$staff->registerValidation("required", ".+", "Field MUST be filled in please.");
//set up fields for validation using regexs above
$staff->validateField("firstname", "required");
$staff->validateField("lastname", "required");
$staff->validateField("change_password", "required");
$staff->validateField("account_status", "required");
#$staff->validateField("country", "required");
#submit msg
$nmSQL = "SELECT firstname,lastname FROM sionapros_users WHERE identifier = {$_SESSION['upd_no']}";
$nm = $db->execute($nmSQL);
$staff->msg_updateSuccess = "{$nm[0]['firstname']} {$nm[0]['lastname']}'s account data was changed.";
//set all output to be returned instead of printed
$staff->returnOutput = true;
//test for last page and no errors to submit form, otherwise start form
if (@$_POST['formitable_multipage'] != "end" || isset($staff->errMsg)) {
    $staffOpen = $staff->openForm();
    $smarty->assign('staffOpen', $staffOpen);
} else {
#set primary key field
$news->setPrimaryKey('news_no');
$news->setEncryptionKey("eoeeuye_eeeoi");
$news->getRecord($news_no);
$news->forceType('news_no', 'hidden');
$news->forceType('photo', 'hidden');
$news->forceType('category', 'select');
$news->hideFields(array('photo_desc', 'reg_date', 'username'));
$news->setDateField('pub_date');
#$news->forceTypes(array('status'), array('select'));
#custom labels
$news->labelFields(array('title', 'summary', 'detail', 'category', 'pub_date'), array('Title *', 'News Summary*', 'Details *', 'Category *', 'Publication Date *'));
//set up regular expressions for field validation
$news->registerValidation("required", ".+", "Field MUST be filled in please.");
//set up fields for validation using regexs above
$news->validateField("title", "required");
$news->validateField("summary", "required");
$news->validateField("category", "required");
$news->validateField("pub_date", "validateDate");
$news->normalizedField("category", "sionapros_categories", "id", "value", "id ASC");
//set all output to be returned instead of printed
$news->returnOutput = true;
if (!isset($_POST['submit']) || isset($_POST['submit']) && $news->submitForm(false) == -1) {
    $newsForm = $news->printForm();
    $smarty->assign('news', $newsForm);
} else {
    #unset prevPath
    unset($_SESSION['prevPath']);
    header("Location: ./index.php?path=./main/news/tm0.news.preview_news.php&news_no={$news->pkeyID}");
    exit;
}
} else {
    $smarty->assign('secMsg', 'Not Allowed');
}
#create form object
$news = new Formitable($db, 'sionapros_news');
$news->setPrimaryKey('news_no');
#set encryption key
$news->setEncryptionKey("eoeeuye_eeeoi");
$news->getRecord($_SESSION['news_no']);
$news->forceTypes(array('news_no', 'photo', 'title', 'summary', 'details', 'username', 'reg_date', 'category', 'pub_date'), array('hidden', 'file', 'hidden', 'hidden', 'hidden', 'hidden', 'hidden', 'hidden', 'hidden'));
#custom labels
$news->labelFields(array('photo', 'photo_desc'), array('Upload A Photo *', 'Short Photo Description *'));
//set up regular expressions for field validation
$news->registerValidation("required", ".+", "Field MUST be filled in please.");
//set up fields for validation using regexs above
$news->validateField("photo", "required");
$news->validateField("photo_desc", "required");
#set default values
$news->setDefaultValue('news_no', $_SESSION['news_no']);
#submit msg
$news->msg_updateSuccess = "A photo for a news article was uploaded.";
//set all output to be returned instead of printed
$news->returnOutput = true;
if (isset($_FILES)) {
    //path to upload to (with trailing slash)
    $path = "./photos";
    //array of filetypes to check against
    $filetypes = array("png", "jpeg", "gif", "PNG", "JPEG", "GIF", "jpg", "JPG");
    //should file be include(ed) or exclude(ed) to be acceptable?
    $filemode = "exclude";
    foreach ($_FILES as $key => $value) {
$newForm->normalizedField("gender", "field_data", "ID", "name", "ID ASC", "type='gender'");
$newForm->normalizedField("WkDays", "field_data", "ID", "name", "ID ASC", "type='days'");
$newForm->normalizedField("StateCode", "states", "Code", "Name", "Name ASC");
//set custom field labels
$newForm->labelFields(array("FName", "MName", "LName", "UserType", "FindUs", "NewsLetter", "volunteer", "Donation", "NamePosted", "WkDays", "PostalCode", "StateCode", "TelePhone", "Mobile", "Facsimile", "Details"), array("First Name", "Middle Name", "Last Name", "I am a", "How did you find us?", "Subscribe to our newsletter?", "I want to Volunteer", "I would like to donate", "Add name to Sponsors page?", "I can work these days", "Zip Code", "State", "Home Phone", "Cell Phone", "FAX", "Personal Message"));
$newForm->labelField("Password_verify", "Verify Password");
//don't output field sets (<fieldset> tag)
#$newForm->fieldSets=false;
//set up regular expressions for field validation
$newForm->registerValidation("required", ".+", "Input is required.");
$newForm->registerValidation("valid_email", '^[a-zA-Z0-9_]{2,50}@[a-zA-Z0-9\\-]+\\.[a-zA-Z0-9\\-\\.?]+$', "Invalid email address.");
$newForm->registerValidation("uspostal", "^[0-9]{5}(-?[0-9]{4})?\$", "Invalid US Postal Code.");
$newForm->registerValidation("currency_us", "^([0-9]+(\\.[0-9]{2})?)?\$", "Use dollar amount only.");
$newForm->registerValidation("six_chars", ".{6,}", "Enter at least six characters.");
//set up fields for validation using regexs above
$newForm->validateField("FName", "required");
$newForm->validateField("Email", "valid_email");
$newForm->validateField("Donation_Amount", "currency_us");
$newForm->validateField("Password", "six_chars");
//require the email field to be unique in the database (doesn't already exist)
$newForm->uniqueField("Email", "Email is already registered.");
print_r($newForm->validate);
//set custom success message for update (after last page)
$newForm->msg_updateSuccess = "<center><div style=\"width:455; padding:15px; background-color:#F1F3F3;\">\n<p>Registration is now complete. Thanks for joining!</p></div></center>";
//set an encryption key so the record ID is encrypted to prevent tampering
$newForm->setEncryptionKey("g00D_3nCr4p7");
//retrieve record if get ID or post pkeyID
if (isset($_GET['ID'])) {
    $newForm->getRecord($_GET['ID']);
} else {
    if (isset($_POST['pkey'])) {
$staff->setPrimaryKey('id');
#set encryption key
$staff->setEncryptionKey("g00D_3nCr4p7");
#set identifier field
$staff->setIdentifier('id');
#unique username
$staff->uniqueField('email', "This Email Address already exists");
$staff->forceTypes(array('id'), array('hidden'));
#custom labels
$staff->labelFields(array('fname', 'lname', 'email'), array('First Name *', 'Last Name *', 'Email Address *'));
//set up regular expressions for field validation
$staff->registerValidation("required", ".+", "Field MUST be filled in please.");
#$staff->setDateField('account_expiry_date');
$staff->setPasswordField('password');
//set up fields for validation using regexs above
$staff->validateField("firstname", "required");
$staff->validateField("lastname", "required");
$staff->validateField("email", "required");
//set all output to be returned instead of printed
$staff->returnOutput = true;
//test for last page and no errors to submit form, otherwise start form
if (@$_POST['formitable_multipage'] != "end" || isset($staff->errMsg)) {
    $staffOpen = $staff->openForm();
    $smarty->assign('staffOpen', $staffOpen);
} else {
    $staff->submitForm(false);
}
//first page - test for no submit OR errors set with a field on the first page
if (!isset($_POST['submit']) || isset($staff->errMsg) && isset($_POST['firstname'])) {
    #print first page
    $page1 = "page 1";
$security = new Security($db);
$result = $security->profileObjects($objectpath);
if (count($result) == 0) {
    $assignedTo = 'NONE';
}
#create form object
$sec = new Formitable($db, 'sionapros_object_profile');
$sec->forceTypes(array('object'), array('hidden'));
$sec->skipFields(array('activefolder', 'filename'));
$sec->normalizedField('profile_id', 'sionapros_profiles', 'profile_id', 'profile', 'profile_id ASC');
#custom labels
$sec->labelField('profile_id', 'Profile *');
//set up regular expressions for field validation
$sec->registerValidation("required", ".+", "Field MUST be filled in please.");
//set up fields for validation using regexs above
$sec->validateField("profile_id", "required");
#set default values
$sec->setDefaultValue('object', $objectpath);
$nmSQL = "SELECT profile FROM sionapros_profiles WHERE profile_id = {$_POST['profile_id']}";
$nm = $db->execute($nmSQL);
$sec->msg_insertSuccess = "The object {$objectpath} is now only accessible to users under the {$nm[0]['profile']} profile.";
//set all output to be returned instead of printed
$sec->returnOutput = true;
$smarty->assign('msg', $msg);
$smarty->assign('assignedTo', $assignedTo);
$smarty->assign('result', $result);
$smarty->assign('objectpath', $objectpath);
if (!isset($_POST['submit']) || isset($_POST['submit']) && $sec->submitForm(false) == -1) {
    $secOpen = $sec->openForm();
    $smarty->assign('secOpen', $secOpen);
    $objectId = $sec->printField('object');