Example #1
0
function feedimport_article_authors()
{
    $result = _dbGet('phpwcms_user', 'usr_id, usr_name, usr_login, usr_admin', 'usr_aktiv=1', '', 'usr_admin DESC, usr_name');
    if (!isset($result[0]['usr_id'])) {
        return array(0 => $GLOBALS['BL']['be_cnt_default']);
    }
    $users = array();
    foreach ($result as $user) {
        $users[$user['usr_id']] = $user['usr_name'] ? $user['usr_name'] : $user['usr_login'];
        if ($user['usr_admin']) {
            $users[$user['usr_id']] .= ' (' . $GLOBALS['BL']['be_article_adminuser'] . ')';
        }
    }
    return $users;
}
 function replace_glossary_tag($matches)
 {
     global $content;
     $inner = trim($matches[2]);
     // search keyword in glossary table
     $keyword = trim($matches[1]);
     if ($keyword !== '') {
         $keyword = html_entity_decode($keyword, ENT_QUOTES, PHPWCMS_CHARSET);
         // check against cache
         if (!isset($content['glossary_cache'][$keyword])) {
             $like = aporeplace($keyword);
             $where = 'glossary_status=1 AND glossary_highlight=1 AND (';
             $where .= "glossary_keyword LIKE '" . $like . "' OR ";
             $where .= "glossary_keyword LIKE '" . $like . ",%' OR ";
             $where .= "glossary_keyword LIKE '%, " . $like . ",%' OR ";
             $where .= "glossary_keyword LIKE '%, " . $like . "'";
             $where .= ')';
             // retrieve only single keyword that matches best
             $entry = _dbGet('phpwcms_glossary', 'glossary_title, glossary_keyword, glossary_text, COUNT(glossary_id) AS count_all', $where, 'glossary_id', 'count_all DESC', '1');
             if (isset($entry[0])) {
                 // get keywords to store each in cache
                 $keywords = convertStringToArray($entry[0]['glossary_keyword']);
                 $title = empty($entry[0]['glossary_title']) ? $inner : html($entry[0]['glossary_title']);
                 $text = trim(clean_slweg($entry[0]['glossary_text']));
                 // store glossary item in cache
                 foreach ($keywords as $key) {
                     $content['glossary_cache'][$key] = array('title' => $title, 'text' => $text);
                 }
             }
         }
         // create ABBR
         if (isset($content['glossary_cache'][$keyword])) {
             $inner = '<abbr class="glossary" title="' . $content['glossary_cache'][$keyword]['title'] . ' :: ' . $content['glossary_cache'][$keyword]['text'] . '">' . $inner . '</abbr>';
         }
     }
     return $inner;
 }
echo $BL['be_subnav_admin_groups'];
?>
</td></tr>
<tr><td colspan="3"><img src="img/leer.gif" alt="" width="1" height="6"></td></tr>
<tr><td colspan="3" bgcolor="#92A1AF"><img src="img/leer.gif" alt="" width="1" height="1"></td></tr>
<tr><td colspan="3"><img src="img/leer.gif" alt="" width="1" height="6"></td></tr>

