예제 #1
0
?>
    </td>
    <td>
    <?php 
echo T_('This tests whether you have the simplexml extension enabled. This is not strictly necessary, but may result in a better experience.');
?>
    </td>
</tr>
<tr>
    <td valign="top"><?php 
echo T_('PHP GD extension');
?>
</td>
    <td valign="top">
    <?php 
echo debug_wresult(check_php_gd());
?>
    </td>
    <td>
    <?php 
echo T_('This tests whether you have the GD extension enabled. This is not strictly necessary, but may result in a better experience.');
?>
    </td>
</tr>
<tr>
    <td valign="top"><?php 
echo T_('PHP safe mode disabled');
?>
</td>
    <td valign="top">
    <?php 
예제 #2
0
function check_php_requirements()
{
    $result = array();
    $result[] = check_php_version();
    $result[] = check_php_memory_limit();
    $result[] = check_php_post_max_size();
    $result[] = check_php_upload_max_filesize();
    $result[] = check_php_max_execution_time();
    $result[] = check_php_max_input_time();
    $result[] = check_php_timezone();
    $result[] = check_php_databases();
    $result[] = check_php_bc();
    $result[] = check_php_mbstring();
    $result[] = check_php_sockets();
    $result[] = check_php_session();
    $result[] = check_php_gd();
    $result[] = check_php_gd_png();
    $result[] = check_php_xml();
    $result[] = check_php_ctype();
    return $result;
}
예제 #3
0
 /**
  * Create waveform from song file.
  * @param string $filename
  * @return binary|string|null
  */
 protected static function create_waveform($filename)
 {
     if (!file_exists($filename)) {
         debug_event('waveform', 'File ' . $filename . ' doesn\'t exists', 1);
         return null;
     }
     if (!check_php_gd()) {
         debug_event('waveform', 'GD extension must be loaded', 1);
         return null;
     }
     $detail = 5;
     $width = 400;
     $height = 32;
     $foreground = AmpConfig::get('waveform_color') ?: '#FF0000';
     $background = '';
     $draw_flat = true;
     // generate foreground color
     list($r, $g, $b) = self::html2rgb($foreground);
     $handle = fopen($filename, "r");
     // wav file header retrieval
     $heading = array();
     $heading[] = fread($handle, 4);
     $heading[] = bin2hex(fread($handle, 4));
     $heading[] = fread($handle, 4);
     $heading[] = fread($handle, 4);
     $heading[] = bin2hex(fread($handle, 4));
     $heading[] = bin2hex(fread($handle, 2));
     $heading[] = bin2hex(fread($handle, 2));
     $heading[] = bin2hex(fread($handle, 4));
     $heading[] = bin2hex(fread($handle, 4));
     $heading[] = bin2hex(fread($handle, 2));
     $heading[] = bin2hex(fread($handle, 2));
     $heading[] = fread($handle, 4);
     $heading[] = bin2hex(fread($handle, 4));
     // wav bitrate
     $peek = hexdec(substr($heading[10], 0, 2));
     $byte = $peek / 8;
     // checking whether a mono or stereo wav
     $channel = hexdec(substr($heading[6], 0, 2));
     $ratio = $channel == 2 ? 40 : 80;
     // start putting together the initial canvas
     // $data_size = (size_of_file - header_bytes_read) / skipped_bytes + 1
     $data_size = floor((Core::get_filesize($filename) - 44) / ($ratio + $byte) + 1);
     $data_point = 0;
     // create original image width based on amount of detail
     // each waveform to be processed with be $height high, but will be condensed
     // and resized later (if specified)
     $img = imagecreatetruecolor($data_size / $detail, $height);
     // fill background of image
     if ($background == "") {
         // transparent background specified
         imagesavealpha($img, true);
         $transparentColor = imagecolorallocatealpha($img, 0, 0, 0, 127);
         imagefill($img, 0, 0, $transparentColor);
     } else {
         list($br, $bg, $bb) = self::html2rgb($background);
         imagefilledrectangle($img, 0, 0, (int) ($data_size / $detail), $height, imagecolorallocate($img, $br, $bg, $bb));
     }
     while (!feof($handle) && $data_point < $data_size) {
         if ($data_point++ % $detail == 0) {
             $bytes = array();
             // get number of bytes depending on bitrate
             for ($i = 0; $i < $byte; $i++) {
                 $bytes[$i] = fgetc($handle);
             }
             switch ($byte) {
                 // get value for 8-bit wav
                 case 1:
                     $data = self::findValues($bytes[0], $bytes[1]);
                     break;
                     // get value for 16-bit wav
                 // get value for 16-bit wav
                 case 2:
                     if (ord($bytes[1]) & 128) {
                         $temp = 0;
                     } else {
                         $temp = 128;
                     }
                     $temp = chr((ord($bytes[1]) & 127) + $temp);
                     $data = floor(self::findValues($bytes[0], $temp) / 256);
                     break;
                 default:
                     $data = 0;
                     break;
             }
             // skip bytes for memory optimization
             fseek($handle, $ratio, SEEK_CUR);
             // draw this data point
             // relative value based on height of image being generated
             // data values can range between 0 and 255
             $v = (int) ($data / 255 * $height);
             // don't print flat values on the canvas if not necessary
             if (!($v / $height == 0.5 && !$draw_flat)) {
                 // draw the line on the image using the $v value and centering it vertically on the canvas
                 imageline($img, (int) ($data_point / $detail), $height - $v, (int) ($data_point / $detail), $height - ($height - $v), imagecolorallocate($img, $r, $g, $b));
             }
         } else {
             // skip this one due to lack of detail
             fseek($handle, $ratio + $byte, SEEK_CUR);
         }
     }
     // close and cleanup
     fclose($handle);
     ob_start();
     // want it resized?
     if ($width) {
         // resample the image to the proportions defined in the form
         $rimg = imagecreatetruecolor($width, $height);
         // save alpha from original image
         imagesavealpha($rimg, true);
         imagealphablending($rimg, false);
         // copy to resized
         imagecopyresampled($rimg, $img, 0, 0, 0, 0, $width, $height, imagesx($img), imagesy($img));
         imagepng($rimg);
         imagedestroy($rimg);
     } else {
         imagepng($img);
     }
     imagedestroy($img);
     $imgdata = ob_get_contents();
     ob_clean();
     return $imgdata;
 }