Skip to content

Commit

Permalink
create table fix joshp23#36
Browse files Browse the repository at this point in the history
Ability to keep expired links in database
  • Loading branch information
Sebastian L. committed Mar 23, 2024
1 parent 5bf6c72 commit dd6e14b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ As any YOURLS plugin:
##### Notes:
- The databse ought to create itself, if not, there is an sql file in the `expiry/assets` folder, make sure to add your database prefix where necessary.
- If upgrading from 2.1.x of this plugin to 2.2.x, set `define( 'EXPIRY_DB_UPDATE', true );` in `config.php` __for one page load__ in order to update the database, otherwise this plugin will not work.
- If you don't want the expired links to be deleted and to kept in database, set `define( 'DELETE_EXPIRED_LINKS', false );` in `config.php`.
##### What's Working:
- add per-link and/or global time based or click count limited links
- update links already in database to have expiration conditions
Expand Down
7 changes: 5 additions & 2 deletions expiry/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,10 @@ function expiry_router($keyword, $result, $postx) {

elseif( $postx == null || $postx == '' || $postx == 'none' ) {

yourls_delete_link_by_keyword( $keyword );
$delete_expired = defined('DELETE_EXPIRED_LINKS') && DELETE_EXPIRED_LINKS === false ? false : true;
if ( $delete_expired ) {
yourls_delete_link_by_keyword( $keyword );
}

if ( !yourls_is_API() && !defined('EXPIRY_CLI')) {

Expand Down Expand Up @@ -1325,7 +1328,7 @@ function expiry_update_DB () {
// Create the expiry table
$table = YOURLS_DB_PREFIX . 'expiry';
$table_expiry = "CREATE TABLE IF NOT EXISTS `".$table."` (";
$table_expiry .= "keyword binary(100) NOT NULL, ";
$table_expiry .= "keyword varchar(200) NOT NULL, ";
$table_expiry .= "type varchar(5) NOT NULL, ";
$table_expiry .= "click varchar(5), ";
$table_expiry .= "timestamp varchar(20), ";
Expand Down

0 comments on commit dd6e14b

Please sign in to comment.