]> CyberLeo.Net >> Repos - Github/YOURLS.git/blob - includes/load-yourls.php
Logic change: include "load-yourls.php" instead of "config.php" to start engine
[Github/YOURLS.git] / includes / load-yourls.php
1 <?php\r
2 // This file initialize everything needed for YOURLS\r
3 \r
4 // Include settings and functions\r
5 if( !file_exists(dirname(__FILE__).'/config.php') )\r
6         die('Cannot find <tt>config.php</tt>. Please read the <tt>readme.html</tt> to learn how to install YOURLS');\r
7         \r
8 require_once (dirname(__FILE__).'/config.php');\r
9 require_once (dirname(__FILE__).'/version.php');\r
10 require_once (dirname(__FILE__).'/functions.php');\r
11 require_once (dirname(__FILE__).'/functions-baseconvert.php');\r
12 require_once (dirname(__FILE__).'/class-mysql.php');\r
13 \r
14 // Check if config.php was properly updated for 1.4\r
15 if( !defined('YOURLS_DB_PREFIX') )\r
16         die('<p>Your <tt>config.php</tt> does not contain all the required constant definitions. Please check <tt>config-sample.php</tt> and update your config accordingly, there are new stuffs!</p>');\r
17 \r
18 // Define tables\r
19 if( !defined('YOURLS_DB_TABLE_URL') )\r
20         define('YOURLS_DB_TABLE_URL', YOURLS_DB_PREFIX.'url');\r
21 if( !defined('YOURLS_DB_TABLE_OPTIONS') )\r
22         define('YOURLS_DB_TABLE_OPTIONS', YOURLS_DB_PREFIX.'options');\r
23 if( !defined('YOURLS_DB_TABLE_LOG') )\r
24         define('YOURLS_DB_TABLE_LOG', YOURLS_DB_PREFIX.'log');\r
25 \r
26 // Create the YOURLS object $ydb that will contain everything we globally need\r
27 if ( function_exists( 'yourls_db_connect' ) ) {\r
28         global $ydb;\r
29         yourls_db_connect();\r
30 }\r
31 \r
32 // Read options right from start\r
33 yourls_get_all_options();\r
34 \r
35 // Check if upgrade is needed.\r
36 // Note: this is bypassable with define('YOURLS_NO_UPGRADE_CHECK', true)\r
37 // This is also bypassed if YOURLS_INSTALLING\r
38 if (\r
39         ( !defined('YOURLS_NO_UPGRADE_CHECK') || YOURLS_NO_UPGRADE_CHECK != true )\r
40         &&  \r
41         ( !defined('YOURLS_INSTALLING') || YOURLS_INSTALLING != true )\r
42 ) {\r
43         if ( yourls_upgrade_is_needed() ) {\r
44                 yourls_redirect( YOURLS_SITE .'/admin/upgrade.php' );\r
45         }\r
46 }