> 24; if( $c ){ if( $byMin ){ $l = ( $stride[$index+1] & 0xFFF); } else { $l = ( ( $stride[$index+1] >> 12 ) & 0xFFF); }; if( $l < 4000 ){ $z = $k * $l; $s = 1.0 - log10( $z ); $R = (int)(255 * $s); $G = (int)(255 * $s); $B = (int)(255 * $s); } else { $R = 0; $G = 0; $B = 0; }; } else { $R = 255; $G = 0; $B = 0; }; $C = imagecolorclosest ( $thumbnail, $R, $G, $B); imagesetpixel ( $thumbnail, $index, $cy , $C ); }; $cy--; }; }; fclose( $handle ); //header("Content-Type: image/png"); ob_start(); imagepng( $thumbnail ); $contents = ob_get_contents(); ob_end_clean(); imagedestroy( $thumbnail ); if( $imagefile != '' ){ $handle = fopen( $imagefile, "wb" ); fprintf( $handle, $contents ); fclose( $handle ); }; return $contents; }; function makeStorageBasePath( $MD ){ global $SYSPath; $FL = substr( $MD, 0, 2 ); $SL = substr( $MD, 2, 2 ); $TL = substr( $MD, 4, 2 ); if( !is_dir( $SYSPath.'/storage/'.$FL ) ){ mkdir( $SYSPath.'/storage/'.$FL ); }; if( !is_dir( $SYSPath.'/storage/'.$FL.'/'.$SL ) ){ mkdir( $SYSPath.'/storage/'.$FL.'/'.$SL ); }; if( !is_dir( $SYSPath.'/storage/'.$FL.'/'.$SL.'/'.$TL ) ){ mkdir( $SYSPath.'/storage/'.$FL.'/'.$SL.'/'.$TL ); }; return $SYSPath.'/storage/'.$FL.'/'.$SL.'/'.$TL; }; function registerPicture( $fname ){ global $DATABASE; if( file_exists( $fname ) ){ $MD5 = md5_file( $fname ); $REXT = substr(strtolower( pathinfo( $fname, PATHINFO_EXTENSION ) ), 3 ); $nfname = makeStorageBasePath( $MD5 ).'/'.$MD5.'.'.$REXT; if( rename( $fname, $nfname ) ){ $QS = "INSERT INTO pictures SET md5='{$MD5}', ext='{$REXT}', TS=NOW()"; $DATABASE->Query( $QS, false ); return $DATABASE->getLastInsertID(); }; }; return 0; }; ?>