Skip to content

Instantly share code, notes, and snippets.

Lawrence Cherone lcherone

Block or report user

Report or block lcherone

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@lcherone
lcherone / gist:67039196dadafacf33c7
Last active Aug 29, 2015
Curl multi function GET snippet
View gist:67039196dadafacf33c7
<?php
function curl_multi($urls = array()) {
$curl = array();
$result = array();
$mh = curl_multi_init();
foreach ($urls as $id=>$url) {
$curl[$id] = curl_init();
curl_setopt($curl[$id], CURLOPT_URL, $url);
curl_setopt($curl[$id], CURLOPT_HEADER, 0);
@lcherone
lcherone / gist:6f8043447f7f0099d430
Created May 3, 2014
Swere words for swear_filter function
View gist:6f8043447f7f0099d430
*damn
*dyke
*fuck*
*shit*
4r5e
5h1t
5hit
@$$
a55
ahole
@lcherone
lcherone / gist:ffee79694aefee1bf28e
Created May 3, 2014
HTTP Request Class to rebuild RAW request from $_SERVER
View gist:ffee79694aefee1bf28e
/**
* Access the HTTP Request
*
* Found on http://www.daniweb.com/web-development/php/code/216846/get-http-request-headers-and-body
*/
class http_request {
/** additional HTTP headers not prefixed with HTTP_ in $_SERVER superglobal */
public $add_headers = array('CONTENT_TYPE', 'CONTENT_LENGTH');
View gist:20708371fe07998a24d3
<?php
session_start();
/**
* Simple OMC pool API class
*
* @author Lawrence Cherone
* @version 0.01
*/
class omc{
@lcherone
lcherone / gist:f5a3d4859c0d11cba868
Last active Aug 29, 2015
http://mattsmines.net/ OMC pool API class (With curl_multi example)
View gist:f5a3d4859c0d11cba868
<?php
session_start();
/**
* Simple OMC pool API class
*
* @author Lawrence Cherone
* @version 0.01
*/
class omc{
View gist:55baab0de65c22e5fb06
<?php
/**
* Swear word filtering function, requiers a list of words,
* Second parameter reveals *n letters
*
* @wordlist https://gist.github.com/lcherone/6f8043447f7f0099d430
*
* @param string $str
* @param int $reveal
* @return string
View deploy.php
<?php
date_default_timezone_set('Europe/London'); // Set this to your local timezone - http://www.php.net/manual/en/timezones.php
/**
* The root directory where the repos live.
*
* @var string
*/
$root_dir = '/your/root/dir/';
View gist:3285cbf0fc8574967f6f
<?php
function bbdecoder($bbcode){
/* Match url */
$urlmatch = "([a-zA-Z]+[:\/\/]+[A-Za-z0-9\-_:]+\\.+[A-Za-z0-9\.\/%&=\?\-_:]+)";
/* Basically remove HTML tag's functionality */
$bbcode = htmlspecialchars($bbcode);
/* Bold text */
$match["b"] = "/\[b\](.*?)\[\/b\]/is";
View gist:e674c6421dcf01883ecd

Obligatory suggestion, Don't use mysql_* functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.

You should change the function name to get_total hits, as it makes no sense, and the scope of the database connection wont be available within functions, your need to pass it to it or use global to access it, this makes it bad practice but for example

<?php 

function get_total_hits(){
	global $db; // or whatever the variable for mysql_connect() is
@lcherone
lcherone / GitDeploy.php
Last active Aug 29, 2015
Git Deployment PHP class
View GitDeploy.php
<?php
// Set your local timezone - http://www.php.net/manual/en/timezones.php
date_default_timezone_set('Europe/London');
/**
* Git Repo Deploment class.
* @version 1-2
* @author (original) arindambiswas <http://www.collectivezen.com>
* @link https://gist.github.com/arindambiswas/4634fff09b3ad4e4bf48
*
You can’t perform that action at this time.