<?php $file = isset($_REQUEST['file']) ? $_REQUEST['file'] : ''; if ($file && file_exists(TYPEF_DIR . $file) && is_file(TYPEF_DIR . $file)) { header('Content-type: text/css'); $dir = dirname($file); $md5 = md5($file) . '.css'; $dst = TYPEF_DIR . '/files/cache/lessphp/' . $md5; lessc::ccompile(TYPEF_DIR . $file, $dst); $css = SimpleCss::LoadFile($dst, TYPEF_WEB_DIR . $dir); $code = $css->toString(); preg_match_all('/url\\(\\"([\\w\\W\\s\\S]*?)"\\)/', $code, $matches); if (isset($matches[1])) { foreach ($matches[1] as $url) { $url = Typeframe_Attribute_Url::ConvertShortUrlToExpression($url); $url = Typeframe::Pagemill()->data()->parseVariables($url); $code = str_replace($matches[1], $url, $code); } } echo $code; exit; } else { http_response_code(404); Typeframe::SetPageTemplate('/404.html'); Typeframe::CurrentPage()->stop(); }
<?php $db = Typeframe::Database(); $pm = Typeframe::Pagemill(); Typeframe::SetPageTemplate('/admin/applications/index.html'); foreach (Typeframe::Registry()->applications() as $a) { $app = array('name' => $a->name(), 'title' => $a->title(), 'map' => $a->map()); $pm->addLoop('applications', $app); if ($a->map() == 'hard') { $pm->addLoop('applications', 'pages', array('uri' => TYPEF_WEB_DIR . $a->base())); } else { // TODO: Figure out what to do about soft-mapped pages /* foreach (Typeframe::Registry()->getApplicationPagesByName($a->name()) as $p) { $pm->addLoop('applications', 'pages', array('uri' => $p->uri())); } */ } } $pm->sortLoop('applications', 'name');
<?php $db = Typeframe::Database(); $pm = Typeframe::Pagemill(); if (empty($_SESSION['typef_ftp_user']) || empty($_SESSION['typef_ftp_pass'])) { if (defined('TYPEF_FTP_USER') && defined('TYPEF_FTP_PASS') && TYPEF_FTP_USER != '') { // Test the provided credentials $ftp = new Ftp(); $ftp->connect(TYPEF_FTP_HOST) or die('Invalid FTP host.'); if ($ftp->login(TYPEF_FTP_USER, TYPEF_FTP_PASS)) { $_SESSION['typef_ftp_user'] = TYPEF_FTP_USER; $_SESSION['typef_ftp_pass'] = TYPEF_FTP_PASS; $ftp->close(); return; } } $pm->setVariable('redirect', $_SERVER['REQUEST_URI']); Typeframe::SetPageTemplate('/admin/ftp/login.html'); Typeframe::CurrentPage()->stop(); }
$userid = $user->get('userid'); $resetkey = randomID(); $expire = date('Y-m-d H:i:s', time() + 86400); // create an entry in the password reset table $reset = Model_UserReset::Create(); $reset->set('userid', $userid); $reset->set('resetkey', $resetkey); $reset->set('expire', $expire); $reset->save(); // construct e-mail body $mm = new Pagemill($pm->root()->fork()); $mm->setVariable('username', $user->get('username')); $mm->setVariable('reseturl', sprintf('http://%s%s/password?userid=%d&resetkey=%s', $_SERVER['HTTP_HOST'], TYPEF_WEB_DIR, $userid, $resetkey)); $body = str_replace('&', '&', $mm->writeString('<pm:include template="/users/reset.eml" />', true)); // e-mail the user so they can reset their password $mailer = new Mailer(); $mailer->Configure(); $mailer->IsHTML(true); $mailer->AddAddress($_POST['email']); $mailer->Subject = 'Request to Reset Password for ' . TYPEF_TITLE; $mailer->Body = $body; $mailer->Send(); $pm->setVariable('reset_email_sent', true); Typeframe::Log('Request to reset password for ' . $_POST['email']); } else { $pm->setVariable('reset_email_failed', true); } } // set template (controller is at root, but template lives in users directory Typeframe::SetPageTemplate('/users/password-reset.html');
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; }
/** * Redirect the request to a new URL. * @param string $message Message to display. * @param string $url The URL where the request will be redirected. * @param int $sec Seconds to pause (0 for instant, -1 to wait for user interaction) * @param bool $addHeader True to add a Location header to the response * @param int $responseCode The HTTP response code (0 to use existing code, usu. 200) * @param string $postOverride The name of a POST variable that can override the $url parameter */ public function redirect($message, $url, $sec = TYPEF_DEFAULT_REDIRECT_TIME, $addHeader = false, $responseCode = 0, $postOverride = 'post_redir') { if ($postOverride && !empty($_POST[$postOverride])) { // TODO: This is weird. Why isn't this value decoded already? $url = urldecode($_POST[$postOverride]); } if (substr($url, 0, 7) != "http://" && substr($url, 0, 8) != "https://") { if ($_SERVER['SERVER_PORT'] != '443') { $url = "http://" . $_SERVER["SERVER_NAME"] . $url; } else { $url = "https://" . $_SERVER["SERVER_NAME"] . $url; } } if ($sec == 0 || $addHeader == true) { // Include a Location redirect in the HTML headers $this->_redirectHeader = true; } else { $this->_redirectHeader = false; } $this->_redirectLocation = $url; $this->_redirectResponseCode = $responseCode ? $responseCode : 302; Typeframe::Pagemill()->setVariable("message", $message); Typeframe::Pagemill()->setVariable("url", $url); Typeframe::Pagemill()->setVariable("time", $sec); Typeframe::SetPageTemplate('/redirect.html'); // TODO: This might be a bad place for this line. Technically, I'm not sure that // HTMLTag should be a required part of the kernel. //Pagemill_Tag_Stylesheets::AddStylesheet('/redirect.css'); }
} $mail->Subject = $mailform['subject'] ? $mailform['subject'] : 'Mailform Submission'; $mail->Body = $body; if (!$mail->Send()) { throw new Exception($mail->ErrorInfo); } } $pm->setVariable('response', $mailform['response']); $pm->setVariable('referer', @$_SERVER['HTTP_REFERER']); if ($mailform['redirect']) { if (requestIsAjax()) { header('Content-Type: text/json'); $response = array('status' => 'ok', 'redirect' => $pm->data()->parseVariables(Typeframe_Attribute_Url::ConvertShortUrlToExpression($mailform['redirect']))); echo json_encode($response); exit; } else { Typeframe::Redirect('Submission received.', $pm->data()->parseVariables(Typeframe_Attribute_Url::ConvertShortUrlToExpression($mailform['redirect']))); } } else { Typeframe::SetPageTemplate('/mailform/completed.html'); } } else { $pm->setVariable('errors', $formHandler->errors()); if (requestIsAjax()) { header('Content-Type: text/json'); $response = array('status' => 'error', 'errors' => $formHandler->errors()); echo json_encode($response); exit; } } }
<?php $db = Typeframe::Database(); $pm = Typeframe::Pagemill(); Typeframe::SetPageTemplate('/admin/skins/index.html'); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $skins = array('TYPEF_SITE_SKIN', 'TYPEF_ADMIN_SKIN', 'TYPEF_MOBILE_SITE_SKIN', 'TYPEF_MOBILE_ADMIN_SKIN'); $key = $_POST['config']; if (in_array($key, $skins)) { $config = Model_Config::Get($key); if ($config->exists()) { $config['configvalue'] = $_POST['skin']; } else { $config = Model_Config::Create(); $config['configname'] = $key; $config['configvalue'] = $_POST['skin']; } $config->save(); Typeframe::Registry()->purgeRegistryCache(); } Typeframe::Redirect('Skins updated.', Typeframe::CurrentPage()->applicationUri()); return; } foreach (Typeframe::GetSkins() as $skin) { $row = array(); $row['skin'] = $skin; if (file_exists(TYPEF_DIR . "/skins/{$skin}/config.xml")) { $row['configurable'] = true; } else { $row['configurable'] = false; }
<?php //include_once(TYPEF_SOURCE_DIR . '/classes/sitemap.class.php'); //$sm = new Sitemap(); //$pm->setVariable('pages', $sm->getAsArray()); $host = $_SERVER['SERVER_NAME']; foreach (Typeframe::Registry()->pages() as $page) { if ($page->pageid()) { $pm->addLoop('pages', array('page' => 'https://' . $host . $page->uri(), 'uri' => $page->uri(), 'name' => $page->title(), 'application' => $page->application()->name())); if (file_exists(TYPEF_SOURCE_DIR . '/scripts' . $page->application()->base() . '/sitemap.php')) { include TYPEF_SOURCE_DIR . '/scripts' . $page->application()->base() . '/sitemap.php'; } } } Typeframe::SetPageTemplate('/sitemap.html');
<?php Typeframe::SetPageTemplate('/mailform/validator.js'); header('Content-Type: text/javascript; charset=utf-8');
// create an entry in the user confirmation table $user_confirm = Model_UserConfirm::Create(); $user_confirm->set('confirmkey', $confirmkey); $user_confirm->set('userid', $userid); $user_confirm->set('expire', $expire); $user_confirm->save(); // construct e-mail body $mm = new Pagemill($pm->root()->fork()); $mm->setVariable('username', $user->get('username')); $mm->setVariable('confirmurl', sprintf('http://%s%s/confirm?userid=%d&confirmkey=%s', $_SERVER['HTTP_HOST'], TYPEF_WEB_DIR, $userid, $confirmkey)); $body = str_replace('&', '&', $mm->writeString('<pm:include template="/users/register/confirmation.eml" />', true)); // e-mail the user so they can confirm their registration $mailer = new Mailer(); $mailer->Configure(); $mailer->IsHTML(true); $mailer->AddAddress($_POST['email']); $mailer->Subject = 'Your Account Confirmation from ' . TYPEF_TITLE; $mailer->Body = $body; $mailer->Send(); } else { // if confirmation is not required, log the user in immediately Typeframe::User()->login($_POST['username'], $_POST['password']); Typeframe::Redirect('Registration complete. Welcome!', TYPEF_WEB_DIR . '/', 1); return; } // registratino is complete Typeframe::SetPageTemplate('/users/register/complete.html'); } } // populate form fields $pm->setVariable('fields', $form->fields());
<?php /** * Typeframe News application * * client-side rss controller */ // set the appropriate content type header('Content-Type: application/rss+xml'); // set the template Typeframe::SetPageTemplate('/news/rss.xml'); // add title, description, link, and lastbuild date to template $pm->setVariable('title', TYPEF_TITLE); $pm->setVariable('description', TYPEF_TITLE . ' News'); $pm->setVariable('link', 'http://' . $_SERVER['HTTP_HOST']); $pm->setVariable('lastbuild', date('D, d M Y H:i:s T')); // get articles; limit to published if non-admin $articles = new Model_News_Article(); $articles->where('pubdate <= ?', Typeframe::Now()); $articles->limit('0, 10'); // add articles to template $pm->setVariable('items', $articles);
<?php $db = Typeframe::Database(); $pm = Typeframe::Pagemill(); Typeframe::SetPageTemplate('/index.html');
<?php Typeframe::SetPageTemplate('/admin/users/update.html'); $usergroups = new Model_Usergroup(); $pm->setVariable('usergroups', $usergroups); if (defined('TYPEF_HOST')) { $sites = new Model_Site(); $pm->setVariable('sites', $sites); }
<?php $db = Typeframe::Database(); $pm = Typeframe::Pagemill(); Typeframe::SetPageTemplate('.'); if (isset($_POST['cmd']) && $_POST['cmd'] == 'backup-delete') { $rs = $db->prepare('SELECT * FROM #__backup WHERE backupid = ?'); if ($row = $rs->execute_fetch($_REQUEST['backupid'])) { if (file_exists(TYPEF_DIR . '/files/secure/backups/' . $row['filename'])) { unlink(TYPEF_DIR . '/files/secure/backups/' . $row['filename']); } $rs = $db->prepare('DELETE FROM #__backup WHERE backupid = ?'); $rs->execute($_REQUEST['backupid']); Typeframe::Redirect('Backup deleted.', Typeframe::CurrentPage()->applicationUri()); return; } else { Typeframe::Redirect('Invalid backup specified.', Typeframe::CurrentPage()->applicationUri(), 1); return; } } $rs = $db->prepare('SELECT * FROM #__backup ORDER BY datecreated DESC'); $rs->execute(); while ($row = $rs->fetch_array()) { $pm->addLoop('backups', $row); }
<?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 Typeframe::SetPageTemplate('/ckeditor/config.js'); header('Content-Type: text/javascript; charset=utf-8');