snipt

Ctrl+h for KB shortcuts

PHP

Wordpress: remove generator

1
2
3
4
5
<?php

// in the functions.php, add this:

remove_action('wp_head', 'wp_generator');
https://snipt.net/embed/5adb5e9746431e0854f7a29f1e7d592d/
/raw/5adb5e9746431e0854f7a29f1e7d592d/
5adb5e9746431e0854f7a29f1e7d592d
php
PHP
5
2019-07-31T14:27:54
True
False
False
/api/public/snipt/20732/
wordpress-remove-generator
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="c1">// in the functions.php, add this:</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a><span class="nx">remove_action</span><span class="p">(</span><span class="s1">&#39;wp_head&#39;</span><span class="p">,</span> <span class="s1">&#39;wp_generator&#39;</span><span class="p">);</span> </span></pre></div> </td></tr></table>
wordpress

Bash

.htaccess: Redirect to under construction page

1
2
3
4
5
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_HOST} !^99.41.147.210
RewriteCond %{REQUEST_URI} !/underconstruction\.html$
RewriteRule .* /underconstruction.html [R=302,L]
https://snipt.net/embed/bac9927e3cf2eb6d88b3bb7651c041a7/
/raw/bac9927e3cf2eb6d88b3bb7651c041a7/
bac9927e3cf2eb6d88b3bb7651c041a7
bash
Bash
5
2019-07-20T14:49:53
True
False
False
/api/public/snipt/20069/
htaccess-redirect-to-under-construction-page
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>RewriteEngine On </span><span id="L-2"><a name="L-2"></a>RewriteBase / </span><span id="L-3"><a name="L-3"></a>RewriteCond %<span class="o">{</span>REMOTE_HOST<span class="o">}</span> !^99.41.147.210 </span><span id="L-4"><a name="L-4"></a>RewriteCond %<span class="o">{</span>REQUEST_URI<span class="o">}</span> !/underconstruction<span class="se">\.</span>html$ </span><span id="L-5"><a name="L-5"></a>RewriteRule .* /underconstruction.html <span class="o">[</span><span class="nv">R</span><span class="o">=</span>302,L<span class="o">]</span> </span></pre></div> </td></tr></table>
.htaccess

Bash

.htaccess: Redirect of subfolders

# redirect all pages under directory "budget" to main index page
RedirectMatch "^/budget($|/(.*))$" http://www.site.com/
https://snipt.net/embed/b20a57d5dbb3d23cddff9c8ecb9467d9/
/raw/b20a57d5dbb3d23cddff9c8ecb9467d9/
b20a57d5dbb3d23cddff9c8ecb9467d9
bash
Bash
2
2019-08-20T22:29:35
True
False
False
/api/public/snipt/19589/
htaccess-redirect-of-subfolders
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1"># redirect all pages under directory &quot;budget&quot; to main index page</span> </span><span id="L-2"><a name="L-2"></a>RedirectMatch <span class="s2">&quot;^/budget(</span>$<span class="s2">|/(.*))</span>$<span class="s2">&quot;</span> http://www.site.com/ </span></pre></div> </td></tr></table>
.htaccess

PHP

PHP: mysql return last inserted ID

1
2
3
4
5
<?php

$query = "SELECT LAST_INSERT_ID() FROM $table";
$this->query($query, $result);
return current($result[0]);
https://snipt.net/embed/71fd122c99d0d52a9215041a05a36da1/
/raw/71fd122c99d0d52a9215041a05a36da1/
71fd122c99d0d52a9215041a05a36da1
php
PHP
5
2019-08-14T07:30:13
True
False
False
/api/public/snipt/19191/
php-mysql-return-last-inserted-id
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="nv">$query</span> <span class="o">=</span> <span class="s2">&quot;SELECT LAST_INSERT_ID() FROM </span><span class="si">$table</span><span class="s2">&quot;</span><span class="p">;</span> </span><span id="L-4"><a name="L-4"></a><span class="nv">$this</span><span class="o">-&gt;</span><span class="na">query</span><span class="p">(</span><span class="nv">$query</span><span class="p">,</span> <span class="nv">$result</span><span class="p">);</span> </span><span id="L-5"><a name="L-5"></a><span class="k">return</span> <span class="nb">current</span><span class="p">(</span><span class="nv">$result</span><span class="p">[</span><span class="mi">0</span><span class="p">]);</span> </span></pre></div> </td></tr></table>
mysql, php