-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchange_drupal_tmp_path.php
67 lines (57 loc) · 1.54 KB
/
change_drupal_tmp_path.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
#!/usr/bin/php
<?php
// update the path for the temporary files. Script for drupal on alternc 3.2.x only
$f=fopen("/etc/alternc/my.cnf","rb");
while ($s=fgets($f,1024)) {
if (preg_match('#database="([^"]*)#',$s,$mat)) {
$mdb=$mat[1];
}
if (preg_match('#host="([^"]*)#',$s,$mat)) {
$mhost=$mat[1];
}
if (preg_match('#user="([^"]*)#',$s,$mat)) {
$muser=$mat[1];
}
if (preg_match('#password="([^"]*)#',$s,$mat)) {
$mpass=$mat[1];
}
}
fclose($f);
$ALTERNC_ROOT="/var/alternc/html";
$f=fopen("/etc/alternc/my.cnf","rb");
while ($s=fgets($f,1024)) {
if (preg_match('#ALTERNC_HTML="([^"]*)#',$s,$mat)) {
$ALTERNC_ROOT=$mat[1];
}
}
fclose($f);
$ALTERNC_ROOT=rtrim($ALTERNC_ROOT,"/");
mysql_connect($mhost,$muser,$mpass);
mysql_select_db($mdb);
$drupaltables=array("variable","role","users","node");
$dbs=array();
$r=mysql_query("SHOW DATABASES");
while ($c=mysql_fetch_array($r)) {
$dbs[]=$c["Database"];
}
foreach($dbs as $db) {
$alternc=preg_replace("#_.*#","",$db);
mysql_select_db($db);
$drupalfound=0;
$r=mysql_query("SHOW TABLES");
while ($c=mysql_fetch_array($r)) {
if (in_array($c[0],$drupaltables)) {
$drupalfound++;
}
}
if ($drupalfound==count($drupaltables)) {
// c'est un drupal ;)
echo "db:$db\n";
$sql="UPDATE variable SET value='".addslashes(serialize($ALTERNC_ROOT."/".substr($alternc,0,1)."/".$alternc."/tmp"))."' WHERE name='file_temporary_path';";
mysql_query($sql);
if (mysql_errno()) {
echo "ERR:".mysql_error()."\n";
}
// echo $sql."\n";
}
}