コード例 #1
0
ファイル: functions.php プロジェクト: nak9x/WCF
function ImportFeed($type)
{
    $url = '';
    $table = '';
    switch ($type) {
        case 'news':
            $url = NEWS_URL;
            $table = 'stock_news';
            break;
        case 'expert':
            $url = EXPERT_URL;
            $table = 'stock_expert_analysis';
            break;
    }
    $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
    $rssFile = GetFeed($url);
    if ($rssFile != null) {
        foreach ($rssFile->channel->item as $rssItem) {
            $query = "insert into " . $table . " (title, pub_date, description, link) values ";
            $query = $query . "(N'" . mysqli_real_escape_string($dbc, $rssItem->title) . "',";
            $query = $query . "STR_TO_DATE('" . $rssItem->pubDate . "', '%a, %d %b %Y %H:%i:%s GMT'),N'";
            $query = $query . mysqli_real_escape_string($dbc, $rssItem->description) . "','";
            $query = $query . mysqli_real_escape_string($dbc, $rssItem->link) . "')";
            mysqli_query($dbc, $query);
        }
        mysqli_close($dbc);
    }
}
コード例 #2
0
ファイル: campaigns-rss.php プロジェクト: 5haman/Sendy
//Get brand name
$q = "SELECT app_key, app_name FROM apps WHERE id = '{$i}'";
$r = mysqli_query($mysqli, $q);
if ($r && mysqli_num_rows($r) > 0) {
    while ($row = mysqli_fetch_array($r)) {
        $app_key = $row['app_key'];
        $brand_name = $row['app_name'];
    }
}
//Exit if app_key is incorrect
if ($app_key != $a) {
    exit;
}
//spit out RSS
header("Content-Type: application/xml; charset=UTF-8");
echo GetFeed();
function GetFeed()
{
    return getDetails() . getItems();
}
function getDetails()
{
    global $brand_name;
    global $a;
    global $i;
    $details = '<?xml version="1.0" encoding="utf-8"?>
					<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
					<channel>
					<title>' . $brand_name . ' - ' . _('Campaigns RSS') . '</title>
					<description>RSS feed archive of the last 100 campaigns sent by ' . $brand_name . '.</description>
					<language>en</language>
コード例 #3
0
function Xml2Array($url)
{
    //gets a feed url and returns an array with xml items
    $xml = GetFeed($url);
    $array = CreateItemList($xml);
    return $array;
}