Ace Editor Mode Getter
0 likes • Nov 18, 2022 • 0 views
PHP
Loading...
More PHP Posts
<?php//generate 239 rgba colors for codecatch's 239 supported programming languages!//this was used to generate the colors that are used in the pie chart on https://codecatch.net/graphs.phpfunction rgbagenerator() {$count = 239;for ($i=0; $i < $count; $i++) {echo "'rgba(". mt_rand(0,255) . ",". mt_rand(0,255) . ",". mt_rand(0,255) . ",1)',";echo "<br>";}}rgbagenerator();?>
<?php$listOfFiles = glob("*.{jpg,png,gif,tiff,jpeg}", GLOB_BRACE);echo 'images = []; ';for($x = 0; $x <= count($listOfFiles)-1; $x++) {echo "images[" . $x . "] =" . '"' . $listOfFiles[$x] . '"' . "; ";}?>
<?phpfunction getFileExtension($file) {return end(explode(".", $file));}?>
<?phpfunction uniqidReal($length = 8) {// uniqid gives 8 chars, can be changedif (function_exists("random_bytes")) {$bytes = random_bytes(ceil($length / 2));} elseif (function_exists("openssl_random_pseudo_bytes")) {$bytes = openssl_random_pseudo_bytes(ceil($length / 2));} else {throw new Exception("no cryptographically secure random function available");}return substr(bin2hex($bytes), 0, $length);}/*//for testingfor($i = 0; $i < 10; $i++) {echo "<br>";echo uniqidReal();}*/?>
<?php$im = imagecreatefrompng('example.png');$size = min(imagesx($im), imagesy($im));$im2 = imagecrop($im, ['x' => 0, 'y' => 0, 'width' => $size, 'height' => $size]);if ($im2 !== FALSE) {imagepng($im2, 'example-cropped.png');imagedestroy($im2);}imagedestroy($im);?>
<?php/** @param string $file Filepath* @param string $query Needed information (0 = width, 1 = height, 2 = mime-type)* @return string Fileinfo*/function getImageinfo($file, $query) {if (!realpath($file)) {$file = $_SERVER["DOCUMENT_ROOT"] . $file;}$image = getimagesize($file);return $image[$query];}?>