1
|
|
|
<?php |
2
|
|
|
### ============================================================= |
3
|
|
|
### Mastop InfoDigital - Paixão por Internet |
4
|
|
|
### ============================================================= |
5
|
|
|
### Funções Padrão para o Módulo |
6
|
|
|
### ============================================================= |
7
|
|
|
### Developer: Fernando Santos (topet05), [email protected] |
8
|
|
|
### Copyright: Mastop InfoDigital © 2003-2006 |
9
|
|
|
### ------------------------------------------------------------- |
10
|
|
|
### www.mastop.com.br |
11
|
|
|
### ============================================================= |
12
|
|
|
### |
13
|
|
|
### ============================================================= |
14
|
|
|
|
15
|
|
|
use XoopsModules\Tdmdownloads; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @param $id |
19
|
|
|
* @return bool |
20
|
|
|
*/ |
21
|
|
|
function turnoffPermissions($id) |
22
|
|
|
{ |
23
|
|
|
global $xoopsModule, $grouppermHandler; |
24
|
|
|
$criteria = new \CriteriaCompo(); |
25
|
|
|
$criteria->add(new \Criteria('gperm_itemid', $id)); |
26
|
|
|
$criteria->add(new \Criteria('gperm_modid', $xoopsModule->getVar('mid'))); |
27
|
|
|
$criteria->add(new \Criteria('gperm_name', 'mpu_mpublish_acesso')); |
28
|
|
|
if ($old_perms = $grouppermHandler->getObjects($criteria)) { |
29
|
|
|
foreach ($old_perms as $p) { |
30
|
|
|
$grouppermHandler->delete($p); |
31
|
|
|
} |
32
|
|
|
} |
33
|
|
|
xoops_comment_delete($xoopsModule->getVar('mid'), $id); |
34
|
|
|
|
35
|
|
|
return true; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param $id |
40
|
|
|
* @return bool |
41
|
|
|
*/ |
42
|
|
|
function deletePermissions($id) |
43
|
|
|
{ |
44
|
|
|
global $xoopsModule; |
45
|
|
|
// require_once XOOPS_ROOT_PATH . '/modules/' . MPU_MOD_DIR . '/class/Publish.class.php'; |
46
|
|
|
$mpu_classe =new \XoopsModules\Tdmdownloads\Publish(); |
|
|
|
|
47
|
|
|
$todos = $mpu_classe->PegaTudo(new \Criteria('mpb_10_idpai', $id)); |
48
|
|
|
if (!empty($todos)) { |
49
|
|
|
foreach ($todos as $v) { |
50
|
|
|
turnoffPermissions($v->getVar('mpb_10_id')); |
51
|
|
|
xoops_comment_delete($xoopsModule->getVar('mid'), $v->getVar('mpb_10_id')); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
return true; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
return false; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param $id |
62
|
|
|
* @param $grupos_ids |
63
|
|
|
* @return bool |
64
|
|
|
*/ |
65
|
|
|
function insertPermission($id, $grupos_ids) |
66
|
|
|
{ |
67
|
|
|
global $xoopsModule; |
68
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
69
|
|
|
foreach ($grupos_ids as $gid) { |
70
|
|
|
$perm = $grouppermHandler->create(); |
71
|
|
|
$perm->setVar('gperm_name', 'mpu_mpublish_acesso'); |
72
|
|
|
$perm->setVar('gperm_itemid', $id); |
73
|
|
|
$perm->setVar('gperm_groupid', $gid); |
74
|
|
|
$perm->setVar('gperm_modid', $xoopsModule->getVar('mid')); |
75
|
|
|
$grouppermHandler->insert($perm); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
return true; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @param $content |
83
|
|
|
* @return mixed|string|string[]|null |
84
|
|
|
*/ |
85
|
|
|
function prepareContent($content) |
86
|
|
|
{ |
87
|
|
|
global $xoopsUser, $xoopsConfig; |
88
|
|
|
if (is_object($xoopsUser)) { |
89
|
|
|
if ($xoopsUser->cleanVars()) { |
90
|
|
|
foreach ($xoopsUser->cleanVars as $k => $v) { |
91
|
|
|
$content = str_replace('{' . $k . '}', $v, $content); |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
foreach ($xoopsConfig as $k => $v) { |
96
|
|
|
if (!is_array($v)) { |
97
|
|
|
$content = str_replace('{' . $k . '}', $v, $content); |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
$content = str_replace('{banner}', xoops_getbanner(), $content); |
101
|
|
|
if (!empty($_GET['busca']) && is_array($_GET['busca'])) { |
102
|
|
|
$search_string = MPU_MOD_HIGHLIGHT_SEARCH; |
|
|
|
|
103
|
|
|
$found = 0; |
104
|
|
|
$bgs = [ |
105
|
|
|
'#ffff66', |
106
|
|
|
'#a0ffff', |
107
|
|
|
'#99ff99', |
108
|
|
|
'#ff9999', |
109
|
|
|
'#880000', |
110
|
|
|
'#00aa00', |
111
|
|
|
'#886800', |
112
|
|
|
'#004699', |
113
|
|
|
'#990099' |
114
|
|
|
]; |
115
|
|
|
$colors = ['black', 'black', 'black', 'black', 'white', 'white', 'white', 'white', 'white']; |
116
|
|
|
$ctrl = 0; |
117
|
|
|
$busca = array_unique($_GET['busca']); |
118
|
|
|
foreach ($busca as $v) { |
119
|
|
|
if (false !== stripos(strip_tags($content), $v)) { |
120
|
|
|
$cfundo = $bgs[$ctrl]; |
121
|
|
|
$ctexto = $colors[$ctrl]; |
122
|
|
|
$busca[0] = '~' . $v . '(?![^<]*>)~'; |
123
|
|
|
$busca[1] = '~' . strtolower($v) . '(?![^<]*>)~'; |
124
|
|
|
$busca[2] = '~' . strtoupper($v) . '(?![^<]*>)~'; |
125
|
|
|
$busca[3] = '~' . ucfirst(strtolower($v)) . '(?![^<]*>)~'; |
126
|
|
|
$troca[0] = '<span style="font-weight:bold; color: ' . $ctexto . '; background-color: ' . $cfundo . ';">' . $v . '</span>'; |
127
|
|
|
$troca[1] = '<span style="font-weight:bold; color: ' . $ctexto . '; background-color: ' . $cfundo . ';">' . strtolower($v) . '</span>'; |
128
|
|
|
$troca[2] = '<span style="font-weight:bold; color: ' . $ctexto . '; background-color: ' . $cfundo . ';">' . strtoupper($v) . '</span>'; |
129
|
|
|
$troca[3] = '<span style="font-weight:bold; color: ' . $ctexto . '; background-color: ' . $cfundo . ';">' . ucfirst(strtolower($v)) . '</span>'; |
130
|
|
|
$content = preg_replace($busca, $troca, $content); |
131
|
|
|
$search_string .= '<span style="font-weight:bold; color: ' . $ctexto . '; background-color: ' . $cfundo . ';">' . $v . '</span>, '; |
132
|
|
|
$found = 1; |
133
|
|
|
if (8 == $ctrl) { |
134
|
|
|
$ctrl = 0; |
135
|
|
|
} else { |
136
|
|
|
++$ctrl; |
137
|
|
|
} |
138
|
|
|
} |
139
|
|
|
} |
140
|
|
|
if ($found) { |
141
|
|
|
$search_string = substr($search_string, 0, -2) . '<br><br>'; |
142
|
|
|
$content = $search_string . $content; |
143
|
|
|
} |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
return $content; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @param $repository |
151
|
|
|
* @param string $default |
152
|
|
|
* @return string |
153
|
|
|
*/ |
154
|
|
|
function getLatestTagUrl($repository, $default = 'master') { |
155
|
|
|
$file = @json_decode(@file_get_contents("https://api.github.com/repos/$repository/releases", false, |
156
|
|
|
stream_context_create(['http' => ['header' => "User-Agent:Publisher\r\n"]]) |
157
|
|
|
)); |
158
|
|
|
|
159
|
|
|
return sprintf("https://github.com/$repository/archive/%s.zip", $file ? reset($file)->tag_name : $default); |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths