當前位置: 首頁>>代碼示例>>PHP>>正文


PHP magpie_error函數代碼示例

本文整理匯總了PHP中magpie_error函數的典型用法代碼示例。如果您正苦於以下問題:PHP magpie_error函數的具體用法?PHP magpie_error怎麽用?PHP magpie_error使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了magpie_error函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: perform

 /**
  * Perform on the action call
  *
  * @param mixed $data Data passed to this action
  */
 public function perform($data = FALSE)
 {
     if (!defined('MAGPIE_OUTPUT_ENCODING')) {
         if (isset($data['encoding'])) {
             define('MAGPIE_OUTPUT_ENCODING', $data['encoding']);
         }
     }
     if (isset($data['cache_time'])) {
         define('MAGPIE_CACHE_ON', TRUE);
         define('MAGPIE_CACHE_AGE', (int) $data['cache_time']);
         define('MAGPIE_CACHE_DIR', SMART_BASE_DIR . 'data/common/rss_cache');
     }
     if (!($rss = fetch_rss($data['url']))) {
         trigger_error('Rss feed not available: ' . magpie_error(), E_USER_WARNING);
         $data['result']['items'] = array();
         $data['result']['channel'] = array();
         $data['result']['image'] = array();
         $data['result']['textinput'] = array();
         return;
     }
     $data['result']['items'] = $rss->items;
     $data['result']['channel'] = $rss->channel;
     $data['result']['image'] = $rss->image;
     $data['result']['textinput'] = $rss->textinput;
 }
開發者ID:BackupTheBerlios,項目名稱:smart-svn,代碼行數:30,代碼來源:ActionCommonRssFetch.php

示例2: handleJSON_getContent

 function handleJSON_getContent($smarty, $module_name, $appletlist)
 {
     $respuesta = array('status' => 'success', 'message' => '(no message)');
     define('MAGPIE_CACHE_DIR', '/tmp/rss-cache');
     define('MAGPIE_OUTPUT_ENCODING', 'UTF-8');
     $infoRSS = @fetch_rss('http://elastix.org/index.php?option=com_mediarss&feed_id=1&format=raw');
     $sMensaje = magpie_error();
     if (strpos($sMensaje, 'HTTP Error: connection failed') !== FALSE) {
         $respuesta['status'] = 'error';
         $respuesta['message'] = _tr('Could not get web server information. You may not have internet access or the web server is down');
     } else {
         // Formato de fecha y hora
         for ($i = 0; $i < count($infoRSS->items); $i++) {
             $infoRSS->items[$i]['date_format'] = date('Y.m.d', $infoRSS->items[$i]['date_timestamp']);
         }
         $smarty->assign(array('WEBSITE' => 'http://www.elastix.org', 'NO_NEWS' => _tr('No News to display'), 'NEWS_LIST' => array_slice($infoRSS->items, 0, 7)));
         $local_templates_dir = getWebDirModule($module_name) . "/applets/News/tpl";
         $respuesta['html'] = $smarty->fetch("{$local_templates_dir}/rssfeed.tpl");
     }
     $json = new Services_JSON();
     Header('Content-Type: application/json');
     return $json->encode($respuesta);
 }
開發者ID:lordbasex,項目名稱:elastix-gui,代碼行數:23,代碼來源:index.php

示例3: strftime

                                $aso_page['date'] = strftime('%d.%m.%Y', $aso_page['datestamp']);
                                break;
                            case 'jmh':
                                $aso_page['date'] = strftime('%d.%m %H:%M', $aso_page['datestamp']);
                                break;
                            case 'jmah':
                                $aso_page['date'] = strftime('%d.%m.%Y %H:%M', $aso_page['datestamp']);
                                break;
                            default:
                                $aso_page['date'] = '';
                        }
                    }
                    $syndication['pagination'] = $pagination;
                    $syndication['pages'][$aso_page['datestamp']] = $aso_page;
                }
            } else {
                echo '<p class="alert alert-danger">' . _t('ERROR') . ' ' . magpie_error() . '</p>' . "\n";
            }
        }
    }
    // Trie des pages par date
    krsort($syndication['pages']);
    echo '<div class="feed_syndication' . ($class ? ' ' . $class : '') . '">' . "\n";
    // Gestion des squelettes
    include $template;
    echo '</div>' . "\n";
} else {
    echo '<div class="alert alert-danger"><strong>' . _t('SYNDICATION_ACTION_SYNDICATION') . '</strong> : ' . _t('SYNDICATION_PARAM_URL_REQUIRED') . '.</div>' . "\n";
}
//ajout du javascript
$this->AddJavascriptFile('tools/syndication/presentation/javascripts/syndication.js');
開發者ID:YesWiki,項目名稱:yeswiki-sandstorm,代碼行數:31,代碼來源:syndication.php

示例4: update_rss_feed_real


//.........這裏部分代碼省略.........
            assign_article_to_labels($link, $entry_ref_id, $article_filters, $owner_uid);
            if (defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug']) {
                _debug("update_rss_feed: looking for enclosures...");
            }
            if (defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug']) {
                print_r($enclosures);
            }
            db_query($link, "BEGIN");
            foreach ($enclosures as $enc) {
                $enc_url = db_escape_string($enc[0]);
                $enc_type = db_escape_string($enc[1]);
                $enc_dur = db_escape_string($enc[2]);
                $result = db_query($link, "SELECT id FROM ttrss_enclosures\n\t\t\t\t\t\tWHERE content_url = '{$enc_url}' AND post_id = '{$entry_ref_id}'");
                if (db_num_rows($result) == 0) {
                    db_query($link, "INSERT INTO ttrss_enclosures\n\t\t\t\t\t\t\t(content_url, content_type, title, duration, post_id) VALUES\n\t\t\t\t\t\t\t('{$enc_url}', '{$enc_type}', '', '{$enc_dur}', '{$entry_ref_id}')");
                }
            }
            db_query($link, "COMMIT");
            if (defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug']) {
                _debug("update_rss_feed: looking for tags...");
            }
            /* taaaags */
            // <a href="..." rel="tag">Xorg</a>, //
            $entry_tags = null;
            preg_match_all("/<a.*?rel=['\"]tag['\"].*?>([^<]+)<\\/a>/i", $entry_content_unescaped, $entry_tags);
            /*				print "<p><br/>$entry_title : $entry_content_unescaped<br>";
            				print_r($entry_tags);
            				print "<br/></p>"; */
            $entry_tags = $entry_tags[1];
            # check for manual tags
            foreach ($article_filters as $f) {
                if ($f[0] == "tag") {
                    $manual_tags = trim_array(split(",", $f[1]));
                    foreach ($manual_tags as $tag) {
                        if (tag_is_valid($tag)) {
                            array_push($entry_tags, $tag);
                        }
                    }
                }
            }
            $boring_tags = trim_array(split(",", mb_strtolower(get_pref($link, 'BLACKLISTED_TAGS', $owner_uid, ''), 'utf-8')));
            if ($additional_tags && is_array($additional_tags)) {
                foreach ($additional_tags as $tag) {
                    if (tag_is_valid($tag) && array_search($tag, $boring_tags) === FALSE) {
                        array_push($entry_tags, $tag);
                    }
                }
            }
            //				print "<p>TAGS: "; print_r($entry_tags); print "</p>";
            if (defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug']) {
                print_r($entry_tags);
            }
            if (count($entry_tags) > 0) {
                db_query($link, "BEGIN");
                foreach ($entry_tags as $tag) {
                    $tag = sanitize_tag($tag);
                    $tag = db_escape_string($tag);
                    if (!tag_is_valid($tag)) {
                        continue;
                    }
                    $result = db_query($link, "SELECT id FROM ttrss_tags\t\t\n\t\t\t\t\t\t\t\tWHERE tag_name = '{$tag}' AND post_int_id = '{$entry_int_id}' AND \n\t\t\t\t\t\t\t\towner_uid = '{$owner_uid}' LIMIT 1");
                    //						print db_fetch_result($result, 0, "id");
                    if ($result && db_num_rows($result) == 0) {
                        db_query($link, "INSERT INTO ttrss_tags \n\t\t\t\t\t\t\t\t\t(owner_uid,tag_name,post_int_id)\n\t\t\t\t\t\t\t\t\tVALUES ('{$owner_uid}','{$tag}', '{$entry_int_id}')");
                    }
                }
                db_query($link, "COMMIT");
            }
            if (defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug']) {
                _debug("update_rss_feed: article processed");
            }
        }
        if (!$last_updated) {
            if (defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug']) {
                _debug("update_rss_feed: new feed, catching it up...");
            }
            catchup_feed($link, $feed, false, $owner_uid);
        }
        purge_feed($link, $feed, 0);
        db_query($link, "UPDATE ttrss_feeds \n\t\t\t\tSET last_updated = NOW(), last_error = '' WHERE id = '{$feed}'");
        //			db_query($link, "COMMIT");
    } else {
        if ($use_simplepie) {
            $error_msg = mb_substr($rss->error(), 0, 250);
        } else {
            $error_msg = mb_substr(magpie_error(), 0, 250);
        }
        if (defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug']) {
            _debug("update_rss_feed: error fetching feed: {$error_msg}");
        }
        $error_msg = db_escape_string($error_msg);
        db_query($link, "UPDATE ttrss_feeds SET last_error = '{$error_msg}', \n\t\t\t\t\tlast_updated = NOW() WHERE id = '{$feed}'");
    }
    if ($use_simplepie) {
        unset($rss);
    }
    if (defined('DAEMON_EXTENDED_DEBUG') || $_REQUEST['xdebug']) {
        _debug("update_rss_feed: done");
    }
}
開發者ID:wangroot,項目名稱:Tiny-Tiny-RSS,代碼行數:101,代碼來源:functions.php

