/** * Verifies the site meets any requirements specified by the app or theme. */ public static function verify_requires($requires) { if (isset($requires->php) && version_compare(PHP_VERSION, $requires->php) < 0) { self::$error = i18n_getf('Verification failed: This install requires PHP %s or newer.', $requires->php); return false; } if (isset($requires->elefant) && version_compare(ELEFANT_VERSION, $requires->elefant) < 0) { self::$error = i18n_getf('Verification failed: This install requires Elefant %s or newer.', $requires->elefant); return false; } return true; }
<?php /** * Forwards a user to the specified URL location * if they match a specific access level. * Works as a dynamic object to be embedded * into the WYSIWYG editor. */ $url = isset($data['to']) ? $data['to'] : $_GET['to']; $user_type = isset($data['user_type']) ? $data['user_type'] : $_GET['user_type']; if (User::is_valid() && User::is('admin')) { printf('<p>%s:</p><p><a href="%s">%s</a></p>', i18n_getf('This page forwards members of the %s group to the following link', $user_type), $url, $url); return; } if (User::is($user_type)) { $this->redirect($url); }
$imported = 0; try { $posts = new SimpleXMLElement(file_get_contents($file)); foreach ($posts->channel->item as $entry) { $dc = $entry->children('http://purl.org/dc/elements/1.1/'); $content = $entry->children('http://purl.org/rss/1.0/modules/content/'); $post = array('title' => (string) $entry->title, 'author' => (string) $dc->creator, 'ts' => gmdate('Y-m-d H:i:s', strtotime($entry->pubDate)), 'published' => $_POST['published'], 'body' => str_replace("\n", "<br />\n", (string) $content->encoded), 'tags' => ''); $sep = ''; for ($i = 0; $i < count($entry->category); $i++) { $post['tags'] .= $sep . $entry->category[$i]->attributes()->nicename; $sep = ', '; } $p = new blog\Post($post); if ($p->put()) { Versions::add($p); $imported++; } } echo '<p>' . i18n_getf('Imported %d posts.', $imported) . '</p>'; echo '<p><a href="/blog/admin">' . i18n_get('Continue') . '</a></p>'; } catch (Exception $e) { echo '<p><strong>' . i18n_get('Error importing file') . ': ' . $e->getMessage() . '</strong></p>'; echo '<p><a href="/blog/admin">' . i18n_get('Back') . '</a></p>'; } return; } else { echo '<p><strong>' . i18n_get('Error uploading file.') . '</strong></p>'; } } $o = new StdClass(); echo $tpl->render('blog/import/wordpress', $o);
<?php /** * Displays a list of blog posts by author. */ $page->layout = $appconf['Blog']['layout']; require_once 'apps/blog/lib/Filters.php'; $page->limit = 10; $page->author = urldecode($this->params[0]); if (!$page->author) { $this->redirect('/blog'); } $page->num = count($this->params) > 1 && is_numeric($this->params[1]) ? $this->params[1] - 1 : 0; $page->offset = $page->num * $page->limit; $p = new blog\Post(); $posts = $p->by($page->author, $page->limit, $page->offset); $page->count = $p->query()->where('published', 'yes')->where('author', $page->author)->count(); $page->last = $page->offset + count($posts); $page->more = $page->count > $page->last ? true : false; $page->next = $page->num + 2; foreach ($posts as $post) { $post->url = '/blog/post/' . $post->id . '/' . URLify::filter($post->title); $post->tag_list = explode(',', $post->tags); echo $tpl->render('blog/post', $post); } $page->title = i18n_getf('Posts by %s', $tpl->sanitize($page->author)); $page->add_script(sprintf('<link rel="alternate" type="application/rss+xml" href="http://%s/blog/rss" />', $_SERVER['HTTP_HOST'])); echo $tpl->render('blog/by', $page);
function test_getf() { global $i18n; $i18n->lang_hash['en'] = array('Hello %s' => 'Bonjour %s'); $this->assertEquals(i18n_getf('Hello %s', 'world'), 'Bonjour world'); }
} } for ($i = 0; $i < count($_FILES['file']['name']); $i++) { if (@file_exists($root . $_POST['path'] . '/' . $_FILES['file']['name'][$i])) { $page->title = i18n_get('File Already Exists') . ': ' . $_FILES['file']['name'][$i]; echo '<p>' . i18n_get('A file by that name already exists.') . '</p>'; echo '<p><a href="/filemanager">' . i18n_get('Back') . '</a></p>'; return; } } $count = 0; $errors = array(); for ($i = 0; $i < count($_FILES['file']['name']); $i++) { if (@move_uploaded_file($_FILES['file']['tmp_name'][$i], $root . $_POST['path'] . '/' . $_FILES['file']['name'][$i])) { $count++; @chmod($root . $_POST['path'] . '/' . $_FILES['file']['name'][$i], 0777); $this->hook('filemanager/add', array('file' => $_POST['path'] . '/' . $_FILES['file']['name'])); } else { $errors[] = $_FILES['file']['name'][$i]; } } if (count($_FILES['file']) > 1) { if (count($_FILES['file']['name']) === $count) { $this->add_notification(i18n_getf('%d files saved.', $count)); } else { $this->add_notification(i18n_getf('%d file saved. Unable to save files: %s', $count, join(', ', $errors))); } } else { $this->add_notification(i18n_get('File saved.')); } $this->redirect('/filemanager?path=' . $_POST['path']);
<?php $page->title = i18n_get('Too many login attempts'); printf('<p>%s</p>', i18n_getf('Your account has been locked temporarily as a security precaution. Please try again in %d minutes.', $appconf['User']['block_attempts_for'] / 60));
<?php /** * Displays a list of blog posts by tag. */ $page->layout = $appconf['Blog']['layout']; require_once 'apps/blog/lib/Filters.php'; $page->limit = 10; $page->tag = $this->params[0]; if (!$page->tag) { $this->redirect('/blog'); } $page->num = count($this->params) > 1 && is_numeric($this->params[1]) ? $this->params[1] - 1 : 0; $page->offset = $page->num * $page->limit; $p = new blog\Post(); $posts = $p->tagged($page->tag, $page->limit, $page->offset); $page->count = $p->count_by_tag($page->tag); $page->last = $page->offset + count($posts); $page->more = $page->count > $page->last ? true : false; $page->next = $page->num + 2; foreach ($posts as $post) { $post->url = '/blog/post/' . $post->id . '/' . URLify::filter($post->title); $post->tag_list = explode(',', $post->tags); echo $tpl->render('blog/post', $post); } $page->title = i18n_getf('Tagged: %s', $tpl->sanitize($page->tag)); $page->add_script(sprintf('<link rel="alternate" type="application/rss+xml" href="http://%s/blog/rss" />', $_SERVER['HTTP_HOST'])); echo $tpl->render('blog/tag', $page);
$o->failed = $f->failed; echo "<form method='post'>\n"; $timepicker_loaded = false; // generate the form fields foreach ($fields as $field) { // disable auto-incrementing fields if (DBMan::is_auto_incrementing($field)) { printf('<input type="hidden" name="%s" value="%s" />' . "\n", $field->name, $o->{$field->name}); continue; } if (isset($f->rules[$field->name]['type']) && $f->rules[$field->name]['type'] == 'numeric') { $rule = ' <span class="notice" id="' . $field->name . '-notice">' . i18n_getf('You must enter a number for %s', $field->name) . '</span>'; } elseif (isset($f->rules[$field->name]['length'])) { $rule = ' <span class="notice" id="' . $field->name . '-notice">' . i18n_getf('You must enter a value for %s no longer than %s', $field->name, $field->length) . '</span>'; } elseif (isset($f->rules[$field->name]['not empty'])) { $rule = ' <span class="notice" id="' . $field->name . '-notice">' . i18n_getf('You must enter a value for %s', $field->name) . '</span>'; } else { $rule = ''; } switch ($field->type) { case 'text': printf('<p>%s:<br /><textarea name="%s" cols="60" rows="8">%s</textarea>%s</p>' . "\n", $field->name, $field->name, Template::quotes($o->{$field->name}), $rule); break; case 'date': if (!$timepicker_loaded) { $page->add_script('/js/jquery-ui/jquery-ui.css'); $page->add_script('/js/jquery-ui/jquery-ui.min.js'); $page->add_script('<style> /* css for timepicker */ .ui-timepicker-div .ui-widget-header{ margin-bottom: 8px; } .ui-timepicker-div dl{ text-align: left; }