This repository has been archived by the owner on Sep 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
wordmove-path-detect
executable file
·60 lines (49 loc) · 2.32 KB
/
wordmove-path-detect
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
#!/usr/bin/php
<?php
if ($argc == 1 || $argc > 3 || in_array($argv[1], array('--help', '-help', '-h', '-?'))) {
?>
wordmove-path-detect V 1.0
With this script is possible detect the path of wordpress.
Detect if httpdocs/publich_html exist in the remote host.
Made by Mte90 - http://www.mte90.net
Usage:
<?php echo $argv[0]; ?> [staging|production|etc]
The first parameter it's needed for get the host.
With the --help, -help, -h, or -? options, you can get this help.
<?php
} else {
if(file_exists('Movefile')) {
//Read the movefile
$movefile = yaml_parse(file_get_contents('Movefile'));
if ($argv[1] != 'local') {
echo 'Logging on the server...'."\n";
if($movefile[$argv[1]]['ftp']['host'] !== 'host') {
$connection = ftp_connect($movefile[$argv[1]]['ftp']['host'], 21)
or die ('It\'s not possible connect to the server'."\n");
ftp_login($connection, $movefile[$argv[1]]['ftp']['user'], $movefile[$argv[1]]['ftp']['password'])
or die('Username or password wrong.'."\n");
$ftp_string = 'ftp://'.$movefile[$argv[1]]['ftp']['user'].':'.$movefile[$argv[1]]['ftp']['password'].'@'.$movefile[$argv[1]]['ftp']['host'].'/';
//Auto Detection
echo 'Autodetection in progress'."\n";
if(is_dir($ftp_string.'httpdocs/')) {
$movefile[$argv[1]]['wordpress_path'] = '/httpdocs/';
} elseif(is_dir($ftp_string.'public_html/')) {
$movefile[$argv[1]]['wordpress_path'] = '/public_html/';
} else {
die('Path httpdocs/public_html not detected!'."\n");
}
$yaml = yaml_emit($movefile);
file_put_contents('Movefile',$yaml);
echo 'Movefile updated!'."\n";
echo 'Good job by Mte90!'."\n";
} else {
die ('You don\'t have insert a valid FTP host!'."\n");
}
} else {
echo 'What are you doing? We are in local, I can not check anything!'."\n";
}
} else {
echo 'ERROR: Missing Movefile!'."\n".'Generate it with `wordmove init`'."\n";
}
}
?>