Skip to content

Instantly share code, notes, and snippets.

View grim-reapper's full-sized avatar

Imran Ali grim-reapper

View GitHub Profile
@grim-reapper
grim-reapper / transfer-copy.php
Created October 9, 2018 07:29 — forked from sarathlal-old/transfer-copy.php
Transfer files from server to server using PHP `copy()` function.
<?php
// Insert this file on server and go to the path from browser.
set_time_limit(0); //Unlimited max execution time
/* Source File URL */
$remote_file_url = 'http://origin-server-url/files.zip';
/* New file name and path for this file */
$local_file = 'files.zip';
@grim-reapper
grim-reapper / docx_editor.php
Created December 24, 2018 06:10 — forked from AndrewChamp/docx_editor.php
Edit a Microsoft Word .docx file using PHP and the zip extension.
<?php
/**
* Edit a Word 2007 and newer .docx file.
* Utilizes the zip extension http://php.net/manual/en/book.zip.php
* to access the document.xml file that holds the markup language for
* contents and formatting of a Word document.
*
* In this example we're replacing some token strings. Using
* the Office Open XML standard ( https://en.wikipedia.org/wiki/Office_Open_XML )
* you can add, modify, or remove content or structure of the document.
@grim-reapper
grim-reapper / iframed.js
Created December 24, 2018 06:11 — forked from AndrewChamp/iframed.js
iFrame'd Site
$(document).ready(function($) {
if(window.location !== window.parent.location){
$('header, footer').hide();
}
});
@grim-reapper
grim-reapper / autoloader.php
Created December 24, 2018 06:11 — forked from AndrewChamp/autoloader.php
PHP Autoloader - Includes files for classes that are instantiated.
<?php
spl_autoload_register(function($class){
$directorys = array(PATH.VERSION.MODULES, INSTALL.MODULES, INSTALL.THEME.'modules/');
foreach($directorys as $directory):
if(file_exists($directory.'class.'.$class.'.php')):
require($directory.'class.'.$class.'.php');
return;
endif;
endforeach;
@grim-reapper
grim-reapper / keygen.php
Created December 24, 2018 06:12 — forked from AndrewChamp/keygen.php
Random Keygen
<?php
function keygen($length='40'){
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$size = strlen($chars);
for($i = 0; $i < $length; $i++):
$str .= $chars[ rand( 0, $size - 1 ) ];
endfor;
return $str;
}
@grim-reapper
grim-reapper / hashing.php
Created December 24, 2018 06:12 — forked from AndrewChamp/hashing.php
Simple Hashing
<?php
function hasher($password, $salt){
$result = base64_encode(hash('md5', $password.$salt));
$result = substr($result, 5, -5);
return strrev($result);
}
//Example
print hasher('myPassword', time());
?>
@grim-reapper
grim-reapper / strip html comments.php
Created December 24, 2018 06:13 — forked from AndrewChamp/strip html comments.php
Regex for stripping HTML comments
<!--(?!<!)[^\[>].*?-->
<?php
$codes = Array(
100 => 'Continue',
101 => 'Switching Protocols',
200 => 'OK',
201 => 'Created',
202 => 'Accepted',
203 => 'Non-Authoritative Information',
204 => 'No Content',
205 => 'Reset Content',
<?php
function seoName($title) {
return preg_replace('/[^a-z0-9_-]/i', '', strtolower(str_replace(' ', '-', trim($title))));
}
?>
<?php
/**
* No Image Options:
* 404 - do not load any image if none is associated with the email hash, instead return an HTTP 404 (File Not Found) response
* mm - (mystery-man) Simple, cartoon-style silhouetted outline of a person
* identicon - Geometric pattern based on an email hash
* monsterid - Generated 'monster' with different colors, faces, etc
* wavatar - Fenerated faces with differing features and backgrounds
* retro - 8-bit arcade-style pixelated faces