<?php

/**
 * phpwcms content management system
 *
 * @author Oliver Georgi <*****@*****.**>
 * @copyright Copyright (c) 2002-2015, Oliver Georgi
 * @license http://opensource.org/licenses/GPL-2.0 GNU GPL-2
 * @link http://www.phpwcms.de
 *
 **/
// ----------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {
    die("You Cannot Access This Script Directly, Have a Nice Day.");
}
// ----------------------------------------------------------------
//PHP variables
if ($crow["acontent_text"]) {
    $crow["acontent_text"] = parse_ini_str($crow["acontent_text"]);
    if (is_array($crow["acontent_text"]) && count($crow["acontent_text"])) {
        $GLOBALS['CUSTOM'] = array_merge($GLOBALS['CUSTOM'], $crow["acontent_text"]);
    }
}
Example #2
0
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {
    die("You Cannot Access This Script Directly, Have a Nice Day.");
}
// ----------------------------------------------------------------
//image with text
// read template
if (empty($crow["acontent_template"]) && is_file(PHPWCMS_TEMPLATE . 'inc_default/imagetext.tmpl')) {
    $crow["acontent_template"] = render_device(@file_get_contents(PHPWCMS_TEMPLATE . 'inc_default/imagetext.tmpl'));
} elseif (is_file(PHPWCMS_TEMPLATE . 'inc_cntpart/imagetext/' . $crow["acontent_template"])) {
    $crow["acontent_template"] = render_device(@file_get_contents(PHPWCMS_TEMPLATE . 'inc_cntpart/imagetext/' . $crow["acontent_template"]));
} else {
    $crow["acontent_template"] = '[IMAGETEXT]<div class="image-with-text">{IMAGETEXT}</div>[/IMAGETEXT]';
}
$crow["settings"] = get_tmpl_section('IMAGETEXT_SETTINGS', $crow["acontent_template"]);
$crow["settings"] = parse_ini_str($crow["settings"], false);
$crow["acontent_template"] = replace_tmpl_section('IMAGETEXT_SETTINGS', $crow["acontent_template"]);
$crow["acontent_template"] = render_cnt_template($crow["acontent_template"], 'TITLE', html($crow['acontent_title']));
$crow["acontent_template"] = render_cnt_template($crow["acontent_template"], 'SUBTITLE', html($crow['acontent_subtitle']));
$crow["acontent_template"] = str_replace('{ID}', $crow["acontent_id"], $crow["acontent_template"]);
$crow['is_imagetext'] = strpos($crow["acontent_template"], '{IMAGETEXT}') !== false ? true : false;
$crow['has_image'] = false;
// 0   :1       :2   :3        :4    :5     :6      :7       :8
// dbid:filename:hash:extension:width:height:caption:position:zoom
$image = $crow["acontent_image"] ? explode(":", $crow["acontent_image"]) : false;
$crow["default_settings"] = array('class_top_left' => $template_default['classes']['imgtxt-top-left'], 'class_top_center' => $template_default['classes']['imgtxt-top-center'], 'class_top_right' => $template_default['classes']['imgtxt-top-right'], 'class_bottom_left' => $template_default['classes']['imgtxt-bottom-left'], 'class_bottom_center' => $template_default['classes']['imgtxt-bottom-center'], 'class_bottom_right' => $template_default['classes']['imgtxt-bottom-right'], 'class_float_left' => $template_default['classes']['imgtxt-left'], 'class_float_right' => $template_default['classes']['imgtxt-right'], 'class_column_left' => $template_default['classes']['imgtxt-column-left'], 'class_column_right' => $template_default['classes']['imgtxt-column-right'], 'class_column_left_image' => $template_default['classes']['imgtxt-column-left-image'], 'class_column_right_image' => $template_default['classes']['imgtxt-column-right-image'], 'class_column_left_text' => $template_default['classes']['imgtxt-column-left-text'], 'class_column_right_text' => $template_default['classes']['imgtxt-column-right-text'], 'width' => $image[4], 'height' => $image[5], 'zoom' => $image[8], 'crop' => 0, 'lightbox' => 0, 'nocaption' => 0);
$image_text = '';
$crow["settings"] = array_merge($crow["default_settings"], $crow["settings"]);
//zoom click = $image[8];
if ($image) {
    $cnt_image = @unserialize($crow["acontent_form"]);
Example #3
0
 $form_field .= '<select name="' . $form_name . '" id="' . $form_name . '"';
 if ($cnt_form["fields"][$key]['class']) {
     $form_field .= ' class="' . $cnt_form["fields"][$key]['class'] . '"';
 }
 if ($cnt_form["fields"][$key]['style']) {
     $form_field .= ' style="' . $cnt_form["fields"][$key]['style'] . '"';
 }
 if ($cnt_form["fields"][$key]['required']) {
     $form_field .= ' required="required"';
 }
 $form_field .= '>' . LF;
 // build country select menu
 if ($cnt_form["fields"][$key]['type'] == 'country') {
     // check which language should be used and
     // which country should be set as default
     $form_value = parse_ini_str($cnt_form["fields"][$key]['value'], false);
     if (isset($form_value['lang'])) {
         $form_value['lang'] = preg_replace('/[^a-zA-Z]/', '', $form_value['lang']);
     } else {
         $form_value['lang'] = $phpwcms['default_lang'];
     }
     if (isset($form_value['default'])) {
         $form_value['default'] = preg_replace('/[^a-zA-Z]/', '', $form_value['default']);
     } else {
         $form_value['default'] = '-';
     }
     $option_value = substr(empty($POST_val[$POST_name]) ? $form_value['default'] : $POST_val[$POST_name], 0, 2);
     if (!empty($form_value['first'])) {
         $form_field .= '<option value="">' . html_specialchars($form_value['first']) . '</option>' . LF;
     }
     $form_field .= list_country($option_value, $form_value['lang']);
Example #4
0
            }
            $content["all"] .= "</div>\n";
            break;
        case 2:
            //create the page layout based only on the content of main block
            $content["all"] = $block["maintext"];
            break;
    }
} elseif ($aktion[2] == 1) {
    //if print layout should be shown
    $_print_tmpl = PRINT_PDF ? 'pdf' : 'print';
    $content['all'] = is_file(PHPWCMS_TEMPLATE . 'inc_default/' . $_print_tmpl . '.tmpl') ? @file_get_contents(PHPWCMS_TEMPLATE . 'inc_default/' . $_print_tmpl . '.tmpl') : '{CONTENT}<hr />{CURRENT_URL}';
    if (PRINT_PDF) {
        $_print_settings = get_tmpl_section('PDF_SETTINGS', $content['all']);
        $content['all'] = replace_tmpl_section('PDF_SETTINGS', $content['all']);
        $_print_settings = parse_ini_str($_print_settings, false);
    }
    if ($content['all']) {
        $content["all"] = str_replace('{CURRENT_URL}', abs_url(), $content["all"]);
        $content["all"] = str_replace('{CONTENT}', $block["maintext"], $content["all"]);
    } else {
        $content['all'] = $block["maintext"];
    }
}
// Render possible PHP Values in category or article keyword field
$content["struct"][$aktion[0]]["acat_info"] = render_PHPcode($content["struct"][$aktion[0]]["acat_info"]);
if (!empty($content["articles"][$aktion[1]]["article_keyword"]) && strpos($content["articles"][$aktion[1]]["article_keyword"], 'PHP') !== FALSE) {
    $content["articles"][$aktion[1]]["article_keyword"] = render_PHPcode($content["articles"][$aktion[1]]["article_keyword"]);
}
// put in the complete rendered content
$content["all"] = str_replace('{CONTENT}', $content["main"], $content["all"]);
Example #5
0
// get template
if ($crow['acontent_template_listmode'] && empty($crow["acontent_template"]) && is_file(PHPWCMS_TEMPLATE . 'inc_default/list.imagespecial.tmpl')) {
    $image['template'] = render_device(@file_get_contents(PHPWCMS_TEMPLATE . 'inc_default/list.imagespecial.tmpl'));
} elseif (empty($crow["acontent_template"]) && is_file(PHPWCMS_TEMPLATE . 'inc_default/imagespecial.tmpl')) {
    $image['template'] = render_device(@file_get_contents(PHPWCMS_TEMPLATE . 'inc_default/imagespecial.tmpl'));
} elseif ($crow['acontent_template_listmode'] && is_file(PHPWCMS_TEMPLATE . 'inc_cntpart/imagespecial/list.' . $crow["acontent_template"])) {
    $image['template'] = render_device(@file_get_contents(PHPWCMS_TEMPLATE . 'inc_cntpart/imagespecial/list.' . $crow["acontent_template"]));
} elseif (is_file(PHPWCMS_TEMPLATE . 'inc_cntpart/imagespecial/' . $crow["acontent_template"])) {
    $image['template'] = render_device(@file_get_contents(PHPWCMS_TEMPLATE . 'inc_cntpart/imagespecial/' . $crow["acontent_template"]));
} else {
    $image['template'] = '';
}
// define default infotext renderer
$image['text_render'] = 'plaintext';
if ($image['template']) {
    $image['tmpl_settings'] = parse_ini_str(get_tmpl_section('IMAGE_SETTINGS', $image['template']), false);
    if (is_array($image['tmpl_settings']) && count($image['tmpl_settings'])) {
        $image = array_merge($image, $image['tmpl_settings']);
        if ($image['text_render'] == 'markdown') {
            // Load ParseDown class
            if (!isset($phpwcms['parsedown_class'])) {
                require_once PHPWCMS_ROOT . '/include/inc_ext/parsedown/Parsedown.php';
                require_once PHPWCMS_ROOT . '/include/inc_ext/parsedown-extra/ParsedownExtra.php';
                $phpwcms['parsedown_class'] = new ParsedownExtra();
            }
        } elseif ($image['text_render'] == 'textile') {
            // Load Textile function and class
            if (!isset($phpwcms['textile_class'])) {
                require_once PHPWCMS_ROOT . '/include/inc_ext/classTextile.php';
                $phpwcms['textile_class'] = new Textile();
            }
 if ($news['list_mode']) {
     // check if news is in list mode
     $news['tmpl_news'] = get_tmpl_section('NEWS_LIST', $news['template']);
     $news['tmpl_entry'] = get_tmpl_section('NEWS_LIST_ENTRY', $news['template']);
     $news['tmpl_entry_space'] = get_tmpl_section('NEWS_LIST_ENTRY_SPACE', $news['template']);
     $news['tmpl_row_space'] = get_tmpl_section('NEWS_LIST_ROW_SPACE', $news['template']);
 } else {
     // or not in list mode
     $news['tmpl_news'] = '[NEWS_ENTRIES]{NEWS_ENTRIES}[/NEWS_ENTRIES]';
     $news['tmpl_entry'] = get_tmpl_section('NEWS_DETAIL', $news['template']);
     $news['tmpl_entry_space'] = '';
     $news['tmpl_row_space'] = '';
 }
 $news['tmpl_gallery_item'] = '';
 // get template based config and merge with defaults
 $news['config'] = array_merge(array('news_per_row' => 1, 'news_teaser_limit_chars' => 0, 'news_teaser_limit_words' => 0, 'news_teaser_limit_ellipse' => $GLOBALS['template_default']['ellipse_sign'], 'files_template_list' => 'default', 'files_template_detail' => 'default', 'files_direct_download' => 0, 'gallery_allowed_ext' => 'jpg,jpeg,png', 'gallery_filecenter_info' => 1), parse_ini_str(get_tmpl_section('NEWS_SETTINGS', $news['template']), false));
 $news['config']['news_per_row'] = abs(intval($news['config']['news_per_row']));
 $news['config']['news_teaser_limit_chars'] = intval($news['config']['news_teaser_limit_chars']);
 $news['config']['news_teaser_limit_words'] = intval($news['config']['news_teaser_limit_words']);
 $news['config']['check_lang'] = count($phpwcms['allowed_lang']) > 1 ? true : false;
 $news['config']['gallery_allowed_ext'] = convertStringToArray(strtolower($news['config']['gallery_allowed_ext']));
 if (count($news['config']['gallery_allowed_ext'])) {
     foreach ($news['config']['gallery_allowed_ext'] as $ikey => $ivalue) {
         $news['config']['gallery_allowed_ext'][$ikey] = _dbEscape($ivalue);
     }
     $news['config']['gallery_allowed_ext'] = implode(',', $news['config']['gallery_allowed_ext']);
 } else {
     $news['config']['gallery_allowed_ext'] = '';
 }
 // start parsing news entries
 $news['row_count'] = 1;
}
if ($_shop_load_cat !== false || $_shop_load_list !== false || $_shop_load_order !== false || $_shop_load_cart_small !== false) {
    $_shop_parsed = true;
    // load template
    $_tmpl = array('config' => array(), 'source' => '', 'lang' => $phpwcms['default_lang']);
    // Check against language specific shop template
    if (is_file($phpwcms['modules']['shop']['path'] . 'template/' . $phpwcms['default_lang'] . '.html')) {
        $_tmpl['source'] = @file_get_contents($phpwcms['modules']['shop']['path'] . 'template/' . $phpwcms['default_lang'] . '.html');
    } else {
        $_tmpl['source'] = @file_get_contents($phpwcms['modules']['shop']['path'] . 'template/default.html');
    }
    if ($_tmpl['source']) {
        if (PHPWCMS_CHARSET !== 'utf-8' && phpwcms_seems_utf8($_tmpl['source'])) {
            $_tmpl['source'] = mb_convert_encoding($_tmpl['source'], PHPWCMS_CHARSET, 'utf-8');
        }
        $_tmpl['config'] = parse_ini_str(get_tmpl_section('CONFIG', $_tmpl['source']), false);
        $_tmpl['config']['cat_list_products'] = empty($_tmpl['config']['cat_list_products']) ? false : phpwcms_boolval($_tmpl['config']['cat_list_products']);
        $_tmpl['config']['image_list_lightbox'] = empty($_tmpl['config']['image_list_lightbox']) ? false : phpwcms_boolval($_tmpl['config']['image_list_lightbox']);
        $_tmpl['config']['image_detail_lightbox'] = empty($_tmpl['config']['image_detail_lightbox']) ? false : phpwcms_boolval($_tmpl['config']['image_detail_lightbox']);
        $_tmpl['config']['image_detail_crop'] = empty($_tmpl['config']['image_detail_crop']) ? false : phpwcms_boolval($_tmpl['config']['image_detail_crop']);
        $_tmpl['config']['image_list_crop'] = empty($_tmpl['config']['image_list_crop']) ? false : phpwcms_boolval($_tmpl['config']['image_list_crop']);
        // Classes
        $_tmpl['config'] = array_merge(array('class_form_product_cart_option' => 'product-cart-option', 'class_shop_amount' => 'shop-amount', 'class_cart_add_button' => 'cart-add-button', 'class_product_option_1' => 'product-option-1', 'class_product_option_2' => 'product-option-2', 'class_form_cart' => 'cart-form'), $_tmpl['config']);
        if (empty($_tmpl['config']['class_prefix_shop_mode'])) {
            $_tmpl['config']['class_prefix_shop_mode'] = 'shopmode-';
        }
        // handle custom fields
        $_tmpl['config']['shop_field'] = array();
        $custom_field_number = 1;
        while (!empty($_tmpl['config']['shop_field_' . $custom_field_number])) {
            $custom_field_type = explode('_', trim($_tmpl['config']['shop_field_' . $custom_field_number]));
     }
     if (isset($content['form']["fields"][$field_counter]['value']['calc'])) {
         $mathspam['calc'] = $content['form']["fields"][$field_counter]['value']['calc'];
     }
     $content['form']["fields"][$field_counter]['value'] = $mathspam;
     unset($mathspam);
     break;
 case 'recaptcha':
     /*
      * reCAPTCHA
      */
     $content['form']["fields"][$field_counter]['name'] = 'recaptcha';
     $content['form']["fields"][$field_counter]['size'] = '';
     $content['form']["fields"][$field_counter]['max'] = '';
     $content['form']["fields"][$field_counter]['required'] = 1;
     $content['form']["fields"][$field_counter]['value'] = parse_ini_str(slweg($_POST['cform_field_value'][$key]), false);
     $content['form']['recaptcha'] = array('site_key' => '', 'secret_key' => '', 'lang' => $phpwcms['default_lang'], 'theme' => 'light', 'type' => 'image');
     if (isset($content['form']["fields"][$field_counter]['value']['site_key'])) {
         $content['form']['recaptcha']['site_key'] = trim($content['form']["fields"][$field_counter]['value']['site_key']);
     } elseif (isset($content['form']["fields"][$field_counter]['value']['public_key'])) {
         $content['form']['recaptcha']['site_key'] = trim($content['form']["fields"][$field_counter]['value']['public_key']);
     }
     if (isset($content['form']["fields"][$field_counter]['value']['secret_key'])) {
         $content['form']['recaptcha']['secret_key'] = trim($content['form']["fields"][$field_counter]['value']['secret_key']);
     } elseif (isset($content['form']["fields"][$field_counter]['value']['private_key'])) {
         $content['form']['recaptcha']['secret_key'] = trim($content['form']["fields"][$field_counter]['value']['private_key']);
     }
     if (!empty($content['form']["fields"][$field_counter]['value']['lang'])) {
         $content['form']['recaptcha']['lang'] = strtolower($content['form']["fields"][$field_counter]['value']['lang']);
     }
     if (isset($content['form']["fields"][$field_counter]['value']['theme']) && in_array($content['form']["fields"][$field_counter]['value']['theme'], array('light', 'dark'))) {
Example #9
0
 /**
  * Parse matched replacement tag
  */
 function parse_match($match = '')
 {
     $default = array();
     $match = trim($match);
     // set query defaults
     $this->dbReset();
     $this->defaultTemplate();
     if ($match !== '' && strpos($match, '=') !== FALSE) {
         // oh yes fix, in case LF was converted to <br /> by phpwcms
         $match = str_replace('<br />', LF, $match);
         // result is a normal array
         $match = parse_ini_str($match, false);
         $default['items'] = isset($match['items']) ? intval($match['items']) : $this->limit;
         $default['template'] = empty($match['template']) ? '' : trim($match['template']);
         $default['lang'] = empty($match['lang']) ? '' : trim($match['lang']);
         $default['tag'] = empty($match['tag']) ? '' : trim($match['tag']);
         $default['tagmode'] = empty($match['tagmode']) ? 'OR' : (trim(strtoupper($match['tagmode'])) === 'AND' ? 'AND' : 'OR');
         $default['href'] = empty($match['href']) ? '' : trim($match['href']);
         $default['place'] = empty($match['place']) ? '' : trim($match['place']);
         $default['gettype'] = empty($match['gettype']) ? '' : $match['gettype'];
         $default['teaserwords'] = empty($match['teaserwords']) ? 0 : intval($match['teaserwords']);
         if (!empty($match['expired'])) {
             $match['expired'] = strtolower(trim($match['expired']));
             $default['expired'] = in_array($match['expired'], array('hide', 'bottom', 'top')) ? $match['expired'] : '';
         } else {
             $default['expired'] = '';
         }
         if (!empty($match['expired_date'])) {
             $match['expired_date'] = strtoupper(trim($match['expired_date']));
             $default['expired_date'] = in_array($match['expired_date'], array('START', 'END')) ? $match['expired_date'] : 'END';
         } else {
             $default['expired_date'] = 'END';
         }
         $default['expired_prefix'] = empty($match['expired_prefix']) ? '' : trim($match['expired_prefix']);
         $default['expired_suffix'] = empty($match['expired_suffix']) ? '' : trim($match['expired_suffix']);
     } else {
         // base format
         // 2,main_page.tmpl,de en, href, tag1, tag2 tag2, tag3 : date_start, date_end, place
         // [item count,[template[,language(en de - separated by space)[, href, tags, tag, tag, tag]]]]
         $match = explode(',', $match, 5);
         $default['items'] = intval($match[0]);
         $default['lang'] = empty($match[1]) ? '' : $match[1];
         $default['template'] = empty($match[2]) ? '' : trim($match[2]);
         $default['href'] = empty($match[3]) ? '' : trim($match[3]);
         $default['tagmode'] = 'OR';
         $default['place'] = '';
         $default['gettype'] = '';
         $default['teaserwords'] = 0;
         $default['expired'] = '';
         $default['expired_date'] = 'END';
         $default['expired_prefix'] = '';
         $default['expired_suffix'] = '';
         if (empty($match[4])) {
             $default['tag'] = '';
         } else {
             // check for start/end date
             $match[4] = explode(':', $match[4], 2);
             if (isset($match[4][1])) {
                 $match[4][1] = explode(',', $match[4][1], 3);
                 if (!empty($match[4][1][0])) {
                     $match['date_start'] = $match[4][1][0];
                 } else {
                     $match['date_start'] = 'TODAY';
                 }
                 if (!empty($match[4][1][1])) {
                     $match['date_end'] = $match[4][1][1];
                 } else {
                     $match['date_end'] = 365 * 24 * 60 * 60 - 1;
                     // + 365 days - 1 second
                 }
                 if (!empty($match[4][1][2])) {
                     $default['place'] = trim($match[4][1][2]);
                 }
             }
         }
     }
     // check for limit
     if (isset($_POST[$this->getbasis . 'limit'])) {
         $default['items'] = intval(clean_slweg($_POST[$this->getbasis . 'limit']));
         $this->session = true;
     } elseif (isset($_GET[$this->getbasis . 'limit'])) {
         $default['items'] = intval(clean_slweg($_GET[$this->getbasis . 'limit']));
         $this->session = true;
     } elseif (!empty($_SESSION['pcal']['limit'])) {
         $default['items'] = $_SESSION['pcal']['limit'];
     }
     // check for place to search
     if (isset($_POST[$this->getbasis . 'place'])) {
         $default['place'] = clean_slweg($_POST[$this->getbasis . 'place']);
         $this->session = true;
     } elseif (isset($_GET[$this->getbasis . 'place'])) {
         $default['place'] = clean_slweg($_GET[$this->getbasis . 'place']);
         $this->session = true;
     } elseif (!empty($_SESSION['pcal']['place'])) {
         $default['place'] = $_SESSION['pcal']['place'];
     }
     // custom start date
     if (isset($_POST[$this->getbasis . 'start'])) {
         if (empty($_POST[$this->getbasis . 'start'])) {
             $match['date_start'] = $_POST[$this->getbasis . 'start_year'] . '-' . $_POST[$this->getbasis . 'start_month'] . '-' . $_POST[$this->getbasis . 'start_day'] . ' 00:00:00';
         } else {
             $match['date_start'] = $_POST[$this->getbasis . 'start'];
         }
         $match['date_start'] = clean_slweg($match['date_start']);
         $this->session = true;
     } elseif (isset($_GET[$this->getbasis . 'start'])) {
         if (empty($_GET[$this->getbasis . 'start'])) {
             $match['date_start'] = $_GET[$this->getbasis . 'start_year'] . '-' . $_GET[$this->getbasis . 'start_month'] . '-' . $_GET[$this->getbasis . 'start_day'] . ' 00:00:00';
         } else {
             $match['date_start'] = $_GET[$this->getbasis . 'start'];
         }
         $match['date_start'] = clean_slweg($match['date_start']);
         $this->session = true;
     } elseif (!empty($_SESSION['pcal']['date_start'])) {
         $match['date_start'] = $_SESSION['pcal']['date_start'];
     }
     // custom end date
     if (isset($_POST[$this->getbasis . 'end'])) {
         if (empty($_POST[$this->getbasis . 'end'])) {
             $match['date_end'] = $_POST[$this->getbasis . 'end_year'] . '-' . $_POST[$this->getbasis . 'end_month'] . '-' . $_POST[$this->getbasis . 'end_day'] . ' 23:59:59';
         } else {
             $match['date_end'] = $_POST[$this->getbasis . 'end'];
         }
         $match['date_end'] = clean_slweg($match['date_end']);
         $this->session = true;
     } elseif (isset($_GET[$this->getbasis . 'end'])) {
         if (empty($_GET[$this->getbasis . 'end'])) {
             $match['date_end'] = $_GET[$this->getbasis . 'end_year'] . '-' . $_GET[$this->getbasis . 'end_month'] . '-' . $_GET[$this->getbasis . 'end_day'] . ' 23:59:59';
         } else {
             $match['date_end'] = $_GET[$this->getbasis . 'end'];
         }
         $this->session = true;
     } elseif (!empty($_SESSION['pcal']['date_end'])) {
         $match['date_end'] = $_SESSION['pcal']['date_end'];
     }
     // set custom defined start/end date
     if (!empty($match['date_start'])) {
         $match['date_start'] = trim($match['date_start']);
         if (strtoupper($match['date_start']) == 'TODAY') {
             $this->date_start = mktime(0, 0, 0, $this->current_date['mon'], $this->current_date['mday'], $this->current_date['year']);
         } elseif (strtoupper($match['date_start']) == 'WEEKSTART') {
             $this->date_start = strtotime((intval(date('w', $this->current_date[0])) === 1 ? 'Today' : 'last Monday') . ' 00:00:00');
         } elseif (strtoupper($match['date_start']) == 'MONTHSTART') {
             $this->date_start = mktime(0, 0, 0, $this->current_date['mon'], 1, $this->current_date['year']);
         } elseif (strtoupper($match['date_start']) == 'YEARSTART') {
             $this->date_start = mktime(0, 0, 0, 1, 1, $current_date['year']);
         } else {
             $match['date_start'] = phpwcms_strtotime($match['date_start']);
             if ($match['date_start']) {
                 $this->date_start = $match['date_start'];
             }
         }
     }
     if (!empty($match['date_end'])) {
         $match['date_end'] = strtoupper(trim($match['date_end']));
         if (is_intval($match['date_end'])) {
             $this->date_end = ceil($this->date_start + $match['date_end'] * 24 * 3600);
             // Get Seconds of this day and match against 23:59:59
             $today_hours = date('G', $this->date_end) * 3600;
             $today_minutes = intval(date('i', $this->date_end)) * 60;
             $today_seconds = intval(date('s', $this->date_end));
             $total_seconds = $today_hours + $today_minutes + $today_seconds;
             $this->date_end += 24 * 3600 - $total_seconds - 1;
         } elseif ($match['date_end'] == 'TODAY') {
             $this->date_end = mktime(23, 59, 59, $this->current_date['mon'], $this->current_date['mday'], $this->current_date['year']);
         } elseif ($match['date_end'] == 'WEEKEND') {
             $this->date_end = strtotime('next Sunday 23:59:59');
         } elseif (preg_match('/(\\d+)\\s{0,1}(DAY|DAYS|WEEK|WEEKS|MONTH|MONTHS)/', $match['date_end'], $add)) {
             $this->date_end = strtotime('+' . $add[1] . ' ' . $add[2] . ' 23:59:59', $this->date_start);
         } elseif (strtoupper($match['date_end']) == 'MONTHEND') {
             $this->date_end = mktime(23, 59, 59, $this->current_date['mon'], intval(date('t', $this->current_date[0])), $this->current_date['year']);
         } elseif (strtoupper($match['date_end']) == 'YEAREND') {
             $this->date_end = mktime(23, 59, 59, 12, 31, $current_date['year']);
         } else {
             if (strlen($match['date_end']) < 12 && preg_match('/[0-9\\-]/', $match['date_end']) && strpos($match['date_end'], ':') === false) {
                 $match['date_end'] .= ' 23:59:59';
             }
             $match['date_end'] = phpwcms_strtotime($match['date_end']);
             if ($match['date_end']) {
                 $this->date_end = $match['date_end'];
             }
         }
     }
     if ($this->date_end <= $this->date_start) {
         $this->date_end = mktime(0, 0, 0, $this->current_date['mon'], $this->current_date['mday'], $this->current_date['year'] + 1) - 1;
     }
     $this->limit = $default['items'];
     $this->limit_item = $default['items'];
     $this->href = $default['href'];
     $this->gettype = $default['gettype'];
     $this->teaserwords = $default['teaserwords'];
     $this->expired = $default['expired'];
     $this->expired_date = $default['expired_date'];
     $this->expired_prefix = $default['expired_prefix'];
     $this->expired_suffix = $default['expired_suffix'];
     if ($default['template'] !== '') {
         $default['template'] = preg_replace('/[\\/\\:]/', '', $default['template']);
         if (is_file(PHPWCMS_TEMPLATE . 'calendar/' . $default['template'])) {
             $default['template'] = file_get_contents(PHPWCMS_TEMPLATE . 'calendar/' . $default['template']);
             if ($default['template']) {
                 $default['template'] = str_replace('{STARTDATE', '{LIVEDATE', $default['template']);
                 $default['template'] = str_replace('{ENDDATE', '{KILLDATE', $default['template']);
                 $this->template = $default['template'];
             }
         }
     }
     $where = array();
     if ($default['lang'] !== '') {
         $default['lang'] = str_replace(',', ' ', preg_replace('/[^a-z\\-]/', '', strtolower($default['lang'])));
         $default['lang'] = array_intersect(convertStringToArray($default['lang'], ' '), $GLOBALS['phpwcms']['allowed_lang']);
         if (count($default['lang'])) {
             $this->where_lang = "calendar_lang IN ('" . implode("','", $default['lang']) . "')";
             $where[] = $this->where_lang;
         }
     }
     if ($default['place'] !== '') {
         $places = convertStringToArray(strtolower($default['place']), ',');
         $place_items = array();
         foreach ($places as $place) {
             $place_items[] = 'calendar_where LIKE ' . _dbEscape('%' . $place . '%');
         }
         if (count($place_items)) {
             $this->where_place = '(' . implode(' OR ', $place_items) . ')';
             $where[] = $this->where_place;
         }
     }
     if ($default['tag'] !== '') {
         $default['tag'] = convertStringToArray(strtolower($default['tag']), ',');
         if (count($default['tag'])) {
             $tag_where = array();
             foreach ($default['tag'] as $tag) {
                 $tag_where[] = "cat_name='" . aporeplace($tag) . "'";
             }
             if (count($tag_where)) {
                 $this->where_tag = '(' . implode(' ' . $default['tagmode'] . ' ', $tag_where) . ')';
                 $where[] = $this->where_tag;
                 $this->join_on = 'LEFT JOIN ' . DB_PREPEND . 'phpwcms_categories ON cat_pid=calendar_id';
                 $this->group_by = 'calendar_id';
             }
         }
     }
     $this->where = implode(' AND ', $where);
     $this->datetime_start = date('Y-m-d H:i:s', $this->date_start);
     $this->datetime_end = date('Y-m-d H:i:s', $this->date_end);
     $this->place = $default['place'];
     $this->getDate();
     if ($this->session && session_id()) {
         $this->session = array('date_start' => $this->datetime_start, 'date_end' => $this->datetime_end, 'place' => $default['place'], 'limit' => $default['items']);
         $_SESSION['pcal'] = isset($_SESSION['pcal']) ? array_merge($_SESSION['pcal'], $this->session) : $this->session;
     }
     return $default;
 }
Example #10
0
 }
 // get filelist template
 if (empty($crow["acontent_template"]) && is_file(PHPWCMS_TEMPLATE . 'inc_default/filelist.tmpl')) {
     $crow["acontent_template"] = render_device(@file_get_contents(PHPWCMS_TEMPLATE . 'inc_default/filelist.tmpl'));
 } elseif ($crow["acontent_template"] == 'download-inline') {
     $crow["acontent_template"] = render_device(@file_get_contents(PHPWCMS_TEMPLATE . 'inc_default/filelist_inline.tmpl'));
 } elseif (is_file(PHPWCMS_TEMPLATE . 'inc_cntpart/filelist/' . $crow["acontent_template"])) {
     $crow["acontent_template"] = render_device(@file_get_contents(PHPWCMS_TEMPLATE . 'inc_cntpart/filelist/' . $crow["acontent_template"]));
 } else {
     $crow["acontent_template"] = '[TITLE]<h4>{TITLE}</h4>[/TITLE][SUBTITLE]<h5>{SUBTITLE}</h5>[/SUBTITLE][TEXT]{TEXT}[/TEXT]' . LF;
     $crow["acontent_template"] .= '<ul class="fileDownload">' . LF . '<!--FILE_ENTRY_START//-->' . LF;
     $crow["acontent_template"] .= '	<li><a href="{FILE_LINK}"{FILE_TARGET}>{FILE_NAME}</a></li>' . LF;
     $crow["acontent_template"] .= '<!--FILE_ENTRY_END//-->' . LF . '</ul>' . LF;
 }
 $_files_settings = get_tmpl_section('FILE_SETTINGS', $crow["acontent_template"]);
 $_files_settings = parse_ini_str($_files_settings, false);
 $_files_settings = array_merge(array('icon_path' => 'img/icons/', 'icon_name' => 'small_icon_{FILE_EXT}.gif', 'thumbnail' => 0, 'thumbnail_width' => 50, 'thumbnail_height' => 50, 'thumbnail_crop' => 1, 'lightbox_init' => 0, 'file_size_round' => 3, 'file_size_space' => ' ', 'date_format' => "%m/%d/%y", 'set_locale' => ''), $_files_settings);
 $crow["acontent_template"] = replace_tmpl_section('FILE_SETTINGS', $crow["acontent_template"]);
 $content['template_file'] = get_tmpl_section('FILE_ENTRY', $crow["acontent_template"]);
 if ($_files_settings['set_locale']) {
     $_files_old_locale = setlocale(LC_ALL, "0");
     setlocale(LC_ALL, $_files_settings['set_locale']);
 }
 if (!empty($_files_settings['lightbox_init'])) {
     initSlimbox();
 }
 $_files_count = count($content['files_result']);
 $_files_entries = array();
 $_files_get_imagesize = strpos($content['template_file'], '{FILE_IMAGE_') === FALSE ? false : true;
 // check if necessary to check for image type and sizes
 foreach ($content['files'] as $fkey => $value) {
 }
 $i = 0;
 foreach ($tmpllist as $value) {
     $value1 = html($value);
     $tmpldata['options'][$i] = '<option value="' . $value1 . '"';
     if ($value == $newsletter["newsletter_vars"]['template']) {
         $tmpldata['options'][$i] .= ' selected="selected"';
         $value3 = $value;
     }
     $tmpldata['options'][$i] .= '>' . $value1 . '</option>' . LF;
     $tmpldata['files'][$i] = returnFileListAsArray(PHPWCMS_TEMPLATE . 'inc_newsletter/' . $value);
     // chech against tmpl file
     if (isset($tmpldata['files'][$i]['newsletter.tmpl'])) {
         $value2 = @file_get_contents(PHPWCMS_TEMPLATE . 'inc_newsletter/' . $value . '/newsletter.tmpl');
         $value2 = get_tmpl_section('NEWSLETTER_SETTINGS', $value2);
         $value2 = parse_ini_str($value2, false);
         if (empty($value2['title'])) {
             $value2['title'] = '';
         }
         if (empty($value2['description'])) {
             $value2['description'] = '';
         }
     } else {
         $value2 = array('title' => '', 'description' => '');
     }
     $tmpldata['js'][] = '  nltemplate["' . $value . '"] = new Array();';
     $tmpldata['js'][] = '  nltemplate["' . $value . '"]["title"] = "' . js_singlequote($value2['title']) . '";';
     $tmpldata['js'][] = '  nltemplate["' . $value . '"]["description"] = "' . js_singlequote($value2['description']) . '";';
     $value2 = '';
     // set preview image
     if (isset($tmpldata['files'][$i]['preview.gif'])) {