/** * Given month, day year input fields in parameters, and a prefix create a unix timestamp * this is useful when processing form data from {html_select_date} * * i.e: <code>$ts = \cge_date_utils::date_from_form($params,$id,'startdate');</code> * * @param array $params An associative array, usually from form submission. * @param string $prefix The prefix for the Month, Day, and Year fields within the params array * @param string $prefix2 An optional second prefix to append to the first one (i.e: the field name) * @return int unix timestamp representing the date in the input parmeters at 00:00 hours. or null */ public static function date_from_form($params, $prefix, $prefix2 = null) { $prefix = (string) $prefix; $prefix .= (string) $prefix2; if (!is_array($params)) { return; } $ts = mktime(0, 0, 0, \cge_param::get_int($params, $prefix . 'Month'), \cge_param::get_int($params, $prefix . 'Day'), \cge_param::get_int($params, $prefix . 'Year')); return $ts; }
function module_action_url($params, &$tpl) { $params['urlonly'] = 1; $assign = \cge_param::get_string($params, 'assign'); unset($params['imageonly'], $params['text'], $params['title'], $params['image'], $params['class'], $params['assign']); $out = module_action_link($params, $tpl); if ($assign) { $tpl->assign($assign, $out); return; } return $out; }
public function __construct() { $input = func_get_args(); if (count($input) == 1 && is_array($input[0])) { $input = $input[0]; } if (cge_array::is_hash($input)) { $this->_wmtext = \cge_param::get_string($input, 'text'); } else { if (is_array($input) && count($input) >= 1) { $tmp = \cge_param::get_string($input, 0); if (is_string($tmp) && !is_numeric($tmp)) { $this->_wmtext = $tmp; } } } }
# Or read it online: http://www.gnu.org/licenses/licenses.html#GPL # #------------------------------------------------------------------------- #END_LICENSE if (!$gCms) { exit; } if (cmsms()->is_frontend_request()) { throw new \LogicException(__METHOD__ . ' cannot be used for frontend requests.'); } $formdata = $mod = null; try { $params = \cge_utils::decrypt_params($params); $module_name = cge_param::get_string($params, '_m'); $class = cge_param::get_string($params, '_c'); $item_id = cge_param::get_int($params, '_i'); $mod = \cms_utils::get_module($module_name); if (!$mod) { throw new \LogicException("Could not get instance of module " . $module_name); } $formdata = $class::get_addedit_formdata(); if (!$formdata instanceof \CGExtensions\lookup_form_data) { throw new \LogicException('Problem occurred getting form data for lookup table: ' . $class); } $formdata->validate(); if ($item_id < 1) { throw new \LogicException('Invalid item id specified for move lookup item'); } $class::delete($item_id); } catch (\Exception $e) { $mod->SetError($e->GetMessage());
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Or read it online: http://www.gnu.org/licenses/licenses.html#GPL # #------------------------------------------------------------------------- #END_LICENSE cge_headers::output_headers(); $config = \CmsApp::get_instance()->GetConfig(); if ($config['debug']) { return; } $pretty_html = \cge_param::get_bool($config, 'cge_prettyhtml', false); $min_html = \cge_param::get_bool($config, 'cge_minhtml', false); if (!$pretty_html && !$min_html) { return; } // do nothin $in = $params['content']; if (strpos('</body>', $in) === FALSE) { $in = str_replace('</html>', '</body></html>', $in); } $the_head_parm = -1; $the_body_parm = -1; if ($pretty_html) { $the_head_parm = 1; $the_body_parm = 4; } $page_top = $page_bottom = $page_middle = $head_section = $body_section = null;
<?php if (!isset($gCms)) { exit; } if (!$this->CheckPermission('Modify Calendar') && !$this->CheckPermission('Add Calendar Events') && !$this->CheckPermission('Edit My Calendar Events')) { exit; } $start = cge_param::get_string($_REQUEST, 'start'); $end = cge_param::get_string($_REQUEST, 'end'); $showchildren = (int) cge_utils::get_param($params, 'showchildren', 0); $category = (int) cge_utils::get_param($params, 'category', -1); $keyword = trim(cge_utils::get_param($params, 'keyword')); $when = strtolower(trim(cge_utils::get_param($params, 'when', 'any'))); // when can only be used when start/end are not specified. $limit = cge_utils::get_param($params, 'limit', 1000); // 1000 is more than enough. debug_to_log(__FILE__); debug_to_log($_REQUEST); debug_to_log("{$start} - {$end}"); $st_ds = $db->DbTimeStamp($start); $en_ds = $db->DbTimeStamp($end); if ($start < 1 || $end < 1) { switch ($when) { case 'past': $start = 1; $end = time(); break; case 'future': $start = time(); $end = 2147483648.0;
} } else { if (isset($cat_map[$one])) { $categories[] = $cat_map[$one]; } } } } // resolve the editpage $editpage = $returnid; $tmp = $this->GetPreference('frontend_redirectpage', ''); if ($tmp) { $tmp = $this->ProcessTemplateFromData($tmp); $editpage = $this->resolve_alias_or_id($tmp, $editpage); } $tmp = \cge_param::get_string($params, 'editpage'); if ($tmp) { $editpage = $this->resolve_alias_or_id($tmp, $editpage); } $feu = \cms_utils::get_module('FrontEndUsers'); $feu_uid = null; if ($feu) { $feu_uid = $feu->LoggedInId(); } $st_ds = $db->DbTimeStamp($start); $en_ds = $db->DbTimeStamp($end); if ($start < 1 || $end < 1) { switch ($when) { case 'past': $start = 1; $end = time();
// deprecated $navigation['ni_next'] = $this->CreateURL($id, 'default', $returnid, $parms, false); $navigation['in_next'] = $this->CreateURL($id, 'default', $returnid, $parms, true); $parms['week'] = $reverse ? $week + 1 : $week - 1; $navigation['prev'] = $this->CreateURL($id, 'default', $returnid, $parms, $inline); // deprecated $navigation['ni_prev'] = $this->CreateURL($id, 'default', $returnid, $parms, false); $navigation['in_prev'] = $this->CreateURL($id, 'default', $returnid, $parms, true); $parms['week'] = date('W'); $parms['year'] = date('Y'); $navigation['current'] = $this->CreateURL($id, 'default', $returnid, $parms, $inline); // deprecated $navigation['ni_current'] = $this->CreateURL($id, 'default', $returnid, $parms, false); $navigation['in_current'] = $this->CreateURL($id, 'default', $returnid, $parms, true); $day_names = $this->GetDayNames(); $day_short_names = $this->GetDayShortNames(); // assign to Smarty $thetemplate = $this->GetPreference(CGCALENDAR_PREF_DFLTLIST_TEMPLATE); $thetemplate = \cge_param::get_string($params, 'listtemplate', $thetemplate); $tpl = $this->CreateSmartyTemplate($thetemplate, 'list_'); $tpl->assign('start_date_ut', $start_ut); $tpl->assign('end_date_ut', $end_ut); $tpl->assign('day_names', $day_names); $tpl->assign('day_short_names', $day_short_names); $tpl->assign('events', $events); $tpl->assign('year', $year); $tpl->assign('week', $week); $tpl->assign('lang', $this->GetLabels()); $tpl->assign('navigation', $navigation); $tpl->assign('file_location', cgcalendar_utils::get_upload_location()); $tpl->display();
} // // Initialization // $feu = $this->GetModuleInstance('FrontEndUsers'); if (!is_object($feu)) { return; } // no feu module. $feu_uid = $feu->LoggedInId(); if ($feu_uid <= 0) { return; } // not logged in $thetemplate = $this->GetPreference(CGCALENDAR_PREF_DFLTMYEVENTS_TEMPLATE); $thetemplate = \cge_param::get_string($params, 'myeventstemplate', $thetemplate); $destpage = $returnid; $tmp = $this->GetPreference('frontend_redirectpage', ''); $tmp = $this->ProcessTemplateFromData($tmp); if (isset($params['editpage'])) { $tmp = trim($params['editpage']); } if ($tmp) { $tmp = $this->resolve_alias_or_id($tmp); } if ($tmp) { $destpage = $tmp; } // // Get data //
/** * @ignore */ public function generate_ga() { // generate analytics stuff $property_id = \cge_param::get_string($this->_config, 'cghm_ga_propertyid'); if (!$property_id) { return; } $linkdomains = \cge_param::get_string($this->_config, 'cghm_ga_linkdomains'); if ($linkdomains) { $linkdomains = $this->str_to_array($linkdomains); } $subdomains = \cge_param::get_bool($this->_config, 'cghm_ga_subdomains'); $domain = \cge_param::get_string($this->_config, 'cghm_ga_domain'); if ($subdomains && !$domain) { $sysconfig = \cms_config::get_instance(); $url = new \cms_url($sysconfig['root_url']); $domain = $url->get_host(); } $tpl = $this->CreateSmartyTemplate('google_analytics.tpl'); $tpl->assign('content_obj', \cms_utils::get_current_content()); $tpl->assign('config', $this->_config); $tpl->assign('domain', $domain); if (count($linkdomains)) { $tpl->assign('linkdomains', $linkdomains); } return $tpl->fetch(); }
public static function &process_image($params) { $mod = cms_utils::get_module(MOD_CGSMARTIMAGE); $config = cmsms()->GetConfig(); $want_transform = 0; $do_transform = 0; $have_transform = 0; $dest_fname = ''; $dest_url = ''; $img = ''; $srcfile = ''; $rel = 0; $outp = array(); // output params $outp['id'] = ''; $outp['name'] = ''; $outp['class'] = ''; $outp['style'] = ''; $outp['src'] = ''; $outp['width'] = ''; $outp['height'] = ''; $outp['error'] = ''; $outp['output'] = null; $opp = array(); // operation params $opp['overwrite'] = 0; $opp['nobcache'] = 0; $opp['noremote'] = 0; $opp['noembed'] = 0; $opp['noauto'] = 0; $opp['noppradjust'] = 0; $opp['norotate'] = 0; $opp['notimecheck'] = 0; $opp['noautoscale'] = 0; $opp['notag'] = 0; $opp['noresponsive'] = 0; $opp['nodpradjust'] = 0; $opp['nobreakpoints'] = 0; $opp['max_width'] = 0; $opp['max_height'] = 0; $opp['d_max_width'] = 0; // device calculated max width (including breakpoints) $opp['d_max_height'] = 0; // device calculated max width (including breakpoints) $opp['src'] = ''; $opp['quality'] = 75; $opp['filters'] = array(); $opp['force_type'] = ''; $opp['force_ext'] = $mod->GetPreference('force_extension', 0); $opp['progressive'] = (int) $mod->GetPreference('progressive', 0); $opp['autoscale_op'] = $mod->GetPreference('autoscale_op', 'croptofit'); $cge = cms_utils::get_module(MOD_CGEXTENSIONS); $srcimgsize = ''; // src image size $lastfilter = null; try { $tmp = $mod->GetPreference('aliases'); if ($tmp) { $aliases = unserialize($tmp); } // first pass... expand aliases and build src $new_params = array(); foreach ($params as $key => $value) { if (startswith($key, 'alias')) { // expand alias $options = self::_get_alias_options($value); if ($options) { // parse a string into an array of arguments. $data = self::_expand_quoted_string($options); if (is_array($data)) { foreach ($data as $key => $value) { $new_params[$key] = $value; } } continue; } } elseif (startswith($key, 'src') && $key != 'src') { // handle src1 through src99 arguments. if (!isset($new_params['src'])) { $new_params['src'] = ''; } if (!empty($new_params['src']) && !endswith($new_params['src'], '/')) { $new_params['src'] .= '/'; } $new_params['src'] .= $value; continue; } // everything else just gets added. $new_params[$key] = $value; } $params = $new_params; // second pass, build our arrays $parse_params = function ($parms, $depth = 0) use(&$parse_params, &$opp, &$outp, &$mod) { foreach ($parms as $key => $value) { $matches = array(); if (preg_match('/^filter_[0-9]._/', $key, $matches)) { $key = substr($key, strlen($matches[0])); $filter = ucwords($key); $args = explode(',', $value); $classname = 'CGImage_' . $filter . '_Filter'; if (!class_exists($classname)) { throw new Exception($mod->Lang('error_unknownfilter', $filter)); } // add it to the ops. $opp['filters'][] = array($classname, $args); // done. continue; } if (startswith($key, 'filter_')) { // handle filter argument. $filter = ucwords(substr($key, strlen('filter_'))); $args = explode(',', $value); $classname = 'CGImage_' . $filter . '_Filter'; if (!class_exists($classname)) { throw new Exception($mod->Lang('error_unknownfilter', $filter)); } // add it to the ops. $opp['filters'][] = array($classname, $args); // done. continue; } switch ($key) { case 'data': if ($depth == 0) { $parse_params($value, $depth + 1); } break; case 'class': case 'id': case 'style': case 'name': case 'alt': case 'rel': case 'title': case 'autoscale_op': $outp[$key] = trim($value); break; case 'width': case 'height': $outp[$key] = (int) $value; break; case 'max_width': case 'max_height': $opp[$key] = (int) $value; break; case 'src': case 'force_type': $opp[$key] = trim($value); break; case 'quality': $opp['quality'] = (int) $value; $opp['quality'] = min(100, max(0, $opp['quality'])); break; case 'overwrite': case 'notag': case 'noremote': case 'noresponsive': case 'nodpradjust': case 'nobreakpoints': case 'nobcache': case 'noembed': case 'noauto': case 'norotate': case 'notimecheck': case 'force_ext': case 'progressive': $opp[$key] = cge_utils::to_bool($value); break; } } }; $parse_params($params); if (!$opp['src']) { throw new Exception($mod->Lang('error_missingparam', 'src')); } // // find the source image ... the actual filename // use some automagic intelligence to find it. // $relative_to = null; $src_decoded = urldecode($opp['src']); if (!$srcfile && startswith($src_decoded, $config['uploads_url'])) { $tmp = str_replace($config['uploads_url'], $config['uploads_path'], $src_decoded); if (is_file($tmp)) { $relative_to = 'uploads'; $srcfile = $tmp; } } if (!$srcfile && startswith($src_decoded, $config['root_url'])) { $tmp = str_replace($config['root_url'], $config['root_path'], $src_decoded); if (is_file($tmp)) { $relative_to = 'root'; $srcfile = $tmp; } } if (!$srcfile && isset($config['ssl_url']) && startswith($src_decoded, $config['ssl_url'])) { $tmp = str_replace($config['ssl_url'], $config['root_path'], $src_decoded); if (is_file($tmp)) { $relative_to = 'root'; $srcfile = $tmp; } } if (!$srcfile && startswith($opp['src'], '/')) { // treat as absolute filename $rp1 = realpath($config['root_path']); $rp2 = realpath($opp['src']); if (startswith($rp2, $rp1) && is_file($opp['src'])) { $relative_to = 'root'; $srcfile = $opp['src']; } } if (!$srcfile) { // check relative path wrt the uploads dir. $tmp = cms_join_path($config['uploads_path'], $opp['src']); $rp1 = realpath($config['uploads_path']); $rp2 = realpath($tmp); if (startswith($rp2, $rp1) && is_file($tmp)) { $relative_to = 'uploads'; $srcfile = $tmp; } } if (!$srcfile) { // check relative path wrt the root dir. $tmp = cms_join_path($config['root_path'], $opp['src']); $rp1 = realpath($config['root_path']); $rp2 = realpath($tmp); if (startswith($rp2, $rp1) && is_file($tmp)) { $relative_to = 'root'; $srcfile = $tmp; } } if (!$srcfile && $opp['noremote'] == 0 && (startswith($opp['src'], 'http:') || startswith($opp['src'], 'https:') || startswith($opp['src'], 'ftp:'))) { // okay, gotta assume that ths is a remote file // get it, and cache it. $cachefile = TMP_CACHE_LOCATION . '/cgsi_' . md5($opp['src']) . '.img'; if (!is_file($cachefile)) { $data = @file_get_contents($opp['src']); if ($data) { file_put_contents($cachefile, $data); $srcfile = $cachefile; } } else { $srcfile = $cachefile; } } if (!$srcfile) { throw new Exception($mod->Lang('error_srcnotfound', $opp['src'])); return $outp; } // get the source image size $srcinfo = getimagesize($srcfile); if (!is_array($srcinfo) || count($srcinfo) < 2) { throw new Exception($mod->Lang('error_srcnotfound', $opp['src'])); } else { $srcimgsize = array('width' => $srcinfo[0], 'height' => $srcinfo[1]); $memory_needed = round($srcinfo[0] * $srcinfo[1] * (isset($srcinfo['bits']) ? $srcinfo['bits'] : 8) * (isset($srcinfo['channels']) ? $srcinfo['channels'] : 3) / 8 + 65535); if ($mod->GetPreference('checkmemory', 1) && !cge_utils::have_enough_memory($memory_needed)) { throw new Exception($mod->Lang('error_insufficientmemory') . ': ' . (int) ($memory_needed / 1024) . 'k'); } } // are we automagically rotating? if (!$opp['norotate'] && function_exists('exif_read_data')) { // if there is already a rotate filter in the list, we won't override that. $fn = 0; for ($f = 0; $f < count($opp['filters']); $f++) { if ($opp['filters'][$f][0] == 'CGImage_Rotate_Filter') { $fn = 1; break; } } if ($fn == 0) { // we can try to read the exif information to find an orientation. $exif = @exif_read_data($srcfile, 0, TRUE); if (is_array($exif) && isset($exif['IFD0']) && isset($exif['IFD0']['Orientation']) && is_int($exif['IFD0']['Orientation'])) { // found an orientation, now we gotta figure out what filters to add. $orientation = (int) $exif['IFD0']['Orientation']; $new_filters = array(); switch ($orientation) { case 1: // nothing. break; case 2: // horizontal flip. $new_filters[] = array('CGImage_Flip_Filter', 0); break; case 3: // rotate 180 $new_filters[] = array('CGImage_Rotate_Filter', array(180)); break; case 4: $new_filters[] = array('CGImage_Flip_Filter', 1); break; case 5: $new_filters[] = array('CGImage_Flip_Filter', 1); $new_filters[] = array('CGImage_Rotate_Filter', array(90)); break; case 6: $new_filters[] = array('CGImage_Rotate_Filter', array(90)); break; case 7: $new_filters[] = array('CGImage_Flip_Filter', 0); $new_filters[] = array('CGImage_Rotate_Filter', array(90)); break; case 8: $new_filters[] = array('CGImage_Rotate_Filter', array(-90)); break; } $opp['filters'] = array_merge($new_filters, $opp['filters']); } } } // doing responsive images... get device width and height. // set it into max_width and max_height $device_caps = null; if (!$opp['noresponsive']) { $device_caps = self::get_device_capabilities(); if (!$device_caps && $mod->GetPreference('assume_responsive')) { // if assume responsive is enabled. we are assuming that a cookie will be present providing device capabilities... // if we could not find the cookie then output nothing so that we do not do redundant image processing. // the next request will have the device capabilities (the javascript that generates the cookie forces a reload if it has to set the cookie) $outp['output'] = '<!-- CGSmartImage processing stopped because of assume_responsive preference and no device capabilities found -->'; // this is way better than a goto. throw new \CGSIStopHereException('force_responsive enabled'); } if (is_array($device_caps) && isset($device_caps['width']) && isset($device_caps['height'])) { // we found device capabilities. $dpr = max(1, \cge_param::get_int($device_caps, 'dpr', 1)); // we have to do auto-scaling now, responsive stuff trumps the setting. $opp['noautoscale'] = 0; // merge that data with any max_width and max_height that have already been supplied. $opp['d_max_width'] = (int) $device_caps['width']; $opp['d_max_height'] = (int) $device_caps['height']; // experimental... check for breakpoints // and if a breakpoint can be found, further adjust the max_width and max_height params if (($tmp = $mod->GetPreference('responsive_breakpoints')) && !$opp['nobreakpoints']) { $tmp = explode(',', $tmp); $bp = array(); for ($i = 0; $i < count($tmp); $i++) { $t1 = (int) trim($tmp[$i]); if ($t1 > 0) { $bp[] = $t1; } } if (count($bp)) { // we have valid breakpoints. // find the most suitable one given our max resolution. asort($bp); $lval = max($opp['d_max_width'], $opp['d_max_height']); for ($i = count($bp) - 1; $i > 0; $i--) { if ($bp[$i] > $lval) { continue; } break; } list($max_w, $max_h) = self::_adjust_sizes_to_aspect_ratio($srcimgsize['width'], $srcimgsize['height'], $bp[$i]); $opp['d_max_width'] = (int) $max_w; $opp['d_max_height'] = (int) $max_h; } } } } if (!$opp['noautoscale']) { $destimgsize['width'] = self::_min_not0($srcimgsize['width'], $opp['max_width'], $opp['d_max_width'], $outp['width']); $destimgsize['height'] = self::_min_not0($srcimgsize['height'], $opp['max_height'], $opp['d_max_height'], $outp['height']); $dominant = null; if ($opp['max_width'] || $outp['width']) { $dominant = $dominant ? 'b' : 'x'; } if ($opp['max_height'] || $outp['height']) { $dominant = $dominant ? 'b' : 'y'; } if ($dominant == 'b') { $dominant = $destimgsize['width'] < $destimgsize['height'] ? 'x' : 'y'; } $aspect_ratio = $srcimgsize['width'] / $srcimgsize['height']; switch ($dominant) { case 'x': /* x is dominant */ // adjust to x dimension, retain aspect ratio $destimgsize['height'] = (int) ($destimgsize['width'] / $aspect_ratio); break; case 'y': /* y is dominant */ // adjust to y dimension, retain aspect ratio $destimgsize['width'] = (int) ($destimgsize['height'] * $aspect_ratio); break; } if ($device_caps && !$opp['nodpradjust'] && isset($device_caps['dpr']) && $device_caps['dpr'] > 1) { // this will adjust the destination width and height based on dpr $tmp = $destimgsize; $tmp['width'] *= $dpr; $tmp['height'] *= $dpr; if ($tmp['width'] <= $srcimgsize['width'] && $tmp['height'] <= $srcimgsize['height']) { // retain the original size of the image in the width and height attributes of the img tag // but for higher dpr devices generate a bigger image. $outp['width'] = $destimgsize['width']; $outp['height'] = $destimgsize['height']; $opp['noauto'] = 1; $destimgsize = $tmp; } } // make sure we're actually doing something if ($destimgsize != $srcimgsize) { switch (strtolower($opp['autoscale_op'])) { case 'resize': $filter = 'CGImage_Resize_Filter'; $tmp = $destimgsize; $tmp['resample'] = 1; $lastfilter = array($filter, $tmp); break; case 'croptofit': default: $filter = 'CGImage_Croptofit_Filter'; $tmp = $destimgsize; $tmp['loc'] = 'c'; $tmp['upscale'] = 0; $lastfilter = array($filter, $tmp); break; } if (!$opp['noauto']) { // we are allowing auto tags... so we adjust the outp stuff to our finished resolution $outp['width'] = $destimgsize['width']; $outp['height'] = $destimgsize['height']; } } } // // check if we are actually doing anything // // if we are forcing a type and that type is not the same as our current type. if ($opp['force_type']) { $tmp_a = self::parse_type($opp['force_type']); if ($tmp_a != $srcinfo['mime']) { $want_transform = 1; } } // if we got the image from a remote location, but there are no other filters, we will do a simple transform if (!$relative_to) { $want_transform = 1; if (!count($opp['filters'])) { $filter = 'CGImage_NOOP_Filter'; $opp['filters'][] = array($filter, array()); } } // if we have a last filter... add it. if ($lastfilter) { $opp['filters'][] = $lastfilter; } // if there are any filters... then we have to transform this image if (count(array_keys($opp['filters']))) { $want_transform = 1; } // // end of smartness stuff... now begin the work // if ($want_transform) { // calculate our destination name and url. $tmp = basename($srcfile); if (!isset($outp['alt'])) { $outp['alt'] = $tmp; } $ext = strrchr($tmp, '.'); $t2 = md5(serialize($opp)); $destname = 'img-' . $t2; $t3 = self::parse_type($opp['force_type'] ? $opp['force_type'] : $srcinfo['mime']); if ($opp['force_ext']) { $destname .= self::get_extension($t3); } $destdir = $mod->get_cache_path(); if (!is_dir($destdir)) { @mkdir($destdir, 0777, true); touch($destdir . '/index.html'); } if (!is_dir($destdir)) { throw new Exception($mod->Lang('error_mkdir', $destdir)); } // see if it exists $dest_fname = $destdir . '/' . $destname; $dest_url = $mod->get_cached_image_url($destname); $t1 = filemtime($srcfile); $t2 = is_file($dest_fname) ? filemtime($dest_fname) : 0; if (!is_file($dest_fname) || $t2 < $t1 && !$opp['notimecheck'] || $opp['overwrite']) { $do_transform = 1; } } else { // no transofmration... just use the src image // but make it into an absolute URL $dest_fname = $srcfile; switch ($relative_to) { case 'root': $_src = $srcfile; if (startswith($_src, $config['root_path'])) { $_src = substr($_src, strlen($config['root_path'])); } $dest_url = $config['root_url'] . $_src; break; case 'uploads': $_src = $srcfile; if (startswith($srcfile, $config['uploads_path'])) { $_src = substr($srcfile, strlen($config['uploads_path'])); } $dest_url = $config['uploads_url'] . $_src; break; } } if ($do_transform) { try { // load the image. $img = new CGImageBase($srcfile); // process filters $i = 0; while ($i < count($opp['filters'])) { $filter = $opp['filters'][$i][0]; $filter_obj = new $filter($opp['filters'][$i][1]); $img = $filter_obj->transform($img); $img['dirty'] = 1; // force the image dirty, just so that we can save it. $i++; } // check some stuff if ($opp['noauto'] == 0 && ($outp['width'] && $img['width'] < $outp['width'] || $outp['height'] && $img['height'] < $outp['height'])) { // user specified a width, and/or height...but they are smaller than the output of the filtering. // this will ensure that the tag will match the image. $outp['width'] = $img['width']; $outp['height'] = $img['height']; } // and write the thing. if (is_object($img)) { if ($opp['force_type']) { $img['type'] = self::parse_type($opp['force_type']); } if ($img['dirty']) { $img->save($dest_fname, $opp['quality'], $opp['progressive']); } } } catch (Exception $e) { audit('', 'CGSmartImage', 'Error encountered on ' . $opp['src'] . ': ' . $e->GetMessage()); throw $e; } } // if // now, we have a cached filename ... need to get its dimensions. // and make sure that we're never outputting anything bigger than the cached dimensions // unless noauto is set if ($opp['noauto'] == 0) { if ($outp['width'] && $srcimgsize['width'] < $outp['width'] || $outp['height'] && $srcimgsize['height'] < $outp['height']) { $outp['width'] = $t_width; $outp['height'] = $t_height; } } // at this point, we're ready to handle building the tag. if ($opp['nobcache']) { $dest_url .= '?x=' . time(); } if (!isset($outp['alt'])) { if ($dest_fname) { $outp['alt'] = basename($dest_fname); } else { if ($srcfile) { $outp['alt'] = basename($srcfile); } else { $outp['alt'] = basename($opp['src']); } } } // build the output. if ($opp['notag'] || self::_is_stylesheet()) { $outp['src'] = $dest_url; if (!$opp['noembed'] && $mod->can_embed($dest_fname)) { $type = cge_utils::get_mime_type($dest_fname); if ($type && $type != 'unknown') { $tmp = base64_encode(file_get_contents($dest_fname)); $outp['src'] = 'data:' . $type . ';base64,' . $tmp; } } else { $outp['src'] = $dest_url; } if (!isset($outp['output'])) { $outp['output'] = $outp['src']; } } else { // // gotta build a tag. // // get the src first. if (!$opp['noembed'] && $mod->can_embed($dest_fname)) { $type = cge_utils::get_mime_type($dest_fname); if ($type && $type != 'unknown') { $tmp = base64_encode(file_get_contents($dest_fname)); $outp['src'] = 'data:' . $type . ';base64,' . $tmp; } } if (!isset($outp['src']) || !$outp['src']) { // fallback to the destination url. $outp['src'] = $dest_url; } if ($dest_fname && !$opp['noauto']) { $details = getimagesize($dest_fname); if (is_array($details)) { $outp['width'] = (int) $details[0]; $outp['height'] = (int) $details[1]; } } // now we can build the tag. $output = '<img'; foreach ($outp as $key => $value) { if (!$value && $key != 'alt') { continue; } // empty alt is valid... stupid, but valid. $output .= ' ' . $key . '="' . $value . '"'; } $output .= '/>'; $outp['output'] = $output; } } catch (\CGSIStopHereException $e) { // we were forced to stop if (!$outp['output']) { $outp['error'] = 'No output from CGSIStopHereException'; } } catch (Exception $e) { $outp['error'] = $e->GetMessage(); } // here we're gonna return something return $outp; }
public static function cgcss_add($params, $content, $smarty, $repeat) { if ($content == '') { return; } $depends = cge_utils::get_param($params, 'depends'); $nominify = cge_param::get_bool($params, 'nominify'); \CGExtensions\jsloader\jsloader::add_css($content, $depends, $nominify); }
$this->SetPreference('overlap_action', $overlap_action); $this->SetPreference('firstdayofweek', $firstdayofweek); $this->SetPreference('use_twelve_hour_clock', $use_twelve_hour_clock); $this->SetPreference('defaultcalendarpage', $_POST['parent_id']); $this->SetPreference('default_category', $default_category); $this->SetPreference('force_category', $force_category); $this->SetPreference('showpastyears', $showpastyears); $this->SetPreference('showfutureyears', $showfutureyears); $this->SetPreference('hidesummary', $hidesummary); $this->SetPreference('hidecontent', $hidecontent); $this->SetPreference('uploaddirectory', $uploaddirectory); $this->SetPreference('uploadfiletypes', $uploadfiletypes); $this->SetPreference('uploadunique', $uploadunique); $this->SetPreference('friendlyname', trim($params['friendlyname'])); $this->SetPreference('dflt_fgcolor', trim($params['dflt_fgcolor'])); $this->SetPreference('dflt_bgcolor', trim($params['dflt_bgcolor'])); $this->SetPreference('ical_holidays', \cge_param::get_string($params, 'ical_holidays')); $this->SetPreference('url_prefix', get_parameter_value($params, 'url_prefix', 'calendar')); $this->SetPreference('dflt_alldayevent', get_parameter_value($params, 'dflt_alldayevent', 0)); $this->SetPreference('holiday_fgcolor', trim($params['holiday_fgcolor'])); $this->SetPreference('holiday_bgcolor', trim($params['holiday_bgcolor'])); $start_time = ''; $start_time = get_parameter_value($params, 'dflt_starttime_Hour', 12) . ':' . get_parameter_value($params, 'dflt_starttime_Minute', 00); $this->SetPreference('dflt_starttime', $start_time); if (isset($params['frontend_group'])) { $this->SetPreference('frontend_group', $params['frontend_group']); } $this->SetPreference('frontend_redirectpage', $frontend_redirectpage); } $this->RedirectToTab($id); }
# # Setup # $limit = \cge_param::get_int($params, 'imit', $limit); $thetemplate = \cge_param::get_string($params, 'searchresulttemplate', $thetemplate); $pagenum = \cge_param::get_int($params, 'cal_pagenum', $pagenum); # # Get Data # # # Handle Form Submission # if (isset($params['cal_search_submit'])) { $search_type = \cge_param::get_string($params, 'cal_search_type'); $search_text = \cge_param::get_string($params, 'cal_search_text'); $search_category = \cge_param::get_int($params, 'cal_search_category'); if (isset($params['cal_search_start_date_Month'])) { $search_start_date = mktime(isset($params['cal_search_start_date_Hour']) ? (int) $params['cal_search_start_date_Hour'] : 0, isset($params['cal_search_start_date_Minute']) ? (int) $params['cal_search_start_date_Minute'] : 0, 0, (int) $params['cal_search_start_date_Month'], (int) $params['cal_search_start_date_Day'], (int) $params['cal_search_start_date_Year']); } if (isset($params['cal_search_end_date_Month'])) { $search_end_date = mktime(isset($params['cal_search_end_date_Hour']) ? (int) $params['cal_search_end_date_Hour'] : 23, isset($params['cal_search_end_date_Minute']) ? (int) $params['cal_search_end_date_Minute'] : 59, 0, (int) $params['cal_search_end_date_Month'], (int) $params['cal_search_end_date_Day'], (int) $params['cal_search_end_date_Year']); } // validate results if ($search_end_date < $search_start_date) { $tmp = $search_start_date; $search_start_date = $search_end_date; $search_end_date = $tmp; } if ($search_end_date - $search_start_date < 60) { $error = $this->Lang('error_search_invalid_dates'); }
$feu = $this->GetModuleInstance('FrontEndUsers'); if (!$feu) { echo '<h3><font color="red">' . $this->Lang('error_nofeu') . "</font></h3>\n"; return; } else { if (!$feu->LoggedIn()) { echo '<h3><font color="red">' . $this->Lang('error_feu_loggedin') . "</font></h3>\n"; return; } } // // initialization // $feu_uid = $feu->LoggedInId(); $thetemplate = $this->GetPreference(CGCALENDAR_PREF_DFLTEDITEVENT_TEMPLATE); $thetemplate = \cge_param::get_string($params, 'editeventtemplate', $thetemplate); $event_id = get_parameter_value($params, 'event_id', -1); $event = $this->GetEvent($event_id, $feu_uid); $fields = $this->GetFields(); $categories = $this->GetCategories(); $policy = $this->GetPreference('overlap_polciy', 'all'); $force_category = $this->GetPreference('force_category', 0); $destpage = $returnid; if (isset($params['return_id'])) { $destpage = (int) $params['return_id']; } else { $tmp = $this->GetPreference('frontend_redirectpage', ''); if ($tmp) { $tmp = $this->ProcessTemplateFromData($tmp); if ($tmp) { $tmp = $this->resolve_alias_or_id($tmp);
} $category = \cge_param::get_string($params, 'category'); $tpl->assign('firstdayofweek', (int) $this->GetPreference('firstdayofweek', 1)); $tpl->assign('datestrings', $locale_info); $tpl->assign('text_week', $this->Lang('week')); $tpl->assign('text_month', $this->Lang('month')); $tpl->assign('text_day', $this->Lang('day')); $tpl->assign('text_today', $this->Lang('today')); $tpl->assign('dflt_fgcolor', $this->GetPreference('dflt_fgcolor', '#ffffff')); $tpl->assign('dflt_bgcolor', $this->GetPreference('dflt_bgcolor', '#009900')); $parms = array(); if ($category) { $parms['category'] = $category; } $fetch_url = $this->create_url('cntnt01', 'ajax_fetchevents', $returnid, $parms); $fetch_url = str_replace('amp;', '', $fetch_url); $tpl->assign('fetch_url', $fetch_url); $tpl->assign('dflt_fgcolor', $this->GetPreference('dflt_fgcolor', '#ffffff')); $tpl->assign('dflt_bgcolor', $this->GetPreference('dflt_bgcolor', '#009900')); $tpl->assign('holiday_fgcolor', $this->GetPreference('holidayfgcolor', '#000000')); $tpl->assign('holiday_bgcolor', $this->GetPreference('holidaybgcolor', '#ccffff')); $detailpage = $returnid; $detailpage_str = \cge_param::get_string($params, 'detailpage'); if ($detailpage_str) { $detailpage = $this->resolve_alias_or_id($detailpage_str, $detailpage); } $tpl->assign('detailpage', $detailpage); $tpl->display(); # # EOF #
# #------------------------------------------------------------------------- #END_LICENSE if (!$gCms) { exit; } if (cmsms()->is_frontend_request()) { throw new \LogicException(__METHOD__ . ' cannot be used for frontend requests.'); } $formdata = $mod = null; try { $params = \cge_utils::decrypt_params($params); $module_name = cge_param::get_string($params, '_m'); $class = cge_param::get_string($params, '_c'); $item_id = cge_param::get_int($params, '_i'); $dir = cge_param::get_string($params, '_dir', 'up'); $mod = \cms_utils::get_module($module_name); if (!$mod) { throw new \LogicException("Could not get instance of module " . $module_name); } $formdata = $class::get_addedit_formdata(); if (!$formdata instanceof \CGExtensions\lookup_form_data) { throw new \LogicException('Problem occurred getting form data for lookup table: ' . $class); } $formdata->validate(); if ($item_id < 1) { throw new \LogicException('Invalid item id specified for move lookup item'); } $item = $class::load($item_id); switch ($dir) { case 'up':
public static function cghm_render($params, &$template) { // make sure that this method is only called once per request. static $_done = 0; if ($_done != 0) { return; } $_done = 1; $groups = \cge_param::get_string($params, 'group'); $assign = \cge_param::get_string($params, 'assign'); if ($groups) { $groups = self::mod()->str_to_array($groups); } if (!$groups) { $groups = self::mod()->get_groups(); } $out = null; $flds = self::mod()->get_fields($groups); foreach ($flds as $name) { $tmp = self::mod()->render_field($name); if ($tmp) { $out .= "{$tmp}\n"; } } // // now do google analytics stuff // $out .= self::mod()->generate_ga(); if ($assign) { $template->assign($assign, $out); } else { return $out; } }
$item = new $class(); if ($item_id > 0) { $item = $class::load($item_id); } // handle the form if (isset($params['cancel'])) { // @todo add showmessage here. if ($formdata->cancel_message) { $mod->SetMessage($formdata->cancel_message); } $mod->RedirectToTab($id, $formdata->return_tab, '', $formdata->return_action); } else { if (isset($params['submit'])) { $in_edit = $item->id > 0 ? TRUE : FALSE; $item->name = cge_param::get_string($params, 'name'); $item->description = cge_param::get_html($params, 'description'); $item->save(); // all done. if ($in_edit) { if ($formdata->post_edit_message) { $mod->SetMessage($formdata->post_edit_message); } } else { if ($formdata->post_add_message) { $mod->SetMessage($formdata->post_add_message); } } $mod->RedirectToTab($id, $formdata->return_tab, '', $formdata->return_action); } } // build the form
# $thetemplate = $this->GetPreference(CGCALENDAR_PREF_DFLTSEARCH_TEMPLATE); $destpage = $returnid; $inline = 0; $search_category = -1; $search_start_date = time(); $search_end_date = strtotime('+1 month', $search_start_date); $search_text = ''; $searchresults = ''; $error = ''; $use_session = ''; # # Setup # $thetemplate = \cge_param::get_string($params, 'searchtemlate', $thetemplate); $inline = \cge_param::get_int($params, 'inline', 0); if (isset($params['searchresultpage'])) { $tmp = $this->resolve_alias_or_id($params['searchresultpage']); if (!empty($tmp)) { $destpage = $tmp; } } if ($destpage != $returnid) { $inline = 0; } if (isset($params['use_session'])) { $search_text = $this->session_get($use_session . 'search_text', $search_text); $search_category = $this->session_get($use_session . 'search_category', $search_category); $search_start_date = $this->session_get($use_session . 'search_start_date', $search_start_date); $search_end_date = $this->session_get($use_session . 'search_end_date', $search_end_date); }
# Or read it online: http://www.gnu.org/licenses/licenses.html#GPL # #------------------------------------------------------------------------- #END_LICENSE if (!isset($gCms)) { exit; } if (!$this->CheckPermission('Modify Modules')) { return; } if (!isset($config['cg_developer_mode']) || !$config['cg_developer_mode']) { return; } try { $act_module = trim(\cge_param::get_string($params, 'act_module')); $act_generate = \cge_param::get_int($params, 'generate'); if ($act_generate && $act_module) { // get the module $mod = \cms_utils::get_module($act_module); if (!$mod) { throw new \LogicException("Could not get instance of module {$act_module}"); } if (!$mod instanceof CGExtensions) { throw new \LogicException("{$act_module} is not derived from CGExtensions"); } $generator = new \CGExtensions\internal\ModuleIntegrityCodeGenerator($act_module); $generator->generate(); $this->SetMessage($this->Lang('msg_vrfy_checksumgenerated', $act_module)); } unset($act_module, $act_generate); // get a list of our modules derived from CGExtensions