snipt

Ctrl+h for KB shortcuts

Text only

Check if logged in

1
2
3
4
5
6
7
$user = JFactory::getUser();
if($user->id){
      // do something because user is logged in
}
esle{
      // do something because user is not logged in
}
https://snipt.net/embed/36ab338cb18ebbd002ec051fca5afe19/
https://snipt.net/raw/36ab338cb18ebbd002ec051fca5afe19/
36ab338cb18ebbd002ec051fca5afe19
text
Text only
7
2016-09-28T21:06:56
True
False
False
Dec 03, 2013 at 06:10 AM
/api/public/snipt/98156/
check-if-logged-in
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>$user = JFactory::getUser(); </span><span id="L-2"><a name="L-2"></a>if($user-&gt;id){ </span><span id="L-3"><a name="L-3"></a> // do something because user is logged in </span><span id="L-4"><a name="L-4"></a>} </span><span id="L-5"><a name="L-5"></a>esle{ </span><span id="L-6"><a name="L-6"></a> // do something because user is not logged in </span><span id="L-7"><a name="L-7"></a>} </span></pre></div> </td></tr></table>
joomla, login, user

PHP

Automatically redirect to current page after login

1
2
3
4
5
6
7
8
/****************
WordPress have a great function named wp_login_url(). This function displays a link to your dashboard login page. It accept one parameter: an url to redirect after the user successfully logged in. By using get_permalink() as a parameter, you'll redirect the user to the current page.

source: http://www.wprecipes.com/automatically-redirect-to-current-page-after-login?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+Wprecipes+(WpRecipes.com:+Daily+recipes+to+cook+with+WordPress)

*****************/

<a href="<?php echo wp_login_url(get_permalink()); ?>" title="Login">Login to view</a>
https://snipt.net/embed/dbc343b91d27d748ff010518ce09dd65/
https://snipt.net/raw/dbc343b91d27d748ff010518ce09dd65/
dbc343b91d27d748ff010518ce09dd65
php
PHP
8
2016-09-28T11:17:08
True
False
False
/api/public/snipt/26516/
automatically-redirect-to-current-page-after-login-1
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="x">/****************</span> </span><span id="L-2"><a name="L-2"></a><span class="x">WordPress have a great function named wp_login_url(). This function displays a link to your dashboard login page. It accept one parameter: an url to redirect after the user successfully logged in. By using get_permalink() as a parameter, you&#39;ll redirect the user to the current page.</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="x">source: http://www.wprecipes.com/automatically-redirect-to-current-page-after-login?utm_source=feedburner&amp;utm_medium=feed&amp;utm_campaign=Feed:+Wprecipes+(WpRecipes.com:+Daily+recipes+to+cook+with+WordPress)</span> </span><span id="L-5"><a name="L-5"></a> </span><span id="L-6"><a name="L-6"></a><span class="x">*****************/</span> </span><span id="L-7"><a name="L-7"></a> </span><span id="L-8"><a name="L-8"></a><span class="x">&lt;a href=&quot;</span><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nx">wp_login_url</span><span class="p">(</span><span class="nx">get_permalink</span><span class="p">());</span> <span class="cp">?&gt;</span><span class="x">&quot; title=&quot;Login&quot;&gt;Login to view&lt;/a&gt;</span> </span></pre></div> </td></tr></table>
functions, login, wordpress

Bash

reboot time

1
2
3
4
5
6
7
8
# last reboot times
last reboot | head -10

# or
who -b

# login times
last -x | head -10
https://snipt.net/embed/ccd21fe2c3c4e63c3e781a9afb7be4eb/
https://snipt.net/raw/ccd21fe2c3c4e63c3e781a9afb7be4eb/
ccd21fe2c3c4e63c3e781a9afb7be4eb
bash
Bash
8
2016-09-22T15:23:58
True
False
False
/api/public/snipt/23855/
reboot-time
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="c"># last reboot times</span> </span><span id="L-2"><a name="L-2"></a>last reboot <span class="p">|</span> head -10 </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="c"># or</span> </span><span id="L-5"><a name="L-5"></a>who -b </span><span id="L-6"><a name="L-6"></a> </span><span id="L-7"><a name="L-7"></a><span class="c"># login times</span> </span><span id="L-8"><a name="L-8"></a>last -x <span class="p">|</span> head -10 </span></pre></div> </td></tr></table>
login, reboot
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.