Skip to content

Instantly share code, notes, and snippets.

View karson's full-sized avatar
🎯
Focusing

Karson karson

🎯
Focusing
View GitHub Profile
@karson
karson / mark_zero_invoices_paid.php
Created May 16, 2020 21:00 — forked from Pierowheelz/mark_zero_invoices_paid.php
A hook for WHMCS which marks invoices which have received payment as paid, where the WHMCS system doesn't automatically mark them paid. I found that if manually associating a transaction with an invoice number in WHMCS, the invoice is not marked as paid even when there is zero total remaining. This fixes that.
<?php
if (!defined("WHMCS"))
die("This file cannot be accessed directly");
use WHMCS\Database\Capsule;
function wb_mark_zero_invoices_paid(){
//get all unpaid invoices
$unpaid_invoices = Capsule::table('tblinvoices')->where('status', 'Unpaid')->get();
foreach( $unpaid_invoices as $inv ){
@karson
karson / c2b.php
Last active June 12, 2020 09:34
C2B mpesa transaction
<?php
require 'vendor/autoload.php';
$mpesa = new \Karson\MpesaPhpSdk\Mpesa();
$mpesa->setPublicKey('Your public key');
$mpesa->setApiKey('Your Api key');
$mpesa->setEnv('test');
@karson
karson / cloudflare_sync_hook.php
Last active September 22, 2022 12:42
WHMCS hook - syncs the Cloudflare IPs
<?php
/**
* Cloudflare IP Sync
*
* This hook syncs the Cloudflare IPs with WHMCS's trusted
* proxy list.
*
* https://www.cloudflare.com/ips/
*
* @version 1.0
@karson
karson / npm-shrinkwrap.json
Created April 21, 2020 20:45
Gulp : fix ReferenceError: primordials is not defined in node
//https://stackoverflow.com/questions/55921442/how-to-fix-referenceerror-primordials-is-not-defined-in-node
//These fixes enable you to use Node.js 12 with gulp@3.9.1 by overriding graceful-fs to version 4.2.3.
//Create a npm-shrinkwrap.json file containing this:
{
"dependencies": {
"graceful-fs": {
"version": "4.2.3"
}
}
@karson
karson / custom-queries.php
Created March 26, 2020 10:41 — forked from carlodaniele/custom-queries.php
An example plugin showing how to add custom query vars, rewrite tags and rewrite rules to WordPress
<?php
/**
* @package Custom_queries
* @version 1.0
*/
/*
Plugin Name: Custom queries
Plugin URI: http://wordpress.org/extend/plugins/#
Description: This is an example plugin
Author: Carlo Daniele
@karson
karson / http.php
Created February 26, 2019 16:35 — forked from xeoncross/http.php
POST requests using curl, sockets, and php-curl
<?php
// command line
// curl --data "text=foobar" http://localhost:3001/api/decrypt
// File sockets
function http_request($url, $data, $a = null, $b = null) {
$opts = array('http' =>
array(
'method' => 'POST',
@karson
karson / replace.sh
Created February 19, 2019 12:23
replace text in files
#no recursive
sed -i -- 's/foo/bar/g' *
perl -i -pe 's/foo/bar/g' ./*
#######Recusive
find . -type f -name 'xa*' -exec sed -i 's/asd/dsg/g' {} \;
#Alternatively, one could use xargs, which will invoke fewer processes:
find . -type f -name 'xa*' | xargs sed -i 's/asd/dsg/g'
#Or more simply use the + exec variant instead of ; in find to allow find to provide more than one file per subprocess call:
@karson
karson / createuser.sh
Created January 14, 2019 11:12
Create mysql user
#In terminal, log into MySQL as root.
sudo mysql -p -u root
#Create pmauser
CREATE USER 'pmauser'@'%' IDENTIFIED BY 'password_here';
#Now we will grant superuser privilege to our new user.
GRANT ALL PRIVILEGES ON *.* TO 'pmauser'@'%' WITH GRANT OPTION;
@karson
karson / emaillist.js
Last active March 19, 2019 08:32
Listar todos os email no cpanel
text = ''; for( el of document.querySelectorAll('.account-name') ) { text+=el.innerHTML+"\n"; }; console.log(text)
@karson
karson / AppServiceProvider.php
Last active November 8, 2018 19:01
Change public path in Laravel 5.5
<?php
public function register()
{
$this->app->bind('path.public', function() {
realpath(base_path().'/../public_html');
});
}