18 if (!isset($instance)) {
39 if ($filepath ==
'')
return false;
41 if (!file_exists($filepath))
return true;
43 return unlink($filepath);
53 $db =& EXMDatabase::get();
54 $sql =
"SELECT COUNT(*) FROM $table";
55 if ($cond!=
'')
$sql .=
" WHERE $cond";
73 if($xoopsModule->dirname()==$module){
76 $mod =
new XoopsModule();
81 $mod->loadInfoAsVar($module);
82 $version =
$mod->getInfo(
'rmversion');
83 $version = is_array($version) ? $version : array(
'number'=>$version,
'revision'=>0,
'status'=>0,
'name'=>
$mod->getInfo(
'name'));
92 $rtn .= (defined($version[
'name']) ? constant($version[
'name']) : $version[
'name']) .
' ';
95 $rtn .= $version[
'number'];
97 if ($version[
'revision'] > 0){
98 $rtn .=
'.' . $version[
'revision'] / 100;
103 switch($version[
'status']){
124 $rtn .= (defined($version[
'name']) ? constant($version[
'name']) : $version[
'name']) .
' ';
128 if(isset($version[
'major'])){
129 $rtn .= $version[
'major'];
130 $rtn .=
'.'.$version[
'minor'];
131 $rtn .=
'.'.($version[
'revision']/10);
132 switch($version[
'stage']){
143 $rtn .=
' production';
149 $rtn .= $version[
'number'];
151 if ($version[
'revision'] > 0){
152 $rtn .=
'.' . ($version[
'revision'] / 100);
157 switch($version[
'status']){
183 static $rmModuleConfigs;
185 if (isset($rmModuleConfigs[$modname])){
187 if($option!=
'' & isset($rmModuleConfigs[$modname][$option]))
return $rmModuleConfigs[$modname][$option];
189 return $rmModuleConfigs[$modname];
193 if (isset($xoopsModuleConfig) && (is_object($xoopsModule) && $xoopsModule->getVar(
'dirname') == $modname && $xoopsModule->getVar(
'isactive'))) {
195 if($option !=
'' && isset($xoopsModuleConfig[$option])) {
196 return $xoopsModuleConfig[$option];
201 $module_handler =& xoops_gethandler(
'module');
202 $module = $module_handler->getByDirname($modname);
203 $config_handler =& xoops_gethandler(
'config');
205 $moduleConfig =& $config_handler->getConfigsByCat(0, $module->getVar(
'mid'));
206 $rmModuleConfigs[$modname] = $moduleConfig;
207 if($option !=
'' && isset($moduleConfig[$option])) {
208 return $moduleConfig[$option];
210 return $moduleConfig;
221 if ($color[0] ==
'#')
222 $color = substr($color, 1);
224 if (strlen($color) == 6)
225 list($r, $g, $b) = array($color[0].$color[1],
227 $color[4].$color[5]);
228 elseif (strlen($color) == 3)
229 list($r, $g, $b) = array($color[0].$color[0], $color[1].$color[1], $color[2].$color[2]);
231 list($r,$g,$b) = array(
"FF",
"FF",
"FF");
233 $r = hexdec($r); $g = hexdec($g); $b = hexdec($b);
234 return array(
'r'=>$r,
'g'=>$g,
'b'=>$b);
240 public function randomString($size, $digit =
true, $special =
false, $upper =
false, $alpha =
true){
241 $aM =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
242 $am =
"abcdefghijklmnopqrstuvwxyz";
244 $s =
"?@#\$%&()=???!.:,;-_+*[]{}";
247 if ($alpha) $que[] =
'alpha';
248 if ($digit) $que[] =
'digit';
249 if ($special) $que[] =
'special';
253 for (
$i=1;
$i<=$size;
$i++){
254 $op = $que[rand(0, count($que) - 1)];
257 $what = $upper ? $aM : (rand(0, 1)==0 ? $aM : $am);
258 $rtn .= substr($what, rand(0, strlen($what)-1), 1);
261 $rtn .= substr($d, rand(0, strlen($d)-1), 1);
264 $rtn .= substr(
$s, rand(0, strlen(
$s)-1), 1);
277 $string = rtrim($string,
"/");
293 return sprintf(
__(
'%s b',
'rmcommon'), $size);
295 return sprintf(
__(
'%s kb',
'rmcommon'), number_format($size / $kb, 2));
297 return sprintf(
__(
'%s MB',
'rmcommon'), number_format($size / $mb, 2));
299 return sprintf(
__(
'%s GB',
'rmcommon'), number_format($size / $mb, 2));
311 if (substr(
$path, 0, strlen(
$path) - 1)!=
'/'){
315 while ((
$file = readdir(
$dir)) !==
false){
318 self::delete_directory(
$path . $file);
320 @unlink(
$path . $file);
338 $img->load_from_params($default);
341 $ret =
'<div id="'.$id.
'-container" class="rmimage_container">';
342 $ret .=
'<div class="thumbnail">';
343 if($default!=
'' && !$img->isNew()){
344 $ret .=
'<a href="'.$img->url().
'" target="_blank"><img src="'.$img->get_smallest().
'" /></a>';
345 $ret .=
'<input type="hidden" name="'.$name.
'" id="'.
$id.
'" value="'.$default.
'" />';
346 $ret .=
'<br /><a href="#" class="removeButton removeButton-'.$id.
'">'.
__(
'Remove Image',
'rmcommon').
'</a>';
348 $ret .=
'<input type="hidden" name="'.$name.
'" id="'.
$id.
'" value="" />';
351 $ret .=
'<span class="image_manager_launcher button buttonGreen btn btn-success">'.__(
'Image manager...',
352 'rmcommon').
'</span>';
357 $tpl->add_head_script(
'var imgmgr_title = "'.
__(
'Image Manager',
'rmcommon').
'"'.
"\n".
'var mgrURL = "'.
RMCURL.
'/include/tiny-images.php";');
358 $tpl->add_local_script(
'image_mgr_launcher.js',
'rmcommon',
'include');