]> CyberLeo.Net >> Repos - Github/YOURLS.git/blob - yourls-api.php
FIX: require() with absolute paths
[Github/YOURLS.git] / yourls-api.php
1 <?php\r
2 ### Require Files\r
3 require_once( dirname(__FILE__).'/includes/config.php' );\r
4 if (defined('YOURLS_PRIVATE') && YOURLS_PRIVATE == true)\r
5         require_once 'includes/auth.php';\r
6 \r
7 $db = yourls_db_connect();\r
8 $return = yourls_add_new_link( $_REQUEST['url'], $_REQUEST['keyword'], $db );\r
9 \r
10 switch ( $_REQUEST['format'] ) {\r
11         case 'json':\r
12                 header('Content-type: application/json');\r
13                 echo yourls_json_encode($return);\r
14                 break;\r
15         \r
16         case 'xml':\r
17                 header('Content-type: application/xml');\r
18                 echo yourls_xml_encode($return);\r
19                 break;\r
20                 \r
21         case 'simple':\r
22         default:\r
23                 echo $return['shorturl'];\r
24                 break;\r
25\r
26 \r
27 die();