示例5: isset

                $title = $item['title'];
                $link = $item['link'];
                $description = $item['description'];
                $pubdate = isset($item['pubdate']) ? "|" . $item['pubdate'] . "|" : "";
                $author = isset($item['author']) ? "by " . $item['author'] : "";
                echo "<li><a href=\"{$link}\">{$title} {$author}</a> <span style=\"font-size: 7pt;\">{$pubdate}</span></li>";
            }
            $count++;
        }
        $retry = $MAX_RETRY;
    }
    $retry++;
}
if (!$rss) {
    echo "<li>Unable to fetch rss feed, try refreshing the page</li>";
    echo "<li><span style=\"font-size: 7pt;\">" . magpie_error() . "</span></li>";
}
?>
</ul>

<h2>Download</h2><a name="download"></a>
<p>To run Entagged, you need first of all to download the Java Runtime Environment (JRE) because Entagged is written in Java. This ensures a great crossplatform compatibility at the (little: approx. 10Mb) cost of these libraries.</p>
<p>You can get the <a href="http://java.sun.com/j2se/1.4.2/download.html">latest Sun JRE</a> (Entagged needs at least JRE v1.4.1 to work properly !).</p> 
<p>Select the "Download J2SE v 1.4.xxx" column and pick under "JRE" your platform's version.</p>
<p>You can then <a href="http://sourceforge.net/project/showfiles.php?group_id=88759&package_id=92893">download Entagged</a> at sourceforge file release section, make sure you are downloading the latest version !</p>
<p>Entagged is packaged in three different ways:</p>
<ul>
	<li>"entagged-install-vx.xx.exe" is the windows installer version of this package (note that it is only a .exe wrapper to lauch the jar file, no native code here)</li>
	<li>"entagged-vx.xx.zip" is the "all platform" package, it contains mainly the executable jar file, and some images files (make sure you extract this archive using the directory structure inside it)</li>
	<li>"entagged-src-vx.xx.tar.gz" wich contains the source code and the resources needed to compile and build entagged (ant file, images, NSIS script, etc). This package is NOT needed if you only want to use Entagged (this is a developper resource)</li>
</ul>
開發者ID:tokazio,項目名稱:musicfile-manager,代碼行數:31,代碼來源:index.php

示例6: foreach

if ($rss) {
    // Show first 50 items
    //      $items = array_slice($rss->items, 0, 50);
    $items = $rss->items;
    // Cycle through each item and echo
    echo '<dl>';
    foreach ($items as $item) {
        $description = $item['description'];
        $publish_date = $item['pubdate'];
        // Check to see if the first 10 characters in the description are a date... when the old
        // news items were imported, the original publish date was put at the start of the description.
        if (substr($description, 10, 1) == ' ') {
            $possible_date = substr($description, 0, 10);
            // verify date is in expected format: yyyy/mm/dd
            if (substr($possible_date, 4, 1) == '/' && substr($possible_date, 7, 1) == '/' && is_numeric(substr($possible_date, 0, 4)) && is_numeric(substr($possible_date, 5, 2)) && is_numeric(substr($possible_date, 8, 2))) {
                $description = substr($description, 11);
                $publish_date = $possible_date;
            }
        }
        $formatted_date = date("Y/m/d", strtotime($publish_date));
        echo '<p><dt><b>' . $formatted_date . '</b> - <a href="' . $item['link'] . '">' . $item['title'] . '</a>' . '</dt><dd>' . $description . '</dd></dt></p>';
    }
    echo '</dl>';
} else {
    echo '<h2>Error:</h2><p>' . magpie_error() . '</p>';
}
// Restore original error reporting value
@ini_restore('error_reporting');
?>
 
開發者ID:ptomulik,項目名稱:www,代碼行數:29,代碼來源:newsinc.php

示例7: fof_update_feed

