]> CyberLeo.Net >> Repos - Github/YOURLS.git/blob - insert_ajax.php
Initial commit (importing from http://svn.planetozh.com/ozhin)
[Github/YOURLS.git] / insert_ajax.php
1 <?php\r
2 ### Require Files\r
3 require_once 'includes/config.php';\r
4 if (defined('YOURLS_PRIVATE') && YOURLS_PRIVATE == true)\r
5         require_once 'includes/auth.php';\r
6 \r
7 ### This file will output a JSON string\r
8 header('Content-type: application/json');\r
9 \r
10 ### Connect To Database\r
11 $db = yourls_db_connect();\r
12 \r
13 ### Pick action\r
14 switch( stripslashes($_REQUEST['mode']) ) {\r
15 \r
16         case 'add':\r
17                 $return = yourls_add_new_link( $_REQUEST['url'], $_REQUEST['keyword'], $db );\r
18                 echo yourls_json_encode($return);\r
19                 break;\r
20                 \r
21         case 'edit_display':\r
22                 $row = yourls_table_edit_row ( $_REQUEST['id'], $db );\r
23                 echo yourls_json_encode( array('html' => $row) );\r
24                 break;\r
25 \r
26         case 'edit_save':\r
27                 $return = yourls_edit_link( $_REQUEST['url'], $_REQUEST['id'], $_REQUEST['newid'], $db );\r
28                 echo yourls_json_encode($return);\r
29                 break;\r
30                 \r
31         case 'delete':\r
32                 $query = yourls_delete_link_by_id( $_REQUEST['id'], $db );\r
33                 echo yourls_json_encode(array('success'=>$query));\r
34                 break;\r
35                 \r
36         case 'logout':\r
37                 // unused for the moment\r
38                 yourls_logout();\r
39                 break;\r
40                 \r
41         default:\r
42                 die('Not implemented');\r
43 \r
44 }\r
45 ?>