%1$s installed, and %2$s activated', $plugins_count, $count_active ); ?>
+ +| + | + | + | + | + |
|---|---|---|---|---|
| %s | %s | %s | %s | %s |
plugin.php.' ); ?>
+ + + +Plugin list.' ); ?>
+diff --git a/admin/admin-ajax.php b/admin/admin-ajax.php
new file mode 100644
index 0000000..77f68ac
--- /dev/null
+++ b/admin/admin-ajax.php
@@ -0,0 +1,53 @@
+ $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();
diff --git a/admin/index.php b/admin/index.php
new file mode 100644
index 0000000..9a6d688
--- /dev/null
+++ b/admin/index.php
@@ -0,0 +1,324 @@
+ '', 'binds' => array());
+/**
+ * $where will collect additional SQL arguments:
+ * - $where['sql'] will concatenate SQL clauses: $where['sql'] .= ' AND something = :value ';
+ * - $where['binds'] will hold the (name => value) placeholder pairs: $where['binds']['value'] = $value;
+ */
+
+// SQL behavior (sorting, searching...)
+$view_params = new YOURLS\Views\AdminParams();
+/**
+ * This class gets all the parameters from the query string. It contains a lot of filters : if you need to modify
+ * something with a plugin, head to this file instead.
+ */
+
+// Pagination
+$page = $view_params->get_page();
+$perpage = $view_params->get_per_page(15);
+
+// Searching
+$search = $view_params->get_search();
+$search_in = $view_params->get_search_in();
+$search_in_text = $view_params->get_param_long_name($search_in);
+if( $search && $search_in && $search_in_text ) {
+ $search_sentence = yourls_s( 'Searching for %1$s in %2$s.', yourls_esc_html( $search ), yourls_esc_html( $search_in_text ) );
+ $search_text = $search;
+ $search = str_replace( '*', '%', '*' . $search . '*' );
+ if( $search_in == 'all' ) {
+ $where['sql'] .= " AND CONCAT_WS('',`keyword`,`url`,`title`,`ip`) LIKE (:search)";
+ // Search across all fields. The resulting SQL will be something like:
+ // SELECT * FROM `yourls_url` WHERE CONCAT_WS('',`keyword`,`url`,`title`,`ip`) LIKE ("%ozh%")
+ // CONCAT_WS because CONCAT('foo', 'bar', NULL) = NULL. NULL wins. Not sure if values can be NULL now or in the future, so better safe.
+ // TODO: pay attention to this bit when the DB schema changes
+ } else {
+ $where['sql'] .= " AND `$search_in` LIKE (:search)";
+ }
+ $where['binds']['search'] = $search;
+}
+
+// Time span
+$date_params = $view_params->get_date_params();
+$date_filter = $date_params['date_filter'];
+$date_first = $date_params['date_first'];
+$date_second = $date_params['date_second'];
+switch( $date_filter ) {
+ case 'before':
+ if( $date_first ) {
+ $date_first_sql = yourls_sanitize_date_for_sql( $date_first );
+ $where['sql'] .= ' AND `timestamp` < :date_first_sql';
+ $where['binds']['date_first_sql'] = $date_first_sql;
+ }
+ break;
+ case 'after':
+ if( $date_first ) {
+ $date_first_sql = yourls_sanitize_date_for_sql( $date_first );
+ $where['sql'] .= ' AND `timestamp` > :date_first_sql';
+ $where['binds']['date_first_sql'] = $date_first_sql;
+ }
+ break;
+ case 'between':
+ if( $date_first && $date_second ) {
+ $date_first_sql = yourls_sanitize_date_for_sql( $date_first );
+ $date_second_sql = yourls_sanitize_date_for_sql( $date_second );
+ $where['sql'] .= ' AND `timestamp` BETWEEN :date_first_sql AND :date_second_sql';
+ $where['binds']['date_first_sql'] = $date_first_sql;
+ $where['binds']['date_second_sql'] = $date_second_sql;
+ }
+ break;
+}
+
+// Sorting
+$sort_by = $view_params->get_sort_by();
+$sort_order = $view_params->get_sort_order();
+$sort_by_text = $view_params->get_param_long_name($sort_by);
+
+// Click filtering
+$click_limit = $view_params->get_click_limit();
+if ( $click_limit !== '' ) {
+ $click_filter = $view_params->get_click_filter();
+ $click_moreless = ($click_filter == 'more' ? '>' : '<');
+ $where['sql'] .= " AND clicks $click_moreless :click_limit";
+ $where['binds']['click_limit'] = $click_limit;
+} else {
+ $click_filter = '';
+}
+
+
+// Get URLs Count for current filter, total links in DB & total clicks
+list( $total_urls, $total_clicks ) = array_values( yourls_get_db_stats() );
+if ( !empty($where['sql']) ) {
+ 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'] ) or isset( $_GET['up'] ) ) {
+ $is_bookmark = true;
+ yourls_do_action( 'bookmarklet' );
+
+ // No sanitization needed here: everything happens in yourls_add_new_link()
+ if( isset( $_GET['u'] ) ) {
+ // Old school bookmarklet: ?u= %1$s to %2$s of %3$s URLs' ), $display_on_page, $max_on_page, $total_items );
+ if( $total_items_clicks !== false )
+ echo ", " . sprintf( yourls_n( 'counting 1 click', 'counting %s clicks', $total_items_clicks ), yourls_number_format_i18n( $total_items_clicks ) );
+ ?>. %1$s links, %2$s clicks, and counting!' ), yourls_number_format_i18n( $total_urls ), yourls_number_format_i18n( $total_clicks ) ); ?> %1$s installed, and %2$s activated', $plugins_count, $count_active ); ?> plugin.php.' ); ?> Plugin list.' ); ?> bookmarklets for easier link shortening and sharing.' ); ?> select text on the page you're viewing before clicking on your bookmarklet link" );
+ ?> Important Note: bookmarklets may fail on websites with https, especially the "Instant" bookrmarklets. There is nothing you can do about this.'); ?>
+
+
+
+
+
+
+
+
+
+ %s\" to the beginning of the current URL (right before its 'http://' part) and hit enter.", preg_replace('@https?://@', '', yourls_get_yourls_site()) . '/' ); ?> . username and password 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." );
+ ?> signature in your API requests. Example:' ); ?> signature and timestamp in your API requests. Example:' ); ?> Passwordless API page on the wiki.', 'https://yourls.org/passwordlessapi' ); ?>
+ API documentation for more', yourls_get_yourls_site() . '/readme.html#API' ); ?> ';
+
+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 );
+?>
+
+
diff --git a/admin/plugins.php b/admin/plugins.php
new file mode 100644
index 0000000..123f630
--- /dev/null
+++ b/admin/plugins.php
@@ -0,0 +1,165 @@
+
+
+ ' . yourls__('No URL') . '
+
+
+
+
+
+
+
+
+
+ $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 ] = yourls__('(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 ), yourls_admin_url('plugins.php') ) );
+ $action_anchor = yourls__( 'Deactivate' );
+ } else {
+ $class = 'inactive';
+ $action_url = yourls_nonce_url( 'manage_plugins', yourls_add_query_arg( array('action' => 'activate', 'plugin' => $plugindir ), yourls_admin_url('plugins.php') ) );
+ $action_anchor = yourls__( 'Activate' );
+ }
+
+ // Other "Fields: Value" in the header? Get them too
+ if( $plugin ) {
+ foreach( $plugin as $extra_field=>$extra_value ) {
+ $data['desc'] .= "
+
+
+
+
+
\n$extra_field: $extra_value";
+ unset( $plugin[$extra_value] );
+ }
+ }
+
+ $data['desc'] .= '
' . yourls_s( 'plugin file location: %s', $file) . '';
+
+ printf( " ",
+ $class, $data['uri'], $data['name'], $data['version'], $data['desc'], $data['author_uri'], $data['author'], $action_url, $action_anchor
+ );
+
+ }
+ ?>
+
+ %s %s %s %s %s
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ %s', yourls_auth_signature() ); ?>
+
+
+
+ /yourls-api.php?signature=&action=...
+ <?php
+$timestamp = time();
+// $time =
+$signature = md5( $timestamp . '' );
+// $signature = ""
+?>
+/yourls-api.php?timestamp=$timestamp&signature=$signature&action=...
+ /yourls-api.php?timestamp=&signature=&action=...
backup your database
(you should do this regularly anyway)' ); ?>
should happen, but this doesn't mean it won't happen, right? ;)" ); ?>
+something goes wrong, you'll see a message and hopefully a way to fix." ); ?>
+good for you, let it go :)' ); ?>
+ + + + + + + + + "; + + 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 '' . yourls__( 'Your installation is now up to date ! ' ) . '
'; + echo '' . yourls_s( 'Go back to the admin interface', yourls_admin_url('index.php') ) . '
'; + } + +} + +?> + +