Exemple #1
0
			<title>' . $item_title . '</title>
			<description>' . $item_description . '</description>
			' . $item_body . '
			<link>' . $item['link'] . '</link>';
    // some additional entries for podcasts
    if ($_GET['feed'] == 'podcast') {
        echo "\n\t\t\t<itunes:author>" . $item['author_name'] . "</itunes:author>\n\t\t\t<dc:creator>" . $item['author_name'] . "</dc:creator>";
        if (!empty($item['seo_keywords'])) {
            echo '
			<itunes:keywords>' . $item['seo_keywords'] . '</itunes:keywords>';
        }
        // add enclosure
        echo "\n\t\t\t<enclosure url=\"" . $item['itunes_link'] . "\" length=\"" . $item['size'] . "\" type=\"" . $item['mime'] . "\"/>";
    } else {
        // check for attachments
        $attachments = get_article_attachments($item['id']);
        if (!empty($attachments)) {
            foreach ($attachments as $attach) {
                // if this is a podcast feed we need to include the filename to trick itunes
                $url = $_GET['feed'] == 'podcast' ? $attach['itunes_link'] : $attach['link'];
                // show enclosure
                echo "\n\t\t\t\t\t<enclosure url=\"" . $url . "\" length=\"" . $attach['size'] . "\" type=\"" . $attach['mime'] . "\"/>";
            }
        }
    }
    // close off item
    echo "\n\t\t\t<guid isPermaLink=\"true\">" . $item['link'] . "</guid> \n\t\t\t<pubDate>" . $item_date . "</pubDate>\n\t\t</item>";
}
// close xml feed
echo '
	</channel>
/**
 * get_article
 * 
 * 
 * 
 * 
 * 
 * 
 */
function get_article($article_id = '')
{
    $article_id = (int) $article_id;
    $conn = reader_connect();
    $query = "SELECT\n\t\t\t\t\tarticles.id, \n\t\t\t\t \tarticles.title, \n\t\t\t\t\tarticles.url, \n\t\t\t\t\tarticles.summary, \n\t\t\t\t\tarticles.body, \n\t\t\t\t\tarticles.date_uploaded, \n\t\t\t\t\tarticles.date_amended,\n\t\t\t\t\tcategories.title AS category_title, \n\t\t\t\t\tcategories.url AS category_url,\n\t\t\t\t\tparent.title AS parent_category_title,\n\t\t\t\t\tparent.url AS parent_category_url,\n\t\t\t\t\tauthors.name AS author_name, \n\t\t\t\t\tauthors.url AS author_url,\n\t\t\t\t\tauthors.email AS author_email,\n\t\t\t\t\tauthors.contact_flag, \n\t\t\t\t\tarticles.seo_title,\n\t\t\t\t\tarticles.seo_desc, \n\t\t\t\t\tarticles.seo_keywords,\n\t\t\t\t\tarticles.comments_disable, \n\t\t\t\t\tarticles.comments_hide\n\t\t\t\tFROM articles\n\t\t\t\t\tLEFT JOIN authors ON articles.author_id = authors.id \n\t\t\t\t\tLEFT JOIN categories ON articles.category_id = categories.id\n\t\t\t\t\tLEFT JOIN categories AS parent ON categories.category_id = parent.id\n\t\t\t\tWHERE articles.status IN('P','A')\n\t\t\t\t\tAND articles.date_uploaded <= NOW()";
    $query .= !empty($article_id) ? " AND articles.id = " . $article_id : " ORDER BY articles.id DESC LIMIT 0,1";
    // echo $query;
    $result = $conn->query($query);
    $row = $result->fetch_assoc();
    $row = stripslashes_deep($row);
    $result->close();
    // fix relative urls
    $row['body'] = convert_relative_urls($row['body']);
    // check pagination
    $row['pages'] = paginate_article_body($row['body']);
    $row['total_pages'] = count($row['pages']);
    // create links
    $row['link']['blog'] = WW_REAL_WEB_ROOT . '/' . date('Y/m/d', strtotime($row['date_uploaded'])) . '/' . $row['url'] . '/';
    $row['link']['cms'] = WW_REAL_WEB_ROOT . '/' . $row['category_url'] . '/' . $row['url'] . '/';
    // get tags
    $tags = get_article_tags($article_id);
    $row['tags'] = !empty($tags) ? $tags : '';
    // get attachments
    $attachments = get_article_attachments($article_id);
    $row['attachments'] = !empty($attachments) ? $attachments : '';
    // get comments
    if (empty($row['comments_hide'])) {
        $comments = get_article_comments($article_id);
        $row['comments'] = !empty($comments) ? $comments : '';
    }
    return $row;
}
/**
 * get_article_form_data
 * 
 * 
 * 
 * 
 * 
 * 
 */