function fof_update_feed($url)
{
    global $FOF_FEED_TABLE, $FOF_ITEM_TABLE;
    $FOF_FEED_TABLE = FOF_FEED_TABLE;
    $FOF_ITEM_TABLE = FOF_ITEM_TABLE;
    if (!$url) {
        return 0;
    }
    $rss = fetch_rss($url);
    if (!$rss) {
        print "Error: <B>" . magpie_error() . "</b> ";
        print "<a href=\"http://feeds.archive.org/validator/check?url={$url}\">try to validate it?</a> ";
        return 0;
    }
    $title = mysql_escape_string($rss->channel['title']);
    $link = $rss->channel['link'];
    $description = mysql_escape_string($rss->channel['description']);
    $safeurl = mysql_escape_string($url);
    $result = fof_do_query("select id, url from {$FOF_FEED_TABLE} where url='{$safeurl}'");
    $row = mysql_fetch_array($result);
    $feed_id = $row['id'];
    $items = $rss->items;
    foreach ($items as $item) {
        if (AMP_CONTENT_RSS_CUSTOMFORMAT == 'true') {
            $link = mysql_escape_string($item['source']);
            $contacts = mysql_escape_string($item['contacts']);
            $subtitle = mysql_escape_string($item['subtitle']);
            $custom1 = mysql_escape_string($item['media_text']);
        } else {
            $link = mysql_escape_string($item['link']);
        }
        $title = mysql_escape_string($item['title']);
        $content = mysql_escape_string($item['description']);
        if ($item['content']['encoded']) {
            $content = mysql_escape_string($item['content']['encoded']);
        }
        if ($item['atom_content']) {
            $content = mysql_escape_string($item['atom_content']);
        }
        if (isset($item['dc'])) {
            $dcdate = strtotime(mysql_escape_string($item['dc']['date']));
            $dcdate = date("Y-m-d", $dcdate);
            $dccreator = mysql_escape_string($item['dc']['creator']);
            $dcsubject = mysql_escape_string($item['dc']['subject']);
        } else {
            $pubdate = isset($item['pubdate']) ? $item['pubdate'] : (isset($item['pubDate']) ? $item['pubDate'] : false);
            if ($pubdate) {
                $dcdate = strtotime(mysql_escape_string($pubdate));
                $dcdate = date("Y-m-d", $dcdate);
            }
            $dccreator = mysql_escape_string($item['author']);
            $dcsubject = mysql_escape_string($item['category']);
        }
        if (!$link) {
            $link = $item['guid'];
        }
        if (!$title) {
            $title = "[no title]";
        }
        $result = fof_do_query("select id from {$FOF_ITEM_TABLE} where feed_id='{$feed_id}' and link='{$link}'");
        $row = mysql_fetch_array($result);
        $id = $row['id'];
        if (mysql_num_rows($result) == 0) {
            $n++;
            if (AMP_CONTENT_RSS_CUSTOMFORMAT == 'true') {
                $sql = "insert into {$FOF_ITEM_TABLE} (feed_id,link,title,content,dcdate,dccreator,dcsubject,contacts,subtitle,custom1) values ('{$feed_id}','{$link}','{$title}','{$content}','{$dcdate}','{$dccreator}','{$dcsubject}','{$contacts}','{$subtitle}','{$custom1}')";
            } else {
                $sql = "insert into {$FOF_ITEM_TABLE} (feed_id,link,title,content,dcdate,dccreator,dcsubject) values ('{$feed_id}','{$link}','{$title}','{$content}','{$dcdate}','{$dccreator}','{$dcsubject}')";
            }
            $result = fof_do_query($sql);
        } else {
            $ids[] = $id;
        }
    }
    if (defined('FOF_KEEP_DAYS')) {
        $keep_days = FOF_KEEP_DAYS;
        if (count($ids) != 0) {
            $first = 1;
            foreach ($ids as $id) {
                if ($first) {
                    $stat = "({$id}";
                    $first = 0;
                } else {
                    $stat .= ", {$id}";
                }
            }
            $stat .= ")";
            $sql = "delete from {$FOF_ITEM_TABLE} where feed_id = {$feed_id} and `read`=1 and id not in {$stat} and to_days( CURDATE(  )  )  - to_days( timestamp )  > {$keep_days}";
            fof_do_query($sql);
        }
    }
    return $n;
}
開發者ID:radicaldesigns,項目名稱:amp,代碼行數:93,代碼來源:init.php

示例8: fetch

 /**
  * Fetch the feed
  */
 function fetch()
 {
     if ($this->getUrl() != "") {
         $this->feed = @fetch_rss($this->getUrl());
     }
     if (!$this->feed) {
         $error = magpie_error();
         if ($error == "") {
             $this->setError("Unknown Error.");
         } else {
             $this->setError(magpie_error());
         }
         return false;
     }
     if (is_array($this->feed->items)) {
         foreach ($this->feed->items as $item) {
             $item_obj = new ilExternalFeedItem();
             $item_obj->setMagpieItem($item);
             $this->items[] = $item_obj;
         }
     }
 }
開發者ID:arlendotcn,項目名稱:ilias,代碼行數:25,代碼來源:class.ilExternalFeed.php

示例9: define

