本文整理汇总了PHP中Typeframe::Now方法的典型用法代码示例。如果您正苦于以下问题:PHP Typeframe::Now方法的具体用法?PHP Typeframe::Now怎么用?PHP Typeframe::Now使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Typeframe
的用法示例。
在下文中一共展示了Typeframe::Now方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
if ($this->loggedIn()) {
$user = Model_User::Get($_SESSION['typef_user']['userid']);
} else {
if (isset($_COOKIE['typef_userid']) && isset($_COOKIE['typef_passhash'])) {
$user = Model_User::Get($_COOKIE['typef_userid']);
if ($user->exists()) {
if ($user['passhash'] == $_COOKIE['typef_passhash']) {
if ($row = $rs->fetch_array()) {
// Log in user and update cookie
$row = $user->getArray(false);
unset($row['salt']);
unset($row['hashtype']);
$_SESSION['typef_user'] = $row;
setcookie('typef_username', $row['username'], time() + 60 * 60 * 24 * 30, '/');
setcookie('typef_passhash', $row['passhash'], time() + 60 * 60 * 24 * 30, '/');
Typeframe::Log("{$row['username']} logged in via cookie");
}
}
}
}
}
if ($this->loggedIn()) {
$user['lastrequest'] = Typeframe::Now();
$user->save();
}
}
示例2: load
public function load()
{
$this->_data = array();
$host = 'http://' . $_SERVER['SERVER_NAME'];
// This will retrieve all the content pages.
if (Typeframe::Registry()->application('Content')) {
$query = "SELECT uri, nickname,\tapplication FROM #__page";
$rs = Typeframe::Database()->prepare($query);
$rs->execute();
while ($data = $rs->fetch_array()) {
$this->_data[] = array('page' => $host . TYPEF_WEB_DIR . $data['uri'], 'uri' => $data['uri'], 'name' => $data['nickname'] != '' ? $data['nickname'] : $data['uri'], 'application' => $data['application']);
}
}
// And the news pages.
if (Typeframe::Registry()->application('News')) {
$select = new BuildSql_Select();
$select->table('#__news n');
$select->leftJoin('#__news_category ncat', 'ncat.categoryid = n.categoryid');
$select->field('n.*');
$select->field('ncat.categoryname');
$select->group('n.newsid');
$select->order('n.pubdate DESC');
$select->where('n.pubdate <= ?', Typeframe::Now());
$rs = $this->db()->prepare($select->query());
$rs->execute();
while ($row = $rs->fetch_array()) {
$uri = News::GetCategoryUri($row['categoryid']) . '/' . ($row['encodedtitle'] ? $row['encodedtitle'] : $row['newsid']);
$this->_data[] = array('page' => $host . TYPEF_WEB_DIR . $uri, 'uri' => $uri, 'name' => $row['title'], 'application' => $row['categoryname']);
}
}
}
示例3: output
public function output(Pagemill_Data $data, Pagemill_Stream $stream)
{
$this->pluginTemplate = '/news/feed.plug.html';
$default = array('limit' => 5, 'categoryid' => null);
$settings = array_merge($default, $this->attributes());
$articles = new Model_News_Article();
if (!is_null($settings['categoryid'])) {
if (!is_array($settings['categoryid'])) {
$settings['categoryid'] = array($settings['categoryid']);
}
if (!in_array(0, $settings['categoryid'])) {
$articles->where('categoryid IN ?', $settings['categoryid']);
}
}
$articles->where('pubdate <= ?', Typeframe::Now());
$articles->where('expdate >= ? OR expdate = ? OR expdate IS NULL', Typeframe::Now(), '0000-00-00 00:00:00');
$articles->where('status = ?', 'published');
$articles->limit($settings['limit']);
$data = $data->fork();
$data['header'] = $settings['header'];
$data['articles'] = $articles;
parent::output($data, $stream);
}
示例4: Log
/**
* Log a user action to the database.
* @param string $action.
* @param string $fulldesc The full description of the event [optional].
*/
public static function Log($action, $fulldesc = false)
{
if (!$fulldesc) {
$fulldesc = $action;
}
// Also addin the source URL, as that may change and reveal important information.
if (isset($_SERVER['HTTP_HOST'])) {
$fulldesc .= "\n" . 'Source URL: ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
if (isset($_SERVER['HTTP_REFERER'])) {
$fulldesc .= "\n" . 'Referrer URL: ' . $_SERVER['HTTP_REFERER'];
}
} else {
$fulldesc .= "\nN/a";
}
$log = Model_Log::Create();
$log['userid'] = Typeframe::User()->get('userid');
$log['ipaddress'] = @$_SERVER['REMOTED_ADDR'];
$log['package'] = Typeframe::CurrentPage() ? Typeframe::CurrentPage()->application()->package() : '';
$log['application'] = Typeframe::CurrentPage() ? Typeframe::CurrentPage()->application()->name() : '';
$log['action'] = $action;
$log['logdate'] = Typeframe::Now();
$log['fulldesc'] = $fulldesc;
$log->save();
}
示例5: Model_News_Article
// save typing below
$typef_app_dir = Typeframe::CurrentPage()->applicationUri();
// get category id, if any
//$categoryid = News::GetCategoryId();
$settings = Typeframe::CurrentPage()->settings();
// set category id in template
//$pm->setVariable('categoryid', $settings['categoryid']);
// get articles; limit to this category and valid publication date
$articles = new Model_News_Article();
$categories = new Model_News_Category();
if (isset($settings['categoryid']) && is_array($settings['categoryid']) && count($settings['categoryid']) && !in_array(0, $settings['categoryid'])) {
$articles->where('news.categoryid IN ?', $settings['categoryid']);
$categories->where('categoryid IN ?', $settings['categoryid']);
}
$articles->where('pubdate <= ?', Typeframe::Now());
$articles->where('expdate > ? OR expdate = ? OR expdate IS NULL', Typeframe::Now(), '0000-00-00 00:00:00');
$articles->where('status = ?', 'published');
$total = $articles->count();
// set up pagination
$perpage = !empty($settings['perpage']) ? $settings['perpage'] : 20;
$pag = Pagination::Calculate($total, $perpage);
$articles->paginate($pag['page'], $pag['perpage']);
$pm->setVariable('pagination', $pag);
$settings = Typeframe::CurrentPage()->settings();
// add articles, pagination to template
$pm->setVariable('news', $articles);
//$pm->setVariableArray(Pagination::Calculate($articles->getTotal(),
// $perpage, $articles->getCurrentPage()));
// get categories; limit to the given parent category
//$categories = new News_Category_Factory();
$categories = new Model_News_Category();
示例6: update
public function update($record)
{
if ($this->_overwrite || !$record[$this->_field]) {
$record[$this->_field] = Typeframe::Now();
}
}
示例7: header
<?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);
示例8: COUNT
<?php
if (TYPEF_NEWS_OVERDUE_ALERT > 0) {
$rs = $db->prepare('SELECT COUNT(*) AS totalpublished FROM #__news WHERE pubdate <= ?');
$totalpublished = $rs->execute_fetch_value(Typeframe::Now());
if ($totalpublished == 0) {
$pm->addLoop('admin_alerts', array('application' => 'News', 'message' => 'No news articles have been published yet.', 'url' => TYPEF_WEB_DIR . '/admin/news/add'));
return;
}
$rs = $db->prepare('SELECT MAX(pubdate) AS lastpubdate FROM #__news WHERE pubdate <= ?');
$last = $rs->execute_fetch(Typeframe::Now());
$diff = (strtotime(Typeframe::Now()) - strtotime($last['lastpubdate'])) / (60 * 60 * 24);
if ($diff > TYPEF_NEWS_OVERDUE_ALERT) {
$pm->addLoop('admin_alerts', array('application' => 'News', 'message' => 'It has been ' . floor($diff) . ' days since your last published news article.', 'url' => TYPEF_WEB_DIR . '/admin/news/add'));
}
}