Browse Source

Fix end of line

pull/1336/head
LeoColomb 6 years ago
parent
commit
3daf6593d8
67 changed files with 13806 additions and 13804 deletions
  1. 2
    0
      .gitattributes
  2. 95
    95
      CHANGELOG.md
  3. 26
    26
      LICENSE.md
  4. 15
    15
      README.md
  5. 51
    51
      admin/admin-ajax.php
  6. 294
    294
      admin/index.php
  7. 75
    75
      admin/install.php
  8. 164
    164
      admin/plugins.php
  9. 117
    117
      admin/tools.php
  10. 86
    86
      admin/upgrade.php
  11. 13
    13
      css/cal.css
  12. 113
    113
      css/infos.css
  13. 65
    65
      css/share.css
  14. 330
    330
      css/style.css
  15. 103
    103
      css/tablesorter.css
  16. 925
    925
      includes/class-mysql.php
  17. 182
    182
      includes/functions-api.php
  18. 205
    205
      includes/functions-auth.php
  19. 171
    171
      includes/functions-compat.php
  20. 489
    489
      includes/functions-formatting.php
  21. 851
    851
      includes/functions-html.php
  22. 167
    167
      includes/functions-http.php
  23. 250
    250
      includes/functions-install.php
  24. 779
    779
      includes/functions-kses.php
  25. 1133
    1133
      includes/functions-l10n.php
  26. 579
    579
      includes/functions-plugins.php
  27. 296
    296
      includes/functions-upgrade.php
  28. 81
    81
      includes/functions-xml.php
  29. 1693
    1693
      includes/functions.php
  30. 177
    177
      includes/load-yourls.php
  31. 77
    77
      includes/pomo/entry.php
  32. 256
    256
      includes/pomo/mo.php
  33. 384
    384
      includes/pomo/po.php
  34. 208
    208
      includes/pomo/streams.php
  35. 275
    275
      includes/pomo/translations.php
  36. 4
    4
      includes/version.php
  37. 157
    157
      js/common.js
  38. 47
    47
      js/infos.js
  39. 202
    202
      js/insert.js
  40. 1
    1
      js/jquery-1.8.2.min.js
  41. 318
    318
      js/jquery.cal.js
  42. 46
    46
      js/jquery.tablesorter.min.js
  43. 11
    11
      js/jquery.zclip.min.js
  44. 57
    57
      js/share.js
  45. 23
    23
      pages/examplepage.php
  46. 830
    830
      readme.html
  47. 12
    12
      sample-public-api.txt
  48. 116
    116
      sample-public-front-page.txt
  49. 46
    46
      sample-remote-api-call.txt
  50. 9
    9
      sample-robots.txt
  51. 85
    85
      user/config-sample.php
  52. 3
    3
      user/plugins/hyphens-in-urls/README.txt
  53. 19
    19
      user/plugins/hyphens-in-urls/plugin.php
  54. 3
    3
      user/plugins/random-bg/README.txt
  55. 27
    27
      user/plugins/random-bg/plugin.php
  56. 3
    3
      user/plugins/sample-page/README.txt
  57. 62
    62
      user/plugins/sample-page/plugin.php
  58. 3
    3
      user/plugins/sample-plugin/README.txt
  59. 61
    61
      user/plugins/sample-plugin/plugin.php
  60. 3
    3
      user/plugins/sample-toolbar/README.txt
  61. 79
    79
      user/plugins/sample-toolbar/css/toolbar.css
  62. 22
    22
      user/plugins/sample-toolbar/js/toolbar.js
  63. 125
    125
      user/plugins/sample-toolbar/plugin.php
  64. 50
    50
      yourls-api.php
  65. 45
    45
      yourls-go.php
  66. 549
    549
      yourls-infos.php
  67. 61
    61
      yourls-loader.php

+ 2
- 0
.gitattributes View File

@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto

+ 95
- 95
CHANGELOG.md View File

@@ -1,96 +1,96 @@
YOURLS Changelog
================
This file attempts to list the main changes through all versions of YOURLS. For a much more detailed
list, simply refer to the commit messages: http://code.google.com/p/yourls/source/list
1.0
---
- initial release
1.0.1
-----
- don't remember. Trivial stuff probably.
1.1
---
- don't remember. Some little bugs I guess.
1.2
---
- don't remember. A few tiny stuff for sure.
1.3-RC1
-------
- added bookmarklet and tools page
- improved XSS filter when adding new URL
- code cleanup in admin/index.php to separate code and display
- added favicon
- stricter coding to prevent notices with undefined indexes
- hide PHP notices & SQL errors & warnings, unless YOURLS_DEBUG constant set to true
1.4
---
- added an upgrader from 1.3 to 1.4
- change in logic: now using a global object $ydb for everything related to DB and other globally needed stuff
- change in logic: include "load-yourls.php" instead of "config.php" to start engine
- change in DB schema: now storing URLs with their keyword as used in shorturl, allowing for any keyword length
- change in DB schema: new table for storing various options including next_id, dropping table of the same name
- change in DB schema: new table for storing hits (for stats)
- improved the installer, with .htaccess file creation
- layout tweak: now prettier, isn't it?
- stats! OMG stats!
1.4.1
-----
- fixed base 62 URLs (keywords with MiXeD CaSe)
- new & secure auth method for API calls, with no need to use login & password combo
- allow SSL enforcement for admin pages
- new API method: stats for individual URL.
- prevent internal redirection loops
- filter and search URLs & short URLs by date
1.4.2
-----
- fixed bug in auth function
- added sample public API file
- added check in API requests for WordPress plugin when adding a new short URL
- prettier sample public interface
1.4.3
-----
- fixed bug no-stats-showing-ffs due to inconsistency in DB schema
- improve error reporting with API method url-stat
1.5
---
- added: plugin architecture! OMG plugins!!1!!1!
- added: directory /user, config.php can be moved there
- added: new "instant bookmarklets"
- added: 1 click copy-to-clipboard a la bitly
- change in logic: now all request are handled by PHP and don't rely on .htaccess
- added: saving URL titles
- added: support for prefix-n-shorten: sho.rt/http://example.com/
- added: core plugin to allow hyphens in URLs
- added: core sample plugin to wrap redirected URLs in a social toolbar
- added: core sample plugin to show how to create administration page in plugins
- added: core plugin to display a random pretty background
- changed: layout now using a more consistent palette, see http://yourls.org/palette
- added: anti XSS and anti CSRF measures
- added: interactive map if possible in stat traffic by countries
- fixed: lots of bugs
1.5.1
-----
- added: full jsonp support
- added: ability to use encrypted passwords in the config file
- fixed: support for http://www.sho.rt/bleh and http://sho.rt/bleh
- added: support for any favicon dropped in the /user directory
- updated: Google Visualization API instead of deprecated Google Charts
- fixed: bugs, bugs, bugs
- added: hooks, hooks, hooks
- improved: things, things, things
1.6
---
YOURLS Changelog
================
This file attempts to list the main changes through all versions of YOURLS. For a much more detailed
list, simply refer to the commit messages: http://code.google.com/p/yourls/source/list
1.0
---
- initial release
1.0.1
-----
- don't remember. Trivial stuff probably.
1.1
---
- don't remember. Some little bugs I guess.
1.2
---
- don't remember. A few tiny stuff for sure.
1.3-RC1
-------
- added bookmarklet and tools page
- improved XSS filter when adding new URL
- code cleanup in admin/index.php to separate code and display
- added favicon
- stricter coding to prevent notices with undefined indexes
- hide PHP notices & SQL errors & warnings, unless YOURLS_DEBUG constant set to true
1.4
---
- added an upgrader from 1.3 to 1.4
- change in logic: now using a global object $ydb for everything related to DB and other globally needed stuff
- change in logic: include "load-yourls.php" instead of "config.php" to start engine
- change in DB schema: now storing URLs with their keyword as used in shorturl, allowing for any keyword length
- change in DB schema: new table for storing various options including next_id, dropping table of the same name
- change in DB schema: new table for storing hits (for stats)
- improved the installer, with .htaccess file creation
- layout tweak: now prettier, isn't it?
- stats! OMG stats!
1.4.1
-----
- fixed base 62 URLs (keywords with MiXeD CaSe)
- new & secure auth method for API calls, with no need to use login & password combo
- allow SSL enforcement for admin pages
- new API method: stats for individual URL.
- prevent internal redirection loops
- filter and search URLs & short URLs by date
1.4.2
-----
- fixed bug in auth function
- added sample public API file
- added check in API requests for WordPress plugin when adding a new short URL
- prettier sample public interface
1.4.3
-----
- fixed bug no-stats-showing-ffs due to inconsistency in DB schema
- improve error reporting with API method url-stat
1.5
---
- added: plugin architecture! OMG plugins!!1!!1!
- added: directory /user, config.php can be moved there
- added: new "instant bookmarklets"
- added: 1 click copy-to-clipboard a la bitly
- change in logic: now all request are handled by PHP and don't rely on .htaccess
- added: saving URL titles
- added: support for prefix-n-shorten: sho.rt/http://example.com/
- added: core plugin to allow hyphens in URLs
- added: core sample plugin to wrap redirected URLs in a social toolbar
- added: core sample plugin to show how to create administration page in plugins
- added: core plugin to display a random pretty background
- changed: layout now using a more consistent palette, see http://yourls.org/palette
- added: anti XSS and anti CSRF measures
- added: interactive map if possible in stat traffic by countries
- fixed: lots of bugs
1.5.1
-----
- added: full jsonp support
- added: ability to use encrypted passwords in the config file
- fixed: support for http://www.sho.rt/bleh and http://sho.rt/bleh
- added: support for any favicon dropped in the /user directory
- updated: Google Visualization API instead of deprecated Google Charts
- fixed: bugs, bugs, bugs
- added: hooks, hooks, hooks
- improved: things, things, things
1.6
---
- added: custom API actions

+ 26
- 26
LICENSE.md View File

