Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

PHP

Force Wordpress Admin Login Page to use SSL/HTTPS

1
2
3
4
5
6
7
8
<?php 
if(strstr($_SERVER["REQUEST_URI"],"/wp-login.php") && $_SERVER["HTTPS"] != "on") {
	$newurl = "https://" . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
	header("Location: $newurl");
	echo $newurl;
	exit();
}
?>
https://snipt.net/embed/1cd623503f4af3596ef9d5390b8f85fe/
https://snipt.net/raw/1cd623503f4af3596ef9d5390b8f85fe/
1cd623503f4af3596ef9d5390b8f85fe
php
PHP
8
2016-12-10T11:30:05
True
False
False
Aug 15, 2012 at 10:31 AM
/api/public/snipt/45737/
force-wordpress-admin-login-page-to-use-sslhttps
<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></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 class="k">if</span><span class="p">(</span><span class="nb">strstr</span><span class="p">(</span><span class="nv">$_SERVER</span><span class="p">[</span><span class="s2">&quot;REQUEST_URI&quot;</span><span class="p">],</span><span class="s2">&quot;/wp-login.php&quot;</span><span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="nv">$_SERVER</span><span class="p">[</span><span class="s2">&quot;HTTPS&quot;</span><span class="p">]</span> <span class="o">!=</span> <span class="s2">&quot;on&quot;</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="nv">$newurl</span> <span class="o">=</span> <span class="s2">&quot;https://&quot;</span> <span class="o">.</span> <span class="nv">$_SERVER</span><span class="p">[</span><span class="s2">&quot;SERVER_NAME&quot;</span><span class="p">]</span> <span class="o">.</span> <span class="nv">$_SERVER</span><span class="p">[</span><span class="s2">&quot;REQUEST_URI&quot;</span><span class="p">];</span> </span><span id="L-4"><a name="L-4"></a> <span class="nb">header</span><span class="p">(</span><span class="s2">&quot;Location: </span><span class="si">$newurl</span><span class="s2">&quot;</span><span class="p">);</span> </span><span id="L-5"><a name="L-5"></a> <span class="k">echo</span> <span class="nv">$newurl</span><span class="p">;</span> </span><span id="L-6"><a name="L-6"></a> <span class="k">exit</span><span class="p">();</span> </span><span id="L-7"><a name="L-7"></a><span class="p">}</span> </span><span id="L-8"><a name="L-8"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
compliance, https, pci, redirect, ssl, wordpress

Bash

How to check an SSL connection and server certificate.

$ openssl s_client -host www.google.com -port 443
https://snipt.net/embed/8ca067dd09635938a11b14aac258b867/
https://snipt.net/raw/8ca067dd09635938a11b14aac258b867/
8ca067dd09635938a11b14aac258b867
bash
Bash
1
2016-12-06T08:38:09
True
False
False
/api/public/snipt/29640/
how-to-check-an-ssl-connection-and-server-certificate
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>$ openssl s_client -host www.google.com -port 443 </span></pre></div> </td></tr></table>
certificate, openssl, ssl

Bash

build postfix + sqlite + sasl + ssl

1
2
3
4
5
6
7
8
# download Cyrus SASL (SQLite3 requires >= 2.1.24)
wget http://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-2.1.24rc1.tar.gz

# configure Cyrus
./configure --enable-plain --enable-login --enable-sql --with-configdir=/etc/postfix/sasl/

# configure Postfix for SQLite3 and SASL support
make -f Makefile.init makefiles 'CCARGS=-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -DUSE_TLS -DHAS_SQLITE -I/usr/local/include -I/usr/local/include/sasl' 'AUXLIBS=-L/usr/local/lib -lsasl2 -lssl -lcrypto -lsqlite3 -lpthread'
https://snipt.net/embed/4aea3542888fb5400230e47b78bc7168/
https://snipt.net/raw/4aea3542888fb5400230e47b78bc7168/
4aea3542888fb5400230e47b78bc7168
bash
Bash
8
2016-12-09T14:50:07
True
False
False
/api/public/snipt/29242/
postfix-build
<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></span><span id="L-1"><a name="L-1"></a><span class="c1"># download Cyrus SASL (SQLite3 requires &gt;= 2.1.24)</span> </span><span id="L-2"><a name="L-2"></a>wget http://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-2.1.24rc1.tar.gz </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="c1"># configure Cyrus</span> </span><span id="L-5"><a name="L-5"></a>./configure --enable-plain --enable-login --enable-sql --with-configdir<span class="o">=</span>/etc/postfix/sasl/ </span><span id="L-6"><a name="L-6"></a> </span><span id="L-7"><a name="L-7"></a><span class="c1"># configure Postfix for SQLite3 and SASL support</span> </span><span id="L-8"><a name="L-8"></a>make -f Makefile.init makefiles <span class="s1">&#39;CCARGS=-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -DUSE_TLS -DHAS_SQLITE -I/usr/local/include -I/usr/local/include/sasl&#39;</span> <span class="s1">&#39;AUXLIBS=-L/usr/local/lib -lsasl2 -lssl -lcrypto -lsqlite3 -lpthread&#39;</span> </span></pre></div> </td></tr></table>
postfix, sasl, sqlite, ssl

JavaScript

GeoTrust Graphic

1
2
3
4
<!-- GeoTrust QuickSSL [tm] Smart Icon tag. Do not edit. -->
<script type="text/javascript"
src="//smarticon.geotrust.com/si.js"></script>
<!-- end GeoTrust Smart Icon tag -->
https://snipt.net/embed/0266e51ba2ac28b73cbef27007d2b1d6/
https://snipt.net/raw/0266e51ba2ac28b73cbef27007d2b1d6/
0266e51ba2ac28b73cbef27007d2b1d6
js
JavaScript
4
2016-12-06T00:47:14
True
False
False
/api/public/snipt/28272/
geotrust-graphic
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c">&lt;!--</span> <span class="nx">GeoTrust</span> <span class="nx">QuickSSL</span> <span class="p">[</span><span class="nx">tm</span><span class="p">]</span> <span class="nx">Smart</span> <span class="nx">Icon</span> <span class="nx">tag</span><span class="p">.</span> <span class="nx">Do</span> <span class="nx">not</span> <span class="nx">edit</span><span class="p">.</span> <span class="o">--&gt;</span> </span><span id="L-2"><a name="L-2"></a><span class="o">&lt;</span><span class="nx">script</span> <span class="nx">type</span><span class="o">=</span><span class="s2">&quot;text/javascript&quot;</span> </span><span id="L-3"><a name="L-3"></a><span class="nx">src</span><span class="o">=</span><span class="s2">&quot;//smarticon.geotrust.com/si.js&quot;</span><span class="o">&gt;&lt;</span><span class="err">/script&gt;</span> </span><span id="L-4"><a name="L-4"></a><span class="c">&lt;!--</span> <span class="nx">end</span> <span class="nx">GeoTrust</span> <span class="nx">Smart</span> <span class="nx">Icon</span> <span class="nx">tag</span> <span class="o">--&gt;</span> </span></pre></div> </td></tr></table>
ssl

PHP

check SSL and redirect to SSL if not

1
2
3
4
5
     if ($_SERVER['HTTPS'] != "on") {
    $url = "https://". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
    header("Location: $url");
    exit;
}  
https://snipt.net/embed/ba9fe48af19d756ebbce3331afb3e4c2/
https://snipt.net/raw/ba9fe48af19d756ebbce3331afb3e4c2/
ba9fe48af19d756ebbce3331afb3e4c2
php
PHP
5
2016-12-09T21:09:30
True
False
False
/api/public/snipt/24394/
check-ssl-and-redirect-to-ssl-if-not
<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="x"> if ($_SERVER[&#39;HTTPS&#39;] != &quot;on&quot;) {</span> </span><span id="L-2"><a name="L-2"></a><span class="x"> $url = &quot;https://&quot;. $_SERVER[&#39;SERVER_NAME&#39;] . $_SERVER[&#39;REQUEST_URI&#39;];</span> </span><span id="L-3"><a name="L-3"></a><span class="x"> header(&quot;Location: $url&quot;);</span> </span><span id="L-4"><a name="L-4"></a><span class="x"> exit;</span> </span><span id="L-5"><a name="L-5"></a><span class="x">} </span> </span></pre></div> </td></tr></table>
php, redirect, ssl
Copyrighted, illegal, or inappropriate content? Email [email protected].