function get_article_form_data()
{
    $article_data = array();
    if (!empty($_GET['article_id'])) {
        // editing an article
        $article_id = (int) $_GET['article_id'];
        $article_data = get_article_admin($article_id);
        $article_data = stripslashes_deep($article_data);
        // date fields - probably don't need these
        /*
        $article_data['day'] 	= date('d',$article_data['date_ts']);
        $article_data['month'] 	= date('m',$article_data['date_ts']);
        $article_data['year'] 	= date('Y',$article_data['date_ts']);
        $article_data['hour'] 	= date('H',$article_data['date_ts']);
        $article_data['minute'] = date('i',$article_data['date_ts']);
        */
        // tags
        $article_data['tags'] = get_article_tags_admin($article_id);
        // attachments
        $article_data['attachments'] = get_article_attachments($article_id);
    } else {
        // brand new article
        // get default comments config from database
        $config = get_settings('comments');
        $article_data['id'] = 0;
        $article_data['title'] = 'New article';
        $article_data['url'] = '';
        $article_data['summary'] = '';
        $article_data['body'] = '';
        $article_data['status'] = 'D';
        $article_data['author_id'] = $_SESSION[WW_SESS]['user_id'];
        $article_data['category_id'] = 0;
        $article_data['category_url'] = '';
        $article_data['tags'] = array();
        $article_data['attachments'] = array();
        $article_data['seo_title'] = '';
        $article_data['seo_desc'] = '';
        $article_data['seo_keywords'] = '';
        $article_data['comments_hide'] = $config['comments']['site_hide'];
        $article_data['comments_disable'] = $config['comments']['site_disable'];
        // $now = strtotime(get_mysql_time());
        $now = time();
        $article_data['day'] = date('d', $now);
        $article_data['month'] = date('m', $now);
        $article_data['year'] = date('Y', $now);
        $article_data['hour'] = date('H', $now);
        $article_data['minute'] = date('i', $now);
    }
    return $article_data;
}
/**
 * get_article
 * 
 * 
 * 
 * 
 * 
 * 
 */
function get_article($article_id = '')
{
    $article_id = (int) $article_id;
    $conn = reader_connect();
    $query = "SELECT\n\t\t\t\t\tarticles.id, \n\t\t\t\t \tarticles.title, \n\t\t\t\t\tarticles.url, \n\t\t\t\t\tarticles.summary, \n\t\t\t\t\tarticles.body, \n\t\t\t\t\tarticles.date_uploaded, \n\t\t\t\t\tarticles.date_amended,\n\t\t\t\t\tcategories.title AS category_title, \n\t\t\t\t\tcategories.url AS category_url,\n\t\t\t\t\tparent.title AS parent_category_title,\n\t\t\t\t\tparent.url AS parent_category_url,\n\t\t\t\t\tauthors.name AS author_name, \n\t\t\t\t\tauthors.url AS author_url,\n\t\t\t\t\tauthors.email AS author_email,\n\t\t\t\t\tauthors.contact_flag, \n\t\t\t\t\tarticles.seo_title,\n\t\t\t\t\tarticles.seo_desc, \n\t\t\t\t\tarticles.seo_keywords,\n\t\t\t\t\tarticles.redirect_url,\n\t\t\t\t\tarticles.redirect_code,\n\t\t\t\t\tarticles.comments_disable, \n\t\t\t\t\tarticles.comments_hide\n\t\t\t\tFROM articles\n\t\t\t\t\tLEFT JOIN authors ON articles.author_id = authors.id \n\t\t\t\t\tLEFT JOIN categories ON articles.category_id = categories.id\n\t\t\t\t\tLEFT JOIN categories AS parent ON categories.category_id = parent.id\n\t\t\t\tWHERE articles.status IN('P','A')\n\t\t\t\t\tAND articles.date_uploaded <= UTC_TIMESTAMP()";
    $query .= !empty($article_id) ? " AND articles.id = " . $article_id : " ORDER BY articles.id DESC LIMIT 0,1";
    $result = $conn->query($query);
    $row = $result->fetch_assoc();
    // if a redirect url has been set we redirect right here
    if (!empty($row['redirect_url'])) {
        // send 301 redirect unless another valid code has been set
        $redirect_code = (int) $row['redirect_code'];
        $redirect_code = !empty($redirect_code) ? $redirect_code : 301;
        redirect_article($row['redirect_url'], $redirect_code);
    }
    $row = stripslashes_deep($row);
    $result->close();
    // adjust times to local timezone if necessary
    $ts = strtotime($row['date_uploaded']);
    $offset = date('Z');
    $row['date_ts'] = $ts + $offset;
    $row['date_uploaded'] = date('Y-m-d H:i:s', $row['date_ts']);
    // fix relative urls
    $row['body'] = convert_relative_urls($row['body']);
    // check pagination
    $row['pages'] = paginate_article_body($row['body']);
    $row['total_pages'] = count($row['pages']);
    // create links
    $row['link']['blog'] = WW_REAL_WEB_ROOT . '/' . date('Y/m/d', $row['date_ts']) . '/' . $row['url'] . '/';
    $row['link']['cms'] = WW_REAL_WEB_ROOT . '/' . $row['category_url'] . '/' . $row['url'] . '/';
    // put category url in a get param if not set (for custom css styles)
    $_GET['category_url'] = isset($_GET['category_url']) ? $_GET['category_url'] : $row['category_url'];
    // get tags
    $tags = get_article_tags($article_id);
    $row['tags'] = !empty($tags) ? $tags : '';
    // get attachments
    $attachments = get_article_attachments($article_id);
    $row['attachments'] = !empty($attachments) ? $attachments : '';
    // get comments
    if (empty($row['comments_hide'])) {
        $comments = get_article_comments($article_id);
        $row['comments'] = !empty($comments) ? $comments : '';
    }
    return $row;
}