} 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; } $article_title = html_entity_decode($rssvalue->get_title(), ENT_COMPAT, PHPWCMS_CHARSET); $article_alias = proof_alias(0, $article_title, 'ARTICLE'); $article_begin = $rssvalue->get_date('U'); $article_end = now() + 3600 * 24 * 365 * 10; $article_summary = $rssvalue->get_description(); $article_content = $rssvalue->get_content(); $article_description = preg_replace('/\\s+/', ' ', html_entity_decode(strip_tags($article_summary), ENT_COMPAT, PHPWCMS_CHARSET)); list($article_description) = explode("\n", wordwrap($article_description, 250), 2); list($article_description) = explode("-- ", $article_description, 2); $article_description = preg_replace('/(.*?\\.).+?$/', '$1', $article_description); $article_author = $rssvalue->get_author(); if ($article_author) { $article_author = html_entity_decode($article_author->get_name(), ENT_COMPAT, PHPWCMS_CHARSET); } else { $article_author = $feedimport_result['cnt_object']['author_name']; } if ($article_summary && $article_content && $article_summary == $article_content) {
$article['image']['list_name'] = ''; $article['image']['list_id'] = 0; $article['image']['list_width'] = ''; $article['image']['list_height'] = ''; $article['image']['list_zoom'] = 0; $article['image']['list_caption'] = ''; $article["image"]["list_hash"] = ''; $article['image']['zoom'] = 0; $set_begin = 0; $set_end = 0; } else { // Take article Post data $article_err = array(); $article["article_catid"] = intval($_POST["article_cid"]); $article["article_title"] = clean_slweg($_POST["article_title"], 255); $article["article_alias"] = proof_alias($article["article_id"], $_POST["article_alias"], 'ARTICLE'); $article["article_subtitle"] = clean_slweg($_POST["article_subtitle"], 255); $article["article_menutitle"] = clean_slweg($_POST["article_menutitle"], 255); $article["article_description"] = clean_slweg($_POST["article_description"]); $article["article_summary"] = str_replace('<p></p>', '<p> </p>', slweg($_POST["article_summary"])); $article["article_notitle"] = isset($_POST["article_notitle"]) ? 1 : 0; $article["article_hidesummary"] = isset($_POST["article_hidesummary"]) ? 1 : 0; $article["article_aktiv"] = isset($_POST["article_aktiv"]) ? 1 : 0; $article["article_begin"] = clean_slweg($_POST["article_begin"]); $article["article_end"] = clean_slweg($_POST["article_end"]); $article["article_keyword"] = implode(', ', convertStringToArray(clean_slweg($_POST["article_keyword"]), ',')); $article["article_lang"] = isset($_POST["article_lang"]) ? clean_slweg($_POST["article_lang"]) : ''; $article['article_lang_type'] = $article["article_lang"] == '' || empty($_POST["article_lang_type"]) ? '' : in_array($_POST["article_lang_type"], array('category', 'article')) ? $_POST["article_lang_type"] : ''; $article['article_lang_id'] = $article['article_lang_type'] == '' || empty($_POST["article_lang_id"]) ? 0 : intval($_POST["article_lang_id"]); $article["article_redirect"] = clean_slweg($_POST["article_redirect"]); $set_begin = isset($_POST["set_begin"]) ? 1 : 0;
$phpwcms = array(); require_once '../include/config/conf.inc.php'; require_once '../include/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'; require_once PHPWCMS_ROOT . '/include/inc_lib/backend.functions.inc.php'; ?> <html> <body> <h3>Upgrade article alias</h3> <?php // get all articles if ($all = _dbQuery("SELECT article_id, article_alias, article_title FROM " . DB_PREPEND . "phpwcms_article WHERE article_deleted != 9")) { foreach ($all as $key => $value) { $alias = empty($value['article_alias']) ? $value['article_title'] : $value['article_alias']; $alias = proof_alias($value['article_id'], $alias, 'ARTICLE'); if ($alias != $value['article_alias']) { $sql = "UPDATE " . DB_PREPEND . "phpwcms_article SET "; $sql .= "article_alias = '" . aporeplace($alias) . "' "; $sql .= "WHERE article_id = " . $value['article_id'] . " LIMIT 1"; $result = _dbQuery($sql, 'UPDATE'); echo '<pre'; if ($result === false) { echo ' style="color:#CC3300"'; } echo '>[ID:' . sprintf('%04s', $all[$key]['article_id']) . '] '; if (!empty($value['article_alias'])) { echo ' OLD ALIAS: ' . html_specialchars($value['article_alias']) . ' '; } echo html_specialchars('-> NEW ALIAS: ' . $alias . ', TITLE: ' . $value['article_title']); echo '</pre>' . LF;
function copy_level_to_level($do, $dbcon) { // $do[1] -- copy level // $do[2] -- paste level // $do[3] -- sort Number $sql = "SELECT * FROM " . DB_PREPEND . "phpwcms_articlecat WHERE acat_trash=0 AND acat_id=" . $do[1]; if ($result = mysql_query($sql, $dbcon) or die("error while connecting to database: <br><pre>" . $sql . "</pre>")) { if ($row = mysql_fetch_assoc($result)) { $row["acat_struct"] = $do[2]; $row["acat_sort"] = $do[3]; $row["acat_alias"] = proof_alias(0, empty($row["acat_alias"]) ? $row['acat_name'] : $row["acat_alias"], 'CATEGORY'); foreach ($row as $key => $value) { if ($key == "acat_id") { $keys = $key; $values = "''"; } else { $keys .= ", " . $key; $values .= ", " . _dbEscape($value); } } } mysql_free_result($result); $sql = "INSERT INTO " . DB_PREPEND . "phpwcms_articlecat (" . $keys . ") VALUES (" . $values . ")"; mysql_query($sql, $dbcon); $acat_insert_id = mysql_insert_id($dbcon); } $sql = "SELECT article_id FROM " . DB_PREPEND . "phpwcms_article WHERE article_deleted=0 AND article_cid=" . $do[1]; if ($result = mysql_query($sql, $dbcon)) { while ($row = mysql_fetch_row($result)) { $do_article[1] = $row[0]; $do_article[2] = $acat_insert_id; copy_article_to_level($do_article, $dbcon); } mysql_free_result($result); } $sql = "SELECT acat_id,acat_sort FROM " . DB_PREPEND . "phpwcms_articlecat WHERE acat_trash=0 AND acat_struct=" . $do[1]; if ($result = mysql_query($sql, $dbcon)) { while ($row = mysql_fetch_row($result)) { $do_struct[1] = $row[0]; $do_struct[2] = $acat_insert_id; $do_struct[3] = $row[1]; copy_level_to_level($do_struct, $dbcon); } mysql_free_result($result); } }
function getPostData() { $post = array(); // do only when news ID is known if ($this->newsId == 0) { $post['cnt_created'] = now(); } $post['cnt_pid'] = 0; $post['cnt_type'] = ''; $post['cnt_module'] = 'news'; $post['cnt_changed'] = time(); $post['cnt_status'] = empty($_POST['cnt_status']) ? 0 : 1; $post['cnt_archive_status'] = empty($_POST['cnt_archive_status']) ? 0 : 1; $post['cnt_prio'] = empty($_POST['cnt_prio']) ? 0 : intval($_POST['cnt_prio']); $temp_time = isset($_POST['calendar_start_time']) ? _getTime($_POST['calendar_start_time']) : ''; $temp_date = isset($_POST['calendar_start_date']) ? _getDate($_POST['calendar_start_date']) : ''; $post['cnt_livedate'] = $temp_date . ' ' . $temp_time; $temp_time = isset($_POST['calendar_end_time']) ? _getTime($_POST['calendar_end_time']) : ''; $temp_date = isset($_POST['calendar_end_date']) ? _getDate($_POST['calendar_end_date']) : ''; $post['cnt_killdate'] = $temp_date . ' ' . $temp_time; $temp_time = isset($_POST['sort_time']) ? _getTime($_POST['sort_time']) : ''; $temp_date = isset($_POST['sort_date']) ? _getDate($_POST['sort_date']) : ''; $post['cnt_sort'] = intval(strtotime($temp_date . ' ' . $temp_time)); $post['cnt_name'] = isset($_POST['cnt_name']) ? clean_slweg($_POST['cnt_name']) : ''; $post['cnt_title'] = isset($_POST['cnt_title']) ? clean_slweg($_POST['cnt_title']) : ''; if ($post['cnt_name'] == '' && $post['cnt_title'] != '') { $post['cnt_name'] = $post['cnt_title']; } elseif ($post['cnt_name'] != '' && $post['cnt_title'] == '') { $post['cnt_title'] = $post['cnt_name']; } $post['cnt_alias'] = isset($_POST['cnt_alias']) ? clean_slweg($_POST['cnt_alias']) : ''; if (empty($this->phpwcms['allow_empty_alias']) && $post['cnt_alias'] == '') { $post['cnt_alias'] = empty($post['cnt_title']) ? $post['cnt_name'] : $post['cnt_title']; } $post['cnt_alias'] = proof_alias($this->newsId, $post['cnt_alias'], 'CONTENT'); $post['cnt_subtitle'] = isset($_POST['cnt_subtitle']) ? clean_slweg($_POST['cnt_subtitle']) : ''; $post['cnt_editor'] = isset($_POST['cnt_editor']) ? clean_slweg($_POST['cnt_editor']) : ''; $post['cnt_place'] = isset($_POST['cnt_place']) ? clean_slweg($_POST['cnt_place']) : ''; $post['cnt_teasertext'] = isset($_POST['cnt_teasertext']) ? clean_slweg($_POST['cnt_teasertext']) : ''; $post['cnt_text'] = isset($_POST['cnt_text']) ? slweg($_POST['cnt_text']) : ''; $category = isset($_POST['cnt_category']) ? decode_entities(clean_slweg($_POST['cnt_category'])) : ''; $category = trim(trim(preg_replace('/\\s+/', ' ', $category), ',')); $post['cnt_lang'] = isset($_POST['cnt_lang']) ? preg_replace('/[^a-z\\-]/', '', strtolower($_POST['cnt_lang'])) : ''; $post['cnt_opengraph'] = empty($_POST['cnt_opengraph']) ? 0 : 1; $post['cnt_object'] = array('cnt_image' => array('id' => isset($_POST['cnt_image_id']) ? intval($_POST['cnt_image_id']) : '', 'name' => isset($_POST['cnt_image_name']) ? clean_slweg($_POST['cnt_image_name']) : '', 'zoom' => empty($_POST['cnt_image_zoom']) ? 0 : 1, 'lightbox' => empty($_POST['cnt_image_lightbox']) ? 0 : 1, 'caption' => isset($_POST['cnt_image_caption']) ? clean_slweg($_POST['cnt_image_caption']) : '', 'link' => isset($_POST['cnt_image_link']) ? clean_slweg($_POST['cnt_image_link']) : ''), 'cnt_files' => array('id' => isset($_POST['cnt_files']) && is_array($_POST['cnt_files']) && count($_POST['cnt_files']) ? $_POST['cnt_files'] : array(), 'caption' => isset($_POST['cnt_file_caption']) ? clean_slweg($_POST['cnt_file_caption'], 0, false) : '', 'gallery' => empty($_POST['cnt_file_gallery']) ? 0 : 1, 'gallery_download' => empty($_POST['cnt_file_gallery_download']) ? 0 : 1), 'cnt_link' => isset($_POST['cnt_link']) ? clean_slweg($_POST['cnt_link']) : '', 'cnt_linktext' => isset($_POST['cnt_linktext']) ? clean_slweg($_POST['cnt_linktext']) : '', 'cnt_category' => $category, 'cnt_readmore' => empty($_POST['cnt_readmore']) ? 0 : 1, 'cnt_textformat' => isset($_POST['cnt_textformat']) ? clean_slweg($_POST['cnt_textformat']) : 'plain', 'cnt_searchoff' => empty($_POST['cnt_searchoff']) ? 0 : 1); return $post; }