<?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
/*** 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"));
//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']);
$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
$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 {
<?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
$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");
$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;
#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);
} else {
    #unset prevPath
示例#9
0
 $updated = $newForm->getFieldValue('timestamp');
 echo iconv('Windows-1253', 'UTF-8', "<h1><i>Πρόγραμμα:</i> ") . $title . "</h1>";
 // hide fields from users
 $hidden = array('id', 'timestamp', 'vev');
 $newForm->hideFields($hidden);
 // force types
 //$newForm->forceType('visits','select');
 //$newForm->forceType('duration','select');
 //set custom field labels
 $rows = array('emails1', 'schnip', 'dimo', 'sch1', 'princ1', 'praxi', 'sch2', 'princ2', 'emails2', 'titel', 'subti', 'categ', 'theme', 'goal', 'meth', 'pedia', 'dura', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6', 'visit', 'act', 'prsnt', 'nam1', 'sur1', 'email1', 'mob1', 'eid1', 'his1', 'qua1', 'nam2', 'sur2', 'email2', 'mob2', 'eid2', 'his2', 'qua2', 'nam3', 'sur3', 'email3', 'mob3', 'eid3', 'his3', 'qua3', 'nam4', 'sur4', 'email4', 'mob4', 'eid4', 'his4', 'qua4', 'Nr', 'cha', 'grade', 'notes', 'chk', 'vev');
 $labels = array('email Σχολείου', 'Τύπος Μονάδας', 'Δήμος', 'Σχολική Μονάδα', 'Ονοματεπώνυμο Διευθυντή/ντριας- Προϊσταμένου/νης', 'Πράξη ανάθεσης', 'Συστεγαζόμενη Σχολική Μονάδα', 'Δ/ντής/ντρια Συστεγαζόμενης', 'email Συστεγαζόμενης', 'Τίτλος προγράμματος', 'Υπότιτλος-Υποθέματα', 'Κατηγορία προγράμματος', 'Θεματολογία', 'Παιδαγωγικοί στόχοι', 'Μεθοδολογία Υλοποίησης-Συνεργασίες', 'Πεδία σύνδεσης με τα προγράμματα σπουδών των αντίστοιχων γνωστικών αντικειμένων', 'Διάρκεια προγράμματος (μήνες)', '1ος Μήνας', '2ος Μήνας', '3ος Μήνας', '4ος Μήνας', '5ος Μήνας', '6ος Μήνας', 'Αριθμός επισκέψεων', 'Δράσεις', 'Πρόθεση παρουσίασης του προγράμματος στη Γιορτή Μαθητικής Δημιουργίας 2016', 'Όνομα 1ου εκπ/κού', 'Επώνυμο 1ου εκπ/κού', 'email 1ου εκπ/κού', 'Κινητό τηλέφωνο 1ου εκπ/κού', 'Ειδικότητα 1ου εκπ/κού', 'Υλοποίηση προγραμμάτων 1ου εκπ/κού στο παρελθόν', 'Επιμόρφωση 1ου εκπ/κού', 'Όνομα 2ου εκπ/κού', 'Επώνυμο 2ου εκπ/κού', 'email 2ου εκπ/κού', 'Κινητό τηλέφωνο 2ου εκπ/κού', 'Ειδικότητα 2ου εκπ/κού', 'Υλοποίηση προγραμμάτων 2ου εκπ/κού στο παρελθόν', 'Επιμόρφωση 2ου εκπ/κού', 'Όνομα 3ου εκπ/κού', 'Επώνυμο 3ου εκπ/κού', 'email 3ου εκπ/κού', 'Κινητό τηλέφωνο 3ου εκπ/κού', 'Ειδικότητα 3ου εκπ/κού', 'Υλοποίηση προγραμμάτων 3ου εκπ/κού στο παρελθόν', 'Επιμόρφωση 3ου εκπ/κού', 'Όνομα 4ου εκπ/κού', 'Επώνυμο 4ου εκπ/κού', 'email 4ου εκπ/κού', 'Κινητό τηλέφωνο 4ου εκπ/κού', 'Ειδικότητα 4ου εκπ/κού', 'Υλοποίηση προγραμμάτων 4ου εκπ/κού στο παρελθόν', 'Επιμόρφωση 4ου εκπ/κού', 'Αριθμός Μαθητών', 'Χαρακτηριστικά ομάδας', 'Τάξεις', 'Τυχόν παρατηρήσεις-επισημάνσεις', 'Βεβαιώνεται ότι ο/η δ/ντής/τρια ή προϊσταμένος/νη της σχολικής μονάδας έλεγξε το παρόν σχέδιο προγράμματος σχολικών δραστηριοτήτων, έκανε απαραίτητες τυχόν διορθώσεις και βεβαιώνει ότι τα στοιχεία που αναφέρονται στο παρόν σχέδιο προγράμματος είναι σωστά.', 'Ο/Η  δ/ντής/τρια ή προϊσταμένος/νη βεβαιώνει ότι το συγκεκριμένο σχέδιο προγράμματος σχολικών δραστηριοτήτων ολοκληρώθηκε επιτυχώς και τα αποτελέσματα του προγράμματος είναι διαθέσιμα στο σχολική μονάδα.');
 // convert greek labels to utf8
 array_walk($labels, function (&$entry) {
     $entry = iconv('Windows-1253', 'UTF-8', $entry);
 });
 $newForm->labelFields($rows, $labels);
 //encryption (not working)
 //$key = "$Ftg/%)poa";
 //$newForm->setEncryptionKey($key);
 //output form
 $newForm->printForm(array(), array(iconv('Windows-1253', 'UTF-8', 'Υποβολή'), '', 'Reset Form', false, true));
 // display print button
 $printText = iconv('Windows-1253', 'UTF-8', 'Εκτύπωση');
 echo "<input type=\"button\" onclick=\"window.open('exp.php?id=" . $newForm->getFieldValue('id') . "');\" value=\"" . $printText . "\" />";
 //$shm = '<h4>ΣΗΜΕΙΩΣΕΙΣ:<br>1. Για την αποθήκευση οποιασδήποτε αλλαγής πατήστε \'Υποβολή\'.<br>2. Τα πεδία: Σχολική μονάδα, Τίτλος προγράμματος, Όνομα-Επώνυμο-Κλάδος εκπ/κών ΔΕ μεταβάλλονται.<br>Για τη μεταβολή τους επικοινωνήστε με το τμήμα Σχολικών Δραστηριοτήτων, τηλ. 2810529318, email: tay@dipe.ira.sch.gr</h4><br>';
 $shm = '<h4>ΣΗΜΕΙΩΣΕΙΣ:<br>Για την αποθήκευση οποιασδήποτε αλλαγής πατήστε \'Υποβολή\'.</h4><br>';
 echo iconv('Windows-1253', 'UTF-8', $shm);
 // display record timestamp
 if ($updated > 0) {
     echo "<small>" . iconv('Windows-1253', 'UTF-8', 'Τελευταία ανανέωση: ') . date('d/m/Y, H:i:s', strtotime($updated)) . "</small>";
 }
#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
$news->returnOutput = true;
if (isset($_FILES)) {
    //path to upload to (with trailing slash)
    $path = "./photos";
    //array of filetypes to check against
示例#11
0
$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");
//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)
<?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);