define('MAGPIE_DIR', '/home/kellan/projs/magpierss/');
require_once MAGPIE_DIR . 'rss_fetch.inc';
require_once MAGPIE_DIR . 'rss_utils.inc';
// optionally show lots of debugging info
# define('MAGPIE_DEBUG', 2);
// optionally flush cache quickly for debugging purposes,
// don't do this on a live site
# define('MAGPIE_CACHE_AGE', 10);
// use cache?  default is yes.  see rss_fetch for other Magpie options
# define('MAGPIE_CACHE_ON', 1)
// setup template object
$smarty = new Smarty();
$smarty->compile_check = true;
// url of an rss file
$url = htmlspecialchars($_GET['rss_url'], ENT_QUOTES);
if ($url) {
    // assign a variable to smarty for use in the template
    $smarty->assign('rss_url', $url);
    // use MagpieRSS to fetch remote RSS file, and parse it
    $rss = fetch_rss($url);
    // if fetch_rss returned false, we encountered an error
    if (!$rss) {
        $smarty->assign('error', magpie_error());
    }
    $smarty->assign('rss', $rss);
    $item = $rss->items[0];
    $date = parse_w3cdtf($item['dc']['date']);
    $smarty->assign('date', $date);
}
// parse smarty template, and display using the variables we assigned
$smarty->display('simple.smarty');
開發者ID:Tjorriemorrie,項目名稱:app,代碼行數:31,代碼來源:simple_smarty.php

示例10: smarty_feed


//.........這裏部分代碼省略.........
 * @param object $smarty
 * @return string
 */
