-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.php
83 lines (65 loc) · 2.73 KB
/
config.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
if (!function_exists('shell_exec')) {
die('Error: shell_exec() is not enabled');
}
// for some reason this may be empty. Let's try to get and set it.
$home_dir = getenv('HOME');
if (empty($home_dir) && function_exists('posix_getpwnam')) {
$user_data = posix_getpwnam(get_current_user());
$home_dir = empty($user_data['dir']) ? '' : $user_data['dir'];
if (!empty($home_dir)) {
putenv("HOME=$home_dir");
} else {
putenv('HOME');
}
}
define( 'APP_BASE_DIR', dirname( __FILE__ ) );
define( 'APP_GIT_BIN', @is_file('/usr/local/bin/ogit') ? '/usr/local/bin/ogit' : '/usr/bin/git');
define( 'APP_SVN_BIN', 'svn');
define( 'APP_NL', "<br/>\n" );
define( 'APP_LIVE_ENV', empty($_SERVER['DEV_ENV']) );
define( 'APP_LATEST_WP', rel_mng_get_latest_wp_version() );// load it dyn
if ( file_exists( APP_BASE_DIR . '/conf/config.custom.php' ) ) {
require_once APP_BASE_DIR . '/conf/config.custom.php';
}
if ( ! defined( 'APP_SVN_USER' ) ) {
define( 'APP_SVN_USER', "THIS-IS-SUPPOSED-TO-BE-YOUR-WP-USER" );
}
if ( ! defined( 'APP_SVN_PASS' ) ) {
define( 'APP_SVN_PASS', "THIS-IS-SUPPOSED-TO-BE-YOUR-WP-PASS" );
}
if ( ! defined( 'APP_SCAN_DIRS' ) ) {
define( 'APP_SCAN_DIRS', dirname(dirname(__DIR__) ) );
}
require_once dirname( __FILE__ ) . '/includes/file.php';
require_once dirname( __FILE__ ) . '/includes/wp_lib.php';
require_once dirname( __FILE__ ) . '/includes/string.php';
require_once dirname( __FILE__ ) . '/includes/ajax.php';
require_once dirname( __FILE__ ) . '/includes/release.php';
/**
* Parses the WP website to get the latest WP version. Requests are made every 24h
*
* @param void
* @return string e.g. 3.5.1
*/
function rel_mng_get_latest_wp_version() {
$url = 'http://wordpress.org/download/';
$ver = '6.5.1';
$ver_file = APP_BASE_DIR . '/data/latest_wp_ver.txt';
if ( !file_exists($ver_file) || (time() - filemtime($ver_file) > 4 * 3600)) {
$body_buff = file_get_contents($url);
// look for a link that points to latest.zip"
// <a class="button download-button" href="/latest.zip" onClick="recordOutboundLink(this, 'Download', 'latest.zip');return false;">
// <strong>Download WordPress 3.5.1</strong></span></a>
if (preg_match('#(<a.*?latest\.zip.*?</a>)#si', $body_buff, $matches)) {
$dl_link = $matches[1];
$dl_link = strip_tags($dl_link);
if (preg_match('#(\d+\.\d+(?:\.\d+)?[\w]*)#si', $dl_link, $ver_matches)) { // 1.2.3 or 1.2.3b
file_put_contents($ver_file, $ver_matches[1], LOCK_EX);
}
}
} else {
$ver = file_get_contents($ver_file);
}
return $ver;
}