<?php //sc/user/account/form/edit.php include 'sc-app.inc'; include APP_WEB_DIR . '/inc/header.inc'; include APP_WEB_DIR . '/inc/role/user.inc'; use com\indigloo\ui\form as Form; use com\indigloo\Constants; use com\indigloo\exception\UIException; use com\indigloo\sc\auth\Login; if (isset($_POST['save']) && $_POST['save'] == 'Save') { $gWeb = \com\indigloo\core\Web::getInstance(); $fvalues = array(); $fUrl = \com\indigloo\Url::tryFormUrl("fUrl"); try { $fhandler = new Form\Handler('web-form-1', $_POST); $fhandler->addRule('first_name', 'First Name', array('required' => 1, 'maxlength' => 32)); $fhandler->addRule('last_name', 'Last Name', array('required' => 1, 'maxlength' => 32)); $fhandler->addRule('email', 'Email', array('required' => 1, 'maxlength' => 64)); $fhandler->addRule('qUrl', 'qUrl', array('required' => 1, 'rawData' => 1)); $fvalues = $fhandler->getValues(); //decode q param to use in redirect $qUrl = base64_decode($fvalues['qUrl']); if ($fhandler->hasErrors()) { throw new UIException($fhandler->getErrors()); } $loginId = Login::getLoginIdInSession(); $userDao = new \com\indigloo\sc\dao\User(); $userDao->update($loginId, $fvalues['first_name'], $fvalues['last_name'], $fvalues['nick_name'], $fvalues['email'], $fvalues['website'], $fvalues['blog'], $fvalues['location'], $fvalues['age'], $fvalues['photo_url'], $fvalues['about_me']); //success header("Location: " . $qUrl);
//monitor/form/group/featured.php include 'sc-app.inc'; include APP_WEB_DIR . '/inc/header.inc'; include APP_WEB_DIR . '/inc/role/admin.inc'; use com\indigloo\ui\form as Form; use com\indigloo\Constants; use com\indigloo\sc\util\Nest; use com\indigloo\Util; use com\indigloo\Url; if (isset($_POST['save']) && $_POST['save'] == 'Save') { $gWeb = \com\indigloo\core\Web::getInstance(); $fvalues = array(); $fUrl = \com\indigloo\Url::tryFormUrl("fUrl"); try { $fhandler = new Form\Handler("web-form-1", $_POST); $fvalues = $fhandler->getValues(); if ($fhandler->hasErrors()) { throw new UIException($fhandler->getErrors()); } $group_slug = ""; $slugs = Util::tryArrayKey($fvalues, "g"); if (!is_null($slugs)) { //remove duplicate entries $slugs = array_unique($slugs); //input - new groups are names / old ones are slugs $slugs = array_map(array("\\com\\indigloo\\util\\StringUtil", "convertNameToKey"), $slugs); //db slugs are space separated for sphinx indexing $group_slug = implode(Constants::SPACE, $slugs); } $collectionDao = new \com\indigloo\sc\dao\Collection();
//qa/form/comment.php include 'sc-app.inc'; include APP_WEB_DIR . '/inc/header.inc'; use com\indigloo\sc\auth\Login; use com\indigloo\Util; use com\indigloo\Logger; use com\indigloo\sc\ui\Constants as UIConstants; use com\indigloo\ui\form as Form; use com\indigloo\Constants; use com\indigloo\exception\UIException; if (isset($_POST['save']) && $_POST['save'] == 'Save') { $gWeb = \com\indigloo\core\Web::getInstance(); $fvalues = array(); $fUrl = \com\indigloo\Url::tryFormUrl("fUrl"); try { $fhandler = new Form\Handler('web-form-1', $_POST); $fhandler->addRule('comment', 'Comment', array('required' => 1)); $fhandler->addRule('post_id', 'post id', array('required' => 1)); $fhandler->addRule('owner_id', 'owner id', array('required' => 1)); $fhandler->addRule('post_title', 'post title', array('required' => 1)); $fvalues = $fhandler->getValues(); // UI checks if ($fhandler->hasErrors()) { throw new UIException($fhandler->getErrors()); } //trim comments to 512 chars $fvalues["comment"] = substr($fvalues["comment"], 0, 512); //use login is required for comments if (Login::hasSession()) { $gSessionLogin = \com\indigloo\sc\auth\Login::getLoginInSession(); $commentDao = new com\indigloo\sc\dao\Comment();
include APP_WEB_DIR . '/inc/role/user.inc'; use com\indigloo\ui\form as Form; use com\indigloo\Constants; use com\indigloo\exception\UIException; use com\indigloo\exception\DBException; use com\indigloo\sc\mysql; use com\indigloo\sc\auth\Login; use com\indigloo\Url; use com\indigloo\Util; use com\indigloo\Logger; if (isset($_POST['save']) && $_POST['save'] == 'Save') { $gWeb = \com\indigloo\core\Web::getInstance(); $fvalues = array(); $fUrl = \com\indigloo\Url::tryFormUrl("fUrl"); try { $fhandler = new Form\Handler("edit-form", $_POST); $fhandler->addRule("name", "Name", array('required' => 1)); $fvalues = $fhandler->getValues(); $name = $fvalues["name"]; if (!Util::isAlphaNumeric($name)) { $fhandler->addError("Bad name : only letters and numbers are allowed!"); } if ($fhandler->hasErrors()) { throw new UIException($fhandler->getErrors()); } $loginId = Login::getLoginIdInSession(); $listDao = new \com\indigloo\sc\dao\Lists(); $listDao->createNew($loginId, $name, $fvalues["description"]); $message = sprintf("success! new list created"); $gWeb->store(Constants::FORM_MESSAGES, array($message)); header("Location: " . $fUrl);
include 'sc-app.inc'; include APP_WEB_DIR . '/inc/header.inc'; use com\indigloo\ui\form as Form; use com\indigloo\Constants; use com\indigloo\Util; use com\indigloo\Url; use com\indigloo\sc\util\PseudoId; use com\indigloo\exception\UIException; use com\indigloo\sc\auth\Login; use com\indigloo\Configuration as Config; if (isset($_POST['save']) && $_POST['save'] == 'Save') { $gWeb = \com\indigloo\core\Web::getInstance(); $fvalues = array(); $fUrl = \com\indigloo\Url::tryFormUrl("fUrl"); try { $fhandler = new Form\Handler('web-form-1', $_POST); $fhandler->addRule('email', 'Emails', array('requred' => 1)); $fhandler->addRule('message', 'Message', array('required' => 1)); $fhandler->addRule('qUrl', 'qUrl', array('required' => 1, 'rawData' => 1)); //check security token $fhandler->checkToken("token", $gWeb->find("form.token", true)); $fvalues = $fhandler->getValues(); if ($fhandler->hasErrors()) { throw new UIException($fhandler->getErrors()); } $loginId = Login::getLoginIdInSession(); $userDao = new \com\indigloo\sc\dao\User(); $userDBRow = $userDao->getOnLoginId($loginId); $emails = explode(",", $fvalues["email"]); $message = $fvalues["message"]; $mailDao = new \com\indigloo\sc\dao\Mail();
include APP_WEB_DIR . '/inc/role/user.inc'; use com\indigloo\ui\form as Form; use com\indigloo\Constants; use com\indigloo\exception\UIException; use com\indigloo\exception\DBException; use com\indigloo\sc\mysql; use com\indigloo\sc\auth\Login; use com\indigloo\Url; use com\indigloo\Logger; use com\indigloo\sc\Util as AppUtil; if (isset($_POST['save']) && $_POST['save'] == 'Save') { $gWeb = \com\indigloo\core\Web::getInstance(); $fvalues = array(); $fUrl = \com\indigloo\Url::tryFormUrl("fUrl"); try { $fhandler = new Form\Handler("edit-form", $_POST); $fhandler->addRule("link", "item URL", array('required' => 1)); $fhandler->addRule("list_id", "list id", array('required' => 1)); $fvalues = $fhandler->getValues(); $link = $fvalues["link"]; if ($fhandler->hasErrors()) { throw new UIException($fhandler->getErrors()); } $loginId = Login::getLoginIdInSession(); $listDao = new \com\indigloo\sc\dao\Lists(); $itemId = AppUtil::getItemIdInUrl($link); if (is_null($itemId)) { $message = "invalid item URL : please add a valid item URL "; throw new UIException(array($message)); } $postDao = new \com\indigloo\sc\dao\Post();
//sc/qa/comment/form/delete.php include 'sc-app.inc'; include APP_WEB_DIR . '/inc/header.inc'; include APP_WEB_DIR . '/inc/role/user.inc'; use com\indigloo\ui\form as Form; use com\indigloo\Constants; use com\indigloo\Util; use com\indigloo\Url; use com\indigloo\exception\UIException; use com\indigloo\sc\util\PseudoId; if (isset($_POST['delete']) && $_POST['delete'] == 'Delete') { $gWeb = \com\indigloo\core\Web::getInstance(); $fvalues = array(); $fUrl = \com\indigloo\Url::tryFormUrl("fUrl"); try { $fhandler = new Form\Handler('web-form-1', $_POST); $fhandler->addRule('comment_id', 'comment_id', array('required' => 1)); $fhandler->addRule('qUrl', 'qUrl', array('required' => 1, 'rawData' => 1)); $fvalues = $fhandler->getValues(); $ferrors = $fhandler->getErrors(); //decode qUrl to use in redirect $qUrl = base64_decode($fvalues['qUrl']); $encodedId = PseudoId::encode($fvalues['comment_id']); if ($fhandler->hasErrors()) { throw new UIException($fhandler->getErrors()); } $commentDao = new com\indigloo\sc\dao\Comment(); $commentDao->delete($fvalues['comment_id']); //success header("Location: " . $qUrl); } catch (UIException $ex) {
include 'sc-app.inc'; include APP_WEB_DIR . '/inc/header.inc'; include APP_WEB_DIR . '/inc/role/user.inc'; use com\indigloo\ui\form as Form; use com\indigloo\Constants; use com\indigloo\Util; use com\indigloo\Url; use com\indigloo\sc\auth\Login; use com\indigloo\sc\util\PseudoId; use com\indigloo\exception\UIException; if (isset($_POST['save']) && $_POST['save'] == 'Save') { $gWeb = \com\indigloo\core\Web::getInstance(); $fvalues = array(); $fUrl = \com\indigloo\Url::tryFormUrl("fUrl"); try { $fhandler = new Form\Handler('web-form-1', $_POST); $fhandler->addRule('links_json', 'links_json', array('rawData' => 1)); $fhandler->addRule('images_json', 'images_json', array('rawData' => 1)); $fhandler->addRule('group_names', 'Tags', array('maxlength' => 64, 'rawData' => 1)); $fhandler->addRule('qUrl', 'qUrl', array('required' => 1, 'rawData' => 1)); $fvalues = $fhandler->getValues(); $qUrl = base64_decode($fvalues['qUrl']); if ($fhandler->hasErrors()) { throw new UIException($fhandler->getErrors()); } $groupDao = new \com\indigloo\sc\dao\Group(); $group_names = $fvalues['group_names']; $group_slug = $groupDao->nameToSlug($group_names); $postDao = new com\indigloo\sc\dao\Post(); $title = Util::abbreviate($fvalues['description'], 128); $postDao->update($fvalues['post_id'], $title, $fvalues['description'], $_POST['links_json'], $_POST['images_json'], $group_slug, $fvalues['category']);
include APP_WEB_DIR . '/inc/header.inc'; include WEBGLOO_LIB_ROOT . '/ext/recaptchalib.php'; use com\indigloo\ui\form as Form; use com\indigloo\Logger; use com\indigloo\Constants; use com\indigloo\exception\UIException; use com\indigloo\exception\DBException; use com\indigloo\sc\mysql; use com\indigloo\sc\auth\Login; use com\indigloo\sc\Constants as AppConstants; if (isset($_POST['register']) && $_POST['register'] == 'Register') { $gWeb = \com\indigloo\core\Web::getInstance(); $fvalues = array(); $fUrl = \com\indigloo\Url::tryFormUrl("fUrl"); try { $fhandler = new Form\Handler('web-form-1', $_POST); $fhandler->addRule('first_name', 'First Name', array('required' => 1, 'maxlength' => 32)); $fhandler->addRule('last_name', 'Last Name', array('required' => 1, 'maxlength' => 32)); $fhandler->addRule('email', 'Email', array('required' => 1, 'maxlength' => 64)); $fhandler->addRule('password', 'Password', array('required' => 1, 'maxlength' => 32)); //check security token $fhandler->checkToken("token", $gWeb->find("form.token", true)); $fvalues = $fhandler->getValues(); if (!empty($fvalues["adrisya_number"])) { $message = "unexpected error with form submission!"; $fhandler->addError($message); $error = "Possible spam bot submission from IP :: " . $_SERVER["REMOTE_ADDR"]; Logger::getInstance()->info($error); } if ($fhandler->hasErrors()) { throw new UIException($fhandler->getErrors());
include APP_WEB_DIR . '/inc/role/user.inc'; use com\indigloo\ui\form as Form; use com\indigloo\Constants; use com\indigloo\exception\UIException; use com\indigloo\exception\DBException; use com\indigloo\sc\mysql; use com\indigloo\sc\auth\Login; use com\indigloo\Url; use com\indigloo\Logger; // submitting via javascript // removed button value check $gWeb = \com\indigloo\core\Web::getInstance(); $fvalues = array(); $fUrl = \com\indigloo\Url::tryFormUrl("fUrl"); try { $fhandler = new Form\Handler("delete-item-form", $_POST); $fhandler->addRule("list_id", "list id", array('required' => 1)); $fhandler->addRule("items_json", "items", array('required' => 1, 'rawData' => 1)); $fvalues = $fhandler->getValues(); if ($fhandler->hasErrors()) { throw new UIException($fhandler->getErrors()); } $loginId = Login::getLoginIdInSession(); $listDao = new \com\indigloo\sc\dao\Lists(); $listDao->deleteItems($loginId, $fvalues["list_id"], $fvalues["items_json"]); $message = sprintf("success! selected items have been deleted"); $gWeb->store(Constants::FORM_MESSAGES, array($message)); header("Location: " . $fUrl); } catch (UIException $ex) { $gWeb->store(Constants::STICKY_MAP, $fvalues); $gWeb->store(Constants::FORM_ERRORS, $ex->getMessages());
<?php //qa/external/router.php include 'sc-app.inc'; include APP_WEB_DIR . '/inc/header.inc'; include APP_WEB_DIR . '/inc/role/user.inc'; use com\indigloo\ui\form as Form; use com\indigloo\Constants; use com\indigloo\exception\UIException; try { $gWeb = \com\indigloo\core\Web::getInstance(); $fhandler = new Form\Handler('web-form-1', $_POST); $fhandler->addRule('images_json', 'images_json', array('rawData' => 1)); $fvalues = $fhandler->getValues(); $fUrl = $fvalues['fUrl']; if ($fhandler->hasErrors()) { throw new UIException($fhandler->getErrors()); } // route to new form page // put images_json in sticky $gWeb->store(Constants::STICKY_MAP, $fvalues); header("Location: " . "/share/new.php"); } catch (UIException $ex) { $gWeb->store(Constants::STICKY_MAP, $fvalues); $gWeb->store(Constants::FORM_ERRORS, $ex->getMessages()); header("Location: " . $fUrl); exit(1); }
include 'sc-app.inc'; include APP_WEB_DIR . '/inc/header.inc'; include APP_WEB_DIR . '/inc/role/user.inc'; $gSessionLogin = \com\indigloo\sc\auth\Login::getLoginInSession(); use com\indigloo\ui\form as Form; use com\indigloo\Constants; use com\indigloo\Util; use com\indigloo\Url; use com\indigloo\sc\util\PseudoId; use com\indigloo\exception\UIException; if (isset($_POST['save']) && $_POST['save'] == 'Save') { $gWeb = \com\indigloo\core\Web::getInstance(); $fvalues = array(); $fUrl = \com\indigloo\Url::tryFormUrl("fUrl"); try { $fhandler = new Form\Handler('web-form-1', $_POST); $fhandler->addRule('links_json', 'links_json', array('rawData' => 1)); $fhandler->addRule('images_json', 'images_json', array('rawData' => 1)); $fhandler->addRule('group_names', 'Tags', array('maxlength' => 64, 'rawData' => 1)); //check security token $fhandler->checkToken("token", $gWeb->find("form.token", true)); $fvalues = $fhandler->getValues(); if ($fhandler->hasErrors()) { throw new UIException($fhandler->getErrors()); } $groupDao = new \com\indigloo\sc\dao\Group(); $group_names = $fvalues['group_names']; $group_slug = $groupDao->nameToSlug($group_names); $postDao = new com\indigloo\sc\dao\Post(); $title = Util::abbreviate($fvalues['description'], 128); $itemId = $postDao->create($title, $fvalues['description'], $gSessionLogin->id, $gSessionLogin->name, $_POST['links_json'], $_POST['images_json'], $group_slug, $fvalues['category']);
use com\indigloo\sc\mysql; use com\indigloo\sc\auth\Login; use com\indigloo\Url; use com\indigloo\Util; use com\indigloo\Logger; use com\indigloo\sc\util\PseudoId; use com\indigloo\sc\html\Lists as ListHtml; // @imp submit buttons are only considered successful controls // if they are used to submit the form // this form can be submitted using javascript also so do not include // submit_button_in_$_POST check. $gWeb = \com\indigloo\core\Web::getInstance(); $fvalues = array(); $qUrl = \com\indigloo\Url::tryFormUrl("qUrl"); try { $fhandler = new Form\Handler("list-form-1", $_POST); $fhandler->addRule("item_id", 'item', array('required' => 1)); $fvalues = $fhandler->getValues(); $qUrl = base64_decode($fvalues["qUrl"]); if ($fhandler->hasErrors()) { throw new UIException($fhandler->getErrors()); } $listId = $fvalues["list_id"]; $itemId = $fvalues["item_id"]; $loginId = Login::getLoginIdInSession(); $flag = intval($fvalues["is_new"]); $listDao = new \com\indigloo\sc\dao\Lists(); $name = $fvalues["new-list-name"]; if ($flag == 1 && empty($listId)) { // create new list if (!Util::isAlphaNumeric($name)) {
<?php //sc/user/account/form/mail-password.php include 'sc-app.inc'; include APP_WEB_DIR . '/inc/header.inc'; use com\indigloo\ui\form as Form; use com\indigloo\Constants; use com\indigloo\Util; use com\indigloo\Url; use com\indigloo\exception\UIException; if (isset($_POST['save']) && $_POST['save'] == 'Save') { $gWeb = \com\indigloo\core\Web::getInstance(); $fvalues = array(); $fUrl = \com\indigloo\Url::tryFormUrl("fUrl"); try { $fhandler = new Form\Handler('web-form-1', $_POST); $fhandler->addRule('email', 'Email', array('maxlength' => 64, 'required' => 1)); $fvalues = $fhandler->getValues(); if ($fhandler->hasErrors()) { throw new UIException($fhandler->getErrors()); } $userDao = new \com\indigloo\sc\dao\User(); $user = $userDao->getOnEmail($fvalues['email']); if (empty($user)) { $message = "Error: We did not find any account with this email!"; throw new UIException(array($message)); } $mailDao = new \com\indigloo\sc\dao\Mail(); $mailDao->addResetPassword($user['name'], $fvalues['email']); $message = "Success! You will receive an email soon!"; $gWeb->store(Constants::STICKY_MAP, $fvalues);
<?php //sc/site/form/contact.php include 'sc-app.inc'; include APP_WEB_DIR . '/inc/header.inc'; use com\indigloo\ui\form as Form; use com\indigloo\Constants; use com\indigloo\Util; use com\indigloo\exception\UIException; if (isset($_POST['save']) && $_POST['save'] == 'Save') { $gWeb = \com\indigloo\core\Web::getInstance(); $fvalues = array(); $fUrl = \com\indigloo\Url::tryFormUrl("fUrl"); try { $fhandler = new Form\Handler('web-form-1', $_POST); $fhandler->addRule('comment', 'Comment', array('required' => 1, 'maxlength' => 512)); $fhandler->addRule('name', 'Name', array('required' => 1, 'maxlength' => 64)); $fhandler->addRule('email', 'Email', array('required' => 1, 'maxlength' => 64)); //check security token $fhandler->checkToken("token", $gWeb->find("form.token", true)); $fvalues = $fhandler->getValues(); if ($fhandler->hasErrors()) { throw new UIException($fhandler->getErrors()); } $feedbackDao = new com\indigloo\sc\dao\Feedback(); $feedbackDao->add($fvalues['name'], $fvalues['email'], $fvalues['phone'], $fvalues['comment']); //success - always go back to feedback form $gWeb->store(Constants::FORM_MESSAGES, array('Thanks for your input.')); header("Location: " . $fUrl); } catch (UIException $ex) { $gWeb->store(Constants::STICKY_MAP, $fvalues);
//sc/user/account/form/change-password.php include 'sc-app.inc'; include APP_WEB_DIR . '/inc/header.inc'; //This form is also used by mail reset workflow //so do not add role/user.inc here use com\indigloo\ui\form as Form; use com\indigloo\Constants; use com\indigloo\Util; use com\indigloo\auth\User as WebglooUser; use com\indigloo\exception\UIException; if (isset($_POST['save']) && $_POST['save'] == 'Save') { $gWeb = \com\indigloo\core\Web::getInstance(); $fvalues = array(); $fUrl = \com\indigloo\Url::tryFormUrl("fUrl"); try { $fhandler = new Form\Handler('web-form-1', $_POST); $fhandler->addRule('password', 'Password', array('required' => 1, 'maxlength' => 32)); $fhandler->addRule('qUrl', 'qUrl', array('required' => 1, 'rawData' => 1)); $fvalues = $fhandler->getValues(); //decode q param for redirect $qUrl = base64_decode($fvalues['qUrl']); if ($fhandler->hasErrors()) { throw new UIException($fhandler->getErrors()); } //form token $session_token = $gWeb->find("change.password.token", true); if ($fvalues['ftoken'] != $session_token) { $message = "form token does not match the value stored in session"; throw new UIException(array($message)); } //decrypt email