From 4f67f20f11317a701e999e165995a6790762bf57 Mon Sep 17 00:00:00 2001 From: ozhozh Date: Tue, 25 May 2010 15:57:03 +0000 Subject: [PATCH] Use global configuration constants (YOURLS_INC etc..) instead of hardcoded paths git-svn-id: http://yourls.googlecode.com/svn/trunk@354 12232710-3e20-11de-b438-597f59cd7555 --- admin/install.php | 2 +- admin/upgrade.php | 4 ++-- includes/functions-install.php | 2 +- includes/functions-upgrade.php | 2 +- includes/functions.php | 12 ++++++------ yourls-go.php | 4 ++-- yourls-infos.php | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/admin/install.php b/admin/install.php index eb57ac1..82de072 100644 --- a/admin/install.php +++ b/admin/install.php @@ -2,7 +2,7 @@ define( 'YOURLS_INSTALLING', true ); define( 'YOURLS_ADMIN', true ); require_once( dirname(dirname(__FILE__)).'/includes/load-yourls.php' ); -require_once( dirname(dirname(__FILE__)).'/includes/functions-install.php' ); +require_once( YOURLS_INC.'/functions-install.php' ); $error = array(); $warning = array(); diff --git a/admin/upgrade.php b/admin/upgrade.php index 984c3a5..933c28a 100644 --- a/admin/upgrade.php +++ b/admin/upgrade.php @@ -2,8 +2,8 @@ define( 'YOURLS_ADMIN', true ); define( 'YOURLS_NO_UPGRADE_CHECK', true ); // Bypass version checking to prevent loop require_once( dirname(dirname(__FILE__)).'/includes/load-yourls.php' ); -require_once( dirname(dirname(__FILE__)).'/includes/functions-upgrade.php' ); -require_once( dirname(dirname(__FILE__)).'/includes/functions-install.php' ); +require_once( YOURLS_INC.'/functions-upgrade.php' ); +require_once( YOURLS_INC.'/functions-install.php' ); yourls_maybe_require_auth(); yourls_html_head( 'tools' ); diff --git a/includes/functions-install.php b/includes/functions-install.php index 19cdc08..e49255c 100644 --- a/includes/functions-install.php +++ b/includes/functions-install.php @@ -65,7 +65,7 @@ function yourls_create_htaccess() { '', ); - $filename = dirname(dirname(__FILE__)).'/.htaccess'; + $filename = YOURLS_ABSPATH.'/.htaccess'; return ( yourls_insert_with_markers( $filename, 'YOURLS', $content ) ); } diff --git a/includes/functions-upgrade.php b/includes/functions-upgrade.php index 37d4643..fd1f4b0 100644 --- a/includes/functions-upgrade.php +++ b/includes/functions-upgrade.php @@ -252,7 +252,7 @@ function yourls_update_table_to_14() { // Clean .htaccess as it existed before 1.4. Returns boolean function yourls_clean_htaccess_for_14() { - $filename = dirname(dirname(__FILE__)).'/.htaccess'; + $filename = YOURLS_ABSPATH.'/.htaccess'; $result = false; if( is_writeable( $filename ) ) { diff --git a/includes/functions.php b/includes/functions.php index 27ce019..5ccdaf7 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -512,7 +512,7 @@ function yourls_db_connect() { // Return XML output. function yourls_xml_encode($array) { - require_once(dirname(__FILE__).'/functions-xml.php'); + require_once(YOURLS_INC.'/functions-xml.php'); $converter= new yourls_array2xml; return $converter->array2xml($array); } @@ -914,14 +914,14 @@ function yourls_geo_ip_to_countrycode( $ip = '', $default = '' ) { if ( false !== $location ) return $location; - if ( !file_exists( dirname(__FILE__).'/geo/GeoIP.dat') || !file_exists( dirname(__FILE__).'/geo/geoip.inc') ) + if ( !file_exists( YOURLS_INC.'/geo/GeoIP.dat') || !file_exists( YOURLS_INC.'/geo/geoip.inc') ) return $default; if ( $ip == '' ) $ip = yourls_get_IP(); - require_once( dirname(__FILE__).'/geo/geoip.inc') ; - $gi = geoip_open( dirname(__FILE__).'/geo/GeoIP.dat', GEOIP_STANDARD); + require_once( YOURLS_INC.'/geo/geoip.inc') ; + $gi = geoip_open( YOURLS_INC.'/geo/GeoIP.dat', GEOIP_STANDARD); $location = geoip_country_code_by_addr($gi, $ip); geoip_close($gi); @@ -1162,7 +1162,7 @@ function yourls_is_private() { // Show login form if required function yourls_maybe_require_auth() { if( yourls_is_private() ) - require_once( dirname(__FILE__).'/auth.php' ); + require_once( YOURLS_INC.'/auth.php' ); } // Return word or words if more than one @@ -1412,7 +1412,7 @@ function yourls_is_ssl() { // Get a remote page , return a string (either title or url) function yourls_get_remote_title( $url ) { - require_once( dirname(__FILE__).'/functions-http.php' ); + require_once( YOURLS_INC.'/functions-http.php' ); $url = yourls_sanitize_url( $url ); diff --git a/yourls-go.php b/yourls-go.php index 6472155..7cec9ce 100644 --- a/yourls-go.php +++ b/yourls-go.php @@ -29,9 +29,9 @@ } else { // Do we have a page? - if (file_exists(dirname(__FILE__)."/pages/$keyword.php")) { + if ( file_exists(YOURLS_PAGEDIR."/$keyword.php") ) { // Include YOURLS functions we've skipped, they might be of use - require_once( dirname(__FILE__).'/includes/functions-html.php' ); + require_once( YOURLS_INC.'/functions-html.php' ); yourls_page($keyword); // Either reserved id, or no such id diff --git a/yourls-infos.php b/yourls-infos.php index 42c3e26..6324679 100644 --- a/yourls-infos.php +++ b/yourls-infos.php @@ -3,7 +3,7 @@ // Require Files require_once( dirname(__FILE__).'/includes/load-yourls.php' ); -require_once( dirname(__FILE__).'/includes/functions-infos.php' ); +require_once( YOURLS_INC.'/functions-infos.php' ); yourls_maybe_require_auth(); if ( !isset( $_GET['id'] ) ) -- 2.45.0