@@ -1,26 +1,26 @@
__ ______ _ _ _____ _ _____
\ \ / / __ \| | | | __ \| | / ____|
\ \_/ / | | | | | | |__) | | | (___
\ /| | | | | | | _ /| | \___ \
| | | |__| | |__| | | \ \| |____ ____) |
|_| \____/ \____/|_| \_\______|_____/
YOURLS - Your Own URL Shortener - A URL shortening script
---------------------------------------------------------------
This program is free software. Do whatever the hell you want with it.
This program is distributed in the hope that it will be useful and/or
fun to use. There is absolutely no guarantee of any kind about anything.
For more text, have a look at http://www.gnu.org/licenses/gpl.txt
---------------------------------------------------------------
This software incorporates code stolen from WordPress, as shown by
comments in source where applicable.
---------------------------------------------------------------
By Lester CHAN (initial idea), Ozh RICHARD (development) and contributors.
__ ______ _ _ _____ _ _____
\ \ / / __ \| | | | __ \| | / ____|
\ \_/ / | | | | | | |__) | | | (___
\ /| | | | | | | _ /| | \___ \
| | | |__| | |__| | | \ \| |____ ____) |
|_| \____/ \____/|_| \_\______|_____/
YOURLS - Your Own URL Shortener - A URL shortening script
---------------------------------------------------------------
This program is free software. Do whatever the hell you want with it.
This program is distributed in the hope that it will be useful and/or
fun to use. There is absolutely no guarantee of any kind about anything.
For more text, have a look at http://www.gnu.org/licenses/gpl.txt
---------------------------------------------------------------
This software incorporates code stolen from WordPress, as shown by
comments in source where applicable.
---------------------------------------------------------------
By Lester CHAN (initial idea), Ozh RICHARD (development) and contributors.

+ 15
- 15
README.md View File

