This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php defined('BASEPATH') OR exit('No direct script access allowed'); | |
| function compressImage64($base64, $saveto, $quality = 60) { | |
| $ret = false; | |
| $img = preg_replace(array("~^data:image/[a-zA-Z]*;base64,~","/\s/"), array("","+"), $base64); | |
| $data= base64_decode($img); | |
| $img = imagecreatefromstring($data); | |
| if (!file_exists( dirname($saveto) )) { | |
| mkdir( dirname($saveto) , 0777, true); | |
| } | |
| if(imagejpeg($img, $saveto, $quality)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sudo visudo | |
| # Add the following line below "pi ALL etc." and exit the visudo editor: | |
| www-data ALL = NOPASSWD: /sbin/shutdown | |
| sudo nano /var/www/index.html | |
| # Absolute minimum contents of the index.html file: | |
| <html><a href="shutdown.php">Shutdown NOW</a></html> | |
| sudo nano /var/www/shutdown.php | |
| # Absolute minimum contents of the shutdown.php file: | |
| <?php system('sudo /sbin/shutdown -h now'); ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function romanic_number($roman) { // V = 5 | |
| $table = array('M'=>1000, 'CM'=>900, 'D'=>500, 'CD'=>400, 'C'=>100, 'XC'=>90, 'L'=>50, 'XL'=>40, 'X'=>10, 'IX'=>9, 'V'=>5, 'IV'=>4, 'I'=>1); | |
| $result = 0; | |
| foreach ($table as $key => $value) { | |
| while (strpos($roman, $key) === 0) { | |
| $result += $value; | |
| $roman = substr($roman, strlen($key)); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function dateid($format, $time = false) { // "Asia/Tokyo" | |
| $day = array('Sen', 'Sel', 'Rab', 'Kam', 'Jum', 'Sab', 'Min'); | |
| $days = array('Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat', 'Sabtu', 'Minggu'); | |
| $month = array('', 'Jan', 'Feb', 'Mar', 'Apr', 'Mei', 'Jun', 'Jul', 'Agu', 'Sep', 'Okt', 'Nov' ,'Des'); | |
| $months= array('', 'Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober', 'November' ,'Desember'); | |
| if(!is_a($time, 'DateTime')) { | |
| if(is_int($time)) { | |
| $time = new DateTime(date('Y-m-d H:i:s.u',$time)); |