Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Victor knust victorknust

🏠
Working from home
View GitHub Profile
View get_the_user_ip.php
<?php
function get_the_user_ip() {
if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
//check ip from share internet
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
//to check ip is pass from proxy
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
@victorknust
victorknust / Security.php
Last active Aug 13, 2020 — forked from raviy1290/Security.php
codeigniter hack: when on CSRF token expiration you need page refresh rather than error on CodeIgniter / system / core / Security.php @ public function csrf_show_error(){...
View Security.php
<?php
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
* Licensed under the Open Software License version 3.0
*
View warning.html
<script>
$(document).ready(function(){
if(window.console || "console" in window) {
console.log("%c WARNING!!!", "color:#FF8F1C; font-size:40px;");
console.log("%c This browser feature is for developers only. Please do not copy-paste any code or run any scripts here. It may cause your PayPal account to be compromised.", "color:#003087; font-size:12px;");
console.log("%c For more information, http://en.wikipedia.org/wiki/Self-XSS", "color:#003087; font-size:12px;");
}
});
</script>
View direct-upload-aws-s3.php
<?php
$access_key = "iam-user-access-key"; //Access Key
$secret_key = "iam-user-secret-key"; //Secret Key
$my_bucket = "mybucket"; //bucket name
$region = "us-east-1"; //bucket region
$success_redirect = 'http://'. $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; //URL to which the client is redirected upon success (currently self)
$allowd_file_size = "1048579"; //1 MB allowed Size
//dates
View bottom-cache.php
<?php
// Cache the contents to a file
$cached = fopen($cachefile, 'w');
fwrite($cached, ob_get_contents());
fclose($cached);
ob_end_flush(); // Send the output to the browser
View App.php
<?php
namespace App;
class App
{
public function __construct()
{
$controller = new Controller\Example;
}
View Model.php
<?php
//
$view = new View();
$view->addGlobal('global', 'Hello!, I\'m a Global var.');
// in the method
echo $view->render('controller.method.phtml', ['var' => 'Hello World!']);
View View.php
<?php
class View
{
public function render( $view, array $data = [] )
{
ob_start() and extract($data, EXTR_SKIP);
try {
View getWeekDays.php
<?php
function getWeekDays() {
$time = strtotime( 'monday this week' );
$days = [];
for($i = 0; $i<7; $i++){
$d = new DateTime();
$d->setTimestamp(strtotime("+$i day",$time));
$days[] = $d->format("Y-m-d");
}
View ResolveCallable.php
<?php
namespace Slim;
use Pimple\Container;
trait ResolveCallable
{
protected $container;