-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpermission.php
122 lines (103 loc) · 3.23 KB
/
permission.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
// Usage without mysql_list_dbs()
/*
$link = mysql_connect('localhost', 'lpcms', 'lp_1234');
$res = mysql_query("SHOW DATABASES");
while ($row = mysql_fetch_assoc($res)) {
echo $row['Database'] . "<br/>";
}
*/
// Deprecated as of PHP 5.4.0
$link = mysql_connect('localhost', 'lpcms', 'lp_1234');
$db_list = mysql_list_dbs($link);
while ($row = mysql_fetch_object($db_list)) {
// echo $row->Database . "<br>";
$db = $row->Database;
$name = explode("_",$db);
$excluded = array("dev");
if($name[0] == "lpcms" && !in_array($name[1],$excluded)){
//echo $db . "<br>";
mysql_select_db ($db, $link) or die("Could not connect to table");
/*$sql = "insert into role_permission(rid, permission, module)
values('6','create ad_for_facebook content','node'),
('6','delete any ad_for_facebook content','node'),
('6','delete own ad_for_facebook content','node'),
('6','edit any ad_for_facebook content','node'),
('6','edit own ad_for_facebook content','node')";
*/
//$sql = "update taxonomy_term_data set name = 'Prochains événements' where name = 'Events'";
try{
/* $table = array("facebook", "twitter", "twitter_account");
$i = count($table);
for(;$i>0;$i--){
$sql = "drop table ".$table[$i-1];
$result = mysql_query($sql, $link);
}
*/
if(table_exists("facebook_data", $db)){
echo "Table found" . "<br>";
}
else
{
echo "not found in database : " . $db;
}
}
catch(Exception $e){
echo "Error";
echo $e->getMessage();
}
}
//db connection details
//$host = "localhost";
//$username = "root";
//$password = "";
//$db = "wordpress";
//connect to db
//$db_connection = mysql_connect($host, $username, $password) or die("Could not connect to db");
/*
mysql_select_db ($db, $link) or die("Could not connect to table");
//get statuses for tables in db
$sql = "SHOW TABLE STATUS";
$result = mysql_query($sql);
//initialize array
$tables = array();
while($row = mysql_fetch_array($result))
{
// return the size in Kilobytes
$table_size = ($row[ "Data_length" ] + $row[ "Index_length" ]) / 1024;
$tables[$row['Name']] = sprintf("%.2f", $table_size);
//get total size of all tables
$total_size += round($table_size,2);
// optimize tables
$optimise_sql = "OPTIMIZE TABLE {$row['Name']}";
$optimise_result = mysql_query($optimise_sql);
}
//get statuses for tables in db after optimization
$sql = "SHOW TABLE STATUS";
//initialize array
$optimised_tables = array();
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
// return the size in Kilobytes
$table_size = ($row[ "Data_length" ] + $row[ "Index_length" ]) / 1024;
$optimised_tables[$row['Name']] = sprintf("%.2f", $table_size);
//get total size of all tables after optimization
$optimise_total_size += round($table_size,2);
}
*/
}
function table_exists($tablename, $database = false) {
if(!$database) {
$res = mysql_query("SELECT DATABASE()");
$database = mysql_result($res, 0);
}
$res = mysql_query("
SELECT COUNT(*) AS count
FROM information_schema.tables
WHERE table_schema = '$database'
AND table_name = '$tablename'
");
return mysql_result($res, 0) == 1;
}
?>