snipt

Ctrl+h for KB shortcuts
Notice: Snipt is moving away from free accounts on May 1st, 2014. Read more about the transition here.
#30588

PHP

clean filename

1
2
3
4
<?php

// clean filename:
$filename = preg_replace("/[^a-z0-9\-\.]/i", "_" , $filename); 
https://snipt.net/embed/d0742c5953ff7f605e76470beec9f31c/
https://snipt.net/raw/d0742c5953ff7f605e76470beec9f31c/
d0742c5953ff7f605e76470beec9f31c
php
PHP
4
2014-04-20T12:06:56
True
False
/api/public/snipt/30588/
clean-filename
<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 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">// clean filename:</span> </span><span id="L-4"><a name="L-4"></a><span class="nv">$filename</span> <span class="o">=</span> <span class="nb">preg_replace</span><span class="p">(</span><span class="s2">&quot;/[^a-z0-9\-\.]/i&quot;</span><span class="p">,</span> <span class="s2">&quot;_&quot;</span> <span class="p">,</span> <span class="nv">$filename</span><span class="p">);</span> </span></pre></div> </td></tr></table>
clean, file, image, php, upload
#23897

PHP

POST: clean email field

1
2
3
4
<?php

// clean for email field
$email = preg_replace("/[^a-zA-Z0-9@\-_\.]/", "", $_POST['email']);
https://snipt.net/embed/0c467e66a9e431c5541ba77eba830332/
https://snipt.net/raw/0c467e66a9e431c5541ba77eba830332/
0c467e66a9e431c5541ba77eba830332
php
PHP
4
2014-04-23T19:44:48
True
False
/api/public/snipt/23897/
post-clean-email-field
<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 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">// clean for email field</span> </span><span id="L-4"><a name="L-4"></a><span class="nv">$email</span> <span class="o">=</span> <span class="nb">preg_replace</span><span class="p">(</span><span class="s2">&quot;/[^a-zA-Z0-9@\-_\.]/&quot;</span><span class="p">,</span> <span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="nv">$_POST</span><span class="p">[</span><span class="s1">&#39;email&#39;</span><span class="p">]);</span> </span></pre></div> </td></tr></table>
clean, email, form, post
#21545

Bash

Clean .svn

find . -type d -name '.svn' -print0 | xargs -0 rm -rdf
https://snipt.net/embed/0dc6c53c7cbc988706821d2ddaec801c/
https://snipt.net/raw/0dc6c53c7cbc988706821d2ddaec801c/
0dc6c53c7cbc988706821d2ddaec801c
bash
Bash
1
2014-04-17T07:40:44
True
False
/api/public/snipt/21545/
clean-svn
<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 id="L-1"><a name="L-1"></a>find . -type d -name <span class="s1">&#39;.svn&#39;</span> -print0 <span class="p">|</span> xargs -0 rm -rdf </span></pre></div> </td></tr></table>
clean, svn
#9985

Bash

clean mysqldump

mysqldump --disable-extended-insert --add-drop-table -u admin -p`cat /etc/psa/.psa.shadow` dbname tablename > file.sql
https://snipt.net/embed/de52625411e33ab3bf0fc6ed43e2464a/
https://snipt.net/raw/de52625411e33ab3bf0fc6ed43e2464a/
de52625411e33ab3bf0fc6ed43e2464a
bash
Bash
1
2014-04-22T16:36:54
True
False
/api/public/snipt/9985/
clean-mysqldump
<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 id="L-1"><a name="L-1"></a>mysqldump --disable-extended-insert --add-drop-table -u admin -p<span class="sb">`</span>cat /etc/psa/.psa.shadow<span class="sb">`</span> dbname tablename &gt; file.sql </span></pre></div> </td></tr></table>
clean, dump, mysql, mysqldump
#3177

Bash

command line to clear svn files from a working copy so it's like an export

1
2
3
4
# See what will be deleted first...
ls -R /target/directory/path/ | grep "^/.*:$" | grep \.svn
# Delete the files... use with caution - CANNOT UNDO THIS
ls -R /target/directory/path/ | grep "^/.*:$" | grep \.svn | xargs rm -f
https://snipt.net/embed/a2a28062906b16d451fb773b18adbd09/
https://snipt.net/raw/a2a28062906b16d451fb773b18adbd09/
a2a28062906b16d451fb773b18adbd09
bash
Bash
4
2014-04-16T10:14:51
True
False
/api/public/snipt/3177/
command-line-to-clear-svn-files-from-a-working-copy-so-its-like-an-export
<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 id="L-1"><a name="L-1"></a><span class="c"># See what will be deleted first...</span> </span><span id="L-2"><a name="L-2"></a>ls -R /target/directory/path/ <span class="p">|</span> grep <span class="s2">&quot;^/.*:$&quot;</span> <span class="p">|</span> grep <span class="se">\.</span>svn </span><span id="L-3"><a name="L-3"></a><span class="c"># Delete the files... use with caution - CANNOT UNDO THIS</span> </span><span id="L-4"><a name="L-4"></a>ls -R /target/directory/path/ <span class="p">|</span> grep <span class="s2">&quot;^/.*:$&quot;</span> <span class="p">|</span> grep <span class="se">\.</span>svn <span class="p">|</span> xargs rm -f </span></pre></div> </td></tr></table>
.svn, clean, delete, files, svn, workingcopy