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
<?php
session_start();
if (isset($_SESSION['LAST_CALL'])) {
$last = strtotime($_SESSION['LAST_CALL']);
$curr = strtotime(date("Y-m-d h:i:s"));
$sec = abs($last - $curr);
if ($sec <= 1) {
$data = 'Rate Limit Exceeded'; // rate limit
header('Content-Type: application/json');
@dovidezra
dovidezra / gist:d90b7ef58eebe034e798ffc11121f8de
Created March 9, 2018 08:05
(php) download remote file with curl
<?php
function download_remote_file_with_curl($file_url, $save_to) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_URL, $file_url);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$file_content = curl_exec($ch);
curl_close($ch);
@dovidezra
dovidezra / gist:b6a5a972a525645f1a73fd1291cd74b3
Created March 8, 2018 19:51
Displaying a Calendar Month with PHP
<?php
$day_num=date("j"); //If today is September 29, $day_num=29
$month_num = date("m"); //If today is September 29, $month_num=9
$year = date("Y"); //4-digit year
$date_today = getdate(mktime(0,0,0,$month_num,1,$year)); //Returns array of date info for 1st day of this month
$month_name = $date_today["month"]; //Example: "September" - to label the Calendar
$first_week_day = $date_today["wday"]; //"wday" is 0-6, 0 being Sunday. This is for day 1 of this month
@dovidezra
dovidezra / otp-auth.php
Last active December 24, 2017 18:41
(OTP-Auth) Easily Create One-Time Password System in PHP App
<?php
/**
* Name: (OTP-Auth) One-Time Password Authentication
* Auth: Jason Jersey
* Date: 12-24-2017
* Link: https://gist.github.com/icryptix/130fa81ca15925b8553bec8700e5813d
*/
/* Verifying whether OTP 1 hour cookie is set */
if(isset($_COOKIE["sitename_otp_cookie"])){
<?php
$user_id = "sharonlaker19";
header("Content-Type: text/plain");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.facebook.com/messages/t/$user_id");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@dovidezra
dovidezra / ERR_EMPTY_RESPONSE
Last active July 15, 2017 23:54
Fix ERR_EMPTY_RESPONSE by using CMD
Go to START MENU
Go to RUN
Type CMD
Run below 6 commands one by one. Copy and paste them one by one into CMD and click ENTER after adding each.
(In CMD, you just have to click with your right mouse button to paste)
ipconfig /release
ipconfig /all
ipconfig /flushdns
@dovidezra
dovidezra / ERR_SOCKET_NOT_CONNECTED
Last active July 13, 2017 23:09
ERR_SOCKET_NOT_CONNECTED
1. Go to the start menu
2. Go to your browser
3. Click on it and open it up
4. Type this following command in the browsers address bar. This is the same place you normally type in https://www.mydomain.com
chrome://net-internals/#sockets
5. Click “Flush Socket Pools”, located at the Top of the screen.
6. Restart browser
https://support.cloudflare.com/hc/en-us/requests
https://support.cloudflare.com/hc/en-us/requests/new
Path to config file
/opt/cpanel/ea-php54/root/etc/
pm = ondemand
pm.process_idle_timeout = 30s
pm.max_children = 10
pm.max_requests = 0
/var/log/imunify360