Skip to content

Instantly share code, notes, and snippets.

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

Victor knust victorknust

🏠
Working from home
View GitHub Profile
<?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 August 13, 2020 10:06 — 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(){...
<?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
*
<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>
<?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
<?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
<?php
namespace App;
class App
{
public function __construct()
{
$controller = new Controller\Example;
}
<?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!']);
<?php
class View
{
public function render( $view, array $data = [] )
{
ob_start() and extract($data, EXTR_SKIP);
try {
<?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");
}
<?php
namespace Slim;
use Pimple\Container;
trait ResolveCallable
{
protected $container;