]> CyberLeo.Net >> Repos - Github/YOURLS.git/blob - includes/load-yourls.php
Fix install procedure. Damn it was broken :/
[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         require_once (dirname(__FILE__).'/functions.php');\r
7         define('YOURLS_SITE', dirname($_SERVER['REQUEST_URI'])); // LOL. Wild guess.\r
8         yourls_die('<p>Cannot find <tt>config.php</tt>.</p><p>Please read the <tt>readme.html</tt> to learn how to install YOURLS</p>');\r
9 }\r
10         \r
11 require_once (dirname(__FILE__).'/config.php');\r
12 require_once (dirname(__FILE__).'/version.php');\r
13 require_once (dirname(__FILE__).'/functions.php');\r
14 require_once (dirname(__FILE__).'/functions-baseconvert.php');\r
15 require_once (dirname(__FILE__).'/class-mysql.php');\r
16 \r
17 // Check if config.php was properly updated for 1.4\r
18 if( !defined('YOURLS_DB_PREFIX') )\r
19         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
20 \r
21 // Define constants that have not been user defined in config.php\r
22 if( !defined('YOURLS_DB_TABLE_URL') )\r
23         define('YOURLS_DB_TABLE_URL', YOURLS_DB_PREFIX.'url'); // table to store URLs\r
24 if( !defined('YOURLS_DB_TABLE_OPTIONS') )\r
25         define('YOURLS_DB_TABLE_OPTIONS', YOURLS_DB_PREFIX.'options'); // table to store options\r
26 if( !defined('YOURLS_DB_TABLE_LOG') )\r
27         define('YOURLS_DB_TABLE_LOG', YOURLS_DB_PREFIX.'log');  // table to store hits, for stats\r
28 if( !defined('YOURLS_FLOOD_DELAY_SECONDS') )\r
29         define('YOURLS_FLOOD_DELAY_SECONDS', 15 ); // minimum delay in sec before a same IP can add another URL. Note: logged in users are not throttled down.\r
30 if( !defined('YOURLS_FLOOD_IP_WHITELIST') )\r
31         define('YOURLS_FLOOD_IP_WHITELIST', '' ); // comma separated list of IPs that can bypass flood check.\r
32 \r
33 // Create the YOURLS object $ydb that will contain everything we globally need\r
34 if ( function_exists( 'yourls_db_connect' ) ) {\r
35         global $ydb;\r
36         yourls_db_connect();\r
37 }\r
38 \r
39 // Read options right from start\r
40 yourls_get_all_options();\r
41 \r
42 // Load auth functions if needed\r
43 if( yourls_is_private() )\r
44         require_once( dirname(__FILE__).'/functions-auth.php' );\r
45 \r
46 // Check if need to redirect to install procedure\r
47 if( !yourls_is_installed() && ( !defined('YOURLS_INSTALLING') || YOURLS_INSTALLING != true ) ) {\r
48         yourls_redirect( YOURLS_SITE .'/admin/install.php' );\r
49 }\r
50 \r
51 // Check if upgrade is needed.\r
52 // Note: this is bypassable with define('YOURLS_NO_UPGRADE_CHECK', true)\r
53 // This is also bypassed if YOURLS_INSTALLING\r
54 if (\r
55         ( !defined('YOURLS_NO_UPGRADE_CHECK') || YOURLS_NO_UPGRADE_CHECK != true )\r
56         &&  \r
57         ( !defined('YOURLS_INSTALLING') || YOURLS_INSTALLING != true )\r
58 ) {\r
59         if ( yourls_upgrade_is_needed() ) {\r
60                 yourls_redirect( YOURLS_SITE .'/admin/upgrade.php' );\r
61         }\r
62 }