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-absolute-path
executable file
·69 lines (53 loc) · 2.81 KB
/
wordmove-absolute-path
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
#!/usr/bin/php
<?php
if ($argc == 1 || $argc > 3 || in_array($argv[1], array('--help', '-help', '-h', '-?'))) {
?>
wordmove-absolute-path V 1.1
With this script is possible auto insert the absolute_path in the Movefile
Made by Mte90 - http://www.mte90.net
Usage:
<?php echo $argv[0]; ?> [staging|production|etc]
The first parameter it's needed for get the absolute path of the host and insert in the Movefile.
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");
//The file that return the absolute path
file_put_contents('absolute.php','<?php echo dirname(__FILE__); ?>');
//Move to the folder
if($movefile[$argv[1]]['wordpress_path'] !== '/var/www/your_site') {
ftp_chdir($connection, $movefile[$argv[1]]['wordpress_path']) or die('The path of Wordpress installation is wrong'."\n");
} else {
die ('You don\'t have insert a valid path of Wordpress!'."\n");
}
//Upload the file and overwrite if exist on the host
$send = ftp_put($connection, 'absolute.php', 'absolute.php', FTP_ASCII);
$absolute = file_get_contents($movefile[$argv[1]]['vhost'].'/absolute.php');
//remove the file generated
unlink('absolute.php');
ftp_delete($connection, 'absolute.php');
//Insert value
$movefile[$argv[1]]['wordpress_absolute_path'] = $absolute;
$yaml = yaml_emit($movefile);
file_put_contents('Movefile',$yaml);
echo (!$send) ? 'Upload Error!'."\n" : 'Movefile updated!'."\n".'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";
}
}
?>