public static function cgsi_getimages($params, $content, &$smarty, $repeat) { if (!$content) { return; } $mod = cms_utils::get_module('CGSmartImage'); $old_errorval = libxml_use_internal_errors(true); $dom = new CGDomDocument(); $dom->strictErrorChecking = FALSE; $dom->validateOnParse = FALSE; if (function_exists('mb_convert_encoding')) { $content = mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8'); } $dom->loadHTML($content); $imgs = $dom->GetElementsByTagName('img'); if (is_object($imgs) && $imgs->length) { $out = array(); for ($i = 0; $i < $imgs->length; $i++) { $node = $imgs->item($i); $sxe = simplexml_import_dom($node); $rec = array(); $rec['tag'] = $sxe->asXML(); foreach ($sxe->attributes() as $name => $value) { $value = (string) $value; if ($value == '') { continue; } $rec[$name] = $value; } $out[] = $rec; } if (isset($params['assign'])) { $smarty->assign($params['assign'], $out); } } $imagesonly = cms_to_bool(get_parameter_value($params, 'imagesonly')); $nocontent = cms_to_bool(get_parameter_value($params, 'nocontent')); if (!$nocontent) { if ($imagesonly) { $content = ''; foreach ($out as $rec) { $content .= $rec['tag']; } } return $content; } }
function plugin_anchorlink($params, &$smarty) { $name = get_parameter_value($params, 'n'); $name = get_parameter_value($params, 'name', $name); $assign = trim(get_parameter_value($params, 'assign')); $urlonly = get_parameter_value($params, 'u'); $urlonly = cms_to_bool(get_parameter_value($params, 'urlonly', $urlonly)); $text = get_parameter_value($params, 'text', $name); unset($params['name'], $params['n'], $params['assign'], $params['u'], $params['urlonly'], $params['text']); // start the work $out = $url = null; if ($name) { $url = cgsimple::anchor_url($name); } if ($urlonly) { $out = $url; } else { // build a link with all the leftover params (don't filter them, there are lots of valid params for a link). $tpl = " %s=\"%s\""; $out = '<a'; $out .= sprintf($tpl, 'href', $url); foreach ($params as $key => $val) { $out .= " {$key}=\"{$val}\""; } $out .= '>' . $text . '</a>'; } if ($assign) { $smarty->assign($assign, $out); } else { return $out; } }
private function _display_text_block($blockInfo, $value, $adding) { $ret = ''; $oneline = isset($blockInfo['oneline']) && cms_to_bool($blockInfo['oneline']); if ($oneline) { $size = isset($blockInfo['size']) ? $blockInfo['size'] : 50; $maxlength = isset($blockInfo['maxlength']) ? $blockInfo['maxlength'] : 255; $ret = '<input type="text" size="' . $size . '" maxlength="' . $maxlength . '" name="' . $blockInfo['id'] . '" value="' . cms_htmlentities($value, ENT_NOQUOTES, get_encoding('')) . '" />'; } else { $block_wysiwyg = true; $hide_wysiwyg = $this->GetPropertyValue('disable_wysiwyg'); if ($hide_wysiwyg) { $block_wysiwyg = false; } else { $block_wysiwyg = $blockInfo['usewysiwyg'] == 'false' ? false : true; } $ret = create_textarea($block_wysiwyg, $value, $blockInfo['id'], '', $blockInfo['id'], '', $this->stylesheet); } return $ret; }
public static function cge_image_list($params, $smarty) { $config = CmsApp::get_instance()->GetConfig(); $dir = ''; $maxdepth = -1; $pattern = array('*.jpg', '*.jpeg', '*.bmp', '*.gif', '*.png', '*.ico'); $excludes = array('_*', '.??*'); $absolute = FALSE; $thumbs = FALSE; $options = FALSE; $selected = null; $novalue = ''; // handle the dir param if (isset($params['dir'])) { $tmp = trim($params['dir']); $tmp2 = cms_join_path($config['uploads_path'], $tmp); if (is_dir($tmp2)) { $dir = $tmp; } } // handle the extensions param if (isset($params['extensions'])) { $tmp = trim($params['extensions']); $pattern = explode('||', $tmp); } if (isset($params['thumbs'])) { $thumbs = cms_to_bool($params['thumbs']); } // handle the excludes param if (isset($params['excludes'])) { $tmp = trim($params['excludes']); $excludes = array_merge($excludes, explode('||', $tmp)); } // handle the maxdepth param if (isset($params['maxdepth'])) { $tmp = (int) $params['excludes']; if ($tmp > 0) { $maxdepth = $tmp; } } if (isset($params['absolute'])) { $absolute = cms_to_bool($params['absolute']); } // handle the options param if (isset($params['options'])) { $options = cms_to_bool($params['options']); } // handle the selected param if (isset($params['selected'])) { $options = TRUE; $selected = trim($params['selected']); } // handle the 'novalue' param if (isset($params['novalue'])) { $novalue = trim($params['novalue']); } if (!$thumbs) { $excludes[] = 'thumb_*'; } if ($dir != '') { $dir = trim($dir, '/'); $dir = cms_join_path($config['uploads_path'], $dir); } else { $dir = $config['uploads_path']; } if (!is_dir($dir)) { return; } $files = cge_dir::recursive_glob($dir, $pattern, 'FILES', $excludes, $maxdepth); if (!is_array($files) || count($files) == 0) { return; } $out = array(); foreach ($files as $one) { if ($absolute) { $out[$one] = $one; } else { $one = substr($one, strlen($dir)); if (startswith($one, '/')) { $one = substr($one, 1); } $out[$one] = $one; } } if ($options) { $tmp = $out; $out = ''; if ($novalue != '') { $out .= "<option value=\"\">" . $novalue . "</option>"; } foreach ($tmp as $k => $v) { if ($k == $selected) { $out .= "<option selected=\"selected\" value=\"{$k}\">{$v}</option>"; } else { $out .= "<option value=\"{$k}\">{$v}</option>"; } } } if (isset($params['assign'])) { $smarty->assign(trim($params['assign']), $out); return; } return $out; }
#magic_quotes_runtime is a nuisance... turn it off before it messes something up if (version_compare(phpversion(), "5.3.0", "<")) { set_magic_quotes_runtime(false); } // minimum stuff to get started (autoloader needs the cmsms() and the config stuff. //require_once($dirname.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'classes'.DIRECTORY_SEPARATOR.'class.cms_variables.php'); require_once $dirname . DIRECTORY_SEPARATOR . 'fileloc.php'; require_once $dirname . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'class.CmsException.php'; require_once $dirname . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'class.cms_config.php'; require_once $dirname . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'class.CmsApp.php'; require_once $dirname . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'autoloader.php'; require_once $dirname . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'misc.functions.php'; require_once $dirname . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'module.functions.php'; require_once $dirname . DIRECTORY_SEPARATOR . 'version.php'; debug_buffer('done loading required files'); if (!isset($CMS_INSTALL_PAGE) && cms_to_bool(ini_get('register_globals'))) { echo 'FATAL ERROR: For security reasons register_globals must not be enabled for any CMSMS install. Please adjust your PHP configuration settings to disable this feature.'; die; } // sanitize $_GET array_walk_recursive($_GET, 'sanitize_input_array'); // sanitize $_SERVER array_walk_recursive($_SERVER, 'sanitize_input_array'); if (isset($starttime)) { cmsms()->set_variable('starttime', $starttime); } if (isset($CMS_ADMIN_PAGE)) { function cms_admin_sendheaders($content_type = 'text/html', $charset = '') { if (!$charset) { $charset = get_encoding();