function smarty_feed($params, $text, &$smarty)
{
    global $PIVOTX;
    $params = cleanParams($params);
    // This function gets called twice. Once when enter it, and once when
    // leaving the block. In the latter case we return an empty string.
    if (!isset($text)) {
        return "";
    }
    if (!isset($params['url'])) {
        return __("You need to specify an URL to a feed");
    }
    $amount = getDefault($params['amount'], 8);
    $dateformat = getDefault($params['dateformat'], "%dayname% %day% %monthname% %year%");
    $trimlength = getDefault($params['trimlength'], 10000);
    include_once $PIVOTX['paths']['pivotx_path'] . 'includes/magpie/rss_fetch.inc';
    // Parse it
    $rss = fetch_rss($params['url']);
    $output = "";
    if (count($rss->items) > 0) {
        // Slice it, so no more than '$amount' items will be shown.
        $rss->items = array_slice($rss->items, 0, $amount);
        foreach ($rss->items as $feeditem) {
            $item = $text;
            // If the feed has authors on an entry-level, override the author name..
            if ($author = $feeditem['author']) {
                $authorname = $feeditem['author'];
            }
            $date = formatDate(date("Y-m-d H-i-s", $feeditem['date_timestamp']), $dateformat);
            // Get the title, description and content, since we might want to do some
            // parsing on it..
            $title = $feeditem['title'];
            $description = $feeditem['description'];
            $content = getDefault($feeditem['atom_content'], $feeditem['summary']);
            // Do some parsing: stripping tags, trimming length, stuff like that.
            if (!empty($params['allowtags'])) {
                $title = stripTagsAttributes($title, $params['allowtags']);
                $description = stripTagsAttributes($description, $params['allowtags']);
                $content = stripTagsAttributes($content, $params['allowtags']);
            } else {
                $title = trimText(stripTagsAttributes($title, "<>"), $trimlength);
                $description = trimText(stripTagsAttributes($description, "<>"), $trimlength);
                $content = trimText(stripTagsAttributes($content, "<>"), $trimlength);
            }
            $item = str_replace('%title%', $title, $item);
            $item = str_replace('%link%', $feeditem['link'], $item);
            $item = str_replace('%description%', $description, $item);
            $item = str_replace('%content%', $content, $item);
            $item = str_replace('%author%', $authorname, $item);
            $item = str_replace('%date%', $date, $item);
            $item = str_replace('%id%', $feeditem['id'], $item);
            // Supporting upto two level arrays in item elements.
            foreach ($feeditem as $key => $value) {
                if (is_string($value)) {
                    if ($key == "link" || $trimlength == -1) {
                        $value = trim($value);
                    } else {
                        $value = trimText(trim($value), $trimlength);
                    }
                    $item = str_replace("%{$key}%", $value, $item);
                } else {
                    if (is_array($value)) {
                        foreach ($value as $arrkey => $arrvalue) {
                            if (is_string($arrvalue)) {
                                $arrvalue = trim($arrvalue);
                                if ($trimlength != -1) {
                                    $arrvalue = trimText($arrvalue, $trimlength);
                                }
                                $item = str_replace("%{$key}" . '->' . "{$arrkey}%", $arrvalue, $item);
                            } else {
                                if (is_array($arrvalue)) {
                                    foreach ($arrvalue as $subarrkey => $subarrvalue) {
                                        if (is_string($subarrvalue)) {
                                            $subarrvalue = trim($subarrvalue);
                                            if ($trimlength != -1) {
                                                $subarrvalue = trimText($subarrvalue, $trimlength);
                                            }
                                            $item = str_replace("%{$key}" . '->' . "{$arrkey}" . '->' . "{$subarrkey}%", $subarrvalue, $item);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            // Remove any unused formatting tags.
            $item = preg_replace("/%[^%]+%/", "", $item);
            $output .= $item;
        }
    } else {
        debug("<p>Oops! I'm afraid I couldn't read the the feed.</p>");
        echo "<p>" . __("Oops! I'm afraid I couldn't read the feed.") . "</p>";
        debug(magpie_error());
    }
    return $output;
}
開發者ID:laiello,項目名稱:pivotx-sqlite,代碼行數:101,代碼來源:module_smarty.php

示例11: update_rss_feed


//.........這裏部分代碼省略.........
                }
            }
            if ($debug_enabled) {
                _debug("update_rss_feed: article enclosures:");
                print_r($enclosures);
            }
            db_query($link, "BEGIN");
            foreach ($enclosures as $enc) {
                $enc_url = db_escape_string($enc[0]);
                $enc_type = db_escape_string($enc[1]);
                $enc_dur = db_escape_string($enc[2]);
                $result = db_query($link, "SELECT id FROM ttrss_enclosures\n\t\t\t\t\t\tWHERE content_url = '{$enc_url}' AND post_id = '{$entry_ref_id}'");
                if (db_num_rows($result) == 0) {
                    db_query($link, "INSERT INTO ttrss_enclosures\n\t\t\t\t\t\t\t(content_url, content_type, title, duration, post_id) VALUES\n\t\t\t\t\t\t\t('{$enc_url}', '{$enc_type}', '', '{$enc_dur}', '{$entry_ref_id}')");
                }
            }
            db_query($link, "COMMIT");
            // check for manual tags (we have to do it here since they're loaded from filters)
            foreach ($article_filters as $f) {
                if ($f["type"] == "tag") {
                    $manual_tags = trim_array(explode(",", $f["param"]));
                    foreach ($manual_tags as $tag) {
                        if (tag_is_valid($tag)) {
                            array_push($entry_tags, $tag);
                        }
                    }
                }
            }
            // Skip boring tags
            $boring_tags = trim_array(explode(",", mb_strtolower(get_pref($link, 'BLACKLISTED_TAGS', $owner_uid, ''), 'utf-8')));
            $filtered_tags = array();
            $tags_to_cache = array();
            if ($entry_tags && is_array($entry_tags)) {
                foreach ($entry_tags as $tag) {
                    if (array_search($tag, $boring_tags) === false) {
                        array_push($filtered_tags, $tag);
                    }
                }
            }
            $filtered_tags = array_unique($filtered_tags);
            if ($debug_enabled) {
                _debug("update_rss_feed: filtered article tags:");
                print_r($filtered_tags);
            }
            // Save article tags in the database
            if (count($filtered_tags) > 0) {
                db_query($link, "BEGIN");
                foreach ($filtered_tags as $tag) {
                    $tag = sanitize_tag($tag);
                    $tag = db_escape_string($tag);
                    if (!tag_is_valid($tag)) {
                        continue;
                    }
                    $result = db_query($link, "SELECT id FROM ttrss_tags\n\t\t\t\t\t\t\tWHERE tag_name = '{$tag}' AND post_int_id = '{$entry_int_id}' AND\n\t\t\t\t\t\t\towner_uid = '{$owner_uid}' LIMIT 1");
                    if ($result && db_num_rows($result) == 0) {
                        db_query($link, "INSERT INTO ttrss_tags\n\t\t\t\t\t\t\t\t\t(owner_uid,tag_name,post_int_id)\n\t\t\t\t\t\t\t\t\tVALUES ('{$owner_uid}','{$tag}', '{$entry_int_id}')");
                    }
                    array_push($tags_to_cache, $tag);
                }
                /* update the cache */
                $tags_to_cache = array_unique($tags_to_cache);
                $tags_str = db_escape_string(join(",", $tags_to_cache));
                db_query($link, "UPDATE ttrss_user_entries\n\t\t\t\t\t\tSET tag_cache = '{$tags_str}' WHERE ref_id = '{$entry_ref_id}'\n\t\t\t\t\t\tAND owner_uid = {$owner_uid}");
                db_query($link, "COMMIT");
            }
            if ($debug_enabled) {
                _debug("update_rss_feed: article processed");
            }
        }
        if (!$last_updated) {
            if ($debug_enabled) {
                _debug("update_rss_feed: new feed, catching it up...");
            }
            catchup_feed($link, $feed, false, $owner_uid);
        }
        if ($debug_enabled) {
            _debug("purging feed...");
        }
        purge_feed($link, $feed, 0, $debug_enabled);
        db_query($link, "UPDATE ttrss_feeds\n\t\t\t\tSET last_updated = NOW(), last_error = '' WHERE id = '{$feed}'");
        //			db_query($link, "COMMIT");
    } else {
        if ($use_simplepie) {
            $error_msg = mb_substr($rss->error(), 0, 250);
        } else {
            $error_msg = mb_substr(magpie_error(), 0, 250);
        }
        if ($debug_enabled) {
            _debug("update_rss_feed: error fetching feed: {$error_msg}");
        }
        $error_msg = db_escape_string($error_msg);
        db_query($link, "UPDATE ttrss_feeds SET last_error = '{$error_msg}',\n\t\t\t\t\tlast_updated = NOW() WHERE id = '{$feed}'");
    }
    if ($use_simplepie) {
        unset($rss);
    }
    if ($debug_enabled) {
        _debug("update_rss_feed: done");
    }
}
開發者ID:nvdnkpr,項目名稱:Tiny-Tiny-RSS,代碼行數:101,代碼來源:rssfuncs.php

示例12: getDataApplet_News

    function getDataApplet_News()
    {
        define('MAGPIE_CACHE_DIR', '/tmp/rss-cache');
        $infoRSS = @fetch_rss($this->arrConf['dir_RSS']);
        $sMensaje = magpie_error();
        if (preg_match("/HTTP Error: connection failed/", $sMensaje)) {
            return _tr('Could not get web server information. You may not have internet access or the web server is down');
        }
        $sContentList = '<div class="neo-applet-news-row">' . _tr('No News to display') . '</div>';
        if (!empty($infoRSS) && is_array($infoRSS->items) && count($infoRSS->items) > 0) {
            $sContentList = '';
            $sPlantilla = <<<PLANTILLA_RSS_ROW
<div class="neo-applet-news-row">
    <span class="neo-applet-news-row-date">%s</span>
    <a href="https://twitter.com/share?original_referer=%s&related=&source=tweetbutton&text=%s&url=%s&via=elastixGui"  target="_blank">
        <img src="modules/dashboard/images/twitter-icon.png" width="16" height="16" alt="tweet" />
    </a>
    <a href="%s" target="_blank">%s</a>
</div>
PLANTILLA_RSS_ROW;
            for ($i = 0; $i < 7 && $i < count($infoRSS->items); $i++) {
                $sContentList .= sprintf($sPlantilla, date('Y.m.d', $infoRSS->items[$i]['date_timestamp']), rawurlencode('http://www.elastix.org'), rawurlencode(utf8_encode($infoRSS->items[$i]['title'])), rawurlencode($infoRSS->items[$i]['link']), $infoRSS->items[$i]['link'], htmlentities($infoRSS->items[$i]['title'], ENT_COMPAT));
            }
        }
        return $sContentList;
    }
開發者ID:hardikk,項目名稱:HNH,代碼行數:26,代碼來源:paloSantoDataApplets.class.php

示例13: _getTagFeedHelper

 protected static function _getTagFeedHelper($feedurl, $feedname, $tag)
 {
     global $PIVOTX;
     $amount = getDefault($PIVOTX['config']->get('tag_fetcher_amount'), 8);
     include_once $PIVOTX['paths']['pivotx_path'] . 'includes/magpie/rss_fetch.inc';
     $rss = fetch_rss($feedurl);
     $output = "";
     if (count($rss->items) > 0) {
         // Slice it, so no more than '$amount' items will be shown.
         $rss->items = array_slice($rss->items, 0, $amount);
         foreach ($rss->items as $item) {
             $output .= sprintf("\n<li><a href='%s'>%s</a><br /><small>%s</small></li> \n", $item['link'], $item['title'], trimText($item['summary'], 200), $readon);
         }
     } else {
         debug("<p>Oops! I'm afraid I couldn't read the Tag feed.</p>");
         echo "<p>" . __("Oops! I'm afraid I couldn't read Tag feed.") . "</p>";
         debug(magpie_error());
     }
     $output = @html_entity_decode($output, ENT_COMPAT, 'UTF-8');
     if ($output == '') {
         $output = sprintf(__('Nothing on <strong>%s</strong> for <strong>%s</strong>'), $feedname, $tag);
     } else {
         $output = sprintf(__('Latest on <strong>%s</strong> for <strong>%s</strong>'), $feedname, $tag) . ':<ul class="taggeratilist">' . $output . '</ul>';
     }
     echo $output;
 }
開發者ID:laiello,項目名稱:pivotx-sqlite,代碼行數:26,代碼來源:ajaxhelper.php

示例14: update

function update($id)
{
    $kses_allowed = getConfig('rss.input.allowed');
    //getAllowedTags();
    $updatedIds = array();
    $sql = "select id, url, title, mode from " . getTable("channels");
    if ($id != "" && is_numeric($id)) {
        $sql .= " where id={$id}";
        $sql .= " and not(mode & " . RSS_MODE_DELETED_STATE . ") ";
    } else {
        $sql .= " where not(mode & " . RSS_MODE_DELETED_STATE . ") ";
    }
    if (getConfig('rss.config.absoluteordering')) {
        $sql .= " order by parent, position";
    } else {
        $sql .= " order by parent, title";
    }
    $res = rss_query($sql);
    while (list($cid, $url, $title, $mode) = rss_fetch_row($res)) {
        // suppress warnings because Magpie is rather noisy
        $old_level = error_reporting(E_ERROR);
        $rss = fetch_rss($url);
        //reset
        error_reporting($old_level);
        if (!$rss && $id != "" && is_numeric($id)) {
            return array(magpie_error(), array());
        } elseif (!$rss || !($rss->rss_origin & MAGPIE_FEED_ORIGIN_HTTP_200)) {
            continue;
            // no need to do anything if we do not get a 200 OK from the feed
        }
        // base URL for items in this feed.
        if (array_key_exists('link', $rss->channel)) {
            $baseUrl = $rss->channel['link'];
        } else {
            $baseUrl = $url;
            // The feed is invalid
        }
        // Keep track of guids we've handled, because some feeds (hello,
        // Technorati!) have this insane habit of serving the same item
        // twice in the same feed.
        $guids = array();
        // Allow updates in this feed?
        $allowUpdates = getProperty($cid, 'rss.input.allowupdates');
        if ($allowUpdates === null) {
            $allowUpdates = getConfig('rss.input.allowupdates');
        }
        $itemIdsInFeed = array();
        // This variable will store the item id's of the elements in the feed
        foreach ($rss->items as $item) {
            $item = rss_plugin_hook('rss.plugins.rssitem', $item);
            // a plugin might delete this item
            if (!isset($item)) {
                continue;
            }
            // item title: strip out html tags
            $title = array_key_exists('title', $item) ? strip_tags($item['title']) : "";
            //$title = str_replace('& ', '&amp; ', $title);
            $description = "";
            // item content, if any
            if (array_key_exists('content', $item) && is_array($item['content']) && array_key_exists('encoded', $item['content'])) {
                $description = $item['content']['encoded'];
            } elseif (array_key_exists('description', $item)) {
                $description = $item['description'];
            } elseif (array_key_exists('atom_content', $item)) {
                $description = $item['atom_content'];
            } elseif (array_key_exists('summary', $item)) {
                $description = $item['summary'];
            } else {
                $description = "";
            }
            $md5sum = "";
            $guid = "";
            if (array_key_exists('guid', $item) && $item['guid'] != "") {
                $guid = $item['guid'];
            } elseif (array_key_exists('id', $item) && $item['id'] != "") {
                $guid = $item['id'];
            }
            $guid = trim($guid);
            $guid = rss_real_escape_string($guid);
            // skip this one if it's an  in-feed-dupe
            if ($guid && isset($guids[$guid])) {
                continue;
            } elseif ($guid) {
                $guids[$guid] = true;
            }
            if ($description != "") {
                $md5sum = md5($description);
                $description = kses($description, $kses_allowed);
                // strip out tags
                if ($baseUrl != "") {
                    $description = relative_to_absolute($description, $baseUrl);
                }
            }
            // Now let plugins modify the description
            $description = rss_plugin_hook('rss.plugins.import.description', $description);
            // link
            if (array_key_exists('link', $item) && $item['link'] != "") {
                $url = $item['link'];
            } elseif (array_key_exists('guid', $item) && $item['guid'] != "") {
                $url = $item['guid'];
//.........這裏部分代碼省略.........
開發者ID:abdallahchamas,項目名稱:haiti_tracker,代碼行數:101,代碼來源:util.php

示例15: test_library_support

    $url = 'http://magpierss.sf.net/test.rss';
}
test_library_support();
$rss = fetch_rss($url);
if ($rss) {
    echo "<h3>Example Output</h3>";
    echo "Channel: " . $rss->channel['title'] . "<p>";
    echo "<ul>";
    foreach ($rss->items as $item) {
        $href = $item['link'];
        $title = $item['title'];
        echo "<li><a href={$href}>{$title}</a></li>";
    }
    echo "</ul>";
} else {
    echo "Error: " . magpie_error();
}
?>
<form>
	RSS URL: <input type="text" size="30" name="url" value="<?php 
echo $url;
?>
"><br />
	<input type="submit" value="Parse RSS">
</form>

<h3>Parsed Results (var_dump'ed)</h3>
<pre>
<?php 
var_dump($rss);
?>
開發者ID:kxopa,項目名稱:WebSite-PHP,代碼行數:31,代碼來源:magpie_debug.php


注:本文中的magpie_error函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。