本文整理汇总了PHP中Auth::user_id方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::user_id方法的具体用法?PHP Auth::user_id怎么用?PHP Auth::user_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Auth
的用法示例。
在下文中一共展示了Auth::user_id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct($path)
{
$chanbar = ' <ul>
<li id="settings" class="option"><a href="#" class="button">settings</a></li>
<li id="files" class="option"><a href="#" class="button">files</a></li>
<li id="people" class="option"><a href="#" class="button">people</a></li>
</ul>
';
$user = Auth::user();
$curchan = DB::get()->val('SELECT name from channels where user_id = :user_id AND active = 1', array('user_id' => $user->id));
if ($curchan == '') {
$curchan = 'bar';
}
$widgets = Widgets::get_widgets();
$components = array('title' => 'Barchat Home', 'path' => $path, 'chanbar' => $chanbar, 'user_id' => Auth::user_id(), 'username' => $user->username, 'nickname' => $user->nickname, 'session_key' => $user->session_key, 'cur_chan' => addslashes($curchan), 'widgets' => $widgets);
$v = new View($components);
Plugin::call('reload', $user);
//check for user agent
$useragent = $_SERVER['HTTP_USER_AGENT'];
//
if (preg_match('/ip(hone|od|ad)/i', $useragent)) {
$v->render('template-ios');
} else {
$v->render('template');
}
}
示例2: header
function header($header)
{
$toolpanelwidth = DB::get()->val("SELECT value FROM options WHERE user_id = :user_id AND grouping = 'Interface' AND name = 'toolpanel';", array('user_id' => Auth::user_id()));
$header .= <<<HEADER
<script type="text/javascript">
\$(function(){
\tgetToolpanel({$toolpanelwidth});
\t\$('#drawer').width(\$(window).width() - {$toolpanelwidth} - 30);
});
</script>
HEADER;
echo $header;
}
示例3: Acl
function __construct()
{
//Instancia de Codeigniter
self::$ci =& get_instance();
//Instancia de Libreria ACL de Zend Framework
self::$acl = new Acl();
//Informacion del Usuario
self::$user_id = self::$ci->session->userdata('id_usuario');
//Recurso Actual
self::$resource_name = self::$ci->uri->uri_string;
//Verificar si la session existe
self::check_session();
//Inicializar permisos del usuario
self::init_acl();
}
示例4: upload
function upload($path)
{
$access = DB::get()->assoc("SELECT name, value FROM options WHERE grouping = 'Amazon Web Services'");
$s3 = new S3($access['AWS Access Key ID'], $access['AWS Secret Access Key']);
$bucketname = $access['S3 Bucket Name'];
$filename = $_FILES['uploaded']['name'];
$s3filename = $this->_safestring(Auth::user()->username) . '/' . date('YmdHis') . '/' . $filename;
preg_match('%\\.(\\w+)$%', $filename, $matches);
$filetype = $matches[1];
$s3->putObject(S3::inputFile($_FILES['uploaded']['tmp_name']), $bucketname, $s3filename, S3::ACL_PUBLIC_READ, array(), array("Content-Type" => "application/octet-stream", "Content-Disposition" => "attachment; filename=" . urlencode($filename) . ';'));
//echo "Put {$filename} to {$bucketname} at {$s3filename}\n";
$url = "http://{$bucketname}.s3.amazonaws.com/{$s3filename}";
DB::get()->query("INSERT INTO files (user_id, filename, filesize, filetype, url) VALUES (:user_id, :filename, :filesize, :filetype, :url);", array('user_id' => Auth::user_id(), 'filename' => $filename, 'filesize' => $_FILES['uploaded']['size'], 'filetype' => $filetype, 'url' => $url));
$filenumber = DB::get()->lastInsertId();
echo <<<RELOAD_FILES
atbottom = isVisible(\$('#notices tr:last-child'));
\$('#filelisting').load('/files/filelist', function(){
\t\$('body').css('margin-bottom', \$('#command').height() + 15);
\tdo_scroll();
});
send('/file {$filenumber}');
RELOAD_FILES;
}
示例5: save
function save($path)
{
$options = DB::get()->results('SELECT * FROM options WHERE user_id = 0 OR user_id = :user_id', array('user_id' => Auth::user_id()));
foreach ($options as $option) {
if ($option->istoggle) {
if (isset($_POST['option'][$option->id])) {
DB::get()->query('UPDATE options SET value = 1 WHERE id = :id', array('id' => $option->id));
} else {
DB::get()->query('UPDATE options SET value = 0 WHERE id = :id', array('id' => $option->id));
}
} elseif ($option->ispassword) {
if (isset($_POST['option'][$option->id]) && !preg_match('%^\\*+$%', $_POST['option'][$option->id])) {
DB::get()->query('UPDATE options SET value = :value WHERE id = :id', array('id' => $option->id, 'value' => $_POST['option'][$option->id]));
}
} else {
if (isset($_POST['option'][$option->id])) {
DB::get()->query('UPDATE options SET value = :value WHERE id = :id', array('id' => $option->id, 'value' => $_POST['option'][$option->id]));
}
}
}
echo <<<JSOUT
<script type="text/javascript">window.parent.\$('#options').slideToggle('fast');</script>
JSOUT;
}
示例6: create_cart
/**
*
* Create the cart array if it doesn't already exist
*
**/
private static function create_cart()
{
if (!isset($_SESSION[Config::$sitename]['cart'][Auth::user_id()])) {
$_SESSION[Config::$sitename]['cart'][Auth::user_id()] = array();
}
}
示例7: Comment
<?php
#1. LOGIC
Auth::kickout('/pokecart/');
$comment = new Comment();
$comment->load(Route::param('id'));
if ($comment->user_id == Auth::user_id()) {
if (Input::posted()) {
$comment->content = Input::get('message');
$comment->save();
URL::restore();
}
}
Sticky::set('message', $comment->content);
#2. LOAD VIEWS
include VIEWS . 'header.php';
include VIEWS . 'edit_comment.php';
include VIEWS . 'footer.php';
示例8: _get_search_sql
function _get_search_sql(&$sql, &$params, $crit, $fortitle = false)
{
$where = <<<DEFAULT_WHERE
((user_to = 0)
OR
(user_to = :user_id)
OR
(presence.user_id = :user_id))
DEFAULT_WHERE;
$criteria = array();
$limited = false;
$limit = '';
$title = '';
if (preg_match('%date\\s*=\\s*(?P<date>("[^"]+"|\\S+))%i', $crit, $datematches)) {
$crit = preg_replace('%date\\s*=\\s*(?P<date>("[^"]+"|\\S+))%i', '', $crit);
$date = trim($datematches['date'], '"');
$df = date('Y-m-d', strtotime($date));
$dt = date('Y-m-d', strtotime($date) + 86400);
$where .= ' AND (presence.msgtime >= :fromtime) AND (presence.msgtime < :totime)';
$params['fromtime'] = $df;
$params['totime'] = $dt;
$criteria[] = 'On ' . date('D, M j, Y', strtotime($df));
$limited = true;
$title = $df;
}
if (preg_match('%(channel|room)\\s*=\\s*(?P<channel>("[^"]+"|\\S+))%i', $crit, $channelmatches)) {
$channel = $channelmatches['channel'];
$crit = preg_replace('%(channel|room)\\s*=\\s*(?P<channel>("[^"]+"|\\S+))%i', '', $crit);
$where .= ' AND (presence.channel = :channel)';
$params['channel'] = $channel;
$criteria[] = 'In channel "' . htmlspecialchars($channel) . '"';
$title = htmlspecialchars($channel);
}
if ($allowedchannels = DB::get()->col("SELECT room FROM options WHERE grouping = 'Permissions' AND name = 'allowedchannel' AND user_id = :user_id", array('user_id' => Auth::user_id()))) {
$inclause = DB::inclause($allowedchannels, 'allowed');
$where .= ' AND (presence.channel IN (' . implode(',', array_keys($inclause)) . '))';
$params = array_merge($params, $inclause);
}
if ($deniedchannels = DB::get()->col("SELECT room FROM options WHERE grouping = 'Permissions' AND name = 'deniedchannel' AND user_id = :user_id", array('user_id' => Auth::user_id()))) {
$inclause = DB::inclause($deniedchannels, 'denied');
$where .= ' AND (presence.channel NOT IN (' . implode(',', array_keys($inclause)) . '))';
$params = array_merge($params, $inclause);
}
if (preg_match('%(type)\\s*=\\s*(?P<type>("[^"]+"|\\S+))%i', $crit, $typematches)) {
$type = $typematches['type'];
$crit = preg_replace('%(type)\\s*=\\s*(?P<type>("[^"]+"|\\S+))%i', '', $crit);
$where .= ' AND (presence.type = :type)';
$params['type'] = $type;
$criteria[] = 'Message type "' . htmlspecialchars($type) . '"';
$title = htmlspecialchars($type);
}
if (trim($crit) != '') {
$where .= " AND data LIKE CONCAT('%', :crit, '%')";
$params['crit'] = trim($crit);
$criteria[] = '"' . htmlspecialchars(trim($crit)) . '"';
$title = htmlspecialchars(trim($crit));
} else {
if (!$limited) {
$limit = 'LIMIT 100';
$criteria[] = 'Last 100 messages';
}
}
$sql = <<<SEARCH_SQL
SELECT
\tpresence.status,
\tpresence.type,
\tpresence.data,
\tpresence.msgtime,
\tpresence.user_id,
\tpresence.cssclass,
\tpresence.js,
\tpresence.user_to,
\tpresence.received,
\tpresence.channel as inchannel,
\t:searchchannel as channel,
\tusers.username,
\toptions.value as nickname,
\t:crit as crit
FROM
\tpresence
LEFT JOIN
\tusers
\tON presence.user_id = users.id
LEFT JOIN
\toptions
\tON options.user_id = users.id AND options.name = 'Nickname' AND options.grouping = 'Identity'
WHERE
\t{$where}
ORDER BY
\tinchannel DESC,
\tstatus DESC
{$limit}
SEARCH_SQL;
if ($fortitle) {
return $title;
} else {
return implode(' · ', $criteria);
}
}
示例9: Project
<?php
# new_task.php
# 1. logic
$project = new Project();
$project->load(['slug' => Route::param('slug')]);
if (Input::posted()) {
$task = new Task();
$task->fill(Input::all());
$task->user_id = Auth::user_id();
$task->project_id = $project->id;
if (Input::get('name') != "" || Input::get('description') != "") {
$task->save();
}
}
URL::redirect('/' . $project->slug);
示例10: get
public static function get($grouping, $name)
{
$sql = "SELECT * FROM options WHERE grouping = :grouping AND name = :name AND (user_id = 0 OR user_id = :user_id) ORDER BY user_id DESC;";
return DB::get()->row($sql, array('grouping' => $grouping, 'name' => $name, 'user_id' => Auth::user_id()), __CLASS__);
}
示例11: User
<?php
# controllers/user.php
# Logic
if (!Auth::is_logged_in()) {
Auth::kickout('/login');
}
$user = new User();
$user->load(Auth::user_id());
## ------------------------------------------------------------------------
$unpaidaccounts = new Accounts_Collection();
$unpaidaccounts->where('paid', '0');
$unpaidaccounts->where('confirmed', '0');
$unpaidaccounts->where('deleted', '0');
$unpaidaccounts->where('user_id', Auth::user()->id);
$unpaidaccounts->get();
$bills = new Bills_Collection();
$bills->where('deleted', '0');
$bills->where('paid', '0');
foreach ($unpaidaccounts->items as $key => $ua) {
$bills->where('id', $ua->bill_id, true, $key != 0);
}
$bills->order_by('date', 'asc');
if (count($unpaidaccounts->items)) {
$bills->get();
}
$total = 0;
foreach ($bills->items as $bill) {
$total += $bill->splitcost;
}
## ------------------------------------------------------------------------
示例12: Comment
<?php
Auth::kickout('/pokecart/product/' . Route::param('id') . '/view');
$comment = new Comment();
$comment->content = Input::get('message');
$comment->product_id = Route::param('id');
$comment->user_id = Auth::user_id();
$comment->date_time = date('Y-m-d H:i:s');
$comment->save();
URL::redirect('/pokecart/product/' . Route::param('id') . '/view');
示例13: _state_task
function _state_task($list, $taskid, $state = 0)
{
$tasks = $this->_get_tasks($list);
$tasks[$taskid]['state'] = $state;
switch ($state) {
case 1:
$tasks[$taskid]['completed'] = time();
break;
}
DB::get()->query("DELETE FROM options WHERE grouping = 'tasklists' AND name = :name AND user_id = :user_id", array('name' => $list, 'user_id' => Auth::user_id()));
DB::get()->query("INSERT INTO options (grouping, name, user_id, value) VALUES ('tasklists', :name, :user_id, :value);", array('name' => $list, 'user_id' => Auth::user_id(), 'value' => serialize($tasks)));
}
示例14: Projects_Collection
# new_project.php
# 1. logic
AUTH::kickout('login');
$projects = new Projects_Collection();
$projects->where(['deleted' => '0']);
$projects->where(['user_id' => AUTH::user_id()]);
$projects->get();
if (Input::posted()) {
$slug = Input::get('project_name');
$slug = strtolower($slug);
$slug = explode(" ", $slug);
$slug = implode("-", $slug);
$deadline = Input::get('deadline');
$deadline = intval($deadline);
$project = new project();
$project->fill(Input::all());
$project->date = date('Y-m-d H:i:s');
$project->slug = $slug;
$project->user_id = Auth::user_id();
if (Input::get('project_name') != "" || Input::get('project_description') != "") {
$project->save();
URL::redirect('/' . $project->slug);
}
URL::redirect('/new_project');
}
$title = 'New Project';
# 2. views
include VIEWS . 'header.php';
include VIEWS . 'new_project.php';
include VIEWS . 'footer.php';
示例15: ucfirst
<div class="thumbnail comment">
<h3><?php
echo ucfirst($comment->author->username);
?>
</h3>
<p>at <?php
echo date('g:ia y/m/d', strtotime($comment->date_time));
?>
</p>
<p><?php
echo $comment->content;
?>
</p>
<? if(Auth::user_id() == $comment->user_id) : ?>
<a href="/pokecart/delete_comment/<?php
echo $comment->id;
?>
" class="white btn btn-danger">Delete</a>
<a href="/pokecart/edit_comment/<?php
echo $comment->id;
?>
" class="white btn btn-success">Edit</a>
<? endif; ?>