Skip to content

Instantly share code, notes, and snippets.

<?php
//Fungsi untuk merubah format bytes
function filesize_formatted($file)
{
$bytes = $file;
if ($bytes >= 1073741824) {
return number_format($bytes / 1073741824, 2) . ' GB';
} elseif ($bytes >= 1048576) {
return number_format($bytes / 1048576, 2) . ' MB';
@heiswayi
heiswayi / zipper.php
Created July 20, 2018 17:46
Example of PHP script I used to zip a folder and then force download the zipped file when this script is visited thru web browser
<?php
$dir = 'inescov1';
$zip_file = 'inescov1.zip';
// Get real path for our folder
$rootPath = realpath($dir);
// Initialize archive object
$zip = new ZipArchive();
@githubgobi
githubgobi / zip-files-with-password.md
Created July 11, 2018 06:00
Creating encrypted ZIP files with password in PHP

Creating encrypted ZIP files with password in PHP

You need at least PHP 7.2 to encrypt ZIP files with a password.

<?php

$zip = new ZipArchive();

$zipFile = __DIR__ . '/output.zip';
@Bartvelp
Bartvelp / stream.php
Created May 10, 2018 17:13
PHP seekable stream external video with url and range header support
<?php
/*
Hi!
So this gist is not a very good implementation, it works great in chrome but the seeking is sort of glitched in firefox.
But it does the job and I hope it can help out!
(Please let me know how to improve this)
*/
ini_set('max_execution_time', 0);
$url = "http://mirrors.standaloneinstaller.com/video-sample/jellyfish-25-mbps-hd-hevc.m4v"; //just some sample url, please dont overload their servers
@yukiakt
yukiakt / login.css
Last active May 31, 2024 19:39
simple login page with html, css, and javascript
*{
text-align: center;
padding: 5px;
}
li {
list-style-type: none;
text-align: center;
padding-bottom: 5%;
}
@heiswayi
heiswayi / SimpleAuth.php
Created December 20, 2017 14:28
Simple PHP script to protect any PHP page using session
<?php
/*
* Filename: SimpleAuth.php
* Version: 1.0
* Author: Heiswayi Nrird
* Dscription: Simple PHP script to protect any PHP page using session
* Website: https://heiswayi.nrird.com
*
* HOW TO USE
* ==========
@heiswayi
heiswayi / img-upload.php
Created October 25, 2017 16:44
Internal Image Hosting Script
<?php
// Configuration
$title = 'Internal Image Hosting Script';
$filedir = 'up'; // uploaded image dir
$maxsize = 5242880; //max size in bytes
$allowedExts = array('png', 'jpg', 'jpeg', 'gif');
$allowedMime = array('image/png', 'image/jpeg', 'image/pjpeg', 'image/gif');
$baseurl = $_SERVER['HTTP_HOST'].dirname($_SERVER['REQUEST_URI']).'/'.$filedir;
function compressImage($source_url, $destination_url, $quality) {
@heiswayi
heiswayi / fm.php
Created October 25, 2017 14:00
Single PHP File Manager Script - Screenshot: https://i.imgur.com/4OtrKUz.png
<?php
/**
* File Manager Script
*/
// Default language ('en' and other from 'filemanager-l10n.php')
$lang = 'en';
// Auth with login/password (set true/false to enable/disable it)
$use_auth = true;
@heiswayi
heiswayi / hnexplorer.php
Created February 7, 2017 15:51
Backup of HNExplorer source code -- a PHP file manager.
<?php
//
// Initialising variables. Don't change these.
//
$_CONFIG = array();
$_ERROR = "";
$_START_TIME = microtime(TRUE);
@yahyaahrika
yahyaahrika / fff.php
Created November 15, 2016 20:28
code php upload image post
<?php
if (isset($_POST["submit"])) {
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);