diff options
| author | s1n <[email protected]> | 2020-03-28 10:36:41 -0700 |
|---|---|---|
| committer | s1n <[email protected]> | 2020-03-28 10:36:41 -0700 |
| commit | 25b7d2aab61ae6421398d3abae5da6ffe590333d (patch) | |
| tree | 611985ec78bb2d94099c9fd5dd687f5c9cee6f3e /admin/admin-ajax.php | |
| parent | Initial commit (diff) | |
| download | crack.cf-backup-master.tar.xz crack.cf-backup-master.zip | |
Diffstat (limited to 'admin/admin-ajax.php')
| -rw-r--r-- | admin/admin-ajax.php | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/admin/admin-ajax.php b/admin/admin-ajax.php new file mode 100644 index 0000000..a89912e --- /dev/null +++ b/admin/admin-ajax.php @@ -0,0 +1,51 @@ +<?php +define( 'YOURLS_ADMIN', true ); +define( 'YOURLS_AJAX', true ); +require_once( dirname( __DIR__ ) .'/includes/load-yourls.php' ); +yourls_maybe_require_auth(); + +// This file will output a JSON string +yourls_content_type_header( '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(); |