<?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) {
<?php

#create form object
$staff = new Formitable($db, 'sionapros_users');
#set primary key field
$staff->setPrimaryKey('identifier');
#set encryption key
$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
<?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");
Пример #4
0
<br><br>
Don't forget to try <a href="<?php 
echo $_SERVER['PHP_SELF'];
?>
?ID=1">retrieving a record</a>.
</div>

<div class="boxed">
<?php 
/*** change the following variables ***/
$user = "******";
$pass = "******";
$DB = "database";
//include class, create new Formitable, set primary key field name
include "../Formitable.class.php";
$newForm = new Formitable(@mysql_connect("localhost", $user, $pass), $DB, "formitable_demo");
$newForm->setPrimaryKey("ID");
$newForm->setEncryptionKey("g00D_3nCr4p7");
//hide primary key field, force a few field types
$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"));
<?php

#create form object
$profile = new Formitable($db, 'sionapros_users');
#set primary key field
$profile->setPrimaryKey('identifier');
$profile->setEncryptionKey("EHm1C_3nCr4p7");
$persNoSQL = "SELECT identifier FROM sionapros_users WHERE username = '******'loginUsername']}'";
$res = $db->execute($persNoSQL);
#retrieve profile's data
$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
<?php

#get staff personnel_no
#$staff_no = $_GET['identifier'];
if (isset($_GET['identifier'])) {
    $_SESSION['upd_no'] = $_GET['identifier'];
}
#create form object
$staff = new Formitable($db, 'sionapros_users');
#set primary key field
$staff->setPrimaryKey('identifier');
$staff->setEncryptionKey("qHm1rC_3nCt4p7");
#retrieve staff's data
$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");
<?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");
<?php

#get the ward_no
$news_no = $_REQUEST['news_no'];
#create form object
$news = new Formitable($db, 'sionapros_news');
#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);
Пример #9
0
<?php

$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
<?php

if ($_GET['news_no']) {
    $_SESSION['news_no'] = $_GET['news_no'];
}
#check to see that the selected news article has no photo already uploaded
$SQL = "SELECT photo FROM sionapros_news WHERE news_no = '{$_SESSION['news_no']}'";
$photo = $db->execute($SQL);
if (count($photo) == 0) {
} 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
Пример #11
0
</title>
</head>
<body>
<div id="content">
<?php 
// Displays program record as a form (via Formitable), for editing and exporting to HTML
require_once 'conf.php';
session_start();
$admin = $_SESSION['admin'];
//include class, create new Formitable, set primary key field name
include "include/Formitable.class.php";
$myconn = mysql_connect($prDbhost, $prDbusername, $prDbpassword);
mysql_query("SET NAMES 'utf8'", $myconn);
mysql_query("SET CHARACTER SET 'utf8'", $myconn);
// initialize Formitable
$newForm = new Formitable($myconn, $prDbname, $prTable);
$newForm->setPrimaryKey("id");
// if form has been submitted, call Formitable submit method
if (isset($_POST['submit'])) {
    // if not admin, skip (don't update) the following fields
    if (!$admin) {
        $skipped = array('emails1', 'schnip', 'dimo', 'sch1', 'sch2');
        $newForm->skipFields($skipped);
    }
    $newForm->submitForm();
} else {
    //retrieve a record for update if GET var is set
    if (isset($_GET['id'])) {
        $newForm->getRecord($_GET['id']);
    } else {
        die("Error...(no get var)");
?>
?ID=1">retrieving a record</a>.
</td></tr></table>

<table align="center" cellpadding=5 style="border:1px solid #888888;">
<tr><td>

<?php 
require_once 'C:\\apachefriends\\xampp\\htdocs\\anyDB2\\examples\\connect.inc.php';
/*** change the following variables ***/
$user = "******";
$pass = "******";
$DB = "hesasys";
//include class, create new Formitable, set primary key field name
include "Formitable.class.php";
$newForm = new Formitable($db, "formitable_demo");
$newForm->setPrimaryKey("ID");
#$fields = $newForm->fields();
#$newForm->printField('f_name');
#echo $newForm->fields();
#print_r($fields);
#$i = 0;
#foreach ($fields as $field){
#	echo $newForm->getFieldType($i);
#	echo $newForm->getFieldLength($i).'<br>';
#	$i++;
#}
if (isset($_GET['ID'])) {
    $newForm->getRecord($_GET['ID']);
}
//call submit method if form has been submitted
<?php

$news = new Formitable($db, 'sionapros_news');
$news->forceTypes(array('news_no', 'reg_date', 'username', 'photo', 'photo_desc', 'category'), array('hidden', 'hidden', 'hidden', 'hidden', 'hidden', 'select'));
#custom labels
$news->labelFields(array('title', 'summary', 'detail', 'photo', 'pub_date'), array('Title *', 'News Summary*', 'Details *', 'Upload Photo', 'Publication Date *'));
$news->setDateField('pub_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("details", "required");
$news->validateField("category", "required");
$news->validateField("pub_date", "validateDate");
#set default values
#get news_No
$newsSQL = "SELECT MAX(news_no) FROM sionapros_news";
$result = $db->execute($newsSQL);
$id = $result[0];
$news_no = $id['MAX(news_no)'] + 1;
$news->setDefaultValue('news_no', $news_no);
$news->setDefaultValue('reg_date', date("Y-m-d H:i:s"));
$news->setDefaultValue('username', $_SESSION['loginUsername']);
$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 {
Пример #14
0
       <title>Title here!</title>
</head>
<body>
<?php 
/*** change the following variables ***/
$user = "******";
$pass = "******";
$DB = "db";
require "Formitable.class.php";
require_once 'C:\\apachefriends\\xampp\\htdocs\\anyDB2\\examples\\connect.inc.php';
if (strstr($_SERVER['SERVER_NAME'], "local")) {
    $server = "localhost";
} else {
    $server = "localhost";
}
$newForm = new Formitable($db, "formitable_users");
//set the field name of primary key
$newForm->setPrimaryKey("UserID");
//force a few field types
$newForm->forceTypes(array("UserType", "WkDays", "Occupation", "Address", "Address2", "City", "Password"), array("select", "checkbox", "text", "text", "text", "text", "password"));
//retrieve normalized data from another table
$newForm->normalizedField("UserType", "field_data", "ID", "name", "ID ASC", "type='user'");
$newForm->normalizedField("NewsLetter", "field_data", "ID", "name", "ID DESC", "type='yn'");
$newForm->normalizedField("Donation", "field_data", "ID", "name", "ID ASC", "type='donate'");
$newForm->normalizedField("recurring_Method", "field_data", "ID", "name", "ID ASC", "type='recurring'");
$newForm->normalizedField("Donation_Type", "field_data", "ID", "name", "ID ASC", "type='dtype'");
$newForm->normalizedField("NamePosted", "field_data", "ID", "name", "ID DESC", "type='yn'");
$newForm->normalizedField("volunteer", "field_data", "ID", "name", "ID ASC", "type='volunteer'");
$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");
<?php

#create form object
$staff = new Formitable($db, 'sionapros_newsletter_receipient');
#set primary key field
$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);
    $objectpath = $_REQUEST['activefolder'];
    #$object = $objectpath;#so that it looks like the path variable
    $smarty->assign('folder', 'set');
} else {
    if ($_REQUEST['filename']) {
        $objectpath = $_REQUEST['filename'];
        #$objectpath = basename($objectpath);
    }
}
$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