@@ -1,16 +1,16 @@
![yourls](http://yourls.org/images/yourls-logo.png)
[YOURLS](http://yourls.org)
======
**YOURLS** is a set of PHP script that will allow you to run your own URL shortener. You'll have full control over your data, detailed stats and analytics, plugins, and more. It's free.
Useful links
------------
* [Project home & doc](http://yourls.org)
* [Official blog](http://blog.yourls.org)
* [Wiki documentation](https://github.com/YOURLS/YOURLS/wiki/)
* [Issue tracker](https://github.com/YOURLS/YOURLS/issues)
* [Release archive](https://github.com/YOURLS/YOURLS/tags)
License
-------
![yourls](http://yourls.org/images/yourls-logo.png)
[YOURLS](http://yourls.org)
======
**YOURLS** is a set of PHP script that will allow you to run your own URL shortener. You'll have full control over your data, detailed stats and analytics, plugins, and more. It's free.
Useful links
------------
* [Project home & doc](http://yourls.org)
* [Official blog](http://blog.yourls.org)
* [Wiki documentation](https://github.com/YOURLS/YOURLS/wiki/)
* [Issue tracker](https://github.com/YOURLS/YOURLS/issues)
* [Release archive](https://github.com/YOURLS/YOURLS/tags)
License
-------
Free software. Do whatever the hell you want with it.

+ 51
- 51
admin/admin-ajax.php View File

@@ -1,51 +1,51 @@
<?php
define( 'YOURLS_ADMIN', true );
define( 'YOURLS_AJAX', true );
require_once( dirname( dirname( __FILE__ ) ) .'/includes/load-yourls.php' );
yourls_maybe_require_auth();
// This file will output a JSON string
header( 'Content-type: application/json' );
if( !isset( $_REQUEST['action'] ) )
die();
// Pick action
$action = $_REQUEST['action'];
switch( $action ) {
case 'add':
yourls_verify_nonce( 'add_url', $_REQUEST['nonce'], false, 'omg error' );
$return = yourls_add_new_link( $_REQUEST['url'], $_REQUEST['keyword'] );
echo json_encode($return);
break;
case 'edit_display':
yourls_verify_nonce( 'edit-link_'.$_REQUEST['id'], $_REQUEST['nonce'], false, 'omg error' );
$row = yourls_table_edit_row ( $_REQUEST['keyword'] );
echo json_encode( array('html' => $row) );
break;
case 'edit_save':
yourls_verify_nonce( 'edit-save_'.$_REQUEST['id'], $_REQUEST['nonce'], false, 'omg error' );
$return = yourls_edit_link( $_REQUEST['url'], $_REQUEST['keyword'], $_REQUEST['newkeyword'], $_REQUEST['title'] );
echo json_encode($return);
break;
case 'delete':
yourls_verify_nonce( 'delete-link_'.$_REQUEST['id'], $_REQUEST['nonce'], false, 'omg error' );
$query = yourls_delete_link_by_keyword( $_REQUEST['keyword'] );
echo json_encode(array('success'=>$query));
break;
case 'logout':
// unused for the moment
yourls_logout();
break;
default:
yourls_do_action( 'yourls_ajax_'.$action );
}
die();
<?php
define( 'YOURLS_ADMIN', true );
define( 'YOURLS_AJAX', true );
require_once( dirname( dirname( __FILE__ ) ) .'/includes/load-yourls.php' );
yourls_maybe_require_auth();
// This file will output a JSON string
header( 'Content-type: application/json' );
if( !isset( $_REQUEST['action'] ) )
die();
// Pick action
$action = $_REQUEST['action'];
switch( $action ) {
case 'add':
yourls_verify_nonce( 'add_url', $_REQUEST['nonce'], false, 'omg error' );
$return = yourls_add_new_link( $_REQUEST['url'], $_REQUEST['keyword'] );
echo json_encode($return);
break;
case 'edit_display':
yourls_verify_nonce( 'edit-link_'.$_REQUEST['id'], $_REQUEST['nonce'], false, 'omg error' );
$row = yourls_table_edit_row ( $_REQUEST['keyword'] );
echo json_encode( array('html' => $row) );
break;
case 'edit_save':
yourls_verify_nonce( 'edit-save_'.$_REQUEST['id'], $_REQUEST['nonce'], false, 'omg error' );
$return = yourls_edit_link( $_REQUEST['url'], $_REQUEST['keyword'], $_REQUEST['newkeyword'], $_REQUEST['title'] );
echo json_encode($return);
break;
case 'delete':
yourls_verify_nonce( 'delete-link_'.$_REQUEST['id'], $_REQUEST['nonce'], false, 'omg error' );
$query = yourls_delete_link_by_keyword( $_REQUEST['keyword'] );
echo json_encode(array('success'=>$query));
break;
case 'logout':
// unused for the moment
yourls_logout();
break;
default:
yourls_do_action( 'yourls_ajax_'.$action );
}
die();

+ 294
- 294
admin/index.php View File

@@ -1,295 +1,295 @@
<?php
define( 'YOURLS_ADMIN', true );
require_once( dirname( dirname( __FILE__ ) ).'/includes/load-yourls.php' );
yourls_maybe_require_auth();
// Variables
$table_url = YOURLS_DB_TABLE_URL;
$where = $search_sentence = $search_text = $url = $keyword = '';
$date_filter = $date_first = $date_second = '';
$base_page = yourls_admin_url( 'index.php' );
// Default SQL behavior
$search_in_text = yourls__( 'URL' );
$search_in = 'url';
$sort_by_text = yourls__( 'Short URL' );
$sort_by = 'timestamp';
$sort_order = 'desc';
$page = ( isset( $_GET['page'] ) ? intval($_GET['page']) : 1 );
$search = ( isset( $_GET['search'] ) ? htmlspecialchars( trim($_GET['search']) ) : '' );
$perpage = ( isset( $_GET['perpage'] ) && intval( $_GET['perpage'] ) ? intval($_GET['perpage']) : 15 );
$click_limit = ( isset( $_GET['click_limit'] ) && $_GET['click_limit'] !== '' ) ? intval( $_GET['click_limit'] ) : '' ;
if ( $click_limit !== '' ) {
$click_filter = ( isset( $_GET['click_filter'] ) && $_GET['click_filter'] == 'more' ? 'more' : 'less' ) ;
$click_moreless = ( $click_filter == 'more' ? '>' : '<' );
$where = " AND clicks $click_moreless $click_limit";
} else {
$click_filter = '';
}
// Searching
if( !empty( $search ) && !empty( $_GET['search_in'] ) ) {
switch( $_GET['search_in'] ) {
case 'keyword':
$search_in_text = yourls__( 'Short URL' );
$search_in = 'keyword';
break;
case 'url':
$search_in_text = yourls__( 'URL' );
$search_in = 'url';
break;
case 'title':
$search_in_text = yourls__( 'Title' );
$search_in = 'title';
break;
case 'ip':
$search_in_text = yourls__( 'IP Address' );
$search_in = 'ip';
break;
}
$search_sentence = yourls_s( 'Searching for <strong>%1$s</strong> in <strong>%2$s</strong>.', yourls_esc_html( $search ), yourls_esc_html( $search_in_text ) );
$search_url = yourls_sanitize_url( "&amp;search=$search&amp;search_in=$search_in" );
$search_text = $search;
$search = str_replace( '*', '%', '*' . yourls_escape( $search ) . '*' );
$where .= " AND `$search_in` LIKE ('$search')";
}
// Time span
if( !empty( $_GET['date_filter'] ) ) {
switch( $_GET['date_filter'] ) {
case 'before':
$date_filter = 'before';
if( isset( $_GET['date_first'] ) && yourls_sanitize_date( $_GET['date_first'] ) ) {
$date_first = yourls_sanitize_date( $_GET['date_first'] );
$date_first_sql = yourls_sanitize_date_for_sql( $_GET['date_first'] );
$where .= " AND `timestamp` < '$date_first_sql'";
}
break;
case 'after':
$date_filter = 'after';
if( isset( $_GET['date_first'] ) && yourls_sanitize_date( $_GET['date_first'] ) ) {
$date_first_sql = yourls_sanitize_date_for_sql( $_GET['date_first'] );
$date_first = yourls_sanitize_date( $_GET['date_first'] );
$where .= " AND `timestamp` > '$date_first_sql'";
}
break;
case 'between':
$date_filter = 'between';
if( isset( $_GET['date_first'] ) && isset( $_GET['date_second'] ) && yourls_sanitize_date( $_GET['date_first'] ) && yourls_sanitize_date( $_GET['date_second'] ) ) {
$date_first_sql = yourls_sanitize_date_for_sql( $_GET['date_first'] );
$date_second_sql = yourls_sanitize_date_for_sql( $_GET['date_second'] );
$date_first = yourls_sanitize_date( $_GET['date_first'] );
$date_second = yourls_sanitize_date( $_GET['date_second'] );
$where .= " AND `timestamp` BETWEEN '$date_first_sql' AND '$date_second_sql'";
}
break;
}
}
// Sorting
if( !empty( $_GET['sort_by'] ) || !empty( $_GET['sort_order'] ) ) {
switch( $_GET['sort_by'] ) {
case 'keyword':
$sort_by_text = yourls__( 'Short URL' );
$sort_by = 'keyword';
break;
case 'url':
$sort_by_text = yourls__( 'URL' );
$sort_by = 'url';
break;
case 'timestamp':
$sort_by_text = yourls__( 'Date' );
$sort_by = 'timestamp';
break;
case 'ip':
$sort_by_text = yourls__( 'IP Address' );
$sort_by = 'ip';
break;
case 'clicks':
$sort_by_text = yourls__( 'Clicks' );
$sort_by = 'clicks';
break;
}
switch( $_GET['sort_order'] ) {
case 'asc':
$sort_order = 'asc';
break;
case 'desc':
$sort_order = 'desc';
break;
}
}
// Get URLs Count for current filter, total links in DB & total clicks
list( $total_urls, $total_clicks ) = array_values( yourls_get_db_stats() );
if ( $where ) {
list( $total_items, $total_items_clicks ) = array_values( yourls_get_db_stats( $where ) );
} else {
$total_items = $total_urls;
$total_items_clicks = false;
}
// This is a bookmarklet
if ( isset( $_GET['u'] ) ) {
$is_bookmark = true;
yourls_do_action( 'bookmarklet' );
// No sanitization needed here: everything happens in yourls_add_new_link()
$url = ( $_GET['u'] );
$keyword = ( isset( $_GET['k'] ) ? ( $_GET['k'] ) : '' );
$title = ( isset( $_GET['t'] ) ? ( $_GET['t'] ) : '' );
$return = yourls_add_new_link( $url, $keyword, $title );
// If fails because keyword already exist, retry with no keyword
if ( isset( $return['status'] ) && $return['status'] == 'fail' && isset( $return['code'] ) && $return['code'] == 'error:keyword' ) {
$msg = $return['message'];
$return = yourls_add_new_link( $url, '', $ydb );
$return['message'] .= ' ('.$msg.')';
}
// Stop here if bookmarklet with a JSON callback function
if( isset( $_GET['jsonp'] ) && $_GET['jsonp'] == 'yourls' ) {
$short = $return['shorturl'] ? $return['shorturl'] : '';
$message = $return['message'];
header( 'Content-type: application/json' );
echo yourls_apply_filter( 'bookmarklet_jsonp', "yourls_callback({'short_url':'$short','message':'$message'});" );
die();
}
// Now use the URL that has been sanitized and returned by yourls_add_new_link()
$url = $return['url']['url'];
$where = sprintf( " AND `url` LIKE '%s' ", yourls_escape( $url ) );
$page = $total_pages = $perpage = 1;
$offset = 0;
$text = ( isset( $_GET['s'] ) ? stripslashes( $_GET['s'] ) : '' );
// This is not a bookmarklet
} else {
$is_bookmark = false;
// Checking $page, $offset, $perpage
if( empty($page) || $page == 0 ) {
$page = 1;
}
if( empty($offset) ) {
$offset = 0;
}
if( empty($perpage) || $perpage == 0) {
$perpage = 50;
}
// Determine $offset
$offset = ( $page-1 ) * $perpage;
// Determine Max Number Of Items To Display On Page
if( ( $offset + $perpage ) > $total_items ) {
$max_on_page = $total_items;
} else {
$max_on_page = ( $offset + $perpage );
}
// Determine Number Of Items To Display On Page
if ( ( $offset + 1 ) > $total_items ) {
$display_on_page = $total_items;
} else {
$display_on_page = ( $offset + 1 );
}
// Determing Total Amount Of Pages
$total_pages = ceil( $total_items / $perpage );
}
// Begin output of the page
$context = ( $is_bookmark ? 'bookmark' : 'index' );
yourls_html_head( $context );
yourls_html_logo();
yourls_html_menu() ;
yourls_do_action( 'admin_page_before_content' );
if ( !$is_bookmark ) { ?>
<p><?php echo $search_sentence; ?></p>
<p><?php
printf( yourls__( 'Display <strong>%1$s</strong> to <strong class="increment">%2$s</strong> of <strong class="increment">%3$s</strong> URLs' ), $display_on_page, $max_on_page, $total_items );
if( $total_items_clicks !== false )
echo ", " . sprintf( yourls_n( 'counting <strong>1</strong> click', 'counting <strong>%s</strong> clicks', $total_items_clicks ), yourls_number_format_i18n( $total_items_clicks ) );
?>.</p>
<?php } ?>
<p><?php printf( yourls__( 'Overall, tracking <strong class="increment">%1$s</strong> links, <strong>%2$s</strong> clicks, and counting!' ), yourls_number_format_i18n( $total_urls ), yourls_number_format_i18n( $total_clicks ) ); ?></p>
<?php yourls_do_action( 'admin_page_before_form' ); ?>
<?php yourls_html_addnew(); ?>
<?php
// If bookmarklet, add message. Otherwise, hide hidden share box.
if ( !$is_bookmark ) {
yourls_share_box( '', '', '', '', '', '', true );
} else {
echo '<script type="text/javascript">$(document).ready(function(){
feedback( "' . $return['message'] . '", "'. $return['status'] .'");
init_clipboard();
});</script>';
}
yourls_do_action( 'admin_page_before_table' );
yourls_table_head();
if ( !$is_bookmark ) {
$params = array(
'search' => $search,
'search_text' => $search_text,
'search_in' => $search_in,
'sort_by' => $sort_by,
'sort_order' => $sort_order,
'page' => $page,
'perpage' => $perpage,
'click_filter' => $click_filter,
'click_limit' => $click_limit,
'total_pages' => $total_pages,
'date_filter' => $date_filter,
'date_first' => $date_first,
'date_second' => $date_second,
);
yourls_html_tfooter( $params );
}
yourls_table_tbody_start();
// Main Query
$where = yourls_apply_filter( 'admin_list_where', $where );
$url_results = $ydb->get_results( "SELECT * FROM `$table_url` WHERE 1=1 $where ORDER BY `$sort_by` $sort_order LIMIT $offset, $perpage;" );
$found_rows = false;
if( $url_results ) {
$found_rows = true;
foreach( $url_results as $url_result ) {
$keyword = yourls_sanitize_string( $url_result->keyword );
$timestamp = strtotime( $url_result->timestamp );
$url = stripslashes( $url_result->url );
$ip = $url_result->ip;
$title = $url_result->title ? $url_result->title : '';
$clicks = $url_result->clicks;
echo yourls_table_add_row( $keyword, $url, $title, $ip, $clicks, $timestamp );
}
}
$display = $found_rows ? 'display:none' : '';
echo '<tr id="nourl_found" style="'.$display.'"><td colspan="6">' . yourls__('No URL') . '</td></tr>';
yourls_table_tbody_end();
yourls_table_end();
yourls_do_action( 'admin_page_after_table' );
if ( $is_bookmark )
yourls_share_box( $url, $return['shorturl'], $title, $text );
?>
<?php
define( 'YOURLS_ADMIN', true );
require_once( dirname( dirname( __FILE__ ) ).'/includes/load-yourls.php' );
yourls_maybe_require_auth();
// Variables
$table_url = YOURLS_DB_TABLE_URL;
$where = $search_sentence = $search_text = $url = $keyword = '';
$date_filter = $date_first = $date_second = '';
$base_page = yourls_admin_url( 'index.php' );
// Default SQL behavior
$search_in_text = yourls__( 'URL' );
$search_in = 'url';
$sort_by_text = yourls__( 'Short URL' );
$sort_by = 'timestamp';
$sort_order = 'desc';
$page = ( isset( $_GET['page'] ) ? intval($_GET['page']) : 1 );
$search = ( isset( $_GET['search'] ) ? htmlspecialchars( trim($_GET['search']) ) : '' );
$perpage = ( isset( $_GET['perpage'] ) && intval( $_GET['perpage'] ) ? intval($_GET['perpage']) : 15 );
$click_limit = ( isset( $_GET['click_limit'] ) && $_GET['click_limit'] !== '' ) ? intval( $_GET['click_limit'] ) : '' ;
if ( $click_limit !== '' ) {
$click_filter = ( isset( $_GET['click_filter'] ) && $_GET['click_filter'] == 'more' ? 'more' : 'less' ) ;
$click_moreless = ( $click_filter == 'more' ? '>' : '<' );
$where = " AND clicks $click_moreless $click_limit";
} else {
$click_filter = '';
}
// Searching
if( !empty( $search ) && !empty( $_GET['search_in'] ) ) {
switch( $_GET['search_in'] ) {
case 'keyword':
$search_in_text = yourls__( 'Short URL' );
$search_in = 'keyword';
break;
case 'url':
$search_in_text = yourls__( 'URL' );
$search_in = 'url';
break;
case 'title':
$search_in_text = yourls__( 'Title' );
$search_in = 'title';
break;
case 'ip':
$search_in_text = yourls__( 'IP Address' );
$search_in = 'ip';
break;
}
$search_sentence = yourls_s( 'Searching for <strong>%1$s</strong> in <strong>%2$s</strong>.', yourls_esc_html( $search ), yourls_esc_html( $search_in_text ) );
$search_url = yourls_sanitize_url( "&amp;search=$search&amp;search_in=$search_in" );
$search_text = $search;
$search = str_replace( '*', '%', '*' . yourls_escape( $search ) . '*' );
$where .= " AND `$search_in` LIKE ('$search')";
}
// Time span
if( !empty( $_GET['date_filter'] ) ) {
switch( $_GET['date_filter'] ) {
case 'before':
$date_filter = 'before';
if( isset( $_GET['date_first'] ) && yourls_sanitize_date( $_GET['date_first'] ) ) {
$date_first = yourls_sanitize_date( $_GET['date_first'] );
$date_first_sql = yourls_sanitize_date_for_sql( $_GET['date_first'] );
$where .= " AND `timestamp` < '$date_first_sql'";
}
break;
case 'after':
$date_filter = 'after';
if( isset( $_GET['date_first'] ) && yourls_sanitize_date( $_GET['date_first'] ) ) {
$date_first_sql = yourls_sanitize_date_for_sql( $_GET['date_first'] );
$date_first = yourls_sanitize_date( $_GET['date_first'] );
$where .= " AND `timestamp` > '$date_first_sql'";
}
break;
case 'between':
$date_filter = 'between';
if( isset( $_GET['date_first'] ) && isset( $_GET['date_second'] ) && yourls_sanitize_date( $_GET['date_first'] ) && yourls_sanitize_date( $_GET['date_second'] ) ) {
$date_first_sql = yourls_sanitize_date_for_sql( $_GET['date_first'] );
$date_second_sql = yourls_sanitize_date_for_sql( $_GET['date_second'] );
$date_first = yourls_sanitize_date( $_GET['date_first'] );
$date_second = yourls_sanitize_date( $_GET['date_second'] );
$where .= " AND `timestamp` BETWEEN '$date_first_sql' AND '$date_second_sql'";
}
break;
}
}
// Sorting
if( !empty( $_GET['sort_by'] ) || !empty( $_GET['sort_order'] ) ) {
switch( $_GET['sort_by'] ) {
case 'keyword':
$sort_by_text = yourls__( 'Short URL' );
$sort_by = 'keyword';
break;
case 'url':
$sort_by_text = yourls__( 'URL' );
$sort_by = 'url';
break;
case 'timestamp':
$sort_by_text = yourls__( 'Date' );
$sort_by = 'timestamp';
break;
case 'ip':
$sort_by_text = yourls__( 'IP Address' );
$sort_by = 'ip';
break;
case 'clicks':
$sort_by_text = yourls__( 'Clicks' );
$sort_by = 'clicks';
break;
}
switch( $_GET['sort_order'] ) {
case 'asc':
$sort_order = 'asc';
break;
case 'desc':
$sort_order = 'desc';
break;
}
}
// Get URLs Count for current filter, total links in DB & total clicks
list( $total_urls, $total_clicks ) = array_values( yourls_get_db_stats() );
if ( $where ) {
list( $total_items, $total_items_clicks ) = array_values( yourls_get_db_stats( $where ) );
} else {
$total_items = $total_urls;
$total_items_clicks = false;
}
// This is a bookmarklet
if ( isset( $_GET['u'] ) ) {
$is_bookmark = true;
yourls_do_action( 'bookmarklet' );
// No sanitization needed here: everything happens in yourls_add_new_link()
$url = ( $_GET['u'] );
$keyword = ( isset( $_GET['k'] ) ? ( $_GET['k'] ) : '' );
$title = ( isset( $_GET['t'] ) ? ( $_GET['t'] ) : '' );
$return = yourls_add_new_link( $url, $keyword, $title );
// If fails because keyword already exist, retry with no keyword
if ( isset( $return['status'] ) && $return['status'] == 'fail' && isset( $return['code'] ) && $return['code'] == 'error:keyword' ) {
$msg = $return['message'];
$return = yourls_add_new_link( $url, '', $ydb );
$return['message'] .= ' ('.$msg.')';
}
// Stop here if bookmarklet with a JSON callback function
if( isset( $_GET['jsonp'] ) && $_GET['jsonp'] == 'yourls' ) {
$short = $return['shorturl'] ? $return['shorturl'] : '';
$message = $return['message'];
header( 'Content-type: application/json' );
echo yourls_apply_filter( 'bookmarklet_jsonp', "yourls_callback({'short_url':'$short','message':'$message'});" );
die();
}
// Now use the URL that has been sanitized and returned by yourls_add_new_link()
$url = $return['url']['url'];
$where = sprintf( " AND `url` LIKE '%s' ", yourls_escape( $url ) );
$page = $total_pages = $perpage = 1;
$offset = 0;
$text = ( isset( $_GET['s'] ) ? stripslashes( $_GET['s'] ) : '' );
// This is not a bookmarklet
} else {
$is_bookmark = false;
// Checking $page, $offset, $perpage
if( empty($page) || $page == 0 ) {
$page = 1;
}
if( empty($offset) ) {
$offset = 0;
}
if( empty($perpage) || $perpage == 0) {
$perpage = 50;
}
// Determine $offset
$offset = ( $page-1 ) * $perpage;
// Determine Max Number Of Items To Display On Page
if( ( $offset + $perpage ) > $total_items ) {
$max_on_page = $total_items;
} else {
$max_on_page = ( $offset + $perpage );
}
// Determine Number Of Items To Display On Page
if ( ( $offset + 1 ) > $total_items ) {
$display_on_page = $total_items;
} else {
$display_on_page = ( $offset + 1 );
}
// Determing Total Amount Of Pages
$total_pages = ceil( $total_items / $perpage );
}
// Begin output of the page
$context = ( $is_bookmark ? 'bookmark' : 'index' );
yourls_html_head( $context );
yourls_html_logo();
yourls_html_menu() ;
yourls_do_action( 'admin_page_before_content' );
if ( !$is_bookmark ) { ?>
<p><?php echo $search_sentence; ?></p>
<p><?php
printf( yourls__( 'Display <strong>%1$s</strong> to <strong class="increment">%2$s</strong> of <strong class="increment">%3$s</strong> URLs' ), $display_on_page, $max_on_page, $total_items );
if( $total_items_clicks !== false )
echo ", " . sprintf( yourls_n( 'counting <strong>1</strong> click', 'counting <strong>%s</strong> clicks', $total_items_clicks ), yourls_number_format_i18n( $total_items_clicks ) );
?>.</p>
<?php } ?>
<p><?php printf( yourls__( 'Overall, tracking <strong class="increment">%1$s</strong> links, <strong>%2$s</strong> clicks, and counting!' ), yourls_number_format_i18n( $total_urls ), yourls_number_format_i18n( $total_clicks ) ); ?></p>
<?php yourls_do_action( 'admin_page_before_form' ); ?>
<?php yourls_html_addnew(); ?>
<?php
// If bookmarklet, add message. Otherwise, hide hidden share box.
if ( !$is_bookmark ) {
yourls_share_box( '', '', '', '', '', '', true );
} else {
echo '<script type="text/javascript">$(document).ready(function(){
feedback( "' . $return['message'] . '", "'. $return['status'] .'");
init_clipboard();
});</script>';
}
yourls_do_action( 'admin_page_before_table' );
yourls_table_head();
if ( !$is_bookmark ) {
$params = array(
'search' => $search,
'search_text' => $search_text,
'search_in' => $search_in,
'sort_by' => $sort_by,
'sort_order' => $sort_order,
'page' => $page,
'perpage' => $perpage,
'click_filter' => $click_filter,
'click_limit' => $click_limit,
'total_pages' => $total_pages,
'date_filter' => $date_filter,
'date_first' => $date_first,
'date_second' => $date_second,
);
yourls_html_tfooter( $params );
}
yourls_table_tbody_start();
// Main Query
$where = yourls_apply_filter( 'admin_list_where', $where );
$url_results = $ydb->get_results( "SELECT * FROM `$table_url` WHERE 1=1 $where ORDER BY `$sort_by` $sort_order LIMIT $offset, $perpage;" );
$found_rows = false;
if( $url_results ) {
$found_rows = true;
foreach( $url_results as $url_result ) {
$keyword = yourls_sanitize_string( $url_result->keyword );
$timestamp = strtotime( $url_result->timestamp );
$url = stripslashes( $url_result->url );
$ip = $url_result->ip;
$title = $url_result->title ? $url_result->title : '';
$clicks = $url_result->clicks;
echo yourls_table_add_row( $keyword, $url, $title, $ip, $clicks, $timestamp );
}
}
$display = $found_rows ? 'display:none' : '';
echo '<tr id="nourl_found" style="'.$display.'"><td colspan="6">' . yourls__('No URL') . '</td></tr>';
yourls_table_tbody_end();
yourls_table_end();
yourls_do_action( 'admin_page_after_table' );
if ( $is_bookmark )
yourls_share_box( $url, $return['shorturl'], $title, $text );
?>
<?php yourls_html_footer( ); ?>

+ 75
- 75
admin/install.php View File

@@ -1,75 +1,75 @@
<?php
define( 'YOURLS_ADMIN', true );
define( 'YOURLS_INSTALLING', true );
require_once( dirname(dirname(__FILE__)).'/includes/load-yourls.php' );
require_once( YOURLS_INC.'/functions-install.php' );
$error = array();
$warning = array();
$success = array();
// Check pre-requisites
if ( !yourls_check_database_version() )
$error[] = yourls_s( '%s version is too old. Ask your server admin for an upgrade.', 'MySQL' );
if ( !yourls_check_php_version() )
$error[] = yourls_s( '%s version is too old. Ask your server admin for an upgrade.', 'PHP' );
// Is YOURLS already installed ?
if ( yourls_is_installed() ) {
$error[] = yourls__( 'YOURLS already installed.' );
// check if .htaccess exists, recreate otherwise. No error checking.
if( !file_exists( YOURLS_ABSPATH.'/.htaccess' ) ) {
yourls_create_htaccess();
}
}
// Start install if possible and needed
if ( isset($_REQUEST['install']) && count( $error ) == 0 ) {
// Create/update .htaccess file
if ( yourls_create_htaccess() ) {
$success[] = yourls__( 'File <tt>.htaccess</tt> successfully created/updated.' );
} else {
$warning[] = yourls__( 'Could not write file <tt>.htaccess</tt> in YOURLS root directory. You will have to do it manually. See <a href="http://yourls.org/htaccess">how</a>.' );
}
// Create SQL tables
$install = yourls_create_sql_tables();
if ( isset( $install['error'] ) )
$error = array_merge( $error, $install['error'] );
if ( isset( $install['success'] ) )
$success = array_merge( $success, $install['success'] );
}
// Start output
yourls_html_head( 'install', yourls__( 'Install YOURLS' ) );
?>
<div id="login">
<form method="post" action="?"><?php // reset any QUERY parameters ?>
<p>
<img src="<?php yourls_site_url(); ?>/images/yourls-logo.png" alt="YOURLS" title="YOURLS" />
</p>
<?php
// Print errors, warnings and success messages
foreach ( array ('error', 'warning', 'success') as $info ) {
if ( count( $$info ) > 0 ) {
echo "<ul class='$info'>";
foreach( $$info as $msg ) {
echo '<li>'.$msg."</li>\n";
}
echo '</ul>';
}
}
// Display install button or link to admin area if applicable
if( !yourls_is_installed() && !isset($_REQUEST['install']) ) {
echo '<p style="text-align: center;"><input type="submit" name="install" value="' . yourls__( 'Install YOURLS') .'" class="button" /></p>';
} else {
if( count($error) == 0 )
echo '<p style="text-align: center;">&raquo; <a href="'.yourls_admin_url().'" title="' . yourls__( 'YOURLS Administration Page') . '">' . yourls__( 'YOURLS Administration Page') . '</a></p>';
}
?>
</form>
</div>
<?php yourls_html_footer(); ?>
<?php
define( 'YOURLS_ADMIN', true );
define( 'YOURLS_INSTALLING', true );
require_once( dirname(dirname(__FILE__)).'/includes/load-yourls.php' );
require_once( YOURLS_INC.'/functions-install.php' );
$error = array();
$warning = array();
$success = array();
// Check pre-requisites
if ( !yourls_check_database_version() )
$error[] = yourls_s( '%s version is too old. Ask your server admin for an upgrade.', 'MySQL' );
if ( !yourls_check_php_version() )
$error[] = yourls_s( '%s version is too old. Ask your server admin for an upgrade.', 'PHP' );
// Is YOURLS already installed ?
if ( yourls_is_installed() ) {
$error[] = yourls__( 'YOURLS already installed.' );
// check if .htaccess exists, recreate otherwise. No error checking.
if( !file_exists( YOURLS_ABSPATH.'/.htaccess' ) ) {
yourls_create_htaccess();
}
}
// Start install if possible and needed
if ( isset($_REQUEST['install']) && count( $error ) == 0 ) {
// Create/update .htaccess file
if ( yourls_create_htaccess() ) {
$success[] = yourls__( 'File <tt>.htaccess</tt> successfully created/updated.' );
} else {
$warning[] = yourls__( 'Could not write file <tt>.htaccess</tt> in YOURLS root directory. You will have to do it manually. See <a href="http://yourls.org/htaccess">how</a>.' );
}
// Create SQL tables
$install = yourls_create_sql_tables();
if ( isset( $install['error'] ) )
$error = array_merge( $error, $install['error'] );
if ( isset( $install['success'] ) )
$success = array_merge( $success, $install['success'] );
}
// Start output
yourls_html_head( 'install', yourls__( 'Install YOURLS' ) );
?>
<div id="login">
<form method="post" action="?"><?php // reset any QUERY parameters ?>
<p>
<img src="<?php yourls_site_url(); ?>/images/yourls-logo.png" alt="YOURLS" title="YOURLS" />
</p>
<?php
// Print errors, warnings and success messages
foreach ( array ('error', 'warning', 'success') as $info ) {
if ( count( $$info ) > 0 ) {
echo "<ul class='$info'>";
foreach( $$info as $msg ) {
echo '<li>'.$msg."</li>\n";
}
echo '</ul>';
}
}
// Display install button or link to admin area if applicable
if( !yourls_is_installed() && !isset($_REQUEST['install']) ) {
echo '<p style="text-align: center;"><input type="submit" name="install" value="' . yourls__( 'Install YOURLS') .'" class="button" /></p>';
} else {
if( count($error) == 0 )
echo '<p style="text-align: center;">&raquo; <a href="'.yourls_admin_url().'" title="' . yourls__( 'YOURLS Administration Page') . '">' . yourls__( 'YOURLS Administration Page') . '</a></p>';
}
?>
</form>
</div>
<?php yourls_html_footer(); ?>

+ 164
- 164
admin/plugins.php View File

@@ -1,164 +1,164 @@
<?php
define( 'YOURLS_ADMIN', true );
require_once( dirname( dirname( __FILE__ ) ).'/includes/load-yourls.php' );
yourls_maybe_require_auth();
// Handle plugin administration pages
if( isset( $_GET['page'] ) && !empty( $_GET['page'] ) ) {
yourls_plugin_admin_page( $_GET['page'] );
}
// Handle activation/deactivation of plugins
if( isset( $_GET['action'] ) ) {
// Check nonce
yourls_verify_nonce( 'manage_plugins', $_REQUEST['nonce'] );
// Check plugin file is valid
if( isset( $_GET['plugin'] ) && yourls_validate_plugin_file( YOURLS_PLUGINDIR.'/'.$_GET['plugin'].'/plugin.php') ) {
global $ydb;
// Activate / Deactive
switch( $_GET['action'] ) {
case 'activate':
$result = yourls_activate_plugin( $_GET['plugin'].'/plugin.php' );
if( $result === true )
yourls_redirect( yourls_admin_url( 'plugins.php?success=activated' ), 302 );
break;
case 'deactivate':
$result = yourls_deactivate_plugin( $_GET['plugin'].'/plugin.php' );
if( $result === true )
yourls_redirect( yourls_admin_url( 'plugins.php?success=deactivated' ), 302 );
break;
default:
$result = yourls__( 'Unsupported action' );
break;
}
} else {
$result = yourls__( 'No plugin specified, or not a valid plugin' );
}
yourls_add_notice( $result );
}
// Handle message upon succesfull (de)activation
if( isset( $_GET['success'] ) && ( ( $_GET['success'] == 'activated' ) OR ( $_GET['success'] == 'deactivated' ) ) ) {
if( $_GET['success'] == 'activated' ) {
$message = yourls__( 'Plugin has been activated' );
} elseif ( $_GET['success'] == 'deactivated' ) {
$message = yourls__( 'Plugin has been deactivated' );
}
yourls_add_notice( $message );
}
yourls_html_head( 'plugins', yourls__( 'Manage Plugins' ) );
yourls_html_logo();
yourls_html_menu();
?>
<h2><?php yourls_e( 'Plugins' ); ?></h2>
<?php
$plugins = (array)yourls_get_plugins();
uasort( $plugins, 'yourls_plugins_sort_callback' );
$count = count( $plugins );
$plugins_count = sprintf( yourls_n( '%s plugin', '%s plugins', $count ), $count );
$count_active = yourls_has_active_plugins();
?>
<p id="plugin_summary"><?php /* //translators: "you have '3 plugins' installed and '1' activated" */ yourls_se( 'You currently have <strong>%1$s</strong> installed, and <strong>%2$s</strong> activated', $plugins_count, $count_active ); ?></p>
<table id="main_table" class="tblSorter" cellpadding="0" cellspacing="1">
<thead>
<tr>
<th><?php yourls_e( 'Plugin Name' ); ?></th>
<th><?php yourls_e( 'Version' ); ?></th>
<th><?php yourls_e( 'Description' ); ?></th>
<th><?php yourls_e( 'Author' ); ?></th>
<th><?php yourls_e( 'Action' ); ?></th>
</tr>
</thead>
<tbody>
<?php
$nonce = yourls_create_nonce( 'manage_plugins' );
foreach( $plugins as $file=>$plugin ) {
// default fields to read from the plugin header
$fields = array(
'name' => 'Plugin Name',
'uri' => 'Plugin URI',
'desc' => 'Description',
'version' => 'Version',
'author' => 'Author',
'author_uri' => 'Author URI'
);
// Loop through all default fields, get value if any and reset it
foreach( $fields as $field=>$value ) {
if( isset( $plugin[ $value ] ) ) {
$data[ $field ] = $plugin[ $value ];
} else {
$data[ $field ] = '(no info)';
}
unset( $plugin[$value] );
}
$plugindir = trim( dirname( $file ), '/' );
if( yourls_is_active_plugin( $file ) ) {
$class = 'active';
$action_url = yourls_nonce_url( 'manage_plugins', yourls_add_query_arg( array('action' => 'deactivate', 'plugin' => $plugindir ) ) );
$action_anchor = yourls__( 'Deactivate' );
} else {
$class = 'inactive';
$action_url = yourls_nonce_url( 'manage_plugins', yourls_add_query_arg( array('action' => 'activate', 'plugin' => $plugindir ) ) );
$action_anchor = yourls__( 'Activate' );
}
// Other "Fields: Value" in the header? Get them too
if( $plugin ) {
foreach( $plugin as $extra_field=>$extra_value ) {
$data['desc'] .= "<br/>\n<em>$extra_field</em>: $extra_value";
unset( $plugin[$extra_value] );
}
}
$data['desc'] .= '<br/><small>' . yourls_s( 'plugin file location: %s', $file) . '</small>';
printf( "<tr class='plugin %s'><td class='plugin_name'><a href='%s'>%s</a></td><td class='plugin_version'>%s</td><td class='plugin_desc'>%s</td><td class='plugin_author'><a href='%s'>%s</a></td><td class='plugin_actions actions'><a href='%s'>%s</a></td></tr>",
$class, $data['uri'], $data['name'], $data['version'], $data['desc'], $data['author_uri'], $data['author'], $action_url, $action_anchor
);
}
?>
</tbody>
</table>
<script type="text/javascript">
yourls_defaultsort = 0;
yourls_defaultorder = 0;
<?php if ($count_active) { ?>
$('#plugin_summary').append('<span id="toggle_plugins">filter</span>');
$('#toggle_plugins').css({'background':'transparent url("../images/filter.gif") top left no-repeat','display':'inline-block','text-indent':'-9999px','width':'16px','height':'16px','margin-left':'3px','cursor':'pointer'})
.attr('title', '<?php echo yourls_esc_attr__( 'Toggle active/inactive plugins' ); ?>')
.click(function(){
$('#main_table tr.inactive').toggle();
});
<?php } ?>
</script>
<p><?php yourls_e( 'If something goes wrong after you activate a plugin and you cannot use YOURLS or access this page, simply rename or delete its directory, or rename the plugin file to something different than <code>plugin.php</code>.' ); ?></p>
<h3><?php yourls_e( 'More plugins' ); ?></h3>
<p><?php yourls_e( 'For more plugins, head to the official <a href="http://yourls.org/pluginlist">Plugin list</a>.' ); ?></p>
<?php yourls_html_footer(); ?>
<?php
define( 'YOURLS_ADMIN', true );
require_once( dirname( dirname( __FILE__ ) ).'/includes/load-yourls.php' );
yourls_maybe_require_auth();
// Handle plugin administration pages
if( isset( $_GET['page'] ) && !empty( $_GET['page'] ) ) {
yourls_plugin_admin_page( $_GET['page'] );
}
// Handle activation/deactivation of plugins
if( isset( $_GET['action'] ) ) {
// Check nonce
yourls_verify_nonce( 'manage_plugins', $_REQUEST['nonce'] );
// Check plugin file is valid
if( isset( $_GET['plugin'] ) && yourls_validate_plugin_file( YOURLS_PLUGINDIR.'/'.$_GET['plugin'].'/plugin.php') ) {
global $ydb;
// Activate / Deactive
switch( $_GET['action'] ) {
case 'activate':
$result = yourls_activate_plugin( $_GET['plugin'].'/plugin.php' );
if( $result === true )
yourls_redirect( yourls_admin_url( 'plugins.php?success=activated' ), 302 );
break;
case 'deactivate':
$result = yourls_deactivate_plugin( $_GET['plugin'].'/plugin.php' );
if( $result === true )
yourls_redirect( yourls_admin_url( 'plugins.php?success=deactivated' ), 302 );
break;
default:
$result = yourls__( 'Unsupported action' );
break;
}
} else {
$result = yourls__( 'No plugin specified, or not a valid plugin' );
}
yourls_add_notice( $result );
}
// Handle message upon succesfull (de)activation
if( isset( $_GET['success'] ) && ( ( $_GET['success'] == 'activated' ) OR ( $_GET['success'] == 'deactivated' ) ) ) {
if( $_GET['success'] == 'activated' ) {
$message = yourls__( 'Plugin has been activated' );
} elseif ( $_GET['success'] == 'deactivated' ) {
$message = yourls__( 'Plugin has been deactivated' );
}
yourls_add_notice( $message );
}
yourls_html_head( 'plugins', yourls__( 'Manage Plugins' ) );
yourls_html_logo();
yourls_html_menu();
?>
<h2><?php yourls_e( 'Plugins' ); ?></h2>
<?php
$plugins = (array)yourls_get_plugins();
uasort( $plugins, 'yourls_plugins_sort_callback' );
$count = count( $plugins );
$plugins_count = sprintf( yourls_n( '%s plugin', '%s plugins', $count ), $count );
$count_active = yourls_has_active_plugins();
?>
<p id="plugin_summary"><?php /* //translators: "you have '3 plugins' installed and '1' activated" */ yourls_se( 'You currently have <strong>%1$s</strong> installed, and <strong>%2$s</strong> activated', $plugins_count, $count_active ); ?></p>
<table id="main_table" class="tblSorter" cellpadding="0" cellspacing="1">
<thead>
<tr>
<th><?php yourls_e( 'Plugin Name' ); ?></th>
<th><?php yourls_e( 'Version' ); ?></th>
<th><?php yourls_e( 'Description' ); ?></th>
<th><?php yourls_e( 'Author' ); ?></th>
<th><?php yourls_e( 'Action' ); ?></th>
</tr>
</thead>
<tbody>
<?php
$nonce = yourls_create_nonce( 'manage_plugins' );
foreach( $plugins as $file=>$plugin ) {
// default fields to read from the plugin header
$fields = array(
'name' => 'Plugin Name',
'uri' => 'Plugin URI',
'desc' => 'Description',
'version' => 'Version',
'author' => 'Author',
'author_uri' => 'Author URI'
);
// Loop through all default fields, get value if any and reset it
foreach( $fields as $field=>$value ) {
if( isset( $plugin[ $value ] ) ) {
$data[ $field ] = $plugin[ $value ];
} else {
$data[ $field ] = '(no info)';
}
unset( $plugin[$value] );
}
$plugindir = trim( dirname( $file ), '/' );
if( yourls_is_active_plugin( $file ) ) {
$class = 'active';
$action_url = yourls_nonce_url( 'manage_plugins', yourls_add_query_arg( array('action' => 'deactivate', 'plugin' => $plugindir ) ) );
$action_anchor = yourls__( 'Deactivate' );
} else {
$class = 'inactive';
$action_url = yourls_nonce_url( 'manage_plugins', yourls_add_query_arg( array('action' => 'activate', 'plugin' => $plugindir ) ) );
$action_anchor = yourls__( 'Activate' );
}
// Other "Fields: Value" in the header? Get them too
if( $plugin ) {
foreach( $plugin as $extra_field=>$extra_value ) {
$data['desc'] .= "<br/>\n<em>$extra_field</em>: $extra_value";
unset( $plugin[$extra_value] );
}
}
$data['desc'] .= '<br/><small>' . yourls_s( 'plugin file location: %s', $file) . '</small>';
printf( "<tr class='plugin %s'><td class='plugin_name'><a href='%s'>%s</a></td><td class='plugin_version'>%s</td><td class='plugin_desc'>%s</td><td class='plugin_author'><a href='%s'>%s</a></td><td class='plugin_actions actions'><a href='%s'>%s</a></td></tr>",
$class, $data['uri'], $data['name'], $data['version'], $data['desc'], $data['author_uri'], $data['author'], $action_url, $action_anchor
);
}
?>
</tbody>
</table>
<script type="text/javascript">
yourls_defaultsort = 0;
yourls_defaultorder = 0;
<?php if ($count_active) { ?>
$('#plugin_summary').append('<span id="toggle_plugins">filter</span>');
$('#toggle_plugins').css({'background':'transparent url("../images/filter.gif") top left no-repeat','display':'inline-block','text-indent':'-9999px','width':'16px','height':'16px','margin-left':'3px','cursor':'pointer'})
.attr('title', '<?php echo yourls_esc_attr__( 'Toggle active/inactive plugins' ); ?>')
.click(function(){
$('#main_table tr.inactive').toggle();
});
<?php } ?>
</script>
<p><?php yourls_e( 'If something goes wrong after you activate a plugin and you cannot use YOURLS or access this page, simply rename or delete its directory, or rename the plugin file to something different than <code>plugin.php</code>.' ); ?></p>
<h3><?php yourls_e( 'More plugins' ); ?></h3>
<p><?php yourls_e( 'For more plugins, head to the official <a href="http://yourls.org/pluginlist">Plugin list</a>.' ); ?></p>
<?php yourls_html_footer(); ?>

+ 117
- 117
admin/tools.php View File

@@ -1,117 +1,117 @@
<?php
define( 'YOURLS_ADMIN', true );
require_once( dirname( dirname( __FILE__ ) ).'/includes/load-yourls.php' );
yourls_maybe_require_auth();
yourls_html_head( 'tools', yourls__( 'Cool YOURLS Tools' ) );
yourls_html_logo();
yourls_html_menu();
?>
<div class="sub_wrap">
<h2><?php yourls_e( 'Bookmarklets' ); ?></h2>
<p><?php yourls_e( 'YOURLS comes with <span>four</span> handy <span>bookmarklets</span> for easier link shortening.' ); ?></p>
<h3><?php yourls_e( 'Standard or Instant, Simple or Custom' ); ?></h3>
<ul>
<li><?php yourls_e( 'The <span>Standard Bookmarklets</span> will take you to a page where you can easily edit or delete your brand new short URL.' ); ?></li>
<li><?php yourls_e( 'The <span>Instant Bookmarklets</span> will pop the short URL without leaving the page you are viewing.' ); ?></li>
<li><?php yourls_e( 'The <span>Simple Bookmarklets</span> will generate a short URL with a random or sequential keyword.' ); ?></li>
<li><?php yourls_e( 'The <span>Custom Keyword Bookmarklets</span> will prompt you for a custom keyword first.' ); ?></li>
</ul>
<p><?php
yourls_e( "With the Standard Bookmarklets you will also get a <span>Quick Share</span> tool box to make posting to Twitter, Facebook or Friendfeed a snap." );
echo "\n";
yourls_e( "If you want to share a description along with the link you're shortening, simply <span>select text</span> on the page you're viewing before clicking on your bookmarklet link" );
?></p>
<h3><?php yourls_e( 'The Bookmarklets' ); ?></h3>
<p><?php yourls_e( 'Click and drag links to your toolbar (or right-click and bookmark it)' ); ?></p>
<table class="tblSorter" cellpadding="0" cellspacing="1">
<thead>
<tr>
<td>&nbsp;</td>
<th><?php yourls_e( 'Standard (new page)' ); ?></th>
<th><?php yourls_e( 'Instant (popup)' ); ?></th>
</tr>
</thead>
<tbody>
<tr>
<th class="header"><?php yourls_e( 'Simple' ); ?></th>
<td><a href="javascript:(function()%7Bvar%20d=document,w=window,enc=encodeURIComponent,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),s2=((s.toString()=='')?s:enc(s)),f='<?php echo yourls_admin_url('index.php'); ?>',l=d.location,p='?u='+enc(l.href)+'&t='+enc(d.title)+'&s='+s2,u=f+p;try%7Bthrow('ozhismygod');%7Dcatch(z)%7Ba=function()%7Bif(!w.open(u))l.href=u;%7D;if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();%7Dvoid(0);%7D)()" class="bookmarklet" onclick="alert('<?php echo yourls_esc_attr__( 'Drag to your toolbar!' ); ?>');return false;"><?php yourls_e( 'Shorten' ); ?></a></td>
<td><a href="javascript:(function()%7Bvar%20d=document,s=d.createElement('script');window.yourls_callback=function(r)%7Bif(r.short_url)%7Bprompt(r.message,r.short_url);%7Delse%7Balert('An%20error%20occured:%20'+r.message);%7D%7D;s.src='<?php echo yourls_admin_url('index.php'); ?>?u='+encodeURIComponent(d.location.href)+'&jsonp=yourls';void(d.body.appendChild(s));%7D)();" class="bookmarklet" onclick="alert('<?php echo yourls_esc_attr__( 'Drag to your toolbar!' ); ?>');return false;"><?php yourls_e( 'Instant Shorten' ); ?></a></td>
</tr>
<tr>
<th class="header"><?php yourls_e( 'Custom Keyword' ); ?></th>
<td><a href="javascript:(function()%7Bvar%20d=document,w=window,enc=encodeURIComponent,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),s2=((s.toString()=='')?s:enc(s)),f='<?php echo yourls_admin_url('index.php'); ?>',l=d.location,k=prompt(%22Custom%20URL%22),k2=(k?'&k='+k:%22%22),p='?u='+enc(l.href)+'&t='+enc(d.title)+'&s='+s2+k2,u=f+p;if(k!=null)%7Btry%7Bthrow('ozhismygod');%7Dcatch(z)%7Ba=function()%7Bif(!w.open(u))l.href=u;%7D;if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();%7Dvoid(0)%7D%7D)()" class="bookmarklet" onclick="alert('<?php echo yourls_esc_attr__( 'Drag to your toolbar!' ); ?>');return false;"><?php yourls_e( 'Custom shorten' ); ?></a></td>
<td><a href="javascript:(function()%7Bvar%20d=document,k=prompt('Custom%20URL'),s=d.createElement('script');if(k!=null){window.yourls_callback=function(r)%7Bif(r.short_url)%7Bprompt(r.message,r.short_url);%7Delse%7Balert('An%20error%20occured:%20'+r.message);%7D%7D;s.src='<?php echo yourls_admin_url('index.php'); ?>?u='+encodeURIComponent(d.location.href)+'&k='+k+'&jsonp=yourls';void(d.body.appendChild(s));%7D%7D)();" class="bookmarklet" onclick="alert('<?php echo yourls_esc_attr__( 'Drag to your toolbar!' ); ?>');return false;"><?php yourls_e( 'Instant Custom Shorten' ); ?></a></td>
</tr>
</tbody>
</table>
<h2><?php yourls_e( 'Prefix-n-Shorten' ); ?></h2>
<p><?php yourls_se( "When viewing a page, you can also prefix its full URL: just head to your browser's address bar, add \"<span>%s</span>\" to the beginning of the current URL (right before its 'http://' part) and hit enter.", preg_replace('@https?://@', '', YOURLS_SITE) . '/' ); ?></p>
<p><?php
yourls_e( 'Note: this will probably not work if your web server is running on Windows' );
if( yourls_is_windows() )
yourls_e( ' (which seems to be the case here)' );
?>.</p>
<?php if( yourls_is_private() ) { ?>
<h2><?php yourls_e( 'Secure passwordless API call' ); ?></h2>
<p><?php
yourls_e( 'YOURLS allows API calls the old fashioned way, using <tt>username</tt> and <tt>password</tt> parameters.' );
echo "\n";
yourls_e( "If you're worried about sending your credentials into the wild, you can also make API calls without using your login or your password, using a secret signature token." );
?></p>
<p><?php
yourls_se( 'Your secret signature token: <strong><code>%s</code></strong>', yourls_auth_signature() );
yourls_e( "(It's a secret. Keep it secret) ");
?></p>
<p><?php yourls_e( 'This signature token can only be used with the API, not with the admin interface.' ); ?></p>
<ul>
<li><h3><?php yourls_e( 'Usage of the signature token' ); ?></h3>
<p><?php yourls_e( 'Simply use parameter <tt>signature</tt> in your API requests. Example:' ); ?></p>
<p><code><?php echo YOURLS_SITE; ?>/yourls-api.php?signature=<?php echo yourls_auth_signature(); ?>&action=...</code></p>
</li>
<li><h3><?php yourls_e( 'Usage of a time limited signature token' ); ?></h3>
<pre><code>&lt;?php
$timestamp = time();
<tt>// <?php yourls_e( 'actual value:' ); ?> $time = <?php $time = time(); echo $time; ?></tt>
$signature = md5( $timestamp . '<?php echo yourls_auth_signature(); ?>' );
<tt>// <?php yourls_e( 'actual value:' ); ?> $signature = "<?php $sign = md5( $time. yourls_auth_signature() ); echo $sign; ?>"</tt>
?>
</code></pre>
<p><?php yourls_e( 'Now use parameters <tt>signature</tt> and <tt>timestamp</tt> in your API requests. Example:' ); ?></p>
<p><code><?php echo YOURLS_SITE; ?>/yourls-api.php?timestamp=<strong>$timestamp</strong>&signature=<strong>$signature</strong>&action=...</code></p>
<p><?php yourls_e( 'Actual values:' ); ?><br/>
<tt><?php echo YOURLS_SITE; ?>/yourls-api.php?timestamp=<?php echo $time; ?>&signature=<?php echo $sign; ?>&action=...</tt></p>
<p><?php yourls_se( 'This URL would be valid for only %s seconds', YOURLS_NONCE_LIFE ); ?></p>
</li>
</ul>
<p><?php yourls_se( 'See the <a href="%s">API documentation</a> for more', YOURLS_SITE . '/readme.html#API' ); ?></p>
</div>
<?php } // end is private ?>
<?php yourls_html_footer(); ?>
<?php
define( 'YOURLS_ADMIN', true );
require_once( dirname( dirname( __FILE__ ) ).'/includes/load-yourls.php' );
yourls_maybe_require_auth();
yourls_html_head( 'tools', yourls__( 'Cool YOURLS Tools' ) );
yourls_html_logo();
yourls_html_menu();
?>
<div class="sub_wrap">
<h2><?php yourls_e( 'Bookmarklets' ); ?></h2>
<p><?php yourls_e( 'YOURLS comes with <span>four</span> handy <span>bookmarklets</span> for easier link shortening.' ); ?></p>
<h3><?php yourls_e( 'Standard or Instant, Simple or Custom' ); ?></h3>
<ul>
<li><?php yourls_e( 'The <span>Standard Bookmarklets</span> will take you to a page where you can easily edit or delete your brand new short URL.' ); ?></li>
<li><?php yourls_e( 'The <span>Instant Bookmarklets</span> will pop the short URL without leaving the page you are viewing.' ); ?></li>
<li><?php yourls_e( 'The <span>Simple Bookmarklets</span> will generate a short URL with a random or sequential keyword.' ); ?></li>
<li><?php yourls_e( 'The <span>Custom Keyword Bookmarklets</span> will prompt you for a custom keyword first.' ); ?></li>
</ul>
<p><?php
yourls_e( "With the Standard Bookmarklets you will also get a <span>Quick Share</span> tool box to make posting to Twitter, Facebook or Friendfeed a snap." );
echo "\n";
yourls_e( "If you want to share a description along with the link you're shortening, simply <span>select text</span> on the page you're viewing before clicking on your bookmarklet link" );
?></p>
<h3><?php yourls_e( 'The Bookmarklets' ); ?></h3>
<p><?php yourls_e( 'Click and drag links to your toolbar (or right-click and bookmark it)' ); ?></p>
<table class="tblSorter" cellpadding="0" cellspacing="1">
<thead>
<tr>
<td>&nbsp;</td>
<th><?php yourls_e( 'Standard (new page)' ); ?></th>
<th><?php yourls_e( 'Instant (popup)' ); ?></th>
</tr>
</thead>
<tbody>
<tr>
<th class="header"><?php yourls_e( 'Simple' ); ?></th>
<td><a href="javascript:(function()%7Bvar%20d=document,w=window,enc=encodeURIComponent,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),s2=((s.toString()=='')?s:enc(s)),f='<?php echo yourls_admin_url('index.php'); ?>',l=d.location,p='?u='+enc(l.href)+'&t='+enc(d.title)+'&s='+s2,u=f+p;try%7Bthrow('ozhismygod');%7Dcatch(z)%7Ba=function()%7Bif(!w.open(u))l.href=u;%7D;if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();%7Dvoid(0);%7D)()" class="bookmarklet" onclick="alert('<?php echo yourls_esc_attr__( 'Drag to your toolbar!' ); ?>');return false;"><?php yourls_e( 'Shorten' ); ?></a></td>
<td><a href="javascript:(function()%7Bvar%20d=document,s=d.createElement('script');window.yourls_callback=function(r)%7Bif(r.short_url)%7Bprompt(r.message,r.short_url);%7Delse%7Balert('An%20error%20occured:%20'+r.message);%7D%7D;s.src='<?php echo yourls_admin_url('index.php'); ?>?u='+encodeURIComponent(d.location.href)+'&jsonp=yourls';void(d.body.appendChild(s));%7D)();" class="bookmarklet" onclick="alert('<?php echo yourls_esc_attr__( 'Drag to your toolbar!' ); ?>');return false;"><?php yourls_e( 'Instant Shorten' ); ?></a></td>
</tr>
<tr>
<th class="header"><?php yourls_e( 'Custom Keyword' ); ?></th>
<td><a href="javascript:(function()%7Bvar%20d=document,w=window,enc=encodeURIComponent,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),s2=((s.toString()=='')?s:enc(s)),f='<?php echo yourls_admin_url('index.php'); ?>',l=d.location,k=prompt(%22Custom%20URL%22),k2=(k?'&k='+k:%22%22),p='?u='+enc(l.href)+'&t='+enc(d.title)+'&s='+s2+k2,u=f+p;if(k!=null)%7Btry%7Bthrow('ozhismygod');%7Dcatch(z)%7Ba=function()%7Bif(!w.open(u))l.href=u;%7D;if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();%7Dvoid(0)%7D%7D)()" class="bookmarklet" onclick="alert('<?php echo yourls_esc_attr__( 'Drag to your toolbar!' ); ?>');return false;"><?php yourls_e( 'Custom shorten' ); ?></a></td>
<td><a href="javascript:(function()%7Bvar%20d=document,k=prompt('Custom%20URL'),s=d.createElement('script');if(k!=null){window.yourls_callback=function(r)%7Bif(r.short_url)%7Bprompt(r.message,r.short_url);%7Delse%7Balert('An%20error%20occured:%20'+r.message);%7D%7D;s.src='<?php echo yourls_admin_url('index.php'); ?>?u='+encodeURIComponent(d.location.href)+'&k='+k+'&jsonp=yourls';void(d.body.appendChild(s));%7D%7D)();" class="bookmarklet" onclick="alert('<?php echo yourls_esc_attr__( 'Drag to your toolbar!' ); ?>');return false;"><?php yourls_e( 'Instant Custom Shorten' ); ?></a></td>
</tr>
</tbody>
</table>
<h2><?php yourls_e( 'Prefix-n-Shorten' ); ?></h2>
<p><?php yourls_se( "When viewing a page, you can also prefix its full URL: just head to your browser's address bar, add \"<span>%s</span>\" to the beginning of the current URL (right before its 'http://' part) and hit enter.", preg_replace('@https?://@', '', YOURLS_SITE) . '/' ); ?></p>
<p><?php
yourls_e( 'Note: this will probably not work if your web server is running on Windows' );
if( yourls_is_windows() )
yourls_e( ' (which seems to be the case here)' );
?>.</p>
<?php if( yourls_is_private() ) { ?>
<h2><?php yourls_e( 'Secure passwordless API call' ); ?></h2>
<p><?php
yourls_e( 'YOURLS allows API calls the old fashioned way, using <tt>username</tt> and <tt>password</tt> parameters.' );
echo "\n";
yourls_e( "If you're worried about sending your credentials into the wild, you can also make API calls without using your login or your password, using a secret signature token." );
?></p>
<p><?php
yourls_se( 'Your secret signature token: <strong><code>%s</code></strong>', yourls_auth_signature() );
yourls_e( "(It's a secret. Keep it secret) ");
?></p>
<p><?php yourls_e( 'This signature token can only be used with the API, not with the admin interface.' ); ?></p>
<ul>
<li><h3><?php yourls_e( 'Usage of the signature token' ); ?></h3>
<p><?php yourls_e( 'Simply use parameter <tt>signature</tt> in your API requests. Example:' ); ?></p>
<p><code><?php echo YOURLS_SITE; ?>/yourls-api.php?signature=<?php echo yourls_auth_signature(); ?>&action=...</code></p>
</li>
<li><h3><?php yourls_e( 'Usage of a time limited signature token' ); ?></h3>
<pre><code>&lt;?php
$timestamp = time();
<tt>// <?php yourls_e( 'actual value:' ); ?> $time = <?php $time = time(); echo $time; ?></tt>
$signature = md5( $timestamp . '<?php echo yourls_auth_signature(); ?>' );
<tt>// <?php yourls_e( 'actual value:' ); ?> $signature = "<?php $sign = md5( $time. yourls_auth_signature() ); echo $sign; ?>"</tt>
?>
</code></pre>
<p><?php yourls_e( 'Now use parameters <tt>signature</tt> and <tt>timestamp</tt> in your API requests. Example:' ); ?></p>
<p><code><?php echo YOURLS_SITE; ?>/yourls-api.php?timestamp=<strong>$timestamp</strong>&signature=<strong>$signature</strong>&action=...</code></p>
<p><?php yourls_e( 'Actual values:' ); ?><br/>
<tt><?php echo YOURLS_SITE; ?>/yourls-api.php?timestamp=<?php echo $time; ?>&signature=<?php echo $sign; ?>&action=...</tt></p>
<p><?php yourls_se( 'This URL would be valid for only %s seconds', YOURLS_NONCE_LIFE ); ?></p>
</li>
</ul>
<p><?php yourls_se( 'See the <a href="%s">API documentation</a> for more', YOURLS_SITE . '/readme.html#API' ); ?></p>
</div>
<?php } // end is private ?>
<?php yourls_html_footer(); ?>

+ 86
- 86
admin/upgrade.php View File

@@ -1,86 +1,86 @@
<?php
define( 'YOURLS_ADMIN', true );
define( 'YOURLS_UPGRADING', true );
require_once( dirname( dirname( __FILE__ ) ).'/includes/load-yourls.php' );
require_once( YOURLS_INC.'/functions-upgrade.php' );
require_once( YOURLS_INC.'/functions-install.php' );
yourls_maybe_require_auth();
yourls_html_head( 'upgrade', yourls__( 'Upgrade YOURLS' ) );
yourls_html_logo();
yourls_html_menu();
?>
<h2><?php yourls_e( 'Upgrade YOURLS' ); ?></h2>
<?php
// Check if upgrade is needed
if ( !yourls_upgrade_is_needed() ) {
echo '<p>' . yourls_s( 'Upgrade not required. Go <a href="%s">back to play</a>!', yourls_admin_url('index.php') ) . '</p>';
} else {
/*
step 1: create new tables and populate them, update old tables structure,
step 2: convert each row of outdated tables if needed
step 3: - if applicable finish updating outdated tables (indexes etc)
- update version & db_version in options, this is all done!
*/
// From what are we upgrading?
if ( isset( $_GET['oldver'] ) && isset( $_GET['oldsql'] ) ) {
$oldver = yourls_sanitize_version( $_GET['oldver'] );
$oldsql = yourls_sanitize_version( $_GET['oldsql'] );
} else {
list( $oldver, $oldsql ) = yourls_get_current_version_from_sql();
}
// To what are we upgrading ?
$newver = YOURLS_VERSION;
$newsql = YOURLS_DB_VERSION;
// Verbose & ugly details
$ydb->show_errors = true;
// Let's go
$step = ( isset( $_GET['step'] ) ? intval( $_GET['step'] ) : 0 );
switch( $step ) {
default:
case 0:
?>
<p><?php yourls_e( 'Your current installation needs to be upgraded.' ); ?></p>
<p><?php yourls_e( 'Please, pretty please, it is recommended that you <strong>backup</strong> your database<br/>(you should do this regularly anyway)' ); ?></p>
<p><?php yourls_e( "Nothing awful <em>should</em> happen, but this doesn't mean it <em>won't</em> happen, right? ;)" ); ?></p>
<p><?php yourls_e( "On every step, if <span class='error'>something goes wrong</span>, you'll see a message and hopefully a way to fix." ); ?></p>
<p><?php yourls_e( 'If everything goes too fast and you cannot read, <span class="success">good for you</span>, let it go :)' ); ?></p>
<p><?php yourls_e( 'Once you are ready, press "Upgrade" !' ); ?></p>
<?php
echo "
<form action='upgrade.php?' method='get'>
<input type='hidden' name='step' value='1' />
<input type='hidden' name='oldver' value='$oldver' />
<input type='hidden' name='newver' value='$newver' />
<input type='hidden' name='oldsql' value='$oldsql' />
<input type='hidden' name='newsql' value='$newsql' />
<input type='submit' class='primary' value='" . yourls_esc_attr__( 'Upgrade' ) . "' />
</form>";
break;
case 1:
case 2:
$upgrade = yourls_upgrade( $step, $oldver, $newver, $oldsql, $newsql );
break;
case 3:
$upgrade = yourls_upgrade( 3, $oldver, $newver, $oldsql, $newsql );
echo '<p>' . yourls__( 'Your installation is now up to date ! ' ) . '</p>';
echo '<p>' . yourls_s( 'Go back to <a href="%s">the admin interface</a>', yourls_admin_url('index.php') ) . '</p>';
}
}
?>
<?php yourls_html_footer(); ?>
<?php
define( 'YOURLS_ADMIN', true );
define( 'YOURLS_UPGRADING', true );
require_once( dirname( dirname( __FILE__ ) ).'/includes/load-yourls.php' );
require_once( YOURLS_INC.'/functions-upgrade.php' );
require_once( YOURLS_INC.'/functions-install.php' );
yourls_maybe_require_auth();
yourls_html_head( 'upgrade', yourls__( 'Upgrade YOURLS' ) );
yourls_html_logo();
yourls_html_menu();
?>
<h2><?php yourls_e( 'Upgrade YOURLS' ); ?></h2>
<?php
// Check if upgrade is needed
if ( !yourls_upgrade_is_needed() ) {
echo '<p>' . yourls_s( 'Upgrade not required. Go <a href="%s">back to play</a>!', yourls_admin_url('index.php') ) . '</p>';
} else {
/*
step 1: create new tables and populate them, update old tables structure,
step 2: convert each row of outdated tables if needed
step 3: - if applicable finish updating outdated tables (indexes etc)
- update version & db_version in options, this is all done!
*/
// From what are we upgrading?
if ( isset( $_GET['oldver'] ) && isset( $_GET['oldsql'] ) ) {
$oldver = yourls_sanitize_version( $_GET['oldver'] );
$oldsql = yourls_sanitize_version( $_GET['oldsql'] );
} else {
list( $oldver, $oldsql ) = yourls_get_current_version_from_sql();
}
// To what are we upgrading ?
$newver = YOURLS_VERSION;
$newsql = YOURLS_DB_VERSION;
// Verbose & ugly details
$ydb->show_errors = true;
// Let's go
$step = ( isset( $_GET['step'] ) ? intval( $_GET['step'] ) : 0 );
switch( $step ) {
default:
case 0:
?>
<p><?php yourls_e( 'Your current installation needs to be upgraded.' ); ?></p>
<p><?php yourls_e( 'Please, pretty please, it is recommended that you <strong>backup</strong> your database<br/>(you should do this regularly anyway)' ); ?></p>
<p><?php yourls_e( "Nothing awful <em>should</em> happen, but this doesn't mean it <em>won't</em> happen, right? ;)" ); ?></p>
<p><?php yourls_e( "On every step, if <span class='error'>something goes wrong</span>, you'll see a message and hopefully a way to fix." ); ?></p>
<p><?php yourls_e( 'If everything goes too fast and you cannot read, <span class="success">good for you</span>, let it go :)' ); ?></p>
<p><?php yourls_e( 'Once you are ready, press "Upgrade" !' ); ?></p>
<?php
echo "
<form action='upgrade.php?' method='get'>
<input type='hidden' name='step' value='1' />
<input type='hidden' name='oldver' value='$oldver' />
<input type='hidden' name='newver' value='$newver' />
<input type='hidden' name='oldsql' value='$oldsql' />
<input type='hidden' name='newsql' value='$newsql' />
<input type='submit' class='primary' value='" . yourls_esc_attr__( 'Upgrade' ) . "' />
</form>";
break;
case 1:
case 2:
$upgrade = yourls_upgrade( $step, $oldver, $newver, $oldsql, $newsql );
break;
case 3:
$upgrade = yourls_upgrade( 3, $oldver, $newver, $oldsql, $newsql );
echo '<p>' . yourls__( 'Your installation is now up to date ! ' ) . '</p>';
echo '<p>' . yourls_s( 'Go back to <a href="%s">the admin interface</a>', yourls_admin_url('index.php') ) . '</p>';
}
}
?>
<?php yourls_html_footer(); ?>

+ 13
- 13
css/cal.css View File

@@ -1,14 +1,14 @@
/* Calendar */
.datepicker { border-collapse: collapse; border: 2px solid #999; position: absolute; width: 215px }
.datepicker tr.controls th { height: 22px; font-size: 11px; }
.datepicker select { font-size: 11px; }
.datepicker tr.days th { height: 18px; }
.datepicker tfoot td { height: 18px; text-align: center; text-transform: capitalize; }
.datepicker th, .datepicker tfoot td { background: #eee; font: 10px/18px Verdana, Arial, Helvetica, sans-serif; }
.datepicker th span, .datepicker tfoot td span { font-weight: bold; }
.datepicker tbody td { width: 24px; height: 24px; border: 1px solid #ccc; font: 11px/22px Arial, Helvetica, sans-serif; text-align: center; background: #fff; }
.datepicker tbody td.date { cursor: pointer; }
.datepicker tbody td.date.over { background-color: #99ffff; }
.datepicker tbody td.date.chosen { font-weight: bold; background-color: #ccffcc; }
/* Form defaults */
/* Calendar */
.datepicker { border-collapse: collapse; border: 2px solid #999; position: absolute; width: 215px }
.datepicker tr.controls th { height: 22px; font-size: 11px; }
.datepicker select { font-size: 11px; }
.datepicker tr.days th { height: 18px; }
.datepicker tfoot td { height: 18px; text-align: center; text-transform: capitalize; }
.datepicker th, .datepicker tfoot td { background: #eee; font: 10px/18px Verdana, Arial, Helvetica, sans-serif; }
.datepicker th span, .datepicker tfoot td span { font-weight: bold; }
.datepicker tbody td { width: 24px; height: 24px; border: 1px solid #ccc; font: 11px/22px Arial, Helvetica, sans-serif; text-align: center; background: #fff; }
.datepicker tbody td.date { cursor: pointer; }
.datepicker tbody td.date.over { background-color: #99ffff; }
.datepicker tbody td.date.chosen { font-weight: bold; background-color: #ccffcc; }
/* Form defaults */
#date_and, #date_second {display:none}

+ 113
- 113
css/infos.css View File

@@ -1,113 +1,113 @@
h3 span.label {
width:100px;
display:inline-block;
}
ul.toggle_display {
display:none;
list-style-type:none;
margin-left:0;
margin-right:23px;
padding:12px 5px 3px;
border-bottom:1px solid #C7E7FF;
}
ul.toggle_display li {
padding:0;
}
#tabs ul#headers li, #tabs ul#headers li h2, #stats_lines li{
display: inline;
margin-right: 10px;
}
#tabs ul#headers {
border-bottom:1px solid #E3F3FF;
padding:12px 5px 3px 5px;
float:left;
}
.wrap_unfloat {
overflow:hidden;
}
#tabs ul#headers li a {
color:#595441;
border:1px solid #C7E7FF;
-moz-border-radius:10px 10px 0 0;
-webkit-border-radius:10px 10px 0 0;
border-radius:10px 10px 0 0;
padding:10px 5px 5px 15px;
background:#E3F3FF;
}
#tabs ul#headers li a:hover {
text-decoration:none;
background:#88C0EB;
}
#tabs ul#headers li a.selected {
border-bottom:2px solid #fff;
background:#fff;
}
#tabs ul#headers li a.selected:hover {
background:#fff;
}
#stats_lines li a {
-moz-border-radius:10px 10px 0 0;
-webkit-border-radius:10px 10px 0 0;
border-radius:10px 10px 0 0;
padding:3px 10px;
background:#E3F3FF;
border:1px solid #C7E7FF;
}
#stats_lines li a:hover {
text-decoration:none;
background:#C7E7FF;
}
#stats_lines li a.selected {
background:#fff;
border:1px solid #C7E7FF;
border-bottom:1px solid white;
}
#stats_lines li a.selected:hover {