public static function FailureOrRedirect($message, $redirect = null, $data = null) { if (requestIsAjax()) { die(self::Failure($message, self::_addRedirectToData($data, $redirect))); } Typeframe::Redirect($message, $redirect); }
if ($_SERVER['REQUEST_METHOD'] == 'POST') { $page->delete(); Typeframe::Redirect('Page deleted.', Typeframe::CurrentPage()->applicationUri()); } } else { Typeframe::Redirect('Invalid page specified.', Typeframe::CurrentPage()->applicationUri()); } return; /** * Typeframe Pages application * * admin delete controller */ // save typing below $typef_app_dir = TYPEF_WEB_DIR . '/admin/pages'; // can only process posts if ('POST' != $_SERVER['REQUEST_METHOD']) { //Typeframe::Redirect('Nothing to do.', $typef_app_dir); return; } // validate the page id $pageid = @$_POST['pageid']; $page = Model_Page::Get($pageid); if (!$page->exists()) { Typeframe::Redirect('Invalid page.', $typef_app_dir); return; } Model_Page::Delete($pageid); Typeframe::Registry()->purgeRegistryCache(); Typeframe::Redirect('Page deleted.', $typef_app_dir);
<?php $site = Model_Site::Get($_REQUEST['id']); if ($site->exists()) { require_once 'options.inc.php'; $pm->setVariable('site', $site); if ($_SERVER['REQUEST_METHOD'] == 'POST') { include 'update.inc.php'; Typeframe::Redirect('Site updated.', Plugin_Breadcrumbs::SavedState(Typeframe::CurrentPage()->applicationUri())); } } else { Typeframe::Redirect('Invalid site specified.', Plugin_Breadcrumbs::SavedState(Typeframe::CurrentPage()->applicationUri())); }
<?php $mailform['mailformname'] = $_POST['mailformname']; $mailform['message'] = $_POST['message']; $mailform['response'] = $_POST['response']; $mailform['subject'] = $_POST['subject']; $mailform['replyto'] = $_POST['replyto']; $mailform['redirect'] = $_POST['redirect']; $mailform['template'] = $_POST['template']; $recipients = array(); for ($i = 0; $i < count($_POST['recipients']['email']); $i++) { if (!empty($_POST['recipients']['email'][$i])) { $recipients[] = array('email' => $_POST['recipients']['email'][$i], 'name' => $_POST['recipients']['name'][$i], 'when' => $_POST['recipients']['when'][$i], 'fieldname' => $_POST['recipients']['fieldname'][$i], 'fieldvalue' => $_POST['recipients']['fieldvalue'][$i]); } } $mailform['recipients'] = $recipients; $formfields = array(); for ($i = 0; $i < count($_POST['fields']['name']); $i++) { if (!empty($_POST['fields']['name'][$i])) { $formfields[] = array('name' => $_POST['fields']['name'][$i], 'class' => $_POST['fields']['class'][$i], 'type' => $_POST['fields']['type'][$i], 'values' => $_POST['fields']['values'][$i], 'required' => $_POST['fields']['required'][$i]); } } $mailform['captcha'] = !empty($_POST['captcha']) ? 1 : 0; $mailform['formfields'] = $formfields; $mailform->save(); Typeframe::Redirect('Mailform saved.', Typeframe::CurrentPage()->applicationUri());
<?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { $mailform = Model_Mailform::Get($_POST['mailformid']); if ($mailform->exists()) { $mailform->delete(); Typeframe::Redirect('Mailform deleted.', Typeframe::CurrentPage()->applicationUri()); return; } } Typeframe::Redirect('Nothing to do.', Typeframe::CurrentPage()->applicationUri());
<?php $userid = trim(@$_REQUEST['userid']); $confirmkey = trim(@$_REQUEST['confirmkey']); $user = Model_User::Get($userid); $confirms = new Model_UserConfirm(); $confirms->where('userid = ?', $userid); $confirms->where('confirmkey = ?', $confirmkey); $confirm = $confirms->getFirst(); if ($confirm->exists()) { $user['confirmed'] = 1; $user->save(); $confirm->delete(); Typeframe::Redirect('Your account confirmation is complete. Welcome!', TYPEF_WEB_DIR . '/', 1); } else { Typeframe::Redirect('Confirmation failed.', TYPEF_WEB_DIR . '/', 1); }
<?php $usergroup = Model_Usergroup::Get($_REQUEST['usergroupid']); if ($usergroup->exists()) { if ($_SERVER['REQUEST_METHOD'] == 'POST') { include 'update.inc.php'; Typeframe::Redirect('User group updated.', Typeframe::CurrentPage()->applicationUri() . '/groups'); } else { $pm->setVariable('usergroup', $usergroup); $admin = new BaseModel_UsergroupAdmin(); $admin->where('usergroupid = ?', $usergroup['usergroupid']); $apps = array(); foreach ($admin->select() as $a) { $apps[] = $a['application']; } $pm->setVariable('admin_applications', $apps); include 'form.inc.php'; } } else { }
<?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { $base = TYPEF_DIR . '/files/public/userfiles/' . Typeframe::User()->get('userid'); if (!file_exists($base)) { mkdir($base); } $folder = isset($_REQUEST['folder']) ? $_REQUEST['folder'] : ''; $currentFolder = "{$base}/{$folder}"; $moved = FileManager::MoveUpload($_FILES['upload']['tmp_name'], "{$currentFolder}/{$_FILES['upload']['name']}"); $message = ''; if ($moved) { $moved = basename($moved); } else { $moved = ''; $message = 'Upload failed.'; } if (!empty($_REQUEST['command']) && $_REQUEST['command'] == 'BrowserUpload') { Typeframe::Redirect('File uploaded.', TYPEF_WEB_DIR . '/ckeditor/browse?type=' . $_REQUEST['type'] . '&folder=' . $_REQUEST['folder'] . '&CKEditorFuncNum=' . $_REQUEST['CKEditorFuncNum']); } else { if ($moved) { $pm->setVariable('file', TYPEF_WEB_DIR . '/files/public/userfiles/' . Typeframe::User()->get('userid') . ($folder ? '/' . $folder : '') . '/' . $moved); } $pm->setVariable('funcnum', $_REQUEST['CKEditorFuncNum']); $pm->setVariable('message', $message); } }
if ('POST' == $_SERVER['REQUEST_METHOD']) { // save typing below $typef_app_dir = TYPEF_WEB_DIR . '/admin/users/groups'; // get and validate user group id $usergroupid = @$_REQUEST['usergroupid']; $usergroup = Model_Usergroup::Get($usergroupid); if (!$usergroup->exists()) { Typeframe::Redirect('No user group provided.', $typef_app_dir, 1); return; } if (in_array($usergroupid, array(TYPEF_DEFAULT_USERGROUPID, TYPEF_ADMIN_USERGROUPID))) { Typeframe::Redirect('Unable to delete primary user groups.', $typef_app_dir, -1); return; } $users = new Model_User(); $users->where('usergroupid = ?', $usergroupid); if ($users->count() > 0) { Typeframe::Redirect('Unable to delete a group containing users. Delete the users or move them to a different group first.', $typef_app_dir, -1); return; } // delete application associations /*$ugadmin = UserGroupAdmin::DAOFactory(); $ugadmin->select()->where('usergroupid = ?', $usergroupid); foreach ($ugadmin->getAll() as $uga) $uga->delete();*/ // delete the user group $usergroup->delete(); // done Typeframe::Redirect('User group deleted.', $typef_app_dir); return; }
if (isset($_POST['action']) && 'Cancel' != $_POST['action']) { $content = array(); foreach ($group['members'] as $member) { $key = $member['name']; if ('image' == $member['type']) { $value = basename(FileManager::GetPostedOrUploadedFile($key, TYPEF_DIR . '/files/public/content')); } elseif (isset($_POST[$key])) { $value = $_POST[$key]; } else { $value = null; } $content[$key] = $value; } $pm->setVariable('row', $content); $pm->setVariable('group', $group); } Typeframe::SetPageTemplate('/admin/content/groups/form-post.html'); } $pm->setVariable('action', $_SERVER['REQUEST_URI']); $pm->setVariable('group', $group); $pm->setVariable('template', $_REQUEST['template']); $pm->setVariable('base', $_REQUEST['base']); if (!empty($_REQUEST['pageid'])) { $pm->setVariable('group_url', TYPEF_WEB_DIR . '/admin/content/groups/form?pageid=' . $_REQUEST['pageid']); } else { $pm->setVariable('group_url', TYPEF_WEB_DIR . '/admin/content/groups/form?plugid=' . $_REQUEST['plugid']); } } else { Typeframe::Redirect('Invalid base.', $typef_app_dir, -1); return; }
/** * Typeframe News application * * admin-side delete controller */ // save some typing below $typef_app_dir = Typeframe::CurrentPage()->applicationUri(); // if not posting, bounce out of here if ('POST' != $_SERVER['REQUEST_METHOD']) { Typeframe::Redirect('Nothing to do.', $typef_app_dir); return; } // create news article object from given id $newsid = @$_POST['newsid']; $article = Model_News_Article::Get($newsid); // news article must exist to proceed if (!$article->exists()) { Typeframe::Redirect('Invalid article id specified.', $typef_app_dir); return; } // current user must be the author of the article or an admin if (Typeframe::User()->get('userid') != $article['authorid'] && Typeframe::User()->get('usergroupid') != TYPEF_ADMIN_USERGROUPID) { Typeframe::Redirect("You cannot delete other users' news items.", $typef_app_dir, 1, false); return; } // perform the delete $article->delete(); // done Typeframe::Redirect('Article has been deleted.', Plugin_Breadcrumbs::SavedState($typef_app_dir));
} // if no errors... if (!$error) { // set values in mailform object; save $values = array(); foreach (array('mailformname', 'message', 'response', 'redirect', 'replyto', 'template') as $field) { $mailform->set($field, trim(@$_POST[$field])); } $mailform->set('multiple', $multiple); $mailform->set('recipient', $recipient); $mailform->set('subject', $subject); $mailform->set('mapping', $mapping); $mailform->set('formfields', trim(@$_POST['fields'])); $mailform->save(); // done; go back to the listing Typeframe::Redirect(Mailform::MODE_ADD == $mode ? 'Mailform added.' : 'Mailform updated.', $typef_app_dir); return; } // otherwise, readd values to template $pm->setVariable('mailform', $_POST); $pm->setVariable('fields', $fields); } else { // add mailform and fields to template $pm->setVariable('mailform', $mailform); $pm->setVariable('fields', $mailform->get('formfields')); // add multiple_data to template, if any if ($mailform->get('multiple')) { $subjects = json_decode($mailform->get('subject')); $recipients = json_decode($mailform->get('recipient')); $mappings = json_decode($mailform->get('mapping')); $multiple_data = array();
Typeframe::Redirect('Unable to connect to FTP server.', Typeframe::CurrentPage()->applicationUri(), -1); return; } if (!$ftp->login($_SESSION['typef_ftp_user'], $_SESSION['typef_ftp_pass'])) { Typeframe::Redirect('Unable to log into FTP server.', Typeframe::CurrentPage()->applicationUri(), -1); return; } $h = tmpfile(); fwrite($h, $_REQUEST['source']); if (!fflush($h)) { die("Failed to flush"); } rewind($h); // Make sure that all required directories exist $dirs = dirname("{$_REQUEST['skin']}{$_REQUEST['stylesheet']}"); $dirnames = split("/", $dirs); $localpath = TYPEF_DIR . '/skins'; $curdir = ''; for ($i = 0; $i < count($dirnames); $i++) { $curdir .= '/' . $dirnames[$i]; if (!file_exists("{$localpath}{$curdir}")) { echo "Making /skins{$curdir}<br/>"; $ftp->mkdir(TYPEF_FTP_ROOT . "/skins{$curdir}"); } } $ftp->fput(TYPEF_FTP_ROOT . "/skins/{$_REQUEST['skin']}{$_REQUEST['stylesheet']}", $h, FTP_ASCII); $ftp->close(); fclose($h); Typeframe::Redirect("Stylesheet updated.", Typeframe::CurrentPage()->applicationUri(), 1); return; }
<?php /** * Change the order of plugins in a socket. */ $typef_app_dir = Typeframe::CurrentPage()->applicationUri(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (!isset($_POST['locid']) || !is_array($_POST['locid'])) { Typeframe::Redirect('Invalid socket plugin ids.', $typef_app_dir); } else { $sortnum = 1; foreach ($_POST['locid'] as $locid) { $plugloc = Model_PlugLoc::Get($locid); $plugloc->set('sortnum', $sortnum); $plugloc->save(); ++$sortnum; } Typeframe::Redirect('Plugins sorted.', $typef_app_dir); } } else { Typeframe::Redirect('Nothing to do.', $typef_app_dir); }
<?php /** * Create a new plugin. */ Plugin_Breadcrumbs::Add('Add'); // save typing below $typef_app_dir = Typeframe::CurrentPage()->applicationUri(); // process form if ('POST' == $_SERVER['REQUEST_METHOD']) { $plug = Model_Plug::Create(); $plug->set('plug', $_POST['plug']); //$plug->set('settings', json_encode((isset($_POST['settings']) && is_array($_POST['settings'])) ? $_POST['settings'] : array())); $plug->set('settings', isset($_POST['settings']) && is_array($_POST['settings']) ? $_POST['settings'] : array()); $plug['siteid'] = Typeframe::CurrentPage()->siteid(); $plug->save(); // done $skin = isset($_REQUEST['skin']) ? "&skin={$_REQUEST['skin']}" : ''; Typeframe::Redirect('Plugin created.', "{$typef_app_dir}/edit?plugid=" . $plug->get('plugid') . $skin); return; } // load plugins; add to template; sort by name foreach (Typeframe::Registry()->plugins() as $plugin) { $pm->addLoop('plugins', array('name' => $plugin->name())); } $pm->sortLoop('plugins', 'name');
<?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { $master = Model_Site_Master::Create(); $master->setArray($_POST, false); $master->save(); Typeframe::Redirect('Master created.', Typeframe::CurrentPage()->applicationUri() . '/masters/pages?masterid=' . $master['id']); }
<?php $form = new Form_Handler_User(!$user->exists() || !empty($_POST['password']) ? true : false); $form->validate(); $errors = $form->errors(); if ($errors) { $pm->setVariable('errors', $errors); $pm->setVariable('user', $form->input()); } else { $user->setArray($_POST, false); $user['password'] = $_POST['password']; $user->save(); if (defined('TYPEF_HOST')) { $sites = Model_User_Site::ForUserId($user['userid']); $sites->deleteQuery(); if (!empty($_POST['admin_siteid'])) { foreach ($_POST['admin_siteid'] as $siteid) { $site = Model_User_Site::Create(); $site['userid'] = $user['userid']; $site['siteid'] = $siteid; $site->save(); } } } Typeframe::Redirect('User saved.', Typeframe::CurrentPage()->applicationUri()); }
<?php $db = Typeframe::Database(); $pm = Typeframe::Pagemill(); $pm->setVariable('typef_dir', TYPEF_DIR); $rs = $db->prepare('SELECT * FROM #__backup WHERE backupid = ?'); $rs->execute($_REQUEST['backupid']); if ($row = $rs->fetch_array()) { $pm->setVariable('backupid', $row['backupid']); $row['datecreated'] = $row['datecreated']; $pm->addLoop('backup', $row); exec('tar -ztf ' . TYPEF_DIR . '/files/secure/backups/' . $row['filename'], $list, $result); if ($result == 0) { foreach ($list as $l) { $pm->addLoop('files', array('filename' => $l)); } } } else { Typeframe::Redirect('The requested backup is not available.', TYPEF_WEB_DIR . '/admin/backups', 3); }
<?php $mailform = Model_Mailform::Get($_REQUEST['mailformid']); if ($mailform->exists()) { include 'form.inc.php'; $log = new Model_Mailform_Log(); $log->where('mailformid = ?', $_REQUEST['mailformid']); /*if ($log->count()) { Typeframe::Redirect( 'This mailform has submissions. If you want to change the fields, it is recommended that you create a new mailform instead.', Typeframe::CurrentPage()->applicationUri(), -1); return; }*/ $pm->setVariable('mailform', $mailform); if ($_SERVER['REQUEST_METHOD'] == 'POST') { require_once 'update.inc.php'; Typeframe::Redirect('Mailform updated.', Typeframe::CurrentPage()->applicationUri()); } } else { Typeframe::Redirect('Invalid mailform specified.', Typeframe::CurrentPage()->applicationUri()); }
<?php /* Comment admin delete controller 24 march 2011: cleanedup 29 march 2011: modified to use Comment class */ // back link $back = Plugin_Breadcrumbs::SavedState(TYPEF_WEB_DIR . '/admin/comments'); // can only process POSTs if ('POST' != $_SERVER['REQUEST_METHOD']) { Typeframe::Redirect('Nothing to do.', $back); return; } // delete given comment $comment = Model_Comment::Get(@$_POST['commentid']); if ($comment->exists()) { $comment->delete(); } // done Typeframe::Redirect('Comment deleted.', $back);
<?php /** * Typeframe News application * * client-side preview controller */ // save some typing below $typef_app_dir = Typeframe::CurrentPage()->applicationUri(); // requires post if ('POST' != $_SERVER['REQUEST_METHOD']) { Typeframe::Redirect('Invalid request method.', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $typef_app_dir); return; } // create news article object $article = new News_Article(); // set author user id and name $article->set('authorid', Typeframe::User()->get('userid')); $article->set('author', @$_POST['author']); // get and validate category id $categoryid = @$_POST['categoryid']; $category = new News_Category($categoryid); if (!$category->exists()) { $category = null; } // get, validate, and set incoming the values $article->set('categoryid', $categoryid); $article->set('title', $_POST['title']); $article->set('article', $_POST['article']); $article->set('status', News_Article::ValidateField('status', @$_POST['status'])); $article->set('pubdate', News_Article::ValidateField('pubdate', @$_POST['pubdate']));
<?php /** * Typeframe News application * * admin-side index controller */ // get sorting options list($sort_options, $sort, $order) = News::GetAdminSortingOptions(); // set sorting in template $pm->setVariable('sort_options', $sort_options); $pm->setVariable('sort', $sort); if (!empty($_REQUEST['pageid'])) { $page = Model_Page::Get($_REQUEST['pageid']); if (!$page->exists() || $page['application'] != 'News' && $page['application'] != 'News RSS') { Typeframe::Redirect('Invalid page specified.', Typeframe::CurrentPage()->applicationUri(), 1); return; } $pm->setVariable('currentpage', $page); } $newspages = new Model_Page(); $newspages->where('application = ?', 'News'); $pm->setVariable('newspages', $newspages); $articles = new Model_News_Article(); $total = $articles->count(); if (!empty($_REQUEST['status'])) { $articles->where('status = ?', $_REQUEST['status']); } $articles->order($order); // set up pagination $page = @$_REQUEST['page'] && ctype_digit($_REQUEST['page']) ? intval($_REQUEST['page']) : 1;
$revisionid = @$_REQUEST['revisionid']; // process form if ('POST' == $_SERVER['REQUEST_METHOD']) { // build content array from post $content = Content::ProcessPOST($inserts, $groups); // add/edit content //$content_plug = new Content_Plug($plugid, $revisionid); $content_plug = Model_Content_Plug::Get($plugid); if (!$content_plug->exists()) { $content_plug = Model_Content_Plug::Create(); $content_plug['plugid'] = $plugid; } $content_plug->set('content', $content); $content_plug->save(); // done; redirect Typeframe::Redirect('Plugin content updated.', $typef_app_dir); return; } // load values from content; add inserts and groups to template //list($plug_content, $inserts, $groups) = Content_Plug::LoadData($plugid, $revisionid, $inserts, $groups); $plug = Model_Content_Plug::Get($plugid); if ($revisionid) { $revision = Model_Content_Plug::Get($revisionid); $plug_content = $revision['data']; } else { $plug_content = $plug['content']; } $pm->setVariable('content', $plug_content); $pm->setVariable('inserts', $inserts); $pm->setVariable('groups', $groups); // add other variables to template
<?php Typeframe::CurrentPage()->registerCallback(Typeframe::CurrentPage()->controllerPath(), function () { if (http_response_code() == 404) { $redirects = new Model_Redirect(); $redirects->where('original = ? OR original = ? OR original = ?', Typeframe::CurrentPage()->uri(), Typeframe::CurrentPage()->uri() . '/', '~' . substr(Typeframe::CurrentPage()->uri(), strlen(TYPEF_WEB_DIR))); $redirect = $redirects->getFirst(); if ($redirect->exists()) { Typeframe::Redirect('Redirecting to ' . $redirect['destination'] . '...', $redirect['destination'], 0, true, 301); } } });
<?php /** * User logout controller. * * Provides a logout form and logs the user out. * * @package User */ // process form if ('POST' == $_SERVER['REQUEST_METHOD']) { Typeframe::User()->logout(); Typeframe::Redirect('Logout complete.', TYPEF_WEB_DIR . '/'); return; } // set template (controller is at root, but template lives in users directory Typeframe::SetPageTemplate('/users/logout.html');
<?php $db = Typeframe::Database(); $pm = Typeframe::Pagemill(); if ($_POST['cmd'] == 'login') { $ftp = new Ftp(); if (!$ftp->connect(TYPEF_FTP_HOST)) { Typeframe::Log("Failed to connect to FTP at '" . TYPEF_FTP_HOST . "'"); $pm->addLoop('errors', array('message' => "Could not connect to '" . TYPEF_FTP_HOST . "'")); } else { if (!$ftp->login($_POST['username'], $_POST['password'])) { Typeframe::Log('FTP login failed'); $pm->addLoop('errors', array('message' => "Login failed.")); } else { Typeframe::Log('FTP login succeeded'); $_SESSION['typef_ftp_user'] = $_POST['username']; $_SESSION['typef_ftp_pass'] = $_POST['password']; Typeframe::Redirect('FTP login confirmed.', $_POST['redirect']); return; } } $pm->setVariable('redirect', $_POST['redirect']); }
<?php /* 29 december 2010: cleanup while trying to add status field to typef_news table; rewrote to use news categories class 3 january 2011: DAOFactory, not DAO_Factory; setCategoryId now static 28 march 2011: merged in HL code 29 march 2011: added page title, header */ // define some handy shortcuts to save typing $settings = Typeframe::CurrentPage()->settings(); if (Typeframe::CurrentPage()->pathInfo()) { Typeframe::IncludeScript('/news/categories/view.php'); return; } if (is_array($settings['categoryid']) && !in_array(0, $settings['categoryid']) && 1 == count($settings['categoryid'])) { Typeframe::Redirect('Redirecting to category listing...', Typeframe::CurrentPage()->applicationUri() . 'categories/' . $settings['categoryid'][0]); return; } // create news category object $categories = News_Category::DAOFactory(); // limit to a particular category id News::SetCategoryId($categories, @$settings['categoryid']); // add categories to template $pm->setVariable('categories', $categories); // add page title and header to template $title = News::GetTitle(); $pm->setVariable('page_title', $title); $pm->setVariable('page_header', $title);
<?php /** * Delete a plugin and remove it from all locations. */ // save typing below $typef_app_dir = Typeframe::CurrentPage()->applicationUri(); // requires POST if ('POST' != $_SERVER['REQUEST_METHOD']) { Typeframe::Redirect('Nothing to do.', $typef_app_dir); return; } // get and validate plugin id $plugid = trim(@$_POST['plugid']); $plug = Model_Plug::Get($plugid); if (!$plug->exists()) { Typeframe::Redirect('Invalid plugin id.', $typef_app_dir); return; } // delete any locations that use this plugin $plug_locs = new Model_PlugLoc(); $plug_locs->where('plugid = ?', $plugid); foreach ($plug_locs->getAll() as $plug_loc) { $plug_loc->delete(); } // delete the plugin itself $plug->delete(); // done Typeframe::Redirect('Plugin deleted.', "{$typef_app_dir}?skin={$_POST['skin']}");
<?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { Model_Redirect::Delete($_POST['id']); Typeframe::Redirect('Redirect deleted.', Typeframe::CurrentPage()->applicationUri()); }
$badCaptcha = false; if (defined('COMMENTS_REQUIRE_CAPTCHA') && COMMENTS_REQUIRE_CAPTCHA && !Typeframe::User()->loggedIn()) { if (!isset($_SESSION['captcha']) || empty($_SESSION['captcha']) || !isset($_POST['captcha']) || $_POST['captcha'] != $_SESSION['captcha']) { $badCaptcha = true; } } if ($badCaptcha) { $pm->addLoop('errors', array('message' => 'Captcha code was incorrect.')); $pm->setVariable('comment', $_POST); } else { $comment = Model_Comment::Create(); $comment->setArray($form->input()); $comment['urlmetaid'] = $_POST['urlmetaid']; $comment['userid'] = Typeframe::User()->get('userid'); $comment->save(); // TODO: Redirect to the originating page. $urlmeta = Model_UrlMeta::Get($section['urlmetaid']); Typeframe::Redirect('Comment submitted.', $urlmeta['fullpath']); } } else { //$pm->setVariable('referer', $referer); // add user input (as comment) to template $pm->setVariable('comment', $_POST); // add section to template //$pm->setVariable('sectionid', $sectionid); // add require captcha flag to template $pm->setVariable('errors', $form->errors()); } } else { Typeframe::Redirect('Nothing to do.', TYPEF_WEB_DIR . '/', -1); }