baseDir = $baseDir; } public function increment( $counterId ){ $file = "{$this->baseDir}/{$counterId}"; $dir = dirname( $file ); if ( ! file_exists( $dir ) ){ mkdir( $dir, 0755, TRUE ); } return file_put_contents( $file, '.', FILE_APPEND ); } public function get_value( $counterId ){ $file = "{$this->baseDir}/{$counterId}"; return file_exists( $file ) ? filesize( $file ) : 0; } public function delete( $counterId ){ $file = "{$this->baseDir}/{$counterId}"; return ! file_exists( $file ) || unlink( $file ); } } // end of file lib/counter.class.php