Skip to content

Instantly share code, notes, and snippets.

<?php
//original article is here http://css-tricks.com/snippets/php/sanitize-database-inputs/
function cleanInput($input) {
$search = array(
'@<script[^>]*?>.*?</script>@si', // Strip out javascript
'@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags
@microweber
microweber / MW.md
Last active December 20, 2015 22:19
Micreoweber doc

Microweber: the Drag-and-Drop CMS

Microweber is a content management system of new generation that allows you to make your website by drag and drop.

You can easily manipulate the content and the layout of your pages without the need to write code.

Try the demo here

Download the latest version from here

<?php
class Foo {
public function bar() {
echo 'foo';
}
}
class Bar {
private $foo;
<?php
action_hook('before_user_login', 'my_user_login');
function my_user_login($params)
{
@microweber
microweber / Cpanel auto make db
Created July 12, 2013 12:26
Cpanel auto make db
http://forums.cpanel.net/f42/auto-creation-mysql-db-postwwwacct-166494.html
#!/usr/bin/php -q
<?php
//set error handling so any warnings are logged
ini_set('error_log','/usr/local/cpanel/logs/error_log');
ini_set('display_errors',0);
<?php
function svgScaleHack($svg, $minWidth, $minHeight)
{
$reW = '/(.*<svg[^>]* width=")([\d.]+px)(.*)/si';
$reH = '/(.*<svg[^>]* height=")([\d.]+px)(.*)/si';
preg_match($reW, $svg, $mw);
preg_match($reH, $svg, $mh);
if(!isset($mw[2]) and isset($mh[2])){
$mw[2] = $mh[2];
@microweber
microweber / LICENSE
Created November 11, 2012 14:07 — forked from mcollina/LICENSE
NetworkButton MQTT Example
Copyright (c) 2008-2012 Nicholas O'Leary
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
@microweber
microweber / gist:3683058
Created September 9, 2012 06:52
Gets a string between two key words and/or phrases.
<?php
function textbetweenarray($s1,$s2,$s){
$myarray=array();
$s1=strtolower($s1);
$s2=strtolower($s2);
$L1=strlen($s1);
$L2=strlen($s2);
$scheck=strtolower($s);
do {
@microweber
microweber / gist:3663864
Created September 7, 2012 06:37
PHp read large file
/**
* Demonstrate an efficient way to search the last 100 lines of a file
* containing roughly ten million lines for a sample string. This should
* function without having to process each line of the file (and without making
* use of the “tail” command or any external system commands).
*/
$filename = '/opt/local/apache2/logs/karwin-access_log';
$searchString = 'index.php';
$numLines = 100;
<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.