コード例 #1
0
ファイル: example1.php プロジェクト: julesbl/ssp
// form definition
// id name for the table is used for detection of submission and error messages
$form = new sfc\Form(SSP_Path(true), "tableNameForSql", "idNameforTable");
$form->tpl = $mainTemplate;
// main template to enclose the form, not required, form inserted into {content}
$form->tplf = "example1.tpl";
// display template for the form
$form->tda("miscTplData", "Some data for display on the form template, password is 'thingy'");
$form->fe("text", "firstElement", "First element, a text box");
$form->fep("required=true, dataType=text");
// element is required and is of data type text
$form->fe("password", "pasword", "enter a password");
$form->fep("required=true, dataType=password, load=false");
$form->addHidden("hiddenStuff", "Some hidden stuff", "text");
// hidden field
// check for submission
if ($form->processForm($_POST)) {
    // check for error
    if (!$form->error) {
        // check password
        if ($form->getField("pasword") != "thingy") {
            $form->addError("Error in the form");
            $form->setError("pasword", "Error in password");
            echo $form->create(true);
        } else {
            echo "Submission succesful";
        }
    }
} else {
    echo $form->create();
}
コード例 #2
0
ファイル: testcheckData.php プロジェクト: julesbl/ssp
// add french translations for this page
Translate::addToLanguage('fr', array('Text input' => 'La saisie de texte', 'Password input' => 'Mot de passe d\'entrée', 'Url input' => 'Url entrée', 'Email input' => 'entrée E-mail', 'Email no dot or at' => 'Envoyer aucun point ou à', 'Email too long' => 'Envoyer à trop long', 'Date input' => 'Date de l\'entrée', 'Time input' => 'saisie de l\'heure', 'Phone input' => 'téléphone d\'entrée', 'Integer input' => 'entrée entier', 'Real input' => 'd\'entrée réel', 'Hexadecimal input' => 'une entrée hexadécimale', 'Octal input' => 'octal entrée', 'Binary input' => 'entrée binaire', 'Text input required' => 'Saisie de texte nécessaire', 'Text minimum number of characters required' => 'Nombre minimum de caractères requis du texte', 'Text maximum number of characters required' => 'Nombre maximum de caractères requis du texte', 'A global error' => 'Une erreur globale', 'A local error added to the password field' => 'Une erreur locale ajoutés au champ Mot de passe'));
// local/global error list
if (!isset($_SESSION['SSP_errorLocal'])) {
    $_SESSION['SSP_errorLocal'] = true;
}
$errorLocal =& $_SESSION['SSP_errorLocal'];
$formLang = new sfc\Form(SSP_Path(), "noTable", "languageform");
$formLang->tplf = "testDatatypeLanguage.tpl";
$formLang->formSubmitVar = 'testLanguagechange';
$formLang->fe('select', 'language', 'Language', Protect::$tranlator->getLanguages());
$formLang->fep('deflt = ' . $session->lang);
$formLang->fe('check', 'localError', 'Errors local to fields', array(0, 1));
$formLang->fep('deflt = ' . $errorLocal);
if ($formLang->processForm($_POST)) {
    $session->lang = $formLang->getField('language');
    if ($formLang->getField('localError') == 1) {
        $errorLocal = true;
    } else {
        $errorLocal = false;
    }
    session_write_close();
    SSP_Divert(SSP_Path());
} else {
    $setLanguage = $formLang->create();
}
$form = new sfc\Form("testcheckData.php", "TestSaveTable", "testdataform");
$form->tplf = "testCheckData_" . $session->lang . ".tpl";
$form->tda('lang', $session->lang);
$form->tda('setLanguage', $setLanguage);
if ($errorLocal) {
コード例 #3
0
ファイル: testSelectRadio.php プロジェクト: julesbl/ssp
*   Revision:	a
*   Rev. Date	02-Mar-2012
*   Descrip:	Created.
*/
namespace w34u\ssp;

require "include.php";
$form = new sfc\Form('', 'noTable', 'testform');
$form->tplf = "testSelectRadio.tpl";
// data for selects and radio
$selectBasic = array(1 => "Option 1", 2 => "Option 2", 3 => "Option 3");
$form->fe("select", 'simpleSelect', "Simple Selection", $selectBasic);
$selectComplex = array(1 => "option 1", 2 => array("text" => "option 2", "class" => "option2Class"), 3 => new sfc\SelectOptions('Option 3'), 4 => new sfc\SelectOptions('Optgroup 4', 'optgroup', array(41 => "Option 41", 42 => "Option 42", 43 => "Option 43")), 5 => "Option 5");
$selectComplex[3]->addAttribute('class', 'option3Class');
$form->fe("select", "selectComplex", "Complex selection", $selectComplex);
//$form->fe("select", 'errorSimple', "Simple Selection", $selectBasic);
//$form->fe("select", "errorComplex", "Complex selection", $selectComplex);
//$form->fe("select", 'noSelect', "No selections", array());
$form->fe("radio", 'radioSelect', "Radio selections", $selectBasic);
$form->fep("deflt=1");
//$form->fe("radio", 'radioSelectError', "Radio error", $selectBasic);
//$form->setParam('validResults', array(1,2,3,4));
if ($form->processForm($_POST)) {
    if (!$form->error) {
        $form->tda("simpleSelectValue", $form->getField("simpleSelect"));
        $form->tda("complexSelectValue", $form->getField("selectComplex"));
        echo $form->create(true);
    }
} else {
    echo $form->create();
}
コード例 #4
0
ファイル: UserAdminBase.php プロジェクト: julesbl/ssp
 /**
  * Start recovery of a users password
  */
 public function startPasswordRecovery()
 {
     $form = new sfc\Form(SSP_Path(), "noTable", "startPasswordRecovery");
     $form->tplf = "passwordrecover.tpl";
     $form->tpl = $this->tpl(array("title" => "Password recovery"));
     $form->errorAutoFormDisplay = false;
     $form->tda("loginPath", $this->cfg->logonScript);
     $form->fe("text", "email", "Enter your registered email");
     $form->fep("required=true,width=30, dataType=email");
     $form->fe("submit", "submit", "Recover Password");
     $form->fep("elClass=SSPFormButton");
     if ($form->processForm($_POST)) {
         if (!$form->error) {
             // check for the email
             $fields = array("UserId", "UserEmail", "UserName", "UserPassword");
             $where["UserEmail"] = SSP_encrypt(trim($form->getField("email")));
             $row = $this->db->getf($this->cfg->userTable, $fields, $where, "SSP user admin: getting user info for password recovery");
             if ($this->db->numRows()) {
                 // found the email
                 $rowMisc = $this->db->get($this->cfg->userMiscTable, array("UserId" => $row->UserId), "Getting user name for password recovery");
                 if ($this->cfg->passwordRecovery == 0 or $this->cfg->encryptPassword) {
                     // use user change of password method
                     // Generate user response token
                     $token = SSP_ResponseToken($row->UserId, $this->cfg->recoverTime);
                     // generate email
                     if ($this->cfg->loginType == 1) {
                         // Supply user name if used for login
                         $content["UserName"] = $row["UserName"];
                     }
                     $content["link"] = $this->cfg->newPassword;
                     $content['token'] = $token;
                     $content["adminEmail"] = $this->cfg->adminEmail;
                     $email = new Email($this->cfg);
                     $email->noReplyEmail($content, "emailpasswordrecovery0.tpl", $row->UserEmail, $rowMisc->FirstName . " " . $rowMisc->FamilyName);
                 } else {
                     // email all info to the user
                     // generate email
                     if ($this->cfg->loginType == 1) {
                         // Supply user name if used for login
                         $content["UserName"] = $row["UserName"];
                     }
                     $content["UserPassword"] = $row["UserPassword"];
                     $content["adminEmail"] = $this->cfg->adminEmail;
                     $email = new Email($this->cfg);
                     $email->noReplyEmail($content, "emailpasswordrecovery1.tpl", $row->UserEmail, $rowMisc->FirstName . " " . $rowMisc->FamilyName);
                 }
                 $form->tda("sent");
                 $result = $form->create();
             } else {
                 // email not found
                 $form->tda("error");
                 $result = $form->create();
             }
         } else {
             $result = $form->create(true);
         }
     } else {
         // display form
         $result = $form->create();
     }
     return $result;
 }
コード例 #5
0
ファイル: test.php プロジェクト: julesbl/ssp
$formLang = new sfc\Form(SSP_Path(), "noTable", "languageform");
$formLang->tplf = "testDatatypeLanguage.tpl";
$formLang->formSubmitVar = 'testLanguagechange';
$formLang->fe('select', 'language', 'Language', Protect::$tranlator->getLanguages());
$formLang->fep('deflt = ' . $session->lang);
$formLang->setParam('script', 'onChange="this.form.submit()"');
if ($formLang->processForm($_POST)) {
    $session->lang = $formLang->getField('language');
    session_write_close();
    SSP_Divert(SSP_Path());
} else {
    $setLanguage = $formLang->create();
}
$form = new sfc\Form(SSP_Path(), "noTable", "testDatatype");
$form->tplf = "testDatatype.tpl";
$form->tda('lang', $session->lang);
$form->tda('setLanguage', $setLanguage);
$form->fe("text", "data", "Data to be checked");
$form->fep("dataType = gen");
$dataType = array("text" => "text " . $dataCheck->dataTypes["text"]->validChars, "password" => "password " . $dataCheck->dataTypes["password"]->validChars, "date" => "date " . $dataCheck->dataTypes["date"]->validChars, "time" => "time " . $dataCheck->dataTypes["time"]->validChars, "phone" => "phone " . $dataCheck->dataTypes["phone"]->validChars, "int" => "int " . $dataCheck->dataTypes["int"]->validChars, "real" => "real " . $dataCheck->dataTypes["real"]->validChars, "hex" => "hex " . $dataCheck->dataTypes["hex"]->validChars, "oct" => "oct " . $dataCheck->dataTypes["oct"]->validChars, "bin" => "bin " . $dataCheck->dataTypes["bin"]->validChars, "email" => "email " . $dataCheck->dataTypes["email"]->validChars, "emailchk" => "emailchk " . $dataCheck->dataTypes["email"]->validChars, "dom" => "dom " . $dataCheck->dataTypes["dom"]->validChars, "domchk" => "domchk " . $dataCheck->dataTypes["dom"]->validChars, "lable" => "lable " . $dataCheck->dataTypes["lable"]->validChars, "gen" => "general data, no checking at all!");
$form->fe("select", "dataType", "Data type to check against", $dataType);
if ($form->processForm($_POST)) {
    if (!$form->error) {
        $error = $dataCheck->check($form->getField("dataType"), $form->getField("data"));
        $form->tda("errorNumber", $error);
        $form->tda("errorString", $dataCheck->errorMessage);
        echo $form->create(true);
    }
} else {
    echo $form->create(true);
}
コード例 #6
0
ファイル: UserAdmin.php プロジェクト: julesbl/ssp
 /**
  * User joinup function
  */
 public function userJoin()
 {
     if ($this->cfg->confirmType == 0 or $this->cfg->confirmType == 3) {
         $needPassword = true;
     } else {
         $needPassword = false;
     }
     $form = new sfc\Form(SSP_Path(), $this->cfg->userTable, "userJoin");
     $form->tpl = $this->tpl(array("title" => "Join SSP"), true);
     $form->errorAutoFormDisplay = false;
     if ($this->subTpl != "") {
         $form->tplf = $this->subTpl;
     } else {
         $form->tplf = "userJoin.tpl";
     }
     $form->fe("text", "firstName", "First name");
     $form->fep("width=30, required=true");
     $form->fe("text", "lastName", "Last name");
     $form->fep("width=30, required=true");
     $form->fe("text", "email", "Your email");
     $form->fep("width=30,required=true, dataType=email");
     if ($this->cfg->loginType == 1 or $this->cfg->getUserName) {
         $form->fe("text", "name", "User name");
         $form->fep("width=15,required=true,dataType=password");
     }
     if ($needPassword) {
         $form->fe("password", "password", "Your password");
         $form->fep("width=15, required=true, dataType=password, minChar=" . $this->cfg->minPassword);
         $form->fe("password", "password2", "Enter password again");
         $form->fep("width=15,sql=false,dataType=password,required=true");
     }
     if ($this->cfg->userHasSignUpOptions) {
         // user has a set of options to sign up
         $form->fe("select", "signUpLevel", "Type of membership", $this->cfg->userAccessSignUpDropdown);
         $form->fep("dataType=int, sql=false");
     }
     $form->tda("loginPath", $this->cfg->logonScript);
     if ($form->processForm($_POST)) {
         if (!$form->error) {
             $form->setField("email", strtolower($form->getField("email")));
             if ($this->userCreateCheck($form)) {
                 return $form->create(true);
             } else {
                 $loginData = array();
                 $userId = SSP_uniqueId();
                 $loginData["UserId"] = $userId;
                 $loginData["UserEmail"] = $form->getField("email");
                 if ($needPassword) {
                     $loginData["UserPassword"] = $this->session->cryptPassword($form->getField("password"));
                 }
                 if ($this->cfg->userHasSignUpOptions) {
                     if (isset($this->cfg->userAccessSignUpLevels[$form->getField("signUpLevel")])) {
                         $loginData["UserAccess"] = $this->cfg->userAccessSignUpLevels[$form->getField("signUpLevel")];
                     } else {
                         $loginData["UserAccess"] = $this->cfg->userDefault;
                     }
                 } else {
                     $loginData["UserAccess"] = $this->cfg->userDefault;
                 }
                 if ($this->cfg->adminCheck) {
                     $loginData["UserAdminPending"] = 1;
                 }
                 if ($this->cfg->confirmType != 0) {
                     $loginData["UserWaiting"] = 1;
                 }
                 if ($this->cfg->furtherProgram) {
                     $loginData["UserPending"] = 1;
                 }
                 // create login record
                 $this->db->insert($this->cfg->userTable, $loginData, "Inserting new member login data");
                 $miscData = array();
                 $miscData["UserId"] = $userId;
                 $miscData["FirstName"] = $form->getField("firstName");
                 $miscData["FamilyName"] = $form->getField("lastName");
                 $this->db->insert($this->cfg->userMiscTable, $miscData, "Inserting new member misc data");
                 $this->id = $userId;
                 $this->userFinish($userId);
                 return $this->welcomeScreen();
             }
         } else {
             return $form->create(true);
         }
     } else {
         return $form->create();
     }
 }
コード例 #7
0
ファイル: Setup.php プロジェクト: julesbl/ssp
 /**
  * creates a template for admin page displays
  * @param array $contentMain the pages content
  * @param string $tpl alternative template name
  * @param bool $createMenu create the main menu
  * @param bool $suppressLangSelect - suppress the language selection dropdown
  * @return Template main template
  */
 function tpl($contentMain, $tpl = "", $createMenu = true, $suppressLangSelect = false)
 {
     // default to the main template if not other template not supplied
     if ($tpl != "") {
         $template = $tpl;
     } else {
         $template = $this->template;
     }
     // if the content suppied is just a string use it as the page title
     if (is_string($contentMain)) {
         $temp = $contentMain;
         $contentMain = array();
         $contentMain["title"] = $temp;
     }
     // build the page title from the supplied segments
     if (count($this->pageTitleSegments)) {
         if ($this->session->isTranslate()) {
             foreach ($this->pageTitleSegments as $key => $titlePart) {
                 $this->pageTitleSegments[$key] = $this->session->t($titlePart);
             }
         }
         $contentMain["title"] = $this->session->t($this->cfg->siteName) . $this->pageTitleSeperator . implode($this->pageTitleSeperator, $this->pageTitleSegments);
     } else {
         $contentMain["title"] = $this->session->t($this->cfg->siteName);
     }
     // add paths to various useful areas
     $contentMain["pathSite"] = $this->cfg->pathSite;
     $contentMain["pathAdmin"] = $this->cfg->adminDir;
     // create the language selection
     if ($this->cfg->translate and !$suppressLangSelect) {
         $formTemplate = array('<form action="{formAction}" method="post" id="languageSelectionform">', '{languageDropdown}', '{formHidden}', '</form>');
         $form = new sfc\Form(SSP_Path(true), 'notable', 'languageSelect');
         $form->translateDisable = true;
         $form->checkToken = false;
         $form->errorAutoFormDisplay = false;
         $form->formSubmitVar = 'languageSelectionformToken';
         $form->tplf = new Template("", $formTemplate);
         $languages = $this->session->getLanguages();
         $dropdownInformation = array();
         foreach ($languages as $lang => $languageInfo) {
             $dropdownInformation[$lang] = array('text' => $languageInfo['description'], 'dir' => $languageInfo['dir'], 'class' => 'lang_' . $lang, 'style' => 'background-image: url(/sspadmin/images/flag_' . $lang . '.png);');
         }
         $form->fe('select', 'languageDropdown', '', $dropdownInformation);
         $form->fep('deflt = ' . Protect::$tranlator->getLanguage());
         $form->setParam('script', 'onChange="this.form.submit()"');
         if ($form->processForm($_POST)) {
             if (!$form->error) {
                 $this->session->lang = $form->getField('languageDropdown');
                 session_write_close();
                 //echo 'code '. $_SESSION['SSP_currentLanguageCode'];
                 SSP_Divert(SSP_Path(true));
             }
         }
         $contentMain['languageSelectForm'] = $form->create();
     }
     if ($createMenu) {
         // generate main menu
         // highlight a main menu item
         if (isset($contentMain["mainSection"])) {
             $section = $contentMain["mainSection"];
         } else {
             $section = "";
         }
         $url = $_SERVER['REQUEST_URI'];
         $menu = new MenuGen();
         $menu->add($this->cfg->adminDir . 'useradmin/info/' . $this->session->userId, $this->session->t("User Details"), strpos($url, "useradmin") !== false);
         $menu->add($this->cfg->adminDir . 'adminusercreation', $this->session->t("New User"), strpos($url, "adminusercreation") !== false);
         $menu->add($this->cfg->userLister, $this->session->t("List Users"), $url === "/sspadmin/" or $url === '/sspadmin/filterChange' or $url === '/sspadmin/filterNormal' or $url === '/sspadmin/filterAdminPending');
         $menu->add($this->cfg->siteRoot, $this->session->t("Home"));
         $menu->add($this->cfg->logoffScript, $this->session->t("Log off"));
         $contentMain["mainMenu"] = $menu->cMenu();
     } else {
         $contentMain["mainMenu"] = "";
     }
     if (!isset($contentMain["menu"])) {
         $contentMain["menu"] = "";
     }
     if ($this->cfg->enableSetup === true) {
         $contentMain['showDisableSetupText'] = true;
     }
     $tpl = new Template($contentMain, $template, false);
     return $tpl;
 }
コード例 #8
0
ファイル: UserLister.php プロジェクト: julesbl/ssp
 /**
  * Display the filter form to change the list
  * @return string - html to be displayed
  */
 public function displayFilterForm()
 {
     // display form to update filter values
     $form = new sfc\Form($this->cfg->userLister . '/filterChange', "noTable", "sspFilter");
     $form->tda("tpl", $this->tpl(array("title" => "Modify search criteria")));
     $form->tda("tplf", "userListerSearchForm.tpl");
     $form->templateRoutine = "\\w34u\\ssp\\UserLister::formFilterCreate";
     $form->tda("fields", $this->filter->filterFields);
     $form->fe("radio", "filterOr", "Select using", array(0 => "All", 1 => "Any"));
     $form->fep("dataType=int, deflt=" . $this->filter->filterOr);
     foreach ($this->filter->filterFields as $key => $value) {
         $form->fe("select", "filterField" . $key, "Search", $this->cfg->fieldsFilterList);
         $form->fep("deflt={$value}");
         $form->fe("text", "filterValue" . $key, "for");
         $form->fep("dataType=gen, deflt=" . $this->filter->filterValues[$key]);
     }
     $form->fe("submit", "addField", "Add Search field");
     $form->fe("select", "limit", "Results per page", $this->cfg->limits);
     $form->fep("dataType=int, deflt=" . $this->filter->limit);
     $accessList = array_merge(array("all" => "All Types"), $this->cfg->userAccessTypeDropdown);
     $form->fe("select", "userAccess", "Member Access", $accessList);
     $form->fep("dataType=password, deflt=" . $this->filter->userAccess);
     $form->fe("check", "filterOnFlags", "Filter using flags", array(0, 1));
     $form->fep("dataType=bin, deflt=" . $this->filter->filterOnFlags);
     $flagFilterOptions = array(0 => " false", 1 => " true", 2 => " ignore");
     $form->fe("radio", "userDisabled", "Users who have been disabled", $flagFilterOptions);
     $form->fep("dataType=int, deflt=" . $this->filter->userDisabled);
     $form->fe("radio", "userPending", "User who are waiting for external OK", $flagFilterOptions);
     $form->fep("dataType=int, deflt=" . $this->filter->userPending);
     $form->fe("radio", "userAdminPending", "User Admin Pending", $flagFilterOptions);
     $form->fep("dataType=int, deflt=" . $this->filter->userAdminPending);
     $form->fe("radio", "creationFinished", "User Properly created", $flagFilterOptions);
     $form->fep("dataType=int, deflt=" . $this->filter->creationFinished);
     $form->fe("radio", "userWaiting", "Waiting for user to respond to email", $flagFilterOptions);
     $form->fep("dataType=int, deflt=" . $this->filter->userWaiting);
     $form->fe("submit", "submit", "Search Now");
     $form->fe("submit", "newSearch", "Reset Search Criteria");
     if ($form->processForm($_POST)) {
         if (!$form->error) {
             $this->filter->filterOr = $form->getField("filterOr");
             foreach ($this->filter->filterFields as $key => $value) {
                 $this->filter->filterFields[$key] = $form->getField("filterField" . $key);
             }
             $this->filter->limit = $form->getField("limit");
             if (array_key_exists("addField", $form->data)) {
                 // add a new search field
                 $this->filter->addField();
                 SSP_Divert($this->cfg->userLister);
             } elseif (array_key_exists("newSearch", $form->data)) {
                 // clears the form and search parameters
                 $this->filter->newSearch();
                 SSP_Divert($this->cfg->userLister);
             } else {
                 // show list with new search
                 $this->filter->update($form->data, true);
                 SSP_Divert($this->cfg->userLister);
             }
         } else {
             return $form->create(true);
         }
     } else {
         return $form->create();
     }
 }