Skip to content

URL shortener #2862

@ywarnier

Description

@ywarnier

Is your feature request related to a problem? Please describe.
In Chamilo, some of the links used for e-mail invitations are extremely long (more than 180 characters sometimes), which make them difficult to send and error-prone when copy-pasting (because they sometimes expand on more than one line).

Describe the solution you'd like
Provide, inside Chamilo, a feature to shorten URLs, using for example a base36 converter to provide short versions of MD5/SHA1 hashes, and a special controller for shortened URLs.

Shortening a MD5 hash is relatively easy:

$num = rand(1, 9999999999);
$hash = md5($num);
$short = base_convert($num, 16, 36);

Managing those shortened link would be best through a dedicated table, because we could have unique links that include several parameters into one single shortened link.

Something like

CREATE TABLE short_url (
  id int not null,
  original_link text,
  shortened_url varchar(100),
  created_at datetime,
  expires_at datetime,
  accessed_at datetime
);

This should be offered as part of the ChamiloAPI, with a specific ShortUrl entity.

[Inspiration: BT#15453]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions