System.php
5.5 KB
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
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
//by Install
class B2S_System {
public function __construct() {
}
public function check($action = 'before') {
$result = array();
if ($action == 'before') {
if (!$this->checkCurl()) {
$result['curl'] = false;
}
/* if(!$this->checkPHP()){
$result['php'] = false;
} */
}
if ($action == 'after') {
if (!$this->checkDbTables()) {
$result['dbTable'] = false;
}
}
return empty($result) ? true : $result;
}
private function checkCurl() {
return function_exists('curl_version');
}
private function checkPHP() {
if (version_compare(phpversion(), '5.5.3', '<')) {
return false;
}
return true;
}
private function checkDbTables() {
global $wpdb;
$return = false;
//ExistsColumn
$b2sUserCols = $wpdb->get_results('SHOW COLUMNS FROM '.$wpdb->prefix.'b2s_user');
if (is_array($b2sUserCols) && isset($b2sUserCols[0])) {
$b2sUserColsData = array();
foreach ($b2sUserCols as $key => $value) {
if (isset($value->Field) && !empty($value->Field)) {
$b2sUserColsData[] = $value->Field;
}
}
if (in_array("state_url", $b2sUserColsData)) {
$return = true;
}
}
//ExistsTable
if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}b2s_posts_sched_details'") != $wpdb->prefix.'b2s_posts_sched_details') {
$return = false;
}
return $return;
}
public function getErrorMessage($errors, $removeBreakline = false) {
$output = '';
if (is_array($errors) && !empty($errors)) {
foreach ($errors as $error => $status) {
if ($error == 'curl' && $status == false) {
$output .= esc_html__('Blog2Social used cURL. cURL is not installed in your PHP installation on your server. Install cURL and activate Blog2Social again.', 'blog2social');
$output .= (!$removeBreakline) ? '<br>' : ' ';
$output .= (!$removeBreakline) ? '<br>' : ' ';
$output .= sprintf(__('<a href="%s" target="_blank">Please find more Information and help in our FAQ</a>', 'blog2social'), esc_url(B2S_Tools::getSupportLink('system')));
}
if ($error == 'php' && $status == false) {
$output .= esc_html__('Blog2Social used PHP. Your installed PHP version on your server is not high enough to use Blog2Social. Update your PHP version on 5.5.3 or higher.', 'blog2social');
$output .= (!$removeBreakline) ? '<br>' : ' ';
$output .= (!$removeBreakline) ? '<br>' : ' ';
$output .= sprintf(__('<a href="%s" target="_blank">Please find more Information and help in our FAQ</a>', 'blog2social'), esc_url(B2S_Tools::getSupportLink('system')));
}
if ($error == 'dbTable' && $status == false) {
$output .= esc_html__('Blog2Social does not seem to have permission to write in your WordPress database. Please assign Blog2Social the permission to write in the WordPress database. Please also make sure that your MySQL server runs on v5.5.3 or higher, or ask your server administrator to do it for you.', 'blog2social');
$output .= (!$removeBreakline) ? '<br>' : ' ';
$output .= (!$removeBreakline) ? '<br>' : ' ';
$output .= sprintf(__('<a href="%s" target="_blank">Please find more Information and help in our FAQ</a>', 'blog2social'), esc_url(B2S_Tools::getSupportLink('system')));
}
}
}
return $output;
}
public function deactivatePlugin() {
deactivate_plugins(B2S_PLUGIN_BASENAME);
}
//V5.7.0 White-Label-Solution
public static function isblockedArea($area = '', $isAdmin = false, $general = false) {
if (defined('B2S_PLUGIN_WHITE_LABEL')) {
if (B2S_PLUGIN_WHITE_LABEL === true) {
if ($general) {
return true;
}
if (defined('B2S_PLUGIN_WHITE_LABEL_BLOCKED_AREA')) {
$blocked = unserialize(B2S_PLUGIN_WHITE_LABEL_BLOCKED_AREA);
if (is_array($blocked) && !empty($blocked)) {
if (in_array(trim($area), $blocked)) {
if ((trim($area) == 'B2S_LICENSE_MODUL_EDIT' || trim($area) == 'B2S_MENU_ITEM_LICENSE') && $isAdmin) {
return false;
}
return true;
}
}
}
}
}
return false;
}
//V5.7.0 White-Label-Solution
public static function customizeArea() {
if (defined('B2S_PLUGIN_WHITE_LABEL')) {
if (B2S_PLUGIN_WHITE_LABEL === true) {
if (defined('B2S_PLUGIN_WHITE_LABEL_LOGO')) {
if (!empty(B2S_PLUGIN_WHITE_LABEL_LOGO)) {
$file = get_home_path() . B2S_PLUGIN_WHITE_LABEL_LOGO;
if (file_exists($file)) {
return array('image_path' => $file);
}
}
}
}
}
return false;
}
}