<?php 
$bg_color1 = "#FFFFFF";
$bg_color2 = "#F3F5F8";
$zaehler = 0;
if (empty($new_group_id)) {
    $new_group_id = 0;
}
//Liste aller Gruppen erzeugen
$result = _dbGet('phpwcms_usergroup', '*', 'group_active != 9', '', 'group_name');
if (isset($result[0])) {
    foreach ($result as $grouplist) {
        $bg_color = $zaehler % 2 ? $bg_color2 : $bg_color1;
        if ($grouplist["group_id"] == $new_group_id) {
            $bg_color = "#FFCC00";
        }
        $goto = "phpwcms.php?do=admin&amp;p=1&amp;s=2&amp;u=" . $grouplist["group_id"];
        ?>
        <tr><td colspan="3"><img src="img/leer.gif" alt="" width="1" height="1"></td></tr>
        <tr bgcolor="<?php 
        echo $bg_color;
        ?>
" onmouseover="bgColor='#DBFF48'" onmouseout="bgColor='<?php 
        echo $bg_color;
        ?>
 // check for selections in $_POST
 // the session var is now prod id|opt1 id|opt2 id
 // addings with no options result in: prod id|0|0
 $opt_1 = isset($_POST['prod_opt1']) ? intval($_POST['prod_opt1']) : 0;
 $opt_2 = isset($_POST['prod_opt2']) ? intval($_POST['prod_opt2']) : 0;
 // Test against product options
 if (!isset($_POST['prod_opt1']) && !isset($_POST['prod_opt2'])) {
     $shop_prod_cartadd = true;
 } elseif (isset($_POST['prod_opt1']) && isset($_POST['prod_opt2']) && $opt_1 && $opt_2) {
     $shop_prod_cartadd = true;
 } elseif (isset($_POST['prod_opt1']) && !isset($_POST['prod_opt2']) && $opt_1) {
     $shop_prod_cartadd = true;
 } elseif (isset($_POST['prod_opt2']) && !isset($_POST['prod_opt1']) && $opt_2) {
     $shop_prod_cartadd = true;
 } else {
     $data = _dbGet('phpwcms_shop_products', 'shopprod_size,shopprod_color', 'shopprod_status=1 AND shopprod_id=' . $shop_prod_id);
     if (isset($data[0]['shopprod_size'])) {
         $data[0]['shopprod_size'] = trim($data[0]['shopprod_size']);
         $data[0]['shopprod_color'] = trim($data[0]['shopprod_color']);
         if ($data[0]['shopprod_size'] === '' && $data[0]['shopprod_color'] === '') {
             $shop_prod_cartadd = true;
         }
     }
 }
 if ($shop_prod_cartadd) {
     // add product to shopping
     if (isset($_SESSION[CART_KEY]['products'][$shop_prod_id][$opt_1][$opt_2])) {
         $_SESSION[CART_KEY]['products'][$shop_prod_id][$opt_1][$opt_2] += $shop_prod_amount;
         $_SESSION[CART_KEY]['options1'][$shop_prod_id][$opt_1][$opt_2] = $opt_1;
         $_SESSION[CART_KEY]['options2'][$shop_prod_id][$opt_1][$opt_2] = $opt_2;
     } else {
Example #5
0
    $shop_api_data['message'] = 'Set or see the API key setting in the shop preferences.';
}
/**
 * Possible Actions
 * ================
 *
 * getorders
 * Will return all orders with status new (at the moment only)
 *
 * setstatus
 * Set order status of a specific order
 *
 */
if ($shop_api_access) {
    if ($shop_api_action === 'getorders') {
        $data = _dbGet('phpwcms_shop_orders', '*', "order_status='NEW-ORDER'", '', 'order_date ASC');
        foreach ($data as $row) {
            $row['order_data'] = @unserialize($row['order_data']);
            // fallback for additional fields
            $row['order_data']['address'] = array_merge(array('INV_SALUTATION' => '', 'INV_TITLE' => '', 'INV_COMPANY' => '', 'INV_ADDRESS2' => ''), $row['order_data']['address']);
            $row_data = array('id' => md5($row["order_id"] . $row['order_number']), 'number' => _convert_charset($row['order_number']), 'date' => $row['order_date'], 'lang' => empty($row['order_data']['lang']) ? '' : _convert_charset($row['order_data']['lang']), 'email' => _convert_charset($row['order_email']), 'salutation' => _convert_charset($row['order_data']['address']['INV_SALUTATION']), 'title' => _convert_charset($row['order_data']['address']['INV_TITLE']), 'firstname' => _convert_charset($row['order_firstname']), 'name' => _convert_charset($row['order_name']), 'company' => _convert_charset($row['order_data']['address']['INV_COMPANY']), 'address' => _convert_charset($row['order_data']['address']['INV_ADDRESS']), 'address2' => _convert_charset($row['order_data']['address']['INV_ADDRESS2']), 'postcode' => _convert_charset($row['order_data']['address']['INV_ZIP']), 'city' => _convert_charset($row['order_data']['address']['INV_CITY']), 'region' => _convert_charset($row['order_data']['address']['INV_REGION']), 'country' => _convert_charset($row['order_data']['address']['INV_COUNTRY']), 'phone' => _convert_charset($row['order_data']['address']['PHONE']), 'custom_fields' => null, 'payment' => _convert_charset(strtolower($row['order_payment'])), 'total' => array('total_net' => floatval($row['order_net']), 'total_vat' => floatval($row['order_gross']) - floatval($row['order_net']), 'total_gross' => floatval($row['order_gross'])), 'subtotal' => isset($row['order_data']['subtotal']) ? $row['order_data']['subtotal'] : null, 'shipping' => isset($row['order_data']['shipping']) ? $row['order_data']['shipping'] : null, 'discount' => isset($row['order_data']['discount']) ? $row['order_data']['discount'] : null, 'loworder' => isset($row['order_data']['loworder']) ? $row['order_data']['loworder'] : null, 'weight' => isset($row['order_data']['weight']) ? $row['order_data']['weight'] : null, 'distance' => isset($row['order_data']['distance']) ? $row['order_data']['distance'] : null, 'positions' => array());
            if ($row_data['shipping']) {
                $row_data['shipping']['shipping_vat'] = $row_data['shipping']['shipping_gross'] - $row_data['shipping']['shipping_net'];
            }
            if (isset($row_data['distance']['label'])) {
                foreach ($row_data['distance'] as $key => $value) {
                    $row_data['distance'][$key] = _convert_charset($row_data['distance'][$key]);
                }
                $row_data['shipping']['shipping_zone'] = $row_data['distance']['label'];
            }
            if ($row_data['subtotal']) {
Example #6
0
 * @copyright Copyright (c) 2002-2015, Oliver Georgi
 * @license http://opensource.org/licenses/GPL-2.0 GNU GPL-2
 * @link http://www.phpwcms.de
 *
 **/
session_start();
$phpwcms = array();
require_once '../../include/config/conf.inc.php';
require_once '../inc_lib/default.inc.php';
require_once PHPWCMS_ROOT . '/include/inc_lib/dbcon.inc.php';
require_once PHPWCMS_ROOT . '/include/inc_lib/general.inc.php';
checkLogin();
require_once PHPWCMS_ROOT . '/include/inc_lib/backend.functions.inc.php';
if ($_SESSION["wcs_user_admin"] == 1) {
    list($do, $id) = explode('|', $_GET['do']);
    $do = intval($do);
    $id = intval($id);
    if ($id) {
        if ($do === 1) {
            _dbUpdate('phpwcms_pagelayout', array('pagelayout_default' => 0, 'pagelayout_trash' => 9), 'pagelayout_id=' . $id);
        } elseif ($do === 2) {
            $result = _dbUpdate('phpwcms_template', array('template_default' => 0, 'template_trash' => 9), 'template_id=' . $id);
            // Update article categories with new default template ID or to 0 if no default template is defined
            if ($result) {
                $default = _dbGet('phpwcms_template', 'template_id, template_default', 'template_trash=0 AND template_default=1', '', '', 1);
                _dbUpdate('phpwcms_articlecat', array('acat_template' => isset($default[0]['template_id']) ? $default[0]['template_id'] : 0), 'acat_trash=0 AND acat_template=' . $id);
            }
        }
    }
}
headerRedirect($_SESSION['REFERER_URL']);
Example #7
0
                 break;
             case 'url_unsubscribe':
                 $form_newletter_setting['url_unsubscribe'] = $form_value_nl[1];
                 break;
             case 'subject':
                 $form_newletter_setting['subject'] = $form_value_nl[1];
                 break;
             case 'double_optin':
                 $form_newletter_setting['double_optin'] = intval($form_value_nl[1]) ? 1 : 0;
                 break;
             case 'optin_template':
                 $form_newletter_setting['optin_template'] = $form_value_nl[1];
                 break;
             default:
                 if ($form_value_nl[0] = intval($form_value_nl[0])) {
                     $query = _dbGet('phpwcms_subscription', '*', 'subscription_id=' . $form_value_nl[0] . ' AND subscription_active=1');
                     if (isset($query[0])) {
                         if ($form_value_nl[1] == '') {
                             $form_value_nl[1] = $query[0]['subscription_name'];
                         }
                         $form_value[$form_value_nl[0]] = $form_value_nl[1];
                     } else {
                         continue;
                     }
                 } else {
                     continue;
                 }
         }
     }
 }
 $form_newletter_setting['subscriptions'] = $form_value;
		<input type="hidden" name="csubtitle" value="" />
		<input type="hidden" name="cpaginate_title" value="" />
		<input type="hidden" name="cpaginate_page" value="" />

<?php 
    // normal contentpart edit mode
} else {
    // Detect Template
    if (!empty($content['article']['acat_template'])) {
        $content['current_template'] = _dbGet('phpwcms_template', '*', 'template_trash=0 AND template_id=' . _dbEscape($content['article']['acat_template']), '', '', 1);
    }
    if (!isset($content['current_template'][0])) {
        $content['current_template'] = _dbGet('phpwcms_template', '*', 'template_trash=0 AND template_default=1', '', '', 1);
    }
    if (!isset($content['current_template'][0])) {
        $content['current_template'] = _dbGet('phpwcms_template', '*', 'template_trash=0', '', 'template_default DESC', 1);
    }
    $content['blocks'] = array();
    if (isset($content['current_template'][0]['template_var'])) {
        $content['template_name'] = html($content['current_template'][0]['template_name']);
        if ($content['current_template'][0]['template_default']) {
            $content['template_name'] .= ' (' . $BL['be_admin_tmpl_default'] . ')';
        }
        $content['current_template'] = unserialize($content['current_template'][0]['template_var']);
        if (!empty($content['current_template']['customblock'])) {
            $content['current_template'] = explode(',', $content['current_template']['customblock']);
            if (count($content['current_template'])) {
                $content['blocks'][] = '<optgroup label="' . $BL['be_admin_page_blocks'] . ', ' . $BL['be_admin_page_customblocks'] . '">';
                foreach ($content['current_template'] as $value) {
                    $value = trim($value);
                    if ($value !== '') {
Example #9
0
     if ($aktion[1]) {
         $_uri_alias = 'aid=' . $aktion[1];
     } elseif ($content['struct'][0]['acat_alias']) {
         $_uri_alias = $content['struct'][0]['acat_alias'];
     } else {
         $_uri_alias = 'id=' . $content['cat_id'];
     }
 } else {
     $_uri_alias = '';
 }
 switch ($fe_action) {
     case '{FE_USER_MANAGE}':
         $_uri = rel_url(array('profile_manage' => 'edit'), array('profile_register', 'profile_reminder'), $_uri_alias);
         // at the moment it is only possible to edit user data of "real" FRONTEND users
         // all BACKEND users should login to backend and edit their data there
         $result = _dbGet('phpwcms_userdetail', '*', "detail_filter='" . aporeplace(FEUSER_REGKEY) . "' AND detail_id=" . intval($_SESSION[$_loginData['session_key'] . '_userdata']['id']), '', '', '1');
         if (isset($result[0])) {
             $fe_data = $result[0];
             $fe_data['detail_password'] = '';
         }
         break;
     case '{FE_USER_REGISTER}':
         $_uri = rel_url(array('profile_register' => 'create'), array('profile_manage', 'profile_reminder'), $_uri_alias);
         break;
 }
 if (isset($_POST['detail_login'])) {
     $udata['user_login'] = clean_slweg($_POST['user_login']);
     $udata['user_password'] = slweg($_POST['user_password']);
     $udata['user_password2'] = slweg($_POST['user_password2']);
     $udata['user_company'] = clean_slweg($_POST['user_company']);
     $udata['user_title'] = clean_slweg($_POST['user_title']);
 /**
  * get the geocode lat/lon points from cache for given address
  *
  * @param string $address
  * @return bool|array False if no cache, array of data if has cache
  */
 function getCache($address)
 {
     $_ret = array();
     $_row = _dbGet($this->_db_cache_table, 'lon,lat', 'address=' . _dbEscape($address));
     if (isset($_row[0])) {
         $_ret['lon'] = $_row[0]['lon'];
         $_ret['lat'] = $_row[0]['lat'];
     } elseif ($_row === false && $this->_db_cache_table && !$this->_db_cache_table_created) {
         $sql = 'CREATE TABLE IF NOT EXISTS `' . DB_PREPEND . $this->_db_cache_table . '` (';
         $sql .= " `address` varchar(1000) NOT NULL DEFAULT '', ";
         $sql .= '`lon` double DEFAULT NULL, ';
         $sql .= '`lat` double DEFAULT NULL, ';
         $sql .= 'PRIMARY KEY (`address`), ';
         $sql .= 'KEY `lon` (`lon`), ';
         $sql .= 'KEY `lat` (`lat`) ';
         $sql .= ')';
         $result = _dbQuery($sql, 'CREATE');
         if ($result) {
             $this->_db_cache_table_created = true;
         }
     }
     return isset($_ret['lon']) ? $_ret : false;
 }
Example #11
0
        // Back to module listing
        if (isset($_POST['save'])) {
            headerRedirect(MODULE_HREF_DECODE);
        }
        // set ID
        if (!empty($result['INSERT_ID'])) {
            $plugin['data']['id'] = $result['INSERT_ID'];
            $plugin['id'] = $result['INSERT_ID'];
        }
    } else {
        set_status_message(implode(LF, $plugin['error']), 'warning');
    }
}
// try to read entry from database
if ($plugin['id'] && !isset($plugin['error'])) {
    $plugin['data'] = _dbGet('phpwcms_content', '*', 'cnt_status!=9 AND cnt_module=' . _dbEscape(MODULE_KEY) . ' AND cnt_id=' . $plugin['id']);
    if (isset($plugin['data'][0])) {
        $plugin['data'] = $plugin['data'][0];
        $plugin['data']['cnt_object'] = @unserialize($plugin['data']['cnt_object']);
        $plugin['data']['id'] = $plugin['data']['cnt_id'];
        if (count($plugin['data']['cnt_object'])) {
            foreach ($plugin['data']['cnt_object'] as $key => $value) {
                $plugin['data']['cnt_object-' . $key] = $value;
            }
        }
        $plugin['fields']['cnt_object-feed_import_trigger_url'] = 'TEXTAREA-DISABLED';
        $plugin['data']['cnt_object-feed_import_trigger_url'] = PHPWCMS_URL . 'index.php?feedimport=' . md5($plugin['data']['cnt_id'] . $plugin['data']['cnt_text']);
    } else {
        $plugin['data'] = false;
        set_status_message(sprintf($BLM['error_false_id'], $plugin['id']), 'warning');
        headerRedirect(MODULE_HREF_DECODE);
Example #12
0
echo $BLM['create_new'];
?>
</span></a>
</div>

<!-- No Pagination or filter -->

<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="">

	<tr><td colspan="4"><img src="img/leer.gif" alt="" width="1" height="3" /></td></tr>
	<tr><td colspan="4" bgcolor="#92A1AF"><img src="img/leer.gif" alt="" width="1" height="1" /></td></tr>

<?php 
// loop listing available rates
$row_count = 0;
$data = _dbGet('phpwcms_content', '*', 'cnt_status!=9 AND cnt_module=' . _dbEscape(MODULE_KEY));
foreach ($data as $row) {
    $url = parse_url($row['cnt_text'], PHP_URL_HOST);
    echo '<tr style="cursor:pointer"' . ($row_count % 2 ? ' bgcolor="#F3F5F8"' : '');
    echo ' onclick="document.location=\'' . MODULE_HREF . '&amp;edit=' . $row["cnt_id"] . '\';">' . LF;
    echo '<td width="25" style="padding:2px 3px 2px 4px;">';
    echo '<img src="img/famfamfam/rss.png" alt="' . $BLM['backend_menu'] . '" /></td>' . LF;
    echo '<td class="dir" width="55%" style="padding-left:3px" nowrap="nowrap">' . html($row['cnt_name']) . "</td>\n";
    echo '<td class="dir" width="35%" nowrap="nowrap">&nbsp;' . $url . "&nbsp;&nbsp;</td>\n";
    echo '<td width="10%" align="right" nowrap="nowrap" class="button_td">';
    echo '<a href="' . MODULE_HREF . '&amp;edit=' . $row["cnt_id"] . '">';
    echo '<img src="img/button/edit_22x13.gif" border="0" alt="" /></a>';
    echo '<a href="' . MODULE_HREF . '&amp;editid=' . $row["cnt_id"] . '&amp;active=';
    echo ($row["cnt_status"] ? '0' : '1') . '">';
    echo '<img src="img/button/aktiv_12x13_' . $row["cnt_status"] . '.gif" border="0" alt="" /></a>';
    echo '<a href="' . MODULE_HREF . '&amp;delete=' . $row["cnt_id"];
Example #13
0
 function edit()
 {
     $this->newsId = intval($_GET['cntid']);
     $this->data = array();
     if (isset($_GET['status'])) {
         $status = intval($_GET['status']);
         switch ($status) {
             case 0:
             case 1:
             case 9:
                 _dbUpdate('phpwcms_content', array('cnt_status' => $status), 'cnt_id=' . $this->newsId);
                 set_status_message($status == 9 ? $this->BL['be_action_deleted'] : $this->BL['be_action_status'], 'success', array('ID' => $this->newsId));
                 break;
             default:
                 set_status_message($this->BL['be_action_notvalid'], 'warning');
         }
         headerRedirect($this->base_url_decoded);
     }
     $start_date = 0;
     $end_date = 0;
     $this->data = array('cnt_id' => 0, 'cnt_pid' => 0, 'cnt_status' => intval($this->phpwcms['set_news_active']), 'cnt_livedate' => '0000-00-00 00:00:00', 'cnt_killdate' => '0000-00-00 00:00:00', 'cnt_archive_status' => 1, 'cnt_alias' => '', 'cnt_name' => '', 'cnt_title' => '', 'cnt_subtitle' => '', 'cnt_editor' => '', 'cnt_place' => '', 'cnt_teasertext' => '', 'cnt_text' => '', 'cnt_duplicate' => 0, 'cnt_lang' => '', 'cnt_prio' => 0, 'cnt_readmore' => 1, 'cnt_image' => array('id' => 0, 'name' => '', 'zoom' => 0, 'lightbox' => 0, 'caption' => '', 'link' => ''), 'cnt_files' => array('id' => array(), 'caption' => '', 'gallery' => 0, 'gallery_download' => 0), 'cnt_link' => '', 'cnt_linktext' => '', 'cnt_category' => '', 'cnt_livedate' => '', 'cnt_killdate' => '', 'cnt_sort' => 0, 'cnt_opengraph' => empty($this->phpwcms['set_sociallink']['news']) ? 0 : 1, 'cnt_textformat' => 'plain', 'cnt_searchoff' => 0);
     // check form post
     if (isset($_POST['cnt_name'])) {
         $post = $this->getPostData();
         $post_error = false;
         if (!empty($_POST['cnt_duplicate'])) {
             $this->newsId = 0;
             $duplicate = 1;
             $post['cnt_created'] = now();
         } else {
             $duplicate = 0;
         }
         // 1st check if we have a name because it's mandatory
         if ($post['cnt_name'] == '') {
             $post_error = true;
             set_status_message($this->BL['be_news_name_mandatory'], 'warning');
             $post['cnt_duplicate'] = $duplicate;
         }
         // do db work
         if ($post_error === false) {
             $values = $post;
             $values['cnt_object'] = serialize($values['cnt_object']);
             $success = false;
             // store new dataset
             if ($this->newsId == 0) {
                 $result = _dbInsert('phpwcms_content', $values);
                 if (isset($result['INSERT_ID'])) {
                     $this->newsId = $result['INSERT_ID'];
                     $success = true;
                     set_status_message($this->BL['be_successfully_saved'] . LF . $post['cnt_name'], 'success');
                 }
                 // update existing dataset
             } else {
                 $result = _dbUpdate('phpwcms_content', $values, 'cnt_id=' . $this->newsId);
                 if ($result != false) {
                     $success = true;
                     set_status_message($this->BL['be_successfully_updated'] . LF . $post['cnt_name'], 'success');
                 }
             }
             // if success
             if ($success) {
                 // save categories
                 if ($this->newsId) {
                     _dbSaveCategories($post['cnt_object']['cnt_category'], 'news', $this->newsId, ',');
                 }
                 // redirect to form again
                 if ($this->newsId && isset($_POST['submit'])) {
                     headerRedirect($this->base_url_decoded . '&cntid=' . $this->newsId . '&action=edit');
                     // back to listing
                 } else {
                     headerRedirect($this->base_url_decoded);
                 }
                 // error while storing data
             } else {
                 set_status_message($BL['be_error_while_save'] . trim(html(' ' . mysql_errno() . ': ' . mysql_error())), 'warning');
             }
         }
         $this->data = array_merge($this->data, $post);
     } elseif ($this->newsId > 0) {
         $result = _dbGet('phpwcms_content', '*', 'cnt_status!=9 AND cnt_id=' . $this->newsId, '', '', '1');
         if (isset($result[0])) {
             $result[0]['cnt_object'] = @unserialize($result[0]['cnt_object']);
             if (is_array($result[0]['cnt_object']['cnt_image'])) {
                 $result[0]['cnt_image'] = array_merge($this->data['cnt_image'], $result[0]['cnt_object']['cnt_image']);
             }
             if (is_array($result[0]['cnt_object']['cnt_files'])) {
                 $result[0]['cnt_files'] = array_merge($this->data['cnt_files'], $result[0]['cnt_object']['cnt_files']);
             }
             if (isset($result[0]['cnt_object']['cnt_link'])) {
                 $result[0]['cnt_link'] = $result[0]['cnt_object']['cnt_link'];
             }
             if (isset($result[0]['cnt_object']['cnt_linktext'])) {
                 $result[0]['cnt_linktext'] = $result[0]['cnt_object']['cnt_linktext'];
             }
             if (isset($result[0]['cnt_object']['cnt_category'])) {
                 $result[0]['cnt_category'] = $result[0]['cnt_object']['cnt_category'];
             }
             if (isset($result[0]['cnt_object']['cnt_readmore'])) {
                 $result[0]['cnt_readmore'] = $result[0]['cnt_object']['cnt_readmore'];
             }
             if (isset($result[0]['cnt_object']['cnt_textformat'])) {
                 $result[0]['cnt_textformat'] = $result[0]['cnt_object']['cnt_textformat'];
             }
             if (isset($result[0]['cnt_object']['cnt_searchoff'])) {
                 $result[0]['cnt_searchoff'] = $result[0]['cnt_object']['cnt_searchoff'];
             }
             $this->data = array_merge($this->data, $result[0]);
         } else {
             set_status_message($this->BL['be_data_select_failed'], 'warning');
             headerRedirect($this->base_url_decoded);
         }
     }
     $start_date = strtotime($this->data['cnt_livedate']);
     $end_date = strtotime($this->data['cnt_killdate']);
     $sort_date = intval($this->data['cnt_sort']);
     if ($start_date <= 0) {
         $this->data['cnt_livedate'] = '0000-00-00 00:00:00';
         $this->data['cnt_date_start'] = '';
         $this->data['cnt_time_start'] = '';
     } else {
         $this->data['cnt_date_start'] = date($this->BL['default_date'], $start_date);
         $this->data['cnt_time_start'] = date($this->BL['default_time'], $start_date);
     }
     if ($end_date <= 0) {
         $this->data['cnt_killdate'] = '0000-00-00 00:00:00';
         $this->data['cnt_date_end'] = '';
         $this->data['cnt_time_end'] = '';
     } else {
         $this->data['cnt_date_end'] = date($this->BL['default_date'], $end_date);
         $this->data['cnt_time_end'] = date($this->BL['default_time'], $end_date);
     }
     // sort date
     if ($sort_date <= 0) {
         $this->data['cnt_sort'] = 0;
         $this->data['cnt_sort_date'] = '';
         $this->data['cnt_sort_time'] = '';
     } else {
         $this->data['cnt_sort_date'] = date($this->BL['default_date'], $sort_date);
         $this->data['cnt_sort_time'] = date($this->BL['default_time'], $sort_date);
     }
 }
 // Dates
 $news['entries'][$key] = render_cnt_date($news['entries'][$key], $value['cnt_changed'], $value['cnt_ts_livedate'], $value['cnt_ts_killdate']);
 $news['entries'][$key] = render_date($news['entries'][$key], $value['cnt_ts_sortdate'], 'SORTDATE');
 $news['files_result'] = '';
 // Files
 if (isset($value['cnt_object']['cnt_files']['id']) && is_array($value['cnt_object']['cnt_files']['id']) && count($value['cnt_object']['cnt_files']['id'])) {
     // should image files used for gallery
     if (!empty($value['cnt_object']['cnt_files']['gallery']) && strpos($news['entries'][$key], '/GALLERY')) {
         if (!$news['config']['gallery_allowed_ext']) {
             $value['cnt_object']['cnt_files']['gallery'] = false;
             // Get Image files
         } else {
             $value['cnt_object']['cnt_files']['where'] = 'f_id IN (' . implode(',', $value['cnt_object']['cnt_files']['id']) . ') AND ';
             $value['cnt_object']['cnt_files']['where'] .= 'f_public=1 AND f_aktiv=1 AND f_kid=1 AND f_trash=0 AND ';
             $value['cnt_object']['cnt_files']['where'] .= 'f_ext IN(' . $news['config']['gallery_allowed_ext'] . ')';
             $value['cnt_object']['cnt_files']['images'] = _dbGet('phpwcms_file', 'f_id,f_hash,f_name,f_ext,f_longinfo,f_copyright,f_vars', $value['cnt_object']['cnt_files']['where']);
             if (!isset($value['cnt_object']['cnt_files']['images'][0])) {
                 $value['cnt_object']['cnt_files']['gallery'] = false;
                 // create gallery
             } else {
                 $value['gallery_id'] = array();
                 // just to have relation between file ID and query result
                 foreach ($value['cnt_object']['cnt_files']['images'] as $ikey => $ivalue) {
                     $value['gallery_id'][$ivalue['f_id']] = $ikey;
                 }
                 // Need to parse file list caption too
                 if (!$news['config']['gallery_filecenter_info']) {
                     // check if info for the file is available
                     // [0] = normal file description like before
                     // [1] = name the file (it's not the file name)
                     // [2] = title
        echo '<img src="img/button/aktiv_12x13_' . $data['active'] . '.gif" alt="" border="0" height="13" width="12" />';
        echo $data['enable_switch_suffix'];
        echo '</td>' . LF . '	</tr>' . LF;
        $x++;
    }
    ?>

	</table>

<?php 
    // Edit Redirects
} else {
    $rid = empty($_GET['rid']) ? 0 : intval($_GET['rid']);
    // now retrieve selected item
    if ($rid) {
        $data = _dbGet('phpwcms_redirect', '*, UNIX_TIMESTAMP(changed) AS timestamp', 'rid=' . $rid, '', 'changed DESC, views DESC');
    }
    if (isset($data[0])) {
        $data = $data[0];
    } else {
        $data = array('rid' => 0, 'alias' => '', 'id' => '', 'aid' => '', 'type' => '', 'active' => 0, 'shortcut' => 0, 'views' => 0, 'timestamp' => now(), 'target' => '', 'code' => '');
    }
    if (count($data_result['data'])) {
        $data = array_merge($data, $data_result['data']);
    }
    ?>
<h1 class="title"><?php 
    echo ($data['rid'] ? $BL['be_cnt_guestbook_edit'] : $BL['be_article_cnt_button2']) . ': ' . $BL['be_link'] . ' &amp; ' . $BL['be_redirect'];
    ?>
</h1>
<form action="phpwcms.php?do=admin&amp;p=14&amp;rid=<?php 
Example #16
0
 function search()
 {
     $this->now = now();
     if (empty($this->search_words)) {
         return NULL;
     }
     $cnt_ts_livedate = 'IF(UNIX_TIMESTAMP(pc.cnt_livedate) > 0, UNIX_TIMESTAMP(pc.cnt_livedate), pc.cnt_created)';
     $cnt_ts_killdate = 'IF(UNIX_TIMESTAMP(pc.cnt_killdate) > 0, UNIX_TIMESTAMP(pc.cnt_killdate), pc.cnt_created + 31536000)';
     $sql = 'SELECT pc.*, ';
     $sql .= $cnt_ts_livedate . ' AS cnt_ts_livedate, ';
     $sql .= $cnt_ts_killdate . ' AS cnt_ts_killdate ';
     $sql .= 'FROM ' . DB_PREPEND . 'phpwcms_content pc ';
     $sql_where = 'WHERE ';
     $sql_where .= 'pc.cnt_status=1 AND ';
     $sql_where .= "pc.cnt_module='news' AND ";
     $sql_where .= $cnt_ts_livedate . ' < ' . $this->now . ' AND ';
     $sql_where .= '(' . $cnt_ts_killdate . ' > ' . $this->now . ' OR cnt_archive_status = 1) ';
     $sql_group = '';
     // choose by category
     if (count($this->search_category)) {
         $cat_sql = array();
         // and/or/not mode
         switch ($this->search_andor) {
             case 'AND':
                 $news_andor = ' AND ';
                 $news_compare = '=';
                 break;
             case 'NOT':
                 $news_andor = ' AND ';
                 $news_compare = '!=';
                 break;
             default:
                 //OR
                 $news_andor = ' OR ';
                 $news_compare = '=';
         }
         foreach ($this->search_category as $value) {
             $cat_sql[] = 'pcat.cat_name' . $news_compare . _dbEscape($value);
         }
         $sql .= "LEFT JOIN " . DB_PREPEND . "phpwcms_categories pcat ON (pcat.cat_type='news' AND pcat.cat_pid=pc.cnt_id) ";
         $sql_where .= 'AND (' . implode($news_andor, $cat_sql) . ') ';
         $sql_group = 'GROUP BY pc.cnt_id ';
     }
     // language selection
     if (count($this->search_language)) {
         $sql_where .= "AND pc.cnt_lang IN ('" . str_replace('#', "','", _dbEscape(implode('#', $this->search_language), false)) . "') ";
     }
     $sql .= $sql_where;
     $sql .= $sql_group;
     $sql = trim($sql);
     $data = _dbQuery($sql);
     $search_target_url_test = strtolower(substr($this->search_target_url, 0, 4));
     if ($search_target_url_test !== 'http' && $search_target_url_test !== '{sit') {
         // expected alias here or aid=123 or id=123
         if ($this->search_highlight) {
             $this->search_target_url = rel_url(array('newsdetail' => '___NEWSDETAIL__', 'highlight' => '___HIGHLIGHT__'), array('searchstart', 'searchwords'), $this->search_target_url);
         } else {
             $this->search_target_url = rel_url(array('newsdetail' => '___NEWSDETAIL__'), array('highlight', 'searchstart', 'searchwords'), $this->search_target_url);
         }
         $search_replace_newsdetail = true;
     } else {
         $search_replace_newsdetail = strpos($this->search_target_url, '___NEWSDETAIL__') !== false ? true : false;
         $this->search_target_url = html_specialchars($this->search_target_url);
     }
     if ($this->search_highlight_words && is_array($this->search_highlight_words)) {
         $s_highlight_words = rawurlencode(implode(' ', $this->search_highlight_words));
     } else {
         $s_highlight_words = '';
     }
     foreach ($data as $value) {
         $s_result = array();
         $s_text = $value['cnt_text'] . ', ' . $value['cnt_teasertext'] . ', ' . $value['cnt_place'] . ', ';
         $s_text .= $value['cnt_subtitle'] . ', ' . $value['cnt_title'];
         if ($this->search_username) {
             $s_text .= ', ' . $value['cnt_editor'];
         }
         $value['cnt_object'] = @unserialize($value['cnt_object']);
         if (!empty($value['cnt_object']['cnt_searchoff'])) {
             continue;
         }
         if (isset($value['cnt_object']['cnt_category'])) {
             if ($this->search_keyword) {
                 $s_text .= ' ' . $value['cnt_object']['cnt_category'];
             }
             if ($this->search_caption) {
                 $s_text .= ' ' . $value['cnt_object']['cnt_image']['caption'];
                 $s_text .= ' ' . $value['cnt_object']['cnt_files']['caption'];
             }
         }
         $s_text = preg_replace('/<script[^>]*>.*?<\\/script>/is', '', $s_text);
         // strip all <script> Tags
         $s_text = str_replace(array('~', '|', ':', 'http', '//', '_blank', '&nbsp;'), ' ', $s_text);
         $s_text = clean_search_text($s_text);
         preg_match_all('/' . $this->search_words . '/is', $s_text, $s_result);
         $s_count = count($s_result[0]);
         //set search_result to 0
         if ($s_count && SEARCH_TYPE_AND) {
             $s_and_or = array();
             foreach ($s_result[0] as $svalue) {
                 $s_and_or[strtolower($svalue)] = 1;
             }
             $s_and_or = count($s_and_or);
             if ($s_and_or != $this->search_word_count) {
                 $s_count = 0;
             }
         }
         if ($s_count) {
             $id = $this->search_result_entry;
             $this->search_results[$id]["id"] = $value['cnt_id'];
             $this->search_results[$id]["cid"] = 0;
             $this->search_results[$id]["rank"] = $s_count;
             if ($this->search_highlight) {
                 $this->search_results[$id]["title"] = highlightSearchResult(html($value['cnt_title']), $this->search_highlight_words);
                 $this->search_results[$id]["subtitle"] = highlightSearchResult(html($value['cnt_subtitle']), $this->search_highlight_words);
             } else {
                 $this->search_results[$id]["title"] = html($value['cnt_title']);
                 $this->search_results[$id]["subtitle"] = html($value['cnt_subtitle']);
             }
             $this->search_results[$id]["date"] = $value['cnt_ts_livedate'];
             $this->search_results[$id]["user"] = html($value['cnt_editor']);
             $value['detail_link'] = date('Ymd', $value['cnt_ts_livedate']) . '-' . $value['cnt_id'] . '_';
             //$crow['acontent_aid']
             $value['detail_link'] .= empty($value['cnt_alias']) ? $value['cnt_id'] : urlencode($value['cnt_alias']);
             if (strpos($this->search_target_url, '___NEWSDETAIL__') !== false) {
                 $this->search_results[$id]['link'] = str_replace(array('___NEWSDETAIL__', '___HIGHLIGHT__'), array($value['detail_link'], $s_highlight_words), $this->search_target_url);
             } else {
                 $this->search_results[$id]['link'] = $this->search_target_url . '&amp;newsdetail=' . $value['detail_link'];
                 if ($this->search_highlight) {
                     $this->search_results[$id]['link'] .= '&amp;highlight=' . $s_highlight_words;
                 }
             }
             $s_text = trim(trim(str_replace(', ,', ',', $s_text)), ' ,');
             $s_text = html(getCleanSubString($s_text, $this->search_wordlimit, $this->ellipse_sign, 'word'), false);
             if ($this->search_highlight) {
                 $s_text = highlightSearchResult($s_text, $this->search_highlight_words);
             }
             $this->search_results[$id]["text"] = $s_text;
             $this->search_results[$id]["image"] = false;
             if ($this->image_render && !empty($value['cnt_object']['cnt_image']['id'])) {
                 $value['cnt_object']['cnt_image'] = _dbGet('phpwcms_file', 'f_id AS `id`, f_hash AS `hash`, f_ext AS `ext`, f_name AS `name`', 'f_id=' . _dbEscape($value['cnt_object']['cnt_image']['id']) . ' AND f_trash=0 AND f_aktiv=1 AND f_public=1');
                 if (isset($value['cnt_object']['cnt_image'][0]['id'])) {
                     $this->search_results[$id]["image"] = $value['cnt_object']['cnt_image'][0];
                 }
             }
             $this->search_result_entry++;
         }
     }
 }
function make_cloud($matches)
{
    global $phpwcms, $content;
    // use $matches for
    // $rendermode,$which_ID,$setLP,$landing
    $rendermode = trim($matches[1]);
    $which_ID = trim($matches[2]);
    $setLP = trim($matches[3]);
    $landing = isset($matches[4]) ? intval($matches[4]) : 0;
    $conf =& $content['tagcloud'];
    // check integrity of user_settings --- else use defaults +++ OG new style
    if (empty($conf['min'])) {
        $conf['min'] = 4;
    }
    if (empty($conf['min_chars'])) {
        $conf['min_chars'] = 4;
    }
    if (!isset($conf['sort'])) {
        $conf['sort'] = false;
    }
    if (empty($conf['inc_or_ex'])) {
        $conf['inc_or_ex'] = 0;
    }
    // avoid php notice: undefined variable
    if (empty($allmyhds)) {
        $allmyhds = '';
    }
    if (empty($allmycps)) {
        $allmycps = '';
    }
    if (empty($at)) {
        $at = '';
    }
    if (empty($ast)) {
        $ast = '';
    }
    if (empty($asm)) {
        $asm = '';
    }
    // avoid php notice: undefined index
    //if(isset($conf['add_t'])) {$auswert_t = $conf['add_t'];}
    // NOW, FINALLY IT'S TIME TO LET A FRESH BREEZE BLOWING UP PRETTY CLOUDS
    if (!empty($landing)) {
        // check if landing page has an article alias ( only versions > 1.3.5  else use fallback )
        // original code has been deleted because +++ o-ton OG: "so geht es schneller"
        $landalias = _dbGet('phpwcms_article', 'article_alias', "article_id=" . $landing . " AND article_alias != ''");
        // "So muss weitermachen...". Hey, here we are:
        if (!empty($landalias[0]['article_alias'])) {
            $aliasfound = $landalias[0]['article_alias'];
        }
        // second BREEZE BLOWING
        if (!empty($setLP)) {
            switch ($setLP) {
                case 'L':
                    if (isset($aliasfound)) {
                        $landing = 'index.php?' . $aliasfound . '#';
                    } else {
                        $landing = 'index.php?aid=' . $landing . '#';
                        //fallback for older versions
                        //$old_style		$landing = 'index.php?id=0,'. $landing . ',0,0,1,0#'; //much older versions
                    }
                    break;
                case 'S':
                    if (isset($aliasfound)) {
                        $landing = 'index.php?' . $aliasfound . '&amp;searchwords=';
                    } else {
                        $landing = 'index.php?aid=' . $landing . '&amp;searchwords=';
                        //fallback for older versions
                        //$old_style		$landing = 'index.php?id=0,'. $landing . ',0,0,1,0&amp;searchwords='; //much older versions
                    }
                    break;
            }
        } else {
            $landing = 'index.php#';
            echo "TagCloud ERROR: Wrong setup of RT! MISSING --> (L) = Landing page OR --> (S) = Search page";
        }
    } else {
        //die("TagCloud ERROR: Article_ID of your (L)Landing Page or your (S)Search Page is missing!");
        echo "TagCloud ERROR: Wrong setup of RT! Article ID of (L) = Landing Page or (S) = Search Page MISSING!";
        $landing = 'index.php#';
    }
    switch ($rendermode) {
        case 'E':
            //exclude array stuff by marcus@localhorst
            $excludeid = explode(',', $which_ID);
            $struct = array_keys($content['struct']);
            $only_cat_id = array_diff($struct, $excludeid);
            break;
        case 'I':
            $only_cat_id = explode(',', $which_ID);
            break;
        default:
            echo "TagCloud ERROR: Rendermode not defined! (I) = match all articles withIN named categories or vice versa (E) = exclude categories!";
            break;
    }
    if (is_array($only_cat_id)) {
        foreach ($only_cat_id as $slid) {
            $sql = "SELECT SQL_CACHE article_id";
            if ($conf['add_t']) {
                $sql .= ",article_title";
            }
            if ($conf['add_st']) {
                $sql .= ",article_subtitle";
            }
            if ($conf['add_sm']) {
                $sql .= ",article_summary";
            }
            $sql .= " FROM " . DB_PREPEND . "phpwcms_article WHERE article_cid={$slid}";
            $sql .= " AND article_public=1 AND article_aktiv=1 AND article_deleted=0";
            $sql .= " AND article_begin < NOW() AND article_end > NOW()";
            $result = _dbQuery($sql);
            foreach ($result as $row) {
                $ai = $row['article_id'];
                if ($conf['add_t']) {
                    $at = $row['article_title'];
                }
                if ($conf['add_st']) {
                    $ast = $row['article_subtitle'];
                }
                if ($conf['add_sm']) {
                    $asm = $row['article_summary'];
                }
                $allmyhds .= $at . ' ' . $ast . ' ' . $asm . ' ';
                $sec_sql = "SELECT SQL_CACHE acontent_html";
                if ($conf['add_cpt']) {
                    $sec_sql .= ",acontent_title";
                }
                if ($conf['add_cpst']) {
                    $sec_sql .= ",acontent_subtitle";
                }
                if ($conf['add_cptximg']) {
                    $sec_sql .= ",acontent_text";
                }
                $sec_sql .= " FROM " . DB_PREPEND . "phpwcms_articlecontent WHERE acontent_aid={$ai}";
                $sec_sql .= " AND acontent_visible=1 AND acontent_trash=0";
                $scd_result = _dbQuery($sec_sql);
                foreach ($scd_result as $scd_row) {
                    $allmycps .= $scd_row['acontent_html'] . ' ';
                    if ($conf['add_cpt']) {
                        $allmycps .= $scd_row['acontent_title'] . ' ';
                    }
                    if ($conf['add_cpst']) {
                        $allmycps .= $scd_row['acontent_subtitle'] . ' ';
                    }
                    if ($conf['add_cptximg']) {
                        $allmycps .= $scd_row['acontent_text'] . ' ';
                    }
                }
            }
        }
        /*****************************************************************
         * JOIN ALL the text of content --> Titles, Summary, CPs
         *****************************************************************/
        $tagtext = $allmyhds . $allmycps;
        /*****************************************************************
         * add NEWS when set =1
         *****************************************************************/
        if ($conf['news_to_cloud'] == 1) {
            $news_sql = "SELECT SQL_CACHE cnt_title, ";
            $news_sql .= "cnt_subtitle, cnt_teasertext, cnt_text";
            $news_sql .= " FROM " . DB_PREPEND . "phpwcms_content WHERE cnt_status=1";
            $news_sql .= " AND cnt_livedate < NOW() AND cnt_killdate > NOW()";
            $news_result = _dbQuery($news_sql);
            foreach ($news_result as $news_row) {
                $newscontent .= $news_row['cnt_title'] . ' ';
                $newscontent .= $news_row['cnt_subtitle'] . ' ';
                $newscontent .= $news_row['cnt_teasertext'] . ' ';
                $newscontent .= $news_row['cnt_text'] . ' ';
            }
            //article content plus news
            $tagtext = $tagtext . $newscontent;
        }
        /*****************************************************************
        	and do some convertions
        	*****************************************************************/
        $tagtext = clean_replacement_tags($tagtext);
        $tagtext = stripped_cache_content($tagtext);
        //delete not wantend and then str_all to lower
        if (phpwcms_seems_utf8($tagtext)) {
            $tagtext = strtolower_utf8(str_replace($conf['del_signs'], '', $tagtext));
        } else {
            $tagtext = strtolower(str_replace($conf['del_signs'], '', $tagtext));
        }
        $tagtext = explode(' ', $tagtext);
        //split in separate words
        $anzahl = array_count_values($tagtext);
        //count the words -- into new array
        $tags = array();
        switch ($conf['inc_or_ex']) {
            case '0':
                foreach ($anzahl as $key => $tagword) {
                    if ($tagword >= $conf['min'] && !in_array($key, $conf['exclude'])) {
                        //look if the word counts the required minimum and is not in the exclude list
                        if (strlen($key) >= $conf['min_chars']) {
                            //ignore words on web site that are NOT longer than (chief inspector even longer) defined in: var min_chars
                            $tags[$key] = $tagword;
                            //put them in a new array
                        }
                        // else { $this_word_out[$key] = $tagword; }
                    }
                }
                break;
            case '1':
                foreach ($anzahl as $key => $tagword) {
                    if ($tagword >= $conf['min'] && in_array($key, $conf['include'])) {
                        //look if the word counts the required minimum and is not in the exclude list
                        if (strlen($key) >= $conf['min_chars']) {
                            //ignore words on web site that are NOT longer than (chief inspector even longer) defined in: var min_chars
                            $tags[$key] = $tagword;
                            //now put them in a new array
                        }
                        // else { $this_word_out[$key] = $tagword; }
                    }
                }
                break;
            default:
                break;
        }
        if (!empty($tags)) {
            //unset($tags['phpwcms']); //if you want to override the value of words (in this case 'phpwcms'), uncomment it and put in your word
            //$weight = count($tags);
            $max_hits = max($tags);
            //tag with most hits
            if (!empty($max_hits)) {
                //$tags['phpwcms']=8; // put in again your deleted word and value from 4 lines above
                switch ($conf['sort']) {
                    case 'asc':
                        ksort($tags);
                        //sort them alphabetically
                        break;
                    case 'desc':
                        krsort($tags);
                        //sort them reverse alphabetically
                        break;
                    case 'random':
                        $keys = array_keys($tags);
                        shuffle($keys);
                        $random_words = array();
                        foreach ($keys as $key) {
                            $random_words[$key] = $tags[$key];
                        }
                        $tags = $random_words;
                        break;
                    default:
                        break;
                }
                // FULL BLOWN CLOUDS LIKE HORNBLOWER
                $tag_cloud = '<div class="' . $conf['class'] . '">';
                foreach ($tags as $key => $tagword) {
                    $key = html_specialchars($key);
                    // new maths by Heiko H.
                    $percent = round(100 * $tagword / $max_hits, 0);
                    $size = ceil($percent / 10);
                    // prepare TC font size for CSS
                    $tag_cloud .= '<a class="tcfs' . $size . '" href="' . PHPWCMS_URL . $landing . urlencode($key) . '">' . $key . '</a>';
                    if ($conf['showCount']) {
                        $tag_cloud .= $conf['SC_before'] . $tagword . $conf['SC_after'];
                    }
                    $tag_cloud .= '	' . LF;
                }
                $tag_cloud .= '</div>';
            }
        }
    }
    return $tag_cloud;
}
Example #18
0
     $where .= "cat_name LIKE '%" . _dbEscape(preg_replace('/[^\\w\\- ]/', '', $value), false) . "%'";
     $result = _dbGet('phpwcms_categories', 'cat_name', $where, 'cat_name', 'cat_name', 20);
     if (isset($result[0])) {
         if ($jquery) {
             $data = $result;
         } else {
             foreach ($result as $value) {
                 $data[] = utf8_encode($value['cat_name']);
             }
         }
     }
     break;
 case 'newstags':
     $where = "cat_status=1 AND cat_type='news' AND ";
     $where .= "cat_name LIKE '%" . _dbEscape(preg_replace('/[^\\w\\- ]/', '', $value), false) . "%'";
     $result = _dbGet('phpwcms_categories', 'cat_name', $where, 'cat_name', 'cat_name', 20);
     if (isset($result[0])) {
         if ($jquery) {
             $data = $result;
         } else {
             foreach ($result as $value) {
                 $data[] = utf8_encode($value['cat_name']);
             }
         }
     }
     break;
 case 'lang':
     $data = is_array($phpwcms['allowed_lang']) && count($phpwcms['allowed_lang']) ? $phpwcms['allowed_lang'] : array($phpwcms['default_lang']);
     sort($data);
     break;
 case 'flush_image_cache':
         }
         if ($result) {
             update_cache();
             // set cache timeout = 0
             _dbSaveCategories($article["article_keyword"], 'article', $article["article_id"], ',');
             $update = isset($_POST['updatesubmit']) ? '&aktion=1' : '';
             headerRedirect(PHPWCMS_URL . 'phpwcms.php?do=articles&p=2&s=1' . $update . '&id=' . $article["article_id"]);
         }
     } else {
         set_status_message($BL['be_admin_usr_err'] . ': ' . implode(', ', $article_err), 'warning');
     }
 }
 // check if it is recommend to overwrite template defaults
 if (!isset($article["acat_overwrite"])) {
     if ($article['article_catid']) {
         $article["acat_overwrite"] = _dbGet('phpwcms_articlecat', 'acat_overwrite', 'acat_trash != 9 AND acat_id = ' . $article['article_catid'], '', '', 1);
         $article["acat_overwrite"] = empty($article["acat_overwrite"][0]['acat_overwrite']) ? '' : $article["acat_overwrite"][0]['acat_overwrite'];
     } elseif ($article['article_catid'] === 0 && !empty($indexpage['acat_overwrite'])) {
         $article["acat_overwrite"] = $indexpage['acat_overwrite'];
     } else {
         $article["acat_overwrite"] = '';
     }
 }
 // include template defaults which should be overwritten by custom settings
 if ($article["acat_overwrite"] && is_file(PHPWCMS_TEMPLATE . 'inc_settings/template_default/' . $article["acat_overwrite"])) {
     @(include PHPWCMS_TEMPLATE . 'inc_settings/template_default/' . $article["acat_overwrite"]);
 }
 // list mode
 if ((!isset($_GET["aktion"]) || !intval($_GET["aktion"])) && !isset($_GET['struct'])) {
     include_once PHPWCMS_ROOT . "/include/inc_tmpl/articlecontent.list.tmpl.php";
     $phpwcms['be_parse_lang_process'] = true;
Example #20
0
                 define('PHPWCMS_ALIAS', $alias);
                 $content['404error']['status'] = false;
             }
         }
     }
     if ($content['404error']['status']) {
         // ToDo: maybe Check against structure/article alias and redirect
         $content['404error']['where'] = sprintf('alias LIKE %s', _dbEscape($content['404error']['alias']));
         $content['404error']['alias'] = $content['404error']['redirect_url'];
     }
 } else {
     $content['404error']['where'] = sprintf('id=%d AND aid=%d AND alias LIKE %s', $content['404error']['id'], $content['404error']['aid'], _dbEscape($content['404error']['alias']));
 }
 if ($content['404error']['status']) {
     // does the combination still exists in the database
     $content['404error']['result'] = _dbGet('phpwcms_redirect', '*', $content['404error']['where']);
     if (isset($content['404error']['result'][0])) {
         $content['404error']['result'] = $content['404error']['result'][0];
         _dbUpdate('phpwcms_redirect', array('views' => intval($content['404error']['result']['views']) + 1), 'rid=' . $content['404error']['result']['rid']);
         // Test for redirect
         if ($content['404error']['result']['active'] == 1) {
             // HTTP Status
             // 301, 302 (default), 307, 401, 404, 503
             $content['404error']['result']['code'] = empty($content['404error']['result']['code']) ? 302 : intval($content['404error']['result']['code']);
             // Redirect to Home
             // home (empty), alias, id, aid, link
             if (empty($content['404error']['result']['type'])) {
                 $content['404error']['result']['target'] = getStructureChildEntryHref($content['struct'][0]);
                 $content['404error']['result']['target'] = PHPWCMS_URL . $content['404error']['result']['target']['link'];
                 headerRedirect($content['404error']['result']['target'], $content['404error']['result']['code']);
             } elseif ($content['404error']['result']['target']) {
             case 'url_unsubscribe':
                 $newletter_array['url_unsubscribe'] = $newsletter[1];
                 break;
             case 'double_optin':
                 $newletter_array['double_optin'] = intval($newsletter[1]) ? 1 : 0;
                 break;
             case 'optin_template':
                 $newletter_array['optin_template'] = $newsletter[1];
                 break;
             case 'subject':
                 $newletter_array['subject'] = $newsletter[1];
                 break;
             default:
                 if (intval($newsletter[0])) {
                     $newsletter[0] = intval($newsletter[0]);
                     $query = _dbGet('phpwcms_subscription', '*', 'subscription_id=' . $newsletter[0] . ' AND subscription_active=1');
                     if (isset($query[0])) {
                         if ($newsletter[1] == '') {
                             $newsletter[1] = $query[0]['subscription_name'];
                         }
                         $newletter_array[$newsletter[0]] = $newsletter[1];
                     } else {
                         continue;
                     }
                 } else {
                     continue;
                 }
         }
     }
 }
 $content['form']["fields"][$field_counter]['value'] = '';
Example #22
0
 if (!empty($feedimport_result['cnt_object']['image_url_replace'])) {
     $feedimport_result['cnt_object']['image_url_replace'] = explode('>', $feedimport_result['cnt_object']['image_url_replace']);
     $feedimport_result['cnt_object']['image_url_replace'][0] = trim(trim($feedimport_result['cnt_object']['image_url_replace'][0]), '"');
     if (isset($feedimport_result['cnt_object']['image_url_replace'][1])) {
         $feedimport_result['cnt_object']['image_url_replace'][1] = trim(trim($feedimport_result['cnt_object']['image_url_replace'][1]), '"');
     }
 } else {
     $feedimport_result['cnt_object']['image_url_replace'] = array(0 => '', 1 => '');
 }
 if (empty($feedimport_result['cnt_object']['image_folder_id'])) {
     $feedimport_result['cnt_object']['image_folder_id'] = 0;
 }
 // need some additional functions
 include_once PHPWCMS_ROOT . '/include/inc_lib/backend.functions.inc.php';
 // set import sort counter
 $article_sort_counter = _dbGet('phpwcms_article', 'article_sort', 'article_cid=' . _dbEscape($feedimport_result['cnt_object']['structure_level_id']), '', 'article_sort DESC', 1);
 if (isset($article_sort_counter[0])) {
     $article_sort_counter = $article_sort_counter[0]['article_sort'] + 10;
 } else {
     $article_sort_counter = 100;
 }
 foreach ($rss_obj->get_items() as $rssvalue) {
     $article_unique_hash = md5($feedimport_result['cnt_text'] . $rssvalue->get_title() . $rssvalue->get_date('U'));
     // check against crossreference table
     $sql = 'SELECT * FROM ' . DB_PREPEND . 'phpwcms_crossreference c ';
     $sql .= 'LEFT JOIN ' . DB_PREPEND . 'phpwcms_article a ';
     $sql .= 'ON c.cref_rid=a.article_id ';
     $sql .= "WHERE c.cref_type='feed_to_article_import' AND c.cref_str=" . _dbEscape('feedimport_' . $article_unique_hash) . ' AND ';
     $sql .= 'a.article_deleted=0 LIMIT 1';
     if (_dbQuery($sql, 'COUNT') > 0) {
         continue;
Example #23
0
function phpwcms_revision_r514()
{
    $status = true;
    // do former revision check – fallback to r509
    if (phpwcms_revision_check_temp('509') !== true) {
        $status = phpwcms_revision_check('509');
    }
    // Delete
    // empty temp images table
    _dbQuery('DROP TABLE IF EXISTS ' . DB_PREPEND . 'phpwcms_imgcache', 'DROP');
    // empty temp images directory
    $thumbnails = returnFileListAsArray(PHPWCMS_THUMB, 'jpg,jpeg,gif,png');
    if (is_array($thumbnails) && count($thumbnails)) {
        foreach ($thumbnails as $thumbnail) {
            @unlink(PHPWCMS_THUMB . $thumbnail['filename']);
        }
    }
    // Set file hash
    $result = _dbQuery("SHOW FIELDS FROM " . DB_PREPEND . "phpwcms_file WHERE Field='f_hash'");
    if ($status && !empty($result[0])) {
        // Remove unused fields but only when file storage upgrade from earlier update is done
        $count = _dbQuery("SHOW COLUMNS FROM " . DB_PREPEND . "phpwcms_file LIKE 'f_thumb_%'", 'COUNT_SHOW');
        if ($count === 2) {
            $count = _dbCount("SELECT * FROM " . DB_PREPEND . "phpwcms_file WHERE f_thumb_list != '' OR f_thumb_preview != ''");
            if ($count === 0) {
                _dbQuery("ALTER TABLE " . DB_PREPEND . "phpwcms_file DROP f_thumb_list", 'ALTER');
                _dbQuery("ALTER TABLE " . DB_PREPEND . "phpwcms_file DROP f_thumb_preview", 'ALTER');
                $status = true;
            } else {
                $status = false;
            }
        }
        $result = array_change_key_case($result[0], CASE_LOWER);
        if ($status && $result['type'] == 'varchar(50)') {
            $status = _dbQuery("ALTER TABLE " . DB_PREPEND . "phpwcms_file CHANGE f_hash f_hash VARCHAR(255) NOT NULL DEFAULT ''", 'ALTER');
            // ensure all went well
            if ($status) {
                $result = _dbQuery("SHOW FIELDS FROM " . DB_PREPEND . "phpwcms_file WHERE Field='f_hash'");
                $status = false;
                if (!empty($result[0])) {
                    $result = array_change_key_case($result[0], CASE_LOWER);
                    if ($result['type'] == 'varchar(255)') {
                        $status = true;
                    }
                }
            }
        }
        // Rename Hash and files
        if ($status) {
            // Cleanup first — Check all files trashed or deleted and not yet physical accessible anymore
            $files = _dbGet('phpwcms_file', '*', 'f_trash IN (8,9) AND f_kid=1');
            if (isset($files[0]['f_id'])) {
                write_textfile(PHPWCMS_STORAGE . 'phpwcms-filestorage.log', date('Y-m-d H:i:s') . ': Prepare removing non-existing, trashed or deleted files from phpwcms_file database table' . LF, 'a');
                $file_id = array();
                foreach ($files as $file) {
                    $file['storage_name'] = $file['f_hash'];
                    if ($file['f_ext']) {
                        $file['storage_name'] .= '.' . $file['f_ext'];
                    }
                    if (!is_file(PHPWCMS_STORAGE . $file['storage_name'])) {
                        write_textfile(PHPWCMS_STORAGE . 'phpwcms-filestorage.log', date('Y-m-d H:i:s') . ': ' . json_encode($file) . LF, 'a');
                        $file_id[] = $file['f_id'];
                    }
                }
                $file_id = implode(',', $file_id);
                write_textfile(PHPWCMS_STORAGE . 'phpwcms-filestorage.log', date('Y-m-d H:i:s') . ': File IDs to be deleted (' . $file_id . ')', 'a');
                if ($file_id) {
                    $result = _dbQuery('DELETE FROM ' . DB_PREPEND . 'phpwcms_file WHERE f_trash IN (8,9) AND f_kid=1 AND f_id IN (' . $file_id . ')', 'DELETE');
                    if (!empty($result['AFFECTED_ROWS'])) {
                        write_textfile(PHPWCMS_STORAGE . 'phpwcms-filestorage.log', ' // DONE: ' . $result['AFFECTED_ROWS'] . ' deleted', 'a');
                    } else {
                        write_textfile(PHPWCMS_STORAGE . 'phpwcms-filestorage.log', ' // DONE: None deleted', 'a');
                    }
                }
                write_textfile(PHPWCMS_STORAGE . 'phpwcms-filestorage.log', LF . LF . '---' . LF . LF, 'a');
            }
            // ToDo: implement new naming
        }
    } else {
        $status = false;
    }
    return $status;
}