Skip to content

Instantly share code, notes, and snippets.

View dovidezra's full-sized avatar
💭
I may be slow to respond.

Dovid Ezra dovidezra

💭
I may be slow to respond.
  • Diaspora
View GitHub Profile
@dovidezra
dovidezra / backup-files.php
Last active April 4, 2023 11:39
An example PHP script that creates a backup of files within a specified path, to be run as a cronjob once a day.
<?php
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/// To run this script as a cronjob once a day, you can add a new entry to the crontab file using the ///
/// crontab -e command and specifying the desired time for the backup to be created. For example, to ////
/// run the backup script every day at midnight, you can add the following line to the crontab file: ////
/// 0 0 * * * /usr/bin/php /path/to/backup-script.php >/dev/null 2>&1 ///////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// Set the path to the source directory to be backed up
@dovidezra
dovidezra / latest-woocommerce-version.php
Created April 4, 2023 10:39
Check the installed WooCommerce version, and compare it to the latest version available on WordPress.org. If the installed version is older, it will print "Newer Version Available." If the installed version is the same or WooCommerce is not found, it will print an appropriate message.
<?php
/////////////////////////////////////////////////////////////////////////////////////////////////////
/// Run the following command in SSH to install the dependency (i.e. "fabpot/goutte"): //////////////
/// composer require fabpot/goutte //////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
/// 1. Get the latest version of the WooCommerce plugin from the WordPress.org plugin repository. ///
/// 2. Check a list of websites for the installed version of the WooCommerce plugin. ////////////////
/// 3. Compare the installed version with the latest version available on WordPress.org. ////////////
/// 4. Output the appropriate message based on the comparison results. //////////////////////////////
@dovidezra
dovidezra / .htaccess
Last active March 7, 2023 13:19 — forked from keithmorris/.htaccess
CodeIgniter 3 htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
@dovidezra
dovidezra / minify.php
Created October 8, 2022 05:01
CSS Minifier PHP Example: Check the example on how to use PHP to minify a CSS hardcoded string and output to stdout
<?php
$url = 'https://www.toptal.com/developers/cssminifier/api/raw';
// init the request, set various options, and send it
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>OpenStreetMap &amp; OpenLayers - Marker Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="https://openlayers.org/en/v4.6.5/css/ol.css" type="text/css">
<script src="https://openlayers.org/en/v4.6.5/build/ol.js" type="text/javascript"></script>
<script>
@dovidezra
dovidezra / gregoriantojd.php
Last active April 26, 2022 01:10
PHP: Covert Current Gregorian Date to Jewish Calendar Date
<?php
$month = date('m');
$day = date('d');
$year = date('Y');
function isJewishLeapYear($year) {
if ($year % 19 == 0 || $year % 19 == 3 || $year % 19 == 6 ||
$year % 19 == 8 || $year % 19 == 11 || $year % 19 == 14 ||
$year % 19 == 17)
@dovidezra
dovidezra / honeypot-example.php
Created April 21, 2021 01:40 — forked from andrewlimaza/honeypot-example.php
Simple honeypot for an HTML form using PHP
<?php
//check if form was sent
if($_POST){
$to = 'some@email.com';
$subject = 'Testing HoneyPot';
$header = "From: $name <$name>";
$name = $_POST['name'];
@dovidezra
dovidezra / functions.php
Created December 7, 2020 17:31 — forked from dartiss/functions.php
WordPress Plugin to List all Site Cookies
<?php
function get_cookies( $paras = '', $content = '' ) {
if ( strtolower( $paras[ 0 ] ) == 'novalue' ) { $novalue = true; } else { $novalue = false; }
if ( $content == '' ) { $seperator = ' : '; } else { $seperator = $content; }
$cookie = $_COOKIE;
ksort( $cookie );
@dovidezra
dovidezra / fakeigniter.php
Created September 10, 2019 06:48 — forked from tinkertim/fakeigniter.php
A fake Codeigniter framework for testing codeigniter-redis
<?php
error_reporting(E_ALL);
/**
* A 'fake' Codeigniter framework for testing codeigniter-redis
* I seriously wrote this because it was faster than setting up another CI install, so I can
* work on it without breaking stuff that other people are using.
* Written by Tim Post <tpost@ezp.net> I take no responsibility for what comes below!
**/
/* Provide some of the CI common functions */
@dovidezra
dovidezra / country-blocker.php
Created November 13, 2018 06:34
Small script used to block some countries (based on ipinfodb.com database)
<?php
/**
* Small script used to block some countries (based on ipinfodb.com database)
*
* @author @Heavenstar_ | alexis.chevalier1@gmail.com
* @version 1.0.0
*/
$apiKey = 'REPLACE WITH YOUR KEY'; //Get an API key here : http://ipinfodb.com/login.php
$apiEndpoint = 'http://api.ipinfodb.com/v3/ip-country/';